@replit/river 0.216.1 → 0.217.1
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/README.md +2 -2
- package/dist/{adapter-BXCk-dmy.d.ts → adapter-Dl5Mewp3.d.ts} +1 -1
- package/dist/{chunk-C4EPHIKQ.js → chunk-JFFRB3SS.js} +48 -26
- package/dist/chunk-JFFRB3SS.js.map +1 -0
- package/dist/{chunk-62BM2WOT.js → chunk-VK3VJZGG.js} +19 -18
- package/dist/chunk-VK3VJZGG.js.map +1 -0
- package/dist/chunk-WMPWPIA4.js +72 -0
- package/dist/chunk-WMPWPIA4.js.map +1 -0
- package/dist/{client-BNc5Pj_4.d.ts → client-YP9bECp8.d.ts} +2 -2
- package/dist/codec/index.d.ts +3 -3
- package/dist/codec/index.js +2 -2
- package/dist/{connection-ou9w2dSY.d.ts → connection-D_HE_YQB.d.ts} +3 -3
- package/dist/customSchemas/index.d.ts +34 -0
- package/dist/customSchemas/index.js +9 -0
- package/dist/customSchemas/index.js.map +1 -0
- package/dist/{index-ZWkoesQD.d.ts → index-DgUMnNOi.d.ts} +1 -1
- package/dist/logging/index.d.ts +3 -3
- package/dist/{message-CpXWqmJw.d.ts → message-DxS8db8A.d.ts} +30 -31
- package/dist/protobuf/index.d.ts +11 -15
- package/dist/protobuf/index.js +7 -5
- package/dist/protobuf/index.js.map +1 -1
- package/dist/router/index.d.ts +11 -11
- package/dist/router/index.js +1 -1
- package/dist/{server-BPu7Td80.d.ts → server-BfM3_JLq.d.ts} +5 -5
- package/dist/{services-DpT2yNtt.d.ts → services-CL6k3HMH.d.ts} +8 -9
- package/dist/testUtil/index.d.ts +8 -8
- package/dist/testUtil/index.js +2 -2
- package/dist/testUtil/index.js.map +1 -1
- package/dist/transport/impls/ws/client.d.ts +7 -7
- package/dist/transport/impls/ws/client.js +2 -2
- package/dist/transport/impls/ws/server.d.ts +7 -7
- package/dist/transport/impls/ws/server.js +2 -2
- package/dist/transport/impls/ws/server.js.map +1 -1
- package/dist/transport/index.d.ts +8 -8
- package/dist/transport/index.js +2 -2
- package/dist/{transport-B1MUtXL7.d.ts → transport-CUpXnch7.d.ts} +4 -4
- package/package.json +14 -39
- package/dist/adapter-D5X11kmP.d.cts +0 -29
- package/dist/chunk-62BM2WOT.js.map +0 -1
- package/dist/chunk-C4EPHIKQ.js.map +0 -1
- package/dist/client-BZUvFL6B.d.cts +0 -54
- package/dist/codec/index.cjs +0 -268
- package/dist/codec/index.cjs.map +0 -1
- package/dist/codec/index.d.cts +0 -19
- package/dist/connection-xxgJHs2o.d.cts +0 -40
- package/dist/index-BAGGleT3.d.cts +0 -37
- package/dist/logging/index.cjs +0 -55
- package/dist/logging/index.cjs.map +0 -1
- package/dist/logging/index.d.cts +0 -4
- package/dist/message-CpXWqmJw.d.cts +0 -119
- package/dist/protobuf/codec.cjs +0 -107
- package/dist/protobuf/codec.cjs.map +0 -1
- package/dist/protobuf/codec.d.cts +0 -13
- package/dist/protobuf/index.cjs +0 -1877
- package/dist/protobuf/index.cjs.map +0 -1
- package/dist/protobuf/index.d.cts +0 -488
- package/dist/router/index.cjs +0 -2043
- package/dist/router/index.cjs.map +0 -1
- package/dist/router/index.d.cts +0 -80
- package/dist/server-JdnoVO11.d.cts +0 -72
- package/dist/services-CjigASqe.d.cts +0 -1135
- package/dist/testUtil/index.cjs +0 -3051
- package/dist/testUtil/index.cjs.map +0 -1
- package/dist/testUtil/index.d.cts +0 -122
- package/dist/transport/impls/ws/client.cjs +0 -2308
- package/dist/transport/impls/ws/client.cjs.map +0 -1
- package/dist/transport/impls/ws/client.d.cts +0 -33
- package/dist/transport/impls/ws/server.cjs +0 -2179
- package/dist/transport/impls/ws/server.cjs.map +0 -1
- package/dist/transport/impls/ws/server.d.cts +0 -21
- package/dist/transport/index.cjs +0 -2727
- package/dist/transport/index.cjs.map +0 -1
- package/dist/transport/index.d.cts +0 -11
- package/dist/transport-BnU3Zb0Q.d.cts +0 -590
- package/dist/types-BGGvYIJM.d.cts +0 -20
- package/dist/wslike-Dng9H1C7.d.cts +0 -40
package/README.md
CHANGED
|
@@ -47,7 +47,7 @@ Before proceeding, ensure you have TypeScript 5 installed and configured appropr
|
|
|
47
47
|
To use River, install the required packages using npm:
|
|
48
48
|
|
|
49
49
|
```bash
|
|
50
|
-
npm i @replit/river
|
|
50
|
+
npm i @replit/river typebox
|
|
51
51
|
```
|
|
52
52
|
|
|
53
53
|
## Writing services
|
|
@@ -72,7 +72,7 @@ First, we create a service:
|
|
|
72
72
|
|
|
73
73
|
```ts
|
|
74
74
|
import { createServiceSchema, Procedure, Ok } from '@replit/river';
|
|
75
|
-
import { Type } from '
|
|
75
|
+
import { Type } from 'typebox';
|
|
76
76
|
|
|
77
77
|
const ServiceSchema = createServiceSchema();
|
|
78
78
|
export const ExampleService = ServiceSchema.define(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { O as OpaqueTransportMessage, E as EncodedTransportMessage } from './message-
|
|
1
|
+
import { O as OpaqueTransportMessage, E as EncodedTransportMessage } from './message-DxS8db8A.js';
|
|
2
2
|
import { C as Codec } from './types-BGGvYIJM.js';
|
|
3
3
|
|
|
4
4
|
type SessionApiResult<T> = {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
// router/services.ts
|
|
2
|
-
import { Type as Type2
|
|
2
|
+
import { Type as Type2 } from "typebox";
|
|
3
3
|
|
|
4
4
|
// router/errors.ts
|
|
5
5
|
import {
|
|
6
|
-
Kind,
|
|
7
6
|
Type
|
|
8
|
-
} from "
|
|
7
|
+
} from "typebox";
|
|
9
8
|
var UNCAUGHT_ERROR_CODE = "UNCAUGHT_ERROR";
|
|
10
9
|
var UNEXPECTED_DISCONNECT_CODE = "UNEXPECTED_DISCONNECT";
|
|
11
10
|
var INVALID_REQUEST_CODE = "INVALID_REQUEST";
|
|
@@ -19,15 +18,32 @@ var ValidationErrorDetails = Type.Object({
|
|
|
19
18
|
message: Type.String()
|
|
20
19
|
});
|
|
21
20
|
var ValidationErrors = Type.Array(ValidationErrorDetails);
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
function validationErrorToRiverErrors(error) {
|
|
22
|
+
let propertyNames;
|
|
23
|
+
switch (error.keyword) {
|
|
24
|
+
case "required":
|
|
25
|
+
propertyNames = error.params.requiredProperties;
|
|
26
|
+
break;
|
|
27
|
+
case "additionalProperties":
|
|
28
|
+
propertyNames = error.params.additionalProperties;
|
|
29
|
+
break;
|
|
30
|
+
case "propertyNames":
|
|
31
|
+
propertyNames = error.params.propertyNames;
|
|
32
|
+
break;
|
|
33
|
+
case "unevaluatedProperties":
|
|
34
|
+
propertyNames = error.params.unevaluatedProperties;
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
if (propertyNames) {
|
|
38
|
+
return propertyNames.map((prop) => ({
|
|
39
|
+
path: `${error.instancePath}/${prop.replace(/~/g, "~0").replace(/\//g, "~1")}`,
|
|
27
40
|
message: error.message
|
|
28
|
-
});
|
|
41
|
+
}));
|
|
29
42
|
}
|
|
30
|
-
return
|
|
43
|
+
return [{ path: error.instancePath, message: error.message }];
|
|
44
|
+
}
|
|
45
|
+
function castTypeboxValueErrors(errors) {
|
|
46
|
+
return errors.flatMap(validationErrorToRiverErrors);
|
|
31
47
|
}
|
|
32
48
|
var CancelErrorSchema = Type.Object({
|
|
33
49
|
code: Type.Literal(CANCEL_CODE),
|
|
@@ -57,7 +73,7 @@ var ReaderErrorSchema = Type.Union([
|
|
|
57
73
|
]);
|
|
58
74
|
var ReaderErrorResultSchema = ErrResultSchema(ReaderErrorSchema);
|
|
59
75
|
function isUnion(schema) {
|
|
60
|
-
return schema
|
|
76
|
+
return Type.IsUnion(schema);
|
|
61
77
|
}
|
|
62
78
|
function flattenErrorType(errType) {
|
|
63
79
|
if (!isUnion(errType)) {
|
|
@@ -286,7 +302,7 @@ function createServiceSchema() {
|
|
|
286
302
|
};
|
|
287
303
|
}
|
|
288
304
|
function getSerializedProcErrors(procDef) {
|
|
289
|
-
if (!("responseError" in procDef) || procDef.responseError
|
|
305
|
+
if (!("responseError" in procDef) || Type2.IsNever(procDef.responseError)) {
|
|
290
306
|
return Strict(ReaderErrorSchema);
|
|
291
307
|
}
|
|
292
308
|
const withProtocolErrors = flattenErrorType(
|
|
@@ -355,7 +371,7 @@ var ServiceScaffold = class {
|
|
|
355
371
|
};
|
|
356
372
|
|
|
357
373
|
// router/result.ts
|
|
358
|
-
import { Type as Type3 } from "
|
|
374
|
+
import { Type as Type3 } from "typebox";
|
|
359
375
|
var AnyResultSchema = Type3.Union([
|
|
360
376
|
Type3.Object({
|
|
361
377
|
ok: Type3.Literal(false),
|
|
@@ -604,7 +620,7 @@ var WritableImpl = class {
|
|
|
604
620
|
};
|
|
605
621
|
|
|
606
622
|
// router/procedures.ts
|
|
607
|
-
import { Type as Type4 } from "
|
|
623
|
+
import { Type as Type4 } from "typebox";
|
|
608
624
|
function rpc({
|
|
609
625
|
requestInit,
|
|
610
626
|
responseData,
|
|
@@ -681,7 +697,7 @@ var Procedure = {
|
|
|
681
697
|
};
|
|
682
698
|
|
|
683
699
|
// transport/message.ts
|
|
684
|
-
import { Type as Type5 } from "
|
|
700
|
+
import { Type as Type5 } from "typebox";
|
|
685
701
|
|
|
686
702
|
// transport/id.ts
|
|
687
703
|
import { customAlphabet } from "nanoid";
|
|
@@ -982,7 +998,7 @@ function getTracer() {
|
|
|
982
998
|
}
|
|
983
999
|
|
|
984
1000
|
// router/client.ts
|
|
985
|
-
import { Value } from "
|
|
1001
|
+
import { Value } from "typebox/value";
|
|
986
1002
|
var noop = () => {
|
|
987
1003
|
};
|
|
988
1004
|
function _createRecursiveProxy(callback, path) {
|
|
@@ -1154,9 +1170,10 @@ function handleProc(procType, transport, serverId, init, serviceName, procedureN
|
|
|
1154
1170
|
{
|
|
1155
1171
|
clientId: transport.clientId,
|
|
1156
1172
|
transportMessage: msg,
|
|
1157
|
-
validationErrors:
|
|
1158
|
-
|
|
1159
|
-
|
|
1173
|
+
validationErrors: Value.Errors(
|
|
1174
|
+
ReaderErrorResultSchema,
|
|
1175
|
+
msg.payload
|
|
1176
|
+
).flatMap(validationErrorToRiverErrors)
|
|
1160
1177
|
}
|
|
1161
1178
|
);
|
|
1162
1179
|
}
|
|
@@ -1184,7 +1201,10 @@ function handleProc(procType, transport, serverId, init, serviceName, procedureN
|
|
|
1184
1201
|
{
|
|
1185
1202
|
clientId: transport.clientId,
|
|
1186
1203
|
transportMessage: msg,
|
|
1187
|
-
validationErrors:
|
|
1204
|
+
validationErrors: Value.Errors(
|
|
1205
|
+
AnyResultSchema,
|
|
1206
|
+
msg.payload
|
|
1207
|
+
).flatMap(validationErrorToRiverErrors)
|
|
1188
1208
|
}
|
|
1189
1209
|
);
|
|
1190
1210
|
}
|
|
@@ -1293,7 +1313,7 @@ async function getSingleMessage(resReadable, log) {
|
|
|
1293
1313
|
}
|
|
1294
1314
|
|
|
1295
1315
|
// router/server.ts
|
|
1296
|
-
import { Value as Value2 } from "
|
|
1316
|
+
import { Value as Value2 } from "typebox/value";
|
|
1297
1317
|
|
|
1298
1318
|
// transport/stringifyError.ts
|
|
1299
1319
|
function coerceErrorString(err) {
|
|
@@ -1458,9 +1478,10 @@ var RiverServer = class {
|
|
|
1458
1478
|
this.log?.warn("got stream cancel without a valid protocol error", {
|
|
1459
1479
|
...loggingMetadata,
|
|
1460
1480
|
transportMessage: msg,
|
|
1461
|
-
validationErrors:
|
|
1462
|
-
|
|
1463
|
-
|
|
1481
|
+
validationErrors: Value2.Errors(
|
|
1482
|
+
CancelResultSchema,
|
|
1483
|
+
msg.payload
|
|
1484
|
+
).flatMap(validationErrorToRiverErrors),
|
|
1464
1485
|
tags: ["invalid-request"]
|
|
1465
1486
|
});
|
|
1466
1487
|
}
|
|
@@ -2067,7 +2088,7 @@ function createServerHandshakeOptions(schema, validate) {
|
|
|
2067
2088
|
}
|
|
2068
2089
|
|
|
2069
2090
|
// package.json
|
|
2070
|
-
var version = "0.
|
|
2091
|
+
var version = "0.217.1";
|
|
2071
2092
|
|
|
2072
2093
|
export {
|
|
2073
2094
|
generateId,
|
|
@@ -2093,6 +2114,7 @@ export {
|
|
|
2093
2114
|
UNEXPECTED_DISCONNECT_CODE,
|
|
2094
2115
|
INVALID_REQUEST_CODE,
|
|
2095
2116
|
CANCEL_CODE,
|
|
2117
|
+
validationErrorToRiverErrors,
|
|
2096
2118
|
ReaderErrorSchema,
|
|
2097
2119
|
flattenErrorType,
|
|
2098
2120
|
serializeSchemaV1Compat,
|
|
@@ -2118,4 +2140,4 @@ export {
|
|
|
2118
2140
|
recordRiverError,
|
|
2119
2141
|
getTracer
|
|
2120
2142
|
};
|
|
2121
|
-
//# sourceMappingURL=chunk-
|
|
2143
|
+
//# sourceMappingURL=chunk-JFFRB3SS.js.map
|