@astrale-os/kernel-client 0.6.0-beta.9 → 1.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/auth.d.ts +22 -10
- package/dist/auth/auth.js +5 -7
- package/dist/auth/authorization.d.ts +4 -2
- package/dist/auth/authorization.js +25 -6
- package/dist/auth/credential.d.ts +7 -4
- package/dist/auth/credential.js +6 -3
- package/dist/auth/identity.d.ts +7 -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 +9 -11
- package/dist/client/client.d.ts +4 -3
- package/dist/client/client.js +16 -4
- package/dist/client/credential.d.ts +5 -3
- package/dist/client/credential.js +7 -3
- package/dist/client/index.d.ts +2 -3
- package/dist/client/index.js +2 -3
- 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 +11 -4
- package/dist/client/routing-control.js +18 -4
- package/dist/errors/client-error.d.ts +0 -1
- package/dist/errors/client-error.js +0 -1
- package/dist/errors/exchange-error.d.ts +19 -0
- package/dist/errors/exchange-error.js +9 -0
- package/dist/errors/index.d.ts +1 -1
- package/dist/errors/index.js +1 -1
- 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 +0 -1
- package/dist/errors/session-error.js +0 -1
- package/dist/errors/stale-route-error.d.ts +4 -4
- package/dist/errors/stale-route-error.js +5 -5
- package/dist/errors/transport-error.d.ts +3 -3
- package/dist/errors/transport-error.js +0 -1
- package/dist/graph/domain/binding.d.ts +0 -1
- package/dist/graph/domain/binding.js +0 -1
- package/dist/graph/domain/domain.typecheck.d.ts +0 -1
- package/dist/graph/domain/domain.typecheck.js +21 -1
- package/dist/graph/domain/index.d.ts +0 -1
- package/dist/graph/domain/index.js +0 -1
- package/dist/graph/domain/model.d.ts +0 -1
- package/dist/graph/domain/model.js +0 -1
- package/dist/graph/domain/page.d.ts +0 -1
- package/dist/graph/domain/page.js +0 -1
- package/dist/graph/domain/project.d.ts +0 -1
- package/dist/graph/domain/project.js +10 -7
- package/dist/graph/domain/provenance.d.ts +0 -1
- package/dist/graph/domain/provenance.js +0 -1
- package/dist/graph/errors.d.ts +0 -1
- package/dist/graph/errors.js +1 -3
- package/dist/graph/expectation.d.ts +3 -0
- package/dist/graph/expectation.js +6 -0
- package/dist/graph/graph.d.ts +6 -3
- package/dist/graph/graph.js +0 -1
- package/dist/graph/index.d.ts +2 -3
- package/dist/graph/index.js +1 -2
- package/dist/graph/mutation.d.ts +2 -4
- package/dist/graph/mutation.js +12 -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 +0 -1
- package/dist/graph/page/neighbors.js +2 -2
- package/dist/graph/page/page.d.ts +0 -1
- package/dist/graph/page/page.js +0 -1
- package/dist/graph/page-contract.d.ts +0 -1
- package/dist/graph/page-contract.js +0 -1
- package/dist/graph/provenance.d.ts +2 -1
- package/dist/graph/provenance.js +5 -1
- package/dist/graph/query.d.ts +3 -1
- package/dist/graph/query.js +15 -8
- package/dist/graph/read.d.ts +0 -1
- package/dist/graph/read.js +6 -5
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- 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 +0 -1
- package/dist/schema/admission.js +0 -1
- package/dist/schema/contracts.d.ts +3 -4
- 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 +0 -1
- package/dist/schema/introspection.js +10 -3
- package/dist/schema/operation.d.ts +0 -1
- package/dist/schema/operation.js +1 -2
- package/dist/schema/schema.d.ts +16 -10
- package/dist/schema/schema.js +92 -13
- package/dist/session/admission.d.ts +6 -0
- package/dist/session/admission.js +52 -0
- package/dist/session/bound.d.ts +17 -14
- package/dist/session/bound.js +54 -10
- package/dist/session/content/api.d.ts +45 -0
- package/dist/session/content/api.js +28 -0
- package/dist/session/content/batch.d.ts +5 -0
- package/dist/session/content/batch.js +93 -0
- package/dist/session/content/index.d.ts +1 -0
- package/dist/session/content/index.js +1 -0
- package/dist/session/content/input.d.ts +9 -0
- package/dist/session/content/input.js +33 -0
- package/dist/session/content/parts.d.ts +36 -0
- package/dist/session/content/parts.js +154 -0
- package/dist/session/content/retry.d.ts +3 -0
- package/dist/session/content/retry.js +41 -0
- package/dist/session/content/wire.d.ts +12 -0
- package/dist/session/content/wire.js +60 -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 +2 -3
- package/dist/session/context/index.js +2 -3
- package/dist/session/context/limits.d.ts +1 -2
- package/dist/session/context/limits.js +1 -2
- package/dist/session/context/operation.d.ts +5 -3
- package/dist/session/context/operation.js +1 -2
- package/dist/session/context/policy.d.ts +0 -2
- package/dist/session/context/policy.js +0 -17
- package/dist/session/credential/credentials.d.ts +65 -0
- package/dist/session/credential/credentials.js +296 -0
- package/dist/session/credential/index.d.ts +1 -0
- package/dist/session/credential/index.js +1 -0
- package/dist/session/credential/limits.d.ts +14 -0
- package/dist/session/credential/limits.js +14 -0
- package/dist/session/discovery/bundle.d.ts +9 -5
- package/dist/session/discovery/bundle.js +43 -26
- package/dist/session/discovery/discovery.d.ts +12 -5
- package/dist/session/discovery/discovery.js +42 -13
- package/dist/session/discovery/index.d.ts +6 -2
- package/dist/session/discovery/index.js +4 -8
- package/dist/session/discovery/release.d.ts +30 -0
- package/dist/session/discovery/release.js +81 -0
- package/dist/session/discovery/response.d.ts +3 -0
- package/dist/session/discovery/response.js +59 -0
- package/dist/session/discovery/snapshot.d.ts +4 -5
- package/dist/session/discovery/snapshot.js +2 -3
- package/dist/session/discovery/transport.d.ts +1 -4
- package/dist/session/discovery/transport.js +0 -1
- package/dist/session/exchange/domain.d.ts +27 -0
- package/dist/session/exchange/domain.js +63 -0
- package/dist/session/exchange/exchange.d.ts +48 -0
- package/dist/session/exchange/exchange.js +54 -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 +37 -0
- package/dist/session/exchange/options.js +65 -0
- package/dist/session/exchange/presentation.d.ts +19 -0
- package/dist/session/exchange/presentation.js +72 -0
- package/dist/session/exchange/source.d.ts +33 -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 -6
- package/dist/session/index.js +3 -2
- package/dist/session/options.d.ts +65 -0
- package/dist/session/options.js +132 -0
- package/dist/session/reference.d.ts +35 -20
- package/dist/session/reference.js +28 -11
- package/dist/session/routing/auth.d.ts +10 -1
- package/dist/session/routing/auth.js +8 -2
- package/dist/session/routing/cache.d.ts +21 -7
- package/dist/session/routing/cache.js +103 -73
- package/dist/session/routing/dispatch.d.ts +19 -11
- package/dist/session/routing/dispatch.js +113 -89
- package/dist/session/routing/envelope.d.ts +4 -3
- package/dist/session/routing/envelope.js +14 -10
- package/dist/session/routing/expiry.d.ts +4 -0
- package/dist/session/routing/expiry.js +32 -0
- package/dist/session/routing/index.d.ts +5 -5
- package/dist/session/routing/index.js +4 -3
- package/dist/session/routing/integrity.d.ts +7 -0
- package/dist/session/routing/integrity.js +44 -0
- package/dist/session/routing/recovery.d.ts +16 -0
- package/dist/session/routing/recovery.js +41 -0
- package/dist/session/routing/request.d.ts +9 -1
- package/dist/session/routing/request.js +17 -1
- package/dist/session/routing/result.d.ts +5 -0
- package/dist/session/routing/result.js +12 -0
- package/dist/session/routing/store.d.ts +23 -0
- package/dist/session/routing/store.js +99 -0
- package/dist/session/session.d.ts +37 -33
- package/dist/session/session.js +126 -152
- package/dist/session/session.typecheck.d.ts +0 -1
- package/dist/session/session.typecheck.js +183 -5
- package/dist/session/views/catalog.d.ts +9 -6
- package/dist/session/views/catalog.js +29 -23
- package/dist/session/views/index.d.ts +1 -2
- package/dist/session/views/index.js +1 -2
- package/dist/session/views/resolve.d.ts +6 -5
- package/dist/session/views/resolve.js +14 -7
- package/dist/store/entity-index.d.ts +1 -3
- package/dist/store/entity-index.js +0 -4
- 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 +40 -17
- 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 +6 -3
- 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 +0 -6
- package/dist/transport/auto/decision.d.ts +3 -3
- package/dist/transport/auto/decision.js +0 -1
- package/dist/transport/auto/fallback.d.ts +2 -2
- package/dist/transport/auto/fallback.js +2 -2
- 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 -2
- package/dist/transport/auto/transport.js +0 -3
- 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 +0 -1
- package/dist/transport/failure.js +0 -1
- package/dist/transport/http/admission.d.ts +5 -0
- package/dist/transport/http/admission.js +101 -0
- package/dist/transport/http/binary.d.ts +5 -0
- package/dist/transport/http/binary.js +70 -0
- package/dist/transport/http/byte-stream.d.ts +18 -0
- package/dist/transport/http/byte-stream.js +94 -0
- package/dist/transport/http/configuration.d.ts +24 -0
- package/dist/transport/http/configuration.js +116 -0
- package/dist/transport/http/index.d.ts +2 -2
- package/dist/transport/http/index.js +0 -1
- package/dist/transport/http/response.d.ts +8 -2
- package/dist/transport/http/response.js +11 -7
- package/dist/transport/http/retired.d.ts +8 -0
- package/dist/transport/http/retired.js +28 -0
- package/dist/transport/http/stream.d.ts +0 -1
- package/dist/transport/http/stream.js +0 -1
- package/dist/transport/http/transport.d.ts +4 -18
- package/dist/transport/http/transport.js +48 -252
- package/dist/transport/index.d.ts +1 -2
- package/dist/transport/index.js +0 -1
- package/dist/transport/transport.d.ts +10 -3
- package/dist/transport/transport.js +0 -1
- package/dist/transport/websocket/connection.d.ts +2 -2
- package/dist/transport/websocket/connection.js +5 -3
- package/dist/transport/websocket/exchange.d.ts +0 -1
- package/dist/transport/websocket/exchange.js +0 -1
- 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 -4
- package/dist/transport/websocket/transport.js +2 -18
- package/package.json +12 -15
- 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/session-error.d.ts.map +0 -1
- package/dist/errors/session-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/domain/binding.d.ts.map +0 -1
- package/dist/graph/domain/binding.js.map +0 -1
- package/dist/graph/domain/domain.typecheck.d.ts.map +0 -1
- package/dist/graph/domain/domain.typecheck.js.map +0 -1
- package/dist/graph/domain/index.d.ts.map +0 -1
- package/dist/graph/domain/index.js.map +0 -1
- package/dist/graph/domain/model.d.ts.map +0 -1
- package/dist/graph/domain/model.js.map +0 -1
- package/dist/graph/domain/page.d.ts.map +0 -1
- package/dist/graph/domain/page.js.map +0 -1
- package/dist/graph/domain/project.d.ts.map +0 -1
- package/dist/graph/domain/project.js.map +0 -1
- package/dist/graph/domain/provenance.d.ts.map +0 -1
- package/dist/graph/domain/provenance.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/provenance.d.ts.map +0 -1
- package/dist/graph/provenance.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/bound.d.ts.map +0 -1
- package/dist/session/bound.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 +0 -24
- package/dist/session/discovery/publication.d.ts.map +0 -1
- package/dist/session/discovery/publication.js +0 -124
- 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/discovery/transport.d.ts.map +0 -1
- package/dist/session/discovery/transport.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/failure.d.ts.map +0 -1
- package/dist/transport/failure.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,3 +1,4 @@
|
|
|
1
|
+
import type { NodePath } from '@astrale-os/kernel-core/path';
|
|
1
2
|
import type { RequestOptions, TransportRequest } from '../index.js';
|
|
2
3
|
import { TransportError } from '../../errors/index.js';
|
|
3
4
|
/** One invocation-owned total timeout budget shared by selection and fallback. */
|
|
@@ -13,5 +14,4 @@ export declare class InvocationBudget {
|
|
|
13
14
|
private remaining;
|
|
14
15
|
}
|
|
15
16
|
export declare function mayFallback(error: unknown): error is TransportError;
|
|
16
|
-
export declare function warningTarget(input: TransportRequest):
|
|
17
|
-
//# sourceMappingURL=fallback.d.ts.map
|
|
17
|
+
export declare function warningTarget(input: TransportRequest): NodePath;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { targetPath } from '@astrale-os/kernel-core/callable';
|
|
1
2
|
import { TransportError } from '../../errors/index.js';
|
|
2
3
|
import { invocationFailure } from '../failure.js';
|
|
3
4
|
import { positiveInteger } from '../index.js';
|
|
@@ -66,11 +67,10 @@ export function mayFallback(error) {
|
|
|
66
67
|
error.phase !== 'timeout');
|
|
67
68
|
}
|
|
68
69
|
export function warningTarget(input) {
|
|
69
|
-
return input.call.target;
|
|
70
|
+
return targetPath(input.call.target);
|
|
70
71
|
}
|
|
71
72
|
function abortReason(signal) {
|
|
72
73
|
return signal.reason instanceof Error
|
|
73
74
|
? signal.reason
|
|
74
75
|
: new Error(signal.reason === undefined ? 'request was cancelled' : String(signal.reason));
|
|
75
76
|
}
|
|
76
|
-
//# sourceMappingURL=fallback.js.map
|
|
@@ -7,7 +7,6 @@ export interface AutoTransportOptions {
|
|
|
7
7
|
readonly http: string;
|
|
8
8
|
readonly websocket: string;
|
|
9
9
|
};
|
|
10
|
-
readonly codec?: 'json' | 'msgpack';
|
|
11
10
|
readonly fetch?: Fetch;
|
|
12
11
|
readonly websocket?: WebSocketConstructor;
|
|
13
12
|
readonly headers?: Readonly<Record<string, string>>;
|
|
@@ -35,4 +34,3 @@ export declare class AutoTransport implements Transport {
|
|
|
35
34
|
private tryWebsocket;
|
|
36
35
|
private requireOpen;
|
|
37
36
|
}
|
|
38
|
-
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -26,7 +26,6 @@ export class AutoTransport {
|
|
|
26
26
|
this.onWarning = options.onWarning;
|
|
27
27
|
this.http = new HttpTransport({
|
|
28
28
|
url: options.endpoints.http,
|
|
29
|
-
...(options.codec === undefined ? {} : { codec: options.codec }),
|
|
30
29
|
...(options.fetch === undefined ? {} : { fetch: options.fetch }),
|
|
31
30
|
...(options.headers === undefined ? {} : { headers: options.headers }),
|
|
32
31
|
timeoutMs: this.timeoutMs,
|
|
@@ -39,7 +38,6 @@ export class AutoTransport {
|
|
|
39
38
|
});
|
|
40
39
|
this.websocket = new WebSocketTransport({
|
|
41
40
|
url: options.endpoints.websocket,
|
|
42
|
-
...(options.codec === undefined ? {} : { codec: options.codec }),
|
|
43
41
|
...(options.websocket === undefined ? {} : { websocket: options.websocket }),
|
|
44
42
|
timeoutMs: this.timeoutMs,
|
|
45
43
|
...(options.maximumRequestBytes === undefined
|
|
@@ -138,4 +136,3 @@ export class AutoTransport {
|
|
|
138
136
|
throw invocationFailure('AutoTransport is closed.', 'closed');
|
|
139
137
|
}
|
|
140
138
|
}
|
|
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,11 +9,13 @@ export function emitWarning(warning, observer) {
|
|
|
9
9
|
try {
|
|
10
10
|
if (observer)
|
|
11
11
|
observer(warning);
|
|
12
|
-
else
|
|
13
|
-
globalThis
|
|
12
|
+
else {
|
|
13
|
+
const runtimeConsole = globalThis
|
|
14
|
+
.console;
|
|
15
|
+
runtimeConsole?.warn(formatClientWarning(warning));
|
|
16
|
+
}
|
|
14
17
|
}
|
|
15
18
|
catch {
|
|
16
19
|
// Warning observation cannot change invocation settlement.
|
|
17
20
|
}
|
|
18
21
|
}
|
|
19
|
-
//# sourceMappingURL=warning.js.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
|
|
@@ -5,4 +5,3 @@ type InvocationFailureEvidence = Omit<InvocationTransportErrorOptions, 'delivery
|
|
|
5
5
|
/** Create invocation transport evidence with the common not-sent default. */
|
|
6
6
|
export declare function invocationFailure(message: string, phase: InvocationTransportErrorOptions['phase'], evidence?: InvocationFailureEvidence): TransportError;
|
|
7
7
|
export {};
|
|
8
|
-
//# sourceMappingURL=failure.d.ts.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as protocol from '@astrale-os/kernel-protocol/invocation';
|
|
2
|
+
import type { TransportResult } from '../index.js';
|
|
3
|
+
import { type ResponseContext } from './response.js';
|
|
4
|
+
/** Admit exactly one response representation, preserving reserved-control precedence. */
|
|
5
|
+
export declare function admitResponse(response: Response, requestId: protocol.RequestId, context: ResponseContext): Promise<TransportResult>;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import * as protocol from '@astrale-os/kernel-protocol/invocation';
|
|
2
|
+
import * as retirement from '@astrale-os/kernel-protocol/routes';
|
|
3
|
+
import { ProtocolError, ResponseError } from '../../errors/index.js';
|
|
4
|
+
import { invocationFailure } from '../failure.js';
|
|
5
|
+
import { requireLive } from '../index.js';
|
|
6
|
+
import { decodeBinary } from './binary.js';
|
|
7
|
+
import { codecForResponse, decodeProtocol, readBoundedBody, requireId, requireNoStore, } from './response.js';
|
|
8
|
+
import { decodeDeploymentRetired } from './retired.js';
|
|
9
|
+
import { HttpStream } from './stream.js';
|
|
10
|
+
/** Admit exactly one response representation, preserving reserved-control precedence. */
|
|
11
|
+
export async function admitResponse(response, requestId, context) {
|
|
12
|
+
const { control, maximumBytes } = context;
|
|
13
|
+
if (response.status >= 300 && response.status < 400) {
|
|
14
|
+
throw new ProtocolError('server returned a network redirect.');
|
|
15
|
+
}
|
|
16
|
+
const streamFraming = response.headers.get(protocol.http.STREAM_FRAMING_FIELD);
|
|
17
|
+
const binaryId = response.headers.get(protocol.http.REQUEST_ID_FIELD);
|
|
18
|
+
const binaryManifest = response.headers.get(protocol.http.BINARY_HEADERS_FIELD);
|
|
19
|
+
const binaryDelivery = response.headers.get(protocol.http.BINARY_DELIVERY_FIELD);
|
|
20
|
+
const hasStreamSignal = streamFraming !== null;
|
|
21
|
+
const hasBinarySignal = binaryId !== null || binaryManifest !== null || binaryDelivery !== null;
|
|
22
|
+
const responseCodec = codecForResponse(response.headers.get('content-type'));
|
|
23
|
+
if (response.headers.has(retirement.HTTP_DEPLOYMENT_RETIRED)) {
|
|
24
|
+
if (hasStreamSignal || hasBinarySignal) {
|
|
25
|
+
throw new ProtocolError('server returned a deployment-retired control with a stream or binary signal.');
|
|
26
|
+
}
|
|
27
|
+
const retired = await decodeDeploymentRetired(response, responseCodec, context);
|
|
28
|
+
requireLive(control);
|
|
29
|
+
return retired;
|
|
30
|
+
}
|
|
31
|
+
if (!response.ok && responseCodec === undefined && !hasStreamSignal && !hasBinarySignal) {
|
|
32
|
+
throw invocationFailure(`server returned HTTP ${response.status} without an invocation response.`, 'receive', { delivery: 'unknown' });
|
|
33
|
+
}
|
|
34
|
+
requireNoStore(response);
|
|
35
|
+
if (hasStreamSignal && hasBinarySignal) {
|
|
36
|
+
throw new ProtocolError('server returned conflicting stream and binary response signals.');
|
|
37
|
+
}
|
|
38
|
+
if (hasBinarySignal) {
|
|
39
|
+
if (binaryId === null || binaryManifest === null) {
|
|
40
|
+
throw new ProtocolError('server returned an incomplete binary response signal.');
|
|
41
|
+
}
|
|
42
|
+
if (binaryDelivery !== null && binaryDelivery !== protocol.http.STREAMING_BINARY_DELIVERY) {
|
|
43
|
+
throw new ProtocolError('server returned an unsupported binary delivery signal.');
|
|
44
|
+
}
|
|
45
|
+
const binary = await decodeBinary(response, requestId, binaryId, binaryDelivery !== null, context);
|
|
46
|
+
return binary;
|
|
47
|
+
}
|
|
48
|
+
if (responseCodec === undefined) {
|
|
49
|
+
throw new ProtocolError(`server returned unsupported Content-Type ${JSON.stringify(response.headers.get('content-type'))}.`);
|
|
50
|
+
}
|
|
51
|
+
if (hasStreamSignal) {
|
|
52
|
+
if (streamFraming !== protocol.http.LENGTH_PREFIX_V1) {
|
|
53
|
+
throw new ProtocolError(`server returned unsupported stream framing ${JSON.stringify(streamFraming)}.`);
|
|
54
|
+
}
|
|
55
|
+
if (!response.ok) {
|
|
56
|
+
throw new ProtocolError('server returned a non-success stream response.');
|
|
57
|
+
}
|
|
58
|
+
const stream = await HttpStream.open(response, responseCodec, requestId, maximumBytes, control);
|
|
59
|
+
requireLive(control);
|
|
60
|
+
return { kind: 'stream', stream, invocation: stream.invocation };
|
|
61
|
+
}
|
|
62
|
+
const body = await readBoundedBody(response, maximumBytes, control.signal);
|
|
63
|
+
requireLive(control);
|
|
64
|
+
const decoded = decodeProtocol('response body', () => responseCodec.decode(body));
|
|
65
|
+
const envelope = decodeProtocol('response envelope', () => protocol.decodeResponse(decoded));
|
|
66
|
+
if (envelope.requestId === null && 'error' in envelope) {
|
|
67
|
+
throw new ResponseError(envelope.error.code, envelope.error.message, envelope.invocation, envelope.error.data);
|
|
68
|
+
}
|
|
69
|
+
requireId(requestId, envelope.requestId);
|
|
70
|
+
if ('kind' in envelope && envelope.kind === 'stale') {
|
|
71
|
+
const stale = decodeProtocol('stale response', () => protocol.decodeStale(envelope));
|
|
72
|
+
requireLive(control);
|
|
73
|
+
return Object.freeze({
|
|
74
|
+
kind: 'stale',
|
|
75
|
+
current: stale.current,
|
|
76
|
+
invocation: stale.invocation,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
if ('kind' in envelope && envelope.kind === 'miss') {
|
|
80
|
+
decodeProtocol('miss response', () => protocol.decodeMiss(envelope));
|
|
81
|
+
requireLive(control);
|
|
82
|
+
return Object.freeze({ kind: 'miss', invocation: envelope.invocation });
|
|
83
|
+
}
|
|
84
|
+
if ('kind' in envelope && envelope.kind === 'redirect') {
|
|
85
|
+
const response = decodeProtocol('redirect response', () => protocol.decodeRedirectResponse(envelope));
|
|
86
|
+
requireLive(control);
|
|
87
|
+
return redirectResult(response);
|
|
88
|
+
}
|
|
89
|
+
if ('error' in envelope) {
|
|
90
|
+
throw new ResponseError(envelope.error.code, envelope.error.message, envelope.invocation, envelope.error.data);
|
|
91
|
+
}
|
|
92
|
+
requireLive(control);
|
|
93
|
+
return { kind: 'value', value: envelope.result, invocation: envelope.invocation };
|
|
94
|
+
}
|
|
95
|
+
function redirectResult(response) {
|
|
96
|
+
return Object.freeze({
|
|
97
|
+
kind: 'redirect',
|
|
98
|
+
invocation: response.invocation,
|
|
99
|
+
redirect: response.redirect,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as protocol from '@astrale-os/kernel-protocol/invocation';
|
|
2
|
+
import type { BinaryResponse } from '../../client/index.js';
|
|
3
|
+
import { type ResponseContext } from './response.js';
|
|
4
|
+
/** Admit buffered or streaming binary output within the invocation's lifetime. */
|
|
5
|
+
export declare function decodeBinary(response: Response, requestId: protocol.RequestId, binaryId: string, streaming: boolean, context: ResponseContext): Promise<BinaryResponse>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { canonicalMediaType } from '@astrale-os/kernel-protocol/artifact';
|
|
2
|
+
import * as protocol from '@astrale-os/kernel-protocol/invocation';
|
|
3
|
+
import { ProtocolError } from '../../errors/index.js';
|
|
4
|
+
import { requireLive } from '../index.js';
|
|
5
|
+
import { HttpByteStream } from './byte-stream.js';
|
|
6
|
+
import { binaryHeaders, decodeProtocol, readBoundedBody } from './response.js';
|
|
7
|
+
/** Admit buffered or streaming binary output within the invocation's lifetime. */
|
|
8
|
+
export async function decodeBinary(response, requestId, binaryId, streaming, context) {
|
|
9
|
+
const { control, maximumBytes } = context;
|
|
10
|
+
if (binaryId !== String(requestId)) {
|
|
11
|
+
throw new ProtocolError(`binary response requestId ${JSON.stringify(binaryId)} does not match request requestId ${requestId}.`);
|
|
12
|
+
}
|
|
13
|
+
const contentType = response.headers.get('content-type');
|
|
14
|
+
if (contentType === null) {
|
|
15
|
+
throw new ProtocolError('binary response has no media type.');
|
|
16
|
+
}
|
|
17
|
+
const mediaType = decodeProtocol('binary media type', () => canonicalMediaType(contentType));
|
|
18
|
+
const headerNames = decodeProtocol('binary application-header manifest', () => protocol.http.decodeBinaryHeaderNames(response.headers.get(protocol.http.BINARY_HEADERS_FIELD)));
|
|
19
|
+
const headers = binaryHeaders(response.headers, headerNames);
|
|
20
|
+
const invocation = decodeProtocol('binary InvocationId field', () => protocol.http.decodeInvocationId(response.headers.get(protocol.http.INVOCATION_FIELD)));
|
|
21
|
+
if (streaming) {
|
|
22
|
+
if (response.body === null)
|
|
23
|
+
throw new ProtocolError('streaming binary has no body.');
|
|
24
|
+
// An intermediary may rewrite Content-Length (for example when it compresses the body), so
|
|
25
|
+
// only the protocol length counts.
|
|
26
|
+
const length = response.headers.get(protocol.http.BINARY_LENGTH_FIELD);
|
|
27
|
+
const expectedBytes = length === null ? undefined : protocol.http.decodeBinaryLength(length);
|
|
28
|
+
if (length !== null && expectedBytes === undefined) {
|
|
29
|
+
throw new ProtocolError(`streaming binary has an invalid ${protocol.http.BINARY_LENGTH_FIELD}.`);
|
|
30
|
+
}
|
|
31
|
+
if (expectedBytes !== undefined && expectedBytes > maximumBytes) {
|
|
32
|
+
throw new ProtocolError(`streaming binary exceeds maximumResponseBytes (${maximumBytes}).`);
|
|
33
|
+
}
|
|
34
|
+
requireLive(control);
|
|
35
|
+
return {
|
|
36
|
+
kind: 'binary',
|
|
37
|
+
invocation,
|
|
38
|
+
value: {
|
|
39
|
+
body: new HttpByteStream(response.body, maximumBytes, control, expectedBytes),
|
|
40
|
+
// The byte stream enforces this exact count through its final read.
|
|
41
|
+
...(expectedBytes === undefined ? {} : { length: expectedBytes }),
|
|
42
|
+
mediaType,
|
|
43
|
+
...(response.status === 200 ? {} : { status: response.status }),
|
|
44
|
+
...(Object.keys(headers).length === 0 ? {} : { headers }),
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
const body = await readBoundedBody(response, maximumBytes, control.signal);
|
|
49
|
+
requireLive(control);
|
|
50
|
+
const binary = decodeProtocol('binary response', () => protocol.decodeBinaryResponse({
|
|
51
|
+
kind: 'binary',
|
|
52
|
+
requestId,
|
|
53
|
+
invocation,
|
|
54
|
+
body,
|
|
55
|
+
mediaType,
|
|
56
|
+
status: response.status,
|
|
57
|
+
...(Object.keys(headers).length === 0 ? {} : { headers }),
|
|
58
|
+
}));
|
|
59
|
+
requireLive(control);
|
|
60
|
+
return {
|
|
61
|
+
kind: 'binary',
|
|
62
|
+
invocation: binary.invocation,
|
|
63
|
+
value: {
|
|
64
|
+
body: binary.body,
|
|
65
|
+
mediaType: binary.mediaType,
|
|
66
|
+
...(binary.status === 200 ? {} : { status: binary.status }),
|
|
67
|
+
...(binary.headers === undefined ? {} : { headers: binary.headers }),
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** Web Fetch capability used by the built-in HTTP transport. */
|
|
2
|
+
export type Fetch = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
3
|
+
export interface HttpTransportOptions {
|
|
4
|
+
readonly url: string;
|
|
5
|
+
/** Inject this capability when the host does not provide global Fetch. */
|
|
6
|
+
readonly fetch?: Fetch;
|
|
7
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
8
|
+
readonly timeoutMs?: number;
|
|
9
|
+
/** Maximum bytes in one encoded request before Fetch handoff. */
|
|
10
|
+
readonly maximumRequestBytes?: number;
|
|
11
|
+
/** Maximum unary, binary, or individual stream-frame body size. */
|
|
12
|
+
readonly maximumResponseBytes?: number;
|
|
13
|
+
}
|
|
14
|
+
/** Captured transport configuration, admitted once before any invocation. */
|
|
15
|
+
export interface Configuration {
|
|
16
|
+
readonly url: string;
|
|
17
|
+
readonly fetch: Fetch;
|
|
18
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
19
|
+
readonly timeoutMs: number;
|
|
20
|
+
readonly maximumRequestBytes: number;
|
|
21
|
+
readonly maximumResponseBytes: number;
|
|
22
|
+
}
|
|
23
|
+
/** Admit static options and detach the caller's request headers. */
|
|
24
|
+
export declare function capture(options: HttpTransportOptions): Configuration;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import * as protocol from '@astrale-os/kernel-protocol/invocation';
|
|
2
|
+
import { asError, positiveInteger } from '../index.js';
|
|
3
|
+
const DEFAULT_TIMEOUT_MS = 30_000;
|
|
4
|
+
const DEFAULT_MAXIMUM_REQUEST_BYTES = 16 * 1024 * 1024;
|
|
5
|
+
const DEFAULT_MAXIMUM_RESPONSE_BYTES = 16 * 1024 * 1024;
|
|
6
|
+
/** Admit static options and detach the caller's request headers. */
|
|
7
|
+
export function capture(options) {
|
|
8
|
+
if (options === null || typeof options !== 'object') {
|
|
9
|
+
throw new TypeError('HttpTransport options must be an object.');
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
url: normalizeUrl(options.url),
|
|
13
|
+
fetch: admitFetch(options.fetch),
|
|
14
|
+
headers: admitHeaders(options.headers ?? {}),
|
|
15
|
+
timeoutMs: positiveInteger(options.timeoutMs ?? DEFAULT_TIMEOUT_MS, 'timeoutMs'),
|
|
16
|
+
maximumRequestBytes: positiveInteger(options.maximumRequestBytes ?? DEFAULT_MAXIMUM_REQUEST_BYTES, 'maximumRequestBytes'),
|
|
17
|
+
maximumResponseBytes: positiveInteger(options.maximumResponseBytes ?? DEFAULT_MAXIMUM_RESPONSE_BYTES, 'maximumResponseBytes'),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function normalizeUrl(input) {
|
|
21
|
+
if (typeof input !== 'string')
|
|
22
|
+
throw new TypeError('server URL must be a string.');
|
|
23
|
+
let parsed;
|
|
24
|
+
try {
|
|
25
|
+
parsed = new URL(input);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
throw new TypeError(`Invalid server URL ${JSON.stringify(input)}.`, { cause: asError(error) });
|
|
29
|
+
}
|
|
30
|
+
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
|
|
31
|
+
throw new TypeError('server URL must use http or https.');
|
|
32
|
+
}
|
|
33
|
+
if (parsed.username !== '' || parsed.password !== '' || parsed.hash !== '') {
|
|
34
|
+
throw new TypeError('server URL cannot contain credentials or a fragment.');
|
|
35
|
+
}
|
|
36
|
+
return parsed.toString();
|
|
37
|
+
}
|
|
38
|
+
function admitHeaders(input) {
|
|
39
|
+
if (input === null || typeof input !== 'object' || Array.isArray(input)) {
|
|
40
|
+
throw new TypeError('HTTP headers must be an object.');
|
|
41
|
+
}
|
|
42
|
+
const output = {};
|
|
43
|
+
for (const [name, value] of Object.entries(input)) {
|
|
44
|
+
if (!HEADER_NAME.test(name)) {
|
|
45
|
+
throw new TypeError(`HTTP header name ${JSON.stringify(name)} is invalid.`);
|
|
46
|
+
}
|
|
47
|
+
const normalized = name.toLowerCase();
|
|
48
|
+
if (Object.hasOwn(output, normalized)) {
|
|
49
|
+
throw new TypeError(`HTTP header ${JSON.stringify(name)} occurs more than once.`);
|
|
50
|
+
}
|
|
51
|
+
if (isReservedRequestHeader(normalized)) {
|
|
52
|
+
throw new TypeError(`HTTP header ${JSON.stringify(name)} is owned by transport.`);
|
|
53
|
+
}
|
|
54
|
+
if (typeof value !== 'string') {
|
|
55
|
+
throw new TypeError(`HTTP header ${JSON.stringify(name)} must be a string.`);
|
|
56
|
+
}
|
|
57
|
+
if (hasControlCharacter(value)) {
|
|
58
|
+
throw new TypeError(`HTTP header ${JSON.stringify(name)} contains a control character.`);
|
|
59
|
+
}
|
|
60
|
+
output[normalized] = value;
|
|
61
|
+
}
|
|
62
|
+
return Object.freeze(output);
|
|
63
|
+
}
|
|
64
|
+
function admitFetch(input) {
|
|
65
|
+
const implementation = input ?? globalThis.fetch;
|
|
66
|
+
if (typeof implementation !== 'function') {
|
|
67
|
+
throw new TypeError('HttpTransport requires a Fetch implementation.');
|
|
68
|
+
}
|
|
69
|
+
return input === undefined ? implementation.bind(globalThis) : implementation;
|
|
70
|
+
}
|
|
71
|
+
const HEADER_NAME = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
|
|
72
|
+
const RESERVED_REQUEST_HEADERS = new Set([
|
|
73
|
+
'accept',
|
|
74
|
+
'accept-encoding',
|
|
75
|
+
'authorization',
|
|
76
|
+
'cache-control',
|
|
77
|
+
'connection',
|
|
78
|
+
'content-length',
|
|
79
|
+
'content-type',
|
|
80
|
+
'cookie',
|
|
81
|
+
'forwarded',
|
|
82
|
+
'host',
|
|
83
|
+
'keep-alive',
|
|
84
|
+
'origin',
|
|
85
|
+
'pragma',
|
|
86
|
+
'proxy-authenticate',
|
|
87
|
+
'proxy-authorization',
|
|
88
|
+
'referer',
|
|
89
|
+
'referrer-policy',
|
|
90
|
+
'set-cookie',
|
|
91
|
+
'te',
|
|
92
|
+
protocol.http.TRACEPARENT_FIELD,
|
|
93
|
+
protocol.http.TRACESTATE_FIELD,
|
|
94
|
+
protocol.http.BAGGAGE_FIELD,
|
|
95
|
+
'trailer',
|
|
96
|
+
'transfer-encoding',
|
|
97
|
+
'upgrade',
|
|
98
|
+
'via',
|
|
99
|
+
]);
|
|
100
|
+
function isReservedRequestHeader(name) {
|
|
101
|
+
return (RESERVED_REQUEST_HEADERS.has(name) ||
|
|
102
|
+
name.startsWith('access-control-') ||
|
|
103
|
+
name.startsWith('content-') ||
|
|
104
|
+
name.startsWith('proxy-') ||
|
|
105
|
+
name.startsWith('sec-websocket-') ||
|
|
106
|
+
name.startsWith('x-astrale-') ||
|
|
107
|
+
name.startsWith('x-forwarded-'));
|
|
108
|
+
}
|
|
109
|
+
function hasControlCharacter(input) {
|
|
110
|
+
for (let index = 0; index < input.length; index += 1) {
|
|
111
|
+
const code = input.charCodeAt(index);
|
|
112
|
+
if (code <= 0x1f || code === 0x7f)
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { HttpTransport
|
|
2
|
-
|
|
1
|
+
export { HttpTransport } from './transport.js';
|
|
2
|
+
export type { Fetch, HttpTransportOptions } from './configuration.js';
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import * as codecs from '@astrale-os/kernel-protocol/codecs';
|
|
2
2
|
import * as protocol from '@astrale-os/kernel-protocol/invocation';
|
|
3
|
-
|
|
3
|
+
import { type ControlledSignal } from '../index.js';
|
|
4
|
+
/** The body budget and cancellation lifetime shared by all response representations. */
|
|
5
|
+
export interface ResponseContext {
|
|
6
|
+
readonly maximumBytes: number;
|
|
7
|
+
readonly control: ControlledSignal;
|
|
8
|
+
}
|
|
9
|
+
export declare function codecForResponse(contentType: string | null): codecs.Codec | undefined;
|
|
4
10
|
export declare function readBoundedBody(response: Response, maximumBytes: number, signal: AbortSignal): Promise<Uint8Array>;
|
|
5
11
|
export declare function requireId(expected: protocol.RequestId, received: protocol.RequestId): void;
|
|
6
12
|
export declare function decodeProtocol<T>(label: string, decode: () => T): T;
|
|
7
13
|
export declare function normalizeMediaType(input: string | null): string | undefined;
|
|
8
14
|
export declare function binaryHeaders(input: Headers, names: readonly string[]): Readonly<Record<string, string>>;
|
|
9
|
-
|
|
15
|
+
export declare function requireNoStore(response: Response): void;
|
|
@@ -2,12 +2,8 @@ import * as codecs from '@astrale-os/kernel-protocol/codecs';
|
|
|
2
2
|
import * as protocol from '@astrale-os/kernel-protocol/invocation';
|
|
3
3
|
import { ProtocolError, ResponseError } from '../../errors/index.js';
|
|
4
4
|
import { asError } from '../index.js';
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
const supported = mediaType === codecs.CONTENT_TYPE_MSGPACK
|
|
8
|
-
? [codecs.json, await codecs.loadMsgpack()]
|
|
9
|
-
: [codecs.json];
|
|
10
|
-
return protocol.http.codecForContentType(contentType, supported);
|
|
5
|
+
export function codecForResponse(contentType) {
|
|
6
|
+
return protocol.http.codecForContentType(contentType, [codecs.json]);
|
|
11
7
|
}
|
|
12
8
|
export async function readBoundedBody(response, maximumBytes, signal) {
|
|
13
9
|
const declared = response.headers.get('content-length');
|
|
@@ -77,4 +73,12 @@ export function binaryHeaders(input, names) {
|
|
|
77
73
|
}
|
|
78
74
|
return Object.freeze(output);
|
|
79
75
|
}
|
|
80
|
-
|
|
76
|
+
export function requireNoStore(response) {
|
|
77
|
+
const directives = response.headers
|
|
78
|
+
.get('cache-control')
|
|
79
|
+
?.split(',')
|
|
80
|
+
.map((directive) => directive.trim().toLowerCase()) ?? [];
|
|
81
|
+
if (!directives.includes('no-store')) {
|
|
82
|
+
throw new ProtocolError('server response is missing Cache-Control: no-store.');
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type * as codecs from '@astrale-os/kernel-protocol/codecs';
|
|
2
|
+
import type { DeploymentRetired } from '../index.js';
|
|
3
|
+
import { type ResponseContext } from './response.js';
|
|
4
|
+
/**
|
|
5
|
+
* Admit the reserved retirement control only as the exact 410, header and envelope triple; the
|
|
6
|
+
* header beside any other status, value or body is an invalid response, never an ordinary error.
|
|
7
|
+
*/
|
|
8
|
+
export declare function decodeDeploymentRetired(response: Response, codec: codecs.Codec | undefined, context: ResponseContext): Promise<DeploymentRetired>;
|