@replit/river
Advanced tools
Comparing version 0.17.3 to 0.17.4
import { TUnion, Static } from '@sinclair/typebox'; | ||
import { e as ProcedureMap, P as PayloadType, c as RiverUncaughtSchema, U as Unbranded, B as Branded, A as AnyProcedure, R as RiverError, b as Result, S as ServiceContext } from '../procedures-79a5f07e.js'; | ||
export { E as Err, O as Ok, a as Procedure, d as ProcedureResult, f as RPCProcedure, m as RiverErrorSchema, j as ServiceContextWithState, k as ServiceContextWithTransportInfo, i as StreamProcedure, h as SubscriptionProcedure, l as UNCAUGHT_ERROR, g as UploadProcedure, V as ValidProcType } from '../procedures-79a5f07e.js'; | ||
import { d as ServerTransport, C as Connection, a as ClientTransport, b as TransportClientId } from '../index-80f87385.js'; | ||
import { e as ProcedureMap, P as PayloadType, c as RiverUncaughtSchema, U as Unbranded, B as Branded, A as AnyProcedure, R as RiverError, b as Result, S as ServiceContext } from '../procedures-1c0d2eee.js'; | ||
export { E as Err, O as Ok, a as Procedure, d as ProcedureResult, f as RPCProcedure, m as RiverErrorSchema, j as ServiceContextWithState, k as ServiceContextWithTransportInfo, i as StreamProcedure, h as SubscriptionProcedure, l as UNCAUGHT_ERROR, g as UploadProcedure, V as ValidProcType } from '../procedures-1c0d2eee.js'; | ||
import { e as ServerTransport, C as Connection, b as ClientTransport, c as TransportClientId } from '../index-9e300e8a.js'; | ||
import { Pushable } from 'it-pushable'; | ||
@@ -6,0 +6,0 @@ import '../types-3e5768ec.js'; |
@@ -1,3 +0,3 @@ | ||
import { a as ClientTransport, c as ProvidedClientTransportOptions, b as TransportClientId } from '../../../index-80f87385.js'; | ||
import { U as UdsConnection } from '../../../connection-713c8c66.js'; | ||
import { b as ClientTransport, d as ProvidedClientTransportOptions, c as TransportClientId } from '../../../index-9e300e8a.js'; | ||
import { U as UdsConnection } from '../../../connection-bdbd20da.js'; | ||
import '../../../types-3e5768ec.js'; | ||
@@ -4,0 +4,0 @@ import '@sinclair/typebox'; |
import { Server, Socket } from 'node:net'; | ||
import { d as ServerTransport, b as TransportClientId, e as ProvidedTransportOptions } from '../../../index-80f87385.js'; | ||
import { U as UdsConnection } from '../../../connection-713c8c66.js'; | ||
import { e as ServerTransport, c as TransportClientId, f as ProvidedTransportOptions } from '../../../index-9e300e8a.js'; | ||
import { U as UdsConnection } from '../../../connection-bdbd20da.js'; | ||
import '../../../types-3e5768ec.js'; | ||
@@ -5,0 +5,0 @@ import '@sinclair/typebox'; |
import WebSocket from 'isomorphic-ws'; | ||
import { a as ClientTransport, b as TransportClientId, c as ProvidedClientTransportOptions } from '../../../index-80f87385.js'; | ||
import { W as WebSocketConnection } from '../../../connection-b79329de.js'; | ||
import { b as ClientTransport, c as TransportClientId, d as ProvidedClientTransportOptions } from '../../../index-9e300e8a.js'; | ||
import { W as WebSocketConnection } from '../../../connection-c4a17403.js'; | ||
import '../../../types-3e5768ec.js'; | ||
@@ -5,0 +5,0 @@ import '@sinclair/typebox'; |
@@ -1,5 +0,5 @@ | ||
import { d as ServerTransport, b as TransportClientId, e as ProvidedTransportOptions } from '../../../index-80f87385.js'; | ||
import { e as ServerTransport, c as TransportClientId, f as ProvidedTransportOptions } from '../../../index-9e300e8a.js'; | ||
import { WebSocketServer } from 'ws'; | ||
import { WebSocket } from 'isomorphic-ws'; | ||
import { W as WebSocketConnection } from '../../../connection-b79329de.js'; | ||
import { W as WebSocketConnection } from '../../../connection-c4a17403.js'; | ||
import '../../../types-3e5768ec.js'; | ||
@@ -6,0 +6,0 @@ import '@sinclair/typebox'; |
@@ -1,3 +0,3 @@ | ||
export { a as ClientTransport, c as ClientTransportOptions, C as Connection, n as EventHandler, E as EventMap, m as EventTypes, O as OpaqueTransportMessage, i as OpaqueTransportMessageSchema, o as ProtocolError, p as ProtocolErrorType, d as ServerTransport, f as Session, T as Transport, b as TransportClientId, j as TransportMessage, h as TransportMessageSchema, e as TransportOptions, g as TransportStatus, l as isStreamClose, k as isStreamOpen } from '../index-80f87385.js'; | ||
export { b as ClientTransport, d as ClientTransportOptions, C as Connection, n as EventHandler, E as EventMap, m as EventTypes, O as OpaqueTransportMessage, i as OpaqueTransportMessageSchema, o as ProtocolError, p as ProtocolErrorType, e as ServerTransport, a as Session, T as Transport, c as TransportClientId, j as TransportMessage, h as TransportMessageSchema, f as TransportOptions, g as TransportStatus, l as isStreamClose, k as isStreamOpen } from '../index-9e300e8a.js'; | ||
import '../types-3e5768ec.js'; | ||
import '@sinclair/typebox'; |
import { Static } from '@sinclair/typebox'; | ||
import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema, d as ProcedureResult } from '../procedures-79a5f07e.js'; | ||
import { P as PartialTransportMessage, T as Transport, C as Connection, O as OpaqueTransportMessage, S as SessionOptions } from '../index-80f87385.js'; | ||
import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema, d as ProcedureResult } from '../procedures-1c0d2eee.js'; | ||
import { P as PartialTransportMessage, T as Transport, C as Connection, O as OpaqueTransportMessage, S as SessionOptions, a as Session } from '../index-9e300e8a.js'; | ||
import * as it_pushable from 'it-pushable'; | ||
@@ -52,6 +52,6 @@ import WebSocket from 'isomorphic-ws'; | ||
declare const testingSessionOptions: SessionOptions; | ||
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'>): (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'>): 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'>): (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'>): readonly [it_pushable.Pushable<Static<I>, void, unknown>, Promise<{ | ||
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: boolean; | ||
@@ -58,0 +58,0 @@ payload: { |
@@ -89,14 +89,16 @@ import { | ||
var testingSessionOptions = defaultTransportOptions; | ||
function dummyCtx(state, extendedContext) { | ||
const session = new Session( | ||
function dummySession() { | ||
return new Session( | ||
void 0, | ||
"client", | ||
"SERVER", | ||
"server", | ||
testingSessionOptions | ||
); | ||
} | ||
function dummyCtx(state, session, extendedContext) { | ||
return { | ||
...extendedContext, | ||
state, | ||
to: "SERVER", | ||
from: "client", | ||
to: session.to, | ||
from: session.from, | ||
streamId: nanoid(), | ||
@@ -106,8 +108,8 @@ session | ||
} | ||
function asClientRpc(state, proc, extendedContext) { | ||
function asClientRpc(state, proc, extendedContext, session = dummySession()) { | ||
return async (msg) => { | ||
return await proc.handler(dummyCtx(state, extendedContext), msg).catch(catchProcError); | ||
return await proc.handler(dummyCtx(state, session, extendedContext), msg).catch(catchProcError); | ||
}; | ||
} | ||
function asClientStream(state, proc, init, extendedContext) { | ||
function asClientStream(state, proc, init, extendedContext, session = dummySession()) { | ||
const input = pushable({ objectMode: true }); | ||
@@ -120,6 +122,6 @@ const output = pushable({ | ||
const _proc = proc; | ||
await _proc.handler(dummyCtx(state, extendedContext), init, input, output).catch((err) => output.push(catchProcError(err))); | ||
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, extendedContext), input, output).catch((err) => output.push(catchProcError(err))); | ||
await _proc.handler(dummyCtx(state, session, extendedContext), input, output).catch((err) => output.push(catchProcError(err))); | ||
} | ||
@@ -129,3 +131,3 @@ })(); | ||
} | ||
function asClientSubscription(state, proc, extendedContext) { | ||
function asClientSubscription(state, proc, extendedContext, session = dummySession()) { | ||
const output = pushable({ | ||
@@ -136,3 +138,3 @@ objectMode: true | ||
void (async () => { | ||
return await proc.handler(dummyCtx(state, extendedContext), msg, output).catch((err) => output.push(catchProcError(err))); | ||
return await proc.handler(dummyCtx(state, session, extendedContext), msg, output).catch((err) => output.push(catchProcError(err))); | ||
})(); | ||
@@ -142,11 +144,11 @@ return output; | ||
} | ||
function asClientUpload(state, proc, init, extendedContext) { | ||
function asClientUpload(state, proc, init, extendedContext, session = dummySession()) { | ||
const input = pushable({ objectMode: true }); | ||
if (init) { | ||
const _proc = proc; | ||
const result = _proc.handler(dummyCtx(state, extendedContext), init, input).catch(catchProcError); | ||
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, extendedContext), input).catch(catchProcError); | ||
const result = _proc.handler(dummyCtx(state, session, extendedContext), input).catch(catchProcError); | ||
return [input, result]; | ||
@@ -153,0 +155,0 @@ } |
{ | ||
"name": "@replit/river", | ||
"description": "It's like tRPC but... with JSON Schema Support, duplex streaming and support for service multiplexing. Transport agnostic!", | ||
"version": "0.17.3", | ||
"version": "0.17.4", | ||
"type": "module", | ||
@@ -6,0 +6,0 @@ "exports": { |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
403242
11537
2