@replit/river 0.200.0-rc.2 → 0.200.0-rc.3
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 +21 -20
- package/dist/{chunk-S5RL45KH.js → chunk-3CCOX55A.js} +76 -42
- package/dist/chunk-3CCOX55A.js.map +1 -0
- package/dist/chunk-GWYJZFCW.js +653 -0
- package/dist/chunk-GWYJZFCW.js.map +1 -0
- package/dist/chunk-O4O2E6DJ.js +277 -0
- package/dist/chunk-O4O2E6DJ.js.map +1 -0
- package/dist/chunk-QXLXDJD5.js +382 -0
- package/dist/chunk-QXLXDJD5.js.map +1 -0
- package/dist/{chunk-4VNY34QG.js → chunk-UFMDEG44.js} +24 -18
- package/dist/chunk-UFMDEG44.js.map +1 -0
- package/dist/{chunk-7CKIN3JT.js → chunk-UIYGPURD.js} +31 -484
- package/dist/chunk-UIYGPURD.js.map +1 -0
- package/dist/{chunk-QMM35C3H.js → chunk-VXYHC666.js} +1 -1
- package/dist/chunk-VXYHC666.js.map +1 -0
- package/dist/chunk-WSCAA7VY.js +50 -0
- package/dist/chunk-WSCAA7VY.js.map +1 -0
- package/dist/chunk-ZQVKFLAB.js +399 -0
- package/dist/chunk-ZQVKFLAB.js.map +1 -0
- package/dist/client-a84783be.d.ts +49 -0
- package/dist/{connection-f900e390.d.ts → connection-320fb130.d.ts} +1 -5
- package/dist/connection-d0b488e6.d.ts +11 -0
- package/dist/context-c9668e95.d.ts +527 -0
- package/dist/logging/index.cjs.map +1 -1
- package/dist/logging/index.d.cts +1 -1
- package/dist/logging/index.d.ts +1 -1
- package/dist/logging/index.js +1 -1
- package/dist/{index-10ebd26a.d.ts → message-fd349b27.d.ts} +31 -31
- package/dist/router/index.cjs +83 -496
- package/dist/router/index.cjs.map +1 -1
- package/dist/router/index.d.cts +11 -46
- package/dist/router/index.d.ts +11 -46
- package/dist/router/index.js +2 -4
- package/dist/server-dbad597e.d.ts +42 -0
- package/dist/{services-970f97bb.d.ts → services-690e5553.d.ts} +5 -602
- package/dist/transport/impls/uds/client.cjs +1240 -1237
- package/dist/transport/impls/uds/client.cjs.map +1 -1
- package/dist/transport/impls/uds/client.d.cts +4 -3
- package/dist/transport/impls/uds/client.d.ts +4 -3
- package/dist/transport/impls/uds/client.js +7 -13
- package/dist/transport/impls/uds/client.js.map +1 -1
- package/dist/transport/impls/uds/server.cjs +1302 -1168
- package/dist/transport/impls/uds/server.cjs.map +1 -1
- package/dist/transport/impls/uds/server.d.cts +4 -4
- package/dist/transport/impls/uds/server.d.ts +4 -4
- package/dist/transport/impls/uds/server.js +6 -6
- package/dist/transport/impls/ws/client.cjs +981 -986
- package/dist/transport/impls/ws/client.cjs.map +1 -1
- package/dist/transport/impls/ws/client.d.cts +6 -5
- package/dist/transport/impls/ws/client.d.ts +6 -5
- package/dist/transport/impls/ws/client.js +6 -7
- package/dist/transport/impls/ws/client.js.map +1 -1
- package/dist/transport/impls/ws/server.cjs +1183 -1064
- package/dist/transport/impls/ws/server.cjs.map +1 -1
- package/dist/transport/impls/ws/server.d.cts +4 -4
- package/dist/transport/impls/ws/server.d.ts +4 -4
- package/dist/transport/impls/ws/server.js +6 -6
- package/dist/transport/index.cjs +1435 -1377
- package/dist/transport/index.cjs.map +1 -1
- package/dist/transport/index.d.cts +4 -26
- package/dist/transport/index.d.ts +4 -26
- package/dist/transport/index.js +9 -9
- package/dist/util/testHelpers.cjs +738 -302
- package/dist/util/testHelpers.cjs.map +1 -1
- package/dist/util/testHelpers.d.cts +9 -4
- package/dist/util/testHelpers.d.ts +9 -4
- package/dist/util/testHelpers.js +32 -8
- package/dist/util/testHelpers.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-47TFNAY2.js +0 -476
- package/dist/chunk-47TFNAY2.js.map +0 -1
- package/dist/chunk-4VNY34QG.js.map +0 -1
- package/dist/chunk-7CKIN3JT.js.map +0 -1
- package/dist/chunk-CZP4LK3F.js +0 -335
- package/dist/chunk-CZP4LK3F.js.map +0 -1
- package/dist/chunk-DJCW3SKT.js +0 -59
- package/dist/chunk-DJCW3SKT.js.map +0 -1
- package/dist/chunk-NQWDT6GS.js +0 -347
- package/dist/chunk-NQWDT6GS.js.map +0 -1
- package/dist/chunk-ONUXWVRC.js +0 -492
- package/dist/chunk-ONUXWVRC.js.map +0 -1
- package/dist/chunk-QMM35C3H.js.map +0 -1
- package/dist/chunk-S5RL45KH.js.map +0 -1
- package/dist/connection-3f117047.d.ts +0 -17
package/dist/router/index.cjs
CHANGED
|
@@ -34,7 +34,6 @@ __export(router_exports, {
|
|
|
34
34
|
createClientHandshakeOptions: () => createClientHandshakeOptions,
|
|
35
35
|
createServer: () => createServer,
|
|
36
36
|
createServerHandshakeOptions: () => createServerHandshakeOptions,
|
|
37
|
-
diffServerSchema: () => diffServerSchema,
|
|
38
37
|
serializeSchema: () => serializeSchema
|
|
39
38
|
});
|
|
40
39
|
module.exports = __toCommonJS(router_exports);
|
|
@@ -241,468 +240,6 @@ var ServiceScaffold = class {
|
|
|
241
240
|
}
|
|
242
241
|
};
|
|
243
242
|
|
|
244
|
-
// router/diff.ts
|
|
245
|
-
function diffServerSchema(oldServer, newServer, options) {
|
|
246
|
-
const allServices = /* @__PURE__ */ new Set([
|
|
247
|
-
...Object.keys(oldServer.services),
|
|
248
|
-
...Object.keys(newServer.services)
|
|
249
|
-
]);
|
|
250
|
-
const breakages = {};
|
|
251
|
-
for (const serviceName of allServices) {
|
|
252
|
-
const oldService = oldServer.services[serviceName];
|
|
253
|
-
const newService = newServer.services[serviceName];
|
|
254
|
-
const breakage = diffService(oldService, newService, options);
|
|
255
|
-
if (breakage) {
|
|
256
|
-
breakages[serviceName] = breakage;
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
if (Object.keys(breakages).length) {
|
|
260
|
-
return { serviceBreakages: breakages };
|
|
261
|
-
}
|
|
262
|
-
return null;
|
|
263
|
-
}
|
|
264
|
-
function diffService(oldService, newService, options) {
|
|
265
|
-
if (!newService) {
|
|
266
|
-
return options?.allowServiceRemoval ? null : { reason: "removed" };
|
|
267
|
-
}
|
|
268
|
-
if (!oldService) {
|
|
269
|
-
return null;
|
|
270
|
-
}
|
|
271
|
-
const allProcedures = /* @__PURE__ */ new Set([
|
|
272
|
-
...Object.keys(oldService.procedures),
|
|
273
|
-
...Object.keys(newService.procedures)
|
|
274
|
-
]);
|
|
275
|
-
const breakages = {};
|
|
276
|
-
for (const procedureName of allProcedures) {
|
|
277
|
-
const aProcedure = oldService.procedures[procedureName];
|
|
278
|
-
const bProcedure = newService.procedures[procedureName];
|
|
279
|
-
const breakage = diffProcedure(aProcedure, bProcedure, options);
|
|
280
|
-
if (breakage) {
|
|
281
|
-
breakages[procedureName] = breakage;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
if (Object.keys(breakages).length) {
|
|
285
|
-
return { reason: "modified", procedureBreakages: breakages };
|
|
286
|
-
}
|
|
287
|
-
return null;
|
|
288
|
-
}
|
|
289
|
-
function diffProcedure(oldProcedure, newProcedure, options) {
|
|
290
|
-
if (!newProcedure) {
|
|
291
|
-
return options?.allowProcedureRemoval ? null : { reason: "removed" };
|
|
292
|
-
}
|
|
293
|
-
if (!oldProcedure) {
|
|
294
|
-
return null;
|
|
295
|
-
}
|
|
296
|
-
if (oldProcedure.type !== newProcedure.type) {
|
|
297
|
-
return {
|
|
298
|
-
reason: "type-changed",
|
|
299
|
-
oldType: oldProcedure.type,
|
|
300
|
-
newType: newProcedure.type
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
const inputBreakage = diffProcedureField(
|
|
304
|
-
oldProcedure.input,
|
|
305
|
-
newProcedure.input,
|
|
306
|
-
"client"
|
|
307
|
-
);
|
|
308
|
-
const initBreakage = diffProcedureField(
|
|
309
|
-
oldProcedure.init,
|
|
310
|
-
newProcedure.init,
|
|
311
|
-
"client"
|
|
312
|
-
);
|
|
313
|
-
const outputBreakage = diffProcedureField(
|
|
314
|
-
oldProcedure.output,
|
|
315
|
-
newProcedure.output,
|
|
316
|
-
"server"
|
|
317
|
-
);
|
|
318
|
-
if (inputBreakage ?? initBreakage ?? outputBreakage) {
|
|
319
|
-
const result = {
|
|
320
|
-
reason: "modified"
|
|
321
|
-
};
|
|
322
|
-
if (inputBreakage) {
|
|
323
|
-
result.input = inputBreakage;
|
|
324
|
-
}
|
|
325
|
-
if (initBreakage) {
|
|
326
|
-
result.init = initBreakage;
|
|
327
|
-
}
|
|
328
|
-
if (outputBreakage) {
|
|
329
|
-
result.output = outputBreakage;
|
|
330
|
-
}
|
|
331
|
-
return result;
|
|
332
|
-
}
|
|
333
|
-
return null;
|
|
334
|
-
}
|
|
335
|
-
function diffProcedureField(oldSchema, newSchema, origin) {
|
|
336
|
-
if (!oldSchema && !newSchema) {
|
|
337
|
-
return null;
|
|
338
|
-
}
|
|
339
|
-
const diffBreakage = diffRequired(oldSchema, newSchema, origin, false, false);
|
|
340
|
-
if (diffBreakage) {
|
|
341
|
-
return diffBreakage;
|
|
342
|
-
}
|
|
343
|
-
if (!oldSchema || !newSchema) {
|
|
344
|
-
throw new Error("Appease typescript, this should never happen");
|
|
345
|
-
}
|
|
346
|
-
return diffJSONSchema(oldSchema, newSchema, origin);
|
|
347
|
-
}
|
|
348
|
-
function diffRequired(oldSchema, newSchema, origin, oldRequired, newRequired) {
|
|
349
|
-
if (!newSchema && !oldSchema) {
|
|
350
|
-
throw new Error("Both old and new schema are undefined");
|
|
351
|
-
}
|
|
352
|
-
if (!newSchema) {
|
|
353
|
-
if (!oldRequired && origin == "server") {
|
|
354
|
-
return null;
|
|
355
|
-
}
|
|
356
|
-
return { reason: "removed-required" };
|
|
357
|
-
}
|
|
358
|
-
if (!oldSchema) {
|
|
359
|
-
if (newRequired && origin === "client") {
|
|
360
|
-
return { reason: "new-required" };
|
|
361
|
-
}
|
|
362
|
-
return null;
|
|
363
|
-
}
|
|
364
|
-
if (origin === "client" && !oldRequired && newRequired) {
|
|
365
|
-
return { reason: "new-required" };
|
|
366
|
-
}
|
|
367
|
-
if (origin === "server" && oldRequired && !newRequired) {
|
|
368
|
-
return { reason: "removed-required" };
|
|
369
|
-
}
|
|
370
|
-
return null;
|
|
371
|
-
}
|
|
372
|
-
function diffJSONSchema(oldSchema, newSchema, origin) {
|
|
373
|
-
if (oldSchema.type !== newSchema.type) {
|
|
374
|
-
return {
|
|
375
|
-
reason: "type-changed",
|
|
376
|
-
oldType: getReportingType(oldSchema),
|
|
377
|
-
newType: getReportingType(newSchema)
|
|
378
|
-
};
|
|
379
|
-
}
|
|
380
|
-
if (getReportingType(oldSchema) !== getReportingType(newSchema)) {
|
|
381
|
-
return {
|
|
382
|
-
reason: "type-changed",
|
|
383
|
-
oldType: getReportingType(oldSchema),
|
|
384
|
-
newType: getReportingType(newSchema)
|
|
385
|
-
};
|
|
386
|
-
}
|
|
387
|
-
if ("const" in oldSchema && "const" in newSchema && oldSchema.const !== newSchema.const) {
|
|
388
|
-
return {
|
|
389
|
-
reason: "type-changed",
|
|
390
|
-
oldType: `${getReportingType(oldSchema)}-const-${oldSchema.const}`,
|
|
391
|
-
newType: `${getReportingType(newSchema)}-const-${newSchema.const}`
|
|
392
|
-
};
|
|
393
|
-
}
|
|
394
|
-
if ("const" in oldSchema && !("const" in newSchema) && origin === "server") {
|
|
395
|
-
return {
|
|
396
|
-
reason: "type-changed",
|
|
397
|
-
oldType: `${getReportingType(oldSchema)}-const-${oldSchema.const}`,
|
|
398
|
-
newType: getReportingType(newSchema)
|
|
399
|
-
};
|
|
400
|
-
}
|
|
401
|
-
if ("const" in newSchema && !("const" in oldSchema) && origin === "client") {
|
|
402
|
-
return {
|
|
403
|
-
reason: "type-changed",
|
|
404
|
-
oldType: getReportingType(oldSchema),
|
|
405
|
-
newType: `${getReportingType(newSchema)}-const-${newSchema.const}`
|
|
406
|
-
};
|
|
407
|
-
}
|
|
408
|
-
const breakages = {};
|
|
409
|
-
if ("$ref" in newSchema) {
|
|
410
|
-
if (newSchema.$ref !== oldSchema.$ref) {
|
|
411
|
-
return {
|
|
412
|
-
reason: "type-changed",
|
|
413
|
-
oldType: getReportingType(oldSchema),
|
|
414
|
-
newType: getReportingType(newSchema)
|
|
415
|
-
};
|
|
416
|
-
}
|
|
417
|
-
} else if ("not" in newSchema) {
|
|
418
|
-
const notBreakage = diffJSONSchema(
|
|
419
|
-
oldSchema.not,
|
|
420
|
-
newSchema.not,
|
|
421
|
-
origin
|
|
422
|
-
);
|
|
423
|
-
if (notBreakage) {
|
|
424
|
-
breakages.not = notBreakage;
|
|
425
|
-
}
|
|
426
|
-
} else if ("anyOf" in newSchema) {
|
|
427
|
-
const oldAnyOfStringified = oldSchema.anyOf.map((el) => JSON.stringify(el)).sort();
|
|
428
|
-
const newAnyOfStringified = newSchema.anyOf.map((el) => JSON.stringify(el)).sort();
|
|
429
|
-
const anyOfBreakages = {};
|
|
430
|
-
for (let i = 0; i < oldAnyOfStringified.length; i++) {
|
|
431
|
-
if (newAnyOfStringified.includes(oldAnyOfStringified[i])) {
|
|
432
|
-
continue;
|
|
433
|
-
}
|
|
434
|
-
if (!newAnyOfStringified[i]) {
|
|
435
|
-
if (origin === "server") {
|
|
436
|
-
continue;
|
|
437
|
-
}
|
|
438
|
-
anyOfBreakages[`old-${i}`] = { reason: "removed-required" };
|
|
439
|
-
} else {
|
|
440
|
-
const breakage = diffJSONSchema(
|
|
441
|
-
JSON.parse(oldAnyOfStringified[i]),
|
|
442
|
-
JSON.parse(newAnyOfStringified[i]),
|
|
443
|
-
origin
|
|
444
|
-
);
|
|
445
|
-
if (breakage) {
|
|
446
|
-
anyOfBreakages[`old-${i}`] = breakage;
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
for (let i = 0; i < newAnyOfStringified.length; i++) {
|
|
451
|
-
if (oldAnyOfStringified.includes(newAnyOfStringified[i])) {
|
|
452
|
-
continue;
|
|
453
|
-
}
|
|
454
|
-
if (!oldAnyOfStringified[i]) {
|
|
455
|
-
if (origin === "client") {
|
|
456
|
-
continue;
|
|
457
|
-
}
|
|
458
|
-
anyOfBreakages[`new-${i}`] = { reason: "new-required" };
|
|
459
|
-
} else {
|
|
460
|
-
const breakage = diffJSONSchema(
|
|
461
|
-
JSON.parse(oldAnyOfStringified[i]),
|
|
462
|
-
JSON.parse(newAnyOfStringified[i]),
|
|
463
|
-
origin
|
|
464
|
-
);
|
|
465
|
-
if (breakage) {
|
|
466
|
-
anyOfBreakages[`new-${i}`] = breakage;
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
if (Object.keys(anyOfBreakages).length > 0) {
|
|
471
|
-
breakages.anyOf = {
|
|
472
|
-
reason: "field-breakage",
|
|
473
|
-
fieldBreakages: anyOfBreakages
|
|
474
|
-
};
|
|
475
|
-
}
|
|
476
|
-
} else if ("oneOf" in newSchema) {
|
|
477
|
-
throw new Error("oneOf is not supported, typebox does not emit it");
|
|
478
|
-
} else if ("allOf" in newSchema) {
|
|
479
|
-
if (newSchema.allOf.length !== oldSchema.allOf.length) {
|
|
480
|
-
breakages.allOf = {
|
|
481
|
-
reason: "type-changed",
|
|
482
|
-
oldType: `${oldSchema.allOf}`,
|
|
483
|
-
newType: `${newSchema.allOf}`
|
|
484
|
-
};
|
|
485
|
-
} else {
|
|
486
|
-
for (let i = 0; i < newSchema.allOf.length; i++) {
|
|
487
|
-
const breakage = diffJSONSchema(
|
|
488
|
-
oldSchema.allOf[i],
|
|
489
|
-
newSchema.allOf[i],
|
|
490
|
-
origin
|
|
491
|
-
);
|
|
492
|
-
if (breakage) {
|
|
493
|
-
breakages.allOf = breakage;
|
|
494
|
-
break;
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
} else if (newSchema.type === "array") {
|
|
499
|
-
const itemsBreakages = diffJSONSchema(
|
|
500
|
-
oldSchema.items,
|
|
501
|
-
newSchema.items,
|
|
502
|
-
origin
|
|
503
|
-
);
|
|
504
|
-
if (itemsBreakages) {
|
|
505
|
-
breakages.items = itemsBreakages;
|
|
506
|
-
}
|
|
507
|
-
if (oldSchema.minItems < newSchema.minItems) {
|
|
508
|
-
if (origin === "client") {
|
|
509
|
-
breakages.minItems = {
|
|
510
|
-
reason: "type-changed",
|
|
511
|
-
oldType: `${oldSchema.minItems}`,
|
|
512
|
-
newType: `${newSchema.minItems}`
|
|
513
|
-
};
|
|
514
|
-
}
|
|
515
|
-
} else if (oldSchema.minItems > newSchema.minItems) {
|
|
516
|
-
if (origin === "server") {
|
|
517
|
-
breakages.minItems = {
|
|
518
|
-
reason: "type-changed",
|
|
519
|
-
oldType: `${oldSchema.minItems}`,
|
|
520
|
-
newType: `${newSchema.minItems}`
|
|
521
|
-
};
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
if (oldSchema.maxItems < newSchema.maxItems) {
|
|
525
|
-
if (origin === "server") {
|
|
526
|
-
breakages.maxItems = {
|
|
527
|
-
reason: "type-changed",
|
|
528
|
-
oldType: `${oldSchema.maxItems}`,
|
|
529
|
-
newType: `${newSchema.maxItems}`
|
|
530
|
-
};
|
|
531
|
-
}
|
|
532
|
-
} else if (oldSchema.maxItems > newSchema.maxItems) {
|
|
533
|
-
if (origin === "client") {
|
|
534
|
-
breakages.maxItems = {
|
|
535
|
-
reason: "type-changed",
|
|
536
|
-
oldType: `${oldSchema.maxItems}`,
|
|
537
|
-
newType: `${newSchema.maxItems}`
|
|
538
|
-
};
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
if (!oldSchema.uniqueItems && newSchema.uniqueItems && origin === "client") {
|
|
542
|
-
breakages.uniqueItems = {
|
|
543
|
-
reason: "type-changed",
|
|
544
|
-
oldType: `${!!oldSchema.uniqueItems}`,
|
|
545
|
-
newType: `${!!newSchema.uniqueItems}`
|
|
546
|
-
};
|
|
547
|
-
}
|
|
548
|
-
if ("contains" in newSchema !== "contains" in oldSchema) {
|
|
549
|
-
if ("contains" in newSchema && !("contains" in oldSchema) && origin === "client") {
|
|
550
|
-
breakages.contains = {
|
|
551
|
-
reason: "type-changed",
|
|
552
|
-
oldType: "no-contains",
|
|
553
|
-
newType: "contains"
|
|
554
|
-
};
|
|
555
|
-
}
|
|
556
|
-
} else if ("contains" in newSchema) {
|
|
557
|
-
const containsBreakage = diffJSONSchema(
|
|
558
|
-
oldSchema.contains,
|
|
559
|
-
newSchema.contains,
|
|
560
|
-
origin
|
|
561
|
-
);
|
|
562
|
-
if (containsBreakage) {
|
|
563
|
-
breakages.contains = containsBreakage;
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
if (oldSchema.minContains < newSchema.minContains) {
|
|
567
|
-
if (origin === "client") {
|
|
568
|
-
breakages.minContains = {
|
|
569
|
-
reason: "type-changed",
|
|
570
|
-
oldType: `${oldSchema.minContains}`,
|
|
571
|
-
newType: `${newSchema.minContains}`
|
|
572
|
-
};
|
|
573
|
-
}
|
|
574
|
-
} else if (oldSchema.minContains > newSchema.minContains) {
|
|
575
|
-
if (origin === "server") {
|
|
576
|
-
breakages.minContains = {
|
|
577
|
-
reason: "type-changed",
|
|
578
|
-
oldType: `${oldSchema.minContains}`,
|
|
579
|
-
newType: `${newSchema.minContains}`
|
|
580
|
-
};
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
if (oldSchema.maxContains < newSchema.maxContains) {
|
|
584
|
-
if (origin === "server") {
|
|
585
|
-
breakages.maxContains = {
|
|
586
|
-
reason: "type-changed",
|
|
587
|
-
oldType: `${oldSchema.maxContains}`,
|
|
588
|
-
newType: `${newSchema.maxContains}`
|
|
589
|
-
};
|
|
590
|
-
}
|
|
591
|
-
} else if (oldSchema.maxContains > newSchema.maxContains) {
|
|
592
|
-
if (origin === "client") {
|
|
593
|
-
breakages.maxContains = {
|
|
594
|
-
reason: "type-changed",
|
|
595
|
-
oldType: `${oldSchema.maxContains}`,
|
|
596
|
-
newType: `${newSchema.maxContains}`
|
|
597
|
-
};
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
} else if (newSchema.type === "object") {
|
|
601
|
-
if ("properties" in newSchema !== "properties" in oldSchema) {
|
|
602
|
-
return {
|
|
603
|
-
reason: "type-changed",
|
|
604
|
-
oldType: "properties" in oldSchema ? "probably-object" : "probably-record",
|
|
605
|
-
newType: "properties" in newSchema ? "probably-object" : "probably-record"
|
|
606
|
-
};
|
|
607
|
-
}
|
|
608
|
-
if ("properties" in newSchema) {
|
|
609
|
-
const propertiesBreakages = diffObjectProperties(
|
|
610
|
-
oldSchema.properties,
|
|
611
|
-
newSchema.properties,
|
|
612
|
-
origin,
|
|
613
|
-
oldSchema.required,
|
|
614
|
-
newSchema.required
|
|
615
|
-
);
|
|
616
|
-
if (Object.keys(propertiesBreakages).length) {
|
|
617
|
-
breakages.properties = {
|
|
618
|
-
reason: "field-breakage",
|
|
619
|
-
fieldBreakages: propertiesBreakages
|
|
620
|
-
};
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
if ("patternProperties" in newSchema) {
|
|
624
|
-
const patternPropertiesBreakages = diffObjectProperties(
|
|
625
|
-
oldSchema.patternProperties,
|
|
626
|
-
newSchema.patternProperties,
|
|
627
|
-
origin,
|
|
628
|
-
oldSchema.required,
|
|
629
|
-
newSchema.required
|
|
630
|
-
);
|
|
631
|
-
if (Object.keys(patternPropertiesBreakages).length) {
|
|
632
|
-
breakages.patternProperties = {
|
|
633
|
-
reason: "field-breakage",
|
|
634
|
-
fieldBreakages: patternPropertiesBreakages
|
|
635
|
-
};
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
if ("additionalProperties" in newSchema || "additionalProperties" in oldSchema) {
|
|
639
|
-
throw new Error("additionalProperties is not supported");
|
|
640
|
-
}
|
|
641
|
-
if ("minProperties" in newSchema || "minProperties" in oldSchema) {
|
|
642
|
-
throw new Error("minProperties is not supported");
|
|
643
|
-
}
|
|
644
|
-
if ("maxProperties" in newSchema || "maxProperties" in oldSchema) {
|
|
645
|
-
throw new Error("maxProperties is not supported");
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
if (Object.keys(breakages).length) {
|
|
649
|
-
return {
|
|
650
|
-
reason: "field-breakage",
|
|
651
|
-
fieldBreakages: breakages
|
|
652
|
-
};
|
|
653
|
-
}
|
|
654
|
-
return null;
|
|
655
|
-
}
|
|
656
|
-
function diffObjectProperties(oldProperties, newProperties, origin, oldRequiredProperties = [], newRequiredProperties = []) {
|
|
657
|
-
const allProperties = /* @__PURE__ */ new Set([
|
|
658
|
-
...Object.keys(oldProperties),
|
|
659
|
-
...Object.keys(newProperties)
|
|
660
|
-
]);
|
|
661
|
-
const breakages = {};
|
|
662
|
-
for (const propertyName of allProperties) {
|
|
663
|
-
const requiredBreakage = diffRequired(
|
|
664
|
-
oldProperties[propertyName],
|
|
665
|
-
newProperties[propertyName],
|
|
666
|
-
origin,
|
|
667
|
-
oldRequiredProperties.includes(propertyName),
|
|
668
|
-
newRequiredProperties.includes(propertyName)
|
|
669
|
-
);
|
|
670
|
-
if (requiredBreakage) {
|
|
671
|
-
breakages[propertyName] = requiredBreakage;
|
|
672
|
-
} else if (oldProperties[propertyName] && newProperties[propertyName]) {
|
|
673
|
-
const propertyBreakage = diffJSONSchema(
|
|
674
|
-
oldProperties[propertyName],
|
|
675
|
-
newProperties[propertyName],
|
|
676
|
-
origin
|
|
677
|
-
);
|
|
678
|
-
if (propertyBreakage) {
|
|
679
|
-
breakages[propertyName] = propertyBreakage;
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
return breakages;
|
|
684
|
-
}
|
|
685
|
-
function getReportingType(schema) {
|
|
686
|
-
if ("not" in schema) {
|
|
687
|
-
return "not";
|
|
688
|
-
}
|
|
689
|
-
if ("anyOf" in schema) {
|
|
690
|
-
return "anyOf";
|
|
691
|
-
}
|
|
692
|
-
if ("allOf" in schema) {
|
|
693
|
-
return "allOf";
|
|
694
|
-
}
|
|
695
|
-
if ("$ref" in schema) {
|
|
696
|
-
return "$ref";
|
|
697
|
-
}
|
|
698
|
-
if (schema.type && typeof schema.type === "string") {
|
|
699
|
-
return schema.type;
|
|
700
|
-
}
|
|
701
|
-
throw new Error(
|
|
702
|
-
"Subschema not supported, probably a conditional subschema. Check logs."
|
|
703
|
-
);
|
|
704
|
-
}
|
|
705
|
-
|
|
706
243
|
// router/result.ts
|
|
707
244
|
var import_typebox2 = require("@sinclair/typebox");
|
|
708
245
|
var ErrResultSchema = (t) => import_typebox2.Type.Object({
|
|
@@ -1109,7 +646,15 @@ var Procedure = {
|
|
|
1109
646
|
|
|
1110
647
|
// transport/message.ts
|
|
1111
648
|
var import_typebox4 = require("@sinclair/typebox");
|
|
649
|
+
|
|
650
|
+
// transport/id.ts
|
|
1112
651
|
var import_nanoid = require("nanoid");
|
|
652
|
+
var alphabet = (0, import_nanoid.customAlphabet)(
|
|
653
|
+
"1234567890abcdefghijklmnopqrstuvxyzABCDEFGHIJKLMNOPQRSTUVXYZ"
|
|
654
|
+
);
|
|
655
|
+
var generateId = () => alphabet(12);
|
|
656
|
+
|
|
657
|
+
// transport/message.ts
|
|
1113
658
|
var TransportMessageSchema = (t) => import_typebox4.Type.Object({
|
|
1114
659
|
id: import_typebox4.Type.String(),
|
|
1115
660
|
from: import_typebox4.Type.String(),
|
|
@@ -1143,18 +688,29 @@ var ControlMessageHandshakeRequestSchema = import_typebox4.Type.Object({
|
|
|
1143
688
|
* used by the server to know whether this is a new or a reestablished connection, and whether it
|
|
1144
689
|
* is compatible with what it already has.
|
|
1145
690
|
*/
|
|
1146
|
-
expectedSessionState: import_typebox4.Type.
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
})
|
|
1155
|
-
),
|
|
691
|
+
expectedSessionState: import_typebox4.Type.Object({
|
|
692
|
+
// what the client expects the server to send next
|
|
693
|
+
nextExpectedSeq: import_typebox4.Type.Integer(),
|
|
694
|
+
// TODO: remove optional once we know all servers
|
|
695
|
+
// are nextSentSeq here
|
|
696
|
+
// what the server expects the client to send next
|
|
697
|
+
nextSentSeq: import_typebox4.Type.Optional(import_typebox4.Type.Integer())
|
|
698
|
+
}),
|
|
1156
699
|
metadata: import_typebox4.Type.Optional(import_typebox4.Type.Unknown())
|
|
1157
700
|
});
|
|
701
|
+
var HandshakeErrorRetriableResponseCodes = import_typebox4.Type.Union([
|
|
702
|
+
import_typebox4.Type.Literal("SESSION_STATE_MISMATCH")
|
|
703
|
+
]);
|
|
704
|
+
var HandshakeErrorFatalResponseCodes = import_typebox4.Type.Union([
|
|
705
|
+
import_typebox4.Type.Literal("MALFORMED_HANDSHAKE_META"),
|
|
706
|
+
import_typebox4.Type.Literal("MALFORMED_HANDSHAKE"),
|
|
707
|
+
import_typebox4.Type.Literal("PROTOCOL_VERSION_MISMATCH"),
|
|
708
|
+
import_typebox4.Type.Literal("REJECTED_BY_CUSTOM_HANDLER")
|
|
709
|
+
]);
|
|
710
|
+
var HandshakeErrorResponseCodes = import_typebox4.Type.Union([
|
|
711
|
+
HandshakeErrorRetriableResponseCodes,
|
|
712
|
+
HandshakeErrorFatalResponseCodes
|
|
713
|
+
]);
|
|
1158
714
|
var ControlMessageHandshakeResponseSchema = import_typebox4.Type.Object({
|
|
1159
715
|
type: import_typebox4.Type.Literal("HANDSHAKE_RESP"),
|
|
1160
716
|
status: import_typebox4.Type.Union([
|
|
@@ -1164,7 +720,10 @@ var ControlMessageHandshakeResponseSchema = import_typebox4.Type.Object({
|
|
|
1164
720
|
}),
|
|
1165
721
|
import_typebox4.Type.Object({
|
|
1166
722
|
ok: import_typebox4.Type.Literal(false),
|
|
1167
|
-
reason: import_typebox4.Type.String()
|
|
723
|
+
reason: import_typebox4.Type.String(),
|
|
724
|
+
// TODO: remove optional once we know all servers
|
|
725
|
+
// are sending code here
|
|
726
|
+
code: import_typebox4.Type.Optional(HandshakeErrorResponseCodes)
|
|
1168
727
|
})
|
|
1169
728
|
])
|
|
1170
729
|
});
|
|
@@ -1177,6 +736,31 @@ var ControlMessagePayloadSchema = import_typebox4.Type.Union([
|
|
|
1177
736
|
var OpaqueTransportMessageSchema = TransportMessageSchema(
|
|
1178
737
|
import_typebox4.Type.Unknown()
|
|
1179
738
|
);
|
|
739
|
+
function closeStreamMessage(streamId) {
|
|
740
|
+
return {
|
|
741
|
+
streamId,
|
|
742
|
+
controlFlags: 8 /* StreamClosedBit */,
|
|
743
|
+
payload: {
|
|
744
|
+
type: "CLOSE"
|
|
745
|
+
}
|
|
746
|
+
};
|
|
747
|
+
}
|
|
748
|
+
function requestCloseStreamMessage(streamId) {
|
|
749
|
+
return {
|
|
750
|
+
streamId,
|
|
751
|
+
controlFlags: 16 /* StreamCloseRequestBit */,
|
|
752
|
+
payload: {
|
|
753
|
+
type: "CLOSE"
|
|
754
|
+
}
|
|
755
|
+
};
|
|
756
|
+
}
|
|
757
|
+
function abortMessage(streamId, payload) {
|
|
758
|
+
return {
|
|
759
|
+
streamId,
|
|
760
|
+
controlFlags: 4 /* StreamAbortBit */,
|
|
761
|
+
payload
|
|
762
|
+
};
|
|
763
|
+
}
|
|
1180
764
|
function isStreamOpen(controlFlag) {
|
|
1181
765
|
return (
|
|
1182
766
|
/* eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison */
|
|
@@ -1202,14 +786,11 @@ function isStreamAbort(controlFlag) {
|
|
|
1202
786
|
);
|
|
1203
787
|
}
|
|
1204
788
|
|
|
1205
|
-
// router/client.ts
|
|
1206
|
-
var import_nanoid2 = require("nanoid");
|
|
1207
|
-
|
|
1208
789
|
// tracing/index.ts
|
|
1209
790
|
var import_api = require("@opentelemetry/api");
|
|
1210
791
|
|
|
1211
792
|
// package.json
|
|
1212
|
-
var version = "0.200.0-rc.
|
|
793
|
+
var version = "0.200.0-rc.3";
|
|
1213
794
|
|
|
1214
795
|
// tracing/index.ts
|
|
1215
796
|
function getPropagationContext(ctx) {
|
|
@@ -1305,7 +886,7 @@ function createClient(transport, serverId, providedClientOptions = {}) {
|
|
|
1305
886
|
}
|
|
1306
887
|
const clientOptions = { ...defaultClientOptions, ...providedClientOptions };
|
|
1307
888
|
if (clientOptions.eagerlyConnect) {
|
|
1308
|
-
|
|
889
|
+
transport.connect(serverId);
|
|
1309
890
|
}
|
|
1310
891
|
return _createRecursiveProxy((opts) => {
|
|
1311
892
|
const [serviceName, procName, procMethod] = [...opts.path];
|
|
@@ -1315,8 +896,8 @@ function createClient(transport, serverId, providedClientOptions = {}) {
|
|
|
1315
896
|
);
|
|
1316
897
|
}
|
|
1317
898
|
const [init, callOptions] = opts.args;
|
|
1318
|
-
if (clientOptions.connectOnInvoke && !transport.
|
|
1319
|
-
|
|
899
|
+
if (clientOptions.connectOnInvoke && !transport.sessions.has(serverId)) {
|
|
900
|
+
transport.connect(serverId);
|
|
1320
901
|
}
|
|
1321
902
|
if (procMethod !== "rpc" && procMethod !== "subscribe" && procMethod !== "stream" && procMethod !== "upload") {
|
|
1322
903
|
throw new Error(
|
|
@@ -1336,7 +917,7 @@ function createClient(transport, serverId, providedClientOptions = {}) {
|
|
|
1336
917
|
}
|
|
1337
918
|
function handleProc(procType, transport, serverId, init, serviceName, procedureName, abortSignal) {
|
|
1338
919
|
const procClosesWithInit = procType === "rpc" || procType === "subscription";
|
|
1339
|
-
const streamId = (
|
|
920
|
+
const streamId = generateId();
|
|
1340
921
|
const { span, ctx } = createProcTelemetryInfo(
|
|
1341
922
|
transport,
|
|
1342
923
|
procType,
|
|
@@ -1356,14 +937,14 @@ function handleProc(procType, transport, serverId, init, serviceName, procedureN
|
|
|
1356
937
|
inputWriter.onClose(() => {
|
|
1357
938
|
span.addEvent("inputWriter closed");
|
|
1358
939
|
if (!procClosesWithInit && cleanClose) {
|
|
1359
|
-
transport.
|
|
940
|
+
transport.send(serverId, closeStreamMessage(streamId));
|
|
1360
941
|
}
|
|
1361
942
|
if (outputReader.isClosed()) {
|
|
1362
943
|
cleanup();
|
|
1363
944
|
}
|
|
1364
945
|
});
|
|
1365
946
|
const outputReader = new ReadStreamImpl(() => {
|
|
1366
|
-
transport.
|
|
947
|
+
transport.send(serverId, requestCloseStreamMessage(streamId));
|
|
1367
948
|
});
|
|
1368
949
|
outputReader.onClose(() => {
|
|
1369
950
|
span.addEvent("outputReader closed");
|
|
@@ -1393,13 +974,15 @@ function handleProc(procType, transport, serverId, init, serviceName, procedureN
|
|
|
1393
974
|
outputReader.triggerClose();
|
|
1394
975
|
}
|
|
1395
976
|
inputWriter.close();
|
|
1396
|
-
transport.
|
|
977
|
+
transport.send(
|
|
1397
978
|
serverId,
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
979
|
+
abortMessage(
|
|
980
|
+
streamId,
|
|
981
|
+
Err({
|
|
982
|
+
code: ABORT_CODE,
|
|
983
|
+
message: "Aborted by client"
|
|
984
|
+
})
|
|
985
|
+
)
|
|
1403
986
|
);
|
|
1404
987
|
}
|
|
1405
988
|
function onMessage(msg) {
|
|
@@ -1638,6 +1221,7 @@ var RiverServer = class {
|
|
|
1638
1221
|
controlFlags,
|
|
1639
1222
|
initPayload,
|
|
1640
1223
|
from,
|
|
1224
|
+
sessionId,
|
|
1641
1225
|
tracingCtx
|
|
1642
1226
|
}) {
|
|
1643
1227
|
this.openStreams.add(streamId);
|
|
@@ -1788,7 +1372,7 @@ var RiverServer = class {
|
|
|
1788
1372
|
onFinishedCallbacks.length = 0;
|
|
1789
1373
|
};
|
|
1790
1374
|
const inputReader = new ReadStreamImpl(() => {
|
|
1791
|
-
this.transport.
|
|
1375
|
+
this.transport.send(from, requestCloseStreamMessage(streamId));
|
|
1792
1376
|
});
|
|
1793
1377
|
inputReader.onClose(() => {
|
|
1794
1378
|
if (outputWriter.isClosed()) {
|
|
@@ -1805,7 +1389,7 @@ var RiverServer = class {
|
|
|
1805
1389
|
});
|
|
1806
1390
|
outputWriter.onClose(() => {
|
|
1807
1391
|
if (!procClosesWithResponse && cleanClose) {
|
|
1808
|
-
this.transport.
|
|
1392
|
+
this.transport.send(from, closeStreamMessage(streamId));
|
|
1809
1393
|
}
|
|
1810
1394
|
if (inputReader.isClosed()) {
|
|
1811
1395
|
cleanup();
|
|
@@ -1833,6 +1417,7 @@ var RiverServer = class {
|
|
|
1833
1417
|
const serviceContextWithTransportInfo = {
|
|
1834
1418
|
...this.getContext(service, serviceName),
|
|
1835
1419
|
from,
|
|
1420
|
+
sessionId,
|
|
1836
1421
|
metadata: sessionMetadata,
|
|
1837
1422
|
abortController: handlerAbortController,
|
|
1838
1423
|
clientAbortSignal: clientAbortController.signal,
|
|
@@ -1988,7 +1573,9 @@ var RiverServer = class {
|
|
|
1988
1573
|
);
|
|
1989
1574
|
return null;
|
|
1990
1575
|
}
|
|
1991
|
-
const sessionMetadata = this.transport.sessionHandshakeMetadata.get(
|
|
1576
|
+
const sessionMetadata = this.transport.sessionHandshakeMetadata.get(
|
|
1577
|
+
session.to
|
|
1578
|
+
);
|
|
1992
1579
|
if (!sessionMetadata) {
|
|
1993
1580
|
const errMessage = `session doesn't have handshake metadata`;
|
|
1994
1581
|
this.log?.error(errMessage, {
|
|
@@ -2129,7 +1716,8 @@ var RiverServer = class {
|
|
|
2129
1716
|
controlFlags: initMessage.controlFlags,
|
|
2130
1717
|
tracingCtx: initMessage.tracing,
|
|
2131
1718
|
initPayload: initMessage.payload,
|
|
2132
|
-
from: initMessage.from
|
|
1719
|
+
from: initMessage.from,
|
|
1720
|
+
sessionId: session.id
|
|
2133
1721
|
};
|
|
2134
1722
|
}
|
|
2135
1723
|
abortStream(to, streamId, payload) {
|
|
@@ -2139,7 +1727,7 @@ var RiverServer = class {
|
|
|
2139
1727
|
this.serverAbortedStreams.set(to, abortedForSession);
|
|
2140
1728
|
}
|
|
2141
1729
|
abortedForSession.add(streamId);
|
|
2142
|
-
this.transport.
|
|
1730
|
+
this.transport.send(to, abortMessage(streamId, payload));
|
|
2143
1731
|
}
|
|
2144
1732
|
};
|
|
2145
1733
|
var LRUSet = class {
|
|
@@ -2197,7 +1785,6 @@ function createServerHandshakeOptions(schema, validate) {
|
|
|
2197
1785
|
createClientHandshakeOptions,
|
|
2198
1786
|
createServer,
|
|
2199
1787
|
createServerHandshakeOptions,
|
|
2200
|
-
diffServerSchema,
|
|
2201
1788
|
serializeSchema
|
|
2202
1789
|
});
|
|
2203
1790
|
//# sourceMappingURL=index.cjs.map
|