@astrale-os/kernel-client 0.6.0-beta.8 → 0.6.0-beta.80
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 +25 -10
- package/dist/auth/auth.js +5 -7
- package/dist/auth/authorization.d.ts +6 -4
- package/dist/auth/authorization.js +25 -6
- package/dist/auth/credential.d.ts +11 -2
- 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 +4 -5
- package/dist/auth/index.js +2 -4
- 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 +4 -3
- package/dist/client/client.js +13 -3
- package/dist/client/credential.d.ts +4 -3
- package/dist/client/credential.js +7 -3
- package/dist/client/index.d.ts +1 -2
- package/dist/client/index.js +1 -2
- package/dist/client/request.d.ts +10 -4
- package/dist/client/request.js +33 -6
- 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/exchange-error.d.ts +19 -0
- package/dist/errors/exchange-error.js +9 -0
- package/dist/errors/index.d.ts +8 -7
- package/dist/errors/index.js +8 -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 +3 -3
- 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 +9 -2
- package/dist/schema/operation.d.ts +0 -1
- package/dist/schema/operation.js +2 -3
- package/dist/schema/schema.d.ts +13 -10
- package/dist/schema/schema.js +83 -11
- package/dist/session/admission.d.ts +6 -0
- package/dist/session/admission.js +59 -0
- package/dist/session/bound.d.ts +48 -0
- package/dist/session/bound.js +110 -0
- package/dist/session/content.d.ts +27 -0
- package/dist/session/content.js +158 -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 +5 -2
- 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/credential/index.d.ts +1 -0
- package/dist/session/credential/index.js +1 -0
- package/dist/session/credential/limits.d.ts +12 -0
- package/dist/session/credential/limits.js +12 -0
- package/dist/session/credential/provider.d.ts +56 -0
- package/dist/session/credential/provider.js +236 -0
- 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 +3 -1
- package/dist/session/discovery/index.js +1 -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/exchange/domain.d.ts +27 -0
- package/dist/session/exchange/domain.js +63 -0
- package/dist/session/exchange/exchange.d.ts +54 -0
- package/dist/session/exchange/exchange.js +58 -0
- package/dist/session/exchange/index.d.ts +5 -0
- package/dist/session/exchange/index.js +5 -0
- package/dist/session/exchange/issuer.d.ts +18 -0
- package/dist/session/exchange/issuer.js +149 -0
- package/dist/session/exchange/limits.d.ts +10 -0
- package/dist/session/exchange/limits.js +10 -0
- package/dist/session/exchange/options.d.ts +29 -0
- package/dist/session/exchange/options.js +57 -0
- package/dist/session/exchange/presentation.d.ts +18 -0
- package/dist/session/exchange/presentation.js +73 -0
- package/dist/session/exchange/source.d.ts +32 -0
- package/dist/session/exchange/source.js +78 -0
- package/dist/session/execution.d.ts +65 -0
- package/dist/session/execution.js +34 -0
- package/dist/session/index.d.ts +9 -4
- package/dist/session/index.js +4 -1
- package/dist/session/reference.d.ts +40 -12
- package/dist/session/reference.js +56 -14
- package/dist/session/routing/auth.d.ts +10 -1
- package/dist/session/routing/auth.js +8 -2
- package/dist/session/routing/cache.d.ts +27 -8
- package/dist/session/routing/cache.js +218 -25
- package/dist/session/routing/dispatch.d.ts +15 -8
- package/dist/session/routing/dispatch.js +121 -48
- package/dist/session/routing/envelope.d.ts +2 -1
- package/dist/session/routing/envelope.js +14 -10
- package/dist/session/routing/index.d.ts +3 -5
- package/dist/session/routing/index.js +2 -3
- package/dist/session/routing/request.d.ts +9 -1
- package/dist/session/routing/request.js +17 -1
- package/dist/session/session.d.ts +41 -8
- package/dist/session/session.js +129 -41
- package/dist/session/session.typecheck.d.ts +0 -1
- package/dist/session/session.typecheck.js +172 -3
- package/dist/session/views/catalog.d.ts +0 -1
- package/dist/session/views/catalog.js +14 -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 +18 -0
- package/dist/transport/http/byte-stream.js +94 -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 +3 -1
- package/dist/transport/http/transport.js +87 -30
- 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,9 @@
|
|
|
1
|
+
import { TransportError } from '../errors/index.js';
|
|
2
|
+
/** Create invocation transport evidence with the common not-sent default. */
|
|
3
|
+
export function invocationFailure(message, phase, evidence = {}) {
|
|
4
|
+
return TransportError.invocation(message, {
|
|
5
|
+
...evidence,
|
|
6
|
+
phase,
|
|
7
|
+
delivery: evidence.delivery ?? 'not-sent',
|
|
8
|
+
});
|
|
9
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ControlledSignal } from '../index.js';
|
|
2
|
+
/** Single-consumer HTTP byte stream preserving invocation lifetime and backpressure. */
|
|
3
|
+
export declare class HttpByteStream implements AsyncIterable<Uint8Array> {
|
|
4
|
+
private readonly maximumBytes;
|
|
5
|
+
private readonly control;
|
|
6
|
+
private readonly expectedBytes?;
|
|
7
|
+
private readonly reader;
|
|
8
|
+
private claimed;
|
|
9
|
+
private terminal;
|
|
10
|
+
private bytes;
|
|
11
|
+
private interruption;
|
|
12
|
+
constructor(body: ReadableStream<Uint8Array>, maximumBytes: number, control: ControlledSignal, expectedBytes?: number | undefined);
|
|
13
|
+
[Symbol.asyncIterator](): AsyncIterator<Uint8Array>;
|
|
14
|
+
cancel(reason?: unknown): Promise<void>;
|
|
15
|
+
private next;
|
|
16
|
+
private interrupt;
|
|
17
|
+
private cancelReader;
|
|
18
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
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
|
+
expectedBytes;
|
|
8
|
+
reader;
|
|
9
|
+
claimed = false;
|
|
10
|
+
terminal = false;
|
|
11
|
+
bytes = 0;
|
|
12
|
+
interruption;
|
|
13
|
+
constructor(body, maximumBytes, control, expectedBytes) {
|
|
14
|
+
this.maximumBytes = maximumBytes;
|
|
15
|
+
this.control = control;
|
|
16
|
+
this.expectedBytes = expectedBytes;
|
|
17
|
+
this.reader = body.getReader();
|
|
18
|
+
const abort = () => void this.interrupt(control.signal.reason);
|
|
19
|
+
if (control.signal.aborted)
|
|
20
|
+
abort();
|
|
21
|
+
else
|
|
22
|
+
control.signal.addEventListener('abort', abort, { once: true });
|
|
23
|
+
}
|
|
24
|
+
[Symbol.asyncIterator]() {
|
|
25
|
+
if (this.claimed)
|
|
26
|
+
throw new TypeError('streaming binary admits exactly one consumer.');
|
|
27
|
+
this.claimed = true;
|
|
28
|
+
return {
|
|
29
|
+
next: () => this.next(),
|
|
30
|
+
return: async () => {
|
|
31
|
+
await this.cancel('streaming binary consumer stopped');
|
|
32
|
+
return { done: true, value: undefined };
|
|
33
|
+
},
|
|
34
|
+
throw: async (error) => {
|
|
35
|
+
await this.cancel('streaming binary consumer failed');
|
|
36
|
+
throw error;
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
async cancel(reason = 'streaming binary cancelled') {
|
|
41
|
+
if (this.terminal)
|
|
42
|
+
return;
|
|
43
|
+
this.terminal = true;
|
|
44
|
+
this.control.cancel(reason);
|
|
45
|
+
await this.cancelReader(reason);
|
|
46
|
+
this.control.close();
|
|
47
|
+
}
|
|
48
|
+
async next() {
|
|
49
|
+
if (this.interruption !== undefined)
|
|
50
|
+
throw this.interruption;
|
|
51
|
+
if (this.terminal)
|
|
52
|
+
return { done: true, value: undefined };
|
|
53
|
+
try {
|
|
54
|
+
const next = await this.reader.read();
|
|
55
|
+
if (this.interruption !== undefined)
|
|
56
|
+
throw this.interruption;
|
|
57
|
+
if (next.done) {
|
|
58
|
+
if (this.expectedBytes !== undefined && this.bytes !== this.expectedBytes) {
|
|
59
|
+
throw new ProtocolError(`streaming binary ended after ${this.bytes} bytes; expected ${this.expectedBytes}.`);
|
|
60
|
+
}
|
|
61
|
+
this.terminal = true;
|
|
62
|
+
this.control.close();
|
|
63
|
+
return { done: true, value: undefined };
|
|
64
|
+
}
|
|
65
|
+
this.bytes += next.value.byteLength;
|
|
66
|
+
if (this.expectedBytes !== undefined && this.bytes > this.expectedBytes) {
|
|
67
|
+
throw new ProtocolError(`streaming binary exceeded its declared length (${this.expectedBytes}).`);
|
|
68
|
+
}
|
|
69
|
+
if (this.bytes > this.maximumBytes) {
|
|
70
|
+
throw new ProtocolError(`streaming binary exceeds maximumResponseBytes (${this.maximumBytes}).`);
|
|
71
|
+
}
|
|
72
|
+
return { done: false, value: new Uint8Array(next.value) };
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
await this.cancel(error);
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async interrupt(reason) {
|
|
80
|
+
if (this.terminal || this.interruption !== undefined)
|
|
81
|
+
return;
|
|
82
|
+
this.interruption = asError(reason ?? new Error('streaming binary was cancelled.'));
|
|
83
|
+
await this.cancelReader(this.interruption);
|
|
84
|
+
this.control.close();
|
|
85
|
+
}
|
|
86
|
+
async cancelReader(reason) {
|
|
87
|
+
try {
|
|
88
|
+
await this.reader.cancel(reason);
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
// Cancellation follows an already chosen terminal outcome.
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -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
|
|
@@ -25,9 +25,11 @@ export declare class HttpTransport implements Transport {
|
|
|
25
25
|
private nextId;
|
|
26
26
|
constructor(options: HttpTransportOptions);
|
|
27
27
|
dispatch(input: TransportRequest, options?: RequestOptions): Promise<TransportResult>;
|
|
28
|
+
/** HTTP-only binary invocation; each call may replay a re-readable Blob. */
|
|
29
|
+
dispatchBinary(input: TransportRequest, body: Blob, options?: RequestOptions): Promise<TransportResult>;
|
|
30
|
+
private dispatchWith;
|
|
28
31
|
private fetchResponse;
|
|
29
32
|
private decodeBinary;
|
|
30
33
|
private nextRequestId;
|
|
31
34
|
private requestCodec;
|
|
32
35
|
}
|
|
33
|
-
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { canonicalMediaType } from '@astrale-os/kernel-protocol/artifact';
|
|
1
2
|
import * as codecs from '@astrale-os/kernel-protocol/codecs';
|
|
2
3
|
import * as protocol from '@astrale-os/kernel-protocol/invocation';
|
|
3
4
|
import { ProtocolError, ResponseError, TransportError } from '../../errors/index.js';
|
|
5
|
+
import { invocationFailure } from '../failure.js';
|
|
4
6
|
import { asError, controlledSignal, positiveInteger, requireLive, } from '../index.js';
|
|
5
|
-
import {
|
|
7
|
+
import { HttpByteStream } from './byte-stream.js';
|
|
8
|
+
import { binaryHeaders, codecForResponse, decodeProtocol, readBoundedBody, requireId, } from './response.js';
|
|
6
9
|
import { HttpStream } from './stream.js';
|
|
7
10
|
const DEFAULT_TIMEOUT_MS = 30_000;
|
|
8
11
|
const DEFAULT_MAXIMUM_REQUEST_BYTES = 16 * 1024 * 1024;
|
|
@@ -30,6 +33,18 @@ export class HttpTransport {
|
|
|
30
33
|
this.maximumResponseBytes = positiveInteger(options.maximumResponseBytes ?? DEFAULT_MAXIMUM_RESPONSE_BYTES, 'maximumResponseBytes');
|
|
31
34
|
}
|
|
32
35
|
async dispatch(input, options = {}) {
|
|
36
|
+
return this.dispatchWith(input, options);
|
|
37
|
+
}
|
|
38
|
+
/** HTTP-only binary invocation; each call may replay a re-readable Blob. */
|
|
39
|
+
async dispatchBinary(input, body, options = {}) {
|
|
40
|
+
if (!(body instanceof Blob))
|
|
41
|
+
throw new TypeError('Binary request body must be a Blob.');
|
|
42
|
+
if (options.idempotencyKey !== undefined) {
|
|
43
|
+
throw new TypeError('Binary requests cannot carry an idempotency key.');
|
|
44
|
+
}
|
|
45
|
+
return this.dispatchWith(input, options, body);
|
|
46
|
+
}
|
|
47
|
+
async dispatchWith(input, options, binaryBody) {
|
|
33
48
|
const requestId = this.nextRequestId();
|
|
34
49
|
const timeoutMs = positiveInteger(options.timeoutMs ?? this.timeoutMs, 'timeoutMs');
|
|
35
50
|
const codec = await this.requestCodec();
|
|
@@ -41,30 +56,37 @@ export class HttpTransport {
|
|
|
41
56
|
...invocationInput,
|
|
42
57
|
...(options.idempotencyKey === undefined ? {} : { idempotencyKey: options.idempotencyKey }),
|
|
43
58
|
});
|
|
44
|
-
const encoded =
|
|
59
|
+
const encoded = binaryBody === undefined
|
|
60
|
+
? codec.encode(request)
|
|
61
|
+
: protocol.http.encodeBinaryRequestEnvelope(request);
|
|
45
62
|
const control = controlledSignal(options.signal, timeoutMs);
|
|
46
63
|
let handedOff = false;
|
|
47
64
|
let phase = 'connect';
|
|
48
65
|
let delivery = 'not-sent';
|
|
49
66
|
try {
|
|
50
67
|
requireLive(control);
|
|
51
|
-
if (encodedByteLength(encoded) > this.maximumRequestBytes) {
|
|
52
|
-
throw
|
|
68
|
+
if (binaryBody === undefined && encodedByteLength(encoded) > this.maximumRequestBytes) {
|
|
69
|
+
throw invocationFailure(`request exceeds maximumRequestBytes (${this.maximumRequestBytes}).`, 'send');
|
|
53
70
|
}
|
|
54
71
|
phase = 'send';
|
|
55
72
|
delivery = 'unknown';
|
|
56
|
-
const response = await this.fetchResponse(codec, encoded, trace, control);
|
|
73
|
+
const response = await this.fetchResponse(codec, encoded, trace, control, binaryBody);
|
|
57
74
|
phase = 'receive';
|
|
58
75
|
requireLive(control);
|
|
59
76
|
if (response.status >= 300 && response.status < 400) {
|
|
60
77
|
throw new ProtocolError('server returned a network redirect.');
|
|
61
78
|
}
|
|
62
|
-
requireNoStore(response);
|
|
63
79
|
const streamFraming = response.headers.get(protocol.http.STREAM_FRAMING_FIELD);
|
|
64
80
|
const binaryId = response.headers.get(protocol.http.REQUEST_ID_FIELD);
|
|
65
81
|
const binaryManifest = response.headers.get(protocol.http.BINARY_HEADERS_FIELD);
|
|
82
|
+
const binaryDelivery = response.headers.get(protocol.http.BINARY_DELIVERY_FIELD);
|
|
66
83
|
const hasStreamSignal = streamFraming !== null;
|
|
67
|
-
const hasBinarySignal = binaryId !== null || binaryManifest !== null;
|
|
84
|
+
const hasBinarySignal = binaryId !== null || binaryManifest !== null || binaryDelivery !== null;
|
|
85
|
+
const responseCodec = await codecForResponse(response.headers.get('content-type'));
|
|
86
|
+
if (!response.ok && responseCodec === undefined && !hasStreamSignal && !hasBinarySignal) {
|
|
87
|
+
throw invocationFailure(`server returned HTTP ${response.status} without an invocation response.`, 'receive', { delivery: 'unknown' });
|
|
88
|
+
}
|
|
89
|
+
requireNoStore(response);
|
|
68
90
|
if (hasStreamSignal && hasBinarySignal) {
|
|
69
91
|
throw new ProtocolError('server returned conflicting stream and binary response signals.');
|
|
70
92
|
}
|
|
@@ -72,9 +94,14 @@ export class HttpTransport {
|
|
|
72
94
|
if (binaryId === null || binaryManifest === null) {
|
|
73
95
|
throw new ProtocolError('server returned an incomplete binary response signal.');
|
|
74
96
|
}
|
|
75
|
-
|
|
97
|
+
if (binaryDelivery !== null && binaryDelivery !== protocol.http.STREAMING_BINARY_DELIVERY) {
|
|
98
|
+
throw new ProtocolError('server returned an unsupported binary delivery signal.');
|
|
99
|
+
}
|
|
100
|
+
const binary = await this.decodeBinary(response, requestId, binaryId, binaryDelivery !== null, control);
|
|
101
|
+
if (!(binary.value.body instanceof Uint8Array))
|
|
102
|
+
handedOff = true;
|
|
103
|
+
return binary;
|
|
76
104
|
}
|
|
77
|
-
const responseCodec = await codecForResponse(response.headers.get('content-type'));
|
|
78
105
|
if (responseCodec === undefined) {
|
|
79
106
|
throw new ProtocolError(`server returned unsupported Content-Type ${JSON.stringify(response.headers.get('content-type'))}.`);
|
|
80
107
|
}
|
|
@@ -131,45 +158,78 @@ export class HttpTransport {
|
|
|
131
158
|
control.close();
|
|
132
159
|
}
|
|
133
160
|
}
|
|
134
|
-
async fetchResponse(codec, encoded, trace, control) {
|
|
135
|
-
|
|
161
|
+
async fetchResponse(codec, encoded, trace, control, binaryBody) {
|
|
162
|
+
const init = {
|
|
136
163
|
method: 'POST',
|
|
137
|
-
redirect: '
|
|
164
|
+
redirect: 'manual',
|
|
138
165
|
credentials: 'omit',
|
|
139
|
-
cache: 'no-store',
|
|
140
166
|
referrerPolicy: 'no-referrer',
|
|
167
|
+
// Fetch owns Content-Length; the protocol carries Blob.size across Fetch runtimes.
|
|
141
168
|
headers: {
|
|
142
169
|
...this.headers,
|
|
143
170
|
...protocol.http.encodeTraceHeaders(trace),
|
|
144
|
-
'content-type': codec.contentType,
|
|
171
|
+
'content-type': binaryBody === undefined ? codec.contentType : protocol.http.BINARY_REQUEST_CONTENT_TYPE,
|
|
145
172
|
accept: codec.contentType,
|
|
173
|
+
...(binaryBody === undefined
|
|
174
|
+
? {}
|
|
175
|
+
: {
|
|
176
|
+
[protocol.http.REQUEST_ENVELOPE_FIELD]: encoded,
|
|
177
|
+
[protocol.http.BINARY_LENGTH_FIELD]: String(binaryBody.size),
|
|
178
|
+
}),
|
|
146
179
|
},
|
|
147
|
-
body: toBody(encoded),
|
|
180
|
+
body: binaryBody ?? toBody(encoded),
|
|
148
181
|
signal: control.signal,
|
|
149
|
-
}
|
|
182
|
+
};
|
|
183
|
+
return this.fetchImpl(this.url, init);
|
|
150
184
|
}
|
|
151
|
-
async decodeBinary(response, requestId, binaryId, control) {
|
|
152
|
-
if (!response.ok) {
|
|
153
|
-
throw new ProtocolError('server returned binary data with an error status.');
|
|
154
|
-
}
|
|
185
|
+
async decodeBinary(response, requestId, binaryId, streaming, control) {
|
|
155
186
|
if (binaryId !== String(requestId)) {
|
|
156
187
|
throw new ProtocolError(`binary response requestId ${JSON.stringify(binaryId)} does not match request requestId ${requestId}.`);
|
|
157
188
|
}
|
|
158
|
-
const
|
|
159
|
-
if (
|
|
189
|
+
const contentType = response.headers.get('content-type');
|
|
190
|
+
if (contentType === null) {
|
|
160
191
|
throw new ProtocolError('binary response has no media type.');
|
|
161
192
|
}
|
|
162
|
-
const
|
|
163
|
-
requireLive(control);
|
|
193
|
+
const mediaType = decodeProtocol('binary media type', () => canonicalMediaType(contentType));
|
|
164
194
|
const headerNames = decodeProtocol('binary application-header manifest', () => protocol.http.decodeBinaryHeaderNames(response.headers.get(protocol.http.BINARY_HEADERS_FIELD)));
|
|
165
195
|
const headers = binaryHeaders(response.headers, headerNames);
|
|
166
196
|
const invocation = decodeProtocol('binary InvocationId field', () => protocol.http.decodeInvocationId(response.headers.get(protocol.http.INVOCATION_FIELD)));
|
|
197
|
+
if (streaming) {
|
|
198
|
+
if (response.body === null)
|
|
199
|
+
throw new ProtocolError('streaming binary has no body.');
|
|
200
|
+
// An intermediary may rewrite Content-Length (for example when it compresses the body), so the
|
|
201
|
+
// protocol length wins; Content-Length only counts for a Server that predates the field.
|
|
202
|
+
const declared = response.headers.get(protocol.http.BINARY_LENGTH_FIELD);
|
|
203
|
+
const length = declared ?? response.headers.get('content-length');
|
|
204
|
+
const expectedBytes = length === null ? undefined : Number(length);
|
|
205
|
+
if (length !== null &&
|
|
206
|
+
(!/^(?:0|[1-9][0-9]*)$/u.test(length) || !Number.isSafeInteger(expectedBytes))) {
|
|
207
|
+
throw new ProtocolError(`streaming binary has an invalid ${declared === null ? 'Content-Length' : protocol.http.BINARY_LENGTH_FIELD}.`);
|
|
208
|
+
}
|
|
209
|
+
if (expectedBytes !== undefined && expectedBytes > this.maximumResponseBytes) {
|
|
210
|
+
throw new ProtocolError(`streaming binary exceeds maximumResponseBytes (${this.maximumResponseBytes}).`);
|
|
211
|
+
}
|
|
212
|
+
requireLive(control);
|
|
213
|
+
return {
|
|
214
|
+
kind: 'binary',
|
|
215
|
+
invocation,
|
|
216
|
+
value: {
|
|
217
|
+
body: new HttpByteStream(response.body, this.maximumResponseBytes, control, expectedBytes),
|
|
218
|
+
mediaType,
|
|
219
|
+
...(response.status === 200 ? {} : { status: response.status }),
|
|
220
|
+
...(Object.keys(headers).length === 0 ? {} : { headers }),
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
const body = await readBoundedBody(response, this.maximumResponseBytes, control.signal);
|
|
225
|
+
requireLive(control);
|
|
167
226
|
const binary = decodeProtocol('binary response', () => protocol.decodeBinaryResponse({
|
|
168
227
|
kind: 'binary',
|
|
169
228
|
requestId,
|
|
170
229
|
invocation,
|
|
171
230
|
body,
|
|
172
231
|
mediaType,
|
|
232
|
+
status: response.status,
|
|
173
233
|
...(Object.keys(headers).length === 0 ? {} : { headers }),
|
|
174
234
|
}));
|
|
175
235
|
requireLive(control);
|
|
@@ -179,6 +239,7 @@ export class HttpTransport {
|
|
|
179
239
|
value: {
|
|
180
240
|
body: binary.body,
|
|
181
241
|
mediaType: binary.mediaType,
|
|
242
|
+
...(binary.status === 200 ? {} : { status: binary.status }),
|
|
182
243
|
...(binary.headers === undefined ? {} : { headers: binary.headers }),
|
|
183
244
|
},
|
|
184
245
|
};
|
|
@@ -265,9 +326,8 @@ function transportFailure(input, control, parent, timeoutMs, url, phase, deliver
|
|
|
265
326
|
if (input instanceof ResponseError || input instanceof ProtocolError)
|
|
266
327
|
return input;
|
|
267
328
|
if (control.timedOut) {
|
|
268
|
-
return
|
|
329
|
+
return invocationFailure(`request timed out after ${timeoutMs}ms.`, 'timeout', {
|
|
269
330
|
cause: asError(input),
|
|
270
|
-
phase: 'timeout',
|
|
271
331
|
delivery,
|
|
272
332
|
});
|
|
273
333
|
}
|
|
@@ -275,9 +335,8 @@ function transportFailure(input, control, parent, timeoutMs, url, phase, deliver
|
|
|
275
335
|
return asError(parent.reason ?? input);
|
|
276
336
|
return input instanceof TransportError
|
|
277
337
|
? input
|
|
278
|
-
:
|
|
338
|
+
: invocationFailure(`Failed to communicate with the server at ${url}.`, phase, {
|
|
279
339
|
cause: asError(input),
|
|
280
|
-
phase,
|
|
281
340
|
delivery,
|
|
282
341
|
});
|
|
283
342
|
}
|
|
@@ -305,7 +364,6 @@ const RESERVED_REQUEST_HEADERS = new Set([
|
|
|
305
364
|
'content-length',
|
|
306
365
|
'content-type',
|
|
307
366
|
'cookie',
|
|
308
|
-
'expect',
|
|
309
367
|
'forwarded',
|
|
310
368
|
'host',
|
|
311
369
|
'keep-alive',
|
|
@@ -342,4 +400,3 @@ function hasControlCharacter(input) {
|
|
|
342
400
|
}
|
|
343
401
|
return false;
|
|
344
402
|
}
|
|
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
|