@replit/river
Advanced tools
Comparing version 0.200.0-rc.2 to 0.200.0-rc.3
@@ -1,4 +0,4 @@ | ||
export { d as LogFn, L as Logger, M as MessageMetadata, j as coloredStringLogger, k as jsonLogger, s as stringLogger } from '../index-10ebd26a.js'; | ||
export { f as LogFn, L as Logger, M as MessageMetadata, h as coloredStringLogger, j as jsonLogger, s as stringLogger } from '../message-fd349b27.js'; | ||
import '@sinclair/typebox/value'; | ||
import '@sinclair/typebox'; | ||
import '@opentelemetry/api'; |
@@ -5,3 +5,3 @@ import { | ||
stringLogger | ||
} from "../chunk-QMM35C3H.js"; | ||
} from "../chunk-VXYHC666.js"; | ||
export { | ||
@@ -8,0 +8,0 @@ coloredStringLogger, |
@@ -1,49 +0,14 @@ | ||
import { j as SerializedServerSchema, A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, C as Connection, k as ServerHandshakeOptions, d as ServiceContext } from '../services-970f97bb.js'; | ||
export { L as Client, X as Err, E as ErrResult, H as INVALID_REQUEST_CODE, J as InputReaderErrorSchema, Q as Ok, O as OkResult, _ as Output, f as OutputReaderErrorSchema, M as ParsedMetadata, P as PayloadType, r as ProcErrors, n as ProcHandler, o as ProcInit, p as ProcInput, q as ProcOutput, s as ProcType, c as Procedure, b as ProcedureErrorSchemaType, N as ProcedureHandlerContext, x as ProcedureMap, y as RPCProcedure, R as ReadStream, e as Result, Z as ResultUnwrapErr, Y as ResultUnwrapOk, w as SerializedProcedureSchema, v as SerializedServiceSchema, l as Service, m as ServiceConfiguration, t as ServiceSchema, D as StreamProcedure, z as SubscriptionProcedure, F as UNCAUGHT_ERROR_CODE, G as UNEXPECTED_DISCONNECT_CODE, U as UploadProcedure, V as ValidProcType, W as WriteStream, K as createClient, $ as createClientHandshakeOptions, a0 as createServerHandshakeOptions, u as serializeSchema } from '../services-970f97bb.js'; | ||
import { ServerTransport } from '../transport/index.js'; | ||
import { A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap } from '../services-690e5553.js'; | ||
export { C as Client, D as Err, E as ErrResult, w as INVALID_REQUEST_CODE, x as InputReaderErrorSchema, z as Ok, O as OkResult, H as Output, d as OutputReaderErrorSchema, P as PayloadType, j as ProcErrors, f as ProcHandler, g as ProcInit, h as ProcInput, i as ProcOutput, k as ProcType, b as Procedure, a as ProcedureErrorSchemaType, p as ProcedureMap, q as RPCProcedure, R as ReadStream, c as Result, G as ResultUnwrapErr, F as ResultUnwrapOk, o as SerializedProcedureSchema, m as SerializedServerSchema, n as SerializedServiceSchema, S as Service, e as ServiceConfiguration, l as ServiceSchema, t as StreamProcedure, r as SubscriptionProcedure, u as UNCAUGHT_ERROR_CODE, v as UNEXPECTED_DISCONNECT_CODE, U as UploadProcedure, V as ValidProcType, W as WriteStream, y as createClient, s as serializeSchema } from '../services-690e5553.js'; | ||
import { C as Connection, q as ServerHandshakeOptions, n as ServiceContext } from '../context-c9668e95.js'; | ||
export { r as ParsedMetadata, s as ProcedureHandlerContext, t as createClientHandshakeOptions, u as createServerHandshakeOptions } from '../context-c9668e95.js'; | ||
import { S as ServerTransport } from '../server-dbad597e.js'; | ||
import '@sinclair/typebox'; | ||
import '../index-10ebd26a.js'; | ||
import '../message-fd349b27.js'; | ||
import '@sinclair/typebox/value'; | ||
import '@opentelemetry/api'; | ||
import '../client-a84783be.js'; | ||
import '../types-3e5768ec.js'; | ||
interface ServerBreakage { | ||
serviceBreakages: Record<string, ServiceBreakage>; | ||
} | ||
type ServiceBreakage = { | ||
reason: 'removed'; | ||
} | { | ||
reason: 'modified'; | ||
procedureBreakages: Record<string, ProcedureBreakage>; | ||
}; | ||
type ProcedureBreakage = { | ||
reason: 'removed'; | ||
} | { | ||
reason: 'type-changed'; | ||
oldType: string; | ||
newType: string; | ||
} | { | ||
reason: 'modified'; | ||
input?: PayloadBreakage; | ||
init?: PayloadBreakage; | ||
output?: PayloadBreakage; | ||
}; | ||
type PayloadBreakage = { | ||
reason: 'type-changed'; | ||
oldType: string; | ||
newType: string; | ||
} | { | ||
reason: 'new-required'; | ||
} | { | ||
reason: 'removed-required'; | ||
} | { | ||
reason: 'field-breakage'; | ||
fieldBreakages: Record<string, PayloadBreakage>; | ||
}; | ||
interface DiffOptions { | ||
allowServiceRemoval?: boolean; | ||
allowProcedureRemoval?: boolean; | ||
} | ||
declare function diffServerSchema(oldServer: SerializedServerSchema, newServer: SerializedServerSchema, options?: DiffOptions): ServerBreakage | null; | ||
type StreamId = string; | ||
/** | ||
@@ -61,3 +26,3 @@ * Represents a server with a set of services. Use {@link createServer} to create it. | ||
*/ | ||
openStreams: Set<string>; | ||
openStreams: Set<StreamId>; | ||
} | ||
@@ -83,4 +48,4 @@ /** | ||
var version = "0.200.0-rc.2"; | ||
var version = "0.200.0-rc.3"; | ||
export { DiffOptions, PayloadBreakage, ProcedureBreakage, version as RIVER_VERSION, SerializedServerSchema, Server, ServerBreakage, ServiceBreakage, ServiceContext, createServer, diffServerSchema }; | ||
export { version as RIVER_VERSION, Server, ServiceContext, createServer }; |
@@ -15,8 +15,7 @@ import { | ||
createServerHandshakeOptions, | ||
diffServerSchema, | ||
serializeSchema | ||
} from "../chunk-7CKIN3JT.js"; | ||
} from "../chunk-UIYGPURD.js"; | ||
import { | ||
version | ||
} from "../chunk-S5RL45KH.js"; | ||
} from "../chunk-3CCOX55A.js"; | ||
export { | ||
@@ -37,5 +36,4 @@ Err, | ||
createServerHandshakeOptions, | ||
diffServerSchema, | ||
serializeSchema | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,4 +0,5 @@ | ||
import { U as UdsConnection } from '../../../connection-f900e390.js'; | ||
import { T as TransportClientId } from '../../../index-10ebd26a.js'; | ||
import { g as ClientTransport, h as ProvidedClientTransportOptions } from '../../../services-970f97bb.js'; | ||
import { U as UdsConnection } from '../../../connection-320fb130.js'; | ||
import { c as TransportClientId } from '../../../message-fd349b27.js'; | ||
import { C as ClientTransport } from '../../../client-a84783be.js'; | ||
import { b as ProvidedClientTransportOptions } from '../../../context-c9668e95.js'; | ||
import 'node:net'; | ||
@@ -5,0 +6,0 @@ import 'node:stream'; |
import { | ||
UdsConnection | ||
} from "../../../chunk-4VNY34QG.js"; | ||
} from "../../../chunk-UFMDEG44.js"; | ||
import { | ||
ClientTransport | ||
} from "../../../chunk-47TFNAY2.js"; | ||
import "../../../chunk-ONUXWVRC.js"; | ||
import "../../../chunk-QMM35C3H.js"; | ||
import "../../../chunk-NQWDT6GS.js"; | ||
import "../../../chunk-S5RL45KH.js"; | ||
} from "../../../chunk-ZQVKFLAB.js"; | ||
import "../../../chunk-O4O2E6DJ.js"; | ||
import "../../../chunk-VXYHC666.js"; | ||
import "../../../chunk-GWYJZFCW.js"; | ||
import "../../../chunk-3CCOX55A.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 { T as TransportClientId } from '../../../index-10ebd26a.js'; | ||
import { U as UdsConnection } from '../../../connection-f900e390.js'; | ||
import { ServerTransport } from '../../index.js'; | ||
import { i as ProvidedServerTransportOptions } from '../../../services-970f97bb.js'; | ||
import { c as TransportClientId } from '../../../message-fd349b27.js'; | ||
import { U as UdsConnection } from '../../../connection-320fb130.js'; | ||
import { S as ServerTransport } from '../../../server-dbad597e.js'; | ||
import { c as ProvidedServerTransportOptions } from '../../../context-c9668e95.js'; | ||
import '@sinclair/typebox/value'; | ||
@@ -7,0 +7,0 @@ import '@sinclair/typebox'; |
import { | ||
ServerTransport | ||
} from "../../../chunk-CZP4LK3F.js"; | ||
} from "../../../chunk-QXLXDJD5.js"; | ||
import { | ||
UdsConnection | ||
} from "../../../chunk-4VNY34QG.js"; | ||
import "../../../chunk-ONUXWVRC.js"; | ||
import "../../../chunk-QMM35C3H.js"; | ||
import "../../../chunk-NQWDT6GS.js"; | ||
import "../../../chunk-S5RL45KH.js"; | ||
} from "../../../chunk-UFMDEG44.js"; | ||
import "../../../chunk-O4O2E6DJ.js"; | ||
import "../../../chunk-VXYHC666.js"; | ||
import "../../../chunk-GWYJZFCW.js"; | ||
import "../../../chunk-3CCOX55A.js"; | ||
import "../../../chunk-4PVU7J25.js"; | ||
@@ -12,0 +12,0 @@ |
@@ -1,9 +0,10 @@ | ||
import { g as ClientTransport, h as ProvidedClientTransportOptions } from '../../../services-970f97bb.js'; | ||
import { T as TransportClientId } from '../../../index-10ebd26a.js'; | ||
import { W as WebSocketConnection } from '../../../connection-3f117047.js'; | ||
import { C as ClientTransport } from '../../../client-a84783be.js'; | ||
import { c as TransportClientId } from '../../../message-fd349b27.js'; | ||
import { b as ProvidedClientTransportOptions } from '../../../context-c9668e95.js'; | ||
import { W as WebSocketConnection } from '../../../connection-d0b488e6.js'; | ||
import { W as WsLike } from '../../../wslike-e0b32dd5.js'; | ||
import '@sinclair/typebox/value'; | ||
import '@sinclair/typebox'; | ||
import '@opentelemetry/api'; | ||
import '../../../types-3e5768ec.js'; | ||
import '@sinclair/typebox/value'; | ||
import '@opentelemetry/api'; | ||
@@ -10,0 +11,0 @@ /** |
import { | ||
WebSocketConnection | ||
} from "../../../chunk-DJCW3SKT.js"; | ||
} from "../../../chunk-WSCAA7VY.js"; | ||
import { | ||
ClientTransport | ||
} from "../../../chunk-47TFNAY2.js"; | ||
import "../../../chunk-ONUXWVRC.js"; | ||
import "../../../chunk-QMM35C3H.js"; | ||
import "../../../chunk-NQWDT6GS.js"; | ||
import "../../../chunk-S5RL45KH.js"; | ||
} from "../../../chunk-ZQVKFLAB.js"; | ||
import "../../../chunk-O4O2E6DJ.js"; | ||
import "../../../chunk-VXYHC666.js"; | ||
import "../../../chunk-GWYJZFCW.js"; | ||
import "../../../chunk-3CCOX55A.js"; | ||
import "../../../chunk-4PVU7J25.js"; | ||
@@ -60,3 +60,2 @@ | ||
}); | ||
this.handleConnection(conn, to); | ||
return conn; | ||
@@ -63,0 +62,0 @@ } |
@@ -1,7 +0,7 @@ | ||
import { T as TransportClientId } from '../../../index-10ebd26a.js'; | ||
import { c as TransportClientId } from '../../../message-fd349b27.js'; | ||
import { WebSocketServer } from 'ws'; | ||
import { W as WebSocketConnection } from '../../../connection-3f117047.js'; | ||
import { W as WebSocketConnection } from '../../../connection-d0b488e6.js'; | ||
import { W as WsLike } from '../../../wslike-e0b32dd5.js'; | ||
import { ServerTransport } from '../../index.js'; | ||
import { i as ProvidedServerTransportOptions } from '../../../services-970f97bb.js'; | ||
import { S as ServerTransport } from '../../../server-dbad597e.js'; | ||
import { c as ProvidedServerTransportOptions } from '../../../context-c9668e95.js'; | ||
import '@sinclair/typebox/value'; | ||
@@ -8,0 +8,0 @@ import '@sinclair/typebox'; |
import { | ||
ServerTransport | ||
} from "../../../chunk-CZP4LK3F.js"; | ||
} from "../../../chunk-QXLXDJD5.js"; | ||
import { | ||
WebSocketConnection | ||
} from "../../../chunk-DJCW3SKT.js"; | ||
import "../../../chunk-ONUXWVRC.js"; | ||
import "../../../chunk-QMM35C3H.js"; | ||
import "../../../chunk-NQWDT6GS.js"; | ||
import "../../../chunk-S5RL45KH.js"; | ||
} from "../../../chunk-WSCAA7VY.js"; | ||
import "../../../chunk-O4O2E6DJ.js"; | ||
import "../../../chunk-VXYHC666.js"; | ||
import "../../../chunk-GWYJZFCW.js"; | ||
import "../../../chunk-3CCOX55A.js"; | ||
import "../../../chunk-4PVU7J25.js"; | ||
@@ -12,0 +12,0 @@ |
@@ -1,5 +0,5 @@ | ||
import { C as Connection, T as Transport, a1 as ServerTransportOptions, k as ServerHandshakeOptions, a as Session, M as ParsedMetadata, i as ProvidedServerTransportOptions } from '../services-970f97bb.js'; | ||
export { g as ClientTransport, h as ClientTransportOptions, a6 as EventHandler, a4 as EventMap, a5 as EventTypes, a7 as ProtocolError, a8 as ProtocolErrorType, a3 as TransportOptions, a2 as TransportStatus } from '../services-970f97bb.js'; | ||
import { T as TransportClientId } from '../index-10ebd26a.js'; | ||
export { O as OpaqueTransportMessage, g as OpaqueTransportMessageSchema, c as TransportMessage, f as TransportMessageSchema, h as isStreamClose, i as isStreamOpen } from '../index-10ebd26a.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 '../context-c9668e95.js'; | ||
export { C as ClientTransport } from '../client-a84783be.js'; | ||
export { S as ServerTransport, a as SessionWaitingForHandshake } from '../server-dbad597e.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-fd349b27.js'; | ||
import '@sinclair/typebox'; | ||
@@ -9,23 +9,1 @@ import '../types-3e5768ec.js'; | ||
import '@opentelemetry/api'; | ||
declare abstract class ServerTransport<ConnType extends Connection> extends Transport<ConnType> { | ||
/** | ||
* The options for this transport. | ||
*/ | ||
protected options: ServerTransportOptions; | ||
/** | ||
* Optional handshake options for the server. | ||
*/ | ||
handshakeExtensions?: ServerHandshakeOptions; | ||
/** | ||
* A map of session handshake data for each session. | ||
*/ | ||
sessionHandshakeMetadata: WeakMap<Session<ConnType>, ParsedMetadata>; | ||
constructor(clientId: TransportClientId, providedOptions?: ProvidedServerTransportOptions); | ||
extendHandshake(options: ServerHandshakeOptions): void; | ||
protected handleConnection(conn: ConnType): void; | ||
private validateHandshakeMetadata; | ||
receiveHandshakeRequestMessage(data: Uint8Array, conn: ConnType): Promise<Session<ConnType> | false>; | ||
} | ||
export { Connection, ServerTransport, ProvidedServerTransportOptions as ServerTransportOptions, Session, Transport, TransportClientId }; |
import { | ||
ServerTransport | ||
} from "../chunk-CZP4LK3F.js"; | ||
} from "../chunk-QXLXDJD5.js"; | ||
import { | ||
ClientTransport | ||
} from "../chunk-47TFNAY2.js"; | ||
} from "../chunk-ZQVKFLAB.js"; | ||
import { | ||
Connection, | ||
ProtocolError, | ||
Transport | ||
} from "../chunk-ONUXWVRC.js"; | ||
import "../chunk-QMM35C3H.js"; | ||
} from "../chunk-O4O2E6DJ.js"; | ||
import "../chunk-VXYHC666.js"; | ||
import { | ||
Connection, | ||
Session | ||
} from "../chunk-NQWDT6GS.js"; | ||
SessionState | ||
} from "../chunk-GWYJZFCW.js"; | ||
import { | ||
OpaqueTransportMessageSchema, | ||
TransportMessageSchema | ||
} from "../chunk-S5RL45KH.js"; | ||
} from "../chunk-3CCOX55A.js"; | ||
import "../chunk-4PVU7J25.js"; | ||
@@ -27,3 +27,3 @@ export { | ||
ServerTransport, | ||
Session, | ||
SessionState, | ||
Transport, | ||
@@ -30,0 +30,0 @@ TransportMessageSchema |
@@ -0,4 +1,5 @@ | ||
import { T as Transport, C as Connection, m as SessionOptions, e as SessionNoConnection, n as ServiceContext, S as Session } from '../context-c9668e95.js'; | ||
import { P as PartialTransportMessage, b as OpaqueTransportMessage } from '../message-fd349b27.js'; | ||
import { Static } from '@sinclair/typebox'; | ||
import { B as BaseErrorSchemaType, R as ReadStream, O as OkResult, E as ErrResult, T as Transport, C as Connection, S as SessionOptions, a as Session, P as PayloadType, b as ProcedureErrorSchemaType, c as Procedure, d as ServiceContext, e as Result, f as OutputReaderErrorSchema, W as WriteStream } from '../services-970f97bb.js'; | ||
import { P as PartialTransportMessage, O as OpaqueTransportMessage } from '../index-10ebd26a.js'; | ||
import { B as BaseErrorSchemaType, R as ReadStream, O as OkResult, E as ErrResult, P as PayloadType, a as ProcedureErrorSchemaType, b as Procedure, c as Result, d as OutputReaderErrorSchema, W as WriteStream } from '../services-690e5553.js'; | ||
import NodeWs from 'ws'; | ||
@@ -11,2 +12,3 @@ import http from 'node:http'; | ||
import '@opentelemetry/api'; | ||
import '../client-a84783be.js'; | ||
@@ -75,3 +77,3 @@ /** | ||
declare const testingSessionOptions: SessionOptions; | ||
declare function dummySession(): Session<Connection>; | ||
declare function dummySession(): SessionNoConnection; | ||
declare function asClientRpc<State extends object, Init extends PayloadType, Output extends PayloadType, Err extends ProcedureErrorSchemaType>(state: State, proc: Procedure<State, 'rpc', Init, null, Output, Err>, extendedContext?: Omit<ServiceContext, 'state'>, session?: Session<Connection>): (msg: Static<Init>) => Promise<Result<Static<Output>, Static<Err> | Static<typeof OutputReaderErrorSchema>>>; | ||
@@ -85,3 +87,6 @@ declare function asClientStream<State extends object, Init extends PayloadType, Input extends PayloadType, Output extends PayloadType, Err extends ProcedureErrorSchemaType>(state: State, proc: Procedure<State, 'stream', Init, Input, Output, Err>, init?: Static<Init>, extendedContext?: Omit<ServiceContext, 'state'>, session?: Session<Connection>): [WriteStream<Static<Input>>, ReadStream<Static<Output>, Static<Err>>]; | ||
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, getIteratorFromStream, getUnixSocketPath, iterNext, onUdsServeReady, onWsServerReady, payloadToTransportMessage, testingSessionOptions, waitForMessage }; | ||
export { asClientRpc, asClientStream, asClientSubscription, asClientUpload, closeAllConnections, createDummyTransportMessage, createLocalWebSocketClient, createWebSocketServer, dummySession, getIteratorFromStream, getTransportConnections, getUnixSocketPath, iterNext, numberOfConnections, onUdsServeReady, onWsServerReady, payloadToTransportMessage, testingSessionOptions, waitForMessage }; |
@@ -7,10 +7,10 @@ import { | ||
WriteStreamImpl | ||
} from "../chunk-7CKIN3JT.js"; | ||
} from "../chunk-UIYGPURD.js"; | ||
import { | ||
Session, | ||
SessionStateGraph, | ||
defaultTransportOptions | ||
} from "../chunk-NQWDT6GS.js"; | ||
} from "../chunk-GWYJZFCW.js"; | ||
import { | ||
coerceErrorString | ||
} from "../chunk-S5RL45KH.js"; | ||
} from "../chunk-3CCOX55A.js"; | ||
import "../chunk-4PVU7J25.js"; | ||
@@ -88,6 +88,9 @@ | ||
function dummySession() { | ||
return new Session( | ||
void 0, | ||
return SessionStateGraph.entrypoints.NoConnection( | ||
"client", | ||
"server", | ||
{ | ||
onSessionGracePeriodElapsed: () => { | ||
} | ||
}, | ||
testingSessionOptions | ||
@@ -99,4 +102,5 @@ ); | ||
...extendedContext, | ||
state, | ||
sessionId: session.id, | ||
from: session.from, | ||
state, | ||
metadata: {}, | ||
@@ -179,4 +183,21 @@ abortController: new AbortController(), | ||
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 { | ||
@@ -187,2 +208,3 @@ asClientRpc, | ||
asClientUpload, | ||
closeAllConnections, | ||
createDummyTransportMessage, | ||
@@ -193,4 +215,6 @@ createLocalWebSocketClient, | ||
getIteratorFromStream, | ||
getTransportConnections, | ||
getUnixSocketPath, | ||
iterNext, | ||
numberOfConnections, | ||
onUdsServeReady, | ||
@@ -197,0 +221,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.200.0-rc.2", | ||
"version": "0.200.0-rc.3", | ||
"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` ⚠️ | ||
@@ -83,3 +83,3 @@ River allows multiple clients to connect to and make remote procedure calls to a remote server as if they were local procedures. | ||
```ts | ||
import { ServicaSchema, Procedure, Ok } from '@replit/river'; | ||
import { ServiceSchema, Procedure, Ok } from '@replit/river'; | ||
import { Type } from '@sinclair/typebox'; | ||
@@ -138,3 +138,3 @@ | ||
import { createClient } from '@replit/river'; | ||
import type ServiceSurface from './server'; | ||
import { WebSocket } from 'ws'; | ||
@@ -146,6 +146,6 @@ const transport = new WebSocketClientTransport( | ||
const client = createClient<ServiceSurface>( | ||
const client = createClient( | ||
transport, | ||
'SERVER', // transport id of the server in the previous step | ||
true, // whether to eagerly connect to the server on creation (optional argument) | ||
{ eagerlyConnect: true }, // whether to eagerly connect to the server on creation (optional argument) | ||
); | ||
@@ -163,11 +163,2 @@ | ||
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 | ||
@@ -199,3 +190,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. | ||
@@ -205,3 +196,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') { | ||
@@ -214,7 +205,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 | ||
} | ||
@@ -263,2 +255,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 | ||
@@ -265,0 +266,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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1772228
86
272
11385
17887
0
123