@replit/river 0.23.16 → 0.23.18

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 (63) hide show
  1. package/README.md +4 -4
  2. package/dist/{chunk-R47IZD67.js → chunk-7MJYOL32.js} +5 -6
  3. package/dist/{chunk-R47IZD67.js.map → chunk-7MJYOL32.js.map} +1 -1
  4. package/dist/{chunk-UDXM64QK.js → chunk-AVL32IMG.js} +6 -4
  5. package/dist/{chunk-UDXM64QK.js.map → chunk-AVL32IMG.js.map} +1 -1
  6. package/dist/{chunk-JA7XGTAL.js → chunk-DPKOJQWF.js} +5 -5
  7. package/dist/chunk-DPKOJQWF.js.map +1 -0
  8. package/dist/{chunk-LTSLICON.js → chunk-EV5HW4IC.js} +5 -468
  9. package/dist/chunk-EV5HW4IC.js.map +1 -0
  10. package/dist/{chunk-WN77AT67.js → chunk-J6N6H2WU.js} +3 -3
  11. package/dist/{chunk-YXDAOVP7.js → chunk-MW5JXLHY.js} +3 -2
  12. package/dist/chunk-MW5JXLHY.js.map +1 -0
  13. package/dist/{chunk-TXSQRTZB.js → chunk-R2HAS3GM.js} +2 -2
  14. package/dist/{chunk-TXSQRTZB.js.map → chunk-R2HAS3GM.js.map} +1 -1
  15. package/dist/{chunk-MQCGG6KL.js → chunk-RJOWZIWB.js} +5 -5
  16. package/dist/chunk-RJOWZIWB.js.map +1 -0
  17. package/dist/{client-0926d3d6.d.ts → client-5776a6bb.d.ts} +1 -1
  18. package/dist/{connection-99a67d3e.d.ts → connection-bd35d442.d.ts} +1 -1
  19. package/dist/{connection-d738cc08.d.ts → connection-df85db7e.d.ts} +1 -1
  20. package/dist/{handshake-75d0124f.d.ts → handshake-a947c234.d.ts} +4 -0
  21. package/dist/router/index.cjs +4 -468
  22. package/dist/router/index.cjs.map +1 -1
  23. package/dist/router/index.d.cts +8 -47
  24. package/dist/router/index.d.ts +8 -47
  25. package/dist/router/index.js +2 -4
  26. package/dist/{server-3740c5d9.d.ts → server-53cd5b7e.d.ts} +1 -1
  27. package/dist/{services-75e84a9f.d.ts → services-38b3f758.d.ts} +6 -6
  28. package/dist/transport/impls/uds/client.cjs +7 -4
  29. package/dist/transport/impls/uds/client.cjs.map +1 -1
  30. package/dist/transport/impls/uds/client.d.cts +3 -3
  31. package/dist/transport/impls/uds/client.d.ts +3 -3
  32. package/dist/transport/impls/uds/client.js +5 -5
  33. package/dist/transport/impls/uds/server.cjs +7 -4
  34. package/dist/transport/impls/uds/server.cjs.map +1 -1
  35. package/dist/transport/impls/uds/server.d.cts +3 -3
  36. package/dist/transport/impls/uds/server.d.ts +3 -3
  37. package/dist/transport/impls/uds/server.js +5 -5
  38. package/dist/transport/impls/ws/client.cjs +6 -6
  39. package/dist/transport/impls/ws/client.cjs.map +1 -1
  40. package/dist/transport/impls/ws/client.d.cts +3 -3
  41. package/dist/transport/impls/ws/client.d.ts +3 -3
  42. package/dist/transport/impls/ws/client.js +5 -5
  43. package/dist/transport/impls/ws/server.cjs +6 -6
  44. package/dist/transport/impls/ws/server.cjs.map +1 -1
  45. package/dist/transport/impls/ws/server.d.cts +3 -3
  46. package/dist/transport/impls/ws/server.d.ts +3 -3
  47. package/dist/transport/impls/ws/server.js +5 -5
  48. package/dist/transport/index.cjs +4 -3
  49. package/dist/transport/index.cjs.map +1 -1
  50. package/dist/transport/index.d.cts +3 -3
  51. package/dist/transport/index.d.ts +3 -3
  52. package/dist/transport/index.js +5 -5
  53. package/dist/util/testHelpers.cjs +2 -1
  54. package/dist/util/testHelpers.cjs.map +1 -1
  55. package/dist/util/testHelpers.d.cts +4 -4
  56. package/dist/util/testHelpers.d.ts +4 -4
  57. package/dist/util/testHelpers.js +3 -3
  58. package/package.json +1 -1
  59. package/dist/chunk-JA7XGTAL.js.map +0 -1
  60. package/dist/chunk-LTSLICON.js.map +0 -1
  61. package/dist/chunk-MQCGG6KL.js.map +0 -1
  62. package/dist/chunk-YXDAOVP7.js.map +0 -1
  63. /package/dist/{chunk-WN77AT67.js.map → chunk-J6N6H2WU.js.map} +0 -0
@@ -31,7 +31,6 @@ __export(router_exports, {
31
31
  createClientHandshakeOptions: () => createClientHandshakeOptions,
32
32
  createServer: () => createServer,
33
33
  createServerHandshakeOptions: () => createServerHandshakeOptions,
34
- diffServerSchema: () => diffServerSchema,
35
34
  serializeSchema: () => serializeSchema
36
35
  });
37
36
  module.exports = __toCommonJS(router_exports);
@@ -174,9 +173,9 @@ var ServiceSchema = class _ServiceSchema {
174
173
  * You probably don't need this, usually the River server will handle this
175
174
  * for you.
176
175
  */
177
- instantiate() {
176
+ instantiate(extendedContext) {
178
177
  return Object.freeze({
179
- state: this.initializeState(),
178
+ state: this.initializeState(extendedContext),
180
179
  procedures: this.procedures
181
180
  });
182
181
  }
@@ -238,468 +237,6 @@ var ServiceScaffold = class {
238
237
  }
239
238
  };
240
239
 
241
- // router/diff.ts
242
- function diffServerSchema(oldServer, newServer, options) {
243
- const allServices = /* @__PURE__ */ new Set([
244
- ...Object.keys(oldServer.services),
245
- ...Object.keys(newServer.services)
246
- ]);
247
- const breakages = {};
248
- for (const serviceName of allServices) {
249
- const oldService = oldServer.services[serviceName];
250
- const newService = newServer.services[serviceName];
251
- const breakage = diffService(oldService, newService, options);
252
- if (breakage) {
253
- breakages[serviceName] = breakage;
254
- }
255
- }
256
- if (Object.keys(breakages).length) {
257
- return { serviceBreakages: breakages };
258
- }
259
- return null;
260
- }
261
- function diffService(oldService, newService, options) {
262
- if (!newService) {
263
- return options?.allowServiceRemoval ? null : { reason: "removed" };
264
- }
265
- if (!oldService) {
266
- return null;
267
- }
268
- const allProcedures = /* @__PURE__ */ new Set([
269
- ...Object.keys(oldService.procedures),
270
- ...Object.keys(newService.procedures)
271
- ]);
272
- const breakages = {};
273
- for (const procedureName of allProcedures) {
274
- const aProcedure = oldService.procedures[procedureName];
275
- const bProcedure = newService.procedures[procedureName];
276
- const breakage = diffProcedure(aProcedure, bProcedure, options);
277
- if (breakage) {
278
- breakages[procedureName] = breakage;
279
- }
280
- }
281
- if (Object.keys(breakages).length) {
282
- return { reason: "modified", procedureBreakages: breakages };
283
- }
284
- return null;
285
- }
286
- function diffProcedure(oldProcedure, newProcedure, options) {
287
- if (!newProcedure) {
288
- return options?.allowProcedureRemoval ? null : { reason: "removed" };
289
- }
290
- if (!oldProcedure) {
291
- return null;
292
- }
293
- if (oldProcedure.type !== newProcedure.type) {
294
- return {
295
- reason: "type-changed",
296
- oldType: oldProcedure.type,
297
- newType: newProcedure.type
298
- };
299
- }
300
- const inputBreakage = diffProcedureField(
301
- oldProcedure.input,
302
- newProcedure.input,
303
- "client"
304
- );
305
- const initBreakage = diffProcedureField(
306
- oldProcedure.init,
307
- newProcedure.init,
308
- "client"
309
- );
310
- const outputBreakage = diffProcedureField(
311
- oldProcedure.output,
312
- newProcedure.output,
313
- "server"
314
- );
315
- if (inputBreakage ?? initBreakage ?? outputBreakage) {
316
- const result = {
317
- reason: "modified"
318
- };
319
- if (inputBreakage) {
320
- result.input = inputBreakage;
321
- }
322
- if (initBreakage) {
323
- result.init = initBreakage;
324
- }
325
- if (outputBreakage) {
326
- result.output = outputBreakage;
327
- }
328
- return result;
329
- }
330
- return null;
331
- }
332
- function diffProcedureField(oldSchema, newSchema, origin) {
333
- if (!oldSchema && !newSchema) {
334
- return null;
335
- }
336
- const diffBreakage = diffRequired(oldSchema, newSchema, origin, false, false);
337
- if (diffBreakage) {
338
- return diffBreakage;
339
- }
340
- if (!oldSchema || !newSchema) {
341
- throw new Error("Appease typescript, this should never happen");
342
- }
343
- return diffJSONSchema(oldSchema, newSchema, origin);
344
- }
345
- function diffRequired(oldSchema, newSchema, origin, oldRequired, newRequired) {
346
- if (!newSchema && !oldSchema) {
347
- throw new Error("Both old and new schema are undefined");
348
- }
349
- if (!newSchema) {
350
- if (!oldRequired && origin == "server") {
351
- return null;
352
- }
353
- return { reason: "removed-required" };
354
- }
355
- if (!oldSchema) {
356
- if (newRequired && origin === "client") {
357
- return { reason: "new-required" };
358
- }
359
- return null;
360
- }
361
- if (origin === "client" && !oldRequired && newRequired) {
362
- return { reason: "new-required" };
363
- }
364
- if (origin === "server" && oldRequired && !newRequired) {
365
- return { reason: "removed-required" };
366
- }
367
- return null;
368
- }
369
- function diffJSONSchema(oldSchema, newSchema, origin) {
370
- if (oldSchema.type !== newSchema.type) {
371
- return {
372
- reason: "type-changed",
373
- oldType: getReportingType(oldSchema),
374
- newType: getReportingType(newSchema)
375
- };
376
- }
377
- if (getReportingType(oldSchema) !== getReportingType(newSchema)) {
378
- return {
379
- reason: "type-changed",
380
- oldType: getReportingType(oldSchema),
381
- newType: getReportingType(newSchema)
382
- };
383
- }
384
- if ("const" in oldSchema && "const" in newSchema && oldSchema.const !== newSchema.const) {
385
- return {
386
- reason: "type-changed",
387
- oldType: `${getReportingType(oldSchema)}-const-${oldSchema.const}`,
388
- newType: `${getReportingType(newSchema)}-const-${newSchema.const}`
389
- };
390
- }
391
- if ("const" in oldSchema && !("const" in newSchema) && origin === "server") {
392
- return {
393
- reason: "type-changed",
394
- oldType: `${getReportingType(oldSchema)}-const-${oldSchema.const}`,
395
- newType: getReportingType(newSchema)
396
- };
397
- }
398
- if ("const" in newSchema && !("const" in oldSchema) && origin === "client") {
399
- return {
400
- reason: "type-changed",
401
- oldType: getReportingType(oldSchema),
402
- newType: `${getReportingType(newSchema)}-const-${newSchema.const}`
403
- };
404
- }
405
- const breakages = {};
406
- if ("$ref" in newSchema) {
407
- if (newSchema.$ref !== oldSchema.$ref) {
408
- return {
409
- reason: "type-changed",
410
- oldType: getReportingType(oldSchema),
411
- newType: getReportingType(newSchema)
412
- };
413
- }
414
- } else if ("not" in newSchema) {
415
- const notBreakage = diffJSONSchema(
416
- oldSchema.not,
417
- newSchema.not,
418
- origin
419
- );
420
- if (notBreakage) {
421
- breakages.not = notBreakage;
422
- }
423
- } else if ("anyOf" in newSchema) {
424
- const oldAnyOfStringified = oldSchema.anyOf.map((el) => JSON.stringify(el)).sort();
425
- const newAnyOfStringified = newSchema.anyOf.map((el) => JSON.stringify(el)).sort();
426
- const anyOfBreakages = {};
427
- for (let i = 0; i < oldAnyOfStringified.length; i++) {
428
- if (newAnyOfStringified.includes(oldAnyOfStringified[i])) {
429
- continue;
430
- }
431
- if (!newAnyOfStringified[i]) {
432
- if (origin === "server") {
433
- continue;
434
- }
435
- anyOfBreakages[`old-${i}`] = { reason: "removed-required" };
436
- } else {
437
- const breakage = diffJSONSchema(
438
- JSON.parse(oldAnyOfStringified[i]),
439
- JSON.parse(newAnyOfStringified[i]),
440
- origin
441
- );
442
- if (breakage) {
443
- anyOfBreakages[`old-${i}`] = breakage;
444
- }
445
- }
446
- }
447
- for (let i = 0; i < newAnyOfStringified.length; i++) {
448
- if (oldAnyOfStringified.includes(newAnyOfStringified[i])) {
449
- continue;
450
- }
451
- if (!oldAnyOfStringified[i]) {
452
- if (origin === "client") {
453
- continue;
454
- }
455
- anyOfBreakages[`new-${i}`] = { reason: "new-required" };
456
- } else {
457
- const breakage = diffJSONSchema(
458
- JSON.parse(oldAnyOfStringified[i]),
459
- JSON.parse(newAnyOfStringified[i]),
460
- origin
461
- );
462
- if (breakage) {
463
- anyOfBreakages[`new-${i}`] = breakage;
464
- }
465
- }
466
- }
467
- if (Object.keys(anyOfBreakages).length > 0) {
468
- breakages.anyOf = {
469
- reason: "field-breakage",
470
- fieldBreakages: anyOfBreakages
471
- };
472
- }
473
- } else if ("oneOf" in newSchema) {
474
- throw new Error("oneOf is not supported, typebox does not emit it");
475
- } else if ("allOf" in newSchema) {
476
- if (newSchema.allOf.length !== oldSchema.allOf.length) {
477
- breakages.allOf = {
478
- reason: "type-changed",
479
- oldType: `${oldSchema.allOf}`,
480
- newType: `${newSchema.allOf}`
481
- };
482
- } else {
483
- for (let i = 0; i < newSchema.allOf.length; i++) {
484
- const breakage = diffJSONSchema(
485
- oldSchema.allOf[i],
486
- newSchema.allOf[i],
487
- origin
488
- );
489
- if (breakage) {
490
- breakages.allOf = breakage;
491
- break;
492
- }
493
- }
494
- }
495
- } else if (newSchema.type === "array") {
496
- const itemsBreakages = diffJSONSchema(
497
- oldSchema.items,
498
- newSchema.items,
499
- origin
500
- );
501
- if (itemsBreakages) {
502
- breakages.items = itemsBreakages;
503
- }
504
- if (oldSchema.minItems < newSchema.minItems) {
505
- if (origin === "client") {
506
- breakages.minItems = {
507
- reason: "type-changed",
508
- oldType: `${oldSchema.minItems}`,
509
- newType: `${newSchema.minItems}`
510
- };
511
- }
512
- } else if (oldSchema.minItems > newSchema.minItems) {
513
- if (origin === "server") {
514
- breakages.minItems = {
515
- reason: "type-changed",
516
- oldType: `${oldSchema.minItems}`,
517
- newType: `${newSchema.minItems}`
518
- };
519
- }
520
- }
521
- if (oldSchema.maxItems < newSchema.maxItems) {
522
- if (origin === "server") {
523
- breakages.maxItems = {
524
- reason: "type-changed",
525
- oldType: `${oldSchema.maxItems}`,
526
- newType: `${newSchema.maxItems}`
527
- };
528
- }
529
- } else if (oldSchema.maxItems > newSchema.maxItems) {
530
- if (origin === "client") {
531
- breakages.maxItems = {
532
- reason: "type-changed",
533
- oldType: `${oldSchema.maxItems}`,
534
- newType: `${newSchema.maxItems}`
535
- };
536
- }
537
- }
538
- if (!oldSchema.uniqueItems && newSchema.uniqueItems && origin === "client") {
539
- breakages.uniqueItems = {
540
- reason: "type-changed",
541
- oldType: `${!!oldSchema.uniqueItems}`,
542
- newType: `${!!newSchema.uniqueItems}`
543
- };
544
- }
545
- if ("contains" in newSchema !== "contains" in oldSchema) {
546
- if ("contains" in newSchema && !("contains" in oldSchema) && origin === "client") {
547
- breakages.contains = {
548
- reason: "type-changed",
549
- oldType: "no-contains",
550
- newType: "contains"
551
- };
552
- }
553
- } else if ("contains" in newSchema) {
554
- const containsBreakage = diffJSONSchema(
555
- oldSchema.contains,
556
- newSchema.contains,
557
- origin
558
- );
559
- if (containsBreakage) {
560
- breakages.contains = containsBreakage;
561
- }
562
- }
563
- if (oldSchema.minContains < newSchema.minContains) {
564
- if (origin === "client") {
565
- breakages.minContains = {
566
- reason: "type-changed",
567
- oldType: `${oldSchema.minContains}`,
568
- newType: `${newSchema.minContains}`
569
- };
570
- }
571
- } else if (oldSchema.minContains > newSchema.minContains) {
572
- if (origin === "server") {
573
- breakages.minContains = {
574
- reason: "type-changed",
575
- oldType: `${oldSchema.minContains}`,
576
- newType: `${newSchema.minContains}`
577
- };
578
- }
579
- }
580
- if (oldSchema.maxContains < newSchema.maxContains) {
581
- if (origin === "server") {
582
- breakages.maxContains = {
583
- reason: "type-changed",
584
- oldType: `${oldSchema.maxContains}`,
585
- newType: `${newSchema.maxContains}`
586
- };
587
- }
588
- } else if (oldSchema.maxContains > newSchema.maxContains) {
589
- if (origin === "client") {
590
- breakages.maxContains = {
591
- reason: "type-changed",
592
- oldType: `${oldSchema.maxContains}`,
593
- newType: `${newSchema.maxContains}`
594
- };
595
- }
596
- }
597
- } else if (newSchema.type === "object") {
598
- if ("properties" in newSchema !== "properties" in oldSchema) {
599
- return {
600
- reason: "type-changed",
601
- oldType: "properties" in oldSchema ? "probably-object" : "probably-record",
602
- newType: "properties" in newSchema ? "probably-object" : "probably-record"
603
- };
604
- }
605
- if ("properties" in newSchema) {
606
- const propertiesBreakages = diffObjectProperties(
607
- oldSchema.properties,
608
- newSchema.properties,
609
- origin,
610
- oldSchema.required,
611
- newSchema.required
612
- );
613
- if (Object.keys(propertiesBreakages).length) {
614
- breakages.properties = {
615
- reason: "field-breakage",
616
- fieldBreakages: propertiesBreakages
617
- };
618
- }
619
- }
620
- if ("patternProperties" in newSchema) {
621
- const patternPropertiesBreakages = diffObjectProperties(
622
- oldSchema.patternProperties,
623
- newSchema.patternProperties,
624
- origin,
625
- oldSchema.required,
626
- newSchema.required
627
- );
628
- if (Object.keys(patternPropertiesBreakages).length) {
629
- breakages.patternProperties = {
630
- reason: "field-breakage",
631
- fieldBreakages: patternPropertiesBreakages
632
- };
633
- }
634
- }
635
- if ("additionalProperties" in newSchema || "additionalProperties" in oldSchema) {
636
- throw new Error("additionalProperties is not supported");
637
- }
638
- if ("minProperties" in newSchema || "minProperties" in oldSchema) {
639
- throw new Error("minProperties is not supported");
640
- }
641
- if ("maxProperties" in newSchema || "maxProperties" in oldSchema) {
642
- throw new Error("maxProperties is not supported");
643
- }
644
- }
645
- if (Object.keys(breakages).length) {
646
- return {
647
- reason: "field-breakage",
648
- fieldBreakages: breakages
649
- };
650
- }
651
- return null;
652
- }
653
- function diffObjectProperties(oldProperties, newProperties, origin, oldRequiredProperties = [], newRequiredProperties = []) {
654
- const allProperties = /* @__PURE__ */ new Set([
655
- ...Object.keys(oldProperties),
656
- ...Object.keys(newProperties)
657
- ]);
658
- const breakages = {};
659
- for (const propertyName of allProperties) {
660
- const requiredBreakage = diffRequired(
661
- oldProperties[propertyName],
662
- newProperties[propertyName],
663
- origin,
664
- oldRequiredProperties.includes(propertyName),
665
- newRequiredProperties.includes(propertyName)
666
- );
667
- if (requiredBreakage) {
668
- breakages[propertyName] = requiredBreakage;
669
- } else if (oldProperties[propertyName] && newProperties[propertyName]) {
670
- const propertyBreakage = diffJSONSchema(
671
- oldProperties[propertyName],
672
- newProperties[propertyName],
673
- origin
674
- );
675
- if (propertyBreakage) {
676
- breakages[propertyName] = propertyBreakage;
677
- }
678
- }
679
- }
680
- return breakages;
681
- }
682
- function getReportingType(schema) {
683
- if ("not" in schema) {
684
- return "not";
685
- }
686
- if ("anyOf" in schema) {
687
- return "anyOf";
688
- }
689
- if ("allOf" in schema) {
690
- return "allOf";
691
- }
692
- if ("$ref" in schema) {
693
- return "$ref";
694
- }
695
- if (schema.type && typeof schema.type === "string") {
696
- return schema.type;
697
- }
698
- throw new Error(
699
- "Subschema not supported, probably a conditional subschema. Check logs."
700
- );
701
- }
702
-
703
240
  // router/procedures.ts
704
241
  var import_typebox2 = require("@sinclair/typebox");
705
242
  function rpc({
@@ -1187,7 +724,7 @@ function Err(error) {
1187
724
  var import_api = require("@opentelemetry/api");
1188
725
 
1189
726
  // package.json
1190
- var version = "0.23.16";
727
+ var version = "0.23.18";
1191
728
 
1192
729
  // tracing/index.ts
1193
730
  function getPropagationContext(ctx) {
@@ -1595,7 +1132,7 @@ var RiverServer = class {
1595
1132
  this.services = instances;
1596
1133
  this.contextMap = /* @__PURE__ */ new Map();
1597
1134
  for (const [name, service] of Object.entries(services)) {
1598
- const instance = service.instantiate();
1135
+ const instance = service.instantiate(extendedContext ?? {});
1599
1136
  instances[name] = instance;
1600
1137
  this.contextMap.set(instance, {
1601
1138
  ...extendedContext,
@@ -2045,7 +1582,6 @@ function createServerHandshakeOptions(schema, validate) {
2045
1582
  createClientHandshakeOptions,
2046
1583
  createServer,
2047
1584
  createServerHandshakeOptions,
2048
- diffServerSchema,
2049
1585
  serializeSchema
2050
1586
  });
2051
1587
  //# sourceMappingURL=index.cjs.map