@replit/river 0.205.2 → 0.207.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-FCN2JPOE.js → chunk-7LMZNSVC.js} +2 -2
- package/dist/{chunk-BYA34LH3.js → chunk-BCCZA7SX.js} +14 -27
- package/dist/chunk-BCCZA7SX.js.map +1 -0
- package/dist/{chunk-W337YQLT.js → chunk-CRD3HDVN.js} +3 -3
- package/dist/{chunk-TP4OJAKI.js → chunk-I27WBSMZ.js} +3 -3
- package/dist/{chunk-FTOB2HQN.js → chunk-QMAVXV4Z.js} +8 -3
- package/dist/chunk-QMAVXV4Z.js.map +1 -0
- package/dist/{connection-8ed39cb5.d.ts → connection-933c87b2.d.ts} +2 -2
- package/dist/logging/index.d.cts +1 -1
- package/dist/logging/index.d.ts +1 -1
- package/dist/{message-865bba35.d.ts → message-ffacb98a.d.ts} +1 -1
- package/dist/router/index.cjs +15 -29
- package/dist/router/index.cjs.map +1 -1
- package/dist/router/index.d.cts +5 -8
- package/dist/router/index.d.ts +5 -8
- package/dist/router/index.js +2 -4
- package/dist/{services-036dcc97.d.ts → services-4cd29829.d.ts} +731 -16
- package/dist/testUtil/index.cjs +7 -2
- package/dist/testUtil/index.cjs.map +1 -1
- package/dist/testUtil/index.d.cts +3 -5
- package/dist/testUtil/index.d.ts +3 -5
- package/dist/testUtil/index.js +4 -4
- package/dist/transport/impls/ws/client.cjs +7 -2
- package/dist/transport/impls/ws/client.cjs.map +1 -1
- package/dist/transport/impls/ws/client.d.cts +3 -4
- package/dist/transport/impls/ws/client.d.ts +3 -4
- package/dist/transport/impls/ws/client.js +4 -4
- package/dist/transport/impls/ws/server.cjs +7 -2
- package/dist/transport/impls/ws/server.cjs.map +1 -1
- package/dist/transport/impls/ws/server.d.cts +4 -4
- package/dist/transport/impls/ws/server.d.ts +4 -4
- package/dist/transport/impls/ws/server.js +4 -4
- package/dist/transport/index.cjs +7 -2
- package/dist/transport/index.cjs.map +1 -1
- package/dist/transport/index.d.cts +72 -5
- package/dist/transport/index.d.ts +72 -5
- package/dist/transport/index.js +4 -4
- package/package.json +1 -1
- package/dist/chunk-BYA34LH3.js.map +0 -1
- package/dist/chunk-FTOB2HQN.js.map +0 -1
- package/dist/client-8ab60722.d.ts +0 -54
- package/dist/context-2c4bb66b.d.ts +0 -670
- package/dist/server-dc261419.d.ts +0 -70
- /package/dist/{chunk-FCN2JPOE.js.map → chunk-7LMZNSVC.js.map} +0 -0
- /package/dist/{chunk-W337YQLT.js.map → chunk-CRD3HDVN.js.map} +0 -0
- /package/dist/{chunk-TP4OJAKI.js.map → chunk-I27WBSMZ.js.map} +0 -0
|
@@ -1,8 +1,627 @@
|
|
|
1
1
|
import * as _sinclair_typebox from '@sinclair/typebox';
|
|
2
|
-
import { TObject, TString,
|
|
3
|
-
import {
|
|
4
|
-
import { c as TransportClientId } from './message-
|
|
5
|
-
import { C as
|
|
2
|
+
import { Static, TSchema, TObject, TString, TUnion, TLiteral, TNever } from '@sinclair/typebox';
|
|
3
|
+
import { Tracer, Span } from '@opentelemetry/api';
|
|
4
|
+
import { c as TelemetryInfo, M as MessageMetadata, T as TransportClientId, L as Logger, O as OpaqueTransportMessage, P as ProtocolVersion, b as PartialTransportMessage, d as TransportMessage, a as Tags, H as HandshakeErrorResponseCodes, e as LogFn, f as LoggingLevel, g as HandshakeErrorCustomHandlerFatalResponseCodes } from './message-ffacb98a.js';
|
|
5
|
+
import { C as Codec } from './types-3e5768ec.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A connection is the actual raw underlying transport connection.
|
|
9
|
+
* It’s responsible for dispatching to/from the actual connection itself
|
|
10
|
+
* This should be instantiated as soon as the client/server has a connection
|
|
11
|
+
* It’s tied to the lifecycle of the underlying transport connection (i.e. if the WS drops, this connection should be deleted)
|
|
12
|
+
*/
|
|
13
|
+
declare abstract class Connection {
|
|
14
|
+
id: string;
|
|
15
|
+
telemetry?: TelemetryInfo;
|
|
16
|
+
constructor();
|
|
17
|
+
get loggingMetadata(): MessageMetadata;
|
|
18
|
+
private _dataListeners;
|
|
19
|
+
private _closeListeners;
|
|
20
|
+
private _errorListeners;
|
|
21
|
+
get dataListeners(): ((msg: Uint8Array) => void)[];
|
|
22
|
+
get closeListeners(): (() => void)[];
|
|
23
|
+
get errorListeners(): ((err: Error) => void)[];
|
|
24
|
+
onData(msg: Uint8Array): void;
|
|
25
|
+
onError(err: Error): void;
|
|
26
|
+
onClose(): void;
|
|
27
|
+
/**
|
|
28
|
+
* Handle adding a callback for when a message is received.
|
|
29
|
+
* @param msg The message that was received.
|
|
30
|
+
*/
|
|
31
|
+
addDataListener(cb: (msg: Uint8Array) => void): void;
|
|
32
|
+
removeDataListener(cb: (msg: Uint8Array) => void): void;
|
|
33
|
+
/**
|
|
34
|
+
* Handle adding a callback for when the connection is closed.
|
|
35
|
+
* This should also be called if an error happens and after notifying all the error listeners.
|
|
36
|
+
* @param cb The callback to call when the connection is closed.
|
|
37
|
+
*/
|
|
38
|
+
addCloseListener(cb: () => void): void;
|
|
39
|
+
removeCloseListener(cb: () => void): void;
|
|
40
|
+
/**
|
|
41
|
+
* Handle adding a callback for when an error is received.
|
|
42
|
+
* This should only be used for this.logging errors, all cleanup
|
|
43
|
+
* should be delegated to addCloseListener.
|
|
44
|
+
*
|
|
45
|
+
* The implementer should take care such that the implemented
|
|
46
|
+
* connection will call both the close and error callbacks
|
|
47
|
+
* on an error.
|
|
48
|
+
*
|
|
49
|
+
* @param cb The callback to call when an error is received.
|
|
50
|
+
*/
|
|
51
|
+
addErrorListener(cb: (err: Error) => void): void;
|
|
52
|
+
removeErrorListener(cb: (err: Error) => void): void;
|
|
53
|
+
/**
|
|
54
|
+
* Sends a message over the connection.
|
|
55
|
+
* @param msg The message to send.
|
|
56
|
+
* @returns true if the message was sent, false otherwise.
|
|
57
|
+
*/
|
|
58
|
+
abstract send(msg: Uint8Array): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Closes the connection.
|
|
61
|
+
*/
|
|
62
|
+
abstract close(): void;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
declare const enum SessionState {
|
|
66
|
+
NoConnection = "NoConnection",
|
|
67
|
+
BackingOff = "BackingOff",
|
|
68
|
+
Connecting = "Connecting",
|
|
69
|
+
Handshaking = "Handshaking",
|
|
70
|
+
Connected = "Connected",
|
|
71
|
+
WaitingForHandshake = "WaitingForHandshake"
|
|
72
|
+
}
|
|
73
|
+
declare abstract class StateMachineState {
|
|
74
|
+
abstract readonly state: SessionState;
|
|
75
|
+
_isConsumed: boolean;
|
|
76
|
+
abstract _handleStateExit(): void;
|
|
77
|
+
abstract _handleClose(): void;
|
|
78
|
+
/**
|
|
79
|
+
* Cleanup this state machine state and mark it as consumed.
|
|
80
|
+
* After calling close, it is an error to access any properties on the state.
|
|
81
|
+
* You should never need to call this as a consumer.
|
|
82
|
+
*
|
|
83
|
+
* If you're looking to close the session from the client,
|
|
84
|
+
* use `.hardDisconnect` on the client transport.
|
|
85
|
+
*/
|
|
86
|
+
close(): void;
|
|
87
|
+
constructor();
|
|
88
|
+
}
|
|
89
|
+
interface SessionOptions {
|
|
90
|
+
/**
|
|
91
|
+
* Frequency at which to send heartbeat acknowledgements
|
|
92
|
+
*/
|
|
93
|
+
heartbeatIntervalMs: number;
|
|
94
|
+
/**
|
|
95
|
+
* Number of elapsed heartbeats without a response message before we consider
|
|
96
|
+
* the connection dead.
|
|
97
|
+
*/
|
|
98
|
+
heartbeatsUntilDead: number;
|
|
99
|
+
/**
|
|
100
|
+
* Max duration that a session can be without a connection before we consider
|
|
101
|
+
* it dead. This deadline is carried between states and is used to determine
|
|
102
|
+
* when to consider the session a lost cause and delete it entirely.
|
|
103
|
+
* Generally, this should be strictly greater than the sum of
|
|
104
|
+
* {@link connectionTimeoutMs} and {@link handshakeTimeoutMs}.
|
|
105
|
+
*/
|
|
106
|
+
sessionDisconnectGraceMs: number;
|
|
107
|
+
/**
|
|
108
|
+
* Connection timeout in milliseconds
|
|
109
|
+
*/
|
|
110
|
+
connectionTimeoutMs: number;
|
|
111
|
+
/**
|
|
112
|
+
* Handshake timeout in milliseconds
|
|
113
|
+
*/
|
|
114
|
+
handshakeTimeoutMs: number;
|
|
115
|
+
/**
|
|
116
|
+
* Whether to enable transparent session reconnects
|
|
117
|
+
*/
|
|
118
|
+
enableTransparentSessionReconnects: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* The codec to use for encoding/decoding messages over the wire
|
|
121
|
+
*/
|
|
122
|
+
codec: Codec;
|
|
123
|
+
}
|
|
124
|
+
interface CommonSessionProps {
|
|
125
|
+
from: TransportClientId;
|
|
126
|
+
options: SessionOptions;
|
|
127
|
+
tracer: Tracer;
|
|
128
|
+
log: Logger | undefined;
|
|
129
|
+
}
|
|
130
|
+
declare abstract class CommonSession extends StateMachineState {
|
|
131
|
+
readonly from: TransportClientId;
|
|
132
|
+
readonly options: SessionOptions;
|
|
133
|
+
tracer: Tracer;
|
|
134
|
+
log?: Logger;
|
|
135
|
+
abstract get loggingMetadata(): MessageMetadata;
|
|
136
|
+
constructor({ from, options, log, tracer }: CommonSessionProps);
|
|
137
|
+
parseMsg(msg: Uint8Array): OpaqueTransportMessage | null;
|
|
138
|
+
}
|
|
139
|
+
type SessionId = string;
|
|
140
|
+
interface IdentifiedSessionProps extends CommonSessionProps {
|
|
141
|
+
id: SessionId;
|
|
142
|
+
to: TransportClientId;
|
|
143
|
+
seq: number;
|
|
144
|
+
ack: number;
|
|
145
|
+
seqSent: number;
|
|
146
|
+
sendBuffer: Array<OpaqueTransportMessage>;
|
|
147
|
+
telemetry: TelemetryInfo;
|
|
148
|
+
protocolVersion: ProtocolVersion;
|
|
149
|
+
}
|
|
150
|
+
declare abstract class IdentifiedSession extends CommonSession {
|
|
151
|
+
readonly id: SessionId;
|
|
152
|
+
readonly telemetry: TelemetryInfo;
|
|
153
|
+
readonly to: TransportClientId;
|
|
154
|
+
readonly protocolVersion: ProtocolVersion;
|
|
155
|
+
/**
|
|
156
|
+
* Index of the message we will send next (excluding handshake)
|
|
157
|
+
*/
|
|
158
|
+
seq: number;
|
|
159
|
+
/**
|
|
160
|
+
* Last seq we sent over the wire this session (excluding handshake) and retransmissions
|
|
161
|
+
*/
|
|
162
|
+
seqSent: number;
|
|
163
|
+
/**
|
|
164
|
+
* Number of unique messages we've received this session (excluding handshake)
|
|
165
|
+
*/
|
|
166
|
+
ack: number;
|
|
167
|
+
sendBuffer: Array<OpaqueTransportMessage>;
|
|
168
|
+
constructor(props: IdentifiedSessionProps);
|
|
169
|
+
get loggingMetadata(): MessageMetadata;
|
|
170
|
+
constructMsg<Payload>(partialMsg: PartialTransportMessage<Payload>): TransportMessage<Payload>;
|
|
171
|
+
nextSeq(): number;
|
|
172
|
+
send(msg: PartialTransportMessage): string;
|
|
173
|
+
_handleStateExit(): void;
|
|
174
|
+
_handleClose(): void;
|
|
175
|
+
}
|
|
176
|
+
interface IdentifiedSessionWithGracePeriodListeners {
|
|
177
|
+
onSessionGracePeriodElapsed: () => void;
|
|
178
|
+
}
|
|
179
|
+
interface IdentifiedSessionWithGracePeriodProps extends IdentifiedSessionProps {
|
|
180
|
+
graceExpiryTime: number;
|
|
181
|
+
listeners: IdentifiedSessionWithGracePeriodListeners;
|
|
182
|
+
}
|
|
183
|
+
declare abstract class IdentifiedSessionWithGracePeriod extends IdentifiedSession {
|
|
184
|
+
graceExpiryTime: number;
|
|
185
|
+
protected gracePeriodTimeout?: ReturnType<typeof setTimeout>;
|
|
186
|
+
listeners: IdentifiedSessionWithGracePeriodListeners;
|
|
187
|
+
constructor(props: IdentifiedSessionWithGracePeriodProps);
|
|
188
|
+
_handleStateExit(): void;
|
|
189
|
+
_handleClose(): void;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
interface SessionConnectingListeners extends IdentifiedSessionWithGracePeriodListeners {
|
|
193
|
+
onConnectionEstablished: (conn: Connection) => void;
|
|
194
|
+
onConnectionFailed: (err: unknown) => void;
|
|
195
|
+
onConnectionTimeout: () => void;
|
|
196
|
+
}
|
|
197
|
+
interface SessionConnectingProps<ConnType extends Connection> extends IdentifiedSessionWithGracePeriodProps {
|
|
198
|
+
connPromise: Promise<ConnType>;
|
|
199
|
+
listeners: SessionConnectingListeners;
|
|
200
|
+
}
|
|
201
|
+
declare class SessionConnecting<ConnType extends Connection> extends IdentifiedSessionWithGracePeriod {
|
|
202
|
+
readonly state: SessionState.Connecting;
|
|
203
|
+
connPromise: Promise<ConnType>;
|
|
204
|
+
listeners: SessionConnectingListeners;
|
|
205
|
+
connectionTimeout?: ReturnType<typeof setTimeout>;
|
|
206
|
+
constructor(props: SessionConnectingProps<ConnType>);
|
|
207
|
+
bestEffortClose(): void;
|
|
208
|
+
_handleStateExit(): void;
|
|
209
|
+
_handleClose(): void;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
declare class SessionNoConnection extends IdentifiedSessionWithGracePeriod {
|
|
213
|
+
readonly state: SessionState.NoConnection;
|
|
214
|
+
_handleClose(): void;
|
|
215
|
+
_handleStateExit(): void;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
interface SessionHandshakingListeners extends IdentifiedSessionWithGracePeriodListeners {
|
|
219
|
+
onConnectionErrored: (err: unknown) => void;
|
|
220
|
+
onConnectionClosed: () => void;
|
|
221
|
+
onHandshake: (msg: OpaqueTransportMessage) => void;
|
|
222
|
+
onInvalidHandshake: (reason: string, code: Static<typeof HandshakeErrorResponseCodes>) => void;
|
|
223
|
+
onHandshakeTimeout: () => void;
|
|
224
|
+
}
|
|
225
|
+
interface SessionHandshakingProps<ConnType extends Connection> extends IdentifiedSessionWithGracePeriodProps {
|
|
226
|
+
conn: ConnType;
|
|
227
|
+
listeners: SessionHandshakingListeners;
|
|
228
|
+
}
|
|
229
|
+
declare class SessionHandshaking<ConnType extends Connection> extends IdentifiedSessionWithGracePeriod {
|
|
230
|
+
readonly state: SessionState.Handshaking;
|
|
231
|
+
conn: ConnType;
|
|
232
|
+
listeners: SessionHandshakingListeners;
|
|
233
|
+
handshakeTimeout?: ReturnType<typeof setTimeout>;
|
|
234
|
+
constructor(props: SessionHandshakingProps<ConnType>);
|
|
235
|
+
get loggingMetadata(): {
|
|
236
|
+
protocolVersion?: ProtocolVersion | undefined;
|
|
237
|
+
clientId?: string | undefined;
|
|
238
|
+
connectedTo?: string | undefined;
|
|
239
|
+
sessionId?: string | undefined;
|
|
240
|
+
connId?: string | undefined;
|
|
241
|
+
transportMessage?: Partial<OpaqueTransportMessage> | undefined;
|
|
242
|
+
validationErrors?: {
|
|
243
|
+
path: string;
|
|
244
|
+
message: string;
|
|
245
|
+
}[] | undefined;
|
|
246
|
+
tags?: Tags[] | undefined;
|
|
247
|
+
telemetry?: {
|
|
248
|
+
traceId: string;
|
|
249
|
+
spanId: string;
|
|
250
|
+
} | undefined;
|
|
251
|
+
extras?: Record<string, unknown> | undefined;
|
|
252
|
+
};
|
|
253
|
+
onHandshakeData: (msg: Uint8Array) => void;
|
|
254
|
+
sendHandshake(msg: TransportMessage): boolean;
|
|
255
|
+
_handleStateExit(): void;
|
|
256
|
+
_handleClose(): void;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
interface SessionConnectedListeners {
|
|
260
|
+
onConnectionErrored: (err: unknown) => void;
|
|
261
|
+
onConnectionClosed: () => void;
|
|
262
|
+
onMessage: (msg: OpaqueTransportMessage) => void;
|
|
263
|
+
onInvalidMessage: (reason: string) => void;
|
|
264
|
+
}
|
|
265
|
+
interface SessionConnectedProps<ConnType extends Connection> extends IdentifiedSessionProps {
|
|
266
|
+
conn: ConnType;
|
|
267
|
+
listeners: SessionConnectedListeners;
|
|
268
|
+
}
|
|
269
|
+
declare class SessionConnected<ConnType extends Connection> extends IdentifiedSession {
|
|
270
|
+
readonly state: SessionState.Connected;
|
|
271
|
+
conn: ConnType;
|
|
272
|
+
listeners: SessionConnectedListeners;
|
|
273
|
+
private heartbeatHandle?;
|
|
274
|
+
private heartbeatMisses;
|
|
275
|
+
isActivelyHeartbeating: boolean;
|
|
276
|
+
updateBookkeeping(ack: number, seq: number): void;
|
|
277
|
+
private assertSendOrdering;
|
|
278
|
+
send(msg: PartialTransportMessage): string;
|
|
279
|
+
constructor(props: SessionConnectedProps<ConnType>);
|
|
280
|
+
get loggingMetadata(): {
|
|
281
|
+
protocolVersion?: ProtocolVersion | undefined;
|
|
282
|
+
clientId?: string | undefined;
|
|
283
|
+
connectedTo?: string | undefined;
|
|
284
|
+
sessionId?: string | undefined;
|
|
285
|
+
connId?: string | undefined;
|
|
286
|
+
transportMessage?: Partial<OpaqueTransportMessage> | undefined;
|
|
287
|
+
validationErrors?: {
|
|
288
|
+
path: string;
|
|
289
|
+
message: string;
|
|
290
|
+
}[] | undefined;
|
|
291
|
+
tags?: Tags[] | undefined;
|
|
292
|
+
telemetry?: {
|
|
293
|
+
traceId: string;
|
|
294
|
+
spanId: string;
|
|
295
|
+
} | undefined;
|
|
296
|
+
extras?: Record<string, unknown> | undefined;
|
|
297
|
+
};
|
|
298
|
+
startActiveHeartbeat(): void;
|
|
299
|
+
private sendHeartbeat;
|
|
300
|
+
closeConnection(): void;
|
|
301
|
+
onMessageData: (msg: Uint8Array) => void;
|
|
302
|
+
_handleStateExit(): void;
|
|
303
|
+
_handleClose(): void;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
interface SessionBackingOffListeners extends IdentifiedSessionWithGracePeriodListeners {
|
|
307
|
+
onBackoffFinished: () => void;
|
|
308
|
+
}
|
|
309
|
+
interface SessionBackingOffProps extends IdentifiedSessionWithGracePeriodProps {
|
|
310
|
+
backoffMs: number;
|
|
311
|
+
listeners: SessionBackingOffListeners;
|
|
312
|
+
}
|
|
313
|
+
declare class SessionBackingOff extends IdentifiedSessionWithGracePeriod {
|
|
314
|
+
readonly state: SessionState.BackingOff;
|
|
315
|
+
listeners: SessionBackingOffListeners;
|
|
316
|
+
backoffTimeout?: ReturnType<typeof setTimeout>;
|
|
317
|
+
constructor(props: SessionBackingOffProps);
|
|
318
|
+
_handleClose(): void;
|
|
319
|
+
_handleStateExit(): void;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
type ClientSession<ConnType extends Connection> = SessionNoConnection | SessionBackingOff | SessionConnecting<ConnType> | SessionHandshaking<ConnType> | SessionConnected<ConnType>;
|
|
323
|
+
type ServerSession<ConnType extends Connection> = SessionConnected<ConnType> | SessionNoConnection;
|
|
324
|
+
type Session<ConnType extends Connection> = ClientSession<ConnType> | ServerSession<ConnType>;
|
|
325
|
+
|
|
326
|
+
declare const ProtocolError: {
|
|
327
|
+
readonly RetriesExceeded: "conn_retry_exceeded";
|
|
328
|
+
readonly HandshakeFailed: "handshake_failed";
|
|
329
|
+
readonly MessageOrderingViolated: "message_ordering_violated";
|
|
330
|
+
readonly InvalidMessage: "invalid_message";
|
|
331
|
+
};
|
|
332
|
+
type ProtocolErrorType = (typeof ProtocolError)[keyof typeof ProtocolError];
|
|
333
|
+
interface EventMap {
|
|
334
|
+
message: OpaqueTransportMessage;
|
|
335
|
+
sessionStatus: {
|
|
336
|
+
status: 'created' | 'closing';
|
|
337
|
+
session: Session<Connection>;
|
|
338
|
+
} | {
|
|
339
|
+
status: 'closed';
|
|
340
|
+
session: Pick<Session<Connection>, 'id' | 'to'>;
|
|
341
|
+
};
|
|
342
|
+
sessionTransition: {
|
|
343
|
+
state: SessionState.Connected;
|
|
344
|
+
id: SessionId;
|
|
345
|
+
} | {
|
|
346
|
+
state: SessionState.Handshaking;
|
|
347
|
+
id: SessionId;
|
|
348
|
+
} | {
|
|
349
|
+
state: SessionState.Connecting;
|
|
350
|
+
id: SessionId;
|
|
351
|
+
} | {
|
|
352
|
+
state: SessionState.BackingOff;
|
|
353
|
+
id: SessionId;
|
|
354
|
+
} | {
|
|
355
|
+
state: SessionState.NoConnection;
|
|
356
|
+
id: SessionId;
|
|
357
|
+
};
|
|
358
|
+
protocolError: {
|
|
359
|
+
type: (typeof ProtocolError)['HandshakeFailed'];
|
|
360
|
+
code: Static<typeof HandshakeErrorResponseCodes>;
|
|
361
|
+
message: string;
|
|
362
|
+
} | {
|
|
363
|
+
type: Omit<ProtocolErrorType, (typeof ProtocolError)['HandshakeFailed']>;
|
|
364
|
+
message: string;
|
|
365
|
+
};
|
|
366
|
+
transportStatus: {
|
|
367
|
+
status: TransportStatus;
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
type EventTypes = keyof EventMap;
|
|
371
|
+
type EventHandler<K extends EventTypes> = (event: EventMap[K]) => unknown;
|
|
372
|
+
declare class EventDispatcher<T extends EventTypes> {
|
|
373
|
+
private eventListeners;
|
|
374
|
+
removeAllListeners(): void;
|
|
375
|
+
numberOfListeners<K extends T>(eventType: K): number;
|
|
376
|
+
addEventListener<K extends T>(eventType: K, handler: EventHandler<K>): void;
|
|
377
|
+
removeEventListener<K extends T>(eventType: K, handler: EventHandler<K>): void;
|
|
378
|
+
dispatchEvent<K extends T>(eventType: K, event: EventMap[K]): void;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Options to control the backoff and retry behavior of the client transport's connection behaviour.
|
|
383
|
+
*
|
|
384
|
+
* River implements exponential backoff with jitter to prevent flooding the server
|
|
385
|
+
* when there's an issue with connection establishment.
|
|
386
|
+
*
|
|
387
|
+
* The backoff is calculated via the following:
|
|
388
|
+
* backOff = min(jitter + {@link baseIntervalMs} * 2 ^ budget_consumed, {@link maxBackoffMs})
|
|
389
|
+
*
|
|
390
|
+
* We use a leaky bucket rate limit with a budget of {@link attemptBudgetCapacity} reconnection attempts.
|
|
391
|
+
* Budget only starts to restore after a successful handshake at a rate of one budget per {@link budgetRestoreIntervalMs}.
|
|
392
|
+
*/
|
|
393
|
+
interface ConnectionRetryOptions {
|
|
394
|
+
/**
|
|
395
|
+
* The base interval to wait before retrying a connection.
|
|
396
|
+
*/
|
|
397
|
+
baseIntervalMs: number;
|
|
398
|
+
/**
|
|
399
|
+
* The maximum random jitter to add to the total backoff time.
|
|
400
|
+
*/
|
|
401
|
+
maxJitterMs: number;
|
|
402
|
+
/**
|
|
403
|
+
* The maximum amount of time to wait before retrying a connection.
|
|
404
|
+
* This does not include the jitter.
|
|
405
|
+
*/
|
|
406
|
+
maxBackoffMs: number;
|
|
407
|
+
/**
|
|
408
|
+
* The max number of times to attempt a connection before a successful handshake.
|
|
409
|
+
* This persists across connections but starts restoring budget after a successful handshake.
|
|
410
|
+
* The restoration interval depends on {@link budgetRestoreIntervalMs}
|
|
411
|
+
*/
|
|
412
|
+
attemptBudgetCapacity: number;
|
|
413
|
+
/**
|
|
414
|
+
* After a successful connection attempt, how long to wait before we restore a single budget.
|
|
415
|
+
*/
|
|
416
|
+
budgetRestoreIntervalMs: number;
|
|
417
|
+
}
|
|
418
|
+
declare class LeakyBucketRateLimit {
|
|
419
|
+
private budgetConsumed;
|
|
420
|
+
private intervalHandle?;
|
|
421
|
+
private readonly options;
|
|
422
|
+
constructor(options: ConnectionRetryOptions);
|
|
423
|
+
getBackoffMs(): number;
|
|
424
|
+
get totalBudgetRestoreTime(): number;
|
|
425
|
+
consumeBudget(): void;
|
|
426
|
+
getBudgetConsumed(): number;
|
|
427
|
+
hasBudget(): boolean;
|
|
428
|
+
startRestoringBudget(): void;
|
|
429
|
+
private stopLeak;
|
|
430
|
+
close(): void;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
type TransportOptions = SessionOptions;
|
|
434
|
+
type ProvidedTransportOptions = Partial<TransportOptions>;
|
|
435
|
+
type ClientTransportOptions = TransportOptions & ConnectionRetryOptions;
|
|
436
|
+
type ProvidedClientTransportOptions = Partial<ClientTransportOptions>;
|
|
437
|
+
type ServerTransportOptions = TransportOptions;
|
|
438
|
+
type ProvidedServerTransportOptions = Partial<ServerTransportOptions>;
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* Represents the possible states of a transport.
|
|
442
|
+
* @property {'open'} open - The transport is open and operational (note that this doesn't mean it is actively connected)
|
|
443
|
+
* @property {'closed'} closed - The transport is permanently closed and cannot be reopened.
|
|
444
|
+
*/
|
|
445
|
+
type TransportStatus = 'open' | 'closed';
|
|
446
|
+
interface DeleteSessionOptions {
|
|
447
|
+
unhealthy: boolean;
|
|
448
|
+
}
|
|
449
|
+
type SessionBoundSendFn = (msg: PartialTransportMessage) => string | undefined;
|
|
450
|
+
/**
|
|
451
|
+
* Transports manage the lifecycle (creation/deletion) of sessions
|
|
452
|
+
*
|
|
453
|
+
* ```plaintext
|
|
454
|
+
* ▲
|
|
455
|
+
* incoming │
|
|
456
|
+
* messages │
|
|
457
|
+
* ▼
|
|
458
|
+
* ┌─────────────┐ 1:N ┌───────────┐ 1:1* ┌────────────┐
|
|
459
|
+
* │ Transport │ ◄─────► │ Session │ ◄─────► │ Connection │
|
|
460
|
+
* └─────────────┘ └───────────┘ └────────────┘
|
|
461
|
+
* ▲ * (may or may not be initialized yet)
|
|
462
|
+
* │
|
|
463
|
+
* ▼
|
|
464
|
+
* ┌───────────┐
|
|
465
|
+
* │ Message │
|
|
466
|
+
* │ Listeners │
|
|
467
|
+
* └───────────┘
|
|
468
|
+
* ```
|
|
469
|
+
* @abstract
|
|
470
|
+
*/
|
|
471
|
+
declare abstract class Transport<ConnType extends Connection> {
|
|
472
|
+
/**
|
|
473
|
+
* The status of the transport.
|
|
474
|
+
*/
|
|
475
|
+
private status;
|
|
476
|
+
/**
|
|
477
|
+
* The client ID of this transport.
|
|
478
|
+
*/
|
|
479
|
+
clientId: TransportClientId;
|
|
480
|
+
/**
|
|
481
|
+
* The event dispatcher for handling events of type EventTypes.
|
|
482
|
+
*/
|
|
483
|
+
eventDispatcher: EventDispatcher<EventTypes>;
|
|
484
|
+
/**
|
|
485
|
+
* The options for this transport.
|
|
486
|
+
*/
|
|
487
|
+
protected options: TransportOptions;
|
|
488
|
+
log?: Logger;
|
|
489
|
+
tracer: Tracer;
|
|
490
|
+
sessions: Map<TransportClientId, Session<ConnType>>;
|
|
491
|
+
/**
|
|
492
|
+
* Creates a new Transport instance.
|
|
493
|
+
* @param codec The codec used to encode and decode messages.
|
|
494
|
+
* @param clientId The client ID of this transport.
|
|
495
|
+
*/
|
|
496
|
+
constructor(clientId: TransportClientId, providedOptions?: ProvidedTransportOptions);
|
|
497
|
+
bindLogger(fn: LogFn | Logger, level?: LoggingLevel): void;
|
|
498
|
+
/**
|
|
499
|
+
* Called when a message is received by this transport.
|
|
500
|
+
* You generally shouldn't need to override this in downstream transport implementations.
|
|
501
|
+
* @param message The received message.
|
|
502
|
+
*/
|
|
503
|
+
protected handleMsg(message: OpaqueTransportMessage): void;
|
|
504
|
+
/**
|
|
505
|
+
* Adds a listener to this transport.
|
|
506
|
+
* @param the type of event to listen for
|
|
507
|
+
* @param handler The message handler to add.
|
|
508
|
+
*/
|
|
509
|
+
addEventListener<K extends EventTypes, T extends EventHandler<K>>(type: K, handler: T): void;
|
|
510
|
+
/**
|
|
511
|
+
* Removes a listener from this transport.
|
|
512
|
+
* @param the type of event to un-listen on
|
|
513
|
+
* @param handler The message handler to remove.
|
|
514
|
+
*/
|
|
515
|
+
removeEventListener<K extends EventTypes, T extends EventHandler<K>>(type: K, handler: T): void;
|
|
516
|
+
protected protocolError(message: EventMap['protocolError']): void;
|
|
517
|
+
/**
|
|
518
|
+
* Default close implementation for transports. You should override this in the downstream
|
|
519
|
+
* implementation if you need to do any additional cleanup and call super.close() at the end.
|
|
520
|
+
* Closes the transport. Any messages sent while the transport is closed will be silently discarded.
|
|
521
|
+
*/
|
|
522
|
+
close(): void;
|
|
523
|
+
getStatus(): TransportStatus;
|
|
524
|
+
protected createSession<S extends Session<ConnType>>(session: S): void;
|
|
525
|
+
protected updateSession<S extends Session<ConnType>>(session: S): void;
|
|
526
|
+
protected deleteSession(session: Session<ConnType>, options?: DeleteSessionOptions): void;
|
|
527
|
+
protected onSessionGracePeriodElapsed(session: Session<ConnType>): void;
|
|
528
|
+
protected onConnectingFailed(session: SessionConnecting<ConnType>): SessionNoConnection;
|
|
529
|
+
protected onConnClosed(session: SessionHandshaking<ConnType> | SessionConnected<ConnType>): SessionNoConnection;
|
|
530
|
+
/**
|
|
531
|
+
* Gets a send closure scoped to a specific session. Sending using the returned
|
|
532
|
+
* closure after the session has transitioned to a different state will be a noop.
|
|
533
|
+
*
|
|
534
|
+
* Session objects themselves can become stale as they transition between
|
|
535
|
+
* states. As stale sessions cannot be used again (and will throw), holding
|
|
536
|
+
* onto a session object is not recommended.
|
|
537
|
+
*/
|
|
538
|
+
getSessionBoundSendFn(to: TransportClientId, sessionId: SessionId): SessionBoundSendFn;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
type ConstructHandshake<T extends TSchema> = () => Static<T> | Promise<Static<T>>;
|
|
542
|
+
type ValidateHandshake<T extends TSchema> = (metadata: Static<T>, previousParsedMetadata?: ParsedMetadata) => Static<typeof HandshakeErrorCustomHandlerFatalResponseCodes> | ParsedMetadata | Promise<Static<typeof HandshakeErrorCustomHandlerFatalResponseCodes> | ParsedMetadata>;
|
|
543
|
+
interface ClientHandshakeOptions<MetadataSchema extends TSchema = TSchema> {
|
|
544
|
+
/**
|
|
545
|
+
* Schema for the metadata that the client sends to the server
|
|
546
|
+
* during the handshake.
|
|
547
|
+
*/
|
|
548
|
+
schema: MetadataSchema;
|
|
549
|
+
/**
|
|
550
|
+
* Gets the {@link HandshakeRequestMetadata} to send to the server.
|
|
551
|
+
*/
|
|
552
|
+
construct: ConstructHandshake<MetadataSchema>;
|
|
553
|
+
}
|
|
554
|
+
interface ServerHandshakeOptions<MetadataSchema extends TSchema = TSchema> {
|
|
555
|
+
/**
|
|
556
|
+
* Schema for the metadata that the server receives from the client
|
|
557
|
+
* during the handshake.
|
|
558
|
+
*/
|
|
559
|
+
schema: MetadataSchema;
|
|
560
|
+
/**
|
|
561
|
+
* Parses the {@link HandshakeRequestMetadata} sent by the client, transforming
|
|
562
|
+
* it into {@link ParsedHandshakeMetadata}.
|
|
563
|
+
*
|
|
564
|
+
* May return `false` if the client should be rejected.
|
|
565
|
+
*
|
|
566
|
+
* @param metadata - The metadata sent by the client.
|
|
567
|
+
* @param session - The session that the client would be associated with.
|
|
568
|
+
* @param isReconnect - Whether the client is reconnecting to the session,
|
|
569
|
+
* or if this is a new session.
|
|
570
|
+
*/
|
|
571
|
+
validate: ValidateHandshake<MetadataSchema>;
|
|
572
|
+
}
|
|
573
|
+
declare function createClientHandshakeOptions<MetadataSchema extends TSchema = TSchema>(schema: MetadataSchema, construct: ConstructHandshake<MetadataSchema>): ClientHandshakeOptions;
|
|
574
|
+
declare function createServerHandshakeOptions<MetadataSchema extends TSchema = TSchema>(schema: MetadataSchema, validate: ValidateHandshake<MetadataSchema>): ServerHandshakeOptions;
|
|
575
|
+
|
|
576
|
+
declare abstract class ClientTransport<ConnType extends Connection> extends Transport<ConnType> {
|
|
577
|
+
/**
|
|
578
|
+
* The options for this transport.
|
|
579
|
+
*/
|
|
580
|
+
protected options: ClientTransportOptions;
|
|
581
|
+
retryBudget: LeakyBucketRateLimit;
|
|
582
|
+
/**
|
|
583
|
+
* A flag indicating whether the transport should automatically reconnect
|
|
584
|
+
* when a connection is dropped.
|
|
585
|
+
* Realistically, this should always be true for clients unless you are writing
|
|
586
|
+
* tests or a special case where you don't want to reconnect.
|
|
587
|
+
*/
|
|
588
|
+
reconnectOnConnectionDrop: boolean;
|
|
589
|
+
/**
|
|
590
|
+
* Optional handshake options for this client.
|
|
591
|
+
*/
|
|
592
|
+
handshakeExtensions?: ClientHandshakeOptions;
|
|
593
|
+
sessions: Map<TransportClientId, ClientSession<ConnType>>;
|
|
594
|
+
constructor(clientId: TransportClientId, providedOptions?: ProvidedClientTransportOptions);
|
|
595
|
+
extendHandshake(options: ClientHandshakeOptions): void;
|
|
596
|
+
/**
|
|
597
|
+
* Abstract method that creates a new {@link Connection} object.
|
|
598
|
+
*
|
|
599
|
+
* @param to The client ID of the node to connect to.
|
|
600
|
+
* @returns The new connection object.
|
|
601
|
+
*/
|
|
602
|
+
protected abstract createNewOutgoingConnection(to: TransportClientId): Promise<ConnType>;
|
|
603
|
+
private tryReconnecting;
|
|
604
|
+
createUnconnectedSession(to: string): SessionNoConnection;
|
|
605
|
+
protected onConnectingFailed(session: SessionConnecting<ConnType>): SessionNoConnection;
|
|
606
|
+
protected onConnClosed(session: SessionHandshaking<ConnType> | SessionConnected<ConnType>): SessionNoConnection;
|
|
607
|
+
protected onConnectionEstablished(session: SessionConnecting<ConnType>, conn: ConnType): SessionHandshaking<ConnType>;
|
|
608
|
+
private rejectHandshakeResponse;
|
|
609
|
+
protected onHandshakeResponse(session: SessionHandshaking<ConnType>, msg: OpaqueTransportMessage): void;
|
|
610
|
+
/**
|
|
611
|
+
* Manually attempts to connect to a client.
|
|
612
|
+
* @param to The client ID of the node to connect to.
|
|
613
|
+
*/
|
|
614
|
+
connect(to: TransportClientId): void;
|
|
615
|
+
/**
|
|
616
|
+
* Manually kills all sessions to the server (including all pending state).
|
|
617
|
+
* This is useful for when you want to close all connections to a server
|
|
618
|
+
* and don't want to wait for the grace period to elapse.
|
|
619
|
+
*/
|
|
620
|
+
hardDisconnect(): void;
|
|
621
|
+
protected onBackoffFinished(session: SessionBackingOff): void;
|
|
622
|
+
private sendHandshake;
|
|
623
|
+
close(): void;
|
|
624
|
+
}
|
|
6
625
|
|
|
7
626
|
/**
|
|
8
627
|
* {@link UNCAUGHT_ERROR_CODE} is the code that is used when an error is thrown
|
|
@@ -31,6 +650,13 @@ type BaseErrorSchemaType = TObject<{
|
|
|
31
650
|
message: TLiteralString | TString;
|
|
32
651
|
extras: TSchema;
|
|
33
652
|
}>;
|
|
653
|
+
/**
|
|
654
|
+
* A schema for cancel payloads sent from the client
|
|
655
|
+
*/
|
|
656
|
+
declare const CancelResultSchema: TObject<{
|
|
657
|
+
code: TLiteral<"CANCEL">;
|
|
658
|
+
message: TString;
|
|
659
|
+
}>;
|
|
34
660
|
/**
|
|
35
661
|
* {@link ReaderErrorSchema} is the schema for all the built-in river errors that
|
|
36
662
|
* can be emitted to a reader (request reader on the server, and response reader
|
|
@@ -248,13 +874,6 @@ declare function Err<const Err extends Static<BaseErrorSchemaType>>(error: Err):
|
|
|
248
874
|
* Refine a {@link Result} type to its returned payload.
|
|
249
875
|
*/
|
|
250
876
|
type ResultUnwrapOk<R> = R extends Result<infer T, infer __E> ? T : never;
|
|
251
|
-
/**
|
|
252
|
-
* Unwrap a {@link Result} type and return the payload if successful,
|
|
253
|
-
* otherwise throws an error.
|
|
254
|
-
* @param result - The result to unwrap.
|
|
255
|
-
* @throws Will throw an error if the result is not ok.
|
|
256
|
-
*/
|
|
257
|
-
declare function unwrapOrThrow<T, Err extends Static<BaseErrorSchemaType>>(result: Result<T, Err>): T;
|
|
258
877
|
/**
|
|
259
878
|
* Refine a {@link Result} type to its error payload.
|
|
260
879
|
*/
|
|
@@ -283,6 +902,101 @@ type ResponseData<RiverClient, ServiceName extends keyof RiverClient, ProcedureN
|
|
|
283
902
|
resReadable: Readable<infer SubscriptionOutputMessage, Static<BaseErrorSchemaType>>;
|
|
284
903
|
} ? SubscriptionOutputMessage : never : never : never : never;
|
|
285
904
|
|
|
905
|
+
/**
|
|
906
|
+
* ServiceContext exist for the purpose of declaration merging
|
|
907
|
+
* to extend the context with additional properties.
|
|
908
|
+
*
|
|
909
|
+
* For example:
|
|
910
|
+
*
|
|
911
|
+
* ```ts
|
|
912
|
+
* declare module '@replit/river' {
|
|
913
|
+
* interface ServiceContext {
|
|
914
|
+
* db: Database;
|
|
915
|
+
* }
|
|
916
|
+
* }
|
|
917
|
+
*
|
|
918
|
+
* createServer(someTransport, myServices, { extendedContext: { db: myDb } });
|
|
919
|
+
* ```
|
|
920
|
+
*
|
|
921
|
+
* Once you do this, your {@link ProcedureHandlerContext} will have `db` property on it.
|
|
922
|
+
*/
|
|
923
|
+
interface ServiceContext {
|
|
924
|
+
}
|
|
925
|
+
/**
|
|
926
|
+
* The parsed metadata schema for a service. This is the
|
|
927
|
+
* return value of the {@link ServerHandshakeOptions.validate}
|
|
928
|
+
* if the handshake extension is used.
|
|
929
|
+
*
|
|
930
|
+
* You should use declaration merging to extend this interface
|
|
931
|
+
* with the sanitized metadata.
|
|
932
|
+
*
|
|
933
|
+
* ```ts
|
|
934
|
+
* declare module '@replit/river' {
|
|
935
|
+
* interface ParsedMetadata {
|
|
936
|
+
* userId: number;
|
|
937
|
+
* }
|
|
938
|
+
* }
|
|
939
|
+
* ```
|
|
940
|
+
*/
|
|
941
|
+
interface ParsedMetadata extends Record<string, unknown> {
|
|
942
|
+
}
|
|
943
|
+
/**
|
|
944
|
+
* This is passed to every procedure handler and contains various context-level
|
|
945
|
+
* information and utilities. This may be extended, see {@link ServiceContext}
|
|
946
|
+
*/
|
|
947
|
+
type ProcedureHandlerContext<State> = ServiceContext & {
|
|
948
|
+
/**
|
|
949
|
+
* State for this service as defined by the service definition.
|
|
950
|
+
*/
|
|
951
|
+
state: State;
|
|
952
|
+
/**
|
|
953
|
+
* The span for this procedure call. You can use this to add attributes, events, and
|
|
954
|
+
* links to the span.
|
|
955
|
+
*/
|
|
956
|
+
span: Span;
|
|
957
|
+
/**
|
|
958
|
+
* Metadata parsed on the server. See {@link ParsedMetadata}
|
|
959
|
+
*/
|
|
960
|
+
metadata: ParsedMetadata;
|
|
961
|
+
/**
|
|
962
|
+
* The ID of the session that sent this request.
|
|
963
|
+
*/
|
|
964
|
+
sessionId: SessionId;
|
|
965
|
+
/**
|
|
966
|
+
* The ID of the client that sent this request. There may be multiple sessions per client.
|
|
967
|
+
*/
|
|
968
|
+
from: TransportClientId;
|
|
969
|
+
/**
|
|
970
|
+
* This is used to cancel the procedure call from the handler and notify the client that the
|
|
971
|
+
* call was cancelled.
|
|
972
|
+
*
|
|
973
|
+
* Cancelling is not the same as closing procedure calls gracefully, please refer to
|
|
974
|
+
* the river documentation to understand the difference between the two concepts.
|
|
975
|
+
*/
|
|
976
|
+
cancel: (message?: string) => ErrResult<Static<typeof CancelResultSchema>>;
|
|
977
|
+
/**
|
|
978
|
+
* This signal is a standard [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)
|
|
979
|
+
* triggered when the procedure invocation is done. This signal tracks the invocation/request finishing
|
|
980
|
+
* for _any_ reason, for example:
|
|
981
|
+
* - client explicit cancellation
|
|
982
|
+
* - procedure handler explicit cancellation via {@link cancel}
|
|
983
|
+
* - client session disconnect
|
|
984
|
+
* - server cancellation due to client invalid payload
|
|
985
|
+
* - invocation finishes cleanly, this depends on the type of the procedure (i.e. rpc handler return, or in a stream after the client-side has closed the request writable and the server-side has closed the response writable)
|
|
986
|
+
*
|
|
987
|
+
* You can use this to pass it on to asynchronous operations (such as fetch).
|
|
988
|
+
*
|
|
989
|
+
* You may also want to explicitly register callbacks on the
|
|
990
|
+
* ['abort' event](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/abort_event)
|
|
991
|
+
* as a way to cleanup after the request is finished.
|
|
992
|
+
*
|
|
993
|
+
* Note that (per standard AbortSignals) callbacks registered _after_ the procedure invocation
|
|
994
|
+
* is done are not triggered. In such cases, you can check the "aborted" property and cleanup
|
|
995
|
+
* immediately if needed.
|
|
996
|
+
*/
|
|
997
|
+
signal: AbortSignal;
|
|
998
|
+
};
|
|
999
|
+
|
|
286
1000
|
/**
|
|
287
1001
|
* Brands a type to prevent it from being directly constructed.
|
|
288
1002
|
*/
|
|
@@ -303,6 +1017,7 @@ type ValidProcType = 'rpc' | 'upload' | 'subscription' | 'stream';
|
|
|
303
1017
|
* Represents the payload type for {@link Procedure}s.
|
|
304
1018
|
*/
|
|
305
1019
|
type PayloadType = TSchema;
|
|
1020
|
+
type Cancellable<T> = T | Static<typeof CancelResultSchema>;
|
|
306
1021
|
/**
|
|
307
1022
|
* Procedure for a single message in both directions (1:1).
|
|
308
1023
|
*
|
|
@@ -320,7 +1035,7 @@ interface RpcProcedure<State, RequestInit extends PayloadType, ResponseData exte
|
|
|
320
1035
|
handler(param: {
|
|
321
1036
|
ctx: ProcedureHandlerContext<State>;
|
|
322
1037
|
reqInit: Static<RequestInit>;
|
|
323
|
-
}): Promise<Result<Static<ResponseData>, Static<ResponseErr
|
|
1038
|
+
}): Promise<Result<Static<ResponseData>, Cancellable<Static<ResponseErr>>>>;
|
|
324
1039
|
}
|
|
325
1040
|
/**
|
|
326
1041
|
* Procedure for a client-stream (potentially preceded by an initialization message),
|
|
@@ -343,7 +1058,7 @@ interface UploadProcedure<State, RequestInit extends PayloadType, RequestData ex
|
|
|
343
1058
|
ctx: ProcedureHandlerContext<State>;
|
|
344
1059
|
reqInit: Static<RequestInit>;
|
|
345
1060
|
reqReadable: Readable<Static<RequestData>, Static<typeof ReaderErrorSchema>>;
|
|
346
|
-
}): Promise<Result<Static<ResponseData>, Static<ResponseErr
|
|
1061
|
+
}): Promise<Result<Static<ResponseData>, Cancellable<Static<ResponseErr>>>>;
|
|
347
1062
|
}
|
|
348
1063
|
/**
|
|
349
1064
|
* Procedure for a single message from client, stream from server (1:n).
|
|
@@ -362,7 +1077,7 @@ interface SubscriptionProcedure<State, RequestInit extends PayloadType, Response
|
|
|
362
1077
|
handler(param: {
|
|
363
1078
|
ctx: ProcedureHandlerContext<State>;
|
|
364
1079
|
reqInit: Static<RequestInit>;
|
|
365
|
-
resWritable: Writable<Result<Static<ResponseData>, Static<ResponseErr
|
|
1080
|
+
resWritable: Writable<Result<Static<ResponseData>, Cancellable<Static<ResponseErr>>>>;
|
|
366
1081
|
}): Promise<void | undefined>;
|
|
367
1082
|
}
|
|
368
1083
|
/**
|
|
@@ -386,7 +1101,7 @@ interface StreamProcedure<State, RequestInit extends PayloadType, RequestData ex
|
|
|
386
1101
|
ctx: ProcedureHandlerContext<State>;
|
|
387
1102
|
reqInit: Static<RequestInit>;
|
|
388
1103
|
reqReadable: Readable<Static<RequestData>, Static<typeof ReaderErrorSchema>>;
|
|
389
|
-
resWritable: Writable<Result<Static<ResponseData>, Static<ResponseErr
|
|
1104
|
+
resWritable: Writable<Result<Static<ResponseData>, Cancellable<Static<ResponseErr>>>>;
|
|
390
1105
|
}): Promise<void | undefined>;
|
|
391
1106
|
}
|
|
392
1107
|
/**
|
|
@@ -846,4 +1561,4 @@ declare class ServiceScaffold<State extends object> {
|
|
|
846
1561
|
}>;
|
|
847
1562
|
}
|
|
848
1563
|
|
|
849
|
-
export { AnyServiceSchemaMap as A,
|
|
1564
|
+
export { ResultUnwrapOk as $, AnyServiceSchemaMap as A, Readable as B, ClientTransport as C, Procedure as D, ProcedureErrorSchemaType as E, flattenErrorType as F, UNCAUGHT_ERROR_CODE as G, UNEXPECTED_DISCONNECT_CODE as H, InstantiatedServiceSchemaMap as I, INVALID_REQUEST_CODE as J, CANCEL_CODE as K, ReaderErrorSchema as L, BaseErrorSchemaType as M, createClient as N, Client as O, ProvidedClientTransportOptions as P, ProcedureHandlerContext as Q, RpcProcedure as R, ServerHandshakeOptions as S, Ok as T, UploadProcedure as U, ValidProcType as V, Writable as W, Err as X, Result as Y, ErrResult as Z, OkResult as _, ProvidedServerTransportOptions as a, ResultUnwrapErr as a0, ResponseData as a1, createClientHandshakeOptions as a2, createServerHandshakeOptions as a3, ClientHandshakeOptions as a4, ReadableIterator as a5, ReadableResult as a6, Transport as a7, SessionOptions as a8, ClientTransportOptions as a9, SessionNoConnection as aa, SessionBoundSendFn as ab, CommonSession as ac, SessionState as ad, CommonSessionProps as ae, ServerTransportOptions as af, ServerSession as ag, DeleteSessionOptions as ah, TransportStatus as ai, ProvidedTransportOptions as aj, Session as ak, SessionConnecting as al, SessionHandshaking as am, SessionConnected as an, EventMap as ao, EventTypes as ap, EventHandler as aq, ProtocolError as ar, ProtocolErrorType as as, Connection as b, ParsedMetadata as c, AnyProcedure as d, ServiceContext as e, Service as f, ServiceConfiguration as g, ProcHandler as h, ProcInit as i, ProcRequest as j, ProcResponse as k, ProcErrors as l, ProcType as m, ServiceSchema as n, SerializedServerSchema as o, SerializedServiceSchema as p, SerializedProcedureSchema as q, serializeSchemaV1Compat as r, serializeSchema as s, SerializedServerSchemaProtocolv1 as t, SerializedServiceSchemaProtocolv1 as u, SerializedProcedureSchemaProtocolv1 as v, PayloadType as w, ProcedureMap as x, SubscriptionProcedure as y, StreamProcedure as z };
|