@moltzap/client 2026.503.3 → 2026.504.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/auth.d.ts +10 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +8 -5
- package/dist/auth.js.map +1 -1
- package/dist/channel-core.d.ts +1 -4
- package/dist/channel-core.d.ts.map +1 -1
- package/dist/channel-core.js +0 -9
- package/dist/channel-core.js.map +1 -1
- package/dist/channel-core.test.js +90 -71
- package/dist/channel-core.test.js.map +1 -1
- package/dist/cli/commands/agents.d.ts.map +1 -1
- package/dist/cli/commands/agents.js +5 -3
- package/dist/cli/commands/agents.js.map +1 -1
- package/dist/cli/commands/apps.d.ts +9 -27
- package/dist/cli/commands/apps.d.ts.map +1 -1
- package/dist/cli/commands/apps.js +36 -57
- package/dist/cli/commands/apps.js.map +1 -1
- package/dist/cli/commands/apps.test.js +63 -75
- package/dist/cli/commands/apps.test.js.map +1 -1
- package/dist/cli/commands/contacts.d.ts +1 -5
- package/dist/cli/commands/contacts.d.ts.map +1 -1
- package/dist/cli/commands/contacts.js +14 -27
- package/dist/cli/commands/contacts.js.map +1 -1
- package/dist/cli/commands/conversations-v2.test.js +34 -29
- package/dist/cli/commands/conversations-v2.test.js.map +1 -1
- package/dist/cli/commands/conversations.d.ts +7 -3
- package/dist/cli/commands/conversations.d.ts.map +1 -1
- package/dist/cli/commands/conversations.js +63 -48
- package/dist/cli/commands/conversations.js.map +1 -1
- package/dist/cli/commands/messages.d.ts +7 -3
- package/dist/cli/commands/messages.d.ts.map +1 -1
- package/dist/cli/commands/messages.js +13 -15
- package/dist/cli/commands/messages.js.map +1 -1
- package/dist/cli/commands/messages.test.js +30 -31
- package/dist/cli/commands/messages.test.js.map +1 -1
- package/dist/cli/commands/ping.d.ts +9 -0
- package/dist/cli/commands/ping.d.ts.map +1 -1
- package/dist/cli/commands/ping.js +17 -4
- package/dist/cli/commands/ping.js.map +1 -1
- package/dist/cli/commands/presence.d.ts.map +1 -1
- package/dist/cli/commands/presence.js +6 -4
- package/dist/cli/commands/presence.js.map +1 -1
- package/dist/cli/commands/register.d.ts.map +1 -1
- package/dist/cli/commands/register.js +2 -1
- package/dist/cli/commands/register.js.map +1 -1
- package/dist/cli/commands/send.d.ts.map +1 -1
- package/dist/cli/commands/send.js +22 -11
- package/dist/cli/commands/send.js.map +1 -1
- package/dist/cli/commands/send.test.js +12 -9
- package/dist/cli/commands/send.test.js.map +1 -1
- package/dist/cli/commands/status.js +2 -2
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/test-transport.d.ts +10 -0
- package/dist/cli/commands/test-transport.d.ts.map +1 -0
- package/dist/cli/commands/test-transport.js +29 -0
- package/dist/cli/commands/test-transport.js.map +1 -0
- package/dist/cli/commands/whoami.d.ts.map +1 -1
- package/dist/cli/commands/whoami.js +5 -1
- package/dist/cli/commands/whoami.js.map +1 -1
- package/dist/cli/config.d.ts +42 -6
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +91 -27
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/http-client.d.ts +11 -1
- package/dist/cli/http-client.d.ts.map +1 -1
- package/dist/cli/http-client.js +13 -4
- package/dist/cli/http-client.js.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +2 -3
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/profile.d.ts +3 -4
- package/dist/cli/profile.d.ts.map +1 -1
- package/dist/cli/profile.js +42 -29
- package/dist/cli/profile.js.map +1 -1
- package/dist/cli/runtime.d.ts.map +1 -1
- package/dist/cli/runtime.js +9 -4
- package/dist/cli/runtime.js.map +1 -1
- package/dist/cli/socket-client.d.ts +29 -4
- package/dist/cli/socket-client.d.ts.map +1 -1
- package/dist/cli/socket-client.js +52 -21
- package/dist/cli/socket-client.js.map +1 -1
- package/dist/cli/transport.d.ts +6 -9
- package/dist/cli/transport.d.ts.map +1 -1
- package/dist/cli/transport.js +47 -37
- package/dist/cli/transport.js.map +1 -1
- package/dist/cli/transport.test.js +19 -16
- package/dist/cli/transport.test.js.map +1 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/__tests__/app-callback-partition-key.test.d.ts +2 -0
- package/dist/internal/__tests__/app-callback-partition-key.test.d.ts.map +1 -0
- package/dist/internal/__tests__/app-callback-partition-key.test.js +33 -0
- package/dist/internal/__tests__/app-callback-partition-key.test.js.map +1 -0
- package/dist/internal/__tests__/app-callback-partition-worker.test.d.ts +2 -0
- package/dist/internal/__tests__/app-callback-partition-worker.test.d.ts.map +1 -0
- package/dist/internal/__tests__/{s2c-partition-worker.test.js → app-callback-partition-worker.test.js} +6 -8
- package/dist/internal/__tests__/app-callback-partition-worker.test.js.map +1 -0
- package/dist/internal/__tests__/app-callback-partitioned-dispatcher-real-ws.test.d.ts +2 -0
- package/dist/internal/__tests__/app-callback-partitioned-dispatcher-real-ws.test.d.ts.map +1 -0
- package/dist/internal/__tests__/{s2c-partitioned-dispatcher-real-ws.test.js → app-callback-partitioned-dispatcher-real-ws.test.js} +69 -93
- package/dist/internal/__tests__/app-callback-partitioned-dispatcher-real-ws.test.js.map +1 -0
- package/dist/internal/__tests__/app-callback-partitioned-dispatcher.test.d.ts +2 -0
- package/dist/internal/__tests__/app-callback-partitioned-dispatcher.test.d.ts.map +1 -0
- package/dist/internal/__tests__/{s2c-partitioned-dispatcher.test.js → app-callback-partitioned-dispatcher.test.js} +36 -69
- package/dist/internal/__tests__/app-callback-partitioned-dispatcher.test.js.map +1 -0
- package/dist/internal/__tests__/app-callback-test-requests.d.ts +58 -0
- package/dist/internal/__tests__/app-callback-test-requests.d.ts.map +1 -0
- package/dist/internal/__tests__/app-callback-test-requests.js +124 -0
- package/dist/internal/__tests__/app-callback-test-requests.js.map +1 -0
- package/dist/internal/{s2c-dispatcher-errors.d.ts → app-callback-dispatcher-errors.d.ts} +5 -21
- package/dist/internal/app-callback-dispatcher-errors.d.ts.map +1 -0
- package/dist/internal/{s2c-dispatcher-errors.js → app-callback-dispatcher-errors.js} +3 -13
- package/dist/internal/app-callback-dispatcher-errors.js.map +1 -0
- package/dist/internal/app-callback-partition-key.d.ts +68 -0
- package/dist/internal/app-callback-partition-key.d.ts.map +1 -0
- package/dist/internal/app-callback-partition-key.js +90 -0
- package/dist/internal/app-callback-partition-key.js.map +1 -0
- package/dist/internal/{s2c-partition-worker.d.ts → app-callback-partition-worker.d.ts} +5 -5
- package/dist/internal/app-callback-partition-worker.d.ts.map +1 -0
- package/dist/internal/{s2c-partition-worker.js → app-callback-partition-worker.js} +5 -5
- package/dist/internal/app-callback-partition-worker.js.map +1 -0
- package/dist/internal/{s2c-partitioned-dispatcher.d.ts → app-callback-partitioned-dispatcher.d.ts} +9 -10
- package/dist/internal/app-callback-partitioned-dispatcher.d.ts.map +1 -0
- package/dist/internal/{s2c-partitioned-dispatcher.js → app-callback-partitioned-dispatcher.js} +13 -21
- package/dist/internal/app-callback-partitioned-dispatcher.js.map +1 -0
- package/dist/runtime/close-info.d.ts +15 -16
- package/dist/runtime/close-info.d.ts.map +1 -1
- package/dist/runtime/close-info.js +12 -8
- package/dist/runtime/close-info.js.map +1 -1
- package/dist/runtime/errors.d.ts +2 -28
- package/dist/runtime/errors.d.ts.map +1 -1
- package/dist/runtime/errors.js +0 -9
- package/dist/runtime/errors.js.map +1 -1
- package/dist/runtime/errors.test.js +4 -3
- package/dist/runtime/errors.test.js.map +1 -1
- package/dist/runtime/frame.d.ts +17 -18
- package/dist/runtime/frame.d.ts.map +1 -1
- package/dist/runtime/frame.js +86 -31
- package/dist/runtime/frame.js.map +1 -1
- package/dist/runtime/frame.test.js +15 -11
- package/dist/runtime/frame.test.js.map +1 -1
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +1 -1
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/local-service-commands.d.ts +7 -0
- package/dist/runtime/local-service-commands.d.ts.map +1 -0
- package/dist/runtime/local-service-commands.js +6 -0
- package/dist/runtime/local-service-commands.js.map +1 -0
- package/dist/runtime/runtime.test.js +3 -3
- package/dist/runtime/runtime.test.js.map +1 -1
- package/dist/runtime/subscribers.d.ts +37 -33
- package/dist/runtime/subscribers.d.ts.map +1 -1
- package/dist/runtime/subscribers.js +22 -21
- package/dist/runtime/subscribers.js.map +1 -1
- package/dist/runtime/subscribers.test.js +50 -31
- package/dist/runtime/subscribers.test.js.map +1 -1
- package/dist/service.d.ts +24 -39
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +190 -171
- package/dist/service.js.map +1 -1
- package/dist/service.test.js +117 -175
- package/dist/service.test.js.map +1 -1
- package/dist/test/index.d.ts +9 -1
- package/dist/test/index.d.ts.map +1 -1
- package/dist/test/index.js +14 -3
- package/dist/test/index.js.map +1 -1
- package/dist/test-utils/channel-service-fixture.d.ts +1 -2
- package/dist/test-utils/channel-service-fixture.d.ts.map +1 -1
- package/dist/test-utils/channel-service-fixture.js +28 -20
- package/dist/test-utils/channel-service-fixture.js.map +1 -1
- package/dist/test-utils/conformance-adapter.d.ts +2 -2
- package/dist/test-utils/conformance-adapter.d.ts.map +1 -1
- package/dist/test-utils/conformance-adapter.js +78 -54
- package/dist/test-utils/conformance-adapter.js.map +1 -1
- package/dist/test-utils/fake-service.d.ts +14 -39
- package/dist/test-utils/fake-service.d.ts.map +1 -1
- package/dist/test-utils/fake-service.js +33 -39
- package/dist/test-utils/fake-service.js.map +1 -1
- package/dist/test-utils/ids.d.ts +9 -0
- package/dist/test-utils/ids.d.ts.map +1 -0
- package/dist/test-utils/ids.js +52 -0
- package/dist/test-utils/ids.js.map +1 -0
- package/dist/test-utils/index.d.ts +10 -2
- package/dist/test-utils/index.d.ts.map +1 -1
- package/dist/test-utils/index.js +25 -9
- package/dist/test-utils/index.js.map +1 -1
- package/dist/ws-client.d.ts +59 -64
- package/dist/ws-client.d.ts.map +1 -1
- package/dist/ws-client.js +228 -175
- package/dist/ws-client.js.map +1 -1
- package/dist/ws-client.test.js +190 -176
- package/dist/ws-client.test.js.map +1 -1
- package/package.json +3 -3
- package/dist/cli/commands/permissions.d.ts +0 -66
- package/dist/cli/commands/permissions.d.ts.map +0 -1
- package/dist/cli/commands/permissions.js +0 -101
- package/dist/cli/commands/permissions.js.map +0 -1
- package/dist/cli/commands/permissions.test.d.ts +0 -2
- package/dist/cli/commands/permissions.test.d.ts.map +0 -1
- package/dist/cli/commands/permissions.test.js +0 -126
- package/dist/cli/commands/permissions.test.js.map +0 -1
- package/dist/internal/__tests__/s2c-partition-key.test.d.ts +0 -2
- package/dist/internal/__tests__/s2c-partition-key.test.d.ts.map +0 -1
- package/dist/internal/__tests__/s2c-partition-key.test.js +0 -230
- package/dist/internal/__tests__/s2c-partition-key.test.js.map +0 -1
- package/dist/internal/__tests__/s2c-partition-worker.test.d.ts +0 -2
- package/dist/internal/__tests__/s2c-partition-worker.test.d.ts.map +0 -1
- package/dist/internal/__tests__/s2c-partition-worker.test.js.map +0 -1
- package/dist/internal/__tests__/s2c-partitioned-dispatcher-real-ws.test.d.ts +0 -2
- package/dist/internal/__tests__/s2c-partitioned-dispatcher-real-ws.test.d.ts.map +0 -1
- package/dist/internal/__tests__/s2c-partitioned-dispatcher-real-ws.test.js.map +0 -1
- package/dist/internal/__tests__/s2c-partitioned-dispatcher.test.d.ts +0 -2
- package/dist/internal/__tests__/s2c-partitioned-dispatcher.test.d.ts.map +0 -1
- package/dist/internal/__tests__/s2c-partitioned-dispatcher.test.js.map +0 -1
- package/dist/internal/s2c-dispatcher-errors.d.ts.map +0 -1
- package/dist/internal/s2c-dispatcher-errors.js.map +0 -1
- package/dist/internal/s2c-partition-key.d.ts +0 -71
- package/dist/internal/s2c-partition-key.d.ts.map +0 -1
- package/dist/internal/s2c-partition-key.js +0 -140
- package/dist/internal/s2c-partition-key.js.map +0 -1
- package/dist/internal/s2c-partition-worker.d.ts.map +0 -1
- package/dist/internal/s2c-partition-worker.js.map +0 -1
- package/dist/internal/s2c-partitioned-dispatcher.d.ts.map +0 -1
- package/dist/internal/s2c-partitioned-dispatcher.js.map +0 -1
package/dist/ws-client.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
-
import { type
|
|
3
|
-
import { DuplicateServerRpcHandlerError
|
|
4
|
-
import { type
|
|
2
|
+
import { Connect, NotConnectedError, RpcServerError, RpcTimeoutError, type AnyAppCallbackRpcDefinition, type AnyNotificationDefinition, type JsonRpcStringId, type ParamsOf, type ResultOf, type RpcDefinition, type TSchema, type Static } from "@moltzap/protocol";
|
|
3
|
+
import { DuplicateServerRpcHandlerError } from "./runtime/errors.js";
|
|
4
|
+
import { type DecodedNotification } from "./runtime/frame.js";
|
|
5
|
+
import { type NotificationSubscription, type SubscriberHandler, type SubscriptionFilter } from "./runtime/subscribers.js";
|
|
5
6
|
import { type CloseInfo } from "./runtime/close-info.js";
|
|
6
|
-
import { type PartitionedDispatcherConfig } from "./internal/
|
|
7
|
+
import { type PartitionedDispatcherConfig } from "./internal/app-callback-partitioned-dispatcher.js";
|
|
7
8
|
export type { CloseInfo };
|
|
8
9
|
/**
|
|
9
10
|
* Default per-RPC timeout. Exported so tests driving `TestClock` can match
|
|
@@ -13,8 +14,9 @@ export declare const RPC_TIMEOUT_MS = 30000;
|
|
|
13
14
|
export interface RpcCallOptions {
|
|
14
15
|
readonly timeoutMs?: number;
|
|
15
16
|
}
|
|
17
|
+
type ConnectResult = Static<typeof Connect.resultSchema>;
|
|
16
18
|
/**
|
|
17
|
-
*
|
|
19
|
+
* appCallback dispatcher knobs exposed on `MoltZapWsClientOptions`. All optional;
|
|
18
20
|
* defaults from `DEFAULT_PARTITIONED_DISPATCHER_CONFIG`.
|
|
19
21
|
*
|
|
20
22
|
* Spec #356 OQ-3 (`idlePartitionTtlMs`) ships at the architect's
|
|
@@ -23,7 +25,7 @@ export interface RpcCallOptions {
|
|
|
23
25
|
* at peak), so the cap doubles as a per-tenant DoS guard, not a
|
|
24
26
|
* cardinality lever.
|
|
25
27
|
*/
|
|
26
|
-
export type
|
|
28
|
+
export type AppCallbackDispatcherConfig = Partial<PartitionedDispatcherConfig>;
|
|
27
29
|
/**
|
|
28
30
|
* Handler signature for `handleServerRpc`. The handler returns an
|
|
29
31
|
* `Effect<unknown, RpcServerError>` — success values are encoded as the
|
|
@@ -32,15 +34,21 @@ export type S2cDispatcherConfig = Partial<PartitionedDispatcherConfig>;
|
|
|
32
34
|
* generic InternalError reply.
|
|
33
35
|
*
|
|
34
36
|
* The `unknown`/`unknown` parameter and result types are transitional —
|
|
35
|
-
* once Phase 1.1 (B.2) registers admission verbs in `
|
|
36
|
-
* narrows generically against `
|
|
37
|
+
* once Phase 1.1 (B.2) registers admission verbs in `appCallbackRpcMethods`, this
|
|
38
|
+
* narrows generically against `AppCallbackRpcMap[M]`.
|
|
37
39
|
*/
|
|
38
40
|
export interface ServerRpcContext {
|
|
39
|
-
readonly requestId:
|
|
40
|
-
readonly
|
|
41
|
+
readonly requestId: JsonRpcStringId;
|
|
42
|
+
readonly definition: AnyAppCallbackRpcDefinition;
|
|
41
43
|
readonly traceparent?: string;
|
|
42
44
|
}
|
|
43
|
-
export type ServerRpcHandler = (params:
|
|
45
|
+
export type ServerRpcHandler<D extends AnyAppCallbackRpcDefinition = AnyAppCallbackRpcDefinition> = (params: Static<D["paramsSchema"]>, ctx: ServerRpcContext & {
|
|
46
|
+
readonly definition: D;
|
|
47
|
+
}) => Effect.Effect<Static<D["resultSchema"]>, RpcServerError>;
|
|
48
|
+
type AnyDecodedNotification = DecodedNotification<AnyNotificationDefinition>;
|
|
49
|
+
type DecodedNotificationFor<D extends AnyNotificationDefinition> = Extract<AnyDecodedNotification, {
|
|
50
|
+
readonly definition: D;
|
|
51
|
+
}>;
|
|
44
52
|
export interface WsClientLogger {
|
|
45
53
|
info: (...args: unknown[]) => void;
|
|
46
54
|
warn: (...args: unknown[]) => void;
|
|
@@ -56,38 +64,28 @@ export interface MoltZapWsClientOptions {
|
|
|
56
64
|
* arg (OQ-6 rewrite): zero-arg `() => void` callers must migrate to
|
|
57
65
|
* accept (and may ignore) the arg.
|
|
58
66
|
*
|
|
59
|
-
* Migration note (spec #222 OQ-4 rewrite): the previous `
|
|
67
|
+
* Migration note (spec #222 OQ-4 rewrite): the previous `onNotification`
|
|
60
68
|
* callback was deleted in this rewrite. Callers that want to observe
|
|
61
|
-
* every inbound
|
|
62
|
-
* construction;
|
|
69
|
+
* every inbound notification register `client.subscribe({}, handler)` after
|
|
70
|
+
* construction; notifications flow through the per-subscription registry,
|
|
63
71
|
* not through a top-level option.
|
|
64
72
|
*/
|
|
65
73
|
onDisconnect?: (close: CloseInfo) => void;
|
|
66
|
-
onReconnect?: (helloOk:
|
|
74
|
+
onReconnect?: (helloOk: ConnectResult) => void;
|
|
67
75
|
logger?: WsClientLogger;
|
|
68
76
|
/**
|
|
69
|
-
* Spec #356 — partitioned
|
|
77
|
+
* Spec #356 — partitioned appCallback dispatcher knobs. Optional; omitted
|
|
70
78
|
* fields fall back to `DEFAULT_PARTITIONED_DISPATCHER_CONFIG`.
|
|
71
79
|
*/
|
|
72
|
-
|
|
80
|
+
appCallbackDispatcher?: AppCallbackDispatcherConfig;
|
|
73
81
|
}
|
|
74
82
|
/**
|
|
75
|
-
* Return shape of `MoltZapWsClient.sendRpcTracked`.
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* and the response envelope `type` (un-vacuates V5 at
|
|
79
|
-
* `rpc-semantics.ts:103-110`), without leaking `jsonrpc` onto the
|
|
80
|
-
* caller surface.
|
|
81
|
-
*
|
|
82
|
-
* `type` is the literal `"response"` — the only response-frame kind
|
|
83
|
-
* `packages/protocol/src/schema/frames.ts:18` defines — but it is
|
|
84
|
-
* surfaced as an observable value (not a synthesized adapter constant)
|
|
85
|
-
* so the V5 predicate can flip under a mutation that forges a
|
|
86
|
-
* non-response shape.
|
|
83
|
+
* Return shape of `MoltZapWsClient.sendRpcTracked`. Surfaces the outbound
|
|
84
|
+
* request `id` alongside the typed result without leaking the JSON-RPC wire
|
|
85
|
+
* object onto the caller surface.
|
|
87
86
|
*/
|
|
88
87
|
export interface TrackedRpcResponse<R> {
|
|
89
|
-
readonly id:
|
|
90
|
-
readonly type: "response";
|
|
88
|
+
readonly id: JsonRpcStringId;
|
|
91
89
|
readonly result: R;
|
|
92
90
|
}
|
|
93
91
|
/**
|
|
@@ -107,17 +105,15 @@ export declare class MoltZapWsClient {
|
|
|
107
105
|
private readonly pendingRef;
|
|
108
106
|
private readonly stateRef;
|
|
109
107
|
private readonly malformedRef;
|
|
110
|
-
private readonly
|
|
108
|
+
private readonly notificationsBufferRef;
|
|
111
109
|
/**
|
|
112
|
-
* Waiters keyed by
|
|
113
|
-
* pops the most recently registered waiter (the tail).
|
|
114
|
-
* name keeps dispatch O(1) per inbound frame regardless of total
|
|
115
|
-
* outstanding waiters.
|
|
110
|
+
* Waiters keyed by notification descriptor identity. Each bucket is a FIFO
|
|
111
|
+
* stack: delivery pops the most recently registered waiter (the tail).
|
|
116
112
|
*/
|
|
117
|
-
private readonly
|
|
113
|
+
private readonly notificationWaitersRef;
|
|
118
114
|
private readonly runtime;
|
|
119
115
|
/**
|
|
120
|
-
* Per-subscription
|
|
116
|
+
* Per-subscription notification registry. Spec #222 §5.3 (C4 + the
|
|
121
117
|
* `RealClientEventSubscriber.subscribe` filter stub). Constructed
|
|
122
118
|
* synchronously alongside the other Refs; `MoltZapWsClient.subscribe`
|
|
123
119
|
* delegates to it directly.
|
|
@@ -127,9 +123,9 @@ export declare class MoltZapWsClient {
|
|
|
127
123
|
* Per-method handler registry for server-initiated RPCs. Survives
|
|
128
124
|
* reconnects so apps register once and re-attach automatically when the
|
|
129
125
|
* socket comes back. Each entry is invoked by the per-connection
|
|
130
|
-
* dispatcher fiber when an
|
|
126
|
+
* dispatcher fiber when an appCallback request frame arrives.
|
|
131
127
|
*/
|
|
132
|
-
private readonly
|
|
128
|
+
private readonly appCallbackHandlersRef;
|
|
133
129
|
private requestCounter;
|
|
134
130
|
private closed;
|
|
135
131
|
private reconnectFiber;
|
|
@@ -145,42 +141,40 @@ export declare class MoltZapWsClient {
|
|
|
145
141
|
*
|
|
146
142
|
* The dispatcher fiber forked at `connect()` time picks up handlers via
|
|
147
143
|
* `Ref.get` per-frame, so a registration made BEFORE `connect()` is
|
|
148
|
-
* visible to the very first inbound
|
|
144
|
+
* visible to the very first inbound appCallback request, and a registration
|
|
149
145
|
* made AFTER `connect()` takes effect on the next inbound frame.
|
|
150
146
|
*/
|
|
151
|
-
handleServerRpc(
|
|
152
|
-
get helloOk():
|
|
147
|
+
handleServerRpc<D extends AnyAppCallbackRpcDefinition>(definition: D, handler: ServerRpcHandler<D>): Effect.Effect<void, DuplicateServerRpcHandlerError>;
|
|
148
|
+
get helloOk(): ConnectResult | null;
|
|
153
149
|
/** Open the socket, perform auth/connect, resolve with HelloOk. Fails
|
|
154
150
|
* immediately on pre-open close or error. */
|
|
155
|
-
connect(): Effect.Effect<
|
|
151
|
+
connect(): Effect.Effect<ConnectResult, NotConnectedError | RpcTimeoutError | RpcServerError>;
|
|
156
152
|
/**
|
|
157
153
|
* Send an RPC. Fails with a typed error:
|
|
158
154
|
* - `NotConnectedError` if the socket isn't OPEN or closes mid-RPC
|
|
159
155
|
* - `RpcTimeoutError` after `RPC_TIMEOUT_MS` — no automatic retry
|
|
160
156
|
* - `RpcServerError` on a typed server-error frame
|
|
161
157
|
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
158
|
+
* Descriptor-backed RPC call. Callers pass the protocol descriptor, and the
|
|
159
|
+
* client extracts the wire method only inside the encoder path.
|
|
164
160
|
*/
|
|
165
|
-
sendRpc<D extends RpcDefinition<string, TSchema, TSchema>>(
|
|
166
|
-
sendRpc(method: string, params?: unknown, opts?: RpcCallOptions): Effect.Effect<unknown, NotConnectedError | RpcTimeoutError | RpcServerError>;
|
|
161
|
+
sendRpc<D extends RpcDefinition<string, TSchema, TSchema>>(definition: D, params: ParamsOf<D>, opts?: RpcCallOptions): Effect.Effect<ResultOf<D>, NotConnectedError | RpcTimeoutError | RpcServerError>;
|
|
167
162
|
/**
|
|
168
163
|
* Send an RPC and surface the outbound request id alongside the
|
|
169
164
|
* response envelope `type` and `result`. Spec #222 §5.1–5.2:
|
|
170
165
|
* un-vacuates B4 (request-id tracking) and V5 (response-type
|
|
171
|
-
* exposure). Mirrors `sendRpc`'s
|
|
166
|
+
* exposure). Mirrors `sendRpc`'s descriptor-backed call shape.
|
|
172
167
|
*
|
|
173
168
|
* Invariant 3 (spec #222 §4): the returned `id` is the same identity
|
|
174
169
|
* minted inside the existing `rpc-${++counter}` site — no parallel
|
|
175
170
|
* counter, no mirror. The single-id pre-condition is what makes B4 a
|
|
176
171
|
* real check rather than a tautology.
|
|
177
172
|
*/
|
|
178
|
-
sendRpcTracked<D extends RpcDefinition<string, TSchema, TSchema>>(
|
|
179
|
-
sendRpcTracked(method: string, params?: unknown): Effect.Effect<TrackedRpcResponse<unknown>, NotConnectedError | RpcTimeoutError | RpcServerError>;
|
|
173
|
+
sendRpcTracked<D extends RpcDefinition<string, TSchema, TSchema>>(definition: D, params: ParamsOf<D>): Effect.Effect<TrackedRpcResponse<ResultOf<D>>, NotConnectedError | RpcTimeoutError | RpcServerError>;
|
|
180
174
|
/**
|
|
181
|
-
* Register a per-subscription
|
|
175
|
+
* Register a per-subscription notification handler. Spec #222 §5.3 + OQ-2
|
|
182
176
|
* (A): filter grammar is the three-field `SubscriptionFilter`
|
|
183
|
-
* (`emissionTag` / `conversationId` / `
|
|
177
|
+
* (`emissionTag` / `conversationId` / `notificationNamePrefix`). Returns a
|
|
184
178
|
* handle whose `unsubscribe` Effect drops delivery starting with the
|
|
185
179
|
* next inbound frame (OQ-3 A snapshot semantics).
|
|
186
180
|
*
|
|
@@ -189,7 +183,7 @@ export declare class MoltZapWsClient {
|
|
|
189
183
|
* producing frames. Fails with `NotConnectedError` only if the client
|
|
190
184
|
* has been permanently torn down via `close()`.
|
|
191
185
|
*/
|
|
192
|
-
subscribe(filter: SubscriptionFilter, handler: SubscriberHandler): Effect.Effect<
|
|
186
|
+
subscribe(filter: SubscriptionFilter, handler: SubscriberHandler): Effect.Effect<NotificationSubscription, NotConnectedError>;
|
|
193
187
|
/**
|
|
194
188
|
* Close the socket permanently (no reconnection). Writes a clean WebSocket
|
|
195
189
|
* close frame (code 1000) before tearing down the scope so the server
|
|
@@ -197,12 +191,12 @@ export declare class MoltZapWsClient {
|
|
|
197
191
|
* lingering CLOSE_WAIT sockets on the server side.
|
|
198
192
|
*/
|
|
199
193
|
close(): Effect.Effect<void, never>;
|
|
200
|
-
/** Wait for the next inbound
|
|
194
|
+
/** Wait for the next inbound notification matching `definition`.
|
|
201
195
|
* Consumes a buffered match if present; otherwise awaits the next match
|
|
202
196
|
* with a per-call timeout. */
|
|
203
|
-
|
|
204
|
-
/** Return all buffered
|
|
205
|
-
|
|
197
|
+
waitForNotification<D extends AnyNotificationDefinition>(definition: D, timeoutMs?: number): Effect.Effect<DecodedNotificationFor<D>, Error>;
|
|
198
|
+
/** Return all buffered notifications and clear the buffer. Synchronous. */
|
|
199
|
+
drainNotifications(): DecodedNotification[];
|
|
206
200
|
/** Close the socket without marking as permanently closed, triggering reconnection. */
|
|
207
201
|
disconnect(): Effect.Effect<void, never>;
|
|
208
202
|
private disconnectSync;
|
|
@@ -210,7 +204,7 @@ export declare class MoltZapWsClient {
|
|
|
210
204
|
/**
|
|
211
205
|
* Tracked variant of `sendRpcEffect`. Reuses the same Deferred /
|
|
212
206
|
* pendingRef plumbing — the only difference is the resolved value:
|
|
213
|
-
* `{id,
|
|
207
|
+
* `{id, result}` instead of bare `result`. This
|
|
214
208
|
* keeps Invariant 3 (single id source) trivially: we mint `id` once
|
|
215
209
|
* inside this body, register the Deferred under that id, and return
|
|
216
210
|
* the same id to the caller alongside the result.
|
|
@@ -235,8 +229,9 @@ export declare class MoltZapWsClient {
|
|
|
235
229
|
* new tag fails the compile here.
|
|
236
230
|
*/
|
|
237
231
|
private writeOfferRejection;
|
|
232
|
+
private offerRejectedResponse;
|
|
238
233
|
/**
|
|
239
|
-
* Dispatch one inbound
|
|
234
|
+
* Dispatch one inbound appCallback request to the registered handler, encode
|
|
240
235
|
* the response, and write it back to the server. Errors are projected
|
|
241
236
|
* onto an error response so the server's `Deferred.await` always
|
|
242
237
|
* settles deterministically — never hangs on a missing or crashing
|
|
@@ -251,11 +246,11 @@ export declare class MoltZapWsClient {
|
|
|
251
246
|
* - No handler registered → encode MethodNotFound error response.
|
|
252
247
|
*/
|
|
253
248
|
private dispatchInboundServerRequest;
|
|
254
|
-
/** Route an inbound frame. Malformed frames are logged + dropped;
|
|
255
|
-
* frames dispatch to `
|
|
249
|
+
/** Route an inbound frame. Malformed frames are logged + dropped; notification
|
|
250
|
+
* frames dispatch to `onNotification` after the shape check. */
|
|
256
251
|
private handleIncoming;
|
|
257
|
-
/** Fail every outstanding
|
|
258
|
-
private
|
|
252
|
+
/** Fail every outstanding notification waiter with `message` and clear the map. */
|
|
253
|
+
private failAllNotificationWaiters;
|
|
259
254
|
private failAllPending;
|
|
260
255
|
/** Schedule a reconnect attempt. Jittered exponential backoff (1s base,
|
|
261
256
|
* 30s cap) routed through `Effect.sleep` so `TestClock` can drive it. */
|
package/dist/ws-client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ws-client.d.ts","sourceRoot":"","sources":["../src/ws-client.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"ws-client.d.ts","sourceRoot":"","sources":["../src/ws-client.ts"],"names":[],"mappings":"AAEA,OAAO,EAML,MAAM,EASP,MAAM,QAAQ,CAAC;AAChB,OAAO,EAEL,OAAO,EAGP,iBAAiB,EAGjB,cAAc,EACd,eAAe,EACf,KAAK,2BAA2B,EAChC,KAAK,yBAAyB,EAC9B,KAAK,eAAe,EACpB,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