@astrale-os/kernel-client 0.6.0-beta.1 → 0.6.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/auth.d.ts +1 -2
- package/dist/auth/auth.js +0 -1
- package/dist/auth/authorization.d.ts +2 -3
- package/dist/auth/authorization.js +3 -4
- package/dist/auth/credential.d.ts +2 -3
- package/dist/auth/credential.js +5 -6
- package/dist/auth/identity.d.ts +2 -3
- package/dist/auth/identity.js +4 -5
- package/dist/auth/index.d.ts +1 -2
- package/dist/auth/index.js +0 -1
- package/dist/auth/provision.d.ts +0 -1
- package/dist/auth/provision.js +2 -3
- package/dist/client/admission.d.ts +0 -1
- package/dist/client/admission.js +0 -1
- package/dist/client/client.d.ts +7 -5
- package/dist/client/client.js +13 -5
- package/dist/client/credential.d.ts +4 -5
- package/dist/client/credential.js +0 -1
- package/dist/client/index.d.ts +2 -2
- package/dist/client/index.js +1 -2
- package/dist/client/request.d.ts +6 -4
- package/dist/client/request.js +20 -3
- package/dist/client/result.d.ts +35 -5
- package/dist/client/result.js +3 -4
- package/dist/client/routing-control.d.ts +3 -4
- package/dist/client/routing-control.js +4 -5
- package/dist/errors/client-error.d.ts +0 -1
- package/dist/errors/client-error.js +2 -1
- package/dist/errors/index.d.ts +7 -7
- package/dist/errors/index.js +7 -7
- package/dist/errors/miss-error.d.ts +3 -2
- package/dist/errors/miss-error.js +3 -2
- package/dist/errors/protocol-error.d.ts +6 -2
- package/dist/errors/protocol-error.js +2 -1
- package/dist/errors/response-error.d.ts +4 -3
- package/dist/errors/response-error.js +4 -3
- package/dist/errors/session-error.d.ts +9 -0
- package/dist/errors/session-error.js +9 -0
- package/dist/errors/stale-route-error.d.ts +3 -3
- package/dist/errors/stale-route-error.js +3 -2
- package/dist/errors/transport-error.d.ts +20 -5
- package/dist/errors/transport-error.js +11 -5
- package/dist/graph/domain/binding.d.ts +22 -0
- package/dist/graph/domain/binding.js +123 -0
- package/dist/graph/domain/domain.typecheck.d.ts +1 -0
- package/dist/graph/domain/domain.typecheck.js +139 -0
- package/dist/graph/domain/index.d.ts +3 -0
- package/dist/graph/domain/index.js +1 -0
- package/dist/graph/domain/model.d.ts +18 -0
- package/dist/graph/domain/model.js +1 -0
- package/dist/graph/domain/page.d.ts +23 -0
- package/dist/graph/domain/page.js +42 -0
- package/dist/graph/domain/project.d.ts +8 -0
- package/dist/graph/domain/project.js +120 -0
- package/dist/graph/domain/provenance.d.ts +6 -0
- package/dist/graph/domain/provenance.js +11 -0
- package/dist/graph/errors.d.ts +2 -3
- package/dist/graph/errors.js +2 -2
- package/dist/graph/expectation.d.ts +3 -0
- package/dist/graph/expectation.js +6 -0
- package/dist/graph/graph.d.ts +14 -11
- package/dist/graph/graph.js +0 -1
- package/dist/graph/index.d.ts +3 -2
- package/dist/graph/index.js +1 -1
- package/dist/graph/mutation.d.ts +2 -4
- package/dist/graph/mutation.js +12 -4
- package/dist/graph/page/index.d.ts +0 -1
- package/dist/graph/page/index.js +0 -1
- package/dist/graph/page/neighbors.d.ts +4 -5
- package/dist/graph/page/neighbors.js +6 -7
- package/dist/graph/page/page.d.ts +6 -3
- package/dist/graph/page/page.js +0 -1
- package/dist/graph/page-contract.d.ts +13 -0
- package/dist/graph/page-contract.js +1 -0
- package/dist/graph/provenance.d.ts +12 -0
- package/dist/graph/provenance.js +37 -0
- package/dist/graph/query.d.ts +1 -2
- package/dist/graph/query.js +21 -13
- package/dist/graph/read.d.ts +3 -4
- package/dist/graph/read.js +1 -2
- package/dist/index.d.ts +2 -3
- package/dist/index.js +1 -2
- package/dist/pacer/batcher/batcher.d.ts +0 -1
- package/dist/pacer/batcher/batcher.js +0 -1
- package/dist/pacer/batcher/defaults.d.ts +0 -1
- package/dist/pacer/batcher/defaults.js +0 -1
- package/dist/pacer/batcher/index.d.ts +0 -1
- package/dist/pacer/batcher/index.js +0 -1
- package/dist/pacer/index.d.ts +0 -1
- package/dist/pacer/index.js +0 -1
- package/dist/pacer/limiter/defaults.d.ts +0 -1
- package/dist/pacer/limiter/defaults.js +0 -1
- package/dist/pacer/limiter/index.d.ts +0 -1
- package/dist/pacer/limiter/index.js +0 -1
- package/dist/pacer/limiter/limiter.d.ts +0 -1
- package/dist/pacer/limiter/limiter.js +0 -1
- package/dist/pacer/queue/defaults.d.ts +0 -1
- package/dist/pacer/queue/defaults.js +0 -1
- package/dist/pacer/queue/index.d.ts +0 -1
- package/dist/pacer/queue/index.js +0 -1
- package/dist/pacer/queue/queue.d.ts +0 -1
- package/dist/pacer/queue/queue.js +0 -1
- package/dist/pacer/retry/defaults.d.ts +0 -1
- package/dist/pacer/retry/defaults.js +0 -1
- package/dist/pacer/retry/index.d.ts +0 -1
- package/dist/pacer/retry/index.js +0 -1
- package/dist/pacer/retry/retry.d.ts +0 -1
- package/dist/pacer/retry/retry.js +0 -1
- package/dist/pool/index.d.ts +0 -1
- package/dist/pool/index.js +0 -1
- package/dist/pool/pool.d.ts +0 -1
- package/dist/pool/pool.js +0 -1
- package/dist/pool/target.d.ts +0 -1
- package/dist/pool/target.js +0 -1
- package/dist/schema/admission.d.ts +12 -0
- package/dist/schema/admission.js +17 -0
- package/dist/schema/contracts.d.ts +12 -0
- package/dist/schema/contracts.js +1 -0
- package/dist/schema/index.d.ts +3 -0
- package/dist/schema/index.js +2 -0
- package/dist/schema/introspection.d.ts +5 -0
- package/dist/schema/introspection.js +15 -0
- package/dist/schema/operation.d.ts +5 -0
- package/dist/schema/operation.js +9 -0
- package/dist/schema/schema.d.ts +19 -0
- package/dist/schema/schema.js +43 -0
- package/dist/session/bound.d.ts +44 -0
- package/dist/session/bound.js +75 -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 +1 -2
- package/dist/session/context/index.js +1 -2
- 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 +3 -2
- package/dist/session/context/policy.js +12 -6
- package/dist/session/discovery/bundle.d.ts +0 -1
- package/dist/session/discovery/bundle.js +11 -11
- package/dist/session/discovery/discovery.d.ts +3 -11
- package/dist/session/discovery/discovery.js +6 -20
- package/dist/session/discovery/index.d.ts +3 -7
- package/dist/session/discovery/index.js +2 -2
- package/dist/session/discovery/publication.d.ts +7 -6
- package/dist/session/discovery/publication.js +25 -26
- package/dist/session/discovery/snapshot.d.ts +3 -3
- package/dist/session/discovery/snapshot.js +2 -3
- package/dist/session/discovery/transport.d.ts +6 -0
- package/dist/session/discovery/transport.js +13 -0
- package/dist/session/index.d.ts +6 -2
- package/dist/session/index.js +3 -2
- package/dist/session/reference.d.ts +36 -0
- package/dist/session/reference.js +74 -0
- package/dist/session/routing/auth.d.ts +1 -2
- package/dist/session/routing/auth.js +2 -6
- package/dist/session/routing/cache.d.ts +2 -2
- package/dist/session/routing/cache.js +9 -4
- package/dist/session/routing/dispatch.d.ts +6 -7
- package/dist/session/routing/dispatch.js +54 -18
- package/dist/session/routing/envelope.d.ts +0 -1
- package/dist/session/routing/envelope.js +0 -1
- package/dist/session/routing/expectation.d.ts +6 -0
- package/dist/session/routing/expectation.js +1 -0
- package/dist/session/routing/index.d.ts +1 -1
- package/dist/session/routing/index.js +0 -1
- package/dist/session/routing/request.d.ts +1 -2
- package/dist/session/routing/request.js +1 -2
- package/dist/session/session.d.ts +26 -15
- package/dist/session/session.js +87 -13
- package/dist/session/session.typecheck.d.ts +0 -1
- package/dist/session/session.typecheck.js +23 -2
- package/dist/session/views/catalog.d.ts +2 -3
- package/dist/session/views/catalog.js +14 -7
- package/dist/session/views/index.d.ts +0 -1
- package/dist/session/views/index.js +0 -1
- package/dist/session/views/resolve.d.ts +1 -3
- package/dist/session/views/resolve.js +4 -3
- package/dist/store/entity-index.d.ts +0 -1
- package/dist/store/entity-index.js +0 -1
- package/dist/store/index.d.ts +0 -1
- package/dist/store/index.js +0 -1
- package/dist/store/memory.d.ts +1 -2
- package/dist/store/memory.js +0 -1
- package/dist/store/mutation.d.ts +0 -1
- package/dist/store/mutation.js +0 -1
- package/dist/store/observe.d.ts +0 -1
- package/dist/store/observe.js +0 -1
- package/dist/store/optimistic.d.ts +0 -1
- package/dist/store/optimistic.js +0 -1
- package/dist/store/query-key.d.ts +1 -2
- package/dist/store/query-key.js +0 -1
- package/dist/store/shape.d.ts +1 -2
- package/dist/store/shape.js +0 -1
- package/dist/store/store.d.ts +1 -2
- package/dist/store/store.js +0 -1
- package/dist/store/store.typecheck.d.ts +0 -1
- package/dist/store/store.typecheck.js +3 -4
- package/dist/transport/auto/decision.d.ts +0 -1
- package/dist/transport/auto/decision.js +0 -1
- package/dist/transport/auto/fallback.d.ts +0 -1
- package/dist/transport/auto/fallback.js +8 -10
- package/dist/transport/auto/index.d.ts +0 -1
- package/dist/transport/auto/index.js +0 -1
- package/dist/transport/auto/transport.d.ts +0 -1
- package/dist/transport/auto/transport.js +5 -6
- package/dist/transport/auto/warning.d.ts +0 -1
- package/dist/transport/auto/warning.js +0 -1
- package/dist/transport/deadline.d.ts +0 -1
- package/dist/transport/deadline.js +0 -1
- package/dist/transport/failure.d.ts +7 -0
- package/dist/transport/failure.js +9 -0
- package/dist/transport/http/index.d.ts +0 -1
- package/dist/transport/http/index.js +0 -1
- package/dist/transport/http/response.d.ts +2 -2
- package/dist/transport/http/response.js +2 -2
- package/dist/transport/http/stream.d.ts +6 -5
- package/dist/transport/http/stream.js +29 -12
- package/dist/transport/http/transport.d.ts +0 -1
- package/dist/transport/http/transport.js +46 -36
- package/dist/transport/index.d.ts +0 -1
- package/dist/transport/index.js +0 -1
- package/dist/transport/transport.d.ts +7 -2
- package/dist/transport/transport.js +0 -1
- package/dist/transport/websocket/connection.d.ts +3 -3
- package/dist/transport/websocket/connection.js +21 -34
- package/dist/transport/websocket/exchange.d.ts +7 -7
- package/dist/transport/websocket/exchange.js +50 -38
- package/dist/transport/websocket/index.d.ts +0 -1
- package/dist/transport/websocket/index.js +0 -1
- package/dist/transport/websocket/transport.d.ts +0 -1
- package/dist/transport/websocket/transport.js +9 -21
- package/package.json +25 -16
- package/dist/auth/auth.d.ts.map +0 -1
- package/dist/auth/auth.js.map +0 -1
- package/dist/auth/authorization.d.ts.map +0 -1
- package/dist/auth/authorization.js.map +0 -1
- package/dist/auth/credential.d.ts.map +0 -1
- package/dist/auth/credential.js.map +0 -1
- package/dist/auth/identity.d.ts.map +0 -1
- package/dist/auth/identity.js.map +0 -1
- package/dist/auth/index.d.ts.map +0 -1
- package/dist/auth/index.js.map +0 -1
- package/dist/auth/provision.d.ts.map +0 -1
- package/dist/auth/provision.js.map +0 -1
- package/dist/client/admission.d.ts.map +0 -1
- package/dist/client/admission.js.map +0 -1
- package/dist/client/client.d.ts.map +0 -1
- package/dist/client/client.js.map +0 -1
- package/dist/client/credential.d.ts.map +0 -1
- package/dist/client/credential.js.map +0 -1
- package/dist/client/index.d.ts.map +0 -1
- package/dist/client/index.js.map +0 -1
- package/dist/client/request.d.ts.map +0 -1
- package/dist/client/request.js.map +0 -1
- package/dist/client/result.d.ts.map +0 -1
- package/dist/client/result.js.map +0 -1
- package/dist/client/routing-control.d.ts.map +0 -1
- package/dist/client/routing-control.js.map +0 -1
- package/dist/domain/binding.d.ts +0 -25
- package/dist/domain/binding.d.ts.map +0 -1
- package/dist/domain/binding.js +0 -50
- package/dist/domain/binding.js.map +0 -1
- package/dist/domain/callable.d.ts +0 -23
- package/dist/domain/callable.d.ts.map +0 -1
- package/dist/domain/callable.js +0 -66
- package/dist/domain/callable.js.map +0 -1
- package/dist/domain/domain.typecheck.d.ts +0 -2
- package/dist/domain/domain.typecheck.d.ts.map +0 -1
- package/dist/domain/domain.typecheck.js +0 -69
- package/dist/domain/domain.typecheck.js.map +0 -1
- package/dist/domain/index.d.ts +0 -4
- package/dist/domain/index.d.ts.map +0 -1
- package/dist/domain/index.js +0 -2
- package/dist/domain/index.js.map +0 -1
- package/dist/domain/node.d.ts +0 -10
- package/dist/domain/node.d.ts.map +0 -1
- package/dist/domain/node.js +0 -6
- package/dist/domain/node.js.map +0 -1
- package/dist/errors/client-error.d.ts.map +0 -1
- package/dist/errors/client-error.js.map +0 -1
- package/dist/errors/index.d.ts.map +0 -1
- package/dist/errors/index.js.map +0 -1
- package/dist/errors/miss-error.d.ts.map +0 -1
- package/dist/errors/miss-error.js.map +0 -1
- package/dist/errors/protocol-error.d.ts.map +0 -1
- package/dist/errors/protocol-error.js.map +0 -1
- package/dist/errors/response-error.d.ts.map +0 -1
- package/dist/errors/response-error.js.map +0 -1
- package/dist/errors/stale-route-error.d.ts.map +0 -1
- package/dist/errors/stale-route-error.js.map +0 -1
- package/dist/errors/transport-error.d.ts.map +0 -1
- package/dist/errors/transport-error.js.map +0 -1
- package/dist/graph/errors.d.ts.map +0 -1
- package/dist/graph/errors.js.map +0 -1
- package/dist/graph/graph.d.ts.map +0 -1
- package/dist/graph/graph.js.map +0 -1
- package/dist/graph/index.d.ts.map +0 -1
- package/dist/graph/index.js.map +0 -1
- package/dist/graph/mutation.d.ts.map +0 -1
- package/dist/graph/mutation.js.map +0 -1
- package/dist/graph/page/index.d.ts.map +0 -1
- package/dist/graph/page/index.js.map +0 -1
- package/dist/graph/page/neighbors.d.ts.map +0 -1
- package/dist/graph/page/neighbors.js.map +0 -1
- package/dist/graph/page/page.d.ts.map +0 -1
- package/dist/graph/page/page.js.map +0 -1
- package/dist/graph/query.d.ts.map +0 -1
- package/dist/graph/query.js.map +0 -1
- package/dist/graph/read.d.ts.map +0 -1
- package/dist/graph/read.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/pacer/batcher/batcher.d.ts.map +0 -1
- package/dist/pacer/batcher/batcher.js.map +0 -1
- package/dist/pacer/batcher/defaults.d.ts.map +0 -1
- package/dist/pacer/batcher/defaults.js.map +0 -1
- package/dist/pacer/batcher/index.d.ts.map +0 -1
- package/dist/pacer/batcher/index.js.map +0 -1
- package/dist/pacer/index.d.ts.map +0 -1
- package/dist/pacer/index.js.map +0 -1
- package/dist/pacer/limiter/defaults.d.ts.map +0 -1
- package/dist/pacer/limiter/defaults.js.map +0 -1
- package/dist/pacer/limiter/index.d.ts.map +0 -1
- package/dist/pacer/limiter/index.js.map +0 -1
- package/dist/pacer/limiter/limiter.d.ts.map +0 -1
- package/dist/pacer/limiter/limiter.js.map +0 -1
- package/dist/pacer/queue/defaults.d.ts.map +0 -1
- package/dist/pacer/queue/defaults.js.map +0 -1
- package/dist/pacer/queue/index.d.ts.map +0 -1
- package/dist/pacer/queue/index.js.map +0 -1
- package/dist/pacer/queue/queue.d.ts.map +0 -1
- package/dist/pacer/queue/queue.js.map +0 -1
- package/dist/pacer/retry/defaults.d.ts.map +0 -1
- package/dist/pacer/retry/defaults.js.map +0 -1
- package/dist/pacer/retry/index.d.ts.map +0 -1
- package/dist/pacer/retry/index.js.map +0 -1
- package/dist/pacer/retry/retry.d.ts.map +0 -1
- package/dist/pacer/retry/retry.js.map +0 -1
- package/dist/pool/index.d.ts.map +0 -1
- package/dist/pool/index.js.map +0 -1
- package/dist/pool/pool.d.ts.map +0 -1
- package/dist/pool/pool.js.map +0 -1
- package/dist/pool/target.d.ts.map +0 -1
- package/dist/pool/target.js.map +0 -1
- package/dist/session/context/control.d.ts.map +0 -1
- package/dist/session/context/control.js.map +0 -1
- package/dist/session/context/index.d.ts.map +0 -1
- package/dist/session/context/index.js.map +0 -1
- package/dist/session/context/limits.d.ts.map +0 -1
- package/dist/session/context/limits.js.map +0 -1
- package/dist/session/context/operation.d.ts.map +0 -1
- package/dist/session/context/operation.js.map +0 -1
- package/dist/session/context/policy.d.ts.map +0 -1
- package/dist/session/context/policy.js.map +0 -1
- package/dist/session/discovery/bundle.d.ts.map +0 -1
- package/dist/session/discovery/bundle.js.map +0 -1
- package/dist/session/discovery/discovery.d.ts.map +0 -1
- package/dist/session/discovery/discovery.js.map +0 -1
- package/dist/session/discovery/index.d.ts.map +0 -1
- package/dist/session/discovery/index.js.map +0 -1
- package/dist/session/discovery/publication.d.ts.map +0 -1
- package/dist/session/discovery/publication.js.map +0 -1
- package/dist/session/discovery/snapshot.d.ts.map +0 -1
- package/dist/session/discovery/snapshot.js.map +0 -1
- package/dist/session/index.d.ts.map +0 -1
- package/dist/session/index.js.map +0 -1
- package/dist/session/routing/auth.d.ts.map +0 -1
- package/dist/session/routing/auth.js.map +0 -1
- package/dist/session/routing/cache.d.ts.map +0 -1
- package/dist/session/routing/cache.js.map +0 -1
- package/dist/session/routing/dispatch.d.ts.map +0 -1
- package/dist/session/routing/dispatch.js.map +0 -1
- package/dist/session/routing/envelope.d.ts.map +0 -1
- package/dist/session/routing/envelope.js.map +0 -1
- package/dist/session/routing/index.d.ts.map +0 -1
- package/dist/session/routing/index.js.map +0 -1
- package/dist/session/routing/request.d.ts.map +0 -1
- package/dist/session/routing/request.js.map +0 -1
- package/dist/session/session.d.ts.map +0 -1
- package/dist/session/session.js.map +0 -1
- package/dist/session/session.typecheck.d.ts.map +0 -1
- package/dist/session/session.typecheck.js.map +0 -1
- package/dist/session/views/catalog.d.ts.map +0 -1
- package/dist/session/views/catalog.js.map +0 -1
- package/dist/session/views/index.d.ts.map +0 -1
- package/dist/session/views/index.js.map +0 -1
- package/dist/session/views/resolve.d.ts.map +0 -1
- package/dist/session/views/resolve.js.map +0 -1
- package/dist/store/entity-index.d.ts.map +0 -1
- package/dist/store/entity-index.js.map +0 -1
- package/dist/store/index.d.ts.map +0 -1
- package/dist/store/index.js.map +0 -1
- package/dist/store/memory.d.ts.map +0 -1
- package/dist/store/memory.js.map +0 -1
- package/dist/store/mutation.d.ts.map +0 -1
- package/dist/store/mutation.js.map +0 -1
- package/dist/store/observe.d.ts.map +0 -1
- package/dist/store/observe.js.map +0 -1
- package/dist/store/optimistic.d.ts.map +0 -1
- package/dist/store/optimistic.js.map +0 -1
- package/dist/store/query-key.d.ts.map +0 -1
- package/dist/store/query-key.js.map +0 -1
- package/dist/store/shape.d.ts.map +0 -1
- package/dist/store/shape.js.map +0 -1
- package/dist/store/store.d.ts.map +0 -1
- package/dist/store/store.js.map +0 -1
- package/dist/store/store.typecheck.d.ts.map +0 -1
- package/dist/store/store.typecheck.js.map +0 -1
- package/dist/transport/auto/decision.d.ts.map +0 -1
- package/dist/transport/auto/decision.js.map +0 -1
- package/dist/transport/auto/fallback.d.ts.map +0 -1
- package/dist/transport/auto/fallback.js.map +0 -1
- package/dist/transport/auto/index.d.ts.map +0 -1
- package/dist/transport/auto/index.js.map +0 -1
- package/dist/transport/auto/transport.d.ts.map +0 -1
- package/dist/transport/auto/transport.js.map +0 -1
- package/dist/transport/auto/warning.d.ts.map +0 -1
- package/dist/transport/auto/warning.js.map +0 -1
- package/dist/transport/deadline.d.ts.map +0 -1
- package/dist/transport/deadline.js.map +0 -1
- package/dist/transport/http/index.d.ts.map +0 -1
- package/dist/transport/http/index.js.map +0 -1
- package/dist/transport/http/response.d.ts.map +0 -1
- package/dist/transport/http/response.js.map +0 -1
- package/dist/transport/http/stream.d.ts.map +0 -1
- package/dist/transport/http/stream.js.map +0 -1
- package/dist/transport/http/transport.d.ts.map +0 -1
- package/dist/transport/http/transport.js.map +0 -1
- package/dist/transport/index.d.ts.map +0 -1
- package/dist/transport/index.js.map +0 -1
- package/dist/transport/transport.d.ts.map +0 -1
- package/dist/transport/transport.js.map +0 -1
- package/dist/transport/websocket/connection.d.ts.map +0 -1
- package/dist/transport/websocket/connection.js.map +0 -1
- package/dist/transport/websocket/exchange.d.ts.map +0 -1
- package/dist/transport/websocket/exchange.js.map +0 -1
- package/dist/transport/websocket/index.d.ts.map +0 -1
- package/dist/transport/websocket/index.js.map +0 -1
- package/dist/transport/websocket/transport.d.ts.map +0 -1
- package/dist/transport/websocket/transport.js.map +0 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TransportError } from '../../errors/index.js';
|
|
2
|
+
import { invocationFailure } from '../failure.js';
|
|
2
3
|
import { positiveInteger } from '../index.js';
|
|
3
4
|
const MAXIMUM_TIMEOUT_MS = 2_147_483_647;
|
|
4
5
|
/** One invocation-owned total timeout budget shared by selection and fallback. */
|
|
@@ -33,10 +34,7 @@ export class InvocationBudget {
|
|
|
33
34
|
let timer;
|
|
34
35
|
let abort;
|
|
35
36
|
const interrupted = new Promise((_resolve, reject) => {
|
|
36
|
-
timer = setTimeout(() => reject(
|
|
37
|
-
phase: 'timeout',
|
|
38
|
-
delivery: 'not-sent',
|
|
39
|
-
})), remaining);
|
|
37
|
+
timer = setTimeout(() => reject(invocationFailure('Automatic transport decision exceeded its timeout.', 'timeout')), remaining);
|
|
40
38
|
if (this.input?.signal) {
|
|
41
39
|
abort = () => reject(abortReason(this.input.signal));
|
|
42
40
|
this.input.signal.addEventListener('abort', abort, { once: true });
|
|
@@ -55,16 +53,17 @@ export class InvocationBudget {
|
|
|
55
53
|
remaining() {
|
|
56
54
|
const remaining = Math.min(MAXIMUM_TIMEOUT_MS, this.timeoutMs - (Date.now() - this.started));
|
|
57
55
|
if (remaining < 1) {
|
|
58
|
-
throw
|
|
59
|
-
phase: 'timeout',
|
|
60
|
-
delivery: 'not-sent',
|
|
61
|
-
});
|
|
56
|
+
throw invocationFailure('Automatic transport invocation exceeded its timeout.', 'timeout');
|
|
62
57
|
}
|
|
63
58
|
return remaining;
|
|
64
59
|
}
|
|
65
60
|
}
|
|
66
61
|
export function mayFallback(error) {
|
|
67
|
-
return error instanceof TransportError &&
|
|
62
|
+
return (error instanceof TransportError &&
|
|
63
|
+
error.context.kind === 'invocation' &&
|
|
64
|
+
error.context.delivery === 'not-sent' &&
|
|
65
|
+
error.phase !== 'closed' &&
|
|
66
|
+
error.phase !== 'timeout');
|
|
68
67
|
}
|
|
69
68
|
export function warningTarget(input) {
|
|
70
69
|
return input.call.target;
|
|
@@ -74,4 +73,3 @@ function abortReason(signal) {
|
|
|
74
73
|
? signal.reason
|
|
75
74
|
: new Error(signal.reason === undefined ? 'request was cancelled' : String(signal.reason));
|
|
76
75
|
}
|
|
77
|
-
//# sourceMappingURL=fallback.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TransportError } from '../../errors/index.js';
|
|
2
|
+
import { invocationFailure } from '../failure.js';
|
|
2
3
|
import { HttpTransport } from '../http/index.js';
|
|
3
4
|
import { positiveInteger } from '../index.js';
|
|
4
5
|
import { WebSocketTransport } from '../websocket/index.js';
|
|
@@ -104,7 +105,9 @@ export class AutoTransport {
|
|
|
104
105
|
this.decision.release();
|
|
105
106
|
throw error;
|
|
106
107
|
}
|
|
107
|
-
if (error instanceof TransportError &&
|
|
108
|
+
if (error instanceof TransportError &&
|
|
109
|
+
error.context.kind === 'invocation' &&
|
|
110
|
+
error.context.delivery === 'unknown') {
|
|
108
111
|
this.decision.demote();
|
|
109
112
|
throw error;
|
|
110
113
|
}
|
|
@@ -132,10 +135,6 @@ export class AutoTransport {
|
|
|
132
135
|
requireOpen() {
|
|
133
136
|
if (!this.closed)
|
|
134
137
|
return;
|
|
135
|
-
throw
|
|
136
|
-
phase: 'closed',
|
|
137
|
-
delivery: 'not-sent',
|
|
138
|
-
});
|
|
138
|
+
throw invocationFailure('AutoTransport is closed.', 'closed');
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
-
//# sourceMappingURL=transport.js.map
|
|
@@ -11,4 +11,3 @@ export interface ClientWarning {
|
|
|
11
11
|
}
|
|
12
12
|
export declare function formatClientWarning(warning: ClientWarning): string;
|
|
13
13
|
export declare function emitWarning(warning: ClientWarning, observer: ((warning: ClientWarning) => void) | undefined): void;
|
|
14
|
-
//# sourceMappingURL=warning.d.ts.map
|
|
@@ -9,4 +9,3 @@ export declare function controlledSignal(parent: AbortSignal | undefined, timeou
|
|
|
9
9
|
export declare function positiveInteger(input: number, label: string): number;
|
|
10
10
|
export declare function requireLive(control: ControlledSignal): void;
|
|
11
11
|
export declare function asError(value: unknown): Error;
|
|
12
|
-
//# sourceMappingURL=deadline.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TransportError, type InvocationTransportErrorOptions } from '../errors/index.js';
|
|
2
|
+
type InvocationFailureEvidence = Omit<InvocationTransportErrorOptions, 'delivery' | 'phase'> & {
|
|
3
|
+
readonly delivery?: InvocationTransportErrorOptions['delivery'];
|
|
4
|
+
};
|
|
5
|
+
/** Create invocation transport evidence with the common not-sent default. */
|
|
6
|
+
export declare function invocationFailure(message: string, phase: InvocationTransportErrorOptions['phase'], evidence?: InvocationFailureEvidence): TransportError;
|
|
7
|
+
export {};
|
|
@@ -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
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as codecs from '@astrale-os/kernel-protocol/codecs';
|
|
2
|
+
import * as protocol from '@astrale-os/kernel-protocol/invocation';
|
|
2
3
|
export declare function codecForResponse(contentType: string | null): Promise<codecs.Codec | undefined>;
|
|
3
4
|
export declare function readBoundedBody(response: Response, maximumBytes: number, signal: AbortSignal): Promise<Uint8Array>;
|
|
4
5
|
export declare function requireId(expected: protocol.RequestId, received: protocol.RequestId): void;
|
|
5
6
|
export declare function decodeProtocol<T>(label: string, decode: () => T): T;
|
|
6
7
|
export declare function normalizeMediaType(input: string | null): string | undefined;
|
|
7
8
|
export declare function binaryHeaders(input: Headers, names: readonly string[]): Readonly<Record<string, string>>;
|
|
8
|
-
//# sourceMappingURL=response.d.ts.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as codecs from '@astrale-os/kernel-protocol/codecs';
|
|
2
|
+
import * as protocol from '@astrale-os/kernel-protocol/invocation';
|
|
2
3
|
import { ProtocolError, ResponseError } from '../../errors/index.js';
|
|
3
4
|
import { asError } from '../index.js';
|
|
4
5
|
export async function codecForResponse(contentType) {
|
|
@@ -76,4 +77,3 @@ export function binaryHeaders(input, names) {
|
|
|
76
77
|
}
|
|
77
78
|
return Object.freeze(output);
|
|
78
79
|
}
|
|
79
|
-
//# sourceMappingURL=response.js.map
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import type { Value } from '@astrale-os/kernel-dsl/value';
|
|
2
|
-
import type
|
|
3
|
-
import
|
|
2
|
+
import type * as codecs from '@astrale-os/kernel-protocol/codecs';
|
|
3
|
+
import * as protocol from '@astrale-os/kernel-protocol/invocation';
|
|
4
|
+
import type { Stream } from '../../client/index.js';
|
|
4
5
|
import { type ControlledSignal } from '../index.js';
|
|
5
6
|
export declare class HttpStream implements Stream {
|
|
6
7
|
private readonly frames;
|
|
7
8
|
private readonly codec;
|
|
8
|
-
private readonly
|
|
9
|
+
private readonly requestId;
|
|
9
10
|
private readonly control;
|
|
11
|
+
invocation: protocol.InvocationId;
|
|
10
12
|
private claimed;
|
|
11
13
|
private terminal;
|
|
12
14
|
private index;
|
|
13
15
|
private interruption;
|
|
14
16
|
private constructor();
|
|
15
|
-
static open(response: Response, codec: codecs.Codec,
|
|
17
|
+
static open(response: Response, codec: codecs.Codec, requestId: protocol.RequestId, maximumFrameBytes: number, control: ControlledSignal): Promise<HttpStream>;
|
|
16
18
|
[Symbol.asyncIterator](): AsyncIterator<Value>;
|
|
17
19
|
cancel(reason?: string): Promise<void>;
|
|
18
20
|
private next;
|
|
@@ -22,4 +24,3 @@ export declare class HttpStream implements Stream {
|
|
|
22
24
|
private stop;
|
|
23
25
|
private abortFailure;
|
|
24
26
|
}
|
|
25
|
-
//# sourceMappingURL=stream.d.ts.map
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import
|
|
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 {
|
|
6
7
|
frames;
|
|
7
8
|
codec;
|
|
8
|
-
|
|
9
|
+
requestId;
|
|
9
10
|
control;
|
|
11
|
+
invocation;
|
|
10
12
|
claimed = false;
|
|
11
13
|
terminal = false;
|
|
12
14
|
index = 0;
|
|
13
15
|
interruption;
|
|
14
|
-
constructor(frames, codec,
|
|
16
|
+
constructor(frames, codec, requestId, control) {
|
|
15
17
|
this.frames = frames;
|
|
16
18
|
this.codec = codec;
|
|
17
|
-
this.
|
|
19
|
+
this.requestId = requestId;
|
|
18
20
|
this.control = control;
|
|
19
21
|
const abort = () => void this.interrupt(this.abortFailure(control.signal.reason));
|
|
20
22
|
if (control.signal.aborted)
|
|
@@ -22,15 +24,16 @@ export class HttpStream {
|
|
|
22
24
|
else
|
|
23
25
|
control.signal.addEventListener('abort', abort, { once: true });
|
|
24
26
|
}
|
|
25
|
-
static async open(response, codec,
|
|
27
|
+
static async open(response, codec, requestId, maximumFrameBytes, control) {
|
|
26
28
|
if (response.body === null)
|
|
27
29
|
throw new ProtocolError('stream has no body.');
|
|
28
|
-
const stream = new HttpStream(new LengthPrefixedFrames(response.body.getReader(), maximumFrameBytes), codec,
|
|
30
|
+
const stream = new HttpStream(new LengthPrefixedFrames(response.body.getReader(), maximumFrameBytes), codec, requestId, control);
|
|
29
31
|
const first = await stream.readFrame();
|
|
30
32
|
if (first === null || first.kind !== 'stream.start') {
|
|
31
33
|
await stream.stop('invalid stream start');
|
|
32
34
|
throw new ProtocolError('stream did not begin with stream.start.');
|
|
33
35
|
}
|
|
36
|
+
stream.invocation = first.invocation;
|
|
34
37
|
return stream;
|
|
35
38
|
}
|
|
36
39
|
[Symbol.asyncIterator]() {
|
|
@@ -71,7 +74,7 @@ export class HttpStream {
|
|
|
71
74
|
}
|
|
72
75
|
if (frame.kind === 'stream.error') {
|
|
73
76
|
await this.finish();
|
|
74
|
-
throw new ResponseError(frame.error.code, frame.error.message, frame.error.data);
|
|
77
|
+
throw new ResponseError(frame.error.code, frame.error.message, this.invocation, frame.error.data);
|
|
75
78
|
}
|
|
76
79
|
if (frame.kind !== 'stream.end') {
|
|
77
80
|
throw new ProtocolError(`Unexpected ${frame.kind} frame inside stream.`);
|
|
@@ -83,7 +86,7 @@ export class HttpStream {
|
|
|
83
86
|
return { done: true, value: undefined };
|
|
84
87
|
}
|
|
85
88
|
catch (error) {
|
|
86
|
-
const failure = this.interruption ?? error;
|
|
89
|
+
const failure = this.interruption ?? retainInvocationId(error, this.invocation);
|
|
87
90
|
await this.stop(failure);
|
|
88
91
|
throw failure;
|
|
89
92
|
}
|
|
@@ -95,7 +98,7 @@ export class HttpStream {
|
|
|
95
98
|
if (payload === null)
|
|
96
99
|
return null;
|
|
97
100
|
const frame = decodeProtocol('stream frame', () => protocol.decodeStreamFrame(this.codec.decode(payload)));
|
|
98
|
-
requireId(this.
|
|
101
|
+
requireId(this.requestId, frame.requestId);
|
|
99
102
|
return frame;
|
|
100
103
|
}
|
|
101
104
|
async finish() {
|
|
@@ -122,15 +125,30 @@ export class HttpStream {
|
|
|
122
125
|
}
|
|
123
126
|
abortFailure(reason) {
|
|
124
127
|
if (this.control.timedOut) {
|
|
125
|
-
return
|
|
128
|
+
return invocationFailure('stream exceeded its invocation timeout.', 'timeout', {
|
|
126
129
|
cause: asError(reason),
|
|
127
|
-
phase: 'timeout',
|
|
128
130
|
delivery: 'unknown',
|
|
131
|
+
invocation: this.invocation,
|
|
129
132
|
});
|
|
130
133
|
}
|
|
131
134
|
return asError(reason ?? new Error('stream was cancelled.'));
|
|
132
135
|
}
|
|
133
136
|
}
|
|
137
|
+
function retainInvocationId(input, invocation) {
|
|
138
|
+
if (input instanceof ProtocolError && input.invocation === undefined) {
|
|
139
|
+
return new ProtocolError(input.message, { cause: input, invocation });
|
|
140
|
+
}
|
|
141
|
+
if (input instanceof TransportError &&
|
|
142
|
+
input.context.kind === 'invocation' &&
|
|
143
|
+
input.context.invocation === undefined) {
|
|
144
|
+
return invocationFailure(input.message, input.phase, {
|
|
145
|
+
cause: input,
|
|
146
|
+
delivery: input.context.delivery,
|
|
147
|
+
invocation,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
return input;
|
|
151
|
+
}
|
|
134
152
|
class LengthPrefixedFrames {
|
|
135
153
|
reader;
|
|
136
154
|
maximumFrameBytes;
|
|
@@ -194,4 +212,3 @@ class LengthPrefixedFrames {
|
|
|
194
212
|
return output;
|
|
195
213
|
}
|
|
196
214
|
}
|
|
197
|
-
//# sourceMappingURL=stream.js.map
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as codecs from '@astrale-os/kernel-protocol/codecs';
|
|
2
|
+
import * as protocol from '@astrale-os/kernel-protocol/invocation';
|
|
2
3
|
import { ProtocolError, ResponseError, TransportError } from '../../errors/index.js';
|
|
4
|
+
import { invocationFailure } from '../failure.js';
|
|
3
5
|
import { asError, controlledSignal, positiveInteger, requireLive, } from '../index.js';
|
|
4
6
|
import { binaryHeaders, codecForResponse, decodeProtocol, normalizeMediaType, readBoundedBody, requireId, } from './response.js';
|
|
5
7
|
import { HttpStream } from './stream.js';
|
|
@@ -29,13 +31,15 @@ export class HttpTransport {
|
|
|
29
31
|
this.maximumResponseBytes = positiveInteger(options.maximumResponseBytes ?? DEFAULT_MAXIMUM_RESPONSE_BYTES, 'maximumResponseBytes');
|
|
30
32
|
}
|
|
31
33
|
async dispatch(input, options = {}) {
|
|
32
|
-
const
|
|
34
|
+
const requestId = this.nextRequestId();
|
|
33
35
|
const timeoutMs = positiveInteger(options.timeoutMs ?? this.timeoutMs, 'timeoutMs');
|
|
34
36
|
const codec = await this.requestCodec();
|
|
37
|
+
const { trace: traceInput, ...invocationInput } = input;
|
|
38
|
+
const trace = traceInput === undefined ? undefined : protocol.admitTrace(traceInput);
|
|
35
39
|
const request = protocol.decodeRequest({
|
|
36
40
|
version: protocol.VERSION,
|
|
37
|
-
|
|
38
|
-
...
|
|
41
|
+
requestId,
|
|
42
|
+
...invocationInput,
|
|
39
43
|
...(options.idempotencyKey === undefined ? {} : { idempotencyKey: options.idempotencyKey }),
|
|
40
44
|
});
|
|
41
45
|
const encoded = codec.encode(request);
|
|
@@ -46,11 +50,11 @@ export class HttpTransport {
|
|
|
46
50
|
try {
|
|
47
51
|
requireLive(control);
|
|
48
52
|
if (encodedByteLength(encoded) > this.maximumRequestBytes) {
|
|
49
|
-
throw
|
|
53
|
+
throw invocationFailure(`request exceeds maximumRequestBytes (${this.maximumRequestBytes}).`, 'send');
|
|
50
54
|
}
|
|
51
55
|
phase = 'send';
|
|
52
56
|
delivery = 'unknown';
|
|
53
|
-
const response = await this.fetchResponse(codec, encoded, control);
|
|
57
|
+
const response = await this.fetchResponse(codec, encoded, trace, control);
|
|
54
58
|
phase = 'receive';
|
|
55
59
|
requireLive(control);
|
|
56
60
|
if (response.status >= 300 && response.status < 400) {
|
|
@@ -69,7 +73,7 @@ export class HttpTransport {
|
|
|
69
73
|
if (binaryId === null || binaryManifest === null) {
|
|
70
74
|
throw new ProtocolError('server returned an incomplete binary response signal.');
|
|
71
75
|
}
|
|
72
|
-
return await this.decodeBinary(response,
|
|
76
|
+
return await this.decodeBinary(response, requestId, binaryId, control);
|
|
73
77
|
}
|
|
74
78
|
const responseCodec = await codecForResponse(response.headers.get('content-type'));
|
|
75
79
|
if (responseCodec === undefined) {
|
|
@@ -82,39 +86,43 @@ export class HttpTransport {
|
|
|
82
86
|
if (!response.ok) {
|
|
83
87
|
throw new ProtocolError('server returned a non-success stream response.');
|
|
84
88
|
}
|
|
85
|
-
const stream = await HttpStream.open(response, responseCodec,
|
|
89
|
+
const stream = await HttpStream.open(response, responseCodec, requestId, this.maximumResponseBytes, control);
|
|
86
90
|
requireLive(control);
|
|
87
91
|
handedOff = true;
|
|
88
|
-
return { kind: 'stream', stream };
|
|
92
|
+
return { kind: 'stream', stream, invocation: stream.invocation };
|
|
89
93
|
}
|
|
90
94
|
const body = await readBoundedBody(response, this.maximumResponseBytes, control.signal);
|
|
91
95
|
requireLive(control);
|
|
92
96
|
const decoded = decodeProtocol('response body', () => responseCodec.decode(body));
|
|
93
97
|
const envelope = decodeProtocol('response envelope', () => protocol.decodeResponse(decoded));
|
|
94
|
-
if (envelope.
|
|
95
|
-
throw new ResponseError(envelope.error.code, envelope.error.message, envelope.error.data);
|
|
98
|
+
if (envelope.requestId === null && 'error' in envelope) {
|
|
99
|
+
throw new ResponseError(envelope.error.code, envelope.error.message, envelope.invocation, envelope.error.data);
|
|
96
100
|
}
|
|
97
|
-
requireId(
|
|
101
|
+
requireId(requestId, envelope.requestId);
|
|
98
102
|
if ('kind' in envelope && envelope.kind === 'stale') {
|
|
99
103
|
const stale = decodeProtocol('stale response', () => protocol.decodeStale(envelope));
|
|
100
104
|
requireLive(control);
|
|
101
|
-
return Object.freeze({
|
|
105
|
+
return Object.freeze({
|
|
106
|
+
kind: 'stale',
|
|
107
|
+
current: stale.current,
|
|
108
|
+
invocation: stale.invocation,
|
|
109
|
+
});
|
|
102
110
|
}
|
|
103
111
|
if ('kind' in envelope && envelope.kind === 'miss') {
|
|
104
112
|
decodeProtocol('miss response', () => protocol.decodeMiss(envelope));
|
|
105
113
|
requireLive(control);
|
|
106
|
-
return Object.freeze({ kind: 'miss' });
|
|
114
|
+
return Object.freeze({ kind: 'miss', invocation: envelope.invocation });
|
|
107
115
|
}
|
|
108
116
|
if ('kind' in envelope && envelope.kind === 'redirect') {
|
|
109
|
-
const
|
|
117
|
+
const response = decodeProtocol('redirect response', () => protocol.decodeRedirectResponse(envelope));
|
|
110
118
|
requireLive(control);
|
|
111
|
-
return redirectResult(
|
|
119
|
+
return redirectResult(response);
|
|
112
120
|
}
|
|
113
121
|
if ('error' in envelope) {
|
|
114
|
-
throw new ResponseError(envelope.error.code, envelope.error.message, envelope.error.data);
|
|
122
|
+
throw new ResponseError(envelope.error.code, envelope.error.message, envelope.invocation, envelope.error.data);
|
|
115
123
|
}
|
|
116
124
|
requireLive(control);
|
|
117
|
-
return { kind: 'value', value: envelope.result };
|
|
125
|
+
return { kind: 'value', value: envelope.result, invocation: envelope.invocation };
|
|
118
126
|
}
|
|
119
127
|
catch (error) {
|
|
120
128
|
throw transportFailure(error, control, options.signal, timeoutMs, this.url, phase, delivery);
|
|
@@ -124,7 +132,7 @@ export class HttpTransport {
|
|
|
124
132
|
control.close();
|
|
125
133
|
}
|
|
126
134
|
}
|
|
127
|
-
async fetchResponse(codec, encoded, control) {
|
|
135
|
+
async fetchResponse(codec, encoded, trace, control) {
|
|
128
136
|
return this.fetchImpl(this.url, {
|
|
129
137
|
method: 'POST',
|
|
130
138
|
redirect: 'error',
|
|
@@ -133,6 +141,7 @@ export class HttpTransport {
|
|
|
133
141
|
referrerPolicy: 'no-referrer',
|
|
134
142
|
headers: {
|
|
135
143
|
...this.headers,
|
|
144
|
+
...protocol.http.encodeTraceHeaders(trace),
|
|
136
145
|
'content-type': codec.contentType,
|
|
137
146
|
accept: codec.contentType,
|
|
138
147
|
},
|
|
@@ -140,12 +149,12 @@ export class HttpTransport {
|
|
|
140
149
|
signal: control.signal,
|
|
141
150
|
});
|
|
142
151
|
}
|
|
143
|
-
async decodeBinary(response,
|
|
152
|
+
async decodeBinary(response, requestId, binaryId, control) {
|
|
144
153
|
if (!response.ok) {
|
|
145
154
|
throw new ProtocolError('server returned binary data with an error status.');
|
|
146
155
|
}
|
|
147
|
-
if (binaryId !== String(
|
|
148
|
-
throw new ProtocolError(`binary response
|
|
156
|
+
if (binaryId !== String(requestId)) {
|
|
157
|
+
throw new ProtocolError(`binary response requestId ${JSON.stringify(binaryId)} does not match request requestId ${requestId}.`);
|
|
149
158
|
}
|
|
150
159
|
const mediaType = normalizeMediaType(response.headers.get('content-type'));
|
|
151
160
|
if (mediaType === undefined) {
|
|
@@ -155,9 +164,11 @@ export class HttpTransport {
|
|
|
155
164
|
requireLive(control);
|
|
156
165
|
const headerNames = decodeProtocol('binary application-header manifest', () => protocol.http.decodeBinaryHeaderNames(response.headers.get(protocol.http.BINARY_HEADERS_FIELD)));
|
|
157
166
|
const headers = binaryHeaders(response.headers, headerNames);
|
|
167
|
+
const invocation = decodeProtocol('binary InvocationId field', () => protocol.http.decodeInvocationId(response.headers.get(protocol.http.INVOCATION_FIELD)));
|
|
158
168
|
const binary = decodeProtocol('binary response', () => protocol.decodeBinaryResponse({
|
|
159
169
|
kind: 'binary',
|
|
160
|
-
|
|
170
|
+
requestId,
|
|
171
|
+
invocation,
|
|
161
172
|
body,
|
|
162
173
|
mediaType,
|
|
163
174
|
...(Object.keys(headers).length === 0 ? {} : { headers }),
|
|
@@ -165,6 +176,7 @@ export class HttpTransport {
|
|
|
165
176
|
requireLive(control);
|
|
166
177
|
return {
|
|
167
178
|
kind: 'binary',
|
|
179
|
+
invocation: binary.invocation,
|
|
168
180
|
value: {
|
|
169
181
|
body: binary.body,
|
|
170
182
|
mediaType: binary.mediaType,
|
|
@@ -173,21 +185,19 @@ export class HttpTransport {
|
|
|
173
185
|
};
|
|
174
186
|
}
|
|
175
187
|
nextRequestId() {
|
|
176
|
-
const
|
|
177
|
-
this.nextId =
|
|
178
|
-
return
|
|
188
|
+
const requestId = this.nextId;
|
|
189
|
+
this.nextId = requestId === Number.MAX_SAFE_INTEGER ? 1 : requestId + 1;
|
|
190
|
+
return requestId;
|
|
179
191
|
}
|
|
180
192
|
requestCodec() {
|
|
181
193
|
return this.codecName === 'msgpack' ? codecs.loadMsgpack() : Promise.resolve(codecs.json);
|
|
182
194
|
}
|
|
183
195
|
}
|
|
184
|
-
function redirectResult(
|
|
196
|
+
function redirectResult(response) {
|
|
185
197
|
return Object.freeze({
|
|
186
198
|
kind: 'redirect',
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
...(redirect.credential === undefined ? {} : { credential: redirect.credential }),
|
|
190
|
-
}),
|
|
199
|
+
invocation: response.invocation,
|
|
200
|
+
redirect: response.redirect,
|
|
191
201
|
});
|
|
192
202
|
}
|
|
193
203
|
function normalizeUrl(input) {
|
|
@@ -256,9 +266,8 @@ function transportFailure(input, control, parent, timeoutMs, url, phase, deliver
|
|
|
256
266
|
if (input instanceof ResponseError || input instanceof ProtocolError)
|
|
257
267
|
return input;
|
|
258
268
|
if (control.timedOut) {
|
|
259
|
-
return
|
|
269
|
+
return invocationFailure(`request timed out after ${timeoutMs}ms.`, 'timeout', {
|
|
260
270
|
cause: asError(input),
|
|
261
|
-
phase: 'timeout',
|
|
262
271
|
delivery,
|
|
263
272
|
});
|
|
264
273
|
}
|
|
@@ -266,9 +275,8 @@ function transportFailure(input, control, parent, timeoutMs, url, phase, deliver
|
|
|
266
275
|
return asError(parent.reason ?? input);
|
|
267
276
|
return input instanceof TransportError
|
|
268
277
|
? input
|
|
269
|
-
:
|
|
278
|
+
: invocationFailure(`Failed to communicate with the server at ${url}.`, phase, {
|
|
270
279
|
cause: asError(input),
|
|
271
|
-
phase,
|
|
272
280
|
delivery,
|
|
273
281
|
});
|
|
274
282
|
}
|
|
@@ -308,6 +316,9 @@ const RESERVED_REQUEST_HEADERS = new Set([
|
|
|
308
316
|
'referrer-policy',
|
|
309
317
|
'set-cookie',
|
|
310
318
|
'te',
|
|
319
|
+
protocol.http.TRACEPARENT_FIELD,
|
|
320
|
+
protocol.http.TRACESTATE_FIELD,
|
|
321
|
+
protocol.http.BAGGAGE_FIELD,
|
|
311
322
|
'trailer',
|
|
312
323
|
'transfer-encoding',
|
|
313
324
|
'upgrade',
|
|
@@ -330,4 +341,3 @@ function hasControlCharacter(input) {
|
|
|
330
341
|
}
|
|
331
342
|
return false;
|
|
332
343
|
}
|
|
333
|
-
//# sourceMappingURL=transport.js.map
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
export type { RequestOptions, MissControl, StaleControl, Transport, TransportRequest, TransportResult, } from './transport.js';
|
|
2
2
|
export { asError, controlledSignal, positiveInteger, requireLive, type ControlledSignal, } from './deadline.js';
|
|
3
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/transport/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Result } from '@astrale-os/kernel-ports/functions';
|
|
2
1
|
import type { invocation as protocol } from '@astrale-os/kernel-protocol';
|
|
2
|
+
import type { Result } from '../client/result.js';
|
|
3
3
|
export interface RequestOptions {
|
|
4
4
|
readonly signal?: AbortSignal;
|
|
5
5
|
readonly timeoutMs?: number;
|
|
@@ -7,17 +7,23 @@ export interface RequestOptions {
|
|
|
7
7
|
}
|
|
8
8
|
export interface TransportRequest {
|
|
9
9
|
readonly call: protocol.Call;
|
|
10
|
+
/** Internally supplied per-attempt correlation syntax; never a RequestOptions field. */
|
|
11
|
+
readonly trace?: protocol.Trace;
|
|
10
12
|
readonly credential?: string;
|
|
11
13
|
readonly delegate?: protocol.Delegate;
|
|
12
14
|
readonly routing?: protocol.Routing;
|
|
15
|
+
/** Source-Kernel Schema Registration precondition; omitted after routing. */
|
|
16
|
+
readonly schema?: protocol.SchemaTarget;
|
|
13
17
|
}
|
|
14
18
|
/** Correlated reserved control decoded independently from application results and errors. */
|
|
15
19
|
export interface StaleControl {
|
|
16
20
|
readonly kind: 'stale';
|
|
17
21
|
readonly current: protocol.Stale['current'];
|
|
22
|
+
readonly invocation: protocol.InvocationId;
|
|
18
23
|
}
|
|
19
24
|
export interface MissControl {
|
|
20
25
|
readonly kind: 'miss';
|
|
26
|
+
readonly invocation: protocol.InvocationId;
|
|
21
27
|
}
|
|
22
28
|
export type TransportResult = Result | StaleControl | MissControl;
|
|
23
29
|
export interface Transport {
|
|
@@ -26,4 +32,3 @@ export interface Transport {
|
|
|
26
32
|
/** Optional owned-resource shutdown used by Client.close(). */
|
|
27
33
|
readonly close?: () => void;
|
|
28
34
|
}
|
|
29
|
-
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type * as codecs from '@astrale-os/kernel-protocol/codecs';
|
|
2
|
+
import * as protocol from '@astrale-os/kernel-protocol/invocation';
|
|
2
3
|
import type { ControlledSignal } from '../index.js';
|
|
3
4
|
import type { TransportResult } from '../index.js';
|
|
4
5
|
import type { ExchangeOwner } from './exchange.js';
|
|
@@ -29,10 +30,9 @@ export declare class WebSocketConnection implements ExchangeOwner {
|
|
|
29
30
|
connect(control: ControlledSignal): Promise<void>;
|
|
30
31
|
dispatch(request: protocol.Request, control: ControlledSignal, maximumBufferedItems: number): Promise<TransportResult>;
|
|
31
32
|
finish(exchange: WebSocketExchange, reusable: boolean, closeCode?: 1002 | 1008 | 1011): void;
|
|
32
|
-
cancel(exchange: WebSocketExchange,
|
|
33
|
+
cancel(exchange: WebSocketExchange, requestId: protocol.RequestId): void;
|
|
33
34
|
shutdown(reason?: Error, closeCode?: number, closeReason?: string): void;
|
|
34
35
|
private onOpen;
|
|
35
36
|
private onMessage;
|
|
36
37
|
private onFailure;
|
|
37
38
|
}
|
|
38
|
-
//# sourceMappingURL=connection.d.ts.map
|