@sinclair/typebox 0.32.0-dev-4 → 0.32.0-dev-5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/import/compiler/compiler.mjs +571 -0
- package/build/import/compiler/index.mjs +2 -0
- package/build/import/errors/errors.mjs +531 -0
- package/build/import/errors/index.mjs +1 -0
- package/build/import/index.mjs +69 -0
- package/build/import/system/errors.mjs +150 -0
- package/build/import/system/index.mjs +4 -0
- package/build/import/system/policy.mjs +31 -0
- package/build/import/system/system.mjs +30 -0
- package/build/import/type/any/any.mjs +4 -0
- package/build/import/type/any/index.mjs +1 -0
- package/build/import/type/array/array.mjs +10 -0
- package/build/import/type/array/index.mjs +1 -0
- package/build/import/type/async-iterator/async-iterator.mjs +10 -0
- package/build/import/type/async-iterator/index.mjs +1 -0
- package/build/import/type/awaited/awaited.mjs +28 -0
- package/build/import/type/awaited/index.mjs +1 -0
- package/build/import/type/bigint/bigint.mjs +8 -0
- package/build/import/type/bigint/index.mjs +1 -0
- package/build/import/type/boolean/boolean.mjs +8 -0
- package/build/import/type/boolean/index.mjs +1 -0
- package/build/import/type/clone/index.mjs +2 -0
- package/build/import/type/clone/type.mjs +7 -0
- package/build/import/type/clone/value.mjs +25 -0
- package/build/import/type/composite/composite.mjs +14 -0
- package/build/import/type/composite/index.mjs +1 -0
- package/build/import/type/const/const.mjs +49 -0
- package/build/import/type/const/index.mjs +1 -0
- package/build/import/type/constructor/constructor.mjs +11 -0
- package/build/import/type/constructor/index.mjs +1 -0
- package/build/import/type/constructor-parameters/constructor-parameters.mjs +5 -0
- package/build/import/type/constructor-parameters/index.mjs +1 -0
- package/build/import/type/date/date.mjs +8 -0
- package/build/import/type/date/index.mjs +1 -0
- package/build/import/type/deref/deref.mjs +90 -0
- package/build/import/type/deref/index.mjs +1 -0
- package/build/import/type/discard/discard.mjs +7 -0
- package/build/import/type/discard/index.mjs +1 -0
- package/build/import/type/enum/enum.mjs +14 -0
- package/build/import/type/enum/index.mjs +1 -0
- package/build/import/type/exclude/exclude.mjs +20 -0
- package/build/import/type/exclude/index.mjs +1 -0
- package/build/import/type/extends/extends-check.mjs +450 -0
- package/build/import/type/extends/extends-undefined.mjs +17 -0
- package/build/import/type/extends/extends.mjs +13 -0
- package/build/import/type/extends/index.mjs +3 -0
- package/build/import/type/extract/extract.mjs +20 -0
- package/build/import/type/extract/index.mjs +1 -0
- package/build/import/type/function/function.mjs +11 -0
- package/build/import/type/function/index.mjs +1 -0
- package/build/import/type/guard/index.mjs +2 -0
- package/build/import/type/guard/type.mjs +366 -0
- package/build/import/type/guard/value.mjs +42 -0
- package/build/import/type/helpers/helpers.mjs +3 -0
- package/build/import/type/helpers/index.mjs +1 -0
- package/build/import/type/index.mjs +70 -0
- package/build/import/type/indexed/index.mjs +3 -0
- package/build/import/type/indexed/indexed-key.mjs +29 -0
- package/build/import/type/indexed/indexed-type.mjs +64 -0
- package/build/import/type/indexed/indexed.mjs +9 -0
- package/build/import/type/instance-type/index.mjs +1 -0
- package/build/import/type/instance-type/instance-type.mjs +4 -0
- package/build/import/type/integer/index.mjs +1 -0
- package/build/import/type/integer/integer.mjs +8 -0
- package/build/import/type/intersect/index.mjs +1 -0
- package/build/import/type/intersect/intersect.mjs +25 -0
- package/build/import/type/intrinsic/index.mjs +1 -0
- package/build/import/type/intrinsic/intrinsic.mjs +59 -0
- package/build/import/type/iterator/index.mjs +1 -0
- package/build/import/type/iterator/iterator.mjs +10 -0
- package/build/import/type/keyof/index.mjs +3 -0
- package/build/import/type/keyof/keyof-string.mjs +55 -0
- package/build/import/type/keyof/keyof-type.mjs +15 -0
- package/build/import/type/keyof/keyof.mjs +6 -0
- package/build/import/type/literal/index.mjs +1 -0
- package/build/import/type/literal/literal.mjs +9 -0
- package/build/import/type/mapped/index.mjs +1 -0
- package/build/import/type/mapped/mapped.mjs +14 -0
- package/build/import/type/modifiers/index.mjs +1 -0
- package/build/import/type/modifiers/modifiers.mjs +40 -0
- package/build/import/type/never/index.mjs +1 -0
- package/build/import/type/never/never.mjs +8 -0
- package/build/import/type/not/index.mjs +1 -0
- package/build/import/type/not/not.mjs +9 -0
- package/build/import/type/null/index.mjs +1 -0
- package/build/import/type/null/null.mjs +8 -0
- package/build/import/type/number/index.mjs +1 -0
- package/build/import/type/number/number.mjs +8 -0
- package/build/import/type/object/index.mjs +1 -0
- package/build/import/type/object/object.mjs +14 -0
- package/build/import/type/omit/index.mjs +1 -0
- package/build/import/type/omit/omit.mjs +35 -0
- package/build/import/type/operators/index.mjs +1 -0
- package/build/import/type/operators/operators.mjs +66 -0
- package/build/import/type/optional/index.mjs +1 -0
- package/build/import/type/optional/optional.mjs +5 -0
- package/build/import/type/parameters/index.mjs +1 -0
- package/build/import/type/parameters/parameters.mjs +5 -0
- package/build/import/type/partial/index.mjs +1 -0
- package/build/import/type/partial/partial.mjs +36 -0
- package/build/import/type/patterns/index.mjs +1 -0
- package/build/import/type/patterns/patterns.mjs +6 -0
- package/build/import/type/pick/index.mjs +1 -0
- package/build/import/type/pick/pick.mjs +31 -0
- package/build/import/type/promise/index.mjs +1 -0
- package/build/import/type/promise/promise.mjs +10 -0
- package/build/import/type/readonly/index.mjs +1 -0
- package/build/import/type/readonly/readonly.mjs +5 -0
- package/build/import/type/readonly-optional/index.mjs +1 -0
- package/build/import/type/readonly-optional/readonly-optional.mjs +5 -0
- package/build/import/type/record/index.mjs +1 -0
- package/build/import/type/record/record.mjs +51 -0
- package/build/import/type/recursive/index.mjs +1 -0
- package/build/import/type/recursive/recursive.mjs +15 -0
- package/build/import/type/ref/index.mjs +1 -0
- package/build/import/type/ref/ref.mjs +13 -0
- package/build/import/type/regexp/index.mjs +1 -0
- package/build/import/type/regexp/regexp.mjs +6 -0
- package/build/import/type/registry/format.mjs +19 -0
- package/build/import/type/registry/index.mjs +2 -0
- package/build/import/type/registry/type.mjs +19 -0
- package/build/import/type/required/index.mjs +1 -0
- package/build/import/type/required/required.mjs +35 -0
- package/build/import/type/rest/index.mjs +1 -0
- package/build/import/type/rest/rest.mjs +8 -0
- package/build/import/type/return-type/index.mjs +1 -0
- package/build/import/type/return-type/return-type.mjs +4 -0
- package/build/import/type/schema/anyschema.mjs +1 -0
- package/build/import/type/schema/index.mjs +2 -0
- package/build/import/type/schema/schema.mjs +1 -0
- package/build/import/type/static/index.mjs +1 -0
- package/build/import/type/static/static.mjs +1 -0
- package/build/import/type/strict/index.mjs +1 -0
- package/build/import/type/strict/strict.mjs +3 -0
- package/build/import/type/string/index.mjs +1 -0
- package/build/import/type/string/string.mjs +4 -0
- package/build/import/type/symbol/index.mjs +1 -0
- package/build/import/type/symbol/symbol.mjs +4 -0
- package/build/import/type/symbols/index.mjs +1 -0
- package/build/import/type/symbols/symbols.mjs +5 -0
- package/build/import/type/template-literal/finite.mjs +29 -0
- package/build/import/type/template-literal/generate.mjs +32 -0
- package/build/import/type/template-literal/index.mjs +7 -0
- package/build/import/type/template-literal/parser.mjs +125 -0
- package/build/import/type/template-literal/pattern.mjs +22 -0
- package/build/import/type/template-literal/syntax.mjs +48 -0
- package/build/import/type/template-literal/template-literal.mjs +10 -0
- package/build/import/type/template-literal/union.mjs +13 -0
- package/build/import/type/transform/index.mjs +1 -0
- package/build/import/type/transform/transform.mjs +37 -0
- package/build/import/type/tuple/index.mjs +1 -0
- package/build/import/type/tuple/tuple.mjs +8 -0
- package/build/import/type/type/index.mjs +6 -0
- package/build/import/type/type/javascript.mjs +71 -0
- package/build/import/type/type/json.mjs +171 -0
- package/build/import/type/type/type.mjs +58 -0
- package/build/import/type/uint8array/index.mjs +1 -0
- package/build/import/type/uint8array/uint8array.mjs +4 -0
- package/build/import/type/undefined/index.mjs +1 -0
- package/build/import/type/undefined/undefined.mjs +4 -0
- package/build/import/type/union/index.mjs +1 -0
- package/build/import/type/union/union.mjs +15 -0
- package/build/import/type/unknown/index.mjs +1 -0
- package/build/import/type/unknown/unknown.mjs +7 -0
- package/build/import/type/unsafe/index.mjs +1 -0
- package/build/import/type/unsafe/unsafe.mjs +7 -0
- package/build/import/type/void/index.mjs +1 -0
- package/build/import/type/void/void.mjs +8 -0
- package/build/import/value/cast/cast.mjs +205 -0
- package/build/import/value/cast/index.mjs +1 -0
- package/build/import/value/check/check.mjs +419 -0
- package/build/import/value/check/index.mjs +1 -0
- package/build/import/value/clean/clean.mjs +125 -0
- package/build/import/value/clean/index.mjs +1 -0
- package/build/import/value/clone/clone.mjs +30 -0
- package/build/import/value/clone/index.mjs +1 -0
- package/build/import/value/convert/convert.mjs +231 -0
- package/build/import/value/convert/index.mjs +1 -0
- package/build/import/value/create/create.mjs +460 -0
- package/build/import/value/create/index.mjs +1 -0
- package/build/import/value/default/default.mjs +125 -0
- package/build/import/value/default/index.mjs +1 -0
- package/build/import/value/delta/delta.mjs +152 -0
- package/build/import/value/delta/index.mjs +1 -0
- package/build/import/value/deref/deref.mjs +13 -0
- package/build/import/value/deref/index.mjs +1 -0
- package/build/import/value/equal/equal.mjs +39 -0
- package/build/import/value/equal/index.mjs +1 -0
- package/build/import/value/guard/guard.mjs +66 -0
- package/build/import/value/guard/index.mjs +1 -0
- package/build/import/value/hash/hash.mjs +127 -0
- package/build/import/value/hash/index.mjs +1 -0
- package/build/import/value/index.mjs +18 -0
- package/build/import/value/mutate/index.mjs +1 -0
- package/build/import/value/mutate/mutate.mjs +85 -0
- package/build/import/value/pointer/index.mjs +1 -0
- package/build/import/value/pointer/pointer.mjs +101 -0
- package/build/import/value/transform/decode.mjs +160 -0
- package/build/import/value/transform/encode.mjs +166 -0
- package/build/import/value/transform/has.mjs +99 -0
- package/build/import/value/transform/index.mjs +3 -0
- package/build/import/value/value/index.mjs +1 -0
- package/build/import/value/value/value.mjs +65 -0
- package/compiler/package.json +4 -0
- package/errors/package.json +4 -0
- package/package.json +52 -53
- package/system/package.json +4 -0
- package/type/package.json +4 -0
- package/value/package.json +4 -0
- /package/{compiler → build/default/compiler}/compiler.js +0 -0
- /package/{compiler → build/default/compiler}/index.js +0 -0
- /package/{errors → build/default/errors}/errors.js +0 -0
- /package/{errors → build/default/errors}/index.js +0 -0
- /package/{index.js → build/default/index.js} +0 -0
- /package/{system → build/default/system}/errors.js +0 -0
- /package/{system → build/default/system}/index.js +0 -0
- /package/{system → build/default/system}/policy.js +0 -0
- /package/{system → build/default/system}/system.js +0 -0
- /package/{type → build/default/type}/any/any.js +0 -0
- /package/{type → build/default/type}/any/index.js +0 -0
- /package/{type → build/default/type}/array/array.js +0 -0
- /package/{type → build/default/type}/array/index.js +0 -0
- /package/{type → build/default/type}/async-iterator/async-iterator.js +0 -0
- /package/{type → build/default/type}/async-iterator/index.js +0 -0
- /package/{type → build/default/type}/awaited/awaited.js +0 -0
- /package/{type → build/default/type}/awaited/index.js +0 -0
- /package/{type → build/default/type}/bigint/bigint.js +0 -0
- /package/{type → build/default/type}/bigint/index.js +0 -0
- /package/{type → build/default/type}/boolean/boolean.js +0 -0
- /package/{type → build/default/type}/boolean/index.js +0 -0
- /package/{type → build/default/type}/clone/index.js +0 -0
- /package/{type → build/default/type}/clone/type.js +0 -0
- /package/{type → build/default/type}/clone/value.js +0 -0
- /package/{type → build/default/type}/composite/composite.js +0 -0
- /package/{type → build/default/type}/composite/index.js +0 -0
- /package/{type → build/default/type}/const/const.js +0 -0
- /package/{type → build/default/type}/const/index.js +0 -0
- /package/{type → build/default/type}/constructor/constructor.js +0 -0
- /package/{type → build/default/type}/constructor/index.js +0 -0
- /package/{type → build/default/type}/constructor-parameters/constructor-parameters.js +0 -0
- /package/{type → build/default/type}/constructor-parameters/index.js +0 -0
- /package/{type → build/default/type}/date/date.js +0 -0
- /package/{type → build/default/type}/date/index.js +0 -0
- /package/{type → build/default/type}/deref/deref.js +0 -0
- /package/{type → build/default/type}/deref/index.js +0 -0
- /package/{type → build/default/type}/discard/discard.js +0 -0
- /package/{type → build/default/type}/discard/index.js +0 -0
- /package/{type → build/default/type}/enum/enum.js +0 -0
- /package/{type → build/default/type}/enum/index.js +0 -0
- /package/{type → build/default/type}/exclude/exclude.js +0 -0
- /package/{type → build/default/type}/exclude/index.js +0 -0
- /package/{type → build/default/type}/extends/extends-check.js +0 -0
- /package/{type → build/default/type}/extends/extends-undefined.js +0 -0
- /package/{type → build/default/type}/extends/extends.js +0 -0
- /package/{type → build/default/type}/extends/index.js +0 -0
- /package/{type → build/default/type}/extract/extract.js +0 -0
- /package/{type → build/default/type}/extract/index.js +0 -0
- /package/{type → build/default/type}/function/function.js +0 -0
- /package/{type → build/default/type}/function/index.js +0 -0
- /package/{type → build/default/type}/guard/index.js +0 -0
- /package/{type → build/default/type}/guard/type.js +0 -0
- /package/{type → build/default/type}/guard/value.js +0 -0
- /package/{type → build/default/type}/helpers/helpers.js +0 -0
- /package/{type → build/default/type}/helpers/index.js +0 -0
- /package/{type → build/default/type}/index.js +0 -0
- /package/{type → build/default/type}/indexed/index.js +0 -0
- /package/{type → build/default/type}/indexed/indexed-key.js +0 -0
- /package/{type → build/default/type}/indexed/indexed-type.js +0 -0
- /package/{type → build/default/type}/indexed/indexed.js +0 -0
- /package/{type → build/default/type}/instance-type/index.js +0 -0
- /package/{type → build/default/type}/instance-type/instance-type.js +0 -0
- /package/{type → build/default/type}/integer/index.js +0 -0
- /package/{type → build/default/type}/integer/integer.js +0 -0
- /package/{type → build/default/type}/intersect/index.js +0 -0
- /package/{type → build/default/type}/intersect/intersect.js +0 -0
- /package/{type → build/default/type}/intrinsic/index.js +0 -0
- /package/{type → build/default/type}/intrinsic/intrinsic.js +0 -0
- /package/{type → build/default/type}/iterator/index.js +0 -0
- /package/{type → build/default/type}/iterator/iterator.js +0 -0
- /package/{type → build/default/type}/keyof/index.js +0 -0
- /package/{type → build/default/type}/keyof/keyof-string.js +0 -0
- /package/{type → build/default/type}/keyof/keyof-type.js +0 -0
- /package/{type → build/default/type}/keyof/keyof.js +0 -0
- /package/{type → build/default/type}/literal/index.js +0 -0
- /package/{type → build/default/type}/literal/literal.js +0 -0
- /package/{type → build/default/type}/mapped/index.js +0 -0
- /package/{type → build/default/type}/mapped/mapped.js +0 -0
- /package/{type → build/default/type}/modifiers/index.js +0 -0
- /package/{type → build/default/type}/modifiers/modifiers.js +0 -0
- /package/{type → build/default/type}/never/index.js +0 -0
- /package/{type → build/default/type}/never/never.js +0 -0
- /package/{type → build/default/type}/not/index.js +0 -0
- /package/{type → build/default/type}/not/not.js +0 -0
- /package/{type → build/default/type}/null/index.js +0 -0
- /package/{type → build/default/type}/null/null.js +0 -0
- /package/{type → build/default/type}/number/index.js +0 -0
- /package/{type → build/default/type}/number/number.js +0 -0
- /package/{type → build/default/type}/object/index.js +0 -0
- /package/{type → build/default/type}/object/object.js +0 -0
- /package/{type → build/default/type}/omit/index.js +0 -0
- /package/{type → build/default/type}/omit/omit.js +0 -0
- /package/{type → build/default/type}/operators/index.js +0 -0
- /package/{type → build/default/type}/operators/operators.js +0 -0
- /package/{type → build/default/type}/optional/index.js +0 -0
- /package/{type → build/default/type}/optional/optional.js +0 -0
- /package/{type → build/default/type}/parameters/index.js +0 -0
- /package/{type → build/default/type}/parameters/parameters.js +0 -0
- /package/{type → build/default/type}/partial/index.js +0 -0
- /package/{type → build/default/type}/partial/partial.js +0 -0
- /package/{type → build/default/type}/patterns/index.js +0 -0
- /package/{type → build/default/type}/patterns/patterns.js +0 -0
- /package/{type → build/default/type}/pick/index.js +0 -0
- /package/{type → build/default/type}/pick/pick.js +0 -0
- /package/{type → build/default/type}/promise/index.js +0 -0
- /package/{type → build/default/type}/promise/promise.js +0 -0
- /package/{type → build/default/type}/readonly/index.js +0 -0
- /package/{type → build/default/type}/readonly/readonly.js +0 -0
- /package/{type → build/default/type}/readonly-optional/index.js +0 -0
- /package/{type → build/default/type}/readonly-optional/readonly-optional.js +0 -0
- /package/{type → build/default/type}/record/index.js +0 -0
- /package/{type → build/default/type}/record/record.js +0 -0
- /package/{type → build/default/type}/recursive/index.js +0 -0
- /package/{type → build/default/type}/recursive/recursive.js +0 -0
- /package/{type → build/default/type}/ref/index.js +0 -0
- /package/{type → build/default/type}/ref/ref.js +0 -0
- /package/{type → build/default/type}/regexp/index.js +0 -0
- /package/{type → build/default/type}/regexp/regexp.js +0 -0
- /package/{type → build/default/type}/registry/format.js +0 -0
- /package/{type → build/default/type}/registry/index.js +0 -0
- /package/{type → build/default/type}/registry/type.js +0 -0
- /package/{type → build/default/type}/required/index.js +0 -0
- /package/{type → build/default/type}/required/required.js +0 -0
- /package/{type → build/default/type}/rest/index.js +0 -0
- /package/{type → build/default/type}/rest/rest.js +0 -0
- /package/{type → build/default/type}/return-type/index.js +0 -0
- /package/{type → build/default/type}/return-type/return-type.js +0 -0
- /package/{type → build/default/type}/schema/anyschema.js +0 -0
- /package/{type → build/default/type}/schema/index.js +0 -0
- /package/{type → build/default/type}/schema/schema.js +0 -0
- /package/{type → build/default/type}/static/index.js +0 -0
- /package/{type → build/default/type}/static/static.js +0 -0
- /package/{type → build/default/type}/strict/index.js +0 -0
- /package/{type → build/default/type}/strict/strict.js +0 -0
- /package/{type → build/default/type}/string/index.js +0 -0
- /package/{type → build/default/type}/string/string.js +0 -0
- /package/{type → build/default/type}/symbol/index.js +0 -0
- /package/{type → build/default/type}/symbol/symbol.js +0 -0
- /package/{type → build/default/type}/symbols/index.js +0 -0
- /package/{type → build/default/type}/symbols/symbols.js +0 -0
- /package/{type → build/default/type}/template-literal/finite.js +0 -0
- /package/{type → build/default/type}/template-literal/generate.js +0 -0
- /package/{type → build/default/type}/template-literal/index.js +0 -0
- /package/{type → build/default/type}/template-literal/parser.js +0 -0
- /package/{type → build/default/type}/template-literal/pattern.js +0 -0
- /package/{type → build/default/type}/template-literal/syntax.js +0 -0
- /package/{type → build/default/type}/template-literal/template-literal.js +0 -0
- /package/{type → build/default/type}/template-literal/union.js +0 -0
- /package/{type → build/default/type}/transform/index.js +0 -0
- /package/{type → build/default/type}/transform/transform.js +0 -0
- /package/{type → build/default/type}/tuple/index.js +0 -0
- /package/{type → build/default/type}/tuple/tuple.js +0 -0
- /package/{type → build/default/type}/type/index.js +0 -0
- /package/{type → build/default/type}/type/javascript.js +0 -0
- /package/{type → build/default/type}/type/json.js +0 -0
- /package/{type → build/default/type}/type/type.js +0 -0
- /package/{type → build/default/type}/uint8array/index.js +0 -0
- /package/{type → build/default/type}/uint8array/uint8array.js +0 -0
- /package/{type → build/default/type}/undefined/index.js +0 -0
- /package/{type → build/default/type}/undefined/undefined.js +0 -0
- /package/{type → build/default/type}/union/index.js +0 -0
- /package/{type → build/default/type}/union/union.js +0 -0
- /package/{type → build/default/type}/unknown/index.js +0 -0
- /package/{type → build/default/type}/unknown/unknown.js +0 -0
- /package/{type → build/default/type}/unsafe/index.js +0 -0
- /package/{type → build/default/type}/unsafe/unsafe.js +0 -0
- /package/{type → build/default/type}/void/index.js +0 -0
- /package/{type → build/default/type}/void/void.js +0 -0
- /package/{value → build/default/value}/cast/cast.js +0 -0
- /package/{value → build/default/value}/cast/index.js +0 -0
- /package/{value → build/default/value}/check/check.js +0 -0
- /package/{value → build/default/value}/check/index.js +0 -0
- /package/{value → build/default/value}/clean/clean.js +0 -0
- /package/{value → build/default/value}/clean/index.js +0 -0
- /package/{value → build/default/value}/clone/clone.js +0 -0
- /package/{value → build/default/value}/clone/index.js +0 -0
- /package/{value → build/default/value}/convert/convert.js +0 -0
- /package/{value → build/default/value}/convert/index.js +0 -0
- /package/{value → build/default/value}/create/create.js +0 -0
- /package/{value → build/default/value}/create/index.js +0 -0
- /package/{value → build/default/value}/default/default.js +0 -0
- /package/{value → build/default/value}/default/index.js +0 -0
- /package/{value → build/default/value}/delta/delta.js +0 -0
- /package/{value → build/default/value}/delta/index.js +0 -0
- /package/{value → build/default/value}/deref/deref.js +0 -0
- /package/{value → build/default/value}/deref/index.js +0 -0
- /package/{value → build/default/value}/equal/equal.js +0 -0
- /package/{value → build/default/value}/equal/index.js +0 -0
- /package/{value → build/default/value}/guard/guard.js +0 -0
- /package/{value → build/default/value}/guard/index.js +0 -0
- /package/{value → build/default/value}/hash/hash.js +0 -0
- /package/{value → build/default/value}/hash/index.js +0 -0
- /package/{value → build/default/value}/index.js +0 -0
- /package/{value → build/default/value}/mutate/index.js +0 -0
- /package/{value → build/default/value}/mutate/mutate.js +0 -0
- /package/{value → build/default/value}/pointer/index.js +0 -0
- /package/{value → build/default/value}/pointer/pointer.js +0 -0
- /package/{value → build/default/value}/transform/decode.js +0 -0
- /package/{value → build/default/value}/transform/encode.js +0 -0
- /package/{value → build/default/value}/transform/has.js +0 -0
- /package/{value → build/default/value}/transform/index.js +0 -0
- /package/{value → build/default/value}/value/index.js +0 -0
- /package/{value → build/default/value}/value/value.js +0 -0
- /package/{compiler → build/types/compiler}/compiler.d.ts +0 -0
- /package/{compiler → build/types/compiler}/index.d.ts +0 -0
- /package/{errors → build/types/errors}/errors.d.ts +0 -0
- /package/{errors → build/types/errors}/index.d.ts +0 -0
- /package/{index.d.ts → build/types/index.d.ts} +0 -0
- /package/{system → build/types/system}/errors.d.ts +0 -0
- /package/{system → build/types/system}/index.d.ts +0 -0
- /package/{system → build/types/system}/policy.d.ts +0 -0
- /package/{system → build/types/system}/system.d.ts +0 -0
- /package/{type → build/types/type}/any/any.d.ts +0 -0
- /package/{type → build/types/type}/any/index.d.ts +0 -0
- /package/{type → build/types/type}/array/array.d.ts +0 -0
- /package/{type → build/types/type}/array/index.d.ts +0 -0
- /package/{type → build/types/type}/async-iterator/async-iterator.d.ts +0 -0
- /package/{type → build/types/type}/async-iterator/index.d.ts +0 -0
- /package/{type → build/types/type}/awaited/awaited.d.ts +0 -0
- /package/{type → build/types/type}/awaited/index.d.ts +0 -0
- /package/{type → build/types/type}/bigint/bigint.d.ts +0 -0
- /package/{type → build/types/type}/bigint/index.d.ts +0 -0
- /package/{type → build/types/type}/boolean/boolean.d.ts +0 -0
- /package/{type → build/types/type}/boolean/index.d.ts +0 -0
- /package/{type → build/types/type}/clone/index.d.ts +0 -0
- /package/{type → build/types/type}/clone/type.d.ts +0 -0
- /package/{type → build/types/type}/clone/value.d.ts +0 -0
- /package/{type → build/types/type}/composite/composite.d.ts +0 -0
- /package/{type → build/types/type}/composite/index.d.ts +0 -0
- /package/{type → build/types/type}/const/const.d.ts +0 -0
- /package/{type → build/types/type}/const/index.d.ts +0 -0
- /package/{type → build/types/type}/constructor/constructor.d.ts +0 -0
- /package/{type → build/types/type}/constructor/index.d.ts +0 -0
- /package/{type → build/types/type}/constructor-parameters/constructor-parameters.d.ts +0 -0
- /package/{type → build/types/type}/constructor-parameters/index.d.ts +0 -0
- /package/{type → build/types/type}/date/date.d.ts +0 -0
- /package/{type → build/types/type}/date/index.d.ts +0 -0
- /package/{type → build/types/type}/deref/deref.d.ts +0 -0
- /package/{type → build/types/type}/deref/index.d.ts +0 -0
- /package/{type → build/types/type}/discard/discard.d.ts +0 -0
- /package/{type → build/types/type}/discard/index.d.ts +0 -0
- /package/{type → build/types/type}/enum/enum.d.ts +0 -0
- /package/{type → build/types/type}/enum/index.d.ts +0 -0
- /package/{type → build/types/type}/exclude/exclude.d.ts +0 -0
- /package/{type → build/types/type}/exclude/index.d.ts +0 -0
- /package/{type → build/types/type}/extends/extends-check.d.ts +0 -0
- /package/{type → build/types/type}/extends/extends-undefined.d.ts +0 -0
- /package/{type → build/types/type}/extends/extends.d.ts +0 -0
- /package/{type → build/types/type}/extends/index.d.ts +0 -0
- /package/{type → build/types/type}/extract/extract.d.ts +0 -0
- /package/{type → build/types/type}/extract/index.d.ts +0 -0
- /package/{type → build/types/type}/function/function.d.ts +0 -0
- /package/{type → build/types/type}/function/index.d.ts +0 -0
- /package/{type → build/types/type}/guard/index.d.ts +0 -0
- /package/{type → build/types/type}/guard/type.d.ts +0 -0
- /package/{type → build/types/type}/guard/value.d.ts +0 -0
- /package/{type → build/types/type}/helpers/helpers.d.ts +0 -0
- /package/{type → build/types/type}/helpers/index.d.ts +0 -0
- /package/{type → build/types/type}/index.d.ts +0 -0
- /package/{type → build/types/type}/indexed/index.d.ts +0 -0
- /package/{type → build/types/type}/indexed/indexed-key.d.ts +0 -0
- /package/{type → build/types/type}/indexed/indexed-type.d.ts +0 -0
- /package/{type → build/types/type}/indexed/indexed.d.ts +0 -0
- /package/{type → build/types/type}/instance-type/index.d.ts +0 -0
- /package/{type → build/types/type}/instance-type/instance-type.d.ts +0 -0
- /package/{type → build/types/type}/integer/index.d.ts +0 -0
- /package/{type → build/types/type}/integer/integer.d.ts +0 -0
- /package/{type → build/types/type}/intersect/index.d.ts +0 -0
- /package/{type → build/types/type}/intersect/intersect.d.ts +0 -0
- /package/{type → build/types/type}/intrinsic/index.d.ts +0 -0
- /package/{type → build/types/type}/intrinsic/intrinsic.d.ts +0 -0
- /package/{type → build/types/type}/iterator/index.d.ts +0 -0
- /package/{type → build/types/type}/iterator/iterator.d.ts +0 -0
- /package/{type → build/types/type}/keyof/index.d.ts +0 -0
- /package/{type → build/types/type}/keyof/keyof-string.d.ts +0 -0
- /package/{type → build/types/type}/keyof/keyof-type.d.ts +0 -0
- /package/{type → build/types/type}/keyof/keyof.d.ts +0 -0
- /package/{type → build/types/type}/literal/index.d.ts +0 -0
- /package/{type → build/types/type}/literal/literal.d.ts +0 -0
- /package/{type → build/types/type}/mapped/index.d.ts +0 -0
- /package/{type → build/types/type}/mapped/mapped.d.ts +0 -0
- /package/{type → build/types/type}/modifiers/index.d.ts +0 -0
- /package/{type → build/types/type}/modifiers/modifiers.d.ts +0 -0
- /package/{type → build/types/type}/never/index.d.ts +0 -0
- /package/{type → build/types/type}/never/never.d.ts +0 -0
- /package/{type → build/types/type}/not/index.d.ts +0 -0
- /package/{type → build/types/type}/not/not.d.ts +0 -0
- /package/{type → build/types/type}/null/index.d.ts +0 -0
- /package/{type → build/types/type}/null/null.d.ts +0 -0
- /package/{type → build/types/type}/number/index.d.ts +0 -0
- /package/{type → build/types/type}/number/number.d.ts +0 -0
- /package/{type → build/types/type}/object/index.d.ts +0 -0
- /package/{type → build/types/type}/object/object.d.ts +0 -0
- /package/{type → build/types/type}/omit/index.d.ts +0 -0
- /package/{type → build/types/type}/omit/omit.d.ts +0 -0
- /package/{type → build/types/type}/operators/index.d.ts +0 -0
- /package/{type → build/types/type}/operators/operators.d.ts +0 -0
- /package/{type → build/types/type}/optional/index.d.ts +0 -0
- /package/{type → build/types/type}/optional/optional.d.ts +0 -0
- /package/{type → build/types/type}/parameters/index.d.ts +0 -0
- /package/{type → build/types/type}/parameters/parameters.d.ts +0 -0
- /package/{type → build/types/type}/partial/index.d.ts +0 -0
- /package/{type → build/types/type}/partial/partial.d.ts +0 -0
- /package/{type → build/types/type}/patterns/index.d.ts +0 -0
- /package/{type → build/types/type}/patterns/patterns.d.ts +0 -0
- /package/{type → build/types/type}/pick/index.d.ts +0 -0
- /package/{type → build/types/type}/pick/pick.d.ts +0 -0
- /package/{type → build/types/type}/promise/index.d.ts +0 -0
- /package/{type → build/types/type}/promise/promise.d.ts +0 -0
- /package/{type → build/types/type}/readonly/index.d.ts +0 -0
- /package/{type → build/types/type}/readonly/readonly.d.ts +0 -0
- /package/{type → build/types/type}/readonly-optional/index.d.ts +0 -0
- /package/{type → build/types/type}/readonly-optional/readonly-optional.d.ts +0 -0
- /package/{type → build/types/type}/record/index.d.ts +0 -0
- /package/{type → build/types/type}/record/record.d.ts +0 -0
- /package/{type → build/types/type}/recursive/index.d.ts +0 -0
- /package/{type → build/types/type}/recursive/recursive.d.ts +0 -0
- /package/{type → build/types/type}/ref/index.d.ts +0 -0
- /package/{type → build/types/type}/ref/ref.d.ts +0 -0
- /package/{type → build/types/type}/regexp/index.d.ts +0 -0
- /package/{type → build/types/type}/regexp/regexp.d.ts +0 -0
- /package/{type → build/types/type}/registry/format.d.ts +0 -0
- /package/{type → build/types/type}/registry/index.d.ts +0 -0
- /package/{type → build/types/type}/registry/type.d.ts +0 -0
- /package/{type → build/types/type}/required/index.d.ts +0 -0
- /package/{type → build/types/type}/required/required.d.ts +0 -0
- /package/{type → build/types/type}/rest/index.d.ts +0 -0
- /package/{type → build/types/type}/rest/rest.d.ts +0 -0
- /package/{type → build/types/type}/return-type/index.d.ts +0 -0
- /package/{type → build/types/type}/return-type/return-type.d.ts +0 -0
- /package/{type → build/types/type}/schema/anyschema.d.ts +0 -0
- /package/{type → build/types/type}/schema/index.d.ts +0 -0
- /package/{type → build/types/type}/schema/schema.d.ts +0 -0
- /package/{type → build/types/type}/static/index.d.ts +0 -0
- /package/{type → build/types/type}/static/static.d.ts +0 -0
- /package/{type → build/types/type}/strict/index.d.ts +0 -0
- /package/{type → build/types/type}/strict/strict.d.ts +0 -0
- /package/{type → build/types/type}/string/index.d.ts +0 -0
- /package/{type → build/types/type}/string/string.d.ts +0 -0
- /package/{type → build/types/type}/symbol/index.d.ts +0 -0
- /package/{type → build/types/type}/symbol/symbol.d.ts +0 -0
- /package/{type → build/types/type}/symbols/index.d.ts +0 -0
- /package/{type → build/types/type}/symbols/symbols.d.ts +0 -0
- /package/{type → build/types/type}/template-literal/finite.d.ts +0 -0
- /package/{type → build/types/type}/template-literal/generate.d.ts +0 -0
- /package/{type → build/types/type}/template-literal/index.d.ts +0 -0
- /package/{type → build/types/type}/template-literal/parser.d.ts +0 -0
- /package/{type → build/types/type}/template-literal/pattern.d.ts +0 -0
- /package/{type → build/types/type}/template-literal/syntax.d.ts +0 -0
- /package/{type → build/types/type}/template-literal/template-literal.d.ts +0 -0
- /package/{type → build/types/type}/template-literal/union.d.ts +0 -0
- /package/{type → build/types/type}/transform/index.d.ts +0 -0
- /package/{type → build/types/type}/transform/transform.d.ts +0 -0
- /package/{type → build/types/type}/tuple/index.d.ts +0 -0
- /package/{type → build/types/type}/tuple/tuple.d.ts +0 -0
- /package/{type → build/types/type}/type/index.d.ts +0 -0
- /package/{type → build/types/type}/type/javascript.d.ts +0 -0
- /package/{type → build/types/type}/type/json.d.ts +0 -0
- /package/{type → build/types/type}/type/type.d.ts +0 -0
- /package/{type → build/types/type}/uint8array/index.d.ts +0 -0
- /package/{type → build/types/type}/uint8array/uint8array.d.ts +0 -0
- /package/{type → build/types/type}/undefined/index.d.ts +0 -0
- /package/{type → build/types/type}/undefined/undefined.d.ts +0 -0
- /package/{type → build/types/type}/union/index.d.ts +0 -0
- /package/{type → build/types/type}/union/union.d.ts +0 -0
- /package/{type → build/types/type}/unknown/index.d.ts +0 -0
- /package/{type → build/types/type}/unknown/unknown.d.ts +0 -0
- /package/{type → build/types/type}/unsafe/index.d.ts +0 -0
- /package/{type → build/types/type}/unsafe/unsafe.d.ts +0 -0
- /package/{type → build/types/type}/void/index.d.ts +0 -0
- /package/{type → build/types/type}/void/void.d.ts +0 -0
- /package/{value → build/types/value}/cast/cast.d.ts +0 -0
- /package/{value → build/types/value}/cast/index.d.ts +0 -0
- /package/{value → build/types/value}/check/check.d.ts +0 -0
- /package/{value → build/types/value}/check/index.d.ts +0 -0
- /package/{value → build/types/value}/clean/clean.d.ts +0 -0
- /package/{value → build/types/value}/clean/index.d.ts +0 -0
- /package/{value → build/types/value}/clone/clone.d.ts +0 -0
- /package/{value → build/types/value}/clone/index.d.ts +0 -0
- /package/{value → build/types/value}/convert/convert.d.ts +0 -0
- /package/{value → build/types/value}/convert/index.d.ts +0 -0
- /package/{value → build/types/value}/create/create.d.ts +0 -0
- /package/{value → build/types/value}/create/index.d.ts +0 -0
- /package/{value → build/types/value}/default/default.d.ts +0 -0
- /package/{value → build/types/value}/default/index.d.ts +0 -0
- /package/{value → build/types/value}/delta/delta.d.ts +0 -0
- /package/{value → build/types/value}/delta/index.d.ts +0 -0
- /package/{value → build/types/value}/deref/deref.d.ts +0 -0
- /package/{value → build/types/value}/deref/index.d.ts +0 -0
- /package/{value → build/types/value}/equal/equal.d.ts +0 -0
- /package/{value → build/types/value}/equal/index.d.ts +0 -0
- /package/{value → build/types/value}/guard/guard.d.ts +0 -0
- /package/{value → build/types/value}/guard/index.d.ts +0 -0
- /package/{value → build/types/value}/hash/hash.d.ts +0 -0
- /package/{value → build/types/value}/hash/index.d.ts +0 -0
- /package/{value → build/types/value}/index.d.ts +0 -0
- /package/{value → build/types/value}/mutate/index.d.ts +0 -0
- /package/{value → build/types/value}/mutate/mutate.d.ts +0 -0
- /package/{value → build/types/value}/pointer/index.d.ts +0 -0
- /package/{value → build/types/value}/pointer/pointer.d.ts +0 -0
- /package/{value → build/types/value}/transform/decode.d.ts +0 -0
- /package/{value → build/types/value}/transform/encode.d.ts +0 -0
- /package/{value → build/types/value}/transform/has.d.ts +0 -0
- /package/{value → build/types/value}/transform/index.d.ts +0 -0
- /package/{value → build/types/value}/value/index.d.ts +0 -0
- /package/{value → build/types/value}/value/value.d.ts +0 -0
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { IsArray, IsObject, IsDate, IsUndefined, IsString, IsNumber, IsBoolean, IsBigInt, IsSymbol } from '../guard/index.mjs';
|
|
2
|
+
import { Clone } from '../clone/index.mjs';
|
|
3
|
+
import { Check } from '../check/index.mjs';
|
|
4
|
+
import { Deref } from '../deref/index.mjs';
|
|
5
|
+
import { TObject as IsObjectType } from '../../type/guard/type.mjs';
|
|
6
|
+
import { Kind } from '../../type/symbols/index.mjs';
|
|
7
|
+
import { Composite } from '../../type/composite/index.mjs';
|
|
8
|
+
export class ValueConvertUnknownTypeError extends Error {
|
|
9
|
+
schema;
|
|
10
|
+
constructor(schema) {
|
|
11
|
+
super('Unknown type');
|
|
12
|
+
this.schema = schema;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function IsStringNumeric(value) {
|
|
16
|
+
return IsString(value) && !isNaN(value) && !isNaN(parseFloat(value));
|
|
17
|
+
}
|
|
18
|
+
function IsValueToString(value) {
|
|
19
|
+
return IsBigInt(value) || IsBoolean(value) || IsNumber(value);
|
|
20
|
+
}
|
|
21
|
+
function IsValueTrue(value) {
|
|
22
|
+
return value === true || (IsNumber(value) && value === 1) || (IsBigInt(value) && value === BigInt('1')) || (IsString(value) && (value.toLowerCase() === 'true' || value === '1'));
|
|
23
|
+
}
|
|
24
|
+
function IsValueFalse(value) {
|
|
25
|
+
return value === false || (IsNumber(value) && (value === 0 || Object.is(value, -0))) || (IsBigInt(value) && value === BigInt('0')) || (IsString(value) && (value.toLowerCase() === 'false' || value === '0' || value === '-0'));
|
|
26
|
+
}
|
|
27
|
+
function IsTimeStringWithTimeZone(value) {
|
|
28
|
+
return IsString(value) && /^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i.test(value);
|
|
29
|
+
}
|
|
30
|
+
function IsTimeStringWithoutTimeZone(value) {
|
|
31
|
+
return IsString(value) && /^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)?$/i.test(value);
|
|
32
|
+
}
|
|
33
|
+
function IsDateTimeStringWithTimeZone(value) {
|
|
34
|
+
return IsString(value) && /^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i.test(value);
|
|
35
|
+
}
|
|
36
|
+
function IsDateTimeStringWithoutTimeZone(value) {
|
|
37
|
+
return IsString(value) && /^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)?$/i.test(value);
|
|
38
|
+
}
|
|
39
|
+
function IsDateString(value) {
|
|
40
|
+
return IsString(value) && /^\d\d\d\d-[0-1]\d-[0-3]\d$/i.test(value);
|
|
41
|
+
}
|
|
42
|
+
function TryConvertLiteralString(value, target) {
|
|
43
|
+
const conversion = TryConvertString(value);
|
|
44
|
+
return conversion === target ? conversion : value;
|
|
45
|
+
}
|
|
46
|
+
function TryConvertLiteralNumber(value, target) {
|
|
47
|
+
const conversion = TryConvertNumber(value);
|
|
48
|
+
return conversion === target ? conversion : value;
|
|
49
|
+
}
|
|
50
|
+
function TryConvertLiteralBoolean(value, target) {
|
|
51
|
+
const conversion = TryConvertBoolean(value);
|
|
52
|
+
return conversion === target ? conversion : value;
|
|
53
|
+
}
|
|
54
|
+
function TryConvertLiteral(schema, value) {
|
|
55
|
+
return (IsString(schema.const) ? TryConvertLiteralString(value, schema.const) :
|
|
56
|
+
IsNumber(schema.const) ? TryConvertLiteralNumber(value, schema.const) :
|
|
57
|
+
IsBoolean(schema.const) ? TryConvertLiteralBoolean(value, schema.const) :
|
|
58
|
+
Clone(value));
|
|
59
|
+
}
|
|
60
|
+
function TryConvertBoolean(value) {
|
|
61
|
+
return IsValueTrue(value) ? true : IsValueFalse(value) ? false : value;
|
|
62
|
+
}
|
|
63
|
+
function TryConvertBigInt(value) {
|
|
64
|
+
return IsStringNumeric(value) ? BigInt(parseInt(value)) : IsNumber(value) ? BigInt(value | 0) : IsValueFalse(value) ? BigInt(0) : IsValueTrue(value) ? BigInt(1) : value;
|
|
65
|
+
}
|
|
66
|
+
function TryConvertString(value) {
|
|
67
|
+
return IsValueToString(value) ? value.toString() : IsSymbol(value) && value.description !== undefined ? value.description.toString() : value;
|
|
68
|
+
}
|
|
69
|
+
function TryConvertNumber(value) {
|
|
70
|
+
return IsStringNumeric(value) ? parseFloat(value) : IsValueTrue(value) ? 1 : IsValueFalse(value) ? 0 : value;
|
|
71
|
+
}
|
|
72
|
+
function TryConvertInteger(value) {
|
|
73
|
+
return IsStringNumeric(value) ? parseInt(value) : IsNumber(value) ? value | 0 : IsValueTrue(value) ? 1 : IsValueFalse(value) ? 0 : value;
|
|
74
|
+
}
|
|
75
|
+
function TryConvertNull(value) {
|
|
76
|
+
return IsString(value) && value.toLowerCase() === 'null' ? null : value;
|
|
77
|
+
}
|
|
78
|
+
function TryConvertUndefined(value) {
|
|
79
|
+
return IsString(value) && value === 'undefined' ? undefined : value;
|
|
80
|
+
}
|
|
81
|
+
function TryConvertDate(value) {
|
|
82
|
+
return (IsDate(value) ? value :
|
|
83
|
+
IsNumber(value) ? new Date(value) :
|
|
84
|
+
IsValueTrue(value) ? new Date(1) :
|
|
85
|
+
IsValueFalse(value) ? new Date(0) :
|
|
86
|
+
IsStringNumeric(value) ? new Date(parseInt(value)) :
|
|
87
|
+
IsTimeStringWithoutTimeZone(value) ? new Date(`1970-01-01T${value}.000Z`) :
|
|
88
|
+
IsTimeStringWithTimeZone(value) ? new Date(`1970-01-01T${value}`) :
|
|
89
|
+
IsDateTimeStringWithoutTimeZone(value) ? new Date(`${value}.000Z`) :
|
|
90
|
+
IsDateTimeStringWithTimeZone(value) ? new Date(value) :
|
|
91
|
+
IsDateString(value) ? new Date(`${value}T00:00:00.000Z`) :
|
|
92
|
+
value);
|
|
93
|
+
}
|
|
94
|
+
function Default(value) {
|
|
95
|
+
return value;
|
|
96
|
+
}
|
|
97
|
+
function TArray(schema, references, value) {
|
|
98
|
+
if (IsArray(value)) {
|
|
99
|
+
return value.map((value) => Visit(schema.items, references, value));
|
|
100
|
+
}
|
|
101
|
+
return value;
|
|
102
|
+
}
|
|
103
|
+
function TBigInt(schema, references, value) {
|
|
104
|
+
return TryConvertBigInt(value);
|
|
105
|
+
}
|
|
106
|
+
function TBoolean(schema, references, value) {
|
|
107
|
+
return TryConvertBoolean(value);
|
|
108
|
+
}
|
|
109
|
+
function TDate(schema, references, value) {
|
|
110
|
+
return TryConvertDate(value);
|
|
111
|
+
}
|
|
112
|
+
function TInteger(schema, references, value) {
|
|
113
|
+
return TryConvertInteger(value);
|
|
114
|
+
}
|
|
115
|
+
function TIntersect(schema, references, value) {
|
|
116
|
+
const allObjects = schema.allOf.every(schema => IsObjectType(schema));
|
|
117
|
+
if (allObjects)
|
|
118
|
+
return Visit(Composite(schema.allOf), references, value);
|
|
119
|
+
return Visit(schema.allOf[0], references, value);
|
|
120
|
+
}
|
|
121
|
+
function TLiteral(schema, references, value) {
|
|
122
|
+
return TryConvertLiteral(schema, value);
|
|
123
|
+
}
|
|
124
|
+
function TNull(schema, references, value) {
|
|
125
|
+
return TryConvertNull(value);
|
|
126
|
+
}
|
|
127
|
+
function TNumber(schema, references, value) {
|
|
128
|
+
return TryConvertNumber(value);
|
|
129
|
+
}
|
|
130
|
+
function TObject(schema, references, value) {
|
|
131
|
+
const isConvertable = IsObject(value);
|
|
132
|
+
if (!isConvertable)
|
|
133
|
+
return value;
|
|
134
|
+
return Object.getOwnPropertyNames(schema.properties).reduce((value, key) => {
|
|
135
|
+
return !IsUndefined(value[key])
|
|
136
|
+
? ({ ...value, [key]: Visit(schema.properties[key], references, value[key]) })
|
|
137
|
+
: ({ ...value });
|
|
138
|
+
}, value);
|
|
139
|
+
}
|
|
140
|
+
function TRecord(schema, references, value) {
|
|
141
|
+
const propertyKey = Object.getOwnPropertyNames(schema.patternProperties)[0];
|
|
142
|
+
const property = schema.patternProperties[propertyKey];
|
|
143
|
+
const result = {};
|
|
144
|
+
for (const [propKey, propValue] of Object.entries(value)) {
|
|
145
|
+
result[propKey] = Visit(property, references, propValue);
|
|
146
|
+
}
|
|
147
|
+
return result;
|
|
148
|
+
}
|
|
149
|
+
function TRef(schema, references, value) {
|
|
150
|
+
return Visit(Deref(schema, references), references, value);
|
|
151
|
+
}
|
|
152
|
+
function TString(schema, references, value) {
|
|
153
|
+
return TryConvertString(value);
|
|
154
|
+
}
|
|
155
|
+
function TSymbol(schema, references, value) {
|
|
156
|
+
return IsString(value) || IsNumber(value) ? Symbol(value) : value;
|
|
157
|
+
}
|
|
158
|
+
function TThis(schema, references, value) {
|
|
159
|
+
return Visit(Deref(schema, references), references, value);
|
|
160
|
+
}
|
|
161
|
+
function TTuple(schema, references, value) {
|
|
162
|
+
const isConvertable = IsArray(value) && !IsUndefined(schema.items);
|
|
163
|
+
if (!isConvertable)
|
|
164
|
+
return value;
|
|
165
|
+
return value.map((value, index) => {
|
|
166
|
+
return (index < schema.items.length)
|
|
167
|
+
? Visit(schema.items[index], references, value)
|
|
168
|
+
: value;
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
function TUndefined(schema, references, value) {
|
|
172
|
+
return TryConvertUndefined(value);
|
|
173
|
+
}
|
|
174
|
+
function TUnion(schema, references, value) {
|
|
175
|
+
for (const subschema of schema.anyOf) {
|
|
176
|
+
const converted = Visit(subschema, references, value);
|
|
177
|
+
if (Check(subschema, references, converted)) {
|
|
178
|
+
return converted;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return value;
|
|
182
|
+
}
|
|
183
|
+
function Visit(schema, references, value) {
|
|
184
|
+
const references_ = IsString(schema.$id) ? [...references, schema] : references;
|
|
185
|
+
const schema_ = schema;
|
|
186
|
+
switch (schema[Kind]) {
|
|
187
|
+
case 'Array':
|
|
188
|
+
return TArray(schema_, references_, value);
|
|
189
|
+
case 'BigInt':
|
|
190
|
+
return TBigInt(schema_, references_, value);
|
|
191
|
+
case 'Boolean':
|
|
192
|
+
return TBoolean(schema_, references_, value);
|
|
193
|
+
case 'Date':
|
|
194
|
+
return TDate(schema_, references_, value);
|
|
195
|
+
case 'Integer':
|
|
196
|
+
return TInteger(schema_, references_, value);
|
|
197
|
+
case 'Intersect':
|
|
198
|
+
return TIntersect(schema_, references_, value);
|
|
199
|
+
case 'Literal':
|
|
200
|
+
return TLiteral(schema_, references_, value);
|
|
201
|
+
case 'Null':
|
|
202
|
+
return TNull(schema_, references_, value);
|
|
203
|
+
case 'Number':
|
|
204
|
+
return TNumber(schema_, references_, value);
|
|
205
|
+
case 'Object':
|
|
206
|
+
return TObject(schema_, references_, value);
|
|
207
|
+
case 'Record':
|
|
208
|
+
return TRecord(schema_, references_, value);
|
|
209
|
+
case 'Ref':
|
|
210
|
+
return TRef(schema_, references_, value);
|
|
211
|
+
case 'String':
|
|
212
|
+
return TString(schema_, references_, value);
|
|
213
|
+
case 'Symbol':
|
|
214
|
+
return TSymbol(schema_, references_, value);
|
|
215
|
+
case 'This':
|
|
216
|
+
return TThis(schema_, references_, value);
|
|
217
|
+
case 'Tuple':
|
|
218
|
+
return TTuple(schema_, references_, value);
|
|
219
|
+
case 'Undefined':
|
|
220
|
+
return TUndefined(schema_, references_, value);
|
|
221
|
+
case 'Union':
|
|
222
|
+
return TUnion(schema_, references_, value);
|
|
223
|
+
default:
|
|
224
|
+
return Default(value);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
export function Convert(...args) {
|
|
228
|
+
return args.length === 3
|
|
229
|
+
? Visit(args[0], args[1], args[2])
|
|
230
|
+
: Visit(args[0], [], args[1]);
|
|
231
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './convert.mjs';
|
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
import { HasPropertyKey, IsString } from '../guard/index.mjs';
|
|
2
|
+
import { Check } from '../check/index.mjs';
|
|
3
|
+
import { Deref } from '../deref/index.mjs';
|
|
4
|
+
import { TemplateLiteralParseExact, IsTemplateLiteralFinite, TemplateLiteralGenerate } from '../../type/template-literal/index.mjs';
|
|
5
|
+
import { PatternStringExact, PatternNumberExact } from '../../type/patterns/index.mjs';
|
|
6
|
+
import { TypeRegistry } from '../../type/registry/index.mjs';
|
|
7
|
+
import { Kind } from '../../type/symbols/index.mjs';
|
|
8
|
+
export class ValueCreateUnknownTypeError extends Error {
|
|
9
|
+
schema;
|
|
10
|
+
constructor(schema) {
|
|
11
|
+
super('Unknown type');
|
|
12
|
+
this.schema = schema;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export class ValueCreateNeverTypeError extends Error {
|
|
16
|
+
schema;
|
|
17
|
+
constructor(schema) {
|
|
18
|
+
super('Never types cannot be created');
|
|
19
|
+
this.schema = schema;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export class ValueCreateNotTypeError extends Error {
|
|
23
|
+
schema;
|
|
24
|
+
constructor(schema) {
|
|
25
|
+
super('Not types must have a default value');
|
|
26
|
+
this.schema = schema;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export class ValueCreateIntersectTypeError extends Error {
|
|
30
|
+
schema;
|
|
31
|
+
constructor(schema) {
|
|
32
|
+
super('Intersect produced invalid value. Consider using a default value.');
|
|
33
|
+
this.schema = schema;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export class ValueCreateTempateLiteralTypeError extends Error {
|
|
37
|
+
schema;
|
|
38
|
+
constructor(schema) {
|
|
39
|
+
super('Can only create template literal values from patterns that produce finite sequences. Consider using a default value.');
|
|
40
|
+
this.schema = schema;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export class ValueCreateRecursiveInstantiationError extends Error {
|
|
44
|
+
schema;
|
|
45
|
+
recursiveMaxDepth;
|
|
46
|
+
constructor(schema, recursiveMaxDepth) {
|
|
47
|
+
super('Value cannot be created as recursive type may produce value of infinite size. Consider using a default.');
|
|
48
|
+
this.schema = schema;
|
|
49
|
+
this.recursiveMaxDepth = recursiveMaxDepth;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function TAny(schema, references) {
|
|
53
|
+
if (HasPropertyKey(schema, 'default')) {
|
|
54
|
+
return schema.default;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
return {};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function TArray(schema, references) {
|
|
61
|
+
if (schema.uniqueItems === true && !HasPropertyKey(schema, 'default')) {
|
|
62
|
+
throw new Error('ValueCreate.Array: Array with the uniqueItems constraint requires a default value');
|
|
63
|
+
}
|
|
64
|
+
else if ('contains' in schema && !HasPropertyKey(schema, 'default')) {
|
|
65
|
+
throw new Error('ValueCreate.Array: Array with the contains constraint requires a default value');
|
|
66
|
+
}
|
|
67
|
+
else if ('default' in schema) {
|
|
68
|
+
return schema.default;
|
|
69
|
+
}
|
|
70
|
+
else if (schema.minItems !== undefined) {
|
|
71
|
+
return Array.from({ length: schema.minItems }).map((item) => {
|
|
72
|
+
return Visit(schema.items, references);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
return [];
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function TAsyncIterator(schema, references) {
|
|
80
|
+
if (HasPropertyKey(schema, 'default')) {
|
|
81
|
+
return schema.default;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
return (async function* () { })();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function TBigInt(schema, references) {
|
|
88
|
+
if (HasPropertyKey(schema, 'default')) {
|
|
89
|
+
return schema.default;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
return BigInt(0);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function TBoolean(schema, references) {
|
|
96
|
+
if (HasPropertyKey(schema, 'default')) {
|
|
97
|
+
return schema.default;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function TConstructor(schema, references) {
|
|
104
|
+
if (HasPropertyKey(schema, 'default')) {
|
|
105
|
+
return schema.default;
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
const value = Visit(schema.returns, references);
|
|
109
|
+
if (typeof value === 'object' && !Array.isArray(value)) {
|
|
110
|
+
return class {
|
|
111
|
+
constructor() {
|
|
112
|
+
for (const [key, val] of Object.entries(value)) {
|
|
113
|
+
const self = this;
|
|
114
|
+
self[key] = val;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
return class {
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function TDate(schema, references) {
|
|
126
|
+
if (HasPropertyKey(schema, 'default')) {
|
|
127
|
+
return schema.default;
|
|
128
|
+
}
|
|
129
|
+
else if (schema.minimumTimestamp !== undefined) {
|
|
130
|
+
return new Date(schema.minimumTimestamp);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
return new Date();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function TFunction(schema, references) {
|
|
137
|
+
if (HasPropertyKey(schema, 'default')) {
|
|
138
|
+
return schema.default;
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
return () => Visit(schema.returns, references);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
function TInteger(schema, references) {
|
|
145
|
+
if (HasPropertyKey(schema, 'default')) {
|
|
146
|
+
return schema.default;
|
|
147
|
+
}
|
|
148
|
+
else if (schema.minimum !== undefined) {
|
|
149
|
+
return schema.minimum;
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
return 0;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function TIntersect(schema, references) {
|
|
156
|
+
if (HasPropertyKey(schema, 'default')) {
|
|
157
|
+
return schema.default;
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
const value = schema.allOf.reduce((acc, schema) => {
|
|
161
|
+
const next = Visit(schema, references);
|
|
162
|
+
return typeof next === 'object' ? { ...acc, ...next } : next;
|
|
163
|
+
}, {});
|
|
164
|
+
if (!Check(schema, references, value))
|
|
165
|
+
throw new ValueCreateIntersectTypeError(schema);
|
|
166
|
+
return value;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
function TIterator(schema, references) {
|
|
170
|
+
if (HasPropertyKey(schema, 'default')) {
|
|
171
|
+
return schema.default;
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
return (function* () { })();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function TLiteral(schema, references) {
|
|
178
|
+
if (HasPropertyKey(schema, 'default')) {
|
|
179
|
+
return schema.default;
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
return schema.const;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
function TNever(schema, references) {
|
|
186
|
+
throw new ValueCreateNeverTypeError(schema);
|
|
187
|
+
}
|
|
188
|
+
function TNot(schema, references) {
|
|
189
|
+
if (HasPropertyKey(schema, 'default')) {
|
|
190
|
+
return schema.default;
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
throw new ValueCreateNotTypeError(schema);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
function TNull(schema, references) {
|
|
197
|
+
if (HasPropertyKey(schema, 'default')) {
|
|
198
|
+
return schema.default;
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
function TNumber(schema, references) {
|
|
205
|
+
if (HasPropertyKey(schema, 'default')) {
|
|
206
|
+
return schema.default;
|
|
207
|
+
}
|
|
208
|
+
else if (schema.minimum !== undefined) {
|
|
209
|
+
return schema.minimum;
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
return 0;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
function TObject(schema, references) {
|
|
216
|
+
if (HasPropertyKey(schema, 'default')) {
|
|
217
|
+
return schema.default;
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
const required = new Set(schema.required);
|
|
221
|
+
return (schema.default ||
|
|
222
|
+
Object.entries(schema.properties).reduce((acc, [key, schema]) => {
|
|
223
|
+
return required.has(key) ? { ...acc, [key]: Visit(schema, references) } : { ...acc };
|
|
224
|
+
}, {}));
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
function TPromise(schema, references) {
|
|
228
|
+
if (HasPropertyKey(schema, 'default')) {
|
|
229
|
+
return schema.default;
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
return Promise.resolve(Visit(schema.item, references));
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
function TRecord(schema, references) {
|
|
236
|
+
const [keyPattern, valueSchema] = Object.entries(schema.patternProperties)[0];
|
|
237
|
+
if (HasPropertyKey(schema, 'default')) {
|
|
238
|
+
return schema.default;
|
|
239
|
+
}
|
|
240
|
+
else if (!(keyPattern === PatternStringExact || keyPattern === PatternNumberExact)) {
|
|
241
|
+
const propertyKeys = keyPattern.slice(1, keyPattern.length - 1).split('|');
|
|
242
|
+
return propertyKeys.reduce((acc, key) => {
|
|
243
|
+
return { ...acc, [key]: Visit(valueSchema, references) };
|
|
244
|
+
}, {});
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
return {};
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
function TRef(schema, references) {
|
|
251
|
+
if (HasPropertyKey(schema, 'default')) {
|
|
252
|
+
return schema.default;
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
return Visit(Deref(schema, references), references);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
function TString(schema, references) {
|
|
259
|
+
if (schema.pattern !== undefined) {
|
|
260
|
+
if (!HasPropertyKey(schema, 'default')) {
|
|
261
|
+
throw new Error('ValueCreate.String: String types with patterns must specify a default value');
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
return schema.default;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
else if (schema.format !== undefined) {
|
|
268
|
+
if (!HasPropertyKey(schema, 'default')) {
|
|
269
|
+
throw new Error('ValueCreate.String: String types with formats must specify a default value');
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
return schema.default;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
if (HasPropertyKey(schema, 'default')) {
|
|
277
|
+
return schema.default;
|
|
278
|
+
}
|
|
279
|
+
else if (schema.minLength !== undefined) {
|
|
280
|
+
return Array.from({ length: schema.minLength })
|
|
281
|
+
.map(() => '.')
|
|
282
|
+
.join('');
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
return '';
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
function TSymbol(schema, references) {
|
|
290
|
+
if (HasPropertyKey(schema, 'default')) {
|
|
291
|
+
return schema.default;
|
|
292
|
+
}
|
|
293
|
+
else if ('value' in schema) {
|
|
294
|
+
return Symbol.for(schema.value);
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
return Symbol();
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
function TTemplateLiteral(schema, references) {
|
|
301
|
+
if (HasPropertyKey(schema, 'default')) {
|
|
302
|
+
return schema.default;
|
|
303
|
+
}
|
|
304
|
+
const expression = TemplateLiteralParseExact(schema.pattern);
|
|
305
|
+
if (!IsTemplateLiteralFinite(expression))
|
|
306
|
+
throw new ValueCreateTempateLiteralTypeError(schema);
|
|
307
|
+
const sequence = TemplateLiteralGenerate(expression);
|
|
308
|
+
return sequence.next().value;
|
|
309
|
+
}
|
|
310
|
+
function TThis(schema, references) {
|
|
311
|
+
if (recursiveDepth++ > recursiveMaxDepth)
|
|
312
|
+
throw new ValueCreateRecursiveInstantiationError(schema, recursiveMaxDepth);
|
|
313
|
+
if (HasPropertyKey(schema, 'default')) {
|
|
314
|
+
return schema.default;
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
return Visit(Deref(schema, references), references);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
function TTuple(schema, references) {
|
|
321
|
+
if (HasPropertyKey(schema, 'default')) {
|
|
322
|
+
return schema.default;
|
|
323
|
+
}
|
|
324
|
+
if (schema.items === undefined) {
|
|
325
|
+
return [];
|
|
326
|
+
}
|
|
327
|
+
else {
|
|
328
|
+
return Array.from({ length: schema.minItems }).map((_, index) => Visit(schema.items[index], references));
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
function TUndefined(schema, references) {
|
|
332
|
+
if (HasPropertyKey(schema, 'default')) {
|
|
333
|
+
return schema.default;
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
return undefined;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
function TUnion(schema, references) {
|
|
340
|
+
if (HasPropertyKey(schema, 'default')) {
|
|
341
|
+
return schema.default;
|
|
342
|
+
}
|
|
343
|
+
else if (schema.anyOf.length === 0) {
|
|
344
|
+
throw new Error('ValueCreate.Union: Cannot create Union with zero variants');
|
|
345
|
+
}
|
|
346
|
+
else {
|
|
347
|
+
return Visit(schema.anyOf[0], references);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
function TUint8Array(schema, references) {
|
|
351
|
+
if (HasPropertyKey(schema, 'default')) {
|
|
352
|
+
return schema.default;
|
|
353
|
+
}
|
|
354
|
+
else if (schema.minByteLength !== undefined) {
|
|
355
|
+
return new Uint8Array(schema.minByteLength);
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
return new Uint8Array(0);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
function TUnknown(schema, references) {
|
|
362
|
+
if (HasPropertyKey(schema, 'default')) {
|
|
363
|
+
return schema.default;
|
|
364
|
+
}
|
|
365
|
+
else {
|
|
366
|
+
return {};
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
function TVoid(schema, references) {
|
|
370
|
+
if (HasPropertyKey(schema, 'default')) {
|
|
371
|
+
return schema.default;
|
|
372
|
+
}
|
|
373
|
+
else {
|
|
374
|
+
return void 0;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
function TKind(schema, references) {
|
|
378
|
+
if (HasPropertyKey(schema, 'default')) {
|
|
379
|
+
return schema.default;
|
|
380
|
+
}
|
|
381
|
+
else {
|
|
382
|
+
throw new Error('User defined types must specify a default value');
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
function Visit(schema, references) {
|
|
386
|
+
const references_ = IsString(schema.$id) ? [...references, schema] : references;
|
|
387
|
+
const schema_ = schema;
|
|
388
|
+
switch (schema_[Kind]) {
|
|
389
|
+
case 'Any':
|
|
390
|
+
return TAny(schema_, references_);
|
|
391
|
+
case 'Array':
|
|
392
|
+
return TArray(schema_, references_);
|
|
393
|
+
case 'AsyncIterator':
|
|
394
|
+
return TAsyncIterator(schema_, references_);
|
|
395
|
+
case 'BigInt':
|
|
396
|
+
return TBigInt(schema_, references_);
|
|
397
|
+
case 'Boolean':
|
|
398
|
+
return TBoolean(schema_, references_);
|
|
399
|
+
case 'Constructor':
|
|
400
|
+
return TConstructor(schema_, references_);
|
|
401
|
+
case 'Date':
|
|
402
|
+
return TDate(schema_, references_);
|
|
403
|
+
case 'Function':
|
|
404
|
+
return TFunction(schema_, references_);
|
|
405
|
+
case 'Integer':
|
|
406
|
+
return TInteger(schema_, references_);
|
|
407
|
+
case 'Intersect':
|
|
408
|
+
return TIntersect(schema_, references_);
|
|
409
|
+
case 'Iterator':
|
|
410
|
+
return TIterator(schema_, references_);
|
|
411
|
+
case 'Literal':
|
|
412
|
+
return TLiteral(schema_, references_);
|
|
413
|
+
case 'Never':
|
|
414
|
+
return TNever(schema_, references_);
|
|
415
|
+
case 'Not':
|
|
416
|
+
return TNot(schema_, references_);
|
|
417
|
+
case 'Null':
|
|
418
|
+
return TNull(schema_, references_);
|
|
419
|
+
case 'Number':
|
|
420
|
+
return TNumber(schema_, references_);
|
|
421
|
+
case 'Object':
|
|
422
|
+
return TObject(schema_, references_);
|
|
423
|
+
case 'Promise':
|
|
424
|
+
return TPromise(schema_, references_);
|
|
425
|
+
case 'Record':
|
|
426
|
+
return TRecord(schema_, references_);
|
|
427
|
+
case 'Ref':
|
|
428
|
+
return TRef(schema_, references_);
|
|
429
|
+
case 'String':
|
|
430
|
+
return TString(schema_, references_);
|
|
431
|
+
case 'Symbol':
|
|
432
|
+
return TSymbol(schema_, references_);
|
|
433
|
+
case 'TemplateLiteral':
|
|
434
|
+
return TTemplateLiteral(schema_, references_);
|
|
435
|
+
case 'This':
|
|
436
|
+
return TThis(schema_, references_);
|
|
437
|
+
case 'Tuple':
|
|
438
|
+
return TTuple(schema_, references_);
|
|
439
|
+
case 'Undefined':
|
|
440
|
+
return TUndefined(schema_, references_);
|
|
441
|
+
case 'Union':
|
|
442
|
+
return TUnion(schema_, references_);
|
|
443
|
+
case 'Uint8Array':
|
|
444
|
+
return TUint8Array(schema_, references_);
|
|
445
|
+
case 'Unknown':
|
|
446
|
+
return TUnknown(schema_, references_);
|
|
447
|
+
case 'Void':
|
|
448
|
+
return TVoid(schema_, references_);
|
|
449
|
+
default:
|
|
450
|
+
if (!TypeRegistry.Has(schema_[Kind]))
|
|
451
|
+
throw new ValueCreateUnknownTypeError(schema_);
|
|
452
|
+
return TKind(schema_, references_);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
const recursiveMaxDepth = 512;
|
|
456
|
+
let recursiveDepth = 0;
|
|
457
|
+
export function Create(...args) {
|
|
458
|
+
recursiveDepth = 0;
|
|
459
|
+
return args.length === 2 ? Visit(args[0], args[1]) : Visit(args[0], []);
|
|
460
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './create.mjs';
|