@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
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ControlMessageCloseSchema,
|
|
3
3
|
ControlMessagePayloadSchema,
|
|
4
|
+
abortMessage,
|
|
5
|
+
closeStreamMessage,
|
|
4
6
|
coerceErrorString,
|
|
5
7
|
createHandlerSpan,
|
|
6
8
|
createProcTelemetryInfo,
|
|
9
|
+
generateId,
|
|
7
10
|
getPropagationContext,
|
|
8
11
|
isStreamAbort,
|
|
9
12
|
isStreamClose,
|
|
10
13
|
isStreamCloseRequest,
|
|
11
|
-
isStreamOpen
|
|
12
|
-
|
|
14
|
+
isStreamOpen,
|
|
15
|
+
requestCloseStreamMessage
|
|
16
|
+
} from "./chunk-3CCOX55A.js";
|
|
13
17
|
|
|
14
18
|
// router/services.ts
|
|
15
19
|
import { Type } from "@sinclair/typebox";
|
|
@@ -213,468 +217,6 @@ var ServiceScaffold = class {
|
|
|
213
217
|
}
|
|
214
218
|
};
|
|
215
219
|
|
|
216
|
-
// router/diff.ts
|
|
217
|
-
function diffServerSchema(oldServer, newServer, options) {
|
|
218
|
-
const allServices = /* @__PURE__ */ new Set([
|
|
219
|
-
...Object.keys(oldServer.services),
|
|
220
|
-
...Object.keys(newServer.services)
|
|
221
|
-
]);
|
|
222
|
-
const breakages = {};
|
|
223
|
-
for (const serviceName of allServices) {
|
|
224
|
-
const oldService = oldServer.services[serviceName];
|
|
225
|
-
const newService = newServer.services[serviceName];
|
|
226
|
-
const breakage = diffService(oldService, newService, options);
|
|
227
|
-
if (breakage) {
|
|
228
|
-
breakages[serviceName] = breakage;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
if (Object.keys(breakages).length) {
|
|
232
|
-
return { serviceBreakages: breakages };
|
|
233
|
-
}
|
|
234
|
-
return null;
|
|
235
|
-
}
|
|
236
|
-
function diffService(oldService, newService, options) {
|
|
237
|
-
if (!newService) {
|
|
238
|
-
return options?.allowServiceRemoval ? null : { reason: "removed" };
|
|
239
|
-
}
|
|
240
|
-
if (!oldService) {
|
|
241
|
-
return null;
|
|
242
|
-
}
|
|
243
|
-
const allProcedures = /* @__PURE__ */ new Set([
|
|
244
|
-
...Object.keys(oldService.procedures),
|
|
245
|
-
...Object.keys(newService.procedures)
|
|
246
|
-
]);
|
|
247
|
-
const breakages = {};
|
|
248
|
-
for (const procedureName of allProcedures) {
|
|
249
|
-
const aProcedure = oldService.procedures[procedureName];
|
|
250
|
-
const bProcedure = newService.procedures[procedureName];
|
|
251
|
-
const breakage = diffProcedure(aProcedure, bProcedure, options);
|
|
252
|
-
if (breakage) {
|
|
253
|
-
breakages[procedureName] = breakage;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
if (Object.keys(breakages).length) {
|
|
257
|
-
return { reason: "modified", procedureBreakages: breakages };
|
|
258
|
-
}
|
|
259
|
-
return null;
|
|
260
|
-
}
|
|
261
|
-
function diffProcedure(oldProcedure, newProcedure, options) {
|
|
262
|
-
if (!newProcedure) {
|
|
263
|
-
return options?.allowProcedureRemoval ? null : { reason: "removed" };
|
|
264
|
-
}
|
|
265
|
-
if (!oldProcedure) {
|
|
266
|
-
return null;
|
|
267
|
-
}
|
|
268
|
-
if (oldProcedure.type !== newProcedure.type) {
|
|
269
|
-
return {
|
|
270
|
-
reason: "type-changed",
|
|
271
|
-
oldType: oldProcedure.type,
|
|
272
|
-
newType: newProcedure.type
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
|
-
const inputBreakage = diffProcedureField(
|
|
276
|
-
oldProcedure.input,
|
|
277
|
-
newProcedure.input,
|
|
278
|
-
"client"
|
|
279
|
-
);
|
|
280
|
-
const initBreakage = diffProcedureField(
|
|
281
|
-
oldProcedure.init,
|
|
282
|
-
newProcedure.init,
|
|
283
|
-
"client"
|
|
284
|
-
);
|
|
285
|
-
const outputBreakage = diffProcedureField(
|
|
286
|
-
oldProcedure.output,
|
|
287
|
-
newProcedure.output,
|
|
288
|
-
"server"
|
|
289
|
-
);
|
|
290
|
-
if (inputBreakage ?? initBreakage ?? outputBreakage) {
|
|
291
|
-
const result = {
|
|
292
|
-
reason: "modified"
|
|
293
|
-
};
|
|
294
|
-
if (inputBreakage) {
|
|
295
|
-
result.input = inputBreakage;
|
|
296
|
-
}
|
|
297
|
-
if (initBreakage) {
|
|
298
|
-
result.init = initBreakage;
|
|
299
|
-
}
|
|
300
|
-
if (outputBreakage) {
|
|
301
|
-
result.output = outputBreakage;
|
|
302
|
-
}
|
|
303
|
-
return result;
|
|
304
|
-
}
|
|
305
|
-
return null;
|
|
306
|
-
}
|
|
307
|
-
function diffProcedureField(oldSchema, newSchema, origin) {
|
|
308
|
-
if (!oldSchema && !newSchema) {
|
|
309
|
-
return null;
|
|
310
|
-
}
|
|
311
|
-
const diffBreakage = diffRequired(oldSchema, newSchema, origin, false, false);
|
|
312
|
-
if (diffBreakage) {
|
|
313
|
-
return diffBreakage;
|
|
314
|
-
}
|
|
315
|
-
if (!oldSchema || !newSchema) {
|
|
316
|
-
throw new Error("Appease typescript, this should never happen");
|
|
317
|
-
}
|
|
318
|
-
return diffJSONSchema(oldSchema, newSchema, origin);
|
|
319
|
-
}
|
|
320
|
-
function diffRequired(oldSchema, newSchema, origin, oldRequired, newRequired) {
|
|
321
|
-
if (!newSchema && !oldSchema) {
|
|
322
|
-
throw new Error("Both old and new schema are undefined");
|
|
323
|
-
}
|
|
324
|
-
if (!newSchema) {
|
|
325
|
-
if (!oldRequired && origin == "server") {
|
|
326
|
-
return null;
|
|
327
|
-
}
|
|
328
|
-
return { reason: "removed-required" };
|
|
329
|
-
}
|
|
330
|
-
if (!oldSchema) {
|
|
331
|
-
if (newRequired && origin === "client") {
|
|
332
|
-
return { reason: "new-required" };
|
|
333
|
-
}
|
|
334
|
-
return null;
|
|
335
|
-
}
|
|
336
|
-
if (origin === "client" && !oldRequired && newRequired) {
|
|
337
|
-
return { reason: "new-required" };
|
|
338
|
-
}
|
|
339
|
-
if (origin === "server" && oldRequired && !newRequired) {
|
|
340
|
-
return { reason: "removed-required" };
|
|
341
|
-
}
|
|
342
|
-
return null;
|
|
343
|
-
}
|
|
344
|
-
function diffJSONSchema(oldSchema, newSchema, origin) {
|
|
345
|
-
if (oldSchema.type !== newSchema.type) {
|
|
346
|
-
return {
|
|
347
|
-
reason: "type-changed",
|
|
348
|
-
oldType: getReportingType(oldSchema),
|
|
349
|
-
newType: getReportingType(newSchema)
|
|
350
|
-
};
|
|
351
|
-
}
|
|
352
|
-
if (getReportingType(oldSchema) !== getReportingType(newSchema)) {
|
|
353
|
-
return {
|
|
354
|
-
reason: "type-changed",
|
|
355
|
-
oldType: getReportingType(oldSchema),
|
|
356
|
-
newType: getReportingType(newSchema)
|
|
357
|
-
};
|
|
358
|
-
}
|
|
359
|
-
if ("const" in oldSchema && "const" in newSchema && oldSchema.const !== newSchema.const) {
|
|
360
|
-
return {
|
|
361
|
-
reason: "type-changed",
|
|
362
|
-
oldType: `${getReportingType(oldSchema)}-const-${oldSchema.const}`,
|
|
363
|
-
newType: `${getReportingType(newSchema)}-const-${newSchema.const}`
|
|
364
|
-
};
|
|
365
|
-
}
|
|
366
|
-
if ("const" in oldSchema && !("const" in newSchema) && origin === "server") {
|
|
367
|
-
return {
|
|
368
|
-
reason: "type-changed",
|
|
369
|
-
oldType: `${getReportingType(oldSchema)}-const-${oldSchema.const}`,
|
|
370
|
-
newType: getReportingType(newSchema)
|
|
371
|
-
};
|
|
372
|
-
}
|
|
373
|
-
if ("const" in newSchema && !("const" in oldSchema) && origin === "client") {
|
|
374
|
-
return {
|
|
375
|
-
reason: "type-changed",
|
|
376
|
-
oldType: getReportingType(oldSchema),
|
|
377
|
-
newType: `${getReportingType(newSchema)}-const-${newSchema.const}`
|
|
378
|
-
};
|
|
379
|
-
}
|
|
380
|
-
const breakages = {};
|
|
381
|
-
if ("$ref" in newSchema) {
|
|
382
|
-
if (newSchema.$ref !== oldSchema.$ref) {
|
|
383
|
-
return {
|
|
384
|
-
reason: "type-changed",
|
|
385
|
-
oldType: getReportingType(oldSchema),
|
|
386
|
-
newType: getReportingType(newSchema)
|
|
387
|
-
};
|
|
388
|
-
}
|
|
389
|
-
} else if ("not" in newSchema) {
|
|
390
|
-
const notBreakage = diffJSONSchema(
|
|
391
|
-
oldSchema.not,
|
|
392
|
-
newSchema.not,
|
|
393
|
-
origin
|
|
394
|
-
);
|
|
395
|
-
if (notBreakage) {
|
|
396
|
-
breakages.not = notBreakage;
|
|
397
|
-
}
|
|
398
|
-
} else if ("anyOf" in newSchema) {
|
|
399
|
-
const oldAnyOfStringified = oldSchema.anyOf.map((el) => JSON.stringify(el)).sort();
|
|
400
|
-
const newAnyOfStringified = newSchema.anyOf.map((el) => JSON.stringify(el)).sort();
|
|
401
|
-
const anyOfBreakages = {};
|
|
402
|
-
for (let i = 0; i < oldAnyOfStringified.length; i++) {
|
|
403
|
-
if (newAnyOfStringified.includes(oldAnyOfStringified[i])) {
|
|
404
|
-
continue;
|
|
405
|
-
}
|
|
406
|
-
if (!newAnyOfStringified[i]) {
|
|
407
|
-
if (origin === "server") {
|
|
408
|
-
continue;
|
|
409
|
-
}
|
|
410
|
-
anyOfBreakages[`old-${i}`] = { reason: "removed-required" };
|
|
411
|
-
} else {
|
|
412
|
-
const breakage = diffJSONSchema(
|
|
413
|
-
JSON.parse(oldAnyOfStringified[i]),
|
|
414
|
-
JSON.parse(newAnyOfStringified[i]),
|
|
415
|
-
origin
|
|
416
|
-
);
|
|
417
|
-
if (breakage) {
|
|
418
|
-
anyOfBreakages[`old-${i}`] = breakage;
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
for (let i = 0; i < newAnyOfStringified.length; i++) {
|
|
423
|
-
if (oldAnyOfStringified.includes(newAnyOfStringified[i])) {
|
|
424
|
-
continue;
|
|
425
|
-
}
|
|
426
|
-
if (!oldAnyOfStringified[i]) {
|
|
427
|
-
if (origin === "client") {
|
|
428
|
-
continue;
|
|
429
|
-
}
|
|
430
|
-
anyOfBreakages[`new-${i}`] = { reason: "new-required" };
|
|
431
|
-
} else {
|
|
432
|
-
const breakage = diffJSONSchema(
|
|
433
|
-
JSON.parse(oldAnyOfStringified[i]),
|
|
434
|
-
JSON.parse(newAnyOfStringified[i]),
|
|
435
|
-
origin
|
|
436
|
-
);
|
|
437
|
-
if (breakage) {
|
|
438
|
-
anyOfBreakages[`new-${i}`] = breakage;
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
if (Object.keys(anyOfBreakages).length > 0) {
|
|
443
|
-
breakages.anyOf = {
|
|
444
|
-
reason: "field-breakage",
|
|
445
|
-
fieldBreakages: anyOfBreakages
|
|
446
|
-
};
|
|
447
|
-
}
|
|
448
|
-
} else if ("oneOf" in newSchema) {
|
|
449
|
-
throw new Error("oneOf is not supported, typebox does not emit it");
|
|
450
|
-
} else if ("allOf" in newSchema) {
|
|
451
|
-
if (newSchema.allOf.length !== oldSchema.allOf.length) {
|
|
452
|
-
breakages.allOf = {
|
|
453
|
-
reason: "type-changed",
|
|
454
|
-
oldType: `${oldSchema.allOf}`,
|
|
455
|
-
newType: `${newSchema.allOf}`
|
|
456
|
-
};
|
|
457
|
-
} else {
|
|
458
|
-
for (let i = 0; i < newSchema.allOf.length; i++) {
|
|
459
|
-
const breakage = diffJSONSchema(
|
|
460
|
-
oldSchema.allOf[i],
|
|
461
|
-
newSchema.allOf[i],
|
|
462
|
-
origin
|
|
463
|
-
);
|
|
464
|
-
if (breakage) {
|
|
465
|
-
breakages.allOf = breakage;
|
|
466
|
-
break;
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
} else if (newSchema.type === "array") {
|
|
471
|
-
const itemsBreakages = diffJSONSchema(
|
|
472
|
-
oldSchema.items,
|
|
473
|
-
newSchema.items,
|
|
474
|
-
origin
|
|
475
|
-
);
|
|
476
|
-
if (itemsBreakages) {
|
|
477
|
-
breakages.items = itemsBreakages;
|
|
478
|
-
}
|
|
479
|
-
if (oldSchema.minItems < newSchema.minItems) {
|
|
480
|
-
if (origin === "client") {
|
|
481
|
-
breakages.minItems = {
|
|
482
|
-
reason: "type-changed",
|
|
483
|
-
oldType: `${oldSchema.minItems}`,
|
|
484
|
-
newType: `${newSchema.minItems}`
|
|
485
|
-
};
|
|
486
|
-
}
|
|
487
|
-
} else if (oldSchema.minItems > newSchema.minItems) {
|
|
488
|
-
if (origin === "server") {
|
|
489
|
-
breakages.minItems = {
|
|
490
|
-
reason: "type-changed",
|
|
491
|
-
oldType: `${oldSchema.minItems}`,
|
|
492
|
-
newType: `${newSchema.minItems}`
|
|
493
|
-
};
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
if (oldSchema.maxItems < newSchema.maxItems) {
|
|
497
|
-
if (origin === "server") {
|
|
498
|
-
breakages.maxItems = {
|
|
499
|
-
reason: "type-changed",
|
|
500
|
-
oldType: `${oldSchema.maxItems}`,
|
|
501
|
-
newType: `${newSchema.maxItems}`
|
|
502
|
-
};
|
|
503
|
-
}
|
|
504
|
-
} else if (oldSchema.maxItems > newSchema.maxItems) {
|
|
505
|
-
if (origin === "client") {
|
|
506
|
-
breakages.maxItems = {
|
|
507
|
-
reason: "type-changed",
|
|
508
|
-
oldType: `${oldSchema.maxItems}`,
|
|
509
|
-
newType: `${newSchema.maxItems}`
|
|
510
|
-
};
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
if (!oldSchema.uniqueItems && newSchema.uniqueItems && origin === "client") {
|
|
514
|
-
breakages.uniqueItems = {
|
|
515
|
-
reason: "type-changed",
|
|
516
|
-
oldType: `${!!oldSchema.uniqueItems}`,
|
|
517
|
-
newType: `${!!newSchema.uniqueItems}`
|
|
518
|
-
};
|
|
519
|
-
}
|
|
520
|
-
if ("contains" in newSchema !== "contains" in oldSchema) {
|
|
521
|
-
if ("contains" in newSchema && !("contains" in oldSchema) && origin === "client") {
|
|
522
|
-
breakages.contains = {
|
|
523
|
-
reason: "type-changed",
|
|
524
|
-
oldType: "no-contains",
|
|
525
|
-
newType: "contains"
|
|
526
|
-
};
|
|
527
|
-
}
|
|
528
|
-
} else if ("contains" in newSchema) {
|
|
529
|
-
const containsBreakage = diffJSONSchema(
|
|
530
|
-
oldSchema.contains,
|
|
531
|
-
newSchema.contains,
|
|
532
|
-
origin
|
|
533
|
-
);
|
|
534
|
-
if (containsBreakage) {
|
|
535
|
-
breakages.contains = containsBreakage;
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
if (oldSchema.minContains < newSchema.minContains) {
|
|
539
|
-
if (origin === "client") {
|
|
540
|
-
breakages.minContains = {
|
|
541
|
-
reason: "type-changed",
|
|
542
|
-
oldType: `${oldSchema.minContains}`,
|
|
543
|
-
newType: `${newSchema.minContains}`
|
|
544
|
-
};
|
|
545
|
-
}
|
|
546
|
-
} else if (oldSchema.minContains > newSchema.minContains) {
|
|
547
|
-
if (origin === "server") {
|
|
548
|
-
breakages.minContains = {
|
|
549
|
-
reason: "type-changed",
|
|
550
|
-
oldType: `${oldSchema.minContains}`,
|
|
551
|
-
newType: `${newSchema.minContains}`
|
|
552
|
-
};
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
if (oldSchema.maxContains < newSchema.maxContains) {
|
|
556
|
-
if (origin === "server") {
|
|
557
|
-
breakages.maxContains = {
|
|
558
|
-
reason: "type-changed",
|
|
559
|
-
oldType: `${oldSchema.maxContains}`,
|
|
560
|
-
newType: `${newSchema.maxContains}`
|
|
561
|
-
};
|
|
562
|
-
}
|
|
563
|
-
} else if (oldSchema.maxContains > newSchema.maxContains) {
|
|
564
|
-
if (origin === "client") {
|
|
565
|
-
breakages.maxContains = {
|
|
566
|
-
reason: "type-changed",
|
|
567
|
-
oldType: `${oldSchema.maxContains}`,
|
|
568
|
-
newType: `${newSchema.maxContains}`
|
|
569
|
-
};
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
} else if (newSchema.type === "object") {
|
|
573
|
-
if ("properties" in newSchema !== "properties" in oldSchema) {
|
|
574
|
-
return {
|
|
575
|
-
reason: "type-changed",
|
|
576
|
-
oldType: "properties" in oldSchema ? "probably-object" : "probably-record",
|
|
577
|
-
newType: "properties" in newSchema ? "probably-object" : "probably-record"
|
|
578
|
-
};
|
|
579
|
-
}
|
|
580
|
-
if ("properties" in newSchema) {
|
|
581
|
-
const propertiesBreakages = diffObjectProperties(
|
|
582
|
-
oldSchema.properties,
|
|
583
|
-
newSchema.properties,
|
|
584
|
-
origin,
|
|
585
|
-
oldSchema.required,
|
|
586
|
-
newSchema.required
|
|
587
|
-
);
|
|
588
|
-
if (Object.keys(propertiesBreakages).length) {
|
|
589
|
-
breakages.properties = {
|
|
590
|
-
reason: "field-breakage",
|
|
591
|
-
fieldBreakages: propertiesBreakages
|
|
592
|
-
};
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
if ("patternProperties" in newSchema) {
|
|
596
|
-
const patternPropertiesBreakages = diffObjectProperties(
|
|
597
|
-
oldSchema.patternProperties,
|
|
598
|
-
newSchema.patternProperties,
|
|
599
|
-
origin,
|
|
600
|
-
oldSchema.required,
|
|
601
|
-
newSchema.required
|
|
602
|
-
);
|
|
603
|
-
if (Object.keys(patternPropertiesBreakages).length) {
|
|
604
|
-
breakages.patternProperties = {
|
|
605
|
-
reason: "field-breakage",
|
|
606
|
-
fieldBreakages: patternPropertiesBreakages
|
|
607
|
-
};
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
if ("additionalProperties" in newSchema || "additionalProperties" in oldSchema) {
|
|
611
|
-
throw new Error("additionalProperties is not supported");
|
|
612
|
-
}
|
|
613
|
-
if ("minProperties" in newSchema || "minProperties" in oldSchema) {
|
|
614
|
-
throw new Error("minProperties is not supported");
|
|
615
|
-
}
|
|
616
|
-
if ("maxProperties" in newSchema || "maxProperties" in oldSchema) {
|
|
617
|
-
throw new Error("maxProperties is not supported");
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
if (Object.keys(breakages).length) {
|
|
621
|
-
return {
|
|
622
|
-
reason: "field-breakage",
|
|
623
|
-
fieldBreakages: breakages
|
|
624
|
-
};
|
|
625
|
-
}
|
|
626
|
-
return null;
|
|
627
|
-
}
|
|
628
|
-
function diffObjectProperties(oldProperties, newProperties, origin, oldRequiredProperties = [], newRequiredProperties = []) {
|
|
629
|
-
const allProperties = /* @__PURE__ */ new Set([
|
|
630
|
-
...Object.keys(oldProperties),
|
|
631
|
-
...Object.keys(newProperties)
|
|
632
|
-
]);
|
|
633
|
-
const breakages = {};
|
|
634
|
-
for (const propertyName of allProperties) {
|
|
635
|
-
const requiredBreakage = diffRequired(
|
|
636
|
-
oldProperties[propertyName],
|
|
637
|
-
newProperties[propertyName],
|
|
638
|
-
origin,
|
|
639
|
-
oldRequiredProperties.includes(propertyName),
|
|
640
|
-
newRequiredProperties.includes(propertyName)
|
|
641
|
-
);
|
|
642
|
-
if (requiredBreakage) {
|
|
643
|
-
breakages[propertyName] = requiredBreakage;
|
|
644
|
-
} else if (oldProperties[propertyName] && newProperties[propertyName]) {
|
|
645
|
-
const propertyBreakage = diffJSONSchema(
|
|
646
|
-
oldProperties[propertyName],
|
|
647
|
-
newProperties[propertyName],
|
|
648
|
-
origin
|
|
649
|
-
);
|
|
650
|
-
if (propertyBreakage) {
|
|
651
|
-
breakages[propertyName] = propertyBreakage;
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
return breakages;
|
|
656
|
-
}
|
|
657
|
-
function getReportingType(schema) {
|
|
658
|
-
if ("not" in schema) {
|
|
659
|
-
return "not";
|
|
660
|
-
}
|
|
661
|
-
if ("anyOf" in schema) {
|
|
662
|
-
return "anyOf";
|
|
663
|
-
}
|
|
664
|
-
if ("allOf" in schema) {
|
|
665
|
-
return "allOf";
|
|
666
|
-
}
|
|
667
|
-
if ("$ref" in schema) {
|
|
668
|
-
return "$ref";
|
|
669
|
-
}
|
|
670
|
-
if (schema.type && typeof schema.type === "string") {
|
|
671
|
-
return schema.type;
|
|
672
|
-
}
|
|
673
|
-
throw new Error(
|
|
674
|
-
"Subschema not supported, probably a conditional subschema. Check logs."
|
|
675
|
-
);
|
|
676
|
-
}
|
|
677
|
-
|
|
678
220
|
// router/result.ts
|
|
679
221
|
import {
|
|
680
222
|
Type as Type2
|
|
@@ -1082,7 +624,6 @@ var Procedure = {
|
|
|
1082
624
|
};
|
|
1083
625
|
|
|
1084
626
|
// router/client.ts
|
|
1085
|
-
import { nanoid } from "nanoid";
|
|
1086
627
|
import { Value } from "@sinclair/typebox/value";
|
|
1087
628
|
var OutputErrResultSchema = ErrResultSchema(OutputReaderErrorSchema);
|
|
1088
629
|
var noop = () => {
|
|
@@ -1115,7 +656,7 @@ function createClient(transport, serverId, providedClientOptions = {}) {
|
|
|
1115
656
|
}
|
|
1116
657
|
const clientOptions = { ...defaultClientOptions, ...providedClientOptions };
|
|
1117
658
|
if (clientOptions.eagerlyConnect) {
|
|
1118
|
-
|
|
659
|
+
transport.connect(serverId);
|
|
1119
660
|
}
|
|
1120
661
|
return _createRecursiveProxy((opts) => {
|
|
1121
662
|
const [serviceName, procName, procMethod] = [...opts.path];
|
|
@@ -1125,8 +666,8 @@ function createClient(transport, serverId, providedClientOptions = {}) {
|
|
|
1125
666
|
);
|
|
1126
667
|
}
|
|
1127
668
|
const [init, callOptions] = opts.args;
|
|
1128
|
-
if (clientOptions.connectOnInvoke && !transport.
|
|
1129
|
-
|
|
669
|
+
if (clientOptions.connectOnInvoke && !transport.sessions.has(serverId)) {
|
|
670
|
+
transport.connect(serverId);
|
|
1130
671
|
}
|
|
1131
672
|
if (procMethod !== "rpc" && procMethod !== "subscribe" && procMethod !== "stream" && procMethod !== "upload") {
|
|
1132
673
|
throw new Error(
|
|
@@ -1146,7 +687,7 @@ function createClient(transport, serverId, providedClientOptions = {}) {
|
|
|
1146
687
|
}
|
|
1147
688
|
function handleProc(procType, transport, serverId, init, serviceName, procedureName, abortSignal) {
|
|
1148
689
|
const procClosesWithInit = procType === "rpc" || procType === "subscription";
|
|
1149
|
-
const streamId =
|
|
690
|
+
const streamId = generateId();
|
|
1150
691
|
const { span, ctx } = createProcTelemetryInfo(
|
|
1151
692
|
transport,
|
|
1152
693
|
procType,
|
|
@@ -1166,14 +707,14 @@ function handleProc(procType, transport, serverId, init, serviceName, procedureN
|
|
|
1166
707
|
inputWriter.onClose(() => {
|
|
1167
708
|
span.addEvent("inputWriter closed");
|
|
1168
709
|
if (!procClosesWithInit && cleanClose) {
|
|
1169
|
-
transport.
|
|
710
|
+
transport.send(serverId, closeStreamMessage(streamId));
|
|
1170
711
|
}
|
|
1171
712
|
if (outputReader.isClosed()) {
|
|
1172
713
|
cleanup();
|
|
1173
714
|
}
|
|
1174
715
|
});
|
|
1175
716
|
const outputReader = new ReadStreamImpl(() => {
|
|
1176
|
-
transport.
|
|
717
|
+
transport.send(serverId, requestCloseStreamMessage(streamId));
|
|
1177
718
|
});
|
|
1178
719
|
outputReader.onClose(() => {
|
|
1179
720
|
span.addEvent("outputReader closed");
|
|
@@ -1203,13 +744,15 @@ function handleProc(procType, transport, serverId, init, serviceName, procedureN
|
|
|
1203
744
|
outputReader.triggerClose();
|
|
1204
745
|
}
|
|
1205
746
|
inputWriter.close();
|
|
1206
|
-
transport.
|
|
747
|
+
transport.send(
|
|
1207
748
|
serverId,
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
749
|
+
abortMessage(
|
|
750
|
+
streamId,
|
|
751
|
+
Err({
|
|
752
|
+
code: ABORT_CODE,
|
|
753
|
+
message: "Aborted by client"
|
|
754
|
+
})
|
|
755
|
+
)
|
|
1213
756
|
);
|
|
1214
757
|
}
|
|
1215
758
|
function onMessage(msg) {
|
|
@@ -1438,6 +981,7 @@ var RiverServer = class {
|
|
|
1438
981
|
controlFlags,
|
|
1439
982
|
initPayload,
|
|
1440
983
|
from,
|
|
984
|
+
sessionId,
|
|
1441
985
|
tracingCtx
|
|
1442
986
|
}) {
|
|
1443
987
|
this.openStreams.add(streamId);
|
|
@@ -1588,7 +1132,7 @@ var RiverServer = class {
|
|
|
1588
1132
|
onFinishedCallbacks.length = 0;
|
|
1589
1133
|
};
|
|
1590
1134
|
const inputReader = new ReadStreamImpl(() => {
|
|
1591
|
-
this.transport.
|
|
1135
|
+
this.transport.send(from, requestCloseStreamMessage(streamId));
|
|
1592
1136
|
});
|
|
1593
1137
|
inputReader.onClose(() => {
|
|
1594
1138
|
if (outputWriter.isClosed()) {
|
|
@@ -1605,7 +1149,7 @@ var RiverServer = class {
|
|
|
1605
1149
|
});
|
|
1606
1150
|
outputWriter.onClose(() => {
|
|
1607
1151
|
if (!procClosesWithResponse && cleanClose) {
|
|
1608
|
-
this.transport.
|
|
1152
|
+
this.transport.send(from, closeStreamMessage(streamId));
|
|
1609
1153
|
}
|
|
1610
1154
|
if (inputReader.isClosed()) {
|
|
1611
1155
|
cleanup();
|
|
@@ -1633,6 +1177,7 @@ var RiverServer = class {
|
|
|
1633
1177
|
const serviceContextWithTransportInfo = {
|
|
1634
1178
|
...this.getContext(service, serviceName),
|
|
1635
1179
|
from,
|
|
1180
|
+
sessionId,
|
|
1636
1181
|
metadata: sessionMetadata,
|
|
1637
1182
|
abortController: handlerAbortController,
|
|
1638
1183
|
clientAbortSignal: clientAbortController.signal,
|
|
@@ -1788,7 +1333,9 @@ var RiverServer = class {
|
|
|
1788
1333
|
);
|
|
1789
1334
|
return null;
|
|
1790
1335
|
}
|
|
1791
|
-
const sessionMetadata = this.transport.sessionHandshakeMetadata.get(
|
|
1336
|
+
const sessionMetadata = this.transport.sessionHandshakeMetadata.get(
|
|
1337
|
+
session.to
|
|
1338
|
+
);
|
|
1792
1339
|
if (!sessionMetadata) {
|
|
1793
1340
|
const errMessage = `session doesn't have handshake metadata`;
|
|
1794
1341
|
this.log?.error(errMessage, {
|
|
@@ -1929,7 +1476,8 @@ var RiverServer = class {
|
|
|
1929
1476
|
controlFlags: initMessage.controlFlags,
|
|
1930
1477
|
tracingCtx: initMessage.tracing,
|
|
1931
1478
|
initPayload: initMessage.payload,
|
|
1932
|
-
from: initMessage.from
|
|
1479
|
+
from: initMessage.from,
|
|
1480
|
+
sessionId: session.id
|
|
1933
1481
|
};
|
|
1934
1482
|
}
|
|
1935
1483
|
abortStream(to, streamId, payload) {
|
|
@@ -1939,7 +1487,7 @@ var RiverServer = class {
|
|
|
1939
1487
|
this.serverAbortedStreams.set(to, abortedForSession);
|
|
1940
1488
|
}
|
|
1941
1489
|
abortedForSession.add(streamId);
|
|
1942
|
-
this.transport.
|
|
1490
|
+
this.transport.send(to, abortMessage(streamId, payload));
|
|
1943
1491
|
}
|
|
1944
1492
|
};
|
|
1945
1493
|
var LRUSet = class {
|
|
@@ -1985,7 +1533,6 @@ function createServerHandshakeOptions(schema, validate) {
|
|
|
1985
1533
|
export {
|
|
1986
1534
|
serializeSchema,
|
|
1987
1535
|
ServiceSchema,
|
|
1988
|
-
diffServerSchema,
|
|
1989
1536
|
Ok,
|
|
1990
1537
|
Err,
|
|
1991
1538
|
ReadStreamImpl,
|
|
@@ -2001,4 +1548,4 @@ export {
|
|
|
2001
1548
|
createClientHandshakeOptions,
|
|
2002
1549
|
createServerHandshakeOptions
|
|
2003
1550
|
};
|
|
2004
|
-
//# sourceMappingURL=chunk-
|
|
1551
|
+
//# sourceMappingURL=chunk-UIYGPURD.js.map
|