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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as checks from "./checks.js";
|
|
2
2
|
import * as core from "./core.js";
|
|
3
3
|
import { Doc } from "./doc.js";
|
|
4
|
-
import { parse, parseAsync
|
|
4
|
+
import { parse, parseAsync } from "./parse.js";
|
|
5
5
|
import * as regexes from "./regexes.js";
|
|
6
6
|
import * as util from "./util.js";
|
|
7
7
|
import { version } from "./versions.js";
|
|
@@ -11,19 +11,20 @@ export const $ZodType = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def)
|
|
|
11
11
|
inst._zod.def = def; // set _def property
|
|
12
12
|
inst._zod.bag = inst._zod.bag || {}; // initialize _bag object
|
|
13
13
|
inst._zod.version = version;
|
|
14
|
-
const
|
|
14
|
+
const defChecks = inst._zod.def.checks;
|
|
15
15
|
// if inst is itself a checks.$ZodCheck, run it as a check
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
const checks = inst._zod.traits.has("$ZodCheck")
|
|
17
|
+
? [inst, ...(defChecks ?? [])]
|
|
18
|
+
: defChecks?.length
|
|
19
|
+
? [...defChecks]
|
|
20
|
+
: [];
|
|
19
21
|
for (const ch of checks) {
|
|
20
22
|
for (const fn of ch._zod.onattach) {
|
|
21
23
|
fn(inst);
|
|
22
24
|
}
|
|
23
25
|
}
|
|
24
26
|
if (checks.length === 0) {
|
|
25
|
-
// deferred initializer
|
|
26
|
-
// inst._zod.parse is not yet defined
|
|
27
|
+
// deferred initializer inst._zod.parse is not yet defined
|
|
27
28
|
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
28
29
|
inst._zod.deferred?.push(() => {
|
|
29
30
|
inst._zod.run = inst._zod.parse;
|
|
@@ -31,10 +32,14 @@ export const $ZodType = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def)
|
|
|
31
32
|
}
|
|
32
33
|
else {
|
|
33
34
|
const runChecks = (payload, checks, ctx) => {
|
|
35
|
+
if (payload.memo)
|
|
36
|
+
return payload;
|
|
34
37
|
let isAborted = util.aborted(payload);
|
|
35
38
|
let asyncResult;
|
|
36
39
|
for (const ch of checks) {
|
|
37
40
|
if (ch._zod.def.when) {
|
|
41
|
+
if (util.explicitlyAborted(payload))
|
|
42
|
+
continue;
|
|
38
43
|
const shouldRun = ch._zod.def.when(payload);
|
|
39
44
|
if (!shouldRun)
|
|
40
45
|
continue;
|
|
@@ -53,6 +58,7 @@ export const $ZodType = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def)
|
|
|
53
58
|
const nextLen = payload.issues.length;
|
|
54
59
|
if (nextLen === currLen)
|
|
55
60
|
return;
|
|
61
|
+
util.attachSchema(payload.issues, currLen, inst);
|
|
56
62
|
if (!isAborted)
|
|
57
63
|
isAborted = util.aborted(payload, currLen);
|
|
58
64
|
});
|
|
@@ -61,6 +67,7 @@ export const $ZodType = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def)
|
|
|
61
67
|
const nextLen = payload.issues.length;
|
|
62
68
|
if (nextLen === currLen)
|
|
63
69
|
continue;
|
|
70
|
+
util.attachSchema(payload.issues, currLen, inst);
|
|
64
71
|
if (!isAborted)
|
|
65
72
|
isAborted = util.aborted(payload, currLen);
|
|
66
73
|
}
|
|
@@ -92,8 +99,7 @@ export const $ZodType = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def)
|
|
|
92
99
|
return inst._zod.parse(payload, ctx);
|
|
93
100
|
}
|
|
94
101
|
if (ctx.direction === "backward") {
|
|
95
|
-
// run canary
|
|
96
|
-
// initial pass (no checks)
|
|
102
|
+
// run canary initial pass (no checks)
|
|
97
103
|
const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
|
|
98
104
|
if (canary instanceof Promise) {
|
|
99
105
|
return canary.then((canary) => {
|
|
@@ -112,25 +118,44 @@ export const $ZodType = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def)
|
|
|
112
118
|
return runChecks(result, checks, ctx);
|
|
113
119
|
};
|
|
114
120
|
}
|
|
115
|
-
|
|
116
|
-
|
|
121
|
+
}, {
|
|
122
|
+
// Wrappers extend this by installing a richer factory over it; reading it eagerly would defeat the laziness.
|
|
123
|
+
get "~standard"() {
|
|
124
|
+
return util.hide(this, "~standard", standardProps(this));
|
|
125
|
+
},
|
|
126
|
+
set "~standard"(value) {
|
|
127
|
+
util.own(this, "~standard", value);
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
/** The Standard Schema surface for `inst`. Shared so wrappers can extend it without forcing it. */
|
|
131
|
+
// 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
|
|
132
|
+
const toStandardResult = (r, ctx) => r.issues.length ? { issues: r.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())) } : { value: r.value };
|
|
133
|
+
async function validateAsync(inst, value) {
|
|
134
|
+
const ctx = { async: true };
|
|
135
|
+
return toStandardResult((await inst._zod.run({ value, issues: [] }, ctx)), ctx);
|
|
136
|
+
}
|
|
137
|
+
export function standardProps(inst) {
|
|
138
|
+
return {
|
|
117
139
|
validate: (value) => {
|
|
140
|
+
const ctx = { async: false };
|
|
118
141
|
try {
|
|
119
|
-
const r =
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
catch (_) {
|
|
123
|
-
return safeParseAsync(inst, value).then((r) => (r.success ? { value: r.data } : { issues: r.error?.issues }));
|
|
142
|
+
const r = inst._zod.run({ value, issues: [] }, ctx);
|
|
143
|
+
if (!(r instanceof Promise))
|
|
144
|
+
return toStandardResult(r, ctx);
|
|
124
145
|
}
|
|
146
|
+
catch (_) { }
|
|
147
|
+
// async function so a synchronously throwing check rejects instead of escaping validate
|
|
148
|
+
return validateAsync(inst, value);
|
|
125
149
|
},
|
|
126
150
|
vendor: "zod",
|
|
127
151
|
version: 1,
|
|
128
|
-
}
|
|
129
|
-
}
|
|
152
|
+
};
|
|
153
|
+
}
|
|
130
154
|
export { clone } from "./util.js";
|
|
131
155
|
export const $ZodString = /*@__PURE__*/ core.$constructor("$ZodString", (inst, def) => {
|
|
132
156
|
$ZodType.init(inst, def);
|
|
133
|
-
|
|
157
|
+
// a format's own pattern, else unbounded; a template literal derives the check-aware form itself
|
|
158
|
+
inst._zod.pattern = def.pattern ?? regexes.anyString;
|
|
134
159
|
inst._zod.parse = (payload, _) => {
|
|
135
160
|
if (def.coerce)
|
|
136
161
|
try {
|
|
@@ -182,51 +207,115 @@ export const $ZodEmail = /*@__PURE__*/ core.$constructor("$ZodEmail", (inst, def
|
|
|
182
207
|
def.pattern ?? (def.pattern = regexes.email);
|
|
183
208
|
$ZodStringFormat.init(inst, def);
|
|
184
209
|
});
|
|
210
|
+
/** The `://` guard rejected the input before the URL constructor saw it. */
|
|
211
|
+
export const URL_BAD_FORMAT = 1;
|
|
212
|
+
/** The URL parser rejected the input. */
|
|
213
|
+
export const URL_UNPARSEABLE = 2;
|
|
214
|
+
export function canParseURL(input) {
|
|
215
|
+
try {
|
|
216
|
+
if (typeof URL !== "undefined" && typeof URL.canParse === "function")
|
|
217
|
+
return URL.canParse(input);
|
|
218
|
+
new URL(input);
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
221
|
+
catch {
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
export function validateURL(trimmed, def) {
|
|
226
|
+
if (!("normalize" in def) && !("hostname" in def) && !("protocol" in def)) {
|
|
227
|
+
return canParseURL(trimmed) || URL_UNPARSEABLE;
|
|
228
|
+
}
|
|
229
|
+
return parseURLObject(trimmed, def);
|
|
230
|
+
}
|
|
231
|
+
/** Parses a URL while preserving the non-normalizing HTTP guard. */
|
|
232
|
+
export function parseURLObject(trimmed, def) {
|
|
233
|
+
// When normalize is off, require :// for http/https URLs. This prevents strings like "http:example.com" or "https:/path" from being silently accepted
|
|
234
|
+
if (!def.normalize && def.protocol?.source === regexes.httpProtocol.source && !/^https?:\/\//i.test(trimmed)) {
|
|
235
|
+
return URL_BAD_FORMAT;
|
|
236
|
+
}
|
|
237
|
+
try {
|
|
238
|
+
if (typeof URL !== "undefined") {
|
|
239
|
+
const URLStatic = URL;
|
|
240
|
+
if (typeof URLStatic.parse === "function")
|
|
241
|
+
return URLStatic.parse(trimmed) ?? URL_UNPARSEABLE;
|
|
242
|
+
}
|
|
243
|
+
// @ts-ignore
|
|
244
|
+
return new URL(trimmed);
|
|
245
|
+
}
|
|
246
|
+
catch {
|
|
247
|
+
return URL_UNPARSEABLE;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
const asciiTabOrNewline = /[\t\n\r]/g;
|
|
251
|
+
/** 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. */
|
|
252
|
+
export function stripTabAndNewline(value) {
|
|
253
|
+
return value.replace(asciiTabOrNewline, "");
|
|
254
|
+
}
|
|
255
|
+
export function urlHostnameOk(url, hostname) {
|
|
256
|
+
hostname.lastIndex = 0;
|
|
257
|
+
return hostname.test(url.hostname);
|
|
258
|
+
}
|
|
259
|
+
export function urlProtocolOk(url, protocol) {
|
|
260
|
+
protocol.lastIndex = 0;
|
|
261
|
+
return protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol);
|
|
262
|
+
}
|
|
185
263
|
export const $ZodURL = /*@__PURE__*/ core.$constructor("$ZodURL", (inst, def) => {
|
|
186
264
|
$ZodStringFormat.init(inst, def);
|
|
187
265
|
inst._zod.check = (payload) => {
|
|
188
266
|
try {
|
|
189
267
|
// Trim whitespace from input
|
|
190
268
|
const trimmed = payload.value.trim();
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
inst,
|
|
203
|
-
continue: !def.abort,
|
|
204
|
-
});
|
|
205
|
-
}
|
|
269
|
+
const url = validateURL(trimmed, def);
|
|
270
|
+
if (url === URL_BAD_FORMAT) {
|
|
271
|
+
payload.issues.push({
|
|
272
|
+
code: "invalid_format",
|
|
273
|
+
format: "url",
|
|
274
|
+
note: "Invalid URL format",
|
|
275
|
+
input: payload.value,
|
|
276
|
+
inst,
|
|
277
|
+
continue: !def.abort,
|
|
278
|
+
});
|
|
279
|
+
return;
|
|
206
280
|
}
|
|
207
|
-
if (
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
inst,
|
|
217
|
-
continue: !def.abort,
|
|
218
|
-
});
|
|
219
|
-
}
|
|
281
|
+
if (url === URL_UNPARSEABLE) {
|
|
282
|
+
payload.issues.push({
|
|
283
|
+
code: "invalid_format",
|
|
284
|
+
format: "url",
|
|
285
|
+
input: payload.value,
|
|
286
|
+
inst,
|
|
287
|
+
continue: !def.abort,
|
|
288
|
+
});
|
|
289
|
+
return;
|
|
220
290
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
payload.value = url.href;
|
|
291
|
+
if (url === true) {
|
|
292
|
+
payload.value = stripTabAndNewline(trimmed);
|
|
293
|
+
return;
|
|
225
294
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
295
|
+
if (def.hostname && !urlHostnameOk(url, def.hostname)) {
|
|
296
|
+
payload.issues.push({
|
|
297
|
+
code: "invalid_format",
|
|
298
|
+
format: "url",
|
|
299
|
+
note: "Invalid hostname",
|
|
300
|
+
pattern: def.hostname.source,
|
|
301
|
+
input: payload.value,
|
|
302
|
+
inst,
|
|
303
|
+
continue: !def.abort,
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
if (def.protocol && !urlProtocolOk(url, def.protocol)) {
|
|
307
|
+
payload.issues.push({
|
|
308
|
+
code: "invalid_format",
|
|
309
|
+
format: "url",
|
|
310
|
+
note: "Invalid protocol",
|
|
311
|
+
pattern: def.protocol.source,
|
|
312
|
+
input: payload.value,
|
|
313
|
+
inst,
|
|
314
|
+
continue: !def.abort,
|
|
315
|
+
});
|
|
229
316
|
}
|
|
317
|
+
// Set the output value based on normalize flag
|
|
318
|
+
payload.value = def.normalize ? url.href : stripTabAndNewline(trimmed);
|
|
230
319
|
return;
|
|
231
320
|
}
|
|
232
321
|
catch (_) {
|
|
@@ -245,9 +334,16 @@ export const $ZodEmoji = /*@__PURE__*/ core.$constructor("$ZodEmoji", (inst, def
|
|
|
245
334
|
$ZodStringFormat.init(inst, def);
|
|
246
335
|
});
|
|
247
336
|
export const $ZodNanoID = /*@__PURE__*/ core.$constructor("$ZodNanoID", (inst, def) => {
|
|
248
|
-
def.
|
|
337
|
+
if (def.length !== undefined && (!Number.isInteger(def.length) || def.length < 1))
|
|
338
|
+
throw new Error(`Invalid nanoid length: ${def.length}`);
|
|
339
|
+
def.pattern ?? (def.pattern = def.length === undefined ? regexes.nanoid : regexes.nanoidOfLength(def.length));
|
|
249
340
|
$ZodStringFormat.init(inst, def);
|
|
250
341
|
});
|
|
342
|
+
/**
|
|
343
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
344
|
+
* (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
|
|
345
|
+
* See https://github.com/paralleldrive/cuid.
|
|
346
|
+
*/
|
|
251
347
|
export const $ZodCUID = /*@__PURE__*/ core.$constructor("$ZodCUID", (inst, def) => {
|
|
252
348
|
def.pattern ?? (def.pattern = regexes.cuid);
|
|
253
349
|
$ZodStringFormat.init(inst, def);
|
|
@@ -287,19 +383,19 @@ export const $ZodISODuration = /*@__PURE__*/ core.$constructor("$ZodISODuration"
|
|
|
287
383
|
export const $ZodIPv4 = /*@__PURE__*/ core.$constructor("$ZodIPv4", (inst, def) => {
|
|
288
384
|
def.pattern ?? (def.pattern = regexes.ipv4);
|
|
289
385
|
$ZodStringFormat.init(inst, def);
|
|
290
|
-
inst._zod.bag.format = `ipv4`;
|
|
291
386
|
});
|
|
387
|
+
/** 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`. */
|
|
388
|
+
const ipv6Alphabet = /^[0-9a-fA-F:.]+$/;
|
|
389
|
+
export function isValidIPv6(value) {
|
|
390
|
+
if (!ipv6Alphabet.test(value))
|
|
391
|
+
return false;
|
|
392
|
+
return canParseURL(`http://[${value}]`);
|
|
393
|
+
}
|
|
292
394
|
export const $ZodIPv6 = /*@__PURE__*/ core.$constructor("$ZodIPv6", (inst, def) => {
|
|
293
395
|
def.pattern ?? (def.pattern = regexes.ipv6);
|
|
294
396
|
$ZodStringFormat.init(inst, def);
|
|
295
|
-
inst._zod.bag.format = `ipv6`;
|
|
296
397
|
inst._zod.check = (payload) => {
|
|
297
|
-
|
|
298
|
-
// @ts-ignore
|
|
299
|
-
new URL(`http://[${payload.value}]`);
|
|
300
|
-
// return;
|
|
301
|
-
}
|
|
302
|
-
catch {
|
|
398
|
+
if (!isValidIPv6(payload.value)) {
|
|
303
399
|
payload.issues.push({
|
|
304
400
|
code: "invalid_format",
|
|
305
401
|
format: "ipv6",
|
|
@@ -313,32 +409,30 @@ export const $ZodIPv6 = /*@__PURE__*/ core.$constructor("$ZodIPv6", (inst, def)
|
|
|
313
409
|
export const $ZodMAC = /*@__PURE__*/ core.$constructor("$ZodMAC", (inst, def) => {
|
|
314
410
|
def.pattern ?? (def.pattern = regexes.mac(def.delimiter));
|
|
315
411
|
$ZodStringFormat.init(inst, def);
|
|
316
|
-
inst._zod.bag.format = `mac`;
|
|
317
412
|
});
|
|
318
413
|
export const $ZodCIDRv4 = /*@__PURE__*/ core.$constructor("$ZodCIDRv4", (inst, def) => {
|
|
319
414
|
def.pattern ?? (def.pattern = regexes.cidrv4);
|
|
320
415
|
$ZodStringFormat.init(inst, def);
|
|
321
416
|
});
|
|
417
|
+
export function isValidCIDRv6(value) {
|
|
418
|
+
const parts = value.split("/");
|
|
419
|
+
if (parts.length !== 2)
|
|
420
|
+
return false;
|
|
421
|
+
const [address, prefix] = parts;
|
|
422
|
+
if (!prefix)
|
|
423
|
+
return false;
|
|
424
|
+
const prefixNum = Number(prefix);
|
|
425
|
+
if (`${prefixNum}` !== prefix)
|
|
426
|
+
return false;
|
|
427
|
+
if (prefixNum < 0 || prefixNum > 128)
|
|
428
|
+
return false;
|
|
429
|
+
return isValidIPv6(address);
|
|
430
|
+
}
|
|
322
431
|
export const $ZodCIDRv6 = /*@__PURE__*/ core.$constructor("$ZodCIDRv6", (inst, def) => {
|
|
323
432
|
def.pattern ?? (def.pattern = regexes.cidrv6); // not used for validation
|
|
324
433
|
$ZodStringFormat.init(inst, def);
|
|
325
434
|
inst._zod.check = (payload) => {
|
|
326
|
-
|
|
327
|
-
try {
|
|
328
|
-
if (parts.length !== 2)
|
|
329
|
-
throw new Error();
|
|
330
|
-
const [address, prefix] = parts;
|
|
331
|
-
if (!prefix)
|
|
332
|
-
throw new Error();
|
|
333
|
-
const prefixNum = Number(prefix);
|
|
334
|
-
if (`${prefixNum}` !== prefix)
|
|
335
|
-
throw new Error();
|
|
336
|
-
if (prefixNum < 0 || prefixNum > 128)
|
|
337
|
-
throw new Error();
|
|
338
|
-
// @ts-ignore
|
|
339
|
-
new URL(`http://[${address}]`);
|
|
340
|
-
}
|
|
341
|
-
catch {
|
|
435
|
+
if (!isValidCIDRv6(payload.value)) {
|
|
342
436
|
payload.issues.push({
|
|
343
437
|
code: "invalid_format",
|
|
344
438
|
format: "cidrv6",
|
|
@@ -353,6 +447,9 @@ export const $ZodCIDRv6 = /*@__PURE__*/ core.$constructor("$ZodCIDRv6", (inst, d
|
|
|
353
447
|
export function isValidBase64(data) {
|
|
354
448
|
if (data === "")
|
|
355
449
|
return true;
|
|
450
|
+
// atob ignores whitespace, so reject it up front.
|
|
451
|
+
if (/\s/.test(data))
|
|
452
|
+
return false;
|
|
356
453
|
if (data.length % 4 !== 0)
|
|
357
454
|
return false;
|
|
358
455
|
try {
|
|
@@ -364,10 +461,11 @@ export function isValidBase64(data) {
|
|
|
364
461
|
return false;
|
|
365
462
|
}
|
|
366
463
|
}
|
|
464
|
+
// 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
|
|
465
|
+
export const base64Charset = /^[0-9a-zA-Z+/]*={0,2}$/;
|
|
367
466
|
export const $ZodBase64 = /*@__PURE__*/ core.$constructor("$ZodBase64", (inst, def) => {
|
|
368
|
-
def.pattern ?? (def.pattern =
|
|
467
|
+
def.pattern ?? (def.pattern = base64Charset);
|
|
369
468
|
$ZodStringFormat.init(inst, def);
|
|
370
|
-
inst._zod.bag.contentEncoding = "base64";
|
|
371
469
|
inst._zod.check = (payload) => {
|
|
372
470
|
if (isValidBase64(payload.value))
|
|
373
471
|
return;
|
|
@@ -380,18 +478,19 @@ export const $ZodBase64 = /*@__PURE__*/ core.$constructor("$ZodBase64", (inst, d
|
|
|
380
478
|
});
|
|
381
479
|
};
|
|
382
480
|
});
|
|
383
|
-
//////////////////////////////
|
|
481
|
+
////////////////////////////// ZodBase64URL //////////////////////////////
|
|
482
|
+
// lax on purpose: the quantified regexes.base64url overflows the regex stack on multi-MB input; isValidBase64 enforces length on the padded string
|
|
483
|
+
export const base64urlCharset = /^[A-Za-z0-9_-]*$/;
|
|
384
484
|
export function isValidBase64URL(data) {
|
|
385
|
-
if (!
|
|
485
|
+
if (!base64urlCharset.test(data))
|
|
386
486
|
return false;
|
|
387
487
|
const base64 = data.replace(/[-_]/g, (c) => (c === "-" ? "+" : "/"));
|
|
388
488
|
const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, "=");
|
|
389
489
|
return isValidBase64(padded);
|
|
390
490
|
}
|
|
391
491
|
export const $ZodBase64URL = /*@__PURE__*/ core.$constructor("$ZodBase64URL", (inst, def) => {
|
|
392
|
-
def.pattern ?? (def.pattern =
|
|
492
|
+
def.pattern ?? (def.pattern = base64urlCharset);
|
|
393
493
|
$ZodStringFormat.init(inst, def);
|
|
394
|
-
inst._zod.bag.contentEncoding = "base64url";
|
|
395
494
|
inst._zod.check = (payload) => {
|
|
396
495
|
if (isValidBase64URL(payload.value))
|
|
397
496
|
return;
|
|
@@ -408,6 +507,77 @@ export const $ZodE164 = /*@__PURE__*/ core.$constructor("$ZodE164", (inst, def)
|
|
|
408
507
|
def.pattern ?? (def.pattern = regexes.e164);
|
|
409
508
|
$ZodStringFormat.init(inst, def);
|
|
410
509
|
});
|
|
510
|
+
////////////////////////////// ZodCreditCard //////////////////////////////
|
|
511
|
+
const CC_SANITIZE = /[- ]/g;
|
|
512
|
+
/** Luhn checksum on a digit-only string. Adapted from valibot (MIT). */
|
|
513
|
+
function isLuhnAlgo(digits) {
|
|
514
|
+
let length = digits.length;
|
|
515
|
+
let bit = 1;
|
|
516
|
+
let sum = 0;
|
|
517
|
+
while (length) {
|
|
518
|
+
const value = digits.charCodeAt(--length) - 48;
|
|
519
|
+
bit ^= 1;
|
|
520
|
+
sum += bit ? [0, 2, 4, 6, 8, 1, 3, 5, 7, 9][value] : value;
|
|
521
|
+
}
|
|
522
|
+
return sum % 10 === 0;
|
|
523
|
+
}
|
|
524
|
+
export function isValidCreditCard(input) {
|
|
525
|
+
if (!regexes.creditCard.test(input))
|
|
526
|
+
return false;
|
|
527
|
+
return isLuhnAlgo(input.replace(CC_SANITIZE, ""));
|
|
528
|
+
}
|
|
529
|
+
export const $ZodCreditCard = /*@__PURE__*/ core.$constructor("$ZodCreditCard", (inst, def) => {
|
|
530
|
+
// 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.
|
|
531
|
+
def.pattern ?? (def.pattern = regexes.creditCard);
|
|
532
|
+
$ZodStringFormat.init(inst, def);
|
|
533
|
+
inst._zod.check = (payload) => {
|
|
534
|
+
if (isValidCreditCard(payload.value))
|
|
535
|
+
return;
|
|
536
|
+
payload.issues.push({
|
|
537
|
+
code: "invalid_format",
|
|
538
|
+
format: "credit_card",
|
|
539
|
+
input: payload.value,
|
|
540
|
+
inst,
|
|
541
|
+
continue: !def.abort,
|
|
542
|
+
});
|
|
543
|
+
};
|
|
544
|
+
});
|
|
545
|
+
////////////////////////////// ZodIBAN //////////////////////////////
|
|
546
|
+
// iso 7064 mod 97-10 checksum without BigInt
|
|
547
|
+
function isIso7064Mod97(iban) {
|
|
548
|
+
let remainder = 0;
|
|
549
|
+
const len = iban.length;
|
|
550
|
+
for (let i = 4; i < len; i++) {
|
|
551
|
+
const code = iban.charCodeAt(i);
|
|
552
|
+
remainder = (code >= 65 ? remainder * 100 + (code - 55) : remainder * 10 + (code - 48)) % 97;
|
|
553
|
+
}
|
|
554
|
+
for (let i = 0; i < 4; i++) {
|
|
555
|
+
const code = iban.charCodeAt(i);
|
|
556
|
+
remainder = (code >= 65 ? remainder * 100 + (code - 55) : remainder * 10 + (code - 48)) % 97;
|
|
557
|
+
}
|
|
558
|
+
return remainder === 1;
|
|
559
|
+
}
|
|
560
|
+
export function isValidIBAN(input) {
|
|
561
|
+
if (!regexes.iban.test(input))
|
|
562
|
+
return false;
|
|
563
|
+
return isIso7064Mod97(input);
|
|
564
|
+
}
|
|
565
|
+
export const $ZodIBAN = /*@__PURE__*/ core.$constructor("$ZodIBAN", (inst, def) => {
|
|
566
|
+
// shape only — checksum is not expressible as a pattern
|
|
567
|
+
def.pattern ?? (def.pattern = regexes.iban);
|
|
568
|
+
$ZodStringFormat.init(inst, def);
|
|
569
|
+
inst._zod.check = (payload) => {
|
|
570
|
+
if (isValidIBAN(payload.value))
|
|
571
|
+
return;
|
|
572
|
+
payload.issues.push({
|
|
573
|
+
code: "invalid_format",
|
|
574
|
+
format: "iban",
|
|
575
|
+
input: payload.value,
|
|
576
|
+
inst,
|
|
577
|
+
continue: !def.abort,
|
|
578
|
+
});
|
|
579
|
+
};
|
|
580
|
+
});
|
|
411
581
|
////////////////////////////// ZodJWT //////////////////////////////
|
|
412
582
|
export function isValidJWT(token, algorithm = null) {
|
|
413
583
|
try {
|
|
@@ -461,7 +631,7 @@ export const $ZodCustomStringFormat = /*@__PURE__*/ core.$constructor("$ZodCusto
|
|
|
461
631
|
});
|
|
462
632
|
export const $ZodNumber = /*@__PURE__*/ core.$constructor("$ZodNumber", (inst, def) => {
|
|
463
633
|
$ZodType.init(inst, def);
|
|
464
|
-
inst._zod.pattern =
|
|
634
|
+
inst._zod.pattern = regexes.number;
|
|
465
635
|
inst._zod.parse = (payload, _ctx) => {
|
|
466
636
|
if (def.coerce)
|
|
467
637
|
try {
|
|
@@ -476,7 +646,7 @@ export const $ZodNumber = /*@__PURE__*/ core.$constructor("$ZodNumber", (inst, d
|
|
|
476
646
|
? Number.isNaN(input)
|
|
477
647
|
? "NaN"
|
|
478
648
|
: !Number.isFinite(input)
|
|
479
|
-
?
|
|
649
|
+
? String(input)
|
|
480
650
|
: undefined
|
|
481
651
|
: undefined;
|
|
482
652
|
payload.issues.push({
|
|
@@ -557,8 +727,6 @@ export const $ZodUndefined = /*@__PURE__*/ core.$constructor("$ZodUndefined", (i
|
|
|
557
727
|
$ZodType.init(inst, def);
|
|
558
728
|
inst._zod.pattern = regexes.undefined;
|
|
559
729
|
inst._zod.values = new Set([undefined]);
|
|
560
|
-
inst._zod.optin = "optional";
|
|
561
|
-
inst._zod.optout = "optional";
|
|
562
730
|
inst._zod.parse = (payload, _ctx) => {
|
|
563
731
|
const input = payload.value;
|
|
564
732
|
if (typeof input === "undefined")
|
|
@@ -648,6 +816,33 @@ export const $ZodDate = /*@__PURE__*/ core.$constructor("$ZodDate", (inst, def)
|
|
|
648
816
|
return payload;
|
|
649
817
|
};
|
|
650
818
|
});
|
|
819
|
+
// an oversized container fails its leading size checks before any element is parsed
|
|
820
|
+
function capSize(inst, size) {
|
|
821
|
+
const caps = util.sizeCaps(inst._zod.def.checks);
|
|
822
|
+
if (!caps.length)
|
|
823
|
+
return;
|
|
824
|
+
const cap = Math.min(...caps.map((c) => c[0]));
|
|
825
|
+
const parse = inst._zod.parse;
|
|
826
|
+
inst._zod.parse = (payload, ctx) => {
|
|
827
|
+
const n = size(payload.value);
|
|
828
|
+
if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
|
|
829
|
+
for (const [max, ch] of util.sizeCaps(inst._zod.def.checks)) {
|
|
830
|
+
if (n > max && ch._zod.def.when(payload)) {
|
|
831
|
+
const start = payload.issues.length;
|
|
832
|
+
ch._zod.check(payload);
|
|
833
|
+
// the value is still the raw input, so no later check may read it
|
|
834
|
+
payload.issues[start].continue = false;
|
|
835
|
+
util.attachSchema(payload.issues, start, inst);
|
|
836
|
+
return payload;
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
return parse(payload, ctx);
|
|
841
|
+
};
|
|
842
|
+
}
|
|
843
|
+
const arraySize = (input) => (Array.isArray(input) ? input.length : -1);
|
|
844
|
+
const mapSize = (input) => (input instanceof Map ? input.size : -1);
|
|
845
|
+
const setSize = (input) => (input instanceof Set ? input.size : -1);
|
|
651
846
|
function handleArrayResult(result, final, index) {
|
|
652
847
|
if (result.issues.length) {
|
|
653
848
|
final.issues.push(...util.prefixIssues(index, result.issues));
|
|
@@ -656,6 +851,8 @@ function handleArrayResult(result, final, index) {
|
|
|
656
851
|
}
|
|
657
852
|
export const $ZodArray = /*@__PURE__*/ core.$constructor("$ZodArray", (inst, def) => {
|
|
658
853
|
$ZodType.init(inst, def);
|
|
854
|
+
const memo = core.globalConfig.memoizer;
|
|
855
|
+
memo?.attach(inst);
|
|
659
856
|
inst._zod.parse = (payload, ctx) => {
|
|
660
857
|
const input = payload.value;
|
|
661
858
|
if (!Array.isArray(input)) {
|
|
@@ -667,8 +864,9 @@ export const $ZodArray = /*@__PURE__*/ core.$constructor("$ZodArray", (inst, def
|
|
|
667
864
|
});
|
|
668
865
|
return payload;
|
|
669
866
|
}
|
|
670
|
-
payload.value = Array(input.length);
|
|
867
|
+
payload.value = memo ? memo.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
|
|
671
868
|
const proms = [];
|
|
869
|
+
const abortEarly = ctx?.abortEarly;
|
|
672
870
|
for (let i = 0; i < input.length; i++) {
|
|
673
871
|
const item = input[i];
|
|
674
872
|
const result = def.element._zod.run({
|
|
@@ -680,6 +878,9 @@ export const $ZodArray = /*@__PURE__*/ core.$constructor("$ZodArray", (inst, def
|
|
|
680
878
|
}
|
|
681
879
|
else {
|
|
682
880
|
handleArrayResult(result, payload, i);
|
|
881
|
+
// the element's payload is authoritative here, since handleArrayResult forwards every issue; an object's is not, because it drops a failed absent optional
|
|
882
|
+
if (abortEarly && result.issues.length !== 0 && util.aborted(result))
|
|
883
|
+
break;
|
|
683
884
|
}
|
|
684
885
|
}
|
|
685
886
|
if (proms.length) {
|
|
@@ -687,17 +888,35 @@ export const $ZodArray = /*@__PURE__*/ core.$constructor("$ZodArray", (inst, def
|
|
|
687
888
|
}
|
|
688
889
|
return payload; //handleArrayResultsAsync(parseResults, final);
|
|
689
890
|
};
|
|
891
|
+
capSize(inst, arraySize);
|
|
690
892
|
});
|
|
691
|
-
function handlePropertyResult(result, final, key, input,
|
|
893
|
+
function handlePropertyResult(result, final, key, input, optin, optout) {
|
|
894
|
+
const isPresent = key in input;
|
|
895
|
+
const isOptionalOut = optout === "optional";
|
|
896
|
+
// 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.
|
|
897
|
+
if (!isPresent && isOptionalOut && optin === "optional") {
|
|
898
|
+
return;
|
|
899
|
+
}
|
|
692
900
|
if (result.issues.length) {
|
|
693
|
-
// For optional-out schemas, ignore errors on absent keys
|
|
694
|
-
if (isOptionalOut && !
|
|
901
|
+
// For optional-in/out schemas, ignore errors on absent keys.
|
|
902
|
+
if (optin !== undefined && isOptionalOut && !isPresent) {
|
|
695
903
|
return;
|
|
696
904
|
}
|
|
697
905
|
final.issues.push(...util.prefixIssues(key, result.issues));
|
|
698
906
|
}
|
|
907
|
+
if (!isPresent && optin === undefined) {
|
|
908
|
+
if (!result.issues.length) {
|
|
909
|
+
final.issues.push({
|
|
910
|
+
code: "invalid_type",
|
|
911
|
+
expected: "nonoptional",
|
|
912
|
+
input: undefined,
|
|
913
|
+
path: [key],
|
|
914
|
+
});
|
|
915
|
+
}
|
|
916
|
+
return;
|
|
917
|
+
}
|
|
699
918
|
if (result.value === undefined) {
|
|
700
|
-
if (
|
|
919
|
+
if (isPresent || (optin === "defaulted" && !isOptionalOut)) {
|
|
701
920
|
final.value[key] = undefined;
|
|
702
921
|
}
|
|
703
922
|
}
|
|
@@ -705,42 +924,64 @@ function handlePropertyResult(result, final, key, input, isOptionalOut) {
|
|
|
705
924
|
final.value[key] = result.value;
|
|
706
925
|
}
|
|
707
926
|
}
|
|
927
|
+
// one shared instance; a fresh [] per schema cost 56 bytes retained
|
|
928
|
+
const NO_SYMBOL_KEYS = [];
|
|
708
929
|
function normalizeDef(def) {
|
|
709
930
|
const keys = Object.keys(def.shape);
|
|
710
|
-
|
|
931
|
+
const ownSymbols = Object.getOwnPropertySymbols(def.shape);
|
|
932
|
+
const symbolKeys = ownSymbols.length ? ownSymbols : NO_SYMBOL_KEYS;
|
|
933
|
+
// aliases `keys` when there are no symbols, so a string-only shape keeps one array
|
|
934
|
+
const allKeys = symbolKeys.length ? [...keys, ...symbolKeys] : keys;
|
|
935
|
+
for (const k of allKeys) {
|
|
711
936
|
if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
|
|
712
|
-
throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
|
|
937
|
+
throw new Error(`Invalid element at key "${String(k)}": expected a Zod schema`);
|
|
713
938
|
}
|
|
714
939
|
}
|
|
715
940
|
const okeys = util.optionalKeys(def.shape);
|
|
716
941
|
return {
|
|
717
942
|
...def,
|
|
718
|
-
|
|
943
|
+
allKeys,
|
|
944
|
+
symbolKeys,
|
|
945
|
+
// string-only: handleCatchall matches it against `for...in`, which never yields a symbol
|
|
719
946
|
keySet: new Set(keys),
|
|
720
947
|
numKeys: keys.length,
|
|
721
948
|
optionalKeys: new Set(okeys),
|
|
722
949
|
};
|
|
723
950
|
}
|
|
724
|
-
function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
951
|
+
function handleCatchall(proms, input, payload, ctx, def, inst, abortEarly) {
|
|
725
952
|
const unrecognized = [];
|
|
726
|
-
// iterate over input keys
|
|
727
953
|
const keySet = def.keySet;
|
|
728
954
|
const _catchall = def.catchall._zod;
|
|
729
955
|
const t = _catchall.def.type;
|
|
730
|
-
const
|
|
956
|
+
const optin = _catchall.optin;
|
|
957
|
+
const optout = _catchall.optout;
|
|
958
|
+
// starts at 0, not the current length: the shape phase already ran and may have aborted
|
|
959
|
+
let seen = 0;
|
|
731
960
|
for (const key in input) {
|
|
961
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
962
|
+
if (util.aborted(payload, seen))
|
|
963
|
+
break;
|
|
964
|
+
seen = payload.issues.length;
|
|
965
|
+
}
|
|
966
|
+
// Must precede the __proto__ branch: a declared key is not unrecognized, even though the shape loop deliberately strips __proto__ from the parsed output.
|
|
732
967
|
if (keySet.has(key))
|
|
733
968
|
continue;
|
|
969
|
+
// 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.
|
|
970
|
+
if (key === "__proto__") {
|
|
971
|
+
if (t === "never")
|
|
972
|
+
unrecognized.push(key);
|
|
973
|
+
continue;
|
|
974
|
+
}
|
|
734
975
|
if (t === "never") {
|
|
735
976
|
unrecognized.push(key);
|
|
736
977
|
continue;
|
|
737
978
|
}
|
|
738
979
|
const r = _catchall.run({ value: input[key], issues: [] }, ctx);
|
|
739
980
|
if (r instanceof Promise) {
|
|
740
|
-
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input,
|
|
981
|
+
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
|
|
741
982
|
}
|
|
742
983
|
else {
|
|
743
|
-
handlePropertyResult(r, payload, key, input,
|
|
984
|
+
handlePropertyResult(r, payload, key, input, optin, optout);
|
|
744
985
|
}
|
|
745
986
|
}
|
|
746
987
|
if (unrecognized.length) {
|
|
@@ -749,6 +990,8 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
749
990
|
keys: unrecognized,
|
|
750
991
|
input,
|
|
751
992
|
inst,
|
|
993
|
+
// 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.
|
|
994
|
+
continue: true,
|
|
752
995
|
});
|
|
753
996
|
}
|
|
754
997
|
if (!proms.length)
|
|
@@ -760,30 +1003,35 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
760
1003
|
export const $ZodObject = /*@__PURE__*/ core.$constructor("$ZodObject", (inst, def) => {
|
|
761
1004
|
// requires cast because technically $ZodObject doesn't extend
|
|
762
1005
|
$ZodType.init(inst, def);
|
|
763
|
-
// const sh = def.shape;
|
|
764
1006
|
const desc = Object.getOwnPropertyDescriptor(def, "shape");
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
1007
|
+
// 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
|
|
1008
|
+
const sh = desc?.get ? desc.get.raw : (def.shape ?? {});
|
|
1009
|
+
if (sh) {
|
|
1010
|
+
// Freezes the shape on first read, so its getters resolve once and every later read sees the same schemas.
|
|
1011
|
+
const get = () => {
|
|
1012
|
+
const newSh = { ...sh };
|
|
1013
|
+
Object.defineProperty(def, "shape", { value: newSh });
|
|
1014
|
+
get.raw = newSh;
|
|
1015
|
+
return newSh;
|
|
1016
|
+
};
|
|
1017
|
+
get.raw = sh;
|
|
1018
|
+
Object.defineProperty(def, "shape", { get });
|
|
776
1019
|
}
|
|
777
1020
|
const _normalized = util.cached(() => normalizeDef(def));
|
|
778
|
-
util.
|
|
779
|
-
const shape = def.shape;
|
|
1021
|
+
util.defineLazyInternal(inst, "propValues", (zod) => {
|
|
1022
|
+
const shape = zod.def.shape;
|
|
780
1023
|
const propValues = {};
|
|
781
1024
|
for (const key in shape) {
|
|
782
1025
|
const field = shape[key]._zod;
|
|
783
1026
|
if (field.values) {
|
|
784
|
-
|
|
1027
|
+
if (!Object.prototype.hasOwnProperty.call(propValues, key)) {
|
|
1028
|
+
util.assignProp(propValues, key, new Set());
|
|
1029
|
+
}
|
|
785
1030
|
for (const v of field.values)
|
|
786
1031
|
propValues[key].add(v);
|
|
1032
|
+
// 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.
|
|
1033
|
+
if (field.optin !== undefined)
|
|
1034
|
+
propValues[key].add(undefined);
|
|
787
1035
|
}
|
|
788
1036
|
}
|
|
789
1037
|
return propValues;
|
|
@@ -791,6 +1039,8 @@ export const $ZodObject = /*@__PURE__*/ core.$constructor("$ZodObject", (inst, d
|
|
|
791
1039
|
const isObject = util.isObject;
|
|
792
1040
|
const catchall = def.catchall;
|
|
793
1041
|
let value;
|
|
1042
|
+
const memo = core.globalConfig.memoizer;
|
|
1043
|
+
memo?.attach(inst);
|
|
794
1044
|
inst._zod.parse = (payload, ctx) => {
|
|
795
1045
|
value ?? (value = _normalized.value);
|
|
796
1046
|
const input = payload.value;
|
|
@@ -803,24 +1053,34 @@ export const $ZodObject = /*@__PURE__*/ core.$constructor("$ZodObject", (inst, d
|
|
|
803
1053
|
});
|
|
804
1054
|
return payload;
|
|
805
1055
|
}
|
|
806
|
-
payload.value = {};
|
|
1056
|
+
payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
|
|
807
1057
|
const proms = [];
|
|
808
1058
|
const shape = value.shape;
|
|
809
|
-
|
|
1059
|
+
const abortEarly = ctx?.abortEarly;
|
|
1060
|
+
let seen = payload.issues.length;
|
|
1061
|
+
for (const key of value.allKeys) {
|
|
1062
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
1063
|
+
if (util.aborted(payload, seen))
|
|
1064
|
+
break;
|
|
1065
|
+
seen = payload.issues.length;
|
|
1066
|
+
}
|
|
1067
|
+
if (key === "__proto__")
|
|
1068
|
+
continue;
|
|
810
1069
|
const el = shape[key];
|
|
811
|
-
const
|
|
1070
|
+
const optin = el._zod.optin;
|
|
1071
|
+
const optout = el._zod.optout;
|
|
812
1072
|
const r = el._zod.run({ value: input[key], issues: [] }, ctx);
|
|
813
1073
|
if (r instanceof Promise) {
|
|
814
|
-
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input,
|
|
1074
|
+
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
|
|
815
1075
|
}
|
|
816
1076
|
else {
|
|
817
|
-
handlePropertyResult(r, payload, key, input,
|
|
1077
|
+
handlePropertyResult(r, payload, key, input, optin, optout);
|
|
818
1078
|
}
|
|
819
1079
|
}
|
|
820
1080
|
if (!catchall) {
|
|
821
1081
|
return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
822
1082
|
}
|
|
823
|
-
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
|
|
1083
|
+
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst, abortEarly === true);
|
|
824
1084
|
};
|
|
825
1085
|
});
|
|
826
1086
|
export const $ZodObjectJIT = /*@__PURE__*/ core.$constructor("$ZodObjectJIT", (inst, def) => {
|
|
@@ -828,73 +1088,106 @@ export const $ZodObjectJIT = /*@__PURE__*/ core.$constructor("$ZodObjectJIT", (i
|
|
|
828
1088
|
$ZodObject.init(inst, def);
|
|
829
1089
|
const superParse = inst._zod.parse;
|
|
830
1090
|
const _normalized = util.cached(() => normalizeDef(def));
|
|
1091
|
+
const memo = core.globalConfig.memoizer;
|
|
831
1092
|
const generateFastpass = (shape) => {
|
|
832
|
-
const doc = new Doc(["shape", "payload", "ctx"]);
|
|
833
1093
|
const normalized = _normalized.value;
|
|
834
|
-
const
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
}
|
|
1094
|
+
const syms = normalized.symbolKeys;
|
|
1095
|
+
// a symbol has no source literal, so it is read as `syms[i]` off the closed-over scope
|
|
1096
|
+
const doc = new Doc(["payload", "ctx"], { shape, inst, memo, syms });
|
|
1097
|
+
const parseStr = (k) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
|
1098
|
+
// 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
|
|
1099
|
+
const prefixStr = (id, k) => `
|
|
1100
|
+
let ${id}_ab = false;
|
|
1101
|
+
for (let i = 0; i < ${id}.issues.length; i++) {
|
|
1102
|
+
const iss = ${id}.issues[i];
|
|
1103
|
+
iss.path = iss.path ? [${k}, ...iss.path] : [${k}];
|
|
1104
|
+
payload.issues.push(iss);
|
|
1105
|
+
if (iss.continue !== true) ${id}_ab = true;
|
|
1106
|
+
}
|
|
1107
|
+
if (${id}_ab && ctx && ctx.abortEarly) {
|
|
1108
|
+
payload.value = newResult;
|
|
1109
|
+
return payload;
|
|
1110
|
+
}`;
|
|
838
1111
|
doc.write(`const input = payload.value;`);
|
|
839
1112
|
const ids = Object.create(null);
|
|
840
1113
|
let counter = 0;
|
|
841
|
-
for (const key of normalized.
|
|
1114
|
+
for (const key of normalized.allKeys) {
|
|
842
1115
|
ids[key] = `key_${counter++}`;
|
|
843
1116
|
}
|
|
844
1117
|
// A: preserve key order {
|
|
845
|
-
doc.write(`const newResult = {};`);
|
|
846
|
-
for (const key of normalized.
|
|
1118
|
+
doc.write(memo ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
|
|
1119
|
+
for (const key of normalized.allKeys) {
|
|
1120
|
+
if (key === "__proto__")
|
|
1121
|
+
continue;
|
|
847
1122
|
const id = ids[key];
|
|
848
|
-
const k = util.esc(key);
|
|
1123
|
+
const k = typeof key === "symbol" ? `syms[${syms.indexOf(key)}]` : util.esc(key);
|
|
1124
|
+
const isPresent = `${k} in input`;
|
|
849
1125
|
const schema = shape[key];
|
|
1126
|
+
const optin = schema?._zod?.optin;
|
|
1127
|
+
const isOptionalIn = optin !== undefined;
|
|
850
1128
|
const isOptionalOut = schema?._zod?.optout === "optional";
|
|
851
|
-
doc.write(`const ${id} = ${parseStr(
|
|
852
|
-
if (isOptionalOut) {
|
|
853
|
-
// For optional-out schemas, ignore errors on absent keys
|
|
1129
|
+
doc.write(`const ${id} = ${parseStr(k)};`);
|
|
1130
|
+
if (isOptionalIn && isOptionalOut) {
|
|
1131
|
+
// 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.
|
|
1132
|
+
const assign = optin === "optional" ? `${id}_present` : `${id}.value !== undefined || ${id}_present`;
|
|
854
1133
|
doc.write(`
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
1134
|
+
const ${id}_present = ${isPresent};
|
|
1135
|
+
if (!${id}.issues.length || ${id}_present) {
|
|
1136
|
+
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
if (${assign}) {
|
|
1140
|
+
newResult[${k}] = ${id}.value;
|
|
861
1141
|
}
|
|
862
1142
|
}
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
1143
|
+
|
|
1144
|
+
`);
|
|
1145
|
+
}
|
|
1146
|
+
else if (!isOptionalIn) {
|
|
1147
|
+
doc.write(`
|
|
1148
|
+
const ${id}_present = ${isPresent};
|
|
1149
|
+
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
1150
|
+
}
|
|
1151
|
+
if (!${id}_present && !${id}.issues.length) {
|
|
1152
|
+
payload.issues.push({
|
|
1153
|
+
code: "invalid_type",
|
|
1154
|
+
expected: "nonoptional",
|
|
1155
|
+
input: undefined,
|
|
1156
|
+
path: [${k}]
|
|
1157
|
+
});
|
|
1158
|
+
if (ctx && ctx.abortEarly) {
|
|
1159
|
+
payload.value = newResult;
|
|
1160
|
+
return payload;
|
|
867
1161
|
}
|
|
868
|
-
}
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
if (${id}_present) {
|
|
869
1165
|
newResult[${k}] = ${id}.value;
|
|
870
1166
|
}
|
|
871
|
-
|
|
1167
|
+
|
|
872
1168
|
`);
|
|
873
1169
|
}
|
|
874
1170
|
else {
|
|
875
1171
|
doc.write(`
|
|
876
|
-
if (${id}.issues.length) {
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
newResult[${k}] = undefined;
|
|
886
|
-
}
|
|
887
|
-
} else {
|
|
1172
|
+
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
1173
|
+
}
|
|
1174
|
+
`);
|
|
1175
|
+
if (optin === "defaulted") {
|
|
1176
|
+
doc.write(`newResult[${k}] = ${id}.value;`);
|
|
1177
|
+
}
|
|
1178
|
+
else {
|
|
1179
|
+
doc.write(`
|
|
1180
|
+
if (${id}.value !== undefined || ${isPresent}) {
|
|
888
1181
|
newResult[${k}] = ${id}.value;
|
|
889
1182
|
}
|
|
890
|
-
|
|
891
1183
|
`);
|
|
1184
|
+
}
|
|
892
1185
|
}
|
|
893
1186
|
}
|
|
894
1187
|
doc.write(`payload.value = newResult;`);
|
|
895
1188
|
doc.write(`return payload;`);
|
|
896
|
-
|
|
897
|
-
return (
|
|
1189
|
+
// 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
|
|
1190
|
+
return doc.compile();
|
|
898
1191
|
};
|
|
899
1192
|
let fastpass;
|
|
900
1193
|
const isObject = util.isObject;
|
|
@@ -922,7 +1215,7 @@ export const $ZodObjectJIT = /*@__PURE__*/ core.$constructor("$ZodObjectJIT", (i
|
|
|
922
1215
|
payload = fastpass(payload, ctx);
|
|
923
1216
|
if (!catchall)
|
|
924
1217
|
return payload;
|
|
925
|
-
return handleCatchall([], input, payload, ctx, value, inst);
|
|
1218
|
+
return handleCatchall([], input, payload, ctx, value, inst, ctx?.abortEarly === true);
|
|
926
1219
|
}
|
|
927
1220
|
return superParse(payload, ctx);
|
|
928
1221
|
};
|
|
@@ -949,25 +1242,28 @@ function handleUnionResults(results, final, inst, ctx) {
|
|
|
949
1242
|
}
|
|
950
1243
|
export const $ZodUnion = /*@__PURE__*/ core.$constructor("$ZodUnion", (inst, def) => {
|
|
951
1244
|
$ZodType.init(inst, def);
|
|
952
|
-
util.
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
1245
|
+
util.defineLazyInternal(inst, "optin", (zod) => zod.def.options.some((o) => o._zod.optin === "defaulted")
|
|
1246
|
+
? "defaulted"
|
|
1247
|
+
: zod.def.options.some((o) => o._zod.optin !== undefined)
|
|
1248
|
+
? "optional"
|
|
1249
|
+
: undefined);
|
|
1250
|
+
util.defineLazyInternal(inst, "optout", (zod) => zod.def.options.some((o) => o._zod.optout === "optional") ? "optional" : undefined);
|
|
1251
|
+
util.defineLazyInternal(inst, "values", (zod) => {
|
|
1252
|
+
if (zod.def.options.every((o) => o._zod.values)) {
|
|
1253
|
+
return new Set(zod.def.options.flatMap((option) => Array.from(option._zod.values)));
|
|
957
1254
|
}
|
|
958
1255
|
return undefined;
|
|
959
1256
|
});
|
|
960
|
-
util.
|
|
961
|
-
if (def.options.every((o) => o._zod.pattern)) {
|
|
962
|
-
const patterns = def.options.map((o) => o._zod.pattern);
|
|
1257
|
+
util.defineLazyInternal(inst, "pattern", (zod) => {
|
|
1258
|
+
if (zod.def.options.every((o) => o._zod.pattern)) {
|
|
1259
|
+
const patterns = zod.def.options.map((o) => o._zod.pattern);
|
|
963
1260
|
return new RegExp(`^(${patterns.map((p) => util.cleanRegex(p.source)).join("|")})$`);
|
|
964
1261
|
}
|
|
965
1262
|
return undefined;
|
|
966
1263
|
});
|
|
967
|
-
const
|
|
968
|
-
const first = def.options[0]._zod.run;
|
|
1264
|
+
const first = def.options.length === 1 ? def.options[0]._zod.run : null;
|
|
969
1265
|
inst._zod.parse = (payload, ctx) => {
|
|
970
|
-
if (
|
|
1266
|
+
if (first) {
|
|
971
1267
|
return first(payload, ctx);
|
|
972
1268
|
}
|
|
973
1269
|
let async = false;
|
|
@@ -995,12 +1291,16 @@ export const $ZodUnion = /*@__PURE__*/ core.$constructor("$ZodUnion", (inst, def
|
|
|
995
1291
|
};
|
|
996
1292
|
});
|
|
997
1293
|
function handleExclusiveUnionResults(results, final, inst, ctx) {
|
|
998
|
-
const
|
|
999
|
-
|
|
1000
|
-
|
|
1294
|
+
const matches = [];
|
|
1295
|
+
for (let i = 0; i < results.length; i++) {
|
|
1296
|
+
if (results[i].issues.length === 0)
|
|
1297
|
+
matches.push(i);
|
|
1298
|
+
}
|
|
1299
|
+
if (matches.length === 1) {
|
|
1300
|
+
final.value = results[matches[0]].value;
|
|
1001
1301
|
return final;
|
|
1002
1302
|
}
|
|
1003
|
-
if (
|
|
1303
|
+
if (matches.length === 0) {
|
|
1004
1304
|
// No matches - same as regular union
|
|
1005
1305
|
final.issues.push({
|
|
1006
1306
|
code: "invalid_union",
|
|
@@ -1017,6 +1317,7 @@ function handleExclusiveUnionResults(results, final, inst, ctx) {
|
|
|
1017
1317
|
inst,
|
|
1018
1318
|
errors: [],
|
|
1019
1319
|
inclusive: false,
|
|
1320
|
+
matches,
|
|
1020
1321
|
});
|
|
1021
1322
|
}
|
|
1022
1323
|
return final;
|
|
@@ -1024,10 +1325,9 @@ function handleExclusiveUnionResults(results, final, inst, ctx) {
|
|
|
1024
1325
|
export const $ZodXor = /*@__PURE__*/ core.$constructor("$ZodXor", (inst, def) => {
|
|
1025
1326
|
$ZodUnion.init(inst, def);
|
|
1026
1327
|
def.inclusive = false;
|
|
1027
|
-
const
|
|
1028
|
-
const first = def.options[0]._zod.run;
|
|
1328
|
+
const first = def.options.length === 1 ? def.options[0]._zod.run : null;
|
|
1029
1329
|
inst._zod.parse = (payload, ctx) => {
|
|
1030
|
-
if (
|
|
1330
|
+
if (first) {
|
|
1031
1331
|
return first(payload, ctx);
|
|
1032
1332
|
}
|
|
1033
1333
|
let async = false;
|
|
@@ -1052,44 +1352,75 @@ export const $ZodXor = /*@__PURE__*/ core.$constructor("$ZodXor", (inst, def) =>
|
|
|
1052
1352
|
});
|
|
1053
1353
|
};
|
|
1054
1354
|
});
|
|
1355
|
+
/** Returns the option whose discriminator claims `value`, or throws if ambiguous. */
|
|
1356
|
+
export function getDiscriminatedOption(union, value) {
|
|
1357
|
+
const internals = union._zod;
|
|
1358
|
+
let map = internals.bag.optionsMap;
|
|
1359
|
+
if (!map) {
|
|
1360
|
+
map = discriminatorMap(internals.def);
|
|
1361
|
+
internals.bag.optionsMap = map;
|
|
1362
|
+
}
|
|
1363
|
+
const option = map.get(value);
|
|
1364
|
+
if (option === null)
|
|
1365
|
+
throw new Error(`Ambiguous discriminator value "${String(value)}"`);
|
|
1366
|
+
return option;
|
|
1367
|
+
}
|
|
1368
|
+
function discriminatorMap(def) {
|
|
1369
|
+
const map = new Map();
|
|
1370
|
+
for (const option of def.options) {
|
|
1371
|
+
const values = option._zod.propValues?.[def.discriminator];
|
|
1372
|
+
if (!values || values.size === 0)
|
|
1373
|
+
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
|
|
1374
|
+
for (const value of values) {
|
|
1375
|
+
if (map.has(value)) {
|
|
1376
|
+
if (value !== undefined)
|
|
1377
|
+
throw new Error(`Duplicate discriminator value "${String(value)}"`);
|
|
1378
|
+
// keep the collision marked so a later member cannot reclaim it
|
|
1379
|
+
map.set(value, null);
|
|
1380
|
+
}
|
|
1381
|
+
else {
|
|
1382
|
+
map.set(value, option);
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
return map;
|
|
1387
|
+
}
|
|
1055
1388
|
export const $ZodDiscriminatedUnion =
|
|
1056
1389
|
/*@__PURE__*/
|
|
1057
1390
|
core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
1058
1391
|
def.inclusive = false;
|
|
1059
1392
|
$ZodUnion.init(inst, def);
|
|
1060
1393
|
const _super = inst._zod.parse;
|
|
1061
|
-
util.
|
|
1394
|
+
util.defineLazyInternal(inst, "propValues", (zod) => {
|
|
1062
1395
|
const propValues = {};
|
|
1063
|
-
|
|
1396
|
+
let undefinedCount = 0;
|
|
1397
|
+
for (const option of zod.def.options) {
|
|
1064
1398
|
const pv = option._zod.propValues;
|
|
1065
1399
|
if (!pv || Object.keys(pv).length === 0)
|
|
1066
|
-
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
|
|
1400
|
+
throw new Error(`Invalid discriminated union option at index "${zod.def.options.indexOf(option)}"`);
|
|
1401
|
+
if (pv[zod.def.discriminator]?.has(undefined))
|
|
1402
|
+
undefinedCount++;
|
|
1067
1403
|
for (const [k, v] of Object.entries(pv)) {
|
|
1068
|
-
if (!propValues
|
|
1069
|
-
propValues
|
|
1404
|
+
if (!Object.prototype.hasOwnProperty.call(propValues, k)) {
|
|
1405
|
+
util.assignProp(propValues, k, new Set());
|
|
1406
|
+
}
|
|
1070
1407
|
for (const val of v) {
|
|
1071
1408
|
propValues[k].add(val);
|
|
1072
1409
|
}
|
|
1073
1410
|
}
|
|
1074
1411
|
}
|
|
1412
|
+
if (!zod.def.unionFallback && undefinedCount > 1)
|
|
1413
|
+
propValues[zod.def.discriminator]?.delete(undefined);
|
|
1075
1414
|
return propValues;
|
|
1076
1415
|
});
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
const
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
if (!values || values.size === 0)
|
|
1083
|
-
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
|
|
1084
|
-
for (const v of values) {
|
|
1085
|
-
if (map.has(v)) {
|
|
1086
|
-
throw new Error(`Duplicate discriminator value "${String(v)}"`);
|
|
1087
|
-
}
|
|
1088
|
-
map.set(v, o);
|
|
1089
|
-
}
|
|
1416
|
+
// 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.
|
|
1417
|
+
def.options.forEach((option, i) => {
|
|
1418
|
+
const propShape = util.rawShape(option._zod.def);
|
|
1419
|
+
if (propShape && !Object.prototype.hasOwnProperty.call(propShape, def.discriminator)) {
|
|
1420
|
+
throw new Error(`Invalid discriminated union option at index "${i}"`);
|
|
1090
1421
|
}
|
|
1091
|
-
return map;
|
|
1092
1422
|
});
|
|
1423
|
+
const disc = util.cached(() => discriminatorMap(def));
|
|
1093
1424
|
inst._zod.parse = (payload, ctx) => {
|
|
1094
1425
|
const input = payload.value;
|
|
1095
1426
|
if (!util.isObject(input)) {
|
|
@@ -1101,11 +1432,16 @@ core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
|
1101
1432
|
});
|
|
1102
1433
|
return payload;
|
|
1103
1434
|
}
|
|
1104
|
-
const
|
|
1105
|
-
|
|
1435
|
+
const value = input?.[def.discriminator];
|
|
1436
|
+
const opt = disc.value.get(value);
|
|
1437
|
+
// forward metadata cannot choose an encoder for an absent tag
|
|
1438
|
+
if (opt && (value !== undefined || ctx.direction !== "backward")) {
|
|
1106
1439
|
return opt._zod.run(payload, ctx);
|
|
1107
1440
|
}
|
|
1108
|
-
|
|
1441
|
+
// Fall back to union matching when the fast discriminator path fails:
|
|
1442
|
+
// - explicitly enabled via unionFallback, or
|
|
1443
|
+
// - during backward direction (encode), since codec-based discriminators have different values in forward vs backward directions
|
|
1444
|
+
if (def.unionFallback || ctx.direction === "backward") {
|
|
1109
1445
|
return _super(payload, ctx);
|
|
1110
1446
|
}
|
|
1111
1447
|
// no matching discriminator
|
|
@@ -1114,6 +1450,7 @@ core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
|
1114
1450
|
errors: [],
|
|
1115
1451
|
note: "No matching discriminator",
|
|
1116
1452
|
discriminator: def.discriminator,
|
|
1453
|
+
options: Array.from(disc.value.keys()).filter((value) => disc.value.get(value) !== null),
|
|
1117
1454
|
input,
|
|
1118
1455
|
path: [def.discriminator],
|
|
1119
1456
|
inst,
|
|
@@ -1136,7 +1473,7 @@ export const $ZodIntersection = /*@__PURE__*/ core.$constructor("$ZodIntersectio
|
|
|
1136
1473
|
return handleIntersectionResults(payload, left, right);
|
|
1137
1474
|
};
|
|
1138
1475
|
});
|
|
1139
|
-
function mergeValues(a, b) {
|
|
1476
|
+
export function mergeValues(a, b) {
|
|
1140
1477
|
// const aType = parse.t(a);
|
|
1141
1478
|
// const bType = parse.t(b);
|
|
1142
1479
|
if (a === b) {
|
|
@@ -1149,7 +1486,11 @@ function mergeValues(a, b) {
|
|
|
1149
1486
|
const bKeys = Object.keys(b);
|
|
1150
1487
|
const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
|
1151
1488
|
const newObj = { ...a, ...b };
|
|
1489
|
+
if (Object.prototype.hasOwnProperty.call(newObj, "__proto__"))
|
|
1490
|
+
delete newObj.__proto__;
|
|
1152
1491
|
for (const key of sharedKeys) {
|
|
1492
|
+
if (key === "__proto__")
|
|
1493
|
+
continue;
|
|
1153
1494
|
const sharedValue = mergeValues(a[key], b[key]);
|
|
1154
1495
|
if (!sharedValue.valid) {
|
|
1155
1496
|
return {
|
|
@@ -1183,43 +1524,55 @@ function mergeValues(a, b) {
|
|
|
1183
1524
|
return { valid: false, mergeErrorPath: [] };
|
|
1184
1525
|
}
|
|
1185
1526
|
function handleIntersectionResults(result, left, right) {
|
|
1186
|
-
// Track which side(s)
|
|
1527
|
+
// 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.
|
|
1187
1528
|
const unrecKeys = new Map();
|
|
1188
1529
|
let unrecIssue;
|
|
1189
|
-
|
|
1190
|
-
|
|
1530
|
+
const keyIssues = new Map();
|
|
1531
|
+
const collect = (iss, side) => {
|
|
1532
|
+
let keys;
|
|
1533
|
+
if (iss.code === "unrecognized_keys" && !iss.path?.length) {
|
|
1191
1534
|
unrecIssue ?? (unrecIssue = iss);
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1535
|
+
keys = iss.keys;
|
|
1536
|
+
}
|
|
1537
|
+
else if (iss.code === "invalid_key" && iss.origin === "record" && iss.path?.length === 1) {
|
|
1538
|
+
const k = String(iss.path[0]);
|
|
1539
|
+
if (!keyIssues.has(k))
|
|
1540
|
+
keyIssues.set(k, iss);
|
|
1541
|
+
keys = [k];
|
|
1197
1542
|
}
|
|
1198
1543
|
else {
|
|
1199
|
-
|
|
1544
|
+
return false;
|
|
1545
|
+
}
|
|
1546
|
+
for (const k of keys) {
|
|
1547
|
+
if (!unrecKeys.has(k))
|
|
1548
|
+
unrecKeys.set(k, {});
|
|
1549
|
+
unrecKeys.get(k)[side] = true;
|
|
1200
1550
|
}
|
|
1551
|
+
return true;
|
|
1552
|
+
};
|
|
1553
|
+
for (const iss of left.issues) {
|
|
1554
|
+
if (!collect(iss, "l"))
|
|
1555
|
+
result.issues.push(iss);
|
|
1201
1556
|
}
|
|
1202
1557
|
for (const iss of right.issues) {
|
|
1203
|
-
if (iss
|
|
1204
|
-
for (const k of iss.keys) {
|
|
1205
|
-
if (!unrecKeys.has(k))
|
|
1206
|
-
unrecKeys.set(k, {});
|
|
1207
|
-
unrecKeys.get(k).r = true;
|
|
1208
|
-
}
|
|
1209
|
-
}
|
|
1210
|
-
else {
|
|
1558
|
+
if (!collect(iss, "r"))
|
|
1211
1559
|
result.issues.push(iss);
|
|
1212
|
-
}
|
|
1213
1560
|
}
|
|
1214
|
-
// Report only keys
|
|
1561
|
+
// Report only keys rejected by BOTH sides
|
|
1215
1562
|
const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
|
|
1216
|
-
if (bothKeys.length
|
|
1217
|
-
|
|
1563
|
+
if (bothKeys.length) {
|
|
1564
|
+
const aggregated = unrecIssue ? bothKeys.filter((k) => unrecIssue.keys.includes(k)) : [];
|
|
1565
|
+
if (aggregated.length)
|
|
1566
|
+
result.issues.push({ ...unrecIssue, keys: aggregated });
|
|
1567
|
+
for (const k of bothKeys) {
|
|
1568
|
+
if (!aggregated.includes(k) && keyIssues.has(k))
|
|
1569
|
+
result.issues.push(keyIssues.get(k));
|
|
1570
|
+
}
|
|
1218
1571
|
}
|
|
1219
|
-
if (util.aborted(result))
|
|
1220
|
-
return result;
|
|
1221
1572
|
const merged = mergeValues(left.value, right.value);
|
|
1222
1573
|
if (!merged.valid) {
|
|
1574
|
+
if (util.aborted(result))
|
|
1575
|
+
return result;
|
|
1223
1576
|
throw new Error(`Unmergable intersection. Error path: ` + `${JSON.stringify(merged.mergeErrorPath)}`);
|
|
1224
1577
|
}
|
|
1225
1578
|
result.value = merged.data;
|
|
@@ -1228,6 +1581,8 @@ function handleIntersectionResults(result, left, right) {
|
|
|
1228
1581
|
export const $ZodTuple = /*@__PURE__*/ core.$constructor("$ZodTuple", (inst, def) => {
|
|
1229
1582
|
$ZodType.init(inst, def);
|
|
1230
1583
|
const items = def.items;
|
|
1584
|
+
const memo = core.globalConfig.memoizer;
|
|
1585
|
+
memo?.attach(inst);
|
|
1231
1586
|
inst._zod.parse = (payload, ctx) => {
|
|
1232
1587
|
const input = payload.value;
|
|
1233
1588
|
if (!Array.isArray(input)) {
|
|
@@ -1239,71 +1594,132 @@ export const $ZodTuple = /*@__PURE__*/ core.$constructor("$ZodTuple", (inst, def
|
|
|
1239
1594
|
});
|
|
1240
1595
|
return payload;
|
|
1241
1596
|
}
|
|
1242
|
-
payload.value = [];
|
|
1597
|
+
payload.value = memo ? memo.alloc(inst, payload, [], ctx) : [];
|
|
1243
1598
|
const proms = [];
|
|
1244
|
-
const
|
|
1245
|
-
const
|
|
1599
|
+
const optinStart = getTupleOptStart(items, "optin");
|
|
1600
|
+
const optoutStart = getTupleOptStart(items, "optout");
|
|
1246
1601
|
if (!def.rest) {
|
|
1247
|
-
|
|
1248
|
-
const tooSmall = input.length < optStart - 1;
|
|
1249
|
-
if (tooBig || tooSmall) {
|
|
1602
|
+
if (input.length < optinStart) {
|
|
1250
1603
|
payload.issues.push({
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1604
|
+
code: "too_small",
|
|
1605
|
+
minimum: optinStart,
|
|
1606
|
+
inclusive: true,
|
|
1254
1607
|
input,
|
|
1255
1608
|
inst,
|
|
1256
1609
|
origin: "array",
|
|
1257
1610
|
});
|
|
1258
1611
|
return payload;
|
|
1259
1612
|
}
|
|
1613
|
+
if (input.length > items.length) {
|
|
1614
|
+
payload.issues.push({
|
|
1615
|
+
code: "too_big",
|
|
1616
|
+
maximum: items.length,
|
|
1617
|
+
inclusive: true,
|
|
1618
|
+
input,
|
|
1619
|
+
inst,
|
|
1620
|
+
origin: "array",
|
|
1621
|
+
});
|
|
1622
|
+
}
|
|
1260
1623
|
}
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
const
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
proms.push(result.then((result) => handleTupleResult(result, payload, i)));
|
|
1624
|
+
// 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.
|
|
1625
|
+
const itemResults = new Array(items.length);
|
|
1626
|
+
// only tracked when there is a rest loop to skip
|
|
1627
|
+
const abortEarly = def.rest ? ctx?.abortEarly : undefined;
|
|
1628
|
+
let itemAborted = false;
|
|
1629
|
+
for (let i = 0; i < items.length; i++) {
|
|
1630
|
+
const r = items[i]._zod.run({ value: input[i], issues: [] }, ctx);
|
|
1631
|
+
if (r instanceof Promise) {
|
|
1632
|
+
proms.push(r.then((rr) => {
|
|
1633
|
+
itemResults[i] = rr;
|
|
1634
|
+
}));
|
|
1273
1635
|
}
|
|
1274
1636
|
else {
|
|
1275
|
-
|
|
1637
|
+
itemResults[i] = r;
|
|
1638
|
+
if (abortEarly && !itemAborted && r.issues.length)
|
|
1639
|
+
itemAborted = util.aborted(r);
|
|
1276
1640
|
}
|
|
1277
1641
|
}
|
|
1278
|
-
|
|
1642
|
+
// sound because rest is non-empty exactly when every fixed index is present, the one case handleTupleResults cannot discard an item's issues
|
|
1643
|
+
if (def.rest && !itemAborted) {
|
|
1644
|
+
let i = items.length - 1;
|
|
1279
1645
|
const rest = input.slice(items.length);
|
|
1646
|
+
let seen = payload.issues.length;
|
|
1280
1647
|
for (const el of rest) {
|
|
1648
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
1649
|
+
if (util.aborted(payload, seen))
|
|
1650
|
+
break;
|
|
1651
|
+
seen = payload.issues.length;
|
|
1652
|
+
}
|
|
1281
1653
|
i++;
|
|
1282
|
-
const result = def.rest._zod.run({
|
|
1283
|
-
value: el,
|
|
1284
|
-
issues: [],
|
|
1285
|
-
}, ctx);
|
|
1654
|
+
const result = def.rest._zod.run({ value: el, issues: [] }, ctx);
|
|
1286
1655
|
if (result instanceof Promise) {
|
|
1287
|
-
proms.push(result.then((
|
|
1656
|
+
proms.push(result.then((r) => handleTupleResult(r, payload, i)));
|
|
1288
1657
|
}
|
|
1289
1658
|
else {
|
|
1290
1659
|
handleTupleResult(result, payload, i);
|
|
1291
1660
|
}
|
|
1292
1661
|
}
|
|
1293
1662
|
}
|
|
1294
|
-
if (proms.length)
|
|
1295
|
-
return Promise.all(proms).then(() => payload);
|
|
1296
|
-
|
|
1663
|
+
if (proms.length) {
|
|
1664
|
+
return Promise.all(proms).then(() => handleTupleResults(itemResults, payload, items, input, optoutStart));
|
|
1665
|
+
}
|
|
1666
|
+
return handleTupleResults(itemResults, payload, items, input, optoutStart);
|
|
1297
1667
|
};
|
|
1298
1668
|
});
|
|
1669
|
+
function getTupleOptStart(items, key) {
|
|
1670
|
+
for (let i = items.length - 1; i >= 0; i--) {
|
|
1671
|
+
// optin is a three-rung ladder so any rung above `undefined` permits an absent slot; optout stays two-valued.
|
|
1672
|
+
const omittable = key === "optin" ? items[i]._zod.optin !== undefined : items[i]._zod.optout === "optional";
|
|
1673
|
+
if (!omittable)
|
|
1674
|
+
return i + 1;
|
|
1675
|
+
}
|
|
1676
|
+
return 0;
|
|
1677
|
+
}
|
|
1299
1678
|
function handleTupleResult(result, final, index) {
|
|
1300
1679
|
if (result.issues.length) {
|
|
1301
1680
|
final.issues.push(...util.prefixIssues(index, result.issues));
|
|
1302
1681
|
}
|
|
1303
1682
|
final.value[index] = result.value;
|
|
1304
1683
|
}
|
|
1684
|
+
function handleTupleResults(itemResults, final, items, input, optoutStart) {
|
|
1685
|
+
// 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.
|
|
1686
|
+
for (let i = 0; i < items.length; i++) {
|
|
1687
|
+
const r = itemResults[i];
|
|
1688
|
+
const isPresent = i < input.length;
|
|
1689
|
+
// 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`.
|
|
1690
|
+
if (!isPresent && i >= optoutStart && items[i]._zod.optin === "optional") {
|
|
1691
|
+
final.value.length = i;
|
|
1692
|
+
break;
|
|
1693
|
+
}
|
|
1694
|
+
if (r.issues.length) {
|
|
1695
|
+
if (!isPresent && i >= optoutStart) {
|
|
1696
|
+
final.value.length = i;
|
|
1697
|
+
break;
|
|
1698
|
+
}
|
|
1699
|
+
final.issues.push(...util.prefixIssues(i, r.issues));
|
|
1700
|
+
}
|
|
1701
|
+
final.value[i] = r.value;
|
|
1702
|
+
}
|
|
1703
|
+
// Drop trailing slots that produced `undefined` for absent input
|
|
1704
|
+
// (the array analog of an absent optional key on an object). The
|
|
1705
|
+
// `i >= input.length` floor is critical: an explicit `undefined`
|
|
1706
|
+
// *inside* the input must be preserved even when the schema is
|
|
1707
|
+
// optional-out (e.g. `z.string().or(z.undefined())` accepting an
|
|
1708
|
+
// explicit undefined value).
|
|
1709
|
+
for (let i = final.value.length - 1; i >= input.length; i--) {
|
|
1710
|
+
if (items[i]._zod.optout === "optional" && final.value[i] === undefined) {
|
|
1711
|
+
final.value.length = i;
|
|
1712
|
+
}
|
|
1713
|
+
else {
|
|
1714
|
+
break;
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
return final;
|
|
1718
|
+
}
|
|
1305
1719
|
export const $ZodRecord = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, def) => {
|
|
1306
1720
|
$ZodType.init(inst, def);
|
|
1721
|
+
const memo = core.globalConfig.memoizer;
|
|
1722
|
+
memo?.attach(inst);
|
|
1307
1723
|
inst._zod.parse = (payload, ctx) => {
|
|
1308
1724
|
const input = payload.value;
|
|
1309
1725
|
if (!util.isPlainObject(input)) {
|
|
@@ -1315,36 +1731,66 @@ export const $ZodRecord = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, d
|
|
|
1315
1731
|
});
|
|
1316
1732
|
return payload;
|
|
1317
1733
|
}
|
|
1734
|
+
// 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
|
|
1318
1735
|
const proms = [];
|
|
1319
1736
|
const values = def.keyType._zod.values;
|
|
1320
|
-
if (values) {
|
|
1321
|
-
payload.value = {};
|
|
1737
|
+
if (values && !def.partial) {
|
|
1738
|
+
payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
|
|
1322
1739
|
const recordKeys = new Set();
|
|
1323
1740
|
for (const key of values) {
|
|
1324
1741
|
if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
|
|
1325
1742
|
recordKeys.add(typeof key === "number" ? key.toString() : key);
|
|
1743
|
+
// A declared __proto__ is stripped but is not an unrecognized key.
|
|
1744
|
+
if (key === "__proto__")
|
|
1745
|
+
continue;
|
|
1746
|
+
const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
1747
|
+
if (keyResult instanceof Promise) {
|
|
1748
|
+
throw new Error("Async schemas not supported in object keys currently");
|
|
1749
|
+
}
|
|
1750
|
+
if (keyResult.issues.length) {
|
|
1751
|
+
payload.issues.push({
|
|
1752
|
+
code: "invalid_key",
|
|
1753
|
+
origin: "record",
|
|
1754
|
+
issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
|
1755
|
+
input: key,
|
|
1756
|
+
path: [key],
|
|
1757
|
+
inst,
|
|
1758
|
+
});
|
|
1759
|
+
continue;
|
|
1760
|
+
}
|
|
1761
|
+
const outKey = keyResult.value;
|
|
1762
|
+
if (outKey === "__proto__")
|
|
1763
|
+
continue;
|
|
1326
1764
|
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
|
|
1327
1765
|
if (result instanceof Promise) {
|
|
1328
1766
|
proms.push(result.then((result) => {
|
|
1329
1767
|
if (result.issues.length) {
|
|
1330
1768
|
payload.issues.push(...util.prefixIssues(key, result.issues));
|
|
1331
1769
|
}
|
|
1332
|
-
payload.value[
|
|
1770
|
+
payload.value[outKey] = result.value;
|
|
1333
1771
|
}));
|
|
1334
1772
|
}
|
|
1335
1773
|
else {
|
|
1336
1774
|
if (result.issues.length) {
|
|
1337
1775
|
payload.issues.push(...util.prefixIssues(key, result.issues));
|
|
1338
1776
|
}
|
|
1339
|
-
payload.value[
|
|
1777
|
+
payload.value[outKey] = result.value;
|
|
1340
1778
|
}
|
|
1341
1779
|
}
|
|
1342
1780
|
}
|
|
1343
1781
|
let unrecognized;
|
|
1344
1782
|
for (const key in input) {
|
|
1345
1783
|
if (!recordKeys.has(key)) {
|
|
1346
|
-
|
|
1347
|
-
|
|
1784
|
+
if (def.mode === "loose") {
|
|
1785
|
+
// skip __proto__ so it can't replace the result prototype via the assignment setter on the plain {} we build into
|
|
1786
|
+
if (key === "__proto__")
|
|
1787
|
+
continue;
|
|
1788
|
+
payload.value[key] = input[key];
|
|
1789
|
+
}
|
|
1790
|
+
else {
|
|
1791
|
+
unrecognized = unrecognized ?? [];
|
|
1792
|
+
unrecognized.push(key);
|
|
1793
|
+
}
|
|
1348
1794
|
}
|
|
1349
1795
|
}
|
|
1350
1796
|
if (unrecognized && unrecognized.length > 0) {
|
|
@@ -1353,20 +1799,25 @@ export const $ZodRecord = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, d
|
|
|
1353
1799
|
input,
|
|
1354
1800
|
inst,
|
|
1355
1801
|
keys: unrecognized,
|
|
1802
|
+
continue: true,
|
|
1356
1803
|
});
|
|
1357
1804
|
}
|
|
1358
1805
|
}
|
|
1359
1806
|
else {
|
|
1360
|
-
payload.value = {};
|
|
1807
|
+
payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
|
|
1808
|
+
// 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.
|
|
1809
|
+
let unrecognized;
|
|
1810
|
+
// Reflect.ownKeys for Symbol-key support; filter non-enumerable to match z.object()
|
|
1361
1811
|
for (const key of Reflect.ownKeys(input)) {
|
|
1362
1812
|
if (key === "__proto__")
|
|
1363
1813
|
continue;
|
|
1814
|
+
if (!Object.prototype.propertyIsEnumerable.call(input, key))
|
|
1815
|
+
continue;
|
|
1364
1816
|
let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
1365
1817
|
if (keyResult instanceof Promise) {
|
|
1366
1818
|
throw new Error("Async schemas not supported in object keys currently");
|
|
1367
1819
|
}
|
|
1368
|
-
// Numeric string fallback: if key is a numeric string and failed, retry with Number(key)
|
|
1369
|
-
// This handles z.number(), z.literal([1, 2, 3]), and unions containing numeric literals
|
|
1820
|
+
// 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
|
|
1370
1821
|
const checkNumericKey = typeof key === "string" && regexes.number.test(key) && keyResult.issues.length;
|
|
1371
1822
|
if (checkNumericKey) {
|
|
1372
1823
|
const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
|
|
@@ -1382,6 +1833,10 @@ export const $ZodRecord = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, d
|
|
|
1382
1833
|
// Pass through unchanged
|
|
1383
1834
|
payload.value[key] = input[key];
|
|
1384
1835
|
}
|
|
1836
|
+
else if (values) {
|
|
1837
|
+
unrecognized = unrecognized ?? [];
|
|
1838
|
+
unrecognized.push(key);
|
|
1839
|
+
}
|
|
1385
1840
|
else {
|
|
1386
1841
|
// Default "strict" behavior: error on invalid key
|
|
1387
1842
|
payload.issues.push({
|
|
@@ -1395,22 +1850,35 @@ export const $ZodRecord = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, d
|
|
|
1395
1850
|
}
|
|
1396
1851
|
continue;
|
|
1397
1852
|
}
|
|
1853
|
+
// 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
|
|
1854
|
+
const outKey = keyResult.value;
|
|
1855
|
+
if (outKey === "__proto__")
|
|
1856
|
+
continue;
|
|
1398
1857
|
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
|
|
1399
1858
|
if (result instanceof Promise) {
|
|
1400
1859
|
proms.push(result.then((result) => {
|
|
1401
1860
|
if (result.issues.length) {
|
|
1402
1861
|
payload.issues.push(...util.prefixIssues(key, result.issues));
|
|
1403
1862
|
}
|
|
1404
|
-
payload.value[
|
|
1863
|
+
payload.value[outKey] = result.value;
|
|
1405
1864
|
}));
|
|
1406
1865
|
}
|
|
1407
1866
|
else {
|
|
1408
1867
|
if (result.issues.length) {
|
|
1409
1868
|
payload.issues.push(...util.prefixIssues(key, result.issues));
|
|
1410
1869
|
}
|
|
1411
|
-
payload.value[
|
|
1870
|
+
payload.value[outKey] = result.value;
|
|
1412
1871
|
}
|
|
1413
1872
|
}
|
|
1873
|
+
if (unrecognized && unrecognized.length > 0) {
|
|
1874
|
+
payload.issues.push({
|
|
1875
|
+
code: "unrecognized_keys",
|
|
1876
|
+
input,
|
|
1877
|
+
inst,
|
|
1878
|
+
keys: unrecognized,
|
|
1879
|
+
continue: true,
|
|
1880
|
+
});
|
|
1881
|
+
}
|
|
1414
1882
|
}
|
|
1415
1883
|
if (proms.length) {
|
|
1416
1884
|
return Promise.all(proms).then(() => payload);
|
|
@@ -1420,6 +1888,8 @@ export const $ZodRecord = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, d
|
|
|
1420
1888
|
});
|
|
1421
1889
|
export const $ZodMap = /*@__PURE__*/ core.$constructor("$ZodMap", (inst, def) => {
|
|
1422
1890
|
$ZodType.init(inst, def);
|
|
1891
|
+
const memo = core.globalConfig.memoizer;
|
|
1892
|
+
memo?.attach(inst);
|
|
1423
1893
|
inst._zod.parse = (payload, ctx) => {
|
|
1424
1894
|
const input = payload.value;
|
|
1425
1895
|
if (!(input instanceof Map)) {
|
|
@@ -1432,8 +1902,15 @@ export const $ZodMap = /*@__PURE__*/ core.$constructor("$ZodMap", (inst, def) =>
|
|
|
1432
1902
|
return payload;
|
|
1433
1903
|
}
|
|
1434
1904
|
const proms = [];
|
|
1435
|
-
payload.value = new Map();
|
|
1905
|
+
payload.value = memo ? memo.alloc(inst, payload, new Map(), ctx) : new Map();
|
|
1906
|
+
const abortEarly = ctx?.abortEarly;
|
|
1907
|
+
let seen = payload.issues.length;
|
|
1436
1908
|
for (const [key, value] of input) {
|
|
1909
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
1910
|
+
if (util.aborted(payload, seen))
|
|
1911
|
+
break;
|
|
1912
|
+
seen = payload.issues.length;
|
|
1913
|
+
}
|
|
1437
1914
|
const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
1438
1915
|
const valueResult = def.valueType._zod.run({ value: value, issues: [] }, ctx);
|
|
1439
1916
|
if (keyResult instanceof Promise || valueResult instanceof Promise) {
|
|
@@ -1449,6 +1926,7 @@ export const $ZodMap = /*@__PURE__*/ core.$constructor("$ZodMap", (inst, def) =>
|
|
|
1449
1926
|
return Promise.all(proms).then(() => payload);
|
|
1450
1927
|
return payload;
|
|
1451
1928
|
};
|
|
1929
|
+
capSize(inst, mapSize);
|
|
1452
1930
|
});
|
|
1453
1931
|
function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
|
|
1454
1932
|
if (keyResult.issues.length) {
|
|
@@ -1484,6 +1962,8 @@ function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
|
|
|
1484
1962
|
}
|
|
1485
1963
|
export const $ZodSet = /*@__PURE__*/ core.$constructor("$ZodSet", (inst, def) => {
|
|
1486
1964
|
$ZodType.init(inst, def);
|
|
1965
|
+
const memo = core.globalConfig.memoizer;
|
|
1966
|
+
memo?.attach(inst);
|
|
1487
1967
|
inst._zod.parse = (payload, ctx) => {
|
|
1488
1968
|
const input = payload.value;
|
|
1489
1969
|
if (!(input instanceof Set)) {
|
|
@@ -1496,8 +1976,15 @@ export const $ZodSet = /*@__PURE__*/ core.$constructor("$ZodSet", (inst, def) =>
|
|
|
1496
1976
|
return payload;
|
|
1497
1977
|
}
|
|
1498
1978
|
const proms = [];
|
|
1499
|
-
payload.value = new Set();
|
|
1979
|
+
payload.value = memo ? memo.alloc(inst, payload, new Set(), ctx) : new Set();
|
|
1980
|
+
const abortEarly = ctx?.abortEarly;
|
|
1981
|
+
let seen = payload.issues.length;
|
|
1500
1982
|
for (const item of input) {
|
|
1983
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
1984
|
+
if (util.aborted(payload, seen))
|
|
1985
|
+
break;
|
|
1986
|
+
seen = payload.issues.length;
|
|
1987
|
+
}
|
|
1501
1988
|
const result = def.valueType._zod.run({ value: item, issues: [] }, ctx);
|
|
1502
1989
|
if (result instanceof Promise) {
|
|
1503
1990
|
proms.push(result.then((result) => handleSetResult(result, payload)));
|
|
@@ -1509,6 +1996,7 @@ export const $ZodSet = /*@__PURE__*/ core.$constructor("$ZodSet", (inst, def) =>
|
|
|
1509
1996
|
return Promise.all(proms).then(() => payload);
|
|
1510
1997
|
return payload;
|
|
1511
1998
|
};
|
|
1999
|
+
capSize(inst, setSize);
|
|
1512
2000
|
});
|
|
1513
2001
|
function handleSetResult(result, final) {
|
|
1514
2002
|
if (result.issues.length) {
|
|
@@ -1521,10 +2009,11 @@ export const $ZodEnum = /*@__PURE__*/ core.$constructor("$ZodEnum", (inst, def)
|
|
|
1521
2009
|
const values = util.getEnumValues(def.entries);
|
|
1522
2010
|
const valuesSet = new Set(values);
|
|
1523
2011
|
inst._zod.values = valuesSet;
|
|
1524
|
-
inst
|
|
1525
|
-
.filter((k) => util.propertyKeyTypes.has(typeof k))
|
|
1526
|
-
|
|
1527
|
-
.join("|")})$`);
|
|
2012
|
+
util.defineLazyInternal(inst, "pattern", (zod) => {
|
|
2013
|
+
const patternValues = util.getEnumValues(zod.def.entries).filter((k) => util.propertyKeyTypes.has(typeof k));
|
|
2014
|
+
// unmatchable fallback, RE2-safe: an empty alternation would compile to /^()$/, which matches ""
|
|
2015
|
+
return new RegExp(patternValues.length ? `^(${patternValues.map((o) => util.escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$");
|
|
2016
|
+
});
|
|
1528
2017
|
inst._zod.parse = (payload, _ctx) => {
|
|
1529
2018
|
const input = payload.value;
|
|
1530
2019
|
if (valuesSet.has(input)) {
|
|
@@ -1541,14 +2030,17 @@ export const $ZodEnum = /*@__PURE__*/ core.$constructor("$ZodEnum", (inst, def)
|
|
|
1541
2030
|
});
|
|
1542
2031
|
export const $ZodLiteral = /*@__PURE__*/ core.$constructor("$ZodLiteral", (inst, def) => {
|
|
1543
2032
|
$ZodType.init(inst, def);
|
|
1544
|
-
if (def.values.length === 0) {
|
|
1545
|
-
throw new Error("Cannot create literal schema with no valid values");
|
|
1546
|
-
}
|
|
1547
2033
|
const values = new Set(def.values);
|
|
1548
2034
|
inst._zod.values = values;
|
|
1549
|
-
inst
|
|
1550
|
-
|
|
1551
|
-
|
|
2035
|
+
util.defineLazyInternal(inst, "pattern", (zod) => {
|
|
2036
|
+
const vals = zod.def.values;
|
|
2037
|
+
// unmatchable fallback, RE2-safe: an empty alternation would compile to /^()$/, which matches ""
|
|
2038
|
+
return new RegExp(vals.length
|
|
2039
|
+
? `^(${vals
|
|
2040
|
+
.map((o) => typeof o === "string" ? util.escapeRegex(o) : o ? util.escapeRegex(o.toString()) : String(o))
|
|
2041
|
+
.join("|")})$`
|
|
2042
|
+
: "^[^\\s\\S]$");
|
|
2043
|
+
});
|
|
1552
2044
|
inst._zod.parse = (payload, _ctx) => {
|
|
1553
2045
|
const input = payload.value;
|
|
1554
2046
|
if (values.has(input)) {
|
|
@@ -1581,6 +2073,8 @@ export const $ZodFile = /*@__PURE__*/ core.$constructor("$ZodFile", (inst, def)
|
|
|
1581
2073
|
});
|
|
1582
2074
|
export const $ZodTransform = /*@__PURE__*/ core.$constructor("$ZodTransform", (inst, def) => {
|
|
1583
2075
|
$ZodType.init(inst, def);
|
|
2076
|
+
inst._zod.optin = "optional";
|
|
2077
|
+
core.globalConfig.memoizer?.guard(inst);
|
|
1584
2078
|
inst._zod.parse = (payload, ctx) => {
|
|
1585
2079
|
if (ctx.direction === "backward") {
|
|
1586
2080
|
throw new core.$ZodEncodeError(inst.constructor.name);
|
|
@@ -1600,32 +2094,34 @@ export const $ZodTransform = /*@__PURE__*/ core.$constructor("$ZodTransform", (i
|
|
|
1600
2094
|
return payload;
|
|
1601
2095
|
};
|
|
1602
2096
|
});
|
|
1603
|
-
function handleOptionalResult(
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
return result;
|
|
2097
|
+
function handleOptionalResult(payload, result) {
|
|
2098
|
+
// 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.
|
|
2099
|
+
payload.value = result.issues.length ? undefined : result.value;
|
|
2100
|
+
return payload;
|
|
1608
2101
|
}
|
|
1609
2102
|
export const $ZodOptional = /*@__PURE__*/ core.$constructor("$ZodOptional", (inst, def) => {
|
|
1610
2103
|
$ZodType.init(inst, def);
|
|
1611
|
-
|
|
2104
|
+
// .optional() propagates absence rather than substituting for it, so a defaulted inner keeps its rung.
|
|
2105
|
+
util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
|
|
1612
2106
|
inst._zod.optout = "optional";
|
|
1613
|
-
util.
|
|
1614
|
-
|
|
2107
|
+
util.defineLazyInternal(inst, "values", (zod) => {
|
|
2108
|
+
const values = zod.def.innerType._zod.values;
|
|
2109
|
+
return values ? new Set([...values, undefined]) : undefined;
|
|
1615
2110
|
});
|
|
1616
|
-
util.
|
|
1617
|
-
const pattern = def.innerType._zod.pattern;
|
|
2111
|
+
util.defineLazyInternal(inst, "pattern", (zod) => {
|
|
2112
|
+
const pattern = zod.def.innerType._zod.pattern;
|
|
1618
2113
|
return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)})?$`) : undefined;
|
|
1619
2114
|
});
|
|
1620
2115
|
inst._zod.parse = (payload, ctx) => {
|
|
1621
|
-
if (def.innerType._zod.optin === "optional") {
|
|
1622
|
-
const result = def.innerType._zod.run(payload, ctx);
|
|
1623
|
-
if (result instanceof Promise)
|
|
1624
|
-
return result.then((r) => handleOptionalResult(r, payload.value));
|
|
1625
|
-
return handleOptionalResult(result, payload.value);
|
|
1626
|
-
}
|
|
1627
2116
|
if (payload.value === undefined) {
|
|
1628
|
-
|
|
2117
|
+
// Only the top rung substitutes a value for absence; everything else leaves it intact, which is what .optional() means.
|
|
2118
|
+
if (def.innerType._zod.optin !== "defaulted")
|
|
2119
|
+
return payload;
|
|
2120
|
+
// 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.
|
|
2121
|
+
const result = def.innerType._zod.run({ value: payload.value, issues: [] }, ctx);
|
|
2122
|
+
if (result instanceof Promise)
|
|
2123
|
+
return result.then((result) => handleOptionalResult(payload, result));
|
|
2124
|
+
return handleOptionalResult(payload, result);
|
|
1629
2125
|
}
|
|
1630
2126
|
return def.innerType._zod.run(payload, ctx);
|
|
1631
2127
|
};
|
|
@@ -1634,8 +2130,8 @@ export const $ZodExactOptional = /*@__PURE__*/ core.$constructor("$ZodExactOptio
|
|
|
1634
2130
|
// Call parent init - inherits optin/optout = "optional"
|
|
1635
2131
|
$ZodOptional.init(inst, def);
|
|
1636
2132
|
// Override values/pattern to NOT add undefined
|
|
1637
|
-
util.
|
|
1638
|
-
util.
|
|
2133
|
+
util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
2134
|
+
util.defineLazyInternal(inst, "pattern", (zod) => zod.def.innerType._zod.pattern);
|
|
1639
2135
|
// Override parse to just delegate (no undefined handling)
|
|
1640
2136
|
inst._zod.parse = (payload, ctx) => {
|
|
1641
2137
|
return def.innerType._zod.run(payload, ctx);
|
|
@@ -1643,14 +2139,14 @@ export const $ZodExactOptional = /*@__PURE__*/ core.$constructor("$ZodExactOptio
|
|
|
1643
2139
|
});
|
|
1644
2140
|
export const $ZodNullable = /*@__PURE__*/ core.$constructor("$ZodNullable", (inst, def) => {
|
|
1645
2141
|
$ZodType.init(inst, def);
|
|
1646
|
-
util.
|
|
1647
|
-
util.
|
|
1648
|
-
util.
|
|
1649
|
-
const pattern = def.innerType._zod.pattern;
|
|
2142
|
+
util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin);
|
|
2143
|
+
util.defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
|
|
2144
|
+
util.defineLazyInternal(inst, "pattern", (zod) => {
|
|
2145
|
+
const pattern = zod.def.innerType._zod.pattern;
|
|
1650
2146
|
return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)}|null)$`) : undefined;
|
|
1651
2147
|
});
|
|
1652
|
-
util.
|
|
1653
|
-
return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : undefined;
|
|
2148
|
+
util.defineLazyInternal(inst, "values", (zod) => {
|
|
2149
|
+
return zod.def.innerType._zod.values ? new Set([...zod.def.innerType._zod.values, null]) : undefined;
|
|
1654
2150
|
});
|
|
1655
2151
|
inst._zod.parse = (payload, ctx) => {
|
|
1656
2152
|
// Forward direction (decode): allow null to pass through
|
|
@@ -1662,8 +2158,8 @@ export const $ZodNullable = /*@__PURE__*/ core.$constructor("$ZodNullable", (ins
|
|
|
1662
2158
|
export const $ZodDefault = /*@__PURE__*/ core.$constructor("$ZodDefault", (inst, def) => {
|
|
1663
2159
|
$ZodType.init(inst, def);
|
|
1664
2160
|
// inst._zod.qin = "true";
|
|
1665
|
-
inst._zod.optin = "
|
|
1666
|
-
util.
|
|
2161
|
+
inst._zod.optin = "defaulted";
|
|
2162
|
+
util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
1667
2163
|
inst._zod.parse = (payload, ctx) => {
|
|
1668
2164
|
if (ctx.direction === "backward") {
|
|
1669
2165
|
return def.innerType._zod.run(payload, ctx);
|
|
@@ -1692,8 +2188,8 @@ function handleDefaultResult(payload, def) {
|
|
|
1692
2188
|
}
|
|
1693
2189
|
export const $ZodPrefault = /*@__PURE__*/ core.$constructor("$ZodPrefault", (inst, def) => {
|
|
1694
2190
|
$ZodType.init(inst, def);
|
|
1695
|
-
inst._zod.optin = "
|
|
1696
|
-
util.
|
|
2191
|
+
inst._zod.optin = "defaulted";
|
|
2192
|
+
util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
1697
2193
|
inst._zod.parse = (payload, ctx) => {
|
|
1698
2194
|
if (ctx.direction === "backward") {
|
|
1699
2195
|
return def.innerType._zod.run(payload, ctx);
|
|
@@ -1707,8 +2203,8 @@ export const $ZodPrefault = /*@__PURE__*/ core.$constructor("$ZodPrefault", (ins
|
|
|
1707
2203
|
});
|
|
1708
2204
|
export const $ZodNonOptional = /*@__PURE__*/ core.$constructor("$ZodNonOptional", (inst, def) => {
|
|
1709
2205
|
$ZodType.init(inst, def);
|
|
1710
|
-
util.
|
|
1711
|
-
const v = def.innerType._zod.values;
|
|
2206
|
+
util.defineLazyInternal(inst, "values", (zod) => {
|
|
2207
|
+
const v = zod.def.innerType._zod.values;
|
|
1712
2208
|
return v ? new Set([...v].filter((x) => x !== undefined)) : undefined;
|
|
1713
2209
|
});
|
|
1714
2210
|
inst._zod.parse = (payload, ctx) => {
|
|
@@ -1747,45 +2243,40 @@ export const $ZodSuccess = /*@__PURE__*/ core.$constructor("$ZodSuccess", (inst,
|
|
|
1747
2243
|
return payload;
|
|
1748
2244
|
};
|
|
1749
2245
|
});
|
|
2246
|
+
function handleCatchResult(payload, result, def, ctx) {
|
|
2247
|
+
if (!result.issues.length) {
|
|
2248
|
+
payload.value = result.value;
|
|
2249
|
+
// 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.
|
|
2250
|
+
if (result.memo)
|
|
2251
|
+
payload.memo = true;
|
|
2252
|
+
return payload;
|
|
2253
|
+
}
|
|
2254
|
+
// 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.
|
|
2255
|
+
payload.value = def.catchValue({
|
|
2256
|
+
...result,
|
|
2257
|
+
value: payload.value,
|
|
2258
|
+
error: {
|
|
2259
|
+
issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
|
2260
|
+
},
|
|
2261
|
+
input: payload.value,
|
|
2262
|
+
});
|
|
2263
|
+
return payload;
|
|
2264
|
+
}
|
|
1750
2265
|
export const $ZodCatch = /*@__PURE__*/ core.$constructor("$ZodCatch", (inst, def) => {
|
|
1751
2266
|
$ZodType.init(inst, def);
|
|
1752
|
-
util.
|
|
1753
|
-
util.
|
|
1754
|
-
util.
|
|
2267
|
+
util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
|
|
2268
|
+
util.defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
|
|
2269
|
+
util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
1755
2270
|
inst._zod.parse = (payload, ctx) => {
|
|
1756
2271
|
if (ctx.direction === "backward") {
|
|
1757
2272
|
return def.innerType._zod.run(payload, ctx);
|
|
1758
2273
|
}
|
|
1759
2274
|
// Forward direction (decode): apply catch logic
|
|
1760
|
-
const result = def.innerType._zod.run(payload, ctx);
|
|
2275
|
+
const result = def.innerType._zod.run({ value: payload.value, issues: [] }, ctx);
|
|
1761
2276
|
if (result instanceof Promise) {
|
|
1762
|
-
return result.then((result) =>
|
|
1763
|
-
payload.value = result.value;
|
|
1764
|
-
if (result.issues.length) {
|
|
1765
|
-
payload.value = def.catchValue({
|
|
1766
|
-
...payload,
|
|
1767
|
-
error: {
|
|
1768
|
-
issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
|
1769
|
-
},
|
|
1770
|
-
input: payload.value,
|
|
1771
|
-
});
|
|
1772
|
-
payload.issues = [];
|
|
1773
|
-
}
|
|
1774
|
-
return payload;
|
|
1775
|
-
});
|
|
2277
|
+
return result.then((result) => handleCatchResult(payload, result, def, ctx));
|
|
1776
2278
|
}
|
|
1777
|
-
payload
|
|
1778
|
-
if (result.issues.length) {
|
|
1779
|
-
payload.value = def.catchValue({
|
|
1780
|
-
...payload,
|
|
1781
|
-
error: {
|
|
1782
|
-
issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
|
1783
|
-
},
|
|
1784
|
-
input: payload.value,
|
|
1785
|
-
});
|
|
1786
|
-
payload.issues = [];
|
|
1787
|
-
}
|
|
1788
|
-
return payload;
|
|
2279
|
+
return handleCatchResult(payload, result, def, ctx);
|
|
1789
2280
|
};
|
|
1790
2281
|
});
|
|
1791
2282
|
export const $ZodNaN = /*@__PURE__*/ core.$constructor("$ZodNaN", (inst, def) => {
|
|
@@ -1805,10 +2296,10 @@ export const $ZodNaN = /*@__PURE__*/ core.$constructor("$ZodNaN", (inst, def) =>
|
|
|
1805
2296
|
});
|
|
1806
2297
|
export const $ZodPipe = /*@__PURE__*/ core.$constructor("$ZodPipe", (inst, def) => {
|
|
1807
2298
|
$ZodType.init(inst, def);
|
|
1808
|
-
util.
|
|
1809
|
-
util.
|
|
1810
|
-
util.
|
|
1811
|
-
util.
|
|
2299
|
+
util.defineLazyInternal(inst, "values", (zod) => zod.def.in._zod.values);
|
|
2300
|
+
util.defineLazyInternal(inst, "optin", (zod) => zod.def.in._zod.optin);
|
|
2301
|
+
util.defineLazyInternal(inst, "optout", (zod) => zod.def.out._zod.optout);
|
|
2302
|
+
util.defineLazyInternal(inst, "propValues", (zod) => zod.def.in._zod.propValues);
|
|
1812
2303
|
inst._zod.parse = (payload, ctx) => {
|
|
1813
2304
|
if (ctx.direction === "backward") {
|
|
1814
2305
|
const right = def.out._zod.run(payload, ctx);
|
|
@@ -1825,7 +2316,8 @@ export const $ZodPipe = /*@__PURE__*/ core.$constructor("$ZodPipe", (inst, def)
|
|
|
1825
2316
|
};
|
|
1826
2317
|
});
|
|
1827
2318
|
function handlePipeResult(left, next, ctx) {
|
|
1828
|
-
|
|
2319
|
+
// 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.
|
|
2320
|
+
if (left.issues.some((iss) => iss.code !== "unrecognized_keys")) {
|
|
1829
2321
|
// prevent further checks
|
|
1830
2322
|
left.aborted = true;
|
|
1831
2323
|
return left;
|
|
@@ -1834,10 +2326,10 @@ function handlePipeResult(left, next, ctx) {
|
|
|
1834
2326
|
}
|
|
1835
2327
|
export const $ZodCodec = /*@__PURE__*/ core.$constructor("$ZodCodec", (inst, def) => {
|
|
1836
2328
|
$ZodType.init(inst, def);
|
|
1837
|
-
util.
|
|
1838
|
-
util.
|
|
1839
|
-
util.
|
|
1840
|
-
util.
|
|
2329
|
+
util.defineLazyInternal(inst, "values", (zod) => zod.def.in._zod.values);
|
|
2330
|
+
util.defineLazyInternal(inst, "optin", (zod) => zod.def.in._zod.optin);
|
|
2331
|
+
util.defineLazyInternal(inst, "optout", (zod) => zod.def.out._zod.optout);
|
|
2332
|
+
util.defineLazyInternal(inst, "propValues", (zod) => zod.def.in._zod.propValues);
|
|
1841
2333
|
inst._zod.parse = (payload, ctx) => {
|
|
1842
2334
|
const direction = ctx.direction || "forward";
|
|
1843
2335
|
if (direction === "forward") {
|
|
@@ -1886,12 +2378,15 @@ function handleCodecTxResult(left, value, nextSchema, ctx) {
|
|
|
1886
2378
|
}
|
|
1887
2379
|
return nextSchema._zod.run({ value, issues: left.issues }, ctx);
|
|
1888
2380
|
}
|
|
2381
|
+
export const $ZodPreprocess = /*@__PURE__*/ core.$constructor("$ZodPreprocess", (inst, def) => {
|
|
2382
|
+
$ZodPipe.init(inst, def);
|
|
2383
|
+
});
|
|
1889
2384
|
export const $ZodReadonly = /*@__PURE__*/ core.$constructor("$ZodReadonly", (inst, def) => {
|
|
1890
2385
|
$ZodType.init(inst, def);
|
|
1891
|
-
util.
|
|
1892
|
-
util.
|
|
1893
|
-
util.
|
|
1894
|
-
util.
|
|
2386
|
+
util.defineLazyInternal(inst, "propValues", (zod) => zod.def.innerType._zod.propValues);
|
|
2387
|
+
util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
2388
|
+
util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType?._zod?.optin);
|
|
2389
|
+
util.defineLazyInternal(inst, "optout", (zod) => zod.def.innerType?._zod?.optout);
|
|
1895
2390
|
inst._zod.parse = (payload, ctx) => {
|
|
1896
2391
|
if (ctx.direction === "backward") {
|
|
1897
2392
|
return def.innerType._zod.run(payload, ctx);
|
|
@@ -1904,25 +2399,72 @@ export const $ZodReadonly = /*@__PURE__*/ core.$constructor("$ZodReadonly", (ins
|
|
|
1904
2399
|
};
|
|
1905
2400
|
});
|
|
1906
2401
|
function handleReadonlyResult(payload) {
|
|
1907
|
-
|
|
2402
|
+
// 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.
|
|
2403
|
+
if (!payload.memo)
|
|
2404
|
+
payload.value = Object.freeze(payload.value);
|
|
1908
2405
|
return payload;
|
|
1909
2406
|
}
|
|
2407
|
+
// 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
|
|
2408
|
+
function leafPattern(schema) {
|
|
2409
|
+
const def = schema._zod.def;
|
|
2410
|
+
let pattern = def.pattern;
|
|
2411
|
+
let isInt = !!def.format?.includes("int");
|
|
2412
|
+
let minimum;
|
|
2413
|
+
let maximum;
|
|
2414
|
+
for (const ch of def.checks ?? []) {
|
|
2415
|
+
const d = ch._zod.def;
|
|
2416
|
+
if (d.pattern)
|
|
2417
|
+
pattern = d.pattern;
|
|
2418
|
+
isInt || (isInt = !!d.format?.includes("int"));
|
|
2419
|
+
const lo = d.minimum ?? d.length;
|
|
2420
|
+
const hi = d.maximum ?? d.length;
|
|
2421
|
+
if (lo !== undefined && (minimum === undefined || lo > minimum))
|
|
2422
|
+
minimum = lo;
|
|
2423
|
+
if (hi !== undefined && (maximum === undefined || hi < maximum))
|
|
2424
|
+
maximum = hi;
|
|
2425
|
+
}
|
|
2426
|
+
if (pattern)
|
|
2427
|
+
return pattern.source;
|
|
2428
|
+
// an empty range matches nothing at runtime, and `{8,5}` is not a legal quantifier
|
|
2429
|
+
if (minimum !== undefined && maximum !== undefined && minimum > maximum)
|
|
2430
|
+
return "(?!)";
|
|
2431
|
+
if (minimum !== undefined || maximum !== undefined)
|
|
2432
|
+
return regexes.string({ minimum, maximum }).source;
|
|
2433
|
+
const own = schema._zod.pattern;
|
|
2434
|
+
return (isInt && own === regexes.number ? regexes.integer : own)?.source;
|
|
2435
|
+
}
|
|
2436
|
+
// 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
|
|
2437
|
+
function partPattern(schema) {
|
|
2438
|
+
const def = schema._zod.def;
|
|
2439
|
+
const own = schema._zod.pattern?.source;
|
|
2440
|
+
// lazy resolves its inner on the internals, not the def
|
|
2441
|
+
const inner = def.innerType ?? schema._zod.innerType;
|
|
2442
|
+
if (inner) {
|
|
2443
|
+
const before = inner._zod.pattern?.source;
|
|
2444
|
+
const after = partPattern(inner);
|
|
2445
|
+
if (own && before && after && after !== before) {
|
|
2446
|
+
return own.replace(util.cleanRegex(before), () => util.cleanRegex(after));
|
|
2447
|
+
}
|
|
2448
|
+
return own;
|
|
2449
|
+
}
|
|
2450
|
+
if (def.options) {
|
|
2451
|
+
const sources = def.options.map(partPattern);
|
|
2452
|
+
if (sources.every(Boolean))
|
|
2453
|
+
return `^(${sources.map((s) => util.cleanRegex(s)).join("|")})$`;
|
|
2454
|
+
}
|
|
2455
|
+
return leafPattern(schema);
|
|
2456
|
+
}
|
|
1910
2457
|
export const $ZodTemplateLiteral = /*@__PURE__*/ core.$constructor("$ZodTemplateLiteral", (inst, def) => {
|
|
1911
2458
|
$ZodType.init(inst, def);
|
|
1912
2459
|
const regexParts = [];
|
|
1913
2460
|
for (const part of def.parts) {
|
|
1914
2461
|
if (typeof part === "object" && part !== null) {
|
|
1915
2462
|
// is Zod schema
|
|
1916
|
-
|
|
1917
|
-
|
|
2463
|
+
const source = partPattern(part);
|
|
2464
|
+
if (!source) {
|
|
1918
2465
|
throw new Error(`Invalid template literal part, no pattern found: ${[...part._zod.traits].shift()}`);
|
|
1919
2466
|
}
|
|
1920
|
-
|
|
1921
|
-
if (!source)
|
|
1922
|
-
throw new Error(`Invalid template literal part: ${part._zod.traits}`);
|
|
1923
|
-
const start = source.startsWith("^") ? 1 : 0;
|
|
1924
|
-
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
1925
|
-
regexParts.push(source.slice(start, end));
|
|
2467
|
+
regexParts.push(util.cleanRegex(source));
|
|
1926
2468
|
}
|
|
1927
2469
|
else if (part === null || util.primitiveTypes.has(typeof part)) {
|
|
1928
2470
|
regexParts.push(util.escapeRegex(`${part}`));
|
|
@@ -1958,33 +2500,35 @@ export const $ZodTemplateLiteral = /*@__PURE__*/ core.$constructor("$ZodTemplate
|
|
|
1958
2500
|
});
|
|
1959
2501
|
export const $ZodFunction = /*@__PURE__*/ core.$constructor("$ZodFunction", (inst, def) => {
|
|
1960
2502
|
$ZodType.init(inst, def);
|
|
1961
|
-
|
|
2503
|
+
// Defined, not assigned: the classic prototype exposes `_def` as a getter with no setter.
|
|
2504
|
+
Object.defineProperty(inst, "_def", { value: def });
|
|
1962
2505
|
inst._zod.def = def;
|
|
1963
2506
|
inst.implement = (func) => {
|
|
1964
2507
|
if (typeof func !== "function") {
|
|
1965
2508
|
throw new Error("implement() must be called with a function");
|
|
1966
2509
|
}
|
|
1967
|
-
|
|
2510
|
+
// Defined inline so the closure stays anonymous: binding it to a `const` first names it, which costs 256 bytes per implemented function.
|
|
2511
|
+
return Object.defineProperty(function (...args) {
|
|
1968
2512
|
const parsedArgs = inst._def.input ? parse(inst._def.input, args) : args;
|
|
1969
2513
|
const result = Reflect.apply(func, this, parsedArgs);
|
|
1970
2514
|
if (inst._def.output) {
|
|
1971
2515
|
return parse(inst._def.output, result);
|
|
1972
2516
|
}
|
|
1973
2517
|
return result;
|
|
1974
|
-
};
|
|
2518
|
+
}, "_zod", { value: inst._zod, enumerable: false });
|
|
1975
2519
|
};
|
|
1976
2520
|
inst.implementAsync = (func) => {
|
|
1977
2521
|
if (typeof func !== "function") {
|
|
1978
2522
|
throw new Error("implementAsync() must be called with a function");
|
|
1979
2523
|
}
|
|
1980
|
-
return async function (...args) {
|
|
2524
|
+
return Object.defineProperty(async function (...args) {
|
|
1981
2525
|
const parsedArgs = inst._def.input ? await parseAsync(inst._def.input, args) : args;
|
|
1982
2526
|
const result = await Reflect.apply(func, this, parsedArgs);
|
|
1983
2527
|
if (inst._def.output) {
|
|
1984
2528
|
return await parseAsync(inst._def.output, result);
|
|
1985
2529
|
}
|
|
1986
2530
|
return result;
|
|
1987
|
-
};
|
|
2531
|
+
}, "_zod", { value: inst._zod, enumerable: false });
|
|
1988
2532
|
};
|
|
1989
2533
|
inst._zod.parse = (payload, _ctx) => {
|
|
1990
2534
|
if (typeof payload.value !== "function") {
|
|
@@ -2043,18 +2587,17 @@ export const $ZodPromise = /*@__PURE__*/ core.$constructor("$ZodPromise", (inst,
|
|
|
2043
2587
|
});
|
|
2044
2588
|
export const $ZodLazy = /*@__PURE__*/ core.$constructor("$ZodLazy", (inst, def) => {
|
|
2045
2589
|
$ZodType.init(inst, def);
|
|
2046
|
-
//
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
util.
|
|
2054
|
-
util.
|
|
2055
|
-
util.
|
|
2056
|
-
util.
|
|
2057
|
-
util.defineLazy(inst._zod, "optout", () => inst._zod.innerType?._zod?.optout ?? undefined);
|
|
2590
|
+
// 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.
|
|
2591
|
+
util.defineLazy(inst._zod, "innerType", () => {
|
|
2592
|
+
const d = def;
|
|
2593
|
+
if (!d._cachedInner)
|
|
2594
|
+
d._cachedInner = def.getter();
|
|
2595
|
+
return d._cachedInner;
|
|
2596
|
+
});
|
|
2597
|
+
util.defineLazyInternal(inst, "pattern", (zod) => zod.innerType?._zod?.pattern);
|
|
2598
|
+
util.defineLazyInternal(inst, "propValues", (zod) => zod.innerType?._zod?.propValues);
|
|
2599
|
+
util.defineLazyInternal(inst, "optin", (zod) => zod.innerType?._zod?.optin ?? undefined);
|
|
2600
|
+
util.defineLazyInternal(inst, "optout", (zod) => zod.innerType?._zod?.optout ?? undefined);
|
|
2058
2601
|
inst._zod.parse = (payload, ctx) => {
|
|
2059
2602
|
const inner = inst._zod.innerType;
|
|
2060
2603
|
return inner._zod.run(payload, ctx);
|