@astrale-os/kernel-client 0.6.0-beta.6 → 0.6.0-beta.61
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 +7 -6
- package/dist/auth/auth.js +2 -3
- package/dist/auth/authorization.d.ts +2 -3
- package/dist/auth/authorization.js +0 -1
- package/dist/auth/credential.d.ts +5 -1
- package/dist/auth/credential.js +6 -3
- package/dist/auth/identity.d.ts +6 -9
- package/dist/auth/identity.js +0 -1
- package/dist/auth/index.d.ts +3 -4
- package/dist/auth/index.js +2 -3
- package/dist/auth/register.d.ts +24 -0
- package/dist/auth/register.js +10 -0
- package/dist/client/admission.d.ts +4 -2
- package/dist/client/admission.js +8 -2
- package/dist/client/client.d.ts +0 -1
- package/dist/client/client.js +0 -1
- package/dist/client/credential.d.ts +0 -1
- package/dist/client/credential.js +0 -1
- package/dist/client/index.d.ts +0 -1
- package/dist/client/index.js +0 -1
- package/dist/client/request.d.ts +3 -3
- package/dist/client/request.js +3 -1
- package/dist/client/result.d.ts +3 -4
- package/dist/client/result.js +3 -1
- package/dist/client/routing-control.d.ts +0 -1
- package/dist/client/routing-control.js +0 -1
- 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 +0 -1
- package/dist/errors/miss-error.js +0 -1
- package/dist/errors/protocol-error.d.ts +0 -1
- package/dist/errors/protocol-error.js +0 -1
- package/dist/errors/response-error.d.ts +0 -1
- package/dist/errors/response-error.js +0 -1
- 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 +0 -1
- package/dist/errors/stale-route-error.js +0 -1
- package/dist/errors/transport-error.d.ts +18 -6
- package/dist/errors/transport-error.js +11 -7
- 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 +147 -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 +124 -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 +1 -2
- package/dist/graph/expectation.d.ts +3 -0
- package/dist/graph/expectation.js +6 -0
- package/dist/graph/graph.d.ts +12 -8
- package/dist/graph/graph.js +0 -1
- package/dist/graph/index.d.ts +2 -2
- package/dist/graph/index.js +1 -1
- package/dist/graph/mutation.d.ts +2 -4
- package/dist/graph/mutation.js +10 -2
- 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 +7 -7
- package/dist/graph/page/page.d.ts +5 -2
- package/dist/graph/page/page.js +0 -1
- package/dist/graph/page-contract.d.ts +1 -2
- package/dist/graph/page-contract.js +0 -1
- package/dist/graph/provenance.d.ts +14 -0
- package/dist/graph/provenance.js +42 -0
- package/dist/graph/query.d.ts +3 -1
- package/dist/graph/query.js +33 -13
- package/dist/graph/read.d.ts +3 -4
- package/dist/graph/read.js +6 -5
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -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 +1 -2
- package/dist/schema/admission.js +0 -1
- package/dist/schema/contracts.d.ts +6 -16
- package/dist/schema/contracts.js +0 -1
- package/dist/schema/index.d.ts +2 -3
- package/dist/schema/index.js +1 -2
- package/dist/schema/introspection.d.ts +1 -2
- package/dist/schema/introspection.js +5 -2
- package/dist/schema/operation.d.ts +0 -1
- package/dist/schema/operation.js +2 -3
- package/dist/schema/schema.d.ts +11 -10
- package/dist/schema/schema.js +80 -11
- package/dist/session/bound.d.ts +45 -0
- package/dist/session/bound.js +89 -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 +0 -1
- package/dist/session/context/policy.js +0 -1
- package/dist/session/discovery/bundle.d.ts +5 -2
- package/dist/session/discovery/bundle.js +34 -15
- package/dist/session/discovery/discovery.d.ts +4 -2
- package/dist/session/discovery/discovery.js +34 -6
- package/dist/session/discovery/index.d.ts +2 -1
- package/dist/session/discovery/index.js +0 -1
- package/dist/session/discovery/publication.d.ts +0 -1
- package/dist/session/discovery/publication.js +4 -4
- package/dist/session/discovery/snapshot.d.ts +0 -1
- 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 +4 -3
- package/dist/session/index.js +2 -1
- package/dist/session/reference.d.ts +18 -10
- package/dist/session/reference.js +31 -9
- package/dist/session/routing/auth.d.ts +0 -1
- package/dist/session/routing/auth.js +0 -1
- package/dist/session/routing/cache.d.ts +27 -8
- package/dist/session/routing/cache.js +218 -25
- package/dist/session/routing/dispatch.d.ts +3 -7
- package/dist/session/routing/dispatch.js +36 -26
- package/dist/session/routing/envelope.d.ts +2 -1
- package/dist/session/routing/envelope.js +14 -10
- package/dist/session/routing/index.d.ts +1 -3
- package/dist/session/routing/index.js +1 -2
- package/dist/session/routing/request.d.ts +0 -1
- package/dist/session/routing/request.js +0 -1
- package/dist/session/session.d.ts +16 -7
- package/dist/session/session.js +49 -30
- package/dist/session/session.typecheck.d.ts +0 -1
- package/dist/session/session.typecheck.js +87 -3
- package/dist/session/views/catalog.d.ts +0 -1
- package/dist/session/views/catalog.js +13 -5
- package/dist/session/views/index.d.ts +0 -1
- package/dist/session/views/index.js +0 -1
- package/dist/session/views/resolve.d.ts +0 -1
- package/dist/session/views/resolve.js +0 -1
- 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 +2 -2
- package/dist/store/memory.js +38 -15
- package/dist/store/mutation.d.ts +1 -2
- package/dist/store/mutation.js +6 -4
- 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 +2 -2
- package/dist/store/query-key.js +7 -3
- package/dist/store/shape.d.ts +4 -2
- package/dist/store/shape.js +4 -2
- package/dist/store/store.d.ts +2 -4
- package/dist/store/store.js +6 -5
- package/dist/store/store.typecheck.d.ts +0 -1
- package/dist/store/store.typecheck.js +3 -9
- package/dist/transport/auto/decision.d.ts +0 -1
- package/dist/transport/auto/decision.js +0 -1
- package/dist/transport/auto/fallback.d.ts +2 -2
- package/dist/transport/auto/fallback.js +10 -11
- 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 +5 -3
- 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 +0 -1
- package/dist/transport/http/response.js +0 -1
- package/dist/transport/http/stream.d.ts +0 -1
- package/dist/transport/http/stream.js +7 -7
- package/dist/transport/http/transport.d.ts +0 -1
- package/dist/transport/http/transport.js +43 -20
- package/dist/transport/index.d.ts +0 -1
- package/dist/transport/index.js +0 -1
- package/dist/transport/transport.d.ts +0 -1
- package/dist/transport/transport.js +0 -1
- package/dist/transport/websocket/connection.d.ts +0 -1
- package/dist/transport/websocket/connection.js +16 -26
- package/dist/transport/websocket/exchange.d.ts +0 -1
- package/dist/transport/websocket/exchange.js +5 -9
- 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 +7 -20
- package/package.json +12 -14
- 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 +0 -9
- package/dist/auth/provision.d.ts.map +0 -1
- package/dist/auth/provision.js +0 -11
- 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/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/page-contract.d.ts.map +0 -1
- package/dist/graph/page-contract.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/contracts.d.ts.map +0 -1
- package/dist/schema/contracts.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/operation.d.ts.map +0 -1
- package/dist/schema/operation.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/reference.d.ts.map +0 -1
- package/dist/session/reference.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/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/expectation.d.ts +0 -7
- package/dist/session/routing/expectation.d.ts.map +0 -1
- package/dist/session/routing/expectation.js +0 -2
- package/dist/session/routing/expectation.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
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { ProtocolError } from '../../errors/index.js';
|
|
2
|
+
import { asError } from '../index.js';
|
|
3
|
+
/** Single-consumer HTTP byte stream preserving invocation lifetime and backpressure. */
|
|
4
|
+
export class HttpByteStream {
|
|
5
|
+
maximumBytes;
|
|
6
|
+
control;
|
|
7
|
+
reader;
|
|
8
|
+
claimed = false;
|
|
9
|
+
terminal = false;
|
|
10
|
+
bytes = 0;
|
|
11
|
+
interruption;
|
|
12
|
+
constructor(body, maximumBytes, control) {
|
|
13
|
+
this.maximumBytes = maximumBytes;
|
|
14
|
+
this.control = control;
|
|
15
|
+
this.reader = body.getReader();
|
|
16
|
+
const abort = () => void this.interrupt(control.signal.reason);
|
|
17
|
+
if (control.signal.aborted)
|
|
18
|
+
abort();
|
|
19
|
+
else
|
|
20
|
+
control.signal.addEventListener('abort', abort, { once: true });
|
|
21
|
+
}
|
|
22
|
+
[Symbol.asyncIterator]() {
|
|
23
|
+
if (this.claimed)
|
|
24
|
+
throw new TypeError('streaming binary admits exactly one consumer.');
|
|
25
|
+
this.claimed = true;
|
|
26
|
+
return {
|
|
27
|
+
next: () => this.next(),
|
|
28
|
+
return: async () => {
|
|
29
|
+
await this.cancel('streaming binary consumer stopped');
|
|
30
|
+
return { done: true, value: undefined };
|
|
31
|
+
},
|
|
32
|
+
throw: async (error) => {
|
|
33
|
+
await this.cancel('streaming binary consumer failed');
|
|
34
|
+
throw error;
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
async cancel(reason = 'streaming binary cancelled') {
|
|
39
|
+
if (this.terminal)
|
|
40
|
+
return;
|
|
41
|
+
this.terminal = true;
|
|
42
|
+
this.control.cancel(reason);
|
|
43
|
+
await this.cancelReader(reason);
|
|
44
|
+
this.control.close();
|
|
45
|
+
}
|
|
46
|
+
async next() {
|
|
47
|
+
if (this.interruption !== undefined)
|
|
48
|
+
throw this.interruption;
|
|
49
|
+
if (this.terminal)
|
|
50
|
+
return { done: true, value: undefined };
|
|
51
|
+
try {
|
|
52
|
+
const next = await this.reader.read();
|
|
53
|
+
if (this.interruption !== undefined)
|
|
54
|
+
throw this.interruption;
|
|
55
|
+
if (next.done) {
|
|
56
|
+
this.terminal = true;
|
|
57
|
+
this.control.close();
|
|
58
|
+
return { done: true, value: undefined };
|
|
59
|
+
}
|
|
60
|
+
this.bytes += next.value.byteLength;
|
|
61
|
+
if (this.bytes > this.maximumBytes) {
|
|
62
|
+
throw new ProtocolError(`streaming binary exceeds maximumResponseBytes (${this.maximumBytes}).`);
|
|
63
|
+
}
|
|
64
|
+
return { done: false, value: new Uint8Array(next.value) };
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
await this.cancel(error);
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async interrupt(reason) {
|
|
72
|
+
if (this.terminal || this.interruption !== undefined)
|
|
73
|
+
return;
|
|
74
|
+
this.interruption = asError(reason ?? new Error('streaming binary was cancelled.'));
|
|
75
|
+
await this.cancelReader(this.interruption);
|
|
76
|
+
this.control.close();
|
|
77
|
+
}
|
|
78
|
+
async cancelReader(reason) {
|
|
79
|
+
try {
|
|
80
|
+
await this.reader.cancel(reason);
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
// Cancellation follows an already chosen terminal outcome.
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -6,4 +6,3 @@ export declare function requireId(expected: protocol.RequestId, received: protoc
|
|
|
6
6
|
export declare function decodeProtocol<T>(label: string, decode: () => T): T;
|
|
7
7
|
export declare function normalizeMediaType(input: string | null): string | undefined;
|
|
8
8
|
export declare function binaryHeaders(input: Headers, names: readonly string[]): Readonly<Record<string, string>>;
|
|
9
|
-
//# sourceMappingURL=response.d.ts.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as protocol from '@astrale-os/kernel-protocol/invocation';
|
|
2
2
|
import { ProtocolError, ResponseError, TransportError } from '../../errors/index.js';
|
|
3
|
+
import { invocationFailure } from '../failure.js';
|
|
3
4
|
import { asError } from '../index.js';
|
|
4
5
|
import { decodeProtocol, requireId } from './response.js';
|
|
5
6
|
export class HttpStream {
|
|
@@ -124,9 +125,8 @@ export class HttpStream {
|
|
|
124
125
|
}
|
|
125
126
|
abortFailure(reason) {
|
|
126
127
|
if (this.control.timedOut) {
|
|
127
|
-
return
|
|
128
|
+
return invocationFailure('stream exceeded its invocation timeout.', 'timeout', {
|
|
128
129
|
cause: asError(reason),
|
|
129
|
-
phase: 'timeout',
|
|
130
130
|
delivery: 'unknown',
|
|
131
131
|
invocation: this.invocation,
|
|
132
132
|
});
|
|
@@ -138,11 +138,12 @@ function retainInvocationId(input, invocation) {
|
|
|
138
138
|
if (input instanceof ProtocolError && input.invocation === undefined) {
|
|
139
139
|
return new ProtocolError(input.message, { cause: input, invocation });
|
|
140
140
|
}
|
|
141
|
-
if (input instanceof TransportError &&
|
|
142
|
-
|
|
141
|
+
if (input instanceof TransportError &&
|
|
142
|
+
input.context.kind === 'invocation' &&
|
|
143
|
+
input.context.invocation === undefined) {
|
|
144
|
+
return invocationFailure(input.message, input.phase, {
|
|
143
145
|
cause: input,
|
|
144
|
-
|
|
145
|
-
delivery: input.delivery,
|
|
146
|
+
delivery: input.context.delivery,
|
|
146
147
|
invocation,
|
|
147
148
|
});
|
|
148
149
|
}
|
|
@@ -211,4 +212,3 @@ class LengthPrefixedFrames {
|
|
|
211
212
|
return output;
|
|
212
213
|
}
|
|
213
214
|
}
|
|
214
|
-
//# sourceMappingURL=stream.js.map
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import * as codecs from '@astrale-os/kernel-protocol/codecs';
|
|
2
2
|
import * as protocol from '@astrale-os/kernel-protocol/invocation';
|
|
3
3
|
import { ProtocolError, ResponseError, TransportError } from '../../errors/index.js';
|
|
4
|
+
import { invocationFailure } from '../failure.js';
|
|
4
5
|
import { asError, controlledSignal, positiveInteger, requireLive, } from '../index.js';
|
|
6
|
+
import { HttpByteStream } from './byte-stream.js';
|
|
5
7
|
import { binaryHeaders, codecForResponse, decodeProtocol, normalizeMediaType, readBoundedBody, requireId, } from './response.js';
|
|
6
8
|
import { HttpStream } from './stream.js';
|
|
7
9
|
const DEFAULT_TIMEOUT_MS = 30_000;
|
|
@@ -49,7 +51,7 @@ export class HttpTransport {
|
|
|
49
51
|
try {
|
|
50
52
|
requireLive(control);
|
|
51
53
|
if (encodedByteLength(encoded) > this.maximumRequestBytes) {
|
|
52
|
-
throw
|
|
54
|
+
throw invocationFailure(`request exceeds maximumRequestBytes (${this.maximumRequestBytes}).`, 'send');
|
|
53
55
|
}
|
|
54
56
|
phase = 'send';
|
|
55
57
|
delivery = 'unknown';
|
|
@@ -59,12 +61,17 @@ export class HttpTransport {
|
|
|
59
61
|
if (response.status >= 300 && response.status < 400) {
|
|
60
62
|
throw new ProtocolError('server returned a network redirect.');
|
|
61
63
|
}
|
|
62
|
-
requireNoStore(response);
|
|
63
64
|
const streamFraming = response.headers.get(protocol.http.STREAM_FRAMING_FIELD);
|
|
64
65
|
const binaryId = response.headers.get(protocol.http.REQUEST_ID_FIELD);
|
|
65
66
|
const binaryManifest = response.headers.get(protocol.http.BINARY_HEADERS_FIELD);
|
|
67
|
+
const binaryDelivery = response.headers.get(protocol.http.BINARY_DELIVERY_FIELD);
|
|
66
68
|
const hasStreamSignal = streamFraming !== null;
|
|
67
|
-
const hasBinarySignal = binaryId !== null || binaryManifest !== null;
|
|
69
|
+
const hasBinarySignal = binaryId !== null || binaryManifest !== null || binaryDelivery !== null;
|
|
70
|
+
const responseCodec = await codecForResponse(response.headers.get('content-type'));
|
|
71
|
+
if (!response.ok && responseCodec === undefined && !hasStreamSignal && !hasBinarySignal) {
|
|
72
|
+
throw invocationFailure(`server returned HTTP ${response.status} without an invocation response.`, 'receive', { delivery: 'unknown' });
|
|
73
|
+
}
|
|
74
|
+
requireNoStore(response);
|
|
68
75
|
if (hasStreamSignal && hasBinarySignal) {
|
|
69
76
|
throw new ProtocolError('server returned conflicting stream and binary response signals.');
|
|
70
77
|
}
|
|
@@ -72,9 +79,14 @@ export class HttpTransport {
|
|
|
72
79
|
if (binaryId === null || binaryManifest === null) {
|
|
73
80
|
throw new ProtocolError('server returned an incomplete binary response signal.');
|
|
74
81
|
}
|
|
75
|
-
|
|
82
|
+
if (binaryDelivery !== null && binaryDelivery !== protocol.http.STREAMING_BINARY_DELIVERY) {
|
|
83
|
+
throw new ProtocolError('server returned an unsupported binary delivery signal.');
|
|
84
|
+
}
|
|
85
|
+
const binary = await this.decodeBinary(response, requestId, binaryId, binaryDelivery !== null, control);
|
|
86
|
+
if (!(binary.value.body instanceof Uint8Array))
|
|
87
|
+
handedOff = true;
|
|
88
|
+
return binary;
|
|
76
89
|
}
|
|
77
|
-
const responseCodec = await codecForResponse(response.headers.get('content-type'));
|
|
78
90
|
if (responseCodec === undefined) {
|
|
79
91
|
throw new ProtocolError(`server returned unsupported Content-Type ${JSON.stringify(response.headers.get('content-type'))}.`);
|
|
80
92
|
}
|
|
@@ -132,9 +144,9 @@ export class HttpTransport {
|
|
|
132
144
|
}
|
|
133
145
|
}
|
|
134
146
|
async fetchResponse(codec, encoded, trace, control) {
|
|
135
|
-
|
|
147
|
+
const init = {
|
|
136
148
|
method: 'POST',
|
|
137
|
-
redirect: '
|
|
149
|
+
redirect: 'manual',
|
|
138
150
|
credentials: 'omit',
|
|
139
151
|
cache: 'no-store',
|
|
140
152
|
referrerPolicy: 'no-referrer',
|
|
@@ -146,12 +158,10 @@ export class HttpTransport {
|
|
|
146
158
|
},
|
|
147
159
|
body: toBody(encoded),
|
|
148
160
|
signal: control.signal,
|
|
149
|
-
}
|
|
161
|
+
};
|
|
162
|
+
return this.fetchImpl(this.url, init);
|
|
150
163
|
}
|
|
151
|
-
async decodeBinary(response, requestId, binaryId, control) {
|
|
152
|
-
if (!response.ok) {
|
|
153
|
-
throw new ProtocolError('server returned binary data with an error status.');
|
|
154
|
-
}
|
|
164
|
+
async decodeBinary(response, requestId, binaryId, streaming, control) {
|
|
155
165
|
if (binaryId !== String(requestId)) {
|
|
156
166
|
throw new ProtocolError(`binary response requestId ${JSON.stringify(binaryId)} does not match request requestId ${requestId}.`);
|
|
157
167
|
}
|
|
@@ -159,17 +169,33 @@ export class HttpTransport {
|
|
|
159
169
|
if (mediaType === undefined) {
|
|
160
170
|
throw new ProtocolError('binary response has no media type.');
|
|
161
171
|
}
|
|
162
|
-
const body = await readBoundedBody(response, this.maximumResponseBytes, control.signal);
|
|
163
|
-
requireLive(control);
|
|
164
172
|
const headerNames = decodeProtocol('binary application-header manifest', () => protocol.http.decodeBinaryHeaderNames(response.headers.get(protocol.http.BINARY_HEADERS_FIELD)));
|
|
165
173
|
const headers = binaryHeaders(response.headers, headerNames);
|
|
166
174
|
const invocation = decodeProtocol('binary InvocationId field', () => protocol.http.decodeInvocationId(response.headers.get(protocol.http.INVOCATION_FIELD)));
|
|
175
|
+
if (streaming) {
|
|
176
|
+
if (response.body === null)
|
|
177
|
+
throw new ProtocolError('streaming binary has no body.');
|
|
178
|
+
requireLive(control);
|
|
179
|
+
return {
|
|
180
|
+
kind: 'binary',
|
|
181
|
+
invocation,
|
|
182
|
+
value: {
|
|
183
|
+
body: new HttpByteStream(response.body, this.maximumResponseBytes, control),
|
|
184
|
+
mediaType,
|
|
185
|
+
...(response.status === 200 ? {} : { status: response.status }),
|
|
186
|
+
...(Object.keys(headers).length === 0 ? {} : { headers }),
|
|
187
|
+
},
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
const body = await readBoundedBody(response, this.maximumResponseBytes, control.signal);
|
|
191
|
+
requireLive(control);
|
|
167
192
|
const binary = decodeProtocol('binary response', () => protocol.decodeBinaryResponse({
|
|
168
193
|
kind: 'binary',
|
|
169
194
|
requestId,
|
|
170
195
|
invocation,
|
|
171
196
|
body,
|
|
172
197
|
mediaType,
|
|
198
|
+
status: response.status,
|
|
173
199
|
...(Object.keys(headers).length === 0 ? {} : { headers }),
|
|
174
200
|
}));
|
|
175
201
|
requireLive(control);
|
|
@@ -179,6 +205,7 @@ export class HttpTransport {
|
|
|
179
205
|
value: {
|
|
180
206
|
body: binary.body,
|
|
181
207
|
mediaType: binary.mediaType,
|
|
208
|
+
...(binary.status === 200 ? {} : { status: binary.status }),
|
|
182
209
|
...(binary.headers === undefined ? {} : { headers: binary.headers }),
|
|
183
210
|
},
|
|
184
211
|
};
|
|
@@ -265,9 +292,8 @@ function transportFailure(input, control, parent, timeoutMs, url, phase, deliver
|
|
|
265
292
|
if (input instanceof ResponseError || input instanceof ProtocolError)
|
|
266
293
|
return input;
|
|
267
294
|
if (control.timedOut) {
|
|
268
|
-
return
|
|
295
|
+
return invocationFailure(`request timed out after ${timeoutMs}ms.`, 'timeout', {
|
|
269
296
|
cause: asError(input),
|
|
270
|
-
phase: 'timeout',
|
|
271
297
|
delivery,
|
|
272
298
|
});
|
|
273
299
|
}
|
|
@@ -275,9 +301,8 @@ function transportFailure(input, control, parent, timeoutMs, url, phase, deliver
|
|
|
275
301
|
return asError(parent.reason ?? input);
|
|
276
302
|
return input instanceof TransportError
|
|
277
303
|
? input
|
|
278
|
-
:
|
|
304
|
+
: invocationFailure(`Failed to communicate with the server at ${url}.`, phase, {
|
|
279
305
|
cause: asError(input),
|
|
280
|
-
phase,
|
|
281
306
|
delivery,
|
|
282
307
|
});
|
|
283
308
|
}
|
|
@@ -305,7 +330,6 @@ const RESERVED_REQUEST_HEADERS = new Set([
|
|
|
305
330
|
'content-length',
|
|
306
331
|
'content-type',
|
|
307
332
|
'cookie',
|
|
308
|
-
'expect',
|
|
309
333
|
'forwarded',
|
|
310
334
|
'host',
|
|
311
335
|
'keep-alive',
|
|
@@ -342,4 +366,3 @@ function hasControlCharacter(input) {
|
|
|
342
366
|
}
|
|
343
367
|
return false;
|
|
344
368
|
}
|
|
345
|
-
//# 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,6 @@
|
|
|
1
1
|
import * as protocol from '@astrale-os/kernel-protocol/invocation';
|
|
2
|
-
import { ProtocolError
|
|
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,10 +64,7 @@ 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
69
|
const key = requestKey(request.requestId);
|
|
72
70
|
if (this.active.has(key) || this.cancelled.has(key)) {
|
|
@@ -75,17 +73,17 @@ export class WebSocketConnection {
|
|
|
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
|
-
if (this.socket
|
|
84
|
+
if (socketBufferedAmount(this.socket) + 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
88
|
const exchange = new WebSocketExchange(this, request.requestId, control, maximumBufferedItems);
|
|
91
89
|
this.active.set(key, exchange);
|
|
@@ -94,10 +92,7 @@ export class WebSocketConnection {
|
|
|
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
98
|
cancel(exchange, requestId) {
|
|
@@ -110,23 +105,19 @@ export class WebSocketConnection {
|
|
|
110
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
|
-
this.socket
|
|
108
|
+
socketBufferedAmount(this.socket) + bytes > this.maximumBufferedBytes) {
|
|
114
109
|
throw new WebSocketBindingFailure('WebSocket cancellation exceeds the connection send policy.', 1008, 'Client send policy exceeded');
|
|
115
110
|
}
|
|
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;
|
|
@@ -186,12 +177,12 @@ 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
|
}
|
|
183
|
+
function socketBufferedAmount(socket) {
|
|
184
|
+
return socket.bufferedAmount ?? 0;
|
|
185
|
+
}
|
|
195
186
|
async function normalizeFrame(input) {
|
|
196
187
|
if (typeof input === 'string')
|
|
197
188
|
return input;
|
|
@@ -294,4 +285,3 @@ function removeExchange(exchanges, exchange) {
|
|
|
294
285
|
return;
|
|
295
286
|
}
|
|
296
287
|
}
|
|
297
|
-
//# sourceMappingURL=connection.js.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as errors from '@astrale-os/kernel-protocol/errors';
|
|
2
|
-
import { ProtocolError, ResponseError
|
|
2
|
+
import { ProtocolError, ResponseError } from '../../errors/index.js';
|
|
3
|
+
import { invocationFailure } from '../failure.js';
|
|
3
4
|
import { asError } from '../index.js';
|
|
4
5
|
/** One correlated invocation within a multiplexed WebSocket connection. */
|
|
5
6
|
export class WebSocketExchange {
|
|
@@ -44,10 +45,8 @@ export class WebSocketExchange {
|
|
|
44
45
|
this.sent = true;
|
|
45
46
|
}
|
|
46
47
|
catch (error) {
|
|
47
|
-
this.fail(
|
|
48
|
+
this.fail(invocationFailure('Failed to send the WebSocket invocation.', 'send', {
|
|
48
49
|
cause: asError(error),
|
|
49
|
-
phase: 'send',
|
|
50
|
-
delivery: 'not-sent',
|
|
51
50
|
}), 1011);
|
|
52
51
|
}
|
|
53
52
|
return this.result;
|
|
@@ -70,9 +69,8 @@ export class WebSocketExchange {
|
|
|
70
69
|
}
|
|
71
70
|
connectionFailed(error) {
|
|
72
71
|
this.fail(this.sent
|
|
73
|
-
?
|
|
72
|
+
? invocationFailure(error.message, 'receive', {
|
|
74
73
|
cause: error,
|
|
75
|
-
phase: 'receive',
|
|
76
74
|
delivery: 'unknown',
|
|
77
75
|
...(this.invocation === undefined ? {} : { invocation: this.invocation }),
|
|
78
76
|
})
|
|
@@ -257,9 +255,8 @@ export class WebSocketExchange {
|
|
|
257
255
|
}
|
|
258
256
|
abortFailure() {
|
|
259
257
|
if (this.control.timedOut) {
|
|
260
|
-
return
|
|
258
|
+
return invocationFailure('WebSocket invocation exceeded its timeout.', 'timeout', {
|
|
261
259
|
cause: asError(this.control.signal.reason),
|
|
262
|
-
phase: 'timeout',
|
|
263
260
|
delivery: this.sent ? 'unknown' : 'not-sent',
|
|
264
261
|
...(this.invocation === undefined ? {} : { invocation: this.invocation }),
|
|
265
262
|
});
|
|
@@ -301,4 +298,3 @@ function isKind(input, kind) {
|
|
|
301
298
|
!Array.isArray(input) &&
|
|
302
299
|
input.kind === kind);
|
|
303
300
|
}
|
|
304
|
-
//# sourceMappingURL=exchange.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as codecs from '@astrale-os/kernel-protocol/codecs';
|
|
2
2
|
import * as protocol from '@astrale-os/kernel-protocol/invocation';
|
|
3
3
|
import { ProtocolError, ResponseError, TransportError } from '../../errors/index.js';
|
|
4
|
+
import { invocationFailure } from '../failure.js';
|
|
4
5
|
import { asError, controlledSignal, positiveInteger, requireLive } from '../index.js';
|
|
5
6
|
import { WebSocketConnection } from './connection.js';
|
|
6
7
|
const DEFAULT_TIMEOUT_MS = 30_000;
|
|
@@ -45,18 +46,12 @@ export class WebSocketTransport {
|
|
|
45
46
|
}
|
|
46
47
|
async dispatch(input, options = {}) {
|
|
47
48
|
if (this.stopped) {
|
|
48
|
-
throw
|
|
49
|
-
phase: 'closed',
|
|
50
|
-
delivery: 'not-sent',
|
|
51
|
-
});
|
|
49
|
+
throw invocationFailure('WebSocketTransport is closed.', 'closed');
|
|
52
50
|
}
|
|
53
51
|
const timeoutMs = positiveInteger(options.timeoutMs ?? this.timeoutMs, 'timeoutMs');
|
|
54
52
|
const codec = await this.codec();
|
|
55
53
|
if (this.stopped) {
|
|
56
|
-
throw
|
|
57
|
-
phase: 'closed',
|
|
58
|
-
delivery: 'not-sent',
|
|
59
|
-
});
|
|
54
|
+
throw invocationFailure('WebSocketTransport is closed.', 'closed');
|
|
60
55
|
}
|
|
61
56
|
const request = protocol.decodeRequest({
|
|
62
57
|
version: protocol.VERSION,
|
|
@@ -87,10 +82,7 @@ export class WebSocketTransport {
|
|
|
87
82
|
return;
|
|
88
83
|
this.stopped = true;
|
|
89
84
|
this.connection = undefined;
|
|
90
|
-
const failure =
|
|
91
|
-
phase: 'closed',
|
|
92
|
-
delivery: 'not-sent',
|
|
93
|
-
});
|
|
85
|
+
const failure = invocationFailure('WebSocketTransport is closed.', 'closed');
|
|
94
86
|
for (const connection of this.connections)
|
|
95
87
|
connection.shutdown(failure);
|
|
96
88
|
}
|
|
@@ -148,7 +140,7 @@ function admitCodecName(input) {
|
|
|
148
140
|
throw new TypeError('codec must be "json" or "msgpack".');
|
|
149
141
|
}
|
|
150
142
|
function admitWebSocket(input) {
|
|
151
|
-
const implementation = input ??
|
|
143
|
+
const implementation = input ?? (typeof WebSocket === 'undefined' ? undefined : WebSocket);
|
|
152
144
|
if (typeof implementation !== 'function') {
|
|
153
145
|
throw new TypeError('WebSocketTransport requires a WebSocket implementation.');
|
|
154
146
|
}
|
|
@@ -160,18 +152,13 @@ function transportFailure(input, control, parent, timeoutMs, url) {
|
|
|
160
152
|
if (input instanceof TransportError)
|
|
161
153
|
return input;
|
|
162
154
|
if (control.timedOut) {
|
|
163
|
-
return
|
|
155
|
+
return invocationFailure(`WebSocket invocation timed out after ${timeoutMs}ms.`, 'timeout', {
|
|
164
156
|
cause: asError(input),
|
|
165
|
-
phase: 'timeout',
|
|
166
|
-
delivery: 'not-sent',
|
|
167
157
|
});
|
|
168
158
|
}
|
|
169
159
|
if (parent?.aborted)
|
|
170
160
|
return asError(parent.reason ?? input);
|
|
171
|
-
return
|
|
161
|
+
return invocationFailure(`Failed to communicate with the server at ${url}.`, 'connect', {
|
|
172
162
|
cause: asError(input),
|
|
173
|
-
phase: 'connect',
|
|
174
|
-
delivery: 'not-sent',
|
|
175
163
|
});
|
|
176
164
|
}
|
|
177
|
-
//# sourceMappingURL=transport.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrale-os/kernel-client",
|
|
3
|
-
"version": "0.6.0-beta.
|
|
3
|
+
"version": "0.6.0-beta.61",
|
|
4
4
|
"description": "Universal Client — protocol-first, transport-agnostic",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"astrale",
|
|
@@ -65,31 +65,29 @@
|
|
|
65
65
|
"access": "public"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@astrale-os/kernel-core": "
|
|
69
|
-
"@astrale-os/kernel-dsl": "
|
|
70
|
-
"@astrale-os/kernel-protocol": "
|
|
68
|
+
"@astrale-os/kernel-core": "0.9.0-beta.46",
|
|
69
|
+
"@astrale-os/kernel-dsl": "0.2.0-beta.33",
|
|
70
|
+
"@astrale-os/kernel-protocol": "0.5.0-beta.52",
|
|
71
71
|
"@tanstack/pacer": "0.20.1",
|
|
72
|
-
"msgpackr": "^
|
|
72
|
+
"msgpackr": "^2.0.5"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
|
+
"@astrale-os/kernel-server": "0.5.0-beta.54",
|
|
75
76
|
"@astrale/typescript-config": "npm:@jsr/astrale__typescript-config@~1.1.0",
|
|
76
77
|
"@types/node": "^22.0.0",
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"vitest": "^3.1.4",
|
|
80
|
-
"@astrale-os/kernel-server": "^0.5.0-beta.6"
|
|
78
|
+
"typescript": "7.0.2",
|
|
79
|
+
"vitest": "^4.1.10"
|
|
81
80
|
},
|
|
82
81
|
"scripts": {
|
|
83
|
-
"build": "
|
|
84
|
-
"dev": "
|
|
85
|
-
"typecheck": "
|
|
82
|
+
"build": "tsc",
|
|
83
|
+
"dev": "tsc --watch",
|
|
84
|
+
"typecheck": "tsc --noEmit",
|
|
86
85
|
"test": "vitest run",
|
|
87
86
|
"test:boundary:protocol": "vitest run --config vitest.protocol-boundary.config.ts",
|
|
88
87
|
"test:boundary:server": "vitest run --config vitest.server-boundary.config.ts",
|
|
89
88
|
"test:file": "vitest run",
|
|
90
89
|
"test:package": "node scripts/verify-packed-package.mjs",
|
|
91
90
|
"test:watch": "vitest",
|
|
92
|
-
"clean": "rm -rf dist"
|
|
93
|
-
"preinstall": "node -e \"try{require('./.check-workspace.cjs')}catch{}\""
|
|
91
|
+
"clean": "rm -rf dist"
|
|
94
92
|
}
|
|
95
93
|
}
|
package/dist/auth/auth.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../auth/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EAChB,MAAM,8BAA8B,CAAA;AACrC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AAE5D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAO/C,MAAM,MAAM,QAAQ,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,cAAc,KAAK,OAAO,CAAC,KAAK,CAAC,CAAA;AAEnG,MAAM,WAAW,OAAO;IACtB,SAAS,CAAC,KAAK,EAAE,gBAAgB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAAA;IACtF,MAAM,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;IACnD,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAA;IAC5E,GAAG,CAAC,KAAK,EAAE,mBAAmB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAC3E,IAAI,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;IAC7E,QAAQ,CACN,QAAQ,EAAE,UAAU,EACpB,KAAK,EAAE,eAAe,EACtB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,gBAAgB,CAAC,CAAA;CAC7B;AAED,0FAA0F;AAC1F,wBAAgB,UAAU,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAQlD"}
|