@replit/river
Advanced tools
Comparing version 0.23.16 to 0.200.0-rc.0
@@ -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 { d as LogFn, L as Logger, M as MessageMetadata, j as coloredStringLogger, k as jsonLogger, s as stringLogger } from '../index-10ebd26a.js'; | ||
import '@sinclair/typebox/value'; | ||
import '@sinclair/typebox'; | ||
import '@opentelemetry/api'; |
@@ -5,3 +5,3 @@ import { | ||
stringLogger | ||
} from "../chunk-6LCL2ZZF.js"; | ||
} from "../chunk-QMM35C3H.js"; | ||
export { | ||
@@ -8,0 +8,0 @@ coloredStringLogger, |
@@ -1,12 +0,8 @@ | ||
import { S as SerializedServerSchema, A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, P as PayloadType, b as Result, R as RiverError } from '../services-75e84a9f.js'; | ||
export { C as Client, E as Err, O as Ok, z as Output, k as ProcErrors, g as ProcHandler, h as ProcInit, i as ProcInput, j as ProcOutput, l 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, n as SerializedServiceSchema, e as Service, f as ServiceConfiguration, m 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-75e84a9f.js'; | ||
import { Static } from '@sinclair/typebox'; | ||
import { Pushable } from 'it-pushable'; | ||
import { C as Connection, m as ServerHandshakeOptions, i as ServiceContext } from '../handshake-75d0124f.js'; | ||
export { n as ParsedMetadata, o as ServiceContextWithState, p as ServiceContextWithTransportInfo, q as createClientHandshakeOptions, r as createServerHandshakeOptions } from '../handshake-75d0124f.js'; | ||
import { S as ServerTransport } from '../server-3740c5d9.js'; | ||
import '../index-ea74cdbb.js'; | ||
import { j as SerializedServerSchema, A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, C as Connection, k as ServerHandshakeOptions, d as ServiceContext } from '../services-34d97070.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, 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, K as createClient, $ as createClientHandshakeOptions, a0 as createServerHandshakeOptions, u as serializeSchema } from '../services-34d97070.js'; | ||
import { ServerTransport } from '../transport/index.js'; | ||
import '@sinclair/typebox'; | ||
import '../index-10ebd26a.js'; | ||
import '@sinclair/typebox/value'; | ||
import '@opentelemetry/api'; | ||
import '../client-0926d3d6.js'; | ||
import '../types-3e5768ec.js'; | ||
@@ -58,16 +54,11 @@ | ||
interface Server<Services extends AnyServiceSchemaMap> { | ||
/** | ||
* Services defined for this server. | ||
*/ | ||
services: InstantiatedServiceSchemaMap<Services>; | ||
streams: Map<string, ProcStream>; | ||
/** | ||
* A set of stream ids that are currently open. | ||
*/ | ||
openStreams: Set<string>; | ||
} | ||
interface ProcStream { | ||
id: string; | ||
serviceName: string; | ||
procedureName: string; | ||
incoming: Pushable<PayloadType>; | ||
outgoing: Pushable<Result<Static<PayloadType>, Static<RiverError>>>; | ||
promises: { | ||
outputHandler: Promise<unknown>; | ||
inputHandler: Promise<unknown>; | ||
}; | ||
} | ||
/** | ||
@@ -85,6 +76,11 @@ * Creates a server instance that listens for incoming messages from a transport and routes them to the appropriate service and procedure. | ||
extendedContext?: Omit<ServiceContext, 'state'>; | ||
/** | ||
* Maximum number of aborted streams to keep track of to avoid | ||
* cascading stream errors. | ||
*/ | ||
maxAbortedStreamTombstonesPerSession?: number; | ||
}>): Server<Services>; | ||
var version = "0.23.16"; | ||
var version = "0.200.0-rc.0"; | ||
export { DiffOptions, PayloadBreakage, PayloadType, ProcedureBreakage, version as RIVER_VERSION, Result, RiverError, SerializedServerSchema, Server, ServerBreakage, ServiceBreakage, ServiceContext, createServer, diffServerSchema }; | ||
export { DiffOptions, PayloadBreakage, ProcedureBreakage, version as RIVER_VERSION, SerializedServerSchema, Server, ServerBreakage, ServiceBreakage, ServiceContext, createServer, diffServerSchema }; |
import { | ||
Err, | ||
INVALID_REQUEST_CODE, | ||
InputReaderErrorSchema, | ||
Ok, | ||
OutputReaderErrorSchema, | ||
Procedure, | ||
RiverUncaughtSchema, | ||
ServiceSchema, | ||
UNCAUGHT_ERROR, | ||
UNCAUGHT_ERROR_CODE, | ||
UNEXPECTED_DISCONNECT_CODE, | ||
createClient, | ||
@@ -14,14 +17,17 @@ createClientHandshakeOptions, | ||
serializeSchema | ||
} from "../chunk-LTSLICON.js"; | ||
} from "../chunk-E2ZXI663.js"; | ||
import { | ||
version | ||
} from "../chunk-TXSQRTZB.js"; | ||
} from "../chunk-LK74ZG7M.js"; | ||
export { | ||
Err, | ||
INVALID_REQUEST_CODE, | ||
InputReaderErrorSchema, | ||
Ok, | ||
OutputReaderErrorSchema, | ||
Procedure, | ||
version as RIVER_VERSION, | ||
RiverUncaughtSchema, | ||
ServiceSchema, | ||
UNCAUGHT_ERROR, | ||
UNCAUGHT_ERROR_CODE, | ||
UNEXPECTED_DISCONNECT_CODE, | ||
createClient, | ||
@@ -28,0 +34,0 @@ createClientHandshakeOptions, |
@@ -1,5 +0,4 @@ | ||
import { U as UdsConnection } from '../../../connection-99a67d3e.js'; | ||
import { c as TransportClientId } from '../../../index-ea74cdbb.js'; | ||
import { C as ClientTransport } from '../../../client-0926d3d6.js'; | ||
import { b as ProvidedClientTransportOptions } from '../../../handshake-75d0124f.js'; | ||
import { U as UdsConnection } from '../../../connection-c6521735.js'; | ||
import { T as TransportClientId } from '../../../index-10ebd26a.js'; | ||
import { g as ClientTransport, h as ProvidedClientTransportOptions } from '../../../services-34d97070.js'; | ||
import 'node:net'; | ||
@@ -6,0 +5,0 @@ import 'node:stream'; |
import { | ||
UdsConnection | ||
} from "../../../chunk-UDXM64QK.js"; | ||
} from "../../../chunk-NDLWNT7B.js"; | ||
import { | ||
ClientTransport | ||
} from "../../../chunk-JA7XGTAL.js"; | ||
import "../../../chunk-WN77AT67.js"; | ||
import "../../../chunk-6LCL2ZZF.js"; | ||
import "../../../chunk-YXDAOVP7.js"; | ||
import "../../../chunk-TXSQRTZB.js"; | ||
} from "../../../chunk-TK7QHUFP.js"; | ||
import "../../../chunk-YUY37VAK.js"; | ||
import "../../../chunk-QMM35C3H.js"; | ||
import "../../../chunk-3FALN7ZG.js"; | ||
import "../../../chunk-LK74ZG7M.js"; | ||
import "../../../chunk-4PVU7J25.js"; | ||
@@ -12,0 +12,0 @@ |
import { Server, Socket } from 'node:net'; | ||
import { c as TransportClientId } from '../../../index-ea74cdbb.js'; | ||
import { U as UdsConnection } from '../../../connection-99a67d3e.js'; | ||
import { S as ServerTransport } from '../../../server-3740c5d9.js'; | ||
import { c as ProvidedServerTransportOptions } from '../../../handshake-75d0124f.js'; | ||
import { T as TransportClientId } from '../../../index-10ebd26a.js'; | ||
import { U as UdsConnection } from '../../../connection-c6521735.js'; | ||
import { ServerTransport } from '../../index.js'; | ||
import { i as ProvidedServerTransportOptions } from '../../../services-34d97070.js'; | ||
import '@sinclair/typebox/value'; | ||
@@ -7,0 +7,0 @@ import '@sinclair/typebox'; |
import { | ||
ServerTransport | ||
} from "../../../chunk-MQCGG6KL.js"; | ||
} from "../../../chunk-6RKO3DDG.js"; | ||
import { | ||
UdsConnection | ||
} from "../../../chunk-UDXM64QK.js"; | ||
import "../../../chunk-WN77AT67.js"; | ||
import "../../../chunk-6LCL2ZZF.js"; | ||
import "../../../chunk-YXDAOVP7.js"; | ||
import "../../../chunk-TXSQRTZB.js"; | ||
} from "../../../chunk-NDLWNT7B.js"; | ||
import "../../../chunk-YUY37VAK.js"; | ||
import "../../../chunk-QMM35C3H.js"; | ||
import "../../../chunk-3FALN7ZG.js"; | ||
import "../../../chunk-LK74ZG7M.js"; | ||
import "../../../chunk-4PVU7J25.js"; | ||
@@ -12,0 +12,0 @@ |
@@ -1,10 +0,9 @@ | ||
import { C as ClientTransport } from '../../../client-0926d3d6.js'; | ||
import { c as TransportClientId } from '../../../index-ea74cdbb.js'; | ||
import { b as ProvidedClientTransportOptions } from '../../../handshake-75d0124f.js'; | ||
import { W as WebSocketConnection } from '../../../connection-d738cc08.js'; | ||
import { g as ClientTransport, h as ProvidedClientTransportOptions } from '../../../services-34d97070.js'; | ||
import { T as TransportClientId } from '../../../index-10ebd26a.js'; | ||
import { W as WebSocketConnection } from '../../../connection-0638316b.js'; | ||
import { W as WsLike } from '../../../wslike-e0b32dd5.js'; | ||
import '@sinclair/typebox'; | ||
import '../../../types-3e5768ec.js'; | ||
import '@sinclair/typebox/value'; | ||
import '@sinclair/typebox'; | ||
import '@opentelemetry/api'; | ||
import '../../../types-3e5768ec.js'; | ||
@@ -11,0 +10,0 @@ /** |
import { | ||
WebSocketConnection | ||
} from "../../../chunk-R47IZD67.js"; | ||
} from "../../../chunk-6GK2IIDP.js"; | ||
import { | ||
ClientTransport | ||
} from "../../../chunk-JA7XGTAL.js"; | ||
import "../../../chunk-WN77AT67.js"; | ||
import "../../../chunk-6LCL2ZZF.js"; | ||
import "../../../chunk-YXDAOVP7.js"; | ||
import "../../../chunk-TXSQRTZB.js"; | ||
} from "../../../chunk-TK7QHUFP.js"; | ||
import "../../../chunk-YUY37VAK.js"; | ||
import "../../../chunk-QMM35C3H.js"; | ||
import "../../../chunk-3FALN7ZG.js"; | ||
import "../../../chunk-LK74ZG7M.js"; | ||
import "../../../chunk-4PVU7J25.js"; | ||
@@ -12,0 +12,0 @@ |
@@ -1,7 +0,7 @@ | ||
import { c as TransportClientId } from '../../../index-ea74cdbb.js'; | ||
import { T as TransportClientId } from '../../../index-10ebd26a.js'; | ||
import { WebSocketServer } from 'ws'; | ||
import { W as WebSocketConnection } from '../../../connection-d738cc08.js'; | ||
import { W as WebSocketConnection } from '../../../connection-0638316b.js'; | ||
import { W as WsLike } from '../../../wslike-e0b32dd5.js'; | ||
import { S as ServerTransport } from '../../../server-3740c5d9.js'; | ||
import { c as ProvidedServerTransportOptions } from '../../../handshake-75d0124f.js'; | ||
import { ServerTransport } from '../../index.js'; | ||
import { i as ProvidedServerTransportOptions } from '../../../services-34d97070.js'; | ||
import '@sinclair/typebox/value'; | ||
@@ -8,0 +8,0 @@ import '@sinclair/typebox'; |
import { | ||
ServerTransport | ||
} from "../../../chunk-MQCGG6KL.js"; | ||
} from "../../../chunk-6RKO3DDG.js"; | ||
import { | ||
WebSocketConnection | ||
} from "../../../chunk-R47IZD67.js"; | ||
import "../../../chunk-WN77AT67.js"; | ||
import "../../../chunk-6LCL2ZZF.js"; | ||
import "../../../chunk-YXDAOVP7.js"; | ||
import "../../../chunk-TXSQRTZB.js"; | ||
} from "../../../chunk-6GK2IIDP.js"; | ||
import "../../../chunk-YUY37VAK.js"; | ||
import "../../../chunk-QMM35C3H.js"; | ||
import "../../../chunk-3FALN7ZG.js"; | ||
import "../../../chunk-LK74ZG7M.js"; | ||
import "../../../chunk-4PVU7J25.js"; | ||
@@ -12,0 +12,0 @@ |
@@ -1,8 +0,30 @@ | ||
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-75d0124f.js'; | ||
export { C as ClientTransport } from '../client-0926d3d6.js'; | ||
export { S as ServerTransport } from '../server-3740c5d9.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'; | ||
import { C as Connection, T as Transport, a1 as ServerTransportOptions, k as ServerHandshakeOptions, a as Session, M as ParsedMetadata, i as ProvidedServerTransportOptions } from '../services-34d97070.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-34d97070.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'; | ||
import '@sinclair/typebox'; | ||
import '../types-3e5768ec.js'; | ||
import '@sinclair/typebox'; | ||
import '@sinclair/typebox/value'; | ||
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-MQCGG6KL.js"; | ||
} from "../chunk-6RKO3DDG.js"; | ||
import { | ||
ClientTransport | ||
} from "../chunk-JA7XGTAL.js"; | ||
} from "../chunk-TK7QHUFP.js"; | ||
import { | ||
ProtocolError, | ||
Transport | ||
} from "../chunk-WN77AT67.js"; | ||
import "../chunk-6LCL2ZZF.js"; | ||
} from "../chunk-YUY37VAK.js"; | ||
import "../chunk-QMM35C3H.js"; | ||
import { | ||
Connection, | ||
Session | ||
} from "../chunk-YXDAOVP7.js"; | ||
} from "../chunk-3FALN7ZG.js"; | ||
import { | ||
OpaqueTransportMessageSchema, | ||
TransportMessageSchema | ||
} from "../chunk-TXSQRTZB.js"; | ||
} from "../chunk-LK74ZG7M.js"; | ||
import "../chunk-4PVU7J25.js"; | ||
@@ -21,0 +21,0 @@ export { |
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-75e84a9f.js'; | ||
import * as it_pushable from 'it-pushable'; | ||
import { P as PartialTransportMessage, b as OpaqueTransportMessage } from '../index-ea74cdbb.js'; | ||
import { T as Transport, C as Connection, h as SessionOptions, S as Session, i as ServiceContext } from '../handshake-75d0124f.js'; | ||
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-34d97070.js'; | ||
import { P as PartialTransportMessage, O as OpaqueTransportMessage } from '../index-10ebd26a.js'; | ||
import NodeWs from 'ws'; | ||
@@ -10,6 +8,5 @@ import http from 'node:http'; | ||
import { W as WsLike } from '../wslike-e0b32dd5.js'; | ||
import '../client-0926d3d6.js'; | ||
import '../types-3e5768ec.js'; | ||
import '@sinclair/typebox/value'; | ||
import '@opentelemetry/api'; | ||
import '../types-3e5768ec.js'; | ||
@@ -39,2 +36,14 @@ /** | ||
declare function onUdsServeReady(server: net.Server, path: string): Promise<void>; | ||
declare function getIteratorFromStream<T, E extends Static<BaseErrorSchemaType>>(readStream: ReadStream<T, E>): { | ||
next(): Promise<{ | ||
done: true; | ||
value: undefined; | ||
} | { | ||
done: false; | ||
value: OkResult<T> | ErrResult<E | { | ||
readonly code: "STREAM_DRAINED"; | ||
readonly message: "Stream was drained"; | ||
}>; | ||
}>; | ||
}; | ||
/** | ||
@@ -45,3 +54,11 @@ * Retrieves the next value from an async iterable iterator. | ||
*/ | ||
declare function iterNext<T>(iter: AsyncIterableIterator<T>): Promise<T>; | ||
declare function iterNext<T>(iter: { | ||
next(): Promise<{ | ||
done: false; | ||
value: T; | ||
} | { | ||
done: true; | ||
value: undefined; | ||
}>; | ||
}): Promise<T>; | ||
declare function payloadToTransportMessage<Payload>(payload: Payload): PartialTransportMessage<Payload>; | ||
@@ -61,17 +78,11 @@ declare function createDummyTransportMessage(): PartialTransportMessage<{ | ||
declare function dummySession(): Session<Connection>; | ||
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>>>; | ||
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 function asClientSubscription<State extends object, I extends PayloadType, O extends PayloadType, E extends RiverError>(state: State, proc: Procedure<State, 'subscription', I, O, E>, extendedContext?: Omit<ServiceContext, 'state'>, session?: Session<Connection>): (msg: Static<I>) => it_pushable.Pushable<Result<Static<O>, Static<E>>, void, unknown>; | ||
declare function asClientUpload<State extends object, I extends PayloadType, O extends PayloadType, E extends RiverError, Init extends PayloadType | null = null>(state: State, proc: Procedure<State, 'upload', 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>, Promise<{ | ||
ok: true; | ||
payload: unknown; | ||
} | { | ||
ok: false; | ||
payload: { | ||
readonly code: "UNCAUGHT_ERROR"; | ||
readonly message: string; | ||
}; | ||
} | ProcedureResult<O, E>>]; | ||
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>>>; | ||
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 function asClientSubscription<State extends object, Init extends PayloadType, Output extends PayloadType, Err extends ProcedureErrorSchemaType>(state: State, proc: Procedure<State, 'subscription', Init, null, Output, Err>, extendedContext?: Omit<ServiceContext, 'state'>, session?: Session<Connection>): (msg: Static<Init>) => ReadStream<Static<Output>, Static<Err>>; | ||
declare function asClientUpload<State extends object, Init extends PayloadType, Input extends PayloadType, Output extends PayloadType, Err extends ProcedureErrorSchemaType>(state: State, proc: Procedure<State, 'upload', Init, Input, Output, Err>, init?: Static<Init>, extendedContext?: Omit<ServiceContext, 'state'>, session?: Session<Connection>): [ | ||
WriteStream<Static<Input>>, | ||
() => Promise<Result<Static<Output>, Static<Err>>> | ||
]; | ||
declare const getUnixSocketPath: () => string; | ||
export { asClientRpc, asClientStream, asClientSubscription, asClientUpload, createDummyTransportMessage, createLocalWebSocketClient, createWebSocketServer, dummySession, getUnixSocketPath, iterNext, onUdsServeReady, onWsServerReady, payloadToTransportMessage, testingSessionOptions, waitForMessage }; | ||
export { asClientRpc, asClientStream, asClientSubscription, asClientUpload, createDummyTransportMessage, createLocalWebSocketClient, createWebSocketServer, dummySession, getIteratorFromStream, getUnixSocketPath, iterNext, onUdsServeReady, onWsServerReady, payloadToTransportMessage, testingSessionOptions, waitForMessage }; |
import { | ||
Err, | ||
UNCAUGHT_ERROR, | ||
pushable | ||
} from "../chunk-LTSLICON.js"; | ||
Ok, | ||
ReadStreamImpl, | ||
UNCAUGHT_ERROR_CODE, | ||
WriteStreamImpl | ||
} from "../chunk-E2ZXI663.js"; | ||
import { | ||
Session, | ||
defaultTransportOptions | ||
} from "../chunk-YXDAOVP7.js"; | ||
} from "../chunk-3FALN7ZG.js"; | ||
import { | ||
coerceErrorString | ||
} from "../chunk-TXSQRTZB.js"; | ||
} from "../chunk-LK74ZG7M.js"; | ||
import "../chunk-4PVU7J25.js"; | ||
@@ -43,2 +45,5 @@ | ||
} | ||
function getIteratorFromStream(readStream) { | ||
return readStream[Symbol.asyncIterator](); | ||
} | ||
async function iterNext(iter) { | ||
@@ -79,3 +84,3 @@ return await iter.next().then((res) => res.value); | ||
const errorMsg = coerceErrorString(err); | ||
return Err({ code: UNCAUGHT_ERROR, message: errorMsg }); | ||
return Err({ code: UNCAUGHT_ERROR_CODE, message: errorMsg }); | ||
} | ||
@@ -94,8 +99,8 @@ var testingSessionOptions = defaultTransportOptions; | ||
...extendedContext, | ||
from: session.from, | ||
state, | ||
to: session.to, | ||
from: session.from, | ||
streamId: nanoid(), | ||
session, | ||
metadata: {} | ||
metadata: {}, | ||
abortController: new AbortController(), | ||
clientAbortSignal: new AbortController().signal, | ||
onRequestFinished: () => void 0 | ||
}; | ||
@@ -105,43 +110,71 @@ } | ||
return async (msg) => { | ||
return await proc.handler(dummyCtx(state, session, extendedContext), msg).catch(catchProcError); | ||
return proc.handler(dummyCtx(state, session, extendedContext), msg).catch(catchProcError); | ||
}; | ||
} | ||
function asClientStream(state, proc, init, extendedContext, session = dummySession()) { | ||
const input = pushable({ objectMode: true }); | ||
const output = pushable({ | ||
objectMode: true | ||
function createOutputPipe() { | ||
const reader = new ReadStreamImpl(() => { | ||
void Promise.resolve().then(() => { | ||
writer.triggerCloseRequest(); | ||
}); | ||
}); | ||
void (async () => { | ||
if (init) { | ||
const _proc = proc; | ||
await _proc.handler(dummyCtx(state, session, extendedContext), init, input, output).catch((err) => output.push(catchProcError(err))); | ||
} else { | ||
const _proc = proc; | ||
await _proc.handler(dummyCtx(state, session, extendedContext), input, output).catch((err) => output.push(catchProcError(err))); | ||
const writer = new WriteStreamImpl( | ||
(v) => { | ||
reader.pushValue(v); | ||
}, | ||
() => { | ||
void Promise.resolve().then(() => { | ||
reader.triggerClose(); | ||
}); | ||
} | ||
})(); | ||
return [input, output]; | ||
); | ||
return { reader, writer }; | ||
} | ||
function createInputPipe() { | ||
const reader = new ReadStreamImpl(() => { | ||
void Promise.resolve().then(() => { | ||
writer.triggerCloseRequest(); | ||
}); | ||
}); | ||
const writer = new WriteStreamImpl( | ||
(v) => { | ||
reader.pushValue(Ok(v)); | ||
}, | ||
() => { | ||
void Promise.resolve().then(() => { | ||
reader.triggerClose(); | ||
}); | ||
} | ||
); | ||
return { reader, writer }; | ||
} | ||
function asClientStream(state, proc, init, extendedContext, session = dummySession()) { | ||
const inputPipe = createInputPipe(); | ||
const outputPipe = createOutputPipe(); | ||
void proc.handler( | ||
dummyCtx(state, session, extendedContext), | ||
init ?? {}, | ||
inputPipe.reader, | ||
outputPipe.writer | ||
).catch((err) => outputPipe.writer.write(catchProcError(err))); | ||
return [inputPipe.writer, outputPipe.reader]; | ||
} | ||
function asClientSubscription(state, proc, extendedContext, session = dummySession()) { | ||
const output = pushable({ | ||
objectMode: true | ||
}); | ||
const outputPipe = createOutputPipe(); | ||
return (msg) => { | ||
void (async () => { | ||
return await proc.handler(dummyCtx(state, session, extendedContext), msg, output).catch((err) => output.push(catchProcError(err))); | ||
})(); | ||
return output; | ||
void proc.handler( | ||
dummyCtx(state, session, extendedContext), | ||
msg, | ||
outputPipe.writer | ||
).catch((err) => outputPipe.writer.write(catchProcError(err))); | ||
return outputPipe.reader; | ||
}; | ||
} | ||
function asClientUpload(state, proc, init, extendedContext, session = dummySession()) { | ||
const input = pushable({ objectMode: true }); | ||
if (init) { | ||
const _proc = proc; | ||
const result = _proc.handler(dummyCtx(state, session, extendedContext), init, input).catch(catchProcError); | ||
return [input, result]; | ||
} else { | ||
const _proc = proc; | ||
const result = _proc.handler(dummyCtx(state, session, extendedContext), input).catch(catchProcError); | ||
return [input, result]; | ||
} | ||
const inputPipe = createInputPipe(); | ||
const result = proc.handler( | ||
dummyCtx(state, session, extendedContext), | ||
init ?? {}, | ||
inputPipe.reader | ||
).catch(catchProcError); | ||
return [inputPipe.writer, () => result]; | ||
} | ||
@@ -160,2 +193,3 @@ var getUnixSocketPath = () => { | ||
dummySession, | ||
getIteratorFromStream, | ||
getUnixSocketPath, | ||
@@ -162,0 +196,0 @@ iterNext, |
{ | ||
"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.16", | ||
"version": "0.200.0-rc.0", | ||
"type": "module", | ||
@@ -52,3 +52,2 @@ "exports": { | ||
"@msgpack/msgpack": "^3.0.0-beta2", | ||
"it-pushable": "^3.2.3", | ||
"nanoid": "^4.0.2", | ||
@@ -62,5 +61,5 @@ "ws": "^8.17.0" | ||
"devDependencies": { | ||
"@opentelemetry/core": "^1.7.0", | ||
"@opentelemetry/sdk-trace-base": "^1.24.1", | ||
"@opentelemetry/sdk-trace-web": "^1.24.1", | ||
"@opentelemetry/core": "^1.7.0", | ||
"@types/ws": "^8.5.5", | ||
@@ -67,0 +66,0 @@ "@typescript-eslint/eslint-plugin": "^7.8.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
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
1695420
5
17956
83
- Removedit-pushable@^3.2.3
- Removedit-pushable@3.2.3(transitive)
- Removedp-defer@4.0.1(transitive)