@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,13 @@
|
|
|
1
|
+
import { Kind } from '../symbols/index.mjs';
|
|
2
|
+
import { IsString, IsUndefined } from '../guard/value.mjs';
|
|
3
|
+
export function Ref(unresolved, options = {}) {
|
|
4
|
+
if (IsString(unresolved))
|
|
5
|
+
return { ...options, [Kind]: 'Ref', $ref: unresolved };
|
|
6
|
+
if (IsUndefined(unresolved.$id))
|
|
7
|
+
throw new Error('Reference target type must specify an $id');
|
|
8
|
+
return {
|
|
9
|
+
...options,
|
|
10
|
+
[Kind]: 'Ref',
|
|
11
|
+
$ref: unresolved.$id,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './regexp.mjs';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IsString } from '../guard/value.mjs';
|
|
2
|
+
import { Kind } from '../symbols/index.mjs';
|
|
3
|
+
export function RegExp(unresolved, options = {}) {
|
|
4
|
+
const pattern = IsString(unresolved) ? unresolved : unresolved.source;
|
|
5
|
+
return { ...options, [Kind]: 'String', type: 'string', pattern };
|
|
6
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const map = new Map();
|
|
2
|
+
export function Entries() {
|
|
3
|
+
return new Map(map);
|
|
4
|
+
}
|
|
5
|
+
export function Clear() {
|
|
6
|
+
return map.clear();
|
|
7
|
+
}
|
|
8
|
+
export function Delete(format) {
|
|
9
|
+
return map.delete(format);
|
|
10
|
+
}
|
|
11
|
+
export function Has(format) {
|
|
12
|
+
return map.has(format);
|
|
13
|
+
}
|
|
14
|
+
export function Set(format, func) {
|
|
15
|
+
map.set(format, func);
|
|
16
|
+
}
|
|
17
|
+
export function Get(format) {
|
|
18
|
+
return map.get(format);
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const map = new Map();
|
|
2
|
+
export function Entries() {
|
|
3
|
+
return new Map(map);
|
|
4
|
+
}
|
|
5
|
+
export function Clear() {
|
|
6
|
+
return map.clear();
|
|
7
|
+
}
|
|
8
|
+
export function Delete(kind) {
|
|
9
|
+
return map.delete(kind);
|
|
10
|
+
}
|
|
11
|
+
export function Has(kind) {
|
|
12
|
+
return map.has(kind);
|
|
13
|
+
}
|
|
14
|
+
export function Set(kind, func) {
|
|
15
|
+
map.set(kind, func);
|
|
16
|
+
}
|
|
17
|
+
export function Get(kind) {
|
|
18
|
+
return map.get(kind);
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './required.mjs';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Intersect } from '../intersect/index.mjs';
|
|
2
|
+
import { Union } from '../union/index.mjs';
|
|
3
|
+
import { Object } from '../object/index.mjs';
|
|
4
|
+
import { OptionalKind, TransformKind } from '../symbols/index.mjs';
|
|
5
|
+
import { CloneType } from '../clone/type.mjs';
|
|
6
|
+
import { Discard } from '../discard/index.mjs';
|
|
7
|
+
import { TIntersect as IsIntersectType, TUnion as IsUnionType, TObject as IsObjectType } from '../guard/type.mjs';
|
|
8
|
+
function FromIntersect(T) {
|
|
9
|
+
const [L, ...R] = T;
|
|
10
|
+
return (T.length > 0
|
|
11
|
+
? [RequiredResolve(L), ...FromIntersect(R)]
|
|
12
|
+
: []);
|
|
13
|
+
}
|
|
14
|
+
function FromUnion(T) {
|
|
15
|
+
const [L, ...R] = T;
|
|
16
|
+
return (T.length > 0
|
|
17
|
+
? [RequiredResolve(L), ...FromUnion(R)]
|
|
18
|
+
: []);
|
|
19
|
+
}
|
|
20
|
+
function FromProperties(T) {
|
|
21
|
+
return globalThis.Object.getOwnPropertyNames(T).reduce((Acc, K) => {
|
|
22
|
+
return { ...Acc, [K]: Discard(T[K], [OptionalKind]) };
|
|
23
|
+
}, {});
|
|
24
|
+
}
|
|
25
|
+
export function RequiredResolve(T) {
|
|
26
|
+
return (IsIntersectType(T) ? Intersect(FromIntersect(T.allOf)) :
|
|
27
|
+
IsUnionType(T) ? Union(FromUnion(T.anyOf)) :
|
|
28
|
+
IsObjectType(T) ? Object(FromProperties(T.properties)) :
|
|
29
|
+
Object({}));
|
|
30
|
+
}
|
|
31
|
+
export function Required(T, options = {}) {
|
|
32
|
+
const D = Discard(T, [TransformKind, '$id', 'required']);
|
|
33
|
+
const R = CloneType(RequiredResolve(T), options);
|
|
34
|
+
return { ...D, ...R };
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './rest.mjs';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CloneRest } from '../clone/type.mjs';
|
|
2
|
+
import { TIntersect as IsIntersectType, TUnion as IsUnionType, TTuple as IsTupleType } from '../guard/type.mjs';
|
|
3
|
+
export function RestResolve(T) {
|
|
4
|
+
return (IsIntersectType(T) ? [...T.allOf] : IsUnionType(T) ? [...T.anyOf] : IsTupleType(T) ? [...(T.items ?? [])] : []);
|
|
5
|
+
}
|
|
6
|
+
export function Rest(T) {
|
|
7
|
+
return CloneRest(RestResolve(T));
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './return-type.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { Kind, Hint, ReadonlyKind, OptionalKind } from '../symbols/index.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './static.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './strict.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './string.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './symbol.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './symbols.mjs';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export const TransformKind = Symbol.for('TypeBox.Transform');
|
|
2
|
+
export const ReadonlyKind = Symbol.for('TypeBox.Readonly');
|
|
3
|
+
export const OptionalKind = Symbol.for('TypeBox.Optional');
|
|
4
|
+
export const Hint = Symbol.for('TypeBox.Hint');
|
|
5
|
+
export const Kind = Symbol.for('TypeBox.Kind');
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export class TemplateLiteralFiniteError extends Error {
|
|
2
|
+
}
|
|
3
|
+
function IsNumberExpression(expression) {
|
|
4
|
+
return (expression.type === 'or' &&
|
|
5
|
+
expression.expr.length === 2 &&
|
|
6
|
+
expression.expr[0].type === 'const' &&
|
|
7
|
+
expression.expr[0].const === '0' &&
|
|
8
|
+
expression.expr[1].type === 'const' &&
|
|
9
|
+
expression.expr[1].const === '[1-9][0-9]*');
|
|
10
|
+
}
|
|
11
|
+
function IsBooleanExpression(expression) {
|
|
12
|
+
return (expression.type === 'or' &&
|
|
13
|
+
expression.expr.length === 2 &&
|
|
14
|
+
expression.expr[0].type === 'const' &&
|
|
15
|
+
expression.expr[0].const === 'true' &&
|
|
16
|
+
expression.expr[1].type === 'const' &&
|
|
17
|
+
expression.expr[1].const === 'false');
|
|
18
|
+
}
|
|
19
|
+
function IsStringExpression(expression) {
|
|
20
|
+
return expression.type === 'const' && expression.const === '.*';
|
|
21
|
+
}
|
|
22
|
+
export function IsTemplateLiteralFinite(expression) {
|
|
23
|
+
return (IsBooleanExpression(expression) ? true :
|
|
24
|
+
IsNumberExpression(expression) || IsStringExpression(expression) ? false :
|
|
25
|
+
(expression.type === 'and') ? expression.expr.every((expr) => IsTemplateLiteralFinite(expr)) :
|
|
26
|
+
(expression.type === 'or') ? expression.expr.every((expr) => IsTemplateLiteralFinite(expr)) :
|
|
27
|
+
(expression.type === 'const') ? true :
|
|
28
|
+
(() => { throw new TemplateLiteralFiniteError(`Unknown expression type`); })());
|
|
29
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
function* GenerateReduce(buffer) {
|
|
2
|
+
if (buffer.length === 1)
|
|
3
|
+
return yield* buffer[0];
|
|
4
|
+
for (const left of buffer[0]) {
|
|
5
|
+
for (const right of GenerateReduce(buffer.slice(1))) {
|
|
6
|
+
yield `${left}${right}`;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
function* GenerateAnd(expression) {
|
|
11
|
+
return yield* GenerateReduce(expression.expr.map((expr) => [...TemplateLiteralGenerate(expr)]));
|
|
12
|
+
}
|
|
13
|
+
function* GenerateOr(expression) {
|
|
14
|
+
for (const expr of expression.expr)
|
|
15
|
+
yield* TemplateLiteralGenerate(expr);
|
|
16
|
+
}
|
|
17
|
+
function* GenerateConst(expression) {
|
|
18
|
+
return yield expression.const;
|
|
19
|
+
}
|
|
20
|
+
export class TemplateLiteralGenerateError extends Error {
|
|
21
|
+
}
|
|
22
|
+
export function* TemplateLiteralGenerate(expression) {
|
|
23
|
+
return expression.type === 'and'
|
|
24
|
+
? yield* GenerateAnd(expression)
|
|
25
|
+
: expression.type === 'or'
|
|
26
|
+
? yield* GenerateOr(expression)
|
|
27
|
+
: expression.type === 'const'
|
|
28
|
+
? yield* GenerateConst(expression)
|
|
29
|
+
: (() => {
|
|
30
|
+
throw new TemplateLiteralGenerateError('Unknown expression');
|
|
31
|
+
})();
|
|
32
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
export class TemplateLiteralParserError extends Error {
|
|
2
|
+
}
|
|
3
|
+
function IsNonEscaped(pattern, index, char) {
|
|
4
|
+
return pattern[index] === char && pattern.charCodeAt(index - 1) !== 92;
|
|
5
|
+
}
|
|
6
|
+
function IsOpenParen(pattern, index) {
|
|
7
|
+
return IsNonEscaped(pattern, index, '(');
|
|
8
|
+
}
|
|
9
|
+
function IsCloseParen(pattern, index) {
|
|
10
|
+
return IsNonEscaped(pattern, index, ')');
|
|
11
|
+
}
|
|
12
|
+
function IsSeparator(pattern, index) {
|
|
13
|
+
return IsNonEscaped(pattern, index, '|');
|
|
14
|
+
}
|
|
15
|
+
function IsGroup(pattern) {
|
|
16
|
+
if (!(IsOpenParen(pattern, 0) && IsCloseParen(pattern, pattern.length - 1)))
|
|
17
|
+
return false;
|
|
18
|
+
let count = 0;
|
|
19
|
+
for (let index = 0; index < pattern.length; index++) {
|
|
20
|
+
if (IsOpenParen(pattern, index))
|
|
21
|
+
count += 1;
|
|
22
|
+
if (IsCloseParen(pattern, index))
|
|
23
|
+
count -= 1;
|
|
24
|
+
if (count === 0 && index !== pattern.length - 1)
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
function InGroup(pattern) {
|
|
30
|
+
return pattern.slice(1, pattern.length - 1);
|
|
31
|
+
}
|
|
32
|
+
function IsPrecedenceOr(pattern) {
|
|
33
|
+
let count = 0;
|
|
34
|
+
for (let index = 0; index < pattern.length; index++) {
|
|
35
|
+
if (IsOpenParen(pattern, index))
|
|
36
|
+
count += 1;
|
|
37
|
+
if (IsCloseParen(pattern, index))
|
|
38
|
+
count -= 1;
|
|
39
|
+
if (IsSeparator(pattern, index) && count === 0)
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
function IsPrecedenceAnd(pattern) {
|
|
45
|
+
for (let index = 0; index < pattern.length; index++) {
|
|
46
|
+
if (IsOpenParen(pattern, index))
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
function Or(pattern) {
|
|
52
|
+
let [count, start] = [0, 0];
|
|
53
|
+
const expressions = [];
|
|
54
|
+
for (let index = 0; index < pattern.length; index++) {
|
|
55
|
+
if (IsOpenParen(pattern, index))
|
|
56
|
+
count += 1;
|
|
57
|
+
if (IsCloseParen(pattern, index))
|
|
58
|
+
count -= 1;
|
|
59
|
+
if (IsSeparator(pattern, index) && count === 0) {
|
|
60
|
+
const range = pattern.slice(start, index);
|
|
61
|
+
if (range.length > 0)
|
|
62
|
+
expressions.push(TemplateLiteralParse(range));
|
|
63
|
+
start = index + 1;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const range = pattern.slice(start);
|
|
67
|
+
if (range.length > 0)
|
|
68
|
+
expressions.push(TemplateLiteralParse(range));
|
|
69
|
+
if (expressions.length === 0)
|
|
70
|
+
return { type: 'const', const: '' };
|
|
71
|
+
if (expressions.length === 1)
|
|
72
|
+
return expressions[0];
|
|
73
|
+
return { type: 'or', expr: expressions };
|
|
74
|
+
}
|
|
75
|
+
function And(pattern) {
|
|
76
|
+
function Group(value, index) {
|
|
77
|
+
if (!IsOpenParen(value, index))
|
|
78
|
+
throw new TemplateLiteralParserError(`TemplateLiteralParser: Index must point to open parens`);
|
|
79
|
+
let count = 0;
|
|
80
|
+
for (let scan = index; scan < value.length; scan++) {
|
|
81
|
+
if (IsOpenParen(value, scan))
|
|
82
|
+
count += 1;
|
|
83
|
+
if (IsCloseParen(value, scan))
|
|
84
|
+
count -= 1;
|
|
85
|
+
if (count === 0)
|
|
86
|
+
return [index, scan];
|
|
87
|
+
}
|
|
88
|
+
throw new TemplateLiteralParserError(`TemplateLiteralParser: Unclosed group parens in expression`);
|
|
89
|
+
}
|
|
90
|
+
function Range(pattern, index) {
|
|
91
|
+
for (let scan = index; scan < pattern.length; scan++) {
|
|
92
|
+
if (IsOpenParen(pattern, scan))
|
|
93
|
+
return [index, scan];
|
|
94
|
+
}
|
|
95
|
+
return [index, pattern.length];
|
|
96
|
+
}
|
|
97
|
+
const expressions = [];
|
|
98
|
+
for (let index = 0; index < pattern.length; index++) {
|
|
99
|
+
if (IsOpenParen(pattern, index)) {
|
|
100
|
+
const [start, end] = Group(pattern, index);
|
|
101
|
+
const range = pattern.slice(start, end + 1);
|
|
102
|
+
expressions.push(TemplateLiteralParse(range));
|
|
103
|
+
index = end;
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
const [start, end] = Range(pattern, index);
|
|
107
|
+
const range = pattern.slice(start, end);
|
|
108
|
+
if (range.length > 0)
|
|
109
|
+
expressions.push(TemplateLiteralParse(range));
|
|
110
|
+
index = end - 1;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return ((expressions.length === 0) ? { type: 'const', const: '' } :
|
|
114
|
+
(expressions.length === 1) ? expressions[0] :
|
|
115
|
+
{ type: 'and', expr: expressions });
|
|
116
|
+
}
|
|
117
|
+
export function TemplateLiteralParse(pattern) {
|
|
118
|
+
return (IsGroup(pattern) ? TemplateLiteralParse(InGroup(pattern)) :
|
|
119
|
+
IsPrecedenceOr(pattern) ? Or(pattern) :
|
|
120
|
+
IsPrecedenceAnd(pattern) ? And(pattern) :
|
|
121
|
+
{ type: 'const', const: pattern });
|
|
122
|
+
}
|
|
123
|
+
export function TemplateLiteralParseExact(pattern) {
|
|
124
|
+
return TemplateLiteralParse(pattern.slice(1, pattern.length - 1));
|
|
125
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { PatternNumber, PatternString, PatternBoolean } from '../patterns/index.mjs';
|
|
2
|
+
import { Kind } from '../symbols/index.mjs';
|
|
3
|
+
import { TTemplateLiteral as IsTemplateLiteralType, TUnion as IsUnionType, TNumber as IsNumberType, TInteger as IsIntegerType, TBigInt as IsBigIntType, TString as IsStringType, TLiteral as IsLiteralType, TBoolean as IsBooleanType, } from '../guard/type.mjs';
|
|
4
|
+
export class TemplateLiteralPatternError extends Error {
|
|
5
|
+
}
|
|
6
|
+
function Escape(value) {
|
|
7
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
8
|
+
}
|
|
9
|
+
function Visit(schema, acc) {
|
|
10
|
+
return (IsTemplateLiteralType(schema) ? schema.pattern.slice(1, schema.pattern.length - 1) :
|
|
11
|
+
IsUnionType(schema) ? `(${schema.anyOf.map((schema) => Visit(schema, acc)).join('|')})` :
|
|
12
|
+
IsNumberType(schema) ? `${acc}${PatternNumber}` :
|
|
13
|
+
IsIntegerType(schema) ? `${acc}${PatternNumber}` :
|
|
14
|
+
IsBigIntType(schema) ? `${acc}${PatternNumber}` :
|
|
15
|
+
IsStringType(schema) ? `${acc}${PatternString}` :
|
|
16
|
+
IsLiteralType(schema) ? `${acc}${Escape(schema.const.toString())}` :
|
|
17
|
+
IsBooleanType(schema) ? `${acc}${PatternBoolean}` :
|
|
18
|
+
(() => { throw new TemplateLiteralPatternError(`Unexpected Kind '${schema[Kind]}'`); })());
|
|
19
|
+
}
|
|
20
|
+
export function TemplateLiteralPattern(kinds) {
|
|
21
|
+
return `^${kinds.map((schema) => Visit(schema, '')).join('')}\$`;
|
|
22
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Literal } from '../literal/index.mjs';
|
|
2
|
+
import { Boolean } from '../boolean/index.mjs';
|
|
3
|
+
import { BigInt } from '../bigint/index.mjs';
|
|
4
|
+
import { Number } from '../number/index.mjs';
|
|
5
|
+
import { String } from '../string/index.mjs';
|
|
6
|
+
import { Union } from '../union/index.mjs';
|
|
7
|
+
import { Never } from '../never/index.mjs';
|
|
8
|
+
function* FromUnion(syntax) {
|
|
9
|
+
const trim = syntax.trim().replace(/"|'/g, '');
|
|
10
|
+
return (trim === 'boolean' ? yield Boolean() :
|
|
11
|
+
trim === 'number' ? yield Number() :
|
|
12
|
+
trim === 'bigint' ? yield BigInt() :
|
|
13
|
+
trim === 'string' ? yield String() :
|
|
14
|
+
yield (() => {
|
|
15
|
+
const literals = trim.split('|').map((literal) => Literal(literal.trim()));
|
|
16
|
+
return (literals.length === 0 ? Never() :
|
|
17
|
+
literals.length === 1 ? literals[0] :
|
|
18
|
+
Union(literals));
|
|
19
|
+
})());
|
|
20
|
+
}
|
|
21
|
+
function* FromTerminal(syntax) {
|
|
22
|
+
if (syntax[1] !== '{') {
|
|
23
|
+
const L = Literal('$');
|
|
24
|
+
const R = FromSyntax(syntax.slice(1));
|
|
25
|
+
return yield* [L, ...R];
|
|
26
|
+
}
|
|
27
|
+
for (let i = 2; i < syntax.length; i++) {
|
|
28
|
+
if (syntax[i] === '}') {
|
|
29
|
+
const L = FromUnion(syntax.slice(2, i));
|
|
30
|
+
const R = FromSyntax(syntax.slice(i + 1));
|
|
31
|
+
return yield* [...L, ...R];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
yield Literal(syntax);
|
|
35
|
+
}
|
|
36
|
+
function* FromSyntax(syntax) {
|
|
37
|
+
for (let i = 0; i < syntax.length; i++) {
|
|
38
|
+
if (syntax[i] === '$') {
|
|
39
|
+
const L = Literal(syntax.slice(0, i));
|
|
40
|
+
const R = FromTerminal(syntax.slice(i));
|
|
41
|
+
return yield* [L, ...R];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
yield Literal(syntax);
|
|
45
|
+
}
|
|
46
|
+
export function TemplateLiteralSyntax(syntax) {
|
|
47
|
+
return [...FromSyntax(syntax)];
|
|
48
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TemplateLiteralPattern } from './pattern.mjs';
|
|
2
|
+
import { TemplateLiteralSyntax } from './syntax.mjs';
|
|
3
|
+
import { IsString } from '../guard/value.mjs';
|
|
4
|
+
import { Kind } from '../symbols/index.mjs';
|
|
5
|
+
export function TemplateLiteral(unresolved, options = {}) {
|
|
6
|
+
const pattern = IsString(unresolved)
|
|
7
|
+
? TemplateLiteralPattern(TemplateLiteralSyntax(unresolved))
|
|
8
|
+
: TemplateLiteralPattern(unresolved);
|
|
9
|
+
return { ...options, [Kind]: 'TemplateLiteral', type: 'string', pattern };
|
|
10
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Union } from '../union/index.mjs';
|
|
2
|
+
import { Literal } from '../literal/index.mjs';
|
|
3
|
+
import { String } from '../string/index.mjs';
|
|
4
|
+
import { TemplateLiteralGenerate } from './generate.mjs';
|
|
5
|
+
import { TemplateLiteralParseExact } from './parser.mjs';
|
|
6
|
+
import { IsTemplateLiteralFinite } from './finite.mjs';
|
|
7
|
+
export function TemplateLiteralToUnion(template) {
|
|
8
|
+
const expression = TemplateLiteralParseExact(template.pattern);
|
|
9
|
+
if (!IsTemplateLiteralFinite(expression))
|
|
10
|
+
return String();
|
|
11
|
+
const literals = [...TemplateLiteralGenerate(expression)].map((value) => Literal(value));
|
|
12
|
+
return Union(literals);
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './transform.mjs';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { TTransform as IsTransform } from '../guard/type.mjs';
|
|
2
|
+
import { CloneType } from '../clone/type.mjs';
|
|
3
|
+
import { TransformKind } from '../symbols/index.mjs';
|
|
4
|
+
export class TransformDecodeBuilder {
|
|
5
|
+
schema;
|
|
6
|
+
constructor(schema) {
|
|
7
|
+
this.schema = schema;
|
|
8
|
+
}
|
|
9
|
+
Decode(decode) {
|
|
10
|
+
return new TransformEncodeBuilder(this.schema, decode);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export class TransformEncodeBuilder {
|
|
14
|
+
schema;
|
|
15
|
+
decode;
|
|
16
|
+
constructor(schema, decode) {
|
|
17
|
+
this.schema = schema;
|
|
18
|
+
this.decode = decode;
|
|
19
|
+
}
|
|
20
|
+
EncodeTransform(encode, schema) {
|
|
21
|
+
const Encode = (value) => schema[TransformKind].Encode(encode(value));
|
|
22
|
+
const Decode = (value) => this.decode(schema[TransformKind].Decode(value));
|
|
23
|
+
const Codec = { Encode: Encode, Decode: Decode };
|
|
24
|
+
return { ...schema, [TransformKind]: Codec };
|
|
25
|
+
}
|
|
26
|
+
EncodeSchema(encode, schema) {
|
|
27
|
+
const Codec = { Decode: this.decode, Encode: encode };
|
|
28
|
+
return { ...schema, [TransformKind]: Codec };
|
|
29
|
+
}
|
|
30
|
+
Encode(encode) {
|
|
31
|
+
const schema = CloneType(this.schema);
|
|
32
|
+
return (IsTransform(schema) ? this.EncodeTransform(encode, schema) : this.EncodeSchema(encode, schema));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export function Transform(schema) {
|
|
36
|
+
return new TransformDecodeBuilder(schema);
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './tuple.mjs';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CloneRest } from '../clone/type.mjs';
|
|
2
|
+
import { Kind } from '../symbols/index.mjs';
|
|
3
|
+
export function Tuple(items, options = {}) {
|
|
4
|
+
const [additionalItems, minItems, maxItems] = [false, items.length, items.length];
|
|
5
|
+
return (items.length > 0 ?
|
|
6
|
+
{ ...options, [Kind]: 'Tuple', type: 'array', items: CloneRest(items), additionalItems, minItems, maxItems } :
|
|
7
|
+
{ ...options, [Kind]: 'Tuple', type: 'array', minItems, maxItems });
|
|
8
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { JsonTypeBuilder } from './json.mjs';
|
|
2
|
+
import { AsyncIterator } from '../async-iterator/index.mjs';
|
|
3
|
+
import { Awaited } from '../awaited/index.mjs';
|
|
4
|
+
import { BigInt } from '../bigint/index.mjs';
|
|
5
|
+
import { Constructor } from '../constructor/index.mjs';
|
|
6
|
+
import { ConstructorParameters } from '../constructor-parameters/index.mjs';
|
|
7
|
+
import { Date } from '../date/index.mjs';
|
|
8
|
+
import { Function } from '../function/index.mjs';
|
|
9
|
+
import { InstanceType } from '../instance-type/index.mjs';
|
|
10
|
+
import { Iterator } from '../iterator/index.mjs';
|
|
11
|
+
import { Parameters } from '../parameters/index.mjs';
|
|
12
|
+
import { Promise } from '../promise/index.mjs';
|
|
13
|
+
import { RegExp } from '../regexp/index.mjs';
|
|
14
|
+
import { ReturnType } from '../return-type/index.mjs';
|
|
15
|
+
import { Symbol } from '../symbol/index.mjs';
|
|
16
|
+
import { Uint8Array } from '../uint8array/index.mjs';
|
|
17
|
+
import { Undefined } from '../undefined/index.mjs';
|
|
18
|
+
import { Void } from '../void/index.mjs';
|
|
19
|
+
export class JavaScriptTypeBuilder extends JsonTypeBuilder {
|
|
20
|
+
AsyncIterator(items, options = {}) {
|
|
21
|
+
return AsyncIterator(items, options);
|
|
22
|
+
}
|
|
23
|
+
Awaited(schema, options = {}) {
|
|
24
|
+
return Awaited(schema, options);
|
|
25
|
+
}
|
|
26
|
+
BigInt(options = {}) {
|
|
27
|
+
return BigInt(options);
|
|
28
|
+
}
|
|
29
|
+
ConstructorParameters(schema, options = {}) {
|
|
30
|
+
return ConstructorParameters(schema, options);
|
|
31
|
+
}
|
|
32
|
+
Constructor(parameters, returns, options) {
|
|
33
|
+
return Constructor(parameters, returns, options);
|
|
34
|
+
}
|
|
35
|
+
Date(options = {}) {
|
|
36
|
+
return Date(options);
|
|
37
|
+
}
|
|
38
|
+
Function(parameters, returns, options) {
|
|
39
|
+
return Function(parameters, returns, options);
|
|
40
|
+
}
|
|
41
|
+
InstanceType(schema, options = {}) {
|
|
42
|
+
return InstanceType(schema, options);
|
|
43
|
+
}
|
|
44
|
+
Iterator(items, options = {}) {
|
|
45
|
+
return Iterator(items, options);
|
|
46
|
+
}
|
|
47
|
+
Parameters(schema, options = {}) {
|
|
48
|
+
return Parameters(schema, options);
|
|
49
|
+
}
|
|
50
|
+
Promise(item, options = {}) {
|
|
51
|
+
return Promise(item, options);
|
|
52
|
+
}
|
|
53
|
+
RegExp(unresolved, options = {}) {
|
|
54
|
+
return RegExp(unresolved, options);
|
|
55
|
+
}
|
|
56
|
+
ReturnType(schema, options = {}) {
|
|
57
|
+
return ReturnType(schema, options);
|
|
58
|
+
}
|
|
59
|
+
Symbol(options) {
|
|
60
|
+
return Symbol(options);
|
|
61
|
+
}
|
|
62
|
+
Undefined(options = {}) {
|
|
63
|
+
return Undefined(options);
|
|
64
|
+
}
|
|
65
|
+
Uint8Array(options = {}) {
|
|
66
|
+
return Uint8Array(options);
|
|
67
|
+
}
|
|
68
|
+
Void(options = {}) {
|
|
69
|
+
return Void(options);
|
|
70
|
+
}
|
|
71
|
+
}
|