@replit/river 0.17.3 → 0.17.4
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.
- package/dist/{connection-713c8c66.d.ts → connection-bdbd20da.d.ts} +1 -1
- package/dist/{connection-b79329de.d.ts → connection-c4a17403.d.ts} +1 -1
- package/dist/{index-80f87385.d.ts → index-9e300e8a.d.ts} +1 -1
- package/dist/{procedures-79a5f07e.d.ts → procedures-1c0d2eee.d.ts} +1 -1
- package/dist/router/index.d.cts +3 -3
- package/dist/router/index.d.ts +3 -3
- package/dist/transport/impls/uds/client.d.cts +2 -2
- package/dist/transport/impls/uds/client.d.ts +2 -2
- package/dist/transport/impls/uds/server.d.cts +2 -2
- package/dist/transport/impls/uds/server.d.ts +2 -2
- package/dist/transport/impls/ws/client.d.cts +2 -2
- package/dist/transport/impls/ws/client.d.ts +2 -2
- package/dist/transport/impls/ws/server.d.cts +2 -2
- package/dist/transport/impls/ws/server.d.ts +2 -2
- package/dist/transport/index.d.cts +1 -1
- package/dist/transport/index.d.ts +1 -1
- package/dist/util/testHelpers.cjs +17 -15
- package/dist/util/testHelpers.d.cts +6 -6
- package/dist/util/testHelpers.d.ts +6 -6
- package/dist/util/testHelpers.js +17 -15
- package/package.json +1 -1
|
@@ -499,4 +499,4 @@ declare abstract class ServerTransport<ConnType extends Connection> extends Tran
|
|
|
499
499
|
receiveHandshakeRequestMessage(data: Uint8Array, conn: ConnType): Session<ConnType> | false;
|
|
500
500
|
}
|
|
501
501
|
|
|
502
|
-
export { Connection as C, EventMap as E, OpaqueTransportMessage as O, PartialTransportMessage as P, SessionOptions as S, Transport as T,
|
|
502
|
+
export { Connection as C, EventMap as E, OpaqueTransportMessage as O, PartialTransportMessage as P, SessionOptions as S, Transport as T, Session as a, ClientTransport as b, TransportClientId as c, ProvidedClientTransportOptions as d, ServerTransport as e, ProvidedTransportOptions as f, TransportStatus as g, TransportMessageSchema as h, OpaqueTransportMessageSchema as i, TransportMessage as j, isStreamOpen as k, isStreamClose as l, EventTypes as m, EventHandler as n, ProtocolError as o, ProtocolErrorType as p };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TObject, TUnion, TString, TSchema, TNever, TLiteral, Static } from '@sinclair/typebox';
|
|
2
2
|
import { Pushable } from 'it-pushable';
|
|
3
|
-
import {
|
|
3
|
+
import { c as TransportClientId, a as Session, C as Connection } from './index-9e300e8a.js';
|
|
4
4
|
|
|
5
5
|
type TLiteralString = TLiteral<string>;
|
|
6
6
|
type RiverErrorSchema = TObject<{
|
package/dist/router/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TUnion, Static } from '@sinclair/typebox';
|
|
2
|
-
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-
|
|
3
|
-
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-
|
|
4
|
-
import {
|
|
2
|
+
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';
|
|
3
|
+
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';
|
|
4
|
+
import { e as ServerTransport, C as Connection, b as ClientTransport, c as TransportClientId } from '../index-9e300e8a.js';
|
|
5
5
|
import { Pushable } from 'it-pushable';
|
|
6
6
|
import '../types-3e5768ec.js';
|
|
7
7
|
|
package/dist/router/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TUnion, Static } from '@sinclair/typebox';
|
|
2
|
-
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-
|
|
3
|
-
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-
|
|
4
|
-
import {
|
|
2
|
+
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';
|
|
3
|
+
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';
|
|
4
|
+
import { e as ServerTransport, C as Connection, b as ClientTransport, c as TransportClientId } from '../index-9e300e8a.js';
|
|
5
5
|
import { Pushable } from 'it-pushable';
|
|
6
6
|
import '../types-3e5768ec.js';
|
|
7
7
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { U as UdsConnection } from '../../../connection-
|
|
1
|
+
import { b as ClientTransport, d as ProvidedClientTransportOptions, c as TransportClientId } from '../../../index-9e300e8a.js';
|
|
2
|
+
import { U as UdsConnection } from '../../../connection-bdbd20da.js';
|
|
3
3
|
import '../../../types-3e5768ec.js';
|
|
4
4
|
import '@sinclair/typebox';
|
|
5
5
|
import 'node:net';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { U as UdsConnection } from '../../../connection-
|
|
1
|
+
import { b as ClientTransport, d as ProvidedClientTransportOptions, c as TransportClientId } from '../../../index-9e300e8a.js';
|
|
2
|
+
import { U as UdsConnection } from '../../../connection-bdbd20da.js';
|
|
3
3
|
import '../../../types-3e5768ec.js';
|
|
4
4
|
import '@sinclair/typebox';
|
|
5
5
|
import 'node:net';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Server, Socket } from 'node:net';
|
|
2
|
-
import {
|
|
3
|
-
import { U as UdsConnection } from '../../../connection-
|
|
2
|
+
import { e as ServerTransport, c as TransportClientId, f as ProvidedTransportOptions } from '../../../index-9e300e8a.js';
|
|
3
|
+
import { U as UdsConnection } from '../../../connection-bdbd20da.js';
|
|
4
4
|
import '../../../types-3e5768ec.js';
|
|
5
5
|
import '@sinclair/typebox';
|
|
6
6
|
import 'node:stream';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Server, Socket } from 'node:net';
|
|
2
|
-
import {
|
|
3
|
-
import { U as UdsConnection } from '../../../connection-
|
|
2
|
+
import { e as ServerTransport, c as TransportClientId, f as ProvidedTransportOptions } from '../../../index-9e300e8a.js';
|
|
3
|
+
import { U as UdsConnection } from '../../../connection-bdbd20da.js';
|
|
4
4
|
import '../../../types-3e5768ec.js';
|
|
5
5
|
import '@sinclair/typebox';
|
|
6
6
|
import 'node:stream';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import WebSocket from 'isomorphic-ws';
|
|
2
|
-
import {
|
|
3
|
-
import { W as WebSocketConnection } from '../../../connection-
|
|
2
|
+
import { b as ClientTransport, c as TransportClientId, d as ProvidedClientTransportOptions } from '../../../index-9e300e8a.js';
|
|
3
|
+
import { W as WebSocketConnection } from '../../../connection-c4a17403.js';
|
|
4
4
|
import '../../../types-3e5768ec.js';
|
|
5
5
|
import '@sinclair/typebox';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import WebSocket from 'isomorphic-ws';
|
|
2
|
-
import {
|
|
3
|
-
import { W as WebSocketConnection } from '../../../connection-
|
|
2
|
+
import { b as ClientTransport, c as TransportClientId, d as ProvidedClientTransportOptions } from '../../../index-9e300e8a.js';
|
|
3
|
+
import { W as WebSocketConnection } from '../../../connection-c4a17403.js';
|
|
4
4
|
import '../../../types-3e5768ec.js';
|
|
5
5
|
import '@sinclair/typebox';
|
|
6
6
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { e as ServerTransport, c as TransportClientId, f as ProvidedTransportOptions } from '../../../index-9e300e8a.js';
|
|
2
2
|
import { WebSocketServer } from 'ws';
|
|
3
3
|
import { WebSocket } from 'isomorphic-ws';
|
|
4
|
-
import { W as WebSocketConnection } from '../../../connection-
|
|
4
|
+
import { W as WebSocketConnection } from '../../../connection-c4a17403.js';
|
|
5
5
|
import '../../../types-3e5768ec.js';
|
|
6
6
|
import '@sinclair/typebox';
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { e as ServerTransport, c as TransportClientId, f as ProvidedTransportOptions } from '../../../index-9e300e8a.js';
|
|
2
2
|
import { WebSocketServer } from 'ws';
|
|
3
3
|
import { WebSocket } from 'isomorphic-ws';
|
|
4
|
-
import { W as WebSocketConnection } from '../../../connection-
|
|
4
|
+
import { W as WebSocketConnection } from '../../../connection-c4a17403.js';
|
|
5
5
|
import '../../../types-3e5768ec.js';
|
|
6
6
|
import '@sinclair/typebox';
|
|
7
7
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export {
|
|
1
|
+
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';
|
|
2
2
|
import '../types-3e5768ec.js';
|
|
3
3
|
import '@sinclair/typebox';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export {
|
|
1
|
+
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';
|
|
2
2
|
import '../types-3e5768ec.js';
|
|
3
3
|
import '@sinclair/typebox';
|
|
@@ -696,28 +696,30 @@ function catchProcError(err) {
|
|
|
696
696
|
};
|
|
697
697
|
}
|
|
698
698
|
var testingSessionOptions = defaultTransportOptions;
|
|
699
|
-
function
|
|
700
|
-
|
|
699
|
+
function dummySession() {
|
|
700
|
+
return new Session(
|
|
701
701
|
void 0,
|
|
702
702
|
"client",
|
|
703
|
-
"
|
|
703
|
+
"server",
|
|
704
704
|
testingSessionOptions
|
|
705
705
|
);
|
|
706
|
+
}
|
|
707
|
+
function dummyCtx(state, session, extendedContext) {
|
|
706
708
|
return {
|
|
707
709
|
...extendedContext,
|
|
708
710
|
state,
|
|
709
|
-
to:
|
|
710
|
-
from:
|
|
711
|
+
to: session.to,
|
|
712
|
+
from: session.from,
|
|
711
713
|
streamId: (0, import_nanoid2.nanoid)(),
|
|
712
714
|
session
|
|
713
715
|
};
|
|
714
716
|
}
|
|
715
|
-
function asClientRpc(state, proc, extendedContext) {
|
|
717
|
+
function asClientRpc(state, proc, extendedContext, session = dummySession()) {
|
|
716
718
|
return async (msg) => {
|
|
717
|
-
return await proc.handler(dummyCtx(state, extendedContext), msg).catch(catchProcError);
|
|
719
|
+
return await proc.handler(dummyCtx(state, session, extendedContext), msg).catch(catchProcError);
|
|
718
720
|
};
|
|
719
721
|
}
|
|
720
|
-
function asClientStream(state, proc, init, extendedContext) {
|
|
722
|
+
function asClientStream(state, proc, init, extendedContext, session = dummySession()) {
|
|
721
723
|
const input = pushable({ objectMode: true });
|
|
722
724
|
const output = pushable({
|
|
723
725
|
objectMode: true
|
|
@@ -725,34 +727,34 @@ function asClientStream(state, proc, init, extendedContext) {
|
|
|
725
727
|
void (async () => {
|
|
726
728
|
if (init) {
|
|
727
729
|
const _proc = proc;
|
|
728
|
-
await _proc.handler(dummyCtx(state, extendedContext), init, input, output).catch((err) => output.push(catchProcError(err)));
|
|
730
|
+
await _proc.handler(dummyCtx(state, session, extendedContext), init, input, output).catch((err) => output.push(catchProcError(err)));
|
|
729
731
|
} else {
|
|
730
732
|
const _proc = proc;
|
|
731
|
-
await _proc.handler(dummyCtx(state, extendedContext), input, output).catch((err) => output.push(catchProcError(err)));
|
|
733
|
+
await _proc.handler(dummyCtx(state, session, extendedContext), input, output).catch((err) => output.push(catchProcError(err)));
|
|
732
734
|
}
|
|
733
735
|
})();
|
|
734
736
|
return [input, output];
|
|
735
737
|
}
|
|
736
|
-
function asClientSubscription(state, proc, extendedContext) {
|
|
738
|
+
function asClientSubscription(state, proc, extendedContext, session = dummySession()) {
|
|
737
739
|
const output = pushable({
|
|
738
740
|
objectMode: true
|
|
739
741
|
});
|
|
740
742
|
return (msg) => {
|
|
741
743
|
void (async () => {
|
|
742
|
-
return await proc.handler(dummyCtx(state, extendedContext), msg, output).catch((err) => output.push(catchProcError(err)));
|
|
744
|
+
return await proc.handler(dummyCtx(state, session, extendedContext), msg, output).catch((err) => output.push(catchProcError(err)));
|
|
743
745
|
})();
|
|
744
746
|
return output;
|
|
745
747
|
};
|
|
746
748
|
}
|
|
747
|
-
function asClientUpload(state, proc, init, extendedContext) {
|
|
749
|
+
function asClientUpload(state, proc, init, extendedContext, session = dummySession()) {
|
|
748
750
|
const input = pushable({ objectMode: true });
|
|
749
751
|
if (init) {
|
|
750
752
|
const _proc = proc;
|
|
751
|
-
const result = _proc.handler(dummyCtx(state, extendedContext), init, input).catch(catchProcError);
|
|
753
|
+
const result = _proc.handler(dummyCtx(state, session, extendedContext), init, input).catch(catchProcError);
|
|
752
754
|
return [input, result];
|
|
753
755
|
} else {
|
|
754
756
|
const _proc = proc;
|
|
755
|
-
const result = _proc.handler(dummyCtx(state, extendedContext), input).catch(catchProcError);
|
|
757
|
+
const result = _proc.handler(dummyCtx(state, session, extendedContext), input).catch(catchProcError);
|
|
756
758
|
return [input, result];
|
|
757
759
|
}
|
|
758
760
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Static } from '@sinclair/typebox';
|
|
2
|
-
import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema, d as ProcedureResult } from '../procedures-
|
|
3
|
-
import { P as PartialTransportMessage, T as Transport, C as Connection, O as OpaqueTransportMessage, S as SessionOptions } from '../index-
|
|
2
|
+
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';
|
|
3
|
+
import { P as PartialTransportMessage, T as Transport, C as Connection, O as OpaqueTransportMessage, S as SessionOptions, a as Session } from '../index-9e300e8a.js';
|
|
4
4
|
import * as it_pushable from 'it-pushable';
|
|
5
5
|
import WebSocket from 'isomorphic-ws';
|
|
6
6
|
import http from 'node:http';
|
|
@@ -49,10 +49,10 @@ declare function createDummyTransportMessage(): PartialTransportMessage<{
|
|
|
49
49
|
*/
|
|
50
50
|
declare function waitForMessage(t: Transport<Connection>, filter?: (msg: OpaqueTransportMessage) => boolean, rejectMismatch?: boolean): Promise<unknown>;
|
|
51
51
|
declare const testingSessionOptions: SessionOptions;
|
|
52
|
-
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>>>;
|
|
53
|
-
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>];
|
|
54
|
-
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>;
|
|
55
|
-
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<{
|
|
52
|
+
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>>>;
|
|
53
|
+
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>];
|
|
54
|
+
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>;
|
|
55
|
+
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<{
|
|
56
56
|
ok: boolean;
|
|
57
57
|
payload: {
|
|
58
58
|
code: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Static } from '@sinclair/typebox';
|
|
2
|
-
import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema, d as ProcedureResult } from '../procedures-
|
|
3
|
-
import { P as PartialTransportMessage, T as Transport, C as Connection, O as OpaqueTransportMessage, S as SessionOptions } from '../index-
|
|
2
|
+
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';
|
|
3
|
+
import { P as PartialTransportMessage, T as Transport, C as Connection, O as OpaqueTransportMessage, S as SessionOptions, a as Session } from '../index-9e300e8a.js';
|
|
4
4
|
import * as it_pushable from 'it-pushable';
|
|
5
5
|
import WebSocket from 'isomorphic-ws';
|
|
6
6
|
import http from 'node:http';
|
|
@@ -49,10 +49,10 @@ declare function createDummyTransportMessage(): PartialTransportMessage<{
|
|
|
49
49
|
*/
|
|
50
50
|
declare function waitForMessage(t: Transport<Connection>, filter?: (msg: OpaqueTransportMessage) => boolean, rejectMismatch?: boolean): Promise<unknown>;
|
|
51
51
|
declare const testingSessionOptions: SessionOptions;
|
|
52
|
-
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>>>;
|
|
53
|
-
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>];
|
|
54
|
-
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>;
|
|
55
|
-
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<{
|
|
52
|
+
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>>>;
|
|
53
|
+
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>];
|
|
54
|
+
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>;
|
|
55
|
+
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<{
|
|
56
56
|
ok: boolean;
|
|
57
57
|
payload: {
|
|
58
58
|
code: string;
|
package/dist/util/testHelpers.js
CHANGED
|
@@ -86,28 +86,30 @@ function catchProcError(err) {
|
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
88
|
var testingSessionOptions = defaultTransportOptions;
|
|
89
|
-
function
|
|
90
|
-
|
|
89
|
+
function dummySession() {
|
|
90
|
+
return new Session(
|
|
91
91
|
void 0,
|
|
92
92
|
"client",
|
|
93
|
-
"
|
|
93
|
+
"server",
|
|
94
94
|
testingSessionOptions
|
|
95
95
|
);
|
|
96
|
+
}
|
|
97
|
+
function dummyCtx(state, session, extendedContext) {
|
|
96
98
|
return {
|
|
97
99
|
...extendedContext,
|
|
98
100
|
state,
|
|
99
|
-
to:
|
|
100
|
-
from:
|
|
101
|
+
to: session.to,
|
|
102
|
+
from: session.from,
|
|
101
103
|
streamId: nanoid(),
|
|
102
104
|
session
|
|
103
105
|
};
|
|
104
106
|
}
|
|
105
|
-
function asClientRpc(state, proc, extendedContext) {
|
|
107
|
+
function asClientRpc(state, proc, extendedContext, session = dummySession()) {
|
|
106
108
|
return async (msg) => {
|
|
107
|
-
return await proc.handler(dummyCtx(state, extendedContext), msg).catch(catchProcError);
|
|
109
|
+
return await proc.handler(dummyCtx(state, session, extendedContext), msg).catch(catchProcError);
|
|
108
110
|
};
|
|
109
111
|
}
|
|
110
|
-
function asClientStream(state, proc, init, extendedContext) {
|
|
112
|
+
function asClientStream(state, proc, init, extendedContext, session = dummySession()) {
|
|
111
113
|
const input = pushable({ objectMode: true });
|
|
112
114
|
const output = pushable({
|
|
113
115
|
objectMode: true
|
|
@@ -115,34 +117,34 @@ function asClientStream(state, proc, init, extendedContext) {
|
|
|
115
117
|
void (async () => {
|
|
116
118
|
if (init) {
|
|
117
119
|
const _proc = proc;
|
|
118
|
-
await _proc.handler(dummyCtx(state, extendedContext), init, input, output).catch((err) => output.push(catchProcError(err)));
|
|
120
|
+
await _proc.handler(dummyCtx(state, session, extendedContext), init, input, output).catch((err) => output.push(catchProcError(err)));
|
|
119
121
|
} else {
|
|
120
122
|
const _proc = proc;
|
|
121
|
-
await _proc.handler(dummyCtx(state, extendedContext), input, output).catch((err) => output.push(catchProcError(err)));
|
|
123
|
+
await _proc.handler(dummyCtx(state, session, extendedContext), input, output).catch((err) => output.push(catchProcError(err)));
|
|
122
124
|
}
|
|
123
125
|
})();
|
|
124
126
|
return [input, output];
|
|
125
127
|
}
|
|
126
|
-
function asClientSubscription(state, proc, extendedContext) {
|
|
128
|
+
function asClientSubscription(state, proc, extendedContext, session = dummySession()) {
|
|
127
129
|
const output = pushable({
|
|
128
130
|
objectMode: true
|
|
129
131
|
});
|
|
130
132
|
return (msg) => {
|
|
131
133
|
void (async () => {
|
|
132
|
-
return await proc.handler(dummyCtx(state, extendedContext), msg, output).catch((err) => output.push(catchProcError(err)));
|
|
134
|
+
return await proc.handler(dummyCtx(state, session, extendedContext), msg, output).catch((err) => output.push(catchProcError(err)));
|
|
133
135
|
})();
|
|
134
136
|
return output;
|
|
135
137
|
};
|
|
136
138
|
}
|
|
137
|
-
function asClientUpload(state, proc, init, extendedContext) {
|
|
139
|
+
function asClientUpload(state, proc, init, extendedContext, session = dummySession()) {
|
|
138
140
|
const input = pushable({ objectMode: true });
|
|
139
141
|
if (init) {
|
|
140
142
|
const _proc = proc;
|
|
141
|
-
const result = _proc.handler(dummyCtx(state, extendedContext), init, input).catch(catchProcError);
|
|
143
|
+
const result = _proc.handler(dummyCtx(state, session, extendedContext), init, input).catch(catchProcError);
|
|
142
144
|
return [input, result];
|
|
143
145
|
} else {
|
|
144
146
|
const _proc = proc;
|
|
145
|
-
const result = _proc.handler(dummyCtx(state, extendedContext), input).catch(catchProcError);
|
|
147
|
+
const result = _proc.handler(dummyCtx(state, session, extendedContext), input).catch(catchProcError);
|
|
146
148
|
return [input, result];
|
|
147
149
|
}
|
|
148
150
|
}
|
package/package.json
CHANGED