@astrale-os/kernel-client 0.2.0
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/client/batch.d.ts +26 -0
- package/dist/client/batch.d.ts.map +1 -0
- package/dist/client/batch.js +8 -0
- package/dist/client/batch.js.map +1 -0
- package/dist/client/bound.d.ts +27 -0
- package/dist/client/bound.d.ts.map +1 -0
- package/dist/client/bound.js +14 -0
- package/dist/client/bound.js.map +1 -0
- package/dist/client/client.d.ts +93 -0
- package/dist/client/client.d.ts.map +1 -0
- package/dist/client/client.js +393 -0
- package/dist/client/client.js.map +1 -0
- package/dist/client/config.d.ts +112 -0
- package/dist/client/config.d.ts.map +1 -0
- package/dist/client/config.js +10 -0
- package/dist/client/config.js.map +1 -0
- package/dist/client/fn-map.d.ts +61 -0
- package/dist/client/fn-map.d.ts.map +1 -0
- package/dist/client/fn-map.js +2 -0
- package/dist/client/fn-map.js.map +1 -0
- package/dist/client/freeze.d.ts +32 -0
- package/dist/client/freeze.d.ts.map +1 -0
- package/dist/client/freeze.js +42 -0
- package/dist/client/freeze.js.map +1 -0
- package/dist/client/hooks.d.ts +49 -0
- package/dist/client/hooks.d.ts.map +1 -0
- package/dist/client/hooks.js +2 -0
- package/dist/client/hooks.js.map +1 -0
- package/dist/client/index.d.ts +7 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +2 -0
- package/dist/client/index.js.map +1 -0
- package/dist/delegation/cache.d.ts +133 -0
- package/dist/delegation/cache.d.ts.map +1 -0
- package/dist/delegation/cache.js +258 -0
- package/dist/delegation/cache.js.map +1 -0
- package/dist/delegation/errors.d.ts +44 -0
- package/dist/delegation/errors.d.ts.map +1 -0
- package/dist/delegation/errors.js +62 -0
- package/dist/delegation/errors.js.map +1 -0
- package/dist/delegation/index.d.ts +6 -0
- package/dist/delegation/index.d.ts.map +1 -0
- package/dist/delegation/index.js +4 -0
- package/dist/delegation/index.js.map +1 -0
- package/dist/delegation/policy.d.ts +175 -0
- package/dist/delegation/policy.d.ts.map +1 -0
- package/dist/delegation/policy.js +109 -0
- package/dist/delegation/policy.js.map +1 -0
- package/dist/errors/errors.d.ts +103 -0
- package/dist/errors/errors.d.ts.map +1 -0
- package/dist/errors/errors.js +170 -0
- package/dist/errors/errors.js.map +1 -0
- package/dist/errors/index.d.ts +4 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +3 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/errors/session-error.d.ts +21 -0
- package/dist/errors/session-error.d.ts.map +1 -0
- package/dist/errors/session-error.js +25 -0
- package/dist/errors/session-error.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/pacer/batcher.d.ts +11 -0
- package/dist/pacer/batcher.d.ts.map +1 -0
- package/dist/pacer/batcher.js +15 -0
- package/dist/pacer/batcher.js.map +1 -0
- package/dist/pacer/defaults.d.ts +18 -0
- package/dist/pacer/defaults.d.ts.map +1 -0
- package/dist/pacer/defaults.js +18 -0
- package/dist/pacer/defaults.js.map +1 -0
- package/dist/pacer/index.d.ts +10 -0
- package/dist/pacer/index.d.ts.map +1 -0
- package/dist/pacer/index.js +11 -0
- package/dist/pacer/index.js.map +1 -0
- package/dist/pacer/queue.d.ts +11 -0
- package/dist/pacer/queue.d.ts.map +1 -0
- package/dist/pacer/queue.js +15 -0
- package/dist/pacer/queue.js.map +1 -0
- package/dist/pacer/rate-limiter.d.ts +11 -0
- package/dist/pacer/rate-limiter.d.ts.map +1 -0
- package/dist/pacer/rate-limiter.js +15 -0
- package/dist/pacer/rate-limiter.js.map +1 -0
- package/dist/pacer/retry.d.ts +14 -0
- package/dist/pacer/retry.d.ts.map +1 -0
- package/dist/pacer/retry.js +50 -0
- package/dist/pacer/retry.js.map +1 -0
- package/dist/persistence/index.d.ts +3 -0
- package/dist/persistence/index.d.ts.map +1 -0
- package/dist/persistence/index.js +2 -0
- package/dist/persistence/index.js.map +1 -0
- package/dist/persistence/persistence.d.ts +52 -0
- package/dist/persistence/persistence.d.ts.map +1 -0
- package/dist/persistence/persistence.js +32 -0
- package/dist/persistence/persistence.js.map +1 -0
- package/dist/pool/errors.d.ts +13 -0
- package/dist/pool/errors.d.ts.map +1 -0
- package/dist/pool/errors.js +16 -0
- package/dist/pool/errors.js.map +1 -0
- package/dist/pool/index.d.ts +4 -0
- package/dist/pool/index.d.ts.map +1 -0
- package/dist/pool/index.js +3 -0
- package/dist/pool/index.js.map +1 -0
- package/dist/pool/pool.d.ts +63 -0
- package/dist/pool/pool.d.ts.map +1 -0
- package/dist/pool/pool.js +87 -0
- package/dist/pool/pool.js.map +1 -0
- package/dist/redirect/errors.d.ts +45 -0
- package/dist/redirect/errors.d.ts.map +1 -0
- package/dist/redirect/errors.js +52 -0
- package/dist/redirect/errors.js.map +1 -0
- package/dist/redirect/index.d.ts +4 -0
- package/dist/redirect/index.d.ts.map +1 -0
- package/dist/redirect/index.js +3 -0
- package/dist/redirect/index.js.map +1 -0
- package/dist/redirect/policy.d.ts +79 -0
- package/dist/redirect/policy.d.ts.map +1 -0
- package/dist/redirect/policy.js +69 -0
- package/dist/redirect/policy.js.map +1 -0
- package/dist/schema/call-args.d.ts +6 -0
- package/dist/schema/call-args.d.ts.map +1 -0
- package/dist/schema/call-args.js +21 -0
- package/dist/schema/call-args.js.map +1 -0
- package/dist/schema/class-proxy.d.ts +8 -0
- package/dist/schema/class-proxy.d.ts.map +1 -0
- package/dist/schema/class-proxy.js +38 -0
- package/dist/schema/class-proxy.js.map +1 -0
- package/dist/schema/extract.d.ts +9 -0
- package/dist/schema/extract.d.ts.map +1 -0
- package/dist/schema/extract.js +16 -0
- package/dist/schema/extract.js.map +1 -0
- package/dist/schema/from-entries.d.ts +12 -0
- package/dist/schema/from-entries.d.ts.map +1 -0
- package/dist/schema/from-entries.js +39 -0
- package/dist/schema/from-entries.js.map +1 -0
- package/dist/schema/index.d.ts +11 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +9 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/node-proxy.d.ts +9 -0
- package/dist/schema/node-proxy.d.ts.map +1 -0
- package/dist/schema/node-proxy.js +32 -0
- package/dist/schema/node-proxy.js.map +1 -0
- package/dist/schema/proxy-types.d.ts +112 -0
- package/dist/schema/proxy-types.d.ts.map +1 -0
- package/dist/schema/proxy-types.js +2 -0
- package/dist/schema/proxy-types.js.map +1 -0
- package/dist/schema/registry.d.ts +51 -0
- package/dist/schema/registry.d.ts.map +1 -0
- package/dist/schema/registry.js +111 -0
- package/dist/schema/registry.js.map +1 -0
- package/dist/schema/resolve.d.ts +26 -0
- package/dist/schema/resolve.d.ts.map +1 -0
- package/dist/schema/resolve.js +27 -0
- package/dist/schema/resolve.js.map +1 -0
- package/dist/schema/typed-client.d.ts +10 -0
- package/dist/schema/typed-client.d.ts.map +1 -0
- package/dist/schema/typed-client.js +26 -0
- package/dist/schema/typed-client.js.map +1 -0
- package/dist/schema/types.d.ts +9 -0
- package/dist/schema/types.d.ts.map +1 -0
- package/dist/schema/types.js +2 -0
- package/dist/schema/types.js.map +1 -0
- package/dist/session/bound.d.ts +11 -0
- package/dist/session/bound.d.ts.map +1 -0
- package/dist/session/bound.js +24 -0
- package/dist/session/bound.js.map +1 -0
- package/dist/session/client-session.d.ts +61 -0
- package/dist/session/client-session.d.ts.map +1 -0
- package/dist/session/client-session.js +635 -0
- package/dist/session/client-session.js.map +1 -0
- package/dist/session/config.d.ts +157 -0
- package/dist/session/config.d.ts.map +1 -0
- package/dist/session/config.js +2 -0
- package/dist/session/config.js.map +1 -0
- package/dist/session/errors/index.d.ts +6 -0
- package/dist/session/errors/index.d.ts.map +1 -0
- package/dist/session/errors/index.js +8 -0
- package/dist/session/errors/index.js.map +1 -0
- package/dist/session/errors/session-errors.d.ts +52 -0
- package/dist/session/errors/session-errors.d.ts.map +1 -0
- package/dist/session/errors/session-errors.js +70 -0
- package/dist/session/errors/session-errors.js.map +1 -0
- package/dist/session/forward.d.ts +14 -0
- package/dist/session/forward.d.ts.map +1 -0
- package/dist/session/forward.js +44 -0
- package/dist/session/forward.js.map +1 -0
- package/dist/session/helpers.d.ts +23 -0
- package/dist/session/helpers.d.ts.map +1 -0
- package/dist/session/helpers.js +56 -0
- package/dist/session/helpers.js.map +1 -0
- package/dist/session/hooks.d.ts +140 -0
- package/dist/session/hooks.d.ts.map +1 -0
- package/dist/session/hooks.js +2 -0
- package/dist/session/hooks.js.map +1 -0
- package/dist/session/index.d.ts +6 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +3 -0
- package/dist/session/index.js.map +1 -0
- package/dist/session/types.d.ts +38 -0
- package/dist/session/types.d.ts.map +1 -0
- package/dist/session/types.js +2 -0
- package/dist/session/types.js.map +1 -0
- package/dist/transport/binary.d.ts +15 -0
- package/dist/transport/binary.d.ts.map +1 -0
- package/dist/transport/binary.js +2 -0
- package/dist/transport/binary.js.map +1 -0
- package/dist/transport/contract.d.ts +58 -0
- package/dist/transport/contract.d.ts.map +1 -0
- package/dist/transport/contract.js +11 -0
- package/dist/transport/contract.js.map +1 -0
- package/dist/transport/fetch.d.ts +28 -0
- package/dist/transport/fetch.d.ts.map +1 -0
- package/dist/transport/fetch.js +74 -0
- package/dist/transport/fetch.js.map +1 -0
- package/dist/transport/http-envelope.d.ts +49 -0
- package/dist/transport/http-envelope.d.ts.map +1 -0
- package/dist/transport/http-envelope.js +405 -0
- package/dist/transport/http-envelope.js.map +1 -0
- package/dist/transport/http-routed.d.ts +61 -0
- package/dist/transport/http-routed.d.ts.map +1 -0
- package/dist/transport/http-routed.js +409 -0
- package/dist/transport/http-routed.js.map +1 -0
- package/dist/transport/index.d.ts +8 -0
- package/dist/transport/index.d.ts.map +1 -0
- package/dist/transport/index.js +6 -0
- package/dist/transport/index.js.map +1 -0
- package/dist/transport/request-id.d.ts +9 -0
- package/dist/transport/request-id.d.ts.map +1 -0
- package/dist/transport/request-id.js +12 -0
- package/dist/transport/request-id.js.map +1 -0
- package/dist/transport/ws-envelope.d.ts +74 -0
- package/dist/transport/ws-envelope.d.ts.map +1 -0
- package/dist/transport/ws-envelope.js +560 -0
- package/dist/transport/ws-envelope.js.map +1 -0
- package/dist/util/race-signal.d.ts +12 -0
- package/dist/util/race-signal.d.ts.map +1 -0
- package/dist/util/race-signal.js +34 -0
- package/dist/util/race-signal.js.map +1 -0
- package/dist/wire/controller.d.ts +38 -0
- package/dist/wire/controller.d.ts.map +1 -0
- package/dist/wire/controller.js +38 -0
- package/dist/wire/controller.js.map +1 -0
- package/dist/wire/index.d.ts +7 -0
- package/dist/wire/index.d.ts.map +1 -0
- package/dist/wire/index.js +4 -0
- package/dist/wire/index.js.map +1 -0
- package/dist/wire/meta.d.ts +81 -0
- package/dist/wire/meta.d.ts.map +1 -0
- package/dist/wire/meta.js +44 -0
- package/dist/wire/meta.js.map +1 -0
- package/dist/wire/sse.d.ts +67 -0
- package/dist/wire/sse.d.ts.map +1 -0
- package/dist/wire/sse.js +170 -0
- package/dist/wire/sse.js.map +1 -0
- package/package.json +104 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type-level helpers for the kernel envelope HTTP batch endpoint.
|
|
3
|
+
*
|
|
4
|
+
* Batches are envelope-only — the routed transport has no batching and
|
|
5
|
+
* throws `UnsupportedTransportError`.
|
|
6
|
+
*/
|
|
7
|
+
import type { CallFns, FnMap, SendResult } from './fn-map';
|
|
8
|
+
/** A batch request entry constrained to known call functions in M. */
|
|
9
|
+
export type TypedBatchRequest<M extends FnMap, K extends CallFns<M> = CallFns<M>> = {
|
|
10
|
+
[Path in K]: {
|
|
11
|
+
method: Path;
|
|
12
|
+
params: M[Path]['params'];
|
|
13
|
+
};
|
|
14
|
+
}[K];
|
|
15
|
+
/**
|
|
16
|
+
* Map a tuple of batch requests to a tuple of per-item results. Each
|
|
17
|
+
* entry is either a discriminated `SendResult<M[K]['result']>` (which
|
|
18
|
+
* may be a value or a redirect) or a thrown `Error` — never a mix
|
|
19
|
+
* inside a single position.
|
|
20
|
+
*/
|
|
21
|
+
export type BatchResults<M extends FnMap, Reqs extends readonly TypedBatchRequest<M>[]> = {
|
|
22
|
+
[I in keyof Reqs]: Reqs[I] extends {
|
|
23
|
+
method: infer K extends string;
|
|
24
|
+
} ? K extends keyof M ? SendResult<M[K]['result']> | Error : SendResult<unknown> | Error : SendResult<unknown> | Error;
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=batch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../../src/client/batch.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE1D,sEAAsE;AACtE,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,KAAK,EAAE,CAAC,SAAS,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI;KACjF,IAAI,IAAI,CAAC,GAAG;QAAE,MAAM,EAAE,IAAI,CAAC;QAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAA;KAAE;CACzD,CAAC,CAAC,CAAC,CAAA;AAEJ;;;;;GAKG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,KAAK,EAAE,IAAI,SAAS,SAAS,iBAAiB,CAAC,CAAC,CAAC,EAAE,IAAI;KACvF,CAAC,IAAI,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,SAAS;QAAE,MAAM,EAAE,MAAM,CAAC,SAAS,MAAM,CAAA;KAAE,GACjE,CAAC,SAAS,MAAM,CAAC,GACf,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,GAAG,KAAK,GAClC,UAAU,CAAC,OAAO,CAAC,GAAG,KAAK,GAC7B,UAAU,CAAC,OAAO,CAAC,GAAG,KAAK;CAChC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch.js","sourceRoot":"","sources":["../../src/client/batch.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { CredentialInput } from '@astrale-os/kernel-core';
|
|
2
|
+
import type { Schema } from '@astrale-os/kernel-dsl';
|
|
3
|
+
import type { SchemaTypedClient } from '../schema/proxy-types';
|
|
4
|
+
import type { BatchResults, TypedBatchRequest } from './batch';
|
|
5
|
+
import type { KernelClient } from './client';
|
|
6
|
+
import type { CallOptions } from './config';
|
|
7
|
+
import type { BinaryFns, CallFns, FnMap, SendBinaryResult, SendResult, SendStreamResult, SignalFns, StreamFns } from './fn-map';
|
|
8
|
+
/**
|
|
9
|
+
* Credential-bound view over a `KernelClient`. Plain value — not a class.
|
|
10
|
+
* Created by `client.as(credential)`. Each method delegates to the
|
|
11
|
+
* underlying client, currying the credential in.
|
|
12
|
+
*
|
|
13
|
+
* A credential supplier function is also accepted; it's invoked once per
|
|
14
|
+
* call, so rotated credentials flow through without recreating the view.
|
|
15
|
+
*/
|
|
16
|
+
export type BoundClientView<M extends FnMap> = {
|
|
17
|
+
readonly url: string;
|
|
18
|
+
send<K extends CallFns<M>>(method: K, params: M[K]['params'], opts?: CallOptions): Promise<SendResult<M[K]['result']>>;
|
|
19
|
+
sendStream<K extends StreamFns<M>>(method: K, params: M[K]['params'], opts?: CallOptions): Promise<SendStreamResult<M[K]['result']>>;
|
|
20
|
+
sendBinary<K extends BinaryFns<M>>(method: K, params: M[K]['params'], opts?: CallOptions): Promise<SendBinaryResult>;
|
|
21
|
+
signal<K extends SignalFns<M>>(method: K, params: M[K]['params'], opts?: CallOptions): void;
|
|
22
|
+
batch<const Reqs extends readonly TypedBatchRequest<M>[]>(requests: [...Reqs], opts?: CallOptions): Promise<BatchResults<M, Reqs>>;
|
|
23
|
+
withSchema<S extends Schema>(schema: S): SchemaTypedClient<S>;
|
|
24
|
+
as(credential: CredentialInput | (() => CredentialInput)): BoundClientView<M>;
|
|
25
|
+
};
|
|
26
|
+
export declare function createBoundClientView<M extends FnMap>(client: KernelClient<M>, credential: CredentialInput | (() => CredentialInput)): BoundClientView<M>;
|
|
27
|
+
//# sourceMappingURL=bound.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bound.d.ts","sourceRoot":"","sources":["../../src/client/bound.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAEpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAC3C,OAAO,KAAK,EACV,SAAS,EACT,OAAO,EACP,KAAK,EACL,gBAAgB,EAChB,UAAU,EACV,gBAAgB,EAChB,SAAS,EACT,SAAS,EACV,MAAM,UAAU,CAAA;AAEjB;;;;;;;GAOG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,KAAK,IAAI;IAC7C,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,CAAC,SAAS,OAAO,CAAC,CAAC,CAAC,EACvB,MAAM,EAAE,CAAC,EACT,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EACtB,IAAI,CAAC,EAAE,WAAW,GACjB,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;IAC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CAAC,GACpD,eAAe,CAAC,CAAC,CAAC,CAYpB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function createBoundClientView(client, credential) {
|
|
2
|
+
const cred = () => (typeof credential === 'function' ? credential() : credential);
|
|
3
|
+
return {
|
|
4
|
+
url: client.url,
|
|
5
|
+
send: (method, params, opts) => client.send(method, params, cred(), opts),
|
|
6
|
+
sendStream: (method, params, opts) => client.sendStream(method, params, cred(), opts),
|
|
7
|
+
sendBinary: (method, params, opts) => client.sendBinary(method, params, cred(), opts),
|
|
8
|
+
signal: (method, params, opts) => client.signal(method, params, cred(), opts),
|
|
9
|
+
batch: (requests, opts) => client.batch(requests, cred(), opts),
|
|
10
|
+
withSchema: (schema) => client.withSchema(schema, cred),
|
|
11
|
+
as: (next) => createBoundClientView(client, next),
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=bound.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bound.js","sourceRoot":"","sources":["../../src/client/bound.ts"],"names":[],"mappings":"AAoDA,MAAM,UAAU,qBAAqB,CACnC,MAAuB,EACvB,UAAqD;IAErD,MAAM,IAAI,GAAG,GAAoB,EAAE,CAAC,CAAC,OAAO,UAAU,KAAK,UAAU,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAA;IAClG,OAAO;QACL,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,IAAI,CAAC;QACzE,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,IAAI,CAAC;QACrF,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,IAAI,CAAC;QACrF,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,IAAI,CAAC;QAC7E,KAAK,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,IAAI,CAAC;QAC/D,UAAU,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC;QACvD,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,qBAAqB,CAAC,MAAM,EAAE,IAAI,CAAC;KAClD,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { CredentialInput } from '@astrale-os/kernel-core';
|
|
2
|
+
import type { Schema } from '@astrale-os/kernel-dsl';
|
|
3
|
+
import type { SchemaTypedClient } from '../schema/proxy-types';
|
|
4
|
+
import type { FunctionSchema } from '../schema/types';
|
|
5
|
+
import type { BatchResults, TypedBatchRequest } from './batch';
|
|
6
|
+
import type { BoundClientView } from './bound';
|
|
7
|
+
import type { CallOptions, ClientConfig } from './config';
|
|
8
|
+
import type { BinaryFns, CallFns, FnMap, SendBinaryResult, SendResult, SendStreamResult, SignalFns, StreamFns } from './fn-map';
|
|
9
|
+
/**
|
|
10
|
+
* KernelClient — one URL, one kernel. Discriminated `Send*Result`s,
|
|
11
|
+
* no auto-follow, no cross-host pool, no transport fallback. Identity
|
|
12
|
+
* is opaque — the client forwards credentials onto the wire and never
|
|
13
|
+
* inspects, compares, or rotates them.
|
|
14
|
+
*
|
|
15
|
+
* Four facets:
|
|
16
|
+
* - Lean primitives: `send` / `sendStream` / `sendBinary` / `signal` /
|
|
17
|
+
* `batch` — surface transport outcomes as-is, no orchestration.
|
|
18
|
+
* - Identity views: `as(credential)` returns a `BoundClientView` that
|
|
19
|
+
* curries the credential into every call. A value, not a class.
|
|
20
|
+
* - Schema proxy: `withSchema(schema)` returns a schema-typed proxy
|
|
21
|
+
* that throws `UNHANDLED_REDIRECT` on redirect (use `send` for
|
|
22
|
+
* redirect-aware calls).
|
|
23
|
+
* - Lifecycle: `disconnect()` releases held resources (open WS).
|
|
24
|
+
*/
|
|
25
|
+
export declare class KernelClient<M extends FnMap = FnMap> {
|
|
26
|
+
readonly url: string;
|
|
27
|
+
private readonly defaultTimeout;
|
|
28
|
+
private readonly defaultTransport;
|
|
29
|
+
private readonly defaultProtocol;
|
|
30
|
+
private readonly hooks;
|
|
31
|
+
private readonly codec;
|
|
32
|
+
private readonly schema;
|
|
33
|
+
private readonly httpEnvelope;
|
|
34
|
+
private readonly httpRouted;
|
|
35
|
+
private readonly wsFactory;
|
|
36
|
+
private readonly logger;
|
|
37
|
+
private ws;
|
|
38
|
+
private wsState;
|
|
39
|
+
constructor(config: ClientConfig);
|
|
40
|
+
send<K extends CallFns<M>>(method: K, params: M[K]['params'], credential: CredentialInput, opts?: CallOptions): Promise<SendResult<M[K]['result']>>;
|
|
41
|
+
sendStream<K extends StreamFns<M>>(method: K, params: M[K]['params'], credential: CredentialInput, opts?: CallOptions): Promise<SendStreamResult<M[K]['result']>>;
|
|
42
|
+
sendBinary<K extends BinaryFns<M>>(method: K, params: M[K]['params'], credential: CredentialInput, opts?: CallOptions): Promise<SendBinaryResult>;
|
|
43
|
+
signal<K extends SignalFns<M>>(method: K, params: M[K]['params'], credential: CredentialInput, opts?: CallOptions): void;
|
|
44
|
+
batch<const Reqs extends readonly TypedBatchRequest<M>[]>(requests: [...Reqs], credential: CredentialInput, opts?: CallOptions): Promise<BatchResults<M, Reqs>>;
|
|
45
|
+
as(credential: CredentialInput | (() => CredentialInput)): BoundClientView<M>;
|
|
46
|
+
/**
|
|
47
|
+
* Return a schema-typed proxy. `defaultCredential` — used by
|
|
48
|
+
* `BoundClientView.withSchema` — supplies a credential when the
|
|
49
|
+
* per-call `ProxyCallOptions.credential` is absent. Unbound callers
|
|
50
|
+
* that provide neither send a no-auth request; the server decides
|
|
51
|
+
* whether that's valid (per §9.0.1 the client treats credentials as
|
|
52
|
+
* opaque and never pre-judges them).
|
|
53
|
+
*/
|
|
54
|
+
withSchema<S extends Schema>(schema: S, defaultCredential?: () => CredentialInput): SchemaTypedClient<S>;
|
|
55
|
+
describe(method: string): FunctionSchema | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Release any held resources (open WebSocket). Idempotent. The client
|
|
58
|
+
* stays reusable — a subsequent `send(...)` lazily re-opens a fresh
|
|
59
|
+
* WebSocket if the default or per-call transport selects `'ws'`. Resets
|
|
60
|
+
* the `'auto'` probe state so the next call re-probes.
|
|
61
|
+
*/
|
|
62
|
+
disconnect(): void;
|
|
63
|
+
private lookupSchema;
|
|
64
|
+
/**
|
|
65
|
+
* Resolve the transport instance + request shape for this call.
|
|
66
|
+
* `canFallback` signals to `dispatchUnary` that a WS `ConnectionError`
|
|
67
|
+
* on this attempt should retry on HTTP (auto-mode probe only).
|
|
68
|
+
*/
|
|
69
|
+
private selectTransport;
|
|
70
|
+
/**
|
|
71
|
+
* Resolve `CallTransport` to a concrete envelope pipe. Binary is always
|
|
72
|
+
* HTTP (server-side WS binary unimplemented). In `'auto'+unknown`, signal
|
|
73
|
+
* stays on HTTP — fire-and-forget can't communicate fallback.
|
|
74
|
+
*/
|
|
75
|
+
private resolveEnvelopePipe;
|
|
76
|
+
private envelopeWs;
|
|
77
|
+
private buildEnvelopeRequest;
|
|
78
|
+
private buildRoutedRequest;
|
|
79
|
+
private dispatchUnary;
|
|
80
|
+
private dispatchOnce;
|
|
81
|
+
private beforeCtx;
|
|
82
|
+
private instrumentStream;
|
|
83
|
+
private runHooks;
|
|
84
|
+
/**
|
|
85
|
+
* Log a hook-layer failure. Only the error's name + message are
|
|
86
|
+
* surfaced — the error may chain a `cause` that captured a credential
|
|
87
|
+
* or other sensitive ref by closure, and the client never leaks those
|
|
88
|
+
* per §9.0.1. Consumers who need full diagnostics provide a
|
|
89
|
+
* `logger` with their own redaction policy.
|
|
90
|
+
*/
|
|
91
|
+
private logHookError;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAIpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAErD,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAyC,MAAM,UAAU,CAAA;AAChG,OAAO,KAAK,EACV,SAAS,EACT,OAAO,EACP,KAAK,EACL,gBAAgB,EAChB,UAAU,EACV,gBAAgB,EAChB,SAAS,EACT,SAAS,EACV,MAAM,UAAU,CAAA;AAwBjB;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,YAAY,CAAC,CAAC,SAAS,KAAK,GAAG,KAAK;IAC/C,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAQ;IACvC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAe;IAChD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAU;IAC1C,OAAO,CAAC,QAAQ,CAAC,KAAK,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KernelError, WebOSError, withDetails, } from '../errors/errors';
|
|
3
|
+
import { SchemaRegistry } from '../schema/registry';
|
|
4
|
+
import { createSchemaClient } from '../schema/typed-client';
|
|
5
|
+
import { HttpEnvelopeTransport, HttpRoutedTransport, WsEnvelopeTransport, } from '../transport';
|
|
6
|
+
import { DEFAULT_REQUEST_TIMEOUT_MS } from '../wire/meta';
|
|
7
|
+
import { createBoundClientView } from './bound';
|
|
8
|
+
import { freezeResult } from './freeze';
|
|
9
|
+
/**
|
|
10
|
+
* KernelClient — one URL, one kernel. Discriminated `Send*Result`s,
|
|
11
|
+
* no auto-follow, no cross-host pool, no transport fallback. Identity
|
|
12
|
+
* is opaque — the client forwards credentials onto the wire and never
|
|
13
|
+
* inspects, compares, or rotates them.
|
|
14
|
+
*
|
|
15
|
+
* Four facets:
|
|
16
|
+
* - Lean primitives: `send` / `sendStream` / `sendBinary` / `signal` /
|
|
17
|
+
* `batch` — surface transport outcomes as-is, no orchestration.
|
|
18
|
+
* - Identity views: `as(credential)` returns a `BoundClientView` that
|
|
19
|
+
* curries the credential into every call. A value, not a class.
|
|
20
|
+
* - Schema proxy: `withSchema(schema)` returns a schema-typed proxy
|
|
21
|
+
* that throws `UNHANDLED_REDIRECT` on redirect (use `send` for
|
|
22
|
+
* redirect-aware calls).
|
|
23
|
+
* - Lifecycle: `disconnect()` releases held resources (open WS).
|
|
24
|
+
*/
|
|
25
|
+
export class KernelClient {
|
|
26
|
+
url;
|
|
27
|
+
defaultTimeout;
|
|
28
|
+
defaultTransport;
|
|
29
|
+
defaultProtocol;
|
|
30
|
+
hooks;
|
|
31
|
+
codec;
|
|
32
|
+
schema;
|
|
33
|
+
httpEnvelope;
|
|
34
|
+
httpRouted;
|
|
35
|
+
wsFactory;
|
|
36
|
+
logger;
|
|
37
|
+
ws = null;
|
|
38
|
+
wsState = 'unknown';
|
|
39
|
+
constructor(config) {
|
|
40
|
+
this.url = config.url.replace(/\/$/, '');
|
|
41
|
+
this.defaultTimeout = config.requestTimeout ?? DEFAULT_REQUEST_TIMEOUT_MS;
|
|
42
|
+
this.defaultTransport = config.defaultTransport ?? 'http';
|
|
43
|
+
this.defaultProtocol = config.defaultProtocol ?? 'envelope';
|
|
44
|
+
this.hooks = config.hooks ?? {};
|
|
45
|
+
this.codec = config.codec ?? 'json';
|
|
46
|
+
this.logger = config.logger ?? console;
|
|
47
|
+
// Schema: either an existing registry (shared across clients) or an
|
|
48
|
+
// array we load into a fresh registry. `SchemaRegistry.is` is a duck
|
|
49
|
+
// check — `instanceof` fails across package duplicates / realms.
|
|
50
|
+
if (SchemaRegistry.is(config.schema)) {
|
|
51
|
+
this.schema = config.schema;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
this.schema = new SchemaRegistry();
|
|
55
|
+
if (Array.isArray(config.schema) && config.schema.length > 0) {
|
|
56
|
+
this.schema.load(config.schema);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
this.httpEnvelope = new HttpEnvelopeTransport({
|
|
60
|
+
url: this.url,
|
|
61
|
+
codec: this.codec,
|
|
62
|
+
requestTimeout: this.defaultTimeout,
|
|
63
|
+
retry: config.retry,
|
|
64
|
+
fetch: config.fetch,
|
|
65
|
+
});
|
|
66
|
+
this.httpRouted = new HttpRoutedTransport({
|
|
67
|
+
requestTimeout: this.defaultTimeout,
|
|
68
|
+
fetch: config.fetch,
|
|
69
|
+
});
|
|
70
|
+
this.wsFactory = () => new WsEnvelopeTransport({
|
|
71
|
+
url: this.url,
|
|
72
|
+
codec: this.codec,
|
|
73
|
+
requestTimeout: this.defaultTimeout,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
// ─── Transport primitives ─────────────────────────────────────────────────
|
|
77
|
+
async send(method, params, credential, opts) {
|
|
78
|
+
return this.dispatchUnary('call', method, params, credential, opts);
|
|
79
|
+
}
|
|
80
|
+
async sendStream(method, params, credential, opts) {
|
|
81
|
+
return this.dispatchUnary('stream', method, params, credential, opts);
|
|
82
|
+
}
|
|
83
|
+
async sendBinary(method, params, credential, opts) {
|
|
84
|
+
return this.dispatchUnary('binary', method, params, credential, opts);
|
|
85
|
+
}
|
|
86
|
+
signal(method, params, credential, opts) {
|
|
87
|
+
const schemaEntry = this.lookupSchema(method, opts);
|
|
88
|
+
const { transport, transportReq } = this.selectTransport('signal', method, params, credential, opts, schemaEntry);
|
|
89
|
+
const beforeCtx = this.beforeCtx(method, params, credential, transport.name, transportReq, opts);
|
|
90
|
+
void this.runHooks('onBeforeSend', beforeCtx);
|
|
91
|
+
transport.signal(transportReq);
|
|
92
|
+
void this.runHooks('onAfterSignal', { ...beforeCtx, dispatchedAt: Date.now() });
|
|
93
|
+
}
|
|
94
|
+
async batch(requests, credential, opts) {
|
|
95
|
+
if (requests.length === 0)
|
|
96
|
+
return [];
|
|
97
|
+
// Batch uses the envelope transport — the only path with a
|
|
98
|
+
// multi-request wire shape. Snapshot each entry's schema once so an
|
|
99
|
+
// external registry mutating mid-dispatch doesn't retarget half the
|
|
100
|
+
// batch. Mixing routed-only methods in is a policy error — flag it
|
|
101
|
+
// before any wire work starts.
|
|
102
|
+
const snapshot = requests.map((r) => ({
|
|
103
|
+
method: r.method,
|
|
104
|
+
params: r.params,
|
|
105
|
+
schema: this.lookupSchema(r.method, opts),
|
|
106
|
+
}));
|
|
107
|
+
for (const entry of snapshot) {
|
|
108
|
+
if (isRoutedOnly(entry.schema)) {
|
|
109
|
+
throw new InvalidTransportError(`Method "${entry.method}" has a route binding; batch only supports envelope calls`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const transportRequests = snapshot.map((entry) => this.buildEnvelopeRequest(entry.method, entry.params, credential, opts, entry.schema));
|
|
113
|
+
const entries = await this.httpEnvelope.batch(transportRequests);
|
|
114
|
+
return entries;
|
|
115
|
+
}
|
|
116
|
+
// ─── Identity & schema views ──────────────────────────────────────────────
|
|
117
|
+
as(credential) {
|
|
118
|
+
return createBoundClientView(this, credential);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Return a schema-typed proxy. `defaultCredential` — used by
|
|
122
|
+
* `BoundClientView.withSchema` — supplies a credential when the
|
|
123
|
+
* per-call `ProxyCallOptions.credential` is absent. Unbound callers
|
|
124
|
+
* that provide neither send a no-auth request; the server decides
|
|
125
|
+
* whether that's valid (per §9.0.1 the client treats credentials as
|
|
126
|
+
* opaque and never pre-judges them).
|
|
127
|
+
*/
|
|
128
|
+
withSchema(schema, defaultCredential) {
|
|
129
|
+
return createSchemaClient(async (method, params, credential, opts) => {
|
|
130
|
+
const effective = (credential ?? defaultCredential?.() ?? '');
|
|
131
|
+
const result = await this.send(method, params, effective, opts);
|
|
132
|
+
if (result.kind === 'redirect') {
|
|
133
|
+
// Proxy is value-path only by contract (§9.4). Callers wanting
|
|
134
|
+
// redirect awareness use `client.send` directly.
|
|
135
|
+
const err = new KernelError(`Unhandled redirect: "${method}" resolved to ${result.redirection.url}. ` +
|
|
136
|
+
`Use client.send() to handle redirects explicitly.`, KERNEL_ERROR_CODES.INTERNAL_ERROR, 'UNHANDLED_REDIRECT');
|
|
137
|
+
withDetails(err, {
|
|
138
|
+
method: String(method),
|
|
139
|
+
params,
|
|
140
|
+
url: this.url,
|
|
141
|
+
transport: result.meta.transport,
|
|
142
|
+
correlationId: opts?.correlationId,
|
|
143
|
+
meta: result.meta,
|
|
144
|
+
redirection: result.redirection,
|
|
145
|
+
});
|
|
146
|
+
throw err;
|
|
147
|
+
}
|
|
148
|
+
return result.value;
|
|
149
|
+
}, schema);
|
|
150
|
+
}
|
|
151
|
+
describe(method) {
|
|
152
|
+
return this.schema.get(method);
|
|
153
|
+
}
|
|
154
|
+
// ─── Connection lifecycle ─────────────────────────────────────────────────
|
|
155
|
+
/**
|
|
156
|
+
* Release any held resources (open WebSocket). Idempotent. The client
|
|
157
|
+
* stays reusable — a subsequent `send(...)` lazily re-opens a fresh
|
|
158
|
+
* WebSocket if the default or per-call transport selects `'ws'`. Resets
|
|
159
|
+
* the `'auto'` probe state so the next call re-probes.
|
|
160
|
+
*/
|
|
161
|
+
disconnect() {
|
|
162
|
+
this.ws?.disconnect();
|
|
163
|
+
this.ws = null;
|
|
164
|
+
this.httpEnvelope.disconnect();
|
|
165
|
+
this.httpRouted.disconnect();
|
|
166
|
+
this.wsState = 'unknown';
|
|
167
|
+
}
|
|
168
|
+
// ─── Internals ────────────────────────────────────────────────────────────
|
|
169
|
+
lookupSchema(method, opts) {
|
|
170
|
+
return this.schema.resolve(method, opts?.class) ?? this.schema.get(method);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Resolve the transport instance + request shape for this call.
|
|
174
|
+
* `canFallback` signals to `dispatchUnary` that a WS `ConnectionError`
|
|
175
|
+
* on this attempt should retry on HTTP (auto-mode probe only).
|
|
176
|
+
*/
|
|
177
|
+
selectTransport(kind, method, params, credential, opts, schemaEntry) {
|
|
178
|
+
const requested = opts?.transport ?? this.defaultTransport;
|
|
179
|
+
const protocol = opts?.protocol ?? this.defaultProtocol;
|
|
180
|
+
const binding = schemaEntry?.binding;
|
|
181
|
+
const route = binding?.route;
|
|
182
|
+
const remoteUrl = opts?.url ?? binding?.remoteUrl;
|
|
183
|
+
const preferRoute = protocol === 'auto' && !!route;
|
|
184
|
+
if (preferRoute) {
|
|
185
|
+
if (!remoteUrl) {
|
|
186
|
+
// Binding without remoteUrl is a schema misconfig — caller can
|
|
187
|
+
// still rescue by passing opts.url, but both missing is broken.
|
|
188
|
+
throw new InvalidTransportError(`Method "${method}" declares a route binding but has no remoteUrl; ` +
|
|
189
|
+
`register a schema with binding.remoteUrl or pass opts.url`);
|
|
190
|
+
}
|
|
191
|
+
return {
|
|
192
|
+
transport: this.httpRouted,
|
|
193
|
+
transportReq: this.buildRoutedRequest(method, params, credential, opts, route, remoteUrl),
|
|
194
|
+
canFallback: false,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
const resolved = this.resolveEnvelopePipe(requested, kind);
|
|
198
|
+
return {
|
|
199
|
+
transport: resolved === 'ws' ? this.envelopeWs() : this.httpEnvelope,
|
|
200
|
+
transportReq: this.buildEnvelopeRequest(method, params, credential, opts, schemaEntry),
|
|
201
|
+
canFallback: requested === 'auto' && resolved === 'ws' && this.wsState === 'unknown',
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Resolve `CallTransport` to a concrete envelope pipe. Binary is always
|
|
206
|
+
* HTTP (server-side WS binary unimplemented). In `'auto'+unknown`, signal
|
|
207
|
+
* stays on HTTP — fire-and-forget can't communicate fallback.
|
|
208
|
+
*/
|
|
209
|
+
resolveEnvelopePipe(requested, kind) {
|
|
210
|
+
if (kind === 'binary')
|
|
211
|
+
return 'http';
|
|
212
|
+
if (requested === 'http')
|
|
213
|
+
return 'http';
|
|
214
|
+
if (requested === 'ws')
|
|
215
|
+
return 'ws';
|
|
216
|
+
if (this.wsState === 'unavailable')
|
|
217
|
+
return 'http';
|
|
218
|
+
if (this.wsState === 'proven')
|
|
219
|
+
return 'ws';
|
|
220
|
+
return kind === 'signal' ? 'http' : 'ws';
|
|
221
|
+
}
|
|
222
|
+
envelopeWs() {
|
|
223
|
+
if (!this.ws)
|
|
224
|
+
this.ws = this.wsFactory();
|
|
225
|
+
return this.ws;
|
|
226
|
+
}
|
|
227
|
+
buildEnvelopeRequest(method, params, credential, opts, schemaEntry) {
|
|
228
|
+
const binding = schemaEntry?.binding;
|
|
229
|
+
const remoteUrl = opts?.url ?? binding?.remoteUrl;
|
|
230
|
+
const url = remoteUrl && params && typeof params === 'object'
|
|
231
|
+
? substituteTemplate(remoteUrl, params)
|
|
232
|
+
: remoteUrl;
|
|
233
|
+
return {
|
|
234
|
+
method,
|
|
235
|
+
params,
|
|
236
|
+
credential,
|
|
237
|
+
timeout: opts?.timeout ?? this.defaultTimeout,
|
|
238
|
+
signal: opts?.signal,
|
|
239
|
+
correlationId: opts?.correlationId,
|
|
240
|
+
url,
|
|
241
|
+
...(opts?.self !== undefined && { self: opts.self }),
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
buildRoutedRequest(method, params, credential, opts, route, remoteUrl) {
|
|
245
|
+
return {
|
|
246
|
+
method,
|
|
247
|
+
params: params ?? {},
|
|
248
|
+
credential,
|
|
249
|
+
timeout: opts?.timeout ?? this.defaultTimeout,
|
|
250
|
+
signal: opts?.signal,
|
|
251
|
+
correlationId: opts?.correlationId,
|
|
252
|
+
route,
|
|
253
|
+
remoteUrl,
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Unary dispatch (call / stream / binary). Selects transport, fires
|
|
258
|
+
* `onBeforeSend`, awaits the transport, freezes the result (deeply,
|
|
259
|
+
* including `meta.wire`), wraps streams in the observability
|
|
260
|
+
* iterator, fires `onAfterReceive`, and decorates errors with
|
|
261
|
+
* `ClientErrorDetails` if the transport didn't already.
|
|
262
|
+
*/
|
|
263
|
+
async dispatchUnary(kind, method, params, credential, opts) {
|
|
264
|
+
const schemaEntry = this.lookupSchema(method, opts);
|
|
265
|
+
const selection = this.selectTransport(kind, method, params, credential, opts, schemaEntry);
|
|
266
|
+
try {
|
|
267
|
+
return await this.dispatchOnce(kind, method, params, credential, opts, selection, !selection.canFallback);
|
|
268
|
+
}
|
|
269
|
+
catch (err) {
|
|
270
|
+
if (selection.canFallback && err instanceof ConnectionError) {
|
|
271
|
+
this.wsState = 'unavailable';
|
|
272
|
+
const httpSel = this.selectTransport(kind, method, params, credential, opts, schemaEntry);
|
|
273
|
+
return this.dispatchOnce(kind, method, params, credential, opts, httpSel, true);
|
|
274
|
+
}
|
|
275
|
+
throw err;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* One dispatch attempt: hooks + wire + freeze. `fireErrorHook = false`
|
|
280
|
+
* suppresses `onError` so a recovered auto-mode WS probe failure doesn't
|
|
281
|
+
* surface as a phantom error when the fallback HTTP call succeeds.
|
|
282
|
+
*/
|
|
283
|
+
async dispatchOnce(kind, method, params, credential, opts, selection, fireErrorHook) {
|
|
284
|
+
const { transport, transportReq } = selection;
|
|
285
|
+
const beforeCtx = this.beforeCtx(method, params, credential, transport.name, transportReq, opts);
|
|
286
|
+
await this.runHooks('onBeforeSend', beforeCtx);
|
|
287
|
+
try {
|
|
288
|
+
const raw = kind === 'call'
|
|
289
|
+
? await transport.call(transportReq)
|
|
290
|
+
: kind === 'stream'
|
|
291
|
+
? await transport.stream(transportReq)
|
|
292
|
+
: await transport.binary(transportReq);
|
|
293
|
+
if (transport.name === 'ws-envelope' && this.wsState === 'unknown') {
|
|
294
|
+
this.wsState = 'proven';
|
|
295
|
+
}
|
|
296
|
+
// For streams, wrap `chunks` in the instrumented iterable BEFORE
|
|
297
|
+
// freezing — hook and caller must see the same iterable so a hook
|
|
298
|
+
// that iterates doesn't steal frames from the caller.
|
|
299
|
+
const toFreeze = raw.kind === 'stream' && this.hooks.onStreamFrame
|
|
300
|
+
? {
|
|
301
|
+
...raw,
|
|
302
|
+
chunks: this.instrumentStream(raw.chunks, beforeCtx, raw.meta),
|
|
303
|
+
}
|
|
304
|
+
: raw;
|
|
305
|
+
const frozen = freezeResult(toFreeze);
|
|
306
|
+
await this.runHooks('onAfterReceive', {
|
|
307
|
+
...beforeCtx,
|
|
308
|
+
result: frozen,
|
|
309
|
+
meta: frozen.meta,
|
|
310
|
+
});
|
|
311
|
+
return frozen;
|
|
312
|
+
}
|
|
313
|
+
catch (err) {
|
|
314
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
315
|
+
if (error instanceof WebOSError && !error.details) {
|
|
316
|
+
withDetails(error, {
|
|
317
|
+
method,
|
|
318
|
+
params,
|
|
319
|
+
url: transport.url ?? this.url,
|
|
320
|
+
transport: transport.name,
|
|
321
|
+
correlationId: opts?.correlationId,
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
if (fireErrorHook) {
|
|
325
|
+
await this.runHooks('onError', {
|
|
326
|
+
...beforeCtx,
|
|
327
|
+
error,
|
|
328
|
+
meta: error.details?.meta,
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
throw error;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
beforeCtx(method, params, credential, transport, transportReq, opts) {
|
|
335
|
+
return {
|
|
336
|
+
method,
|
|
337
|
+
params,
|
|
338
|
+
credential,
|
|
339
|
+
transport,
|
|
340
|
+
url: transportReq.url ?? this.url,
|
|
341
|
+
correlationId: opts?.correlationId,
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Wrap a stream iterable so each chunk fires `onStreamFrame`. Errors
|
|
346
|
+
* during hook evaluation are swallowed per the hook contract (pure
|
|
347
|
+
* observation); a hook that misbehaves never aborts the stream.
|
|
348
|
+
*/
|
|
349
|
+
async *instrumentStream(chunks, beforeCtx, meta) {
|
|
350
|
+
let index = 0;
|
|
351
|
+
for await (const data of chunks) {
|
|
352
|
+
if (this.hooks.onStreamFrame) {
|
|
353
|
+
try {
|
|
354
|
+
await this.hooks.onStreamFrame({ ...beforeCtx, index, data, meta });
|
|
355
|
+
}
|
|
356
|
+
catch (err) {
|
|
357
|
+
this.logHookError('onStreamFrame', err);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
index++;
|
|
361
|
+
yield data;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
async runHooks(key, ctx) {
|
|
365
|
+
const hook = this.hooks[key];
|
|
366
|
+
if (!hook)
|
|
367
|
+
return;
|
|
368
|
+
try {
|
|
369
|
+
await hook(ctx);
|
|
370
|
+
}
|
|
371
|
+
catch (err) {
|
|
372
|
+
this.logHookError(key, err);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Log a hook-layer failure. Only the error's name + message are
|
|
377
|
+
* surfaced — the error may chain a `cause` that captured a credential
|
|
378
|
+
* or other sensitive ref by closure, and the client never leaks those
|
|
379
|
+
* per §9.0.1. Consumers who need full diagnostics provide a
|
|
380
|
+
* `logger` with their own redaction policy.
|
|
381
|
+
*/
|
|
382
|
+
logHookError(key, err) {
|
|
383
|
+
const e = err instanceof Error ? err : new Error(String(err));
|
|
384
|
+
this.logger.error(`[kernel-client] hook "${key}" threw: ${e.name}: ${e.message}`);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
function isRoutedOnly(schema) {
|
|
388
|
+
if (!schema)
|
|
389
|
+
return false;
|
|
390
|
+
const binding = schema.binding;
|
|
391
|
+
return !!binding?.route;
|
|
392
|
+
}
|
|
393
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAoB/E,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,WAAW,EACX,UAAU,EACV,WAAW,GACZ,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAC3D,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,GAIpB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAA;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAEvC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,YAAY;IACd,GAAG,CAAQ;IACH,cAAc,CAAQ;IACtB,gBAAgB,CAAe;IAC/B,eAAe,CAAU;IACzB,KAAK,CAAa;IAClB,KAAK,CAAoB;IACzB,MAAM,CAAgB;IACtB,YAAY,CAAuB;IACnC,UAAU,CAAqB;IAC/B,SAAS,CAA2B;IACpC,MAAM,CAAc;IAC7B,EAAE,GAA+B,IAAI,CAAA;IACrC,OAA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