@replit/river 0.200.0-rc.4 → 0.200.0-rc.6

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 (44) hide show
  1. package/dist/{chunk-2BF4VMUZ.js → chunk-GXRIBO3N.js} +2 -2
  2. package/dist/{chunk-V57VWV5S.js → chunk-IGNFE3QW.js} +2 -2
  3. package/dist/{chunk-V57VWV5S.js.map → chunk-IGNFE3QW.js.map} +1 -1
  4. package/dist/{chunk-F7Z2QQRL.js → chunk-MU25KVV7.js} +2 -2
  5. package/dist/{chunk-SIRRYRLQ.js → chunk-MXU6DJVG.js} +64 -7
  6. package/dist/chunk-MXU6DJVG.js.map +1 -0
  7. package/dist/{chunk-SI4YHBTI.js → chunk-NOLXEIRP.js} +3 -3
  8. package/dist/{chunk-RDGHFHXN.js → chunk-TMNVRR5R.js} +2 -2
  9. package/dist/{chunk-BZQQXMVF.js → chunk-WE2PAPNC.js} +4 -4
  10. package/dist/{chunk-IMFMNIEO.js → chunk-WF3AW2CB.js} +4 -4
  11. package/dist/router/index.cjs +63 -6
  12. package/dist/router/index.cjs.map +1 -1
  13. package/dist/router/index.d.cts +3 -3
  14. package/dist/router/index.d.ts +3 -3
  15. package/dist/router/index.js +2 -2
  16. package/dist/{services-c67758fc.d.ts → services-69d72cd5.d.ts} +19 -0
  17. package/dist/transport/impls/uds/client.cjs +1 -1
  18. package/dist/transport/impls/uds/client.cjs.map +1 -1
  19. package/dist/transport/impls/uds/client.js +5 -5
  20. package/dist/transport/impls/uds/server.cjs +1 -1
  21. package/dist/transport/impls/uds/server.cjs.map +1 -1
  22. package/dist/transport/impls/uds/server.js +5 -5
  23. package/dist/transport/impls/ws/client.cjs +1 -1
  24. package/dist/transport/impls/ws/client.cjs.map +1 -1
  25. package/dist/transport/impls/ws/client.js +5 -5
  26. package/dist/transport/impls/ws/server.cjs +1 -1
  27. package/dist/transport/impls/ws/server.cjs.map +1 -1
  28. package/dist/transport/impls/ws/server.js +5 -5
  29. package/dist/transport/index.cjs +1 -1
  30. package/dist/transport/index.cjs.map +1 -1
  31. package/dist/transport/index.js +5 -5
  32. package/dist/util/testHelpers.cjs +1 -1
  33. package/dist/util/testHelpers.cjs.map +1 -1
  34. package/dist/util/testHelpers.d.cts +1 -1
  35. package/dist/util/testHelpers.d.ts +1 -1
  36. package/dist/util/testHelpers.js +3 -3
  37. package/package.json +1 -1
  38. package/dist/chunk-SIRRYRLQ.js.map +0 -1
  39. /package/dist/{chunk-2BF4VMUZ.js.map → chunk-GXRIBO3N.js.map} +0 -0
  40. /package/dist/{chunk-F7Z2QQRL.js.map → chunk-MU25KVV7.js.map} +0 -0
  41. /package/dist/{chunk-SI4YHBTI.js.map → chunk-NOLXEIRP.js.map} +0 -0
  42. /package/dist/{chunk-RDGHFHXN.js.map → chunk-TMNVRR5R.js.map} +0 -0
  43. /package/dist/{chunk-BZQQXMVF.js.map → chunk-WE2PAPNC.js.map} +0 -0
  44. /package/dist/{chunk-IMFMNIEO.js.map → chunk-WF3AW2CB.js.map} +0 -0
@@ -5,10 +5,10 @@ import {
5
5
  import {
6
6
  SessionStateGraph,
7
7
  defaultTransportOptions
8
- } from "./chunk-RDGHFHXN.js";
8
+ } from "./chunk-TMNVRR5R.js";
9
9
  import {
10
10
  generateId
11
- } from "./chunk-V57VWV5S.js";
11
+ } from "./chunk-IGNFE3QW.js";
12
12
 
13
13
  // transport/events.ts
14
14
  var ProtocolError = {
@@ -274,4 +274,4 @@ export {
274
274
  Transport,
275
275
  Connection
276
276
  };
277
- //# sourceMappingURL=chunk-SI4YHBTI.js.map
277
+ //# sourceMappingURL=chunk-NOLXEIRP.js.map
@@ -3,7 +3,7 @@ import {
3
3
  createSessionTelemetryInfo,
4
4
  generateId,
5
5
  isAck
6
- } from "./chunk-V57VWV5S.js";
6
+ } from "./chunk-IGNFE3QW.js";
7
7
  import {
8
8
  NaiveJsonCodec
9
9
  } from "./chunk-4PVU7J25.js";
@@ -655,4 +655,4 @@ export {
655
655
  SessionState,
656
656
  SessionStateGraph
657
657
  };
658
- //# sourceMappingURL=chunk-RDGHFHXN.js.map
658
+ //# sourceMappingURL=chunk-TMNVRR5R.js.map
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  ProtocolError,
3
3
  Transport
4
- } from "./chunk-SI4YHBTI.js";
4
+ } from "./chunk-NOLXEIRP.js";
5
5
  import {
6
6
  SessionStateGraph,
7
7
  defaultClientTransportOptions
8
- } from "./chunk-RDGHFHXN.js";
8
+ } from "./chunk-TMNVRR5R.js";
9
9
  import {
10
10
  ControlMessageHandshakeResponseSchema,
11
11
  HandshakeErrorRetriableResponseCodes,
@@ -14,7 +14,7 @@ import {
14
14
  getPropagationContext,
15
15
  handshakeRequestMessage,
16
16
  tracing_default
17
- } from "./chunk-V57VWV5S.js";
17
+ } from "./chunk-IGNFE3QW.js";
18
18
 
19
19
  // transport/client.ts
20
20
  import { SpanStatusCode } from "@opentelemetry/api";
@@ -398,4 +398,4 @@ var ClientTransport = class extends Transport {
398
398
  export {
399
399
  ClientTransport
400
400
  };
401
- //# sourceMappingURL=chunk-BZQQXMVF.js.map
401
+ //# sourceMappingURL=chunk-WE2PAPNC.js.map
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  ProtocolError,
3
3
  Transport
4
- } from "./chunk-SI4YHBTI.js";
4
+ } from "./chunk-NOLXEIRP.js";
5
5
  import {
6
6
  SessionStateGraph,
7
7
  defaultServerTransportOptions
8
- } from "./chunk-RDGHFHXN.js";
8
+ } from "./chunk-TMNVRR5R.js";
9
9
  import {
10
10
  ControlMessageHandshakeRequestSchema,
11
11
  acceptedProtocolVersions,
12
12
  coerceErrorString,
13
13
  currentProtocolVersion,
14
14
  handshakeResponseMessage
15
- } from "./chunk-V57VWV5S.js";
15
+ } from "./chunk-IGNFE3QW.js";
16
16
 
17
17
  // transport/server.ts
18
18
  import { SpanStatusCode } from "@opentelemetry/api";
@@ -381,4 +381,4 @@ var ServerTransport = class extends Transport {
381
381
  export {
382
382
  ServerTransport
383
383
  };
384
- //# sourceMappingURL=chunk-IMFMNIEO.js.map
384
+ //# sourceMappingURL=chunk-WF3AW2CB.js.map
@@ -170,6 +170,55 @@ var ServiceSchema = class _ServiceSchema {
170
170
  )
171
171
  };
172
172
  }
173
+ // TODO remove once clients migrate to v2
174
+ /**
175
+ * Same as {@link ServiceSchema.serialize}, but with a format that is compatible with
176
+ * protocol v1. This is useful to be able to continue to generate schemas for older
177
+ * clients as they are still supported.
178
+ */
179
+ serializeBackwardsCompatible() {
180
+ return {
181
+ procedures: Object.fromEntries(
182
+ Object.entries(this.procedures).map(
183
+ ([procName, procDef]) => {
184
+ if (procDef.type === "rpc" || procDef.type === "subscription") {
185
+ return [
186
+ procName,
187
+ {
188
+ // BACKWARDS COMPAT: map init to input for protocolv1
189
+ // this is the only change needed to make it compatible.
190
+ input: import_typebox.Type.Strict(procDef.init),
191
+ output: import_typebox.Type.Strict(procDef.output),
192
+ // Only add `description` field if the type declares it.
193
+ ..."description" in procDef ? { description: procDef.description } : {},
194
+ // Only add the `errors` field if the type declares it.
195
+ ..."errors" in procDef ? {
196
+ errors: import_typebox.Type.Strict(procDef.errors)
197
+ } : {},
198
+ type: procDef.type
199
+ }
200
+ ];
201
+ }
202
+ return [
203
+ procName,
204
+ {
205
+ init: import_typebox.Type.Strict(procDef.init),
206
+ output: import_typebox.Type.Strict(procDef.output),
207
+ // Only add `description` field if the type declares it.
208
+ ..."description" in procDef ? { description: procDef.description } : {},
209
+ // Only add the `errors` field if the type declares it.
210
+ ..."errors" in procDef ? {
211
+ errors: import_typebox.Type.Strict(procDef.errors)
212
+ } : {},
213
+ type: procDef.type,
214
+ input: import_typebox.Type.Strict(procDef.input)
215
+ }
216
+ ];
217
+ }
218
+ )
219
+ )
220
+ };
221
+ }
173
222
  /**
174
223
  * Instantiates this schema into a {@link Service} object.
175
224
  *
@@ -790,7 +839,7 @@ function isStreamAbort(controlFlag) {
790
839
  var import_api = require("@opentelemetry/api");
791
840
 
792
841
  // package.json
793
- var version = "0.200.0-rc.4";
842
+ var version = "0.200.0-rc.6";
794
843
 
795
844
  // tracing/index.ts
796
845
  function getPropagationContext(ctx) {
@@ -1223,7 +1272,8 @@ var RiverServer = class {
1223
1272
  from,
1224
1273
  sessionId,
1225
1274
  tracingCtx,
1226
- protocolVersion
1275
+ protocolVersion,
1276
+ passInitAsInputForBackwardsCompat
1227
1277
  }) {
1228
1278
  this.openStreams.add(streamId);
1229
1279
  let cleanClose = true;
@@ -1386,6 +1436,9 @@ var RiverServer = class {
1386
1436
  cleanup();
1387
1437
  }
1388
1438
  });
1439
+ if (passInitAsInputForBackwardsCompat) {
1440
+ inputReader.pushValue(Ok(initPayload));
1441
+ }
1389
1442
  const outputWriter = new WriteStreamImpl((response) => {
1390
1443
  this.transport.send(from, {
1391
1444
  streamId,
@@ -1506,7 +1559,7 @@ var RiverServer = class {
1506
1559
  try {
1507
1560
  await procedure.handler(
1508
1561
  serviceContextWithTransportInfo,
1509
- initPayload,
1562
+ passInitAsInputForBackwardsCompat ? null : initPayload,
1510
1563
  outputWriter
1511
1564
  );
1512
1565
  } catch (err) {
@@ -1528,7 +1581,7 @@ var RiverServer = class {
1528
1581
  try {
1529
1582
  const outputMessage = await procedure.handler(
1530
1583
  serviceContextWithTransportInfo,
1531
- initPayload,
1584
+ passInitAsInputForBackwardsCompat ? null : initPayload,
1532
1585
  inputReader
1533
1586
  );
1534
1587
  if (outputWriter.isClosed()) {
@@ -1697,7 +1750,10 @@ var RiverServer = class {
1697
1750
  return null;
1698
1751
  }
1699
1752
  const procedure = service.procedures[initMessage.procedureName];
1700
- if (!import_value2.Value.Check(procedure.init, initMessage.payload)) {
1753
+ let passInitAsInputForBackwardsCompat = false;
1754
+ if (session.protocolVersion === "v1.1" && (procedure.type === "upload" || procedure.type === "stream") && import_value2.Value.Check(procedure.input, initMessage.payload) && import_value2.Value.Check(procedure.init, {})) {
1755
+ passInitAsInputForBackwardsCompat = true;
1756
+ } else if (!import_value2.Value.Check(procedure.init, initMessage.payload)) {
1701
1757
  const errMessage = `procedure init failed validation`;
1702
1758
  this.log?.warn(errMessage, {
1703
1759
  ...session.loggingMetadata,
@@ -1731,7 +1787,8 @@ var RiverServer = class {
1731
1787
  initPayload: initMessage.payload,
1732
1788
  from: initMessage.from,
1733
1789
  sessionId: session.id,
1734
- protocolVersion: session.protocolVersion
1790
+ protocolVersion: session.protocolVersion,
1791
+ passInitAsInputForBackwardsCompat
1735
1792
  };
1736
1793
  }
1737
1794
  abortStream(to, streamId, payload) {