@replit/river 0.17.1 → 0.17.3
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/{chunk-7IQO434V.js → chunk-4C2OXQJB.js} +66 -5
- package/dist/{chunk-F6KWMEPR.js → chunk-7WY3Z5ZN.js} +5 -3
- package/dist/{chunk-MSAS5CVJ.js → chunk-F3LFO3GU.js} +1 -1
- package/dist/{chunk-4A7FDC2C.js → chunk-Q7OSVPZ5.js} +1 -1
- package/dist/{connection-0767dc6b.d.ts → connection-713c8c66.d.ts} +1 -1
- package/dist/{connection-f31edbcd.d.ts → connection-b79329de.d.ts} +1 -1
- package/dist/{index-8df0bdfb.d.ts → index-80f87385.d.ts} +1 -0
- package/dist/{procedures-b5ddb54d.d.ts → procedures-79a5f07e.d.ts} +20 -2
- package/dist/router/index.cjs +66 -5
- package/dist/router/index.d.cts +18 -7
- package/dist/router/index.d.ts +18 -7
- package/dist/router/index.js +1 -1
- package/dist/transport/impls/uds/client.cjs +5 -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/client.js +2 -2
- package/dist/transport/impls/uds/server.cjs +4 -9
- package/dist/transport/impls/uds/server.d.cts +2 -2
- package/dist/transport/impls/uds/server.d.ts +2 -2
- package/dist/transport/impls/uds/server.js +3 -8
- package/dist/transport/impls/ws/client.cjs +5 -3
- 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/client.js +2 -2
- package/dist/transport/impls/ws/server.cjs +1 -3
- package/dist/transport/impls/ws/server.d.cts +2 -2
- package/dist/transport/impls/ws/server.d.ts +2 -2
- package/dist/transport/impls/ws/server.js +2 -2
- package/dist/transport/index.cjs +5 -3
- package/dist/transport/index.d.cts +1 -1
- package/dist/transport/index.d.ts +1 -1
- package/dist/transport/index.js +1 -1
- package/dist/util/testHelpers.d.cts +2 -2
- package/dist/util/testHelpers.d.ts +2 -2
- package/dist/util/testHelpers.js +2 -2
- package/package.json +2 -2
|
@@ -111,7 +111,9 @@ var ServiceSchema = class _ServiceSchema {
|
|
|
111
111
|
{
|
|
112
112
|
input: Type.Strict(procDef.input),
|
|
113
113
|
output: Type.Strict(procDef.output),
|
|
114
|
-
// Only add
|
|
114
|
+
// Only add `description` field if the type declares it.
|
|
115
|
+
..."description" in procDef ? { description: procDef.description } : {},
|
|
116
|
+
// Only add the `errors` field if the type declares it.
|
|
115
117
|
..."errors" in procDef ? {
|
|
116
118
|
errors: Type.Strict(procDef.errors)
|
|
117
119
|
} : {},
|
|
@@ -201,35 +203,83 @@ function rpc({
|
|
|
201
203
|
input,
|
|
202
204
|
output,
|
|
203
205
|
errors = Type2.Never(),
|
|
206
|
+
description,
|
|
204
207
|
handler
|
|
205
208
|
}) {
|
|
206
|
-
return {
|
|
209
|
+
return {
|
|
210
|
+
...description ? { description } : {},
|
|
211
|
+
type: "rpc",
|
|
212
|
+
input,
|
|
213
|
+
output,
|
|
214
|
+
errors,
|
|
215
|
+
handler
|
|
216
|
+
};
|
|
207
217
|
}
|
|
208
218
|
function upload({
|
|
209
219
|
init,
|
|
210
220
|
input,
|
|
211
221
|
output,
|
|
212
222
|
errors = Type2.Never(),
|
|
223
|
+
description,
|
|
213
224
|
handler
|
|
214
225
|
}) {
|
|
215
|
-
return init !== void 0 && init !== null ? {
|
|
226
|
+
return init !== void 0 && init !== null ? {
|
|
227
|
+
type: "upload",
|
|
228
|
+
...description ? { description } : {},
|
|
229
|
+
init,
|
|
230
|
+
input,
|
|
231
|
+
output,
|
|
232
|
+
errors,
|
|
233
|
+
handler
|
|
234
|
+
} : {
|
|
235
|
+
type: "upload",
|
|
236
|
+
...description ? { description } : {},
|
|
237
|
+
input,
|
|
238
|
+
output,
|
|
239
|
+
errors,
|
|
240
|
+
handler
|
|
241
|
+
};
|
|
216
242
|
}
|
|
217
243
|
function subscription({
|
|
218
244
|
input,
|
|
219
245
|
output,
|
|
220
246
|
errors = Type2.Never(),
|
|
247
|
+
description,
|
|
221
248
|
handler
|
|
222
249
|
}) {
|
|
223
|
-
return {
|
|
250
|
+
return {
|
|
251
|
+
type: "subscription",
|
|
252
|
+
...description ? { description } : {},
|
|
253
|
+
input,
|
|
254
|
+
output,
|
|
255
|
+
errors,
|
|
256
|
+
handler
|
|
257
|
+
};
|
|
224
258
|
}
|
|
225
259
|
function stream({
|
|
226
260
|
init,
|
|
227
261
|
input,
|
|
228
262
|
output,
|
|
229
263
|
errors = Type2.Never(),
|
|
264
|
+
description,
|
|
230
265
|
handler
|
|
231
266
|
}) {
|
|
232
|
-
return init !== void 0 && init !== null ? {
|
|
267
|
+
return init !== void 0 && init !== null ? {
|
|
268
|
+
type: "stream",
|
|
269
|
+
...description ? { description } : {},
|
|
270
|
+
init,
|
|
271
|
+
input,
|
|
272
|
+
output,
|
|
273
|
+
errors,
|
|
274
|
+
handler
|
|
275
|
+
} : {
|
|
276
|
+
type: "stream",
|
|
277
|
+
...description ? { description } : {},
|
|
278
|
+
input,
|
|
279
|
+
output,
|
|
280
|
+
errors,
|
|
281
|
+
handler
|
|
282
|
+
};
|
|
233
283
|
}
|
|
234
284
|
var Procedure = {
|
|
235
285
|
rpc,
|
|
@@ -858,6 +908,7 @@ function handleUpload(transport, serverId, init, serviceName, procedureName) {
|
|
|
858
908
|
import { Value } from "@sinclair/typebox/value";
|
|
859
909
|
var RiverServer = class {
|
|
860
910
|
transport;
|
|
911
|
+
serviceDefs;
|
|
861
912
|
services;
|
|
862
913
|
contextMap;
|
|
863
914
|
// map of streamId to ProcStream
|
|
@@ -866,6 +917,7 @@ var RiverServer = class {
|
|
|
866
917
|
clientStreams;
|
|
867
918
|
disconnectedSessions;
|
|
868
919
|
constructor(transport, services, extendedContext) {
|
|
920
|
+
this.serviceDefs = services;
|
|
869
921
|
const instances = {};
|
|
870
922
|
this.services = instances;
|
|
871
923
|
this.contextMap = /* @__PURE__ */ new Map();
|
|
@@ -887,6 +939,15 @@ var RiverServer = class {
|
|
|
887
939
|
get streams() {
|
|
888
940
|
return this.streamMap;
|
|
889
941
|
}
|
|
942
|
+
serialize() {
|
|
943
|
+
return Object.entries(this.serviceDefs).reduce(
|
|
944
|
+
(acc, [name, value]) => {
|
|
945
|
+
acc[name] = value.serialize();
|
|
946
|
+
return acc;
|
|
947
|
+
},
|
|
948
|
+
{}
|
|
949
|
+
);
|
|
950
|
+
}
|
|
890
951
|
onMessage = async (message) => {
|
|
891
952
|
if (message.to !== this.transport.clientId) {
|
|
892
953
|
log?.info(
|
|
@@ -407,7 +407,6 @@ var Transport = class {
|
|
|
407
407
|
log?.warn(
|
|
408
408
|
`${this.clientId} -- connection from ${connectedTo} is a different session (id: ${advertisedSessionId}, last connected to: ${oldSession.advertisedSessionId}), starting a new session`
|
|
409
409
|
);
|
|
410
|
-
oldSession.close();
|
|
411
410
|
this.deleteSession(oldSession);
|
|
412
411
|
oldSession = void 0;
|
|
413
412
|
}
|
|
@@ -452,6 +451,7 @@ var Transport = class {
|
|
|
452
451
|
return session;
|
|
453
452
|
}
|
|
454
453
|
deleteSession(session) {
|
|
454
|
+
session.close();
|
|
455
455
|
this.sessions.delete(session.to);
|
|
456
456
|
log?.info(
|
|
457
457
|
`${this.clientId} -- session ${session.id} disconnect from ${session.to}`
|
|
@@ -599,7 +599,6 @@ var Transport = class {
|
|
|
599
599
|
close() {
|
|
600
600
|
this.state = "closed";
|
|
601
601
|
for (const session of this.sessions.values()) {
|
|
602
|
-
session.close();
|
|
603
602
|
this.deleteSession(session);
|
|
604
603
|
}
|
|
605
604
|
log?.info(`${this.clientId} -- manually closed transport`);
|
|
@@ -612,7 +611,6 @@ var Transport = class {
|
|
|
612
611
|
destroy() {
|
|
613
612
|
this.state = "destroyed";
|
|
614
613
|
for (const session of this.sessions.values()) {
|
|
615
|
-
session.close();
|
|
616
614
|
this.deleteSession(session);
|
|
617
615
|
}
|
|
618
616
|
log?.info(`${this.clientId} -- manually destroyed transport`);
|
|
@@ -793,6 +791,10 @@ var ClientTransport = class extends Transport {
|
|
|
793
791
|
}
|
|
794
792
|
}
|
|
795
793
|
}
|
|
794
|
+
deleteSession(session) {
|
|
795
|
+
this.inflightConnectionPromises.delete(session.to);
|
|
796
|
+
super.deleteSession(session);
|
|
797
|
+
}
|
|
796
798
|
sendHandshake(to, conn) {
|
|
797
799
|
const session = this.getOrCreateSession(to, conn);
|
|
798
800
|
const requestMsg = handshakeRequestMessage(this.clientId, to, session.id);
|
|
@@ -489,6 +489,7 @@ declare abstract class ClientTransport<ConnType extends Connection> extends Tran
|
|
|
489
489
|
* @param to The client ID of the node to connect to.
|
|
490
490
|
*/
|
|
491
491
|
connect(to: TransportClientId): Promise<void>;
|
|
492
|
+
protected deleteSession(session: Session<ConnType>): void;
|
|
492
493
|
protected sendHandshake(to: TransportClientId, conn: ConnType): void;
|
|
493
494
|
close(): void;
|
|
494
495
|
}
|
|
@@ -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 { b as TransportClientId, f as Session, C as Connection } from './index-
|
|
3
|
+
import { b as TransportClientId, f as Session, C as Connection } from './index-80f87385.js';
|
|
4
4
|
|
|
5
5
|
type TLiteralString = TLiteral<string>;
|
|
6
6
|
type RiverErrorSchema = TObject<{
|
|
@@ -83,7 +83,7 @@ type ValidProcType = 'rpc' | 'upload' | 'subscription' | 'stream';
|
|
|
83
83
|
/**
|
|
84
84
|
* Represents the payload type for {@link Procedure}s.
|
|
85
85
|
*/
|
|
86
|
-
type PayloadType =
|
|
86
|
+
type PayloadType = TSchema;
|
|
87
87
|
/**
|
|
88
88
|
* Represents results from a {@link Procedure}. Might come from inside a stream or
|
|
89
89
|
* from a single message.
|
|
@@ -102,6 +102,7 @@ interface RPCProcedure<State, I extends PayloadType, O extends PayloadType, E ex
|
|
|
102
102
|
input: I;
|
|
103
103
|
output: O;
|
|
104
104
|
errors: E;
|
|
105
|
+
description?: string;
|
|
105
106
|
handler(context: ServiceContextWithTransportInfo<State>, input: Static<I>): Promise<ProcedureResult<O, E>>;
|
|
106
107
|
}
|
|
107
108
|
/**
|
|
@@ -120,12 +121,14 @@ type UploadProcedure<State, I extends PayloadType, O extends PayloadType, E exte
|
|
|
120
121
|
input: I;
|
|
121
122
|
output: O;
|
|
122
123
|
errors: E;
|
|
124
|
+
description?: string;
|
|
123
125
|
handler(context: ServiceContextWithTransportInfo<State>, init: Static<Init>, input: AsyncIterableIterator<Static<I>>): Promise<ProcedureResult<O, E>>;
|
|
124
126
|
} : {
|
|
125
127
|
type: 'upload';
|
|
126
128
|
input: I;
|
|
127
129
|
output: O;
|
|
128
130
|
errors: E;
|
|
131
|
+
description?: string;
|
|
129
132
|
handler(context: ServiceContextWithTransportInfo<State>, input: AsyncIterableIterator<Static<I>>): Promise<ProcedureResult<O, E>>;
|
|
130
133
|
};
|
|
131
134
|
/**
|
|
@@ -141,6 +144,7 @@ interface SubscriptionProcedure<State, I extends PayloadType, O extends PayloadT
|
|
|
141
144
|
input: I;
|
|
142
145
|
output: O;
|
|
143
146
|
errors: E;
|
|
147
|
+
description?: string;
|
|
144
148
|
handler(context: ServiceContextWithTransportInfo<State>, input: Static<I>, output: Pushable<ProcedureResult<O, E>>): Promise<(() => void) | void>;
|
|
145
149
|
}
|
|
146
150
|
/**
|
|
@@ -159,12 +163,14 @@ type StreamProcedure<State, I extends PayloadType, O extends PayloadType, E exte
|
|
|
159
163
|
input: I;
|
|
160
164
|
output: O;
|
|
161
165
|
errors: E;
|
|
166
|
+
description?: string;
|
|
162
167
|
handler(context: ServiceContextWithTransportInfo<State>, init: Static<Init>, input: AsyncIterableIterator<Static<I>>, output: Pushable<ProcedureResult<O, E>>): Promise<void>;
|
|
163
168
|
} : {
|
|
164
169
|
type: 'stream';
|
|
165
170
|
input: I;
|
|
166
171
|
output: O;
|
|
167
172
|
errors: E;
|
|
173
|
+
description?: string;
|
|
168
174
|
handler(context: ServiceContextWithTransportInfo<State>, input: AsyncIterableIterator<Static<I>>, output: Pushable<ProcedureResult<O, E>>): Promise<void>;
|
|
169
175
|
};
|
|
170
176
|
/**
|
|
@@ -188,12 +194,14 @@ declare function rpc<State, I extends PayloadType, O extends PayloadType>(def: {
|
|
|
188
194
|
input: I;
|
|
189
195
|
output: O;
|
|
190
196
|
errors?: never;
|
|
197
|
+
description?: string;
|
|
191
198
|
handler: RPCProcedure<State, I, O, TNever>['handler'];
|
|
192
199
|
}): Branded<RPCProcedure<State, I, O, TNever>>;
|
|
193
200
|
declare function rpc<State, I extends PayloadType, O extends PayloadType, E extends RiverError>(def: {
|
|
194
201
|
input: I;
|
|
195
202
|
output: O;
|
|
196
203
|
errors: E;
|
|
204
|
+
description?: string;
|
|
197
205
|
handler: RPCProcedure<State, I, O, E>['handler'];
|
|
198
206
|
}): Branded<RPCProcedure<State, I, O, E>>;
|
|
199
207
|
/**
|
|
@@ -204,6 +212,7 @@ declare function upload<State, I extends PayloadType, O extends PayloadType, Ini
|
|
|
204
212
|
input: I;
|
|
205
213
|
output: O;
|
|
206
214
|
errors?: never;
|
|
215
|
+
description?: string;
|
|
207
216
|
handler: UploadProcedure<State, I, O, TNever, Init>['handler'];
|
|
208
217
|
}): Branded<UploadProcedure<State, I, O, TNever, Init>>;
|
|
209
218
|
declare function upload<State, I extends PayloadType, O extends PayloadType, E extends RiverError, Init extends PayloadType>(def: {
|
|
@@ -211,6 +220,7 @@ declare function upload<State, I extends PayloadType, O extends PayloadType, E e
|
|
|
211
220
|
input: I;
|
|
212
221
|
output: O;
|
|
213
222
|
errors: E;
|
|
223
|
+
description?: string;
|
|
214
224
|
handler: UploadProcedure<State, I, O, E, Init>['handler'];
|
|
215
225
|
}): Branded<UploadProcedure<State, I, O, E, Init>>;
|
|
216
226
|
declare function upload<State, I extends PayloadType, O extends PayloadType>(def: {
|
|
@@ -218,6 +228,7 @@ declare function upload<State, I extends PayloadType, O extends PayloadType>(def
|
|
|
218
228
|
input: I;
|
|
219
229
|
output: O;
|
|
220
230
|
errors?: never;
|
|
231
|
+
description?: string;
|
|
221
232
|
handler: UploadProcedure<State, I, O, TNever>['handler'];
|
|
222
233
|
}): Branded<UploadProcedure<State, I, O, TNever>>;
|
|
223
234
|
declare function upload<State, I extends PayloadType, O extends PayloadType, E extends RiverError>(def: {
|
|
@@ -225,6 +236,7 @@ declare function upload<State, I extends PayloadType, O extends PayloadType, E e
|
|
|
225
236
|
input: I;
|
|
226
237
|
output: O;
|
|
227
238
|
errors: E;
|
|
239
|
+
description?: string;
|
|
228
240
|
handler: UploadProcedure<State, I, O, E>['handler'];
|
|
229
241
|
}): Branded<UploadProcedure<State, I, O, E>>;
|
|
230
242
|
/**
|
|
@@ -234,12 +246,14 @@ declare function subscription<State, I extends PayloadType, O extends PayloadTyp
|
|
|
234
246
|
input: I;
|
|
235
247
|
output: O;
|
|
236
248
|
errors?: never;
|
|
249
|
+
description?: string;
|
|
237
250
|
handler: SubscriptionProcedure<State, I, O, TNever>['handler'];
|
|
238
251
|
}): Branded<SubscriptionProcedure<State, I, O, TNever>>;
|
|
239
252
|
declare function subscription<State, I extends PayloadType, O extends PayloadType, E extends RiverError>(def: {
|
|
240
253
|
input: I;
|
|
241
254
|
output: O;
|
|
242
255
|
errors: E;
|
|
256
|
+
description?: string;
|
|
243
257
|
handler: SubscriptionProcedure<State, I, O, E>['handler'];
|
|
244
258
|
}): Branded<SubscriptionProcedure<State, I, O, E>>;
|
|
245
259
|
/**
|
|
@@ -250,6 +264,7 @@ declare function stream<State, I extends PayloadType, O extends PayloadType, Ini
|
|
|
250
264
|
input: I;
|
|
251
265
|
output: O;
|
|
252
266
|
errors?: never;
|
|
267
|
+
description?: string;
|
|
253
268
|
handler: StreamProcedure<State, I, O, TNever, Init>['handler'];
|
|
254
269
|
}): Branded<StreamProcedure<State, I, O, TNever, Init>>;
|
|
255
270
|
declare function stream<State, I extends PayloadType, O extends PayloadType, E extends RiverError, Init extends PayloadType>(def: {
|
|
@@ -257,6 +272,7 @@ declare function stream<State, I extends PayloadType, O extends PayloadType, E e
|
|
|
257
272
|
input: I;
|
|
258
273
|
output: O;
|
|
259
274
|
errors: E;
|
|
275
|
+
description?: string;
|
|
260
276
|
handler: StreamProcedure<State, I, O, E, Init>['handler'];
|
|
261
277
|
}): Branded<StreamProcedure<State, I, O, E, Init>>;
|
|
262
278
|
declare function stream<State, I extends PayloadType, O extends PayloadType>(def: {
|
|
@@ -264,6 +280,7 @@ declare function stream<State, I extends PayloadType, O extends PayloadType>(def
|
|
|
264
280
|
input: I;
|
|
265
281
|
output: O;
|
|
266
282
|
errors?: never;
|
|
283
|
+
description?: string;
|
|
267
284
|
handler: StreamProcedure<State, I, O, TNever>['handler'];
|
|
268
285
|
}): Branded<StreamProcedure<State, I, O, TNever>>;
|
|
269
286
|
declare function stream<State, I extends PayloadType, O extends PayloadType, E extends RiverError>(def: {
|
|
@@ -271,6 +288,7 @@ declare function stream<State, I extends PayloadType, O extends PayloadType, E e
|
|
|
271
288
|
input: I;
|
|
272
289
|
output: O;
|
|
273
290
|
errors: E;
|
|
291
|
+
description?: string;
|
|
274
292
|
handler: StreamProcedure<State, I, O, E>['handler'];
|
|
275
293
|
}): Branded<StreamProcedure<State, I, O, E>>;
|
|
276
294
|
/**
|
package/dist/router/index.cjs
CHANGED
|
@@ -134,7 +134,9 @@ var ServiceSchema = class _ServiceSchema {
|
|
|
134
134
|
{
|
|
135
135
|
input: import_typebox.Type.Strict(procDef.input),
|
|
136
136
|
output: import_typebox.Type.Strict(procDef.output),
|
|
137
|
-
// Only add
|
|
137
|
+
// Only add `description` field if the type declares it.
|
|
138
|
+
..."description" in procDef ? { description: procDef.description } : {},
|
|
139
|
+
// Only add the `errors` field if the type declares it.
|
|
138
140
|
..."errors" in procDef ? {
|
|
139
141
|
errors: import_typebox.Type.Strict(procDef.errors)
|
|
140
142
|
} : {},
|
|
@@ -224,35 +226,83 @@ function rpc({
|
|
|
224
226
|
input,
|
|
225
227
|
output,
|
|
226
228
|
errors = import_typebox2.Type.Never(),
|
|
229
|
+
description,
|
|
227
230
|
handler
|
|
228
231
|
}) {
|
|
229
|
-
return {
|
|
232
|
+
return {
|
|
233
|
+
...description ? { description } : {},
|
|
234
|
+
type: "rpc",
|
|
235
|
+
input,
|
|
236
|
+
output,
|
|
237
|
+
errors,
|
|
238
|
+
handler
|
|
239
|
+
};
|
|
230
240
|
}
|
|
231
241
|
function upload({
|
|
232
242
|
init,
|
|
233
243
|
input,
|
|
234
244
|
output,
|
|
235
245
|
errors = import_typebox2.Type.Never(),
|
|
246
|
+
description,
|
|
236
247
|
handler
|
|
237
248
|
}) {
|
|
238
|
-
return init !== void 0 && init !== null ? {
|
|
249
|
+
return init !== void 0 && init !== null ? {
|
|
250
|
+
type: "upload",
|
|
251
|
+
...description ? { description } : {},
|
|
252
|
+
init,
|
|
253
|
+
input,
|
|
254
|
+
output,
|
|
255
|
+
errors,
|
|
256
|
+
handler
|
|
257
|
+
} : {
|
|
258
|
+
type: "upload",
|
|
259
|
+
...description ? { description } : {},
|
|
260
|
+
input,
|
|
261
|
+
output,
|
|
262
|
+
errors,
|
|
263
|
+
handler
|
|
264
|
+
};
|
|
239
265
|
}
|
|
240
266
|
function subscription({
|
|
241
267
|
input,
|
|
242
268
|
output,
|
|
243
269
|
errors = import_typebox2.Type.Never(),
|
|
270
|
+
description,
|
|
244
271
|
handler
|
|
245
272
|
}) {
|
|
246
|
-
return {
|
|
273
|
+
return {
|
|
274
|
+
type: "subscription",
|
|
275
|
+
...description ? { description } : {},
|
|
276
|
+
input,
|
|
277
|
+
output,
|
|
278
|
+
errors,
|
|
279
|
+
handler
|
|
280
|
+
};
|
|
247
281
|
}
|
|
248
282
|
function stream({
|
|
249
283
|
init,
|
|
250
284
|
input,
|
|
251
285
|
output,
|
|
252
286
|
errors = import_typebox2.Type.Never(),
|
|
287
|
+
description,
|
|
253
288
|
handler
|
|
254
289
|
}) {
|
|
255
|
-
return init !== void 0 && init !== null ? {
|
|
290
|
+
return init !== void 0 && init !== null ? {
|
|
291
|
+
type: "stream",
|
|
292
|
+
...description ? { description } : {},
|
|
293
|
+
init,
|
|
294
|
+
input,
|
|
295
|
+
output,
|
|
296
|
+
errors,
|
|
297
|
+
handler
|
|
298
|
+
} : {
|
|
299
|
+
type: "stream",
|
|
300
|
+
...description ? { description } : {},
|
|
301
|
+
input,
|
|
302
|
+
output,
|
|
303
|
+
errors,
|
|
304
|
+
handler
|
|
305
|
+
};
|
|
256
306
|
}
|
|
257
307
|
var Procedure = {
|
|
258
308
|
rpc,
|
|
@@ -953,6 +1003,7 @@ function coerceErrorString(err) {
|
|
|
953
1003
|
// router/server.ts
|
|
954
1004
|
var RiverServer = class {
|
|
955
1005
|
transport;
|
|
1006
|
+
serviceDefs;
|
|
956
1007
|
services;
|
|
957
1008
|
contextMap;
|
|
958
1009
|
// map of streamId to ProcStream
|
|
@@ -961,6 +1012,7 @@ var RiverServer = class {
|
|
|
961
1012
|
clientStreams;
|
|
962
1013
|
disconnectedSessions;
|
|
963
1014
|
constructor(transport, services, extendedContext) {
|
|
1015
|
+
this.serviceDefs = services;
|
|
964
1016
|
const instances = {};
|
|
965
1017
|
this.services = instances;
|
|
966
1018
|
this.contextMap = /* @__PURE__ */ new Map();
|
|
@@ -982,6 +1034,15 @@ var RiverServer = class {
|
|
|
982
1034
|
get streams() {
|
|
983
1035
|
return this.streamMap;
|
|
984
1036
|
}
|
|
1037
|
+
serialize() {
|
|
1038
|
+
return Object.entries(this.serviceDefs).reduce(
|
|
1039
|
+
(acc, [name, value]) => {
|
|
1040
|
+
acc[name] = value.serialize();
|
|
1041
|
+
return acc;
|
|
1042
|
+
},
|
|
1043
|
+
{}
|
|
1044
|
+
);
|
|
1045
|
+
}
|
|
985
1046
|
onMessage = async (message) => {
|
|
986
1047
|
if (message.to !== this.transport.clientId) {
|
|
987
1048
|
log?.info(
|
package/dist/router/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { e as ProcedureMap, c as RiverUncaughtSchema, U as Unbranded, B as Branded, A as AnyProcedure,
|
|
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 { d as ServerTransport, C as Connection, a as ClientTransport, b as TransportClientId } from '../index-
|
|
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-79a5f07e.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-79a5f07e.js';
|
|
4
|
+
import { d as ServerTransport, C as Connection, a as ClientTransport, b as TransportClientId } from '../index-80f87385.js';
|
|
5
5
|
import { Pushable } from 'it-pushable';
|
|
6
6
|
import '../types-3e5768ec.js';
|
|
7
7
|
|
|
@@ -45,7 +45,7 @@ type ProcHandler<S extends AnyService, ProcName extends keyof S['procedures']> =
|
|
|
45
45
|
* @template ProcName - The name of the procedure.
|
|
46
46
|
*/
|
|
47
47
|
type ProcHasInit<S extends AnyService, ProcName extends keyof S['procedures']> = S['procedures'][ProcName] extends {
|
|
48
|
-
init:
|
|
48
|
+
init: PayloadType;
|
|
49
49
|
} ? true : false;
|
|
50
50
|
/**
|
|
51
51
|
* Helper to get the type definition for the procedure init type of a service.
|
|
@@ -53,7 +53,7 @@ type ProcHasInit<S extends AnyService, ProcName extends keyof S['procedures']> =
|
|
|
53
53
|
* @template ProcName - The name of the procedure.
|
|
54
54
|
*/
|
|
55
55
|
type ProcInit<S extends AnyService, ProcName extends keyof S['procedures']> = S['procedures'][ProcName] extends {
|
|
56
|
-
init:
|
|
56
|
+
init: PayloadType;
|
|
57
57
|
} ? S['procedures'][ProcName]['init'] : never;
|
|
58
58
|
/**
|
|
59
59
|
* Helper to get the type definition for the procedure input of a service.
|
|
@@ -93,6 +93,15 @@ interface ServiceConfiguration<State extends object> {
|
|
|
93
93
|
*/
|
|
94
94
|
initializeState: () => State;
|
|
95
95
|
}
|
|
96
|
+
interface SerializedServiceSchema {
|
|
97
|
+
procedures: Record<string, {
|
|
98
|
+
input: PayloadType;
|
|
99
|
+
output: PayloadType;
|
|
100
|
+
errors?: RiverError;
|
|
101
|
+
type: 'rpc' | 'subscription' | 'upload' | 'stream';
|
|
102
|
+
init?: PayloadType;
|
|
103
|
+
}>;
|
|
104
|
+
}
|
|
96
105
|
/**
|
|
97
106
|
* The schema for a {@link Service}. This is used to define a service, specifically
|
|
98
107
|
* its initial state and procedures.
|
|
@@ -239,7 +248,7 @@ declare class ServiceSchema<State extends object, Procedures extends ProcedureMa
|
|
|
239
248
|
/**
|
|
240
249
|
* Serializes this schema's procedures into a plain object that is JSON compatible.
|
|
241
250
|
*/
|
|
242
|
-
serialize():
|
|
251
|
+
serialize(): SerializedServiceSchema;
|
|
243
252
|
/**
|
|
244
253
|
* Instantiates this schema into a {@link Service} object.
|
|
245
254
|
*
|
|
@@ -313,6 +322,7 @@ declare class ServiceScaffold<State extends object> {
|
|
|
313
322
|
interface Server<Services extends ServiceSchemaMap> {
|
|
314
323
|
services: InstantiatedServiceSchemaMap<Services>;
|
|
315
324
|
streams: Map<string, ProcStream>;
|
|
325
|
+
serialize(): SerializedServerSchema;
|
|
316
326
|
close(): Promise<void>;
|
|
317
327
|
}
|
|
318
328
|
interface ProcStream {
|
|
@@ -326,6 +336,7 @@ interface ProcStream {
|
|
|
326
336
|
inputHandler: Promise<unknown>;
|
|
327
337
|
};
|
|
328
338
|
}
|
|
339
|
+
type SerializedServerSchema = Record<string, SerializedServiceSchema>;
|
|
329
340
|
/**
|
|
330
341
|
* Creates a server instance that listens for incoming messages from a transport and routes them to the appropriate service and procedure.
|
|
331
342
|
* The server tracks the state of each service along with open streams and the extended context object.
|
package/dist/router/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { e as ProcedureMap, c as RiverUncaughtSchema, U as Unbranded, B as Branded, A as AnyProcedure,
|
|
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 { d as ServerTransport, C as Connection, a as ClientTransport, b as TransportClientId } from '../index-
|
|
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-79a5f07e.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-79a5f07e.js';
|
|
4
|
+
import { d as ServerTransport, C as Connection, a as ClientTransport, b as TransportClientId } from '../index-80f87385.js';
|
|
5
5
|
import { Pushable } from 'it-pushable';
|
|
6
6
|
import '../types-3e5768ec.js';
|
|
7
7
|
|
|
@@ -45,7 +45,7 @@ type ProcHandler<S extends AnyService, ProcName extends keyof S['procedures']> =
|
|
|
45
45
|
* @template ProcName - The name of the procedure.
|
|
46
46
|
*/
|
|
47
47
|
type ProcHasInit<S extends AnyService, ProcName extends keyof S['procedures']> = S['procedures'][ProcName] extends {
|
|
48
|
-
init:
|
|
48
|
+
init: PayloadType;
|
|
49
49
|
} ? true : false;
|
|
50
50
|
/**
|
|
51
51
|
* Helper to get the type definition for the procedure init type of a service.
|
|
@@ -53,7 +53,7 @@ type ProcHasInit<S extends AnyService, ProcName extends keyof S['procedures']> =
|
|
|
53
53
|
* @template ProcName - The name of the procedure.
|
|
54
54
|
*/
|
|
55
55
|
type ProcInit<S extends AnyService, ProcName extends keyof S['procedures']> = S['procedures'][ProcName] extends {
|
|
56
|
-
init:
|
|
56
|
+
init: PayloadType;
|
|
57
57
|
} ? S['procedures'][ProcName]['init'] : never;
|
|
58
58
|
/**
|
|
59
59
|
* Helper to get the type definition for the procedure input of a service.
|
|
@@ -93,6 +93,15 @@ interface ServiceConfiguration<State extends object> {
|
|
|
93
93
|
*/
|
|
94
94
|
initializeState: () => State;
|
|
95
95
|
}
|
|
96
|
+
interface SerializedServiceSchema {
|
|
97
|
+
procedures: Record<string, {
|
|
98
|
+
input: PayloadType;
|
|
99
|
+
output: PayloadType;
|
|
100
|
+
errors?: RiverError;
|
|
101
|
+
type: 'rpc' | 'subscription' | 'upload' | 'stream';
|
|
102
|
+
init?: PayloadType;
|
|
103
|
+
}>;
|
|
104
|
+
}
|
|
96
105
|
/**
|
|
97
106
|
* The schema for a {@link Service}. This is used to define a service, specifically
|
|
98
107
|
* its initial state and procedures.
|
|
@@ -239,7 +248,7 @@ declare class ServiceSchema<State extends object, Procedures extends ProcedureMa
|
|
|
239
248
|
/**
|
|
240
249
|
* Serializes this schema's procedures into a plain object that is JSON compatible.
|
|
241
250
|
*/
|
|
242
|
-
serialize():
|
|
251
|
+
serialize(): SerializedServiceSchema;
|
|
243
252
|
/**
|
|
244
253
|
* Instantiates this schema into a {@link Service} object.
|
|
245
254
|
*
|
|
@@ -313,6 +322,7 @@ declare class ServiceScaffold<State extends object> {
|
|
|
313
322
|
interface Server<Services extends ServiceSchemaMap> {
|
|
314
323
|
services: InstantiatedServiceSchemaMap<Services>;
|
|
315
324
|
streams: Map<string, ProcStream>;
|
|
325
|
+
serialize(): SerializedServerSchema;
|
|
316
326
|
close(): Promise<void>;
|
|
317
327
|
}
|
|
318
328
|
interface ProcStream {
|
|
@@ -326,6 +336,7 @@ interface ProcStream {
|
|
|
326
336
|
inputHandler: Promise<unknown>;
|
|
327
337
|
};
|
|
328
338
|
}
|
|
339
|
+
type SerializedServerSchema = Record<string, SerializedServiceSchema>;
|
|
329
340
|
/**
|
|
330
341
|
* Creates a server instance that listens for incoming messages from a transport and routes them to the appropriate service and procedure.
|
|
331
342
|
* The server tracks the state of each service along with open streams and the extended context object.
|
package/dist/router/index.js
CHANGED
|
@@ -644,7 +644,6 @@ var Transport = class {
|
|
|
644
644
|
log?.warn(
|
|
645
645
|
`${this.clientId} -- connection from ${connectedTo} is a different session (id: ${advertisedSessionId}, last connected to: ${oldSession.advertisedSessionId}), starting a new session`
|
|
646
646
|
);
|
|
647
|
-
oldSession.close();
|
|
648
647
|
this.deleteSession(oldSession);
|
|
649
648
|
oldSession = void 0;
|
|
650
649
|
}
|
|
@@ -689,6 +688,7 @@ var Transport = class {
|
|
|
689
688
|
return session;
|
|
690
689
|
}
|
|
691
690
|
deleteSession(session) {
|
|
691
|
+
session.close();
|
|
692
692
|
this.sessions.delete(session.to);
|
|
693
693
|
log?.info(
|
|
694
694
|
`${this.clientId} -- session ${session.id} disconnect from ${session.to}`
|
|
@@ -836,7 +836,6 @@ var Transport = class {
|
|
|
836
836
|
close() {
|
|
837
837
|
this.state = "closed";
|
|
838
838
|
for (const session of this.sessions.values()) {
|
|
839
|
-
session.close();
|
|
840
839
|
this.deleteSession(session);
|
|
841
840
|
}
|
|
842
841
|
log?.info(`${this.clientId} -- manually closed transport`);
|
|
@@ -849,7 +848,6 @@ var Transport = class {
|
|
|
849
848
|
destroy() {
|
|
850
849
|
this.state = "destroyed";
|
|
851
850
|
for (const session of this.sessions.values()) {
|
|
852
|
-
session.close();
|
|
853
851
|
this.deleteSession(session);
|
|
854
852
|
}
|
|
855
853
|
log?.info(`${this.clientId} -- manually destroyed transport`);
|
|
@@ -1030,6 +1028,10 @@ var ClientTransport = class extends Transport {
|
|
|
1030
1028
|
}
|
|
1031
1029
|
}
|
|
1032
1030
|
}
|
|
1031
|
+
deleteSession(session) {
|
|
1032
|
+
this.inflightConnectionPromises.delete(session.to);
|
|
1033
|
+
super.deleteSession(session);
|
|
1034
|
+
}
|
|
1033
1035
|
sendHandshake(to, conn) {
|
|
1034
1036
|
const session = this.getOrCreateSession(to, conn);
|
|
1035
1037
|
const requestMsg = handshakeRequestMessage(this.clientId, to, session.id);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as ClientTransport, c as ProvidedClientTransportOptions, b as TransportClientId } from '../../../index-
|
|
2
|
-
import { U as UdsConnection } from '../../../connection-
|
|
1
|
+
import { a as ClientTransport, c as ProvidedClientTransportOptions, b as TransportClientId } from '../../../index-80f87385.js';
|
|
2
|
+
import { U as UdsConnection } from '../../../connection-713c8c66.js';
|
|
3
3
|
import '../../../types-3e5768ec.js';
|
|
4
4
|
import '@sinclair/typebox';
|
|
5
5
|
import 'node:net';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as ClientTransport, c as ProvidedClientTransportOptions, b as TransportClientId } from '../../../index-
|
|
2
|
-
import { U as UdsConnection } from '../../../connection-
|
|
1
|
+
import { a as ClientTransport, c as ProvidedClientTransportOptions, b as TransportClientId } from '../../../index-80f87385.js';
|
|
2
|
+
import { U as UdsConnection } from '../../../connection-713c8c66.js';
|
|
3
3
|
import '../../../types-3e5768ec.js';
|
|
4
4
|
import '@sinclair/typebox';
|
|
5
5
|
import 'node:net';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
UdsConnection
|
|
3
|
-
} from "../../../chunk-
|
|
3
|
+
} from "../../../chunk-Q7OSVPZ5.js";
|
|
4
4
|
import {
|
|
5
5
|
ClientTransport
|
|
6
|
-
} from "../../../chunk-
|
|
6
|
+
} from "../../../chunk-7WY3Z5ZN.js";
|
|
7
7
|
import "../../../chunk-VH3NGOXQ.js";
|
|
8
8
|
import {
|
|
9
9
|
log
|
|
@@ -24,9 +24,6 @@ __export(server_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(server_exports);
|
|
26
26
|
|
|
27
|
-
// logging/index.ts
|
|
28
|
-
var log;
|
|
29
|
-
|
|
30
27
|
// transport/transport.ts
|
|
31
28
|
var import_value = require("@sinclair/typebox/value");
|
|
32
29
|
|
|
@@ -98,6 +95,9 @@ function isAck(controlFlag) {
|
|
|
98
95
|
return (controlFlag & 1 /* AckBit */) === 1 /* AckBit */;
|
|
99
96
|
}
|
|
100
97
|
|
|
98
|
+
// logging/index.ts
|
|
99
|
+
var log;
|
|
100
|
+
|
|
101
101
|
// transport/events.ts
|
|
102
102
|
var ProtocolError = {
|
|
103
103
|
RetriesExceeded: "conn_retry_exceeded",
|
|
@@ -476,7 +476,6 @@ var Transport = class {
|
|
|
476
476
|
log?.warn(
|
|
477
477
|
`${this.clientId} -- connection from ${connectedTo} is a different session (id: ${advertisedSessionId}, last connected to: ${oldSession.advertisedSessionId}), starting a new session`
|
|
478
478
|
);
|
|
479
|
-
oldSession.close();
|
|
480
479
|
this.deleteSession(oldSession);
|
|
481
480
|
oldSession = void 0;
|
|
482
481
|
}
|
|
@@ -521,6 +520,7 @@ var Transport = class {
|
|
|
521
520
|
return session;
|
|
522
521
|
}
|
|
523
522
|
deleteSession(session) {
|
|
523
|
+
session.close();
|
|
524
524
|
this.sessions.delete(session.to);
|
|
525
525
|
log?.info(
|
|
526
526
|
`${this.clientId} -- session ${session.id} disconnect from ${session.to}`
|
|
@@ -668,7 +668,6 @@ var Transport = class {
|
|
|
668
668
|
close() {
|
|
669
669
|
this.state = "closed";
|
|
670
670
|
for (const session of this.sessions.values()) {
|
|
671
|
-
session.close();
|
|
672
671
|
this.deleteSession(session);
|
|
673
672
|
}
|
|
674
673
|
log?.info(`${this.clientId} -- manually closed transport`);
|
|
@@ -681,7 +680,6 @@ var Transport = class {
|
|
|
681
680
|
destroy() {
|
|
682
681
|
this.state = "destroyed";
|
|
683
682
|
for (const session of this.sessions.values()) {
|
|
684
|
-
session.close();
|
|
685
683
|
this.deleteSession(session);
|
|
686
684
|
}
|
|
687
685
|
log?.info(`${this.clientId} -- manually destroyed transport`);
|
|
@@ -887,9 +885,6 @@ var UnixDomainSocketServerTransport = class extends ServerTransport {
|
|
|
887
885
|
super(clientId, providedOptions);
|
|
888
886
|
this.server = server;
|
|
889
887
|
server.addListener("connection", this.connectionHandler);
|
|
890
|
-
server.on("listening", () => {
|
|
891
|
-
log?.info(`${this.clientId} -- server is listening`);
|
|
892
|
-
});
|
|
893
888
|
}
|
|
894
889
|
connectionHandler = (sock) => {
|
|
895
890
|
const conn = new UdsConnection(sock);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Server, Socket } from 'node:net';
|
|
2
|
-
import { d as ServerTransport, b as TransportClientId, e as ProvidedTransportOptions } from '../../../index-
|
|
3
|
-
import { U as UdsConnection } from '../../../connection-
|
|
2
|
+
import { d as ServerTransport, b as TransportClientId, e as ProvidedTransportOptions } from '../../../index-80f87385.js';
|
|
3
|
+
import { U as UdsConnection } from '../../../connection-713c8c66.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 { d as ServerTransport, b as TransportClientId, e as ProvidedTransportOptions } from '../../../index-
|
|
3
|
-
import { U as UdsConnection } from '../../../connection-
|
|
2
|
+
import { d as ServerTransport, b as TransportClientId, e as ProvidedTransportOptions } from '../../../index-80f87385.js';
|
|
3
|
+
import { U as UdsConnection } from '../../../connection-713c8c66.js';
|
|
4
4
|
import '../../../types-3e5768ec.js';
|
|
5
5
|
import '@sinclair/typebox';
|
|
6
6
|
import 'node:stream';
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
UdsConnection
|
|
3
|
-
} from "../../../chunk-
|
|
3
|
+
} from "../../../chunk-Q7OSVPZ5.js";
|
|
4
4
|
import {
|
|
5
5
|
ServerTransport
|
|
6
|
-
} from "../../../chunk-
|
|
6
|
+
} from "../../../chunk-7WY3Z5ZN.js";
|
|
7
7
|
import "../../../chunk-VH3NGOXQ.js";
|
|
8
|
-
import
|
|
9
|
-
log
|
|
10
|
-
} from "../../../chunk-H4BYJELI.js";
|
|
8
|
+
import "../../../chunk-H4BYJELI.js";
|
|
11
9
|
import "../../../chunk-GZ7HCLLM.js";
|
|
12
10
|
|
|
13
11
|
// transport/impls/uds/server.ts
|
|
@@ -17,9 +15,6 @@ var UnixDomainSocketServerTransport = class extends ServerTransport {
|
|
|
17
15
|
super(clientId, providedOptions);
|
|
18
16
|
this.server = server;
|
|
19
17
|
server.addListener("connection", this.connectionHandler);
|
|
20
|
-
server.on("listening", () => {
|
|
21
|
-
log?.info(`${this.clientId} -- server is listening`);
|
|
22
|
-
});
|
|
23
18
|
}
|
|
24
19
|
connectionHandler = (sock) => {
|
|
25
20
|
const conn = new UdsConnection(sock);
|
|
@@ -548,7 +548,6 @@ var Transport = class {
|
|
|
548
548
|
log?.warn(
|
|
549
549
|
`${this.clientId} -- connection from ${connectedTo} is a different session (id: ${advertisedSessionId}, last connected to: ${oldSession.advertisedSessionId}), starting a new session`
|
|
550
550
|
);
|
|
551
|
-
oldSession.close();
|
|
552
551
|
this.deleteSession(oldSession);
|
|
553
552
|
oldSession = void 0;
|
|
554
553
|
}
|
|
@@ -593,6 +592,7 @@ var Transport = class {
|
|
|
593
592
|
return session;
|
|
594
593
|
}
|
|
595
594
|
deleteSession(session) {
|
|
595
|
+
session.close();
|
|
596
596
|
this.sessions.delete(session.to);
|
|
597
597
|
log?.info(
|
|
598
598
|
`${this.clientId} -- session ${session.id} disconnect from ${session.to}`
|
|
@@ -740,7 +740,6 @@ var Transport = class {
|
|
|
740
740
|
close() {
|
|
741
741
|
this.state = "closed";
|
|
742
742
|
for (const session of this.sessions.values()) {
|
|
743
|
-
session.close();
|
|
744
743
|
this.deleteSession(session);
|
|
745
744
|
}
|
|
746
745
|
log?.info(`${this.clientId} -- manually closed transport`);
|
|
@@ -753,7 +752,6 @@ var Transport = class {
|
|
|
753
752
|
destroy() {
|
|
754
753
|
this.state = "destroyed";
|
|
755
754
|
for (const session of this.sessions.values()) {
|
|
756
|
-
session.close();
|
|
757
755
|
this.deleteSession(session);
|
|
758
756
|
}
|
|
759
757
|
log?.info(`${this.clientId} -- manually destroyed transport`);
|
|
@@ -934,6 +932,10 @@ var ClientTransport = class extends Transport {
|
|
|
934
932
|
}
|
|
935
933
|
}
|
|
936
934
|
}
|
|
935
|
+
deleteSession(session) {
|
|
936
|
+
this.inflightConnectionPromises.delete(session.to);
|
|
937
|
+
super.deleteSession(session);
|
|
938
|
+
}
|
|
937
939
|
sendHandshake(to, conn) {
|
|
938
940
|
const session = this.getOrCreateSession(to, conn);
|
|
939
941
|
const requestMsg = handshakeRequestMessage(this.clientId, to, session.id);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import WebSocket from 'isomorphic-ws';
|
|
2
|
-
import { a as ClientTransport, b as TransportClientId, c as ProvidedClientTransportOptions } from '../../../index-
|
|
3
|
-
import { W as WebSocketConnection } from '../../../connection-
|
|
2
|
+
import { a as ClientTransport, b as TransportClientId, c as ProvidedClientTransportOptions } from '../../../index-80f87385.js';
|
|
3
|
+
import { W as WebSocketConnection } from '../../../connection-b79329de.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 { a as ClientTransport, b as TransportClientId, c as ProvidedClientTransportOptions } from '../../../index-
|
|
3
|
-
import { W as WebSocketConnection } from '../../../connection-
|
|
2
|
+
import { a as ClientTransport, b as TransportClientId, c as ProvidedClientTransportOptions } from '../../../index-80f87385.js';
|
|
3
|
+
import { W as WebSocketConnection } from '../../../connection-b79329de.js';
|
|
4
4
|
import '../../../types-3e5768ec.js';
|
|
5
5
|
import '@sinclair/typebox';
|
|
6
6
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
WebSocketConnection
|
|
3
|
-
} from "../../../chunk-
|
|
3
|
+
} from "../../../chunk-F3LFO3GU.js";
|
|
4
4
|
import {
|
|
5
5
|
ClientTransport
|
|
6
|
-
} from "../../../chunk-
|
|
6
|
+
} from "../../../chunk-7WY3Z5ZN.js";
|
|
7
7
|
import "../../../chunk-VH3NGOXQ.js";
|
|
8
8
|
import {
|
|
9
9
|
log
|
|
@@ -476,7 +476,6 @@ var Transport = class {
|
|
|
476
476
|
log?.warn(
|
|
477
477
|
`${this.clientId} -- connection from ${connectedTo} is a different session (id: ${advertisedSessionId}, last connected to: ${oldSession.advertisedSessionId}), starting a new session`
|
|
478
478
|
);
|
|
479
|
-
oldSession.close();
|
|
480
479
|
this.deleteSession(oldSession);
|
|
481
480
|
oldSession = void 0;
|
|
482
481
|
}
|
|
@@ -521,6 +520,7 @@ var Transport = class {
|
|
|
521
520
|
return session;
|
|
522
521
|
}
|
|
523
522
|
deleteSession(session) {
|
|
523
|
+
session.close();
|
|
524
524
|
this.sessions.delete(session.to);
|
|
525
525
|
log?.info(
|
|
526
526
|
`${this.clientId} -- session ${session.id} disconnect from ${session.to}`
|
|
@@ -668,7 +668,6 @@ var Transport = class {
|
|
|
668
668
|
close() {
|
|
669
669
|
this.state = "closed";
|
|
670
670
|
for (const session of this.sessions.values()) {
|
|
671
|
-
session.close();
|
|
672
671
|
this.deleteSession(session);
|
|
673
672
|
}
|
|
674
673
|
log?.info(`${this.clientId} -- manually closed transport`);
|
|
@@ -681,7 +680,6 @@ var Transport = class {
|
|
|
681
680
|
destroy() {
|
|
682
681
|
this.state = "destroyed";
|
|
683
682
|
for (const session of this.sessions.values()) {
|
|
684
|
-
session.close();
|
|
685
683
|
this.deleteSession(session);
|
|
686
684
|
}
|
|
687
685
|
log?.info(`${this.clientId} -- manually destroyed transport`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { d as ServerTransport, b as TransportClientId, e as ProvidedTransportOptions } from '../../../index-
|
|
1
|
+
import { d as ServerTransport, b as TransportClientId, e as ProvidedTransportOptions } from '../../../index-80f87385.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-b79329de.js';
|
|
5
5
|
import '../../../types-3e5768ec.js';
|
|
6
6
|
import '@sinclair/typebox';
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { d as ServerTransport, b as TransportClientId, e as ProvidedTransportOptions } from '../../../index-
|
|
1
|
+
import { d as ServerTransport, b as TransportClientId, e as ProvidedTransportOptions } from '../../../index-80f87385.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-b79329de.js';
|
|
5
5
|
import '../../../types-3e5768ec.js';
|
|
6
6
|
import '@sinclair/typebox';
|
|
7
7
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
WebSocketConnection
|
|
3
|
-
} from "../../../chunk-
|
|
3
|
+
} from "../../../chunk-F3LFO3GU.js";
|
|
4
4
|
import {
|
|
5
5
|
ServerTransport
|
|
6
|
-
} from "../../../chunk-
|
|
6
|
+
} from "../../../chunk-7WY3Z5ZN.js";
|
|
7
7
|
import "../../../chunk-VH3NGOXQ.js";
|
|
8
8
|
import "../../../chunk-H4BYJELI.js";
|
|
9
9
|
import "../../../chunk-GZ7HCLLM.js";
|
package/dist/transport/index.cjs
CHANGED
|
@@ -570,7 +570,6 @@ var Transport = class {
|
|
|
570
570
|
log?.warn(
|
|
571
571
|
`${this.clientId} -- connection from ${connectedTo} is a different session (id: ${advertisedSessionId}, last connected to: ${oldSession.advertisedSessionId}), starting a new session`
|
|
572
572
|
);
|
|
573
|
-
oldSession.close();
|
|
574
573
|
this.deleteSession(oldSession);
|
|
575
574
|
oldSession = void 0;
|
|
576
575
|
}
|
|
@@ -615,6 +614,7 @@ var Transport = class {
|
|
|
615
614
|
return session;
|
|
616
615
|
}
|
|
617
616
|
deleteSession(session) {
|
|
617
|
+
session.close();
|
|
618
618
|
this.sessions.delete(session.to);
|
|
619
619
|
log?.info(
|
|
620
620
|
`${this.clientId} -- session ${session.id} disconnect from ${session.to}`
|
|
@@ -762,7 +762,6 @@ var Transport = class {
|
|
|
762
762
|
close() {
|
|
763
763
|
this.state = "closed";
|
|
764
764
|
for (const session of this.sessions.values()) {
|
|
765
|
-
session.close();
|
|
766
765
|
this.deleteSession(session);
|
|
767
766
|
}
|
|
768
767
|
log?.info(`${this.clientId} -- manually closed transport`);
|
|
@@ -775,7 +774,6 @@ var Transport = class {
|
|
|
775
774
|
destroy() {
|
|
776
775
|
this.state = "destroyed";
|
|
777
776
|
for (const session of this.sessions.values()) {
|
|
778
|
-
session.close();
|
|
779
777
|
this.deleteSession(session);
|
|
780
778
|
}
|
|
781
779
|
log?.info(`${this.clientId} -- manually destroyed transport`);
|
|
@@ -956,6 +954,10 @@ var ClientTransport = class extends Transport {
|
|
|
956
954
|
}
|
|
957
955
|
}
|
|
958
956
|
}
|
|
957
|
+
deleteSession(session) {
|
|
958
|
+
this.inflightConnectionPromises.delete(session.to);
|
|
959
|
+
super.deleteSession(session);
|
|
960
|
+
}
|
|
959
961
|
sendHandshake(to, conn) {
|
|
960
962
|
const session = this.getOrCreateSession(to, conn);
|
|
961
963
|
const requestMsg = handshakeRequestMessage(this.clientId, to, session.id);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
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-
|
|
1
|
+
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';
|
|
2
2
|
import '../types-3e5768ec.js';
|
|
3
3
|
import '@sinclair/typebox';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
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-
|
|
1
|
+
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';
|
|
2
2
|
import '../types-3e5768ec.js';
|
|
3
3
|
import '@sinclair/typebox';
|
package/dist/transport/index.js
CHANGED
|
@@ -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-79a5f07e.js';
|
|
3
|
+
import { P as PartialTransportMessage, T as Transport, C as Connection, O as OpaqueTransportMessage, S as SessionOptions } from '../index-80f87385.js';
|
|
4
4
|
import * as it_pushable from 'it-pushable';
|
|
5
5
|
import WebSocket from 'isomorphic-ws';
|
|
6
6
|
import http from 'node:http';
|
|
@@ -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-79a5f07e.js';
|
|
3
|
+
import { P as PartialTransportMessage, T as Transport, C as Connection, O as OpaqueTransportMessage, S as SessionOptions } from '../index-80f87385.js';
|
|
4
4
|
import * as it_pushable from 'it-pushable';
|
|
5
5
|
import WebSocket from 'isomorphic-ws';
|
|
6
6
|
import http from 'node:http';
|
package/dist/util/testHelpers.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
UNCAUGHT_ERROR,
|
|
3
3
|
pushable
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-4C2OXQJB.js";
|
|
5
5
|
import "../chunk-RPIDSIQG.js";
|
|
6
6
|
import {
|
|
7
7
|
Session,
|
|
8
8
|
defaultTransportOptions
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-7WY3Z5ZN.js";
|
|
10
10
|
import {
|
|
11
11
|
coerceErrorString
|
|
12
12
|
} from "../chunk-VH3NGOXQ.js";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@replit/river",
|
|
3
3
|
"description": "It's like tRPC but... with JSON Schema Support, duplex streaming and support for service multiplexing. Transport agnostic!",
|
|
4
|
-
"version": "0.17.
|
|
4
|
+
"version": "0.17.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"release": "npm publish --access public",
|
|
83
83
|
"test:ui": "echo \"remember to go to /__vitest__ in the webview\" && vitest --ui --api.host 0.0.0.0 --api.port 3000",
|
|
84
84
|
"test": "vitest --test-timeout=500",
|
|
85
|
-
"test:single": "vitest run --test-timeout=500",
|
|
85
|
+
"test:single": "vitest run --test-timeout=500 --reporter=dot",
|
|
86
86
|
"test:flake": "./flake.sh",
|
|
87
87
|
"bench": "vitest bench"
|
|
88
88
|
},
|