@blade-hq/agent-client 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -25
- package/dist/blade-client.d.ts +2 -14
- package/dist/index.d.ts +5 -2
- package/dist/index.js +212 -106
- package/dist/index.js.map +1 -1
- package/dist/resources/models.d.ts +15 -0
- package/dist/resources/sessions.d.ts +8 -1
- package/dist/session/agent-session.d.ts +10 -0
- package/dist/session/definition.d.ts +49 -0
- package/dist/shared/projection/helpers.d.ts +1 -1
- package/dist/types/rest.d.ts +378 -10
- package/dist/version.d.ts +4 -42
- package/node_modules/@ark/schema/LICENSE +7 -0
- package/node_modules/@ark/schema/README.md +18 -0
- package/node_modules/@ark/schema/out/config.d.ts +58 -0
- package/node_modules/@ark/schema/out/config.js +95 -0
- package/node_modules/@ark/schema/out/constraint.d.ts +67 -0
- package/node_modules/@ark/schema/out/constraint.js +136 -0
- package/node_modules/@ark/schema/out/generic.d.ts +73 -0
- package/node_modules/@ark/schema/out/generic.js +76 -0
- package/node_modules/@ark/schema/out/index.d.ts +47 -0
- package/node_modules/@ark/schema/out/index.js +47 -0
- package/node_modules/@ark/schema/out/intrinsic.d.ts +24 -0
- package/node_modules/@ark/schema/out/intrinsic.js +56 -0
- package/node_modules/@ark/schema/out/kinds.d.ts +73 -0
- package/node_modules/@ark/schema/out/kinds.js +71 -0
- package/node_modules/@ark/schema/out/module.d.ts +24 -0
- package/node_modules/@ark/schema/out/module.js +15 -0
- package/node_modules/@ark/schema/out/node.d.ts +154 -0
- package/node_modules/@ark/schema/out/node.js +438 -0
- package/node_modules/@ark/schema/out/parse.d.ts +52 -0
- package/node_modules/@ark/schema/out/parse.js +215 -0
- package/node_modules/@ark/schema/out/predicate.d.ts +52 -0
- package/node_modules/@ark/schema/out/predicate.js +63 -0
- package/node_modules/@ark/schema/out/refinements/after.d.ts +41 -0
- package/node_modules/@ark/schema/out/refinements/after.js +35 -0
- package/node_modules/@ark/schema/out/refinements/before.d.ts +41 -0
- package/node_modules/@ark/schema/out/refinements/before.js +41 -0
- package/node_modules/@ark/schema/out/refinements/divisor.d.ts +43 -0
- package/node_modules/@ark/schema/out/refinements/divisor.js +58 -0
- package/node_modules/@ark/schema/out/refinements/exactLength.d.ts +49 -0
- package/node_modules/@ark/schema/out/refinements/exactLength.js +55 -0
- package/node_modules/@ark/schema/out/refinements/kinds.d.ts +34 -0
- package/node_modules/@ark/schema/out/refinements/kinds.js +25 -0
- package/node_modules/@ark/schema/out/refinements/max.d.ts +37 -0
- package/node_modules/@ark/schema/out/refinements/max.js +45 -0
- package/node_modules/@ark/schema/out/refinements/maxLength.d.ts +40 -0
- package/node_modules/@ark/schema/out/refinements/maxLength.js +49 -0
- package/node_modules/@ark/schema/out/refinements/min.d.ts +37 -0
- package/node_modules/@ark/schema/out/refinements/min.js +39 -0
- package/node_modules/@ark/schema/out/refinements/minLength.d.ts +40 -0
- package/node_modules/@ark/schema/out/refinements/minLength.js +47 -0
- package/node_modules/@ark/schema/out/refinements/pattern.d.ts +43 -0
- package/node_modules/@ark/schema/out/refinements/pattern.js +52 -0
- package/node_modules/@ark/schema/out/refinements/range.d.ts +106 -0
- package/node_modules/@ark/schema/out/refinements/range.js +103 -0
- package/node_modules/@ark/schema/out/roots/alias.d.ts +45 -0
- package/node_modules/@ark/schema/out/roots/alias.js +115 -0
- package/node_modules/@ark/schema/out/roots/basis.d.ts +12 -0
- package/node_modules/@ark/schema/out/roots/basis.js +26 -0
- package/node_modules/@ark/schema/out/roots/domain.d.ts +45 -0
- package/node_modules/@ark/schema/out/roots/domain.js +72 -0
- package/node_modules/@ark/schema/out/roots/intersection.d.ts +98 -0
- package/node_modules/@ark/schema/out/roots/intersection.js +292 -0
- package/node_modules/@ark/schema/out/roots/morph.d.ts +62 -0
- package/node_modules/@ark/schema/out/roots/morph.js +159 -0
- package/node_modules/@ark/schema/out/roots/proto.d.ts +53 -0
- package/node_modules/@ark/schema/out/roots/proto.js +101 -0
- package/node_modules/@ark/schema/out/roots/root.d.ts +145 -0
- package/node_modules/@ark/schema/out/roots/root.js +455 -0
- package/node_modules/@ark/schema/out/roots/union.d.ts +99 -0
- package/node_modules/@ark/schema/out/roots/union.js +718 -0
- package/node_modules/@ark/schema/out/roots/unit.d.ts +41 -0
- package/node_modules/@ark/schema/out/roots/unit.js +86 -0
- package/node_modules/@ark/schema/out/roots/utils.d.ts +3 -0
- package/node_modules/@ark/schema/out/roots/utils.js +6 -0
- package/node_modules/@ark/schema/out/scope.d.ts +158 -0
- package/node_modules/@ark/schema/out/scope.js +481 -0
- package/node_modules/@ark/schema/out/shared/compile.d.ts +62 -0
- package/node_modules/@ark/schema/out/shared/compile.js +145 -0
- package/node_modules/@ark/schema/out/shared/declare.d.ts +80 -0
- package/node_modules/@ark/schema/out/shared/declare.js +1 -0
- package/node_modules/@ark/schema/out/shared/disjoint.d.ts +41 -0
- package/node_modules/@ark/schema/out/shared/disjoint.js +65 -0
- package/node_modules/@ark/schema/out/shared/errors.d.ts +145 -0
- package/node_modules/@ark/schema/out/shared/errors.js +252 -0
- package/node_modules/@ark/schema/out/shared/implement.d.ts +151 -0
- package/node_modules/@ark/schema/out/shared/implement.js +98 -0
- package/node_modules/@ark/schema/out/shared/intersections.d.ts +10 -0
- package/node_modules/@ark/schema/out/shared/intersections.js +132 -0
- package/node_modules/@ark/schema/out/shared/jsonSchema.d.ts +93 -0
- package/node_modules/@ark/schema/out/shared/jsonSchema.js +1 -0
- package/node_modules/@ark/schema/out/shared/registry.d.ts +7 -0
- package/node_modules/@ark/schema/out/shared/registry.js +10 -0
- package/node_modules/@ark/schema/out/shared/standardSchema.d.ts +122 -0
- package/node_modules/@ark/schema/out/shared/standardSchema.js +2 -0
- package/node_modules/@ark/schema/out/shared/toJsonSchema.d.ts +139 -0
- package/node_modules/@ark/schema/out/shared/toJsonSchema.js +40 -0
- package/node_modules/@ark/schema/out/shared/traversal.d.ts +117 -0
- package/node_modules/@ark/schema/out/shared/traversal.js +226 -0
- package/node_modules/@ark/schema/out/shared/utils.d.ts +34 -0
- package/node_modules/@ark/schema/out/shared/utils.js +8 -0
- package/node_modules/@ark/schema/out/structure/index.d.ts +46 -0
- package/node_modules/@ark/schema/out/structure/index.js +89 -0
- package/node_modules/@ark/schema/out/structure/optional.d.ts +49 -0
- package/node_modules/@ark/schema/out/structure/optional.js +127 -0
- package/node_modules/@ark/schema/out/structure/prop.d.ts +45 -0
- package/node_modules/@ark/schema/out/structure/prop.js +85 -0
- package/node_modules/@ark/schema/out/structure/required.d.ts +39 -0
- package/node_modules/@ark/schema/out/structure/required.js +38 -0
- package/node_modules/@ark/schema/out/structure/sequence.d.ts +110 -0
- package/node_modules/@ark/schema/out/structure/sequence.js +521 -0
- package/node_modules/@ark/schema/out/structure/shared.d.ts +4 -0
- package/node_modules/@ark/schema/out/structure/shared.js +4 -0
- package/node_modules/@ark/schema/out/structure/structure.d.ts +113 -0
- package/node_modules/@ark/schema/out/structure/structure.js +747 -0
- package/node_modules/@ark/schema/package.json +51 -0
- package/node_modules/@ark/util/LICENSE +7 -0
- package/node_modules/@ark/util/out/arrays.d.ts +166 -0
- package/node_modules/@ark/util/out/arrays.js +147 -0
- package/node_modules/@ark/util/out/clone.d.ts +4 -0
- package/node_modules/@ark/util/out/clone.js +33 -0
- package/node_modules/@ark/util/out/describe.d.ts +25 -0
- package/node_modules/@ark/util/out/describe.js +1 -0
- package/node_modules/@ark/util/out/domain.d.ts +48 -0
- package/node_modules/@ark/util/out/domain.js +25 -0
- package/node_modules/@ark/util/out/errors.d.ts +29 -0
- package/node_modules/@ark/util/out/errors.js +17 -0
- package/node_modules/@ark/util/out/flatMorph.d.ts +41 -0
- package/node_modules/@ark/util/out/flatMorph.js +24 -0
- package/node_modules/@ark/util/out/functions.d.ts +33 -0
- package/node_modules/@ark/util/out/functions.js +53 -0
- package/node_modules/@ark/util/out/generics.d.ts +59 -0
- package/node_modules/@ark/util/out/generics.js +5 -0
- package/node_modules/@ark/util/out/get.d.ts +9 -0
- package/node_modules/@ark/util/out/get.js +7 -0
- package/node_modules/@ark/util/out/hkt.d.ts +27 -0
- package/node_modules/@ark/util/out/hkt.js +5 -0
- package/node_modules/@ark/util/out/index.d.ts +24 -0
- package/node_modules/@ark/util/out/index.js +24 -0
- package/node_modules/@ark/util/out/intersections.d.ts +50 -0
- package/node_modules/@ark/util/out/intersections.js +1 -0
- package/node_modules/@ark/util/out/isomorphic.d.ts +5 -0
- package/node_modules/@ark/util/out/isomorphic.js +19 -0
- package/node_modules/@ark/util/out/keys.d.ts +18 -0
- package/node_modules/@ark/util/out/keys.js +1 -0
- package/node_modules/@ark/util/out/lazily.d.ts +1 -0
- package/node_modules/@ark/util/out/lazily.js +16 -0
- package/node_modules/@ark/util/out/numbers.d.ts +72 -0
- package/node_modules/@ark/util/out/numbers.js +138 -0
- package/node_modules/@ark/util/out/objectKinds.d.ts +205 -0
- package/node_modules/@ark/util/out/objectKinds.js +150 -0
- package/node_modules/@ark/util/out/path.d.ts +22 -0
- package/node_modules/@ark/util/out/path.js +65 -0
- package/node_modules/@ark/util/out/primitive.d.ts +16 -0
- package/node_modules/@ark/util/out/primitive.js +3 -0
- package/node_modules/@ark/util/out/records.d.ts +183 -0
- package/node_modules/@ark/util/out/records.js +63 -0
- package/node_modules/@ark/util/out/registry.d.ts +21 -0
- package/node_modules/@ark/util/out/registry.js +49 -0
- package/node_modules/@ark/util/out/scanner.d.ts +44 -0
- package/node_modules/@ark/util/out/scanner.js +87 -0
- package/node_modules/@ark/util/out/serialize.d.ts +34 -0
- package/node_modules/@ark/util/out/serialize.js +150 -0
- package/node_modules/@ark/util/out/strings.d.ts +33 -0
- package/node_modules/@ark/util/out/strings.js +59 -0
- package/node_modules/@ark/util/out/traits.d.ts +89 -0
- package/node_modules/@ark/util/out/traits.js +75 -0
- package/node_modules/@ark/util/out/unionToTuple.d.ts +14 -0
- package/node_modules/@ark/util/out/unionToTuple.js +1 -0
- package/node_modules/@ark/util/package.json +39 -0
- package/node_modules/@ark/util/tsconfig.base.json +18 -0
- package/node_modules/@socket.io/component-emitter/LICENSE +24 -0
- package/node_modules/@socket.io/component-emitter/Readme.md +79 -0
- package/node_modules/@socket.io/component-emitter/lib/cjs/index.d.ts +179 -0
- package/node_modules/@socket.io/component-emitter/lib/cjs/index.js +176 -0
- package/node_modules/@socket.io/component-emitter/lib/cjs/package.json +4 -0
- package/node_modules/@socket.io/component-emitter/lib/esm/index.d.ts +179 -0
- package/node_modules/@socket.io/component-emitter/lib/esm/index.js +169 -0
- package/node_modules/@socket.io/component-emitter/lib/esm/package.json +4 -0
- package/node_modules/@socket.io/component-emitter/package.json +28 -0
- package/node_modules/arkregex/LICENSE +7 -0
- package/node_modules/arkregex/README.md +61 -0
- package/node_modules/arkregex/out/charset.d.ts +15 -0
- package/node_modules/arkregex/out/charset.js +1 -0
- package/node_modules/arkregex/out/escape.d.ts +29 -0
- package/node_modules/arkregex/out/escape.js +10 -0
- package/node_modules/arkregex/out/execArray.d.ts +23 -0
- package/node_modules/arkregex/out/execArray.js +1 -0
- package/node_modules/arkregex/out/group.d.ts +33 -0
- package/node_modules/arkregex/out/group.js +6 -0
- package/node_modules/arkregex/out/index.d.ts +1 -0
- package/node_modules/arkregex/out/index.js +1 -0
- package/node_modules/arkregex/out/parse.d.ts +10 -0
- package/node_modules/arkregex/out/parse.js +1 -0
- package/node_modules/arkregex/out/quantify.d.ts +43 -0
- package/node_modules/arkregex/out/quantify.js +2 -0
- package/node_modules/arkregex/out/regex.d.ts +38 -0
- package/node_modules/arkregex/out/regex.js +2 -0
- package/node_modules/arkregex/out/state.d.ts +359 -0
- package/node_modules/arkregex/out/state.js +2 -0
- package/node_modules/arkregex/package.json +42 -0
- package/node_modules/arktype/LICENSE +7 -0
- package/node_modules/arktype/README.md +157 -0
- package/node_modules/arktype/out/attributes.d.ts +104 -0
- package/node_modules/arktype/out/attributes.js +3 -0
- package/node_modules/arktype/out/config.d.ts +35 -0
- package/node_modules/arktype/out/config.js +3 -0
- package/node_modules/arktype/out/declare.d.ts +35 -0
- package/node_modules/arktype/out/declare.js +1 -0
- package/node_modules/arktype/out/fn.d.ts +61 -0
- package/node_modules/arktype/out/fn.js +54 -0
- package/node_modules/arktype/out/generic.d.ts +118 -0
- package/node_modules/arktype/out/generic.js +37 -0
- package/node_modules/arktype/out/index.d.ts +12 -0
- package/node_modules/arktype/out/index.js +9 -0
- package/node_modules/arktype/out/keywords/Array.d.ts +20 -0
- package/node_modules/arktype/out/keywords/Array.js +21 -0
- package/node_modules/arktype/out/keywords/FormData.d.ts +15 -0
- package/node_modules/arktype/out/keywords/FormData.js +40 -0
- package/node_modules/arktype/out/keywords/TypedArray.d.ts +19 -0
- package/node_modules/arktype/out/keywords/TypedArray.js +16 -0
- package/node_modules/arktype/out/keywords/builtins.d.ts +18 -0
- package/node_modules/arktype/out/keywords/builtins.js +11 -0
- package/node_modules/arktype/out/keywords/constructors.d.ts +31 -0
- package/node_modules/arktype/out/keywords/constructors.js +16 -0
- package/node_modules/arktype/out/keywords/keywords.d.ts +70 -0
- package/node_modules/arktype/out/keywords/keywords.js +48 -0
- package/node_modules/arktype/out/keywords/number.d.ts +23 -0
- package/node_modules/arktype/out/keywords/number.js +49 -0
- package/node_modules/arktype/out/keywords/string.d.ts +334 -0
- package/node_modules/arktype/out/keywords/string.js +463 -0
- package/node_modules/arktype/out/keywords/ts.d.ts +108 -0
- package/node_modules/arktype/out/keywords/ts.js +82 -0
- package/node_modules/arktype/out/match.d.ts +152 -0
- package/node_modules/arktype/out/match.js +95 -0
- package/node_modules/arktype/out/module.d.ts +22 -0
- package/node_modules/arktype/out/module.js +3 -0
- package/node_modules/arktype/out/nary.d.ts +473 -0
- package/node_modules/arktype/out/nary.js +1 -0
- package/node_modules/arktype/out/parser/ast/bounds.d.ts +18 -0
- package/node_modules/arktype/out/parser/ast/bounds.js +1 -0
- package/node_modules/arktype/out/parser/ast/default.d.ts +8 -0
- package/node_modules/arktype/out/parser/ast/default.js +1 -0
- package/node_modules/arktype/out/parser/ast/divisor.d.ts +9 -0
- package/node_modules/arktype/out/parser/ast/divisor.js +1 -0
- package/node_modules/arktype/out/parser/ast/generic.d.ts +17 -0
- package/node_modules/arktype/out/parser/ast/generic.js +1 -0
- package/node_modules/arktype/out/parser/ast/infer.d.ts +25 -0
- package/node_modules/arktype/out/parser/ast/infer.js +1 -0
- package/node_modules/arktype/out/parser/ast/keyof.d.ts +7 -0
- package/node_modules/arktype/out/parser/ast/keyof.js +1 -0
- package/node_modules/arktype/out/parser/ast/utils.d.ts +8 -0
- package/node_modules/arktype/out/parser/ast/utils.js +1 -0
- package/node_modules/arktype/out/parser/ast/validate.d.ts +30 -0
- package/node_modules/arktype/out/parser/ast/validate.js +3 -0
- package/node_modules/arktype/out/parser/definition.d.ts +30 -0
- package/node_modules/arktype/out/parser/definition.js +74 -0
- package/node_modules/arktype/out/parser/objectLiteral.d.ts +70 -0
- package/node_modules/arktype/out/parser/objectLiteral.js +113 -0
- package/node_modules/arktype/out/parser/property.d.ts +34 -0
- package/node_modules/arktype/out/parser/property.js +16 -0
- package/node_modules/arktype/out/parser/reduce/dynamic.d.ts +42 -0
- package/node_modules/arktype/out/parser/reduce/dynamic.js +153 -0
- package/node_modules/arktype/out/parser/reduce/shared.d.ts +39 -0
- package/node_modules/arktype/out/parser/reduce/shared.js +25 -0
- package/node_modules/arktype/out/parser/reduce/static.d.ts +186 -0
- package/node_modules/arktype/out/parser/reduce/static.js +1 -0
- package/node_modules/arktype/out/parser/shift/operand/date.d.ts +11 -0
- package/node_modules/arktype/out/parser/shift/operand/date.js +23 -0
- package/node_modules/arktype/out/parser/shift/operand/enclosed.d.ts +57 -0
- package/node_modules/arktype/out/parser/shift/operand/enclosed.js +78 -0
- package/node_modules/arktype/out/parser/shift/operand/genericArgs.d.ts +27 -0
- package/node_modules/arktype/out/parser/shift/operand/genericArgs.js +16 -0
- package/node_modules/arktype/out/parser/shift/operand/operand.d.ts +8 -0
- package/node_modules/arktype/out/parser/shift/operand/operand.js +16 -0
- package/node_modules/arktype/out/parser/shift/operand/unenclosed.d.ts +43 -0
- package/node_modules/arktype/out/parser/shift/operand/unenclosed.js +59 -0
- package/node_modules/arktype/out/parser/shift/operator/bounds.d.ts +24 -0
- package/node_modules/arktype/out/parser/shift/operator/bounds.js +91 -0
- package/node_modules/arktype/out/parser/shift/operator/brand.d.ts +7 -0
- package/node_modules/arktype/out/parser/shift/operator/brand.js +6 -0
- package/node_modules/arktype/out/parser/shift/operator/default.d.ts +24 -0
- package/node_modules/arktype/out/parser/shift/operator/default.js +15 -0
- package/node_modules/arktype/out/parser/shift/operator/divisor.d.ts +8 -0
- package/node_modules/arktype/out/parser/shift/operator/divisor.js +13 -0
- package/node_modules/arktype/out/parser/shift/operator/operator.d.ts +14 -0
- package/node_modules/arktype/out/parser/shift/operator/operator.js +28 -0
- package/node_modules/arktype/out/parser/shift/tokens.d.ts +33 -0
- package/node_modules/arktype/out/parser/shift/tokens.js +37 -0
- package/node_modules/arktype/out/parser/string.d.ts +30 -0
- package/node_modules/arktype/out/parser/string.js +42 -0
- package/node_modules/arktype/out/parser/tupleExpressions.d.ts +79 -0
- package/node_modules/arktype/out/parser/tupleExpressions.js +75 -0
- package/node_modules/arktype/out/parser/tupleLiteral.d.ts +95 -0
- package/node_modules/arktype/out/parser/tupleLiteral.js +128 -0
- package/node_modules/arktype/out/scope.d.ts +158 -0
- package/node_modules/arktype/out/scope.js +106 -0
- package/node_modules/arktype/out/type.d.ts +144 -0
- package/node_modules/arktype/out/type.js +55 -0
- package/node_modules/arktype/out/variants/array.d.ts +12 -0
- package/node_modules/arktype/out/variants/array.js +1 -0
- package/node_modules/arktype/out/variants/base.d.ts +542 -0
- package/node_modules/arktype/out/variants/base.js +1 -0
- package/node_modules/arktype/out/variants/date.d.ts +10 -0
- package/node_modules/arktype/out/variants/date.js +1 -0
- package/node_modules/arktype/out/variants/instantiate.d.ts +12 -0
- package/node_modules/arktype/out/variants/instantiate.js +1 -0
- package/node_modules/arktype/out/variants/number.d.ts +11 -0
- package/node_modules/arktype/out/variants/number.js +1 -0
- package/node_modules/arktype/out/variants/object.d.ts +107 -0
- package/node_modules/arktype/out/variants/object.js +1 -0
- package/node_modules/arktype/out/variants/string.d.ts +15 -0
- package/node_modules/arktype/out/variants/string.js +1 -0
- package/node_modules/arktype/package.json +57 -0
- package/node_modules/debug/LICENSE +20 -0
- package/node_modules/debug/README.md +481 -0
- package/node_modules/debug/package.json +64 -0
- package/node_modules/debug/src/browser.js +272 -0
- package/node_modules/debug/src/common.js +292 -0
- package/node_modules/debug/src/index.js +10 -0
- package/node_modules/debug/src/node.js +263 -0
- package/node_modules/engine.io-client/LICENSE +22 -0
- package/node_modules/engine.io-client/README.md +331 -0
- package/node_modules/engine.io-client/build/cjs/browser-entrypoint.d.ts +3 -0
- package/node_modules/engine.io-client/build/cjs/browser-entrypoint.js +4 -0
- package/node_modules/engine.io-client/build/cjs/contrib/has-cors.d.ts +1 -0
- package/node_modules/engine.io-client/build/cjs/contrib/has-cors.js +14 -0
- package/node_modules/engine.io-client/build/cjs/contrib/parseqs.d.ts +15 -0
- package/node_modules/engine.io-client/build/cjs/contrib/parseqs.js +38 -0
- package/node_modules/engine.io-client/build/cjs/contrib/parseuri.d.ts +1 -0
- package/node_modules/engine.io-client/build/cjs/contrib/parseuri.js +67 -0
- package/node_modules/engine.io-client/build/cjs/globals.d.ts +4 -0
- package/node_modules/engine.io-client/build/cjs/globals.js +26 -0
- package/node_modules/engine.io-client/build/cjs/globals.node.d.ts +21 -0
- package/node_modules/engine.io-client/build/cjs/globals.node.js +97 -0
- package/node_modules/engine.io-client/build/cjs/index.d.ts +15 -0
- package/node_modules/engine.io-client/build/cjs/index.js +32 -0
- package/node_modules/engine.io-client/build/cjs/package.json +10 -0
- package/node_modules/engine.io-client/build/cjs/socket.d.ts +482 -0
- package/node_modules/engine.io-client/build/cjs/socket.js +765 -0
- package/node_modules/engine.io-client/build/cjs/transport.d.ts +106 -0
- package/node_modules/engine.io-client/build/cjs/transport.js +153 -0
- package/node_modules/engine.io-client/build/cjs/transports/index.d.ts +8 -0
- package/node_modules/engine.io-client/build/cjs/transports/index.js +11 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling-fetch.d.ts +15 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling-fetch.js +60 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.d.ts +108 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.js +285 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.node.d.ts +11 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.node.js +44 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling.d.ts +52 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling.js +165 -0
- package/node_modules/engine.io-client/build/cjs/transports/websocket.d.ts +36 -0
- package/node_modules/engine.io-client/build/cjs/transports/websocket.js +136 -0
- package/node_modules/engine.io-client/build/cjs/transports/websocket.node.d.ts +14 -0
- package/node_modules/engine.io-client/build/cjs/transports/websocket.node.js +68 -0
- package/node_modules/engine.io-client/build/cjs/transports/webtransport.d.ts +18 -0
- package/node_modules/engine.io-client/build/cjs/transports/webtransport.js +94 -0
- package/node_modules/engine.io-client/build/cjs/util.d.ts +7 -0
- package/node_modules/engine.io-client/build/cjs/util.js +65 -0
- package/node_modules/engine.io-client/build/esm/browser-entrypoint.d.ts +3 -0
- package/node_modules/engine.io-client/build/esm/browser-entrypoint.js +2 -0
- package/node_modules/engine.io-client/build/esm/contrib/has-cors.d.ts +1 -0
- package/node_modules/engine.io-client/build/esm/contrib/has-cors.js +11 -0
- package/node_modules/engine.io-client/build/esm/contrib/parseqs.d.ts +15 -0
- package/node_modules/engine.io-client/build/esm/contrib/parseqs.js +34 -0
- package/node_modules/engine.io-client/build/esm/contrib/parseuri.d.ts +1 -0
- package/node_modules/engine.io-client/build/esm/contrib/parseuri.js +64 -0
- package/node_modules/engine.io-client/build/esm/globals.d.ts +4 -0
- package/node_modules/engine.io-client/build/esm/globals.js +22 -0
- package/node_modules/engine.io-client/build/esm/globals.node.d.ts +21 -0
- package/node_modules/engine.io-client/build/esm/globals.node.js +91 -0
- package/node_modules/engine.io-client/build/esm/index.d.ts +15 -0
- package/node_modules/engine.io-client/build/esm/index.js +15 -0
- package/node_modules/engine.io-client/build/esm/package.json +10 -0
- package/node_modules/engine.io-client/build/esm/socket.d.ts +482 -0
- package/node_modules/engine.io-client/build/esm/socket.js +727 -0
- package/node_modules/engine.io-client/build/esm/transport.d.ts +106 -0
- package/node_modules/engine.io-client/build/esm/transport.js +142 -0
- package/node_modules/engine.io-client/build/esm/transports/index.d.ts +8 -0
- package/node_modules/engine.io-client/build/esm/transports/index.js +8 -0
- package/node_modules/engine.io-client/build/esm/transports/polling-fetch.d.ts +15 -0
- package/node_modules/engine.io-client/build/esm/transports/polling-fetch.js +56 -0
- package/node_modules/engine.io-client/build/esm/transports/polling-xhr.d.ts +108 -0
- package/node_modules/engine.io-client/build/esm/transports/polling-xhr.js +271 -0
- package/node_modules/engine.io-client/build/esm/transports/polling-xhr.node.d.ts +11 -0
- package/node_modules/engine.io-client/build/esm/transports/polling-xhr.node.js +17 -0
- package/node_modules/engine.io-client/build/esm/transports/polling.d.ts +52 -0
- package/node_modules/engine.io-client/build/esm/transports/polling.js +145 -0
- package/node_modules/engine.io-client/build/esm/transports/websocket.d.ts +36 -0
- package/node_modules/engine.io-client/build/esm/transports/websocket.js +125 -0
- package/node_modules/engine.io-client/build/esm/transports/websocket.node.d.ts +14 -0
- package/node_modules/engine.io-client/build/esm/transports/websocket.node.js +41 -0
- package/node_modules/engine.io-client/build/esm/transports/webtransport.d.ts +18 -0
- package/node_modules/engine.io-client/build/esm/transports/webtransport.js +80 -0
- package/node_modules/engine.io-client/build/esm/util.d.ts +7 -0
- package/node_modules/engine.io-client/build/esm/util.js +59 -0
- package/node_modules/engine.io-client/build/esm-debug/browser-entrypoint.d.ts +3 -0
- package/node_modules/engine.io-client/build/esm-debug/browser-entrypoint.js +2 -0
- package/node_modules/engine.io-client/build/esm-debug/contrib/has-cors.d.ts +1 -0
- package/node_modules/engine.io-client/build/esm-debug/contrib/has-cors.js +11 -0
- package/node_modules/engine.io-client/build/esm-debug/contrib/parseqs.d.ts +15 -0
- package/node_modules/engine.io-client/build/esm-debug/contrib/parseqs.js +34 -0
- package/node_modules/engine.io-client/build/esm-debug/contrib/parseuri.d.ts +1 -0
- package/node_modules/engine.io-client/build/esm-debug/contrib/parseuri.js +64 -0
- package/node_modules/engine.io-client/build/esm-debug/globals.d.ts +4 -0
- package/node_modules/engine.io-client/build/esm-debug/globals.js +22 -0
- package/node_modules/engine.io-client/build/esm-debug/globals.node.d.ts +21 -0
- package/node_modules/engine.io-client/build/esm-debug/globals.node.js +91 -0
- package/node_modules/engine.io-client/build/esm-debug/index.d.ts +15 -0
- package/node_modules/engine.io-client/build/esm-debug/index.js +15 -0
- package/node_modules/engine.io-client/build/esm-debug/package.json +10 -0
- package/node_modules/engine.io-client/build/esm-debug/socket.d.ts +482 -0
- package/node_modules/engine.io-client/build/esm-debug/socket.js +756 -0
- package/node_modules/engine.io-client/build/esm-debug/transport.d.ts +106 -0
- package/node_modules/engine.io-client/build/esm-debug/transport.js +145 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/index.d.ts +8 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/index.js +8 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-fetch.d.ts +15 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-fetch.js +56 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.d.ts +108 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.js +276 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.node.d.ts +11 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.node.js +17 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling.d.ts +52 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling.js +158 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/websocket.d.ts +36 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/websocket.js +128 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/websocket.node.d.ts +14 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/websocket.node.js +41 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/webtransport.d.ts +18 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/webtransport.js +87 -0
- package/node_modules/engine.io-client/build/esm-debug/util.d.ts +7 -0
- package/node_modules/engine.io-client/build/esm-debug/util.js +59 -0
- package/node_modules/engine.io-client/dist/engine.io.esm.min.js +7 -0
- package/node_modules/engine.io-client/dist/engine.io.esm.min.js.map +1 -0
- package/node_modules/engine.io-client/dist/engine.io.js +3064 -0
- package/node_modules/engine.io-client/dist/engine.io.js.map +1 -0
- package/node_modules/engine.io-client/dist/engine.io.min.js +7 -0
- package/node_modules/engine.io-client/dist/engine.io.min.js.map +1 -0
- package/node_modules/engine.io-client/package.json +95 -0
- package/node_modules/engine.io-parser/LICENSE +22 -0
- package/node_modules/engine.io-parser/Readme.md +158 -0
- package/node_modules/engine.io-parser/build/cjs/commons.d.ts +14 -0
- package/node_modules/engine.io-parser/build/cjs/commons.js +19 -0
- package/node_modules/engine.io-parser/build/cjs/contrib/base64-arraybuffer.d.ts +2 -0
- package/node_modules/engine.io-parser/build/cjs/contrib/base64-arraybuffer.js +48 -0
- package/node_modules/engine.io-parser/build/cjs/decodePacket.browser.d.ts +2 -0
- package/node_modules/engine.io-parser/build/cjs/decodePacket.browser.js +66 -0
- package/node_modules/engine.io-parser/build/cjs/decodePacket.d.ts +2 -0
- package/node_modules/engine.io-parser/build/cjs/decodePacket.js +59 -0
- package/node_modules/engine.io-parser/build/cjs/encodePacket.browser.d.ts +4 -0
- package/node_modules/engine.io-parser/build/cjs/encodePacket.browser.js +72 -0
- package/node_modules/engine.io-parser/build/cjs/encodePacket.d.ts +3 -0
- package/node_modules/engine.io-parser/build/cjs/encodePacket.js +38 -0
- package/node_modules/engine.io-parser/build/cjs/index.d.ts +9 -0
- package/node_modules/engine.io-parser/build/cjs/index.js +164 -0
- package/node_modules/engine.io-parser/build/cjs/package.json +8 -0
- package/node_modules/engine.io-parser/build/esm/commons.d.ts +14 -0
- package/node_modules/engine.io-parser/build/esm/commons.js +14 -0
- package/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.d.ts +2 -0
- package/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.js +43 -0
- package/node_modules/engine.io-parser/build/esm/decodePacket.browser.d.ts +2 -0
- package/node_modules/engine.io-parser/build/esm/decodePacket.browser.js +62 -0
- package/node_modules/engine.io-parser/build/esm/decodePacket.d.ts +2 -0
- package/node_modules/engine.io-parser/build/esm/decodePacket.js +55 -0
- package/node_modules/engine.io-parser/build/esm/encodePacket.browser.d.ts +4 -0
- package/node_modules/engine.io-parser/build/esm/encodePacket.browser.js +68 -0
- package/node_modules/engine.io-parser/build/esm/encodePacket.d.ts +3 -0
- package/node_modules/engine.io-parser/build/esm/encodePacket.js +33 -0
- package/node_modules/engine.io-parser/build/esm/index.d.ts +9 -0
- package/node_modules/engine.io-parser/build/esm/index.js +156 -0
- package/node_modules/engine.io-parser/build/esm/package.json +8 -0
- package/node_modules/engine.io-parser/package.json +46 -0
- package/node_modules/ms/index.js +162 -0
- package/node_modules/ms/license.md +21 -0
- package/node_modules/ms/package.json +38 -0
- package/node_modules/ms/readme.md +59 -0
- package/node_modules/socket.io-client/LICENSE +21 -0
- package/node_modules/socket.io-client/README.md +29 -0
- package/node_modules/socket.io-client/build/cjs/browser-entrypoint.d.ts +2 -0
- package/node_modules/socket.io-client/build/cjs/browser-entrypoint.js +4 -0
- package/node_modules/socket.io-client/build/cjs/contrib/backo2.d.ts +12 -0
- package/node_modules/socket.io-client/build/cjs/contrib/backo2.js +69 -0
- package/node_modules/socket.io-client/build/cjs/index.d.ts +29 -0
- package/node_modules/socket.io-client/build/cjs/index.js +76 -0
- package/node_modules/socket.io-client/build/cjs/manager.d.ts +295 -0
- package/node_modules/socket.io-client/build/cjs/manager.js +416 -0
- package/node_modules/socket.io-client/build/cjs/on.d.ts +2 -0
- package/node_modules/socket.io-client/build/cjs/on.js +9 -0
- package/node_modules/socket.io-client/build/cjs/socket.d.ts +593 -0
- package/node_modules/socket.io-client/build/cjs/socket.js +909 -0
- package/node_modules/socket.io-client/build/cjs/url.d.ts +33 -0
- package/node_modules/socket.io-client/build/cjs/url.js +69 -0
- package/node_modules/socket.io-client/build/esm/browser-entrypoint.d.ts +2 -0
- package/node_modules/socket.io-client/build/esm/browser-entrypoint.js +2 -0
- package/node_modules/socket.io-client/build/esm/contrib/backo2.d.ts +12 -0
- package/node_modules/socket.io-client/build/esm/contrib/backo2.js +66 -0
- package/node_modules/socket.io-client/build/esm/index.d.ts +29 -0
- package/node_modules/socket.io-client/build/esm/index.js +58 -0
- package/node_modules/socket.io-client/build/esm/manager.d.ts +295 -0
- package/node_modules/socket.io-client/build/esm/manager.js +367 -0
- package/node_modules/socket.io-client/build/esm/on.d.ts +2 -0
- package/node_modules/socket.io-client/build/esm/on.js +6 -0
- package/node_modules/socket.io-client/build/esm/package.json +5 -0
- package/node_modules/socket.io-client/build/esm/socket.d.ts +593 -0
- package/node_modules/socket.io-client/build/esm/socket.js +880 -0
- package/node_modules/socket.io-client/build/esm/url.d.ts +33 -0
- package/node_modules/socket.io-client/build/esm/url.js +59 -0
- package/node_modules/socket.io-client/build/esm-debug/browser-entrypoint.d.ts +2 -0
- package/node_modules/socket.io-client/build/esm-debug/browser-entrypoint.js +2 -0
- package/node_modules/socket.io-client/build/esm-debug/contrib/backo2.d.ts +12 -0
- package/node_modules/socket.io-client/build/esm-debug/contrib/backo2.js +66 -0
- package/node_modules/socket.io-client/build/esm-debug/index.d.ts +29 -0
- package/node_modules/socket.io-client/build/esm-debug/index.js +62 -0
- package/node_modules/socket.io-client/build/esm-debug/manager.d.ts +295 -0
- package/node_modules/socket.io-client/build/esm-debug/manager.js +386 -0
- package/node_modules/socket.io-client/build/esm-debug/on.d.ts +2 -0
- package/node_modules/socket.io-client/build/esm-debug/on.js +6 -0
- package/node_modules/socket.io-client/build/esm-debug/package.json +5 -0
- package/node_modules/socket.io-client/build/esm-debug/socket.d.ts +593 -0
- package/node_modules/socket.io-client/build/esm-debug/socket.js +902 -0
- package/node_modules/socket.io-client/build/esm-debug/url.d.ts +33 -0
- package/node_modules/socket.io-client/build/esm-debug/url.js +63 -0
- package/node_modules/socket.io-client/dist/socket.io.esm.min.js +7 -0
- package/node_modules/socket.io-client/dist/socket.io.esm.min.js.map +1 -0
- package/node_modules/socket.io-client/dist/socket.io.js +4955 -0
- package/node_modules/socket.io-client/dist/socket.io.js.map +1 -0
- package/node_modules/socket.io-client/dist/socket.io.min.js +7 -0
- package/node_modules/socket.io-client/dist/socket.io.min.js.map +1 -0
- package/node_modules/socket.io-client/dist/socket.io.msgpack.min.js +7 -0
- package/node_modules/socket.io-client/dist/socket.io.msgpack.min.js.map +1 -0
- package/node_modules/socket.io-client/package.json +101 -0
- package/node_modules/socket.io-parser/LICENSE +20 -0
- package/node_modules/socket.io-parser/Readme.md +81 -0
- package/node_modules/socket.io-parser/build/cjs/binary.d.ts +20 -0
- package/node_modules/socket.io-parser/build/cjs/binary.js +87 -0
- package/node_modules/socket.io-parser/build/cjs/index.d.ts +91 -0
- package/node_modules/socket.io-parser/build/cjs/index.js +359 -0
- package/node_modules/socket.io-parser/build/cjs/is-binary.d.ts +7 -0
- package/node_modules/socket.io-parser/build/cjs/is-binary.js +54 -0
- package/node_modules/socket.io-parser/build/cjs/package.json +3 -0
- package/node_modules/socket.io-parser/build/esm/binary.d.ts +20 -0
- package/node_modules/socket.io-parser/build/esm/binary.js +83 -0
- package/node_modules/socket.io-parser/build/esm/index.d.ts +91 -0
- package/node_modules/socket.io-parser/build/esm/index.js +348 -0
- package/node_modules/socket.io-parser/build/esm/is-binary.d.ts +7 -0
- package/node_modules/socket.io-parser/build/esm/is-binary.js +50 -0
- package/node_modules/socket.io-parser/build/esm/package.json +3 -0
- package/node_modules/socket.io-parser/build/esm-debug/binary.d.ts +20 -0
- package/node_modules/socket.io-parser/build/esm-debug/binary.js +83 -0
- package/node_modules/socket.io-parser/build/esm-debug/index.d.ts +91 -0
- package/node_modules/socket.io-parser/build/esm-debug/index.js +353 -0
- package/node_modules/socket.io-parser/build/esm-debug/is-binary.d.ts +7 -0
- package/node_modules/socket.io-parser/build/esm-debug/is-binary.js +50 -0
- package/node_modules/socket.io-parser/build/esm-debug/package.json +3 -0
- package/node_modules/socket.io-parser/package.json +44 -0
- package/node_modules/ws/LICENSE +20 -0
- package/node_modules/ws/README.md +548 -0
- package/node_modules/ws/browser.js +8 -0
- package/node_modules/ws/index.js +13 -0
- package/node_modules/ws/lib/buffer-util.js +131 -0
- package/node_modules/ws/lib/constants.js +18 -0
- package/node_modules/ws/lib/event-target.js +292 -0
- package/node_modules/ws/lib/extension.js +203 -0
- package/node_modules/ws/lib/limiter.js +55 -0
- package/node_modules/ws/lib/permessage-deflate.js +528 -0
- package/node_modules/ws/lib/receiver.js +706 -0
- package/node_modules/ws/lib/sender.js +602 -0
- package/node_modules/ws/lib/stream.js +161 -0
- package/node_modules/ws/lib/subprotocol.js +62 -0
- package/node_modules/ws/lib/validation.js +152 -0
- package/node_modules/ws/lib/websocket-server.js +550 -0
- package/node_modules/ws/lib/websocket.js +1388 -0
- package/node_modules/ws/package.json +69 -0
- package/node_modules/ws/wrapper.mjs +8 -0
- package/node_modules/xmlhttprequest-ssl/LICENSE +22 -0
- package/node_modules/xmlhttprequest-ssl/README.md +67 -0
- package/node_modules/xmlhttprequest-ssl/lib/XMLHttpRequest.js +689 -0
- package/node_modules/xmlhttprequest-ssl/package.json +40 -0
- package/package.json +34 -4
- package/public-api.md +85 -23
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { postfixAfterOptionalOrDefaultableMessage, type BaseParseContext, type BaseRoot, type Sequence } from "@ark/schema";
|
|
2
|
+
import { type array, type conform, type ErrorMessage, type satisfy } from "@ark/util";
|
|
3
|
+
import type { inferDefinition, validateInnerDefinition } from "./definition.ts";
|
|
4
|
+
import { type DefaultablePropertyTuple, type isDefaultable, type OptionalPropertyDefinition } from "./property.ts";
|
|
5
|
+
export declare const parseTupleLiteral: (def: array, ctx: BaseParseContext) => BaseRoot;
|
|
6
|
+
export type validateTupleLiteral<def extends array, $, args> = parseSequence<def, $, args> extends infer s extends SequenceParseState ? Readonly<s["validated"]> : never;
|
|
7
|
+
export type inferTupleLiteral<def extends array, $, args> = parseSequence<def, $, args> extends infer s extends SequenceParseState ? s["inferred"] : never;
|
|
8
|
+
type SequencePhase = satisfy<keyof Sequence.Inner, SequencePhase.prefix | SequencePhase.optionals | SequencePhase.defaultables | SequencePhase.postfix>;
|
|
9
|
+
declare namespace SequencePhase {
|
|
10
|
+
type prefix = "prefix";
|
|
11
|
+
type optionals = "optionals";
|
|
12
|
+
type defaultables = "defaultables";
|
|
13
|
+
type postfix = "postfix";
|
|
14
|
+
}
|
|
15
|
+
type SequenceParseState = {
|
|
16
|
+
unscanned: array;
|
|
17
|
+
inferred: array;
|
|
18
|
+
validated: array;
|
|
19
|
+
phase: SequencePhase;
|
|
20
|
+
};
|
|
21
|
+
type parseSequence<def extends array, $, args> = parseNextElement<{
|
|
22
|
+
unscanned: def;
|
|
23
|
+
inferred: [];
|
|
24
|
+
validated: [];
|
|
25
|
+
phase: SequencePhase.prefix;
|
|
26
|
+
}, $, args>;
|
|
27
|
+
type PreparsedElementKind = "required" | SequencePhase.optionals | SequencePhase.defaultables;
|
|
28
|
+
type PreparsedElement = {
|
|
29
|
+
head: unknown;
|
|
30
|
+
tail: array;
|
|
31
|
+
inferred: unknown;
|
|
32
|
+
validated: unknown;
|
|
33
|
+
kind: PreparsedElementKind;
|
|
34
|
+
spread: boolean;
|
|
35
|
+
};
|
|
36
|
+
declare namespace PreparsedElement {
|
|
37
|
+
type from<result extends PreparsedElement> = result;
|
|
38
|
+
type required = "required";
|
|
39
|
+
type optionals = "optionals";
|
|
40
|
+
type defaultables = "defaultables";
|
|
41
|
+
}
|
|
42
|
+
type preparseNextState<s extends SequenceParseState, $, args> = s["unscanned"] extends readonly ["...", infer head, ...infer tail] ? preparseNextElement<head, tail, true, $, args> : s["unscanned"] extends readonly [infer head, ...infer tail] ? preparseNextElement<head, tail, false, $, args> : null;
|
|
43
|
+
type preparseNextElement<head, tail extends array, spread extends boolean, $, args> = PreparsedElement.from<{
|
|
44
|
+
head: head;
|
|
45
|
+
tail: tail;
|
|
46
|
+
inferred: inferDefinition<head, $, args>;
|
|
47
|
+
validated: validateInnerDefinition<head, $, args>;
|
|
48
|
+
kind: head extends OptionalPropertyDefinition ? PreparsedElement.optionals : head extends DefaultablePropertyTuple ? PreparsedElement.defaultables : isDefaultable<head, $, args> extends true ? PreparsedElement.defaultables : PreparsedElement.required;
|
|
49
|
+
spread: spread;
|
|
50
|
+
}>;
|
|
51
|
+
type parseNextElement<s extends SequenceParseState, $, args> = preparseNextState<s, $, args> extends infer next extends PreparsedElement ? parseNextElement<{
|
|
52
|
+
unscanned: next["tail"];
|
|
53
|
+
inferred: nextInferred<s, next>;
|
|
54
|
+
validated: nextValidated<s, next>;
|
|
55
|
+
phase: next["kind"] extends (SequencePhase.optionals | SequencePhase.defaultables) ? next["kind"] : number extends nextInferred<s, next>["length"] ? s["phase"] : SequencePhase.prefix;
|
|
56
|
+
}, $, args> : s;
|
|
57
|
+
type nextInferred<s extends SequenceParseState, next extends PreparsedElement> = next["spread"] extends true ? [
|
|
58
|
+
...s["inferred"],
|
|
59
|
+
...conform<next["inferred"], array>
|
|
60
|
+
] : next["kind"] extends SequencePhase.optionals ? [
|
|
61
|
+
...s["inferred"],
|
|
62
|
+
next["inferred"]?
|
|
63
|
+
] : [...s["inferred"], next["inferred"]];
|
|
64
|
+
type nextValidated<s extends SequenceParseState, next extends PreparsedElement> = [
|
|
65
|
+
...s["validated"],
|
|
66
|
+
...nextValidatedSpreadOperatorIfPresent<s, next>,
|
|
67
|
+
nextValidatedElement<s, next>
|
|
68
|
+
];
|
|
69
|
+
type nextValidatedSpreadOperatorIfPresent<s extends SequenceParseState, next extends PreparsedElement> = next["spread"] extends true ? [
|
|
70
|
+
next["inferred"] extends infer spreadOperand extends array ? [
|
|
71
|
+
number,
|
|
72
|
+
number
|
|
73
|
+
] extends ([
|
|
74
|
+
s["inferred"]["length"],
|
|
75
|
+
spreadOperand["length"]
|
|
76
|
+
]) ? ErrorMessage<multipleVariadicMessage> : "..." : ErrorMessage<writeNonArraySpreadMessage<next["head"]>>
|
|
77
|
+
] : [];
|
|
78
|
+
type nextValidatedElement<s extends SequenceParseState, next extends PreparsedElement> = next["kind"] extends SequencePhase.optionals ? next["spread"] extends true ? ErrorMessage<spreadOptionalMessage> : s["phase"] extends SequencePhase.postfix ? ErrorMessage<optionalOrDefaultableAfterVariadicMessage> : next["validated"] : next["kind"] extends SequencePhase.defaultables ? next["spread"] extends true ? ErrorMessage<spreadDefaultableMessage> : s["phase"] extends SequencePhase.optionals ? ErrorMessage<defaultablePostOptionalMessage> : s["phase"] extends SequencePhase.postfix ? ErrorMessage<optionalOrDefaultableAfterVariadicMessage> : next["validated"] : [s["phase"], next["spread"]] extends ([
|
|
79
|
+
SequencePhase.optionals | SequencePhase.defaultables,
|
|
80
|
+
false
|
|
81
|
+
]) ? ErrorMessage<postfixAfterOptionalOrDefaultableMessage> : next["validated"];
|
|
82
|
+
export declare const writeNonArraySpreadMessage: <operand extends string>(operand: operand) => writeNonArraySpreadMessage<operand>;
|
|
83
|
+
type writeNonArraySpreadMessage<operand> = `Spread element must be an array${operand extends string ? ` (was ${operand})` : ""}`;
|
|
84
|
+
export declare const multipleVariadicMesage = "A tuple may have at most one variadic element";
|
|
85
|
+
type multipleVariadicMessage = typeof multipleVariadicMesage;
|
|
86
|
+
export declare const requiredPostOptionalMessage = "A required element may not follow an optional element";
|
|
87
|
+
export declare const optionalOrDefaultableAfterVariadicMessage = "An optional element may not follow a variadic element";
|
|
88
|
+
type optionalOrDefaultableAfterVariadicMessage = typeof optionalOrDefaultableAfterVariadicMessage;
|
|
89
|
+
export declare const spreadOptionalMessage = "A spread element cannot be optional";
|
|
90
|
+
type spreadOptionalMessage = typeof spreadOptionalMessage;
|
|
91
|
+
export declare const spreadDefaultableMessage = "A spread element cannot have a default";
|
|
92
|
+
type spreadDefaultableMessage = typeof spreadDefaultableMessage;
|
|
93
|
+
export declare const defaultablePostOptionalMessage = "A defaultable element may not follow an optional element without a default";
|
|
94
|
+
type defaultablePostOptionalMessage = typeof defaultablePostOptionalMessage;
|
|
95
|
+
export {};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { $ark, makeRootAndArrayPropertiesMutable, postfixAfterOptionalOrDefaultableMessage } from "@ark/schema";
|
|
2
|
+
import { append, isArray, isEmptyObject, throwParseError } from "@ark/util";
|
|
3
|
+
import { parseProperty } from "./property.js";
|
|
4
|
+
export const parseTupleLiteral = (def, ctx) => {
|
|
5
|
+
let sequences = [{}];
|
|
6
|
+
let i = 0;
|
|
7
|
+
while (i < def.length) {
|
|
8
|
+
let spread = false;
|
|
9
|
+
if (def[i] === "..." && i < def.length - 1) {
|
|
10
|
+
spread = true;
|
|
11
|
+
i++;
|
|
12
|
+
}
|
|
13
|
+
const parsedProperty = parseProperty(def[i], ctx);
|
|
14
|
+
const [valueNode, operator, possibleDefaultValue] = !isArray(parsedProperty) ? [parsedProperty] : parsedProperty;
|
|
15
|
+
i++;
|
|
16
|
+
if (spread) {
|
|
17
|
+
if (!valueNode.extends($ark.intrinsic.Array))
|
|
18
|
+
return throwParseError(writeNonArraySpreadMessage(valueNode.expression));
|
|
19
|
+
// a spread must be distributed over branches e.g.:
|
|
20
|
+
// def: [string, ...(number[] | [true, false])]
|
|
21
|
+
// nodes: [string, ...number[]] | [string, true, false]
|
|
22
|
+
sequences = sequences.flatMap(base =>
|
|
23
|
+
// since appendElement mutates base, we have to shallow-ish clone it for each branch
|
|
24
|
+
valueNode.distribute(branch => appendSpreadBranch(makeRootAndArrayPropertiesMutable(base), branch)));
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
sequences = sequences.map(base => {
|
|
28
|
+
if (operator === "?")
|
|
29
|
+
return appendOptionalElement(base, valueNode);
|
|
30
|
+
if (operator === "=")
|
|
31
|
+
return appendDefaultableElement(base, valueNode, possibleDefaultValue);
|
|
32
|
+
return appendRequiredElement(base, valueNode);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return ctx.$.parseSchema(sequences.map(sequence => isEmptyObject(sequence) ?
|
|
37
|
+
{
|
|
38
|
+
proto: Array,
|
|
39
|
+
exactLength: 0
|
|
40
|
+
}
|
|
41
|
+
: {
|
|
42
|
+
proto: Array,
|
|
43
|
+
sequence
|
|
44
|
+
}));
|
|
45
|
+
};
|
|
46
|
+
const appendRequiredElement = (base, element) => {
|
|
47
|
+
if (base.defaultables || base.optionals) {
|
|
48
|
+
return throwParseError(base.variadic ?
|
|
49
|
+
// e.g. [boolean = true, ...string[], number]
|
|
50
|
+
postfixAfterOptionalOrDefaultableMessage
|
|
51
|
+
// e.g. [string?, number]
|
|
52
|
+
: requiredPostOptionalMessage);
|
|
53
|
+
}
|
|
54
|
+
if (base.variadic) {
|
|
55
|
+
// e.g. [...string[], number]
|
|
56
|
+
base.postfix = append(base.postfix, element);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
// e.g. [string, number]
|
|
60
|
+
base.prefix = append(base.prefix, element);
|
|
61
|
+
}
|
|
62
|
+
return base;
|
|
63
|
+
};
|
|
64
|
+
const appendOptionalElement = (base, element) => {
|
|
65
|
+
if (base.variadic)
|
|
66
|
+
// e.g. [...string[], number?]
|
|
67
|
+
return throwParseError(optionalOrDefaultableAfterVariadicMessage);
|
|
68
|
+
// e.g. [string, number?]
|
|
69
|
+
base.optionals = append(base.optionals, element);
|
|
70
|
+
return base;
|
|
71
|
+
};
|
|
72
|
+
const appendDefaultableElement = (base, element, value) => {
|
|
73
|
+
if (base.variadic)
|
|
74
|
+
// e.g. [...string[], number = 0]
|
|
75
|
+
return throwParseError(optionalOrDefaultableAfterVariadicMessage);
|
|
76
|
+
if (base.optionals)
|
|
77
|
+
// e.g. [string?, number = 0]
|
|
78
|
+
return throwParseError(defaultablePostOptionalMessage);
|
|
79
|
+
// value's assignability to element will be checked when the
|
|
80
|
+
// sequence is instantiated by @ark/schema
|
|
81
|
+
// e.g. [string, number = 0]
|
|
82
|
+
base.defaultables = append(base.defaultables, [[element, value]]);
|
|
83
|
+
return base;
|
|
84
|
+
};
|
|
85
|
+
const appendVariadicElement = (base, element) => {
|
|
86
|
+
// e.g. [...string[], number, ...string[]]
|
|
87
|
+
if (base.postfix)
|
|
88
|
+
throwParseError(multipleVariadicMesage);
|
|
89
|
+
if (base.variadic) {
|
|
90
|
+
if (!base.variadic.equals(element)) {
|
|
91
|
+
// e.g. [...string[], ...number[]]
|
|
92
|
+
throwParseError(multipleVariadicMesage);
|
|
93
|
+
}
|
|
94
|
+
// e.g. [...string[], ...string[]]
|
|
95
|
+
// do nothing, second spread doesn't change the type
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
// e.g. [string, ...number[]]
|
|
99
|
+
base.variadic = element.internal;
|
|
100
|
+
}
|
|
101
|
+
return base;
|
|
102
|
+
};
|
|
103
|
+
const appendSpreadBranch = (base, branch) => {
|
|
104
|
+
const spread = branch.select({ method: "find", kind: "sequence" });
|
|
105
|
+
if (!spread) {
|
|
106
|
+
// the only array with no sequence reference is unknown[]
|
|
107
|
+
return appendVariadicElement(base, $ark.intrinsic.unknown);
|
|
108
|
+
}
|
|
109
|
+
if (spread.prefix)
|
|
110
|
+
for (const node of spread.prefix)
|
|
111
|
+
appendRequiredElement(base, node);
|
|
112
|
+
if (spread.optionals)
|
|
113
|
+
for (const node of spread.optionals)
|
|
114
|
+
appendOptionalElement(base, node);
|
|
115
|
+
if (spread.variadic)
|
|
116
|
+
appendVariadicElement(base, spread.variadic);
|
|
117
|
+
if (spread.postfix)
|
|
118
|
+
for (const node of spread.postfix)
|
|
119
|
+
appendRequiredElement(base, node);
|
|
120
|
+
return base;
|
|
121
|
+
};
|
|
122
|
+
export const writeNonArraySpreadMessage = (operand) => `Spread element must be an array (was ${operand})`;
|
|
123
|
+
export const multipleVariadicMesage = "A tuple may have at most one variadic element";
|
|
124
|
+
export const requiredPostOptionalMessage = "A required element may not follow an optional element";
|
|
125
|
+
export const optionalOrDefaultableAfterVariadicMessage = "An optional element may not follow a variadic element";
|
|
126
|
+
export const spreadOptionalMessage = "A spread element cannot be optional";
|
|
127
|
+
export const spreadDefaultableMessage = "A spread element cannot have a default";
|
|
128
|
+
export const defaultablePostOptionalMessage = "A defaultable element may not follow an optional element without a default";
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { BaseScope, type AliasDefEntry, type ArkSchemaRegistry, type ArkSchemaScopeConfig, type BaseNode, type BaseParseContext, type BaseParseContextInput, type BaseParseOptions, type BaseRoot, type GenericAst, type GenericParamAst, type GenericParamDef, type NodeKind, type NodeSchema, type PreparsedNodeResolution, type PrivateDeclaration, type RootKind, type RootSchema, type arkKind, type exportedNameOf, type nodeOfKind, type reducibleKindOf, type toInternalScope, type writeDuplicateAliasError } from "@ark/schema";
|
|
2
|
+
import { type Brand, type ErrorType, type JsonStructure, type anyOrNever, type array, type flattenListable, type noSuggest } from "@ark/util";
|
|
3
|
+
import type { DeclarationParser } from "./declare.ts";
|
|
4
|
+
import { InternalFnParser, type FnParser } from "./fn.ts";
|
|
5
|
+
import { type GenericDeclaration, type GenericParser, type ParameterString, type baseGenericConstraints, type parseGenericParams, type parseValidGenericParams } from "./generic.ts";
|
|
6
|
+
import type { Ark, type } from "./keywords/keywords.ts";
|
|
7
|
+
import { InternalMatchParser, type MatchParser } from "./match.ts";
|
|
8
|
+
import type { BoundModule, Module, Submodule, exportScope, instantiateExport } from "./module.ts";
|
|
9
|
+
import type { NaryIntersectionParser, NaryMergeParser, NaryPipeParser, NaryUnionParser } from "./nary.ts";
|
|
10
|
+
import type { DefAst, InferredAst } from "./parser/ast/infer.ts";
|
|
11
|
+
import { type inferDefinition } from "./parser/definition.ts";
|
|
12
|
+
import type { ParsedOptionalProperty } from "./parser/property.ts";
|
|
13
|
+
import type { ParsedDefaultableProperty } from "./parser/shift/operator/default.ts";
|
|
14
|
+
import { InternalTypeParser, type DefinitionParser, type EnumeratedTypeParser, type InstanceOfTypeParser, type SchemaParser, type TypeParser, type UnitTypeParser, type ValueOfTypeParser } from "./type.ts";
|
|
15
|
+
/** The convenience properties attached to `scope` */
|
|
16
|
+
export type ScopeParserAttachments = Omit<ScopeParser, never>;
|
|
17
|
+
export interface ArkScopeConfig extends ArkSchemaScopeConfig {
|
|
18
|
+
}
|
|
19
|
+
export interface ScopeParser {
|
|
20
|
+
<const def>(def: scope.validate<def>, config?: ArkScopeConfig): Scope<scope.infer<def>>;
|
|
21
|
+
define: <const def>(def: scope.validate<def>) => def;
|
|
22
|
+
}
|
|
23
|
+
export type ModuleParser = <const def>(def: scope.validate<def>, config?: ArkScopeConfig) => scope.infer<def> extends infer $ ? Module<{
|
|
24
|
+
[k in exportedNameOf<$>]: $[k];
|
|
25
|
+
}> : never;
|
|
26
|
+
export type bindThis<def> = {
|
|
27
|
+
this: Def<def>;
|
|
28
|
+
};
|
|
29
|
+
/** nominal type for an unparsed definition used during scope bootstrapping */
|
|
30
|
+
type Def<def = {}> = Brand<def, "unparsed">;
|
|
31
|
+
/** sentinel indicating a scope that will be associated with a generic has not yet been parsed */
|
|
32
|
+
export type UnparsedScope = "$";
|
|
33
|
+
/** These are legal as values of a scope but not as definitions in other contexts */
|
|
34
|
+
type PreparsedResolution = PreparsedNodeResolution;
|
|
35
|
+
type bootstrapAliases<def> = {
|
|
36
|
+
[k in Exclude<keyof def, GenericDeclaration>]: def[k] extends (PreparsedResolution) ? def[k] extends {
|
|
37
|
+
t: infer g extends GenericAst;
|
|
38
|
+
} ? g : def[k] extends Module<infer $> | BoundModule<infer $, any> ? Submodule<$> : def[k] : def[k] extends (() => infer thunkReturn extends PreparsedResolution) ? thunkReturn extends {
|
|
39
|
+
t: infer g extends GenericAst;
|
|
40
|
+
} ? g : thunkReturn extends Module<infer $> | BoundModule<infer $, any> ? Submodule<$> : thunkReturn : Def<def[k]>;
|
|
41
|
+
} & {
|
|
42
|
+
[k in keyof def & GenericDeclaration as extractGenericName<k>]: GenericAst<parseValidGenericParams<extractGenericParameters<k>, bootstrapAliases<def>>, def[k], UnparsedScope>;
|
|
43
|
+
};
|
|
44
|
+
type inferBootstrapped<$> = {
|
|
45
|
+
[name in keyof $]: $[name] extends Def<infer def> ? inferDefinition<def, $, {}> : $[name] extends {
|
|
46
|
+
t: infer g extends GenericAst;
|
|
47
|
+
} ? bindGenericToScope<g, $> : $[name];
|
|
48
|
+
} & unknown;
|
|
49
|
+
export type bindGenericToScope<g extends GenericAst, $> = GenericAst<g["paramsAst"], g["bodyDef"], g["$"] extends UnparsedScope ? $ : g["$"], $>;
|
|
50
|
+
type extractGenericName<k> = k extends GenericDeclaration<infer name> ? name : never;
|
|
51
|
+
type extractGenericParameters<k> = k extends `${string}<${infer params}>` ? ParameterString<params> : never;
|
|
52
|
+
export type resolutionToAst<alias extends string, resolution> = [
|
|
53
|
+
resolution
|
|
54
|
+
] extends [anyOrNever] ? InferredAst<resolution, alias> : resolution extends Def<infer def> ? DefAst<def, alias> : resolution extends {
|
|
55
|
+
[arkKind]: "module";
|
|
56
|
+
root: infer root;
|
|
57
|
+
} ? InferredAst<root, alias> : resolution extends GenericAst ? resolution : InferredAst<resolution, alias>;
|
|
58
|
+
export type moduleKeyOf<$> = {
|
|
59
|
+
[k in keyof $]: $[k] extends {
|
|
60
|
+
[arkKind]: "module";
|
|
61
|
+
} ? [
|
|
62
|
+
$[k]
|
|
63
|
+
] extends [anyOrNever] ? never : k & string : never;
|
|
64
|
+
}[keyof $];
|
|
65
|
+
export interface ArkTypeRegistry extends ArkSchemaRegistry {
|
|
66
|
+
typeAttachments?: Ark.boundTypeAttachments<any>;
|
|
67
|
+
ambient: exportScope<Ark>;
|
|
68
|
+
}
|
|
69
|
+
export declare const $arkTypeRegistry: ArkTypeRegistry;
|
|
70
|
+
export interface InternalScope {
|
|
71
|
+
constructor: typeof InternalScope;
|
|
72
|
+
}
|
|
73
|
+
export declare class InternalScope<$ extends {} = {}> extends BaseScope<$> {
|
|
74
|
+
get ambientAttachments(): Ark.boundTypeAttachments<$> | undefined;
|
|
75
|
+
protected preparseOwnAliasEntry(alias: string, def: unknown): AliasDefEntry;
|
|
76
|
+
parseGenericParams(def: string, opts: BaseParseOptions): array<GenericParamDef>;
|
|
77
|
+
protected normalizeRootScopeValue(resolution: unknown): unknown;
|
|
78
|
+
protected preparseOwnDefinitionFormat(def: unknown, opts: BaseParseOptions): BaseRoot | BaseParseContextInput;
|
|
79
|
+
parseOwnDefinitionFormat(def: unknown, ctx: BaseParseContext): BaseRoot;
|
|
80
|
+
unit: UnitTypeParser<$>;
|
|
81
|
+
valueOf: ValueOfTypeParser<$>;
|
|
82
|
+
enumerated: EnumeratedTypeParser<$>;
|
|
83
|
+
instanceOf: InstanceOfTypeParser<$>;
|
|
84
|
+
or: NaryUnionParser<$>;
|
|
85
|
+
and: NaryIntersectionParser<$>;
|
|
86
|
+
merge: NaryMergeParser<$>;
|
|
87
|
+
pipe: NaryPipeParser<$>;
|
|
88
|
+
fn: InternalFnParser;
|
|
89
|
+
match: InternalMatchParser;
|
|
90
|
+
declare: () => {
|
|
91
|
+
type: InternalTypeParser;
|
|
92
|
+
};
|
|
93
|
+
define<def>(def: def): def;
|
|
94
|
+
type: InternalTypeParser;
|
|
95
|
+
static scope: ScopeParser;
|
|
96
|
+
static module: ModuleParser;
|
|
97
|
+
}
|
|
98
|
+
export declare const scope: ScopeParser;
|
|
99
|
+
export declare namespace scope {
|
|
100
|
+
type validate<def> = {
|
|
101
|
+
[k in keyof def]: k extends noSuggest ? unknown : parseScopeKey<k, def>["params"] extends infer params ? params extends array<GenericParamAst> ? params["length"] extends 0 ? def[k] extends type.Any | PreparsedResolution ? def[k] : k extends (PrivateDeclaration<infer name extends keyof def & string>) ? ErrorType<writeDuplicateAliasError<name>> : type.validate<def[k], bootstrapAliases<def>, {}> : type.validate<def[k], bootstrapAliases<def>, baseGenericConstraints<params>> : params : never;
|
|
102
|
+
};
|
|
103
|
+
type infer<def> = inferBootstrapped<bootstrapAliases<def>>;
|
|
104
|
+
}
|
|
105
|
+
export interface Scope<$ = {}> {
|
|
106
|
+
t: $;
|
|
107
|
+
[arkKind]: "scope";
|
|
108
|
+
config: ArkScopeConfig;
|
|
109
|
+
references: readonly BaseNode[];
|
|
110
|
+
json: JsonStructure;
|
|
111
|
+
exportedNames: array<exportedNameOf<$>>;
|
|
112
|
+
/** The set of names defined at the root-level of the scope mapped to their
|
|
113
|
+
* corresponding definitions.**/
|
|
114
|
+
aliases: Record<string, unknown>;
|
|
115
|
+
internal: toInternalScope<$>;
|
|
116
|
+
defineSchema<const def extends RootSchema>(schema: def): def;
|
|
117
|
+
node<kinds extends NodeKind | array<RootKind>>(kinds: kinds, schema: NodeSchema<flattenListable<kinds>>, opts?: BaseParseOptions): nodeOfKind<reducibleKindOf<flattenListable<kinds>>>;
|
|
118
|
+
unit: UnitTypeParser<$>;
|
|
119
|
+
enumerated: EnumeratedTypeParser<$>;
|
|
120
|
+
valueOf: ValueOfTypeParser<$>;
|
|
121
|
+
instanceOf: InstanceOfTypeParser<$>;
|
|
122
|
+
type: TypeParser<$>;
|
|
123
|
+
match: MatchParser<$>;
|
|
124
|
+
fn: FnParser<$>;
|
|
125
|
+
declare: DeclarationParser<$>;
|
|
126
|
+
define: DefinitionParser<$>;
|
|
127
|
+
generic: GenericParser<$>;
|
|
128
|
+
schema: SchemaParser<$>;
|
|
129
|
+
import(): Module<{
|
|
130
|
+
[k in exportedNameOf<$> as PrivateDeclaration<k>]: $[k];
|
|
131
|
+
}>;
|
|
132
|
+
import<names extends exportedNameOf<$>[]>(...names: names): BoundModule<{
|
|
133
|
+
[k in names[number] as PrivateDeclaration<k>]: $[k];
|
|
134
|
+
} & unknown, $>;
|
|
135
|
+
export(): Module<{
|
|
136
|
+
[k in exportedNameOf<$>]: $[k];
|
|
137
|
+
}>;
|
|
138
|
+
export<names extends exportedNameOf<$>[]>(...names: names): BoundModule<{
|
|
139
|
+
[k in names[number]]: $[k];
|
|
140
|
+
} & unknown, $>;
|
|
141
|
+
resolve<name extends exportedNameOf<$>>(name: name): instantiateExport<$[name], $>;
|
|
142
|
+
}
|
|
143
|
+
export interface ScopeConstructor {
|
|
144
|
+
new <$ = {}>(...args: ConstructorParameters<typeof InternalScope>): Scope<$>;
|
|
145
|
+
scope: ScopeParser;
|
|
146
|
+
module: ModuleParser;
|
|
147
|
+
}
|
|
148
|
+
export declare const Scope: ScopeConstructor;
|
|
149
|
+
export type parseScopeKey<k, def> = k extends `${infer name}<${infer params}>` ? parseGenericScopeKey<name, params, def> : {
|
|
150
|
+
name: k;
|
|
151
|
+
params: [];
|
|
152
|
+
};
|
|
153
|
+
type parseGenericScopeKey<name extends string, params extends string, def> = {
|
|
154
|
+
name: name;
|
|
155
|
+
params: parseGenericParams<params, bootstrapAliases<def>>;
|
|
156
|
+
};
|
|
157
|
+
export type InnerParseResult = BaseRoot | ParsedOptionalProperty | ParsedDefaultableProperty;
|
|
158
|
+
export {};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { $ark, BaseScope, hasArkKind, parseGeneric } from "@ark/schema";
|
|
2
|
+
import { Scanner, enumValues, flatMorph, isArray, isThunk, throwParseError } from "@ark/util";
|
|
3
|
+
import { InternalFnParser } from "./fn.js";
|
|
4
|
+
import { parseGenericParamName } from "./generic.js";
|
|
5
|
+
import { InternalMatchParser } from "./match.js";
|
|
6
|
+
import { shallowDefaultableMessage, shallowOptionalMessage } from "./parser/ast/validate.js";
|
|
7
|
+
import { parseInnerDefinition } from "./parser/definition.js";
|
|
8
|
+
import { InternalTypeParser } from "./type.js";
|
|
9
|
+
export const $arkTypeRegistry = $ark;
|
|
10
|
+
export class InternalScope extends BaseScope {
|
|
11
|
+
get ambientAttachments() {
|
|
12
|
+
if (!$arkTypeRegistry.typeAttachments)
|
|
13
|
+
return;
|
|
14
|
+
return this.cacheGetter("ambientAttachments", flatMorph($arkTypeRegistry.typeAttachments, (k, v) => [
|
|
15
|
+
k,
|
|
16
|
+
this.bindReference(v)
|
|
17
|
+
]));
|
|
18
|
+
}
|
|
19
|
+
preparseOwnAliasEntry(alias, def) {
|
|
20
|
+
const firstParamIndex = alias.indexOf("<");
|
|
21
|
+
if (firstParamIndex === -1) {
|
|
22
|
+
if (hasArkKind(def, "module") || hasArkKind(def, "generic"))
|
|
23
|
+
return [alias, def];
|
|
24
|
+
const qualifiedName = this.name === "ark" ? alias
|
|
25
|
+
: alias === "root" ? this.name
|
|
26
|
+
: `${this.name}.${alias}`;
|
|
27
|
+
const config = this.resolvedConfig.keywords?.[qualifiedName];
|
|
28
|
+
if (config)
|
|
29
|
+
def = [def, "@", config];
|
|
30
|
+
return [alias, def];
|
|
31
|
+
}
|
|
32
|
+
if (alias[alias.length - 1] !== ">") {
|
|
33
|
+
throwParseError(`'>' must be the last character of a generic declaration in a scope`);
|
|
34
|
+
}
|
|
35
|
+
const name = alias.slice(0, firstParamIndex);
|
|
36
|
+
const paramString = alias.slice(firstParamIndex + 1, -1);
|
|
37
|
+
return [
|
|
38
|
+
name,
|
|
39
|
+
// use a thunk definition for the generic so that we can parse
|
|
40
|
+
// constraints within the current scope
|
|
41
|
+
() => {
|
|
42
|
+
const params = this.parseGenericParams(paramString, { alias: name });
|
|
43
|
+
const generic = parseGeneric(params, def, this);
|
|
44
|
+
return generic;
|
|
45
|
+
}
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
parseGenericParams(def, opts) {
|
|
49
|
+
return parseGenericParamName(new Scanner(def), [], this.createParseContext({
|
|
50
|
+
...opts,
|
|
51
|
+
def,
|
|
52
|
+
prefix: "generic"
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
normalizeRootScopeValue(resolution) {
|
|
56
|
+
if (isThunk(resolution) && !hasArkKind(resolution, "generic"))
|
|
57
|
+
return resolution();
|
|
58
|
+
return resolution;
|
|
59
|
+
}
|
|
60
|
+
preparseOwnDefinitionFormat(def, opts) {
|
|
61
|
+
return {
|
|
62
|
+
...opts,
|
|
63
|
+
def,
|
|
64
|
+
prefix: opts.alias ?? "type"
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
parseOwnDefinitionFormat(def, ctx) {
|
|
68
|
+
const isScopeAlias = ctx.alias && ctx.alias in this.aliases;
|
|
69
|
+
// if the definition being parsed is not a scope alias and is not a
|
|
70
|
+
// generic instantiation (i.e. opts don't include args), add `this` as a resolution.
|
|
71
|
+
// if we're parsing a nested string, ctx.args will have already been set
|
|
72
|
+
if (!isScopeAlias && !ctx.args)
|
|
73
|
+
ctx.args = { this: ctx.id };
|
|
74
|
+
const result = parseInnerDefinition(def, ctx);
|
|
75
|
+
if (isArray(result)) {
|
|
76
|
+
if (result[1] === "=")
|
|
77
|
+
return throwParseError(shallowDefaultableMessage);
|
|
78
|
+
if (result[1] === "?")
|
|
79
|
+
return throwParseError(shallowOptionalMessage);
|
|
80
|
+
}
|
|
81
|
+
return result;
|
|
82
|
+
}
|
|
83
|
+
unit = value => this.units([value]);
|
|
84
|
+
valueOf = tsEnum => this.units(enumValues(tsEnum));
|
|
85
|
+
enumerated = (...values) => this.units(values);
|
|
86
|
+
instanceOf = ctor => this.node("proto", { proto: ctor }, { prereduced: true });
|
|
87
|
+
or = (...defs) => this.schema(defs.map(def => this.parse(def)));
|
|
88
|
+
and = (...defs) => defs.reduce((node, def) => node.and(this.parse(def)), this.intrinsic.unknown);
|
|
89
|
+
merge = (...defs) => defs.reduce((node, def) => node.merge(this.parse(def)), this.intrinsic.object);
|
|
90
|
+
pipe = (...morphs) => this.intrinsic.unknown.pipe(...morphs);
|
|
91
|
+
fn = new InternalFnParser(this);
|
|
92
|
+
match = new InternalMatchParser(this);
|
|
93
|
+
declare = () => ({
|
|
94
|
+
type: this.type
|
|
95
|
+
});
|
|
96
|
+
define(def) {
|
|
97
|
+
return def;
|
|
98
|
+
}
|
|
99
|
+
type = new InternalTypeParser(this);
|
|
100
|
+
static scope = ((def, config = {}) => new InternalScope(def, config));
|
|
101
|
+
static module = ((def, config = {}) => this.scope(def, config).export());
|
|
102
|
+
}
|
|
103
|
+
export const scope = Object.assign(InternalScope.scope, {
|
|
104
|
+
define: (def) => def
|
|
105
|
+
});
|
|
106
|
+
export const Scope = InternalScope;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { ArkErrors, BaseRoot, type BaseParseOptions, type Morph, type NodeSelector, type Predicate, type RootSchema, type TypeMeta } from "@ark/schema";
|
|
2
|
+
import { Callable, Hkt, type Constructor, type array, type conform } from "@ark/util";
|
|
3
|
+
import type { distill } from "./attributes.ts";
|
|
4
|
+
import type { DeclarationParser } from "./declare.ts";
|
|
5
|
+
import type { FnParser } from "./fn.ts";
|
|
6
|
+
import type { Generic, GenericParser, ParameterString, baseGenericConstraints, parseValidGenericParams, validateParameterString } from "./generic.ts";
|
|
7
|
+
import type { Ark, keywords, type } from "./keywords/keywords.ts";
|
|
8
|
+
import type { MatchParser } from "./match.ts";
|
|
9
|
+
import type { NaryIntersectionParser, NaryMergeParser, NaryPipeParser, NaryUnionParser } from "./nary.ts";
|
|
10
|
+
import type { ArgTwoOperator, IndexZeroOperator, TupleInfixOperator } from "./parser/tupleExpressions.ts";
|
|
11
|
+
import type { InternalScope, ModuleParser, Scope, ScopeParser } from "./scope.ts";
|
|
12
|
+
import type { BaseType } from "./variants/base.ts";
|
|
13
|
+
import type { instantiateType } from "./variants/instantiate.ts";
|
|
14
|
+
/** The convenience properties attached to `type` */
|
|
15
|
+
export type TypeParserAttachments = Omit<TypeParser, never>;
|
|
16
|
+
export interface TypeParser<$ = {}> extends Ark.boundTypeAttachments<$> {
|
|
17
|
+
/**
|
|
18
|
+
* Create a {@link Type} from your definition.
|
|
19
|
+
*
|
|
20
|
+
* @example const Person = type({ name: "string" })
|
|
21
|
+
*/
|
|
22
|
+
<const def, r = type.instantiate<def, $>>(def: type.validate<def, $>): r extends infer _ ? _ : never;
|
|
23
|
+
/**
|
|
24
|
+
* Create a {@link Generic} from a parameter string and body definition.
|
|
25
|
+
*
|
|
26
|
+
* @param params A string like "<t, n extends number>" specifying the
|
|
27
|
+
* {@link Generic}'s parameters and any associated constraints via `extends`.
|
|
28
|
+
*
|
|
29
|
+
* @param def The definition for the body of the {@link Generic}. Can reference the
|
|
30
|
+
* parameter names specified in the previous argument in addition to aliases
|
|
31
|
+
* from its {@link Scope}.
|
|
32
|
+
*
|
|
33
|
+
* @example const BoxOf = type("<t extends string | number>", { contents: "t" })
|
|
34
|
+
*/
|
|
35
|
+
<const params extends ParameterString, const def, r = Generic<parseValidGenericParams<params, $>, def, $>>(params: validateParameterString<params, $>, def: type.validate<def, $, baseGenericConstraints<parseValidGenericParams<params, $>>>): r extends infer _ ? _ : never;
|
|
36
|
+
/**
|
|
37
|
+
* Create a {@link Type} from a [tuple expression](http://localhost:3000/docs/expressions)
|
|
38
|
+
* spread as this function's arguments.
|
|
39
|
+
*
|
|
40
|
+
* @example type("string", "|", { foo: "number" })
|
|
41
|
+
*/
|
|
42
|
+
<const zero, const one, const rest extends array, r = type.instantiate<[zero, one, ...rest], $>>(_0: zero extends IndexZeroOperator ? zero : type.validate<zero, $>, _1: zero extends "keyof" ? type.validate<one, $> : zero extends "instanceof" ? conform<one, Constructor> : zero extends "===" ? conform<one, unknown> : conform<one, ArgTwoOperator>, ..._2: zero extends "===" ? rest : zero extends "instanceof" ? conform<rest, readonly Constructor[]> : one extends TupleInfixOperator ? one extends ":" ? [Predicate<distill.In<type.infer<zero, $>>>] : one extends "=>" ? [Morph<distill.Out<type.infer<zero, $>>, unknown>] : one extends "|>" ? [type.validate<rest[0], $>] : one extends "@" ? [TypeMeta.MappableInput, NodeSelector?] : [type.validate<rest[0], $>] : []): r extends infer _ ? _ : never;
|
|
43
|
+
/**
|
|
44
|
+
* An alias of the {@link ArkErrors} class, an instance of which is returned when a {@link Type}
|
|
45
|
+
* is invoked with invalid input.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* const out = myType(data)
|
|
49
|
+
*
|
|
50
|
+
* if(out instanceof type.errors) console.log(out.summary)
|
|
51
|
+
*/
|
|
52
|
+
errors: typeof ArkErrors;
|
|
53
|
+
hkt: typeof Hkt;
|
|
54
|
+
keywords: typeof keywords;
|
|
55
|
+
/**
|
|
56
|
+
* The {@link Scope} in which definitions passed to this function will be parsed.
|
|
57
|
+
*/
|
|
58
|
+
$: Scope<$>;
|
|
59
|
+
/**
|
|
60
|
+
* An alias of `type` with no type-level validation or inference.
|
|
61
|
+
*
|
|
62
|
+
* Useful when wrapping `type` or using it to parse a dynamic definition.
|
|
63
|
+
*/
|
|
64
|
+
raw(def: unknown): BaseType<any, $>;
|
|
65
|
+
module: ModuleParser;
|
|
66
|
+
scope: ScopeParser;
|
|
67
|
+
define: DefinitionParser<$>;
|
|
68
|
+
declare: DeclarationParser<$>;
|
|
69
|
+
generic: GenericParser<$>;
|
|
70
|
+
match: MatchParser<$>;
|
|
71
|
+
schema: SchemaParser<$>;
|
|
72
|
+
/**
|
|
73
|
+
* Create a {@link Type} that is satisfied only by a value strictly equal (`===`) to the argument passed to this function.
|
|
74
|
+
* @example const foo = type.unit('foo') // {@link Type}<'foo'>
|
|
75
|
+
* @example const sym: unique symbol = Symbol(); type.unit(sym) // {@link Type}<typeof sym>
|
|
76
|
+
*/
|
|
77
|
+
unit: UnitTypeParser<$>;
|
|
78
|
+
/**
|
|
79
|
+
* Create a {@link Type} that is satisfied only by a value strictly equal (`===`) to one of the arguments passed to this function.
|
|
80
|
+
* @example const enum = type.enumerated('foo', 'bar', obj) // obj is a by-reference object
|
|
81
|
+
* @example const TupleForm = type(['===', 'foo', 'bar', obj])
|
|
82
|
+
* @example const ArgsForm = type('===', 'foo', 'bar', obj)
|
|
83
|
+
*/
|
|
84
|
+
enumerated: EnumeratedTypeParser<$>;
|
|
85
|
+
/**
|
|
86
|
+
* Create a {@link Type} that is satisfied only by one of the Object.values() of the argument passed to this function.
|
|
87
|
+
*
|
|
88
|
+
* ⚠️ For TypeScript enum compatibility, values at numeric keys with corresponding numeric values will not be included.
|
|
89
|
+
* @example const myEnum = type.valueOf(myTsEnum)
|
|
90
|
+
*/
|
|
91
|
+
valueOf: ValueOfTypeParser<$>;
|
|
92
|
+
/**
|
|
93
|
+
* Create a {@link Type} that is satisfied only by a value of a specific class.
|
|
94
|
+
* @example const array = type.instanceOf(Array)
|
|
95
|
+
*/
|
|
96
|
+
instanceOf: InstanceOfTypeParser<$>;
|
|
97
|
+
/**
|
|
98
|
+
* Create a {@link Type} from a union of definitions
|
|
99
|
+
* @example const T = type.or("string", "number")
|
|
100
|
+
*/
|
|
101
|
+
or: NaryUnionParser<$>;
|
|
102
|
+
/**
|
|
103
|
+
* Create a {@link Type} from an intersection of definitions
|
|
104
|
+
* @example const T = type.and({ a: "1" }, { b: "2" })
|
|
105
|
+
*/
|
|
106
|
+
and: NaryIntersectionParser<$>;
|
|
107
|
+
/**
|
|
108
|
+
* Create a {@link Type} by merging object definitions, with later
|
|
109
|
+
* definitions having precedence for overlapping keys
|
|
110
|
+
* @example
|
|
111
|
+
* // Type<{ a: "3", b: "2", c: "4" }>
|
|
112
|
+
* const T = type.merge({ a: "1", b: "2" }, { a: "3", c: "4" })
|
|
113
|
+
*/
|
|
114
|
+
merge: NaryMergeParser<$>;
|
|
115
|
+
/**
|
|
116
|
+
* Create a {@link Type} from a set of morphs (including Types)
|
|
117
|
+
* @example
|
|
118
|
+
* // Type<(In: string) => To<object>>
|
|
119
|
+
* const T = type.pipe(type.string, s => JSON.parse(s), type.object)
|
|
120
|
+
*/
|
|
121
|
+
pipe: NaryPipeParser<$>;
|
|
122
|
+
/**
|
|
123
|
+
* Define a validated function
|
|
124
|
+
* @example
|
|
125
|
+
* const len = type.fn("string | unknown[]", ":", "number")(s => s.length)
|
|
126
|
+
* len("foo") // 3
|
|
127
|
+
* // TypeScript: boolean is not assignable to string | unknown[]
|
|
128
|
+
* // Runtime (throws): must be a string or an object (was boolean)
|
|
129
|
+
* len(true)
|
|
130
|
+
*/
|
|
131
|
+
fn: FnParser<$>;
|
|
132
|
+
}
|
|
133
|
+
export declare class InternalTypeParser extends Callable<(...args: unknown[]) => BaseRoot | Generic, TypeParserAttachments> {
|
|
134
|
+
constructor($: InternalScope);
|
|
135
|
+
}
|
|
136
|
+
export type UnitTypeParser<$> = <const t>(value: t) => Type<t, $>;
|
|
137
|
+
export type InstanceOfTypeParser<$> = <const t extends object>(ctor: Constructor<t>) => Type<t, $>;
|
|
138
|
+
export type EnumeratedTypeParser<$> = <const values extends readonly unknown[]>(...values: values) => Type<values[number], $>;
|
|
139
|
+
export type ValueOfTypeParser<$> = <const o extends object>(o: o) => Type<o[keyof o], $>;
|
|
140
|
+
export type DefinitionParser<$> = <const def>(def: type.validate<def, $>) => def;
|
|
141
|
+
export type SchemaParser<$> = (schema: RootSchema, opts?: BaseParseOptions) => Type<unknown, $>;
|
|
142
|
+
export type Type<t = unknown, $ = {}> = instantiateType<t, $>;
|
|
143
|
+
export type TypeConstructor<t = unknown, $ = {}> = new (def: unknown, $: Scope<$>) => Type<t, $>;
|
|
144
|
+
export declare const Type: TypeConstructor;
|