liminal 0.1.0-beta.25
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/LICENSE +202 -0
- package/README.md +26 -0
- package/esm/_dnt.shims.d.ts +2 -0
- package/esm/_dnt.shims.d.ts.map +1 -0
- package/esm/_dnt.shims.js +58 -0
- package/esm/_dnt.shims.js.map +1 -0
- package/esm/client/Adapter.d.ts +46 -0
- package/esm/client/Adapter.d.ts.map +1 -0
- package/esm/client/Adapter.js +2 -0
- package/esm/client/Adapter.js.map +1 -0
- package/esm/client/Liminal.d.ts +19 -0
- package/esm/client/Liminal.d.ts.map +1 -0
- package/esm/client/Liminal.js +154 -0
- package/esm/client/Liminal.js.map +1 -0
- package/esm/client/Tool.d.ts +15 -0
- package/esm/client/Tool.d.ts.map +1 -0
- package/esm/client/Tool.js +23 -0
- package/esm/client/Tool.js.map +1 -0
- package/esm/client/constants.d.ts +2 -0
- package/esm/client/constants.d.ts.map +1 -0
- package/esm/client/constants.js +7 -0
- package/esm/client/constants.js.map +1 -0
- package/esm/client/mod.d.ts +5 -0
- package/esm/client/mod.d.ts.map +1 -0
- package/esm/client/mod.js +6 -0
- package/esm/client/mod.js.map +1 -0
- package/esm/core/DescriptionContext.d.ts +11 -0
- package/esm/core/DescriptionContext.d.ts.map +1 -0
- package/esm/core/DescriptionContext.js +103 -0
- package/esm/core/DescriptionContext.js.map +1 -0
- package/esm/core/L.d.ts +4 -0
- package/esm/core/L.d.ts.map +1 -0
- package/esm/core/L.js +4 -0
- package/esm/core/L.js.map +1 -0
- package/esm/core/ReduceDependencies.d.ts +6 -0
- package/esm/core/ReduceDependencies.d.ts.map +1 -0
- package/esm/core/ReduceDependencies.js +2 -0
- package/esm/core/ReduceDependencies.js.map +1 -0
- package/esm/core/Type.d.ts +30 -0
- package/esm/core/Type.d.ts.map +1 -0
- package/esm/core/Type.js +2 -0
- package/esm/core/Type.js.map +1 -0
- package/esm/core/TypeVisitor.d.ts +15 -0
- package/esm/core/TypeVisitor.d.ts.map +1 -0
- package/esm/core/TypeVisitor.js +12 -0
- package/esm/core/TypeVisitor.js.map +1 -0
- package/esm/core/annotations/Annotation.d.ts +7 -0
- package/esm/core/annotations/Annotation.d.ts.map +1 -0
- package/esm/core/annotations/Annotation.js +2 -0
- package/esm/core/annotations/Annotation.js.map +1 -0
- package/esm/core/annotations/Assertion.d.ts +8 -0
- package/esm/core/annotations/Assertion.d.ts.map +1 -0
- package/esm/core/annotations/Assertion.js +8 -0
- package/esm/core/annotations/Assertion.js.map +1 -0
- package/esm/core/annotations/Description.d.ts +7 -0
- package/esm/core/annotations/Description.d.ts.map +1 -0
- package/esm/core/annotations/Description.js +8 -0
- package/esm/core/annotations/Description.js.map +1 -0
- package/esm/core/annotations/Param.d.ts +13 -0
- package/esm/core/annotations/Param.d.ts.map +1 -0
- package/esm/core/annotations/Param.js +11 -0
- package/esm/core/annotations/Param.js.map +1 -0
- package/esm/core/annotations/Template.d.ts +10 -0
- package/esm/core/annotations/Template.d.ts.map +1 -0
- package/esm/core/annotations/Template.js +2 -0
- package/esm/core/annotations/Template.js.map +1 -0
- package/esm/core/annotations/mod.d.ts +6 -0
- package/esm/core/annotations/mod.d.ts.map +1 -0
- package/esm/core/annotations/mod.js +7 -0
- package/esm/core/annotations/mod.js.map +1 -0
- package/esm/core/assert.d.ts +22 -0
- package/esm/core/assert.d.ts.map +1 -0
- package/esm/core/assert.js +155 -0
- package/esm/core/assert.js.map +1 -0
- package/esm/core/declareIntrinsic.d.ts +4 -0
- package/esm/core/declareIntrinsic.d.ts.map +1 -0
- package/esm/core/declareIntrinsic.js +26 -0
- package/esm/core/declareIntrinsic.js.map +1 -0
- package/esm/core/deserialize.d.ts +3 -0
- package/esm/core/deserialize.d.ts.map +1 -0
- package/esm/core/deserialize.js +32 -0
- package/esm/core/deserialize.js.map +1 -0
- package/esm/core/display.d.ts +3 -0
- package/esm/core/display.d.ts.map +1 -0
- package/esm/core/display.js +75 -0
- package/esm/core/display.js.map +1 -0
- package/esm/core/inspect.node.d.ts +5 -0
- package/esm/core/inspect.node.d.ts.map +1 -0
- package/esm/core/inspect.node.js +7 -0
- package/esm/core/inspect.node.js.map +1 -0
- package/esm/core/intrinsics.d.ts +19 -0
- package/esm/core/intrinsics.d.ts.map +1 -0
- package/esm/core/intrinsics.js +64 -0
- package/esm/core/intrinsics.js.map +1 -0
- package/esm/core/intrinsics_util.d.ts +6 -0
- package/esm/core/intrinsics_util.d.ts.map +1 -0
- package/esm/core/intrinsics_util.js +46 -0
- package/esm/core/intrinsics_util.js.map +1 -0
- package/esm/core/isType.d.ts +4 -0
- package/esm/core/isType.d.ts.map +1 -0
- package/esm/core/isType.js +18 -0
- package/esm/core/isType.js.map +1 -0
- package/esm/core/mod.d.ts +13 -0
- package/esm/core/mod.d.ts.map +1 -0
- package/esm/core/mod.js +14 -0
- package/esm/core/mod.js.map +1 -0
- package/esm/core/signature.d.ts +4 -0
- package/esm/core/signature.d.ts.map +1 -0
- package/esm/core/signature.js +93 -0
- package/esm/core/signature.js.map +1 -0
- package/esm/core/utility/Flatten.d.ts +8 -0
- package/esm/core/utility/Flatten.d.ts.map +1 -0
- package/esm/core/utility/Flatten.js +6 -0
- package/esm/core/utility/Flatten.js.map +1 -0
- package/esm/core/utility/Intersection.d.ts +12 -0
- package/esm/core/utility/Intersection.d.ts.map +1 -0
- package/esm/core/utility/Intersection.js +5 -0
- package/esm/core/utility/Intersection.js.map +1 -0
- package/esm/core/utility/Option.d.ts +3 -0
- package/esm/core/utility/Option.d.ts.map +1 -0
- package/esm/core/utility/Option.js +5 -0
- package/esm/core/utility/Option.js.map +1 -0
- package/esm/core/utility/Record.d.ts +3 -0
- package/esm/core/utility/Record.d.ts.map +1 -0
- package/esm/core/utility/Record.js +6 -0
- package/esm/core/utility/Record.js.map +1 -0
- package/esm/core/utility/Set.d.ts +4 -0
- package/esm/core/utility/Set.d.ts.map +1 -0
- package/esm/core/utility/Set.js +7 -0
- package/esm/core/utility/Set.js.map +1 -0
- package/esm/core/utility/TaggedUnion.d.ts +13 -0
- package/esm/core/utility/TaggedUnion.d.ts.map +1 -0
- package/esm/core/utility/TaggedUnion.js +8 -0
- package/esm/core/utility/TaggedUnion.js.map +1 -0
- package/esm/core/utility/Tuple.d.ts +9 -0
- package/esm/core/utility/Tuple.d.ts.map +1 -0
- package/esm/core/utility/Tuple.js +11 -0
- package/esm/core/utility/Tuple.js.map +1 -0
- package/esm/core/utility/mod.d.ts +8 -0
- package/esm/core/utility/mod.d.ts.map +1 -0
- package/esm/core/utility/mod.js +9 -0
- package/esm/core/utility/mod.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/almost_equals.d.ts +29 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/almost_equals.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/almost_equals.js +47 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/almost_equals.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/array_includes.d.ts +24 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/array_includes.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/array_includes.js +47 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/array_includes.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/assert.d.ts +16 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/assert.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/assert.js +23 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/assert.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/assertion_error.d.ts +26 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/assertion_error.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/assertion_error.js +31 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/assertion_error.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/equal.d.ts +17 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/equal.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/equal.js +184 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/equal.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/equals.d.ts +35 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/equals.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/equals.js +59 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/equals.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/exists.d.ts +18 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/exists.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/exists.js +28 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/exists.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/fail.d.ts +15 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/fail.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/fail.js +21 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/fail.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/false.d.ts +18 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/false.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/false.js +23 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/false.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/greater.d.ts +20 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/greater.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/greater.js +30 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/greater.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/greater_or_equal.d.ts +20 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/greater_or_equal.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/greater_or_equal.js +30 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/greater_or_equal.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/instance_of.d.ts +23 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/instance_of.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/instance_of.js +53 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/instance_of.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/is_error.d.ts +25 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/is_error.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/is_error.js +54 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/is_error.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/less.d.ts +19 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/less.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/less.js +29 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/less.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/less_or_equal.d.ts +20 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/less_or_equal.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/less_or_equal.js +30 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/less_or_equal.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/match.d.ts +18 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/match.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/match.js +27 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/match.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/mod.d.ts +44 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/mod.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/mod.js +46 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/mod.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/not_equals.d.ts +21 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/not_equals.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/not_equals.js +34 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/not_equals.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/not_instance_of.d.ts +20 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/not_instance_of.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/not_instance_of.js +30 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/not_instance_of.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/not_match.d.ts +18 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/not_match.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/not_match.js +27 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/not_match.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/not_strict_equals.d.ts +23 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/not_strict_equals.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/not_strict_equals.js +33 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/not_strict_equals.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/object_match.d.ts +29 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/object_match.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/object_match.js +161 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/object_match.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/rejects.d.ts +42 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/rejects.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/rejects.js +54 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/rejects.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/strict_equals.d.ts +24 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/strict_equals.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/strict_equals.js +58 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/strict_equals.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/string_includes.d.ts +18 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/string_includes.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/string_includes.js +27 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/string_includes.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/throws.d.ts +45 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/throws.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/throws.js +45 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/throws.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/unimplemented.d.ts +15 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/unimplemented.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/unimplemented.js +21 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/unimplemented.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/unreachable.d.ts +15 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/unreachable.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/unreachable.js +21 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/unreachable.js.map +1 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/_base32_common.d.ts +17 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/_base32_common.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/_base32_common.js +184 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/_base32_common.js.map +1 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/_validate_binary_like.d.ts +2 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/_validate_binary_like.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/_validate_binary_like.js +27 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/_validate_binary_like.js.map +1 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/ascii85.d.ts +59 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/ascii85.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/ascii85.js +153 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/ascii85.js.map +1 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/base32.d.ts +38 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/base32.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/base32.js +70 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/base32.js.map +1 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/base58.d.ts +38 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/base58.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/base58.js +132 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/base58.js.map +1 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/base64.d.ts +38 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/base64.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/base64.js +164 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/base64.js.map +1 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/base64url.d.ts +38 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/base64url.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/base64url.js +82 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/base64url.js.map +1 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/hex.d.ts +37 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/hex.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/hex.js +110 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/hex.js.map +1 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/mod.d.ts +22 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/mod.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/mod.js +23 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/mod.js.map +1 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/varint.d.ts +118 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/varint.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/varint.js +208 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.6/varint.js.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.5/build_message.d.ts +82 -0
- package/esm/deps/jsr.io/@std/internal/1.0.5/build_message.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.5/build_message.js +111 -0
- package/esm/deps/jsr.io/@std/internal/1.0.5/build_message.js.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.5/diff.d.ts +140 -0
- package/esm/deps/jsr.io/@std/internal/1.0.5/diff.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.5/diff.js +277 -0
- package/esm/deps/jsr.io/@std/internal/1.0.5/diff.js.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.5/diff_str.d.ts +99 -0
- package/esm/deps/jsr.io/@std/internal/1.0.5/diff_str.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.5/diff_str.js +180 -0
- package/esm/deps/jsr.io/@std/internal/1.0.5/diff_str.js.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.5/format.d.ts +2 -0
- package/esm/deps/jsr.io/@std/internal/1.0.5/format.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.5/format.js +38 -0
- package/esm/deps/jsr.io/@std/internal/1.0.5/format.js.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.5/styles.d.ts +159 -0
- package/esm/deps/jsr.io/@std/internal/1.0.5/styles.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.5/styles.js +208 -0
- package/esm/deps/jsr.io/@std/internal/1.0.5/styles.js.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.5/types.d.ts +16 -0
- package/esm/deps/jsr.io/@std/internal/1.0.5/types.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.5/types.js +3 -0
- package/esm/deps/jsr.io/@std/internal/1.0.5/types.js.map +1 -0
- package/esm/json_schema/Hydrated.d.ts +4 -0
- package/esm/json_schema/Hydrated.d.ts.map +1 -0
- package/esm/json_schema/Hydrated.js +49 -0
- package/esm/json_schema/Hydrated.js.map +1 -0
- package/esm/json_schema/JSONSchema.d.ts +50 -0
- package/esm/json_schema/JSONSchema.d.ts.map +1 -0
- package/esm/json_schema/JSONSchema.js +46 -0
- package/esm/json_schema/JSONSchema.js.map +1 -0
- package/esm/json_schema/MetaType.d.ts +4 -0
- package/esm/json_schema/MetaType.d.ts.map +1 -0
- package/esm/json_schema/MetaType.js +25 -0
- package/esm/json_schema/MetaType.js.map +1 -0
- package/esm/json_schema/MetaTypeMigration.d.ts +19 -0
- package/esm/json_schema/MetaTypeMigration.d.ts.map +1 -0
- package/esm/json_schema/MetaTypeMigration.js +15 -0
- package/esm/json_schema/MetaTypeMigration.js.map +1 -0
- package/esm/json_schema/PathLike.d.ts +4 -0
- package/esm/json_schema/PathLike.d.ts.map +1 -0
- package/esm/json_schema/PathLike.js +3 -0
- package/esm/json_schema/PathLike.js.map +1 -0
- package/esm/json_schema/mod.d.ts +7 -0
- package/esm/json_schema/mod.d.ts.map +1 -0
- package/esm/json_schema/mod.js +8 -0
- package/esm/json_schema/mod.js.map +1 -0
- package/esm/json_schema/toJSONSchema.d.ts +4 -0
- package/esm/json_schema/toJSONSchema.d.ts.map +1 -0
- package/esm/json_schema/toJSONSchema.js +117 -0
- package/esm/json_schema/toJSONSchema.js.map +1 -0
- package/esm/mod.d.ts +4 -0
- package/esm/mod.d.ts.map +1 -0
- package/esm/mod.js +4 -0
- package/esm/mod.js.map +1 -0
- package/esm/package.json +3 -0
- package/esm/providers/OpenAI/OpenAIAdapter.d.ts +17 -0
- package/esm/providers/OpenAI/OpenAIAdapter.d.ts.map +1 -0
- package/esm/providers/OpenAI/OpenAIAdapter.js +56 -0
- package/esm/providers/OpenAI/OpenAIAdapter.js.map +1 -0
- package/esm/providers/OpenAI/OpenAIResponseFormat.d.ts +18 -0
- package/esm/providers/OpenAI/OpenAIResponseFormat.d.ts.map +1 -0
- package/esm/providers/OpenAI/OpenAIResponseFormat.js +26 -0
- package/esm/providers/OpenAI/OpenAIResponseFormat.js.map +1 -0
- package/esm/providers/OpenAI/TokenAllowance.d.ts +17 -0
- package/esm/providers/OpenAI/TokenAllowance.d.ts.map +1 -0
- package/esm/providers/OpenAI/TokenAllowance.js +32 -0
- package/esm/providers/OpenAI/TokenAllowance.js.map +1 -0
- package/esm/providers/OpenAI/mod.d.ts +6 -0
- package/esm/providers/OpenAI/mod.d.ts.map +1 -0
- package/esm/providers/OpenAI/mod.js +7 -0
- package/esm/providers/OpenAI/mod.js.map +1 -0
- package/esm/providers/OpenAI/openai_util.d.ts +4 -0
- package/esm/providers/OpenAI/openai_util.d.ts.map +1 -0
- package/esm/providers/OpenAI/openai_util.js +14 -0
- package/esm/providers/OpenAI/openai_util.js.map +1 -0
- package/esm/providers/OpenAI/refine.d.ts +2 -0
- package/esm/providers/OpenAI/refine.d.ts.map +1 -0
- package/esm/providers/OpenAI/refine.js +166 -0
- package/esm/providers/OpenAI/refine.js.map +1 -0
- package/esm/util/ArrayOfLength.d.ts +2 -0
- package/esm/util/ArrayOfLength.d.ts.map +1 -0
- package/esm/util/ArrayOfLength.js +2 -0
- package/esm/util/ArrayOfLength.js.map +1 -0
- package/esm/util/PromiseOr.d.ts +2 -0
- package/esm/util/PromiseOr.d.ts.map +1 -0
- package/esm/util/PromiseOr.js +2 -0
- package/esm/util/PromiseOr.js.map +1 -0
- package/esm/util/WeakMemo.d.ts +7 -0
- package/esm/util/WeakMemo.d.ts.map +1 -0
- package/esm/util/WeakMemo.js +32 -0
- package/esm/util/WeakMemo.js.map +1 -0
- package/esm/util/collect.d.ts +2 -0
- package/esm/util/collect.d.ts.map +1 -0
- package/esm/util/collect.js +8 -0
- package/esm/util/collect.js.map +1 -0
- package/esm/util/isPromise.d.ts +2 -0
- package/esm/util/isPromise.d.ts.map +1 -0
- package/esm/util/isPromise.js +7 -0
- package/esm/util/isPromise.js.map +1 -0
- package/esm/util/isTemplateStringsArray.d.ts +2 -0
- package/esm/util/isTemplateStringsArray.d.ts.map +1 -0
- package/esm/util/isTemplateStringsArray.js +4 -0
- package/esm/util/isTemplateStringsArray.js.map +1 -0
- package/esm/util/mod.d.ts +10 -0
- package/esm/util/mod.d.ts.map +1 -0
- package/esm/util/mod.js +11 -0
- package/esm/util/mod.js.map +1 -0
- package/esm/util/recombine.d.ts +2 -0
- package/esm/util/recombine.d.ts.map +1 -0
- package/esm/util/recombine.js +11 -0
- package/esm/util/recombine.js.map +1 -0
- package/esm/util/splitLast.d.ts +2 -0
- package/esm/util/splitLast.d.ts.map +1 -0
- package/esm/util/splitLast.js +8 -0
- package/esm/util/splitLast.js.map +1 -0
- package/esm/util/type_util.d.ts +5 -0
- package/esm/util/type_util.d.ts.map +1 -0
- package/esm/util/type_util.js +2 -0
- package/esm/util/type_util.js.map +1 -0
- package/package.json +22 -0
- package/src/_dnt.shims.ts +60 -0
- package/src/client/Adapter.ts +50 -0
- package/src/client/Liminal.ts +113 -0
- package/src/client/Tool.ts +17 -0
- package/src/client/constants.ts +6 -0
- package/src/client/mod.ts +6 -0
- package/src/core/DescriptionContext.ts +89 -0
- package/src/core/L.ts +3 -0
- package/src/core/ReduceDependencies.ts +9 -0
- package/src/core/Type.ts +45 -0
- package/src/core/TypeVisitor.ts +44 -0
- package/src/core/annotations/Annotation.ts +14 -0
- package/src/core/annotations/Assertion.ts +18 -0
- package/src/core/annotations/Description.ts +16 -0
- package/src/core/annotations/Param.ts +30 -0
- package/src/core/annotations/Template.ts +11 -0
- package/src/core/annotations/mod.ts +7 -0
- package/src/core/assert.ts +145 -0
- package/src/core/declareIntrinsic.ts +45 -0
- package/src/core/deserialize.ts +36 -0
- package/src/core/display.ts +68 -0
- package/src/core/inspect.node.ts +13 -0
- package/src/core/intrinsics.ts +86 -0
- package/src/core/intrinsics_util.ts +50 -0
- package/src/core/isType.ts +20 -0
- package/src/core/mod.ts +15 -0
- package/src/core/signature.ts +90 -0
- package/src/core/utility/Flatten.ts +14 -0
- package/src/core/utility/Intersection.ts +24 -0
- package/src/core/utility/Option.ts +6 -0
- package/src/core/utility/Record.ts +7 -0
- package/src/core/utility/Set.ts +8 -0
- package/src/core/utility/TaggedUnion.ts +23 -0
- package/src/core/utility/Tuple.ts +24 -0
- package/src/core/utility/mod.ts +9 -0
- package/src/deps/jsr.io/@std/assert/1.0.10/almost_equals.ts +55 -0
- package/src/deps/jsr.io/@std/assert/1.0.10/array_includes.ts +57 -0
- package/src/deps/jsr.io/@std/assert/1.0.10/assert.ts +23 -0
- package/src/deps/jsr.io/@std/assert/1.0.10/assertion_error.ts +31 -0
- package/src/deps/jsr.io/@std/assert/1.0.10/equal.ts +210 -0
- package/src/deps/jsr.io/@std/assert/1.0.10/equals.ts +65 -0
- package/src/deps/jsr.io/@std/assert/1.0.10/exists.ts +31 -0
- package/src/deps/jsr.io/@std/assert/1.0.10/fail.ts +21 -0
- package/src/deps/jsr.io/@std/assert/1.0.10/false.ts +26 -0
- package/src/deps/jsr.io/@std/assert/1.0.10/greater.ts +30 -0
- package/src/deps/jsr.io/@std/assert/1.0.10/greater_or_equal.ts +36 -0
- package/src/deps/jsr.io/@std/assert/1.0.10/instance_of.ts +64 -0
- package/src/deps/jsr.io/@std/assert/1.0.10/is_error.ts +65 -0
- package/src/deps/jsr.io/@std/assert/1.0.10/less.ts +29 -0
- package/src/deps/jsr.io/@std/assert/1.0.10/less_or_equal.ts +36 -0
- package/src/deps/jsr.io/@std/assert/1.0.10/match.ts +30 -0
- package/src/deps/jsr.io/@std/assert/1.0.10/mod.ts +47 -0
- package/src/deps/jsr.io/@std/assert/1.0.10/not_equals.ts +37 -0
- package/src/deps/jsr.io/@std/assert/1.0.10/not_instance_of.ts +33 -0
- package/src/deps/jsr.io/@std/assert/1.0.10/not_match.ts +30 -0
- package/src/deps/jsr.io/@std/assert/1.0.10/not_strict_equals.ts +42 -0
- package/src/deps/jsr.io/@std/assert/1.0.10/object_match.ts +203 -0
- package/src/deps/jsr.io/@std/assert/1.0.10/rejects.ts +123 -0
- package/src/deps/jsr.io/@std/assert/1.0.10/strict_equals.ts +67 -0
- package/src/deps/jsr.io/@std/assert/1.0.10/string_includes.ts +30 -0
- package/src/deps/jsr.io/@std/assert/1.0.10/throws.ts +111 -0
- package/src/deps/jsr.io/@std/assert/1.0.10/unimplemented.ts +21 -0
- package/src/deps/jsr.io/@std/assert/1.0.10/unreachable.ts +21 -0
- package/src/deps/jsr.io/@std/encoding/1.0.6/_base32_common.ts +218 -0
- package/src/deps/jsr.io/@std/encoding/1.0.6/_validate_binary_like.ts +29 -0
- package/src/deps/jsr.io/@std/encoding/1.0.6/ascii85.ts +203 -0
- package/src/deps/jsr.io/@std/encoding/1.0.6/base32.ts +73 -0
- package/src/deps/jsr.io/@std/encoding/1.0.6/base58.ts +173 -0
- package/src/deps/jsr.io/@std/encoding/1.0.6/base64.ts +174 -0
- package/src/deps/jsr.io/@std/encoding/1.0.6/base64url.ts +88 -0
- package/src/deps/jsr.io/@std/encoding/1.0.6/hex.ts +120 -0
- package/src/deps/jsr.io/@std/encoding/1.0.6/mod.ts +24 -0
- package/src/deps/jsr.io/@std/encoding/1.0.6/varint.ts +242 -0
- package/src/deps/jsr.io/@std/internal/1.0.5/build_message.ts +134 -0
- package/src/deps/jsr.io/@std/internal/1.0.5/diff.ts +317 -0
- package/src/deps/jsr.io/@std/internal/1.0.5/diff_str.ts +204 -0
- package/src/deps/jsr.io/@std/internal/1.0.5/format.ts +39 -0
- package/src/deps/jsr.io/@std/internal/1.0.5/styles.ts +233 -0
- package/src/deps/jsr.io/@std/internal/1.0.5/types.ts +18 -0
- package/src/json_schema/Hydrated.ts +52 -0
- package/src/json_schema/JSONSchema.ts +95 -0
- package/src/json_schema/MetaType.ts +32 -0
- package/src/json_schema/MetaTypeMigration.ts +31 -0
- package/src/json_schema/PathLike.ts +9 -0
- package/src/json_schema/mod.ts +8 -0
- package/src/json_schema/toJSONSchema.ts +114 -0
- package/src/mod.ts +3 -0
- package/src/providers/OpenAI/OpenAIAdapter.ts +89 -0
- package/src/providers/OpenAI/OpenAIResponseFormat.ts +54 -0
- package/src/providers/OpenAI/TokenAllowance.ts +29 -0
- package/src/providers/OpenAI/mod.ts +7 -0
- package/src/providers/OpenAI/openai_util.ts +19 -0
- package/src/providers/OpenAI/refine.ts +171 -0
- package/src/util/ArrayOfLength.ts +5 -0
- package/src/util/PromiseOr.ts +1 -0
- package/src/util/WeakMemo.ts +13 -0
- package/src/util/collect.ts +7 -0
- package/src/util/isPromise.ts +8 -0
- package/src/util/isTemplateStringsArray.ts +3 -0
- package/src/util/mod.ts +11 -0
- package/src/util/recombine.ts +10 -0
- package/src/util/splitLast.ts +7 -0
- package/src/util/type_util.ts +3 -0
package/src/core/Type.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Annotation } from "./annotations/Annotation.js"
|
|
2
|
+
import type { Param, TemplatePart } from "./annotations/mod.js"
|
|
3
|
+
import type { ReduceDependencies } from "./ReduceDependencies.js"
|
|
4
|
+
|
|
5
|
+
export interface Type<T, D extends symbol = never> {
|
|
6
|
+
<A extends Array<Annotation<T>>>(
|
|
7
|
+
...annotations: A | Array<Annotation<T>> & { length: never }
|
|
8
|
+
): Type<T, ReduceDependencies<D, A>>
|
|
9
|
+
|
|
10
|
+
<A extends Array<TemplatePart>>(
|
|
11
|
+
template: TemplateStringsArray,
|
|
12
|
+
...descriptionParts: A
|
|
13
|
+
): Type<T, ReduceDependencies<D, A>>
|
|
14
|
+
|
|
15
|
+
T: T
|
|
16
|
+
D: D
|
|
17
|
+
|
|
18
|
+
[TypeKey]: true
|
|
19
|
+
type: "Type"
|
|
20
|
+
trace: string
|
|
21
|
+
declaration: TypeDeclaration
|
|
22
|
+
annotations: Array<Annotation>
|
|
23
|
+
|
|
24
|
+
extract: <K extends symbol, V>(param: Param<K, V>) => Array<V>
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type TypeDeclaration = {
|
|
28
|
+
getAtom: () => PartialType
|
|
29
|
+
factory?: never
|
|
30
|
+
args?: never
|
|
31
|
+
} | {
|
|
32
|
+
getAtom?: never
|
|
33
|
+
factory: (...args: any) => PartialType
|
|
34
|
+
args: unknown[]
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type PartialType<T = any> = Type<T, symbol>
|
|
38
|
+
|
|
39
|
+
export type DerivedType<
|
|
40
|
+
T,
|
|
41
|
+
X extends Array<PartialType>,
|
|
42
|
+
P extends symbol = never,
|
|
43
|
+
> = [Type<T, P | X[number]["D"]>][0]
|
|
44
|
+
|
|
45
|
+
export const TypeKey: unique symbol = Symbol()
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Expand } from "../util/mod.js"
|
|
2
|
+
import { IntrinsicName, type Intrinsics } from "./intrinsics_util.js"
|
|
3
|
+
import type { PartialType } from "./Type.js"
|
|
4
|
+
|
|
5
|
+
export type TypeVisitorArms<C, R> = Expand<
|
|
6
|
+
& {
|
|
7
|
+
hook?: (
|
|
8
|
+
next: (ctx: C, type: PartialType) => R,
|
|
9
|
+
ctx: C,
|
|
10
|
+
type: PartialType,
|
|
11
|
+
) => R
|
|
12
|
+
}
|
|
13
|
+
& (
|
|
14
|
+
| ({ fallback?: never } & TypeVisitorIntrinsicArms<C, R>)
|
|
15
|
+
| (
|
|
16
|
+
& { fallback: (ctx: C, type: PartialType, ...args: unknown[]) => R }
|
|
17
|
+
& Partial<TypeVisitorIntrinsicArms<C, R>>
|
|
18
|
+
)
|
|
19
|
+
)
|
|
20
|
+
>
|
|
21
|
+
|
|
22
|
+
export type TypeVisitorIntrinsicArms<C, R> = {
|
|
23
|
+
[K in IntrinsicName]: (
|
|
24
|
+
ctx: C,
|
|
25
|
+
...rest: Intrinsics[K] extends PartialType ? [type: Intrinsics[K]]
|
|
26
|
+
: [type: ReturnType<Intrinsics[K]>, ...args: Parameters<Intrinsics[K]>]
|
|
27
|
+
) => R
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function TypeVisitor<C, R>(arms: TypeVisitorArms<C, R>): (ctx: C, type: PartialType) => R {
|
|
31
|
+
const { hook } = arms
|
|
32
|
+
if (hook) {
|
|
33
|
+
return (ctx, type) => hook(next, ctx, type)
|
|
34
|
+
}
|
|
35
|
+
return next
|
|
36
|
+
|
|
37
|
+
function next(ctx: C, type: PartialType): R {
|
|
38
|
+
return (arms[IntrinsicName(type)] ?? arms.fallback!)(
|
|
39
|
+
ctx,
|
|
40
|
+
type as never,
|
|
41
|
+
...type.declaration.factory ? type.declaration.args as never : [],
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Falsy } from "../../deps/jsr.io/@std/assert/1.0.10/mod.js"
|
|
2
|
+
import type { PartialType } from "../Type.js"
|
|
3
|
+
import type { Assertion } from "./Assertion.js"
|
|
4
|
+
import type { Arg, Param } from "./Param.js"
|
|
5
|
+
import type { Template } from "./Template.js"
|
|
6
|
+
|
|
7
|
+
export type Annotation<T = any> =
|
|
8
|
+
| Falsy
|
|
9
|
+
| string
|
|
10
|
+
| Template
|
|
11
|
+
| PartialType
|
|
12
|
+
| Assertion<T>
|
|
13
|
+
| Param
|
|
14
|
+
| Arg
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { PromiseOr } from "../../util/mod.js"
|
|
2
|
+
|
|
3
|
+
export interface Assertion<T = any> {
|
|
4
|
+
type: "Assertion"
|
|
5
|
+
description: string
|
|
6
|
+
f?: (value: T) => PromiseOr<void>
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function Assertion<T>(
|
|
10
|
+
description: string,
|
|
11
|
+
f?: (value: T) => PromiseOr<void>,
|
|
12
|
+
): Assertion<T> {
|
|
13
|
+
return {
|
|
14
|
+
type: "Assertion",
|
|
15
|
+
description,
|
|
16
|
+
f,
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Param } from "./Param.js"
|
|
2
|
+
|
|
3
|
+
export const DescriptionParamKey: unique symbol = Symbol()
|
|
4
|
+
|
|
5
|
+
export interface DescriptionArg {
|
|
6
|
+
[DescriptionParamKey]: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function DescriptionParam<K extends symbol, A = string>(
|
|
10
|
+
key: K,
|
|
11
|
+
serialize?: (value: A) => string,
|
|
12
|
+
): Param<K, A, DescriptionArg> {
|
|
13
|
+
return Param(key, (value) => ({
|
|
14
|
+
[DescriptionParamKey]: (serialize?.(value) ?? value) as string,
|
|
15
|
+
}))
|
|
16
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface Param<K extends symbol = symbol, A = any, T = any> {
|
|
2
|
+
(arg: A): Arg<K, T>
|
|
3
|
+
type: "Param"
|
|
4
|
+
key: K
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export type AnyParam<T> = Param<symbol, any, T>
|
|
8
|
+
|
|
9
|
+
export interface Arg<K extends symbol = symbol, T = any> {
|
|
10
|
+
type: "Arg"
|
|
11
|
+
key: K
|
|
12
|
+
value: T
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function Param<K extends symbol, A, T>(
|
|
16
|
+
key: K,
|
|
17
|
+
f: (value: A) => T,
|
|
18
|
+
): Param<K, A, T> {
|
|
19
|
+
return Object.assign(
|
|
20
|
+
(value: A): Arg<K> => ({
|
|
21
|
+
type: "Arg",
|
|
22
|
+
key,
|
|
23
|
+
value: f(value),
|
|
24
|
+
}),
|
|
25
|
+
{
|
|
26
|
+
type: "Param" as const,
|
|
27
|
+
key,
|
|
28
|
+
},
|
|
29
|
+
)
|
|
30
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { PartialType } from "../Type.js"
|
|
2
|
+
import type { DescriptionArg } from "./Description.js"
|
|
3
|
+
import type { AnyParam } from "./Param.js"
|
|
4
|
+
|
|
5
|
+
export interface Template {
|
|
6
|
+
type: "Template"
|
|
7
|
+
template: TemplateStringsArray
|
|
8
|
+
parts: Array<TemplatePart>
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type TemplatePart = string | PartialType | AnyParam<string | DescriptionArg>
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import * as A from "../deps/jsr.io/@std/assert/1.0.10/mod.js"
|
|
2
|
+
import type { PartialType, Type } from "./Type.js"
|
|
3
|
+
import { TypeVisitor } from "./TypeVisitor.js"
|
|
4
|
+
|
|
5
|
+
export interface Diagnostic {
|
|
6
|
+
type: PartialType
|
|
7
|
+
path: string
|
|
8
|
+
exception: unknown
|
|
9
|
+
value: unknown
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export namespace Diagnostic {
|
|
13
|
+
export function toString({ exception, path, value }: Diagnostic): string {
|
|
14
|
+
return `${
|
|
15
|
+
exception instanceof Error ? `Error "${exception.name}"` : "Exception"
|
|
16
|
+
} from value \`${JSON.stringify(value)}\` at \`root${path}\`: ${
|
|
17
|
+
exception instanceof Error ? exception.message : JSON.stringify(exception)
|
|
18
|
+
}`
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export async function assert(type: Type<any>, value: unknown): Promise<void> {
|
|
23
|
+
const ctx = new AssertContext([], [], "root", value)
|
|
24
|
+
visit(ctx, type)
|
|
25
|
+
const diagnostics = [
|
|
26
|
+
...ctx.structuralDiagnostics,
|
|
27
|
+
...await Promise.all(ctx.annotationDiagnostics ?? []).then((v) => v.filter((e) => !!e)),
|
|
28
|
+
]
|
|
29
|
+
if (diagnostics.length) {
|
|
30
|
+
throw new AggregateError(diagnostics.map(({ exception }) => exception))
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function matchUnionMember(members: Array<PartialType>, value: unknown): PartialType | void {
|
|
35
|
+
const queue = [...members]
|
|
36
|
+
while (queue.length) {
|
|
37
|
+
const current = queue.pop()!
|
|
38
|
+
const diagnostics: Array<Diagnostic> = []
|
|
39
|
+
visit(new AssertContext(diagnostics, undefined, "", value), current)
|
|
40
|
+
if (diagnostics.length) {
|
|
41
|
+
continue
|
|
42
|
+
}
|
|
43
|
+
return current
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export class AssertContext {
|
|
48
|
+
constructor(
|
|
49
|
+
readonly structuralDiagnostics: Array<Diagnostic>,
|
|
50
|
+
readonly annotationDiagnostics: undefined | Array<Promise<Diagnostic | void>>,
|
|
51
|
+
readonly path: string,
|
|
52
|
+
readonly value: unknown,
|
|
53
|
+
readonly junction?: number | string,
|
|
54
|
+
) {}
|
|
55
|
+
|
|
56
|
+
descend = (value: unknown, junction?: number | string): AssertContext =>
|
|
57
|
+
new AssertContext(
|
|
58
|
+
this.structuralDiagnostics,
|
|
59
|
+
this.annotationDiagnostics,
|
|
60
|
+
this.path,
|
|
61
|
+
value,
|
|
62
|
+
junction,
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const visit = TypeVisitor<AssertContext, void>({
|
|
67
|
+
hook(next, ctx, type) {
|
|
68
|
+
const path = ctx.junction ? ctx.path : `${ctx.path}["${ctx.junction}"]`
|
|
69
|
+
try {
|
|
70
|
+
next(ctx, type)
|
|
71
|
+
} catch (exception: unknown) {
|
|
72
|
+
ctx.structuralDiagnostics.push({
|
|
73
|
+
type,
|
|
74
|
+
path,
|
|
75
|
+
exception,
|
|
76
|
+
value: ctx.value,
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
const { annotationDiagnostics } = ctx
|
|
80
|
+
if (annotationDiagnostics) {
|
|
81
|
+
type.annotations
|
|
82
|
+
.filter((annotation) => typeof annotation === "object" && annotation?.type === "Assertion")
|
|
83
|
+
.forEach(({ f }) => {
|
|
84
|
+
if (f) {
|
|
85
|
+
annotationDiagnostics.push((async () => {
|
|
86
|
+
try {
|
|
87
|
+
await f(ctx.value)
|
|
88
|
+
} catch (exception: unknown) {
|
|
89
|
+
return {
|
|
90
|
+
type,
|
|
91
|
+
path,
|
|
92
|
+
exception,
|
|
93
|
+
value: ctx.value,
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
})())
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
null({ value }) {
|
|
102
|
+
A.assert(value === null)
|
|
103
|
+
},
|
|
104
|
+
boolean({ value }) {
|
|
105
|
+
A.assert(typeof value === "boolean")
|
|
106
|
+
},
|
|
107
|
+
integer({ value }) {
|
|
108
|
+
A.assert(Number.isInteger(value))
|
|
109
|
+
},
|
|
110
|
+
number({ value }) {
|
|
111
|
+
A.assert(typeof value === "number")
|
|
112
|
+
},
|
|
113
|
+
string({ value }) {
|
|
114
|
+
A.assert(typeof value === "string")
|
|
115
|
+
},
|
|
116
|
+
const({ value }, _1, _2, cmpValue) {
|
|
117
|
+
A.assertEquals(value, cmpValue)
|
|
118
|
+
},
|
|
119
|
+
enum({ value }, _1, ...values) {
|
|
120
|
+
A.assert(typeof value === "string")
|
|
121
|
+
A.assertArrayIncludes(values, [value])
|
|
122
|
+
},
|
|
123
|
+
array(ctx, _1, element) {
|
|
124
|
+
A.assert(Array.isArray(ctx.value))
|
|
125
|
+
ctx.value.forEach((value, i) => visit(ctx.descend(value, i), element))
|
|
126
|
+
},
|
|
127
|
+
object(ctx, _1, fields) {
|
|
128
|
+
const keys = Object.keys(fields).toSorted()
|
|
129
|
+
const { value } = ctx
|
|
130
|
+
A.assert(typeof value === "object" && value !== null)
|
|
131
|
+
A.assertEquals(keys, Object.keys(value).toSorted())
|
|
132
|
+
keys.forEach((key) => visit(ctx.descend(value[key as never], key), fields[key]!))
|
|
133
|
+
},
|
|
134
|
+
transform(ctx, _1, from) {
|
|
135
|
+
visit(ctx, from)
|
|
136
|
+
},
|
|
137
|
+
union(ctx, _1, ...members) {
|
|
138
|
+
const match = matchUnionMember(members, ctx.value)
|
|
139
|
+
A.assert(match)
|
|
140
|
+
visit(ctx, match)
|
|
141
|
+
},
|
|
142
|
+
ref(ctx, _1, get) {
|
|
143
|
+
visit(ctx, get())
|
|
144
|
+
},
|
|
145
|
+
})
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { isTemplateStringsArray } from "../util/mod.js"
|
|
2
|
+
import type { Annotation } from "./annotations/Annotation.js"
|
|
3
|
+
import type { TemplatePart } from "./annotations/mod.js"
|
|
4
|
+
import { inspect } from "./inspect.node.js"
|
|
5
|
+
import type { ReduceDependencies } from "./ReduceDependencies.js"
|
|
6
|
+
import { type Type, type TypeDeclaration, TypeKey } from "./Type.js"
|
|
7
|
+
|
|
8
|
+
export function declare<T, D extends symbol>(
|
|
9
|
+
declaration: TypeDeclaration,
|
|
10
|
+
annotations: Array<Annotation> = [],
|
|
11
|
+
): Type<T, D> {
|
|
12
|
+
return Object.assign(
|
|
13
|
+
Type,
|
|
14
|
+
inspect,
|
|
15
|
+
{
|
|
16
|
+
[TypeKey]: true,
|
|
17
|
+
type: "Type",
|
|
18
|
+
trace: new Error().stack!,
|
|
19
|
+
declaration,
|
|
20
|
+
annotations,
|
|
21
|
+
extract: () => {
|
|
22
|
+
throw 0
|
|
23
|
+
},
|
|
24
|
+
} satisfies Omit<Type<T, D>, "T" | "D"> as never,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
function Type<A extends Array<TemplatePart>>(
|
|
28
|
+
template: TemplateStringsArray,
|
|
29
|
+
...descriptionParts: A
|
|
30
|
+
): Type<T, ReduceDependencies<D, A>>
|
|
31
|
+
function Type<A extends Array<Annotation>>(...annotations: A): Type<T, ReduceDependencies<D, A>>
|
|
32
|
+
function Type(
|
|
33
|
+
maybeTemplate: Annotation | TemplateStringsArray,
|
|
34
|
+
...parts: Array<Annotation>
|
|
35
|
+
): Type<T, symbol> {
|
|
36
|
+
if (isTemplateStringsArray(maybeTemplate)) {
|
|
37
|
+
return declare(declaration, [...annotations, {
|
|
38
|
+
type: "Template",
|
|
39
|
+
template: maybeTemplate,
|
|
40
|
+
parts: parts as Array<TemplatePart>,
|
|
41
|
+
}])
|
|
42
|
+
}
|
|
43
|
+
return declare(declaration, [maybeTemplate, ...annotations, ...parts])
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { assert } from "../deps/jsr.io/@std/assert/1.0.10/mod.js"
|
|
2
|
+
import { matchUnionMember } from "./assert.js"
|
|
3
|
+
import type { Type } from "./Type.js"
|
|
4
|
+
import { TypeVisitor } from "./TypeVisitor.js"
|
|
5
|
+
|
|
6
|
+
export function deserialize<T>(type: Type<T>, jsonText: string): T {
|
|
7
|
+
return visit(JSON.parse(jsonText), type) as never
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const visit = TypeVisitor<unknown, unknown>({
|
|
11
|
+
hook(next, value, type) {
|
|
12
|
+
return next(value, type)
|
|
13
|
+
},
|
|
14
|
+
array(value, _1, element): unknown {
|
|
15
|
+
return (value as unknown[]).map((e) => visit(e, element))
|
|
16
|
+
},
|
|
17
|
+
object(value, _1, fields): unknown {
|
|
18
|
+
return Object.fromEntries(
|
|
19
|
+
Object.entries(fields).map(([k, v]) => [k, visit((value as never)[k], v)]),
|
|
20
|
+
)
|
|
21
|
+
},
|
|
22
|
+
union(value, _1, ...members): unknown {
|
|
23
|
+
const matched = matchUnionMember(members, value)!
|
|
24
|
+
assert(matched)
|
|
25
|
+
return visit(value, matched)
|
|
26
|
+
},
|
|
27
|
+
ref(ctx, _1, get): unknown {
|
|
28
|
+
return visit(ctx, get())
|
|
29
|
+
},
|
|
30
|
+
transform(ctx, _1, from, f): unknown {
|
|
31
|
+
return f(visit(ctx, from))
|
|
32
|
+
},
|
|
33
|
+
fallback(value) {
|
|
34
|
+
return value
|
|
35
|
+
},
|
|
36
|
+
})
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { IntrinsicName } from "./intrinsics_util.js"
|
|
2
|
+
import type { PartialType } from "./Type.js"
|
|
3
|
+
import { TypeVisitor } from "./TypeVisitor.js"
|
|
4
|
+
|
|
5
|
+
export function display(type: PartialType): string {
|
|
6
|
+
return visit(new DisplayContext(type, false, 0), type)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
class DisplayContext {
|
|
10
|
+
constructor(
|
|
11
|
+
readonly rootType: PartialType,
|
|
12
|
+
readonly visitedRoot: boolean,
|
|
13
|
+
readonly depth: number,
|
|
14
|
+
) {}
|
|
15
|
+
|
|
16
|
+
indentCtx = () => new DisplayContext(this.rootType, this.visitedRoot, this.depth + 1)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const visit = TypeVisitor<DisplayContext, string>({
|
|
20
|
+
hook(next, ctx, type): string {
|
|
21
|
+
if (type === ctx.rootType && ctx.visitedRoot) {
|
|
22
|
+
return "self"
|
|
23
|
+
}
|
|
24
|
+
return next(new DisplayContext(ctx.rootType, true, ctx.depth), type)
|
|
25
|
+
},
|
|
26
|
+
const(_0, _1, _2, value): string {
|
|
27
|
+
if (typeof value === "string") {
|
|
28
|
+
return `"${escapeDoubleQuotes(value)}"`
|
|
29
|
+
}
|
|
30
|
+
return JSON.stringify(value)
|
|
31
|
+
},
|
|
32
|
+
array(ctx, _1, element): string {
|
|
33
|
+
return `array(${visit(ctx, element)})`
|
|
34
|
+
},
|
|
35
|
+
object(ctx, _1, fields): string {
|
|
36
|
+
return `object({\n${
|
|
37
|
+
Object
|
|
38
|
+
.entries(fields)
|
|
39
|
+
.map(([k, v]) =>
|
|
40
|
+
`${" ".repeat(ctx.depth + 1)}${escapeDoubleQuotes(k)}: ${visit(ctx.indentCtx(), v)}`
|
|
41
|
+
)
|
|
42
|
+
.join(",\n")
|
|
43
|
+
}\n${" ".repeat(ctx.depth)}})`
|
|
44
|
+
},
|
|
45
|
+
enum(_0, _1, ...values) {
|
|
46
|
+
return `enum("${values.map(escapeDoubleQuotes).join(`", "`)}")`
|
|
47
|
+
},
|
|
48
|
+
union(ctx, _1, ...members): string {
|
|
49
|
+
return `union(\n${" ".repeat(ctx.depth + 1)}${
|
|
50
|
+
members.map((member) => visit(ctx.indentCtx(), member)).join(
|
|
51
|
+
`,\n${" ".repeat(ctx.depth + 1)}`,
|
|
52
|
+
)
|
|
53
|
+
}\n)`
|
|
54
|
+
},
|
|
55
|
+
ref(ctx, _1, get): string {
|
|
56
|
+
return visit(ctx, get())
|
|
57
|
+
},
|
|
58
|
+
transform(ctx, _1, from): string {
|
|
59
|
+
return `f(${visit(ctx, from)})`
|
|
60
|
+
},
|
|
61
|
+
fallback(_0, type) {
|
|
62
|
+
return IntrinsicName(type)
|
|
63
|
+
},
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
function escapeDoubleQuotes(value: string): string {
|
|
67
|
+
return value.indexOf(`"`) !== -1 ? JSON.stringify(value) : value
|
|
68
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { display } from "./display.js"
|
|
2
|
+
import type { PartialType } from "./Type.js"
|
|
3
|
+
|
|
4
|
+
export const inspect = {
|
|
5
|
+
[Symbol.for("nodejs.util.inspect.custom")](
|
|
6
|
+
this: PartialType,
|
|
7
|
+
_0: unknown,
|
|
8
|
+
_1: unknown,
|
|
9
|
+
_inspect_: (value: unknown) => string,
|
|
10
|
+
): string {
|
|
11
|
+
return display(this)
|
|
12
|
+
},
|
|
13
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { declare } from "./declareIntrinsic.js"
|
|
2
|
+
import type { PartialType, Type } from "./Type.js"
|
|
3
|
+
|
|
4
|
+
export { null_ as null }
|
|
5
|
+
const null_: Type<null> = declare({
|
|
6
|
+
getAtom: () => null_,
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
export const boolean: Type<boolean> = declare({
|
|
10
|
+
getAtom: () => boolean,
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
export const integer: Type<number> = declare({
|
|
14
|
+
getAtom: () => integer,
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
export const number: Type<number> = declare({
|
|
18
|
+
getAtom: () => number,
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
export const string: Type<string> = declare({
|
|
22
|
+
getAtom: () => string,
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
export { const_ as const }
|
|
26
|
+
function const_<T, P extends symbol, const A extends T>(
|
|
27
|
+
type: Type<T, P>,
|
|
28
|
+
value: A,
|
|
29
|
+
): Type<A, P> {
|
|
30
|
+
return declare({
|
|
31
|
+
factory: const_,
|
|
32
|
+
args: [type, value],
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
Object.defineProperty(const_, "name", { value: "const" })
|
|
36
|
+
|
|
37
|
+
export function array<T, P extends symbol>(element: Type<T, P>): Type<Array<T>, P> {
|
|
38
|
+
return declare({
|
|
39
|
+
factory: array,
|
|
40
|
+
args: [element],
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function object<F extends Record<string, PartialType>>(
|
|
45
|
+
fields: F,
|
|
46
|
+
): Type<{ [K in keyof F]: F[K]["T"] }, F[keyof F]["D"]> {
|
|
47
|
+
return declare({
|
|
48
|
+
factory: object,
|
|
49
|
+
args: [Object.fromEntries(Object.keys(fields).toSorted().map((key) => [key, fields[key]]))],
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { enum_ as enum }
|
|
54
|
+
function enum_<V extends Array<string>>(...values: V): Type<V[number]> {
|
|
55
|
+
return declare({
|
|
56
|
+
factory: enum_,
|
|
57
|
+
args: values.toSorted(),
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
Object.defineProperty(enum_, "name", { value: "enum" })
|
|
61
|
+
|
|
62
|
+
export function union<M extends Array<PartialType>>(
|
|
63
|
+
...members: M
|
|
64
|
+
): Type<M[number]["T"], M[number]["D"]> {
|
|
65
|
+
return declare({
|
|
66
|
+
factory: union,
|
|
67
|
+
args: members,
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function ref<T, P extends symbol>(get: () => Type<T, P>): Type<T, P> {
|
|
72
|
+
return declare({
|
|
73
|
+
factory: ref,
|
|
74
|
+
args: [get],
|
|
75
|
+
}) as never
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function transform<T, P extends symbol, R>(
|
|
79
|
+
from: Type<T, P>,
|
|
80
|
+
f: (value: T) => R,
|
|
81
|
+
): Type<R, P> {
|
|
82
|
+
return declare({
|
|
83
|
+
factory: transform,
|
|
84
|
+
args: [from, f],
|
|
85
|
+
})
|
|
86
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { unreachable } from "../deps/jsr.io/@std/assert/1.0.10/mod.js"
|
|
2
|
+
import * as I from "./intrinsics.js"
|
|
3
|
+
import type { PartialType } from "./Type.js"
|
|
4
|
+
|
|
5
|
+
export type Intrinsics = typeof I
|
|
6
|
+
export type IntrinsicName = keyof Intrinsics
|
|
7
|
+
|
|
8
|
+
export function IntrinsicName(type: PartialType): IntrinsicName {
|
|
9
|
+
switch (type.declaration.getAtom?.()) {
|
|
10
|
+
case I.null: {
|
|
11
|
+
return "null"
|
|
12
|
+
}
|
|
13
|
+
case I.boolean: {
|
|
14
|
+
return "boolean"
|
|
15
|
+
}
|
|
16
|
+
case I.number: {
|
|
17
|
+
return "number"
|
|
18
|
+
}
|
|
19
|
+
case I.integer: {
|
|
20
|
+
return "integer"
|
|
21
|
+
}
|
|
22
|
+
case I.string: {
|
|
23
|
+
return "string"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
switch (type.declaration.factory) {
|
|
27
|
+
case I.const: {
|
|
28
|
+
return "const"
|
|
29
|
+
}
|
|
30
|
+
case I.array: {
|
|
31
|
+
return "array"
|
|
32
|
+
}
|
|
33
|
+
case I.object: {
|
|
34
|
+
return "object"
|
|
35
|
+
}
|
|
36
|
+
case I.enum: {
|
|
37
|
+
return "enum"
|
|
38
|
+
}
|
|
39
|
+
case I.union: {
|
|
40
|
+
return "union"
|
|
41
|
+
}
|
|
42
|
+
case I.ref: {
|
|
43
|
+
return "ref"
|
|
44
|
+
}
|
|
45
|
+
case I.transform: {
|
|
46
|
+
return "transform"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
unreachable()
|
|
50
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { IntrinsicName } from "./intrinsics_util.js"
|
|
2
|
+
import { type PartialType, TypeKey } from "./Type.js"
|
|
3
|
+
|
|
4
|
+
export function isType<T>(
|
|
5
|
+
inQuestion: unknown,
|
|
6
|
+
...intrinsicNames: Array<IntrinsicName>
|
|
7
|
+
): inQuestion is PartialType<T> {
|
|
8
|
+
if (typeof inQuestion === "function" && TypeKey in inQuestion) {
|
|
9
|
+
if (intrinsicNames.length) {
|
|
10
|
+
for (const intrinsicName of intrinsicNames) {
|
|
11
|
+
if (IntrinsicName(inQuestion as never as PartialType) === intrinsicName) {
|
|
12
|
+
return true
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
} else {
|
|
16
|
+
return true
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return false
|
|
20
|
+
}
|
package/src/core/mod.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * as L from "./L.js"
|
|
2
|
+
|
|
3
|
+
// moderate --exclude annotations declareIntrinsic.ts inspect.ts L.ts utility
|
|
4
|
+
|
|
5
|
+
export * from "./assert.js"
|
|
6
|
+
export * from "./DescriptionContext.js"
|
|
7
|
+
export * from "./deserialize.js"
|
|
8
|
+
export * from "./display.js"
|
|
9
|
+
export * from "./intrinsics.js"
|
|
10
|
+
export * from "./intrinsics_util.js"
|
|
11
|
+
export * from "./isType.js"
|
|
12
|
+
export * from "./ReduceDependencies.js"
|
|
13
|
+
export * from "./signature.js"
|
|
14
|
+
export * from "./Type.js"
|
|
15
|
+
export * from "./TypeVisitor.js"
|