@willaimg/yatsp 4.3.6
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/README.md +22 -0
- package/compile.cjs +96 -0
- package/compile.d.cts +1 -0
- package/compile.d.ts +1 -0
- package/compile.js +52 -0
- package/index.cjs +52 -0
- package/index.d.cts +3 -0
- package/index.d.ts +3 -0
- package/index.js +7 -0
- package/locales/index.cjs +36 -0
- package/locales/index.d.cts +1 -0
- package/locales/index.d.ts +1 -0
- package/locales/index.js +1 -0
- package/mini/index.cjs +51 -0
- package/mini/index.d.cts +3 -0
- package/mini/index.d.ts +3 -0
- package/mini/index.js +3 -0
- package/package.json +142 -0
- package/src/compile.ts +56 -0
- package/src/index.ts +7 -0
- package/src/locales/index.ts +1 -0
- package/src/mini/index.ts +3 -0
- package/src/v3/YatspError.ts +340 -0
- package/src/v3/benchmarks/datetime.ts +58 -0
- package/src/v3/benchmarks/discriminatedUnion.ts +80 -0
- package/src/v3/benchmarks/index.ts +59 -0
- package/src/v3/benchmarks/ipv4.ts +57 -0
- package/src/v3/benchmarks/object.ts +69 -0
- package/src/v3/benchmarks/primitives.ts +162 -0
- package/src/v3/benchmarks/realworld.ts +63 -0
- package/src/v3/benchmarks/string.ts +55 -0
- package/src/v3/benchmarks/union.ts +80 -0
- package/src/v3/errors.ts +13 -0
- package/src/v3/external.ts +6 -0
- package/src/v3/helpers/enumUtil.ts +17 -0
- package/src/v3/helpers/errorUtil.ts +8 -0
- package/src/v3/helpers/parseUtil.ts +176 -0
- package/src/v3/helpers/partialUtil.ts +34 -0
- package/src/v3/helpers/typeAliases.ts +2 -0
- package/src/v3/helpers/util.ts +224 -0
- package/src/v3/index.ts +4 -0
- package/src/v3/locales/en.ts +124 -0
- package/src/v3/standard-schema.ts +113 -0
- package/src/v3/tests/Mocker.ts +54 -0
- package/src/v3/tests/all-errors.test.ts +157 -0
- package/src/v3/tests/anyunknown.test.ts +28 -0
- package/src/v3/tests/array.test.ts +71 -0
- package/src/v3/tests/async-parsing.test.ts +388 -0
- package/src/v3/tests/async-refinements.test.ts +46 -0
- package/src/v3/tests/base.test.ts +29 -0
- package/src/v3/tests/bigint.test.ts +55 -0
- package/src/v3/tests/branded.test.ts +53 -0
- package/src/v3/tests/catch.test.ts +220 -0
- package/src/v3/tests/coerce.test.ts +133 -0
- package/src/v3/tests/complex.test.ts +70 -0
- package/src/v3/tests/custom.test.ts +31 -0
- package/src/v3/tests/date.test.ts +32 -0
- package/src/v3/tests/deepmasking.test.ts +186 -0
- package/src/v3/tests/default.test.ts +112 -0
- package/src/v3/tests/description.test.ts +33 -0
- package/src/v3/tests/discriminated-unions.test.ts +315 -0
- package/src/v3/tests/enum.test.ts +80 -0
- package/src/v3/tests/error.test.ts +586 -0
- package/src/v3/tests/firstparty.test.ts +87 -0
- package/src/v3/tests/firstpartyschematypes.test.ts +21 -0
- package/src/v3/tests/function.test.ts +261 -0
- package/src/v3/tests/generics.test.ts +48 -0
- package/src/v3/tests/instanceof.test.ts +37 -0
- package/src/v3/tests/intersection.test.ts +128 -0
- package/src/v3/tests/language-server.source.ts +76 -0
- package/src/v3/tests/language-server.test.ts +206 -0
- package/src/v3/tests/literal.test.ts +36 -0
- package/src/v3/tests/map.test.ts +110 -0
- package/src/v3/tests/masking.test.ts +4 -0
- package/src/v3/tests/mocker.test.ts +19 -0
- package/src/v3/tests/nan.test.ts +24 -0
- package/src/v3/tests/nativeEnum.test.ts +87 -0
- package/src/v3/tests/nullable.test.ts +42 -0
- package/src/v3/tests/number.test.ts +176 -0
- package/src/v3/tests/object-augmentation.test.ts +29 -0
- package/src/v3/tests/object-in-es5-env.test.ts +29 -0
- package/src/v3/tests/object.test.ts +431 -0
- package/src/v3/tests/optional.test.ts +42 -0
- package/src/v3/tests/parseUtil.test.ts +23 -0
- package/src/v3/tests/parser.test.ts +41 -0
- package/src/v3/tests/partials.test.ts +243 -0
- package/src/v3/tests/pickomit.test.ts +111 -0
- package/src/v3/tests/pipeline.test.ts +29 -0
- package/src/v3/tests/preprocess.test.ts +186 -0
- package/src/v3/tests/primitive.test.ts +440 -0
- package/src/v3/tests/promise.test.ts +90 -0
- package/src/v3/tests/readonly.test.ts +114 -0
- package/src/v3/tests/record.test.ts +171 -0
- package/src/v3/tests/recursive.test.ts +197 -0
- package/src/v3/tests/refine.test.ts +313 -0
- package/src/v3/tests/safeparse.test.ts +27 -0
- package/src/v3/tests/set.test.ts +142 -0
- package/src/v3/tests/standard-schema.test.ts +83 -0
- package/src/v3/tests/string.test.ts +922 -0
- package/src/v3/tests/transformer.test.ts +233 -0
- package/src/v3/tests/tuple.test.ts +90 -0
- package/src/v3/tests/unions.test.ts +57 -0
- package/src/v3/tests/validations.test.ts +133 -0
- package/src/v3/tests/void.test.ts +15 -0
- package/src/v3/types.ts +5162 -0
- package/src/v4/classic/checks.ts +33 -0
- package/src/v4/classic/coerce.ts +27 -0
- package/src/v4/classic/compat.ts +78 -0
- package/src/v4/classic/deep-partial.ts +76 -0
- package/src/v4/classic/errors.ts +97 -0
- package/src/v4/classic/external.ts +57 -0
- package/src/v4/classic/from-json-schema.ts +944 -0
- package/src/v4/classic/in-out.ts +45 -0
- package/src/v4/classic/index.ts +5 -0
- package/src/v4/classic/iso.ts +20 -0
- package/src/v4/classic/parse.ts +88 -0
- package/src/v4/classic/schemas.ts +2994 -0
- package/src/v4/classic/tests/anyunknown.test.ts +26 -0
- package/src/v4/classic/tests/apply.test.ts +86 -0
- package/src/v4/classic/tests/array.test.ts +264 -0
- package/src/v4/classic/tests/assignability.test.ts +402 -0
- package/src/v4/classic/tests/async-parsing.test.ts +381 -0
- package/src/v4/classic/tests/async-refinements.test.ts +68 -0
- package/src/v4/classic/tests/base.test.ts +7 -0
- package/src/v4/classic/tests/bigint.test.ts +89 -0
- package/src/v4/classic/tests/brand.test.ts +106 -0
- package/src/v4/classic/tests/catch.test.ts +604 -0
- package/src/v4/classic/tests/coalesce.test.ts +20 -0
- package/src/v4/classic/tests/codec-examples.test.ts +572 -0
- package/src/v4/classic/tests/codec.test.ts +704 -0
- package/src/v4/classic/tests/coerce.test.ts +160 -0
- package/src/v4/classic/tests/continuability.test.ts +374 -0
- package/src/v4/classic/tests/credit-card.test.ts +76 -0
- package/src/v4/classic/tests/custom.test.ts +40 -0
- package/src/v4/classic/tests/cyclic-data.test.ts +985 -0
- package/src/v4/classic/tests/date.test.ts +92 -0
- package/src/v4/classic/tests/datetime.test.ts +316 -0
- package/src/v4/classic/tests/deep-partial.test.ts +380 -0
- package/src/v4/classic/tests/default-locale.test.ts +32 -0
- package/src/v4/classic/tests/default.test.ts +455 -0
- package/src/v4/classic/tests/describe-meta-checks.test.ts +27 -0
- package/src/v4/classic/tests/description.test.ts +32 -0
- package/src/v4/classic/tests/detached-methods.test.ts +226 -0
- package/src/v4/classic/tests/discriminated-unions.test.ts +942 -0
- package/src/v4/classic/tests/enum.test.ts +305 -0
- package/src/v4/classic/tests/error-utils.test.ts +917 -0
- package/src/v4/classic/tests/error.test.ts +1108 -0
- package/src/v4/classic/tests/file.test.ts +96 -0
- package/src/v4/classic/tests/firstparty.test.ts +179 -0
- package/src/v4/classic/tests/fix-json-issue.test.ts +26 -0
- package/src/v4/classic/tests/from-json-schema.test.ts +1467 -0
- package/src/v4/classic/tests/function.test.ts +391 -0
- package/src/v4/classic/tests/generics.test.ts +72 -0
- package/src/v4/classic/tests/global-config.test.ts +32 -0
- package/src/v4/classic/tests/hash.test.ts +67 -0
- package/src/v4/classic/tests/iban.test.ts +81 -0
- package/src/v4/classic/tests/in-out.test.ts +159 -0
- package/src/v4/classic/tests/index.test.ts +958 -0
- package/src/v4/classic/tests/instance-footprint.test.ts +319 -0
- package/src/v4/classic/tests/instanceof.test.ts +127 -0
- package/src/v4/classic/tests/intersection.test.ts +334 -0
- package/src/v4/classic/tests/issue-schema.test.ts +215 -0
- package/src/v4/classic/tests/jitless-allows-eval.test.ts +39 -0
- package/src/v4/classic/tests/json.test.ts +109 -0
- package/src/v4/classic/tests/lazy.test.ts +262 -0
- package/src/v4/classic/tests/literal.test.ts +128 -0
- package/src/v4/classic/tests/locales_ka.test.ts +29 -0
- package/src/v4/classic/tests/locales_ro.test.ts +24 -0
- package/src/v4/classic/tests/map.test.ts +342 -0
- package/src/v4/classic/tests/nan.test.ts +21 -0
- package/src/v4/classic/tests/nested-refine.test.ts +168 -0
- package/src/v4/classic/tests/nonoptional.test.ts +101 -0
- package/src/v4/classic/tests/nullable.test.ts +22 -0
- package/src/v4/classic/tests/number.test.ts +401 -0
- package/src/v4/classic/tests/object.test.ts +1006 -0
- package/src/v4/classic/tests/optin-ladder.test.ts +235 -0
- package/src/v4/classic/tests/optional.test.ts +366 -0
- package/src/v4/classic/tests/partial.test.ts +497 -0
- package/src/v4/classic/tests/pickomit.test.ts +211 -0
- package/src/v4/classic/tests/pipe.test.ts +101 -0
- package/src/v4/classic/tests/prefault.test.ts +144 -0
- package/src/v4/classic/tests/preprocess-types.test.ts +44 -0
- package/src/v4/classic/tests/preprocess.test.ts +351 -0
- package/src/v4/classic/tests/primitive.test.ts +175 -0
- package/src/v4/classic/tests/promise.test.ts +81 -0
- package/src/v4/classic/tests/properties.test.ts +141 -0
- package/src/v4/classic/tests/prototypes.test.ts +23 -0
- package/src/v4/classic/tests/readonly.test.ts +184 -0
- package/src/v4/classic/tests/record.test.ts +885 -0
- package/src/v4/classic/tests/recursive-types.test.ts +707 -0
- package/src/v4/classic/tests/redos.test.ts +68 -0
- package/src/v4/classic/tests/refine.test.ts +693 -0
- package/src/v4/classic/tests/registries.test.ts +243 -0
- package/src/v4/classic/tests/set.test.ts +190 -0
- package/src/v4/classic/tests/standard-schema.test.ts +153 -0
- package/src/v4/classic/tests/string-formats.test.ts +125 -0
- package/src/v4/classic/tests/string.test.ts +1440 -0
- package/src/v4/classic/tests/stringbool.test.ts +124 -0
- package/src/v4/classic/tests/template-literal.test.ts +814 -0
- package/src/v4/classic/tests/to-json-schema-methods.test.ts +438 -0
- package/src/v4/classic/tests/to-json-schema.test.ts +4733 -0
- package/src/v4/classic/tests/transform.test.ts +378 -0
- package/src/v4/classic/tests/tuple.test.ts +511 -0
- package/src/v4/classic/tests/union.test.ts +310 -0
- package/src/v4/classic/tests/url.test.ts +13 -0
- package/src/v4/classic/tests/validate.test.ts +645 -0
- package/src/v4/classic/tests/validations.test.ts +283 -0
- package/src/v4/classic/tests/void.test.ts +12 -0
- package/src/v4/core/api.ts +1913 -0
- package/src/v4/core/checks.ts +1274 -0
- package/src/v4/core/compile.ts +2315 -0
- package/src/v4/core/core.ts +230 -0
- package/src/v4/core/doc.ts +52 -0
- package/src/v4/core/errors.ts +546 -0
- package/src/v4/core/index.ts +19 -0
- package/src/v4/core/json-schema-generator.ts +131 -0
- package/src/v4/core/json-schema-processors.ts +934 -0
- package/src/v4/core/json-schema.ts +148 -0
- package/src/v4/core/memoizer.ts +331 -0
- package/src/v4/core/parse.ts +309 -0
- package/src/v4/core/regexes.ts +217 -0
- package/src/v4/core/registries.ts +109 -0
- package/src/v4/core/schemas.ts +5295 -0
- package/src/v4/core/standard-schema.ts +159 -0
- package/src/v4/core/tests/cached.test.ts +54 -0
- package/src/v4/core/tests/compile-differential.test.ts +1004 -0
- package/src/v4/core/tests/compile-generative.test.ts +445 -0
- package/src/v4/core/tests/compile-global.test.ts +89 -0
- package/src/v4/core/tests/compile-off-by-default.test.ts +26 -0
- package/src/v4/core/tests/compile-stats.test.ts +34 -0
- package/src/v4/core/tests/compile.test.ts +2040 -0
- package/src/v4/core/tests/email-regex.test.ts +140 -0
- package/src/v4/core/tests/extend.test.ts +59 -0
- package/src/v4/core/tests/index.test.ts +46 -0
- package/src/v4/core/tests/locales/be.test.ts +124 -0
- package/src/v4/core/tests/locales/el.test.ts +214 -0
- package/src/v4/core/tests/locales/en.test.ts +22 -0
- package/src/v4/core/tests/locales/es.test.ts +180 -0
- package/src/v4/core/tests/locales/fr.test.ts +72 -0
- package/src/v4/core/tests/locales/he.test.ts +379 -0
- package/src/v4/core/tests/locales/hr.test.ts +163 -0
- package/src/v4/core/tests/locales/nl.test.ts +46 -0
- package/src/v4/core/tests/locales/parity.test.ts +42 -0
- package/src/v4/core/tests/locales/ru.test.ts +128 -0
- package/src/v4/core/tests/locales/tg.test.ts +85 -0
- package/src/v4/core/tests/locales/tk.test.ts +69 -0
- package/src/v4/core/tests/locales/tr.test.ts +69 -0
- package/src/v4/core/tests/locales/uz.test.ts +105 -0
- package/src/v4/core/tests/polyfill-collision.test.ts +46 -0
- package/src/v4/core/tests/record-constructor.test.ts +125 -0
- package/src/v4/core/tests/recursive-tuples.test.ts +45 -0
- package/src/v4/core/tests/treeshake.test.ts +51 -0
- package/src/v4/core/tests/url-no-canparse.test.ts +133 -0
- package/src/v4/core/to-json-schema.ts +857 -0
- package/src/v4/core/util.ts +1284 -0
- package/src/v4/core/versions.ts +5 -0
- package/src/v4/core/visit.ts +193 -0
- package/src/v4/core/zsf.ts +323 -0
- package/src/v4/index.ts +4 -0
- package/src/v4/locales/ar.ts +120 -0
- package/src/v4/locales/az.ts +116 -0
- package/src/v4/locales/be.ts +188 -0
- package/src/v4/locales/bg.ts +133 -0
- package/src/v4/locales/bn.ts +123 -0
- package/src/v4/locales/ca.ts +121 -0
- package/src/v4/locales/ckb.ts +140 -0
- package/src/v4/locales/cs.ts +123 -0
- package/src/v4/locales/da.ts +128 -0
- package/src/v4/locales/de.ts +121 -0
- package/src/v4/locales/el.ts +124 -0
- package/src/v4/locales/en.ts +136 -0
- package/src/v4/locales/eo.ts +123 -0
- package/src/v4/locales/es.ts +145 -0
- package/src/v4/locales/fa.ts +131 -0
- package/src/v4/locales/fi.ts +126 -0
- package/src/v4/locales/fr-CA.ts +121 -0
- package/src/v4/locales/fr.ts +139 -0
- package/src/v4/locales/gu.ts +123 -0
- package/src/v4/locales/he.ts +253 -0
- package/src/v4/locales/hi.ts +126 -0
- package/src/v4/locales/hr.ts +135 -0
- package/src/v4/locales/hu.ts +122 -0
- package/src/v4/locales/hy.ts +175 -0
- package/src/v4/locales/id.ts +120 -0
- package/src/v4/locales/index.ts +63 -0
- package/src/v4/locales/is.ts +124 -0
- package/src/v4/locales/it.ts +121 -0
- package/src/v4/locales/ja.ts +119 -0
- package/src/v4/locales/ka.ts +128 -0
- package/src/v4/locales/kh.ts +7 -0
- package/src/v4/locales/km.ts +124 -0
- package/src/v4/locales/kn.ts +126 -0
- package/src/v4/locales/ko.ts +126 -0
- package/src/v4/locales/lt.ts +243 -0
- package/src/v4/locales/mk.ts +123 -0
- package/src/v4/locales/ms.ts +120 -0
- package/src/v4/locales/ne.ts +128 -0
- package/src/v4/locales/nl.ts +126 -0
- package/src/v4/locales/nn.ts +121 -0
- package/src/v4/locales/no.ts +121 -0
- package/src/v4/locales/ota.ts +122 -0
- package/src/v4/locales/pl.ts +123 -0
- package/src/v4/locales/ps.ts +131 -0
- package/src/v4/locales/pt-BR.ts +161 -0
- package/src/v4/locales/pt.ts +159 -0
- package/src/v4/locales/ro.ts +132 -0
- package/src/v4/locales/ru.ts +188 -0
- package/src/v4/locales/sk.ts +123 -0
- package/src/v4/locales/sl.ts +123 -0
- package/src/v4/locales/sv.ts +124 -0
- package/src/v4/locales/ta.ts +123 -0
- package/src/v4/locales/tg.ts +135 -0
- package/src/v4/locales/th.ts +124 -0
- package/src/v4/locales/tk.ts +113 -0
- package/src/v4/locales/tr.ts +116 -0
- package/src/v4/locales/ua.ts +7 -0
- package/src/v4/locales/uk.ts +122 -0
- package/src/v4/locales/ur.ts +124 -0
- package/src/v4/locales/uz.ts +120 -0
- package/src/v4/locales/vi.ts +122 -0
- package/src/v4/locales/yo.ts +129 -0
- package/src/v4/locales/zh-CN.ts +121 -0
- package/src/v4/locales/zh-TW.ts +120 -0
- package/src/v4/mini/checks.ts +33 -0
- package/src/v4/mini/coerce.ts +27 -0
- package/src/v4/mini/deep-partial.ts +73 -0
- package/src/v4/mini/external.ts +52 -0
- package/src/v4/mini/in-out.ts +45 -0
- package/src/v4/mini/index.ts +3 -0
- package/src/v4/mini/iso.ts +66 -0
- package/src/v4/mini/parse.ts +16 -0
- package/src/v4/mini/schemas.ts +2093 -0
- package/src/v4/mini/tests/apply.test.ts +57 -0
- package/src/v4/mini/tests/assignability.test.ts +190 -0
- package/src/v4/mini/tests/brand.test.ts +94 -0
- package/src/v4/mini/tests/checks.test.ts +158 -0
- package/src/v4/mini/tests/codec.test.ts +582 -0
- package/src/v4/mini/tests/computed.test.ts +30 -0
- package/src/v4/mini/tests/cyclic-data.test.ts +84 -0
- package/src/v4/mini/tests/deep-partial.test.ts +54 -0
- package/src/v4/mini/tests/error.test.ts +41 -0
- package/src/v4/mini/tests/functions.test.ts +14 -0
- package/src/v4/mini/tests/index.test.ts +1148 -0
- package/src/v4/mini/tests/number.test.ts +109 -0
- package/src/v4/mini/tests/object.test.ts +292 -0
- package/src/v4/mini/tests/prototypes.test.ts +43 -0
- package/src/v4/mini/tests/recursive-types.test.ts +341 -0
- package/src/v4/mini/tests/standard-schema.test.ts +50 -0
- package/src/v4/mini/tests/string.test.ts +396 -0
- package/src/v4-mini/index.ts +3 -0
- package/v3/YatspError.cjs +167 -0
- package/v3/YatspError.d.cts +164 -0
- package/v3/YatspError.d.ts +164 -0
- package/v3/YatspError.js +143 -0
- package/v3/errors.cjs +36 -0
- package/v3/errors.d.cts +5 -0
- package/v3/errors.d.ts +5 -0
- package/v3/errors.js +9 -0
- package/v3/external.cjs +41 -0
- package/v3/external.d.cts +6 -0
- package/v3/external.d.ts +6 -0
- package/v3/external.js +6 -0
- package/v3/helpers/enumUtil.cjs +21 -0
- package/v3/helpers/enumUtil.d.cts +8 -0
- package/v3/helpers/enumUtil.d.ts +8 -0
- package/v3/helpers/enumUtil.js +1 -0
- package/v3/helpers/errorUtil.cjs +28 -0
- package/v3/helpers/errorUtil.d.cts +9 -0
- package/v3/helpers/errorUtil.d.ts +9 -0
- package/v3/helpers/errorUtil.js +6 -0
- package/v3/helpers/parseUtil.cjs +143 -0
- package/v3/helpers/parseUtil.d.cts +78 -0
- package/v3/helpers/parseUtil.d.ts +78 -0
- package/v3/helpers/parseUtil.js +109 -0
- package/v3/helpers/partialUtil.cjs +21 -0
- package/v3/helpers/partialUtil.d.cts +8 -0
- package/v3/helpers/partialUtil.d.ts +8 -0
- package/v3/helpers/partialUtil.js +1 -0
- package/v3/helpers/typeAliases.cjs +21 -0
- package/v3/helpers/typeAliases.d.cts +2 -0
- package/v3/helpers/typeAliases.d.ts +2 -0
- package/v3/helpers/typeAliases.js +1 -0
- package/v3/helpers/util.cjs +156 -0
- package/v3/helpers/util.d.cts +85 -0
- package/v3/helpers/util.d.ts +85 -0
- package/v3/helpers/util.js +133 -0
- package/v3/index.cjs +52 -0
- package/v3/index.d.cts +4 -0
- package/v3/index.d.ts +4 -0
- package/v3/index.js +4 -0
- package/v3/locales/en.cjs +112 -0
- package/v3/locales/en.d.cts +3 -0
- package/v3/locales/en.d.ts +3 -0
- package/v3/locales/en.js +109 -0
- package/v3/standard-schema.cjs +21 -0
- package/v3/standard-schema.d.cts +102 -0
- package/v3/standard-schema.d.ts +102 -0
- package/v3/standard-schema.js +1 -0
- package/v3/types.cjs +3798 -0
- package/v3/types.d.cts +1034 -0
- package/v3/types.d.ts +1034 -0
- package/v3/types.js +3697 -0
- package/v4/classic/checks.cjs +53 -0
- package/v4/classic/checks.d.cts +1 -0
- package/v4/classic/checks.d.ts +1 -0
- package/v4/classic/checks.js +1 -0
- package/v4/classic/coerce.cjs +66 -0
- package/v4/classic/coerce.d.cts +17 -0
- package/v4/classic/coerce.d.ts +17 -0
- package/v4/classic/coerce.js +17 -0
- package/v4/classic/compat.cjs +80 -0
- package/v4/classic/compat.d.cts +48 -0
- package/v4/classic/compat.d.ts +48 -0
- package/v4/classic/compat.js +31 -0
- package/v4/classic/deep-partial.cjs +58 -0
- package/v4/classic/deep-partial.d.cts +14 -0
- package/v4/classic/deep-partial.d.ts +14 -0
- package/v4/classic/deep-partial.js +13 -0
- package/v4/classic/errors.cjs +102 -0
- package/v4/classic/errors.d.cts +29 -0
- package/v4/classic/errors.d.ts +29 -0
- package/v4/classic/errors.js +57 -0
- package/v4/classic/external.cjs +97 -0
- package/v4/classic/external.d.cts +19 -0
- package/v4/classic/external.d.ts +19 -0
- package/v4/classic/external.js +17 -0
- package/v4/classic/from-json-schema.cjs +926 -0
- package/v4/classic/from-json-schema.d.cts +12 -0
- package/v4/classic/from-json-schema.d.ts +12 -0
- package/v4/classic/from-json-schema.js +881 -0
- package/v4/classic/in-out.cjs +82 -0
- package/v4/classic/in-out.d.cts +8 -0
- package/v4/classic/in-out.d.ts +8 -0
- package/v4/classic/in-out.js +36 -0
- package/v4/classic/index.cjs +52 -0
- package/v4/classic/index.d.cts +3 -0
- package/v4/classic/index.d.ts +3 -0
- package/v4/classic/index.js +4 -0
- package/v4/classic/iso.cjs +68 -0
- package/v4/classic/iso.d.cts +7 -0
- package/v4/classic/iso.d.ts +7 -0
- package/v4/classic/iso.js +15 -0
- package/v4/classic/parse.cjs +63 -0
- package/v4/classic/parse.d.cts +44 -0
- package/v4/classic/parse.d.ts +44 -0
- package/v4/classic/parse.js +16 -0
- package/v4/classic/schemas.cjs +1676 -0
- package/v4/classic/schemas.d.cts +816 -0
- package/v4/classic/schemas.d.ts +816 -0
- package/v4/classic/schemas.js +1535 -0
- package/v4/core/api.cjs +1269 -0
- package/v4/core/api.d.cts +335 -0
- package/v4/core/api.d.ts +335 -0
- package/v4/core/api.js +1107 -0
- package/v4/core/checks.cjs +561 -0
- package/v4/core/checks.d.cts +294 -0
- package/v4/core/checks.d.ts +294 -0
- package/v4/core/checks.js +516 -0
- package/v4/core/compile.cjs +1908 -0
- package/v4/core/compile.d.cts +65 -0
- package/v4/core/compile.d.ts +65 -0
- package/v4/core/compile.js +1858 -0
- package/v4/core/core.cjs +167 -0
- package/v4/core/core.d.cts +82 -0
- package/v4/core/core.d.ts +82 -0
- package/v4/core/core.js +141 -0
- package/v4/core/doc.cjs +61 -0
- package/v4/core/doc.d.cts +16 -0
- package/v4/core/doc.d.ts +16 -0
- package/v4/core/doc.js +38 -0
- package/v4/core/errors.cjs +317 -0
- package/v4/core/errors.d.cts +225 -0
- package/v4/core/errors.d.ts +225 -0
- package/v4/core/errors.js +267 -0
- package/v4/core/index.cjs +70 -0
- package/v4/core/index.d.cts +19 -0
- package/v4/core/index.d.ts +19 -0
- package/v4/core/index.js +19 -0
- package/v4/core/json-schema-generator.cjs +122 -0
- package/v4/core/json-schema-generator.d.cts +65 -0
- package/v4/core/json-schema-generator.d.ts +65 -0
- package/v4/core/json-schema-generator.js +99 -0
- package/v4/core/json-schema-processors.cjs +929 -0
- package/v4/core/json-schema-processors.d.cts +65 -0
- package/v4/core/json-schema-processors.d.ts +65 -0
- package/v4/core/json-schema-processors.js +843 -0
- package/v4/core/json-schema.cjs +21 -0
- package/v4/core/json-schema.d.cts +89 -0
- package/v4/core/json-schema.d.ts +89 -0
- package/v4/core/json-schema.js +1 -0
- package/v4/core/memoizer.cjs +360 -0
- package/v4/core/memoizer.d.cts +15 -0
- package/v4/core/memoizer.d.ts +15 -0
- package/v4/core/memoizer.js +311 -0
- package/v4/core/parse.cjs +233 -0
- package/v4/core/parse.d.cts +52 -0
- package/v4/core/parse.d.ts +52 -0
- package/v4/core/parse.js +175 -0
- package/v4/core/regexes.cjs +209 -0
- package/v4/core/regexes.d.cts +90 -0
- package/v4/core/regexes.d.ts +90 -0
- package/v4/core/regexes.js +156 -0
- package/v4/core/registries.cjs +76 -0
- package/v4/core/registries.d.cts +35 -0
- package/v4/core/registries.d.ts +35 -0
- package/v4/core/registries.js +52 -0
- package/v4/core/schemas.cjs +2669 -0
- package/v4/core/schemas.d.cts +1273 -0
- package/v4/core/schemas.d.ts +1273 -0
- package/v4/core/schemas.js +2606 -0
- package/v4/core/standard-schema.cjs +21 -0
- package/v4/core/standard-schema.d.cts +126 -0
- package/v4/core/standard-schema.d.ts +126 -0
- package/v4/core/standard-schema.js +1 -0
- package/v4/core/to-json-schema.cjs +681 -0
- package/v4/core/to-json-schema.d.cts +154 -0
- package/v4/core/to-json-schema.d.ts +154 -0
- package/v4/core/to-json-schema.js +651 -0
- package/v4/core/util.cjs +949 -0
- package/v4/core/util.d.cts +278 -0
- package/v4/core/util.d.ts +278 -0
- package/v4/core/util.js +859 -0
- package/v4/core/versions.cjs +27 -0
- package/v4/core/versions.d.cts +5 -0
- package/v4/core/versions.d.ts +5 -0
- package/v4/core/versions.js +5 -0
- package/v4/core/visit.cjs +214 -0
- package/v4/core/visit.d.cts +30 -0
- package/v4/core/visit.d.ts +30 -0
- package/v4/core/visit.js +169 -0
- package/v4/index.cjs +51 -0
- package/v4/index.d.cts +3 -0
- package/v4/index.d.ts +3 -0
- package/v4/index.js +4 -0
- package/v4/locales/ar.cjs +138 -0
- package/v4/locales/ar.d.cts +5 -0
- package/v4/locales/ar.d.ts +4 -0
- package/v4/locales/ar.js +111 -0
- package/v4/locales/az.cjs +137 -0
- package/v4/locales/az.d.cts +5 -0
- package/v4/locales/az.d.ts +4 -0
- package/v4/locales/az.js +110 -0
- package/v4/locales/be.cjs +195 -0
- package/v4/locales/be.d.cts +5 -0
- package/v4/locales/be.d.ts +4 -0
- package/v4/locales/be.js +168 -0
- package/v4/locales/bg.cjs +152 -0
- package/v4/locales/bg.d.cts +5 -0
- package/v4/locales/bg.d.ts +4 -0
- package/v4/locales/bg.js +125 -0
- package/v4/locales/bn.cjs +140 -0
- package/v4/locales/bn.d.cts +5 -0
- package/v4/locales/bn.d.ts +4 -0
- package/v4/locales/bn.js +113 -0
- package/v4/locales/ca.cjs +139 -0
- package/v4/locales/ca.d.cts +5 -0
- package/v4/locales/ca.d.ts +4 -0
- package/v4/locales/ca.js +112 -0
- package/v4/locales/ckb.cjs +160 -0
- package/v4/locales/ckb.d.cts +5 -0
- package/v4/locales/ckb.d.ts +4 -0
- package/v4/locales/ckb.js +133 -0
- package/v4/locales/cs.cjs +143 -0
- package/v4/locales/cs.d.cts +5 -0
- package/v4/locales/cs.d.ts +4 -0
- package/v4/locales/cs.js +116 -0
- package/v4/locales/da.cjs +147 -0
- package/v4/locales/da.d.cts +5 -0
- package/v4/locales/da.d.ts +4 -0
- package/v4/locales/da.js +120 -0
- package/v4/locales/de.cjs +140 -0
- package/v4/locales/de.d.cts +5 -0
- package/v4/locales/de.d.ts +4 -0
- package/v4/locales/de.js +113 -0
- package/v4/locales/el.cjs +139 -0
- package/v4/locales/el.d.cts +5 -0
- package/v4/locales/el.d.ts +4 -0
- package/v4/locales/el.js +112 -0
- package/v4/locales/en.cjs +152 -0
- package/v4/locales/en.d.cts +5 -0
- package/v4/locales/en.d.ts +4 -0
- package/v4/locales/en.js +125 -0
- package/v4/locales/eo.cjs +141 -0
- package/v4/locales/eo.d.cts +5 -0
- package/v4/locales/eo.d.ts +4 -0
- package/v4/locales/eo.js +114 -0
- package/v4/locales/es.cjs +163 -0
- package/v4/locales/es.d.cts +5 -0
- package/v4/locales/es.d.ts +4 -0
- package/v4/locales/es.js +136 -0
- package/v4/locales/fa.cjs +146 -0
- package/v4/locales/fa.d.cts +5 -0
- package/v4/locales/fa.d.ts +4 -0
- package/v4/locales/fa.js +119 -0
- package/v4/locales/fi.cjs +144 -0
- package/v4/locales/fi.d.cts +5 -0
- package/v4/locales/fi.d.ts +4 -0
- package/v4/locales/fi.js +117 -0
- package/v4/locales/fr-CA.cjs +139 -0
- package/v4/locales/fr-CA.d.cts +5 -0
- package/v4/locales/fr-CA.d.ts +4 -0
- package/v4/locales/fr-CA.js +112 -0
- package/v4/locales/fr.cjs +156 -0
- package/v4/locales/fr.d.cts +5 -0
- package/v4/locales/fr.d.ts +4 -0
- package/v4/locales/fr.js +129 -0
- package/v4/locales/gu.cjs +140 -0
- package/v4/locales/gu.d.cts +5 -0
- package/v4/locales/gu.d.ts +4 -0
- package/v4/locales/gu.js +113 -0
- package/v4/locales/he.cjs +248 -0
- package/v4/locales/he.d.cts +5 -0
- package/v4/locales/he.d.ts +4 -0
- package/v4/locales/he.js +221 -0
- package/v4/locales/hi.cjs +138 -0
- package/v4/locales/hi.d.cts +5 -0
- package/v4/locales/hi.d.ts +4 -0
- package/v4/locales/hi.js +111 -0
- package/v4/locales/hr.cjs +153 -0
- package/v4/locales/hr.d.cts +5 -0
- package/v4/locales/hr.d.ts +4 -0
- package/v4/locales/hr.js +126 -0
- package/v4/locales/hu.cjs +140 -0
- package/v4/locales/hu.d.cts +5 -0
- package/v4/locales/hu.d.ts +4 -0
- package/v4/locales/hu.js +113 -0
- package/v4/locales/hy.cjs +185 -0
- package/v4/locales/hy.d.cts +5 -0
- package/v4/locales/hy.d.ts +4 -0
- package/v4/locales/hy.js +158 -0
- package/v4/locales/id.cjs +138 -0
- package/v4/locales/id.d.cts +5 -0
- package/v4/locales/id.d.ts +4 -0
- package/v4/locales/id.js +111 -0
- package/v4/locales/index.cjs +152 -0
- package/v4/locales/index.d.cts +63 -0
- package/v4/locales/index.d.ts +63 -0
- package/v4/locales/index.js +63 -0
- package/v4/locales/is.cjs +141 -0
- package/v4/locales/is.d.cts +5 -0
- package/v4/locales/is.d.ts +4 -0
- package/v4/locales/is.js +114 -0
- package/v4/locales/it.cjs +140 -0
- package/v4/locales/it.d.cts +5 -0
- package/v4/locales/it.d.ts +4 -0
- package/v4/locales/it.js +113 -0
- package/v4/locales/ja.cjs +139 -0
- package/v4/locales/ja.d.cts +5 -0
- package/v4/locales/ja.d.ts +4 -0
- package/v4/locales/ja.js +112 -0
- package/v4/locales/ka.cjs +144 -0
- package/v4/locales/ka.d.cts +5 -0
- package/v4/locales/ka.d.ts +4 -0
- package/v4/locales/ka.js +117 -0
- package/v4/locales/kh.cjs +12 -0
- package/v4/locales/kh.d.cts +5 -0
- package/v4/locales/kh.d.ts +5 -0
- package/v4/locales/kh.js +5 -0
- package/v4/locales/km.cjs +142 -0
- package/v4/locales/km.d.cts +5 -0
- package/v4/locales/km.d.ts +4 -0
- package/v4/locales/km.js +115 -0
- package/v4/locales/kn.cjs +143 -0
- package/v4/locales/kn.d.cts +5 -0
- package/v4/locales/kn.d.ts +4 -0
- package/v4/locales/kn.js +116 -0
- package/v4/locales/ko.cjs +143 -0
- package/v4/locales/ko.d.cts +5 -0
- package/v4/locales/ko.d.ts +4 -0
- package/v4/locales/ko.js +116 -0
- package/v4/locales/lt.cjs +234 -0
- package/v4/locales/lt.d.cts +5 -0
- package/v4/locales/lt.d.ts +4 -0
- package/v4/locales/lt.js +207 -0
- package/v4/locales/mk.cjs +141 -0
- package/v4/locales/mk.d.cts +5 -0
- package/v4/locales/mk.d.ts +4 -0
- package/v4/locales/mk.js +114 -0
- package/v4/locales/ms.cjs +139 -0
- package/v4/locales/ms.d.cts +5 -0
- package/v4/locales/ms.d.ts +4 -0
- package/v4/locales/ms.js +112 -0
- package/v4/locales/ne.cjs +138 -0
- package/v4/locales/ne.d.cts +5 -0
- package/v4/locales/ne.d.ts +4 -0
- package/v4/locales/ne.js +111 -0
- package/v4/locales/nl.cjs +142 -0
- package/v4/locales/nl.d.cts +5 -0
- package/v4/locales/nl.d.ts +4 -0
- package/v4/locales/nl.js +115 -0
- package/v4/locales/nn.cjs +140 -0
- package/v4/locales/nn.d.cts +5 -0
- package/v4/locales/nn.d.ts +4 -0
- package/v4/locales/nn.js +113 -0
- package/v4/locales/no.cjs +140 -0
- package/v4/locales/no.d.cts +5 -0
- package/v4/locales/no.d.ts +4 -0
- package/v4/locales/no.js +113 -0
- package/v4/locales/ota.cjs +141 -0
- package/v4/locales/ota.d.cts +5 -0
- package/v4/locales/ota.d.ts +4 -0
- package/v4/locales/ota.js +114 -0
- package/v4/locales/pl.cjs +141 -0
- package/v4/locales/pl.d.cts +5 -0
- package/v4/locales/pl.d.ts +4 -0
- package/v4/locales/pl.js +114 -0
- package/v4/locales/ps.cjs +146 -0
- package/v4/locales/ps.d.cts +5 -0
- package/v4/locales/ps.d.ts +4 -0
- package/v4/locales/ps.js +119 -0
- package/v4/locales/pt-BR.cjs +170 -0
- package/v4/locales/pt-BR.d.cts +5 -0
- package/v4/locales/pt-BR.d.ts +4 -0
- package/v4/locales/pt-BR.js +143 -0
- package/v4/locales/pt.cjs +169 -0
- package/v4/locales/pt.d.cts +5 -0
- package/v4/locales/pt.d.ts +4 -0
- package/v4/locales/pt.js +142 -0
- package/v4/locales/ro.cjs +149 -0
- package/v4/locales/ro.d.cts +5 -0
- package/v4/locales/ro.d.ts +4 -0
- package/v4/locales/ro.js +122 -0
- package/v4/locales/ru.cjs +195 -0
- package/v4/locales/ru.d.cts +5 -0
- package/v4/locales/ru.d.ts +4 -0
- package/v4/locales/ru.js +168 -0
- package/v4/locales/sk.cjs +143 -0
- package/v4/locales/sk.d.cts +5 -0
- package/v4/locales/sk.d.ts +4 -0
- package/v4/locales/sk.js +116 -0
- package/v4/locales/sl.cjs +141 -0
- package/v4/locales/sl.d.cts +5 -0
- package/v4/locales/sl.d.ts +4 -0
- package/v4/locales/sl.js +114 -0
- package/v4/locales/sv.cjs +142 -0
- package/v4/locales/sv.d.cts +5 -0
- package/v4/locales/sv.d.ts +4 -0
- package/v4/locales/sv.js +115 -0
- package/v4/locales/ta.cjs +142 -0
- package/v4/locales/ta.d.cts +5 -0
- package/v4/locales/ta.d.ts +4 -0
- package/v4/locales/ta.js +115 -0
- package/v4/locales/tg.cjs +144 -0
- package/v4/locales/tg.d.cts +5 -0
- package/v4/locales/tg.d.ts +4 -0
- package/v4/locales/tg.js +117 -0
- package/v4/locales/th.cjs +142 -0
- package/v4/locales/th.d.cts +5 -0
- package/v4/locales/th.d.ts +4 -0
- package/v4/locales/th.js +115 -0
- package/v4/locales/tk.cjs +134 -0
- package/v4/locales/tk.d.cts +5 -0
- package/v4/locales/tk.d.ts +4 -0
- package/v4/locales/tk.js +107 -0
- package/v4/locales/tr.cjs +137 -0
- package/v4/locales/tr.d.cts +5 -0
- package/v4/locales/tr.d.ts +4 -0
- package/v4/locales/tr.js +110 -0
- package/v4/locales/ua.cjs +12 -0
- package/v4/locales/ua.d.cts +5 -0
- package/v4/locales/ua.d.ts +5 -0
- package/v4/locales/ua.js +5 -0
- package/v4/locales/uk.cjs +140 -0
- package/v4/locales/uk.d.cts +5 -0
- package/v4/locales/uk.d.ts +4 -0
- package/v4/locales/uk.js +113 -0
- package/v4/locales/ur.cjs +142 -0
- package/v4/locales/ur.d.cts +5 -0
- package/v4/locales/ur.d.ts +4 -0
- package/v4/locales/ur.js +115 -0
- package/v4/locales/uz.cjs +140 -0
- package/v4/locales/uz.d.cts +5 -0
- package/v4/locales/uz.d.ts +4 -0
- package/v4/locales/uz.js +113 -0
- package/v4/locales/vi.cjs +140 -0
- package/v4/locales/vi.d.cts +5 -0
- package/v4/locales/vi.d.ts +4 -0
- package/v4/locales/vi.js +113 -0
- package/v4/locales/yo.cjs +139 -0
- package/v4/locales/yo.d.cts +5 -0
- package/v4/locales/yo.d.ts +4 -0
- package/v4/locales/yo.js +112 -0
- package/v4/locales/zh-CN.cjs +141 -0
- package/v4/locales/zh-CN.d.cts +5 -0
- package/v4/locales/zh-CN.d.ts +4 -0
- package/v4/locales/zh-CN.js +114 -0
- package/v4/locales/zh-TW.cjs +139 -0
- package/v4/locales/zh-TW.d.cts +5 -0
- package/v4/locales/zh-TW.d.ts +4 -0
- package/v4/locales/zh-TW.js +112 -0
- package/v4/mini/checks.cjs +54 -0
- package/v4/mini/checks.d.cts +1 -0
- package/v4/mini/checks.d.ts +1 -0
- package/v4/mini/checks.js +1 -0
- package/v4/mini/coerce.cjs +71 -0
- package/v4/mini/coerce.d.cts +7 -0
- package/v4/mini/coerce.d.ts +7 -0
- package/v4/mini/coerce.js +22 -0
- package/v4/mini/deep-partial.cjs +58 -0
- package/v4/mini/deep-partial.d.cts +14 -0
- package/v4/mini/deep-partial.d.ts +14 -0
- package/v4/mini/deep-partial.js +13 -0
- package/v4/mini/external.cjs +95 -0
- package/v4/mini/external.d.cts +16 -0
- package/v4/mini/external.d.ts +16 -0
- package/v4/mini/external.js +16 -0
- package/v4/mini/in-out.cjs +82 -0
- package/v4/mini/in-out.d.cts +8 -0
- package/v4/mini/in-out.d.ts +8 -0
- package/v4/mini/in-out.js +36 -0
- package/v4/mini/index.cjs +51 -0
- package/v4/mini/index.d.cts +3 -0
- package/v4/mini/index.d.ts +3 -0
- package/v4/mini/index.js +3 -0
- package/v4/mini/iso.cjs +83 -0
- package/v4/mini/iso.d.cts +22 -0
- package/v4/mini/iso.d.ts +22 -0
- package/v4/mini/iso.js +34 -0
- package/v4/mini/parse.cjs +37 -0
- package/v4/mini/parse.d.cts +1 -0
- package/v4/mini/parse.d.ts +1 -0
- package/v4/mini/parse.js +1 -0
- package/v4/mini/schemas.cjs +1149 -0
- package/v4/mini/schemas.d.cts +480 -0
- package/v4/mini/schemas.d.ts +480 -0
- package/v4/mini/schemas.js +1004 -0
- package/v4-mini/index.cjs +51 -0
- package/v4-mini/index.d.cts +3 -0
- package/v4-mini/index.d.ts +3 -0
- package/v4-mini/index.js +3 -0
|
@@ -0,0 +1,2093 @@
|
|
|
1
|
+
import * as core from "../core/index.js";
|
|
2
|
+
import type { $YatspBigIntFormats } from "../core/index.js";
|
|
3
|
+
import * as regexes from "../core/regexes.js";
|
|
4
|
+
import * as util from "../core/util.js";
|
|
5
|
+
import * as parse from "./parse.js";
|
|
6
|
+
|
|
7
|
+
type SomeType = core.SomeType;
|
|
8
|
+
|
|
9
|
+
export interface YatspMiniType<
|
|
10
|
+
out Output = unknown,
|
|
11
|
+
out Input = unknown,
|
|
12
|
+
out Internals extends core.$YatspTypeInternals<Output, Input> = core.$YatspTypeInternals<Output, Input>,
|
|
13
|
+
> extends core.$YatspType<Output, Input, Internals> {
|
|
14
|
+
type: Internals["def"]["type"];
|
|
15
|
+
check(...checks: (core.CheckFn<core.output<this>> | core.$YatspCheck<core.output<this>>)[]): this;
|
|
16
|
+
with(...checks: (core.CheckFn<core.output<this>> | core.$YatspCheck<core.output<this>>)[]): this;
|
|
17
|
+
clone(def?: Internals["def"], params?: { parent: boolean }): this;
|
|
18
|
+
register<R extends core.$YatspRegistry>(
|
|
19
|
+
registry: R,
|
|
20
|
+
...meta: this extends R["_schema"]
|
|
21
|
+
? undefined extends R["_meta"]
|
|
22
|
+
? [core.$replace<R["_meta"], this>?]
|
|
23
|
+
: [core.$replace<R["_meta"], this>]
|
|
24
|
+
: ["Incompatible schema"]
|
|
25
|
+
): this;
|
|
26
|
+
brand<T extends PropertyKey = PropertyKey, Dir extends "in" | "out" | "inout" = "out">(
|
|
27
|
+
value?: T
|
|
28
|
+
): PropertyKey extends T ? this : core.$YatspBranded<this, T, Dir>;
|
|
29
|
+
|
|
30
|
+
def: Internals["def"];
|
|
31
|
+
|
|
32
|
+
parse(data: unknown, params?: core.ParseContext<core.$YatspIssue>): core.output<this>;
|
|
33
|
+
safeParse(data: unknown, params?: core.ParseContext<core.$YatspIssue>): util.SafeParseResult<core.output<this>>;
|
|
34
|
+
parseAsync(data: unknown, params?: core.ParseContext<core.$YatspIssue>): Promise<core.output<this>>;
|
|
35
|
+
safeParseAsync(
|
|
36
|
+
data: unknown,
|
|
37
|
+
params?: core.ParseContext<core.$YatspIssue>
|
|
38
|
+
): Promise<util.SafeParseResult<core.output<this>>>;
|
|
39
|
+
apply<T, TArgs extends unknown[] = []>(fn: (schema: this, ...args: TArgs) => T, ...args: TArgs): T;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface _YatspMiniType<out Internals extends core.$YatspTypeInternals = core.$YatspTypeInternals>
|
|
43
|
+
extends YatspMiniType<any, any, Internals> {}
|
|
44
|
+
|
|
45
|
+
export const YatspMiniType: core.$constructor<YatspMiniType> = /*@__PURE__*/ core.$constructor<YatspMiniType>(
|
|
46
|
+
"YatspMiniType",
|
|
47
|
+
(inst, def) => {
|
|
48
|
+
if (!inst._yatsp) throw new Error("Uninitialized schema in YatspMiniType.");
|
|
49
|
+
|
|
50
|
+
core.$YatspType.init(inst, def);
|
|
51
|
+
|
|
52
|
+
inst.def = def;
|
|
53
|
+
inst.type = def.type;
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
// `with` is an alias for `check`: the same function object, not a wrapper.
|
|
57
|
+
get with(): YatspMiniType["check"] {
|
|
58
|
+
return this.check;
|
|
59
|
+
},
|
|
60
|
+
set with(value: YatspMiniType["check"]) {
|
|
61
|
+
util.own(this, "with", value);
|
|
62
|
+
},
|
|
63
|
+
parse(data, params) {
|
|
64
|
+
return parse.parse(this, data, params, { callee: this.parse });
|
|
65
|
+
},
|
|
66
|
+
parseAsync(data, params) {
|
|
67
|
+
return parse.parseAsync(this, data, params, { callee: this.parseAsync });
|
|
68
|
+
},
|
|
69
|
+
safeParse(data, params) {
|
|
70
|
+
return parse.safeParse(this, data, params);
|
|
71
|
+
},
|
|
72
|
+
safeParseAsync(data, params) {
|
|
73
|
+
return parse.safeParseAsync(this, data, params);
|
|
74
|
+
},
|
|
75
|
+
check(...checks) {
|
|
76
|
+
const def = this.def;
|
|
77
|
+
return this.clone(
|
|
78
|
+
{
|
|
79
|
+
...def,
|
|
80
|
+
checks: [
|
|
81
|
+
...(def.checks ?? []),
|
|
82
|
+
...checks.map((ch) =>
|
|
83
|
+
typeof ch === "function" ? { _yatsp: { check: ch, def: { check: "custom" }, onattach: [] } } : ch
|
|
84
|
+
),
|
|
85
|
+
],
|
|
86
|
+
},
|
|
87
|
+
{ parent: true }
|
|
88
|
+
);
|
|
89
|
+
},
|
|
90
|
+
clone(_def, params) {
|
|
91
|
+
return core.clone(this, _def, params);
|
|
92
|
+
},
|
|
93
|
+
brand() {
|
|
94
|
+
return this as any;
|
|
95
|
+
},
|
|
96
|
+
register(reg: any, meta: any): any {
|
|
97
|
+
reg.add(this, meta);
|
|
98
|
+
return this;
|
|
99
|
+
},
|
|
100
|
+
apply(fn: any, ...args: any[]) {
|
|
101
|
+
return args.length === 0 ? fn(this) : fn(this, ...args);
|
|
102
|
+
},
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
export interface _YatspMiniString<T extends core.$YatspStringInternals<unknown> = core.$YatspStringInternals<unknown>>
|
|
107
|
+
extends _YatspMiniType<T>,
|
|
108
|
+
core.$YatspString<T["input"]> {
|
|
109
|
+
_yatsp: T;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// YatspMiniString
|
|
113
|
+
export interface YatspMiniString<Input = unknown>
|
|
114
|
+
extends _YatspMiniString<core.$YatspStringInternals<Input>>,
|
|
115
|
+
core.$YatspString<Input> {}
|
|
116
|
+
export const YatspMiniString: core.$constructor<YatspMiniString> = /*@__PURE__*/ core.$constructor(
|
|
117
|
+
"YatspMiniString",
|
|
118
|
+
(inst, def) => {
|
|
119
|
+
core.$YatspString.init(inst, def);
|
|
120
|
+
YatspMiniType.init(inst, def);
|
|
121
|
+
}
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
// @__NO_SIDE_EFFECTS__
|
|
125
|
+
export function string(params?: string | core.$YatspStringParams): YatspMiniString<string> {
|
|
126
|
+
return core._string(YatspMiniString, params) as any;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// YatspMiniStringFormat
|
|
130
|
+
export interface YatspMiniStringFormat<Format extends string = string>
|
|
131
|
+
extends _YatspMiniString<core.$YatspStringFormatInternals<Format>>,
|
|
132
|
+
core.$YatspStringFormat<Format> {
|
|
133
|
+
// _yatsp: core.$YatspStringFormatInternals<Format>;
|
|
134
|
+
}
|
|
135
|
+
export const YatspMiniStringFormat: core.$constructor<YatspMiniStringFormat> = /*@__PURE__*/ core.$constructor(
|
|
136
|
+
"YatspMiniStringFormat",
|
|
137
|
+
(inst, def) => {
|
|
138
|
+
core.$YatspStringFormat.init(inst, def);
|
|
139
|
+
YatspMiniString.init(inst, def);
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
// YatspMiniEmail
|
|
144
|
+
export interface YatspMiniEmail extends _YatspMiniString<core.$YatspEmailInternals> {}
|
|
145
|
+
export const YatspMiniEmail: core.$constructor<YatspMiniEmail> = /*@__PURE__*/ core.$constructor(
|
|
146
|
+
"YatspMiniEmail",
|
|
147
|
+
(inst, def) => {
|
|
148
|
+
core.$YatspEmail.init(inst, def);
|
|
149
|
+
YatspMiniStringFormat.init(inst, def);
|
|
150
|
+
}
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
// @__NO_SIDE_EFFECTS__
|
|
154
|
+
export function email(params?: string | core.$YatspEmailParams): YatspMiniEmail {
|
|
155
|
+
return core._email(YatspMiniEmail, params);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// YatspMiniGUID
|
|
159
|
+
export interface YatspMiniGUID extends _YatspMiniString<core.$YatspGUIDInternals> {
|
|
160
|
+
// _yatsp: core.$YatspGUIDInternals;
|
|
161
|
+
}
|
|
162
|
+
export const YatspMiniGUID: core.$constructor<YatspMiniGUID> = /*@__PURE__*/ core.$constructor(
|
|
163
|
+
"YatspMiniGUID",
|
|
164
|
+
(inst, def) => {
|
|
165
|
+
core.$YatspGUID.init(inst, def);
|
|
166
|
+
YatspMiniStringFormat.init(inst, def);
|
|
167
|
+
}
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
// @__NO_SIDE_EFFECTS__
|
|
171
|
+
export function guid(params?: string | core.$YatspGUIDParams): YatspMiniGUID {
|
|
172
|
+
return core._guid(YatspMiniGUID, params);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// YatspMiniUUID
|
|
176
|
+
export interface YatspMiniUUID extends _YatspMiniString<core.$YatspUUIDInternals> {
|
|
177
|
+
// _yatsp: core.$YatspUUIDInternals;
|
|
178
|
+
}
|
|
179
|
+
export const YatspMiniUUID: core.$constructor<YatspMiniUUID> = /*@__PURE__*/ core.$constructor(
|
|
180
|
+
"YatspMiniUUID",
|
|
181
|
+
(inst, def) => {
|
|
182
|
+
core.$YatspUUID.init(inst, def);
|
|
183
|
+
YatspMiniStringFormat.init(inst, def);
|
|
184
|
+
}
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
// @__NO_SIDE_EFFECTS__
|
|
188
|
+
export function uuid(params?: string | core.$YatspUUIDParams): YatspMiniUUID {
|
|
189
|
+
return core._uuid(YatspMiniUUID, params);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// @__NO_SIDE_EFFECTS__
|
|
193
|
+
export function uuidv4(params?: string | core.$YatspUUIDv4Params): YatspMiniUUID {
|
|
194
|
+
return core._uuidv4(YatspMiniUUID, params);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// YatspMiniUUIDv6
|
|
198
|
+
|
|
199
|
+
// @__NO_SIDE_EFFECTS__
|
|
200
|
+
export function uuidv6(params?: string | core.$YatspUUIDv6Params): YatspMiniUUID {
|
|
201
|
+
return core._uuidv6(YatspMiniUUID, params);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// YatspMiniUUIDv7
|
|
205
|
+
|
|
206
|
+
// @__NO_SIDE_EFFECTS__
|
|
207
|
+
export function uuidv7(params?: string | core.$YatspUUIDv7Params): YatspMiniUUID {
|
|
208
|
+
return core._uuidv7(YatspMiniUUID, params);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// YatspMiniURL
|
|
212
|
+
export interface YatspMiniURL extends _YatspMiniString<core.$YatspURLInternals> {
|
|
213
|
+
// _yatsp: core.$YatspURLInternals;
|
|
214
|
+
}
|
|
215
|
+
export const YatspMiniURL: core.$constructor<YatspMiniURL> = /*@__PURE__*/ core.$constructor(
|
|
216
|
+
"YatspMiniURL",
|
|
217
|
+
(inst, def) => {
|
|
218
|
+
core.$YatspURL.init(inst, def);
|
|
219
|
+
YatspMiniStringFormat.init(inst, def);
|
|
220
|
+
}
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
// @__NO_SIDE_EFFECTS__
|
|
224
|
+
export function url(params?: string | core.$YatspURLParams): YatspMiniURL {
|
|
225
|
+
return core._url(YatspMiniURL, params);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// @__NO_SIDE_EFFECTS__
|
|
229
|
+
export function httpUrl(params?: string | Omit<core.$YatspURLParams, "protocol" | "hostname">): YatspMiniURL {
|
|
230
|
+
return core._url(YatspMiniURL, {
|
|
231
|
+
protocol: regexes.httpProtocol,
|
|
232
|
+
hostname: regexes.domain,
|
|
233
|
+
...util.normalizeParams(params),
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// YatspMiniEmoji
|
|
238
|
+
export interface YatspMiniEmoji extends _YatspMiniString<core.$YatspEmojiInternals> {
|
|
239
|
+
// _yatsp: core.$YatspEmojiInternals;
|
|
240
|
+
}
|
|
241
|
+
export const YatspMiniEmoji: core.$constructor<YatspMiniEmoji> = /*@__PURE__*/ core.$constructor(
|
|
242
|
+
"YatspMiniEmoji",
|
|
243
|
+
(inst, def) => {
|
|
244
|
+
core.$YatspEmoji.init(inst, def);
|
|
245
|
+
YatspMiniStringFormat.init(inst, def);
|
|
246
|
+
}
|
|
247
|
+
);
|
|
248
|
+
|
|
249
|
+
// @__NO_SIDE_EFFECTS__
|
|
250
|
+
export function emoji(params?: string | core.$YatspEmojiParams): YatspMiniEmoji {
|
|
251
|
+
return core._emoji(YatspMiniEmoji, params);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// YatspMiniNanoID
|
|
255
|
+
export interface YatspMiniNanoID extends _YatspMiniString<core.$YatspNanoIDInternals> {
|
|
256
|
+
// _yatsp: core.$YatspNanoIDInternals;
|
|
257
|
+
}
|
|
258
|
+
export const YatspMiniNanoID: core.$constructor<YatspMiniNanoID> = /*@__PURE__*/ core.$constructor(
|
|
259
|
+
"YatspMiniNanoID",
|
|
260
|
+
(inst, def) => {
|
|
261
|
+
core.$YatspNanoID.init(inst, def);
|
|
262
|
+
YatspMiniStringFormat.init(inst, def);
|
|
263
|
+
}
|
|
264
|
+
);
|
|
265
|
+
|
|
266
|
+
// @__NO_SIDE_EFFECTS__
|
|
267
|
+
export function nanoid(params?: string | core.$YatspNanoIDParams): YatspMiniNanoID {
|
|
268
|
+
return core._nanoid(YatspMiniNanoID, params);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// YatspMiniCUID
|
|
272
|
+
/**
|
|
273
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
274
|
+
* (timestamps embedded in the id). Use {@link YatspMiniCUID2} instead.
|
|
275
|
+
* See https://github.com/paralleldrive/cuid.
|
|
276
|
+
*/
|
|
277
|
+
export interface YatspMiniCUID extends _YatspMiniString<core.$YatspCUIDInternals> {
|
|
278
|
+
// _yatsp: core.$YatspCUIDInternals;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
282
|
+
* (timestamps embedded in the id). Use {@link YatspMiniCUID2} instead.
|
|
283
|
+
* See https://github.com/paralleldrive/cuid.
|
|
284
|
+
*/
|
|
285
|
+
export const YatspMiniCUID: core.$constructor<YatspMiniCUID> = /*@__PURE__*/ core.$constructor(
|
|
286
|
+
"YatspMiniCUID",
|
|
287
|
+
(inst, def) => {
|
|
288
|
+
core.$YatspCUID.init(inst, def);
|
|
289
|
+
YatspMiniStringFormat.init(inst, def);
|
|
290
|
+
}
|
|
291
|
+
);
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Validates a CUID v1 string.
|
|
295
|
+
*
|
|
296
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
297
|
+
* (timestamps embedded in the id). Use {@link cuid2 | `z.cuid2()`} instead.
|
|
298
|
+
* See https://github.com/paralleldrive/cuid.
|
|
299
|
+
*/
|
|
300
|
+
// @__NO_SIDE_EFFECTS__
|
|
301
|
+
export function cuid(params?: string | core.$YatspCUIDParams): YatspMiniCUID {
|
|
302
|
+
return core._cuid(YatspMiniCUID, params);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// YatspMiniCUID2
|
|
306
|
+
export interface YatspMiniCUID2 extends _YatspMiniString<core.$YatspCUID2Internals> {
|
|
307
|
+
// _yatsp: core.$YatspCUID2Internals;
|
|
308
|
+
}
|
|
309
|
+
export const YatspMiniCUID2: core.$constructor<YatspMiniCUID2> = /*@__PURE__*/ core.$constructor(
|
|
310
|
+
"YatspMiniCUID2",
|
|
311
|
+
(inst, def) => {
|
|
312
|
+
core.$YatspCUID2.init(inst, def);
|
|
313
|
+
YatspMiniStringFormat.init(inst, def);
|
|
314
|
+
}
|
|
315
|
+
);
|
|
316
|
+
|
|
317
|
+
// @__NO_SIDE_EFFECTS__
|
|
318
|
+
export function cuid2(params?: string | core.$YatspCUID2Params): YatspMiniCUID2 {
|
|
319
|
+
return core._cuid2(YatspMiniCUID2, params);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// YatspMiniULID
|
|
323
|
+
export interface YatspMiniULID extends _YatspMiniString<core.$YatspULIDInternals> {
|
|
324
|
+
// _yatsp: core.$YatspULIDInternals;
|
|
325
|
+
}
|
|
326
|
+
export const YatspMiniULID: core.$constructor<YatspMiniULID> = /*@__PURE__*/ core.$constructor(
|
|
327
|
+
"YatspMiniULID",
|
|
328
|
+
(inst, def) => {
|
|
329
|
+
core.$YatspULID.init(inst, def);
|
|
330
|
+
YatspMiniStringFormat.init(inst, def);
|
|
331
|
+
}
|
|
332
|
+
);
|
|
333
|
+
|
|
334
|
+
// @__NO_SIDE_EFFECTS__
|
|
335
|
+
export function ulid(params?: string | core.$YatspULIDParams): YatspMiniULID {
|
|
336
|
+
return core._ulid(YatspMiniULID, params);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// YatspMiniXID
|
|
340
|
+
export interface YatspMiniXID extends _YatspMiniString<core.$YatspXIDInternals> {
|
|
341
|
+
// _yatsp: core.$YatspXIDInternals;
|
|
342
|
+
}
|
|
343
|
+
export const YatspMiniXID: core.$constructor<YatspMiniXID> = /*@__PURE__*/ core.$constructor(
|
|
344
|
+
"YatspMiniXID",
|
|
345
|
+
(inst, def) => {
|
|
346
|
+
core.$YatspXID.init(inst, def);
|
|
347
|
+
YatspMiniStringFormat.init(inst, def);
|
|
348
|
+
}
|
|
349
|
+
);
|
|
350
|
+
|
|
351
|
+
// @__NO_SIDE_EFFECTS__
|
|
352
|
+
export function xid(params?: string | core.$YatspXIDParams): YatspMiniXID {
|
|
353
|
+
return core._xid(YatspMiniXID, params);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// YatspMiniKSUID
|
|
357
|
+
export interface YatspMiniKSUID extends _YatspMiniString<core.$YatspKSUIDInternals> {
|
|
358
|
+
// _yatsp: core.$YatspKSUIDInternals;
|
|
359
|
+
}
|
|
360
|
+
export const YatspMiniKSUID: core.$constructor<YatspMiniKSUID> = /*@__PURE__*/ core.$constructor(
|
|
361
|
+
"YatspMiniKSUID",
|
|
362
|
+
(inst, def) => {
|
|
363
|
+
core.$YatspKSUID.init(inst, def);
|
|
364
|
+
YatspMiniStringFormat.init(inst, def);
|
|
365
|
+
}
|
|
366
|
+
);
|
|
367
|
+
|
|
368
|
+
// @__NO_SIDE_EFFECTS__
|
|
369
|
+
export function ksuid(params?: string | core.$YatspKSUIDParams): YatspMiniKSUID {
|
|
370
|
+
return core._ksuid(YatspMiniKSUID, params);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
// YatspMiniIPv4
|
|
374
|
+
export interface YatspMiniIPv4 extends _YatspMiniString<core.$YatspIPv4Internals> {
|
|
375
|
+
// _yatsp: core.$YatspIPv4Internals;
|
|
376
|
+
}
|
|
377
|
+
export const YatspMiniIPv4: core.$constructor<YatspMiniIPv4> = /*@__PURE__*/ core.$constructor(
|
|
378
|
+
"YatspMiniIPv4",
|
|
379
|
+
(inst, def) => {
|
|
380
|
+
core.$YatspIPv4.init(inst, def);
|
|
381
|
+
YatspMiniStringFormat.init(inst, def);
|
|
382
|
+
}
|
|
383
|
+
);
|
|
384
|
+
|
|
385
|
+
// @__NO_SIDE_EFFECTS__
|
|
386
|
+
export function ipv4(params?: string | core.$YatspIPv4Params): YatspMiniIPv4 {
|
|
387
|
+
return core._ipv4(YatspMiniIPv4, params);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// YatspMiniIPv6
|
|
391
|
+
export interface YatspMiniIPv6 extends _YatspMiniString<core.$YatspIPv6Internals> {
|
|
392
|
+
// _yatsp: core.$YatspIPv6Internals;
|
|
393
|
+
}
|
|
394
|
+
export const YatspMiniIPv6: core.$constructor<YatspMiniIPv6> = /*@__PURE__*/ core.$constructor(
|
|
395
|
+
"YatspMiniIPv6",
|
|
396
|
+
(inst, def) => {
|
|
397
|
+
core.$YatspIPv6.init(inst, def);
|
|
398
|
+
YatspMiniStringFormat.init(inst, def);
|
|
399
|
+
}
|
|
400
|
+
);
|
|
401
|
+
|
|
402
|
+
// @__NO_SIDE_EFFECTS__
|
|
403
|
+
export function ipv6(params?: string | core.$YatspIPv6Params): YatspMiniIPv6 {
|
|
404
|
+
return core._ipv6(YatspMiniIPv6, params);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// YatspMiniCIDRv4
|
|
408
|
+
export interface YatspMiniCIDRv4 extends _YatspMiniString<core.$YatspCIDRv4Internals> {
|
|
409
|
+
// _yatsp: core.$YatspCIDRv4Internals;
|
|
410
|
+
}
|
|
411
|
+
export const YatspMiniCIDRv4: core.$constructor<YatspMiniCIDRv4> = /*@__PURE__*/ core.$constructor(
|
|
412
|
+
"YatspMiniCIDRv4",
|
|
413
|
+
(inst, def) => {
|
|
414
|
+
core.$YatspCIDRv4.init(inst, def);
|
|
415
|
+
YatspMiniStringFormat.init(inst, def);
|
|
416
|
+
}
|
|
417
|
+
);
|
|
418
|
+
|
|
419
|
+
// @__NO_SIDE_EFFECTS__
|
|
420
|
+
export function cidrv4(params?: string | core.$YatspCIDRv4Params): YatspMiniCIDRv4 {
|
|
421
|
+
return core._cidrv4(YatspMiniCIDRv4, params);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// YatspMiniCIDRv6
|
|
425
|
+
export interface YatspMiniCIDRv6 extends _YatspMiniString<core.$YatspCIDRv6Internals> {
|
|
426
|
+
// _yatsp: core.$YatspCIDRv6Internals;
|
|
427
|
+
}
|
|
428
|
+
export const YatspMiniCIDRv6: core.$constructor<YatspMiniCIDRv6> = /*@__PURE__*/ core.$constructor(
|
|
429
|
+
"YatspMiniCIDRv6",
|
|
430
|
+
(inst, def) => {
|
|
431
|
+
core.$YatspCIDRv6.init(inst, def);
|
|
432
|
+
YatspMiniStringFormat.init(inst, def);
|
|
433
|
+
}
|
|
434
|
+
);
|
|
435
|
+
|
|
436
|
+
// @__NO_SIDE_EFFECTS__
|
|
437
|
+
export function cidrv6(params?: string | core.$YatspCIDRv6Params): YatspMiniCIDRv6 {
|
|
438
|
+
return core._cidrv6(YatspMiniCIDRv6, params);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
// YatspMiniMAC
|
|
442
|
+
export interface YatspMiniMAC extends _YatspMiniString<core.$YatspMACInternals> {
|
|
443
|
+
// _yatsp: core.$YatspMACInternals;
|
|
444
|
+
}
|
|
445
|
+
export const YatspMiniMAC: core.$constructor<YatspMiniMAC> = /*@__PURE__*/ core.$constructor(
|
|
446
|
+
"YatspMiniMAC",
|
|
447
|
+
(inst, def) => {
|
|
448
|
+
core.$YatspMAC.init(inst, def);
|
|
449
|
+
YatspMiniStringFormat.init(inst, def);
|
|
450
|
+
}
|
|
451
|
+
);
|
|
452
|
+
|
|
453
|
+
// @__NO_SIDE_EFFECTS__
|
|
454
|
+
export function mac(params?: string | core.$YatspMACParams): YatspMiniMAC {
|
|
455
|
+
return core._mac(YatspMiniMAC, params);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
// YatspMiniBase64
|
|
459
|
+
export interface YatspMiniBase64 extends _YatspMiniString<core.$YatspBase64Internals> {
|
|
460
|
+
// _yatsp: core.$YatspBase64Internals;
|
|
461
|
+
}
|
|
462
|
+
export const YatspMiniBase64: core.$constructor<YatspMiniBase64> = /*@__PURE__*/ core.$constructor(
|
|
463
|
+
"YatspMiniBase64",
|
|
464
|
+
(inst, def) => {
|
|
465
|
+
core.$YatspBase64.init(inst, def);
|
|
466
|
+
YatspMiniStringFormat.init(inst, def);
|
|
467
|
+
}
|
|
468
|
+
);
|
|
469
|
+
// @__NO_SIDE_EFFECTS__
|
|
470
|
+
export function base64(params?: string | core.$YatspBase64Params): YatspMiniBase64 {
|
|
471
|
+
return core._base64(YatspMiniBase64, params);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
// YatspMiniBase64URL
|
|
475
|
+
export interface YatspMiniBase64URL extends _YatspMiniString<core.$YatspBase64URLInternals> {
|
|
476
|
+
// _yatsp: core.$YatspBase64URLInternals;
|
|
477
|
+
}
|
|
478
|
+
export const YatspMiniBase64URL: core.$constructor<YatspMiniBase64URL> = /*@__PURE__*/ core.$constructor(
|
|
479
|
+
"YatspMiniBase64URL",
|
|
480
|
+
(inst, def) => {
|
|
481
|
+
core.$YatspBase64URL.init(inst, def);
|
|
482
|
+
YatspMiniStringFormat.init(inst, def);
|
|
483
|
+
}
|
|
484
|
+
);
|
|
485
|
+
// @__NO_SIDE_EFFECTS__
|
|
486
|
+
export function base64url(params?: string | core.$YatspBase64URLParams): YatspMiniBase64URL {
|
|
487
|
+
return core._base64url(YatspMiniBase64URL, params);
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
// YatspMiniE164
|
|
491
|
+
export interface YatspMiniE164 extends _YatspMiniString<core.$YatspE164Internals> {
|
|
492
|
+
// _yatsp: core.$YatspE164Internals;
|
|
493
|
+
}
|
|
494
|
+
export const YatspMiniE164: core.$constructor<YatspMiniE164> = /*@__PURE__*/ core.$constructor(
|
|
495
|
+
"YatspMiniE164",
|
|
496
|
+
(inst, def) => {
|
|
497
|
+
core.$YatspE164.init(inst, def);
|
|
498
|
+
YatspMiniStringFormat.init(inst, def);
|
|
499
|
+
}
|
|
500
|
+
);
|
|
501
|
+
|
|
502
|
+
// @__NO_SIDE_EFFECTS__
|
|
503
|
+
export function e164(params?: string | core.$YatspE164Params): YatspMiniE164 {
|
|
504
|
+
return core._e164(YatspMiniE164, params);
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
// YatspMiniCreditCard
|
|
508
|
+
export interface YatspMiniCreditCard extends _YatspMiniString<core.$YatspCreditCardInternals> {}
|
|
509
|
+
export const YatspMiniCreditCard: core.$constructor<YatspMiniCreditCard> = /*@__PURE__*/ core.$constructor(
|
|
510
|
+
"YatspMiniCreditCard",
|
|
511
|
+
(inst, def) => {
|
|
512
|
+
core.$YatspCreditCard.init(inst, def);
|
|
513
|
+
YatspMiniStringFormat.init(inst, def);
|
|
514
|
+
}
|
|
515
|
+
);
|
|
516
|
+
|
|
517
|
+
// @__NO_SIDE_EFFECTS__
|
|
518
|
+
export function creditCard(params?: string | core.$YatspCreditCardParams): YatspMiniCreditCard {
|
|
519
|
+
return core._creditCard(YatspMiniCreditCard, params);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
// YatspMiniIBAN
|
|
523
|
+
export interface YatspMiniIBAN extends _YatspMiniString<core.$YatspIBANInternals> {}
|
|
524
|
+
export const YatspMiniIBAN: core.$constructor<YatspMiniIBAN> = /*@__PURE__*/ core.$constructor(
|
|
525
|
+
"YatspMiniIBAN",
|
|
526
|
+
(inst, def) => {
|
|
527
|
+
core.$YatspIBAN.init(inst, def);
|
|
528
|
+
YatspMiniStringFormat.init(inst, def);
|
|
529
|
+
}
|
|
530
|
+
);
|
|
531
|
+
|
|
532
|
+
// @__NO_SIDE_EFFECTS__
|
|
533
|
+
export function iban(params?: string | core.$YatspIBANParams): YatspMiniIBAN {
|
|
534
|
+
return core._iban(YatspMiniIBAN, params);
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
// YatspMiniJWT
|
|
538
|
+
export interface YatspMiniJWT extends _YatspMiniString<core.$YatspJWTInternals> {
|
|
539
|
+
// _yatsp: core.$YatspJWTInternals;
|
|
540
|
+
}
|
|
541
|
+
export const YatspMiniJWT: core.$constructor<YatspMiniJWT> = /*@__PURE__*/ core.$constructor(
|
|
542
|
+
"YatspMiniJWT",
|
|
543
|
+
(inst, def) => {
|
|
544
|
+
core.$YatspJWT.init(inst, def);
|
|
545
|
+
YatspMiniStringFormat.init(inst, def);
|
|
546
|
+
}
|
|
547
|
+
);
|
|
548
|
+
|
|
549
|
+
// @__NO_SIDE_EFFECTS__
|
|
550
|
+
export function jwt(params?: string | core.$YatspJWTParams): YatspMiniJWT {
|
|
551
|
+
return core._jwt(YatspMiniJWT, params);
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
// YatspMiniCustomStringFormat
|
|
555
|
+
export interface YatspMiniCustomStringFormat<Format extends string = string>
|
|
556
|
+
extends YatspMiniStringFormat<Format>,
|
|
557
|
+
core.$YatspCustomStringFormat<Format> {
|
|
558
|
+
_yatsp: core.$YatspCustomStringFormatInternals<Format>;
|
|
559
|
+
}
|
|
560
|
+
export const YatspMiniCustomStringFormat: core.$constructor<YatspMiniCustomStringFormat> =
|
|
561
|
+
/*@__PURE__*/ core.$constructor("YatspMiniCustomStringFormat", (inst, def) => {
|
|
562
|
+
core.$YatspCustomStringFormat.init(inst, def);
|
|
563
|
+
YatspMiniStringFormat.init(inst, def);
|
|
564
|
+
});
|
|
565
|
+
|
|
566
|
+
// @__NO_SIDE_EFFECTS__
|
|
567
|
+
export function stringFormat<Format extends string>(
|
|
568
|
+
format: Format,
|
|
569
|
+
fnOrRegex: ((arg: string) => util.MaybeAsync<unknown>) | RegExp,
|
|
570
|
+
_params: string | core.$YatspStringFormatParams = {}
|
|
571
|
+
): YatspMiniCustomStringFormat<Format> {
|
|
572
|
+
return core._stringFormat(YatspMiniCustomStringFormat, format, fnOrRegex, _params) as any;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
// @__NO_SIDE_EFFECTS__
|
|
576
|
+
export function hostname(_params?: string | core.$YatspStringFormatParams): YatspMiniCustomStringFormat<"hostname"> {
|
|
577
|
+
return core._stringFormat(YatspMiniCustomStringFormat, "hostname", regexes.hostname, _params) as any;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
// @__NO_SIDE_EFFECTS__
|
|
581
|
+
export function hex(_params?: string | core.$YatspStringFormatParams): YatspMiniCustomStringFormat<"hex"> {
|
|
582
|
+
return core._stringFormat(YatspMiniCustomStringFormat, "hex", regexes.hex, _params) as any;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
// @__NO_SIDE_EFFECTS__
|
|
586
|
+
export function currencyCode(
|
|
587
|
+
_params?: string | core.$YatspStringFormatParams
|
|
588
|
+
): YatspMiniCustomStringFormat<"currency_code"> {
|
|
589
|
+
return core._stringFormat(YatspMiniCustomStringFormat, "currency_code", regexes.currencyCode, _params) as any;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
// @__NO_SIDE_EFFECTS__
|
|
593
|
+
export function hash<Alg extends util.HashAlgorithm, Enc extends util.HashEncoding = "hex">(
|
|
594
|
+
alg: Alg,
|
|
595
|
+
params?: {
|
|
596
|
+
enc?: Enc;
|
|
597
|
+
} & core.$YatspStringFormatParams
|
|
598
|
+
): YatspMiniCustomStringFormat<`${Alg}_${Enc}`> {
|
|
599
|
+
const enc = params?.enc ?? "hex";
|
|
600
|
+
const format = `${alg}_${enc}` as const;
|
|
601
|
+
const regex = core.regexes[format as keyof typeof core.regexes] as RegExp;
|
|
602
|
+
// check for unrecognized format
|
|
603
|
+
if (!regex) throw new Error(`Unrecognized hash format: ${format}`);
|
|
604
|
+
return core._stringFormat(YatspMiniCustomStringFormat, format, regex, params) as any;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
// YatspMiniNumber
|
|
608
|
+
interface _YatspMiniNumber<T extends core.$YatspNumberInternals<unknown> = core.$YatspNumberInternals<unknown>>
|
|
609
|
+
extends _YatspMiniType<T>,
|
|
610
|
+
core.$YatspNumber<T["input"]> {
|
|
611
|
+
_yatsp: T;
|
|
612
|
+
}
|
|
613
|
+
export interface YatspMiniNumber<Input = unknown>
|
|
614
|
+
extends _YatspMiniNumber<core.$YatspNumberInternals<Input>>,
|
|
615
|
+
core.$YatspNumber<Input> {}
|
|
616
|
+
export const YatspMiniNumber: core.$constructor<YatspMiniNumber> = /*@__PURE__*/ core.$constructor(
|
|
617
|
+
"YatspMiniNumber",
|
|
618
|
+
(inst, def) => {
|
|
619
|
+
core.$YatspNumber.init(inst, def);
|
|
620
|
+
YatspMiniType.init(inst, def);
|
|
621
|
+
}
|
|
622
|
+
);
|
|
623
|
+
|
|
624
|
+
// @__NO_SIDE_EFFECTS__
|
|
625
|
+
export function number(params?: string | core.$YatspNumberParams): YatspMiniNumber<number> {
|
|
626
|
+
return core._number(YatspMiniNumber, params) as any;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
// YatspMiniNumberFormat
|
|
630
|
+
export interface YatspMiniNumberFormat<Format extends core.$YatspNumberFormats = core.$YatspNumberFormats>
|
|
631
|
+
extends _YatspMiniNumber<core.$YatspNumberFormatInternals<Format>>,
|
|
632
|
+
core.$YatspNumberFormat<Format> {}
|
|
633
|
+
export const YatspMiniNumberFormat: core.$constructor<YatspMiniNumberFormat> = /*@__PURE__*/ core.$constructor(
|
|
634
|
+
"YatspMiniNumberFormat",
|
|
635
|
+
(inst, def) => {
|
|
636
|
+
core.$YatspNumberFormat.init(inst, def);
|
|
637
|
+
YatspMiniNumber.init(inst, def);
|
|
638
|
+
}
|
|
639
|
+
);
|
|
640
|
+
|
|
641
|
+
// int
|
|
642
|
+
|
|
643
|
+
// @__NO_SIDE_EFFECTS__
|
|
644
|
+
export interface YatspMiniInt extends YatspMiniNumberFormat<"safeint"> {}
|
|
645
|
+
export function int(params?: string | core.$YatspCheckNumberFormatParams): YatspMiniInt {
|
|
646
|
+
return core._int(YatspMiniNumberFormat, params) as YatspMiniInt;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
// float32
|
|
650
|
+
|
|
651
|
+
// @__NO_SIDE_EFFECTS__
|
|
652
|
+
export interface YatspMiniFloat32 extends YatspMiniNumberFormat<"float32"> {}
|
|
653
|
+
export function float32(params?: string | core.$YatspCheckNumberFormatParams): YatspMiniFloat32 {
|
|
654
|
+
return core._float32(YatspMiniNumberFormat, params) as YatspMiniFloat32;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
// float64
|
|
658
|
+
|
|
659
|
+
// @__NO_SIDE_EFFECTS__
|
|
660
|
+
export interface YatspMiniFloat64 extends YatspMiniNumberFormat<"float64"> {}
|
|
661
|
+
export function float64(params?: string | core.$YatspCheckNumberFormatParams): YatspMiniFloat64 {
|
|
662
|
+
return core._float64(YatspMiniNumberFormat, params) as YatspMiniFloat64;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
// int32
|
|
666
|
+
|
|
667
|
+
// @__NO_SIDE_EFFECTS__
|
|
668
|
+
export interface YatspMiniInt32 extends YatspMiniNumberFormat<"int32"> {}
|
|
669
|
+
export function int32(params?: string | core.$YatspCheckNumberFormatParams): YatspMiniInt32 {
|
|
670
|
+
return core._int32(YatspMiniNumberFormat, params) as YatspMiniInt32;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
// uint32
|
|
674
|
+
|
|
675
|
+
// @__NO_SIDE_EFFECTS__
|
|
676
|
+
export interface YatspMiniUInt32 extends YatspMiniNumberFormat<"uint32"> {}
|
|
677
|
+
export function uint32(params?: string | core.$YatspCheckNumberFormatParams): YatspMiniUInt32 {
|
|
678
|
+
return core._uint32(YatspMiniNumberFormat, params) as YatspMiniUInt32;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
// YatspMiniBoolean
|
|
682
|
+
export interface YatspMiniBoolean<T = unknown> extends _YatspMiniType<core.$YatspBooleanInternals<T>> {
|
|
683
|
+
// _yatsp: core.$YatspBooleanInternals<T>;
|
|
684
|
+
}
|
|
685
|
+
export const YatspMiniBoolean: core.$constructor<YatspMiniBoolean> = /*@__PURE__*/ core.$constructor(
|
|
686
|
+
"YatspMiniBoolean",
|
|
687
|
+
(inst, def) => {
|
|
688
|
+
core.$YatspBoolean.init(inst, def);
|
|
689
|
+
YatspMiniType.init(inst, def);
|
|
690
|
+
}
|
|
691
|
+
);
|
|
692
|
+
|
|
693
|
+
// @__NO_SIDE_EFFECTS__
|
|
694
|
+
export function boolean(params?: string | core.$YatspBooleanParams): YatspMiniBoolean<boolean> {
|
|
695
|
+
return core._boolean(YatspMiniBoolean, params) as any;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
// YatspMiniBigInt
|
|
699
|
+
export interface YatspMiniBigInt<T = unknown>
|
|
700
|
+
extends _YatspMiniType<core.$YatspBigIntInternals<T>>,
|
|
701
|
+
core.$YatspBigInt<T> {
|
|
702
|
+
// _yatsp: core.$YatspBigIntInternals<T>;
|
|
703
|
+
}
|
|
704
|
+
export const YatspMiniBigInt: core.$constructor<YatspMiniBigInt> = /*@__PURE__*/ core.$constructor(
|
|
705
|
+
"YatspMiniBigInt",
|
|
706
|
+
(inst, def) => {
|
|
707
|
+
core.$YatspBigInt.init(inst, def);
|
|
708
|
+
YatspMiniType.init(inst, def);
|
|
709
|
+
}
|
|
710
|
+
);
|
|
711
|
+
|
|
712
|
+
// @__NO_SIDE_EFFECTS__
|
|
713
|
+
export function bigint(params?: string | core.$YatspBigIntParams): YatspMiniBigInt<bigint> {
|
|
714
|
+
return core._bigint(YatspMiniBigInt, params) as any;
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
// bigint formats
|
|
718
|
+
|
|
719
|
+
// YatspMiniBigIntFormat
|
|
720
|
+
export interface YatspMiniBigIntFormat<Format extends $YatspBigIntFormats = $YatspBigIntFormats>
|
|
721
|
+
extends _YatspMiniType<core.$YatspBigIntFormatInternals<Format>> {
|
|
722
|
+
// _yatsp: core.$YatspBigIntFormatInternals<Format>;
|
|
723
|
+
}
|
|
724
|
+
export const YatspMiniBigIntFormat: core.$constructor<YatspMiniBigIntFormat> = /*@__PURE__*/ core.$constructor(
|
|
725
|
+
"YatspMiniBigIntFormat",
|
|
726
|
+
(inst, def) => {
|
|
727
|
+
core.$YatspBigIntFormat.init(inst, def);
|
|
728
|
+
YatspMiniBigInt.init(inst, def);
|
|
729
|
+
}
|
|
730
|
+
);
|
|
731
|
+
|
|
732
|
+
// int64
|
|
733
|
+
|
|
734
|
+
// @__NO_SIDE_EFFECTS__
|
|
735
|
+
export interface YatspMiniInt64 extends YatspMiniBigIntFormat<"int64"> {}
|
|
736
|
+
export function int64(params?: string | core.$YatspBigIntFormatParams): YatspMiniInt64 {
|
|
737
|
+
return core._int64(YatspMiniBigIntFormat, params) as YatspMiniInt64;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
// uint64
|
|
741
|
+
|
|
742
|
+
// @__NO_SIDE_EFFECTS__
|
|
743
|
+
export interface YatspMiniUInt64 extends YatspMiniBigIntFormat<"uint64"> {}
|
|
744
|
+
export function uint64(params?: string | core.$YatspBigIntFormatParams): YatspMiniUInt64 {
|
|
745
|
+
return core._uint64(YatspMiniBigIntFormat, params) as YatspMiniUInt64;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
// YatspMiniSymbol
|
|
749
|
+
export interface YatspMiniSymbol extends _YatspMiniType<core.$YatspSymbolInternals> {
|
|
750
|
+
// _yatsp: core.$YatspSymbolInternals;
|
|
751
|
+
}
|
|
752
|
+
export const YatspMiniSymbol: core.$constructor<YatspMiniSymbol> = /*@__PURE__*/ core.$constructor(
|
|
753
|
+
"YatspMiniSymbol",
|
|
754
|
+
(inst, def) => {
|
|
755
|
+
core.$YatspSymbol.init(inst, def);
|
|
756
|
+
YatspMiniType.init(inst, def);
|
|
757
|
+
}
|
|
758
|
+
);
|
|
759
|
+
|
|
760
|
+
// @__NO_SIDE_EFFECTS__
|
|
761
|
+
export function symbol(params?: string | core.$YatspSymbolParams): YatspMiniSymbol {
|
|
762
|
+
return core._symbol(YatspMiniSymbol, params) as any;
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
// YatspMiniUndefined
|
|
766
|
+
export interface YatspMiniUndefined extends _YatspMiniType<core.$YatspUndefinedInternals> {
|
|
767
|
+
// _yatsp: core.$YatspUndefinedInternals;
|
|
768
|
+
}
|
|
769
|
+
export const YatspMiniUndefined: core.$constructor<YatspMiniUndefined> = /*@__PURE__*/ core.$constructor(
|
|
770
|
+
"YatspMiniUndefined",
|
|
771
|
+
(inst, def) => {
|
|
772
|
+
core.$YatspUndefined.init(inst, def);
|
|
773
|
+
YatspMiniType.init(inst, def);
|
|
774
|
+
}
|
|
775
|
+
);
|
|
776
|
+
|
|
777
|
+
// @__NO_SIDE_EFFECTS__
|
|
778
|
+
function _undefined(params?: string | core.$YatspUndefinedParams): YatspMiniUndefined {
|
|
779
|
+
return core._undefined(YatspMiniUndefined, params) as any;
|
|
780
|
+
}
|
|
781
|
+
export { _undefined as undefined };
|
|
782
|
+
|
|
783
|
+
// YatspMiniNull
|
|
784
|
+
export interface YatspMiniNull extends _YatspMiniType<core.$YatspNullInternals> {
|
|
785
|
+
// _yatsp: core.$YatspNullInternals;
|
|
786
|
+
}
|
|
787
|
+
export const YatspMiniNull: core.$constructor<YatspMiniNull> = /*@__PURE__*/ core.$constructor(
|
|
788
|
+
"YatspMiniNull",
|
|
789
|
+
(inst, def) => {
|
|
790
|
+
core.$YatspNull.init(inst, def);
|
|
791
|
+
YatspMiniType.init(inst, def);
|
|
792
|
+
}
|
|
793
|
+
);
|
|
794
|
+
|
|
795
|
+
// @__NO_SIDE_EFFECTS__
|
|
796
|
+
function _null(params?: string | core.$YatspNullParams): YatspMiniNull {
|
|
797
|
+
return core._null(YatspMiniNull, params) as any;
|
|
798
|
+
}
|
|
799
|
+
export { _null as null };
|
|
800
|
+
|
|
801
|
+
// YatspMiniAny
|
|
802
|
+
export interface YatspMiniAny extends _YatspMiniType<core.$YatspAnyInternals> {
|
|
803
|
+
// _yatsp: core.$YatspAnyInternals;
|
|
804
|
+
}
|
|
805
|
+
export const YatspMiniAny: core.$constructor<YatspMiniAny> = /*@__PURE__*/ core.$constructor(
|
|
806
|
+
"YatspMiniAny",
|
|
807
|
+
(inst, def) => {
|
|
808
|
+
core.$YatspAny.init(inst, def);
|
|
809
|
+
YatspMiniType.init(inst, def);
|
|
810
|
+
}
|
|
811
|
+
);
|
|
812
|
+
|
|
813
|
+
// @__NO_SIDE_EFFECTS__
|
|
814
|
+
export function any(): YatspMiniAny {
|
|
815
|
+
return core._any(YatspMiniAny) as any;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
// YatspMiniUnknown
|
|
819
|
+
export interface YatspMiniUnknown extends _YatspMiniType<core.$YatspUnknownInternals> {
|
|
820
|
+
// _yatsp: core.$YatspUnknownInternals;
|
|
821
|
+
}
|
|
822
|
+
export const YatspMiniUnknown: core.$constructor<YatspMiniUnknown> = /*@__PURE__*/ core.$constructor(
|
|
823
|
+
"YatspMiniUnknown",
|
|
824
|
+
(inst, def) => {
|
|
825
|
+
core.$YatspUnknown.init(inst, def);
|
|
826
|
+
YatspMiniType.init(inst, def);
|
|
827
|
+
}
|
|
828
|
+
);
|
|
829
|
+
|
|
830
|
+
// @__NO_SIDE_EFFECTS__
|
|
831
|
+
export function unknown(): YatspMiniUnknown {
|
|
832
|
+
return core._unknown(YatspMiniUnknown) as any;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
// YatspMiniNever
|
|
836
|
+
export interface YatspMiniNever extends _YatspMiniType<core.$YatspNeverInternals> {
|
|
837
|
+
// _yatsp: core.$YatspNeverInternals;
|
|
838
|
+
}
|
|
839
|
+
export const YatspMiniNever: core.$constructor<YatspMiniNever> = /*@__PURE__*/ core.$constructor(
|
|
840
|
+
"YatspMiniNever",
|
|
841
|
+
(inst, def) => {
|
|
842
|
+
core.$YatspNever.init(inst, def);
|
|
843
|
+
YatspMiniType.init(inst, def);
|
|
844
|
+
}
|
|
845
|
+
);
|
|
846
|
+
|
|
847
|
+
// @__NO_SIDE_EFFECTS__
|
|
848
|
+
export function never(params?: string | core.$YatspNeverParams): YatspMiniNever {
|
|
849
|
+
return core._never(YatspMiniNever, params) as any;
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
// YatspMiniVoid
|
|
853
|
+
export interface YatspMiniVoid extends _YatspMiniType<core.$YatspVoidInternals> {
|
|
854
|
+
// _yatsp: core.$YatspVoidInternals;
|
|
855
|
+
}
|
|
856
|
+
export const YatspMiniVoid: core.$constructor<YatspMiniVoid> = /*@__PURE__*/ core.$constructor(
|
|
857
|
+
"YatspMiniVoid",
|
|
858
|
+
(inst, def) => {
|
|
859
|
+
core.$YatspVoid.init(inst, def);
|
|
860
|
+
YatspMiniType.init(inst, def);
|
|
861
|
+
}
|
|
862
|
+
);
|
|
863
|
+
|
|
864
|
+
// @__NO_SIDE_EFFECTS__
|
|
865
|
+
function _void(params?: string | core.$YatspVoidParams): YatspMiniVoid {
|
|
866
|
+
return core._void(YatspMiniVoid, params) as any;
|
|
867
|
+
}
|
|
868
|
+
export { _void as void };
|
|
869
|
+
|
|
870
|
+
// YatspMiniDate
|
|
871
|
+
export interface YatspMiniDate<T = unknown> extends _YatspMiniType<core.$YatspDateInternals<T>> {
|
|
872
|
+
// _yatsp: core.$YatspDateInternals<T>;
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
export const YatspMiniDate: core.$constructor<YatspMiniDate> = /*@__PURE__*/ core.$constructor(
|
|
876
|
+
"YatspMiniDate",
|
|
877
|
+
(inst, def) => {
|
|
878
|
+
core.$YatspDate.init(inst, def);
|
|
879
|
+
YatspMiniType.init(inst, def);
|
|
880
|
+
}
|
|
881
|
+
);
|
|
882
|
+
|
|
883
|
+
// @__NO_SIDE_EFFECTS__
|
|
884
|
+
export function date(params?: string | core.$YatspDateParams): YatspMiniDate<Date> {
|
|
885
|
+
return core._date(YatspMiniDate, params) as any;
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
// YatspMiniArray
|
|
889
|
+
export interface YatspMiniArray<T extends SomeType = core.$YatspType>
|
|
890
|
+
extends _YatspMiniType<core.$YatspArrayInternals<T>>,
|
|
891
|
+
core.$YatspArray<T> {
|
|
892
|
+
// _yatsp: core.$YatspArrayInternals<T>;
|
|
893
|
+
}
|
|
894
|
+
export const YatspMiniArray: core.$constructor<YatspMiniArray> = /*@__PURE__*/ core.$constructor(
|
|
895
|
+
"YatspMiniArray",
|
|
896
|
+
(inst, def) => {
|
|
897
|
+
core.$YatspArray.init(inst, def);
|
|
898
|
+
YatspMiniType.init(inst, def);
|
|
899
|
+
}
|
|
900
|
+
);
|
|
901
|
+
|
|
902
|
+
export function array<T extends SomeType>(element: T, params?: string | core.$YatspArrayParams): YatspMiniArray<T>;
|
|
903
|
+
// @__NO_SIDE_EFFECTS__
|
|
904
|
+
export function array<T extends SomeType>(element: SomeType, params?: any): YatspMiniArray<T> {
|
|
905
|
+
return new YatspMiniArray({
|
|
906
|
+
type: "array",
|
|
907
|
+
element: element as core.$YatspType,
|
|
908
|
+
...util.normalizeParams(params),
|
|
909
|
+
}) as any;
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
// .keyof
|
|
913
|
+
// @__NO_SIDE_EFFECTS__
|
|
914
|
+
export function keyof<T extends YatspMiniObject>(schema: T): YatspMiniEnum<util.KeysEnum<T["shape"]>> {
|
|
915
|
+
const shape = schema._yatsp.def.shape;
|
|
916
|
+
return _enum(Object.keys(shape)) as any;
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
// YatspMiniObject
|
|
920
|
+
export interface YatspMiniObject<
|
|
921
|
+
/** @ts-ignore Cast variance */
|
|
922
|
+
out Shape extends core.$YatspShape = core.$YatspShape,
|
|
923
|
+
out Config extends core.$YatspObjectConfig = core.$strip,
|
|
924
|
+
> extends YatspMiniType<any, any, core.$YatspObjectInternals<Shape, Config>>,
|
|
925
|
+
core.$YatspObject<Shape, Config> {
|
|
926
|
+
shape: Shape;
|
|
927
|
+
}
|
|
928
|
+
export const YatspMiniObject: core.$constructor<YatspMiniObject> = /*@__PURE__*/ core.$constructor(
|
|
929
|
+
"YatspMiniObject",
|
|
930
|
+
(inst, def) => {
|
|
931
|
+
core.$YatspObject.init(inst, def);
|
|
932
|
+
YatspMiniType.init(inst, def);
|
|
933
|
+
util.installLazyProp(inst, "shape", (self) => self._yatsp.def.shape, false);
|
|
934
|
+
}
|
|
935
|
+
);
|
|
936
|
+
// @__NO_SIDE_EFFECTS__
|
|
937
|
+
export function object<T extends core.$YatspLooseShape = Record<never, SomeType>>(
|
|
938
|
+
shape?: T,
|
|
939
|
+
params?: string | core.$YatspObjectParams
|
|
940
|
+
): YatspMiniObject<util.Writeable<T>, core.$strip> {
|
|
941
|
+
const def: core.$YatspObjectDef = {
|
|
942
|
+
type: "object",
|
|
943
|
+
shape: shape ?? {},
|
|
944
|
+
...util.normalizeParams(params),
|
|
945
|
+
};
|
|
946
|
+
return new YatspMiniObject(def) as any;
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
// strictObject
|
|
950
|
+
// @__NO_SIDE_EFFECTS__
|
|
951
|
+
export function strictObject<T extends core.$YatspLooseShape>(
|
|
952
|
+
shape: T,
|
|
953
|
+
params?: string | core.$YatspObjectParams
|
|
954
|
+
): YatspMiniObject<util.Writeable<T>, core.$strict> {
|
|
955
|
+
return new YatspMiniObject({
|
|
956
|
+
type: "object",
|
|
957
|
+
shape,
|
|
958
|
+
catchall: never(),
|
|
959
|
+
...util.normalizeParams(params),
|
|
960
|
+
}) as any;
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
// looseObject
|
|
964
|
+
// @__NO_SIDE_EFFECTS__
|
|
965
|
+
export function looseObject<T extends core.$YatspLooseShape>(
|
|
966
|
+
shape: T,
|
|
967
|
+
params?: string | core.$YatspObjectParams
|
|
968
|
+
): YatspMiniObject<util.Writeable<T>, core.$loose> {
|
|
969
|
+
return new YatspMiniObject({
|
|
970
|
+
type: "object",
|
|
971
|
+
shape,
|
|
972
|
+
catchall: unknown(),
|
|
973
|
+
...util.normalizeParams(params),
|
|
974
|
+
}) as any;
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
// object methods
|
|
978
|
+
// @__NO_SIDE_EFFECTS__
|
|
979
|
+
export function extend<T extends YatspMiniObject, U extends core.$YatspLooseShape>(
|
|
980
|
+
schema: T,
|
|
981
|
+
shape: U
|
|
982
|
+
): YatspMiniObject<util.Extend<T["shape"], util.Writeable<U>>, T["_yatsp"]["config"]> {
|
|
983
|
+
return util.extend(schema, shape);
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
export type SafeExtendShape<Base extends core.$YatspShape, Ext extends core.$YatspLooseShape> = {
|
|
987
|
+
[K in keyof Ext]: K extends keyof Base
|
|
988
|
+
? core.output<Ext[K]> extends core.output<Base[K]>
|
|
989
|
+
? core.input<Ext[K]> extends core.input<Base[K]>
|
|
990
|
+
? Ext[K]
|
|
991
|
+
: never
|
|
992
|
+
: never
|
|
993
|
+
: Ext[K];
|
|
994
|
+
};
|
|
995
|
+
|
|
996
|
+
// @__NO_SIDE_EFFECTS__
|
|
997
|
+
export function safeExtend<T extends YatspMiniObject, U extends core.$YatspLooseShape>(
|
|
998
|
+
schema: T,
|
|
999
|
+
shape: SafeExtendShape<T["shape"], U>
|
|
1000
|
+
): YatspMiniObject<util.Extend<T["shape"], util.Writeable<U>>, T["_yatsp"]["config"]> {
|
|
1001
|
+
return util.safeExtend(schema, shape as any);
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
/**
|
|
1005
|
+
* @deprecated Use [`z.extend(A, B.shape)`](https://yatsp.dev/api?id=extend) instead.
|
|
1006
|
+
*/
|
|
1007
|
+
// @__NO_SIDE_EFFECTS__
|
|
1008
|
+
export function merge<T extends YatspMiniObject, U extends YatspMiniObject>(
|
|
1009
|
+
a: T,
|
|
1010
|
+
b: U
|
|
1011
|
+
): YatspMiniObject<util.Extend<T["shape"], U["shape"]>, U["_yatsp"]["config"]> {
|
|
1012
|
+
return util.merge(a, b) as any;
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
// @__NO_SIDE_EFFECTS__
|
|
1016
|
+
export function pick<T extends YatspMiniObject, M extends util.Mask<keyof T["shape"]>>(
|
|
1017
|
+
schema: T,
|
|
1018
|
+
mask: M & Record<Exclude<keyof M, keyof T["shape"]>, never>
|
|
1019
|
+
): YatspMiniObject<util.Flatten<Pick<T["shape"], keyof T["shape"] & keyof M>>, T["_yatsp"]["config"]> {
|
|
1020
|
+
return util.pick(schema, mask as any);
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
// .omit
|
|
1024
|
+
|
|
1025
|
+
// @__NO_SIDE_EFFECTS__
|
|
1026
|
+
export function omit<T extends YatspMiniObject, M extends util.Mask<keyof T["shape"]>>(
|
|
1027
|
+
schema: T,
|
|
1028
|
+
mask: M & Record<Exclude<keyof M, keyof T["shape"]>, never>
|
|
1029
|
+
): YatspMiniObject<util.Flatten<Omit<T["shape"], keyof M>>, T["_yatsp"]["config"]> {
|
|
1030
|
+
return util.omit(schema, mask);
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
// @__NO_SIDE_EFFECTS__
|
|
1034
|
+
export function partial<T extends YatspMiniObject>(
|
|
1035
|
+
schema: T
|
|
1036
|
+
): YatspMiniObject<
|
|
1037
|
+
{
|
|
1038
|
+
-readonly [k in keyof T["shape"]]: YatspMiniOptional<T["shape"][k]>;
|
|
1039
|
+
},
|
|
1040
|
+
T["_yatsp"]["config"]
|
|
1041
|
+
>;
|
|
1042
|
+
// @__NO_SIDE_EFFECTS__
|
|
1043
|
+
export function partial<T extends YatspMiniObject, M extends util.Mask<keyof T["shape"]>>(
|
|
1044
|
+
schema: T,
|
|
1045
|
+
mask: M & Record<Exclude<keyof M, keyof T["shape"]>, never>
|
|
1046
|
+
): YatspMiniObject<
|
|
1047
|
+
{
|
|
1048
|
+
-readonly [k in keyof T["shape"]]: k extends keyof M ? YatspMiniOptional<T["shape"][k]> : T["shape"][k];
|
|
1049
|
+
},
|
|
1050
|
+
T["_yatsp"]["config"]
|
|
1051
|
+
>;
|
|
1052
|
+
// @__NO_SIDE_EFFECTS__
|
|
1053
|
+
export function partial<T extends util.TupleItems, Rest extends SomeType | null>(
|
|
1054
|
+
schema: YatspMiniTuple<T, Rest>
|
|
1055
|
+
): YatspMiniTuple<{ -readonly [k in keyof T]: YatspMiniOptional<T[k]> }, Rest>;
|
|
1056
|
+
// @__NO_SIDE_EFFECTS__
|
|
1057
|
+
export function partial(schema: YatspMiniObject | YatspMiniTuple, mask?: object) {
|
|
1058
|
+
const def = schema._yatsp.def;
|
|
1059
|
+
if (def.type !== "tuple") return util.partial(YatspMiniOptional, schema as YatspMiniObject, mask);
|
|
1060
|
+
// a refinement was authored against the full arity; partialing would run it on a shorter array
|
|
1061
|
+
if (def.checks?.length) throw new Error(".partial() cannot be used on tuple schemas containing refinements");
|
|
1062
|
+
return util.clone(schema, {
|
|
1063
|
+
...def,
|
|
1064
|
+
items: def.items.map((item) => new YatspMiniOptional({ type: "optional", innerType: item as core.$YatspType })),
|
|
1065
|
+
});
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
// @__NO_SIDE_EFFECTS__
|
|
1069
|
+
export function exactPartial<T extends YatspMiniObject>(
|
|
1070
|
+
schema: T
|
|
1071
|
+
): YatspMiniObject<
|
|
1072
|
+
{
|
|
1073
|
+
-readonly [k in keyof T["shape"]]: YatspMiniExactOptional<T["shape"][k]>;
|
|
1074
|
+
},
|
|
1075
|
+
T["_yatsp"]["config"]
|
|
1076
|
+
>;
|
|
1077
|
+
// @__NO_SIDE_EFFECTS__
|
|
1078
|
+
export function exactPartial<T extends YatspMiniObject, M extends util.Mask<keyof T["shape"]>>(
|
|
1079
|
+
schema: T,
|
|
1080
|
+
mask: M & Record<Exclude<keyof M, keyof T["shape"]>, never>
|
|
1081
|
+
): YatspMiniObject<
|
|
1082
|
+
{
|
|
1083
|
+
-readonly [k in keyof T["shape"]]: k extends keyof M ? YatspMiniExactOptional<T["shape"][k]> : T["shape"][k];
|
|
1084
|
+
},
|
|
1085
|
+
T["_yatsp"]["config"]
|
|
1086
|
+
>;
|
|
1087
|
+
// @__NO_SIDE_EFFECTS__
|
|
1088
|
+
export function exactPartial(schema: YatspMiniObject, mask?: object) {
|
|
1089
|
+
return util.partial(YatspMiniExactOptional, schema, mask, "exactPartial");
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
export type RequiredInterfaceShape<
|
|
1093
|
+
Shape extends core.$YatspLooseShape,
|
|
1094
|
+
Keys extends PropertyKey = keyof Shape,
|
|
1095
|
+
> = util.Identity<
|
|
1096
|
+
{
|
|
1097
|
+
[k in keyof Shape as k extends Keys ? k : never]: YatspMiniNonOptional<Shape[k]>;
|
|
1098
|
+
} & {
|
|
1099
|
+
[k in keyof Shape as k extends Keys ? never : k]: Shape[k];
|
|
1100
|
+
}
|
|
1101
|
+
>;
|
|
1102
|
+
|
|
1103
|
+
// @__NO_SIDE_EFFECTS__
|
|
1104
|
+
export function required<T extends YatspMiniObject>(
|
|
1105
|
+
schema: T
|
|
1106
|
+
): YatspMiniObject<
|
|
1107
|
+
{
|
|
1108
|
+
-readonly [k in keyof T["shape"]]: YatspMiniNonOptional<T["shape"][k]>;
|
|
1109
|
+
},
|
|
1110
|
+
T["_yatsp"]["config"]
|
|
1111
|
+
>;
|
|
1112
|
+
// @__NO_SIDE_EFFECTS__
|
|
1113
|
+
export function required<T extends YatspMiniObject, M extends util.Mask<keyof T["shape"]>>(
|
|
1114
|
+
schema: T,
|
|
1115
|
+
mask: M & Record<Exclude<keyof M, keyof T["shape"]>, never>
|
|
1116
|
+
): YatspMiniObject<
|
|
1117
|
+
util.Extend<
|
|
1118
|
+
T["shape"],
|
|
1119
|
+
{
|
|
1120
|
+
[k in keyof M & keyof T["shape"]]: YatspMiniNonOptional<T["shape"][k]>;
|
|
1121
|
+
}
|
|
1122
|
+
>,
|
|
1123
|
+
T["_yatsp"]["config"]
|
|
1124
|
+
>;
|
|
1125
|
+
// @__NO_SIDE_EFFECTS__
|
|
1126
|
+
export function required(schema: YatspMiniObject, mask?: object) {
|
|
1127
|
+
return util.required(YatspMiniNonOptional, schema, mask);
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
// @__NO_SIDE_EFFECTS__
|
|
1131
|
+
export function catchall<T extends YatspMiniObject, U extends SomeType>(
|
|
1132
|
+
inst: T,
|
|
1133
|
+
catchall: U
|
|
1134
|
+
): YatspMiniObject<T["shape"], core.$catchall<U>> {
|
|
1135
|
+
// `mergeDefs` rather than a spread: spreading reads `shape`, and resolving it can mint a whole fresh subtree
|
|
1136
|
+
return inst.clone(util.mergeDefs(inst._yatsp.def, { catchall: catchall as any })) as any;
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
// YatspMiniUnion
|
|
1140
|
+
export interface YatspMiniUnion<T extends readonly SomeType[] = readonly core.$YatspType[]>
|
|
1141
|
+
extends _YatspMiniType<core.$YatspUnionInternals<T>> {
|
|
1142
|
+
// _yatsp: core.$YatspUnionInternals<T>;
|
|
1143
|
+
}
|
|
1144
|
+
export const YatspMiniUnion: core.$constructor<YatspMiniUnion> = /*@__PURE__*/ core.$constructor(
|
|
1145
|
+
"YatspMiniUnion",
|
|
1146
|
+
(inst, def) => {
|
|
1147
|
+
core.$YatspUnion.init(inst, def);
|
|
1148
|
+
YatspMiniType.init(inst, def);
|
|
1149
|
+
}
|
|
1150
|
+
);
|
|
1151
|
+
|
|
1152
|
+
// @__NO_SIDE_EFFECTS__
|
|
1153
|
+
export function union<const T extends readonly SomeType[]>(
|
|
1154
|
+
options: T,
|
|
1155
|
+
params?: string | core.$YatspUnionParams
|
|
1156
|
+
): YatspMiniUnion<T> {
|
|
1157
|
+
return new YatspMiniUnion({
|
|
1158
|
+
type: "union",
|
|
1159
|
+
options: options as any as core.$YatspType[],
|
|
1160
|
+
...util.normalizeParams(params),
|
|
1161
|
+
}) as any;
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
// YatspMiniXor
|
|
1165
|
+
export interface YatspMiniXor<T extends readonly SomeType[] = readonly core.$YatspType[]>
|
|
1166
|
+
extends _YatspMiniType<core.$YatspXorInternals<T>> {
|
|
1167
|
+
// _yatsp: core.$YatspXorInternals<T>;
|
|
1168
|
+
}
|
|
1169
|
+
export const YatspMiniXor: core.$constructor<YatspMiniXor> = /*@__PURE__*/ core.$constructor(
|
|
1170
|
+
"YatspMiniXor",
|
|
1171
|
+
(inst, def) => {
|
|
1172
|
+
YatspMiniUnion.init(inst, def);
|
|
1173
|
+
core.$YatspXor.init(inst, def);
|
|
1174
|
+
}
|
|
1175
|
+
);
|
|
1176
|
+
|
|
1177
|
+
/** Creates an exclusive union (XOR) where exactly one option must match.
|
|
1178
|
+
* Unlike regular unions that succeed when any option matches, xor fails if
|
|
1179
|
+
* zero or more than one option matches the input. */
|
|
1180
|
+
export function xor<const T extends readonly SomeType[]>(
|
|
1181
|
+
options: T,
|
|
1182
|
+
params?: string | core.$YatspXorParams
|
|
1183
|
+
): YatspMiniXor<T> {
|
|
1184
|
+
return new YatspMiniXor({
|
|
1185
|
+
type: "union",
|
|
1186
|
+
options: options as any as core.$YatspType[],
|
|
1187
|
+
inclusive: false,
|
|
1188
|
+
...util.normalizeParams(params),
|
|
1189
|
+
}) as any;
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
// YatspMiniDiscriminatedUnion
|
|
1193
|
+
export interface YatspMiniDiscriminatedUnion<
|
|
1194
|
+
Options extends readonly SomeType[] = readonly core.$YatspType[],
|
|
1195
|
+
Disc extends string = string,
|
|
1196
|
+
> extends YatspMiniUnion<Options> {
|
|
1197
|
+
_yatsp: core.$YatspDiscriminatedUnionInternals<Options, Disc>;
|
|
1198
|
+
}
|
|
1199
|
+
export const YatspMiniDiscriminatedUnion: core.$constructor<YatspMiniDiscriminatedUnion> =
|
|
1200
|
+
/*@__PURE__*/ core.$constructor("YatspMiniDiscriminatedUnion", (inst, def) => {
|
|
1201
|
+
core.$YatspDiscriminatedUnion.init(inst, def);
|
|
1202
|
+
YatspMiniType.init(inst, def);
|
|
1203
|
+
});
|
|
1204
|
+
|
|
1205
|
+
// @__NO_SIDE_EFFECTS__
|
|
1206
|
+
export function discriminatedUnion<
|
|
1207
|
+
Types extends readonly [core.$YatspTypeDiscriminable, ...core.$YatspTypeDiscriminable[]],
|
|
1208
|
+
Disc extends string,
|
|
1209
|
+
>(
|
|
1210
|
+
discriminator: Disc,
|
|
1211
|
+
options: Types,
|
|
1212
|
+
params?: string | core.$YatspDiscriminatedUnionParams
|
|
1213
|
+
): YatspMiniDiscriminatedUnion<Types, Disc> {
|
|
1214
|
+
return new YatspMiniDiscriminatedUnion({
|
|
1215
|
+
type: "union",
|
|
1216
|
+
options: options as any as core.$YatspType[],
|
|
1217
|
+
discriminator,
|
|
1218
|
+
...util.normalizeParams(params),
|
|
1219
|
+
}) as any as YatspMiniDiscriminatedUnion<Types, Disc>;
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
// YatspMiniIntersection
|
|
1223
|
+
export interface YatspMiniIntersection<A extends SomeType = core.$YatspType, B extends SomeType = core.$YatspType>
|
|
1224
|
+
extends _YatspMiniType<core.$YatspIntersectionInternals<A, B>> {
|
|
1225
|
+
// _yatsp: core.$YatspIntersectionInternals<A, B>;
|
|
1226
|
+
}
|
|
1227
|
+
export const YatspMiniIntersection: core.$constructor<YatspMiniIntersection> = /*@__PURE__*/ core.$constructor(
|
|
1228
|
+
"YatspMiniIntersection",
|
|
1229
|
+
(inst, def) => {
|
|
1230
|
+
core.$YatspIntersection.init(inst, def);
|
|
1231
|
+
YatspMiniType.init(inst, def);
|
|
1232
|
+
}
|
|
1233
|
+
);
|
|
1234
|
+
|
|
1235
|
+
// @__NO_SIDE_EFFECTS__
|
|
1236
|
+
export function intersection<T extends SomeType, U extends SomeType>(left: T, right: U): YatspMiniIntersection<T, U> {
|
|
1237
|
+
return new YatspMiniIntersection({
|
|
1238
|
+
type: "intersection",
|
|
1239
|
+
left: left as any as core.$YatspType,
|
|
1240
|
+
right: right as any as core.$YatspType,
|
|
1241
|
+
}) as any;
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
// YatspMiniTuple
|
|
1245
|
+
export interface YatspMiniTuple<
|
|
1246
|
+
T extends util.TupleItems = readonly core.$YatspType[],
|
|
1247
|
+
Rest extends SomeType | null = core.$YatspType | null,
|
|
1248
|
+
> extends _YatspMiniType<core.$YatspTupleInternals<T, Rest>> {
|
|
1249
|
+
// _yatsp: core.$YatspTupleInternals<T, Rest>;
|
|
1250
|
+
}
|
|
1251
|
+
export const YatspMiniTuple: core.$constructor<YatspMiniTuple> = /*@__PURE__*/ core.$constructor(
|
|
1252
|
+
"YatspMiniTuple",
|
|
1253
|
+
(inst, def) => {
|
|
1254
|
+
core.$YatspTuple.init(inst, def);
|
|
1255
|
+
YatspMiniType.init(inst, def);
|
|
1256
|
+
}
|
|
1257
|
+
);
|
|
1258
|
+
|
|
1259
|
+
export function tuple<const T extends readonly [SomeType, ...SomeType[]]>(
|
|
1260
|
+
items: T,
|
|
1261
|
+
params?: string | core.$YatspTupleParams
|
|
1262
|
+
): YatspMiniTuple<T, null>;
|
|
1263
|
+
export function tuple<const T extends readonly [SomeType, ...SomeType[]], Rest extends SomeType>(
|
|
1264
|
+
items: T,
|
|
1265
|
+
rest: Rest,
|
|
1266
|
+
params?: string | core.$YatspTupleParams
|
|
1267
|
+
): YatspMiniTuple<T, Rest>;
|
|
1268
|
+
export function tuple(items: [], params?: string | core.$YatspTupleParams): YatspMiniTuple<[], null>;
|
|
1269
|
+
// @__NO_SIDE_EFFECTS__
|
|
1270
|
+
export function tuple(
|
|
1271
|
+
items: SomeType[],
|
|
1272
|
+
_paramsOrRest?: string | core.$YatspTupleParams | SomeType,
|
|
1273
|
+
_params?: string | core.$YatspTupleParams
|
|
1274
|
+
) {
|
|
1275
|
+
const hasRest = _paramsOrRest instanceof core.$YatspType;
|
|
1276
|
+
const params = hasRest ? _params : _paramsOrRest;
|
|
1277
|
+
const rest = hasRest ? _paramsOrRest : null;
|
|
1278
|
+
return new YatspMiniTuple({
|
|
1279
|
+
type: "tuple",
|
|
1280
|
+
items: items as any as core.$YatspType[],
|
|
1281
|
+
rest,
|
|
1282
|
+
...util.normalizeParams(params),
|
|
1283
|
+
});
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
// YatspMiniRecord
|
|
1287
|
+
export interface YatspMiniRecord<
|
|
1288
|
+
Key extends core.$YatspRecordKey = core.$YatspRecordKey,
|
|
1289
|
+
Value extends SomeType = core.$YatspType,
|
|
1290
|
+
> extends _YatspMiniType<core.$YatspRecordInternals<Key, Value>> {
|
|
1291
|
+
// _yatsp: core.$YatspRecordInternals<Key, Value>;
|
|
1292
|
+
}
|
|
1293
|
+
export const YatspMiniRecord: core.$constructor<YatspMiniRecord> = /*@__PURE__*/ core.$constructor(
|
|
1294
|
+
"YatspMiniRecord",
|
|
1295
|
+
(inst, def) => {
|
|
1296
|
+
core.$YatspRecord.init(inst, def);
|
|
1297
|
+
YatspMiniType.init(inst, def);
|
|
1298
|
+
}
|
|
1299
|
+
);
|
|
1300
|
+
|
|
1301
|
+
// @__NO_SIDE_EFFECTS__
|
|
1302
|
+
export function record<Key extends core.$YatspRecordKey, Value extends SomeType>(
|
|
1303
|
+
keyType: Key,
|
|
1304
|
+
valueType: Value,
|
|
1305
|
+
params?: string | core.$YatspRecordParams
|
|
1306
|
+
): YatspMiniRecord<Key, Value> {
|
|
1307
|
+
// v3-compat: z.record(valueType, params?) — defaults keyType to z.string()
|
|
1308
|
+
if (!valueType || !(valueType as any)._yatsp) {
|
|
1309
|
+
return new YatspMiniRecord({
|
|
1310
|
+
type: "record",
|
|
1311
|
+
keyType: string() as any,
|
|
1312
|
+
valueType: keyType as any as core.$YatspType,
|
|
1313
|
+
...util.normalizeParams(valueType as string | core.$YatspRecordParams | undefined),
|
|
1314
|
+
}) as any;
|
|
1315
|
+
}
|
|
1316
|
+
return new YatspMiniRecord({
|
|
1317
|
+
type: "record",
|
|
1318
|
+
keyType,
|
|
1319
|
+
valueType: valueType as any as core.$YatspType,
|
|
1320
|
+
...util.normalizeParams(params),
|
|
1321
|
+
}) as any;
|
|
1322
|
+
}
|
|
1323
|
+
// @__NO_SIDE_EFFECTS__
|
|
1324
|
+
export function partialRecord<Key extends core.$YatspRecordKey, Value extends SomeType>(
|
|
1325
|
+
keyType: Key,
|
|
1326
|
+
valueType: Value,
|
|
1327
|
+
params?: string | core.$YatspRecordParams
|
|
1328
|
+
): YatspMiniRecord<Key & core.$partial, Value> {
|
|
1329
|
+
return new YatspMiniRecord({
|
|
1330
|
+
type: "record",
|
|
1331
|
+
keyType,
|
|
1332
|
+
valueType: valueType as any,
|
|
1333
|
+
...util.normalizeParams(params),
|
|
1334
|
+
partial: true,
|
|
1335
|
+
}) as any;
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
export function looseRecord<Key extends core.$YatspRecordKey, Value extends SomeType>(
|
|
1339
|
+
keyType: Key,
|
|
1340
|
+
valueType: Value,
|
|
1341
|
+
params?: string | core.$YatspRecordParams
|
|
1342
|
+
): YatspMiniRecord<Key, Value> {
|
|
1343
|
+
return new YatspMiniRecord({
|
|
1344
|
+
type: "record",
|
|
1345
|
+
keyType,
|
|
1346
|
+
valueType: valueType as any as core.$YatspType,
|
|
1347
|
+
mode: "loose",
|
|
1348
|
+
...util.normalizeParams(params),
|
|
1349
|
+
}) as any;
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1352
|
+
// YatspMiniMap
|
|
1353
|
+
export interface YatspMiniMap<Key extends SomeType = core.$YatspType, Value extends SomeType = core.$YatspType>
|
|
1354
|
+
extends _YatspMiniType<core.$YatspMapInternals<Key, Value>> {
|
|
1355
|
+
// _yatsp: core.$YatspMapInternals<Key, Value>;
|
|
1356
|
+
}
|
|
1357
|
+
export const YatspMiniMap: core.$constructor<YatspMiniMap> = /*@__PURE__*/ core.$constructor(
|
|
1358
|
+
"YatspMiniMap",
|
|
1359
|
+
(inst, def) => {
|
|
1360
|
+
core.$YatspMap.init(inst, def);
|
|
1361
|
+
YatspMiniType.init(inst, def);
|
|
1362
|
+
}
|
|
1363
|
+
);
|
|
1364
|
+
|
|
1365
|
+
// @__NO_SIDE_EFFECTS__
|
|
1366
|
+
export function map<Key extends SomeType, Value extends SomeType>(
|
|
1367
|
+
keyType: Key,
|
|
1368
|
+
valueType: Value,
|
|
1369
|
+
params?: string | core.$YatspMapParams
|
|
1370
|
+
): YatspMiniMap<Key, Value> {
|
|
1371
|
+
return new YatspMiniMap({
|
|
1372
|
+
type: "map",
|
|
1373
|
+
keyType: keyType as any as core.$YatspType,
|
|
1374
|
+
valueType: valueType as any as core.$YatspType,
|
|
1375
|
+
...util.normalizeParams(params),
|
|
1376
|
+
}) as any;
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
// YatspMiniSet
|
|
1380
|
+
export interface YatspMiniSet<T extends SomeType = core.$YatspType> extends _YatspMiniType<core.$YatspSetInternals<T>> {
|
|
1381
|
+
// _yatsp: core.$YatspSetInternals<T>;
|
|
1382
|
+
}
|
|
1383
|
+
export const YatspMiniSet: core.$constructor<YatspMiniSet> = /*@__PURE__*/ core.$constructor(
|
|
1384
|
+
"YatspMiniSet",
|
|
1385
|
+
(inst, def) => {
|
|
1386
|
+
core.$YatspSet.init(inst, def);
|
|
1387
|
+
YatspMiniType.init(inst, def);
|
|
1388
|
+
}
|
|
1389
|
+
);
|
|
1390
|
+
|
|
1391
|
+
// @__NO_SIDE_EFFECTS__
|
|
1392
|
+
export function set<Value extends SomeType>(
|
|
1393
|
+
valueType: Value,
|
|
1394
|
+
params?: string | core.$YatspSetParams
|
|
1395
|
+
): YatspMiniSet<Value> {
|
|
1396
|
+
return new YatspMiniSet({
|
|
1397
|
+
type: "set",
|
|
1398
|
+
valueType: valueType as any as core.$YatspType,
|
|
1399
|
+
...util.normalizeParams(params),
|
|
1400
|
+
}) as any;
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
// YatspMiniEnum
|
|
1404
|
+
export interface YatspMiniEnum<T extends util.EnumLike = util.EnumLike>
|
|
1405
|
+
extends _YatspMiniType<core.$YatspEnumInternals<T>> {
|
|
1406
|
+
// _yatsp: core.$YatspEnumInternals<T>;
|
|
1407
|
+
options: Array<T[keyof T]>;
|
|
1408
|
+
}
|
|
1409
|
+
export const YatspMiniEnum: core.$constructor<YatspMiniEnum> = /*@__PURE__*/ core.$constructor(
|
|
1410
|
+
"YatspMiniEnum",
|
|
1411
|
+
(inst, def) => {
|
|
1412
|
+
core.$YatspEnum.init(inst, def);
|
|
1413
|
+
YatspMiniType.init(inst, def);
|
|
1414
|
+
|
|
1415
|
+
// reuse the parsed value set so a numeric TS enum's reverse-mapping keys stay out
|
|
1416
|
+
inst.options = [...inst._yatsp.values] as util.EnumValue[];
|
|
1417
|
+
}
|
|
1418
|
+
);
|
|
1419
|
+
|
|
1420
|
+
function _enum<const T extends readonly string[]>(
|
|
1421
|
+
values: T,
|
|
1422
|
+
params?: string | core.$YatspEnumParams
|
|
1423
|
+
): YatspMiniEnum<util.ToEnum<T[number]>>;
|
|
1424
|
+
function _enum<T extends util.EnumLike>(entries: T, params?: string | core.$YatspEnumParams): YatspMiniEnum<T>;
|
|
1425
|
+
// @__NO_SIDE_EFFECTS__
|
|
1426
|
+
function _enum(values: any, params?: string | core.$YatspEnumParams) {
|
|
1427
|
+
const entries: any = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
|
|
1428
|
+
|
|
1429
|
+
return new YatspMiniEnum({
|
|
1430
|
+
type: "enum",
|
|
1431
|
+
entries,
|
|
1432
|
+
...util.normalizeParams(params),
|
|
1433
|
+
}) as any;
|
|
1434
|
+
}
|
|
1435
|
+
export { _enum as enum };
|
|
1436
|
+
|
|
1437
|
+
// @__NO_SIDE_EFFECTS__
|
|
1438
|
+
/** @deprecated This API has been merged into `z.enum()`. Use `z.enum()` instead.
|
|
1439
|
+
*
|
|
1440
|
+
* ```ts
|
|
1441
|
+
* enum Colors { red, green, blue }
|
|
1442
|
+
* z.enum(Colors);
|
|
1443
|
+
* ```
|
|
1444
|
+
*/
|
|
1445
|
+
export function nativeEnum<T extends util.EnumLike>(
|
|
1446
|
+
entries: T,
|
|
1447
|
+
params?: string | core.$YatspEnumParams
|
|
1448
|
+
): YatspMiniEnum<T> {
|
|
1449
|
+
return new YatspMiniEnum({
|
|
1450
|
+
type: "enum",
|
|
1451
|
+
entries,
|
|
1452
|
+
...util.normalizeParams(params),
|
|
1453
|
+
}) as any as YatspMiniEnum<T>;
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
// YatspMiniLiteral
|
|
1457
|
+
export interface YatspMiniLiteral<T extends util.Literal = util.Literal>
|
|
1458
|
+
extends _YatspMiniType<core.$YatspLiteralInternals<T>> {
|
|
1459
|
+
// _yatsp: core.$YatspLiteralInternals<T>;
|
|
1460
|
+
}
|
|
1461
|
+
export const YatspMiniLiteral: core.$constructor<YatspMiniLiteral> = /*@__PURE__*/ core.$constructor(
|
|
1462
|
+
"YatspMiniLiteral",
|
|
1463
|
+
(inst, def) => {
|
|
1464
|
+
core.$YatspLiteral.init(inst, def);
|
|
1465
|
+
YatspMiniType.init(inst, def);
|
|
1466
|
+
}
|
|
1467
|
+
);
|
|
1468
|
+
|
|
1469
|
+
export function literal<const T extends ReadonlyArray<util.Literal>>(
|
|
1470
|
+
value: T,
|
|
1471
|
+
params?: string | core.$YatspLiteralParams
|
|
1472
|
+
): YatspMiniLiteral<T[number]>;
|
|
1473
|
+
export function literal<const T extends util.Literal>(
|
|
1474
|
+
value: T,
|
|
1475
|
+
params?: string | core.$YatspLiteralParams
|
|
1476
|
+
): YatspMiniLiteral<T>;
|
|
1477
|
+
// @__NO_SIDE_EFFECTS__
|
|
1478
|
+
export function literal(value: any, params: any) {
|
|
1479
|
+
return new YatspMiniLiteral({
|
|
1480
|
+
type: "literal",
|
|
1481
|
+
values: Array.isArray(value) ? value : [value],
|
|
1482
|
+
...util.normalizeParams(params),
|
|
1483
|
+
});
|
|
1484
|
+
}
|
|
1485
|
+
|
|
1486
|
+
// YatspMiniFile
|
|
1487
|
+
export interface YatspMiniFile extends _YatspMiniType<core.$YatspFileInternals> {
|
|
1488
|
+
// _yatsp: core.$YatspFileInternals;
|
|
1489
|
+
}
|
|
1490
|
+
export const YatspMiniFile: core.$constructor<YatspMiniFile> = /*@__PURE__*/ core.$constructor(
|
|
1491
|
+
"YatspMiniFile",
|
|
1492
|
+
(inst, def) => {
|
|
1493
|
+
core.$YatspFile.init(inst, def);
|
|
1494
|
+
YatspMiniType.init(inst, def);
|
|
1495
|
+
}
|
|
1496
|
+
);
|
|
1497
|
+
|
|
1498
|
+
// @__NO_SIDE_EFFECTS__
|
|
1499
|
+
export function file(params?: string | core.$YatspFileParams): YatspMiniFile {
|
|
1500
|
+
return core._file(YatspMiniFile, params) as any;
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
// YatspMiniTransform
|
|
1504
|
+
export interface YatspMiniTransform<O = unknown, I = unknown>
|
|
1505
|
+
extends _YatspMiniType<core.$YatspTransformInternals<O, I>> {
|
|
1506
|
+
// _yatsp: core.$YatspTransformInternals<O, I>;
|
|
1507
|
+
}
|
|
1508
|
+
export const YatspMiniTransform: core.$constructor<YatspMiniTransform> = /*@__PURE__*/ core.$constructor(
|
|
1509
|
+
"YatspMiniTransform",
|
|
1510
|
+
(inst, def) => {
|
|
1511
|
+
core.$YatspTransform.init(inst, def);
|
|
1512
|
+
YatspMiniType.init(inst, def);
|
|
1513
|
+
}
|
|
1514
|
+
);
|
|
1515
|
+
|
|
1516
|
+
// @__NO_SIDE_EFFECTS__
|
|
1517
|
+
export function transform<I = unknown, O = I>(
|
|
1518
|
+
fn: (input: I, ctx: core.ParsePayload) => O
|
|
1519
|
+
): YatspMiniTransform<Awaited<O>, I> {
|
|
1520
|
+
return new YatspMiniTransform({
|
|
1521
|
+
type: "transform",
|
|
1522
|
+
transform: fn as any,
|
|
1523
|
+
}) as any;
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
// YatspMiniOptional
|
|
1527
|
+
export interface YatspMiniOptional<T extends SomeType = core.$YatspType>
|
|
1528
|
+
extends _YatspMiniType<core.$YatspOptionalInternals<T>>,
|
|
1529
|
+
core.$YatspOptional<T> {
|
|
1530
|
+
// _yatsp: core.$YatspOptionalInternals<T>;
|
|
1531
|
+
}
|
|
1532
|
+
export const YatspMiniOptional: core.$constructor<YatspMiniOptional> = /*@__PURE__*/ core.$constructor(
|
|
1533
|
+
"YatspMiniOptional",
|
|
1534
|
+
(inst, def) => {
|
|
1535
|
+
core.$YatspOptional.init(inst, def);
|
|
1536
|
+
YatspMiniType.init(inst, def);
|
|
1537
|
+
}
|
|
1538
|
+
);
|
|
1539
|
+
|
|
1540
|
+
// @__NO_SIDE_EFFECTS__
|
|
1541
|
+
export function optional<T extends SomeType>(innerType: T): YatspMiniOptional<T> {
|
|
1542
|
+
return new YatspMiniOptional({
|
|
1543
|
+
type: "optional",
|
|
1544
|
+
innerType: innerType as any as core.$YatspType,
|
|
1545
|
+
}) as any;
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1548
|
+
// YatspMiniExactOptional
|
|
1549
|
+
export interface YatspMiniExactOptional<T extends SomeType = core.$YatspType>
|
|
1550
|
+
extends _YatspMiniType<core.$YatspExactOptionalInternals<T>>,
|
|
1551
|
+
core.$YatspExactOptional<T> {
|
|
1552
|
+
// _yatsp: core.$YatspExactOptionalInternals<T>;
|
|
1553
|
+
}
|
|
1554
|
+
export const YatspMiniExactOptional: core.$constructor<YatspMiniExactOptional> = /*@__PURE__*/ core.$constructor(
|
|
1555
|
+
"YatspMiniExactOptional",
|
|
1556
|
+
(inst, def) => {
|
|
1557
|
+
core.$YatspExactOptional.init(inst, def);
|
|
1558
|
+
YatspMiniType.init(inst, def);
|
|
1559
|
+
}
|
|
1560
|
+
);
|
|
1561
|
+
|
|
1562
|
+
// @__NO_SIDE_EFFECTS__
|
|
1563
|
+
export function exactOptional<T extends SomeType>(innerType: T): YatspMiniExactOptional<T> {
|
|
1564
|
+
return new YatspMiniExactOptional({
|
|
1565
|
+
type: "optional",
|
|
1566
|
+
innerType: innerType as any as core.$YatspType,
|
|
1567
|
+
}) as any;
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
// YatspMiniNullable
|
|
1571
|
+
export interface YatspMiniNullable<T extends SomeType = core.$YatspType>
|
|
1572
|
+
extends _YatspMiniType<core.$YatspNullableInternals<T>> {
|
|
1573
|
+
// _yatsp: core.$YatspNullableInternals<T>;
|
|
1574
|
+
}
|
|
1575
|
+
export const YatspMiniNullable: core.$constructor<YatspMiniNullable> = /*@__PURE__*/ core.$constructor(
|
|
1576
|
+
"YatspMiniNullable",
|
|
1577
|
+
(inst, def) => {
|
|
1578
|
+
core.$YatspNullable.init(inst, def);
|
|
1579
|
+
YatspMiniType.init(inst, def);
|
|
1580
|
+
}
|
|
1581
|
+
);
|
|
1582
|
+
|
|
1583
|
+
// @__NO_SIDE_EFFECTS__
|
|
1584
|
+
export function nullable<T extends SomeType>(innerType: T): YatspMiniNullable<T> {
|
|
1585
|
+
return new YatspMiniNullable({
|
|
1586
|
+
type: "nullable",
|
|
1587
|
+
innerType: innerType as any as core.$YatspType,
|
|
1588
|
+
}) as any;
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
// nullish
|
|
1592
|
+
// @__NO_SIDE_EFFECTS__
|
|
1593
|
+
export function nullish<T extends SomeType>(innerType: T): YatspMiniOptional<YatspMiniNullable<T>> {
|
|
1594
|
+
return optional(nullable(innerType));
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
// YatspMiniDefault
|
|
1598
|
+
export interface YatspMiniDefault<T extends SomeType = core.$YatspType>
|
|
1599
|
+
extends _YatspMiniType<core.$YatspDefaultInternals<T>> {
|
|
1600
|
+
// _yatsp: core.$YatspDefaultInternals<T>;
|
|
1601
|
+
}
|
|
1602
|
+
export const YatspMiniDefault: core.$constructor<YatspMiniDefault> = /*@__PURE__*/ core.$constructor(
|
|
1603
|
+
"YatspMiniDefault",
|
|
1604
|
+
(inst, def) => {
|
|
1605
|
+
core.$YatspDefault.init(inst, def);
|
|
1606
|
+
YatspMiniType.init(inst, def);
|
|
1607
|
+
}
|
|
1608
|
+
);
|
|
1609
|
+
|
|
1610
|
+
// @__NO_SIDE_EFFECTS__
|
|
1611
|
+
export function _default<T extends SomeType>(
|
|
1612
|
+
innerType: T,
|
|
1613
|
+
defaultValue: util.NoUndefined<core.output<T>> | (() => util.NoUndefined<core.output<T>>)
|
|
1614
|
+
): YatspMiniDefault<T> {
|
|
1615
|
+
return new YatspMiniDefault({
|
|
1616
|
+
type: "default",
|
|
1617
|
+
innerType: innerType as any as core.$YatspType,
|
|
1618
|
+
get defaultValue() {
|
|
1619
|
+
return typeof defaultValue === "function" ? (defaultValue as Function)() : util.shallowClone(defaultValue);
|
|
1620
|
+
},
|
|
1621
|
+
}) as any;
|
|
1622
|
+
}
|
|
1623
|
+
|
|
1624
|
+
// YatspMiniPrefault
|
|
1625
|
+
export interface YatspMiniPrefault<T extends SomeType = core.$YatspType>
|
|
1626
|
+
extends _YatspMiniType<core.$YatspPrefaultInternals<T>> {
|
|
1627
|
+
// _yatsp: core.$YatspPrefaultInternals<T>;
|
|
1628
|
+
}
|
|
1629
|
+
export const YatspMiniPrefault: core.$constructor<YatspMiniPrefault> = /*@__PURE__*/ core.$constructor(
|
|
1630
|
+
"YatspMiniPrefault",
|
|
1631
|
+
(inst, def) => {
|
|
1632
|
+
core.$YatspPrefault.init(inst, def);
|
|
1633
|
+
YatspMiniType.init(inst, def);
|
|
1634
|
+
}
|
|
1635
|
+
);
|
|
1636
|
+
// @__NO_SIDE_EFFECTS__
|
|
1637
|
+
export function prefault<T extends SomeType>(
|
|
1638
|
+
innerType: T,
|
|
1639
|
+
defaultValue: core.input<T> | (() => core.input<T>)
|
|
1640
|
+
): YatspMiniPrefault<T> {
|
|
1641
|
+
return new YatspMiniPrefault({
|
|
1642
|
+
type: "prefault",
|
|
1643
|
+
innerType: innerType as any as core.$YatspType,
|
|
1644
|
+
get defaultValue() {
|
|
1645
|
+
return typeof defaultValue === "function" ? (defaultValue as Function)() : util.shallowClone(defaultValue);
|
|
1646
|
+
},
|
|
1647
|
+
}) as any;
|
|
1648
|
+
}
|
|
1649
|
+
|
|
1650
|
+
// YatspMiniNonOptional
|
|
1651
|
+
export interface YatspMiniNonOptional<T extends SomeType = core.$YatspType>
|
|
1652
|
+
extends _YatspMiniType<core.$YatspNonOptionalInternals<T>> {
|
|
1653
|
+
// _yatsp: core.$YatspNonOptionalInternals<T>;
|
|
1654
|
+
}
|
|
1655
|
+
export const YatspMiniNonOptional: core.$constructor<YatspMiniNonOptional> = /*@__PURE__*/ core.$constructor(
|
|
1656
|
+
"YatspMiniNonOptional",
|
|
1657
|
+
(inst, def) => {
|
|
1658
|
+
core.$YatspNonOptional.init(inst, def);
|
|
1659
|
+
YatspMiniType.init(inst, def);
|
|
1660
|
+
}
|
|
1661
|
+
);
|
|
1662
|
+
|
|
1663
|
+
// @__NO_SIDE_EFFECTS__
|
|
1664
|
+
export function nonoptional<T extends SomeType>(
|
|
1665
|
+
innerType: T,
|
|
1666
|
+
params?: string | core.$YatspNonOptionalParams
|
|
1667
|
+
): YatspMiniNonOptional<T> {
|
|
1668
|
+
return new YatspMiniNonOptional({
|
|
1669
|
+
type: "nonoptional",
|
|
1670
|
+
innerType: innerType as any as core.$YatspType,
|
|
1671
|
+
...util.normalizeParams(params),
|
|
1672
|
+
}) as any;
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1675
|
+
// YatspMiniSuccess
|
|
1676
|
+
export interface YatspMiniSuccess<T extends SomeType = core.$YatspType>
|
|
1677
|
+
extends _YatspMiniType<core.$YatspSuccessInternals<T>> {
|
|
1678
|
+
// _yatsp: core.$YatspSuccessInternals<T>;
|
|
1679
|
+
}
|
|
1680
|
+
export const YatspMiniSuccess: core.$constructor<YatspMiniSuccess> = /*@__PURE__*/ core.$constructor(
|
|
1681
|
+
"YatspMiniSuccess",
|
|
1682
|
+
(inst, def) => {
|
|
1683
|
+
core.$YatspSuccess.init(inst, def);
|
|
1684
|
+
YatspMiniType.init(inst, def);
|
|
1685
|
+
}
|
|
1686
|
+
);
|
|
1687
|
+
|
|
1688
|
+
// @__NO_SIDE_EFFECTS__
|
|
1689
|
+
export function success<T extends SomeType>(innerType: T): YatspMiniSuccess<T> {
|
|
1690
|
+
return new YatspMiniSuccess({
|
|
1691
|
+
type: "success",
|
|
1692
|
+
innerType: innerType as any as core.$YatspType,
|
|
1693
|
+
}) as any;
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
// YatspMiniCatch
|
|
1697
|
+
export interface YatspMiniCatch<T extends SomeType = core.$YatspType>
|
|
1698
|
+
extends _YatspMiniType<core.$YatspCatchInternals<T>> {
|
|
1699
|
+
// _yatsp: core.$YatspCatchInternals<T>;
|
|
1700
|
+
}
|
|
1701
|
+
export const YatspMiniCatch: core.$constructor<YatspMiniCatch> = /*@__PURE__*/ core.$constructor(
|
|
1702
|
+
"YatspMiniCatch",
|
|
1703
|
+
(inst, def) => {
|
|
1704
|
+
core.$YatspCatch.init(inst, def);
|
|
1705
|
+
YatspMiniType.init(inst, def);
|
|
1706
|
+
}
|
|
1707
|
+
);
|
|
1708
|
+
|
|
1709
|
+
// @__NO_SIDE_EFFECTS__
|
|
1710
|
+
function _catch<T extends SomeType>(
|
|
1711
|
+
innerType: T,
|
|
1712
|
+
catchValue: core.output<T> | ((ctx: core.$YatspCatchCtx) => core.output<T>)
|
|
1713
|
+
): YatspMiniCatch<T> {
|
|
1714
|
+
return new YatspMiniCatch({
|
|
1715
|
+
type: "catch",
|
|
1716
|
+
innerType: innerType as any as core.$YatspType,
|
|
1717
|
+
catchValue: (typeof catchValue === "function" ? catchValue : core.util.constantCatch(catchValue)) as (
|
|
1718
|
+
ctx: core.$YatspCatchCtx
|
|
1719
|
+
) => core.output<T>,
|
|
1720
|
+
}) as any;
|
|
1721
|
+
}
|
|
1722
|
+
export { _catch as catch };
|
|
1723
|
+
|
|
1724
|
+
// YatspMiniNaN
|
|
1725
|
+
export interface YatspMiniNaN extends _YatspMiniType<core.$YatspNaNInternals> {
|
|
1726
|
+
// _yatsp: core.$YatspNaNInternals;
|
|
1727
|
+
}
|
|
1728
|
+
export const YatspMiniNaN: core.$constructor<YatspMiniNaN> = /*@__PURE__*/ core.$constructor(
|
|
1729
|
+
"YatspMiniNaN",
|
|
1730
|
+
(inst, def) => {
|
|
1731
|
+
core.$YatspNaN.init(inst, def);
|
|
1732
|
+
YatspMiniType.init(inst, def);
|
|
1733
|
+
}
|
|
1734
|
+
);
|
|
1735
|
+
|
|
1736
|
+
// @__NO_SIDE_EFFECTS__
|
|
1737
|
+
export function nan(params?: string | core.$YatspNaNParams): YatspMiniNaN {
|
|
1738
|
+
return core._nan(YatspMiniNaN, params) as any;
|
|
1739
|
+
}
|
|
1740
|
+
|
|
1741
|
+
// YatspMiniPipe
|
|
1742
|
+
export interface YatspMiniPipe<A extends SomeType = core.$YatspType, B extends SomeType = core.$YatspType>
|
|
1743
|
+
extends _YatspMiniType<core.$YatspPipeInternals<A, B>> {
|
|
1744
|
+
// _yatsp: core.$YatspPipeInternals<A, B>;
|
|
1745
|
+
}
|
|
1746
|
+
export const YatspMiniPipe: core.$constructor<YatspMiniPipe> = /*@__PURE__*/ core.$constructor(
|
|
1747
|
+
"YatspMiniPipe",
|
|
1748
|
+
(inst, def) => {
|
|
1749
|
+
core.$YatspPipe.init(inst, def);
|
|
1750
|
+
YatspMiniType.init(inst, def);
|
|
1751
|
+
}
|
|
1752
|
+
);
|
|
1753
|
+
|
|
1754
|
+
// @__NO_SIDE_EFFECTS__
|
|
1755
|
+
export function pipe<
|
|
1756
|
+
const A extends SomeType,
|
|
1757
|
+
B extends core.$YatspType<unknown, core.output<A>> = core.$YatspType<unknown, core.output<A>>,
|
|
1758
|
+
>(in_: A, out: B | core.$YatspType<unknown, core.output<A>>): YatspMiniPipe<A, B> {
|
|
1759
|
+
return new YatspMiniPipe({
|
|
1760
|
+
type: "pipe",
|
|
1761
|
+
in: in_ as any as core.$YatspType,
|
|
1762
|
+
out: out as any as core.$YatspType,
|
|
1763
|
+
}) as any;
|
|
1764
|
+
}
|
|
1765
|
+
|
|
1766
|
+
// YatspMiniCodec
|
|
1767
|
+
export interface YatspMiniCodec<A extends SomeType = core.$YatspType, B extends SomeType = core.$YatspType>
|
|
1768
|
+
extends YatspMiniPipe<A, B>,
|
|
1769
|
+
core.$YatspCodec<A, B> {
|
|
1770
|
+
_yatsp: core.$YatspCodecInternals<A, B>;
|
|
1771
|
+
def: core.$YatspCodecDef<A, B>;
|
|
1772
|
+
}
|
|
1773
|
+
export const YatspMiniCodec: core.$constructor<YatspMiniCodec> = /*@__PURE__*/ core.$constructor(
|
|
1774
|
+
"YatspMiniCodec",
|
|
1775
|
+
(inst, def) => {
|
|
1776
|
+
YatspMiniPipe.init(inst, def);
|
|
1777
|
+
core.$YatspCodec.init(inst, def);
|
|
1778
|
+
}
|
|
1779
|
+
);
|
|
1780
|
+
|
|
1781
|
+
// @__NO_SIDE_EFFECTS__
|
|
1782
|
+
export function codec<const A extends SomeType, B extends core.SomeType = core.$YatspType>(
|
|
1783
|
+
in_: A,
|
|
1784
|
+
out: B,
|
|
1785
|
+
params: {
|
|
1786
|
+
decode: (value: core.output<A>, payload: core.ParsePayload<core.output<A>>) => core.util.MaybeAsync<core.input<B>>;
|
|
1787
|
+
encode: (value: core.input<B>, payload: core.ParsePayload<core.input<B>>) => core.util.MaybeAsync<core.output<A>>;
|
|
1788
|
+
}
|
|
1789
|
+
): YatspMiniCodec<A, B> {
|
|
1790
|
+
return new YatspMiniCodec({
|
|
1791
|
+
type: "pipe",
|
|
1792
|
+
in: in_ as any as core.$YatspType,
|
|
1793
|
+
out: out as any as core.$YatspType,
|
|
1794
|
+
transform: params.decode as any,
|
|
1795
|
+
reverseTransform: params.encode as any,
|
|
1796
|
+
}) as any;
|
|
1797
|
+
}
|
|
1798
|
+
|
|
1799
|
+
// @__NO_SIDE_EFFECTS__
|
|
1800
|
+
export function invertCodec<A extends SomeType, B extends SomeType>(codec: YatspMiniCodec<A, B>): YatspMiniCodec<B, A> {
|
|
1801
|
+
const def = codec._yatsp.def;
|
|
1802
|
+
return new YatspMiniCodec({
|
|
1803
|
+
type: "pipe",
|
|
1804
|
+
in: def.out as any,
|
|
1805
|
+
out: def.in as any,
|
|
1806
|
+
transform: def.reverseTransform as any,
|
|
1807
|
+
reverseTransform: def.transform as any,
|
|
1808
|
+
}) as any;
|
|
1809
|
+
}
|
|
1810
|
+
|
|
1811
|
+
// YatspMiniReadonly
|
|
1812
|
+
export interface YatspMiniReadonly<T extends SomeType = core.$YatspType>
|
|
1813
|
+
extends _YatspMiniType<core.$YatspReadonlyInternals<T>> {
|
|
1814
|
+
// _yatsp: core.$YatspReadonlyInternals<T>;
|
|
1815
|
+
}
|
|
1816
|
+
export const YatspMiniReadonly: core.$constructor<YatspMiniReadonly> = /*@__PURE__*/ core.$constructor(
|
|
1817
|
+
"YatspMiniReadonly",
|
|
1818
|
+
(inst, def) => {
|
|
1819
|
+
core.$YatspReadonly.init(inst, def);
|
|
1820
|
+
YatspMiniType.init(inst, def);
|
|
1821
|
+
}
|
|
1822
|
+
);
|
|
1823
|
+
|
|
1824
|
+
// @__NO_SIDE_EFFECTS__
|
|
1825
|
+
export function readonly<T extends SomeType>(innerType: T): YatspMiniReadonly<T> {
|
|
1826
|
+
return new YatspMiniReadonly({
|
|
1827
|
+
type: "readonly",
|
|
1828
|
+
innerType: innerType as any as core.$YatspType,
|
|
1829
|
+
}) as any;
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1832
|
+
// YatspMiniTemplateLiteral
|
|
1833
|
+
export interface YatspMiniTemplateLiteral<Template extends string = string>
|
|
1834
|
+
extends _YatspMiniType<core.$YatspTemplateLiteralInternals<Template>> {
|
|
1835
|
+
// _yatsp: core.$YatspTemplateLiteralInternals<Template>;
|
|
1836
|
+
}
|
|
1837
|
+
export const YatspMiniTemplateLiteral: core.$constructor<YatspMiniTemplateLiteral> = /*@__PURE__*/ core.$constructor(
|
|
1838
|
+
"YatspMiniTemplateLiteral",
|
|
1839
|
+
(inst, def) => {
|
|
1840
|
+
core.$YatspTemplateLiteral.init(inst, def);
|
|
1841
|
+
YatspMiniType.init(inst, def);
|
|
1842
|
+
}
|
|
1843
|
+
);
|
|
1844
|
+
|
|
1845
|
+
// @__NO_SIDE_EFFECTS__
|
|
1846
|
+
export function templateLiteral<const Parts extends core.$YatspTemplateLiteralPart[]>(
|
|
1847
|
+
parts: Parts,
|
|
1848
|
+
params?: string | core.$YatspTemplateLiteralParams
|
|
1849
|
+
): YatspMiniTemplateLiteral<core.$PartsToTemplateLiteral<Parts>> {
|
|
1850
|
+
return new YatspMiniTemplateLiteral({
|
|
1851
|
+
type: "template_literal",
|
|
1852
|
+
parts,
|
|
1853
|
+
...util.normalizeParams(params),
|
|
1854
|
+
}) as any;
|
|
1855
|
+
}
|
|
1856
|
+
|
|
1857
|
+
// YatspMiniLazy
|
|
1858
|
+
export interface YatspMiniLazy<T extends SomeType = core.$YatspType>
|
|
1859
|
+
extends _YatspMiniType<core.$YatspLazyInternals<T>> {
|
|
1860
|
+
// _yatsp: core.$YatspLazyInternals<T>;
|
|
1861
|
+
}
|
|
1862
|
+
export const YatspMiniLazy: core.$constructor<YatspMiniLazy> = /*@__PURE__*/ core.$constructor(
|
|
1863
|
+
"YatspMiniLazy",
|
|
1864
|
+
(inst, def) => {
|
|
1865
|
+
core.$YatspLazy.init(inst, def);
|
|
1866
|
+
YatspMiniType.init(inst, def);
|
|
1867
|
+
}
|
|
1868
|
+
);
|
|
1869
|
+
|
|
1870
|
+
// export function lazy<T extends object>(getter: () => T): T {
|
|
1871
|
+
// return util.createTransparentProxy<T>(getter);
|
|
1872
|
+
// }
|
|
1873
|
+
// @__NO_SIDE_EFFECTS__
|
|
1874
|
+
function _lazy<T extends SomeType>(getter: () => T): YatspMiniLazy<T> {
|
|
1875
|
+
return new YatspMiniLazy({
|
|
1876
|
+
type: "lazy",
|
|
1877
|
+
getter: getter as any,
|
|
1878
|
+
}) as any;
|
|
1879
|
+
}
|
|
1880
|
+
export { _lazy as lazy };
|
|
1881
|
+
|
|
1882
|
+
// YatspMiniPromise
|
|
1883
|
+
export interface YatspMiniPromise<T extends SomeType = core.$YatspType>
|
|
1884
|
+
extends _YatspMiniType<core.$YatspPromiseInternals<T>> {
|
|
1885
|
+
// _yatsp: core.$YatspPromiseInternals<T>;
|
|
1886
|
+
}
|
|
1887
|
+
export const YatspMiniPromise: core.$constructor<YatspMiniPromise> = /*@__PURE__*/ core.$constructor(
|
|
1888
|
+
"YatspMiniPromise",
|
|
1889
|
+
(inst, def) => {
|
|
1890
|
+
core.$YatspPromise.init(inst, def);
|
|
1891
|
+
YatspMiniType.init(inst, def);
|
|
1892
|
+
}
|
|
1893
|
+
);
|
|
1894
|
+
|
|
1895
|
+
// @__NO_SIDE_EFFECTS__
|
|
1896
|
+
export function promise<T extends SomeType>(innerType: T): YatspMiniPromise<T> {
|
|
1897
|
+
return new YatspMiniPromise({
|
|
1898
|
+
type: "promise",
|
|
1899
|
+
innerType: innerType as any as core.$YatspType,
|
|
1900
|
+
}) as any;
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1903
|
+
// YatspMiniCustom
|
|
1904
|
+
export interface YatspMiniCustom<O = unknown, I = unknown> extends _YatspMiniType<core.$YatspCustomInternals<O, I>> {
|
|
1905
|
+
// _yatsp: core.$YatspCustomInternals<O, I>;
|
|
1906
|
+
}
|
|
1907
|
+
export const YatspMiniCustom: core.$constructor<YatspMiniCustom> = /*@__PURE__*/ core.$constructor(
|
|
1908
|
+
"YatspMiniCustom",
|
|
1909
|
+
(inst, def) => {
|
|
1910
|
+
core.$YatspCustom.init(inst, def);
|
|
1911
|
+
YatspMiniType.init(inst, def);
|
|
1912
|
+
}
|
|
1913
|
+
);
|
|
1914
|
+
|
|
1915
|
+
// custom checks
|
|
1916
|
+
// @__NO_SIDE_EFFECTS__
|
|
1917
|
+
export function check<O = unknown>(
|
|
1918
|
+
fn: core.CheckFn<O>,
|
|
1919
|
+
params?: string | core.$YatspCustomParams
|
|
1920
|
+
): core.$YatspCheck<O> {
|
|
1921
|
+
const ch = new core.$YatspCheck({
|
|
1922
|
+
check: "custom",
|
|
1923
|
+
...util.normalizeParams(params),
|
|
1924
|
+
});
|
|
1925
|
+
|
|
1926
|
+
ch._yatsp.check = fn;
|
|
1927
|
+
return ch;
|
|
1928
|
+
}
|
|
1929
|
+
|
|
1930
|
+
// YatspCustom custom schema
|
|
1931
|
+
// @__NO_SIDE_EFFECTS__
|
|
1932
|
+
export function custom<O = unknown, I = O>(
|
|
1933
|
+
fn?: (data: O) => unknown,
|
|
1934
|
+
_params?: string | core.$YatspCustomParams | undefined
|
|
1935
|
+
): YatspMiniCustom<O, I> {
|
|
1936
|
+
return core._custom(YatspMiniCustom, fn ?? (() => true), _params) as any;
|
|
1937
|
+
}
|
|
1938
|
+
|
|
1939
|
+
// refine
|
|
1940
|
+
// @__NO_SIDE_EFFECTS__
|
|
1941
|
+
export function refine<T>(
|
|
1942
|
+
fn: (arg: NoInfer<T>) => util.MaybeAsync<unknown>,
|
|
1943
|
+
_params: string | core.$YatspCustomParams = {}
|
|
1944
|
+
): core.$YatspCheck<T> {
|
|
1945
|
+
return core._refine(YatspMiniCustom, fn, _params);
|
|
1946
|
+
}
|
|
1947
|
+
|
|
1948
|
+
// superRefine
|
|
1949
|
+
// @__NO_SIDE_EFFECTS__
|
|
1950
|
+
export function superRefine<T>(
|
|
1951
|
+
fn: (arg: T, payload: core.$RefinementCtx<T>) => void | Promise<void>,
|
|
1952
|
+
params?: core.$YatspSuperRefineParams
|
|
1953
|
+
): core.$YatspCheck<T> {
|
|
1954
|
+
return core._superRefine(fn, params);
|
|
1955
|
+
}
|
|
1956
|
+
|
|
1957
|
+
// Re-export describe and meta from core
|
|
1958
|
+
export const describe = core.describe;
|
|
1959
|
+
export const meta = core.meta;
|
|
1960
|
+
|
|
1961
|
+
// instanceof
|
|
1962
|
+
abstract class Class {
|
|
1963
|
+
constructor(..._args: any[]) {}
|
|
1964
|
+
}
|
|
1965
|
+
// @__NO_SIDE_EFFECTS__
|
|
1966
|
+
function _instanceof<T extends typeof Class>(
|
|
1967
|
+
cls: T,
|
|
1968
|
+
params: core.$YatspCustomParams = {}
|
|
1969
|
+
): YatspMiniCustom<InstanceType<T>, InstanceType<T>> {
|
|
1970
|
+
const inst = custom((data) => data instanceof cls, params);
|
|
1971
|
+
inst._yatsp.bag.Class = cls;
|
|
1972
|
+
// Override check to emit invalid_type instead of custom
|
|
1973
|
+
inst._yatsp.check = (payload) => {
|
|
1974
|
+
if (!(payload.value instanceof cls)) {
|
|
1975
|
+
payload.issues.push({
|
|
1976
|
+
code: "invalid_type",
|
|
1977
|
+
expected: cls.name,
|
|
1978
|
+
input: payload.value,
|
|
1979
|
+
inst,
|
|
1980
|
+
path: [...(inst._yatsp.def.path ?? [])],
|
|
1981
|
+
});
|
|
1982
|
+
}
|
|
1983
|
+
};
|
|
1984
|
+
return inst as any;
|
|
1985
|
+
}
|
|
1986
|
+
export { _instanceof as instanceof };
|
|
1987
|
+
|
|
1988
|
+
// stringbool
|
|
1989
|
+
export const stringbool: (
|
|
1990
|
+
_params?: string | core.$YatspStringBoolParams
|
|
1991
|
+
) => YatspMiniCodec<YatspMiniString, YatspMiniBoolean> = (...args) =>
|
|
1992
|
+
core._stringbool(
|
|
1993
|
+
{
|
|
1994
|
+
Codec: YatspMiniCodec,
|
|
1995
|
+
Boolean: YatspMiniBoolean,
|
|
1996
|
+
String: YatspMiniString,
|
|
1997
|
+
},
|
|
1998
|
+
...args
|
|
1999
|
+
) as any;
|
|
2000
|
+
|
|
2001
|
+
// json
|
|
2002
|
+
|
|
2003
|
+
// json
|
|
2004
|
+
export type _YatspMiniJSONSchema = YatspMiniUnion<
|
|
2005
|
+
[
|
|
2006
|
+
YatspMiniString,
|
|
2007
|
+
YatspMiniNumber,
|
|
2008
|
+
YatspMiniBoolean,
|
|
2009
|
+
YatspMiniNull,
|
|
2010
|
+
YatspMiniArray<YatspMiniJSONSchema>,
|
|
2011
|
+
YatspMiniRecord<YatspMiniString<string>, YatspMiniJSONSchema>,
|
|
2012
|
+
]
|
|
2013
|
+
>;
|
|
2014
|
+
export type _YatspMiniJSONSchemaInternals = _YatspMiniJSONSchema["_yatsp"];
|
|
2015
|
+
|
|
2016
|
+
export interface YatspMiniJSONSchemaInternals extends _YatspMiniJSONSchemaInternals {
|
|
2017
|
+
output: util.JSONType;
|
|
2018
|
+
input: util.JSONType;
|
|
2019
|
+
}
|
|
2020
|
+
export interface YatspMiniJSONSchema extends _YatspMiniJSONSchema {
|
|
2021
|
+
_yatsp: YatspMiniJSONSchemaInternals;
|
|
2022
|
+
}
|
|
2023
|
+
|
|
2024
|
+
// @__NO_SIDE_EFFECTS__
|
|
2025
|
+
export function json(): YatspMiniJSONSchema {
|
|
2026
|
+
const jsonSchema: any = _lazy(() => {
|
|
2027
|
+
return union([string(), number(), boolean(), _null(), array(jsonSchema), record(string(), jsonSchema)]);
|
|
2028
|
+
});
|
|
2029
|
+
return jsonSchema;
|
|
2030
|
+
}
|
|
2031
|
+
|
|
2032
|
+
// YatspMiniFunction
|
|
2033
|
+
export interface YatspMiniFunction<
|
|
2034
|
+
Args extends core.$YatspFunctionIn = core.$YatspFunctionIn,
|
|
2035
|
+
Returns extends core.$YatspFunctionOut = core.$YatspFunctionOut,
|
|
2036
|
+
> extends _YatspMiniType<core.$YatspFunctionInternals<Args, Returns>>,
|
|
2037
|
+
core.$YatspFunction<Args, Returns> {
|
|
2038
|
+
_def: core.$YatspFunctionDef<Args, Returns>;
|
|
2039
|
+
_input: core.$InferInnerFunctionType<Args, Returns>;
|
|
2040
|
+
_output: core.$InferOuterFunctionType<Args, Returns>;
|
|
2041
|
+
|
|
2042
|
+
input<const Items extends util.TupleItems, const Rest extends core.$YatspFunctionOut = core.$YatspFunctionOut>(
|
|
2043
|
+
args: Items,
|
|
2044
|
+
rest?: Rest
|
|
2045
|
+
): YatspMiniFunction<YatspMiniTuple<Items, Rest>, Returns>;
|
|
2046
|
+
input<NewArgs extends core.$YatspFunctionIn>(args: NewArgs): YatspMiniFunction<NewArgs, Returns>;
|
|
2047
|
+
input(...args: any[]): YatspMiniFunction<any, Returns>;
|
|
2048
|
+
|
|
2049
|
+
output<NewReturns extends core.$YatspFunctionOut>(output: NewReturns): YatspMiniFunction<Args, NewReturns>;
|
|
2050
|
+
}
|
|
2051
|
+
|
|
2052
|
+
export const YatspMiniFunction: core.$constructor<YatspMiniFunction> = /*@__PURE__*/ core.$constructor(
|
|
2053
|
+
"YatspMiniFunction",
|
|
2054
|
+
(inst, def) => {
|
|
2055
|
+
core.$YatspFunction.init(inst, def);
|
|
2056
|
+
YatspMiniType.init(inst, def);
|
|
2057
|
+
}
|
|
2058
|
+
);
|
|
2059
|
+
|
|
2060
|
+
export function _function(): YatspMiniFunction;
|
|
2061
|
+
export function _function<const In extends Array<SomeType> = Array<SomeType>>(params: {
|
|
2062
|
+
input: In;
|
|
2063
|
+
}): YatspMiniFunction<YatspMiniTuple<In, null>, core.$YatspFunctionOut>;
|
|
2064
|
+
export function _function<
|
|
2065
|
+
const In extends Array<SomeType> = Array<SomeType>,
|
|
2066
|
+
const Out extends core.$YatspFunctionOut = core.$YatspFunctionOut,
|
|
2067
|
+
>(params: {
|
|
2068
|
+
input: In;
|
|
2069
|
+
output: Out;
|
|
2070
|
+
}): YatspMiniFunction<YatspMiniTuple<In, null>, Out>;
|
|
2071
|
+
export function _function<const In extends core.$YatspFunctionIn = core.$YatspFunctionIn>(params: {
|
|
2072
|
+
input: In;
|
|
2073
|
+
}): YatspMiniFunction<In, core.$YatspFunctionOut>;
|
|
2074
|
+
export function _function<const Out extends core.$YatspFunctionOut = core.$YatspFunctionOut>(params: {
|
|
2075
|
+
output: Out;
|
|
2076
|
+
}): YatspMiniFunction<core.$YatspFunctionIn, Out>;
|
|
2077
|
+
export function _function<
|
|
2078
|
+
In extends core.$YatspFunctionIn = core.$YatspFunctionIn,
|
|
2079
|
+
Out extends core.$YatspFunctionOut = core.$YatspFunctionOut,
|
|
2080
|
+
>(params?: { input: In; output: Out }): YatspMiniFunction<In, Out>;
|
|
2081
|
+
// @__NO_SIDE_EFFECTS__
|
|
2082
|
+
export function _function(params?: {
|
|
2083
|
+
output?: core.$YatspFunctionOut;
|
|
2084
|
+
input?: core.$YatspFunctionArgs | Array<SomeType>;
|
|
2085
|
+
}): YatspMiniFunction {
|
|
2086
|
+
return new YatspMiniFunction({
|
|
2087
|
+
type: "function",
|
|
2088
|
+
input: Array.isArray(params?.input) ? tuple(params?.input as any) : (params?.input ?? array(unknown())),
|
|
2089
|
+
output: params?.output ?? unknown(),
|
|
2090
|
+
});
|
|
2091
|
+
}
|
|
2092
|
+
|
|
2093
|
+
export { _function as function };
|