Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@replit/river

Package Overview
Dependencies
Maintainers
28
Versions
162
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@replit/river - npm Package Compare versions

Comparing version 0.23.18 to 0.24.0

dist/chunk-AASMR3CQ.js

2

dist/logging/index.d.ts

@@ -1,4 +0,4 @@

export { g as LogFn, L as Logger, M as MessageMetadata, j as coloredStringLogger, k as jsonLogger, s as stringLogger } from '../index-ea74cdbb.js';
export { f as LogFn, L as Logger, M as MessageMetadata, h as coloredStringLogger, j as jsonLogger, s as stringLogger } from '../message-e6c560fd.js';
import '@sinclair/typebox/value';
import '@sinclair/typebox';
import '@opentelemetry/api';

@@ -5,3 +5,3 @@ import {

stringLogger
} from "../chunk-6LCL2ZZF.js";
} from "../chunk-TAH2GVTJ.js";
export {

@@ -8,0 +8,0 @@ coloredStringLogger,

@@ -1,12 +0,12 @@

import { A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, P as PayloadType, b as Result, R as RiverError } from '../services-38b3f758.js';
export { C as Client, E as Err, O as Ok, z as Output, j as ProcErrors, f as ProcHandler, g as ProcInit, h as ProcInput, i as ProcOutput, k as ProcType, a as Procedure, p as ProcedureMap, d as ProcedureResult, q as RPCProcedure, y as ResultUnwrapErr, x as ResultUnwrapOk, w as RiverErrorSchema, c as RiverUncaughtSchema, o as SerializedProcedureSchema, m as SerializedServerSchema, n as SerializedServiceSchema, S as Service, e as ServiceConfiguration, l as ServiceSchema, t as StreamProcedure, r as SubscriptionProcedure, v as UNCAUGHT_ERROR, U as UploadProcedure, V as ValidProcType, u as createClient, s as serializeSchema } from '../services-38b3f758.js';
import { A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, P as PayloadType, b as Result, R as RiverError } from '../services-e1417b33.js';
export { C as Client, E as Err, O as Ok, z as Output, j as ProcErrors, f as ProcHandler, g as ProcInit, h as ProcInput, i as ProcOutput, k as ProcType, a as Procedure, p as ProcedureMap, d as ProcedureResult, q as RPCProcedure, y as ResultUnwrapErr, x as ResultUnwrapOk, w as RiverErrorSchema, c as RiverUncaughtSchema, o as SerializedProcedureSchema, m as SerializedServerSchema, n as SerializedServiceSchema, S as Service, e as ServiceConfiguration, l as ServiceSchema, t as StreamProcedure, r as SubscriptionProcedure, v as UNCAUGHT_ERROR, U as UploadProcedure, V as ValidProcType, u as createClient, s as serializeSchema } from '../services-e1417b33.js';
import { Static } from '@sinclair/typebox';
import { Pushable } from 'it-pushable';
import { C as Connection, m as ServerHandshakeOptions, i as ServiceContext } from '../handshake-a947c234.js';
export { n as ParsedMetadata, o as ServiceContextWithState, p as ServiceContextWithTransportInfo, q as createClientHandshakeOptions, r as createServerHandshakeOptions } from '../handshake-a947c234.js';
import { S as ServerTransport } from '../server-53cd5b7e.js';
import '../index-ea74cdbb.js';
import { C as Connection, q as ServerHandshakeOptions, n as ServiceContext } from '../handshake-cdead82a.js';
export { r as ParsedMetadata, s as ServiceContextWithState, t as ServiceContextWithTransportInfo, u as createClientHandshakeOptions, v as createServerHandshakeOptions } from '../handshake-cdead82a.js';
import { S as ServerTransport } from '../server-2ef5e6ec.js';
import '../message-e6c560fd.js';
import '@sinclair/typebox/value';
import '@opentelemetry/api';
import '../client-5776a6bb.js';
import '../client-ba0d3315.js';
import '../types-3e5768ec.js';

@@ -20,6 +20,7 @@

services: InstantiatedServiceSchemaMap<Services>;
streams: Map<string, ProcStream>;
streams: Map<StreamId, ProcStream>;
}
type StreamId = string;
interface ProcStream {
id: string;
id: StreamId;
serviceName: string;

@@ -48,4 +49,4 @@ procedureName: string;

var version = "0.23.18";
var version = "0.24.0";
export { PayloadType, version as RIVER_VERSION, Result, RiverError, Server, ServiceContext, createServer };

@@ -13,6 +13,6 @@ import {

serializeSchema
} from "../chunk-EV5HW4IC.js";
} from "../chunk-KYYB4DUR.js";
import {
version
} from "../chunk-R2HAS3GM.js";
} from "../chunk-PJGGC3LV.js";
export {

@@ -19,0 +19,0 @@ Err,

@@ -1,5 +0,5 @@

import { U as UdsConnection } from '../../../connection-bd35d442.js';
import { c as TransportClientId } from '../../../index-ea74cdbb.js';
import { C as ClientTransport } from '../../../client-5776a6bb.js';
import { b as ProvidedClientTransportOptions } from '../../../handshake-a947c234.js';
import { U as UdsConnection } from '../../../connection-c3a96d09.js';
import { c as TransportClientId } from '../../../message-e6c560fd.js';
import { C as ClientTransport } from '../../../client-ba0d3315.js';
import { b as ProvidedClientTransportOptions } from '../../../handshake-cdead82a.js';
import 'node:net';

@@ -6,0 +6,0 @@ import 'node:stream';

import {
UdsConnection
} from "../../../chunk-AVL32IMG.js";
} from "../../../chunk-AASMR3CQ.js";
import {
ClientTransport
} from "../../../chunk-DPKOJQWF.js";
import "../../../chunk-J6N6H2WU.js";
import "../../../chunk-6LCL2ZZF.js";
import "../../../chunk-MW5JXLHY.js";
import "../../../chunk-R2HAS3GM.js";
} from "../../../chunk-NLQPPDOT.js";
import "../../../chunk-ZAT3R4CU.js";
import "../../../chunk-TAH2GVTJ.js";
import "../../../chunk-JA57I7MG.js";
import "../../../chunk-PJGGC3LV.js";
import "../../../chunk-4PVU7J25.js";

@@ -22,6 +22,2 @@

async createNewOutgoingConnection(to) {
const oldConnection = this.connections.get(to);
if (oldConnection) {
oldConnection.close();
}
this.log?.info(`establishing a new uds to ${to}`, {

@@ -37,5 +33,3 @@ clientId: this.clientId,

});
const conn = new UdsConnection(sock);
this.handleConnection(conn, to);
return conn;
return new UdsConnection(sock);
}

@@ -42,0 +36,0 @@ };

import { Server, Socket } from 'node:net';
import { c as TransportClientId } from '../../../index-ea74cdbb.js';
import { U as UdsConnection } from '../../../connection-bd35d442.js';
import { S as ServerTransport } from '../../../server-53cd5b7e.js';
import { c as ProvidedServerTransportOptions } from '../../../handshake-a947c234.js';
import { c as TransportClientId } from '../../../message-e6c560fd.js';
import { U as UdsConnection } from '../../../connection-c3a96d09.js';
import { S as ServerTransport } from '../../../server-2ef5e6ec.js';
import { c as ProvidedServerTransportOptions } from '../../../handshake-cdead82a.js';
import '@sinclair/typebox/value';

@@ -7,0 +7,0 @@ import '@sinclair/typebox';

import {
ServerTransport
} from "../../../chunk-RJOWZIWB.js";
} from "../../../chunk-KX5PQRVN.js";
import {
UdsConnection
} from "../../../chunk-AVL32IMG.js";
import "../../../chunk-J6N6H2WU.js";
import "../../../chunk-6LCL2ZZF.js";
import "../../../chunk-MW5JXLHY.js";
import "../../../chunk-R2HAS3GM.js";
} from "../../../chunk-AASMR3CQ.js";
import "../../../chunk-ZAT3R4CU.js";
import "../../../chunk-TAH2GVTJ.js";
import "../../../chunk-JA57I7MG.js";
import "../../../chunk-PJGGC3LV.js";
import "../../../chunk-4PVU7J25.js";

@@ -12,0 +12,0 @@

@@ -1,5 +0,5 @@

import { C as ClientTransport } from '../../../client-5776a6bb.js';
import { c as TransportClientId } from '../../../index-ea74cdbb.js';
import { b as ProvidedClientTransportOptions } from '../../../handshake-a947c234.js';
import { W as WebSocketConnection } from '../../../connection-df85db7e.js';
import { C as ClientTransport } from '../../../client-ba0d3315.js';
import { c as TransportClientId } from '../../../message-e6c560fd.js';
import { b as ProvidedClientTransportOptions } from '../../../handshake-cdead82a.js';
import { W as WebSocketConnection } from '../../../connection-d33e3246.js';
import { W as WsLike } from '../../../wslike-e0b32dd5.js';

@@ -6,0 +6,0 @@ import '@sinclair/typebox/value';

import {
WebSocketConnection
} from "../../../chunk-7MJYOL32.js";
} from "../../../chunk-RXJLI2OP.js";
import {
ClientTransport
} from "../../../chunk-DPKOJQWF.js";
import "../../../chunk-J6N6H2WU.js";
import "../../../chunk-6LCL2ZZF.js";
import "../../../chunk-MW5JXLHY.js";
import "../../../chunk-R2HAS3GM.js";
} from "../../../chunk-NLQPPDOT.js";
import "../../../chunk-ZAT3R4CU.js";
import "../../../chunk-TAH2GVTJ.js";
import "../../../chunk-JA57I7MG.js";
import "../../../chunk-PJGGC3LV.js";
import "../../../chunk-4PVU7J25.js";

@@ -60,3 +60,2 @@

});
this.handleConnection(conn, to);
return conn;

@@ -63,0 +62,0 @@ }

@@ -1,7 +0,7 @@

import { c as TransportClientId } from '../../../index-ea74cdbb.js';
import { c as TransportClientId } from '../../../message-e6c560fd.js';
import { WebSocketServer } from 'ws';
import { W as WebSocketConnection } from '../../../connection-df85db7e.js';
import { W as WebSocketConnection } from '../../../connection-d33e3246.js';
import { W as WsLike } from '../../../wslike-e0b32dd5.js';
import { S as ServerTransport } from '../../../server-53cd5b7e.js';
import { c as ProvidedServerTransportOptions } from '../../../handshake-a947c234.js';
import { S as ServerTransport } from '../../../server-2ef5e6ec.js';
import { c as ProvidedServerTransportOptions } from '../../../handshake-cdead82a.js';
import '@sinclair/typebox/value';

@@ -8,0 +8,0 @@ import '@sinclair/typebox';

import {
ServerTransport
} from "../../../chunk-RJOWZIWB.js";
} from "../../../chunk-KX5PQRVN.js";
import {
WebSocketConnection
} from "../../../chunk-7MJYOL32.js";
import "../../../chunk-J6N6H2WU.js";
import "../../../chunk-6LCL2ZZF.js";
import "../../../chunk-MW5JXLHY.js";
import "../../../chunk-R2HAS3GM.js";
} from "../../../chunk-RXJLI2OP.js";
import "../../../chunk-ZAT3R4CU.js";
import "../../../chunk-TAH2GVTJ.js";
import "../../../chunk-JA57I7MG.js";
import "../../../chunk-PJGGC3LV.js";
import "../../../chunk-4PVU7J25.js";

@@ -12,0 +12,0 @@

@@ -1,5 +0,5 @@

export { b as ClientTransportOptions, C as Connection, e as EventHandler, E as EventMap, d as EventTypes, f as ProtocolError, g as ProtocolErrorType, c as ServerTransportOptions, S as Session, T as Transport, P as TransportOptions, a as TransportStatus } from '../handshake-a947c234.js';
export { C as ClientTransport } from '../client-5776a6bb.js';
export { S as ServerTransport } from '../server-53cd5b7e.js';
export { b as OpaqueTransportMessage, O as OpaqueTransportMessageSchema, c as TransportClientId, a as TransportMessage, T as TransportMessageSchema, d as isStreamClose, i as isStreamOpen } from '../index-ea74cdbb.js';
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 '../handshake-cdead82a.js';
export { C as ClientTransport } from '../client-ba0d3315.js';
export { S as ServerTransport, a as SessionWaitingForHandshake } from '../server-2ef5e6ec.js';
export { b as OpaqueTransportMessage, O as OpaqueTransportMessageSchema, c as TransportClientId, a as TransportMessage, T as TransportMessageSchema, d as isStreamClose, i as isStreamOpen } from '../message-e6c560fd.js';
import '../types-3e5768ec.js';

@@ -6,0 +6,0 @@ import '@sinclair/typebox';

import {
ServerTransport
} from "../chunk-RJOWZIWB.js";
} from "../chunk-KX5PQRVN.js";
import {
ClientTransport
} from "../chunk-DPKOJQWF.js";
} from "../chunk-NLQPPDOT.js";
import {
Connection,
ProtocolError,
Transport
} from "../chunk-J6N6H2WU.js";
import "../chunk-6LCL2ZZF.js";
} from "../chunk-ZAT3R4CU.js";
import "../chunk-TAH2GVTJ.js";
import {
Connection,
Session
} from "../chunk-MW5JXLHY.js";
SessionState
} from "../chunk-JA57I7MG.js";
import {
OpaqueTransportMessageSchema,
TransportMessageSchema
} from "../chunk-R2HAS3GM.js";
} from "../chunk-PJGGC3LV.js";
import "../chunk-4PVU7J25.js";

@@ -27,3 +27,3 @@ export {

ServerTransport,
Session,
SessionState,
Transport,

@@ -30,0 +30,0 @@ TransportMessageSchema

import { Static } from '@sinclair/typebox';
import { P as PayloadType, R as RiverError, a as Procedure, b as Result, c as RiverUncaughtSchema, d as ProcedureResult } from '../services-38b3f758.js';
import { T as Transport, C as Connection, h as SessionOptions, S as Session, i as ServiceContext } from '../handshake-a947c234.js';
import { P as PayloadType, R as RiverError, a as Procedure, b as Result, c as RiverUncaughtSchema, d as ProcedureResult } from '../services-e1417b33.js';
import { T as Transport, C as Connection, m as SessionOptions, e as SessionNoConnection, n as ServiceContext, S as Session } from '../handshake-cdead82a.js';
import * as it_pushable from 'it-pushable';
import { P as PartialTransportMessage, b as OpaqueTransportMessage } from '../index-ea74cdbb.js';
import { P as PartialTransportMessage, b as OpaqueTransportMessage } from '../message-e6c560fd.js';
import NodeWs from 'ws';

@@ -10,3 +10,3 @@ import http from 'node:http';

import { W as WsLike } from '../wslike-e0b32dd5.js';
import '../client-5776a6bb.js';
import '../client-ba0d3315.js';
import '../types-3e5768ec.js';

@@ -58,3 +58,3 @@ import '@sinclair/typebox/value';

declare const testingSessionOptions: SessionOptions;
declare function dummySession(): Session<Connection>;
declare function dummySession(): SessionNoConnection;
declare function asClientRpc<State extends object, I extends PayloadType, O extends PayloadType, E extends RiverError, Init extends PayloadType | null = null>(state: State, proc: Procedure<State, 'rpc', I, O, E, Init>, extendedContext?: Omit<ServiceContext, 'state'>, session?: Session<Connection>): (msg: Static<I>) => Promise<Result<Static<O>, Static<E> | Static<typeof RiverUncaughtSchema>>>;

@@ -74,3 +74,6 @@ declare function asClientStream<State extends object, I extends PayloadType, O extends PayloadType, E extends RiverError, Init extends PayloadType | null = null>(state: State, proc: Procedure<State, 'stream', I, O, E, Init>, init?: Init extends PayloadType ? Static<Init> : null, extendedContext?: Omit<ServiceContext, 'state'>, session?: Session<Connection>): readonly [it_pushable.Pushable<Static<I>, void, unknown>, it_pushable.Pushable<Result<Static<O>, Static<E>>, void, unknown>];

declare const getUnixSocketPath: () => string;
declare function getTransportConnections<ConnType extends Connection>(transport: Transport<ConnType>): Array<ConnType>;
declare function numberOfConnections<ConnType extends Connection>(transport: Transport<ConnType>): number;
declare function closeAllConnections<ConnType extends Connection>(transport: Transport<ConnType>): void;
export { asClientRpc, asClientStream, asClientSubscription, asClientUpload, createDummyTransportMessage, createLocalWebSocketClient, createWebSocketServer, dummySession, getUnixSocketPath, iterNext, onUdsServeReady, onWsServerReady, payloadToTransportMessage, testingSessionOptions, waitForMessage };
export { asClientRpc, asClientStream, asClientSubscription, asClientUpload, closeAllConnections, createDummyTransportMessage, createLocalWebSocketClient, createWebSocketServer, dummySession, getTransportConnections, getUnixSocketPath, iterNext, numberOfConnections, onUdsServeReady, onWsServerReady, payloadToTransportMessage, testingSessionOptions, waitForMessage };

@@ -5,10 +5,11 @@ import {

pushable
} from "../chunk-EV5HW4IC.js";
} from "../chunk-KYYB4DUR.js";
import {
Session,
SessionStateGraph,
defaultTransportOptions
} from "../chunk-MW5JXLHY.js";
} from "../chunk-JA57I7MG.js";
import {
coerceErrorString
} from "../chunk-R2HAS3GM.js";
coerceErrorString,
generateId
} from "../chunk-PJGGC3LV.js";
import "../chunk-4PVU7J25.js";

@@ -83,6 +84,9 @@

function dummySession() {
return new Session(
void 0,
return SessionStateGraph.entrypoints.NoConnection(
"client",
"server",
{
onSessionGracePeriodElapsed: () => {
}
},
testingSessionOptions

@@ -97,4 +101,3 @@ );

from: session.from,
streamId: nanoid(),
session,
streamId: generateId(),
metadata: {}

@@ -148,4 +151,21 @@ };

var getUnixSocketPath = () => {
return process.platform === "win32" ? `\\\\?\\pipe\\${nanoid()}` : `/tmp/${nanoid()}.sock`;
return `/tmp/${nanoid()}.sock`;
};
function getTransportConnections(transport) {
const connections = [];
for (const session of transport.sessions.values()) {
if (session.state === "Connected" /* Connected */) {
connections.push(session.conn);
}
}
return connections;
}
function numberOfConnections(transport) {
return getTransportConnections(transport).length;
}
function closeAllConnections(transport) {
for (const conn of getTransportConnections(transport)) {
conn.close();
}
}
export {

@@ -156,2 +176,3 @@ asClientRpc,

asClientUpload,
closeAllConnections,
createDummyTransportMessage,

@@ -161,4 +182,6 @@ createLocalWebSocketClient,

dummySession,
getTransportConnections,
getUnixSocketPath,
iterNext,
numberOfConnections,
onUdsServeReady,

@@ -165,0 +188,0 @@ onWsServerReady,

{
"name": "@replit/river",
"description": "It's like tRPC but... with JSON Schema Support, duplex streaming and support for service multiplexing. Transport agnostic!",
"version": "0.23.18",
"version": "0.24.0",
"type": "module",

@@ -6,0 +6,0 @@ "exports": {

# River
⚠️ Not production ready, while Replit is using parts of river in production, we are still going through rapid breaking changes. First production ready version will be 1.x.x ⚠️
⚠️ Not production ready, while Replit is using parts of River in production, we are still going through rapid breaking changes. First production ready version will be `1.x.x` ⚠️

@@ -160,11 +160,2 @@ River allows multiple clients to connect to and make remote procedure calls to a remote server as if they were local procedures.

You can then access the `ParsedMetadata` in your procedure handlers:
```ts
async handler(ctx, ...args) {
// this contains the parsed metadata
console.log(ctx.metadata)
}
```
### Logging

@@ -196,3 +187,3 @@

You can listen for transparent reconnects via the `connectionStatus` events, but realistically, no applications should need to listen for this unless it is for debugging purposes. Hard reconnects are signaled via `sessionStatus` events.
Hard reconnects are signaled via `sessionStatus` events.

@@ -202,3 +193,3 @@ If your application is stateful on either the server or the client, the service consumer _should_ wrap all the client-side setup with `transport.addEventListener('sessionStatus', (evt) => ...)` to do appropriate setup and teardown.

```ts
transport.addEventListener('connectionStatus', (evt) => {
transport.addEventListener('sessionStatus', (evt) => {
if (evt.status === 'connect') {

@@ -211,7 +202,8 @@ // do something

transport.addEventListener('sessionStatus', (evt) => {
if (evt.status === 'connect') {
// or, listen for specific session states
transport.addEventListener('sessionTransition', (evt) => {
if (evt.state === SessionState.Connected) {
// switch on various transition states
} else if (evt.state === SessionState.NoConnection) {
// do something
} else if (evt.status === 'disconnect') {
// do something else
}

@@ -260,2 +252,11 @@ });

You can then access the `ParsedMetadata` in your procedure handlers:
```ts
async handler(ctx, ...args) {
// this contains the parsed metadata
console.log(ctx.metadata)
}
```
### Further examples

@@ -262,0 +263,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc