@replit/river 0.26.0 → 0.26.2

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.
Files changed (52) hide show
  1. package/dist/{chunk-KP4UB5NW.js → chunk-AWCUCZY4.js} +2 -2
  2. package/dist/{chunk-5S64PXTU.js → chunk-IV27BICV.js} +36 -9
  3. package/dist/chunk-IV27BICV.js.map +1 -0
  4. package/dist/{chunk-5FDAIAQ5.js → chunk-M5X4JTU3.js} +5 -5
  5. package/dist/chunk-M5X4JTU3.js.map +1 -0
  6. package/dist/{chunk-CCUYKR5C.js → chunk-M75K5TJS.js} +2 -2
  7. package/dist/{chunk-CCUYKR5C.js.map → chunk-M75K5TJS.js.map} +1 -1
  8. package/dist/{chunk-BNNELZM4.js → chunk-MREEJE3X.js} +2 -2
  9. package/dist/{chunk-JSU2KACV.js → chunk-NC54BC47.js} +98 -35
  10. package/dist/chunk-NC54BC47.js.map +1 -0
  11. package/dist/{chunk-7ETNUCOL.js → chunk-YQABPD3C.js} +29 -14
  12. package/dist/chunk-YQABPD3C.js.map +1 -0
  13. package/dist/{client-162c509c.d.ts → client-654098be.d.ts} +2 -4
  14. package/dist/{connection-6a404bb8.d.ts → connection-bc2454dc.d.ts} +1 -1
  15. package/dist/{handshake-3342bb94.d.ts → handshake-1a86f06d.d.ts} +60 -42
  16. package/dist/logging/index.d.cts +1 -1
  17. package/dist/logging/index.d.ts +1 -1
  18. package/dist/{message-1a434848.d.ts → message-57296605.d.ts} +2 -1
  19. package/dist/router/index.cjs +1 -1
  20. package/dist/router/index.cjs.map +1 -1
  21. package/dist/router/index.d.cts +8 -8
  22. package/dist/router/index.d.ts +8 -8
  23. package/dist/router/index.js +2 -2
  24. package/dist/{server-1b695374.d.ts → server-9a6b5a8e.d.ts} +12 -4
  25. package/dist/{services-c17f7eff.d.ts → services-7daa60a0.d.ts} +3 -3
  26. package/dist/transport/impls/ws/client.cjs +131 -41
  27. package/dist/transport/impls/ws/client.cjs.map +1 -1
  28. package/dist/transport/impls/ws/client.d.cts +4 -4
  29. package/dist/transport/impls/ws/client.d.ts +4 -4
  30. package/dist/transport/impls/ws/client.js +5 -5
  31. package/dist/transport/impls/ws/server.cjs +124 -46
  32. package/dist/transport/impls/ws/server.cjs.map +1 -1
  33. package/dist/transport/impls/ws/server.d.cts +4 -4
  34. package/dist/transport/impls/ws/server.d.ts +4 -4
  35. package/dist/transport/impls/ws/server.js +5 -5
  36. package/dist/transport/index.cjs +156 -51
  37. package/dist/transport/index.cjs.map +1 -1
  38. package/dist/transport/index.d.cts +4 -4
  39. package/dist/transport/index.d.ts +4 -4
  40. package/dist/transport/index.js +5 -5
  41. package/dist/util/testHelpers.cjs +97 -34
  42. package/dist/util/testHelpers.cjs.map +1 -1
  43. package/dist/util/testHelpers.d.cts +4 -4
  44. package/dist/util/testHelpers.d.ts +4 -4
  45. package/dist/util/testHelpers.js +3 -3
  46. package/package.json +1 -1
  47. package/dist/chunk-5FDAIAQ5.js.map +0 -1
  48. package/dist/chunk-5S64PXTU.js.map +0 -1
  49. package/dist/chunk-7ETNUCOL.js.map +0 -1
  50. package/dist/chunk-JSU2KACV.js.map +0 -1
  51. /package/dist/{chunk-KP4UB5NW.js.map → chunk-AWCUCZY4.js.map} +0 -0
  52. /package/dist/{chunk-BNNELZM4.js.map → chunk-MREEJE3X.js.map} +0 -0
@@ -1,5 +1,5 @@
1
- import { e as TelemetryInfo, M as MessageMetadata, c as TransportClientId, L as Logger, b as OpaqueTransportMessage, P as PartialTransportMessage, a as TransportMessage, f as LogFn, g as LoggingLevel, H as HandshakeErrorCustomHandlerFatalResponseCodes } from './message-1a434848.js';
2
- import { TSchema, Static } from '@sinclair/typebox';
1
+ import { e as TelemetryInfo, M as MessageMetadata, c as TransportClientId, L as Logger, b as OpaqueTransportMessage, P as PartialTransportMessage, a as TransportMessage, H as HandshakeErrorResponseCodes, f as LogFn, g as LoggingLevel, h as HandshakeErrorCustomHandlerFatalResponseCodes } from './message-57296605.js';
2
+ import { Static, TSchema } from '@sinclair/typebox';
3
3
  import { C as Codec } from './types-3e5768ec.js';
4
4
 
5
5
  /**
@@ -84,7 +84,11 @@ interface SessionOptions {
84
84
  */
85
85
  heartbeatsUntilDead: number;
86
86
  /**
87
- * Duration to wait between connection disconnect and actual session disconnect
87
+ * Max duration that a session can be without a connection before we consider
88
+ * it dead. This deadline is carried between states and is used to determine
89
+ * when to consider the session a lost cause and delete it entirely.
90
+ * Generally, this should be strictly greater than the sum of
91
+ * {@link connectionTimeoutMs} and {@link handshakeTimeoutMs}.
88
92
  */
89
93
  sessionDisconnectGraceMs: number;
90
94
  /**
@@ -95,6 +99,10 @@ interface SessionOptions {
95
99
  * Handshake timeout in milliseconds
96
100
  */
97
101
  handshakeTimeoutMs: number;
102
+ /**
103
+ * Whether to enable transparent session reconnects
104
+ */
105
+ enableTransparentSessionReconnects: boolean;
98
106
  /**
99
107
  * The codec to use for encoding/decoding messages over the wire
100
108
  */
@@ -143,40 +151,32 @@ declare abstract class IdentifiedSession extends CommonSession {
143
151
  _handleStateExit(): void;
144
152
  _handleClose(): void;
145
153
  }
146
-
147
- interface SessionHandshakingListeners {
148
- onConnectionErrored: (err: unknown) => void;
149
- onConnectionClosed: () => void;
150
- onHandshake: (msg: OpaqueTransportMessage) => void;
151
- onInvalidHandshake: (reason: string) => void;
152
- onHandshakeTimeout: () => void;
154
+ interface IdentifiedSessionWithGracePeriodListeners {
155
+ onSessionGracePeriodElapsed: () => void;
153
156
  }
154
- interface SessionHandshakingProps<ConnType extends Connection> extends IdentifiedSessionProps {
155
- conn: ConnType;
156
- listeners: SessionHandshakingListeners;
157
+ interface IdentifiedSessionWithGracePeriodProps extends IdentifiedSessionProps {
158
+ graceExpiryTime: number;
159
+ listeners: IdentifiedSessionWithGracePeriodListeners;
157
160
  }
158
- declare class SessionHandshaking<ConnType extends Connection> extends IdentifiedSession {
159
- readonly state: SessionState.Handshaking;
160
- conn: ConnType;
161
- listeners: SessionHandshakingListeners;
162
- handshakeTimeout: ReturnType<typeof setTimeout>;
163
- constructor(props: SessionHandshakingProps<ConnType>);
164
- onHandshakeData: (msg: Uint8Array) => void;
165
- sendHandshake(msg: TransportMessage): boolean;
161
+ declare abstract class IdentifiedSessionWithGracePeriod extends IdentifiedSession {
162
+ graceExpiryTime: number;
163
+ protected gracePeriodTimeout?: ReturnType<typeof setTimeout>;
164
+ listeners: IdentifiedSessionWithGracePeriodListeners;
165
+ constructor(props: IdentifiedSessionWithGracePeriodProps);
166
166
  _handleStateExit(): void;
167
167
  _handleClose(): void;
168
168
  }
169
169
 
170
- interface SessionConnectingListeners {
170
+ interface SessionConnectingListeners extends IdentifiedSessionWithGracePeriodListeners {
171
171
  onConnectionEstablished: (conn: Connection) => void;
172
172
  onConnectionFailed: (err: unknown) => void;
173
173
  onConnectionTimeout: () => void;
174
174
  }
175
- interface SessionConnectingProps<ConnType extends Connection> extends IdentifiedSessionProps {
175
+ interface SessionConnectingProps<ConnType extends Connection> extends IdentifiedSessionWithGracePeriodProps {
176
176
  connPromise: Promise<ConnType>;
177
177
  listeners: SessionConnectingListeners;
178
178
  }
179
- declare class SessionConnecting<ConnType extends Connection> extends IdentifiedSession {
179
+ declare class SessionConnecting<ConnType extends Connection> extends IdentifiedSessionWithGracePeriod {
180
180
  readonly state: SessionState.Connecting;
181
181
  connPromise: Promise<ConnType>;
182
182
  listeners: SessionConnectingListeners;
@@ -187,21 +187,35 @@ declare class SessionConnecting<ConnType extends Connection> extends IdentifiedS
187
187
  _handleClose(): void;
188
188
  }
189
189
 
190
- interface SessionNoConnectionListeners {
191
- onSessionGracePeriodElapsed: () => void;
192
- }
193
- interface SessionNoConnectionProps extends IdentifiedSessionProps {
194
- listeners: SessionNoConnectionListeners;
195
- }
196
- declare class SessionNoConnection extends IdentifiedSession {
190
+ declare class SessionNoConnection extends IdentifiedSessionWithGracePeriod {
197
191
  readonly state: SessionState.NoConnection;
198
- listeners: SessionNoConnectionListeners;
199
- gracePeriodTimeout?: ReturnType<typeof setTimeout>;
200
- constructor(props: SessionNoConnectionProps);
201
192
  _handleClose(): void;
202
193
  _handleStateExit(): void;
203
194
  }
204
195
 
196
+ interface SessionHandshakingListeners extends IdentifiedSessionWithGracePeriodListeners {
197
+ onConnectionErrored: (err: unknown) => void;
198
+ onConnectionClosed: () => void;
199
+ onHandshake: (msg: OpaqueTransportMessage) => void;
200
+ onInvalidHandshake: (reason: string, code: Static<typeof HandshakeErrorResponseCodes>) => void;
201
+ onHandshakeTimeout: () => void;
202
+ }
203
+ interface SessionHandshakingProps<ConnType extends Connection> extends IdentifiedSessionWithGracePeriodProps {
204
+ conn: ConnType;
205
+ listeners: SessionHandshakingListeners;
206
+ }
207
+ declare class SessionHandshaking<ConnType extends Connection> extends IdentifiedSessionWithGracePeriod {
208
+ readonly state: SessionState.Handshaking;
209
+ conn: ConnType;
210
+ listeners: SessionHandshakingListeners;
211
+ handshakeTimeout?: ReturnType<typeof setTimeout>;
212
+ constructor(props: SessionHandshakingProps<ConnType>);
213
+ onHandshakeData: (msg: Uint8Array) => void;
214
+ sendHandshake(msg: TransportMessage): boolean;
215
+ _handleStateExit(): void;
216
+ _handleClose(): void;
217
+ }
218
+
205
219
  interface SessionConnectedListeners {
206
220
  onConnectionErrored: (err: unknown) => void;
207
221
  onConnectionClosed: () => void;
@@ -229,14 +243,14 @@ declare class SessionConnected<ConnType extends Connection> extends IdentifiedSe
229
243
  _handleClose(): void;
230
244
  }
231
245
 
232
- interface SessionBackingOffListeners {
246
+ interface SessionBackingOffListeners extends IdentifiedSessionWithGracePeriodListeners {
233
247
  onBackoffFinished: () => void;
234
248
  }
235
- interface SessionBackingOffProps extends IdentifiedSessionProps {
249
+ interface SessionBackingOffProps extends IdentifiedSessionWithGracePeriodProps {
236
250
  backoffMs: number;
237
251
  listeners: SessionBackingOffListeners;
238
252
  }
239
- declare class SessionBackingOff extends IdentifiedSession {
253
+ declare class SessionBackingOff extends IdentifiedSessionWithGracePeriod {
240
254
  readonly state: SessionState.BackingOff;
241
255
  listeners: SessionBackingOffListeners;
242
256
  backoffTimeout?: ReturnType<typeof setTimeout>;
@@ -273,7 +287,11 @@ interface EventMap {
273
287
  state: SessionState.NoConnection;
274
288
  };
275
289
  protocolError: {
276
- type: ProtocolErrorType;
290
+ type: (typeof ProtocolError)['HandshakeFailed'];
291
+ code: Static<typeof HandshakeErrorResponseCodes>;
292
+ message: string;
293
+ } | {
294
+ type: Omit<ProtocolErrorType, (typeof ProtocolError)['HandshakeFailed']>;
277
295
  message: string;
278
296
  };
279
297
  transportStatus: {
@@ -428,7 +446,7 @@ declare abstract class Transport<ConnType extends Connection> {
428
446
  * @returns The ID of the sent message or undefined if it wasn't sent
429
447
  */
430
448
  abstract send(to: TransportClientId, msg: PartialTransportMessage): string;
431
- protected protocolError(type: ProtocolErrorType, message: string): void;
449
+ protected protocolError(message: EventMap['protocolError']): void;
432
450
  /**
433
451
  * Default close implementation for transports. You should override this in the downstream
434
452
  * implementation if you need to do any additional cleanup and call super.close() at the end.
@@ -438,7 +456,7 @@ declare abstract class Transport<ConnType extends Connection> {
438
456
  getStatus(): TransportStatus;
439
457
  protected updateSession<S extends Session<ConnType>>(session: S): S;
440
458
  protected deleteSession(session: Session<ConnType>): void;
441
- protected onSessionGracePeriodElapsed(session: SessionNoConnection): void;
459
+ protected onSessionGracePeriodElapsed(session: Session<ConnType>): void;
442
460
  protected onConnectingFailed(session: SessionConnecting<ConnType>): SessionNoConnection;
443
461
  protected onConnClosed(session: SessionHandshaking<ConnType> | SessionConnected<ConnType>): SessionNoConnection;
444
462
  }
@@ -481,7 +499,7 @@ interface ServiceContext {
481
499
  * }
482
500
  * ```
483
501
  */
484
- interface ParsedMetadata {
502
+ interface ParsedMetadata extends Record<string, unknown> {
485
503
  }
486
504
  /**
487
505
  * The {@link ServiceContext} with state. This is what is passed to procedures.
@@ -533,4 +551,4 @@ interface ServerHandshakeOptions<MetadataSchema extends TSchema = TSchema> {
533
551
  declare function createClientHandshakeOptions<MetadataSchema extends TSchema = TSchema>(schema: MetadataSchema, construct: ConstructHandshake<MetadataSchema>): ClientHandshakeOptions;
534
552
  declare function createServerHandshakeOptions<MetadataSchema extends TSchema = TSchema>(schema: MetadataSchema, validate: ValidateHandshake<MetadataSchema>): ServerHandshakeOptions;
535
553
 
536
- export { CommonSessionProps as A, ServerTransportOptions as B, Connection as C, ServerSession as D, EventMap as E, LeakyBucketRateLimit as L, ProvidedTransportOptions as P, Session as S, Transport as T, TransportStatus as a, ProvidedClientTransportOptions as b, ProvidedServerTransportOptions as c, SessionState as d, SessionNoConnection as e, SessionConnecting as f, SessionHandshaking as g, SessionConnected as h, EventTypes as i, EventHandler as j, ProtocolError as k, ProtocolErrorType as l, SessionOptions as m, ClientTransportOptions as n, ServiceContext as o, ClientHandshakeOptions as p, ClientSession as q, SessionBackingOff as r, ServerHandshakeOptions as s, ParsedMetadata as t, ServiceContextWithState as u, ServiceContextWithTransportInfo as v, createClientHandshakeOptions as w, createServerHandshakeOptions as x, CommonSession as y, SessionHandshakingListeners as z };
554
+ export { ServerTransportOptions as A, ServerSession as B, Connection as C, EventMap as E, LeakyBucketRateLimit as L, ProvidedTransportOptions as P, Session as S, Transport as T, TransportStatus as a, ProvidedClientTransportOptions as b, ProvidedServerTransportOptions as c, SessionState as d, SessionNoConnection as e, SessionConnecting as f, SessionHandshaking as g, SessionConnected as h, EventTypes as i, EventHandler as j, ProtocolError as k, ProtocolErrorType as l, SessionOptions as m, ClientTransportOptions as n, ServiceContext as o, ClientHandshakeOptions as p, ClientSession as q, SessionBackingOff as r, ServerHandshakeOptions as s, ParsedMetadata as t, ServiceContextWithState as u, ServiceContextWithTransportInfo as v, createClientHandshakeOptions as w, createServerHandshakeOptions as x, CommonSession as y, CommonSessionProps as z };
@@ -1,4 +1,4 @@
1
- export { f as LogFn, L as Logger, M as MessageMetadata, h as coloredStringLogger, j as jsonLogger, s as stringLogger } from '../message-1a434848.js';
1
+ export { f as LogFn, L as Logger, M as MessageMetadata, j as coloredStringLogger, k as jsonLogger, s as stringLogger } from '../message-57296605.js';
2
2
  import '@sinclair/typebox/value';
3
3
  import '@sinclair/typebox';
4
4
  import '@opentelemetry/api';
@@ -1,4 +1,4 @@
1
- export { f as LogFn, L as Logger, M as MessageMetadata, h as coloredStringLogger, j as jsonLogger, s as stringLogger } from '../message-1a434848.js';
1
+ export { f as LogFn, L as Logger, M as MessageMetadata, j as coloredStringLogger, k as jsonLogger, s as stringLogger } from '../message-57296605.js';
2
2
  import '@sinclair/typebox/value';
3
3
  import '@sinclair/typebox';
4
4
  import '@opentelemetry/api';
@@ -65,6 +65,7 @@ declare const TransportMessageSchema: <T extends TSchema>(t: T) => _sinclair_typ
65
65
  payload: T;
66
66
  }>;
67
67
  declare const HandshakeErrorCustomHandlerFatalResponseCodes: _sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"REJECTED_UNSUPPORTED_CLIENT">, _sinclair_typebox.TLiteral<"REJECTED_BY_CUSTOM_HANDLER">]>;
68
+ declare const HandshakeErrorResponseCodes: _sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"SESSION_STATE_MISMATCH">, _sinclair_typebox.TUnion<[_sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"REJECTED_UNSUPPORTED_CLIENT">, _sinclair_typebox.TLiteral<"REJECTED_BY_CUSTOM_HANDLER">]>, _sinclair_typebox.TLiteral<"MALFORMED_HANDSHAKE_META">, _sinclair_typebox.TLiteral<"MALFORMED_HANDSHAKE">, _sinclair_typebox.TLiteral<"PROTOCOL_VERSION_MISMATCH">]>]>;
68
69
  /**
69
70
  * Defines the schema for an opaque transport message that is agnostic to any
70
71
  * procedure/service.
@@ -134,4 +135,4 @@ declare function isStreamOpen(controlFlag: number): boolean;
134
135
  */
135
136
  declare function isStreamClose(controlFlag: number): boolean;
136
137
 
137
- export { HandshakeErrorCustomHandlerFatalResponseCodes as H, Logger as L, MessageMetadata as M, OpaqueTransportMessageSchema as O, PartialTransportMessage as P, TransportMessageSchema as T, TransportMessage as a, OpaqueTransportMessage as b, TransportClientId as c, isStreamClose as d, TelemetryInfo as e, LogFn as f, LoggingLevel as g, coloredStringLogger as h, isStreamOpen as i, jsonLogger as j, stringLogger as s };
138
+ export { HandshakeErrorResponseCodes as H, Logger as L, MessageMetadata as M, OpaqueTransportMessageSchema as O, PartialTransportMessage as P, TransportMessageSchema as T, TransportMessage as a, OpaqueTransportMessage as b, TransportClientId as c, isStreamClose as d, TelemetryInfo as e, LogFn as f, LoggingLevel as g, HandshakeErrorCustomHandlerFatalResponseCodes as h, isStreamOpen as i, coloredStringLogger as j, jsonLogger as k, stringLogger as s };
@@ -761,7 +761,7 @@ function Err(error) {
761
761
  var import_api = require("@opentelemetry/api");
762
762
 
763
763
  // package.json
764
- var version = "0.26.0";
764
+ var version = "0.26.2";
765
765
 
766
766
  // tracing/index.ts
767
767
  function getPropagationContext(ctx) {