@replit/river 0.208.1 → 0.208.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 (50) hide show
  1. package/dist/{adapter-f2b6e211.d.ts → adapter-ChksXKVN.d.ts} +2 -2
  2. package/dist/adapter-Cuc4JtfV.d.cts +46 -0
  3. package/dist/{chunk-2WFRHXDZ.js → chunk-2OE32RBD.js} +11 -16
  4. package/dist/{chunk-2WFRHXDZ.js.map → chunk-2OE32RBD.js.map} +1 -1
  5. package/dist/{chunk-BXKBENJE.js → chunk-XB663LV7.js} +2 -2
  6. package/dist/{chunk-EVAQ2QMB.js → chunk-XS6CNYUH.js} +21 -25
  7. package/dist/{chunk-EVAQ2QMB.js.map → chunk-XS6CNYUH.js.map} +1 -1
  8. package/dist/codec/index.d.cts +3 -3
  9. package/dist/codec/index.d.ts +3 -3
  10. package/dist/codec/index.js +2 -2
  11. package/dist/connection-BF4zg6Qv.d.cts +35 -0
  12. package/dist/{connection-098d4aad.d.ts → connection-Donr3JRB.d.ts} +4 -4
  13. package/dist/index-C9tpZjBN.d.cts +37 -0
  14. package/dist/{index-02554794.d.ts → index-D8IOd3LG.d.ts} +2 -2
  15. package/dist/logging/index.d.cts +2 -2
  16. package/dist/logging/index.d.ts +2 -2
  17. package/dist/{message-01c3e85a.d.ts → message-Di94OL80.d.cts} +1 -1
  18. package/dist/message-Di94OL80.d.ts +108 -0
  19. package/dist/router/index.cjs +5 -9
  20. package/dist/router/index.cjs.map +1 -1
  21. package/dist/router/index.d.cts +7 -7
  22. package/dist/router/index.d.ts +7 -7
  23. package/dist/router/index.js +1 -1
  24. package/dist/testUtil/index.cjs +7 -13
  25. package/dist/testUtil/index.cjs.map +1 -1
  26. package/dist/testUtil/index.d.cts +5 -5
  27. package/dist/testUtil/index.d.ts +5 -5
  28. package/dist/testUtil/index.js +4 -5
  29. package/dist/testUtil/index.js.map +1 -1
  30. package/dist/transport/impls/ws/client.cjs +5 -9
  31. package/dist/transport/impls/ws/client.cjs.map +1 -1
  32. package/dist/transport/impls/ws/client.d.cts +6 -6
  33. package/dist/transport/impls/ws/client.d.ts +6 -6
  34. package/dist/transport/impls/ws/client.js +3 -3
  35. package/dist/transport/impls/ws/server.cjs +6 -11
  36. package/dist/transport/impls/ws/server.cjs.map +1 -1
  37. package/dist/transport/impls/ws/server.d.cts +6 -6
  38. package/dist/transport/impls/ws/server.d.ts +6 -6
  39. package/dist/transport/impls/ws/server.js +3 -3
  40. package/dist/transport/index.cjs +6 -11
  41. package/dist/transport/index.cjs.map +1 -1
  42. package/dist/transport/index.d.cts +6 -6
  43. package/dist/transport/index.d.ts +6 -6
  44. package/dist/transport/index.js +3 -3
  45. package/dist/transport-CCaWx1Rb.d.cts +1566 -0
  46. package/dist/{services-44be1b6b.d.ts → transport-CZb3vdB4.d.ts} +323 -323
  47. package/dist/{wslike-e0b32dd5.d.ts → wslike-Dng9H1C7.d.cts} +1 -1
  48. package/dist/wslike-Dng9H1C7.d.ts +40 -0
  49. package/package.json +2 -2
  50. /package/dist/{chunk-BXKBENJE.js.map → chunk-XB663LV7.js.map} +0 -0
@@ -1,6 +1,6 @@
1
- import { C as Codec } from '../adapter-f2b6e211.js';
2
- export { a as CodecMessageAdapter } from '../adapter-f2b6e211.js';
3
- import '../message-01c3e85a.js';
1
+ import { C as Codec } from '../adapter-Cuc4JtfV.cjs';
2
+ export { a as CodecMessageAdapter } from '../adapter-Cuc4JtfV.cjs';
3
+ import '../message-Di94OL80.cjs';
4
4
  import '@sinclair/typebox';
5
5
  import '@opentelemetry/api';
6
6
 
@@ -1,6 +1,6 @@
1
- import { C as Codec } from '../adapter-f2b6e211.js';
2
- export { a as CodecMessageAdapter } from '../adapter-f2b6e211.js';
3
- import '../message-01c3e85a.js';
1
+ import { C as Codec } from '../adapter-ChksXKVN.js';
2
+ export { a as CodecMessageAdapter } from '../adapter-ChksXKVN.js';
3
+ import '../message-Di94OL80.js';
4
4
  import '@sinclair/typebox';
5
5
  import '@opentelemetry/api';
6
6
 
@@ -2,9 +2,9 @@ import {
2
2
  BinaryCodec,
3
3
  CodecMessageAdapter,
4
4
  NaiveJsonCodec
5
- } from "../chunk-2WFRHXDZ.js";
6
- import "../chunk-EVAQ2QMB.js";
5
+ } from "../chunk-2OE32RBD.js";
7
6
  import "../chunk-CC7RN7GI.js";
7
+ import "../chunk-XS6CNYUH.js";
8
8
  export {
9
9
  BinaryCodec,
10
10
  CodecMessageAdapter,
@@ -0,0 +1,35 @@
1
+ import { T as Tags } from './index-C9tpZjBN.cjs';
2
+ import { P as ProtocolVersion, O as OpaqueTransportMessage } from './message-Di94OL80.cjs';
3
+ import { b as Connection } from './transport-CCaWx1Rb.cjs';
4
+ import { W as WsLike } from './wslike-Dng9H1C7.cjs';
5
+
6
+ interface ConnectionInfoExtras extends Record<string, unknown> {
7
+ headers: Record<string, string>;
8
+ }
9
+ declare class WebSocketConnection extends Connection {
10
+ ws: WsLike;
11
+ extras?: ConnectionInfoExtras;
12
+ get loggingMetadata(): Partial<{
13
+ protocolVersion: ProtocolVersion;
14
+ clientId: string;
15
+ connectedTo: string;
16
+ sessionId: string;
17
+ connId: string;
18
+ transportMessage: Partial<OpaqueTransportMessage>;
19
+ validationErrors: {
20
+ path: string;
21
+ message: string;
22
+ }[];
23
+ tags: Tags[];
24
+ telemetry: {
25
+ traceId: string;
26
+ spanId: string;
27
+ };
28
+ extras?: Record<string, unknown> | undefined;
29
+ }>;
30
+ constructor(ws: WsLike, extras?: ConnectionInfoExtras);
31
+ send(payload: Uint8Array): boolean;
32
+ close(): void;
33
+ }
34
+
35
+ export { WebSocketConnection as W };
@@ -1,7 +1,7 @@
1
- import { T as Tags } from './index-02554794.js';
2
- import { P as ProtocolVersion, O as OpaqueTransportMessage } from './message-01c3e85a.js';
3
- import { b as Connection } from './services-44be1b6b.js';
4
- import { W as WsLike } from './wslike-e0b32dd5.js';
1
+ import { T as Tags } from './index-D8IOd3LG.js';
2
+ import { P as ProtocolVersion, O as OpaqueTransportMessage } from './message-Di94OL80.js';
3
+ import { b as Connection } from './transport-CZb3vdB4.js';
4
+ import { W as WsLike } from './wslike-Dng9H1C7.js';
5
5
 
6
6
  interface ConnectionInfoExtras extends Record<string, unknown> {
7
7
  headers: Record<string, string>;
@@ -0,0 +1,37 @@
1
+ import { P as ProtocolVersion, O as OpaqueTransportMessage } from './message-Di94OL80.cjs';
2
+
3
+ declare const LoggingLevels: {
4
+ readonly debug: -1;
5
+ readonly info: 0;
6
+ readonly warn: 1;
7
+ readonly error: 2;
8
+ };
9
+ type LoggingLevel = keyof typeof LoggingLevels;
10
+ type LogFn = (msg: string, ctx?: MessageMetadata, level?: LoggingLevel) => void;
11
+ type Logger = {
12
+ [key in LoggingLevel]: (msg: string, metadata?: MessageMetadata) => void;
13
+ };
14
+ type Tags = 'invariant-violation' | 'state-transition' | 'invalid-request' | 'unhealthy-session' | 'uncaught-handler-error';
15
+ type MessageMetadata = Partial<{
16
+ protocolVersion: ProtocolVersion;
17
+ clientId: string;
18
+ connectedTo: string;
19
+ sessionId: string;
20
+ connId: string;
21
+ transportMessage: Partial<OpaqueTransportMessage>;
22
+ validationErrors: Array<{
23
+ path: string;
24
+ message: string;
25
+ }>;
26
+ tags: Array<Tags>;
27
+ telemetry: {
28
+ traceId: string;
29
+ spanId: string;
30
+ };
31
+ extras?: Record<string, unknown>;
32
+ }>;
33
+ declare const stringLogger: LogFn;
34
+ declare const coloredStringLogger: LogFn;
35
+ declare const jsonLogger: LogFn;
36
+
37
+ export { type Logger as L, type MessageMetadata as M, type Tags as T, type LogFn as a, type LoggingLevel as b, coloredStringLogger as c, jsonLogger as j, stringLogger as s };
@@ -1,4 +1,4 @@
1
- import { P as ProtocolVersion, O as OpaqueTransportMessage } from './message-01c3e85a.js';
1
+ import { P as ProtocolVersion, O as OpaqueTransportMessage } from './message-Di94OL80.js';
2
2
 
3
3
  declare const LoggingLevels: {
4
4
  readonly debug: -1;
@@ -34,4 +34,4 @@ declare const stringLogger: LogFn;
34
34
  declare const coloredStringLogger: LogFn;
35
35
  declare const jsonLogger: LogFn;
36
36
 
37
- export { Logger as L, MessageMetadata as M, Tags as T, LogFn as a, LoggingLevel as b, coloredStringLogger as c, jsonLogger as j, stringLogger as s };
37
+ export { type Logger as L, type MessageMetadata as M, type Tags as T, type LogFn as a, type LoggingLevel as b, coloredStringLogger as c, jsonLogger as j, stringLogger as s };
@@ -1,4 +1,4 @@
1
- export { a as LogFn, L as Logger, M as MessageMetadata, c as coloredStringLogger, j as jsonLogger, s as stringLogger } from '../index-02554794.js';
2
- import '../message-01c3e85a.js';
1
+ export { a as LogFn, L as Logger, M as MessageMetadata, c as coloredStringLogger, j as jsonLogger, s as stringLogger } from '../index-C9tpZjBN.cjs';
2
+ import '../message-Di94OL80.cjs';
3
3
  import '@sinclair/typebox';
4
4
  import '@opentelemetry/api';
@@ -1,4 +1,4 @@
1
- export { a as LogFn, L as Logger, M as MessageMetadata, c as coloredStringLogger, j as jsonLogger, s as stringLogger } from '../index-02554794.js';
2
- import '../message-01c3e85a.js';
1
+ export { a as LogFn, L as Logger, M as MessageMetadata, c as coloredStringLogger, j as jsonLogger, s as stringLogger } from '../index-D8IOd3LG.js';
2
+ import '../message-Di94OL80.js';
3
3
  import '@sinclair/typebox';
4
4
  import '@opentelemetry/api';
@@ -105,4 +105,4 @@ declare function isStreamOpen(controlFlag: number): boolean;
105
105
  */
106
106
  declare function isStreamClose(controlFlag: number): boolean;
107
107
 
108
- export { HandshakeErrorResponseCodes as H, OpaqueTransportMessage as O, ProtocolVersion as P, TransportClientId as T, PartialTransportMessage as a, TelemetryInfo as b, TransportMessage as c, HandshakeErrorCustomHandlerFatalResponseCodes as d, TransportMessageSchema as e, OpaqueTransportMessageSchema as f, isStreamClose as g, isStreamOpen as i };
108
+ export { HandshakeErrorCustomHandlerFatalResponseCodes as H, type OpaqueTransportMessage as O, type ProtocolVersion as P, type TransportClientId as T, type PartialTransportMessage as a, type TelemetryInfo as b, type TransportMessage as c, HandshakeErrorResponseCodes as d, TransportMessageSchema as e, OpaqueTransportMessageSchema as f, isStreamClose as g, isStreamOpen as i };
@@ -0,0 +1,108 @@
1
+ import * as _sinclair_typebox from '@sinclair/typebox';
2
+ import { TSchema } from '@sinclair/typebox';
3
+ import { Span, Context } from '@opentelemetry/api';
4
+
5
+ interface PropagationContext {
6
+ traceparent: string;
7
+ tracestate: string;
8
+ }
9
+ interface TelemetryInfo {
10
+ span: Span;
11
+ ctx: Context;
12
+ }
13
+
14
+ /**
15
+ * Generic Typebox schema for a transport message.
16
+ * @template T The type of the payload.
17
+ * @param {T} t The payload schema.
18
+ * @returns The transport message schema.
19
+ */
20
+ declare const TransportMessageSchema: <T extends TSchema>(t: T) => _sinclair_typebox.TObject<{
21
+ id: _sinclair_typebox.TString;
22
+ from: _sinclair_typebox.TString;
23
+ to: _sinclair_typebox.TString;
24
+ seq: _sinclair_typebox.TInteger;
25
+ ack: _sinclair_typebox.TInteger;
26
+ serviceName: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
27
+ procedureName: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
28
+ streamId: _sinclair_typebox.TString;
29
+ controlFlags: _sinclair_typebox.TInteger;
30
+ tracing: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
31
+ traceparent: _sinclair_typebox.TString;
32
+ tracestate: _sinclair_typebox.TString;
33
+ }>>;
34
+ payload: T;
35
+ }>;
36
+ type ProtocolVersion = 'v1.1' | 'v2.0';
37
+ declare const HandshakeErrorCustomHandlerFatalResponseCodes: _sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"REJECTED_UNSUPPORTED_CLIENT">, _sinclair_typebox.TLiteral<"REJECTED_BY_CUSTOM_HANDLER">]>;
38
+ 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">]>]>;
39
+ /**
40
+ * Defines the schema for an opaque transport message that is agnostic to any
41
+ * procedure/service.
42
+ * @returns The transport message schema.
43
+ */
44
+ declare const OpaqueTransportMessageSchema: _sinclair_typebox.TObject<{
45
+ id: _sinclair_typebox.TString;
46
+ from: _sinclair_typebox.TString;
47
+ to: _sinclair_typebox.TString;
48
+ seq: _sinclair_typebox.TInteger;
49
+ ack: _sinclair_typebox.TInteger;
50
+ serviceName: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
51
+ procedureName: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
52
+ streamId: _sinclair_typebox.TString;
53
+ controlFlags: _sinclair_typebox.TInteger;
54
+ tracing: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
55
+ traceparent: _sinclair_typebox.TString;
56
+ tracestate: _sinclair_typebox.TString;
57
+ }>>;
58
+ payload: _sinclair_typebox.TUnknown;
59
+ }>;
60
+ /**
61
+ * Represents a transport message. This is the same type as {@link TransportMessageSchema} but
62
+ * we can't statically infer generics from generic Typebox schemas so we have to define it again here.
63
+ *
64
+ * TypeScript can't enforce types when a bitmask is involved, so these are the semantics of
65
+ * `controlFlags`:
66
+ * * If `controlFlags & StreamOpenBit == StreamOpenBit`, `streamId` must be set to a unique value
67
+ * (suggestion: use `nanoid`).
68
+ * * If `controlFlags & StreamOpenBit == StreamOpenBit`, `serviceName` and `procedureName` must be set.
69
+ * * If `controlFlags & StreamClosedBit == StreamClosedBit` and the kind is `stream` or `subscription`,
70
+ * `payload` should be discarded (usually contains a control message).
71
+ * * If `controlFlags & AckBit == AckBit`, the message is an explicit acknowledgement message and doesn't
72
+ * contain any payload that is relevant to the application so should not be delivered.
73
+ * @template Payload The type of the payload.
74
+ */
75
+ interface TransportMessage<Payload = unknown> {
76
+ id: string;
77
+ from: TransportClientId;
78
+ to: TransportClientId;
79
+ seq: number;
80
+ ack: number;
81
+ serviceName?: string;
82
+ procedureName?: string;
83
+ streamId: string;
84
+ controlFlags: number;
85
+ tracing?: PropagationContext;
86
+ payload: Payload;
87
+ }
88
+ type PartialTransportMessage<Payload = unknown> = Omit<TransportMessage<Payload>, 'id' | 'from' | 'to' | 'seq' | 'ack'>;
89
+ /**
90
+ * A type alias for a transport message with an opaque payload.
91
+ * @template T - The type of the opaque payload.
92
+ */
93
+ type OpaqueTransportMessage = TransportMessage;
94
+ type TransportClientId = string;
95
+ /**
96
+ * Checks if the given control flag (usually found in msg.controlFlag) is a stream open message.
97
+ * @param controlFlag - The control flag to check.
98
+ * @returns True if the control flag contains the StreamOpenBit, false otherwise.
99
+ */
100
+ declare function isStreamOpen(controlFlag: number): boolean;
101
+ /**
102
+ * Checks if the given control flag (usually found in msg.controlFlag) is a stream close message.
103
+ * @param controlFlag - The control flag to check.
104
+ * @returns True if the control flag contains the StreamCloseBit, false otherwise.
105
+ */
106
+ declare function isStreamClose(controlFlag: number): boolean;
107
+
108
+ export { HandshakeErrorCustomHandlerFatalResponseCodes as H, type OpaqueTransportMessage as O, type ProtocolVersion as P, type TransportClientId as T, type PartialTransportMessage as a, type TelemetryInfo as b, type TransportMessage as c, HandshakeErrorResponseCodes as d, TransportMessageSchema as e, OpaqueTransportMessageSchema as f, isStreamClose as g, isStreamOpen as i };
@@ -908,8 +908,7 @@ function _createRecursiveProxy(callback, path) {
908
908
  const proxy = new Proxy(noop, {
909
909
  // property access, recurse and add field to path
910
910
  get(_obj, key) {
911
- if (typeof key !== "string")
912
- return void 0;
911
+ if (typeof key !== "string") return void 0;
913
912
  return _createRecursiveProxy(callback, [...path, key]);
914
913
  },
915
914
  // hit the end, let's invoke the handler
@@ -1038,8 +1037,7 @@ function handleProc(procType, transport, serverId, init, serviceName, procedureN
1038
1037
  );
1039
1038
  }
1040
1039
  function onMessage(msg) {
1041
- if (msg.streamId !== streamId)
1042
- return;
1040
+ if (msg.streamId !== streamId) return;
1043
1041
  if (msg.to !== transport.clientId) {
1044
1042
  transport.log?.error("got stream message from unexpected client", {
1045
1043
  clientId: transport.clientId,
@@ -1264,8 +1262,7 @@ var RiverServer = class {
1264
1262
  );
1265
1263
  };
1266
1264
  const handleSessionStatus = (evt) => {
1267
- if (evt.status !== "closing")
1268
- return;
1265
+ if (evt.status !== "closing") return;
1269
1266
  const disconnectedClientId = evt.session.to;
1270
1267
  this.log?.info(
1271
1268
  `got session disconnect from ${disconnectedClientId}, cleaning up streams`,
@@ -1279,8 +1276,7 @@ var RiverServer = class {
1279
1276
  this.serverCancelledStreams.delete(disconnectedClientId);
1280
1277
  };
1281
1278
  const handleTransportStatus = (evt) => {
1282
- if (evt.status !== "closed")
1283
- return;
1279
+ if (evt.status !== "closed") return;
1284
1280
  this.unregisterTransportListeners();
1285
1281
  };
1286
1282
  this.unregisterTransportListeners = () => {
@@ -1896,7 +1892,7 @@ function createServerHandshakeOptions(schema, validate) {
1896
1892
  }
1897
1893
 
1898
1894
  // package.json
1899
- var version = "0.208.1";
1895
+ var version = "0.208.2";
1900
1896
  // Annotate the CommonJS export names for ESM import in node:
1901
1897
  0 && (module.exports = {
1902
1898
  CANCEL_CODE,