@replit/river 0.213.1 → 0.215.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/{adapter-Cp7_gIVA.d.ts → adapter-CgF7vQPu.d.ts} +3 -2
- package/dist/{adapter-DjiEwOYi.d.cts → adapter-IGrG4KLL.d.cts} +3 -2
- package/dist/{chunk-X4PP65DW.js → chunk-RDTQZ7HO.js} +58 -18
- package/dist/chunk-RDTQZ7HO.js.map +1 -0
- package/dist/{chunk-2A645F27.js → chunk-VXRAFUA3.js} +178 -54
- package/dist/chunk-VXRAFUA3.js.map +1 -0
- package/dist/{client-Dw0JBBs3.d.ts → client-BhwlY0-L.d.ts} +2 -2
- package/dist/{client-DXJRow2s.d.cts → client-Dk4H7qeg.d.cts} +2 -2
- package/dist/codec/index.cjs.map +1 -1
- package/dist/codec/index.d.cts +3 -3
- package/dist/codec/index.d.ts +3 -3
- package/dist/codec/index.js +2 -2
- package/dist/{connection-Dzkqj18h.d.cts → connection-CS00EWuS.d.cts} +3 -3
- package/dist/{connection-C2lYgRh0.d.ts → connection-DU9v3y8a.d.ts} +3 -3
- package/dist/{index-D9R6UTMl.d.cts → index-CHCzvZ9D.d.cts} +1 -1
- package/dist/{index-CSM8soK7.d.ts → index-uF0cBM7z.d.ts} +1 -1
- package/dist/logging/index.d.cts +2 -2
- package/dist/logging/index.d.ts +2 -2
- package/dist/{message-Dlsh5WDF.d.cts → message-aABg0s5M.d.cts} +12 -1
- package/dist/{message-Dlsh5WDF.d.ts → message-aABg0s5M.d.ts} +12 -1
- package/dist/router/index.cjs +60 -17
- package/dist/router/index.cjs.map +1 -1
- package/dist/router/index.d.cts +10 -10
- package/dist/router/index.d.ts +10 -10
- package/dist/router/index.js +1 -1
- package/dist/{server-BDSYa-CO.d.cts → server-BR0DZaWi.d.cts} +4 -4
- package/dist/{server-DFOzjvLh.d.ts → server-uNzkzIRh.d.ts} +4 -4
- package/dist/{services-C656NVV3.d.cts → services-B5SY771g.d.ts} +20 -4
- package/dist/{services-ChTb4jmc.d.ts → services-DBv2nmly.d.cts} +20 -4
- package/dist/testUtil/index.cjs +179 -53
- package/dist/testUtil/index.cjs.map +1 -1
- package/dist/testUtil/index.d.cts +7 -7
- package/dist/testUtil/index.d.ts +7 -7
- package/dist/testUtil/index.js +4 -2
- package/dist/testUtil/index.js.map +1 -1
- package/dist/transport/impls/ws/client.cjs +166 -53
- package/dist/transport/impls/ws/client.cjs.map +1 -1
- package/dist/transport/impls/ws/client.d.cts +6 -6
- package/dist/transport/impls/ws/client.d.ts +6 -6
- package/dist/transport/impls/ws/client.js +2 -2
- package/dist/transport/impls/ws/server.cjs +133 -53
- package/dist/transport/impls/ws/server.cjs.map +1 -1
- package/dist/transport/impls/ws/server.d.cts +6 -6
- package/dist/transport/impls/ws/server.d.ts +6 -6
- package/dist/transport/impls/ws/server.js +2 -2
- package/dist/transport/index.cjs +177 -53
- package/dist/transport/index.cjs.map +1 -1
- package/dist/transport/index.d.cts +7 -7
- package/dist/transport/index.d.ts +7 -7
- package/dist/transport/index.js +2 -2
- package/dist/{transport-CxT7y8Qk.d.cts → transport-BOL2p5s-.d.ts} +70 -64
- package/dist/{transport-pdbkDzmJ.d.ts → transport-D3jzhFSi.d.cts} +70 -64
- package/package.json +1 -1
- package/dist/chunk-2A645F27.js.map +0 -1
- package/dist/chunk-X4PP65DW.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { b as ClientTransportOptions, C as Connection, j as EventHandler, E as EventMap, i as EventTypes, k as ProtocolError, l as ProtocolErrorType, c as ServerTransportOptions, S as Session, h as SessionConnected, f as SessionConnecting, g as SessionHandshaking, e as SessionNoConnection, d as SessionState, T as Transport, P as TransportOptions, a as TransportStatus } from '../transport-
|
|
2
|
-
export { C as ClientTransport } from '../client-
|
|
3
|
-
export { S as ServerTransport, a as SessionWaitingForHandshake } from '../server-
|
|
4
|
-
export { W as WebSocketCloseError, a as WebSocketConnection } from '../connection-
|
|
5
|
-
export { b as OpaqueTransportMessage, O as OpaqueTransportMessageSchema, c as TransportClientId, a as TransportMessage, T as TransportMessageSchema, d as isStreamClose, i as isStreamOpen } from '../message-
|
|
1
|
+
export { b as ClientTransportOptions, C as Connection, j as EventHandler, E as EventMap, i as EventTypes, k as ProtocolError, l as ProtocolErrorType, c as ServerTransportOptions, S as Session, h as SessionConnected, f as SessionConnecting, g as SessionHandshaking, e as SessionNoConnection, d as SessionState, T as Transport, P as TransportOptions, a as TransportStatus } from '../transport-D3jzhFSi.cjs';
|
|
2
|
+
export { C as ClientTransport } from '../client-Dk4H7qeg.cjs';
|
|
3
|
+
export { S as ServerTransport, a as SessionWaitingForHandshake } from '../server-BR0DZaWi.cjs';
|
|
4
|
+
export { W as WebSocketCloseError, a as WebSocketConnection } from '../connection-CS00EWuS.cjs';
|
|
5
|
+
export { b as OpaqueTransportMessage, O as OpaqueTransportMessageSchema, c as TransportClientId, a as TransportMessage, T as TransportMessageSchema, d as isStreamClose, i as isStreamOpen } from '../message-aABg0s5M.cjs';
|
|
6
6
|
import '@sinclair/typebox';
|
|
7
|
-
import '../index-
|
|
8
|
-
import '../adapter-
|
|
7
|
+
import '../index-CHCzvZ9D.cjs';
|
|
8
|
+
import '../adapter-IGrG4KLL.cjs';
|
|
9
9
|
import '@opentelemetry/api';
|
|
10
10
|
import '../wslike-Dng9H1C7.cjs';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { b as ClientTransportOptions, C as Connection, j as EventHandler, E as EventMap, i as EventTypes, k as ProtocolError, l as ProtocolErrorType, c as ServerTransportOptions, S as Session, h as SessionConnected, f as SessionConnecting, g as SessionHandshaking, e as SessionNoConnection, d as SessionState, T as Transport, P as TransportOptions, a as TransportStatus } from '../transport-
|
|
2
|
-
export { C as ClientTransport } from '../client-
|
|
3
|
-
export { S as ServerTransport, a as SessionWaitingForHandshake } from '../server-
|
|
4
|
-
export { W as WebSocketCloseError, a as WebSocketConnection } from '../connection-
|
|
5
|
-
export { b as OpaqueTransportMessage, O as OpaqueTransportMessageSchema, c as TransportClientId, a as TransportMessage, T as TransportMessageSchema, d as isStreamClose, i as isStreamOpen } from '../message-
|
|
1
|
+
export { b as ClientTransportOptions, C as Connection, j as EventHandler, E as EventMap, i as EventTypes, k as ProtocolError, l as ProtocolErrorType, c as ServerTransportOptions, S as Session, h as SessionConnected, f as SessionConnecting, g as SessionHandshaking, e as SessionNoConnection, d as SessionState, T as Transport, P as TransportOptions, a as TransportStatus } from '../transport-BOL2p5s-.js';
|
|
2
|
+
export { C as ClientTransport } from '../client-BhwlY0-L.js';
|
|
3
|
+
export { S as ServerTransport, a as SessionWaitingForHandshake } from '../server-uNzkzIRh.js';
|
|
4
|
+
export { W as WebSocketCloseError, a as WebSocketConnection } from '../connection-DU9v3y8a.js';
|
|
5
|
+
export { b as OpaqueTransportMessage, O as OpaqueTransportMessageSchema, c as TransportClientId, a as TransportMessage, T as TransportMessageSchema, d as isStreamClose, i as isStreamOpen } from '../message-aABg0s5M.js';
|
|
6
6
|
import '@sinclair/typebox';
|
|
7
|
-
import '../index-
|
|
8
|
-
import '../adapter-
|
|
7
|
+
import '../index-uF0cBM7z.js';
|
|
8
|
+
import '../adapter-CgF7vQPu.js';
|
|
9
9
|
import '@opentelemetry/api';
|
|
10
10
|
import '../wslike-Dng9H1C7.js';
|
package/dist/transport/index.js
CHANGED
|
@@ -7,12 +7,12 @@ import {
|
|
|
7
7
|
Transport,
|
|
8
8
|
WebSocketCloseError,
|
|
9
9
|
WebSocketConnection
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-VXRAFUA3.js";
|
|
11
11
|
import "../chunk-CC7RN7GI.js";
|
|
12
12
|
import {
|
|
13
13
|
OpaqueTransportMessageSchema,
|
|
14
14
|
TransportMessageSchema
|
|
15
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-RDTQZ7HO.js";
|
|
16
16
|
export {
|
|
17
17
|
ClientTransport,
|
|
18
18
|
Connection,
|
|
@@ -1,64 +1,9 @@
|
|
|
1
1
|
import { TSchema, Static } from '@sinclair/typebox';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { C as Codec, a as CodecMessageAdapter, S as SendResult, b as SendBufferResult } from './adapter-
|
|
2
|
+
import { c as TransportClientId, f as TelemetryInfo, P as ProtocolVersion, e as PartialTransportMessage, E as EncodedTransportMessage, g as HandshakeErrorCustomHandlerFatalResponseCodes, b as OpaqueTransportMessage, H as HandshakeErrorResponseCodes, a as TransportMessage } from './message-aABg0s5M.js';
|
|
3
|
+
import { L as Logger, M as MessageMetadata, T as Tags, a as LogFn, b as LoggingLevel } from './index-uF0cBM7z.js';
|
|
4
|
+
import { C as Codec, a as CodecMessageAdapter, E as EncodeResult, S as SendResult, b as SendBufferResult } from './adapter-CgF7vQPu.js';
|
|
5
5
|
import { Tracer } from '@opentelemetry/api';
|
|
6
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
|
-
dataListener?: (msg: Uint8Array) => void;
|
|
19
|
-
closeListener?: () => void;
|
|
20
|
-
errorListener?: (err: Error) => void;
|
|
21
|
-
onData(msg: Uint8Array): void;
|
|
22
|
-
onError(err: Error): void;
|
|
23
|
-
onClose(): void;
|
|
24
|
-
/**
|
|
25
|
-
* Set the callback for when a message is received.
|
|
26
|
-
* @param cb The message handler callback.
|
|
27
|
-
*/
|
|
28
|
-
setDataListener(cb: (msg: Uint8Array) => void): void;
|
|
29
|
-
removeDataListener(): void;
|
|
30
|
-
/**
|
|
31
|
-
* Set the callback for when the connection is closed.
|
|
32
|
-
* This should also be called if an error happens and after notifying the error listener.
|
|
33
|
-
* @param cb The callback to call when the connection is closed.
|
|
34
|
-
*/
|
|
35
|
-
setCloseListener(cb: () => void): void;
|
|
36
|
-
removeCloseListener(): void;
|
|
37
|
-
/**
|
|
38
|
-
* Set the callback for when an error is received.
|
|
39
|
-
* This should only be used for logging errors, all cleanup
|
|
40
|
-
* should be delegated to setCloseListener.
|
|
41
|
-
*
|
|
42
|
-
* The implementer should take care such that the implemented
|
|
43
|
-
* connection will call both the close and error callbacks
|
|
44
|
-
* on an error.
|
|
45
|
-
*
|
|
46
|
-
* @param cb The callback to call when an error is received.
|
|
47
|
-
*/
|
|
48
|
-
setErrorListener(cb: (err: Error) => void): void;
|
|
49
|
-
removeErrorListener(): void;
|
|
50
|
-
/**
|
|
51
|
-
* Sends a message over the connection.
|
|
52
|
-
* @param msg The message to send.
|
|
53
|
-
* @returns true if the message was sent, false otherwise.
|
|
54
|
-
*/
|
|
55
|
-
abstract send(msg: Uint8Array): boolean;
|
|
56
|
-
/**
|
|
57
|
-
* Closes the connection.
|
|
58
|
-
*/
|
|
59
|
-
abstract close(): void;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
7
|
declare const enum SessionState {
|
|
63
8
|
NoConnection = "NoConnection",
|
|
64
9
|
BackingOff = "BackingOff",
|
|
@@ -135,21 +80,28 @@ declare abstract class CommonSession extends StateMachineState {
|
|
|
135
80
|
constructor({ from, options, log, tracer, codec }: CommonSessionProps);
|
|
136
81
|
}
|
|
137
82
|
type SessionId = string;
|
|
83
|
+
interface IdentifiedSessionListeners {
|
|
84
|
+
onMessageSendFailure: (msg: PartialTransportMessage & {
|
|
85
|
+
seq: number;
|
|
86
|
+
}, reason: string) => void;
|
|
87
|
+
}
|
|
138
88
|
interface IdentifiedSessionProps extends CommonSessionProps {
|
|
139
89
|
id: SessionId;
|
|
140
90
|
to: TransportClientId;
|
|
141
91
|
seq: number;
|
|
142
92
|
ack: number;
|
|
143
93
|
seqSent: number;
|
|
144
|
-
sendBuffer: Array<
|
|
94
|
+
sendBuffer: Array<EncodedTransportMessage>;
|
|
145
95
|
telemetry: TelemetryInfo;
|
|
146
96
|
protocolVersion: ProtocolVersion;
|
|
97
|
+
listeners: IdentifiedSessionListeners;
|
|
147
98
|
}
|
|
148
99
|
declare abstract class IdentifiedSession extends CommonSession {
|
|
149
100
|
readonly id: SessionId;
|
|
150
101
|
readonly telemetry: TelemetryInfo;
|
|
151
102
|
readonly to: TransportClientId;
|
|
152
103
|
readonly protocolVersion: ProtocolVersion;
|
|
104
|
+
listeners: IdentifiedSessionListeners;
|
|
153
105
|
/**
|
|
154
106
|
* Index of the message we will send next (excluding handshake)
|
|
155
107
|
*/
|
|
@@ -162,16 +114,16 @@ declare abstract class IdentifiedSession extends CommonSession {
|
|
|
162
114
|
* Number of unique messages we've received this session (excluding handshake)
|
|
163
115
|
*/
|
|
164
116
|
ack: number;
|
|
165
|
-
sendBuffer: Array<
|
|
117
|
+
sendBuffer: Array<EncodedTransportMessage>;
|
|
166
118
|
constructor(props: IdentifiedSessionProps);
|
|
167
119
|
get loggingMetadata(): MessageMetadata;
|
|
168
|
-
|
|
120
|
+
encodeMsg(partialMsg: PartialTransportMessage): EncodeResult;
|
|
169
121
|
nextSeq(): number;
|
|
170
122
|
send(msg: PartialTransportMessage): SendResult;
|
|
171
123
|
_handleStateExit(): void;
|
|
172
124
|
_handleClose(): void;
|
|
173
125
|
}
|
|
174
|
-
interface IdentifiedSessionWithGracePeriodListeners {
|
|
126
|
+
interface IdentifiedSessionWithGracePeriodListeners extends IdentifiedSessionListeners {
|
|
175
127
|
onSessionGracePeriodElapsed: () => void;
|
|
176
128
|
}
|
|
177
129
|
interface IdentifiedSessionWithGracePeriodProps extends IdentifiedSessionProps {
|
|
@@ -187,6 +139,61 @@ declare abstract class IdentifiedSessionWithGracePeriod extends IdentifiedSessio
|
|
|
187
139
|
_handleClose(): void;
|
|
188
140
|
}
|
|
189
141
|
|
|
142
|
+
/**
|
|
143
|
+
* A connection is the actual raw underlying transport connection.
|
|
144
|
+
* It's responsible for dispatching to/from the actual connection itself
|
|
145
|
+
* This should be instantiated as soon as the client/server has a connection
|
|
146
|
+
* It's tied to the lifecycle of the underlying transport connection (i.e. if the WS drops, this connection should be deleted)
|
|
147
|
+
*/
|
|
148
|
+
declare abstract class Connection {
|
|
149
|
+
id: string;
|
|
150
|
+
telemetry?: TelemetryInfo;
|
|
151
|
+
constructor();
|
|
152
|
+
get loggingMetadata(): MessageMetadata;
|
|
153
|
+
dataListener?: (msg: Uint8Array) => void;
|
|
154
|
+
closeListener?: () => void;
|
|
155
|
+
errorListener?: (err: Error) => void;
|
|
156
|
+
onData(msg: Uint8Array): void;
|
|
157
|
+
onError(err: Error): void;
|
|
158
|
+
onClose(): void;
|
|
159
|
+
/**
|
|
160
|
+
* Set the callback for when a message is received.
|
|
161
|
+
* @param cb The message handler callback.
|
|
162
|
+
*/
|
|
163
|
+
setDataListener(cb: (msg: Uint8Array) => void): void;
|
|
164
|
+
removeDataListener(): void;
|
|
165
|
+
/**
|
|
166
|
+
* Set the callback for when the connection is closed.
|
|
167
|
+
* This should also be called if an error happens and after notifying the error listener.
|
|
168
|
+
* @param cb The callback to call when the connection is closed.
|
|
169
|
+
*/
|
|
170
|
+
setCloseListener(cb: () => void): void;
|
|
171
|
+
removeCloseListener(): void;
|
|
172
|
+
/**
|
|
173
|
+
* Set the callback for when an error is received.
|
|
174
|
+
* This should only be used for logging errors, all cleanup
|
|
175
|
+
* should be delegated to setCloseListener.
|
|
176
|
+
*
|
|
177
|
+
* The implementer should take care such that the implemented
|
|
178
|
+
* connection will call both the close and error callbacks
|
|
179
|
+
* on an error.
|
|
180
|
+
*
|
|
181
|
+
* @param cb The callback to call when an error is received.
|
|
182
|
+
*/
|
|
183
|
+
setErrorListener(cb: (err: Error) => void): void;
|
|
184
|
+
removeErrorListener(): void;
|
|
185
|
+
/**
|
|
186
|
+
* Sends a message over the connection.
|
|
187
|
+
* @param msg The message to send.
|
|
188
|
+
* @returns true if the message was sent, false otherwise.
|
|
189
|
+
*/
|
|
190
|
+
abstract send(msg: Uint8Array): boolean;
|
|
191
|
+
/**
|
|
192
|
+
* Closes the connection.
|
|
193
|
+
*/
|
|
194
|
+
abstract close(): void;
|
|
195
|
+
}
|
|
196
|
+
|
|
190
197
|
type ConstructHandshake<T extends TSchema> = () => Static<T> | Promise<Static<T>>;
|
|
191
198
|
type ValidateHandshake<T extends TSchema, ParsedMetadata> = (metadata: Static<T>, previousParsedMetadata?: ParsedMetadata) => Static<typeof HandshakeErrorCustomHandlerFatalResponseCodes> | ParsedMetadata | Promise<Static<typeof HandshakeErrorCustomHandlerFatalResponseCodes> | ParsedMetadata>;
|
|
192
199
|
interface ClientHandshakeOptions<MetadataSchema extends TSchema = TSchema> {
|
|
@@ -347,11 +354,10 @@ declare class SessionHandshaking<ConnType extends Connection> extends Identified
|
|
|
347
354
|
_handleClose(): void;
|
|
348
355
|
}
|
|
349
356
|
|
|
350
|
-
interface SessionConnectedListeners {
|
|
357
|
+
interface SessionConnectedListeners extends IdentifiedSessionListeners {
|
|
351
358
|
onConnectionErrored: (err: unknown) => void;
|
|
352
359
|
onConnectionClosed: () => void;
|
|
353
360
|
onMessage: (msg: OpaqueTransportMessage) => void;
|
|
354
|
-
onMessageSendFailure: (msg: PartialTransportMessage, reason: string) => void;
|
|
355
361
|
onInvalidMessage: (reason: string) => void;
|
|
356
362
|
}
|
|
357
363
|
interface SessionConnectedProps<ConnType extends Connection> extends IdentifiedSessionProps {
|
|
@@ -1,64 +1,9 @@
|
|
|
1
1
|
import { TSchema, Static } from '@sinclair/typebox';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { C as Codec, a as CodecMessageAdapter, S as SendResult, b as SendBufferResult } from './adapter-
|
|
2
|
+
import { c as TransportClientId, f as TelemetryInfo, P as ProtocolVersion, e as PartialTransportMessage, E as EncodedTransportMessage, g as HandshakeErrorCustomHandlerFatalResponseCodes, b as OpaqueTransportMessage, H as HandshakeErrorResponseCodes, a as TransportMessage } from './message-aABg0s5M.cjs';
|
|
3
|
+
import { L as Logger, M as MessageMetadata, T as Tags, a as LogFn, b as LoggingLevel } from './index-CHCzvZ9D.cjs';
|
|
4
|
+
import { C as Codec, a as CodecMessageAdapter, E as EncodeResult, S as SendResult, b as SendBufferResult } from './adapter-IGrG4KLL.cjs';
|
|
5
5
|
import { Tracer } from '@opentelemetry/api';
|
|
6
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
|
-
dataListener?: (msg: Uint8Array) => void;
|
|
19
|
-
closeListener?: () => void;
|
|
20
|
-
errorListener?: (err: Error) => void;
|
|
21
|
-
onData(msg: Uint8Array): void;
|
|
22
|
-
onError(err: Error): void;
|
|
23
|
-
onClose(): void;
|
|
24
|
-
/**
|
|
25
|
-
* Set the callback for when a message is received.
|
|
26
|
-
* @param cb The message handler callback.
|
|
27
|
-
*/
|
|
28
|
-
setDataListener(cb: (msg: Uint8Array) => void): void;
|
|
29
|
-
removeDataListener(): void;
|
|
30
|
-
/**
|
|
31
|
-
* Set the callback for when the connection is closed.
|
|
32
|
-
* This should also be called if an error happens and after notifying the error listener.
|
|
33
|
-
* @param cb The callback to call when the connection is closed.
|
|
34
|
-
*/
|
|
35
|
-
setCloseListener(cb: () => void): void;
|
|
36
|
-
removeCloseListener(): void;
|
|
37
|
-
/**
|
|
38
|
-
* Set the callback for when an error is received.
|
|
39
|
-
* This should only be used for logging errors, all cleanup
|
|
40
|
-
* should be delegated to setCloseListener.
|
|
41
|
-
*
|
|
42
|
-
* The implementer should take care such that the implemented
|
|
43
|
-
* connection will call both the close and error callbacks
|
|
44
|
-
* on an error.
|
|
45
|
-
*
|
|
46
|
-
* @param cb The callback to call when an error is received.
|
|
47
|
-
*/
|
|
48
|
-
setErrorListener(cb: (err: Error) => void): void;
|
|
49
|
-
removeErrorListener(): void;
|
|
50
|
-
/**
|
|
51
|
-
* Sends a message over the connection.
|
|
52
|
-
* @param msg The message to send.
|
|
53
|
-
* @returns true if the message was sent, false otherwise.
|
|
54
|
-
*/
|
|
55
|
-
abstract send(msg: Uint8Array): boolean;
|
|
56
|
-
/**
|
|
57
|
-
* Closes the connection.
|
|
58
|
-
*/
|
|
59
|
-
abstract close(): void;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
7
|
declare const enum SessionState {
|
|
63
8
|
NoConnection = "NoConnection",
|
|
64
9
|
BackingOff = "BackingOff",
|
|
@@ -135,21 +80,28 @@ declare abstract class CommonSession extends StateMachineState {
|
|
|
135
80
|
constructor({ from, options, log, tracer, codec }: CommonSessionProps);
|
|
136
81
|
}
|
|
137
82
|
type SessionId = string;
|
|
83
|
+
interface IdentifiedSessionListeners {
|
|
84
|
+
onMessageSendFailure: (msg: PartialTransportMessage & {
|
|
85
|
+
seq: number;
|
|
86
|
+
}, reason: string) => void;
|
|
87
|
+
}
|
|
138
88
|
interface IdentifiedSessionProps extends CommonSessionProps {
|
|
139
89
|
id: SessionId;
|
|
140
90
|
to: TransportClientId;
|
|
141
91
|
seq: number;
|
|
142
92
|
ack: number;
|
|
143
93
|
seqSent: number;
|
|
144
|
-
sendBuffer: Array<
|
|
94
|
+
sendBuffer: Array<EncodedTransportMessage>;
|
|
145
95
|
telemetry: TelemetryInfo;
|
|
146
96
|
protocolVersion: ProtocolVersion;
|
|
97
|
+
listeners: IdentifiedSessionListeners;
|
|
147
98
|
}
|
|
148
99
|
declare abstract class IdentifiedSession extends CommonSession {
|
|
149
100
|
readonly id: SessionId;
|
|
150
101
|
readonly telemetry: TelemetryInfo;
|
|
151
102
|
readonly to: TransportClientId;
|
|
152
103
|
readonly protocolVersion: ProtocolVersion;
|
|
104
|
+
listeners: IdentifiedSessionListeners;
|
|
153
105
|
/**
|
|
154
106
|
* Index of the message we will send next (excluding handshake)
|
|
155
107
|
*/
|
|
@@ -162,16 +114,16 @@ declare abstract class IdentifiedSession extends CommonSession {
|
|
|
162
114
|
* Number of unique messages we've received this session (excluding handshake)
|
|
163
115
|
*/
|
|
164
116
|
ack: number;
|
|
165
|
-
sendBuffer: Array<
|
|
117
|
+
sendBuffer: Array<EncodedTransportMessage>;
|
|
166
118
|
constructor(props: IdentifiedSessionProps);
|
|
167
119
|
get loggingMetadata(): MessageMetadata;
|
|
168
|
-
|
|
120
|
+
encodeMsg(partialMsg: PartialTransportMessage): EncodeResult;
|
|
169
121
|
nextSeq(): number;
|
|
170
122
|
send(msg: PartialTransportMessage): SendResult;
|
|
171
123
|
_handleStateExit(): void;
|
|
172
124
|
_handleClose(): void;
|
|
173
125
|
}
|
|
174
|
-
interface IdentifiedSessionWithGracePeriodListeners {
|
|
126
|
+
interface IdentifiedSessionWithGracePeriodListeners extends IdentifiedSessionListeners {
|
|
175
127
|
onSessionGracePeriodElapsed: () => void;
|
|
176
128
|
}
|
|
177
129
|
interface IdentifiedSessionWithGracePeriodProps extends IdentifiedSessionProps {
|
|
@@ -187,6 +139,61 @@ declare abstract class IdentifiedSessionWithGracePeriod extends IdentifiedSessio
|
|
|
187
139
|
_handleClose(): void;
|
|
188
140
|
}
|
|
189
141
|
|
|
142
|
+
/**
|
|
143
|
+
* A connection is the actual raw underlying transport connection.
|
|
144
|
+
* It's responsible for dispatching to/from the actual connection itself
|
|
145
|
+
* This should be instantiated as soon as the client/server has a connection
|
|
146
|
+
* It's tied to the lifecycle of the underlying transport connection (i.e. if the WS drops, this connection should be deleted)
|
|
147
|
+
*/
|
|
148
|
+
declare abstract class Connection {
|
|
149
|
+
id: string;
|
|
150
|
+
telemetry?: TelemetryInfo;
|
|
151
|
+
constructor();
|
|
152
|
+
get loggingMetadata(): MessageMetadata;
|
|
153
|
+
dataListener?: (msg: Uint8Array) => void;
|
|
154
|
+
closeListener?: () => void;
|
|
155
|
+
errorListener?: (err: Error) => void;
|
|
156
|
+
onData(msg: Uint8Array): void;
|
|
157
|
+
onError(err: Error): void;
|
|
158
|
+
onClose(): void;
|
|
159
|
+
/**
|
|
160
|
+
* Set the callback for when a message is received.
|
|
161
|
+
* @param cb The message handler callback.
|
|
162
|
+
*/
|
|
163
|
+
setDataListener(cb: (msg: Uint8Array) => void): void;
|
|
164
|
+
removeDataListener(): void;
|
|
165
|
+
/**
|
|
166
|
+
* Set the callback for when the connection is closed.
|
|
167
|
+
* This should also be called if an error happens and after notifying the error listener.
|
|
168
|
+
* @param cb The callback to call when the connection is closed.
|
|
169
|
+
*/
|
|
170
|
+
setCloseListener(cb: () => void): void;
|
|
171
|
+
removeCloseListener(): void;
|
|
172
|
+
/**
|
|
173
|
+
* Set the callback for when an error is received.
|
|
174
|
+
* This should only be used for logging errors, all cleanup
|
|
175
|
+
* should be delegated to setCloseListener.
|
|
176
|
+
*
|
|
177
|
+
* The implementer should take care such that the implemented
|
|
178
|
+
* connection will call both the close and error callbacks
|
|
179
|
+
* on an error.
|
|
180
|
+
*
|
|
181
|
+
* @param cb The callback to call when an error is received.
|
|
182
|
+
*/
|
|
183
|
+
setErrorListener(cb: (err: Error) => void): void;
|
|
184
|
+
removeErrorListener(): void;
|
|
185
|
+
/**
|
|
186
|
+
* Sends a message over the connection.
|
|
187
|
+
* @param msg The message to send.
|
|
188
|
+
* @returns true if the message was sent, false otherwise.
|
|
189
|
+
*/
|
|
190
|
+
abstract send(msg: Uint8Array): boolean;
|
|
191
|
+
/**
|
|
192
|
+
* Closes the connection.
|
|
193
|
+
*/
|
|
194
|
+
abstract close(): void;
|
|
195
|
+
}
|
|
196
|
+
|
|
190
197
|
type ConstructHandshake<T extends TSchema> = () => Static<T> | Promise<Static<T>>;
|
|
191
198
|
type ValidateHandshake<T extends TSchema, ParsedMetadata> = (metadata: Static<T>, previousParsedMetadata?: ParsedMetadata) => Static<typeof HandshakeErrorCustomHandlerFatalResponseCodes> | ParsedMetadata | Promise<Static<typeof HandshakeErrorCustomHandlerFatalResponseCodes> | ParsedMetadata>;
|
|
192
199
|
interface ClientHandshakeOptions<MetadataSchema extends TSchema = TSchema> {
|
|
@@ -347,11 +354,10 @@ declare class SessionHandshaking<ConnType extends Connection> extends Identified
|
|
|
347
354
|
_handleClose(): void;
|
|
348
355
|
}
|
|
349
356
|
|
|
350
|
-
interface SessionConnectedListeners {
|
|
357
|
+
interface SessionConnectedListeners extends IdentifiedSessionListeners {
|
|
351
358
|
onConnectionErrored: (err: unknown) => void;
|
|
352
359
|
onConnectionClosed: () => void;
|
|
353
360
|
onMessage: (msg: OpaqueTransportMessage) => void;
|
|
354
|
-
onMessageSendFailure: (msg: PartialTransportMessage, reason: string) => void;
|
|
355
361
|
onInvalidMessage: (reason: string) => void;
|
|
356
362
|
}
|
|
357
363
|
interface SessionConnectedProps<ConnType extends Connection> extends IdentifiedSessionProps {
|
package/package.json
CHANGED