@replit/river 0.23.12 → 0.23.13

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 (74) hide show
  1. package/dist/chunk-2FNLANTJ.js +327 -0
  2. package/dist/chunk-2FNLANTJ.js.map +1 -0
  3. package/dist/{chunk-3AW3IXVD.js → chunk-4PVU7J25.js} +1 -21
  4. package/dist/chunk-4PVU7J25.js.map +1 -0
  5. package/dist/{chunk-H6KTH6W6.js → chunk-4QZOW4DH.js} +2 -2
  6. package/dist/{chunk-7RUKEUKE.js → chunk-ES4XO2XD.js} +2 -2
  7. package/dist/{chunk-7RUKEUKE.js.map → chunk-ES4XO2XD.js.map} +1 -1
  8. package/dist/{chunk-XZ6IOBM5.js → chunk-KFTGQ3QC.js} +2 -2
  9. package/dist/chunk-KFTGQ3QC.js.map +1 -0
  10. package/dist/chunk-S4DUN7KK.js +455 -0
  11. package/dist/chunk-S4DUN7KK.js.map +1 -0
  12. package/dist/{chunk-HDBVL7EF.js → chunk-SX6HI63Q.js} +2 -2
  13. package/dist/chunk-XM656KMN.js +408 -0
  14. package/dist/chunk-XM656KMN.js.map +1 -0
  15. package/dist/chunk-ZUKDZY54.js +271 -0
  16. package/dist/chunk-ZUKDZY54.js.map +1 -0
  17. package/dist/client-dd5c9dd0.d.ts +52 -0
  18. package/dist/codec/index.js +20 -2
  19. package/dist/codec/index.js.map +1 -1
  20. package/dist/{connection-8debd45f.d.ts → connection-39816c00.d.ts} +1 -1
  21. package/dist/{connection-581558f8.d.ts → connection-40318f22.d.ts} +1 -1
  22. package/dist/{transport-47af1c81.d.ts → handshake-e428d1c8.d.ts} +88 -153
  23. package/dist/{index-60f03cb7.d.ts → index-ea74cdbb.d.ts} +1 -1
  24. package/dist/logging/index.d.cts +1 -1
  25. package/dist/logging/index.d.ts +1 -1
  26. package/dist/router/index.cjs +1 -1
  27. package/dist/router/index.cjs.map +1 -1
  28. package/dist/router/index.d.cts +8 -6
  29. package/dist/router/index.d.ts +8 -6
  30. package/dist/router/index.js +2 -2
  31. package/dist/server-ebf80863.d.ts +24 -0
  32. package/dist/{services-ca72c9f8.d.ts → services-f406b3aa.d.ts} +3 -2
  33. package/dist/transport/impls/uds/client.cjs +192 -164
  34. package/dist/transport/impls/uds/client.cjs.map +1 -1
  35. package/dist/transport/impls/uds/client.d.cts +6 -5
  36. package/dist/transport/impls/uds/client.d.ts +6 -5
  37. package/dist/transport/impls/uds/client.js +6 -4
  38. package/dist/transport/impls/uds/client.js.map +1 -1
  39. package/dist/transport/impls/uds/server.cjs +240 -212
  40. package/dist/transport/impls/uds/server.cjs.map +1 -1
  41. package/dist/transport/impls/uds/server.d.cts +6 -5
  42. package/dist/transport/impls/uds/server.d.ts +6 -5
  43. package/dist/transport/impls/uds/server.js +8 -6
  44. package/dist/transport/impls/uds/server.js.map +1 -1
  45. package/dist/transport/impls/ws/client.cjs +194 -166
  46. package/dist/transport/impls/ws/client.cjs.map +1 -1
  47. package/dist/transport/impls/ws/client.d.cts +6 -5
  48. package/dist/transport/impls/ws/client.d.ts +6 -5
  49. package/dist/transport/impls/ws/client.js +6 -4
  50. package/dist/transport/impls/ws/client.js.map +1 -1
  51. package/dist/transport/impls/ws/server.cjs +194 -166
  52. package/dist/transport/impls/ws/server.cjs.map +1 -1
  53. package/dist/transport/impls/ws/server.d.cts +4 -3
  54. package/dist/transport/impls/ws/server.d.ts +4 -3
  55. package/dist/transport/impls/ws/server.js +8 -6
  56. package/dist/transport/impls/ws/server.js.map +1 -1
  57. package/dist/transport/index.cjs +138 -104
  58. package/dist/transport/index.cjs.map +1 -1
  59. package/dist/transport/index.d.cts +4 -2
  60. package/dist/transport/index.d.ts +4 -2
  61. package/dist/transport/index.js +14 -8
  62. package/dist/util/testHelpers.cjs +2 -6
  63. package/dist/util/testHelpers.cjs.map +1 -1
  64. package/dist/util/testHelpers.d.cts +5 -4
  65. package/dist/util/testHelpers.d.ts +5 -4
  66. package/dist/util/testHelpers.js +4 -5
  67. package/dist/util/testHelpers.js.map +1 -1
  68. package/package.json +1 -1
  69. package/dist/chunk-3AW3IXVD.js.map +0 -1
  70. package/dist/chunk-VRU4IKRT.js +0 -1392
  71. package/dist/chunk-VRU4IKRT.js.map +0 -1
  72. package/dist/chunk-XZ6IOBM5.js.map +0 -1
  73. /package/dist/{chunk-H6KTH6W6.js.map → chunk-4QZOW4DH.js.map} +0 -0
  74. /package/dist/{chunk-HDBVL7EF.js.map → chunk-SX6HI63Q.js.map} +0 -0
@@ -1,5 +1,5 @@
1
- import { a as TelemetryInfo, M as MessageMetadata, T as TransportClientId, b as PropagationContext, L as Logger, P as PartialTransportMessage, c as TransportMessage, O as OpaqueTransportMessage, g as LogFn, h as LoggingLevel } from './index-60f03cb7.js';
2
1
  import { C as Codec } from './types-3e5768ec.js';
2
+ import { e as TelemetryInfo, M as MessageMetadata, c as TransportClientId, f as PropagationContext, L as Logger, P as PartialTransportMessage, a as TransportMessage, b as OpaqueTransportMessage, g as LogFn, h as LoggingLevel } from './index-ea74cdbb.js';
3
3
  import { TSchema, Static } from '@sinclair/typebox';
4
4
 
5
5
  /**
@@ -244,95 +244,12 @@ declare class LeakyBucketRateLimit {
244
244
  close(): void;
245
245
  }
246
246
 
247
- /**
248
- * The context for services/procedures. This is used only on
249
- * the server.
250
- *
251
- * An important detail is that the state prop is always on
252
- * this interface and it shouldn't be changed, removed, or
253
- * extended. This prop is for the state of a service.
254
- *
255
- * You should use declaration merging to extend this interface
256
- * with whatever you need. For example, if you need to access
257
- * a database, you could do:
258
- *
259
- * ```ts
260
- * declare module '@replit/river' {
261
- * interface ServiceContext {
262
- * db: Database;
263
- * }
264
- * }
265
- * ```
266
- */
267
- interface ServiceContext {
268
- }
269
- /**
270
- * The parsed metadata schema for a service. This is the
271
- * return value of the {@link ServerHandshakeOptions.validate}
272
- * if the handshake extension is used.
273
-
274
- * You should use declaration merging to extend this interface
275
- * with the sanitized metadata.
276
- *
277
- * ```ts
278
- * declare module '@replit/river' {
279
- * interface ParsedMetadata {
280
- * userId: number;
281
- * }
282
- * }
283
- * ```
284
- */
285
- interface ParsedMetadata {
286
- }
287
- /**
288
- * The {@link ServiceContext} with state. This is what is passed to procedures.
289
- */
290
- type ServiceContextWithState<State> = ServiceContext & {
291
- state: State;
292
- };
293
- type ServiceContextWithTransportInfo<State> = ServiceContext & {
294
- state: State;
295
- to: TransportClientId;
296
- from: TransportClientId;
297
- streamId: string;
298
- session: Session<Connection>;
299
- metadata: ParsedMetadata;
300
- };
301
-
302
- type ConstructHandshake<T extends TSchema> = () => Static<T> | Promise<Static<T>>;
303
- type ValidateHandshake<T extends TSchema> = (metadata: Static<T>, previousParsedMetadata?: ParsedMetadata) => false | ParsedMetadata | Promise<false | ParsedMetadata>;
304
- interface ClientHandshakeOptions<MetadataSchema extends TSchema = TSchema> {
305
- /**
306
- * Schema for the metadata that the client sends to the server
307
- * during the handshake.
308
- */
309
- schema: MetadataSchema;
310
- /**
311
- * Gets the {@link HandshakeRequestMetadata} to send to the server.
312
- */
313
- construct: ConstructHandshake<MetadataSchema>;
314
- }
315
- interface ServerHandshakeOptions<MetadataSchema extends TSchema = TSchema> {
316
- /**
317
- * Schema for the metadata that the server receives from the client
318
- * during the handshake.
319
- */
320
- schema: MetadataSchema;
321
- /**
322
- * Parses the {@link HandshakeRequestMetadata} sent by the client, transforming
323
- * it into {@link ParsedHandshakeMetadata}.
324
- *
325
- * May return `false` if the client should be rejected.
326
- *
327
- * @param metadata - The metadata sent by the client.
328
- * @param session - The session that the client would be associated with.
329
- * @param isReconnect - Whether the client is reconnecting to the session,
330
- * or if this is a new session.
331
- */
332
- validate: ValidateHandshake<MetadataSchema>;
333
- }
334
- declare function createClientHandshakeOptions<MetadataSchema extends TSchema = TSchema>(schema: MetadataSchema, construct: ConstructHandshake<MetadataSchema>): ClientHandshakeOptions;
335
- declare function createServerHandshakeOptions<MetadataSchema extends TSchema = TSchema>(schema: MetadataSchema, validate: ValidateHandshake<MetadataSchema>): ServerHandshakeOptions;
247
+ type TransportOptions = SessionOptions;
248
+ type ProvidedTransportOptions = Partial<TransportOptions>;
249
+ type ClientTransportOptions = TransportOptions & ConnectionRetryOptions;
250
+ type ProvidedClientTransportOptions = Partial<ClientTransportOptions>;
251
+ type ServerTransportOptions = TransportOptions;
252
+ type ProvidedServerTransportOptions = Partial<ServerTransportOptions>;
336
253
 
337
254
  /**
338
255
  * Represents the possible states of a transport.
@@ -340,12 +257,6 @@ declare function createServerHandshakeOptions<MetadataSchema extends TSchema = T
340
257
  * @property {'closed'} closed - The transport is permanently closed and cannot be reopened.
341
258
  */
342
259
  type TransportStatus = 'open' | 'closed';
343
- type TransportOptions = SessionOptions;
344
- type ProvidedTransportOptions = Partial<TransportOptions>;
345
- type ClientTransportOptions = TransportOptions & ConnectionRetryOptions;
346
- type ProvidedClientTransportOptions = Partial<ClientTransportOptions>;
347
- type ServerTransportOptions = TransportOptions;
348
- type ProvidedServerTransportOptions = Partial<ServerTransportOptions>;
349
260
  /**
350
261
  * Transports manage the lifecycle (creation/deletion) of sessions and connections. Its responsibilities include:
351
262
  *
@@ -493,71 +404,95 @@ declare abstract class Transport<ConnType extends Connection> {
493
404
  close(): void;
494
405
  getStatus(): TransportStatus;
495
406
  }
496
- declare abstract class ClientTransport<ConnType extends Connection> extends Transport<ConnType> {
497
- /**
498
- * The options for this transport.
499
- */
500
- protected options: ClientTransportOptions;
501
- /**
502
- * The map of reconnect promises for each client ID.
503
- */
504
- inflightConnectionPromises: Map<TransportClientId, Promise<ConnType>>;
505
- retryBudget: LeakyBucketRateLimit;
506
- /**
507
- * A flag indicating whether the transport should automatically reconnect
508
- * when a connection is dropped.
509
- * Realistically, this should always be true for clients unless you are writing
510
- * tests or a special case where you don't want to reconnect.
511
- */
512
- reconnectOnConnectionDrop: boolean;
513
- /**
514
- * Optional handshake options for this client.
515
- */
516
- handshakeExtensions?: ClientHandshakeOptions;
517
- constructor(clientId: TransportClientId, providedOptions?: ProvidedClientTransportOptions);
518
- extendHandshake(options: ClientHandshakeOptions): void;
519
- protected handleConnection(conn: ConnType, to: TransportClientId): void;
520
- receiveHandshakeResponseMessage(data: Uint8Array, conn: ConnType): Session<ConnType> | false;
407
+
408
+ /**
409
+ * The context for services/procedures. This is used only on
410
+ * the server.
411
+ *
412
+ * An important detail is that the state prop is always on
413
+ * this interface and it shouldn't be changed, removed, or
414
+ * extended. This prop is for the state of a service.
415
+ *
416
+ * You should use declaration merging to extend this interface
417
+ * with whatever you need. For example, if you need to access
418
+ * a database, you could do:
419
+ *
420
+ * ```ts
421
+ * declare module '@replit/river' {
422
+ * interface ServiceContext {
423
+ * db: Database;
424
+ * }
425
+ * }
426
+ * ```
427
+ */
428
+ interface ServiceContext {
429
+ }
430
+ /**
431
+ * The parsed metadata schema for a service. This is the
432
+ * return value of the {@link ServerHandshakeOptions.validate}
433
+ * if the handshake extension is used.
434
+
435
+ * You should use declaration merging to extend this interface
436
+ * with the sanitized metadata.
437
+ *
438
+ * ```ts
439
+ * declare module '@replit/river' {
440
+ * interface ParsedMetadata {
441
+ * userId: number;
442
+ * }
443
+ * }
444
+ * ```
445
+ */
446
+ interface ParsedMetadata {
447
+ }
448
+ /**
449
+ * The {@link ServiceContext} with state. This is what is passed to procedures.
450
+ */
451
+ type ServiceContextWithState<State> = ServiceContext & {
452
+ state: State;
453
+ };
454
+ type ServiceContextWithTransportInfo<State> = ServiceContext & {
455
+ state: State;
456
+ to: TransportClientId;
457
+ from: TransportClientId;
458
+ streamId: string;
459
+ session: Session<Connection>;
460
+ metadata: ParsedMetadata;
461
+ };
462
+
463
+ type ConstructHandshake<T extends TSchema> = () => Static<T> | Promise<Static<T>>;
464
+ type ValidateHandshake<T extends TSchema> = (metadata: Static<T>, previousParsedMetadata?: ParsedMetadata) => false | ParsedMetadata | Promise<false | ParsedMetadata>;
465
+ interface ClientHandshakeOptions<MetadataSchema extends TSchema = TSchema> {
521
466
  /**
522
- * Abstract method that creates a new {@link Connection} object.
523
- * This should call {@link handleConnection} when the connection is created.
524
- * The downstream client implementation needs to implement this.
525
- *
526
- * @param to The client ID of the node to connect to.
527
- * @returns The new connection object.
467
+ * Schema for the metadata that the client sends to the server
468
+ * during the handshake.
528
469
  */
529
- protected abstract createNewOutgoingConnection(to: TransportClientId): Promise<ConnType>;
470
+ schema: MetadataSchema;
530
471
  /**
531
- * Manually attempts to connect to a client.
532
- * @param to The client ID of the node to connect to.
472
+ * Gets the {@link HandshakeRequestMetadata} to send to the server.
533
473
  */
534
- connect(to: TransportClientId): Promise<void>;
535
- protected deleteSession({ session, closeHandshakingConnection, handshakingConn, }: {
536
- session: Session<ConnType>;
537
- closeHandshakingConnection: boolean;
538
- handshakingConn?: ConnType;
539
- }): void;
540
- protected sendHandshake(to: TransportClientId, conn: ConnType): Promise<boolean>;
541
- close(): void;
474
+ construct: ConstructHandshake<MetadataSchema>;
542
475
  }
543
- declare abstract class ServerTransport<ConnType extends Connection> extends Transport<ConnType> {
544
- /**
545
- * The options for this transport.
546
- */
547
- protected options: ServerTransportOptions;
476
+ interface ServerHandshakeOptions<MetadataSchema extends TSchema = TSchema> {
548
477
  /**
549
- * Optional handshake options for the server.
478
+ * Schema for the metadata that the server receives from the client
479
+ * during the handshake.
550
480
  */
551
- handshakeExtensions?: ServerHandshakeOptions;
481
+ schema: MetadataSchema;
552
482
  /**
553
- * A map of session handshake data for each session.
483
+ * Parses the {@link HandshakeRequestMetadata} sent by the client, transforming
484
+ * it into {@link ParsedHandshakeMetadata}.
485
+ *
486
+ * May return `false` if the client should be rejected.
487
+ *
488
+ * @param metadata - The metadata sent by the client.
489
+ * @param session - The session that the client would be associated with.
490
+ * @param isReconnect - Whether the client is reconnecting to the session,
491
+ * or if this is a new session.
554
492
  */
555
- sessionHandshakeMetadata: WeakMap<Session<ConnType>, ParsedMetadata>;
556
- constructor(clientId: TransportClientId, providedOptions?: ProvidedServerTransportOptions);
557
- extendHandshake(options: ServerHandshakeOptions): void;
558
- protected handleConnection(conn: ConnType): void;
559
- private validateHandshakeMetadata;
560
- receiveHandshakeRequestMessage(data: Uint8Array, conn: ConnType): Promise<Session<ConnType> | false>;
493
+ validate: ValidateHandshake<MetadataSchema>;
561
494
  }
495
+ declare function createClientHandshakeOptions<MetadataSchema extends TSchema = TSchema>(schema: MetadataSchema, construct: ConstructHandshake<MetadataSchema>): ClientHandshakeOptions;
496
+ declare function createServerHandshakeOptions<MetadataSchema extends TSchema = TSchema>(schema: MetadataSchema, validate: ValidateHandshake<MetadataSchema>): ServerHandshakeOptions;
562
497
 
563
- export { Connection as C, EventMap as E, ProvidedClientTransportOptions as P, SessionOptions as S, Transport as T, Session as a, ServiceContext as b, ClientTransport as c, ServerTransport as d, ProvidedServerTransportOptions as e, ServerHandshakeOptions as f, ParsedMetadata as g, ServiceContextWithState as h, ServiceContextWithTransportInfo as i, createClientHandshakeOptions as j, createServerHandshakeOptions as k, ClientHandshakeOptions as l, ProvidedTransportOptions as m, TransportStatus as n, EventTypes as o, EventHandler as p, ProtocolError as q, ProtocolErrorType as r };
498
+ export { 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, EventTypes as d, EventHandler as e, ProtocolError as f, ProtocolErrorType as g, SessionOptions as h, ServiceContext as i, ClientTransportOptions as j, ClientHandshakeOptions as k, ServerTransportOptions as l, ServerHandshakeOptions as m, ParsedMetadata as n, ServiceContextWithState as o, ServiceContextWithTransportInfo as p, createClientHandshakeOptions as q, createServerHandshakeOptions as r };
@@ -133,4 +133,4 @@ declare function isStreamOpen(controlFlag: number): boolean;
133
133
  */
134
134
  declare function isStreamClose(controlFlag: number): boolean;
135
135
 
136
- export { Logger as L, MessageMetadata as M, OpaqueTransportMessage as O, PartialTransportMessage as P, TransportClientId as T, TelemetryInfo as a, PropagationContext as b, TransportMessage as c, TransportMessageSchema as d, OpaqueTransportMessageSchema as e, isStreamClose as f, LogFn as g, LoggingLevel as h, isStreamOpen as i, coloredStringLogger as j, jsonLogger as k, stringLogger as s };
136
+ export { 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, PropagationContext as f, LogFn as g, LoggingLevel as h, isStreamOpen as i, coloredStringLogger as j, jsonLogger as k, stringLogger as s };
@@ -1,4 +1,4 @@
1
- export { g as LogFn, L as Logger, M as MessageMetadata, j as coloredStringLogger, k as jsonLogger, s as stringLogger } from '../index-60f03cb7.js';
1
+ export { g as LogFn, L as Logger, M as MessageMetadata, j as coloredStringLogger, k as jsonLogger, s as stringLogger } from '../index-ea74cdbb.js';
2
2
  import '@sinclair/typebox/value';
3
3
  import '@sinclair/typebox';
4
4
  import '@opentelemetry/api';
@@ -1,4 +1,4 @@
1
- export { g as LogFn, L as Logger, M as MessageMetadata, j as coloredStringLogger, k as jsonLogger, s as stringLogger } from '../index-60f03cb7.js';
1
+ export { g as LogFn, L as Logger, M as MessageMetadata, j as coloredStringLogger, k as jsonLogger, s as stringLogger } from '../index-ea74cdbb.js';
2
2
  import '@sinclair/typebox/value';
3
3
  import '@sinclair/typebox';
4
4
  import '@opentelemetry/api';
@@ -1172,7 +1172,7 @@ function Err(error) {
1172
1172
  var import_api = require("@opentelemetry/api");
1173
1173
 
1174
1174
  // package.json
1175
- var version = "0.23.12";
1175
+ var version = "0.23.13";
1176
1176
 
1177
1177
  // tracing/index.ts
1178
1178
  function getPropagationContext(ctx) {