@astrale-os/kernel-client 0.6.0-beta.9 → 1.0.0-beta.1
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
package/dist/session/bound.d.ts
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
import type { IssuerId } from '@astrale-os/kernel-core/auth';
|
|
2
|
-
import type {
|
|
2
|
+
import type { AuthApi } from '../auth/index.js';
|
|
3
|
+
import type { SchemaApi } from '../schema/index.js';
|
|
4
|
+
import type { ContentApi } from './content/index.js';
|
|
3
5
|
import type { SessionControlOptions } from './context/index.js';
|
|
4
|
-
import type { CallableReference, InputOfReference, OutputOfReference } from './reference.js';
|
|
5
6
|
import type { SessionRequestOptions } from './routing/index.js';
|
|
7
|
+
import type { ClientSession } from './session.js';
|
|
6
8
|
import type { ViewCatalog } from './views/index.js';
|
|
7
|
-
import { type
|
|
8
|
-
import { type Binary, type Call, type Input, type Result, type Stream } from '../client/index.js';
|
|
9
|
+
import { type Binary, type Call, type Stream } from '../client/index.js';
|
|
9
10
|
import { type GraphApi } from '../graph/index.js';
|
|
10
11
|
/** Exact live Session surface captured by one credential-bound Kernel view. */
|
|
11
12
|
export interface BoundSessionSource {
|
|
12
13
|
readonly kernel: IssuerId;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
readonly schema: SchemaApi;
|
|
15
|
+
readonly auth: Pick<AuthApi, 'admit'>;
|
|
16
|
+
readonly content?: ContentApi;
|
|
17
|
+
dispatch: ClientSession['dispatch'];
|
|
18
|
+
call: ClientSession['call'];
|
|
19
|
+
invoke: ClientSession['invoke'];
|
|
16
20
|
stream(call: Call, options?: SessionRequestOptions): Promise<Stream>;
|
|
17
21
|
binary(call: Call, options?: SessionRequestOptions): Promise<Binary>;
|
|
18
|
-
|
|
19
|
-
viewsFor(target: Parameters<import('./session.js').ClientSession['viewsFor']>[0], options?: SessionControlOptions): Promise<ViewCatalog>;
|
|
22
|
+
viewsFor(domain: Parameters<ClientSession['viewsFor']>[0], options?: SessionControlOptions): Promise<ViewCatalog>;
|
|
20
23
|
}
|
|
21
24
|
export interface BoundSessionControls {
|
|
22
25
|
readonly signal: AbortSignal;
|
|
@@ -32,14 +35,14 @@ export interface BoundSessionControls {
|
|
|
32
35
|
export interface BoundClientSession extends GraphApi {
|
|
33
36
|
readonly kernel: IssuerId;
|
|
34
37
|
readonly auth: AuthApi;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
readonly schema: SchemaApi;
|
|
39
|
+
readonly content: ContentApi;
|
|
40
|
+
dispatch: ClientSession['dispatch'];
|
|
41
|
+
call: ClientSession['call'];
|
|
42
|
+
invoke: ClientSession['invoke'];
|
|
38
43
|
stream(call: Call, options?: SessionRequestOptions): Promise<Stream>;
|
|
39
44
|
binary(call: Call, options?: SessionRequestOptions): Promise<Binary>;
|
|
40
|
-
installation(origin: string, options?: SessionControlOptions): Promise<ReadyInstallation>;
|
|
41
45
|
viewsFor: BoundSessionSource['viewsFor'];
|
|
42
46
|
}
|
|
43
47
|
/** Capture one Session into the ordinary graph, auth, and invocation Kernel journey. */
|
|
44
48
|
export declare function bindSession(source: BoundSessionSource, controls?: BoundSessionControls): BoundClientSession;
|
|
45
|
-
//# sourceMappingURL=bound.d.ts.map
|
package/dist/session/bound.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createAuth } from '../auth/
|
|
1
|
+
import { createAuth } from '../auth/auth.js';
|
|
2
2
|
import { call as createCall, } from '../client/index.js';
|
|
3
3
|
import { createGraph } from '../graph/index.js';
|
|
4
4
|
/** Capture one Session into the ordinary graph, auth, and invocation Kernel journey. */
|
|
@@ -7,34 +7,67 @@ export function bindSession(source, controls) {
|
|
|
7
7
|
invalid();
|
|
8
8
|
const admittedControls = admitControls(controls);
|
|
9
9
|
const dispatchSource = capture(source, 'dispatch');
|
|
10
|
+
const admitSource = capture(source.auth, 'admit');
|
|
10
11
|
const callSource = capture(source, 'call');
|
|
11
12
|
const invokeSource = capture(source, 'invoke');
|
|
12
13
|
const streamSource = capture(source, 'stream');
|
|
13
14
|
const binarySource = capture(source, 'binary');
|
|
14
|
-
const
|
|
15
|
+
const contentSource = source.content === undefined ? unavailableContent : source.content;
|
|
16
|
+
if (contentSource === null || typeof contentSource !== 'object')
|
|
17
|
+
invalid();
|
|
18
|
+
const uploadSource = capture(contentSource, 'upload');
|
|
19
|
+
const downloadSource = capture(contentSource, 'download');
|
|
15
20
|
const viewsForSource = capture(source, 'viewsFor');
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
21
|
+
const schemaSource = captureSchema(source.schema);
|
|
22
|
+
const dispatch = ((input, options) => dispatchSource(input, requestOptions(options, admittedControls)));
|
|
23
|
+
const admit = (input, options) => admitSource(input, mergeOptions(options, admittedControls));
|
|
24
|
+
const call = ((input, options) => callSource(input, requestOptions(options, admittedControls)));
|
|
25
|
+
const invoke = ((reference, input, options) => invokeSource(reference, input, requestOptions(options, admittedControls)));
|
|
19
26
|
const stream = (input, options) => streamSource(input, requestOptions(options, admittedControls));
|
|
20
27
|
const binary = (input, options) => binarySource(input, requestOptions(options, admittedControls));
|
|
21
|
-
const
|
|
22
|
-
|
|
28
|
+
const upload = (input, options) => uploadSource(input, mergeOptions(options, admittedControls));
|
|
29
|
+
// Both forms share the bound controls; the source selects the form from its argument.
|
|
30
|
+
const download = ((input, options) => downloadSource(input, controlOptions(options, admittedControls)));
|
|
31
|
+
const content = Object.freeze({ upload, download });
|
|
32
|
+
const viewsFor = (domain, options) => viewsForSource(domain, controlOptions(options, admittedControls));
|
|
33
|
+
const install = (request, options) => schemaSource.install(request, controlOptions(options, admittedControls));
|
|
34
|
+
const uninstall = (request, options) => schemaSource.uninstall(request, controlOptions(options, admittedControls));
|
|
35
|
+
const inspect = (origin, options) => schemaSource.inspect(origin, controlOptions(options, admittedControls));
|
|
36
|
+
const bundle = (origin, options) => schemaSource.bundle(origin, controlOptions(options, admittedControls));
|
|
37
|
+
const dependencies = (origin, options) => schemaSource.dependencies(origin, controlOptions(options, admittedControls));
|
|
38
|
+
const installed = (options) => schemaSource.installed(controlOptions(options, admittedControls));
|
|
39
|
+
const schema = Object.freeze({
|
|
40
|
+
install,
|
|
41
|
+
uninstall,
|
|
42
|
+
inspect,
|
|
43
|
+
bundle,
|
|
44
|
+
dependencies,
|
|
45
|
+
installed,
|
|
46
|
+
});
|
|
23
47
|
const graph = createGraph(call);
|
|
24
|
-
const auth = createAuth((target, input, options) => call(createCall(target, input), options));
|
|
48
|
+
const auth = createAuth((target, input, options) => call(createCall(target, input), options), admit);
|
|
25
49
|
return Object.freeze({
|
|
26
50
|
...graph,
|
|
27
51
|
kernel: source.kernel,
|
|
28
52
|
auth,
|
|
53
|
+
schema,
|
|
29
54
|
dispatch,
|
|
30
55
|
call,
|
|
31
56
|
invoke,
|
|
32
57
|
stream,
|
|
33
58
|
binary,
|
|
34
|
-
|
|
59
|
+
content,
|
|
35
60
|
viewsFor,
|
|
36
61
|
});
|
|
37
62
|
}
|
|
63
|
+
const unavailableContent = Object.freeze({
|
|
64
|
+
upload: (() => {
|
|
65
|
+
throw new TypeError('Content transfer is unavailable from this bound Session source.');
|
|
66
|
+
}),
|
|
67
|
+
download: () => {
|
|
68
|
+
throw new TypeError('Content transfer is unavailable from this bound Session source.');
|
|
69
|
+
},
|
|
70
|
+
});
|
|
38
71
|
function admitControls(input) {
|
|
39
72
|
if (input === undefined)
|
|
40
73
|
return undefined;
|
|
@@ -70,7 +103,18 @@ function capture(source, key) {
|
|
|
70
103
|
invalid();
|
|
71
104
|
return value.bind(source);
|
|
72
105
|
}
|
|
106
|
+
function captureSchema(input) {
|
|
107
|
+
if (input === null || typeof input !== 'object')
|
|
108
|
+
invalid();
|
|
109
|
+
return Object.freeze({
|
|
110
|
+
install: capture(input, 'install'),
|
|
111
|
+
uninstall: capture(input, 'uninstall'),
|
|
112
|
+
inspect: capture(input, 'inspect'),
|
|
113
|
+
bundle: capture(input, 'bundle'),
|
|
114
|
+
dependencies: capture(input, 'dependencies'),
|
|
115
|
+
installed: capture(input, 'installed'),
|
|
116
|
+
});
|
|
117
|
+
}
|
|
73
118
|
function invalid() {
|
|
74
119
|
throw new TypeError('Bound ClientSession source is invalid.');
|
|
75
120
|
}
|
|
76
|
-
//# sourceMappingURL=bound.js.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Path } from '@astrale-os/kernel-core/path';
|
|
2
|
+
import type { schema } from '@astrale-os/kernel-dsl/v1';
|
|
3
|
+
import type { Ref } from '@astrale-os/kernel-protocol/artifact';
|
|
4
|
+
import type { Binary, Input, Result } from '../../client/index.js';
|
|
5
|
+
import type { SessionControlOptions, SessionOperation } from '../context/index.js';
|
|
6
|
+
export interface ContentLocation {
|
|
7
|
+
readonly node: string;
|
|
8
|
+
readonly property: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ContentUploadOptions extends SessionControlOptions {
|
|
11
|
+
readonly mediaType: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ContentUploadResult {
|
|
14
|
+
readonly receipt: schema.values.BlobReceipt;
|
|
15
|
+
readonly ref: Ref;
|
|
16
|
+
readonly expiresAt: string;
|
|
17
|
+
}
|
|
18
|
+
/** Why one location yields no content; the reason a lone download of it would be refused. */
|
|
19
|
+
export type ContentRejection = 'BLOB_NOT_FOUND' | 'BLOB_UNAVAILABLE' | 'BLOB_INTEGRITY';
|
|
20
|
+
/** The outcome of one location of a multi-location download. */
|
|
21
|
+
export type ContentDownload = {
|
|
22
|
+
readonly location: ContentLocation;
|
|
23
|
+
readonly outcome: 'content';
|
|
24
|
+
readonly content: Binary;
|
|
25
|
+
} | {
|
|
26
|
+
readonly location: ContentLocation;
|
|
27
|
+
readonly outcome: 'rejected';
|
|
28
|
+
readonly code: ContentRejection;
|
|
29
|
+
};
|
|
30
|
+
export interface ContentApi {
|
|
31
|
+
upload(source: Blob | Uint8Array, options: ContentUploadOptions): Promise<ContentUploadResult>;
|
|
32
|
+
download(location: ContentLocation, options?: SessionControlOptions): Promise<Binary>;
|
|
33
|
+
/**
|
|
34
|
+
* One outcome per location, in order, within one time budget for the whole list. Consume each
|
|
35
|
+
* content body before requesting the next outcome: an unread body is skipped.
|
|
36
|
+
*/
|
|
37
|
+
download(locations: readonly ContentLocation[], options?: SessionControlOptions): AsyncIterable<ContentDownload>;
|
|
38
|
+
}
|
|
39
|
+
/** What the Session lends the content transfer: its time budgets and its routed dispatch. */
|
|
40
|
+
export interface ContentDependencies {
|
|
41
|
+
readonly operation: (options: SessionControlOptions) => SessionOperation;
|
|
42
|
+
readonly dispatch: (target: Path, input: Input, operation: SessionOperation, body?: Blob) => Promise<Result>;
|
|
43
|
+
}
|
|
44
|
+
/** Transfer immutable content over the authenticated Session routing conversation. */
|
|
45
|
+
export declare function createContentApi(dependencies: ContentDependencies): ContentApi;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { requireResultKind } from '../routing/index.js';
|
|
2
|
+
import { downloadBatch } from './batch.js';
|
|
3
|
+
import { acceptBody, acceptControls, acceptLocation, acceptMediaType } from './input.js';
|
|
4
|
+
import { retry } from './retry.js';
|
|
5
|
+
import { DOWNLOAD, UPLOAD, decodeDownload, decodeUploadResult } from './wire.js';
|
|
6
|
+
/** Transfer immutable content over the authenticated Session routing conversation. */
|
|
7
|
+
export function createContentApi(dependencies) {
|
|
8
|
+
async function upload(source, options) {
|
|
9
|
+
const body = acceptBody(source);
|
|
10
|
+
const mediaType = acceptMediaType(options?.mediaType);
|
|
11
|
+
const operation = dependencies.operation(acceptControls(options));
|
|
12
|
+
const result = await retry(operation, () => dependencies.dispatch(UPLOAD, { mediaType }, operation, body));
|
|
13
|
+
return decodeUploadResult(requireResultKind('value', result).value);
|
|
14
|
+
}
|
|
15
|
+
function download(input, options) {
|
|
16
|
+
if (Array.isArray(input)) {
|
|
17
|
+
const locations = input;
|
|
18
|
+
return downloadBatch(dependencies, locations, locations.map(acceptLocation), acceptControls(options));
|
|
19
|
+
}
|
|
20
|
+
return downloadOne(input, options);
|
|
21
|
+
}
|
|
22
|
+
async function downloadOne(location, options) {
|
|
23
|
+
const operation = dependencies.operation(acceptControls(options));
|
|
24
|
+
const result = await dependencies.dispatch(DOWNLOAD, acceptLocation(location), operation);
|
|
25
|
+
return decodeDownload(requireResultKind('binary', result).value);
|
|
26
|
+
}
|
|
27
|
+
return Object.freeze({ upload, download });
|
|
28
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SessionControlOptions } from '../context/index.js';
|
|
2
|
+
import type { ContentDependencies, ContentDownload, ContentLocation } from './api.js';
|
|
3
|
+
import type { Slot } from './input.js';
|
|
4
|
+
/** Download many locations, sharing bodies of parts when the Kernel can, in one time budget. */
|
|
5
|
+
export declare function downloadBatch(dependencies: ContentDependencies, locations: readonly ContentLocation[], slots: readonly Slot[], controls: SessionControlOptions): AsyncGenerator<ContentDownload, void, undefined>;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { MAXIMUM_DOWNLOAD_SLOTS } from '@astrale-os/kernel-core/schema/kernel/syscalls/contracts';
|
|
2
|
+
import { CODES } from '@astrale-os/kernel-protocol/errors';
|
|
3
|
+
import { ProtocolError, ResponseError } from '../../errors/index.js';
|
|
4
|
+
import { requireResultKind } from '../routing/index.js';
|
|
5
|
+
import { PartReader } from './parts.js';
|
|
6
|
+
import { retry } from './retry.js';
|
|
7
|
+
import { DOWNLOAD, cancelBinary, decodeDownload, decodeRejection } from './wire.js';
|
|
8
|
+
/** Download many locations, sharing bodies of parts when the Kernel can, in one time budget. */
|
|
9
|
+
export async function* downloadBatch(dependencies, locations, slots, controls) {
|
|
10
|
+
// One budget for the whole list, however many requests it takes.
|
|
11
|
+
const operation = dependencies.operation(controls);
|
|
12
|
+
// A Kernel that predates slot lists rejects their input: it is then asked slot by slot.
|
|
13
|
+
let lists = true;
|
|
14
|
+
// A body that deferred its end is followed by a narrower request, so that contents too large
|
|
15
|
+
// to share a body do not have the rest of their list resolved again for each of them.
|
|
16
|
+
let width = MAXIMUM_DOWNLOAD_SLOTS;
|
|
17
|
+
for (let offset = 0; offset < slots.length;) {
|
|
18
|
+
if (!lists) {
|
|
19
|
+
yield* lone(dependencies, locations[offset], slots[offset], operation);
|
|
20
|
+
offset += 1;
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
const requested = slots.slice(offset, offset + width);
|
|
24
|
+
let binary;
|
|
25
|
+
try {
|
|
26
|
+
const result = await retry(operation, () => dependencies.dispatch(DOWNLOAD, { slots: requested }, operation));
|
|
27
|
+
binary = await decodeDownload(requireResultKind('binary', result).value);
|
|
28
|
+
}
|
|
29
|
+
catch (cause) {
|
|
30
|
+
if (!(cause instanceof ResponseError) || cause.code !== CODES.VALIDATION_ERROR)
|
|
31
|
+
throw cause;
|
|
32
|
+
lists = false;
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
let answered = 0;
|
|
36
|
+
let parts;
|
|
37
|
+
try {
|
|
38
|
+
parts = new PartReader(binary);
|
|
39
|
+
let deferred = false;
|
|
40
|
+
for (let index = 0; index < requested.length; index++) {
|
|
41
|
+
const part = await parts.next();
|
|
42
|
+
if (part.outcome === 'deferred') {
|
|
43
|
+
deferred = true;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
// A deferral closes the body: every slot after it is deferred as well.
|
|
47
|
+
if (deferred) {
|
|
48
|
+
throw new ProtocolError('Content download answered a slot after deferring one.');
|
|
49
|
+
}
|
|
50
|
+
const location = locations[offset + index];
|
|
51
|
+
answered += 1;
|
|
52
|
+
yield part.outcome === 'content'
|
|
53
|
+
? { location, outcome: 'content', content: part.content }
|
|
54
|
+
: { location, outcome: 'rejected', code: part.code };
|
|
55
|
+
}
|
|
56
|
+
await parts.end();
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
await (parts === undefined ? cancelBinary(binary) : parts.cancel());
|
|
60
|
+
}
|
|
61
|
+
if (answered === 0) {
|
|
62
|
+
// This content is not read in a shared body: it is transferred by its own download.
|
|
63
|
+
yield* lone(dependencies, locations[offset], slots[offset], operation);
|
|
64
|
+
answered = 1;
|
|
65
|
+
}
|
|
66
|
+
offset += answered;
|
|
67
|
+
width = answered < requested.length ? Math.max(2, answered * 2) : MAXIMUM_DOWNLOAD_SLOTS;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/** One location by its own download; a body left unread is closed once the next is asked. */
|
|
71
|
+
async function* lone(dependencies, location, slot, operation) {
|
|
72
|
+
const outcome = await alone(dependencies, location, slot, operation);
|
|
73
|
+
try {
|
|
74
|
+
yield outcome;
|
|
75
|
+
}
|
|
76
|
+
finally {
|
|
77
|
+
if (outcome.outcome === 'content')
|
|
78
|
+
await cancelBinary(outcome.content);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async function alone(dependencies, location, slot, operation) {
|
|
82
|
+
try {
|
|
83
|
+
const result = await retry(operation, () => dependencies.dispatch(DOWNLOAD, slot, operation));
|
|
84
|
+
const content = await decodeDownload(requireResultKind('binary', result).value);
|
|
85
|
+
return { location, outcome: 'content', content };
|
|
86
|
+
}
|
|
87
|
+
catch (cause) {
|
|
88
|
+
const code = cause instanceof ResponseError ? decodeRejection(cause.reason?.code) : undefined;
|
|
89
|
+
if (code === undefined)
|
|
90
|
+
throw cause;
|
|
91
|
+
return { location, outcome: 'rejected', code };
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createContentApi, type ContentApi, type ContentDownload, type ContentLocation, type ContentRejection, type ContentUploadOptions, type ContentUploadResult, } from './api.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createContentApi, } from './api.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SessionControlOptions } from '../context/index.js';
|
|
2
|
+
import type { ContentLocation } from './api.js';
|
|
3
|
+
/** One canonical content location, as a download request carries it. */
|
|
4
|
+
export type Slot = Readonly<Record<'node' | 'property', string>>;
|
|
5
|
+
export declare function acceptLocation(input: ContentLocation): Slot;
|
|
6
|
+
export declare function acceptBody(input: unknown): Blob;
|
|
7
|
+
export declare function acceptMediaType(input: unknown): string;
|
|
8
|
+
/** The caller's controls, with the content transfer's own default time budget. */
|
|
9
|
+
export declare function acceptControls(input: SessionControlOptions | undefined): SessionControlOptions;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { NodeId } from '@astrale-os/kernel-core/graph/node';
|
|
2
|
+
import { PropertyKey } from '@astrale-os/kernel-dsl/v1/addressing';
|
|
3
|
+
import * as artifact from '@astrale-os/kernel-protocol/artifact';
|
|
4
|
+
import { admitControlOptions } from '../context/index.js';
|
|
5
|
+
const CONTENT_TIMEOUT_MS = 30 * 60 * 1_000;
|
|
6
|
+
export function acceptLocation(input) {
|
|
7
|
+
if (input === null || typeof input !== 'object' || Array.isArray(input)) {
|
|
8
|
+
throw new TypeError('Content location is invalid.');
|
|
9
|
+
}
|
|
10
|
+
return Object.freeze({ node: NodeId(input.node), property: PropertyKey(input.property) });
|
|
11
|
+
}
|
|
12
|
+
export function acceptBody(input) {
|
|
13
|
+
if (typeof Blob !== 'undefined' && input instanceof Blob)
|
|
14
|
+
return input;
|
|
15
|
+
if (input instanceof Uint8Array) {
|
|
16
|
+
// Blob snapshots an ArrayBuffer view; a SharedArrayBuffer view needs an owned copy.
|
|
17
|
+
const bytes = input.buffer instanceof ArrayBuffer
|
|
18
|
+
? input
|
|
19
|
+
: new Uint8Array(input);
|
|
20
|
+
return new Blob([bytes]);
|
|
21
|
+
}
|
|
22
|
+
throw new TypeError('Content upload source must be a Blob, File, or Uint8Array.');
|
|
23
|
+
}
|
|
24
|
+
export function acceptMediaType(input) {
|
|
25
|
+
if (typeof input !== 'string')
|
|
26
|
+
throw new TypeError('Content upload mediaType is required.');
|
|
27
|
+
return artifact.identify(new Uint8Array(), input).mediaType;
|
|
28
|
+
}
|
|
29
|
+
/** The caller's controls, with the content transfer's own default time budget. */
|
|
30
|
+
export function acceptControls(input) {
|
|
31
|
+
const controls = admitControlOptions(input);
|
|
32
|
+
return Object.freeze({ ...controls, timeoutMs: controls.timeoutMs ?? CONTENT_TIMEOUT_MS });
|
|
33
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Binary } from '../../client/index.js';
|
|
2
|
+
import type { ContentRejection } from './api.js';
|
|
3
|
+
/** One slot of a multi-slot download body. */
|
|
4
|
+
export type Part = {
|
|
5
|
+
readonly outcome: 'content';
|
|
6
|
+
readonly content: Binary;
|
|
7
|
+
} | {
|
|
8
|
+
readonly outcome: 'rejected';
|
|
9
|
+
readonly code: ContentRejection;
|
|
10
|
+
} | {
|
|
11
|
+
readonly outcome: 'deferred';
|
|
12
|
+
};
|
|
13
|
+
/** Decode the parts of one multi-slot download body, in order, without buffering content. */
|
|
14
|
+
export declare class PartReader {
|
|
15
|
+
private readonly source;
|
|
16
|
+
/** Response fields of the transfer, which every content of it carries. */
|
|
17
|
+
private readonly fields;
|
|
18
|
+
private buffered;
|
|
19
|
+
/** Bytes of the declared body that have not been decoded yet. */
|
|
20
|
+
private undecoded;
|
|
21
|
+
/** Content bytes of the current part that its consumer has not read yet. */
|
|
22
|
+
private unread;
|
|
23
|
+
private current;
|
|
24
|
+
constructor(binary: Binary);
|
|
25
|
+
next(): Promise<Part>;
|
|
26
|
+
private body;
|
|
27
|
+
/** The body ends exactly after its last part. */
|
|
28
|
+
end(): Promise<void>;
|
|
29
|
+
cancel(): Promise<void>;
|
|
30
|
+
/** Pass an unread body; its consumer then learns that it was skipped. */
|
|
31
|
+
private skip;
|
|
32
|
+
/** The next unread bytes of the current content, as the transport delivered them. */
|
|
33
|
+
private content;
|
|
34
|
+
private exactly;
|
|
35
|
+
private read;
|
|
36
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { DOWNLOAD_PARTS_MEDIA_TYPE } from '@astrale-os/kernel-core/schema/kernel/syscalls/contracts';
|
|
2
|
+
import * as artifact from '@astrale-os/kernel-protocol/artifact';
|
|
3
|
+
import { ClientError, ProtocolError } from '../../errors/index.js';
|
|
4
|
+
import { decodeRejection } from './wire.js';
|
|
5
|
+
// A media type fits one request envelope (8 KiB); a part header adds a few fixed fields to it.
|
|
6
|
+
const MAXIMUM_PART_HEADER_BYTES = 16 * 1_024;
|
|
7
|
+
/** Decode the parts of one multi-slot download body, in order, without buffering content. */
|
|
8
|
+
export class PartReader {
|
|
9
|
+
source;
|
|
10
|
+
/** Response fields of the transfer, which every content of it carries. */
|
|
11
|
+
fields;
|
|
12
|
+
buffered = new Uint8Array();
|
|
13
|
+
/** Bytes of the declared body that have not been decoded yet. */
|
|
14
|
+
undecoded;
|
|
15
|
+
/** Content bytes of the current part that its consumer has not read yet. */
|
|
16
|
+
unread = 0;
|
|
17
|
+
current;
|
|
18
|
+
constructor(binary) {
|
|
19
|
+
if (binary.body instanceof Uint8Array ||
|
|
20
|
+
binary.mediaType !== DOWNLOAD_PARTS_MEDIA_TYPE ||
|
|
21
|
+
!('length' in binary) ||
|
|
22
|
+
binary.length === undefined) {
|
|
23
|
+
throw new ProtocolError('Content download returned no part body for its slot list.');
|
|
24
|
+
}
|
|
25
|
+
this.source = binary.body[Symbol.asyncIterator]();
|
|
26
|
+
this.undecoded = binary.length;
|
|
27
|
+
this.fields = binary.headers ?? {};
|
|
28
|
+
}
|
|
29
|
+
async next() {
|
|
30
|
+
await this.skip();
|
|
31
|
+
const length = new DataView((await this.exactly(4)).buffer).getUint32(0);
|
|
32
|
+
if (length === 0 || length > MAXIMUM_PART_HEADER_BYTES) {
|
|
33
|
+
throw new ProtocolError('Content download part header length is invalid.');
|
|
34
|
+
}
|
|
35
|
+
let header;
|
|
36
|
+
try {
|
|
37
|
+
header = JSON.parse(new TextDecoder().decode(await this.exactly(length)));
|
|
38
|
+
}
|
|
39
|
+
catch (cause) {
|
|
40
|
+
throw new ProtocolError('Content download part header is not JSON.', { cause });
|
|
41
|
+
}
|
|
42
|
+
if (header === null || typeof header !== 'object' || Array.isArray(header)) {
|
|
43
|
+
throw new ProtocolError('Content download part header is invalid.');
|
|
44
|
+
}
|
|
45
|
+
const { outcome, mediaType, size, code, headers } = header;
|
|
46
|
+
if (outcome === 'deferred')
|
|
47
|
+
return { outcome };
|
|
48
|
+
if (outcome === 'rejected') {
|
|
49
|
+
const rejection = decodeRejection(code);
|
|
50
|
+
if (rejection === undefined) {
|
|
51
|
+
throw new ProtocolError('Content download part rejection is invalid.');
|
|
52
|
+
}
|
|
53
|
+
return { outcome, code: rejection };
|
|
54
|
+
}
|
|
55
|
+
if (outcome !== 'content' ||
|
|
56
|
+
typeof mediaType !== 'string' ||
|
|
57
|
+
!Number.isSafeInteger(size) ||
|
|
58
|
+
size < 0 ||
|
|
59
|
+
size > this.undecoded) {
|
|
60
|
+
throw new ProtocolError('Content download part header is invalid.');
|
|
61
|
+
}
|
|
62
|
+
let canonical;
|
|
63
|
+
try {
|
|
64
|
+
canonical = artifact.canonicalMediaType(mediaType);
|
|
65
|
+
}
|
|
66
|
+
catch (cause) {
|
|
67
|
+
throw new ProtocolError('Content download part media type is invalid.', { cause });
|
|
68
|
+
}
|
|
69
|
+
// A content carries what its own download would: the transfer's fields, then its own.
|
|
70
|
+
const fields = { ...this.fields, ...decodeFields(headers) };
|
|
71
|
+
this.unread = size;
|
|
72
|
+
this.current = {};
|
|
73
|
+
return {
|
|
74
|
+
outcome,
|
|
75
|
+
content: {
|
|
76
|
+
mediaType: canonical,
|
|
77
|
+
length: size,
|
|
78
|
+
body: this.body(this.current),
|
|
79
|
+
...(Object.keys(fields).length === 0 ? {} : { headers: Object.freeze(fields) }),
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
async *body(part) {
|
|
84
|
+
while (this.current === part && this.unread > 0) {
|
|
85
|
+
const bytes = await this.content();
|
|
86
|
+
// The caller owns its chunks: one that shares its buffer with later parts is copied.
|
|
87
|
+
yield bytes.byteLength === bytes.buffer.byteLength ? bytes : bytes.slice();
|
|
88
|
+
}
|
|
89
|
+
if (this.current !== part) {
|
|
90
|
+
throw new ClientError('Content was skipped: its body was not read before the next one.');
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/** The body ends exactly after its last part. */
|
|
94
|
+
async end() {
|
|
95
|
+
await this.skip();
|
|
96
|
+
if (this.buffered.byteLength > 0 || !(await this.source.next()).done) {
|
|
97
|
+
throw new ProtocolError('Content download continued after its last part.');
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
async cancel() {
|
|
101
|
+
this.current = undefined;
|
|
102
|
+
try {
|
|
103
|
+
await this.source.return?.();
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
// The transfer already ended with its own outcome.
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/** Pass an unread body; its consumer then learns that it was skipped. */
|
|
110
|
+
async skip() {
|
|
111
|
+
this.current = undefined;
|
|
112
|
+
while (this.unread > 0)
|
|
113
|
+
await this.content();
|
|
114
|
+
}
|
|
115
|
+
/** The next unread bytes of the current content, as the transport delivered them. */
|
|
116
|
+
async content() {
|
|
117
|
+
const bytes = await this.read(this.unread);
|
|
118
|
+
this.unread -= bytes.byteLength;
|
|
119
|
+
return bytes;
|
|
120
|
+
}
|
|
121
|
+
async exactly(count) {
|
|
122
|
+
const bytes = new Uint8Array(count);
|
|
123
|
+
for (let filled = 0; filled < count;) {
|
|
124
|
+
const part = await this.read(count - filled);
|
|
125
|
+
bytes.set(part, filled);
|
|
126
|
+
filled += part.byteLength;
|
|
127
|
+
}
|
|
128
|
+
return bytes;
|
|
129
|
+
}
|
|
130
|
+
async read(maximum) {
|
|
131
|
+
if (this.buffered.byteLength === 0) {
|
|
132
|
+
const next = await this.source.next();
|
|
133
|
+
if (next.done)
|
|
134
|
+
throw new ProtocolError('Content download ended inside a part.');
|
|
135
|
+
this.buffered = next.value;
|
|
136
|
+
}
|
|
137
|
+
const bytes = this.buffered.subarray(0, maximum);
|
|
138
|
+
this.buffered = this.buffered.subarray(bytes.byteLength);
|
|
139
|
+
this.undecoded -= bytes.byteLength;
|
|
140
|
+
return bytes;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/** The response fields a part header adds to those of its transfer. */
|
|
144
|
+
function decodeFields(input) {
|
|
145
|
+
if (input === undefined)
|
|
146
|
+
return {};
|
|
147
|
+
if (input === null ||
|
|
148
|
+
typeof input !== 'object' ||
|
|
149
|
+
Array.isArray(input) ||
|
|
150
|
+
!Object.values(input).every((value) => typeof value === 'string')) {
|
|
151
|
+
throw new ProtocolError('Content download part fields are invalid.');
|
|
152
|
+
}
|
|
153
|
+
return input;
|
|
154
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { CODES } from '@astrale-os/kernel-protocol/errors';
|
|
2
|
+
import { ResponseError, TransportError } from '../../errors/index.js';
|
|
3
|
+
import { runSessionOperation } from '../context/index.js';
|
|
4
|
+
const MAXIMUM_ATTEMPTS = 3;
|
|
5
|
+
/** Repeat one content request that failed before any of its result was delivered. */
|
|
6
|
+
export async function retry(operation, request) {
|
|
7
|
+
for (let attempt = 0;; attempt++) {
|
|
8
|
+
try {
|
|
9
|
+
return await request();
|
|
10
|
+
}
|
|
11
|
+
catch (cause) {
|
|
12
|
+
if (!retryable(cause) || attempt + 1 === MAXIMUM_ATTEMPTS || operation.signal.aborted) {
|
|
13
|
+
throw cause;
|
|
14
|
+
}
|
|
15
|
+
await runSessionOperation(operation, (signal) => delay(200 * 2 ** attempt, signal));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function retryable(cause) {
|
|
20
|
+
return ((cause instanceof TransportError && cause.context.kind === 'invocation') ||
|
|
21
|
+
(cause instanceof ResponseError &&
|
|
22
|
+
(cause.reason?.code === 'BLOB_UNAVAILABLE' ||
|
|
23
|
+
cause.code === CODES.CANCELLED ||
|
|
24
|
+
cause.code === CODES.DEADLINE_EXCEEDED ||
|
|
25
|
+
cause.code === CODES.OUTCOME_UNKNOWN)));
|
|
26
|
+
}
|
|
27
|
+
function delay(ms, signal) {
|
|
28
|
+
return new Promise((resolve, reject) => {
|
|
29
|
+
if (signal.aborted)
|
|
30
|
+
return reject(signal.reason);
|
|
31
|
+
const timer = setTimeout(() => {
|
|
32
|
+
signal.removeEventListener('abort', abort);
|
|
33
|
+
resolve();
|
|
34
|
+
}, ms);
|
|
35
|
+
const abort = () => {
|
|
36
|
+
clearTimeout(timer);
|
|
37
|
+
reject(signal.reason);
|
|
38
|
+
};
|
|
39
|
+
signal.addEventListener('abort', abort, { once: true });
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Path } from '@astrale-os/kernel-core/path';
|
|
2
|
+
import type { Binary } from '../../client/index.js';
|
|
3
|
+
import type { ContentRejection, ContentUploadResult } from './api.js';
|
|
4
|
+
export declare const UPLOAD: Path.Projection;
|
|
5
|
+
export declare const DOWNLOAD: Path.Projection;
|
|
6
|
+
export declare function decodeUploadResult(input: unknown): ContentUploadResult;
|
|
7
|
+
/** The rejection a code names, or `undefined` when it names none. */
|
|
8
|
+
export declare function decodeRejection(code: unknown): ContentRejection | undefined;
|
|
9
|
+
/** A download whose exact size is declared; anything else is closed and refused. */
|
|
10
|
+
export declare function decodeDownload(input: Binary): Promise<Binary>;
|
|
11
|
+
/** Close a streamed body nobody will read. */
|
|
12
|
+
export declare function cancelBinary(input: Binary): Promise<void>;
|