@astrale-os/kernel-client 0.5.1 → 0.6.0-beta.10
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 +18 -0
- package/dist/auth/auth.js +15 -0
- package/dist/auth/authorization.d.ts +13 -0
- package/dist/auth/authorization.js +17 -0
- package/dist/auth/credential.d.ts +19 -0
- package/dist/auth/credential.js +21 -0
- package/dist/auth/identity.d.ts +14 -0
- package/dist/auth/identity.js +15 -0
- package/dist/auth/index.d.ts +6 -16
- package/dist/auth/index.js +5 -10
- package/dist/auth/provision.d.ts +8 -0
- package/dist/auth/provision.js +10 -0
- package/dist/client/admission.d.ts +4 -0
- package/dist/client/admission.js +34 -0
- package/dist/client/client.d.ts +24 -109
- package/dist/client/client.js +80 -381
- package/dist/client/credential.d.ts +12 -0
- package/dist/client/credential.js +51 -0
- package/dist/client/index.d.ts +6 -0
- package/dist/client/index.js +4 -0
- package/dist/client/request.d.ts +26 -0
- package/dist/client/request.js +100 -0
- package/dist/client/result.d.ts +35 -0
- package/dist/client/result.js +28 -0
- package/dist/client/routing-control.d.ts +10 -0
- package/dist/client/routing-control.js +23 -0
- package/dist/errors/client-error.d.ts +3 -0
- package/dist/errors/client-error.js +8 -0
- package/dist/errors/index.d.ts +7 -6
- package/dist/errors/index.js +7 -4
- package/dist/errors/miss-error.d.ts +8 -0
- package/dist/errors/miss-error.js +10 -0
- package/dist/errors/protocol-error.d.ts +9 -0
- package/dist/errors/protocol-error.js +9 -0
- package/dist/errors/response-error.d.ts +11 -0
- package/dist/errors/response-error.js +16 -0
- package/dist/errors/session-error.d.ts +8 -20
- package/dist/errors/session-error.js +6 -22
- package/dist/errors/stale-route-error.d.ts +9 -0
- package/dist/errors/stale-route-error.js +12 -0
- package/dist/errors/transport-error.d.ts +30 -0
- package/dist/errors/transport-error.js +18 -0
- package/dist/graph/domain/binding.d.ts +22 -0
- package/dist/graph/domain/binding.js +123 -0
- package/dist/graph/domain/domain.typecheck.d.ts +1 -0
- package/dist/graph/domain/domain.typecheck.js +139 -0
- package/dist/graph/domain/index.d.ts +3 -0
- package/dist/graph/domain/index.js +1 -0
- package/dist/graph/domain/model.d.ts +18 -0
- package/dist/graph/domain/model.js +1 -0
- package/dist/graph/domain/page.d.ts +23 -0
- package/dist/graph/domain/page.js +42 -0
- package/dist/graph/domain/project.d.ts +8 -0
- package/dist/graph/domain/project.js +120 -0
- package/dist/graph/domain/provenance.d.ts +6 -0
- package/dist/graph/domain/provenance.js +11 -0
- package/dist/graph/errors.d.ts +8 -0
- package/dist/graph/errors.js +14 -0
- package/dist/graph/graph.d.ts +26 -0
- package/dist/graph/graph.js +18 -0
- package/dist/graph/index.d.ts +8 -26
- package/dist/graph/index.js +6 -21
- package/dist/graph/mutation.d.ts +5 -0
- package/dist/graph/mutation.js +17 -0
- package/dist/graph/page/index.d.ts +2 -0
- package/dist/graph/page/index.js +1 -0
- package/dist/graph/page/neighbors.d.ts +9 -0
- package/dist/graph/page/neighbors.js +34 -0
- package/dist/graph/page/page.d.ts +37 -0
- package/dist/graph/page/page.js +55 -0
- package/dist/graph/page-contract.d.ts +13 -0
- package/dist/graph/page-contract.js +1 -0
- package/dist/graph/provenance.d.ts +12 -0
- package/dist/graph/provenance.js +37 -0
- package/dist/graph/query.d.ts +4 -0
- package/dist/graph/query.js +69 -0
- package/dist/graph/read.d.ts +6 -0
- package/dist/graph/read.js +17 -0
- package/dist/index.d.ts +6 -25
- package/dist/index.js +6 -21
- package/dist/pacer/batcher/batcher.d.ts +7 -0
- package/dist/pacer/batcher/batcher.js +13 -0
- package/dist/pacer/batcher/defaults.d.ts +2 -0
- package/dist/pacer/batcher/defaults.js +2 -0
- package/dist/pacer/batcher/index.d.ts +1 -0
- package/dist/pacer/batcher/index.js +1 -0
- package/dist/pacer/index.d.ts +4 -10
- package/dist/pacer/index.js +4 -11
- package/dist/pacer/limiter/defaults.d.ts +2 -0
- package/dist/pacer/limiter/defaults.js +2 -0
- package/dist/pacer/limiter/index.d.ts +1 -0
- package/dist/pacer/limiter/index.js +1 -0
- package/dist/pacer/limiter/limiter.d.ts +7 -0
- package/dist/pacer/limiter/limiter.js +14 -0
- package/dist/pacer/queue/defaults.d.ts +1 -0
- package/dist/pacer/queue/defaults.js +1 -0
- package/dist/pacer/queue/index.d.ts +1 -0
- package/dist/pacer/queue/index.js +1 -0
- package/dist/pacer/queue/queue.d.ts +6 -0
- package/dist/pacer/queue/queue.js +12 -0
- package/dist/pacer/retry/defaults.d.ts +6 -0
- package/dist/pacer/retry/defaults.js +16 -0
- package/dist/pacer/retry/index.d.ts +1 -0
- package/dist/pacer/retry/index.js +1 -0
- package/dist/pacer/retry/retry.d.ts +9 -0
- package/dist/pacer/retry/retry.js +55 -0
- package/dist/pool/index.d.ts +2 -4
- package/dist/pool/index.js +0 -2
- package/dist/pool/pool.d.ts +19 -59
- package/dist/pool/pool.js +46 -64
- package/dist/pool/target.d.ts +15 -0
- package/dist/pool/target.js +49 -0
- package/dist/schema/admission.d.ts +12 -0
- package/dist/schema/admission.js +17 -0
- package/dist/schema/contracts.d.ts +12 -0
- package/dist/schema/contracts.js +1 -0
- package/dist/schema/index.d.ts +3 -16
- package/dist/schema/index.js +2 -12
- package/dist/schema/introspection.d.ts +5 -0
- package/dist/schema/introspection.js +15 -0
- package/dist/schema/operation.d.ts +5 -0
- package/dist/schema/operation.js +9 -0
- package/dist/schema/schema.d.ts +19 -0
- package/dist/schema/schema.js +43 -0
- package/dist/session/bound.d.ts +42 -9
- package/dist/session/bound.js +70 -37
- package/dist/session/context/control.d.ts +5 -0
- package/dist/session/context/control.js +17 -0
- package/dist/session/context/index.d.ts +4 -0
- package/dist/session/context/index.js +4 -0
- package/dist/session/context/limits.d.ts +7 -0
- package/dist/session/context/limits.js +18 -0
- package/dist/session/context/operation.d.ts +19 -0
- package/dist/session/context/operation.js +72 -0
- package/dist/session/context/policy.d.ts +11 -0
- package/dist/session/context/policy.js +69 -0
- package/dist/session/discovery/bundle.d.ts +17 -0
- package/dist/session/discovery/bundle.js +55 -0
- package/dist/session/discovery/discovery.d.ts +19 -0
- package/dist/session/discovery/discovery.js +55 -0
- package/dist/session/discovery/index.d.ts +20 -0
- package/dist/session/discovery/index.js +15 -0
- package/dist/session/discovery/publication.d.ts +23 -0
- package/dist/session/discovery/publication.js +123 -0
- package/dist/session/discovery/snapshot.d.ts +12 -0
- package/dist/session/discovery/snapshot.js +3 -0
- package/dist/session/discovery/transport.d.ts +6 -0
- package/dist/session/discovery/transport.js +13 -0
- package/dist/session/index.d.ts +10 -16
- package/dist/session/index.js +3 -9
- package/dist/session/reference.d.ts +36 -0
- package/dist/session/reference.js +74 -0
- package/dist/session/routing/auth.d.ts +18 -0
- package/dist/session/routing/auth.js +39 -0
- package/dist/session/routing/cache.d.ts +20 -0
- package/dist/session/routing/cache.js +115 -0
- package/dist/session/routing/dispatch.d.ts +34 -0
- package/dist/session/routing/dispatch.js +137 -0
- package/dist/session/routing/envelope.d.ts +13 -0
- package/dist/session/routing/envelope.js +35 -0
- package/dist/session/routing/expectation.d.ts +6 -0
- package/dist/session/routing/expectation.js +1 -0
- package/dist/session/routing/index.d.ts +6 -0
- package/dist/session/routing/index.js +5 -0
- package/dist/session/routing/request.d.ts +8 -0
- package/dist/session/routing/request.js +25 -0
- package/dist/session/session.d.ts +67 -0
- package/dist/session/session.js +257 -0
- package/dist/session/session.typecheck.d.ts +1 -0
- package/dist/session/session.typecheck.js +31 -0
- package/dist/session/views/catalog.d.ts +15 -0
- package/dist/session/views/catalog.js +70 -0
- package/dist/session/views/index.d.ts +2 -0
- package/dist/session/views/index.js +2 -0
- package/dist/session/views/resolve.d.ts +11 -0
- package/dist/session/views/resolve.js +13 -0
- package/dist/store/entity-index.d.ts +22 -0
- package/dist/store/entity-index.js +94 -0
- package/dist/store/index.d.ts +1 -26
- package/dist/store/index.js +1 -19
- package/dist/store/memory.d.ts +46 -97
- package/dist/store/memory.js +346 -763
- package/dist/store/mutation.d.ts +5 -0
- package/dist/store/mutation.js +34 -0
- package/dist/store/observe.d.ts +3 -0
- package/dist/store/observe.js +17 -0
- package/dist/store/optimistic.d.ts +12 -0
- package/dist/store/optimistic.js +43 -0
- package/dist/store/query-key.d.ts +5 -0
- package/dist/store/query-key.js +22 -0
- package/dist/store/shape.d.ts +25 -0
- package/dist/store/shape.js +29 -0
- package/dist/store/store.d.ts +68 -0
- package/dist/store/store.js +144 -0
- package/dist/store/store.typecheck.d.ts +1 -0
- package/dist/store/store.typecheck.js +40 -0
- package/dist/transport/auto/decision.d.ts +22 -0
- package/dist/transport/auto/decision.js +48 -0
- package/dist/transport/auto/fallback.d.ts +16 -0
- package/dist/transport/auto/fallback.js +75 -0
- package/dist/transport/auto/index.d.ts +2 -0
- package/dist/transport/auto/index.js +2 -0
- package/dist/transport/auto/transport.d.ts +37 -0
- package/dist/transport/auto/transport.js +140 -0
- package/dist/transport/auto/warning.d.ts +13 -0
- package/dist/transport/auto/warning.js +18 -0
- package/dist/transport/deadline.d.ts +11 -0
- package/dist/transport/deadline.js +39 -0
- package/dist/transport/failure.d.ts +7 -0
- package/dist/transport/failure.js +9 -0
- package/dist/transport/http/index.d.ts +1 -0
- package/dist/transport/http/index.js +1 -0
- package/dist/transport/http/response.d.ts +8 -0
- package/dist/transport/http/response.js +79 -0
- package/dist/transport/http/stream.d.ts +26 -0
- package/dist/transport/http/stream.js +214 -0
- package/dist/transport/http/transport.d.ts +32 -0
- package/dist/transport/http/transport.js +343 -0
- package/dist/transport/index.d.ts +2 -8
- package/dist/transport/index.js +1 -6
- package/dist/transport/transport.d.ts +34 -0
- package/dist/transport/transport.js +1 -0
- package/dist/transport/websocket/connection.d.ts +38 -0
- package/dist/transport/websocket/connection.js +284 -0
- package/dist/transport/websocket/exchange.d.ts +46 -0
- package/dist/transport/websocket/exchange.js +300 -0
- package/dist/transport/websocket/index.d.ts +1 -0
- package/dist/transport/websocket/index.js +1 -0
- package/dist/transport/websocket/transport.d.ts +46 -0
- package/dist/transport/websocket/transport.js +164 -0
- package/package.json +41 -35
- package/dist/auth/addressing.d.ts +0 -32
- package/dist/auth/addressing.d.ts.map +0 -1
- package/dist/auth/addressing.js +0 -36
- package/dist/auth/addressing.js.map +0 -1
- package/dist/auth/api.d.ts +0 -70
- package/dist/auth/api.d.ts.map +0 -1
- package/dist/auth/api.js +0 -36
- package/dist/auth/api.js.map +0 -1
- package/dist/auth/batch.d.ts +0 -18
- package/dist/auth/batch.d.ts.map +0 -1
- package/dist/auth/batch.js +0 -25
- package/dist/auth/batch.js.map +0 -1
- package/dist/auth/composition.d.ts +0 -27
- package/dist/auth/composition.d.ts.map +0 -1
- package/dist/auth/composition.js +0 -83
- package/dist/auth/composition.js.map +0 -1
- package/dist/auth/defaults.d.ts +0 -3
- package/dist/auth/defaults.d.ts.map +0 -1
- package/dist/auth/defaults.js +0 -3
- package/dist/auth/defaults.js.map +0 -1
- package/dist/auth/index.d.ts.map +0 -1
- package/dist/auth/index.js.map +0 -1
- package/dist/auth/minting.d.ts +0 -35
- package/dist/auth/minting.d.ts.map +0 -1
- package/dist/auth/minting.js +0 -31
- package/dist/auth/minting.js.map +0 -1
- package/dist/auth/permissions.d.ts +0 -55
- package/dist/auth/permissions.d.ts.map +0 -1
- package/dist/auth/permissions.js +0 -47
- package/dist/auth/permissions.js.map +0 -1
- package/dist/auth/principal.d.ts +0 -19
- package/dist/auth/principal.d.ts.map +0 -1
- package/dist/auth/principal.js +0 -46
- package/dist/auth/principal.js.map +0 -1
- package/dist/auth/shorthands.d.ts +0 -19
- package/dist/auth/shorthands.d.ts.map +0 -1
- package/dist/auth/shorthands.js +0 -27
- package/dist/auth/shorthands.js.map +0 -1
- package/dist/client/batch.d.ts +0 -26
- package/dist/client/batch.d.ts.map +0 -1
- package/dist/client/batch.js +0 -8
- package/dist/client/batch.js.map +0 -1
- package/dist/client/bound.d.ts +0 -27
- package/dist/client/bound.d.ts.map +0 -1
- package/dist/client/bound.js +0 -14
- package/dist/client/bound.js.map +0 -1
- package/dist/client/client.d.ts.map +0 -1
- package/dist/client/client.js.map +0 -1
- package/dist/client/config.d.ts +0 -112
- package/dist/client/config.d.ts.map +0 -1
- package/dist/client/config.js +0 -10
- package/dist/client/config.js.map +0 -1
- package/dist/client/fn-map.d.ts +0 -61
- package/dist/client/fn-map.d.ts.map +0 -1
- package/dist/client/fn-map.js +0 -2
- package/dist/client/fn-map.js.map +0 -1
- package/dist/client/freeze.d.ts +0 -32
- package/dist/client/freeze.d.ts.map +0 -1
- package/dist/client/freeze.js +0 -42
- package/dist/client/freeze.js.map +0 -1
- package/dist/client/hooks.d.ts +0 -49
- package/dist/client/hooks.d.ts.map +0 -1
- package/dist/client/hooks.js +0 -2
- package/dist/client/hooks.js.map +0 -1
- package/dist/errors/errors.d.ts +0 -156
- package/dist/errors/errors.d.ts.map +0 -1
- package/dist/errors/errors.js +0 -238
- package/dist/errors/errors.js.map +0 -1
- package/dist/errors/guards.d.ts +0 -39
- package/dist/errors/guards.d.ts.map +0 -1
- package/dist/errors/guards.js +0 -127
- package/dist/errors/guards.js.map +0 -1
- package/dist/errors/index.d.ts.map +0 -1
- package/dist/errors/index.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/graph/api.d.ts +0 -85
- package/dist/graph/api.d.ts.map +0 -1
- package/dist/graph/api.js +0 -66
- package/dist/graph/api.js.map +0 -1
- package/dist/graph/index.d.ts.map +0 -1
- package/dist/graph/index.js.map +0 -1
- package/dist/graph/mutate/builder.d.ts +0 -108
- package/dist/graph/mutate/builder.d.ts.map +0 -1
- package/dist/graph/mutate/builder.js +0 -127
- package/dist/graph/mutate/builder.js.map +0 -1
- package/dist/graph/mutate/index.d.ts +0 -5
- package/dist/graph/mutate/index.d.ts.map +0 -1
- package/dist/graph/mutate/index.js +0 -3
- package/dist/graph/mutate/index.js.map +0 -1
- package/dist/graph/mutate/shorthands.d.ts +0 -42
- package/dist/graph/mutate/shorthands.d.ts.map +0 -1
- package/dist/graph/mutate/shorthands.js +0 -65
- package/dist/graph/mutate/shorthands.js.map +0 -1
- package/dist/graph/named.d.ts +0 -38
- package/dist/graph/named.d.ts.map +0 -1
- package/dist/graph/named.js +0 -47
- package/dist/graph/named.js.map +0 -1
- package/dist/graph/query/builder.d.ts +0 -116
- package/dist/graph/query/builder.d.ts.map +0 -1
- package/dist/graph/query/builder.js +0 -136
- package/dist/graph/query/builder.js.map +0 -1
- package/dist/graph/query/edge-ref.d.ts +0 -13
- package/dist/graph/query/edge-ref.d.ts.map +0 -1
- package/dist/graph/query/edge-ref.js +0 -56
- package/dist/graph/query/edge-ref.js.map +0 -1
- package/dist/graph/query/edges.d.ts +0 -10
- package/dist/graph/query/edges.d.ts.map +0 -1
- package/dist/graph/query/edges.js +0 -11
- package/dist/graph/query/edges.js.map +0 -1
- package/dist/graph/query/errors.d.ts +0 -31
- package/dist/graph/query/errors.d.ts.map +0 -1
- package/dist/graph/query/errors.js +0 -28
- package/dist/graph/query/errors.js.map +0 -1
- package/dist/graph/query/filter.d.ts +0 -50
- package/dist/graph/query/filter.d.ts.map +0 -1
- package/dist/graph/query/filter.js +0 -32
- package/dist/graph/query/filter.js.map +0 -1
- package/dist/graph/query/index.d.ts +0 -12
- package/dist/graph/query/index.d.ts.map +0 -1
- package/dist/graph/query/index.js +0 -7
- package/dist/graph/query/index.js.map +0 -1
- package/dist/graph/query/lower.d.ts +0 -30
- package/dist/graph/query/lower.d.ts.map +0 -1
- package/dist/graph/query/lower.js +0 -171
- package/dist/graph/query/lower.js.map +0 -1
- package/dist/graph/query/shorthands.d.ts +0 -34
- package/dist/graph/query/shorthands.d.ts.map +0 -1
- package/dist/graph/query/shorthands.js +0 -71
- package/dist/graph/query/shorthands.js.map +0 -1
- package/dist/graph/query/traverse.d.ts +0 -59
- package/dist/graph/query/traverse.d.ts.map +0 -1
- package/dist/graph/query/traverse.js +0 -144
- package/dist/graph/query/traverse.js.map +0 -1
- package/dist/graph/reconcile/execute.d.ts +0 -8
- package/dist/graph/reconcile/execute.d.ts.map +0 -1
- package/dist/graph/reconcile/execute.js +0 -56
- package/dist/graph/reconcile/execute.js.map +0 -1
- package/dist/graph/reconcile/index.d.ts +0 -5
- package/dist/graph/reconcile/index.d.ts.map +0 -1
- package/dist/graph/reconcile/index.js +0 -3
- package/dist/graph/reconcile/index.js.map +0 -1
- package/dist/graph/reconcile/input.d.ts +0 -80
- package/dist/graph/reconcile/input.d.ts.map +0 -1
- package/dist/graph/reconcile/input.js +0 -5
- package/dist/graph/reconcile/input.js.map +0 -1
- package/dist/graph/reconcile/normalize.d.ts +0 -3
- package/dist/graph/reconcile/normalize.d.ts.map +0 -1
- package/dist/graph/reconcile/normalize.js +0 -144
- package/dist/graph/reconcile/normalize.js.map +0 -1
- package/dist/graph/reconcile/result.d.ts +0 -19
- package/dist/graph/reconcile/result.d.ts.map +0 -1
- package/dist/graph/reconcile/result.js +0 -95
- package/dist/graph/reconcile/result.js.map +0 -1
- package/dist/graph/reconcile/scope.d.ts +0 -6
- package/dist/graph/reconcile/scope.d.ts.map +0 -1
- package/dist/graph/reconcile/scope.js +0 -69
- package/dist/graph/reconcile/scope.js.map +0 -1
- package/dist/graph/result/envelope.d.ts +0 -37
- package/dist/graph/result/envelope.d.ts.map +0 -1
- package/dist/graph/result/envelope.js +0 -59
- package/dist/graph/result/envelope.js.map +0 -1
- package/dist/graph/result/index.d.ts +0 -6
- package/dist/graph/result/index.d.ts.map +0 -1
- package/dist/graph/result/index.js +0 -4
- package/dist/graph/result/index.js.map +0 -1
- package/dist/graph/result/next.d.ts +0 -16
- package/dist/graph/result/next.d.ts.map +0 -1
- package/dist/graph/result/next.js +0 -77
- package/dist/graph/result/next.js.map +0 -1
- package/dist/graph/result/paged.d.ts +0 -30
- package/dist/graph/result/paged.d.ts.map +0 -1
- package/dist/graph/result/paged.js +0 -41
- package/dist/graph/result/paged.js.map +0 -1
- package/dist/graph/wire.d.ts +0 -33
- package/dist/graph/wire.d.ts.map +0 -1
- package/dist/graph/wire.js +0 -16
- package/dist/graph/wire.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/pacer/batcher.d.ts +0 -11
- package/dist/pacer/batcher.d.ts.map +0 -1
- package/dist/pacer/batcher.js +0 -15
- package/dist/pacer/batcher.js.map +0 -1
- package/dist/pacer/defaults.d.ts +0 -18
- package/dist/pacer/defaults.d.ts.map +0 -1
- package/dist/pacer/defaults.js +0 -18
- package/dist/pacer/defaults.js.map +0 -1
- package/dist/pacer/index.d.ts.map +0 -1
- package/dist/pacer/index.js.map +0 -1
- package/dist/pacer/queue.d.ts +0 -11
- package/dist/pacer/queue.d.ts.map +0 -1
- package/dist/pacer/queue.js +0 -15
- package/dist/pacer/queue.js.map +0 -1
- package/dist/pacer/rate-limiter.d.ts +0 -11
- package/dist/pacer/rate-limiter.d.ts.map +0 -1
- package/dist/pacer/rate-limiter.js +0 -15
- package/dist/pacer/rate-limiter.js.map +0 -1
- package/dist/pacer/retry.d.ts +0 -14
- package/dist/pacer/retry.d.ts.map +0 -1
- package/dist/pacer/retry.js +0 -50
- package/dist/pacer/retry.js.map +0 -1
- package/dist/pool/errors.d.ts +0 -13
- package/dist/pool/errors.d.ts.map +0 -1
- package/dist/pool/errors.js +0 -16
- package/dist/pool/errors.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/schema/bound/binder.d.ts +0 -49
- package/dist/schema/bound/binder.d.ts.map +0 -1
- package/dist/schema/bound/binder.js +0 -195
- package/dist/schema/bound/binder.js.map +0 -1
- package/dist/schema/bound/bound-node.d.ts +0 -105
- package/dist/schema/bound/bound-node.d.ts.map +0 -1
- package/dist/schema/bound/bound-node.js +0 -128
- package/dist/schema/bound/bound-node.js.map +0 -1
- package/dist/schema/bound/index.d.ts +0 -10
- package/dist/schema/bound/index.d.ts.map +0 -1
- package/dist/schema/bound/index.js +0 -5
- package/dist/schema/bound/index.js.map +0 -1
- package/dist/schema/bound/view.d.ts +0 -44
- package/dist/schema/bound/view.d.ts.map +0 -1
- package/dist/schema/bound/view.js +0 -117
- package/dist/schema/bound/view.js.map +0 -1
- package/dist/schema/bound/write-props.d.ts +0 -38
- package/dist/schema/bound/write-props.d.ts.map +0 -1
- package/dist/schema/bound/write-props.js +0 -2
- package/dist/schema/bound/write-props.js.map +0 -1
- package/dist/schema/call-args.d.ts +0 -6
- package/dist/schema/call-args.d.ts.map +0 -1
- package/dist/schema/call-args.js +0 -21
- package/dist/schema/call-args.js.map +0 -1
- package/dist/schema/class-proxy.d.ts +0 -11
- package/dist/schema/class-proxy.d.ts.map +0 -1
- package/dist/schema/class-proxy.js +0 -46
- package/dist/schema/class-proxy.js.map +0 -1
- package/dist/schema/extract.d.ts +0 -24
- package/dist/schema/extract.d.ts.map +0 -1
- package/dist/schema/extract.js +0 -45
- package/dist/schema/extract.js.map +0 -1
- package/dist/schema/from-entries.d.ts +0 -12
- package/dist/schema/from-entries.d.ts.map +0 -1
- package/dist/schema/from-entries.js +0 -39
- package/dist/schema/from-entries.js.map +0 -1
- package/dist/schema/index.d.ts.map +0 -1
- package/dist/schema/index.js.map +0 -1
- package/dist/schema/known-dispatch.d.ts +0 -6
- package/dist/schema/known-dispatch.d.ts.map +0 -1
- package/dist/schema/known-dispatch.js +0 -39
- package/dist/schema/known-dispatch.js.map +0 -1
- package/dist/schema/node-proxy.d.ts +0 -21
- package/dist/schema/node-proxy.d.ts.map +0 -1
- package/dist/schema/node-proxy.js +0 -75
- package/dist/schema/node-proxy.js.map +0 -1
- package/dist/schema/persistence.d.ts +0 -31
- package/dist/schema/persistence.d.ts.map +0 -1
- package/dist/schema/persistence.js +0 -2
- package/dist/schema/persistence.js.map +0 -1
- package/dist/schema/proxy-types.d.ts +0 -131
- package/dist/schema/proxy-types.d.ts.map +0 -1
- package/dist/schema/proxy-types.js +0 -2
- package/dist/schema/proxy-types.js.map +0 -1
- package/dist/schema/registry.d.ts +0 -50
- package/dist/schema/registry.d.ts.map +0 -1
- package/dist/schema/registry.js +0 -110
- package/dist/schema/registry.js.map +0 -1
- package/dist/schema/resolve.d.ts +0 -26
- package/dist/schema/resolve.d.ts.map +0 -1
- package/dist/schema/resolve.js +0 -27
- package/dist/schema/resolve.js.map +0 -1
- package/dist/schema/typed-client.d.ts +0 -10
- package/dist/schema/typed-client.d.ts.map +0 -1
- package/dist/schema/typed-client.js +0 -26
- package/dist/schema/typed-client.js.map +0 -1
- package/dist/schema/types.d.ts +0 -9
- package/dist/schema/types.d.ts.map +0 -1
- package/dist/schema/types.js +0 -2
- package/dist/schema/types.js.map +0 -1
- package/dist/session/bound.d.ts.map +0 -1
- package/dist/session/bound.js.map +0 -1
- package/dist/session/client-session.d.ts +0 -72
- package/dist/session/client-session.d.ts.map +0 -1
- package/dist/session/client-session.js +0 -673
- package/dist/session/client-session.js.map +0 -1
- package/dist/session/config.d.ts +0 -168
- package/dist/session/config.d.ts.map +0 -1
- package/dist/session/config.js +0 -2
- package/dist/session/config.js.map +0 -1
- package/dist/session/delegation/cache.d.ts +0 -139
- package/dist/session/delegation/cache.d.ts.map +0 -1
- package/dist/session/delegation/cache.js +0 -256
- package/dist/session/delegation/cache.js.map +0 -1
- package/dist/session/delegation/errors.d.ts +0 -44
- package/dist/session/delegation/errors.d.ts.map +0 -1
- package/dist/session/delegation/errors.js +0 -62
- package/dist/session/delegation/errors.js.map +0 -1
- package/dist/session/delegation/policy.d.ts +0 -183
- package/dist/session/delegation/policy.d.ts.map +0 -1
- package/dist/session/delegation/policy.js +0 -114
- package/dist/session/delegation/policy.js.map +0 -1
- package/dist/session/delegation/utils.d.ts +0 -4
- package/dist/session/delegation/utils.d.ts.map +0 -1
- package/dist/session/delegation/utils.js +0 -12
- package/dist/session/delegation/utils.js.map +0 -1
- package/dist/session/delegation-mint.d.ts +0 -13
- package/dist/session/delegation-mint.d.ts.map +0 -1
- package/dist/session/delegation-mint.js +0 -39
- package/dist/session/delegation-mint.js.map +0 -1
- package/dist/session/dispatch-routes.d.ts +0 -27
- package/dist/session/dispatch-routes.d.ts.map +0 -1
- package/dist/session/dispatch-routes.js +0 -77
- package/dist/session/dispatch-routes.js.map +0 -1
- package/dist/session/errors/index.d.ts +0 -6
- package/dist/session/errors/index.d.ts.map +0 -1
- package/dist/session/errors/index.js +0 -8
- package/dist/session/errors/index.js.map +0 -1
- package/dist/session/errors/session-errors.d.ts +0 -52
- package/dist/session/errors/session-errors.d.ts.map +0 -1
- package/dist/session/errors/session-errors.js +0 -70
- package/dist/session/errors/session-errors.js.map +0 -1
- package/dist/session/forward.d.ts +0 -15
- package/dist/session/forward.d.ts.map +0 -1
- package/dist/session/forward.js +0 -40
- package/dist/session/forward.js.map +0 -1
- package/dist/session/helpers.d.ts +0 -23
- package/dist/session/helpers.d.ts.map +0 -1
- package/dist/session/helpers.js +0 -56
- package/dist/session/helpers.js.map +0 -1
- package/dist/session/hooks.d.ts +0 -140
- package/dist/session/hooks.d.ts.map +0 -1
- package/dist/session/hooks.js +0 -2
- package/dist/session/hooks.js.map +0 -1
- package/dist/session/index.d.ts.map +0 -1
- package/dist/session/index.js.map +0 -1
- package/dist/session/redirect/errors.d.ts +0 -45
- package/dist/session/redirect/errors.d.ts.map +0 -1
- package/dist/session/redirect/errors.js +0 -52
- package/dist/session/redirect/errors.js.map +0 -1
- package/dist/session/redirect/policy.d.ts +0 -79
- package/dist/session/redirect/policy.d.ts.map +0 -1
- package/dist/session/redirect/policy.js +0 -69
- package/dist/session/redirect/policy.js.map +0 -1
- package/dist/session/types.d.ts +0 -54
- package/dist/session/types.d.ts.map +0 -1
- package/dist/session/types.js +0 -2
- package/dist/session/types.js.map +0 -1
- package/dist/store/canonicalize.d.ts +0 -44
- package/dist/store/canonicalize.d.ts.map +0 -1
- package/dist/store/canonicalize.js +0 -0
- package/dist/store/canonicalize.js.map +0 -1
- package/dist/store/entities.d.ts +0 -81
- package/dist/store/entities.d.ts.map +0 -1
- package/dist/store/entities.js +0 -202
- package/dist/store/entities.js.map +0 -1
- package/dist/store/index.d.ts.map +0 -1
- package/dist/store/index.js.map +0 -1
- package/dist/store/invalidate.d.ts +0 -66
- package/dist/store/invalidate.d.ts.map +0 -1
- package/dist/store/invalidate.js +0 -117
- package/dist/store/invalidate.js.map +0 -1
- package/dist/store/memory.d.ts.map +0 -1
- package/dist/store/memory.js.map +0 -1
- package/dist/store/overlay.d.ts +0 -118
- package/dist/store/overlay.d.ts.map +0 -1
- package/dist/store/overlay.js +0 -237
- package/dist/store/overlay.js.map +0 -1
- package/dist/store/schedule.d.ts +0 -31
- package/dist/store/schedule.d.ts.map +0 -1
- package/dist/store/schedule.js +0 -76
- package/dist/store/schedule.js.map +0 -1
- package/dist/store/shapes.d.ts +0 -92
- package/dist/store/shapes.d.ts.map +0 -1
- package/dist/store/shapes.js +0 -369
- package/dist/store/shapes.js.map +0 -1
- package/dist/store/types.d.ts +0 -168
- package/dist/store/types.d.ts.map +0 -1
- package/dist/store/types.js +0 -7
- package/dist/store/types.js.map +0 -1
- package/dist/transport/binary.d.ts +0 -15
- package/dist/transport/binary.d.ts.map +0 -1
- package/dist/transport/binary.js +0 -2
- package/dist/transport/binary.js.map +0 -1
- package/dist/transport/contract.d.ts +0 -58
- package/dist/transport/contract.d.ts.map +0 -1
- package/dist/transport/contract.js +0 -11
- package/dist/transport/contract.js.map +0 -1
- package/dist/transport/fetch.d.ts +0 -31
- package/dist/transport/fetch.d.ts.map +0 -1
- package/dist/transport/fetch.js +0 -78
- package/dist/transport/fetch.js.map +0 -1
- package/dist/transport/http-envelope.d.ts +0 -49
- package/dist/transport/http-envelope.d.ts.map +0 -1
- package/dist/transport/http-envelope.js +0 -418
- package/dist/transport/http-envelope.js.map +0 -1
- package/dist/transport/http-routed.d.ts +0 -61
- package/dist/transport/http-routed.d.ts.map +0 -1
- package/dist/transport/http-routed.js +0 -409
- package/dist/transport/http-routed.js.map +0 -1
- package/dist/transport/index.d.ts.map +0 -1
- package/dist/transport/index.js.map +0 -1
- package/dist/transport/request-id.d.ts +0 -9
- package/dist/transport/request-id.d.ts.map +0 -1
- package/dist/transport/request-id.js +0 -12
- package/dist/transport/request-id.js.map +0 -1
- package/dist/transport/ws-envelope.d.ts +0 -74
- package/dist/transport/ws-envelope.d.ts.map +0 -1
- package/dist/transport/ws-envelope.js +0 -567
- package/dist/transport/ws-envelope.js.map +0 -1
- package/dist/util/race-signal.d.ts +0 -12
- package/dist/util/race-signal.d.ts.map +0 -1
- package/dist/util/race-signal.js +0 -34
- package/dist/util/race-signal.js.map +0 -1
- package/dist/wire/controller.d.ts +0 -38
- package/dist/wire/controller.d.ts.map +0 -1
- package/dist/wire/controller.js +0 -38
- package/dist/wire/controller.js.map +0 -1
- package/dist/wire/index.d.ts +0 -7
- package/dist/wire/index.d.ts.map +0 -1
- package/dist/wire/index.js +0 -4
- package/dist/wire/index.js.map +0 -1
- package/dist/wire/meta.d.ts +0 -81
- package/dist/wire/meta.d.ts.map +0 -1
- package/dist/wire/meta.js +0 -44
- package/dist/wire/meta.js.map +0 -1
- package/dist/wire/sse.d.ts +0 -67
- package/dist/wire/sse.d.ts.map +0 -1
- package/dist/wire/sse.js +0 -170
- package/dist/wire/sse.js.map +0 -1
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
import * as codecs from '@astrale-os/kernel-protocol/codecs';
|
|
2
|
+
import * as protocol from '@astrale-os/kernel-protocol/invocation';
|
|
3
|
+
import { ProtocolError, ResponseError, TransportError } from '../../errors/index.js';
|
|
4
|
+
import { invocationFailure } from '../failure.js';
|
|
5
|
+
import { asError, controlledSignal, positiveInteger, requireLive, } from '../index.js';
|
|
6
|
+
import { binaryHeaders, codecForResponse, decodeProtocol, normalizeMediaType, readBoundedBody, requireId, } from './response.js';
|
|
7
|
+
import { HttpStream } from './stream.js';
|
|
8
|
+
const DEFAULT_TIMEOUT_MS = 30_000;
|
|
9
|
+
const DEFAULT_MAXIMUM_REQUEST_BYTES = 16 * 1024 * 1024;
|
|
10
|
+
const DEFAULT_MAXIMUM_RESPONSE_BYTES = 16 * 1024 * 1024;
|
|
11
|
+
/** HTTP implementation of the universal invocation protocol. */
|
|
12
|
+
export class HttpTransport {
|
|
13
|
+
url;
|
|
14
|
+
codecName;
|
|
15
|
+
fetchImpl;
|
|
16
|
+
headers;
|
|
17
|
+
timeoutMs;
|
|
18
|
+
maximumRequestBytes;
|
|
19
|
+
maximumResponseBytes;
|
|
20
|
+
nextId = 1;
|
|
21
|
+
constructor(options) {
|
|
22
|
+
if (options === null || typeof options !== 'object') {
|
|
23
|
+
throw new TypeError('HttpTransport options must be an object.');
|
|
24
|
+
}
|
|
25
|
+
this.url = normalizeUrl(options.url);
|
|
26
|
+
this.codecName = admitCodecName(options.codec);
|
|
27
|
+
this.fetchImpl = admitFetch(options.fetch);
|
|
28
|
+
this.headers = admitHeaders(options.headers ?? {});
|
|
29
|
+
this.timeoutMs = positiveInteger(options.timeoutMs ?? DEFAULT_TIMEOUT_MS, 'timeoutMs');
|
|
30
|
+
this.maximumRequestBytes = positiveInteger(options.maximumRequestBytes ?? DEFAULT_MAXIMUM_REQUEST_BYTES, 'maximumRequestBytes');
|
|
31
|
+
this.maximumResponseBytes = positiveInteger(options.maximumResponseBytes ?? DEFAULT_MAXIMUM_RESPONSE_BYTES, 'maximumResponseBytes');
|
|
32
|
+
}
|
|
33
|
+
async dispatch(input, options = {}) {
|
|
34
|
+
const requestId = this.nextRequestId();
|
|
35
|
+
const timeoutMs = positiveInteger(options.timeoutMs ?? this.timeoutMs, 'timeoutMs');
|
|
36
|
+
const codec = await this.requestCodec();
|
|
37
|
+
const { trace: traceInput, ...invocationInput } = input;
|
|
38
|
+
const trace = traceInput === undefined ? undefined : protocol.admitTrace(traceInput);
|
|
39
|
+
const request = protocol.decodeRequest({
|
|
40
|
+
version: protocol.VERSION,
|
|
41
|
+
requestId,
|
|
42
|
+
...invocationInput,
|
|
43
|
+
...(options.idempotencyKey === undefined ? {} : { idempotencyKey: options.idempotencyKey }),
|
|
44
|
+
});
|
|
45
|
+
const encoded = codec.encode(request);
|
|
46
|
+
const control = controlledSignal(options.signal, timeoutMs);
|
|
47
|
+
let handedOff = false;
|
|
48
|
+
let phase = 'connect';
|
|
49
|
+
let delivery = 'not-sent';
|
|
50
|
+
try {
|
|
51
|
+
requireLive(control);
|
|
52
|
+
if (encodedByteLength(encoded) > this.maximumRequestBytes) {
|
|
53
|
+
throw invocationFailure(`request exceeds maximumRequestBytes (${this.maximumRequestBytes}).`, 'send');
|
|
54
|
+
}
|
|
55
|
+
phase = 'send';
|
|
56
|
+
delivery = 'unknown';
|
|
57
|
+
const response = await this.fetchResponse(codec, encoded, trace, control);
|
|
58
|
+
phase = 'receive';
|
|
59
|
+
requireLive(control);
|
|
60
|
+
if (response.status >= 300 && response.status < 400) {
|
|
61
|
+
throw new ProtocolError('server returned a network redirect.');
|
|
62
|
+
}
|
|
63
|
+
requireNoStore(response);
|
|
64
|
+
const streamFraming = response.headers.get(protocol.http.STREAM_FRAMING_FIELD);
|
|
65
|
+
const binaryId = response.headers.get(protocol.http.REQUEST_ID_FIELD);
|
|
66
|
+
const binaryManifest = response.headers.get(protocol.http.BINARY_HEADERS_FIELD);
|
|
67
|
+
const hasStreamSignal = streamFraming !== null;
|
|
68
|
+
const hasBinarySignal = binaryId !== null || binaryManifest !== null;
|
|
69
|
+
if (hasStreamSignal && hasBinarySignal) {
|
|
70
|
+
throw new ProtocolError('server returned conflicting stream and binary response signals.');
|
|
71
|
+
}
|
|
72
|
+
if (hasBinarySignal) {
|
|
73
|
+
if (binaryId === null || binaryManifest === null) {
|
|
74
|
+
throw new ProtocolError('server returned an incomplete binary response signal.');
|
|
75
|
+
}
|
|
76
|
+
return await this.decodeBinary(response, requestId, binaryId, control);
|
|
77
|
+
}
|
|
78
|
+
const responseCodec = await codecForResponse(response.headers.get('content-type'));
|
|
79
|
+
if (responseCodec === undefined) {
|
|
80
|
+
throw new ProtocolError(`server returned unsupported Content-Type ${JSON.stringify(response.headers.get('content-type'))}.`);
|
|
81
|
+
}
|
|
82
|
+
if (hasStreamSignal) {
|
|
83
|
+
if (streamFraming !== protocol.http.LENGTH_PREFIX_V1) {
|
|
84
|
+
throw new ProtocolError(`server returned unsupported stream framing ${JSON.stringify(streamFraming)}.`);
|
|
85
|
+
}
|
|
86
|
+
if (!response.ok) {
|
|
87
|
+
throw new ProtocolError('server returned a non-success stream response.');
|
|
88
|
+
}
|
|
89
|
+
const stream = await HttpStream.open(response, responseCodec, requestId, this.maximumResponseBytes, control);
|
|
90
|
+
requireLive(control);
|
|
91
|
+
handedOff = true;
|
|
92
|
+
return { kind: 'stream', stream, invocation: stream.invocation };
|
|
93
|
+
}
|
|
94
|
+
const body = await readBoundedBody(response, this.maximumResponseBytes, control.signal);
|
|
95
|
+
requireLive(control);
|
|
96
|
+
const decoded = decodeProtocol('response body', () => responseCodec.decode(body));
|
|
97
|
+
const envelope = decodeProtocol('response envelope', () => protocol.decodeResponse(decoded));
|
|
98
|
+
if (envelope.requestId === null && 'error' in envelope) {
|
|
99
|
+
throw new ResponseError(envelope.error.code, envelope.error.message, envelope.invocation, envelope.error.data);
|
|
100
|
+
}
|
|
101
|
+
requireId(requestId, envelope.requestId);
|
|
102
|
+
if ('kind' in envelope && envelope.kind === 'stale') {
|
|
103
|
+
const stale = decodeProtocol('stale response', () => protocol.decodeStale(envelope));
|
|
104
|
+
requireLive(control);
|
|
105
|
+
return Object.freeze({
|
|
106
|
+
kind: 'stale',
|
|
107
|
+
current: stale.current,
|
|
108
|
+
invocation: stale.invocation,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
if ('kind' in envelope && envelope.kind === 'miss') {
|
|
112
|
+
decodeProtocol('miss response', () => protocol.decodeMiss(envelope));
|
|
113
|
+
requireLive(control);
|
|
114
|
+
return Object.freeze({ kind: 'miss', invocation: envelope.invocation });
|
|
115
|
+
}
|
|
116
|
+
if ('kind' in envelope && envelope.kind === 'redirect') {
|
|
117
|
+
const response = decodeProtocol('redirect response', () => protocol.decodeRedirectResponse(envelope));
|
|
118
|
+
requireLive(control);
|
|
119
|
+
return redirectResult(response);
|
|
120
|
+
}
|
|
121
|
+
if ('error' in envelope) {
|
|
122
|
+
throw new ResponseError(envelope.error.code, envelope.error.message, envelope.invocation, envelope.error.data);
|
|
123
|
+
}
|
|
124
|
+
requireLive(control);
|
|
125
|
+
return { kind: 'value', value: envelope.result, invocation: envelope.invocation };
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
throw transportFailure(error, control, options.signal, timeoutMs, this.url, phase, delivery);
|
|
129
|
+
}
|
|
130
|
+
finally {
|
|
131
|
+
if (!handedOff)
|
|
132
|
+
control.close();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
async fetchResponse(codec, encoded, trace, control) {
|
|
136
|
+
return this.fetchImpl(this.url, {
|
|
137
|
+
method: 'POST',
|
|
138
|
+
redirect: 'error',
|
|
139
|
+
credentials: 'omit',
|
|
140
|
+
cache: 'no-store',
|
|
141
|
+
referrerPolicy: 'no-referrer',
|
|
142
|
+
headers: {
|
|
143
|
+
...this.headers,
|
|
144
|
+
...protocol.http.encodeTraceHeaders(trace),
|
|
145
|
+
'content-type': codec.contentType,
|
|
146
|
+
accept: codec.contentType,
|
|
147
|
+
},
|
|
148
|
+
body: toBody(encoded),
|
|
149
|
+
signal: control.signal,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
async decodeBinary(response, requestId, binaryId, control) {
|
|
153
|
+
if (!response.ok) {
|
|
154
|
+
throw new ProtocolError('server returned binary data with an error status.');
|
|
155
|
+
}
|
|
156
|
+
if (binaryId !== String(requestId)) {
|
|
157
|
+
throw new ProtocolError(`binary response requestId ${JSON.stringify(binaryId)} does not match request requestId ${requestId}.`);
|
|
158
|
+
}
|
|
159
|
+
const mediaType = normalizeMediaType(response.headers.get('content-type'));
|
|
160
|
+
if (mediaType === undefined) {
|
|
161
|
+
throw new ProtocolError('binary response has no media type.');
|
|
162
|
+
}
|
|
163
|
+
const body = await readBoundedBody(response, this.maximumResponseBytes, control.signal);
|
|
164
|
+
requireLive(control);
|
|
165
|
+
const headerNames = decodeProtocol('binary application-header manifest', () => protocol.http.decodeBinaryHeaderNames(response.headers.get(protocol.http.BINARY_HEADERS_FIELD)));
|
|
166
|
+
const headers = binaryHeaders(response.headers, headerNames);
|
|
167
|
+
const invocation = decodeProtocol('binary InvocationId field', () => protocol.http.decodeInvocationId(response.headers.get(protocol.http.INVOCATION_FIELD)));
|
|
168
|
+
const binary = decodeProtocol('binary response', () => protocol.decodeBinaryResponse({
|
|
169
|
+
kind: 'binary',
|
|
170
|
+
requestId,
|
|
171
|
+
invocation,
|
|
172
|
+
body,
|
|
173
|
+
mediaType,
|
|
174
|
+
...(Object.keys(headers).length === 0 ? {} : { headers }),
|
|
175
|
+
}));
|
|
176
|
+
requireLive(control);
|
|
177
|
+
return {
|
|
178
|
+
kind: 'binary',
|
|
179
|
+
invocation: binary.invocation,
|
|
180
|
+
value: {
|
|
181
|
+
body: binary.body,
|
|
182
|
+
mediaType: binary.mediaType,
|
|
183
|
+
...(binary.headers === undefined ? {} : { headers: binary.headers }),
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
nextRequestId() {
|
|
188
|
+
const requestId = this.nextId;
|
|
189
|
+
this.nextId = requestId === Number.MAX_SAFE_INTEGER ? 1 : requestId + 1;
|
|
190
|
+
return requestId;
|
|
191
|
+
}
|
|
192
|
+
requestCodec() {
|
|
193
|
+
return this.codecName === 'msgpack' ? codecs.loadMsgpack() : Promise.resolve(codecs.json);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
function redirectResult(response) {
|
|
197
|
+
return Object.freeze({
|
|
198
|
+
kind: 'redirect',
|
|
199
|
+
invocation: response.invocation,
|
|
200
|
+
redirect: response.redirect,
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
function normalizeUrl(input) {
|
|
204
|
+
if (typeof input !== 'string')
|
|
205
|
+
throw new TypeError('server URL must be a string.');
|
|
206
|
+
let parsed;
|
|
207
|
+
try {
|
|
208
|
+
parsed = new URL(input);
|
|
209
|
+
}
|
|
210
|
+
catch (error) {
|
|
211
|
+
throw new TypeError(`Invalid server URL ${JSON.stringify(input)}.`, { cause: asError(error) });
|
|
212
|
+
}
|
|
213
|
+
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
|
|
214
|
+
throw new TypeError('server URL must use http or https.');
|
|
215
|
+
}
|
|
216
|
+
if (parsed.username !== '' || parsed.password !== '' || parsed.hash !== '') {
|
|
217
|
+
throw new TypeError('server URL cannot contain credentials or a fragment.');
|
|
218
|
+
}
|
|
219
|
+
return parsed.toString();
|
|
220
|
+
}
|
|
221
|
+
function admitHeaders(input) {
|
|
222
|
+
if (input === null || typeof input !== 'object' || Array.isArray(input)) {
|
|
223
|
+
throw new TypeError('HTTP headers must be an object.');
|
|
224
|
+
}
|
|
225
|
+
const output = {};
|
|
226
|
+
for (const [name, value] of Object.entries(input)) {
|
|
227
|
+
if (!HEADER_NAME.test(name)) {
|
|
228
|
+
throw new TypeError(`HTTP header name ${JSON.stringify(name)} is invalid.`);
|
|
229
|
+
}
|
|
230
|
+
const normalized = name.toLowerCase();
|
|
231
|
+
if (Object.hasOwn(output, normalized)) {
|
|
232
|
+
throw new TypeError(`HTTP header ${JSON.stringify(name)} occurs more than once.`);
|
|
233
|
+
}
|
|
234
|
+
if (isReservedRequestHeader(normalized)) {
|
|
235
|
+
throw new TypeError(`HTTP header ${JSON.stringify(name)} is owned by transport.`);
|
|
236
|
+
}
|
|
237
|
+
if (typeof value !== 'string') {
|
|
238
|
+
throw new TypeError(`HTTP header ${JSON.stringify(name)} must be a string.`);
|
|
239
|
+
}
|
|
240
|
+
if (hasControlCharacter(value)) {
|
|
241
|
+
throw new TypeError(`HTTP header ${JSON.stringify(name)} contains a control character.`);
|
|
242
|
+
}
|
|
243
|
+
output[normalized] = value;
|
|
244
|
+
}
|
|
245
|
+
return Object.freeze(output);
|
|
246
|
+
}
|
|
247
|
+
function toBody(input) {
|
|
248
|
+
if (typeof input === 'string')
|
|
249
|
+
return input;
|
|
250
|
+
const copy = new Uint8Array(input);
|
|
251
|
+
return copy.buffer;
|
|
252
|
+
}
|
|
253
|
+
function encodedByteLength(input) {
|
|
254
|
+
return typeof input === 'string' ? new TextEncoder().encode(input).byteLength : input.byteLength;
|
|
255
|
+
}
|
|
256
|
+
function requireNoStore(response) {
|
|
257
|
+
const directives = response.headers
|
|
258
|
+
.get('cache-control')
|
|
259
|
+
?.split(',')
|
|
260
|
+
.map((directive) => directive.trim().toLowerCase()) ?? [];
|
|
261
|
+
if (!directives.includes('no-store')) {
|
|
262
|
+
throw new ProtocolError('server response is missing Cache-Control: no-store.');
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
function transportFailure(input, control, parent, timeoutMs, url, phase, delivery) {
|
|
266
|
+
if (input instanceof ResponseError || input instanceof ProtocolError)
|
|
267
|
+
return input;
|
|
268
|
+
if (control.timedOut) {
|
|
269
|
+
return invocationFailure(`request timed out after ${timeoutMs}ms.`, 'timeout', {
|
|
270
|
+
cause: asError(input),
|
|
271
|
+
delivery,
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
if (parent?.aborted)
|
|
275
|
+
return asError(parent.reason ?? input);
|
|
276
|
+
return input instanceof TransportError
|
|
277
|
+
? input
|
|
278
|
+
: invocationFailure(`Failed to communicate with the server at ${url}.`, phase, {
|
|
279
|
+
cause: asError(input),
|
|
280
|
+
delivery,
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
function admitCodecName(input) {
|
|
284
|
+
if (input === undefined || input === 'json')
|
|
285
|
+
return 'json';
|
|
286
|
+
if (input === 'msgpack')
|
|
287
|
+
return input;
|
|
288
|
+
throw new TypeError('codec must be "json" or "msgpack".');
|
|
289
|
+
}
|
|
290
|
+
function admitFetch(input) {
|
|
291
|
+
const implementation = input ?? globalThis.fetch;
|
|
292
|
+
if (typeof implementation !== 'function') {
|
|
293
|
+
throw new TypeError('HttpTransport requires a Fetch implementation.');
|
|
294
|
+
}
|
|
295
|
+
return input === undefined ? implementation.bind(globalThis) : implementation;
|
|
296
|
+
}
|
|
297
|
+
const HEADER_NAME = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
|
|
298
|
+
const RESERVED_REQUEST_HEADERS = new Set([
|
|
299
|
+
'accept',
|
|
300
|
+
'accept-encoding',
|
|
301
|
+
'authorization',
|
|
302
|
+
'cache-control',
|
|
303
|
+
'connection',
|
|
304
|
+
'content-length',
|
|
305
|
+
'content-type',
|
|
306
|
+
'cookie',
|
|
307
|
+
'expect',
|
|
308
|
+
'forwarded',
|
|
309
|
+
'host',
|
|
310
|
+
'keep-alive',
|
|
311
|
+
'origin',
|
|
312
|
+
'pragma',
|
|
313
|
+
'proxy-authenticate',
|
|
314
|
+
'proxy-authorization',
|
|
315
|
+
'referer',
|
|
316
|
+
'referrer-policy',
|
|
317
|
+
'set-cookie',
|
|
318
|
+
'te',
|
|
319
|
+
protocol.http.TRACEPARENT_FIELD,
|
|
320
|
+
protocol.http.TRACESTATE_FIELD,
|
|
321
|
+
protocol.http.BAGGAGE_FIELD,
|
|
322
|
+
'trailer',
|
|
323
|
+
'transfer-encoding',
|
|
324
|
+
'upgrade',
|
|
325
|
+
'via',
|
|
326
|
+
]);
|
|
327
|
+
function isReservedRequestHeader(name) {
|
|
328
|
+
return (RESERVED_REQUEST_HEADERS.has(name) ||
|
|
329
|
+
name.startsWith('access-control-') ||
|
|
330
|
+
name.startsWith('content-') ||
|
|
331
|
+
name.startsWith('proxy-') ||
|
|
332
|
+
name.startsWith('sec-websocket-') ||
|
|
333
|
+
name.startsWith('x-astrale-') ||
|
|
334
|
+
name.startsWith('x-forwarded-'));
|
|
335
|
+
}
|
|
336
|
+
function hasControlCharacter(input) {
|
|
337
|
+
for (let index = 0; index < input.length; index += 1) {
|
|
338
|
+
const code = input.charCodeAt(index);
|
|
339
|
+
if (code <= 0x1f || code === 0x7f)
|
|
340
|
+
return true;
|
|
341
|
+
}
|
|
342
|
+
return false;
|
|
343
|
+
}
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
export type {
|
|
2
|
-
export {
|
|
3
|
-
export { WsEnvelopeTransport, type WsEnvelopeTransportConfig } from './ws-envelope.js';
|
|
4
|
-
export { HttpRoutedTransport, type HttpRoutedTransportConfig, type RoutedTransportRequest, } from './http-routed.js';
|
|
5
|
-
export type { BinaryResponse } from './binary.js';
|
|
6
|
-
export { safeFetch } from './fetch.js';
|
|
7
|
-
export { nextRequestId } from './request-id.js';
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1
|
+
export type { RequestOptions, MissControl, StaleControl, Transport, TransportRequest, TransportResult, } from './transport.js';
|
|
2
|
+
export { asError, controlledSignal, positiveInteger, requireLive, type ControlledSignal, } from './deadline.js';
|
package/dist/transport/index.js
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { WsEnvelopeTransport } from './ws-envelope.js';
|
|
3
|
-
export { HttpRoutedTransport, } from './http-routed.js';
|
|
4
|
-
export { safeFetch } from './fetch.js';
|
|
5
|
-
export { nextRequestId } from './request-id.js';
|
|
6
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export { asError, controlledSignal, positiveInteger, requireLive, } from './deadline.js';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { invocation as protocol } from '@astrale-os/kernel-protocol';
|
|
2
|
+
import type { Result } from '../client/result.js';
|
|
3
|
+
export interface RequestOptions {
|
|
4
|
+
readonly signal?: AbortSignal;
|
|
5
|
+
readonly timeoutMs?: number;
|
|
6
|
+
readonly idempotencyKey?: protocol.IdempotencyKey;
|
|
7
|
+
}
|
|
8
|
+
export interface TransportRequest {
|
|
9
|
+
readonly call: protocol.Call;
|
|
10
|
+
/** Internally supplied per-attempt correlation syntax; never a RequestOptions field. */
|
|
11
|
+
readonly trace?: protocol.Trace;
|
|
12
|
+
readonly credential?: string;
|
|
13
|
+
readonly delegate?: protocol.Delegate;
|
|
14
|
+
readonly routing?: protocol.Routing;
|
|
15
|
+
/** Source-Kernel Schema Registration precondition; omitted after routing. */
|
|
16
|
+
readonly schema?: protocol.SchemaTarget;
|
|
17
|
+
}
|
|
18
|
+
/** Correlated reserved control decoded independently from application results and errors. */
|
|
19
|
+
export interface StaleControl {
|
|
20
|
+
readonly kind: 'stale';
|
|
21
|
+
readonly current: protocol.Stale['current'];
|
|
22
|
+
readonly invocation: protocol.InvocationId;
|
|
23
|
+
}
|
|
24
|
+
export interface MissControl {
|
|
25
|
+
readonly kind: 'miss';
|
|
26
|
+
readonly invocation: protocol.InvocationId;
|
|
27
|
+
}
|
|
28
|
+
export type TransportResult = Result | StaleControl | MissControl;
|
|
29
|
+
export interface Transport {
|
|
30
|
+
/** Primary embedding-environment adapter for a complete invocation boundary. */
|
|
31
|
+
dispatch(input: TransportRequest, options?: RequestOptions): Promise<TransportResult>;
|
|
32
|
+
/** Optional owned-resource shutdown used by Client.close(). */
|
|
33
|
+
readonly close?: () => void;
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type * as codecs from '@astrale-os/kernel-protocol/codecs';
|
|
2
|
+
import * as protocol from '@astrale-os/kernel-protocol/invocation';
|
|
3
|
+
import type { ControlledSignal } from '../index.js';
|
|
4
|
+
import type { TransportResult } from '../index.js';
|
|
5
|
+
import type { ExchangeOwner } from './exchange.js';
|
|
6
|
+
import type { WebSocketConstructor } from './transport.js';
|
|
7
|
+
import { WebSocketExchange } from './exchange.js';
|
|
8
|
+
export interface ConnectionOwner {
|
|
9
|
+
closed(connection: WebSocketConnection): void;
|
|
10
|
+
}
|
|
11
|
+
export declare class WebSocketConnection implements ExchangeOwner {
|
|
12
|
+
private readonly owner;
|
|
13
|
+
private readonly codec;
|
|
14
|
+
private readonly maximumRequestBytes;
|
|
15
|
+
private readonly maximumResponseBytes;
|
|
16
|
+
private readonly maximumBufferedBytes;
|
|
17
|
+
private readonly maximumActiveInvocations;
|
|
18
|
+
private readonly socket;
|
|
19
|
+
private readonly ready;
|
|
20
|
+
private resolveReady;
|
|
21
|
+
private rejectReady;
|
|
22
|
+
private opened;
|
|
23
|
+
private closedState;
|
|
24
|
+
private readonly active;
|
|
25
|
+
private readonly cancelled;
|
|
26
|
+
private incoming;
|
|
27
|
+
constructor(owner: ConnectionOwner, WebSocketConstructor: WebSocketConstructor, url: string, codec: codecs.Codec, maximumRequestBytes: number, maximumResponseBytes: number, maximumBufferedBytes: number, maximumActiveInvocations: number);
|
|
28
|
+
get isOpen(): boolean;
|
|
29
|
+
get isAvailable(): boolean;
|
|
30
|
+
connect(control: ControlledSignal): Promise<void>;
|
|
31
|
+
dispatch(request: protocol.Request, control: ControlledSignal, maximumBufferedItems: number): Promise<TransportResult>;
|
|
32
|
+
finish(exchange: WebSocketExchange, reusable: boolean, closeCode?: 1002 | 1008 | 1011): void;
|
|
33
|
+
cancel(exchange: WebSocketExchange, requestId: protocol.RequestId): void;
|
|
34
|
+
shutdown(reason?: Error, closeCode?: number, closeReason?: string): void;
|
|
35
|
+
private onOpen;
|
|
36
|
+
private onMessage;
|
|
37
|
+
private onFailure;
|
|
38
|
+
}
|