@replit/river 0.17.0 → 0.17.2
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-VJRLJ3JU.js → chunk-4A7FDC2C.js} +1 -1
- package/dist/{chunk-7IQO434V.js → chunk-4C2OXQJB.js} +66 -5
- package/dist/{chunk-LQMPJI3S.js → chunk-F6KWMEPR.js} +1 -1
- package/dist/{chunk-Y6DLSCKU.js → chunk-MSAS5CVJ.js} +1 -1
- package/dist/{procedures-b5ddb54d.d.ts → procedures-1a298406.d.ts} +19 -1
- package/dist/router/index.cjs +66 -5
- package/dist/router/index.d.cts +17 -6
- package/dist/router/index.d.ts +17 -6
- package/dist/router/index.js +1 -1
- package/dist/transport/impls/uds/client.cjs +1 -1
- package/dist/transport/impls/uds/client.js +2 -2
- package/dist/transport/impls/uds/server.cjs +1 -1
- package/dist/transport/impls/uds/server.js +2 -2
- package/dist/transport/impls/ws/client.cjs +1 -1
- package/dist/transport/impls/ws/client.js +2 -2
- package/dist/transport/impls/ws/server.cjs +1 -1
- package/dist/transport/impls/ws/server.js +2 -2
- package/dist/transport/index.cjs +1 -1
- package/dist/transport/index.js +1 -1
- package/dist/util/testHelpers.cjs +1 -1
- package/dist/util/testHelpers.d.cts +1 -1
- package/dist/util/testHelpers.d.ts +1 -1
- package/dist/util/testHelpers.js +2 -2
- package/package.json +1 -1
|
@@ -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(
|
|
@@ -188,7 +188,7 @@ var Session = class {
|
|
|
188
188
|
log?.error(`${this.from} -- received stale seq ${seq} + 1 < ${this.ack}`);
|
|
189
189
|
return;
|
|
190
190
|
}
|
|
191
|
-
this.sendBuffer = this.sendBuffer.filter((unacked) => unacked.seq
|
|
191
|
+
this.sendBuffer = this.sendBuffer.filter((unacked) => unacked.seq >= ack);
|
|
192
192
|
this.ack = seq + 1;
|
|
193
193
|
}
|
|
194
194
|
closeStaleConnection(conn) {
|
|
@@ -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,6 +1,6 @@
|
|
|
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-
|
|
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-1a298406.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-1a298406.js';
|
|
4
4
|
import { d as ServerTransport, C as Connection, a as ClientTransport, b as TransportClientId } from '../index-8df0bdfb.js';
|
|
5
5
|
import { Pushable } from 'it-pushable';
|
|
6
6
|
import '../types-3e5768ec.js';
|
|
@@ -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,6 +1,6 @@
|
|
|
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-
|
|
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-1a298406.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-1a298406.js';
|
|
4
4
|
import { d as ServerTransport, C as Connection, a as ClientTransport, b as TransportClientId } from '../index-8df0bdfb.js';
|
|
5
5
|
import { Pushable } from 'it-pushable';
|
|
6
6
|
import '../types-3e5768ec.js';
|
|
@@ -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
|
@@ -238,7 +238,7 @@ var Session = class {
|
|
|
238
238
|
log?.error(`${this.from} -- received stale seq ${seq} + 1 < ${this.ack}`);
|
|
239
239
|
return;
|
|
240
240
|
}
|
|
241
|
-
this.sendBuffer = this.sendBuffer.filter((unacked) => unacked.seq
|
|
241
|
+
this.sendBuffer = this.sendBuffer.filter((unacked) => unacked.seq >= ack);
|
|
242
242
|
this.ack = seq + 1;
|
|
243
243
|
}
|
|
244
244
|
closeStaleConnection(conn) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
UdsConnection
|
|
3
|
-
} from "../../../chunk-
|
|
3
|
+
} from "../../../chunk-4A7FDC2C.js";
|
|
4
4
|
import {
|
|
5
5
|
ClientTransport
|
|
6
|
-
} from "../../../chunk-
|
|
6
|
+
} from "../../../chunk-F6KWMEPR.js";
|
|
7
7
|
import "../../../chunk-VH3NGOXQ.js";
|
|
8
8
|
import {
|
|
9
9
|
log
|
|
@@ -271,7 +271,7 @@ var Session = class {
|
|
|
271
271
|
log?.error(`${this.from} -- received stale seq ${seq} + 1 < ${this.ack}`);
|
|
272
272
|
return;
|
|
273
273
|
}
|
|
274
|
-
this.sendBuffer = this.sendBuffer.filter((unacked) => unacked.seq
|
|
274
|
+
this.sendBuffer = this.sendBuffer.filter((unacked) => unacked.seq >= ack);
|
|
275
275
|
this.ack = seq + 1;
|
|
276
276
|
}
|
|
277
277
|
closeStaleConnection(conn) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
UdsConnection
|
|
3
|
-
} from "../../../chunk-
|
|
3
|
+
} from "../../../chunk-4A7FDC2C.js";
|
|
4
4
|
import {
|
|
5
5
|
ServerTransport
|
|
6
|
-
} from "../../../chunk-
|
|
6
|
+
} from "../../../chunk-F6KWMEPR.js";
|
|
7
7
|
import "../../../chunk-VH3NGOXQ.js";
|
|
8
8
|
import {
|
|
9
9
|
log
|
|
@@ -272,7 +272,7 @@ var Session = class {
|
|
|
272
272
|
log?.error(`${this.from} -- received stale seq ${seq} + 1 < ${this.ack}`);
|
|
273
273
|
return;
|
|
274
274
|
}
|
|
275
|
-
this.sendBuffer = this.sendBuffer.filter((unacked) => unacked.seq
|
|
275
|
+
this.sendBuffer = this.sendBuffer.filter((unacked) => unacked.seq >= ack);
|
|
276
276
|
this.ack = seq + 1;
|
|
277
277
|
}
|
|
278
278
|
closeStaleConnection(conn) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
WebSocketConnection
|
|
3
|
-
} from "../../../chunk-
|
|
3
|
+
} from "../../../chunk-MSAS5CVJ.js";
|
|
4
4
|
import {
|
|
5
5
|
ClientTransport
|
|
6
|
-
} from "../../../chunk-
|
|
6
|
+
} from "../../../chunk-F6KWMEPR.js";
|
|
7
7
|
import "../../../chunk-VH3NGOXQ.js";
|
|
8
8
|
import {
|
|
9
9
|
log
|
|
@@ -271,7 +271,7 @@ var Session = class {
|
|
|
271
271
|
log?.error(`${this.from} -- received stale seq ${seq} + 1 < ${this.ack}`);
|
|
272
272
|
return;
|
|
273
273
|
}
|
|
274
|
-
this.sendBuffer = this.sendBuffer.filter((unacked) => unacked.seq
|
|
274
|
+
this.sendBuffer = this.sendBuffer.filter((unacked) => unacked.seq >= ack);
|
|
275
275
|
this.ack = seq + 1;
|
|
276
276
|
}
|
|
277
277
|
closeStaleConnection(conn) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
WebSocketConnection
|
|
3
|
-
} from "../../../chunk-
|
|
3
|
+
} from "../../../chunk-MSAS5CVJ.js";
|
|
4
4
|
import {
|
|
5
5
|
ServerTransport
|
|
6
|
-
} from "../../../chunk-
|
|
6
|
+
} from "../../../chunk-F6KWMEPR.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
|
@@ -294,7 +294,7 @@ var Session = class {
|
|
|
294
294
|
log?.error(`${this.from} -- received stale seq ${seq} + 1 < ${this.ack}`);
|
|
295
295
|
return;
|
|
296
296
|
}
|
|
297
|
-
this.sendBuffer = this.sendBuffer.filter((unacked) => unacked.seq
|
|
297
|
+
this.sendBuffer = this.sendBuffer.filter((unacked) => unacked.seq >= ack);
|
|
298
298
|
this.ack = seq + 1;
|
|
299
299
|
}
|
|
300
300
|
closeStaleConnection(conn) {
|
package/dist/transport/index.js
CHANGED
|
@@ -188,7 +188,7 @@ var Session = class {
|
|
|
188
188
|
log?.error(`${this.from} -- received stale seq ${seq} + 1 < ${this.ack}`);
|
|
189
189
|
return;
|
|
190
190
|
}
|
|
191
|
-
this.sendBuffer = this.sendBuffer.filter((unacked) => unacked.seq
|
|
191
|
+
this.sendBuffer = this.sendBuffer.filter((unacked) => unacked.seq >= ack);
|
|
192
192
|
this.ack = seq + 1;
|
|
193
193
|
}
|
|
194
194
|
closeStaleConnection(conn) {
|
|
@@ -1,5 +1,5 @@
|
|
|
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-
|
|
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-1a298406.js';
|
|
3
3
|
import { P as PartialTransportMessage, T as Transport, C as Connection, O as OpaqueTransportMessage, S as SessionOptions } from '../index-8df0bdfb.js';
|
|
4
4
|
import * as it_pushable from 'it-pushable';
|
|
5
5
|
import WebSocket from 'isomorphic-ws';
|
|
@@ -1,5 +1,5 @@
|
|
|
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-
|
|
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-1a298406.js';
|
|
3
3
|
import { P as PartialTransportMessage, T as Transport, C as Connection, O as OpaqueTransportMessage, S as SessionOptions } from '../index-8df0bdfb.js';
|
|
4
4
|
import * as it_pushable from 'it-pushable';
|
|
5
5
|
import WebSocket from 'isomorphic-ws';
|
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-F6KWMEPR.js";
|
|
10
10
|
import {
|
|
11
11
|
coerceErrorString
|
|
12
12
|
} from "../chunk-VH3NGOXQ.js";
|
package/package.json
CHANGED