@replit/river 0.207.2 → 0.208.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.
Files changed (65) hide show
  1. package/dist/adapter-ChksXKVN.d.ts +46 -0
  2. package/dist/adapter-Cuc4JtfV.d.cts +46 -0
  3. package/dist/chunk-2JNVDUMN.js +2238 -0
  4. package/dist/chunk-2JNVDUMN.js.map +1 -0
  5. package/dist/{chunk-4HE7UYRL.js → chunk-DKW3GC3M.js} +6 -5
  6. package/dist/{chunk-4HE7UYRL.js.map → chunk-DKW3GC3M.js.map} +1 -1
  7. package/dist/{chunk-46IVOKJU.js → chunk-ETZAHFGQ.js} +80 -61
  8. package/dist/chunk-ETZAHFGQ.js.map +1 -0
  9. package/dist/codec/index.cjs +157 -23
  10. package/dist/codec/index.cjs.map +1 -1
  11. package/dist/codec/index.d.cts +5 -1
  12. package/dist/codec/index.d.ts +5 -1
  13. package/dist/codec/index.js +6 -20
  14. package/dist/codec/index.js.map +1 -1
  15. package/dist/connection-BF4zg6Qv.d.cts +35 -0
  16. package/dist/{connection-a18e31d5.d.ts → connection-Donr3JRB.d.ts} +4 -3
  17. package/dist/index-C9tpZjBN.d.cts +37 -0
  18. package/dist/index-D8IOd3LG.d.ts +37 -0
  19. package/dist/logging/index.d.cts +2 -1
  20. package/dist/logging/index.d.ts +2 -1
  21. package/dist/{message-ffacb98a.d.ts → message-Di94OL80.d.cts} +1 -35
  22. package/dist/message-Di94OL80.d.ts +108 -0
  23. package/dist/router/index.cjs +62 -43
  24. package/dist/router/index.cjs.map +1 -1
  25. package/dist/router/index.d.cts +27 -7
  26. package/dist/router/index.d.ts +27 -7
  27. package/dist/router/index.js +1 -1
  28. package/dist/testUtil/index.cjs +828 -725
  29. package/dist/testUtil/index.cjs.map +1 -1
  30. package/dist/testUtil/index.d.cts +5 -4
  31. package/dist/testUtil/index.d.ts +5 -4
  32. package/dist/testUtil/index.js +23 -25
  33. package/dist/testUtil/index.js.map +1 -1
  34. package/dist/transport/impls/ws/client.cjs +293 -233
  35. package/dist/transport/impls/ws/client.cjs.map +1 -1
  36. package/dist/transport/impls/ws/client.d.cts +6 -5
  37. package/dist/transport/impls/ws/client.d.ts +6 -5
  38. package/dist/transport/impls/ws/client.js +5 -7
  39. package/dist/transport/impls/ws/client.js.map +1 -1
  40. package/dist/transport/impls/ws/server.cjs +269 -200
  41. package/dist/transport/impls/ws/server.cjs.map +1 -1
  42. package/dist/transport/impls/ws/server.d.cts +6 -5
  43. package/dist/transport/impls/ws/server.d.ts +6 -5
  44. package/dist/transport/impls/ws/server.js +5 -7
  45. package/dist/transport/impls/ws/server.js.map +1 -1
  46. package/dist/transport/index.cjs +438 -342
  47. package/dist/transport/index.cjs.map +1 -1
  48. package/dist/transport/index.d.cts +7 -6
  49. package/dist/transport/index.d.ts +7 -6
  50. package/dist/transport/index.js +5 -10
  51. package/dist/transport-CCaWx1Rb.d.cts +1566 -0
  52. package/dist/{services-43528f4b.d.ts → transport-CZb3vdB4.d.ts} +294 -293
  53. package/dist/{wslike-e0b32dd5.d.ts → wslike-Dng9H1C7.d.cts} +1 -1
  54. package/dist/wslike-Dng9H1C7.d.ts +40 -0
  55. package/package.json +3 -3
  56. package/dist/chunk-24EWYOGK.js +0 -1287
  57. package/dist/chunk-24EWYOGK.js.map +0 -1
  58. package/dist/chunk-46IVOKJU.js.map +0 -1
  59. package/dist/chunk-A7RGOVRV.js +0 -438
  60. package/dist/chunk-A7RGOVRV.js.map +0 -1
  61. package/dist/chunk-AJGIY2UB.js +0 -56
  62. package/dist/chunk-AJGIY2UB.js.map +0 -1
  63. package/dist/chunk-XV4RQ62N.js +0 -377
  64. package/dist/chunk-XV4RQ62N.js.map +0 -1
  65. package/dist/types-3e5768ec.d.ts +0 -20
@@ -1,10 +1,11 @@
1
- import { A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, c as ParsedMetadata, d as AnyProcedure, b as Connection, S as ServerHandshakeOptions, e as ServiceContext } from '../services-43528f4b.js';
2
- export { M as BaseErrorSchemaType, K as CANCEL_CODE, O as Client, X as Err, Z as ErrResult, J as INVALID_REQUEST_CODE, T as Ok, _ as OkResult, w as PayloadType, l as ProcErrors, h as ProcHandler, i as ProcInit, j as ProcRequest, k as ProcResponse, m as ProcType, D as Procedure, E as ProcedureErrorSchemaType, Q as ProcedureHandlerContext, x as ProcedureMap, R as RPCProcedure, B as Readable, L as ReaderErrorSchema, a1 as ResponseData, Y as Result, a0 as ResultUnwrapErr, $ as ResultUnwrapOk, q as SerializedProcedureSchema, v as SerializedProcedureSchemaProtocolv1, o as SerializedServerSchema, t as SerializedServerSchemaProtocolv1, p as SerializedServiceSchema, u as SerializedServiceSchemaProtocolv1, f as Service, g as ServiceConfiguration, n as ServiceSchema, z as StreamProcedure, y as SubscriptionProcedure, G as UNCAUGHT_ERROR_CODE, H as UNEXPECTED_DISCONNECT_CODE, U as UploadProcedure, V as ValidProcType, W as Writable, N as createClient, a2 as createClientHandshakeOptions, a3 as createServerHandshakeOptions, F as flattenErrorType, s as serializeSchema, r as serializeSchemaV1Compat } from '../services-43528f4b.js';
3
- import { T as TransportClientId, O as OpaqueTransportMessage } from '../message-ffacb98a.js';
1
+ import { A as AnyServiceSchemaMap, b as Connection, S as ServerHandshakeOptions, c as ServiceContext, d as ProcedureHandlerContext, e as PayloadType, I as InstantiatedServiceSchemaMap, f as ParsedMetadata, g as AnyProcedure } from '../transport-CCaWx1Rb.cjs';
2
+ export { N as BaseErrorSchemaType, L as CANCEL_CODE, Q as Client, X as Err, Z as ErrResult, K as INVALID_REQUEST_CODE, T as Ok, _ as OkResult, n as ProcErrors, j as ProcHandler, k as ProcInit, l as ProcRequest, m as ProcResponse, o as ProcType, E as Procedure, F as ProcedureErrorSchemaType, y as ProcedureMap, R as RPCProcedure, D as Readable, M as ReaderErrorSchema, a1 as ResponseData, Y as Result, a0 as ResultUnwrapErr, $ as ResultUnwrapOk, t as SerializedProcedureSchema, x as SerializedProcedureSchemaProtocolv1, q as SerializedServerSchema, v as SerializedServerSchemaProtocolv1, r as SerializedServiceSchema, w as SerializedServiceSchemaProtocolv1, h as Service, i as ServiceConfiguration, p as ServiceSchema, B as StreamProcedure, z as SubscriptionProcedure, H as UNCAUGHT_ERROR_CODE, J as UNEXPECTED_DISCONNECT_CODE, U as UploadProcedure, V as ValidProcType, W as Writable, O as createClient, a2 as createClientHandshakeOptions, a3 as createServerHandshakeOptions, G as flattenErrorType, s as serializeSchema, u as serializeSchemaV1Compat } from '../transport-CCaWx1Rb.cjs';
3
+ import { Static } from '@sinclair/typebox';
4
+ import { T as TransportClientId, O as OpaqueTransportMessage } from '../message-Di94OL80.cjs';
4
5
  import { ServerTransport } from '../transport/index.cjs';
5
- import '@sinclair/typebox';
6
6
  import '@opentelemetry/api';
7
- import '../types-3e5768ec.js';
7
+ import '../index-C9tpZjBN.cjs';
8
+ import '../adapter-Cuc4JtfV.cjs';
8
9
 
9
10
  type StreamId = string;
10
11
  /**
@@ -32,6 +33,21 @@ interface ProcStream {
32
33
  handleMsg: (msg: OpaqueTransportMessage) => void;
33
34
  handleSessionDisconnect: () => void;
34
35
  }
36
+ interface MiddlewareContext extends Readonly<Omit<ProcedureHandlerContext<unknown>, 'cancel'>> {
37
+ readonly streamId: StreamId;
38
+ readonly procedureName: string;
39
+ readonly serviceName: string;
40
+ }
41
+ interface MiddlewareParam {
42
+ readonly ctx: MiddlewareContext;
43
+ readonly reqInit: Static<PayloadType>;
44
+ next: () => void;
45
+ }
46
+ /**
47
+ * Middleware is a function that can inspect requests as they are received.
48
+ * For now modification of the request is not supported behavior.
49
+ */
50
+ type Middleware = (param: MiddlewareParam) => void;
35
51
  /**
36
52
  * Creates a server instance that listens for incoming messages from a transport and routes them to the appropriate service and procedure.
37
53
  * The server tracks the state of each service along with open streams and the extended context object.
@@ -49,8 +65,12 @@ declare function createServer<Services extends AnyServiceSchemaMap>(transport: S
49
65
  * cascading stream errors.
50
66
  */
51
67
  maxCancelledStreamTombstonesPerSession?: number;
68
+ /**
69
+ * Middlewares run before procedure handlers allowing you to inspect requests and responses..
70
+ */
71
+ middlewares?: Array<Middleware>;
52
72
  }>): Server<Services>;
53
73
 
54
- var version = "0.207.2";
74
+ var version = "0.208.0";
55
75
 
56
- export { ParsedMetadata, version as RIVER_VERSION, Server, ServiceContext, createServer };
76
+ export { type Middleware, type MiddlewareContext, type MiddlewareParam, ParsedMetadata, PayloadType, ProcedureHandlerContext, version as RIVER_VERSION, type Server, ServiceContext, createServer };
@@ -1,10 +1,11 @@
1
- import { A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, c as ParsedMetadata, d as AnyProcedure, b as Connection, S as ServerHandshakeOptions, e as ServiceContext } from '../services-43528f4b.js';
2
- export { M as BaseErrorSchemaType, K as CANCEL_CODE, O as Client, X as Err, Z as ErrResult, J as INVALID_REQUEST_CODE, T as Ok, _ as OkResult, w as PayloadType, l as ProcErrors, h as ProcHandler, i as ProcInit, j as ProcRequest, k as ProcResponse, m as ProcType, D as Procedure, E as ProcedureErrorSchemaType, Q as ProcedureHandlerContext, x as ProcedureMap, R as RPCProcedure, B as Readable, L as ReaderErrorSchema, a1 as ResponseData, Y as Result, a0 as ResultUnwrapErr, $ as ResultUnwrapOk, q as SerializedProcedureSchema, v as SerializedProcedureSchemaProtocolv1, o as SerializedServerSchema, t as SerializedServerSchemaProtocolv1, p as SerializedServiceSchema, u as SerializedServiceSchemaProtocolv1, f as Service, g as ServiceConfiguration, n as ServiceSchema, z as StreamProcedure, y as SubscriptionProcedure, G as UNCAUGHT_ERROR_CODE, H as UNEXPECTED_DISCONNECT_CODE, U as UploadProcedure, V as ValidProcType, W as Writable, N as createClient, a2 as createClientHandshakeOptions, a3 as createServerHandshakeOptions, F as flattenErrorType, s as serializeSchema, r as serializeSchemaV1Compat } from '../services-43528f4b.js';
3
- import { T as TransportClientId, O as OpaqueTransportMessage } from '../message-ffacb98a.js';
1
+ import { A as AnyServiceSchemaMap, b as Connection, S as ServerHandshakeOptions, c as ServiceContext, d as ProcedureHandlerContext, e as PayloadType, I as InstantiatedServiceSchemaMap, f as ParsedMetadata, g as AnyProcedure } from '../transport-CZb3vdB4.js';
2
+ export { N as BaseErrorSchemaType, L as CANCEL_CODE, Q as Client, X as Err, Z as ErrResult, K as INVALID_REQUEST_CODE, T as Ok, _ as OkResult, n as ProcErrors, j as ProcHandler, k as ProcInit, l as ProcRequest, m as ProcResponse, o as ProcType, E as Procedure, F as ProcedureErrorSchemaType, y as ProcedureMap, R as RPCProcedure, D as Readable, M as ReaderErrorSchema, a1 as ResponseData, Y as Result, a0 as ResultUnwrapErr, $ as ResultUnwrapOk, t as SerializedProcedureSchema, x as SerializedProcedureSchemaProtocolv1, q as SerializedServerSchema, v as SerializedServerSchemaProtocolv1, r as SerializedServiceSchema, w as SerializedServiceSchemaProtocolv1, h as Service, i as ServiceConfiguration, p as ServiceSchema, B as StreamProcedure, z as SubscriptionProcedure, H as UNCAUGHT_ERROR_CODE, J as UNEXPECTED_DISCONNECT_CODE, U as UploadProcedure, V as ValidProcType, W as Writable, O as createClient, a2 as createClientHandshakeOptions, a3 as createServerHandshakeOptions, G as flattenErrorType, s as serializeSchema, u as serializeSchemaV1Compat } from '../transport-CZb3vdB4.js';
3
+ import { Static } from '@sinclair/typebox';
4
+ import { T as TransportClientId, O as OpaqueTransportMessage } from '../message-Di94OL80.js';
4
5
  import { ServerTransport } from '../transport/index.js';
5
- import '@sinclair/typebox';
6
6
  import '@opentelemetry/api';
7
- import '../types-3e5768ec.js';
7
+ import '../index-D8IOd3LG.js';
8
+ import '../adapter-ChksXKVN.js';
8
9
 
9
10
  type StreamId = string;
10
11
  /**
@@ -32,6 +33,21 @@ interface ProcStream {
32
33
  handleMsg: (msg: OpaqueTransportMessage) => void;
33
34
  handleSessionDisconnect: () => void;
34
35
  }
36
+ interface MiddlewareContext extends Readonly<Omit<ProcedureHandlerContext<unknown>, 'cancel'>> {
37
+ readonly streamId: StreamId;
38
+ readonly procedureName: string;
39
+ readonly serviceName: string;
40
+ }
41
+ interface MiddlewareParam {
42
+ readonly ctx: MiddlewareContext;
43
+ readonly reqInit: Static<PayloadType>;
44
+ next: () => void;
45
+ }
46
+ /**
47
+ * Middleware is a function that can inspect requests as they are received.
48
+ * For now modification of the request is not supported behavior.
49
+ */
50
+ type Middleware = (param: MiddlewareParam) => void;
35
51
  /**
36
52
  * Creates a server instance that listens for incoming messages from a transport and routes them to the appropriate service and procedure.
37
53
  * The server tracks the state of each service along with open streams and the extended context object.
@@ -49,8 +65,12 @@ declare function createServer<Services extends AnyServiceSchemaMap>(transport: S
49
65
  * cascading stream errors.
50
66
  */
51
67
  maxCancelledStreamTombstonesPerSession?: number;
68
+ /**
69
+ * Middlewares run before procedure handlers allowing you to inspect requests and responses..
70
+ */
71
+ middlewares?: Array<Middleware>;
52
72
  }>): Server<Services>;
53
73
 
54
- var version = "0.207.2";
74
+ var version = "0.208.0";
55
75
 
56
- export { ParsedMetadata, version as RIVER_VERSION, Server, ServiceContext, createServer };
76
+ export { type Middleware, type MiddlewareContext, type MiddlewareParam, ParsedMetadata, PayloadType, ProcedureHandlerContext, version as RIVER_VERSION, type Server, ServiceContext, createServer };
@@ -16,7 +16,7 @@ import {
16
16
  serializeSchema,
17
17
  serializeSchemaV1Compat,
18
18
  version
19
- } from "../chunk-46IVOKJU.js";
19
+ } from "../chunk-ETZAHFGQ.js";
20
20
  export {
21
21
  CANCEL_CODE,
22
22
  Err,