@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,747 @@
|
|
|
1
|
+
import { append, conflatenate, flatMorph, printable, spliterate, throwInternalError, throwParseError } from "@ark/util";
|
|
2
|
+
import { BaseConstraint, constraintKeyParser, flattenConstraints, intersectConstraints } from "../constraint.js";
|
|
3
|
+
import { intrinsic } from "../intrinsic.js";
|
|
4
|
+
import { typeOrTermExtends } from "../roots/root.js";
|
|
5
|
+
import { compileSerializedValue } from "../shared/compile.js";
|
|
6
|
+
import { Disjoint } from "../shared/disjoint.js";
|
|
7
|
+
import { implementNode } from "../shared/implement.js";
|
|
8
|
+
import { intersectNodesRoot } from "../shared/intersections.js";
|
|
9
|
+
import { $ark, registeredReference } from "../shared/registry.js";
|
|
10
|
+
import { ToJsonSchema } from "../shared/toJsonSchema.js";
|
|
11
|
+
import { traverseKey } from "../shared/traversal.js";
|
|
12
|
+
import { hasArkKind, isNode, makeRootAndArrayPropertiesMutable } from "../shared/utils.js";
|
|
13
|
+
import { Optional } from "./optional.js";
|
|
14
|
+
const createStructuralWriter = (childStringProp) => (node) => {
|
|
15
|
+
if (node.props.length || node.index) {
|
|
16
|
+
const parts = node.index?.map(index => index[childStringProp]) ?? [];
|
|
17
|
+
for (const prop of node.props)
|
|
18
|
+
parts.push(prop[childStringProp]);
|
|
19
|
+
if (node.undeclared)
|
|
20
|
+
parts.push(`+ (undeclared): ${node.undeclared}`);
|
|
21
|
+
const objectLiteralDescription = `{ ${parts.join(", ")} }`;
|
|
22
|
+
return node.sequence ?
|
|
23
|
+
`${objectLiteralDescription} & ${node.sequence.description}`
|
|
24
|
+
: objectLiteralDescription;
|
|
25
|
+
}
|
|
26
|
+
return node.sequence?.description ?? "{}";
|
|
27
|
+
};
|
|
28
|
+
const structuralDescription = createStructuralWriter("description");
|
|
29
|
+
const structuralExpression = createStructuralWriter("expression");
|
|
30
|
+
const intersectPropsAndIndex = (l, r, $) => {
|
|
31
|
+
const kind = l.required ? "required" : "optional";
|
|
32
|
+
if (!r.signature.allows(l.key))
|
|
33
|
+
return null;
|
|
34
|
+
const value = intersectNodesRoot(l.value, r.value, $);
|
|
35
|
+
if (value instanceof Disjoint) {
|
|
36
|
+
return kind === "optional" ?
|
|
37
|
+
$.node("optional", {
|
|
38
|
+
key: l.key,
|
|
39
|
+
value: $ark.intrinsic.never.internal
|
|
40
|
+
})
|
|
41
|
+
: value.withPrefixKey(l.key, l.kind);
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
};
|
|
45
|
+
const implementation = implementNode({
|
|
46
|
+
kind: "structure",
|
|
47
|
+
hasAssociatedError: false,
|
|
48
|
+
normalize: schema => schema,
|
|
49
|
+
applyConfig: (schema, config) => {
|
|
50
|
+
if (!schema.undeclared && config.onUndeclaredKey !== "ignore") {
|
|
51
|
+
return {
|
|
52
|
+
...schema,
|
|
53
|
+
undeclared: config.onUndeclaredKey
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return schema;
|
|
57
|
+
},
|
|
58
|
+
keys: {
|
|
59
|
+
required: {
|
|
60
|
+
child: true,
|
|
61
|
+
parse: constraintKeyParser("required"),
|
|
62
|
+
reduceIo: (ioKind, inner, nodes) => {
|
|
63
|
+
// ensure we don't overwrite nodes added by optional
|
|
64
|
+
inner.required = append(inner.required, nodes.map(node => (ioKind === "in" ? node.rawIn : node.rawOut)));
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
optional: {
|
|
69
|
+
child: true,
|
|
70
|
+
parse: constraintKeyParser("optional"),
|
|
71
|
+
reduceIo: (ioKind, inner, nodes) => {
|
|
72
|
+
if (ioKind === "in") {
|
|
73
|
+
inner.optional = nodes.map(node => node.rawIn);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
for (const node of nodes) {
|
|
77
|
+
inner[node.outProp.kind] = append(inner[node.outProp.kind], node.outProp.rawOut);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
index: {
|
|
82
|
+
child: true,
|
|
83
|
+
parse: constraintKeyParser("index")
|
|
84
|
+
},
|
|
85
|
+
sequence: {
|
|
86
|
+
child: true,
|
|
87
|
+
parse: constraintKeyParser("sequence")
|
|
88
|
+
},
|
|
89
|
+
undeclared: {
|
|
90
|
+
parse: behavior => (behavior === "ignore" ? undefined : behavior),
|
|
91
|
+
reduceIo: (ioKind, inner, value) => {
|
|
92
|
+
if (value === "reject") {
|
|
93
|
+
inner.undeclared = "reject";
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
// if base is "delete", undeclared keys are "ignore" (i.e. unconstrained)
|
|
97
|
+
// on input and "reject" on output
|
|
98
|
+
if (ioKind === "in")
|
|
99
|
+
delete inner.undeclared;
|
|
100
|
+
else
|
|
101
|
+
inner.undeclared = "reject";
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
defaults: {
|
|
106
|
+
description: structuralDescription
|
|
107
|
+
},
|
|
108
|
+
intersections: {
|
|
109
|
+
structure: (l, r, ctx) => {
|
|
110
|
+
const lInner = { ...l.inner };
|
|
111
|
+
const rInner = { ...r.inner };
|
|
112
|
+
const disjointResult = new Disjoint();
|
|
113
|
+
if (l.undeclared) {
|
|
114
|
+
const lKey = l.keyof();
|
|
115
|
+
for (const k of r.requiredKeys) {
|
|
116
|
+
if (!lKey.allows(k)) {
|
|
117
|
+
disjointResult.add("presence", $ark.intrinsic.never.internal, r.propsByKey[k].value, {
|
|
118
|
+
path: [k]
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (rInner.optional)
|
|
123
|
+
rInner.optional = rInner.optional.filter(n => lKey.allows(n.key));
|
|
124
|
+
if (rInner.index) {
|
|
125
|
+
rInner.index = rInner.index.flatMap(n => {
|
|
126
|
+
if (n.signature.extends(lKey))
|
|
127
|
+
return n;
|
|
128
|
+
const indexOverlap = intersectNodesRoot(lKey, n.signature, ctx.$);
|
|
129
|
+
if (indexOverlap instanceof Disjoint)
|
|
130
|
+
return [];
|
|
131
|
+
const normalized = normalizeIndex(indexOverlap, n.value, ctx.$);
|
|
132
|
+
if (normalized.required) {
|
|
133
|
+
rInner.required = conflatenate(rInner.required, normalized.required);
|
|
134
|
+
}
|
|
135
|
+
if (normalized.optional) {
|
|
136
|
+
rInner.optional = conflatenate(rInner.optional, normalized.optional);
|
|
137
|
+
}
|
|
138
|
+
return normalized.index ?? [];
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (r.undeclared) {
|
|
143
|
+
const rKey = r.keyof();
|
|
144
|
+
for (const k of l.requiredKeys) {
|
|
145
|
+
if (!rKey.allows(k)) {
|
|
146
|
+
disjointResult.add("presence", l.propsByKey[k].value, $ark.intrinsic.never.internal, {
|
|
147
|
+
path: [k]
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (lInner.optional)
|
|
152
|
+
lInner.optional = lInner.optional.filter(n => rKey.allows(n.key));
|
|
153
|
+
if (lInner.index) {
|
|
154
|
+
lInner.index = lInner.index.flatMap(n => {
|
|
155
|
+
if (n.signature.extends(rKey))
|
|
156
|
+
return n;
|
|
157
|
+
const indexOverlap = intersectNodesRoot(rKey, n.signature, ctx.$);
|
|
158
|
+
if (indexOverlap instanceof Disjoint)
|
|
159
|
+
return [];
|
|
160
|
+
const normalized = normalizeIndex(indexOverlap, n.value, ctx.$);
|
|
161
|
+
if (normalized.required) {
|
|
162
|
+
lInner.required = conflatenate(lInner.required, normalized.required);
|
|
163
|
+
}
|
|
164
|
+
if (normalized.optional) {
|
|
165
|
+
lInner.optional = conflatenate(lInner.optional, normalized.optional);
|
|
166
|
+
}
|
|
167
|
+
return normalized.index ?? [];
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
const baseInner = {};
|
|
172
|
+
if (l.undeclared || r.undeclared) {
|
|
173
|
+
baseInner.undeclared =
|
|
174
|
+
l.undeclared === "reject" || r.undeclared === "reject" ?
|
|
175
|
+
"reject"
|
|
176
|
+
: "delete";
|
|
177
|
+
}
|
|
178
|
+
const childIntersectionResult = intersectConstraints({
|
|
179
|
+
kind: "structure",
|
|
180
|
+
baseInner,
|
|
181
|
+
l: flattenConstraints(lInner),
|
|
182
|
+
r: flattenConstraints(rInner),
|
|
183
|
+
roots: [],
|
|
184
|
+
ctx
|
|
185
|
+
});
|
|
186
|
+
if (childIntersectionResult instanceof Disjoint)
|
|
187
|
+
disjointResult.push(...childIntersectionResult);
|
|
188
|
+
if (disjointResult.length)
|
|
189
|
+
return disjointResult;
|
|
190
|
+
return childIntersectionResult;
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
reduce: (inner, $) => {
|
|
194
|
+
if (!inner.required && !inner.optional)
|
|
195
|
+
return;
|
|
196
|
+
const seen = {};
|
|
197
|
+
let updated = false;
|
|
198
|
+
const newOptionalProps = inner.optional ? [...inner.optional] : [];
|
|
199
|
+
// check required keys for duplicates and handle index intersections
|
|
200
|
+
if (inner.required) {
|
|
201
|
+
for (let i = 0; i < inner.required.length; i++) {
|
|
202
|
+
const requiredProp = inner.required[i];
|
|
203
|
+
if (requiredProp.key in seen)
|
|
204
|
+
throwParseError(writeDuplicateKeyMessage(requiredProp.key));
|
|
205
|
+
seen[requiredProp.key] = true;
|
|
206
|
+
if (inner.index) {
|
|
207
|
+
for (const index of inner.index) {
|
|
208
|
+
const intersection = intersectPropsAndIndex(requiredProp, index, $);
|
|
209
|
+
if (intersection instanceof Disjoint)
|
|
210
|
+
return intersection;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
// check optional keys for duplicates and handle index intersections
|
|
216
|
+
if (inner.optional) {
|
|
217
|
+
for (let i = 0; i < inner.optional.length; i++) {
|
|
218
|
+
const optionalProp = inner.optional[i];
|
|
219
|
+
if (optionalProp.key in seen)
|
|
220
|
+
throwParseError(writeDuplicateKeyMessage(optionalProp.key));
|
|
221
|
+
seen[optionalProp.key] = true;
|
|
222
|
+
if (inner.index) {
|
|
223
|
+
for (const index of inner.index) {
|
|
224
|
+
const intersection = intersectPropsAndIndex(optionalProp, index, $);
|
|
225
|
+
if (intersection instanceof Disjoint)
|
|
226
|
+
return intersection;
|
|
227
|
+
if (intersection !== null) {
|
|
228
|
+
newOptionalProps[i] = intersection;
|
|
229
|
+
updated = true;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
if (updated) {
|
|
236
|
+
return $.node("structure", { ...inner, optional: newOptionalProps }, { prereduced: true });
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
export class StructureNode extends BaseConstraint {
|
|
241
|
+
impliedBasis = $ark.intrinsic.object.internal;
|
|
242
|
+
impliedSiblings = this.children.flatMap(n => n.impliedSiblings ?? []);
|
|
243
|
+
props = conflatenate(this.required, this.optional);
|
|
244
|
+
propsByKey = flatMorph(this.props, (i, node) => [node.key, node]);
|
|
245
|
+
propsByKeyReference = registeredReference(this.propsByKey);
|
|
246
|
+
expression = structuralExpression(this);
|
|
247
|
+
requiredKeys = this.required?.map(node => node.key) ?? [];
|
|
248
|
+
optionalKeys = this.optional?.map(node => node.key) ?? [];
|
|
249
|
+
literalKeys = [...this.requiredKeys, ...this.optionalKeys];
|
|
250
|
+
_keyof;
|
|
251
|
+
keyof() {
|
|
252
|
+
if (this._keyof)
|
|
253
|
+
return this._keyof;
|
|
254
|
+
let branches = this.$.units(this.literalKeys).branches;
|
|
255
|
+
if (this.index) {
|
|
256
|
+
for (const { signature } of this.index)
|
|
257
|
+
branches = branches.concat(signature.branches);
|
|
258
|
+
}
|
|
259
|
+
return (this._keyof = this.$.node("union", branches));
|
|
260
|
+
}
|
|
261
|
+
map(flatMapProp) {
|
|
262
|
+
return this.$.node("structure", this.props
|
|
263
|
+
.flatMap(flatMapProp)
|
|
264
|
+
.reduce((structureInner, mapped) => {
|
|
265
|
+
const originalProp = this.propsByKey[mapped.key];
|
|
266
|
+
if (isNode(mapped)) {
|
|
267
|
+
if (mapped.kind !== "required" && mapped.kind !== "optional") {
|
|
268
|
+
return throwParseError(`Map result must have kind "required" or "optional" (was ${mapped.kind})`);
|
|
269
|
+
}
|
|
270
|
+
structureInner[mapped.kind] = append(structureInner[mapped.kind], mapped);
|
|
271
|
+
return structureInner;
|
|
272
|
+
}
|
|
273
|
+
const mappedKind = mapped.kind ?? originalProp?.kind ?? "required";
|
|
274
|
+
// extract the inner keys from the map result in case a node was spread,
|
|
275
|
+
// which would otherwise lead to invalid keys
|
|
276
|
+
const mappedPropInner = flatMorph(mapped, (k, v) => (k in Optional.implementation.keys ? [k, v] : []));
|
|
277
|
+
structureInner[mappedKind] = append(structureInner[mappedKind], this.$.node(mappedKind, mappedPropInner));
|
|
278
|
+
return structureInner;
|
|
279
|
+
}, {}));
|
|
280
|
+
}
|
|
281
|
+
assertHasKeys(keys) {
|
|
282
|
+
const invalidKeys = keys.filter(k => !typeOrTermExtends(k, this.keyof()));
|
|
283
|
+
if (invalidKeys.length) {
|
|
284
|
+
return throwParseError(writeInvalidKeysMessage(this.expression, invalidKeys));
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
get(indexer, ...path) {
|
|
288
|
+
let value;
|
|
289
|
+
let required = false;
|
|
290
|
+
const key = indexerToKey(indexer);
|
|
291
|
+
if ((typeof key === "string" || typeof key === "symbol") &&
|
|
292
|
+
this.propsByKey[key]) {
|
|
293
|
+
value = this.propsByKey[key].value;
|
|
294
|
+
required = this.propsByKey[key].required;
|
|
295
|
+
}
|
|
296
|
+
if (this.index) {
|
|
297
|
+
for (const n of this.index) {
|
|
298
|
+
if (typeOrTermExtends(key, n.signature))
|
|
299
|
+
value = value?.and(n.value) ?? n.value;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
if (this.sequence &&
|
|
303
|
+
typeOrTermExtends(key, $ark.intrinsic.nonNegativeIntegerString)) {
|
|
304
|
+
if (hasArkKind(key, "root")) {
|
|
305
|
+
if (this.sequence.variadic)
|
|
306
|
+
// if there is a variadic element and we're accessing an index, return a union
|
|
307
|
+
// of all possible elements. If there is no variadic expression, we're in a tuple
|
|
308
|
+
// so this access wouldn't be safe based on the array indices
|
|
309
|
+
value = value?.and(this.sequence.element) ?? this.sequence.element;
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
const index = Number.parseInt(key);
|
|
313
|
+
if (index < this.sequence.prevariadic.length) {
|
|
314
|
+
const fixedElement = this.sequence.prevariadic[index].node;
|
|
315
|
+
value = value?.and(fixedElement) ?? fixedElement;
|
|
316
|
+
required ||= index < this.sequence.prefixLength;
|
|
317
|
+
}
|
|
318
|
+
else if (this.sequence.variadic) {
|
|
319
|
+
// ideally we could return something more specific for postfix
|
|
320
|
+
// but there is no way to represent it using an index alone
|
|
321
|
+
const nonFixedElement = this.$.node("union", this.sequence.variadicOrPostfix);
|
|
322
|
+
value = value?.and(nonFixedElement) ?? nonFixedElement;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
if (!value) {
|
|
327
|
+
if (this.sequence?.variadic &&
|
|
328
|
+
hasArkKind(key, "root") &&
|
|
329
|
+
key.extends($ark.intrinsic.number)) {
|
|
330
|
+
return throwParseError(writeNumberIndexMessage(key.expression, this.sequence.expression));
|
|
331
|
+
}
|
|
332
|
+
return throwParseError(writeInvalidKeysMessage(this.expression, [key]));
|
|
333
|
+
}
|
|
334
|
+
const result = value.get(...path);
|
|
335
|
+
return required ? result : result.or($ark.intrinsic.undefined);
|
|
336
|
+
}
|
|
337
|
+
pick(...keys) {
|
|
338
|
+
this.assertHasKeys(keys);
|
|
339
|
+
return this.$.node("structure", this.filterKeys("pick", keys));
|
|
340
|
+
}
|
|
341
|
+
omit(...keys) {
|
|
342
|
+
this.assertHasKeys(keys);
|
|
343
|
+
return this.$.node("structure", this.filterKeys("omit", keys));
|
|
344
|
+
}
|
|
345
|
+
optionalize() {
|
|
346
|
+
const { required, ...inner } = this.inner;
|
|
347
|
+
return this.$.node("structure", {
|
|
348
|
+
...inner,
|
|
349
|
+
optional: this.props.map(prop => prop.hasKind("required") ? this.$.node("optional", prop.inner) : prop)
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
require() {
|
|
353
|
+
const { optional, ...inner } = this.inner;
|
|
354
|
+
return this.$.node("structure", {
|
|
355
|
+
...inner,
|
|
356
|
+
required: this.props.map(prop => prop.hasKind("optional") ?
|
|
357
|
+
{
|
|
358
|
+
key: prop.key,
|
|
359
|
+
value: prop.value
|
|
360
|
+
}
|
|
361
|
+
: prop)
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
merge(r) {
|
|
365
|
+
const inner = this.filterKeys("omit", [r.keyof()]);
|
|
366
|
+
if (r.required)
|
|
367
|
+
inner.required = append(inner.required, r.required);
|
|
368
|
+
if (r.optional)
|
|
369
|
+
inner.optional = append(inner.optional, r.optional);
|
|
370
|
+
if (r.index)
|
|
371
|
+
inner.index = append(inner.index, r.index);
|
|
372
|
+
if (r.sequence)
|
|
373
|
+
inner.sequence = r.sequence;
|
|
374
|
+
if (r.undeclared)
|
|
375
|
+
inner.undeclared = r.undeclared;
|
|
376
|
+
else
|
|
377
|
+
delete inner.undeclared;
|
|
378
|
+
return this.$.node("structure", inner);
|
|
379
|
+
}
|
|
380
|
+
filterKeys(operation, keys) {
|
|
381
|
+
const result = makeRootAndArrayPropertiesMutable(this.inner);
|
|
382
|
+
const shouldKeep = (key) => {
|
|
383
|
+
const matchesKey = keys.some(k => typeOrTermExtends(key, k));
|
|
384
|
+
return operation === "pick" ? matchesKey : !matchesKey;
|
|
385
|
+
};
|
|
386
|
+
if (result.required)
|
|
387
|
+
result.required = result.required.filter(prop => shouldKeep(prop.key));
|
|
388
|
+
if (result.optional)
|
|
389
|
+
result.optional = result.optional.filter(prop => shouldKeep(prop.key));
|
|
390
|
+
if (result.index)
|
|
391
|
+
result.index = result.index.filter(index => shouldKeep(index.signature));
|
|
392
|
+
return result;
|
|
393
|
+
}
|
|
394
|
+
traverseAllows = (data, ctx) => this._traverse("Allows", data, ctx);
|
|
395
|
+
traverseApply = (data, ctx) => this._traverse("Apply", data, ctx);
|
|
396
|
+
_traverse = (traversalKind, data, ctx) => {
|
|
397
|
+
const errorCount = ctx?.currentErrorCount ?? 0;
|
|
398
|
+
for (let i = 0; i < this.props.length; i++) {
|
|
399
|
+
if (traversalKind === "Allows") {
|
|
400
|
+
if (!this.props[i].traverseAllows(data, ctx))
|
|
401
|
+
return false;
|
|
402
|
+
}
|
|
403
|
+
else {
|
|
404
|
+
this.props[i].traverseApply(data, ctx);
|
|
405
|
+
if (ctx.failFast && ctx.currentErrorCount > errorCount)
|
|
406
|
+
return false;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
if (this.sequence) {
|
|
410
|
+
if (traversalKind === "Allows") {
|
|
411
|
+
if (!this.sequence.traverseAllows(data, ctx))
|
|
412
|
+
return false;
|
|
413
|
+
}
|
|
414
|
+
else {
|
|
415
|
+
this.sequence.traverseApply(data, ctx);
|
|
416
|
+
if (ctx.failFast && ctx.currentErrorCount > errorCount)
|
|
417
|
+
return false;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
if (this.index || this.undeclared === "reject") {
|
|
421
|
+
const keys = Object.keys(data);
|
|
422
|
+
keys.push(...Object.getOwnPropertySymbols(data));
|
|
423
|
+
for (let i = 0; i < keys.length; i++) {
|
|
424
|
+
const k = keys[i];
|
|
425
|
+
if (this.index) {
|
|
426
|
+
for (const node of this.index) {
|
|
427
|
+
if (node.signature.traverseAllows(k, ctx)) {
|
|
428
|
+
if (traversalKind === "Allows") {
|
|
429
|
+
const result = traverseKey(k, () => node.value.traverseAllows(data[k], ctx), ctx);
|
|
430
|
+
if (!result)
|
|
431
|
+
return false;
|
|
432
|
+
}
|
|
433
|
+
else {
|
|
434
|
+
traverseKey(k, () => node.value.traverseApply(data[k], ctx), ctx);
|
|
435
|
+
if (ctx.failFast && ctx.currentErrorCount > errorCount)
|
|
436
|
+
return false;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
if (this.undeclared === "reject" && !this.declaresKey(k)) {
|
|
442
|
+
if (traversalKind === "Allows")
|
|
443
|
+
return false;
|
|
444
|
+
// this should have its own error code:
|
|
445
|
+
// https://github.com/arktypeio/arktype/issues/1403
|
|
446
|
+
ctx.errorFromNodeContext({
|
|
447
|
+
code: "predicate",
|
|
448
|
+
expected: "removed",
|
|
449
|
+
actual: "",
|
|
450
|
+
relativePath: [k],
|
|
451
|
+
meta: this.meta
|
|
452
|
+
});
|
|
453
|
+
if (ctx.failFast)
|
|
454
|
+
return false;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
// added additional ctx check here to address
|
|
459
|
+
// https://github.com/arktypeio/arktype/issues/1346
|
|
460
|
+
if (this.structuralMorph && ctx && !ctx.hasError())
|
|
461
|
+
ctx.queueMorphs([this.structuralMorph]);
|
|
462
|
+
return true;
|
|
463
|
+
};
|
|
464
|
+
get defaultable() {
|
|
465
|
+
return this.cacheGetter("defaultable", this.optional?.filter(o => o.hasDefault()) ?? []);
|
|
466
|
+
}
|
|
467
|
+
declaresKey = (k) => k in this.propsByKey ||
|
|
468
|
+
this.index?.some(n => n.signature.allows(k)) ||
|
|
469
|
+
(this.sequence !== undefined &&
|
|
470
|
+
$ark.intrinsic.nonNegativeIntegerString.allows(k));
|
|
471
|
+
_compileDeclaresKey(js) {
|
|
472
|
+
const parts = [];
|
|
473
|
+
if (this.props.length)
|
|
474
|
+
parts.push(`k in ${this.propsByKeyReference}`);
|
|
475
|
+
if (this.index) {
|
|
476
|
+
for (const index of this.index)
|
|
477
|
+
parts.push(js.invoke(index.signature, { kind: "Allows", arg: "k" }));
|
|
478
|
+
}
|
|
479
|
+
if (this.sequence)
|
|
480
|
+
parts.push("$ark.intrinsic.nonNegativeIntegerString.allows(k)");
|
|
481
|
+
// if parts is empty, this is a structure like { "+": "reject" }
|
|
482
|
+
// that declares no keys, so return false
|
|
483
|
+
return parts.join(" || ") || "false";
|
|
484
|
+
}
|
|
485
|
+
get structuralMorph() {
|
|
486
|
+
return this.cacheGetter("structuralMorph", getPossibleMorph(this));
|
|
487
|
+
}
|
|
488
|
+
structuralMorphRef = this.structuralMorph && registeredReference(this.structuralMorph);
|
|
489
|
+
compile(js) {
|
|
490
|
+
if (js.traversalKind === "Apply")
|
|
491
|
+
js.initializeErrorCount();
|
|
492
|
+
for (const prop of this.props) {
|
|
493
|
+
js.check(prop);
|
|
494
|
+
if (js.traversalKind === "Apply")
|
|
495
|
+
js.returnIfFailFast();
|
|
496
|
+
}
|
|
497
|
+
if (this.sequence) {
|
|
498
|
+
js.check(this.sequence);
|
|
499
|
+
if (js.traversalKind === "Apply")
|
|
500
|
+
js.returnIfFailFast();
|
|
501
|
+
}
|
|
502
|
+
if (this.index || this.undeclared === "reject") {
|
|
503
|
+
js.const("keys", "Object.keys(data)");
|
|
504
|
+
js.line("keys.push(...Object.getOwnPropertySymbols(data))");
|
|
505
|
+
js.for("i < keys.length", () => this.compileExhaustiveEntry(js));
|
|
506
|
+
}
|
|
507
|
+
if (js.traversalKind === "Allows")
|
|
508
|
+
return js.return(true);
|
|
509
|
+
// always queue deleteUndeclared on valid traversal for "delete"
|
|
510
|
+
if (this.structuralMorphRef) {
|
|
511
|
+
// added additional ctx check here to address
|
|
512
|
+
// https://github.com/arktypeio/arktype/issues/1346
|
|
513
|
+
js.if("ctx && !ctx.hasError()", () => {
|
|
514
|
+
js.line(`ctx.queueMorphs([`);
|
|
515
|
+
precompileMorphs(js, this);
|
|
516
|
+
return js.line("])");
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
compileExhaustiveEntry(js) {
|
|
521
|
+
js.const("k", "keys[i]");
|
|
522
|
+
if (this.index) {
|
|
523
|
+
for (const node of this.index) {
|
|
524
|
+
js.if(`${js.invoke(node.signature, { arg: "k", kind: "Allows" })}`, () => js.traverseKey("k", "data[k]", node.value));
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
if (this.undeclared === "reject") {
|
|
528
|
+
js.if(`!(${this._compileDeclaresKey(js)})`, () => {
|
|
529
|
+
if (js.traversalKind === "Allows")
|
|
530
|
+
return js.return(false);
|
|
531
|
+
return js
|
|
532
|
+
.line(`ctx.errorFromNodeContext({ code: "predicate", expected: "removed", actual: "", relativePath: [k], meta: ${this.compiledMeta} })`)
|
|
533
|
+
.if("ctx.failFast", () => js.return());
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
return js;
|
|
537
|
+
}
|
|
538
|
+
reduceJsonSchema(schema, ctx) {
|
|
539
|
+
switch (schema.type) {
|
|
540
|
+
case "object":
|
|
541
|
+
return this.reduceObjectJsonSchema(schema, ctx);
|
|
542
|
+
case "array":
|
|
543
|
+
const arraySchema = this.sequence?.reduceJsonSchema(schema, ctx) ?? schema;
|
|
544
|
+
if (this.props.length || this.index) {
|
|
545
|
+
return ctx.fallback.arrayObject({
|
|
546
|
+
code: "arrayObject",
|
|
547
|
+
base: arraySchema,
|
|
548
|
+
object: this.reduceObjectJsonSchema({ type: "object" }, ctx)
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
return arraySchema;
|
|
552
|
+
default:
|
|
553
|
+
return ToJsonSchema.throwInternalOperandError("structure", schema);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
reduceObjectJsonSchema(schema, ctx) {
|
|
557
|
+
if (this.props.length) {
|
|
558
|
+
schema.properties = {};
|
|
559
|
+
for (const prop of this.props) {
|
|
560
|
+
const valueSchema = prop.value.toJsonSchemaRecurse(ctx);
|
|
561
|
+
if (typeof prop.key === "symbol") {
|
|
562
|
+
ctx.fallback.symbolKey({
|
|
563
|
+
code: "symbolKey",
|
|
564
|
+
base: schema,
|
|
565
|
+
key: prop.key,
|
|
566
|
+
value: valueSchema,
|
|
567
|
+
optional: prop.optional
|
|
568
|
+
});
|
|
569
|
+
continue;
|
|
570
|
+
}
|
|
571
|
+
if (prop.hasDefault()) {
|
|
572
|
+
const value = typeof prop.default === "function" ? prop.default() : prop.default;
|
|
573
|
+
valueSchema.default =
|
|
574
|
+
$ark.intrinsic.jsonData.allows(value) ?
|
|
575
|
+
value
|
|
576
|
+
: ctx.fallback.defaultValue({
|
|
577
|
+
code: "defaultValue",
|
|
578
|
+
base: valueSchema,
|
|
579
|
+
value
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
schema.properties[prop.key] = valueSchema;
|
|
583
|
+
}
|
|
584
|
+
if (this.requiredKeys.length && schema.properties) {
|
|
585
|
+
schema.required = this.requiredKeys.filter((k) => typeof k === "string" && k in schema.properties);
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
if (this.index) {
|
|
589
|
+
for (const index of this.index) {
|
|
590
|
+
const valueJsonSchema = index.value.toJsonSchemaRecurse(ctx);
|
|
591
|
+
if (index.signature.equals($ark.intrinsic.string)) {
|
|
592
|
+
schema.additionalProperties = valueJsonSchema;
|
|
593
|
+
continue;
|
|
594
|
+
}
|
|
595
|
+
for (const keyBranch of index.signature.branches) {
|
|
596
|
+
if (!keyBranch.extends($ark.intrinsic.string)) {
|
|
597
|
+
schema = ctx.fallback.symbolKey({
|
|
598
|
+
code: "symbolKey",
|
|
599
|
+
base: schema,
|
|
600
|
+
key: null,
|
|
601
|
+
value: valueJsonSchema,
|
|
602
|
+
optional: false
|
|
603
|
+
});
|
|
604
|
+
continue;
|
|
605
|
+
}
|
|
606
|
+
let keySchema = { type: "string" };
|
|
607
|
+
if (keyBranch.hasKind("morph")) {
|
|
608
|
+
keySchema = ctx.fallback.morph({
|
|
609
|
+
code: "morph",
|
|
610
|
+
base: keyBranch.rawIn.toJsonSchemaRecurse(ctx),
|
|
611
|
+
out: keyBranch.rawOut.toJsonSchemaRecurse(ctx)
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
if (!keyBranch.hasKind("intersection")) {
|
|
615
|
+
return throwInternalError(`Unexpected index branch kind ${keyBranch.kind}.`);
|
|
616
|
+
}
|
|
617
|
+
const { pattern } = keyBranch.inner;
|
|
618
|
+
if (pattern) {
|
|
619
|
+
const keySchemaWithPattern = Object.assign(keySchema, {
|
|
620
|
+
pattern: pattern[0].rule
|
|
621
|
+
});
|
|
622
|
+
for (let i = 1; i < pattern.length; i++) {
|
|
623
|
+
keySchema = ctx.fallback.patternIntersection({
|
|
624
|
+
code: "patternIntersection",
|
|
625
|
+
base: keySchemaWithPattern,
|
|
626
|
+
pattern: pattern[i].rule
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
schema.patternProperties ??= {};
|
|
630
|
+
schema.patternProperties[keySchemaWithPattern.pattern] =
|
|
631
|
+
valueJsonSchema;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
if (this.undeclared && !schema.additionalProperties)
|
|
637
|
+
schema.additionalProperties = false;
|
|
638
|
+
return schema;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
const defaultableMorphsCache = {};
|
|
642
|
+
const constructStructuralMorphCacheKey = (node) => {
|
|
643
|
+
let cacheKey = "";
|
|
644
|
+
for (let i = 0; i < node.defaultable.length; i++)
|
|
645
|
+
cacheKey += node.defaultable[i].defaultValueMorphRef;
|
|
646
|
+
if (node.sequence?.defaultValueMorphsReference)
|
|
647
|
+
cacheKey += node.sequence?.defaultValueMorphsReference;
|
|
648
|
+
if (node.undeclared === "delete") {
|
|
649
|
+
cacheKey += "delete !(";
|
|
650
|
+
if (node.required)
|
|
651
|
+
for (const n of node.required)
|
|
652
|
+
cacheKey += n.compiledKey + " | ";
|
|
653
|
+
if (node.optional)
|
|
654
|
+
for (const n of node.optional)
|
|
655
|
+
cacheKey += n.compiledKey + " | ";
|
|
656
|
+
if (node.index)
|
|
657
|
+
for (const index of node.index)
|
|
658
|
+
cacheKey += index.signature.id + " | ";
|
|
659
|
+
if (node.sequence) {
|
|
660
|
+
if (node.sequence.maxLength === null)
|
|
661
|
+
cacheKey += intrinsic.nonNegativeIntegerString.id;
|
|
662
|
+
else {
|
|
663
|
+
for (let i = 0; i < node.sequence.tuple.length; i++)
|
|
664
|
+
cacheKey += i + " | ";
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
cacheKey += ")";
|
|
668
|
+
}
|
|
669
|
+
return cacheKey;
|
|
670
|
+
};
|
|
671
|
+
const getPossibleMorph = (node) => {
|
|
672
|
+
const cacheKey = constructStructuralMorphCacheKey(node);
|
|
673
|
+
if (!cacheKey)
|
|
674
|
+
return undefined;
|
|
675
|
+
if (defaultableMorphsCache[cacheKey])
|
|
676
|
+
return defaultableMorphsCache[cacheKey];
|
|
677
|
+
const $arkStructuralMorph = (data, ctx) => {
|
|
678
|
+
for (let i = 0; i < node.defaultable.length; i++) {
|
|
679
|
+
if (!(node.defaultable[i].key in data))
|
|
680
|
+
node.defaultable[i].defaultValueMorph(data, ctx);
|
|
681
|
+
}
|
|
682
|
+
if (node.sequence?.defaultables) {
|
|
683
|
+
for (let i = data.length - node.sequence.prefixLength; i < node.sequence.defaultables.length; i++)
|
|
684
|
+
node.sequence.defaultValueMorphs[i](data, ctx);
|
|
685
|
+
}
|
|
686
|
+
if (node.undeclared === "delete")
|
|
687
|
+
for (const k in data)
|
|
688
|
+
if (!node.declaresKey(k))
|
|
689
|
+
delete data[k];
|
|
690
|
+
return data;
|
|
691
|
+
};
|
|
692
|
+
return (defaultableMorphsCache[cacheKey] = $arkStructuralMorph);
|
|
693
|
+
};
|
|
694
|
+
const precompileMorphs = (js, node) => {
|
|
695
|
+
const requiresContext = node.defaultable.some(node => node.defaultValueMorph.length === 2) ||
|
|
696
|
+
node.sequence?.defaultValueMorphs.some(morph => morph.length === 2);
|
|
697
|
+
const args = `(data${requiresContext ? ", ctx" : ""})`;
|
|
698
|
+
return js.block(`${args} => `, js => {
|
|
699
|
+
for (let i = 0; i < node.defaultable.length; i++) {
|
|
700
|
+
const { serializedKey, defaultValueMorphRef } = node.defaultable[i];
|
|
701
|
+
js.if(`!(${serializedKey} in data)`, js => js.line(`${defaultValueMorphRef}${args}`));
|
|
702
|
+
}
|
|
703
|
+
if (node.sequence?.defaultables) {
|
|
704
|
+
js.for(`i < ${node.sequence.defaultables.length}`, js => js.set(`data[i]`, 5), `data.length - ${node.sequence.prefixLength}`);
|
|
705
|
+
}
|
|
706
|
+
if (node.undeclared === "delete") {
|
|
707
|
+
js.forIn("data", js => js.if(`!(${node._compileDeclaresKey(js)})`, js => js.line(`delete data[k]`)));
|
|
708
|
+
}
|
|
709
|
+
return js.return("data");
|
|
710
|
+
});
|
|
711
|
+
};
|
|
712
|
+
export const Structure = {
|
|
713
|
+
implementation,
|
|
714
|
+
Node: StructureNode
|
|
715
|
+
};
|
|
716
|
+
const indexerToKey = (indexable) => {
|
|
717
|
+
if (hasArkKind(indexable, "root") && indexable.hasKind("unit"))
|
|
718
|
+
indexable = indexable.unit;
|
|
719
|
+
if (typeof indexable === "number")
|
|
720
|
+
indexable = `${indexable}`;
|
|
721
|
+
return indexable;
|
|
722
|
+
};
|
|
723
|
+
export const writeNumberIndexMessage = (indexExpression, sequenceExpression) => `${indexExpression} is not allowed as an array index on ${sequenceExpression}. Use the 'nonNegativeIntegerString' keyword instead.`;
|
|
724
|
+
/** extract enumerable named props from an index signature */
|
|
725
|
+
export const normalizeIndex = (signature, value, $) => {
|
|
726
|
+
const [enumerableBranches, nonEnumerableBranches] = spliterate(signature.branches, k => k.hasKind("unit"));
|
|
727
|
+
if (!enumerableBranches.length)
|
|
728
|
+
return { index: $.node("index", { signature, value }) };
|
|
729
|
+
const normalized = {};
|
|
730
|
+
for (const n of enumerableBranches) {
|
|
731
|
+
// since required can be reduced to optional if it has a default or
|
|
732
|
+
// optional meta on its value, we have to assign it depending on the
|
|
733
|
+
// compiled kind
|
|
734
|
+
const prop = $.node("required", { key: n.unit, value });
|
|
735
|
+
normalized[prop.kind] = append(normalized[prop.kind], prop);
|
|
736
|
+
}
|
|
737
|
+
if (nonEnumerableBranches.length) {
|
|
738
|
+
normalized.index = $.node("index", {
|
|
739
|
+
signature: nonEnumerableBranches,
|
|
740
|
+
value
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
return normalized;
|
|
744
|
+
};
|
|
745
|
+
export const typeKeyToString = (k) => hasArkKind(k, "root") ? k.expression : printable(k);
|
|
746
|
+
export const writeInvalidKeysMessage = (o, keys) => `Key${keys.length === 1 ? "" : "s"} ${keys.map(typeKeyToString).join(", ")} ${keys.length === 1 ? "does" : "do"} not exist on ${o}`;
|
|
747
|
+
export const writeDuplicateKeyMessage = (key) => `Duplicate key ${compileSerializedValue(key)}`;
|