@replit/river 0.216.1 → 0.217.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.
Files changed (76) hide show
  1. package/README.md +2 -2
  2. package/dist/{adapter-BXCk-dmy.d.ts → adapter-Dl5Mewp3.d.ts} +1 -1
  3. package/dist/{chunk-C4EPHIKQ.js → chunk-FWVKRK36.js} +48 -26
  4. package/dist/chunk-FWVKRK36.js.map +1 -0
  5. package/dist/chunk-WMPWPIA4.js +72 -0
  6. package/dist/chunk-WMPWPIA4.js.map +1 -0
  7. package/dist/{chunk-62BM2WOT.js → chunk-YTV5S3DJ.js} +27 -19
  8. package/dist/chunk-YTV5S3DJ.js.map +1 -0
  9. package/dist/{client-BNc5Pj_4.d.ts → client-Tf2PXWoq.d.ts} +2 -2
  10. package/dist/codec/index.d.ts +3 -3
  11. package/dist/codec/index.js +2 -2
  12. package/dist/{connection-ou9w2dSY.d.ts → connection-D9yKScvK.d.ts} +3 -3
  13. package/dist/customSchemas/index.d.ts +34 -0
  14. package/dist/customSchemas/index.js +9 -0
  15. package/dist/customSchemas/index.js.map +1 -0
  16. package/dist/{index-ZWkoesQD.d.ts → index-DgUMnNOi.d.ts} +1 -1
  17. package/dist/logging/index.d.ts +3 -3
  18. package/dist/{message-CpXWqmJw.d.ts → message-DxS8db8A.d.ts} +30 -31
  19. package/dist/protobuf/index.d.ts +12 -16
  20. package/dist/protobuf/index.js +9 -7
  21. package/dist/protobuf/index.js.map +1 -1
  22. package/dist/router/index.d.ts +11 -11
  23. package/dist/router/index.js +1 -1
  24. package/dist/{server-BPu7Td80.d.ts → server-DhHG-q75.d.ts} +5 -5
  25. package/dist/{services-DpT2yNtt.d.ts → services-BT8Bq8Rs.d.ts} +8 -9
  26. package/dist/testUtil/index.d.ts +8 -8
  27. package/dist/testUtil/index.js +2 -2
  28. package/dist/testUtil/index.js.map +1 -1
  29. package/dist/transport/impls/ws/client.d.ts +7 -7
  30. package/dist/transport/impls/ws/client.js +2 -2
  31. package/dist/transport/impls/ws/server.d.ts +7 -7
  32. package/dist/transport/impls/ws/server.js +2 -2
  33. package/dist/transport/impls/ws/server.js.map +1 -1
  34. package/dist/transport/index.d.ts +8 -8
  35. package/dist/transport/index.js +2 -2
  36. package/dist/{transport-B1MUtXL7.d.ts → transport-D6czLXyc.d.ts} +13 -12
  37. package/package.json +14 -39
  38. package/dist/adapter-D5X11kmP.d.cts +0 -29
  39. package/dist/chunk-62BM2WOT.js.map +0 -1
  40. package/dist/chunk-C4EPHIKQ.js.map +0 -1
  41. package/dist/client-BZUvFL6B.d.cts +0 -54
  42. package/dist/codec/index.cjs +0 -268
  43. package/dist/codec/index.cjs.map +0 -1
  44. package/dist/codec/index.d.cts +0 -19
  45. package/dist/connection-xxgJHs2o.d.cts +0 -40
  46. package/dist/index-BAGGleT3.d.cts +0 -37
  47. package/dist/logging/index.cjs +0 -55
  48. package/dist/logging/index.cjs.map +0 -1
  49. package/dist/logging/index.d.cts +0 -4
  50. package/dist/message-CpXWqmJw.d.cts +0 -119
  51. package/dist/protobuf/codec.cjs +0 -107
  52. package/dist/protobuf/codec.cjs.map +0 -1
  53. package/dist/protobuf/codec.d.cts +0 -13
  54. package/dist/protobuf/index.cjs +0 -1877
  55. package/dist/protobuf/index.cjs.map +0 -1
  56. package/dist/protobuf/index.d.cts +0 -488
  57. package/dist/router/index.cjs +0 -2043
  58. package/dist/router/index.cjs.map +0 -1
  59. package/dist/router/index.d.cts +0 -80
  60. package/dist/server-JdnoVO11.d.cts +0 -72
  61. package/dist/services-CjigASqe.d.cts +0 -1135
  62. package/dist/testUtil/index.cjs +0 -3051
  63. package/dist/testUtil/index.cjs.map +0 -1
  64. package/dist/testUtil/index.d.cts +0 -122
  65. package/dist/transport/impls/ws/client.cjs +0 -2308
  66. package/dist/transport/impls/ws/client.cjs.map +0 -1
  67. package/dist/transport/impls/ws/client.d.cts +0 -33
  68. package/dist/transport/impls/ws/server.cjs +0 -2179
  69. package/dist/transport/impls/ws/server.cjs.map +0 -1
  70. package/dist/transport/impls/ws/server.d.cts +0 -21
  71. package/dist/transport/index.cjs +0 -2727
  72. package/dist/transport/index.cjs.map +0 -1
  73. package/dist/transport/index.d.cts +0 -11
  74. package/dist/transport-BnU3Zb0Q.d.cts +0 -590
  75. package/dist/types-BGGvYIJM.d.cts +0 -20
  76. 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 @sinclair/typebox
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 '@sinclair/typebox';
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-CpXWqmJw.js';
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, Kind as Kind2 } from "@sinclair/typebox";
2
+ import { Type as Type2 } from "typebox";
3
3
 
4
4
  // router/errors.ts
5
5
  import {
6
- Kind,
7
6
  Type
8
- } from "@sinclair/typebox";
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 castTypeboxValueErrors(errors) {
23
- const result = [];
24
- for (const error of errors) {
25
- result.push({
26
- path: error.path,
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 result;
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[Kind] === "Union";
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[Kind2] === "Never") {
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 "@sinclair/typebox";
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 "@sinclair/typebox";
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 "@sinclair/typebox";
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 "@sinclair/typebox/value";
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
- ...Value.Errors(ReaderErrorResultSchema, msg.payload)
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: [...Value.Errors(AnyResultSchema, msg.payload)]
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 "@sinclair/typebox/value";
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
- ...Value2.Errors(CancelResultSchema, msg.payload)
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.216.1";
2091
+ var version = "0.217.2";
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-C4EPHIKQ.js.map
2143
+ //# sourceMappingURL=chunk-FWVKRK36.js.map