@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,101 @@
|
|
|
1
|
+
export class ValuePointerRootSetError extends Error {
|
|
2
|
+
value;
|
|
3
|
+
path;
|
|
4
|
+
update;
|
|
5
|
+
constructor(value, path, update) {
|
|
6
|
+
super('Cannot set root value');
|
|
7
|
+
this.value = value;
|
|
8
|
+
this.path = path;
|
|
9
|
+
this.update = update;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export class ValuePointerRootDeleteError extends Error {
|
|
13
|
+
value;
|
|
14
|
+
path;
|
|
15
|
+
constructor(value, path) {
|
|
16
|
+
super('Cannot delete root value');
|
|
17
|
+
this.value = value;
|
|
18
|
+
this.path = path;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function Escape(component) {
|
|
22
|
+
return component.indexOf('~') === -1 ? component : component.replace(/~1/g, '/').replace(/~0/g, '~');
|
|
23
|
+
}
|
|
24
|
+
export function* Format(pointer) {
|
|
25
|
+
if (pointer === '')
|
|
26
|
+
return;
|
|
27
|
+
let [start, end] = [0, 0];
|
|
28
|
+
for (let i = 0; i < pointer.length; i++) {
|
|
29
|
+
const char = pointer.charAt(i);
|
|
30
|
+
if (char === '/') {
|
|
31
|
+
if (i === 0) {
|
|
32
|
+
start = i + 1;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
end = i;
|
|
36
|
+
yield Escape(pointer.slice(start, end));
|
|
37
|
+
start = i + 1;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
end = i;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
yield Escape(pointer.slice(start));
|
|
45
|
+
}
|
|
46
|
+
export function Set(value, pointer, update) {
|
|
47
|
+
if (pointer === '')
|
|
48
|
+
throw new ValuePointerRootSetError(value, pointer, update);
|
|
49
|
+
let [owner, next, key] = [null, value, ''];
|
|
50
|
+
for (const component of Format(pointer)) {
|
|
51
|
+
if (next[component] === undefined)
|
|
52
|
+
next[component] = {};
|
|
53
|
+
owner = next;
|
|
54
|
+
next = next[component];
|
|
55
|
+
key = component;
|
|
56
|
+
}
|
|
57
|
+
owner[key] = update;
|
|
58
|
+
}
|
|
59
|
+
export function Delete(value, pointer) {
|
|
60
|
+
if (pointer === '')
|
|
61
|
+
throw new ValuePointerRootDeleteError(value, pointer);
|
|
62
|
+
let [owner, next, key] = [null, value, ''];
|
|
63
|
+
for (const component of Format(pointer)) {
|
|
64
|
+
if (next[component] === undefined || next[component] === null)
|
|
65
|
+
return;
|
|
66
|
+
owner = next;
|
|
67
|
+
next = next[component];
|
|
68
|
+
key = component;
|
|
69
|
+
}
|
|
70
|
+
if (Array.isArray(owner)) {
|
|
71
|
+
const index = parseInt(key);
|
|
72
|
+
owner.splice(index, 1);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
delete owner[key];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
export function Has(value, pointer) {
|
|
79
|
+
if (pointer === '')
|
|
80
|
+
return true;
|
|
81
|
+
let [owner, next, key] = [null, value, ''];
|
|
82
|
+
for (const component of Format(pointer)) {
|
|
83
|
+
if (next[component] === undefined)
|
|
84
|
+
return false;
|
|
85
|
+
owner = next;
|
|
86
|
+
next = next[component];
|
|
87
|
+
key = component;
|
|
88
|
+
}
|
|
89
|
+
return Object.getOwnPropertyNames(owner).includes(key);
|
|
90
|
+
}
|
|
91
|
+
export function Get(value, pointer) {
|
|
92
|
+
if (pointer === '')
|
|
93
|
+
return value;
|
|
94
|
+
let current = value;
|
|
95
|
+
for (const component of Format(pointer)) {
|
|
96
|
+
if (current[component] === undefined)
|
|
97
|
+
return undefined;
|
|
98
|
+
current = current[component];
|
|
99
|
+
}
|
|
100
|
+
return current;
|
|
101
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { TTransform as IsTransformType, TSchema as IsSchemaType } from '../../type/guard/type.mjs';
|
|
2
|
+
import { Kind, TransformKind } from '../../type/symbols/index.mjs';
|
|
3
|
+
import { IsPlainObject, IsArray, IsValueType } from '../guard/index.mjs';
|
|
4
|
+
import { KeyOfStringResolve } from '../../type/keyof/index.mjs';
|
|
5
|
+
import { IndexedTypeResolve } from '../../type/indexed/index.mjs';
|
|
6
|
+
import { Deref } from '../deref/index.mjs';
|
|
7
|
+
import { Check } from '../check/index.mjs';
|
|
8
|
+
export class TransformDecodeCheckError extends Error {
|
|
9
|
+
schema;
|
|
10
|
+
value;
|
|
11
|
+
error;
|
|
12
|
+
constructor(schema, value, error) {
|
|
13
|
+
super(`Unable to decode due to invalid value`);
|
|
14
|
+
this.schema = schema;
|
|
15
|
+
this.value = value;
|
|
16
|
+
this.error = error;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export class TransformDecodeError extends Error {
|
|
20
|
+
schema;
|
|
21
|
+
value;
|
|
22
|
+
constructor(schema, value, error) {
|
|
23
|
+
super(`${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
24
|
+
this.schema = schema;
|
|
25
|
+
this.value = value;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function Default(schema, value) {
|
|
29
|
+
try {
|
|
30
|
+
return IsTransformType(schema) ? schema[TransformKind].Decode(value) : value;
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
throw new TransformDecodeError(schema, value, error);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function TArray(schema, references, value) {
|
|
37
|
+
return (IsArray(value))
|
|
38
|
+
? Default(schema, value.map((value) => Visit(schema.items, references, value)))
|
|
39
|
+
: Default(schema, value);
|
|
40
|
+
}
|
|
41
|
+
function TIntersect(schema, references, value) {
|
|
42
|
+
if (!IsPlainObject(value) || IsValueType(value))
|
|
43
|
+
return Default(schema, value);
|
|
44
|
+
const knownKeys = KeyOfStringResolve(schema);
|
|
45
|
+
const knownProperties = knownKeys.reduce((value, key) => {
|
|
46
|
+
return (key in value)
|
|
47
|
+
? { ...value, [key]: Visit(IndexedTypeResolve(schema, [key]), references, value[key]) }
|
|
48
|
+
: value;
|
|
49
|
+
}, value);
|
|
50
|
+
if (!IsTransformType(schema.unevaluatedProperties)) {
|
|
51
|
+
return Default(schema, knownProperties);
|
|
52
|
+
}
|
|
53
|
+
const unknownKeys = Object.getOwnPropertyNames(knownProperties);
|
|
54
|
+
const unevaluatedProperties = schema.unevaluatedProperties;
|
|
55
|
+
const unknownProperties = unknownKeys.reduce((value, key) => {
|
|
56
|
+
return !knownKeys.includes(key)
|
|
57
|
+
? { ...value, [key]: Default(unevaluatedProperties, value[key]) }
|
|
58
|
+
: value;
|
|
59
|
+
}, knownProperties);
|
|
60
|
+
return Default(schema, unknownProperties);
|
|
61
|
+
}
|
|
62
|
+
function TNot(schema, references, value) {
|
|
63
|
+
return Default(schema, Visit(schema.not, references, value));
|
|
64
|
+
}
|
|
65
|
+
function TObject(schema, references, value) {
|
|
66
|
+
if (!IsPlainObject(value))
|
|
67
|
+
return Default(schema, value);
|
|
68
|
+
const knownKeys = KeyOfStringResolve(schema);
|
|
69
|
+
const knownProperties = knownKeys.reduce((value, key) => {
|
|
70
|
+
return (key in value)
|
|
71
|
+
? { ...value, [key]: Visit(schema.properties[key], references, value[key]) }
|
|
72
|
+
: value;
|
|
73
|
+
}, value);
|
|
74
|
+
if (!IsSchemaType(schema.additionalProperties)) {
|
|
75
|
+
return Default(schema, knownProperties);
|
|
76
|
+
}
|
|
77
|
+
const unknownKeys = Object.getOwnPropertyNames(knownProperties);
|
|
78
|
+
const additionalProperties = schema.additionalProperties;
|
|
79
|
+
const unknownProperties = unknownKeys.reduce((value, key) => {
|
|
80
|
+
return !knownKeys.includes(key)
|
|
81
|
+
? { ...value, [key]: Default(additionalProperties, value[key]) }
|
|
82
|
+
: value;
|
|
83
|
+
}, knownProperties);
|
|
84
|
+
return Default(schema, unknownProperties);
|
|
85
|
+
}
|
|
86
|
+
function TRecord(schema, references, value) {
|
|
87
|
+
if (!IsPlainObject(value))
|
|
88
|
+
return Default(schema, value);
|
|
89
|
+
const pattern = Object.getOwnPropertyNames(schema.patternProperties)[0];
|
|
90
|
+
const knownKeys = new RegExp(pattern);
|
|
91
|
+
const knownProperties = Object.getOwnPropertyNames(value).reduce((value, key) => {
|
|
92
|
+
return knownKeys.test(key)
|
|
93
|
+
? { ...value, [key]: Visit(schema.patternProperties[pattern], references, value[key]) }
|
|
94
|
+
: value;
|
|
95
|
+
}, value);
|
|
96
|
+
if (!IsSchemaType(schema.additionalProperties)) {
|
|
97
|
+
return Default(schema, knownProperties);
|
|
98
|
+
}
|
|
99
|
+
const unknownKeys = Object.getOwnPropertyNames(knownProperties);
|
|
100
|
+
const additionalProperties = schema.additionalProperties;
|
|
101
|
+
const unknownProperties = unknownKeys.reduce((value, key) => {
|
|
102
|
+
return !knownKeys.test(key)
|
|
103
|
+
? { ...value, [key]: Default(additionalProperties, value[key]) }
|
|
104
|
+
: value;
|
|
105
|
+
}, knownProperties);
|
|
106
|
+
return Default(schema, unknownProperties);
|
|
107
|
+
}
|
|
108
|
+
function TRef(schema, references, value) {
|
|
109
|
+
const target = Deref(schema, references);
|
|
110
|
+
return Default(schema, Visit(target, references, value));
|
|
111
|
+
}
|
|
112
|
+
function TThis(schema, references, value) {
|
|
113
|
+
const target = Deref(schema, references);
|
|
114
|
+
return Default(schema, Visit(target, references, value));
|
|
115
|
+
}
|
|
116
|
+
function TTuple(schema, references, value) {
|
|
117
|
+
return (IsArray(value) && IsArray(schema.items))
|
|
118
|
+
? Default(schema, schema.items.map((schema, index) => Visit(schema, references, value[index])))
|
|
119
|
+
: Default(schema, value);
|
|
120
|
+
}
|
|
121
|
+
function TUnion(schema, references, value) {
|
|
122
|
+
for (const subschema of schema.anyOf) {
|
|
123
|
+
if (!Check(subschema, references, value))
|
|
124
|
+
continue;
|
|
125
|
+
const decoded = Visit(subschema, references, value);
|
|
126
|
+
return Default(schema, decoded);
|
|
127
|
+
}
|
|
128
|
+
return Default(schema, value);
|
|
129
|
+
}
|
|
130
|
+
function Visit(schema, references, value) {
|
|
131
|
+
const references_ = typeof schema.$id === 'string' ? [...references, schema] : references;
|
|
132
|
+
const schema_ = schema;
|
|
133
|
+
switch (schema[Kind]) {
|
|
134
|
+
case 'Array':
|
|
135
|
+
return TArray(schema_, references_, value);
|
|
136
|
+
case 'Intersect':
|
|
137
|
+
return TIntersect(schema_, references_, value);
|
|
138
|
+
case 'Not':
|
|
139
|
+
return TNot(schema_, references_, value);
|
|
140
|
+
case 'Object':
|
|
141
|
+
return TObject(schema_, references_, value);
|
|
142
|
+
case 'Record':
|
|
143
|
+
return TRecord(schema_, references_, value);
|
|
144
|
+
case 'Ref':
|
|
145
|
+
return TRef(schema_, references_, value);
|
|
146
|
+
case 'Symbol':
|
|
147
|
+
return Default(schema_, value);
|
|
148
|
+
case 'This':
|
|
149
|
+
return TThis(schema_, references_, value);
|
|
150
|
+
case 'Tuple':
|
|
151
|
+
return TTuple(schema_, references_, value);
|
|
152
|
+
case 'Union':
|
|
153
|
+
return TUnion(schema_, references_, value);
|
|
154
|
+
default:
|
|
155
|
+
return Default(schema_, value);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
export function Decode(schema, references, value) {
|
|
159
|
+
return Visit(schema, references, value);
|
|
160
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { TTransform as IsTransformType, TSchema as IsSchemaType } from '../../type/guard/type.mjs';
|
|
2
|
+
import { Kind, TransformKind } from '../../type/symbols/index.mjs';
|
|
3
|
+
import { IsPlainObject, IsArray, IsValueType } from '../guard/index.mjs';
|
|
4
|
+
import { KeyOfStringResolve } from '../../type/keyof/index.mjs';
|
|
5
|
+
import { IndexedTypeResolve } from '../../type/indexed/index.mjs';
|
|
6
|
+
import { Deref } from '../deref/index.mjs';
|
|
7
|
+
import { Check } from '../check/index.mjs';
|
|
8
|
+
export class TransformEncodeCheckError extends Error {
|
|
9
|
+
schema;
|
|
10
|
+
value;
|
|
11
|
+
error;
|
|
12
|
+
constructor(schema, value, error) {
|
|
13
|
+
super(`Unable to encode due to invalid value`);
|
|
14
|
+
this.schema = schema;
|
|
15
|
+
this.value = value;
|
|
16
|
+
this.error = error;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export class TransformEncodeError extends Error {
|
|
20
|
+
schema;
|
|
21
|
+
value;
|
|
22
|
+
constructor(schema, value, error) {
|
|
23
|
+
super(`${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
24
|
+
this.schema = schema;
|
|
25
|
+
this.value = value;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function Default(schema, value) {
|
|
29
|
+
try {
|
|
30
|
+
return IsTransformType(schema) ? schema[TransformKind].Encode(value) : value;
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
throw new TransformEncodeError(schema, value, error);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function TArray(schema, references, value) {
|
|
37
|
+
const defaulted = Default(schema, value);
|
|
38
|
+
return IsArray(defaulted)
|
|
39
|
+
? defaulted.map((value) => Visit(schema.items, references, value))
|
|
40
|
+
: defaulted;
|
|
41
|
+
}
|
|
42
|
+
function TIntersect(schema, references, value) {
|
|
43
|
+
const defaulted = Default(schema, value);
|
|
44
|
+
if (!IsPlainObject(value) || IsValueType(value))
|
|
45
|
+
return defaulted;
|
|
46
|
+
const knownKeys = KeyOfStringResolve(schema);
|
|
47
|
+
const knownProperties = knownKeys.reduce((value, key) => {
|
|
48
|
+
return key in defaulted
|
|
49
|
+
? { ...value, [key]: Visit(IndexedTypeResolve(schema, [key]), references, value[key]) }
|
|
50
|
+
: value;
|
|
51
|
+
}, defaulted);
|
|
52
|
+
if (!IsTransformType(schema.unevaluatedProperties)) {
|
|
53
|
+
return Default(schema, knownProperties);
|
|
54
|
+
}
|
|
55
|
+
const unknownKeys = Object.getOwnPropertyNames(knownProperties);
|
|
56
|
+
const unevaluatedProperties = schema.unevaluatedProperties;
|
|
57
|
+
return unknownKeys.reduce((value, key) => {
|
|
58
|
+
return !knownKeys.includes(key)
|
|
59
|
+
? { ...value, [key]: Default(unevaluatedProperties, value[key]) }
|
|
60
|
+
: value;
|
|
61
|
+
}, knownProperties);
|
|
62
|
+
}
|
|
63
|
+
function TNot(schema, references, value) {
|
|
64
|
+
return Default(schema.not, Default(schema, value));
|
|
65
|
+
}
|
|
66
|
+
function TObject(schema, references, value) {
|
|
67
|
+
const defaulted = Default(schema, value);
|
|
68
|
+
if (!IsPlainObject(value))
|
|
69
|
+
return defaulted;
|
|
70
|
+
const knownKeys = KeyOfStringResolve(schema);
|
|
71
|
+
const knownProperties = knownKeys.reduce((value, key) => {
|
|
72
|
+
return key in value
|
|
73
|
+
? { ...value, [key]: Visit(schema.properties[key], references, value[key]) }
|
|
74
|
+
: value;
|
|
75
|
+
}, defaulted);
|
|
76
|
+
if (!IsSchemaType(schema.additionalProperties)) {
|
|
77
|
+
return knownProperties;
|
|
78
|
+
}
|
|
79
|
+
const unknownKeys = Object.getOwnPropertyNames(knownProperties);
|
|
80
|
+
const additionalProperties = schema.additionalProperties;
|
|
81
|
+
return unknownKeys.reduce((value, key) => {
|
|
82
|
+
return !knownKeys.includes(key)
|
|
83
|
+
? { ...value, [key]: Default(additionalProperties, value[key]) }
|
|
84
|
+
: value;
|
|
85
|
+
}, knownProperties);
|
|
86
|
+
}
|
|
87
|
+
function TRecord(schema, references, value) {
|
|
88
|
+
const defaulted = Default(schema, value);
|
|
89
|
+
if (!IsPlainObject(value))
|
|
90
|
+
return defaulted;
|
|
91
|
+
const pattern = Object.getOwnPropertyNames(schema.patternProperties)[0];
|
|
92
|
+
const knownKeys = new RegExp(pattern);
|
|
93
|
+
const knownProperties = Object.getOwnPropertyNames(value).reduce((value, key) => {
|
|
94
|
+
return knownKeys.test(key)
|
|
95
|
+
? { ...value, [key]: Visit(schema.patternProperties[pattern], references, value[key]) }
|
|
96
|
+
: value;
|
|
97
|
+
}, defaulted);
|
|
98
|
+
if (!IsSchemaType(schema.additionalProperties)) {
|
|
99
|
+
return Default(schema, knownProperties);
|
|
100
|
+
}
|
|
101
|
+
const unknownKeys = Object.getOwnPropertyNames(knownProperties);
|
|
102
|
+
const additionalProperties = schema.additionalProperties;
|
|
103
|
+
return unknownKeys.reduce((value, key) => {
|
|
104
|
+
return !knownKeys.test(key)
|
|
105
|
+
? { ...value, [key]: Default(additionalProperties, value[key]) }
|
|
106
|
+
: value;
|
|
107
|
+
}, knownProperties);
|
|
108
|
+
}
|
|
109
|
+
function TRef(schema, references, value) {
|
|
110
|
+
const target = Deref(schema, references);
|
|
111
|
+
const resolved = Visit(target, references, value);
|
|
112
|
+
return Default(schema, resolved);
|
|
113
|
+
}
|
|
114
|
+
function TThis(schema, references, value) {
|
|
115
|
+
const target = Deref(schema, references);
|
|
116
|
+
const resolved = Visit(target, references, value);
|
|
117
|
+
return Default(schema, resolved);
|
|
118
|
+
}
|
|
119
|
+
function TTuple(schema, references, value) {
|
|
120
|
+
const value1 = Default(schema, value);
|
|
121
|
+
return IsArray(schema.items) ? schema.items.map((schema, index) => Visit(schema, references, value1[index])) : [];
|
|
122
|
+
}
|
|
123
|
+
function TUnion(schema, references, value) {
|
|
124
|
+
for (const subschema of schema.anyOf) {
|
|
125
|
+
if (!Check(subschema, references, value))
|
|
126
|
+
continue;
|
|
127
|
+
const value1 = Visit(subschema, references, value);
|
|
128
|
+
return Default(schema, value1);
|
|
129
|
+
}
|
|
130
|
+
for (const subschema of schema.anyOf) {
|
|
131
|
+
const value1 = Visit(subschema, references, value);
|
|
132
|
+
if (!Check(schema, references, value1))
|
|
133
|
+
continue;
|
|
134
|
+
return Default(schema, value1);
|
|
135
|
+
}
|
|
136
|
+
return Default(schema, value);
|
|
137
|
+
}
|
|
138
|
+
function Visit(schema, references, value) {
|
|
139
|
+
const references_ = typeof schema.$id === 'string' ? [...references, schema] : references;
|
|
140
|
+
const schema_ = schema;
|
|
141
|
+
switch (schema[Kind]) {
|
|
142
|
+
case 'Array':
|
|
143
|
+
return TArray(schema_, references_, value);
|
|
144
|
+
case 'Intersect':
|
|
145
|
+
return TIntersect(schema_, references_, value);
|
|
146
|
+
case 'Not':
|
|
147
|
+
return TNot(schema_, references_, value);
|
|
148
|
+
case 'Object':
|
|
149
|
+
return TObject(schema_, references_, value);
|
|
150
|
+
case 'Record':
|
|
151
|
+
return TRecord(schema_, references_, value);
|
|
152
|
+
case 'Ref':
|
|
153
|
+
return TRef(schema_, references_, value);
|
|
154
|
+
case 'This':
|
|
155
|
+
return TThis(schema_, references_, value);
|
|
156
|
+
case 'Tuple':
|
|
157
|
+
return TTuple(schema_, references_, value);
|
|
158
|
+
case 'Union':
|
|
159
|
+
return TUnion(schema_, references_, value);
|
|
160
|
+
default:
|
|
161
|
+
return Default(schema_, value);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
export function Encode(schema, references, value) {
|
|
165
|
+
return Visit(schema, references, value);
|
|
166
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { TTransform as IsTransformType, TSchema as IsSchemaType } from '../../type/guard/type.mjs';
|
|
2
|
+
import { IsString, IsUndefined } from '../guard/index.mjs';
|
|
3
|
+
import { Deref } from '../deref/index.mjs';
|
|
4
|
+
import { Kind } from '../../type/symbols/index.mjs';
|
|
5
|
+
function TArray(schema, references) {
|
|
6
|
+
return IsTransformType(schema) || Visit(schema.items, references);
|
|
7
|
+
}
|
|
8
|
+
function TAsyncIterator(schema, references) {
|
|
9
|
+
return IsTransformType(schema) || Visit(schema.items, references);
|
|
10
|
+
}
|
|
11
|
+
function TConstructor(schema, references) {
|
|
12
|
+
return IsTransformType(schema) || Visit(schema.returns, references) || schema.parameters.some((schema) => Visit(schema, references));
|
|
13
|
+
}
|
|
14
|
+
function TFunction(schema, references) {
|
|
15
|
+
return IsTransformType(schema) || Visit(schema.returns, references) || schema.parameters.some((schema) => Visit(schema, references));
|
|
16
|
+
}
|
|
17
|
+
function TIntersect(schema, references) {
|
|
18
|
+
return IsTransformType(schema) || IsTransformType(schema.unevaluatedProperties) || schema.allOf.some((schema) => Visit(schema, references));
|
|
19
|
+
}
|
|
20
|
+
function TIterator(schema, references) {
|
|
21
|
+
return IsTransformType(schema) || Visit(schema.items, references);
|
|
22
|
+
}
|
|
23
|
+
function TNot(schema, references) {
|
|
24
|
+
return IsTransformType(schema) || Visit(schema.not, references);
|
|
25
|
+
}
|
|
26
|
+
function TObject(schema, references) {
|
|
27
|
+
return (IsTransformType(schema) ||
|
|
28
|
+
Object.values(schema.properties).some((schema) => Visit(schema, references)) ||
|
|
29
|
+
(IsSchemaType(schema.additionalProperties) && Visit(schema.additionalProperties, references)));
|
|
30
|
+
}
|
|
31
|
+
function TPromise(schema, references) {
|
|
32
|
+
return IsTransformType(schema) || Visit(schema.item, references);
|
|
33
|
+
}
|
|
34
|
+
function TRecord(schema, references) {
|
|
35
|
+
const pattern = Object.getOwnPropertyNames(schema.patternProperties)[0];
|
|
36
|
+
const property = schema.patternProperties[pattern];
|
|
37
|
+
return IsTransformType(schema) || Visit(property, references) || (IsSchemaType(schema.additionalProperties) && IsTransformType(schema.additionalProperties));
|
|
38
|
+
}
|
|
39
|
+
function TRef(schema, references) {
|
|
40
|
+
if (IsTransformType(schema))
|
|
41
|
+
return true;
|
|
42
|
+
return Visit(Deref(schema, references), references);
|
|
43
|
+
}
|
|
44
|
+
function TThis(schema, references) {
|
|
45
|
+
if (IsTransformType(schema))
|
|
46
|
+
return true;
|
|
47
|
+
return Visit(Deref(schema, references), references);
|
|
48
|
+
}
|
|
49
|
+
function TTuple(schema, references) {
|
|
50
|
+
return IsTransformType(schema) || (!IsUndefined(schema.items) && schema.items.some((schema) => Visit(schema, references)));
|
|
51
|
+
}
|
|
52
|
+
function TUnion(schema, references) {
|
|
53
|
+
return IsTransformType(schema) || schema.anyOf.some((schema) => Visit(schema, references));
|
|
54
|
+
}
|
|
55
|
+
function Visit(schema, references) {
|
|
56
|
+
const references_ = IsString(schema.$id) ? [...references, schema] : references;
|
|
57
|
+
const schema_ = schema;
|
|
58
|
+
if (schema.$id && visited.has(schema.$id))
|
|
59
|
+
return false;
|
|
60
|
+
if (schema.$id)
|
|
61
|
+
visited.add(schema.$id);
|
|
62
|
+
switch (schema[Kind]) {
|
|
63
|
+
case 'Array':
|
|
64
|
+
return TArray(schema_, references_);
|
|
65
|
+
case 'AsyncIterator':
|
|
66
|
+
return TAsyncIterator(schema_, references_);
|
|
67
|
+
case 'Constructor':
|
|
68
|
+
return TConstructor(schema_, references_);
|
|
69
|
+
case 'Function':
|
|
70
|
+
return TFunction(schema_, references_);
|
|
71
|
+
case 'Intersect':
|
|
72
|
+
return TIntersect(schema_, references_);
|
|
73
|
+
case 'Iterator':
|
|
74
|
+
return TIterator(schema_, references_);
|
|
75
|
+
case 'Not':
|
|
76
|
+
return TNot(schema_, references_);
|
|
77
|
+
case 'Object':
|
|
78
|
+
return TObject(schema_, references_);
|
|
79
|
+
case 'Promise':
|
|
80
|
+
return TPromise(schema_, references_);
|
|
81
|
+
case 'Record':
|
|
82
|
+
return TRecord(schema_, references_);
|
|
83
|
+
case 'Ref':
|
|
84
|
+
return TRef(schema_, references_);
|
|
85
|
+
case 'This':
|
|
86
|
+
return TThis(schema_, references_);
|
|
87
|
+
case 'Tuple':
|
|
88
|
+
return TTuple(schema_, references_);
|
|
89
|
+
case 'Union':
|
|
90
|
+
return TUnion(schema_, references_);
|
|
91
|
+
default:
|
|
92
|
+
return IsTransformType(schema);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const visited = new Set();
|
|
96
|
+
export function HasTransform(schema, references) {
|
|
97
|
+
visited.clear();
|
|
98
|
+
return Visit(schema, references);
|
|
99
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as Value from './value.mjs';
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Decode as DecodeValue, Encode as EncodeValue, TransformDecodeCheckError, TransformEncodeCheckError } from '../transform/index.mjs';
|
|
2
|
+
import { Mutate as MutateValue } from '../mutate/index.mjs';
|
|
3
|
+
import { Hash as HashValue } from '../hash/index.mjs';
|
|
4
|
+
import { Equal as EqualValue } from '../equal/index.mjs';
|
|
5
|
+
import { Cast as CastValue } from '../cast/index.mjs';
|
|
6
|
+
import { Clone as CloneValue } from '../clone/index.mjs';
|
|
7
|
+
import { Convert as ConvertValue } from '../convert/index.mjs';
|
|
8
|
+
import { Create as CreateValue } from '../create/index.mjs';
|
|
9
|
+
import { Clean as CleanValue } from '../clean/index.mjs';
|
|
10
|
+
import { Check as CheckValue } from '../check/index.mjs';
|
|
11
|
+
import { Default as DefaultValue } from '../default/index.mjs';
|
|
12
|
+
import { Diff as DiffValue, Patch as PatchValue } from '../delta/index.mjs';
|
|
13
|
+
import { Errors as ValueErrors } from '../../errors/index.mjs';
|
|
14
|
+
export function Cast(...args) {
|
|
15
|
+
return CastValue.apply(CastValue, args);
|
|
16
|
+
}
|
|
17
|
+
export function Create(...args) {
|
|
18
|
+
return CreateValue.apply(CreateValue, args);
|
|
19
|
+
}
|
|
20
|
+
export function Check(...args) {
|
|
21
|
+
return CheckValue.apply(CheckValue, args);
|
|
22
|
+
}
|
|
23
|
+
export function Clean(...args) {
|
|
24
|
+
return CleanValue.apply(CleanValue, args);
|
|
25
|
+
}
|
|
26
|
+
export function Convert(...args) {
|
|
27
|
+
return ConvertValue.apply(ConvertValue, args);
|
|
28
|
+
}
|
|
29
|
+
export function Clone(value) {
|
|
30
|
+
return CloneValue(value);
|
|
31
|
+
}
|
|
32
|
+
export function Decode(...args) {
|
|
33
|
+
const [schema, references, value] = args.length === 3 ? [args[0], args[1], args[2]] : [args[0], [], args[1]];
|
|
34
|
+
if (!Check(schema, references, value))
|
|
35
|
+
throw new TransformDecodeCheckError(schema, value, Errors(schema, references, value).First());
|
|
36
|
+
return DecodeValue(schema, references, value);
|
|
37
|
+
}
|
|
38
|
+
export function Default(...args) {
|
|
39
|
+
return DefaultValue.apply(DefaultValue, args);
|
|
40
|
+
}
|
|
41
|
+
export function Encode(...args) {
|
|
42
|
+
const [schema, references, value] = args.length === 3 ? [args[0], args[1], args[2]] : [args[0], [], args[1]];
|
|
43
|
+
const encoded = EncodeValue(schema, references, value);
|
|
44
|
+
if (!Check(schema, references, encoded))
|
|
45
|
+
throw new TransformEncodeCheckError(schema, value, Errors(schema, references, value).First());
|
|
46
|
+
return encoded;
|
|
47
|
+
}
|
|
48
|
+
export function Errors(...args) {
|
|
49
|
+
return ValueErrors.apply(ValueErrors, args);
|
|
50
|
+
}
|
|
51
|
+
export function Equal(left, right) {
|
|
52
|
+
return EqualValue(left, right);
|
|
53
|
+
}
|
|
54
|
+
export function Diff(current, next) {
|
|
55
|
+
return DiffValue(current, next);
|
|
56
|
+
}
|
|
57
|
+
export function Hash(value) {
|
|
58
|
+
return HashValue(value);
|
|
59
|
+
}
|
|
60
|
+
export function Patch(current, edits) {
|
|
61
|
+
return PatchValue(current, edits);
|
|
62
|
+
}
|
|
63
|
+
export function Mutate(current, next) {
|
|
64
|
+
MutateValue(current, next);
|
|
65
|
+
}
|