@blade-hq/agent-client 1.1.1 → 1.1.3
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,25 @@
|
|
|
1
|
+
import type { arkKeyOf, array } from "@ark/util";
|
|
2
|
+
import type { distill, inferIntersection, inferPipe, LimitLiteral, withDefault } from "../../attributes.ts";
|
|
3
|
+
import type { type } from "../../keywords/keywords.ts";
|
|
4
|
+
import type { inferDefinition } from "../definition.ts";
|
|
5
|
+
import type { Comparator } from "../reduce/shared.ts";
|
|
6
|
+
import type { InfixToken, PostfixToken } from "../shift/tokens.ts";
|
|
7
|
+
import type { GenericInstantiationAst, inferGenericInstantiation } from "./generic.ts";
|
|
8
|
+
export type inferAstRoot<ast, $, args> = ast extends array ? inferExpression<ast, $, args> : never;
|
|
9
|
+
export type inferAstIn<ast, $, args> = distill.In<inferAstRoot<ast, $, args>>;
|
|
10
|
+
export type inferAstOut<ast, $, args> = distill.Out<inferAstRoot<ast, $, args>>;
|
|
11
|
+
export type DefAst<def = unknown, alias extends string = string> = [
|
|
12
|
+
def,
|
|
13
|
+
"def",
|
|
14
|
+
alias
|
|
15
|
+
];
|
|
16
|
+
export type InferredAst<t = unknown, def extends string = string> = [
|
|
17
|
+
t,
|
|
18
|
+
"inferred",
|
|
19
|
+
def
|
|
20
|
+
];
|
|
21
|
+
export type inferExpression<ast, $, args> = ast extends array ? ast extends InferredAst<infer resolution> ? resolution : ast extends DefAst<infer def> ? inferDefinition<def, $, args> : ast extends GenericInstantiationAst<infer g, infer argAsts> ? inferGenericInstantiation<g, argAsts, $, args> : ast[1] extends "[]" ? inferExpression<ast[0], $, args>[] : ast[1] extends "|" ? inferExpression<ast[0], $, args> | inferExpression<ast[2], $, args> : ast[1] extends "&" ? inferIntersection<inferExpression<ast[0], $, args>, inferExpression<ast[2], $, args>> : ast[1] extends "|>" ? inferPipe<inferExpression<ast[0], $, args>, inferExpression<ast[2], $, args>> : ast[1] extends "=" ? type.infer<ast[2]> extends infer defaultValue ? withDefault<inferExpression<ast[0], $, args>, defaultValue> : never : ast[1] extends "#" ? type.brand<inferExpression<ast[0], $, args>, ast[2]> : ast[1] extends Comparator ? ast[0] extends LimitLiteral ? inferExpression<ast[2], $, args> : inferExpression<ast[0], $, args> : ast[1] extends "%" ? inferExpression<ast[0], $, args> : ast[1] extends "?" ? inferExpression<ast[0], $, args> : ast[0] extends "keyof" ? arkKeyOf<inferExpression<ast[1], $, args>> : never : never;
|
|
22
|
+
export type PrefixOperator = "keyof" | "instanceof" | "===" | "node";
|
|
23
|
+
export type PrefixExpression<operator extends PrefixOperator = PrefixOperator, operand = unknown> = [operator, operand];
|
|
24
|
+
export type PostfixExpression<operator extends PostfixToken = PostfixToken, operand = unknown> = readonly [operand, operator];
|
|
25
|
+
export type InfixExpression<operator extends InfixToken = InfixToken, l = unknown, r = unknown> = [l, operator, r];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { writeNonStructuralOperandMessage } from "@ark/schema";
|
|
2
|
+
import type { ErrorMessage, typeToString } from "@ark/util";
|
|
3
|
+
import type { inferAstRoot } from "./infer.ts";
|
|
4
|
+
import type { validateAst } from "./validate.ts";
|
|
5
|
+
export type validateKeyof<operandAst, $, args> = inferAstRoot<operandAst, $, args> extends infer data ? [
|
|
6
|
+
data
|
|
7
|
+
] extends [object] ? validateAst<operandAst, $, args> : ErrorMessage<writeNonStructuralOperandMessage<"keyof", typeToString<data>>> : never;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { satisfy, Stringifiable } from "@ark/util";
|
|
2
|
+
import type { Comparator } from "../reduce/shared.ts";
|
|
3
|
+
import type { OperatorToken } from "../shift/tokens.ts";
|
|
4
|
+
import type { DefAst, InferredAst, InfixExpression, PostfixExpression } from "./infer.ts";
|
|
5
|
+
export type astToString<ast> = ast extends InferredAst | DefAst ? ast[2] : ast extends PostfixExpression<infer operator, infer operand> ? operator extends "[]" ? `${astToString<operand>}[]` : never : ast extends InfixExpression<infer operator, infer l, infer r> ? operator extends "&" | "|" | "%" | Comparator ? `${astToString<l>} ${operator} ${astToString<r>}` : never : ast extends Stringifiable ? `${ast extends bigint ? `${ast}n` : ast}` : "...";
|
|
6
|
+
export type ConstraintOperator = satisfy<OperatorToken, "%" | Comparator>;
|
|
7
|
+
export type writeConstrainedMorphMessage<constrainedAst> = `To constrain the output of ${astToString<constrainedAst>}, pipe like myMorph.to('number > 0').
|
|
8
|
+
To constrain the input, intersect like myMorph.and('number > 0').`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { arkKind, PrivateDeclaration, writeMissingSubmoduleAccessMessage } from "@ark/schema";
|
|
2
|
+
import type { anyOrNever, BigintLiteral, Completion, ErrorMessage, NumberLiteral, writeMalformedNumericLiteralMessage } from "@ark/util";
|
|
3
|
+
import type { Generic } from "../../generic.ts";
|
|
4
|
+
import type { BranchOperator, Comparator } from "../reduce/shared.ts";
|
|
5
|
+
import type { writeInvalidGenericArgCountMessage } from "../shift/operand/genericArgs.ts";
|
|
6
|
+
import type { UnitLiteral } from "../shift/operator/default.ts";
|
|
7
|
+
import type { parseString } from "../string.ts";
|
|
8
|
+
import type { validateRange } from "./bounds.ts";
|
|
9
|
+
import type { validateDefault } from "./default.ts";
|
|
10
|
+
import type { validateDivisor } from "./divisor.ts";
|
|
11
|
+
import type { GenericInstantiationAst, validateGenericInstantiation } from "./generic.ts";
|
|
12
|
+
import type { DefAst, InferredAst, InfixExpression, PostfixExpression } from "./infer.ts";
|
|
13
|
+
import type { validateKeyof } from "./keyof.ts";
|
|
14
|
+
import type { astToString } from "./utils.ts";
|
|
15
|
+
export type validateAst<ast, $, args> = ast extends ErrorMessage ? ast : ast extends InferredAst ? validateInferredAst<ast[0], ast[2]> : ast extends DefAst ? ast[2] extends PrivateDeclaration<infer name> ? ErrorMessage<writePrefixedPrivateReferenceMessage<name>> : undefined : ast extends PostfixExpression<"[]" | "?", infer operand> ? validateAst<operand, $, args> : ast extends InfixExpression<infer operator, infer l, infer r> ? operator extends BranchOperator ? validateInfix<ast, $, args> : operator extends Comparator ? validateRange<l, operator, r, $, args> : operator extends "%" ? validateDivisor<l, $, args> : operator extends "=" ? validateDefault<l, r & UnitLiteral, $, args> : operator extends "#" ? validateAst<l, $, args> : ErrorMessage<writeUnexpectedExpressionMessage<astToString<ast>>> : ast extends ["keyof", infer operand] ? validateKeyof<operand, $, args> : ast extends GenericInstantiationAst<infer g, infer argAsts> ? validateGenericInstantiation<g, argAsts, $, args> : ErrorMessage<writeUnexpectedExpressionMessage<astToString<ast>>> & {
|
|
16
|
+
ast: ast;
|
|
17
|
+
};
|
|
18
|
+
type writeUnexpectedExpressionMessage<expression extends string> = `Failed to parse the expression resulting from ${expression}`;
|
|
19
|
+
export declare const writePrefixedPrivateReferenceMessage: <name extends string>(name: name) => writePrefixedPrivateReferenceMessage<name>;
|
|
20
|
+
export type writePrefixedPrivateReferenceMessage<name extends string> = `Private type references should not include '#'. Use '${name}' instead.`;
|
|
21
|
+
type validateInferredAst<inferred, def extends string> = def extends NumberLiteral ? number extends inferred ? ErrorMessage<writeMalformedNumericLiteralMessage<def, "number">> : undefined : def extends BigintLiteral ? bigint extends inferred ? ErrorMessage<writeMalformedNumericLiteralMessage<def, "bigint">> : undefined : [inferred] extends [anyOrNever] ? undefined : def extends PrivateDeclaration<infer name> ? ErrorMessage<writePrefixedPrivateReferenceMessage<name>> : inferred extends Generic ? ErrorMessage<writeInvalidGenericArgCountMessage<def, inferred["names"], []>> : inferred extends {
|
|
22
|
+
[arkKind]: "module";
|
|
23
|
+
} ? "root" extends keyof inferred ? undefined : ErrorMessage<writeMissingSubmoduleAccessMessage<def>> : def extends ErrorMessage ? def : undefined;
|
|
24
|
+
export type validateString<def extends string, $, args> = parseString<def, $, args> extends infer ast ? validateAst<ast, $, args> extends infer result extends ErrorMessage ? result extends Completion<infer text> ? text : result : def : never;
|
|
25
|
+
type validateInfix<ast extends InfixExpression, $, args> = validateAst<ast[0], $, args> extends infer e extends ErrorMessage ? e : validateAst<ast[2], $, args> extends infer e extends ErrorMessage ? e : undefined;
|
|
26
|
+
export declare const shallowOptionalMessage = "Optional definitions like 'string?' are only valid as properties in an object or tuple";
|
|
27
|
+
export type shallowOptionalMessage = typeof shallowOptionalMessage;
|
|
28
|
+
export declare const shallowDefaultableMessage = "Defaultable definitions like 'number = 0' are only valid as properties in an object or tuple";
|
|
29
|
+
export type shallowDefaultableMessage = typeof shallowDefaultableMessage;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export const writePrefixedPrivateReferenceMessage = (name) => `Private type references should not include '#'. Use '${name}' instead.`;
|
|
2
|
+
export const shallowOptionalMessage = "Optional definitions like 'string?' are only valid as properties in an object or tuple";
|
|
3
|
+
export const shallowDefaultableMessage = "Defaultable definitions like 'number = 0' are only valid as properties in an object or tuple";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type BaseParseContext, type BaseRoot, type StandardSchemaV1 } from "@ark/schema";
|
|
2
|
+
import { type anyOrNever, type array, type ErrorMessage, type Fn, type ifEmptyObjectLiteral, type objectKindOrDomainOf, type Primitive } from "@ark/util";
|
|
3
|
+
import type { Out } from "../attributes.ts";
|
|
4
|
+
import type { type } from "../keywords/keywords.ts";
|
|
5
|
+
import type { InnerParseResult } from "../scope.ts";
|
|
6
|
+
import type { shallowDefaultableMessage, shallowOptionalMessage, validateString } from "./ast/validate.ts";
|
|
7
|
+
import { type inferObjectLiteral, type validateObjectLiteral } from "./objectLiteral.ts";
|
|
8
|
+
import type { isDefaultable, OptionalPropertyDefinition } from "./property.ts";
|
|
9
|
+
import { type BaseCompletions, type inferString } from "./string.ts";
|
|
10
|
+
import { type inferTupleExpression, type maybeValidateTupleExpression, type TupleExpression } from "./tupleExpressions.ts";
|
|
11
|
+
import { type inferTupleLiteral, type validateTupleLiteral } from "./tupleLiteral.ts";
|
|
12
|
+
export declare const parseInnerDefinition: (def: unknown, ctx: BaseParseContext) => InnerParseResult;
|
|
13
|
+
export declare const parseObject: (def: object, ctx: BaseParseContext) => BaseRoot;
|
|
14
|
+
export type inferDefinition<def, $, args> = [
|
|
15
|
+
def
|
|
16
|
+
] extends [anyOrNever] ? def : def extends type.cast<infer t> ? ifEmptyObjectLiteral<def, object, t> : def extends ThunkCast<infer t> ? t : def extends string ? inferString<def, $, args> : def extends array ? inferTuple<def, $, args> : def extends RegExp ? string : def extends StandardSchemaV1 ? inferStandardSchema<def> : def extends object ? inferObjectLiteral<def, $, args> : never;
|
|
17
|
+
type inferStandardSchema<schema extends StandardSchemaV1, i = StandardSchemaV1.InferInput<schema>, o = StandardSchemaV1.InferOutput<schema>> = [i, o] extends [o, i] ? i : (In: i) => Out<o>;
|
|
18
|
+
export type validateDefinition<def, $, args> = null extends undefined ? ErrorMessage<`'strict' or 'strictNullChecks' must be set to true in your tsconfig's 'compilerOptions'`> : [def] extends [anyOrNever] ? def : def extends OptionalPropertyDefinition ? ErrorMessage<shallowOptionalMessage> : isDefaultable<def, $, args> extends true ? ErrorMessage<shallowDefaultableMessage> : validateInnerDefinition<def, $, args>;
|
|
19
|
+
export type validateInnerDefinition<def, $, args> = [
|
|
20
|
+
def
|
|
21
|
+
] extends [TerminalObjectDefinition] ? def : def extends string ? validateString<def, $, args> : unknown extends def ? BaseCompletions<$, args> | {} : def extends readonly unknown[] ? validateTuple<def, $, args> : def extends BadDefinitionType ? ErrorMessage<writeBadDefinitionTypeMessage<objectKindOrDomainOf<def>>> : validateObjectLiteral<def, $, args>;
|
|
22
|
+
export declare const parseTuple: (def: array, ctx: BaseParseContext) => BaseRoot;
|
|
23
|
+
export type validateTuple<def extends array, $, args> = maybeValidateTupleExpression<def, $, args> extends infer result ? result extends null ? validateTupleLiteral<def, $, args> : result : never;
|
|
24
|
+
export type inferTuple<def extends array, $, args> = def extends TupleExpression ? inferTupleExpression<def, $, args> : inferTupleLiteral<def, $, args>;
|
|
25
|
+
export type TerminalObjectDefinition = type.cast<unknown> | Fn | RegExp | StandardSchemaV1;
|
|
26
|
+
export type ThunkCast<t = unknown> = () => type.cast<t>;
|
|
27
|
+
type BadDefinitionType = Exclude<Primitive, string>;
|
|
28
|
+
export declare const writeBadDefinitionTypeMessage: <actual extends string>(actual: actual) => writeBadDefinitionTypeMessage<actual>;
|
|
29
|
+
type writeBadDefinitionTypeMessage<actual extends string> = `Type definitions must be strings or objects (was ${actual})`;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { hasArkKind } from "@ark/schema";
|
|
2
|
+
import { domainOf, hasDomain, isThunk, objectKindOf, printable, throwParseError, uncapitalize } from "@ark/util";
|
|
3
|
+
import { parseObjectLiteral } from "./objectLiteral.js";
|
|
4
|
+
import { parseString } from "./string.js";
|
|
5
|
+
import { maybeParseTupleExpression } from "./tupleExpressions.js";
|
|
6
|
+
import { parseTupleLiteral } from "./tupleLiteral.js";
|
|
7
|
+
const parseCache = {};
|
|
8
|
+
export const parseInnerDefinition = (def, ctx) => {
|
|
9
|
+
if (typeof def === "string") {
|
|
10
|
+
if (ctx.args && Object.keys(ctx.args).some(k => def.includes(k))) {
|
|
11
|
+
// we can only rely on the cache if there are no contextual
|
|
12
|
+
// resolutions like "this" or generic args
|
|
13
|
+
return parseString(def, ctx);
|
|
14
|
+
}
|
|
15
|
+
const scopeCache = (parseCache[ctx.$.name] ??= {});
|
|
16
|
+
return (scopeCache[def] ??= parseString(def, ctx));
|
|
17
|
+
}
|
|
18
|
+
return hasDomain(def, "object") ?
|
|
19
|
+
parseObject(def, ctx)
|
|
20
|
+
: throwParseError(writeBadDefinitionTypeMessage(domainOf(def)));
|
|
21
|
+
};
|
|
22
|
+
export const parseObject = (def, ctx) => {
|
|
23
|
+
const objectKind = objectKindOf(def);
|
|
24
|
+
switch (objectKind) {
|
|
25
|
+
case undefined:
|
|
26
|
+
if (hasArkKind(def, "root"))
|
|
27
|
+
return def;
|
|
28
|
+
if ("~standard" in def)
|
|
29
|
+
return parseStandardSchema(def, ctx);
|
|
30
|
+
return parseObjectLiteral(def, ctx);
|
|
31
|
+
case "Array":
|
|
32
|
+
return parseTuple(def, ctx);
|
|
33
|
+
case "RegExp":
|
|
34
|
+
return ctx.$.node("intersection", {
|
|
35
|
+
domain: "string",
|
|
36
|
+
pattern: def
|
|
37
|
+
}, { prereduced: true });
|
|
38
|
+
case "Function": {
|
|
39
|
+
const resolvedDef = isThunk(def) ? def() : def;
|
|
40
|
+
if (hasArkKind(resolvedDef, "root"))
|
|
41
|
+
return resolvedDef;
|
|
42
|
+
return throwParseError(writeBadDefinitionTypeMessage("Function"));
|
|
43
|
+
}
|
|
44
|
+
default:
|
|
45
|
+
return throwParseError(writeBadDefinitionTypeMessage(objectKind ?? printable(def)));
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const parseStandardSchema = (def, ctx) => ctx.$.intrinsic.unknown.pipe((v, ctx) => {
|
|
49
|
+
const result = def["~standard"].validate(v);
|
|
50
|
+
if (!result.issues)
|
|
51
|
+
return result.value;
|
|
52
|
+
for (const { message, path } of result.issues) {
|
|
53
|
+
if (path) {
|
|
54
|
+
if (path.length) {
|
|
55
|
+
ctx.error({
|
|
56
|
+
problem: uncapitalize(message),
|
|
57
|
+
relativePath: path.map(k => (typeof k === "object" ? k.key : k))
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
ctx.error({
|
|
62
|
+
message
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
ctx.error({
|
|
68
|
+
message
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
export const parseTuple = (def, ctx) => maybeParseTupleExpression(def, ctx) ?? parseTupleLiteral(def, ctx);
|
|
74
|
+
export const writeBadDefinitionTypeMessage = (actual) => `Type definitions must be strings or objects (was ${actual})`;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type BaseParseContext, type BaseRoot, type writeInvalidPropertyKeyMessage } from "@ark/schema";
|
|
2
|
+
import { Backslash, type anyOrNever, type Dict, type ErrorMessage, type ErrorType, type Key, type merge, type show } from "@ark/util";
|
|
3
|
+
import type { validateString } from "./ast/validate.ts";
|
|
4
|
+
import type { inferDefinition } from "./definition.ts";
|
|
5
|
+
import { type OptionalPropertyDefinition, type validateProperty } from "./property.ts";
|
|
6
|
+
export declare const parseObjectLiteral: (def: Dict, ctx: BaseParseContext) => BaseRoot;
|
|
7
|
+
export type inferObjectLiteral<def extends object, $, args> = show<"..." extends keyof def ? merge<inferDefinition<def["..."], $, args>, _inferObjectLiteral<def, $, args>> : _inferObjectLiteral<def, $, args>>;
|
|
8
|
+
/**
|
|
9
|
+
* Infers the contents of an object literal, ignoring a spread definition
|
|
10
|
+
*/
|
|
11
|
+
type _inferObjectLiteral<def extends object, $, args> = {
|
|
12
|
+
-readonly [k in keyof def as nonOptionalKeyFromEntry<k, def[k], $, args>]: inferDefinition<def[k], $, args>;
|
|
13
|
+
} & {
|
|
14
|
+
-readonly [k in keyof def as optionalKeyFromEntry<k, def[k]>]?: def[k] extends OptionalPropertyDefinition<infer baseDef> ? inferDefinition<baseDef, $, args> : inferDefinition<def[k], $, args>;
|
|
15
|
+
};
|
|
16
|
+
export type validateObjectLiteral<def, $, args> = {
|
|
17
|
+
[k in keyof def]: preparseKey<k> extends (infer parsedKey extends PreparsedKey) ? parsedKey extends PreparsedEntryKey<"index"> ? validateString<parsedKey["normalized"], $, args> extends (ErrorMessage<infer message>) ? ErrorType<message> : inferDefinition<parsedKey["normalized"], $, args> extends Key ? validateProperty<def[k], parsedKey["kind"], $, args> : ErrorMessage<writeInvalidPropertyKeyMessage<parsedKey["normalized"]>> : validateProperty<def[k], parsedKey["kind"], $, args> : never;
|
|
18
|
+
};
|
|
19
|
+
type nonOptionalKeyFromEntry<k extends PropertyKey, v, $, args> = preparseKey<k> extends infer parsedKey ? parsedKey extends PreparsedEntryKey<"required"> ? [
|
|
20
|
+
v
|
|
21
|
+
] extends [OptionalPropertyDefinition] ? [
|
|
22
|
+
v
|
|
23
|
+
] extends [anyOrNever] ? parsedKey["normalized"] : never : parsedKey["normalized"] : parsedKey extends PreparsedEntryKey<"index"> ? inferDefinition<parsedKey["normalized"], $, args> & Key : never : never;
|
|
24
|
+
type optionalKeyFromEntry<k extends PropertyKey, v> = preparseKey<k> extends infer parsedKey ? parsedKey extends PreparsedEntryKey<"optional"> ? parsedKey["normalized"] : v extends OptionalPropertyDefinition ? k : never : never;
|
|
25
|
+
export declare const writeInvalidUndeclaredBehaviorMessage: (actual: unknown) => string;
|
|
26
|
+
export declare const nonLeadingSpreadError = "Spread operator may only be used as the first key in an object";
|
|
27
|
+
export type PreparsedKey = PreparsedEntryKey | PreparsedSpecialKey;
|
|
28
|
+
type normalizedKeyKind<kind extends EntryKeyKind> = kind extends "index" ? string : Key;
|
|
29
|
+
export type PreparsedEntryKey<kind extends EntryKeyKind = EntryKeyKind, normalized extends normalizedKeyKind<kind> = normalizedKeyKind<kind>> = {
|
|
30
|
+
kind: kind;
|
|
31
|
+
normalized: normalized;
|
|
32
|
+
};
|
|
33
|
+
export type PreparsedSpecialKey<kind extends SpecialKeyKind = SpecialKeyKind> = {
|
|
34
|
+
kind: kind;
|
|
35
|
+
};
|
|
36
|
+
declare namespace PreparsedKey {
|
|
37
|
+
type from<t extends PreparsedKey> = t;
|
|
38
|
+
}
|
|
39
|
+
export type ParsedKeyKind = EntryKeyKind | SpecialKeyKind;
|
|
40
|
+
export type EntryKeyKind = "required" | "optional" | "index";
|
|
41
|
+
export type SpecialKeyKind = "spread" | "undeclared";
|
|
42
|
+
export type MetaKey = "..." | "+";
|
|
43
|
+
export type IndexKey<def extends string = string> = `[${def}]`;
|
|
44
|
+
export declare const preparseKey: (key: Key) => PreparsedKey;
|
|
45
|
+
export type preparseKey<k> = k extends symbol ? PreparsedKey.from<{
|
|
46
|
+
kind: "required";
|
|
47
|
+
normalized: k;
|
|
48
|
+
}> : k extends `${infer inner}?` ? inner extends `${infer baseName}${Backslash}` ? PreparsedKey.from<{
|
|
49
|
+
kind: "required";
|
|
50
|
+
normalized: `${baseName}?`;
|
|
51
|
+
}> : PreparsedKey.from<{
|
|
52
|
+
kind: "optional";
|
|
53
|
+
normalized: inner;
|
|
54
|
+
}> : k extends "+" ? {
|
|
55
|
+
kind: "undeclared";
|
|
56
|
+
} : k extends "..." ? {
|
|
57
|
+
kind: "spread";
|
|
58
|
+
} : k extends `${Backslash}${infer escapedMeta extends MetaKey}` ? PreparsedKey.from<{
|
|
59
|
+
kind: "required";
|
|
60
|
+
normalized: escapedMeta;
|
|
61
|
+
}> : k extends IndexKey<infer def> ? PreparsedKey.from<{
|
|
62
|
+
kind: "index";
|
|
63
|
+
normalized: def;
|
|
64
|
+
}> : PreparsedKey.from<{
|
|
65
|
+
kind: "required";
|
|
66
|
+
normalized: k extends (`${Backslash}${infer escapedIndexKey extends IndexKey}`) ? escapedIndexKey : k extends Key ? k : `${k & number}`;
|
|
67
|
+
}>;
|
|
68
|
+
export declare const writeInvalidSpreadTypeMessage: <def extends string>(def: def) => writeInvalidSpreadTypeMessage<def>;
|
|
69
|
+
export type writeInvalidSpreadTypeMessage<def extends string> = `Spread operand must resolve to an object literal type (was ${def})`;
|
|
70
|
+
export {};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { intrinsic, normalizeIndex } from "@ark/schema";
|
|
2
|
+
import { append, Backslash, isArray, isEmptyObject, printable, stringAndSymbolicEntriesOf, throwParseError } from "@ark/util";
|
|
3
|
+
import { invalidDefaultableKeyKindMessage, invalidOptionalKeyKindMessage, parseProperty } from "./property.js";
|
|
4
|
+
export const parseObjectLiteral = (def, ctx) => {
|
|
5
|
+
let spread;
|
|
6
|
+
const structure = {};
|
|
7
|
+
// We only allow a spread operator to be used as the first key in an object
|
|
8
|
+
// because to match JS behavior any keys before the spread are overwritten
|
|
9
|
+
// by the values in the target object, so there'd be no useful purpose in having it
|
|
10
|
+
// anywhere except for the beginning.
|
|
11
|
+
const defEntries = stringAndSymbolicEntriesOf(def);
|
|
12
|
+
for (const [k, v] of defEntries) {
|
|
13
|
+
const parsedKey = preparseKey(k);
|
|
14
|
+
if (parsedKey.kind === "spread") {
|
|
15
|
+
if (!isEmptyObject(structure))
|
|
16
|
+
return throwParseError(nonLeadingSpreadError);
|
|
17
|
+
const operand = ctx.$.parseOwnDefinitionFormat(v, ctx);
|
|
18
|
+
// treat object domain as empty for spreading (useful for generic constraints)
|
|
19
|
+
if (operand.equals(intrinsic.object))
|
|
20
|
+
continue;
|
|
21
|
+
if (!operand.hasKind("intersection") ||
|
|
22
|
+
// still error on attempts to spread proto nodes like ...Date
|
|
23
|
+
!operand.basis?.equals(intrinsic.object)) {
|
|
24
|
+
return throwParseError(writeInvalidSpreadTypeMessage(operand.expression));
|
|
25
|
+
}
|
|
26
|
+
spread = operand.structure;
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (parsedKey.kind === "undeclared") {
|
|
30
|
+
if (v !== "reject" && v !== "delete" && v !== "ignore")
|
|
31
|
+
throwParseError(writeInvalidUndeclaredBehaviorMessage(v));
|
|
32
|
+
structure.undeclared = v;
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const parsedValue = parseProperty(v, ctx);
|
|
36
|
+
const parsedEntryKey = parsedKey;
|
|
37
|
+
if (parsedKey.kind === "required") {
|
|
38
|
+
if (!isArray(parsedValue)) {
|
|
39
|
+
appendNamedProp(structure, "required", {
|
|
40
|
+
key: parsedKey.normalized,
|
|
41
|
+
value: parsedValue
|
|
42
|
+
}, ctx);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
appendNamedProp(structure, "optional", parsedValue[1] === "=" ?
|
|
46
|
+
{
|
|
47
|
+
key: parsedKey.normalized,
|
|
48
|
+
value: parsedValue[0],
|
|
49
|
+
default: parsedValue[2]
|
|
50
|
+
}
|
|
51
|
+
: {
|
|
52
|
+
key: parsedKey.normalized,
|
|
53
|
+
value: parsedValue[0]
|
|
54
|
+
}, ctx);
|
|
55
|
+
}
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (isArray(parsedValue)) {
|
|
59
|
+
if (parsedValue[1] === "?")
|
|
60
|
+
throwParseError(invalidOptionalKeyKindMessage);
|
|
61
|
+
if (parsedValue[1] === "=")
|
|
62
|
+
throwParseError(invalidDefaultableKeyKindMessage);
|
|
63
|
+
}
|
|
64
|
+
// value must be a BaseRoot at this point
|
|
65
|
+
if (parsedKey.kind === "optional") {
|
|
66
|
+
appendNamedProp(structure, "optional", {
|
|
67
|
+
key: parsedKey.normalized,
|
|
68
|
+
value: parsedValue
|
|
69
|
+
}, ctx);
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
// must be index at this point
|
|
73
|
+
const signature = ctx.$.parseOwnDefinitionFormat(parsedEntryKey.normalized, ctx);
|
|
74
|
+
const normalized = normalizeIndex(signature, parsedValue, ctx.$);
|
|
75
|
+
if (normalized.index)
|
|
76
|
+
structure.index = append(structure.index, normalized.index);
|
|
77
|
+
if (normalized.required)
|
|
78
|
+
structure.required = append(structure.required, normalized.required);
|
|
79
|
+
}
|
|
80
|
+
const structureNode = ctx.$.node("structure", structure);
|
|
81
|
+
return ctx.$.parseSchema({
|
|
82
|
+
domain: "object",
|
|
83
|
+
structure: spread?.merge(structureNode) ?? structureNode
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
const appendNamedProp = (structure, kind, inner, ctx) => {
|
|
87
|
+
structure[kind] = append(
|
|
88
|
+
// doesn't seem like this cast should be necessary
|
|
89
|
+
structure[kind], ctx.$.node(kind, inner));
|
|
90
|
+
};
|
|
91
|
+
export const writeInvalidUndeclaredBehaviorMessage = (actual) => `Value of '+' key must be 'reject', 'delete', or 'ignore' (was ${printable(actual)})`;
|
|
92
|
+
export const nonLeadingSpreadError = "Spread operator may only be used as the first key in an object";
|
|
93
|
+
export const preparseKey = (key) => typeof key === "symbol" ? { kind: "required", normalized: key }
|
|
94
|
+
: key[key.length - 1] === "?" ?
|
|
95
|
+
key[key.length - 2] === Backslash ?
|
|
96
|
+
{ kind: "required", normalized: `${key.slice(0, -2)}?` }
|
|
97
|
+
: {
|
|
98
|
+
kind: "optional",
|
|
99
|
+
normalized: key.slice(0, -1)
|
|
100
|
+
}
|
|
101
|
+
: key[0] === "[" && key[key.length - 1] === "]" ?
|
|
102
|
+
{ kind: "index", normalized: key.slice(1, -1) }
|
|
103
|
+
: key[0] === Backslash && key[1] === "[" && key[key.length - 1] === "]" ?
|
|
104
|
+
{ kind: "required", normalized: key.slice(1) }
|
|
105
|
+
: key === "..." ? { kind: "spread" }
|
|
106
|
+
: key === "+" ? { kind: "undeclared" }
|
|
107
|
+
: {
|
|
108
|
+
kind: "required",
|
|
109
|
+
normalized: key === "\\..." ? "..."
|
|
110
|
+
: key === "\\+" ? "+"
|
|
111
|
+
: key
|
|
112
|
+
};
|
|
113
|
+
export const writeInvalidSpreadTypeMessage = (def) => `Spread operand must resolve to an object literal type (was ${def})`;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { BaseParseContext, BaseRoot, UndeclaredKeyBehavior } from "@ark/schema";
|
|
2
|
+
import { type anyOrNever, type ErrorMessage, type ErrorType, type typeToString } from "@ark/util";
|
|
3
|
+
import { type inferDefinition, type validateInnerDefinition } from "./definition.ts";
|
|
4
|
+
import type { ParsedKeyKind, writeInvalidSpreadTypeMessage } from "./objectLiteral.ts";
|
|
5
|
+
import type { ParsedDefaultableProperty } from "./shift/operator/default.ts";
|
|
6
|
+
import type { parseString } from "./string.ts";
|
|
7
|
+
export type ParsedPropertyKind = "plain" | "optional" | "defaultable";
|
|
8
|
+
export type ParsedProperty = ParsedRequiredProperty | ParsedOptionalProperty | ParsedDefaultableProperty;
|
|
9
|
+
export type ParsedRequiredProperty = BaseRoot;
|
|
10
|
+
export type ParsedOptionalProperty = readonly [BaseRoot, "?"];
|
|
11
|
+
export declare const parseProperty: (def: unknown, ctx: BaseParseContext) => ParsedProperty;
|
|
12
|
+
export type validateProperty<def, keyKind extends ParsedKeyKind, $, args> = [
|
|
13
|
+
def
|
|
14
|
+
] extends [anyOrNever] ?
|
|
15
|
+
/** this extra [anyOrNever] check is required to ensure that nested `type` invocations
|
|
16
|
+
* like the following are not prematurely validated by the outer call:
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* type({
|
|
20
|
+
* "test?": type("string").pipe(x => x === "true")
|
|
21
|
+
* })
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
def : keyKind extends "spread" ? def extends validateInnerDefinition<def, $, args> ? inferDefinition<def, $, args> extends object ? def : ErrorType<writeInvalidSpreadTypeMessage<typeToString<inferDefinition<def, $, args>>>> : validateInnerDefinition<def, $, args> : keyKind extends "undeclared" ? UndeclaredKeyBehavior : keyKind extends "required" ? validateInnerDefinition<def, $, args> : def extends OptionalPropertyDefinition ? ErrorMessage<invalidOptionalKeyKindMessage> : isDefaultable<def, $, args> extends true ? ErrorMessage<invalidDefaultableKeyKindMessage> : validateInnerDefinition<def, $, args>;
|
|
25
|
+
export type isDefaultable<def, $, args> = def extends DefaultablePropertyTuple ? true : def extends PossibleDefaultableStringDefinition ? parseString<def, $, args> extends DefaultablePropertyTuple ? true : false : false;
|
|
26
|
+
export type OptionalPropertyDefinition<baseDef = unknown> = OptionalPropertyTuple<baseDef> | OptionalPropertyString<baseDef & string>;
|
|
27
|
+
export type OptionalPropertyString<baseDef extends string = string> = `${baseDef}?`;
|
|
28
|
+
export type OptionalPropertyTuple<baseDef = unknown> = readonly [baseDef, "?"];
|
|
29
|
+
export type PossibleDefaultableStringDefinition = `${string}=${string}`;
|
|
30
|
+
export type DefaultablePropertyTuple<baseDef = unknown, thunkableProperty = unknown> = readonly [baseDef, "=", thunkableProperty];
|
|
31
|
+
export declare const invalidOptionalKeyKindMessage = "Only required keys may make their values optional, e.g. { [mySymbol]: ['number', '?'] }";
|
|
32
|
+
export type invalidOptionalKeyKindMessage = typeof invalidOptionalKeyKindMessage;
|
|
33
|
+
export declare const invalidDefaultableKeyKindMessage = "Only required keys may specify default values, e.g. { value: 'number = 0' }";
|
|
34
|
+
export type invalidDefaultableKeyKindMessage = typeof invalidDefaultableKeyKindMessage;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { isArray } from "@ark/util";
|
|
2
|
+
import { parseInnerDefinition } from "./definition.js";
|
|
3
|
+
export const parseProperty = (def, ctx) => {
|
|
4
|
+
if (isArray(def)) {
|
|
5
|
+
if (def[1] === "=")
|
|
6
|
+
return [ctx.$.parseOwnDefinitionFormat(def[0], ctx), "=", def[2]];
|
|
7
|
+
if (def[1] === "?")
|
|
8
|
+
return [ctx.$.parseOwnDefinitionFormat(def[0], ctx), "?"];
|
|
9
|
+
}
|
|
10
|
+
// string-embedded defaults/optionals are handled by the string parser
|
|
11
|
+
return parseInnerDefinition(def, ctx);
|
|
12
|
+
};
|
|
13
|
+
// single quote use here is better for TypeScript's inlined error to avoid escapes
|
|
14
|
+
export const invalidOptionalKeyKindMessage = `Only required keys may make their values optional, e.g. { [mySymbol]: ['number', '?'] }`;
|
|
15
|
+
// single quote use here is better for TypeScript's inlined error to avoid escapes
|
|
16
|
+
export const invalidDefaultableKeyKindMessage = `Only required keys may specify default values, e.g. { value: 'number = 0' }`;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { BaseParseContext, BaseRoot } from "@ark/schema";
|
|
2
|
+
import { type requireKeys, type Scanner } from "@ark/util";
|
|
3
|
+
import type { LimitLiteral } from "../../attributes.ts";
|
|
4
|
+
import type { FinalizingLookahead, InfixToken } from "../shift/tokens.ts";
|
|
5
|
+
import { type BranchOperator, type Comparator, type MinComparator, type OpenLeftBound, type StringifiablePrefixOperator } from "./shared.ts";
|
|
6
|
+
type BranchState = {
|
|
7
|
+
prefixes: StringifiablePrefixOperator[];
|
|
8
|
+
leftBound: OpenLeftBound | null;
|
|
9
|
+
intersection: BaseRoot | null;
|
|
10
|
+
union: BaseRoot | null;
|
|
11
|
+
pipe: BaseRoot | null;
|
|
12
|
+
};
|
|
13
|
+
export type RootedRuntimeState = requireKeys<RuntimeState, "root">;
|
|
14
|
+
export declare class RuntimeState {
|
|
15
|
+
root: BaseRoot | undefined;
|
|
16
|
+
branches: BranchState;
|
|
17
|
+
finalizer: FinalizingLookahead | undefined;
|
|
18
|
+
groups: BranchState[];
|
|
19
|
+
scanner: Scanner;
|
|
20
|
+
ctx: BaseParseContext;
|
|
21
|
+
constructor(scanner: Scanner, ctx: BaseParseContext);
|
|
22
|
+
error(message: string): never;
|
|
23
|
+
hasRoot(): this is RootedRuntimeState;
|
|
24
|
+
setRoot(root: BaseRoot): void;
|
|
25
|
+
unsetRoot(): this["root"];
|
|
26
|
+
constrainRoot(...args: Parameters<BaseRoot<any>["constrain"]>): void;
|
|
27
|
+
finalize(finalizer: FinalizingLookahead): void;
|
|
28
|
+
reduceLeftBound(limit: LimitLiteral, comparator: Comparator): void;
|
|
29
|
+
finalizeBranches(): void;
|
|
30
|
+
finalizeGroup(): void;
|
|
31
|
+
addPrefix(prefix: StringifiablePrefixOperator): void;
|
|
32
|
+
applyPrefixes(): void;
|
|
33
|
+
pushRootToBranch(token: BranchOperator): void;
|
|
34
|
+
parseUntilFinalizer(): RootedRuntimeState;
|
|
35
|
+
parseOperator(this: RootedRuntimeState): void;
|
|
36
|
+
parseOperand(): void;
|
|
37
|
+
private assertRangeUnset;
|
|
38
|
+
reduceGroupOpen(): void;
|
|
39
|
+
previousOperator(): MinComparator | StringifiablePrefixOperator | InfixToken | undefined;
|
|
40
|
+
shiftedBy(count: number): this;
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { isKeyOf, throwInternalError, throwParseError, writeUnclosedGroupMessage, writeUnmatchedGroupCloseMessage } from "@ark/util";
|
|
2
|
+
import { parseOperand } from "../shift/operand/operand.js";
|
|
3
|
+
import { parseOperator } from "../shift/operator/operator.js";
|
|
4
|
+
import { parseUntilFinalizer } from "../string.js";
|
|
5
|
+
import { invertedComparators, minComparators, writeMultipleLeftBoundsMessage, writeOpenRangeMessage, writeUnpairableComparatorMessage } from "./shared.js";
|
|
6
|
+
export class RuntimeState {
|
|
7
|
+
root;
|
|
8
|
+
branches = {
|
|
9
|
+
prefixes: [],
|
|
10
|
+
leftBound: null,
|
|
11
|
+
intersection: null,
|
|
12
|
+
union: null,
|
|
13
|
+
pipe: null
|
|
14
|
+
};
|
|
15
|
+
finalizer;
|
|
16
|
+
groups = [];
|
|
17
|
+
scanner;
|
|
18
|
+
ctx;
|
|
19
|
+
constructor(scanner, ctx) {
|
|
20
|
+
this.scanner = scanner;
|
|
21
|
+
this.ctx = ctx;
|
|
22
|
+
}
|
|
23
|
+
error(message) {
|
|
24
|
+
return throwParseError(message);
|
|
25
|
+
}
|
|
26
|
+
hasRoot() {
|
|
27
|
+
return this.root !== undefined;
|
|
28
|
+
}
|
|
29
|
+
setRoot(root) {
|
|
30
|
+
this.root = root;
|
|
31
|
+
}
|
|
32
|
+
unsetRoot() {
|
|
33
|
+
const value = this.root;
|
|
34
|
+
this.root = undefined;
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
constrainRoot(...args) {
|
|
38
|
+
this.root = this.root.constrain(args[0], args[1]);
|
|
39
|
+
}
|
|
40
|
+
finalize(finalizer) {
|
|
41
|
+
if (this.groups.length)
|
|
42
|
+
return this.error(writeUnclosedGroupMessage(")"));
|
|
43
|
+
this.finalizeBranches();
|
|
44
|
+
this.finalizer = finalizer;
|
|
45
|
+
}
|
|
46
|
+
reduceLeftBound(limit, comparator) {
|
|
47
|
+
const invertedComparator = invertedComparators[comparator];
|
|
48
|
+
if (!isKeyOf(invertedComparator, minComparators))
|
|
49
|
+
return this.error(writeUnpairableComparatorMessage(comparator));
|
|
50
|
+
if (this.branches.leftBound) {
|
|
51
|
+
return this.error(writeMultipleLeftBoundsMessage(this.branches.leftBound.limit, this.branches.leftBound.comparator, limit, invertedComparator));
|
|
52
|
+
}
|
|
53
|
+
this.branches.leftBound = {
|
|
54
|
+
comparator: invertedComparator,
|
|
55
|
+
limit
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
finalizeBranches() {
|
|
59
|
+
this.assertRangeUnset();
|
|
60
|
+
if (this.branches.pipe) {
|
|
61
|
+
this.pushRootToBranch("|>");
|
|
62
|
+
this.root = this.branches.pipe;
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (this.branches.union) {
|
|
66
|
+
this.pushRootToBranch("|");
|
|
67
|
+
this.root = this.branches.union;
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (this.branches.intersection) {
|
|
71
|
+
this.pushRootToBranch("&");
|
|
72
|
+
this.root = this.branches.intersection;
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
this.applyPrefixes();
|
|
76
|
+
}
|
|
77
|
+
finalizeGroup() {
|
|
78
|
+
this.finalizeBranches();
|
|
79
|
+
const topBranchState = this.groups.pop();
|
|
80
|
+
if (!topBranchState) {
|
|
81
|
+
return this.error(writeUnmatchedGroupCloseMessage(")", this.scanner.unscanned));
|
|
82
|
+
}
|
|
83
|
+
this.branches = topBranchState;
|
|
84
|
+
}
|
|
85
|
+
addPrefix(prefix) {
|
|
86
|
+
this.branches.prefixes.push(prefix);
|
|
87
|
+
}
|
|
88
|
+
applyPrefixes() {
|
|
89
|
+
while (this.branches.prefixes.length) {
|
|
90
|
+
const lastPrefix = this.branches.prefixes.pop();
|
|
91
|
+
this.root =
|
|
92
|
+
lastPrefix === "keyof" ?
|
|
93
|
+
this.root.keyof()
|
|
94
|
+
: throwInternalError(`Unexpected prefix '${lastPrefix}'`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
pushRootToBranch(token) {
|
|
98
|
+
this.assertRangeUnset();
|
|
99
|
+
this.applyPrefixes();
|
|
100
|
+
const root = this.root;
|
|
101
|
+
this.root = undefined;
|
|
102
|
+
this.branches.intersection =
|
|
103
|
+
this.branches.intersection?.rawAnd(root) ?? root;
|
|
104
|
+
if (token === "&")
|
|
105
|
+
return;
|
|
106
|
+
this.branches.union =
|
|
107
|
+
this.branches.union?.rawOr(this.branches.intersection) ??
|
|
108
|
+
this.branches.intersection;
|
|
109
|
+
this.branches.intersection = null;
|
|
110
|
+
if (token === "|")
|
|
111
|
+
return;
|
|
112
|
+
this.branches.pipe =
|
|
113
|
+
this.branches.pipe?.rawPipeOnce(this.branches.union) ??
|
|
114
|
+
this.branches.union;
|
|
115
|
+
this.branches.union = null;
|
|
116
|
+
}
|
|
117
|
+
parseUntilFinalizer() {
|
|
118
|
+
return parseUntilFinalizer(new RuntimeState(this.scanner, this.ctx));
|
|
119
|
+
}
|
|
120
|
+
parseOperator() {
|
|
121
|
+
return parseOperator(this);
|
|
122
|
+
}
|
|
123
|
+
parseOperand() {
|
|
124
|
+
return parseOperand(this);
|
|
125
|
+
}
|
|
126
|
+
assertRangeUnset() {
|
|
127
|
+
if (this.branches.leftBound) {
|
|
128
|
+
return this.error(writeOpenRangeMessage(this.branches.leftBound.limit, this.branches.leftBound.comparator));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
reduceGroupOpen() {
|
|
132
|
+
this.groups.push(this.branches);
|
|
133
|
+
this.branches = {
|
|
134
|
+
prefixes: [],
|
|
135
|
+
leftBound: null,
|
|
136
|
+
union: null,
|
|
137
|
+
intersection: null,
|
|
138
|
+
pipe: null
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
previousOperator() {
|
|
142
|
+
return (this.branches.leftBound?.comparator ??
|
|
143
|
+
this.branches.prefixes[this.branches.prefixes.length - 1] ??
|
|
144
|
+
(this.branches.intersection ? "&"
|
|
145
|
+
: this.branches.union ? "|"
|
|
146
|
+
: this.branches.pipe ? "|>"
|
|
147
|
+
: undefined));
|
|
148
|
+
}
|
|
149
|
+
shiftedBy(count) {
|
|
150
|
+
this.scanner.jumpForward(count);
|
|
151
|
+
return this;
|
|
152
|
+
}
|
|
153
|
+
}
|