@itookit/dsht 0.6.9 → 0.6.10
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/dist/transport/events.js +10 -3
- package/package.json +1 -1
package/dist/transport/events.js
CHANGED
|
@@ -44,10 +44,13 @@ export function controlFrame(value) {
|
|
|
44
44
|
const frame = object(value);
|
|
45
45
|
if (frame.type === 'baseline') {
|
|
46
46
|
const baseline = object(frame.value);
|
|
47
|
-
|
|
47
|
+
// The baseline's sections are capabilities, not a fixed schema: a host that reports no queue or
|
|
48
|
+
// job stream simply omits them, and demanding the newer three-section shape would discard the
|
|
49
|
+
// projection snapshot those hosts do send. An absent section is empty, not an error.
|
|
50
|
+
const projections = optionalRows(baseline.projections)
|
|
48
51
|
.map(([id, snapshot]) => [id, projectionSnapshot(snapshot)]);
|
|
49
|
-
const queues =
|
|
50
|
-
const jobs =
|
|
52
|
+
const queues = optionalRows(baseline.queues).map(([id, items]) => [id, queuedInputs(items)]);
|
|
53
|
+
const jobs = optionalRows(baseline.jobs).map(([id, items]) => [id, activeJobs(items)]);
|
|
51
54
|
return { kind: 'baseline', projections: new Map(projections), queues: new Map(queues), jobs: new Map(jobs) };
|
|
52
55
|
}
|
|
53
56
|
if (frame.type === 'projection' || frame.type === 'queue' || frame.type === 'jobs') {
|
|
@@ -64,6 +67,10 @@ export function controlFrame(value) {
|
|
|
64
67
|
}
|
|
65
68
|
throw new Error('Unknown session control frame');
|
|
66
69
|
}
|
|
70
|
+
/** Read a baseline section that a host may not provide, as an empty list rather than a throw. */
|
|
71
|
+
function optionalRows(value) {
|
|
72
|
+
return value === undefined ? [] : Object.entries(object(value));
|
|
73
|
+
}
|
|
67
74
|
/** Read a possibly-absent string field without turning protocol drift into a throw. */
|
|
68
75
|
function optionalString(value) {
|
|
69
76
|
return typeof value === 'string' ? value : undefined;
|