@astrale-os/kernel-client 0.6.0-beta.2 → 0.6.0-beta.20
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/dist/auth/auth.d.ts +1 -2
- package/dist/auth/auth.js +0 -1
- package/dist/auth/authorization.d.ts +2 -3
- package/dist/auth/authorization.js +3 -4
- package/dist/auth/credential.d.ts +1 -2
- package/dist/auth/credential.js +5 -6
- package/dist/auth/identity.d.ts +2 -3
- package/dist/auth/identity.js +4 -5
- package/dist/auth/index.d.ts +1 -2
- package/dist/auth/index.js +0 -1
- package/dist/auth/provision.d.ts +0 -1
- package/dist/auth/provision.js +2 -3
- package/dist/client/admission.d.ts +0 -1
- package/dist/client/admission.js +0 -1
- package/dist/client/client.d.ts +4 -5
- package/dist/client/client.js +2 -3
- package/dist/client/credential.d.ts +4 -5
- package/dist/client/credential.js +0 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +0 -1
- package/dist/client/request.d.ts +2 -3
- package/dist/client/request.js +1 -2
- package/dist/client/result.d.ts +35 -5
- package/dist/client/result.js +6 -4
- package/dist/client/routing-control.d.ts +3 -4
- package/dist/client/routing-control.js +4 -5
- package/dist/errors/client-error.d.ts +0 -1
- package/dist/errors/client-error.js +2 -1
- package/dist/errors/index.d.ts +7 -7
- package/dist/errors/index.js +7 -7
- package/dist/errors/miss-error.d.ts +3 -2
- package/dist/errors/miss-error.js +3 -2
- package/dist/errors/protocol-error.d.ts +6 -2
- package/dist/errors/protocol-error.js +2 -1
- package/dist/errors/response-error.d.ts +4 -3
- package/dist/errors/response-error.js +4 -3
- package/dist/errors/session-error.d.ts +9 -0
- package/dist/errors/session-error.js +9 -0
- package/dist/errors/stale-route-error.d.ts +3 -3
- package/dist/errors/stale-route-error.js +3 -2
- package/dist/errors/transport-error.d.ts +20 -5
- package/dist/errors/transport-error.js +11 -5
- package/dist/graph/domain/binding.d.ts +22 -0
- package/dist/graph/domain/binding.js +123 -0
- package/dist/graph/domain/domain.typecheck.d.ts +1 -0
- package/dist/graph/domain/domain.typecheck.js +139 -0
- package/dist/graph/domain/index.d.ts +3 -0
- package/dist/graph/domain/index.js +1 -0
- package/dist/graph/domain/model.d.ts +18 -0
- package/dist/graph/domain/model.js +1 -0
- package/dist/graph/domain/page.d.ts +23 -0
- package/dist/graph/domain/page.js +42 -0
- package/dist/graph/domain/project.d.ts +8 -0
- package/dist/graph/domain/project.js +120 -0
- package/dist/graph/domain/provenance.d.ts +6 -0
- package/dist/graph/domain/provenance.js +11 -0
- package/dist/graph/errors.d.ts +2 -3
- package/dist/graph/errors.js +2 -2
- package/dist/graph/expectation.d.ts +3 -0
- package/dist/graph/expectation.js +6 -0
- package/dist/graph/graph.d.ts +14 -11
- package/dist/graph/graph.js +0 -1
- package/dist/graph/index.d.ts +3 -2
- package/dist/graph/index.js +1 -1
- package/dist/graph/mutation.d.ts +2 -4
- package/dist/graph/mutation.js +12 -4
- package/dist/graph/page/index.d.ts +0 -1
- package/dist/graph/page/index.js +0 -1
- package/dist/graph/page/neighbors.d.ts +4 -5
- package/dist/graph/page/neighbors.js +6 -7
- package/dist/graph/page/page.d.ts +6 -3
- package/dist/graph/page/page.js +0 -1
- package/dist/graph/page-contract.d.ts +13 -0
- package/dist/graph/page-contract.js +1 -0
- package/dist/graph/provenance.d.ts +14 -0
- package/dist/graph/provenance.js +42 -0
- package/dist/graph/query.d.ts +1 -2
- package/dist/graph/query.js +21 -13
- package/dist/graph/read.d.ts +3 -4
- package/dist/graph/read.js +1 -2
- package/dist/index.d.ts +2 -3
- package/dist/index.js +1 -2
- package/dist/pacer/batcher/batcher.d.ts +0 -1
- package/dist/pacer/batcher/batcher.js +0 -1
- package/dist/pacer/batcher/defaults.d.ts +0 -1
- package/dist/pacer/batcher/defaults.js +0 -1
- package/dist/pacer/batcher/index.d.ts +0 -1
- package/dist/pacer/batcher/index.js +0 -1
- package/dist/pacer/index.d.ts +0 -1
- package/dist/pacer/index.js +0 -1
- package/dist/pacer/limiter/defaults.d.ts +0 -1
- package/dist/pacer/limiter/defaults.js +0 -1
- package/dist/pacer/limiter/index.d.ts +0 -1
- package/dist/pacer/limiter/index.js +0 -1
- package/dist/pacer/limiter/limiter.d.ts +0 -1
- package/dist/pacer/limiter/limiter.js +0 -1
- package/dist/pacer/queue/defaults.d.ts +0 -1
- package/dist/pacer/queue/defaults.js +0 -1
- package/dist/pacer/queue/index.d.ts +0 -1
- package/dist/pacer/queue/index.js +0 -1
- package/dist/pacer/queue/queue.d.ts +0 -1
- package/dist/pacer/queue/queue.js +0 -1
- package/dist/pacer/retry/defaults.d.ts +0 -1
- package/dist/pacer/retry/defaults.js +0 -1
- package/dist/pacer/retry/index.d.ts +0 -1
- package/dist/pacer/retry/index.js +0 -1
- package/dist/pacer/retry/retry.d.ts +0 -1
- package/dist/pacer/retry/retry.js +0 -1
- package/dist/pool/index.d.ts +0 -1
- package/dist/pool/index.js +0 -1
- package/dist/pool/pool.d.ts +0 -1
- package/dist/pool/pool.js +0 -1
- package/dist/pool/target.d.ts +0 -1
- package/dist/pool/target.js +0 -1
- package/dist/schema/admission.d.ts +9 -7
- package/dist/schema/admission.js +6 -12
- package/dist/schema/contracts.d.ts +12 -0
- package/dist/schema/contracts.js +1 -0
- package/dist/schema/index.d.ts +3 -4
- package/dist/schema/index.js +1 -1
- package/dist/schema/introspection.d.ts +1 -2
- package/dist/schema/introspection.js +7 -4
- package/dist/schema/operation.d.ts +5 -0
- package/dist/schema/operation.js +9 -0
- package/dist/schema/schema.d.ts +10 -12
- package/dist/schema/schema.js +47 -10
- package/dist/session/bound.d.ts +41 -0
- package/dist/session/bound.js +72 -0
- package/dist/session/context/control.d.ts +0 -1
- package/dist/session/context/control.js +0 -1
- package/dist/session/context/index.d.ts +0 -1
- package/dist/session/context/index.js +0 -1
- package/dist/session/context/limits.d.ts +0 -1
- package/dist/session/context/limits.js +0 -1
- package/dist/session/context/operation.d.ts +0 -1
- package/dist/session/context/operation.js +19 -17
- package/dist/session/context/policy.d.ts +1 -2
- package/dist/session/context/policy.js +2 -3
- package/dist/session/discovery/bundle.d.ts +0 -1
- package/dist/session/discovery/bundle.js +6 -6
- package/dist/session/discovery/discovery.d.ts +1 -2
- package/dist/session/discovery/discovery.js +0 -1
- package/dist/session/discovery/index.d.ts +1 -2
- package/dist/session/discovery/index.js +0 -1
- package/dist/session/discovery/publication.d.ts +1 -2
- package/dist/session/discovery/publication.js +6 -5
- package/dist/session/discovery/snapshot.d.ts +1 -2
- package/dist/session/discovery/snapshot.js +0 -1
- package/dist/session/discovery/transport.d.ts +6 -0
- package/dist/session/discovery/transport.js +13 -0
- package/dist/session/index.d.ts +6 -4
- package/dist/session/index.js +3 -2
- package/dist/session/reference.d.ts +36 -0
- package/dist/session/reference.js +74 -0
- package/dist/session/routing/auth.d.ts +1 -2
- package/dist/session/routing/auth.js +1 -2
- package/dist/session/routing/cache.d.ts +2 -3
- package/dist/session/routing/cache.js +1 -13
- package/dist/session/routing/dispatch.d.ts +4 -9
- package/dist/session/routing/dispatch.js +14 -22
- package/dist/session/routing/envelope.d.ts +0 -1
- package/dist/session/routing/envelope.js +0 -1
- package/dist/session/routing/expectation.d.ts +6 -0
- package/dist/session/routing/expectation.js +1 -0
- package/dist/session/routing/index.d.ts +1 -2
- package/dist/session/routing/index.js +0 -1
- package/dist/session/routing/request.d.ts +1 -2
- package/dist/session/routing/request.js +1 -2
- package/dist/session/session.d.ts +16 -13
- package/dist/session/session.js +49 -35
- package/dist/session/session.typecheck.d.ts +0 -1
- package/dist/session/session.typecheck.js +23 -2
- package/dist/session/views/catalog.d.ts +2 -3
- package/dist/session/views/catalog.js +14 -7
- package/dist/session/views/index.d.ts +0 -1
- package/dist/session/views/index.js +0 -1
- package/dist/session/views/resolve.d.ts +1 -3
- package/dist/session/views/resolve.js +4 -3
- package/dist/store/entity-index.d.ts +0 -1
- package/dist/store/entity-index.js +0 -1
- package/dist/store/index.d.ts +0 -1
- package/dist/store/index.js +0 -1
- package/dist/store/memory.d.ts +3 -3
- package/dist/store/memory.js +24 -13
- package/dist/store/mutation.d.ts +0 -1
- package/dist/store/mutation.js +0 -1
- package/dist/store/observe.d.ts +0 -1
- package/dist/store/observe.js +0 -1
- package/dist/store/optimistic.d.ts +0 -1
- package/dist/store/optimistic.js +0 -1
- package/dist/store/query-key.d.ts +3 -3
- package/dist/store/query-key.js +7 -3
- package/dist/store/shape.d.ts +4 -3
- package/dist/store/shape.js +3 -2
- package/dist/store/store.d.ts +3 -5
- package/dist/store/store.js +5 -4
- package/dist/store/store.typecheck.d.ts +0 -1
- package/dist/store/store.typecheck.js +3 -4
- package/dist/transport/auto/decision.d.ts +0 -1
- package/dist/transport/auto/decision.js +0 -1
- package/dist/transport/auto/fallback.d.ts +0 -1
- package/dist/transport/auto/fallback.js +8 -10
- package/dist/transport/auto/index.d.ts +0 -1
- package/dist/transport/auto/index.js +0 -1
- package/dist/transport/auto/transport.d.ts +0 -1
- package/dist/transport/auto/transport.js +5 -6
- package/dist/transport/auto/warning.d.ts +0 -1
- package/dist/transport/auto/warning.js +0 -1
- package/dist/transport/deadline.d.ts +0 -1
- package/dist/transport/deadline.js +0 -1
- package/dist/transport/failure.d.ts +7 -0
- package/dist/transport/failure.js +9 -0
- package/dist/transport/http/byte-stream.d.ts +17 -0
- package/dist/transport/http/byte-stream.js +86 -0
- package/dist/transport/http/index.d.ts +0 -1
- package/dist/transport/http/index.js +0 -1
- package/dist/transport/http/response.d.ts +2 -2
- package/dist/transport/http/response.js +2 -2
- package/dist/transport/http/stream.d.ts +6 -5
- package/dist/transport/http/stream.js +29 -12
- package/dist/transport/http/transport.d.ts +0 -1
- package/dist/transport/http/transport.js +65 -40
- package/dist/transport/index.d.ts +0 -1
- package/dist/transport/index.js +0 -1
- package/dist/transport/transport.d.ts +3 -2
- package/dist/transport/transport.js +0 -1
- package/dist/transport/websocket/connection.d.ts +3 -3
- package/dist/transport/websocket/connection.js +21 -34
- package/dist/transport/websocket/exchange.d.ts +7 -7
- package/dist/transport/websocket/exchange.js +50 -39
- package/dist/transport/websocket/index.d.ts +0 -1
- package/dist/transport/websocket/index.js +0 -1
- package/dist/transport/websocket/transport.d.ts +0 -1
- package/dist/transport/websocket/transport.js +9 -21
- package/package.json +21 -19
- package/dist/auth/auth.d.ts.map +0 -1
- package/dist/auth/auth.js.map +0 -1
- package/dist/auth/authorization.d.ts.map +0 -1
- package/dist/auth/authorization.js.map +0 -1
- package/dist/auth/credential.d.ts.map +0 -1
- package/dist/auth/credential.js.map +0 -1
- package/dist/auth/identity.d.ts.map +0 -1
- package/dist/auth/identity.js.map +0 -1
- package/dist/auth/index.d.ts.map +0 -1
- package/dist/auth/index.js.map +0 -1
- package/dist/auth/provision.d.ts.map +0 -1
- package/dist/auth/provision.js.map +0 -1
- package/dist/client/admission.d.ts.map +0 -1
- package/dist/client/admission.js.map +0 -1
- package/dist/client/client.d.ts.map +0 -1
- package/dist/client/client.js.map +0 -1
- package/dist/client/credential.d.ts.map +0 -1
- package/dist/client/credential.js.map +0 -1
- package/dist/client/index.d.ts.map +0 -1
- package/dist/client/index.js.map +0 -1
- package/dist/client/request.d.ts.map +0 -1
- package/dist/client/request.js.map +0 -1
- package/dist/client/result.d.ts.map +0 -1
- package/dist/client/result.js.map +0 -1
- package/dist/client/routing-control.d.ts.map +0 -1
- package/dist/client/routing-control.js.map +0 -1
- package/dist/domain/binding.d.ts +0 -24
- package/dist/domain/binding.d.ts.map +0 -1
- package/dist/domain/binding.js +0 -69
- package/dist/domain/binding.js.map +0 -1
- package/dist/domain/callable.d.ts +0 -25
- package/dist/domain/callable.d.ts.map +0 -1
- package/dist/domain/callable.js +0 -70
- package/dist/domain/callable.js.map +0 -1
- package/dist/domain/domain.typecheck.d.ts +0 -2
- package/dist/domain/domain.typecheck.d.ts.map +0 -1
- package/dist/domain/domain.typecheck.js +0 -69
- package/dist/domain/domain.typecheck.js.map +0 -1
- package/dist/domain/index.d.ts +0 -4
- package/dist/domain/index.d.ts.map +0 -1
- package/dist/domain/index.js +0 -2
- package/dist/domain/index.js.map +0 -1
- package/dist/domain/node.d.ts +0 -10
- package/dist/domain/node.d.ts.map +0 -1
- package/dist/domain/node.js +0 -6
- package/dist/domain/node.js.map +0 -1
- package/dist/errors/client-error.d.ts.map +0 -1
- package/dist/errors/client-error.js.map +0 -1
- package/dist/errors/index.d.ts.map +0 -1
- package/dist/errors/index.js.map +0 -1
- package/dist/errors/miss-error.d.ts.map +0 -1
- package/dist/errors/miss-error.js.map +0 -1
- package/dist/errors/protocol-error.d.ts.map +0 -1
- package/dist/errors/protocol-error.js.map +0 -1
- package/dist/errors/response-error.d.ts.map +0 -1
- package/dist/errors/response-error.js.map +0 -1
- package/dist/errors/stale-route-error.d.ts.map +0 -1
- package/dist/errors/stale-route-error.js.map +0 -1
- package/dist/errors/transport-error.d.ts.map +0 -1
- package/dist/errors/transport-error.js.map +0 -1
- package/dist/graph/errors.d.ts.map +0 -1
- package/dist/graph/errors.js.map +0 -1
- package/dist/graph/graph.d.ts.map +0 -1
- package/dist/graph/graph.js.map +0 -1
- package/dist/graph/index.d.ts.map +0 -1
- package/dist/graph/index.js.map +0 -1
- package/dist/graph/mutation.d.ts.map +0 -1
- package/dist/graph/mutation.js.map +0 -1
- package/dist/graph/page/index.d.ts.map +0 -1
- package/dist/graph/page/index.js.map +0 -1
- package/dist/graph/page/neighbors.d.ts.map +0 -1
- package/dist/graph/page/neighbors.js.map +0 -1
- package/dist/graph/page/page.d.ts.map +0 -1
- package/dist/graph/page/page.js.map +0 -1
- package/dist/graph/query.d.ts.map +0 -1
- package/dist/graph/query.js.map +0 -1
- package/dist/graph/read.d.ts.map +0 -1
- package/dist/graph/read.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/pacer/batcher/batcher.d.ts.map +0 -1
- package/dist/pacer/batcher/batcher.js.map +0 -1
- package/dist/pacer/batcher/defaults.d.ts.map +0 -1
- package/dist/pacer/batcher/defaults.js.map +0 -1
- package/dist/pacer/batcher/index.d.ts.map +0 -1
- package/dist/pacer/batcher/index.js.map +0 -1
- package/dist/pacer/index.d.ts.map +0 -1
- package/dist/pacer/index.js.map +0 -1
- package/dist/pacer/limiter/defaults.d.ts.map +0 -1
- package/dist/pacer/limiter/defaults.js.map +0 -1
- package/dist/pacer/limiter/index.d.ts.map +0 -1
- package/dist/pacer/limiter/index.js.map +0 -1
- package/dist/pacer/limiter/limiter.d.ts.map +0 -1
- package/dist/pacer/limiter/limiter.js.map +0 -1
- package/dist/pacer/queue/defaults.d.ts.map +0 -1
- package/dist/pacer/queue/defaults.js.map +0 -1
- package/dist/pacer/queue/index.d.ts.map +0 -1
- package/dist/pacer/queue/index.js.map +0 -1
- package/dist/pacer/queue/queue.d.ts.map +0 -1
- package/dist/pacer/queue/queue.js.map +0 -1
- package/dist/pacer/retry/defaults.d.ts.map +0 -1
- package/dist/pacer/retry/defaults.js.map +0 -1
- package/dist/pacer/retry/index.d.ts.map +0 -1
- package/dist/pacer/retry/index.js.map +0 -1
- package/dist/pacer/retry/retry.d.ts.map +0 -1
- package/dist/pacer/retry/retry.js.map +0 -1
- package/dist/pool/index.d.ts.map +0 -1
- package/dist/pool/index.js.map +0 -1
- package/dist/pool/pool.d.ts.map +0 -1
- package/dist/pool/pool.js.map +0 -1
- package/dist/pool/target.d.ts.map +0 -1
- package/dist/pool/target.js.map +0 -1
- package/dist/schema/admission.d.ts.map +0 -1
- package/dist/schema/admission.js.map +0 -1
- package/dist/schema/index.d.ts.map +0 -1
- package/dist/schema/index.js.map +0 -1
- package/dist/schema/introspection.d.ts.map +0 -1
- package/dist/schema/introspection.js.map +0 -1
- package/dist/schema/schema.d.ts.map +0 -1
- package/dist/schema/schema.js.map +0 -1
- package/dist/session/context/control.d.ts.map +0 -1
- package/dist/session/context/control.js.map +0 -1
- package/dist/session/context/index.d.ts.map +0 -1
- package/dist/session/context/index.js.map +0 -1
- package/dist/session/context/limits.d.ts.map +0 -1
- package/dist/session/context/limits.js.map +0 -1
- package/dist/session/context/operation.d.ts.map +0 -1
- package/dist/session/context/operation.js.map +0 -1
- package/dist/session/context/policy.d.ts.map +0 -1
- package/dist/session/context/policy.js.map +0 -1
- package/dist/session/discovery/bundle.d.ts.map +0 -1
- package/dist/session/discovery/bundle.js.map +0 -1
- package/dist/session/discovery/discovery.d.ts.map +0 -1
- package/dist/session/discovery/discovery.js.map +0 -1
- package/dist/session/discovery/index.d.ts.map +0 -1
- package/dist/session/discovery/index.js.map +0 -1
- package/dist/session/discovery/publication.d.ts.map +0 -1
- package/dist/session/discovery/publication.js.map +0 -1
- package/dist/session/discovery/snapshot.d.ts.map +0 -1
- package/dist/session/discovery/snapshot.js.map +0 -1
- package/dist/session/index.d.ts.map +0 -1
- package/dist/session/index.js.map +0 -1
- package/dist/session/routing/auth.d.ts.map +0 -1
- package/dist/session/routing/auth.js.map +0 -1
- package/dist/session/routing/bound.d.ts +0 -7
- package/dist/session/routing/bound.d.ts.map +0 -1
- package/dist/session/routing/bound.js +0 -2
- package/dist/session/routing/bound.js.map +0 -1
- package/dist/session/routing/cache.d.ts.map +0 -1
- package/dist/session/routing/cache.js.map +0 -1
- package/dist/session/routing/dispatch.d.ts.map +0 -1
- package/dist/session/routing/dispatch.js.map +0 -1
- package/dist/session/routing/envelope.d.ts.map +0 -1
- package/dist/session/routing/envelope.js.map +0 -1
- package/dist/session/routing/index.d.ts.map +0 -1
- package/dist/session/routing/index.js.map +0 -1
- package/dist/session/routing/request.d.ts.map +0 -1
- package/dist/session/routing/request.js.map +0 -1
- package/dist/session/session.d.ts.map +0 -1
- package/dist/session/session.js.map +0 -1
- package/dist/session/session.typecheck.d.ts.map +0 -1
- package/dist/session/session.typecheck.js.map +0 -1
- package/dist/session/views/catalog.d.ts.map +0 -1
- package/dist/session/views/catalog.js.map +0 -1
- package/dist/session/views/index.d.ts.map +0 -1
- package/dist/session/views/index.js.map +0 -1
- package/dist/session/views/resolve.d.ts.map +0 -1
- package/dist/session/views/resolve.js.map +0 -1
- package/dist/store/entity-index.d.ts.map +0 -1
- package/dist/store/entity-index.js.map +0 -1
- package/dist/store/index.d.ts.map +0 -1
- package/dist/store/index.js.map +0 -1
- package/dist/store/memory.d.ts.map +0 -1
- package/dist/store/memory.js.map +0 -1
- package/dist/store/mutation.d.ts.map +0 -1
- package/dist/store/mutation.js.map +0 -1
- package/dist/store/observe.d.ts.map +0 -1
- package/dist/store/observe.js.map +0 -1
- package/dist/store/optimistic.d.ts.map +0 -1
- package/dist/store/optimistic.js.map +0 -1
- package/dist/store/query-key.d.ts.map +0 -1
- package/dist/store/query-key.js.map +0 -1
- package/dist/store/shape.d.ts.map +0 -1
- package/dist/store/shape.js.map +0 -1
- package/dist/store/store.d.ts.map +0 -1
- package/dist/store/store.js.map +0 -1
- package/dist/store/store.typecheck.d.ts.map +0 -1
- package/dist/store/store.typecheck.js.map +0 -1
- package/dist/transport/auto/decision.d.ts.map +0 -1
- package/dist/transport/auto/decision.js.map +0 -1
- package/dist/transport/auto/fallback.d.ts.map +0 -1
- package/dist/transport/auto/fallback.js.map +0 -1
- package/dist/transport/auto/index.d.ts.map +0 -1
- package/dist/transport/auto/index.js.map +0 -1
- package/dist/transport/auto/transport.d.ts.map +0 -1
- package/dist/transport/auto/transport.js.map +0 -1
- package/dist/transport/auto/warning.d.ts.map +0 -1
- package/dist/transport/auto/warning.js.map +0 -1
- package/dist/transport/deadline.d.ts.map +0 -1
- package/dist/transport/deadline.js.map +0 -1
- package/dist/transport/http/index.d.ts.map +0 -1
- package/dist/transport/http/index.js.map +0 -1
- package/dist/transport/http/response.d.ts.map +0 -1
- package/dist/transport/http/response.js.map +0 -1
- package/dist/transport/http/stream.d.ts.map +0 -1
- package/dist/transport/http/stream.js.map +0 -1
- package/dist/transport/http/transport.d.ts.map +0 -1
- package/dist/transport/http/transport.js.map +0 -1
- package/dist/transport/index.d.ts.map +0 -1
- package/dist/transport/index.js.map +0 -1
- package/dist/transport/transport.d.ts.map +0 -1
- package/dist/transport/transport.js.map +0 -1
- package/dist/transport/websocket/connection.d.ts.map +0 -1
- package/dist/transport/websocket/connection.js.map +0 -1
- package/dist/transport/websocket/exchange.d.ts.map +0 -1
- package/dist/transport/websocket/exchange.js.map +0 -1
- package/dist/transport/websocket/index.d.ts.map +0 -1
- package/dist/transport/websocket/index.js.map +0 -1
- package/dist/transport/websocket/transport.d.ts.map +0 -1
- package/dist/transport/websocket/transport.js.map +0 -1
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as codecs from '@astrale-os/kernel-protocol/codecs';
|
|
2
|
+
import * as protocol from '@astrale-os/kernel-protocol/invocation';
|
|
2
3
|
import { ProtocolError, ResponseError, TransportError } from '../../errors/index.js';
|
|
4
|
+
import { invocationFailure } from '../failure.js';
|
|
3
5
|
import { asError, controlledSignal, positiveInteger, requireLive, } from '../index.js';
|
|
6
|
+
import { HttpByteStream } from './byte-stream.js';
|
|
4
7
|
import { binaryHeaders, codecForResponse, decodeProtocol, normalizeMediaType, readBoundedBody, requireId, } from './response.js';
|
|
5
8
|
import { HttpStream } from './stream.js';
|
|
6
9
|
const DEFAULT_TIMEOUT_MS = 30_000;
|
|
@@ -29,14 +32,14 @@ export class HttpTransport {
|
|
|
29
32
|
this.maximumResponseBytes = positiveInteger(options.maximumResponseBytes ?? DEFAULT_MAXIMUM_RESPONSE_BYTES, 'maximumResponseBytes');
|
|
30
33
|
}
|
|
31
34
|
async dispatch(input, options = {}) {
|
|
32
|
-
const
|
|
35
|
+
const requestId = this.nextRequestId();
|
|
33
36
|
const timeoutMs = positiveInteger(options.timeoutMs ?? this.timeoutMs, 'timeoutMs');
|
|
34
37
|
const codec = await this.requestCodec();
|
|
35
38
|
const { trace: traceInput, ...invocationInput } = input;
|
|
36
39
|
const trace = traceInput === undefined ? undefined : protocol.admitTrace(traceInput);
|
|
37
40
|
const request = protocol.decodeRequest({
|
|
38
41
|
version: protocol.VERSION,
|
|
39
|
-
|
|
42
|
+
requestId,
|
|
40
43
|
...invocationInput,
|
|
41
44
|
...(options.idempotencyKey === undefined ? {} : { idempotencyKey: options.idempotencyKey }),
|
|
42
45
|
});
|
|
@@ -48,7 +51,7 @@ export class HttpTransport {
|
|
|
48
51
|
try {
|
|
49
52
|
requireLive(control);
|
|
50
53
|
if (encodedByteLength(encoded) > this.maximumRequestBytes) {
|
|
51
|
-
throw
|
|
54
|
+
throw invocationFailure(`request exceeds maximumRequestBytes (${this.maximumRequestBytes}).`, 'send');
|
|
52
55
|
}
|
|
53
56
|
phase = 'send';
|
|
54
57
|
delivery = 'unknown';
|
|
@@ -62,8 +65,9 @@ export class HttpTransport {
|
|
|
62
65
|
const streamFraming = response.headers.get(protocol.http.STREAM_FRAMING_FIELD);
|
|
63
66
|
const binaryId = response.headers.get(protocol.http.REQUEST_ID_FIELD);
|
|
64
67
|
const binaryManifest = response.headers.get(protocol.http.BINARY_HEADERS_FIELD);
|
|
68
|
+
const binaryDelivery = response.headers.get(protocol.http.BINARY_DELIVERY_FIELD);
|
|
65
69
|
const hasStreamSignal = streamFraming !== null;
|
|
66
|
-
const hasBinarySignal = binaryId !== null || binaryManifest !== null;
|
|
70
|
+
const hasBinarySignal = binaryId !== null || binaryManifest !== null || binaryDelivery !== null;
|
|
67
71
|
if (hasStreamSignal && hasBinarySignal) {
|
|
68
72
|
throw new ProtocolError('server returned conflicting stream and binary response signals.');
|
|
69
73
|
}
|
|
@@ -71,7 +75,13 @@ export class HttpTransport {
|
|
|
71
75
|
if (binaryId === null || binaryManifest === null) {
|
|
72
76
|
throw new ProtocolError('server returned an incomplete binary response signal.');
|
|
73
77
|
}
|
|
74
|
-
|
|
78
|
+
if (binaryDelivery !== null && binaryDelivery !== protocol.http.STREAMING_BINARY_DELIVERY) {
|
|
79
|
+
throw new ProtocolError('server returned an unsupported binary delivery signal.');
|
|
80
|
+
}
|
|
81
|
+
const binary = await this.decodeBinary(response, requestId, binaryId, binaryDelivery !== null, control);
|
|
82
|
+
if (!(binary.value.body instanceof Uint8Array))
|
|
83
|
+
handedOff = true;
|
|
84
|
+
return binary;
|
|
75
85
|
}
|
|
76
86
|
const responseCodec = await codecForResponse(response.headers.get('content-type'));
|
|
77
87
|
if (responseCodec === undefined) {
|
|
@@ -84,39 +94,43 @@ export class HttpTransport {
|
|
|
84
94
|
if (!response.ok) {
|
|
85
95
|
throw new ProtocolError('server returned a non-success stream response.');
|
|
86
96
|
}
|
|
87
|
-
const stream = await HttpStream.open(response, responseCodec,
|
|
97
|
+
const stream = await HttpStream.open(response, responseCodec, requestId, this.maximumResponseBytes, control);
|
|
88
98
|
requireLive(control);
|
|
89
99
|
handedOff = true;
|
|
90
|
-
return { kind: 'stream', stream };
|
|
100
|
+
return { kind: 'stream', stream, invocation: stream.invocation };
|
|
91
101
|
}
|
|
92
102
|
const body = await readBoundedBody(response, this.maximumResponseBytes, control.signal);
|
|
93
103
|
requireLive(control);
|
|
94
104
|
const decoded = decodeProtocol('response body', () => responseCodec.decode(body));
|
|
95
105
|
const envelope = decodeProtocol('response envelope', () => protocol.decodeResponse(decoded));
|
|
96
|
-
if (envelope.
|
|
97
|
-
throw new ResponseError(envelope.error.code, envelope.error.message, envelope.error.data);
|
|
106
|
+
if (envelope.requestId === null && 'error' in envelope) {
|
|
107
|
+
throw new ResponseError(envelope.error.code, envelope.error.message, envelope.invocation, envelope.error.data);
|
|
98
108
|
}
|
|
99
|
-
requireId(
|
|
109
|
+
requireId(requestId, envelope.requestId);
|
|
100
110
|
if ('kind' in envelope && envelope.kind === 'stale') {
|
|
101
111
|
const stale = decodeProtocol('stale response', () => protocol.decodeStale(envelope));
|
|
102
112
|
requireLive(control);
|
|
103
|
-
return Object.freeze({
|
|
113
|
+
return Object.freeze({
|
|
114
|
+
kind: 'stale',
|
|
115
|
+
current: stale.current,
|
|
116
|
+
invocation: stale.invocation,
|
|
117
|
+
});
|
|
104
118
|
}
|
|
105
119
|
if ('kind' in envelope && envelope.kind === 'miss') {
|
|
106
120
|
decodeProtocol('miss response', () => protocol.decodeMiss(envelope));
|
|
107
121
|
requireLive(control);
|
|
108
|
-
return Object.freeze({ kind: 'miss' });
|
|
122
|
+
return Object.freeze({ kind: 'miss', invocation: envelope.invocation });
|
|
109
123
|
}
|
|
110
124
|
if ('kind' in envelope && envelope.kind === 'redirect') {
|
|
111
|
-
const
|
|
125
|
+
const response = decodeProtocol('redirect response', () => protocol.decodeRedirectResponse(envelope));
|
|
112
126
|
requireLive(control);
|
|
113
|
-
return redirectResult(
|
|
127
|
+
return redirectResult(response);
|
|
114
128
|
}
|
|
115
129
|
if ('error' in envelope) {
|
|
116
|
-
throw new ResponseError(envelope.error.code, envelope.error.message, envelope.error.data);
|
|
130
|
+
throw new ResponseError(envelope.error.code, envelope.error.message, envelope.invocation, envelope.error.data);
|
|
117
131
|
}
|
|
118
132
|
requireLive(control);
|
|
119
|
-
return { kind: 'value', value: envelope.result };
|
|
133
|
+
return { kind: 'value', value: envelope.result, invocation: envelope.invocation };
|
|
120
134
|
}
|
|
121
135
|
catch (error) {
|
|
122
136
|
throw transportFailure(error, control, options.signal, timeoutMs, this.url, phase, delivery);
|
|
@@ -143,55 +157,69 @@ export class HttpTransport {
|
|
|
143
157
|
signal: control.signal,
|
|
144
158
|
});
|
|
145
159
|
}
|
|
146
|
-
async decodeBinary(response,
|
|
147
|
-
if (
|
|
148
|
-
throw new ProtocolError(
|
|
149
|
-
}
|
|
150
|
-
if (binaryId !== String(id)) {
|
|
151
|
-
throw new ProtocolError(`binary response id ${JSON.stringify(binaryId)} does not match request id ${id}.`);
|
|
160
|
+
async decodeBinary(response, requestId, binaryId, streaming, control) {
|
|
161
|
+
if (binaryId !== String(requestId)) {
|
|
162
|
+
throw new ProtocolError(`binary response requestId ${JSON.stringify(binaryId)} does not match request requestId ${requestId}.`);
|
|
152
163
|
}
|
|
153
164
|
const mediaType = normalizeMediaType(response.headers.get('content-type'));
|
|
154
165
|
if (mediaType === undefined) {
|
|
155
166
|
throw new ProtocolError('binary response has no media type.');
|
|
156
167
|
}
|
|
157
|
-
const body = await readBoundedBody(response, this.maximumResponseBytes, control.signal);
|
|
158
|
-
requireLive(control);
|
|
159
168
|
const headerNames = decodeProtocol('binary application-header manifest', () => protocol.http.decodeBinaryHeaderNames(response.headers.get(protocol.http.BINARY_HEADERS_FIELD)));
|
|
160
169
|
const headers = binaryHeaders(response.headers, headerNames);
|
|
170
|
+
const invocation = decodeProtocol('binary InvocationId field', () => protocol.http.decodeInvocationId(response.headers.get(protocol.http.INVOCATION_FIELD)));
|
|
171
|
+
if (streaming) {
|
|
172
|
+
if (response.body === null)
|
|
173
|
+
throw new ProtocolError('streaming binary has no body.');
|
|
174
|
+
requireLive(control);
|
|
175
|
+
return {
|
|
176
|
+
kind: 'binary',
|
|
177
|
+
invocation,
|
|
178
|
+
value: {
|
|
179
|
+
body: new HttpByteStream(response.body, this.maximumResponseBytes, control),
|
|
180
|
+
mediaType,
|
|
181
|
+
...(response.status === 200 ? {} : { status: response.status }),
|
|
182
|
+
...(Object.keys(headers).length === 0 ? {} : { headers }),
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
const body = await readBoundedBody(response, this.maximumResponseBytes, control.signal);
|
|
187
|
+
requireLive(control);
|
|
161
188
|
const binary = decodeProtocol('binary response', () => protocol.decodeBinaryResponse({
|
|
162
189
|
kind: 'binary',
|
|
163
|
-
|
|
190
|
+
requestId,
|
|
191
|
+
invocation,
|
|
164
192
|
body,
|
|
165
193
|
mediaType,
|
|
194
|
+
status: response.status,
|
|
166
195
|
...(Object.keys(headers).length === 0 ? {} : { headers }),
|
|
167
196
|
}));
|
|
168
197
|
requireLive(control);
|
|
169
198
|
return {
|
|
170
199
|
kind: 'binary',
|
|
200
|
+
invocation: binary.invocation,
|
|
171
201
|
value: {
|
|
172
202
|
body: binary.body,
|
|
173
203
|
mediaType: binary.mediaType,
|
|
204
|
+
...(binary.status === 200 ? {} : { status: binary.status }),
|
|
174
205
|
...(binary.headers === undefined ? {} : { headers: binary.headers }),
|
|
175
206
|
},
|
|
176
207
|
};
|
|
177
208
|
}
|
|
178
209
|
nextRequestId() {
|
|
179
|
-
const
|
|
180
|
-
this.nextId =
|
|
181
|
-
return
|
|
210
|
+
const requestId = this.nextId;
|
|
211
|
+
this.nextId = requestId === Number.MAX_SAFE_INTEGER ? 1 : requestId + 1;
|
|
212
|
+
return requestId;
|
|
182
213
|
}
|
|
183
214
|
requestCodec() {
|
|
184
215
|
return this.codecName === 'msgpack' ? codecs.loadMsgpack() : Promise.resolve(codecs.json);
|
|
185
216
|
}
|
|
186
217
|
}
|
|
187
|
-
function redirectResult(
|
|
218
|
+
function redirectResult(response) {
|
|
188
219
|
return Object.freeze({
|
|
189
220
|
kind: 'redirect',
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
...(redirect.credential === undefined ? {} : { credential: redirect.credential }),
|
|
193
|
-
...(redirect.trace === undefined ? {} : { trace: redirect.trace }),
|
|
194
|
-
}),
|
|
221
|
+
invocation: response.invocation,
|
|
222
|
+
redirect: response.redirect,
|
|
195
223
|
});
|
|
196
224
|
}
|
|
197
225
|
function normalizeUrl(input) {
|
|
@@ -260,9 +288,8 @@ function transportFailure(input, control, parent, timeoutMs, url, phase, deliver
|
|
|
260
288
|
if (input instanceof ResponseError || input instanceof ProtocolError)
|
|
261
289
|
return input;
|
|
262
290
|
if (control.timedOut) {
|
|
263
|
-
return
|
|
291
|
+
return invocationFailure(`request timed out after ${timeoutMs}ms.`, 'timeout', {
|
|
264
292
|
cause: asError(input),
|
|
265
|
-
phase: 'timeout',
|
|
266
293
|
delivery,
|
|
267
294
|
});
|
|
268
295
|
}
|
|
@@ -270,9 +297,8 @@ function transportFailure(input, control, parent, timeoutMs, url, phase, deliver
|
|
|
270
297
|
return asError(parent.reason ?? input);
|
|
271
298
|
return input instanceof TransportError
|
|
272
299
|
? input
|
|
273
|
-
:
|
|
300
|
+
: invocationFailure(`Failed to communicate with the server at ${url}.`, phase, {
|
|
274
301
|
cause: asError(input),
|
|
275
|
-
phase,
|
|
276
302
|
delivery,
|
|
277
303
|
});
|
|
278
304
|
}
|
|
@@ -337,4 +363,3 @@ function hasControlCharacter(input) {
|
|
|
337
363
|
}
|
|
338
364
|
return false;
|
|
339
365
|
}
|
|
340
|
-
//# sourceMappingURL=transport.js.map
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
export type { RequestOptions, MissControl, StaleControl, Transport, TransportRequest, TransportResult, } from './transport.js';
|
|
2
2
|
export { asError, controlledSignal, positiveInteger, requireLive, type ControlledSignal, } from './deadline.js';
|
|
3
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/transport/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Result } from '@astrale-os/kernel-ports/functions';
|
|
2
1
|
import type { invocation as protocol } from '@astrale-os/kernel-protocol';
|
|
2
|
+
import type { Result } from '../client/result.js';
|
|
3
3
|
export interface RequestOptions {
|
|
4
4
|
readonly signal?: AbortSignal;
|
|
5
5
|
readonly timeoutMs?: number;
|
|
@@ -19,9 +19,11 @@ export interface TransportRequest {
|
|
|
19
19
|
export interface StaleControl {
|
|
20
20
|
readonly kind: 'stale';
|
|
21
21
|
readonly current: protocol.Stale['current'];
|
|
22
|
+
readonly invocation: protocol.InvocationId;
|
|
22
23
|
}
|
|
23
24
|
export interface MissControl {
|
|
24
25
|
readonly kind: 'miss';
|
|
26
|
+
readonly invocation: protocol.InvocationId;
|
|
25
27
|
}
|
|
26
28
|
export type TransportResult = Result | StaleControl | MissControl;
|
|
27
29
|
export interface Transport {
|
|
@@ -30,4 +32,3 @@ export interface Transport {
|
|
|
30
32
|
/** Optional owned-resource shutdown used by Client.close(). */
|
|
31
33
|
readonly close?: () => void;
|
|
32
34
|
}
|
|
33
|
-
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type * as codecs from '@astrale-os/kernel-protocol/codecs';
|
|
2
|
+
import * as protocol from '@astrale-os/kernel-protocol/invocation';
|
|
2
3
|
import type { ControlledSignal } from '../index.js';
|
|
3
4
|
import type { TransportResult } from '../index.js';
|
|
4
5
|
import type { ExchangeOwner } from './exchange.js';
|
|
@@ -29,10 +30,9 @@ export declare class WebSocketConnection implements ExchangeOwner {
|
|
|
29
30
|
connect(control: ControlledSignal): Promise<void>;
|
|
30
31
|
dispatch(request: protocol.Request, control: ControlledSignal, maximumBufferedItems: number): Promise<TransportResult>;
|
|
31
32
|
finish(exchange: WebSocketExchange, reusable: boolean, closeCode?: 1002 | 1008 | 1011): void;
|
|
32
|
-
cancel(exchange: WebSocketExchange,
|
|
33
|
+
cancel(exchange: WebSocketExchange, requestId: protocol.RequestId): void;
|
|
33
34
|
shutdown(reason?: Error, closeCode?: number, closeReason?: string): void;
|
|
34
35
|
private onOpen;
|
|
35
36
|
private onMessage;
|
|
36
37
|
private onFailure;
|
|
37
38
|
}
|
|
38
|
-
//# sourceMappingURL=connection.d.ts.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ProtocolError
|
|
1
|
+
import * as protocol from '@astrale-os/kernel-protocol/invocation';
|
|
2
|
+
import { ProtocolError } from '../../errors/index.js';
|
|
3
|
+
import { invocationFailure } from '../failure.js';
|
|
3
4
|
import { asError } from '../index.js';
|
|
4
5
|
import { WebSocketExchange } from './exchange.js';
|
|
5
6
|
const WS_CONNECTING = 0;
|
|
@@ -63,51 +64,45 @@ export class WebSocketConnection {
|
|
|
63
64
|
dispatch(request, control, maximumBufferedItems) {
|
|
64
65
|
if (!this.isOpen) {
|
|
65
66
|
control.close();
|
|
66
|
-
return Promise.reject(
|
|
67
|
-
phase: 'connect',
|
|
68
|
-
delivery: 'not-sent',
|
|
69
|
-
}));
|
|
67
|
+
return Promise.reject(invocationFailure('WebSocket connection is not available.', 'connect'));
|
|
70
68
|
}
|
|
71
|
-
const key = requestKey(request.
|
|
69
|
+
const key = requestKey(request.requestId);
|
|
72
70
|
if (this.active.has(key) || this.cancelled.has(key)) {
|
|
73
71
|
control.close();
|
|
74
72
|
return Promise.reject(new ProtocolError('WebSocket request ID is already in use.'));
|
|
75
73
|
}
|
|
76
74
|
if (this.active.size + this.cancelled.size >= this.maximumActiveInvocations) {
|
|
77
75
|
control.close();
|
|
78
|
-
return Promise.reject(
|
|
76
|
+
return Promise.reject(invocationFailure(`WebSocket connection exceeds maximumActiveInvocations (${this.maximumActiveInvocations}).`, 'send'));
|
|
79
77
|
}
|
|
80
78
|
const encoded = this.codec.encode(request);
|
|
81
79
|
const encodedBytes = frameSize(encoded);
|
|
82
80
|
if (encodedBytes > this.maximumRequestBytes) {
|
|
83
81
|
control.close();
|
|
84
|
-
return Promise.reject(
|
|
82
|
+
return Promise.reject(invocationFailure(`WebSocket request exceeds maximumRequestBytes (${this.maximumRequestBytes}).`, 'send'));
|
|
85
83
|
}
|
|
86
84
|
if (this.socket.bufferedAmount + encodedBytes > this.maximumBufferedBytes) {
|
|
87
85
|
control.close();
|
|
88
|
-
return Promise.reject(
|
|
86
|
+
return Promise.reject(invocationFailure(`WebSocket connection exceeds maximumBufferedBytes (${this.maximumBufferedBytes}).`, 'send'));
|
|
89
87
|
}
|
|
90
|
-
const exchange = new WebSocketExchange(this, request.
|
|
88
|
+
const exchange = new WebSocketExchange(this, request.requestId, control, maximumBufferedItems);
|
|
91
89
|
this.active.set(key, exchange);
|
|
92
90
|
return exchange.start((data) => this.socket.send(socketData(data)), encoded);
|
|
93
91
|
}
|
|
94
92
|
finish(exchange, reusable, closeCode = 1002) {
|
|
95
93
|
removeExchange(this.active, exchange);
|
|
96
94
|
if (!reusable) {
|
|
97
|
-
this.shutdown(
|
|
98
|
-
phase: 'receive',
|
|
99
|
-
delivery: 'not-sent',
|
|
100
|
-
}), closeCode, closeReason(closeCode));
|
|
95
|
+
this.shutdown(invocationFailure('WebSocket connection was closed after a binding failure.', 'receive'), closeCode, closeReason(closeCode));
|
|
101
96
|
}
|
|
102
97
|
}
|
|
103
|
-
cancel(exchange,
|
|
104
|
-
const key = requestKey(
|
|
98
|
+
cancel(exchange, requestId) {
|
|
99
|
+
const key = requestKey(requestId);
|
|
105
100
|
if (this.active.get(key) !== exchange)
|
|
106
101
|
return;
|
|
107
102
|
this.active.delete(key);
|
|
108
103
|
this.cancelled.add(key);
|
|
109
104
|
try {
|
|
110
|
-
const encoded = this.codec.encode(protocol.decodeCancelRequest({ version: protocol.VERSION, kind: 'cancel',
|
|
105
|
+
const encoded = this.codec.encode(protocol.decodeCancelRequest({ version: protocol.VERSION, kind: 'cancel', requestId }));
|
|
111
106
|
const bytes = frameSize(encoded);
|
|
112
107
|
if (bytes > this.maximumRequestBytes ||
|
|
113
108
|
this.socket.bufferedAmount + bytes > this.maximumBufferedBytes) {
|
|
@@ -116,17 +111,13 @@ export class WebSocketConnection {
|
|
|
116
111
|
this.socket.send(socketData(encoded));
|
|
117
112
|
}
|
|
118
113
|
catch (error) {
|
|
119
|
-
this.shutdown(
|
|
114
|
+
this.shutdown(invocationFailure('Failed to send WebSocket cancellation.', 'send', {
|
|
120
115
|
cause: asError(error),
|
|
121
|
-
phase: 'send',
|
|
122
116
|
delivery: 'unknown',
|
|
123
117
|
}), error instanceof WebSocketBindingFailure ? error.closeCode : 1011, error instanceof WebSocketBindingFailure ? error.closeReason : 'Client send failed');
|
|
124
118
|
}
|
|
125
119
|
}
|
|
126
|
-
shutdown(reason =
|
|
127
|
-
phase: 'closed',
|
|
128
|
-
delivery: 'not-sent',
|
|
129
|
-
}), closeCode = 1000, closeReason = 'Client closed') {
|
|
120
|
+
shutdown(reason = invocationFailure('WebSocket connection was closed.', 'closed'), closeCode = 1000, closeReason = 'Client closed') {
|
|
130
121
|
if (this.closedState)
|
|
131
122
|
return;
|
|
132
123
|
this.closedState = true;
|
|
@@ -151,7 +142,7 @@ export class WebSocketConnection {
|
|
|
151
142
|
return;
|
|
152
143
|
const expected = protocol.websocket.subprotocolFor(this.codec);
|
|
153
144
|
if (this.socket.protocol !== expected) {
|
|
154
|
-
this.shutdown(
|
|
145
|
+
this.shutdown(invocationFailure(`server selected WebSocket subprotocol ${JSON.stringify(this.socket.protocol)}; expected ${JSON.stringify(expected)}.`, 'connect'), 1002, 'Subprotocol mismatch');
|
|
155
146
|
return;
|
|
156
147
|
}
|
|
157
148
|
this.opened = true;
|
|
@@ -165,7 +156,7 @@ export class WebSocketConnection {
|
|
|
165
156
|
throw new WebSocketBindingFailure(`WebSocket frame exceeds maximumResponseBytes (${this.maximumResponseBytes}).`, 1009, 'Message too big');
|
|
166
157
|
}
|
|
167
158
|
const admitted = decodeFrame(this.codec, frame);
|
|
168
|
-
const key = requestKey(admitted.
|
|
159
|
+
const key = requestKey(admitted.requestId);
|
|
169
160
|
const exchange = this.active.get(key);
|
|
170
161
|
if (exchange !== undefined) {
|
|
171
162
|
exchange.receive(admitted);
|
|
@@ -186,10 +177,7 @@ export class WebSocketConnection {
|
|
|
186
177
|
onFailure(message) {
|
|
187
178
|
if (this.closedState)
|
|
188
179
|
return;
|
|
189
|
-
this.shutdown(
|
|
190
|
-
phase: this.opened ? 'receive' : 'connect',
|
|
191
|
-
delivery: 'not-sent',
|
|
192
|
-
}));
|
|
180
|
+
this.shutdown(invocationFailure(message, this.opened ? 'receive' : 'connect'));
|
|
193
181
|
}
|
|
194
182
|
}
|
|
195
183
|
async function normalizeFrame(input) {
|
|
@@ -225,7 +213,7 @@ function decodeFrame(codec, input) {
|
|
|
225
213
|
}
|
|
226
214
|
const decoded = codec.decode(input);
|
|
227
215
|
if (isKind(decoded, 'redirect'))
|
|
228
|
-
return protocol.
|
|
216
|
+
return protocol.decodeRedirectResponse(decoded);
|
|
229
217
|
if (isKind(decoded, 'stale'))
|
|
230
218
|
return protocol.decodeStale(decoded);
|
|
231
219
|
if (isKind(decoded, 'miss'))
|
|
@@ -283,8 +271,8 @@ function isKind(input, kind) {
|
|
|
283
271
|
!Array.isArray(input) &&
|
|
284
272
|
input.kind === kind);
|
|
285
273
|
}
|
|
286
|
-
function requestKey(
|
|
287
|
-
return
|
|
274
|
+
function requestKey(requestId) {
|
|
275
|
+
return requestId === null ? 'null:' : `${typeof requestId}:${String(requestId)}`;
|
|
288
276
|
}
|
|
289
277
|
function removeExchange(exchanges, exchange) {
|
|
290
278
|
for (const [key, active] of exchanges) {
|
|
@@ -294,4 +282,3 @@ function removeExchange(exchanges, exchange) {
|
|
|
294
282
|
return;
|
|
295
283
|
}
|
|
296
284
|
}
|
|
297
|
-
//# sourceMappingURL=connection.js.map
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import type { Value } from '@astrale-os/kernel-dsl/value';
|
|
2
|
-
import type
|
|
3
|
-
import
|
|
2
|
+
import type * as protocol from '@astrale-os/kernel-protocol/invocation';
|
|
3
|
+
import type { Stream } from '../../client/index.js';
|
|
4
4
|
import type { ControlledSignal } from '../index.js';
|
|
5
5
|
import type { TransportResult } from '../index.js';
|
|
6
6
|
export interface ExchangeOwner {
|
|
7
7
|
finish(exchange: WebSocketExchange, reusable: boolean, closeCode?: 1002 | 1008 | 1011): void;
|
|
8
|
-
cancel(exchange: WebSocketExchange,
|
|
8
|
+
cancel(exchange: WebSocketExchange, requestId: protocol.RequestId): void;
|
|
9
9
|
}
|
|
10
|
-
export type WebSocketInbound = protocol.BinaryResponse | protocol.
|
|
10
|
+
export type WebSocketInbound = protocol.BinaryResponse | protocol.RedirectResponse | protocol.Stale | protocol.Miss | protocol.Response | protocol.StreamFrame;
|
|
11
11
|
/** One correlated invocation within a multiplexed WebSocket connection. */
|
|
12
12
|
export declare class WebSocketExchange implements Stream {
|
|
13
13
|
private readonly owner;
|
|
14
|
-
private readonly
|
|
14
|
+
private readonly requestId;
|
|
15
15
|
private readonly control;
|
|
16
16
|
private readonly maximumBufferedItems;
|
|
17
17
|
private readonly result;
|
|
@@ -25,7 +25,8 @@ export declare class WebSocketExchange implements Stream {
|
|
|
25
25
|
private readonly waiters;
|
|
26
26
|
private terminal;
|
|
27
27
|
private sent;
|
|
28
|
-
|
|
28
|
+
private invocation?;
|
|
29
|
+
constructor(owner: ExchangeOwner, requestId: protocol.RequestId, control: ControlledSignal, maximumBufferedItems: number);
|
|
29
30
|
start(send: (data: string | Uint8Array) => void, encoded: string | Uint8Array): Promise<TransportResult>;
|
|
30
31
|
receive(input: WebSocketInbound): void;
|
|
31
32
|
connectionFailed(error: Error): void;
|
|
@@ -43,4 +44,3 @@ export declare class WebSocketExchange implements Stream {
|
|
|
43
44
|
private flushTerminal;
|
|
44
45
|
private abortFailure;
|
|
45
46
|
}
|
|
46
|
-
//# sourceMappingURL=exchange.d.ts.map
|