@dxos/echo-pipeline 0.1.52 → 0.1.53-main.01cbc6b
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/lib/browser/{chunk-AXGWKSM3.mjs → chunk-RFRZMQ5T.mjs} +444 -392
- package/dist/lib/browser/chunk-RFRZMQ5T.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +2 -2
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +3 -3
- package/dist/lib/browser/testing/index.mjs.map +2 -2
- package/dist/lib/node/index.cjs +512 -460
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +502 -450
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/types/src/dbhost/data-service-host.d.ts +3 -0
- package/dist/types/src/dbhost/data-service-host.d.ts.map +1 -1
- package/dist/types/src/dbhost/data-service.d.ts +2 -2
- package/dist/types/src/dbhost/data-service.d.ts.map +1 -1
- package/dist/types/src/dbhost/snapshot-store.d.ts +3 -0
- package/dist/types/src/dbhost/snapshot-store.d.ts.map +1 -1
- package/dist/types/src/metadata/metadata-store.d.ts +4 -0
- package/dist/types/src/metadata/metadata-store.d.ts.map +1 -1
- package/dist/types/src/pipeline/message-selector.d.ts.map +1 -1
- package/dist/types/src/pipeline/pipeline.d.ts +0 -1
- package/dist/types/src/pipeline/pipeline.d.ts.map +1 -1
- package/dist/types/src/space/data-pipeline.d.ts +3 -3
- package/dist/types/src/space/data-pipeline.d.ts.map +1 -1
- package/dist/types/src/space/space-protocol.d.ts +3 -0
- package/dist/types/src/space/space-protocol.d.ts.map +1 -1
- package/dist/types/src/space/space.d.ts +0 -1
- package/dist/types/src/space/space.d.ts.map +1 -1
- package/package.json +31 -32
- package/src/common/feeds.ts +3 -3
- package/src/dbhost/data-service-host.ts +17 -4
- package/src/dbhost/data-service.ts +10 -6
- package/src/dbhost/snapshot-store.ts +3 -0
- package/src/metadata/metadata-store.ts +20 -6
- package/src/pipeline/message-selector.ts +3 -5
- package/src/pipeline/pipeline.ts +24 -12
- package/src/space/auth.ts +3 -3
- package/src/space/data-pipeline.ts +36 -29
- package/src/space/space-protocol.browser.test.ts +2 -2
- package/src/space/space-protocol.test.ts +2 -2
- package/src/space/space-protocol.ts +10 -4
- package/src/space/space.test.ts +46 -5
- package/src/space/space.ts +8 -17
- package/src/testing/util.ts +1 -1
- package/src/tests/database.test.ts +1 -1
- package/dist/lib/browser/chunk-AXGWKSM3.mjs.map +0 -7
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import "@dxos/node-std/globals"
|
|
1
|
+
import "@dxos/node-std/globals";
|
|
2
2
|
|
|
3
3
|
// packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts
|
|
4
4
|
import CRC32 from "crc-32";
|
|
5
|
-
import
|
|
5
|
+
import invariant from "tiny-invariant";
|
|
6
6
|
import { synchronized, Event } from "@dxos/async";
|
|
7
7
|
import { DataCorruptionError } from "@dxos/errors";
|
|
8
8
|
import { log } from "@dxos/log";
|
|
9
9
|
import { STORAGE_VERSION, schema } from "@dxos/protocols";
|
|
10
|
-
|
|
10
|
+
import { SpaceState } from "@dxos/protocols/proto/dxos/client/services";
|
|
11
|
+
import { arrayToBuffer } from "@dxos/util";
|
|
12
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
11
13
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
12
14
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
13
15
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -16,13 +18,15 @@ var __decorate = function(decorators, target, key, desc) {
|
|
|
16
18
|
if (d = decorators[i])
|
|
17
19
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
18
20
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
19
|
-
}
|
|
21
|
+
}
|
|
22
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts";
|
|
20
23
|
var emptyEchoMetadata = () => ({
|
|
21
24
|
version: STORAGE_VERSION,
|
|
22
25
|
spaces: [],
|
|
23
26
|
created: new Date(),
|
|
24
27
|
updated: new Date()
|
|
25
28
|
});
|
|
29
|
+
var EchoMetadata = schema.getCodecForType("dxos.echo.metadata.EchoMetadata");
|
|
26
30
|
var MetadataStore = class {
|
|
27
31
|
// prettier-ignore
|
|
28
32
|
constructor(_directory) {
|
|
@@ -49,6 +53,7 @@ var MetadataStore = class {
|
|
|
49
53
|
* Loads metadata from persistent storage.
|
|
50
54
|
*/
|
|
51
55
|
async load() {
|
|
56
|
+
var _a;
|
|
52
57
|
const file = this._directory.getOrCreateFile("EchoMetadata");
|
|
53
58
|
try {
|
|
54
59
|
const { size: fileLength } = await file.stat();
|
|
@@ -61,10 +66,10 @@ var MetadataStore = class {
|
|
|
61
66
|
size: dataSize,
|
|
62
67
|
checksum
|
|
63
68
|
}, {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
69
|
+
F: __dxlog_file,
|
|
70
|
+
L: 72,
|
|
71
|
+
S: this,
|
|
72
|
+
C: (f, a) => f(...a)
|
|
68
73
|
});
|
|
69
74
|
if (fileLength < dataSize + 8) {
|
|
70
75
|
throw new DataCorruptionError("Metadata size is smaller than expected.");
|
|
@@ -74,15 +79,19 @@ var MetadataStore = class {
|
|
|
74
79
|
if (calculatedChecksum !== checksum) {
|
|
75
80
|
throw new DataCorruptionError("Metadata checksum is invalid.");
|
|
76
81
|
}
|
|
77
|
-
this._metadata =
|
|
82
|
+
this._metadata = EchoMetadata.decode(data);
|
|
83
|
+
(_a = this._metadata.spaces) == null ? void 0 : _a.forEach((space) => {
|
|
84
|
+
var _a2;
|
|
85
|
+
(_a2 = space.state) != null ? _a2 : space.state = SpaceState.ACTIVE;
|
|
86
|
+
});
|
|
78
87
|
} catch (err) {
|
|
79
88
|
log.error("failed to load metadata", {
|
|
80
89
|
err
|
|
81
90
|
}, {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
91
|
+
F: __dxlog_file,
|
|
92
|
+
L: 92,
|
|
93
|
+
S: this,
|
|
94
|
+
C: (f, a) => f(...a)
|
|
86
95
|
});
|
|
87
96
|
this._metadata = emptyEchoMetadata();
|
|
88
97
|
} finally {
|
|
@@ -100,7 +109,7 @@ var MetadataStore = class {
|
|
|
100
109
|
this.update.emit(data);
|
|
101
110
|
const file = this._directory.getOrCreateFile("EchoMetadata");
|
|
102
111
|
try {
|
|
103
|
-
const encoded =
|
|
112
|
+
const encoded = arrayToBuffer(EchoMetadata.encode(data));
|
|
104
113
|
const checksum = CRC32.buf(encoded);
|
|
105
114
|
const result = Buffer.alloc(8 + encoded.length);
|
|
106
115
|
result.writeInt32LE(encoded.length, 0);
|
|
@@ -111,10 +120,10 @@ var MetadataStore = class {
|
|
|
111
120
|
size: encoded.length,
|
|
112
121
|
checksum
|
|
113
122
|
}, {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
123
|
+
F: __dxlog_file,
|
|
124
|
+
L: 124,
|
|
125
|
+
S: this,
|
|
126
|
+
C: (f, a) => f(...a)
|
|
118
127
|
});
|
|
119
128
|
} finally {
|
|
120
129
|
await file.close();
|
|
@@ -126,18 +135,18 @@ var MetadataStore = class {
|
|
|
126
135
|
return this._metadata.identity.haloSpace;
|
|
127
136
|
}
|
|
128
137
|
const space = this.spaces.find((space2) => space2.key === spaceKey);
|
|
129
|
-
|
|
138
|
+
invariant(space, "Space not found");
|
|
130
139
|
return space;
|
|
131
140
|
}
|
|
132
141
|
/**
|
|
133
142
|
* Clears storage - doesn't work for now.
|
|
134
143
|
*/
|
|
135
144
|
async clear() {
|
|
136
|
-
log("clearing all metadata",
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
145
|
+
log("clearing all metadata", void 0, {
|
|
146
|
+
F: __dxlog_file,
|
|
147
|
+
L: 145,
|
|
148
|
+
S: this,
|
|
149
|
+
C: (f, a) => f(...a)
|
|
141
150
|
});
|
|
142
151
|
await this._directory.delete();
|
|
143
152
|
this._metadata = emptyEchoMetadata();
|
|
@@ -146,13 +155,13 @@ var MetadataStore = class {
|
|
|
146
155
|
return this._metadata.identity;
|
|
147
156
|
}
|
|
148
157
|
async setIdentityRecord(record) {
|
|
149
|
-
|
|
158
|
+
invariant(!this._metadata.identity, "Cannot overwrite existing identity in metadata");
|
|
150
159
|
this._metadata.identity = record;
|
|
151
160
|
await this._save();
|
|
152
161
|
}
|
|
153
162
|
async addSpace(record) {
|
|
154
163
|
var _a, _b, _c;
|
|
155
|
-
|
|
164
|
+
invariant(!((_a = this._metadata.spaces) != null ? _a : []).find((space) => space.key === record.key), "Cannot overwrite existing space in metadata");
|
|
156
165
|
((_c = (_b = this._metadata).spaces) != null ? _c : _b.spaces = []).push(record);
|
|
157
166
|
await this._save();
|
|
158
167
|
}
|
|
@@ -174,11 +183,15 @@ var MetadataStore = class {
|
|
|
174
183
|
space.dataFeedKey = dataFeedKey;
|
|
175
184
|
await this._save();
|
|
176
185
|
}
|
|
186
|
+
async setSpaceState(spaceKey, state) {
|
|
187
|
+
this._getSpace(spaceKey).state = state;
|
|
188
|
+
await this._save();
|
|
189
|
+
}
|
|
177
190
|
};
|
|
178
|
-
|
|
191
|
+
_ts_decorate([
|
|
179
192
|
synchronized
|
|
180
193
|
], MetadataStore.prototype, "load", null);
|
|
181
|
-
|
|
194
|
+
_ts_decorate([
|
|
182
195
|
synchronized
|
|
183
196
|
], MetadataStore.prototype, "_save", null);
|
|
184
197
|
var fromBytesInt32 = (buf) => buf.readInt32LE(0);
|
|
@@ -190,10 +203,10 @@ var codec = schema2.getCodecForType("dxos.echo.feed.FeedMessage");
|
|
|
190
203
|
var valueEncoding = createCodecEncoding(codec);
|
|
191
204
|
|
|
192
205
|
// packages/core/echo/echo-pipeline/src/common/feeds.ts
|
|
193
|
-
import
|
|
206
|
+
import invariant2 from "tiny-invariant";
|
|
194
207
|
var createMappedFeedWriter = (mapper, writer) => {
|
|
195
|
-
|
|
196
|
-
|
|
208
|
+
invariant2(mapper);
|
|
209
|
+
invariant2(writer);
|
|
197
210
|
return {
|
|
198
211
|
write: async (data, options) => await writer.write(await mapper(data), options)
|
|
199
212
|
};
|
|
@@ -204,7 +217,7 @@ import { Event as Event2 } from "@dxos/async";
|
|
|
204
217
|
import { timed } from "@dxos/debug";
|
|
205
218
|
import { log as log2 } from "@dxos/log";
|
|
206
219
|
import { Timeframe } from "@dxos/timeframe";
|
|
207
|
-
|
|
220
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
208
221
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
209
222
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
210
223
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -213,7 +226,8 @@ var __decorate2 = function(decorators, target, key, desc) {
|
|
|
213
226
|
if (d = decorators[i])
|
|
214
227
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
215
228
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
216
|
-
}
|
|
229
|
+
}
|
|
230
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts";
|
|
217
231
|
var mapTimeframeToFeedIndexes = (timeframe) => timeframe.frames().map(([feedKey, index]) => ({
|
|
218
232
|
feedKey,
|
|
219
233
|
index
|
|
@@ -272,10 +286,10 @@ var TimeframeClock = class {
|
|
|
272
286
|
target,
|
|
273
287
|
current: this._timeframe
|
|
274
288
|
}, {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
289
|
+
F: __dxlog_file2,
|
|
290
|
+
L: 73,
|
|
291
|
+
S: this,
|
|
292
|
+
C: (f, a) => f(...a)
|
|
279
293
|
});
|
|
280
294
|
await this.update.waitForCondition(() => {
|
|
281
295
|
log2("check if reached", {
|
|
@@ -283,21 +297,21 @@ var TimeframeClock = class {
|
|
|
283
297
|
current: this._timeframe,
|
|
284
298
|
deps: Timeframe.dependencies(target, this._timeframe)
|
|
285
299
|
}, {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
300
|
+
F: __dxlog_file2,
|
|
301
|
+
L: 75,
|
|
302
|
+
S: this,
|
|
303
|
+
C: (f, a) => f(...a)
|
|
290
304
|
});
|
|
291
305
|
return Timeframe.dependencies(target, this._timeframe).isEmpty();
|
|
292
306
|
});
|
|
293
307
|
}
|
|
294
308
|
};
|
|
295
|
-
|
|
309
|
+
_ts_decorate2([
|
|
296
310
|
timed(5e3)
|
|
297
311
|
], TimeframeClock.prototype, "waitUntilReached", null);
|
|
298
312
|
|
|
299
313
|
// packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts
|
|
300
|
-
import
|
|
314
|
+
import invariant4 from "tiny-invariant";
|
|
301
315
|
import { Event as Event3, sleep, synchronized as synchronized2, Trigger } from "@dxos/async";
|
|
302
316
|
import { Context, rejectOnDispose } from "@dxos/context";
|
|
303
317
|
import { failUndefined } from "@dxos/debug";
|
|
@@ -308,24 +322,29 @@ import { Timeframe as Timeframe2 } from "@dxos/timeframe";
|
|
|
308
322
|
import { ComplexMap } from "@dxos/util";
|
|
309
323
|
|
|
310
324
|
// packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts
|
|
311
|
-
import
|
|
312
|
-
import
|
|
313
|
-
var
|
|
325
|
+
import invariant3 from "tiny-invariant";
|
|
326
|
+
import { log as log3 } from "@dxos/log";
|
|
327
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts";
|
|
314
328
|
var createMessageSelector = (timeframeClock) => {
|
|
315
329
|
return (messages) => {
|
|
316
330
|
for (let i = 0; i < messages.length; i++) {
|
|
317
331
|
const { data: { timeframe } } = messages[i];
|
|
318
|
-
|
|
332
|
+
invariant3(timeframe);
|
|
319
333
|
if (!timeframeClock.hasGaps(timeframe)) {
|
|
320
334
|
return i;
|
|
321
335
|
}
|
|
322
336
|
}
|
|
323
|
-
log3("Skipping..."
|
|
337
|
+
log3("Skipping...", void 0, {
|
|
338
|
+
F: __dxlog_file3,
|
|
339
|
+
L: 34,
|
|
340
|
+
S: void 0,
|
|
341
|
+
C: (f, a) => f(...a)
|
|
342
|
+
});
|
|
324
343
|
};
|
|
325
344
|
};
|
|
326
345
|
|
|
327
346
|
// packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts
|
|
328
|
-
|
|
347
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
329
348
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
330
349
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
331
350
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -334,12 +353,14 @@ var __decorate3 = function(decorators, target, key, desc) {
|
|
|
334
353
|
if (d = decorators[i])
|
|
335
354
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
336
355
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
337
|
-
}
|
|
356
|
+
}
|
|
357
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts";
|
|
338
358
|
var PipelineState = class {
|
|
339
359
|
// prettier-ignore
|
|
340
360
|
constructor(_feeds, _timeframeClock) {
|
|
341
361
|
this._feeds = _feeds;
|
|
342
362
|
this._timeframeClock = _timeframeClock;
|
|
363
|
+
this._ctx = new Context();
|
|
343
364
|
this.timeframeUpdate = this._timeframeClock.update;
|
|
344
365
|
this.stalled = new Event3();
|
|
345
366
|
this._startTimeframe = new Timeframe2();
|
|
@@ -390,10 +411,10 @@ var PipelineState = class {
|
|
|
390
411
|
current: this.timeframe,
|
|
391
412
|
target: this.targetTimeframe
|
|
392
413
|
}, {
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
414
|
+
F: __dxlog_file4,
|
|
415
|
+
L: 126,
|
|
416
|
+
S: this,
|
|
417
|
+
C: (f, a) => f(...a)
|
|
397
418
|
});
|
|
398
419
|
(_a = this._reachedTargetPromise) != null ? _a : this._reachedTargetPromise = Promise.race([
|
|
399
420
|
this._timeframeClock.update.waitForCondition(() => {
|
|
@@ -407,6 +428,7 @@ var PipelineState = class {
|
|
|
407
428
|
if (timeout) {
|
|
408
429
|
return Promise.race([
|
|
409
430
|
rejectOnDispose(ctx),
|
|
431
|
+
rejectOnDispose(this._ctx),
|
|
410
432
|
this._reachedTargetPromise.then(() => {
|
|
411
433
|
done = true;
|
|
412
434
|
}),
|
|
@@ -420,10 +442,10 @@ var PipelineState = class {
|
|
|
420
442
|
target: this.targetTimeframe,
|
|
421
443
|
dependencies: Timeframe2.dependencies(this.targetTimeframe, this.timeframe)
|
|
422
444
|
}, {
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
445
|
+
F: __dxlog_file4,
|
|
446
|
+
L: 153,
|
|
447
|
+
S: this,
|
|
448
|
+
C: (f, a) => f(...a)
|
|
427
449
|
});
|
|
428
450
|
})
|
|
429
451
|
]);
|
|
@@ -450,7 +472,7 @@ var Pipeline = class {
|
|
|
450
472
|
return this._state;
|
|
451
473
|
}
|
|
452
474
|
get writer() {
|
|
453
|
-
|
|
475
|
+
invariant4(this._writer, "Writer not set.");
|
|
454
476
|
return this._writer;
|
|
455
477
|
}
|
|
456
478
|
getFeeds() {
|
|
@@ -469,8 +491,8 @@ var Pipeline = class {
|
|
|
469
491
|
return this._feeds.has(feedKey);
|
|
470
492
|
}
|
|
471
493
|
setWriteFeed(feed) {
|
|
472
|
-
|
|
473
|
-
|
|
494
|
+
invariant4(!this._writer, "Writer already set.");
|
|
495
|
+
invariant4(feed.properties.writable, "Feed must be writable.");
|
|
474
496
|
this._writer = createMappedFeedWriter((payload) => ({
|
|
475
497
|
timeframe: this._timeframeClock.timeframe,
|
|
476
498
|
payload
|
|
@@ -478,37 +500,40 @@ var Pipeline = class {
|
|
|
478
500
|
}
|
|
479
501
|
async start() {
|
|
480
502
|
log4("starting...", {}, {
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
503
|
+
F: __dxlog_file4,
|
|
504
|
+
L: 273,
|
|
505
|
+
S: this,
|
|
506
|
+
C: (f, a) => f(...a)
|
|
485
507
|
});
|
|
486
508
|
await this._initIterator();
|
|
487
509
|
await this._feedSetIterator.open();
|
|
488
|
-
log4("started",
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
510
|
+
log4("started", void 0, {
|
|
511
|
+
F: __dxlog_file4,
|
|
512
|
+
L: 276,
|
|
513
|
+
S: this,
|
|
514
|
+
C: (f, a) => f(...a)
|
|
493
515
|
});
|
|
494
516
|
this._isStarted = true;
|
|
495
517
|
}
|
|
496
518
|
async stop() {
|
|
497
519
|
var _a;
|
|
498
520
|
log4("stopping...", {}, {
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
521
|
+
F: __dxlog_file4,
|
|
522
|
+
L: 282,
|
|
523
|
+
S: this,
|
|
524
|
+
C: (f, a) => f(...a)
|
|
503
525
|
});
|
|
504
526
|
this._isStopping = true;
|
|
505
527
|
await ((_a = this._feedSetIterator) == null ? void 0 : _a.close());
|
|
506
528
|
await this._processingTrigger.wait();
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
529
|
+
await this._state._ctx.dispose();
|
|
530
|
+
this._state._ctx = new Context();
|
|
531
|
+
this._state._reachedTargetPromise = void 0;
|
|
532
|
+
log4("stopped", void 0, {
|
|
533
|
+
F: __dxlog_file4,
|
|
534
|
+
L: 289,
|
|
535
|
+
S: this,
|
|
536
|
+
C: (f, a) => f(...a)
|
|
512
537
|
});
|
|
513
538
|
this._isStarted = false;
|
|
514
539
|
}
|
|
@@ -516,7 +541,7 @@ var Pipeline = class {
|
|
|
516
541
|
* @param timeframe Timeframe of already processed messages. The pipeline will start processing messages AFTER this timeframe.
|
|
517
542
|
*/
|
|
518
543
|
async setCursor(timeframe) {
|
|
519
|
-
|
|
544
|
+
invariant4(!this._isStarted || this._isPaused, "Invalid state.");
|
|
520
545
|
this._state._startTimeframe = timeframe;
|
|
521
546
|
this._timeframeClock.setTimeframe(timeframe);
|
|
522
547
|
for (const feed of this._feeds.values()) {
|
|
@@ -532,7 +557,7 @@ var Pipeline = class {
|
|
|
532
557
|
* Calling pause while processing will cause a deadlock.
|
|
533
558
|
*/
|
|
534
559
|
async pause() {
|
|
535
|
-
|
|
560
|
+
invariant4(this._isStarted, "Pipeline is not open.");
|
|
536
561
|
if (this._isPaused) {
|
|
537
562
|
return;
|
|
538
563
|
}
|
|
@@ -541,8 +566,8 @@ var Pipeline = class {
|
|
|
541
566
|
this._isPaused = true;
|
|
542
567
|
}
|
|
543
568
|
async unpause() {
|
|
544
|
-
|
|
545
|
-
|
|
569
|
+
invariant4(this._isStarted, "Pipeline is not open.");
|
|
570
|
+
invariant4(this._isPaused, "Pipeline is not paused.");
|
|
546
571
|
this._pauseTrigger.wake();
|
|
547
572
|
this._isPaused = false;
|
|
548
573
|
}
|
|
@@ -551,15 +576,15 @@ var Pipeline = class {
|
|
|
551
576
|
* Updates the timeframe clock after the message has bee processed.
|
|
552
577
|
*/
|
|
553
578
|
async *consume() {
|
|
554
|
-
|
|
579
|
+
invariant4(!this._isOpen, "Pipeline is already being consumed.");
|
|
555
580
|
this._isOpen = true;
|
|
556
|
-
|
|
581
|
+
invariant4(this._feedSetIterator, "Iterator not initialized.");
|
|
557
582
|
let lastFeedSetIterator = this._feedSetIterator;
|
|
558
583
|
let iterable = lastFeedSetIterator[Symbol.asyncIterator]();
|
|
559
584
|
while (!this._isStopping) {
|
|
560
585
|
await this._pauseTrigger.wait();
|
|
561
586
|
if (lastFeedSetIterator !== this._feedSetIterator) {
|
|
562
|
-
|
|
587
|
+
invariant4(this._feedSetIterator, "Iterator not initialized.");
|
|
563
588
|
lastFeedSetIterator = this._feedSetIterator;
|
|
564
589
|
iterable = lastFeedSetIterator[Symbol.asyncIterator]();
|
|
565
590
|
}
|
|
@@ -581,11 +606,11 @@ var Pipeline = class {
|
|
|
581
606
|
const timeframe = this._state._startTimeframe;
|
|
582
607
|
const seq = (_a = timeframe.get(feed.key)) != null ? _a : 0;
|
|
583
608
|
feed.undownload({
|
|
584
|
-
callback: () => log4("Undownloaded",
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
609
|
+
callback: () => log4("Undownloaded", void 0, {
|
|
610
|
+
F: __dxlog_file4,
|
|
611
|
+
L: 383,
|
|
612
|
+
S: this,
|
|
613
|
+
C: (f, a) => f(...a)
|
|
589
614
|
})
|
|
590
615
|
});
|
|
591
616
|
feed.download({
|
|
@@ -595,10 +620,10 @@ var Pipeline = class {
|
|
|
595
620
|
log4("failed to download feed", {
|
|
596
621
|
err
|
|
597
622
|
}, {
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
623
|
+
F: __dxlog_file4,
|
|
624
|
+
L: 386,
|
|
625
|
+
S: this,
|
|
626
|
+
C: (f, a) => f(...a)
|
|
602
627
|
});
|
|
603
628
|
});
|
|
604
629
|
}
|
|
@@ -608,11 +633,11 @@ var Pipeline = class {
|
|
|
608
633
|
stallTimeout: 1e3
|
|
609
634
|
});
|
|
610
635
|
this._feedSetIterator.stalled.on((iterator) => {
|
|
611
|
-
log4.warn(`Stalled after ${iterator.options.stallTimeout}ms with ${iterator.size} feeds.`,
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
636
|
+
log4.warn(`Stalled after ${iterator.options.stallTimeout}ms with ${iterator.size} feeds.`, void 0, {
|
|
637
|
+
F: __dxlog_file4,
|
|
638
|
+
L: 396,
|
|
639
|
+
S: this,
|
|
640
|
+
C: (f, a) => f(...a)
|
|
616
641
|
});
|
|
617
642
|
this._state.stalled.emit();
|
|
618
643
|
});
|
|
@@ -621,30 +646,31 @@ var Pipeline = class {
|
|
|
621
646
|
}
|
|
622
647
|
}
|
|
623
648
|
};
|
|
624
|
-
|
|
649
|
+
_ts_decorate3([
|
|
625
650
|
synchronized2
|
|
626
651
|
], Pipeline.prototype, "start", null);
|
|
627
|
-
|
|
652
|
+
_ts_decorate3([
|
|
628
653
|
synchronized2
|
|
629
654
|
], Pipeline.prototype, "stop", null);
|
|
630
|
-
|
|
655
|
+
_ts_decorate3([
|
|
631
656
|
synchronized2
|
|
632
657
|
], Pipeline.prototype, "setCursor", null);
|
|
633
|
-
|
|
658
|
+
_ts_decorate3([
|
|
634
659
|
synchronized2
|
|
635
660
|
], Pipeline.prototype, "pause", null);
|
|
636
|
-
|
|
661
|
+
_ts_decorate3([
|
|
637
662
|
synchronized2
|
|
638
663
|
], Pipeline.prototype, "unpause", null);
|
|
639
664
|
|
|
640
665
|
// packages/core/echo/echo-pipeline/src/space/auth.ts
|
|
641
|
-
import
|
|
666
|
+
import invariant5 from "tiny-invariant";
|
|
642
667
|
import { runInContext, scheduleTask } from "@dxos/async";
|
|
643
668
|
import { Context as Context2 } from "@dxos/context";
|
|
644
669
|
import { randomBytes } from "@dxos/crypto";
|
|
645
670
|
import { log as log5 } from "@dxos/log";
|
|
646
671
|
import { schema as schema3 } from "@dxos/protocols";
|
|
647
672
|
import { RpcExtension } from "@dxos/teleport";
|
|
673
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/auth.ts";
|
|
648
674
|
var AuthExtension = class extends RpcExtension {
|
|
649
675
|
constructor(_authParams) {
|
|
650
676
|
super({
|
|
@@ -659,11 +685,11 @@ var AuthExtension = class extends RpcExtension {
|
|
|
659
685
|
this._authParams = _authParams;
|
|
660
686
|
this._ctx = new Context2({
|
|
661
687
|
onError: (err) => {
|
|
662
|
-
log5.catch(err,
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
688
|
+
log5.catch(err, void 0, {
|
|
689
|
+
F: __dxlog_file5,
|
|
690
|
+
L: 29,
|
|
691
|
+
S: this,
|
|
692
|
+
C: (f, a) => f(...a)
|
|
667
693
|
});
|
|
668
694
|
}
|
|
669
695
|
});
|
|
@@ -682,10 +708,10 @@ var AuthExtension = class extends RpcExtension {
|
|
|
682
708
|
};
|
|
683
709
|
} catch (err) {
|
|
684
710
|
log5.error("failed to generate auth credentials", err, {
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
711
|
+
F: __dxlog_file5,
|
|
712
|
+
L: 56,
|
|
713
|
+
S: this,
|
|
714
|
+
C: (f, a) => f(...a)
|
|
689
715
|
});
|
|
690
716
|
throw new Error("auth rejected");
|
|
691
717
|
}
|
|
@@ -701,16 +727,16 @@ var AuthExtension = class extends RpcExtension {
|
|
|
701
727
|
const { credential } = await this.rpc.AuthService.authenticate({
|
|
702
728
|
challenge
|
|
703
729
|
});
|
|
704
|
-
|
|
730
|
+
invariant5((credential == null ? void 0 : credential.length) > 0, "invalid credential");
|
|
705
731
|
const success = await this._authParams.verifier(challenge, credential);
|
|
706
|
-
|
|
732
|
+
invariant5(success, "credential not verified");
|
|
707
733
|
runInContext(this._ctx, () => this._authParams.onAuthSuccess());
|
|
708
734
|
} catch (err) {
|
|
709
735
|
log5("auth failed", err, {
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
736
|
+
F: __dxlog_file5,
|
|
737
|
+
L: 75,
|
|
738
|
+
S: this,
|
|
739
|
+
C: (f, a) => f(...a)
|
|
714
740
|
});
|
|
715
741
|
this.close();
|
|
716
742
|
this._authParams.onAuthFailure();
|
|
@@ -724,23 +750,32 @@ var AuthExtension = class extends RpcExtension {
|
|
|
724
750
|
};
|
|
725
751
|
|
|
726
752
|
// packages/core/echo/echo-pipeline/src/dbhost/data-service-host.ts
|
|
727
|
-
import
|
|
753
|
+
import invariant6 from "tiny-invariant";
|
|
728
754
|
import { Stream } from "@dxos/codec-protobuf";
|
|
755
|
+
import { Context as Context3 } from "@dxos/context";
|
|
729
756
|
import { tagMutationsInBatch, setMetadataOnObject } from "@dxos/echo-db";
|
|
730
757
|
import { log as log6 } from "@dxos/log";
|
|
731
758
|
import { ComplexMap as ComplexMap2 } from "@dxos/util";
|
|
759
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/dbhost/data-service-host.ts";
|
|
732
760
|
var DataServiceHost = class {
|
|
733
761
|
constructor(_itemManager, _itemDemuxer, _writeStream) {
|
|
734
762
|
this._itemManager = _itemManager;
|
|
735
763
|
this._itemDemuxer = _itemDemuxer;
|
|
736
764
|
this._writeStream = _writeStream;
|
|
765
|
+
this._ctx = new Context3();
|
|
737
766
|
this._clientTagMap = new ComplexMap2(([feedKey, seq]) => `${feedKey.toHex()}:${seq}`);
|
|
738
767
|
}
|
|
768
|
+
async open() {
|
|
769
|
+
}
|
|
770
|
+
async close() {
|
|
771
|
+
await this._ctx.dispose();
|
|
772
|
+
}
|
|
739
773
|
/**
|
|
740
774
|
* Real-time subscription to data objects in a space.
|
|
741
775
|
*/
|
|
742
776
|
subscribe() {
|
|
743
|
-
return new Stream(({ next, ctx }) => {
|
|
777
|
+
return new Stream(({ next, close, ctx }) => {
|
|
778
|
+
ctx.onDispose(this._ctx.onDispose(close));
|
|
744
779
|
const objects = Array.from(this._itemManager.entities.values()).map((entity) => entity.createSnapshot());
|
|
745
780
|
next({
|
|
746
781
|
batch: {
|
|
@@ -750,15 +785,15 @@ var DataServiceHost = class {
|
|
|
750
785
|
this._itemDemuxer.mutation.on(ctx, (message) => {
|
|
751
786
|
var _a;
|
|
752
787
|
const { batch, meta } = message;
|
|
753
|
-
|
|
788
|
+
invariant6(!meta.clientTag, "Unexpected client tag in mutation message");
|
|
754
789
|
log6("message", {
|
|
755
790
|
batch,
|
|
756
791
|
meta
|
|
757
792
|
}, {
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
793
|
+
F: __dxlog_file6,
|
|
794
|
+
L: 63,
|
|
795
|
+
S: this,
|
|
796
|
+
C: (f, a) => f(...a)
|
|
762
797
|
});
|
|
763
798
|
const clientTag = this._clientTagMap.get([
|
|
764
799
|
message.meta.feedKey,
|
|
@@ -783,15 +818,16 @@ var DataServiceHost = class {
|
|
|
783
818
|
}
|
|
784
819
|
async write(request) {
|
|
785
820
|
var _a, _b;
|
|
786
|
-
|
|
821
|
+
invariant6(!this._ctx.disposed, "Cannot write to closed DataServiceHost");
|
|
822
|
+
invariant6(this._writeStream, "Cannot write mutations in readonly mode");
|
|
787
823
|
log6("write", {
|
|
788
824
|
clientTag: request.clientTag,
|
|
789
825
|
objectCount: (_b = (_a = request.batch.objects) == null ? void 0 : _a.length) != null ? _b : 0
|
|
790
826
|
}, {
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
827
|
+
F: __dxlog_file6,
|
|
828
|
+
L: 92,
|
|
829
|
+
S: this,
|
|
830
|
+
C: (f, a) => f(...a)
|
|
795
831
|
});
|
|
796
832
|
const message = createDataMessage(request.batch);
|
|
797
833
|
const receipt = await this._writeStream.write(message, {
|
|
@@ -802,10 +838,10 @@ var DataServiceHost = class {
|
|
|
802
838
|
feedKey: receipt2.feedKey,
|
|
803
839
|
seq: receipt2.seq
|
|
804
840
|
}, {
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
841
|
+
F: __dxlog_file6,
|
|
842
|
+
L: 101,
|
|
843
|
+
S: this,
|
|
844
|
+
C: (f, a) => f(...a)
|
|
809
845
|
});
|
|
810
846
|
this._clientTagMap.set([
|
|
811
847
|
receipt2.feedKey,
|
|
@@ -875,7 +911,7 @@ import { timed as timed2 } from "@dxos/debug";
|
|
|
875
911
|
import { PublicKey as PublicKey2 } from "@dxos/keys";
|
|
876
912
|
import { schema as schema4 } from "@dxos/protocols";
|
|
877
913
|
import { BlobMeta } from "@dxos/protocols/proto/dxos/echo/blob";
|
|
878
|
-
|
|
914
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
879
915
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
880
916
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
881
917
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -884,7 +920,7 @@ var __decorate4 = function(decorators, target, key, desc) {
|
|
|
884
920
|
if (d = decorators[i])
|
|
885
921
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
886
922
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
887
|
-
}
|
|
923
|
+
}
|
|
888
924
|
var SnapshotManager = class SnapshotManager2 {
|
|
889
925
|
// prettier-ignore
|
|
890
926
|
constructor(_snapshotStore, _blobStore, _blobSync) {
|
|
@@ -915,10 +951,10 @@ var SnapshotManager = class SnapshotManager2 {
|
|
|
915
951
|
return PublicKey2.from(id).toHex();
|
|
916
952
|
}
|
|
917
953
|
};
|
|
918
|
-
|
|
954
|
+
_ts_decorate4([
|
|
919
955
|
timed2(1e4)
|
|
920
956
|
], SnapshotManager.prototype, "load", null);
|
|
921
|
-
SnapshotManager =
|
|
957
|
+
SnapshotManager = _ts_decorate4([
|
|
922
958
|
trackLeaks("open", "close")
|
|
923
959
|
], SnapshotManager);
|
|
924
960
|
|
|
@@ -968,11 +1004,12 @@ var SnapshotStore = class {
|
|
|
968
1004
|
};
|
|
969
1005
|
|
|
970
1006
|
// packages/core/echo/echo-pipeline/src/dbhost/data-service.ts
|
|
971
|
-
import
|
|
1007
|
+
import invariant7 from "tiny-invariant";
|
|
972
1008
|
import { raise } from "@dxos/debug";
|
|
973
1009
|
import { PublicKey as PublicKey3 } from "@dxos/keys";
|
|
974
1010
|
import { log as log7 } from "@dxos/log";
|
|
975
1011
|
import { ComplexMap as ComplexMap3 } from "@dxos/util";
|
|
1012
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/dbhost/data-service.ts";
|
|
976
1013
|
var DataServiceSubscriptions = class {
|
|
977
1014
|
constructor() {
|
|
978
1015
|
this._spaces = new ComplexMap3(PublicKey3.hash);
|
|
@@ -980,26 +1017,30 @@ var DataServiceSubscriptions = class {
|
|
|
980
1017
|
clear() {
|
|
981
1018
|
this._spaces.clear();
|
|
982
1019
|
}
|
|
983
|
-
registerSpace(spaceKey, host) {
|
|
1020
|
+
async registerSpace(spaceKey, host) {
|
|
984
1021
|
log7("Registering space", {
|
|
985
1022
|
spaceKey
|
|
986
1023
|
}, {
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
1024
|
+
F: __dxlog_file7,
|
|
1025
|
+
L: 31,
|
|
1026
|
+
S: this,
|
|
1027
|
+
C: (f, a) => f(...a)
|
|
991
1028
|
});
|
|
1029
|
+
invariant7(!this._spaces.has(spaceKey));
|
|
1030
|
+
await host.open();
|
|
992
1031
|
this._spaces.set(spaceKey, host);
|
|
993
1032
|
}
|
|
994
|
-
unregisterSpace(spaceKey) {
|
|
1033
|
+
async unregisterSpace(spaceKey) {
|
|
995
1034
|
log7("Unregistering space", {
|
|
996
1035
|
spaceKey
|
|
997
1036
|
}, {
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1037
|
+
F: __dxlog_file7,
|
|
1038
|
+
L: 38,
|
|
1039
|
+
S: this,
|
|
1040
|
+
C: (f, a) => f(...a)
|
|
1002
1041
|
});
|
|
1042
|
+
const host = this._spaces.get(spaceKey);
|
|
1043
|
+
await (host == null ? void 0 : host.close());
|
|
1003
1044
|
this._spaces.delete(spaceKey);
|
|
1004
1045
|
}
|
|
1005
1046
|
getDataService(spaceKey) {
|
|
@@ -1012,29 +1053,29 @@ var DataServiceImpl = class {
|
|
|
1012
1053
|
}
|
|
1013
1054
|
subscribe(request) {
|
|
1014
1055
|
var _a;
|
|
1015
|
-
|
|
1056
|
+
invariant7(request.spaceKey);
|
|
1016
1057
|
const host = (_a = this._subscriptions.getDataService(request.spaceKey)) != null ? _a : raise(new Error(`space not found: ${request.spaceKey}`));
|
|
1017
1058
|
return host.subscribe();
|
|
1018
1059
|
}
|
|
1019
1060
|
write(request) {
|
|
1020
1061
|
var _a;
|
|
1021
|
-
|
|
1022
|
-
|
|
1062
|
+
invariant7(request.spaceKey);
|
|
1063
|
+
invariant7(request.batch);
|
|
1023
1064
|
const host = (_a = this._subscriptions.getDataService(request.spaceKey)) != null ? _a : raise(new Error(`space not found: ${request.spaceKey}`));
|
|
1024
1065
|
return host.write(request);
|
|
1025
1066
|
}
|
|
1026
1067
|
};
|
|
1027
1068
|
|
|
1028
1069
|
// packages/core/echo/echo-pipeline/src/space/data-pipeline.ts
|
|
1029
|
-
import
|
|
1070
|
+
import invariant8 from "tiny-invariant";
|
|
1030
1071
|
import { Event as Event4, scheduleTask as scheduleTask2, synchronized as synchronized3, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
1031
|
-
import { Context as
|
|
1072
|
+
import { Context as Context4 } from "@dxos/context";
|
|
1032
1073
|
import { checkCredentialType } from "@dxos/credentials";
|
|
1033
1074
|
import { getStateMachineFromItem, ItemManager } from "@dxos/echo-db";
|
|
1034
1075
|
import { CancelledError } from "@dxos/errors";
|
|
1035
1076
|
import { log as log8 } from "@dxos/log";
|
|
1036
1077
|
import { Timeframe as Timeframe3 } from "@dxos/timeframe";
|
|
1037
|
-
|
|
1078
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
1038
1079
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1039
1080
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1040
1081
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1043,18 +1084,23 @@ var __decorate5 = function(decorators, target, key, desc) {
|
|
|
1043
1084
|
if (d = decorators[i])
|
|
1044
1085
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1045
1086
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1046
|
-
}
|
|
1087
|
+
}
|
|
1088
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/data-pipeline.ts";
|
|
1047
1089
|
var MESSAGES_PER_SNAPSHOT = 10;
|
|
1048
1090
|
var AUTOMATIC_SNAPSHOT_DEBOUNCE_INTERVAL = 5e3;
|
|
1049
1091
|
var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL = 500;
|
|
1050
1092
|
var DataPipeline = class DataPipeline2 {
|
|
1051
1093
|
constructor(_params) {
|
|
1052
1094
|
this._params = _params;
|
|
1053
|
-
this._ctx = new
|
|
1095
|
+
this._ctx = new Context4();
|
|
1096
|
+
this._pipeline = void 0;
|
|
1097
|
+
this._targetTimeframe = void 0;
|
|
1054
1098
|
this._lastAutomaticSnapshotTimeframe = new Timeframe3();
|
|
1055
1099
|
this._isOpen = false;
|
|
1056
1100
|
this._lastTimeframeSaveTime = 0;
|
|
1057
1101
|
this._lastSnapshotSaveTime = 0;
|
|
1102
|
+
this.currentEpoch = void 0;
|
|
1103
|
+
this.appliedEpoch = void 0;
|
|
1058
1104
|
this._lastProcessedEpoch = -1;
|
|
1059
1105
|
this.onNewEpoch = new Event4();
|
|
1060
1106
|
}
|
|
@@ -1073,18 +1119,14 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1073
1119
|
this._targetTimeframe = timeframe;
|
|
1074
1120
|
(_a = this._pipeline) == null ? void 0 : _a.state.setTargetTimeframe(timeframe);
|
|
1075
1121
|
}
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
await this._processEpochInSeparateTask(credential);
|
|
1085
|
-
}
|
|
1086
|
-
}
|
|
1087
|
-
};
|
|
1122
|
+
async processCredential(credential) {
|
|
1123
|
+
if (!checkCredentialType(credential, "dxos.halo.credentials.Epoch")) {
|
|
1124
|
+
return;
|
|
1125
|
+
}
|
|
1126
|
+
this.currentEpoch = credential;
|
|
1127
|
+
if (this._isOpen) {
|
|
1128
|
+
await this._processEpochInSeparateTask(credential);
|
|
1129
|
+
}
|
|
1088
1130
|
}
|
|
1089
1131
|
async open() {
|
|
1090
1132
|
if (this._isOpen) {
|
|
@@ -1099,8 +1141,8 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1099
1141
|
}
|
|
1100
1142
|
const feedWriter = {
|
|
1101
1143
|
write: (data, options) => {
|
|
1102
|
-
|
|
1103
|
-
|
|
1144
|
+
invariant8(this._pipeline, "Pipeline is not initialized.");
|
|
1145
|
+
invariant8(this.currentEpoch, "Epoch is not initialized.");
|
|
1104
1146
|
return this._pipeline.writer.write({
|
|
1105
1147
|
data
|
|
1106
1148
|
}, options);
|
|
@@ -1119,11 +1161,11 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1119
1161
|
if (!this._isOpen) {
|
|
1120
1162
|
return;
|
|
1121
1163
|
}
|
|
1122
|
-
log8("close",
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1164
|
+
log8("close", void 0, {
|
|
1165
|
+
F: __dxlog_file8,
|
|
1166
|
+
L: 171,
|
|
1167
|
+
S: this,
|
|
1168
|
+
C: (f, a) => f(...a)
|
|
1127
1169
|
});
|
|
1128
1170
|
this._isOpen = false;
|
|
1129
1171
|
await this._ctx.dispose();
|
|
@@ -1134,15 +1176,23 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1134
1176
|
await this._saveTargetTimeframe(this._pipeline.state.timeframe);
|
|
1135
1177
|
}
|
|
1136
1178
|
} catch (err) {
|
|
1137
|
-
log8.catch(err,
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1179
|
+
log8.catch(err, void 0, {
|
|
1180
|
+
F: __dxlog_file8,
|
|
1181
|
+
L: 184,
|
|
1182
|
+
S: this,
|
|
1183
|
+
C: (f, a) => f(...a)
|
|
1142
1184
|
});
|
|
1143
1185
|
}
|
|
1144
1186
|
await ((_b = this.databaseHost) == null ? void 0 : _b.close());
|
|
1145
1187
|
await ((_c = this.itemManager) == null ? void 0 : _c.destroy());
|
|
1188
|
+
this._ctx = new Context4();
|
|
1189
|
+
this._pipeline = void 0;
|
|
1190
|
+
this._targetTimeframe = void 0;
|
|
1191
|
+
this._lastAutomaticSnapshotTimeframe = new Timeframe3();
|
|
1192
|
+
this.currentEpoch = void 0;
|
|
1193
|
+
this.appliedEpoch = void 0;
|
|
1194
|
+
this._lastProcessedEpoch = -1;
|
|
1195
|
+
this._epochCtx = void 0;
|
|
1146
1196
|
}
|
|
1147
1197
|
async _consumePipeline() {
|
|
1148
1198
|
if (this.currentEpoch) {
|
|
@@ -1150,17 +1200,17 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1150
1200
|
await this._processEpochInSeparateTask(this.currentEpoch);
|
|
1151
1201
|
await waitForOneEpoch;
|
|
1152
1202
|
}
|
|
1153
|
-
|
|
1203
|
+
invariant8(this._pipeline, "Pipeline is not initialized.");
|
|
1154
1204
|
for await (const msg of this._pipeline.consume()) {
|
|
1155
1205
|
const { feedKey, seq, data } = msg;
|
|
1156
1206
|
log8("processing message", {
|
|
1157
1207
|
feedKey,
|
|
1158
1208
|
seq
|
|
1159
1209
|
}, {
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1210
|
+
F: __dxlog_file8,
|
|
1211
|
+
L: 210,
|
|
1212
|
+
S: this,
|
|
1213
|
+
C: (f, a) => f(...a)
|
|
1164
1214
|
});
|
|
1165
1215
|
try {
|
|
1166
1216
|
if (data.payload.data) {
|
|
@@ -1169,10 +1219,10 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1169
1219
|
log8.error("Could not find feed.", {
|
|
1170
1220
|
feedKey
|
|
1171
1221
|
}, {
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1222
|
+
F: __dxlog_file8,
|
|
1223
|
+
L: 216,
|
|
1224
|
+
S: this,
|
|
1225
|
+
C: (f, a) => f(...a)
|
|
1176
1226
|
});
|
|
1177
1227
|
continue;
|
|
1178
1228
|
}
|
|
@@ -1190,25 +1240,25 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1190
1240
|
seq,
|
|
1191
1241
|
spaceKey: this._params.spaceKey.toHex()
|
|
1192
1242
|
}, {
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1243
|
+
F: __dxlog_file8,
|
|
1244
|
+
L: 230,
|
|
1245
|
+
S: this,
|
|
1246
|
+
C: (f, a) => f(...a)
|
|
1197
1247
|
});
|
|
1198
1248
|
await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
|
|
1199
1249
|
}
|
|
1200
1250
|
} catch (err) {
|
|
1201
|
-
log8.catch(err,
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1251
|
+
log8.catch(err, void 0, {
|
|
1252
|
+
F: __dxlog_file8,
|
|
1253
|
+
L: 240,
|
|
1254
|
+
S: this,
|
|
1255
|
+
C: (f, a) => f(...a)
|
|
1206
1256
|
});
|
|
1207
1257
|
}
|
|
1208
1258
|
}
|
|
1209
1259
|
}
|
|
1210
1260
|
_createSnapshot() {
|
|
1211
|
-
|
|
1261
|
+
invariant8(this.databaseHost, "Database backend is not initialized.");
|
|
1212
1262
|
return {
|
|
1213
1263
|
spaceKey: this._params.spaceKey.asUint8Array(),
|
|
1214
1264
|
timeframe: this._pipeline.state.timeframe,
|
|
@@ -1227,17 +1277,17 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1227
1277
|
try {
|
|
1228
1278
|
const propertiesItem = this.itemManager.items.find((item) => {
|
|
1229
1279
|
var _a2, _b;
|
|
1230
|
-
return ((_a2 = item.modelMeta) == null ? void 0 : _a2.type) === "dxos:model/document" && ((_b = getStateMachineFromItem(item)) == null ? void 0 : _b.snapshot().type
|
|
1280
|
+
return ((_a2 = item.modelMeta) == null ? void 0 : _a2.type) === "dxos:model/document" && ((_b = getStateMachineFromItem(item)) == null ? void 0 : _b.snapshot()).type === "dxos.sdk.client.Properties";
|
|
1231
1281
|
});
|
|
1232
1282
|
if (propertiesItem) {
|
|
1233
1283
|
cache.properties = (_a = getStateMachineFromItem(propertiesItem)) == null ? void 0 : _a.snapshot();
|
|
1234
1284
|
}
|
|
1235
1285
|
} catch (err) {
|
|
1236
1286
|
log8.warn("Failed to cache properties", err, {
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1287
|
+
F: __dxlog_file8,
|
|
1288
|
+
L: 275,
|
|
1289
|
+
S: this,
|
|
1290
|
+
C: (f, a) => f(...a)
|
|
1241
1291
|
});
|
|
1242
1292
|
}
|
|
1243
1293
|
await this._params.metadataStore.setCache(this._params.spaceKey, cache);
|
|
@@ -1257,21 +1307,21 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1257
1307
|
return;
|
|
1258
1308
|
}
|
|
1259
1309
|
await ((_a = this._epochCtx) == null ? void 0 : _a.dispose());
|
|
1260
|
-
const ctx = new
|
|
1310
|
+
const ctx = new Context4({
|
|
1261
1311
|
onError: (err) => {
|
|
1262
1312
|
if (err instanceof CancelledError) {
|
|
1263
|
-
log8("Epoch processing cancelled.",
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1313
|
+
log8("Epoch processing cancelled.", void 0, {
|
|
1314
|
+
F: __dxlog_file8,
|
|
1315
|
+
L: 307,
|
|
1316
|
+
S: this,
|
|
1317
|
+
C: (f, a) => f(...a)
|
|
1268
1318
|
});
|
|
1269
1319
|
} else {
|
|
1270
|
-
log8.catch(err,
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1320
|
+
log8.catch(err, void 0, {
|
|
1321
|
+
F: __dxlog_file8,
|
|
1322
|
+
L: 309,
|
|
1323
|
+
S: this,
|
|
1324
|
+
C: (f, a) => f(...a)
|
|
1275
1325
|
});
|
|
1276
1326
|
}
|
|
1277
1327
|
}
|
|
@@ -1284,10 +1334,10 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1284
1334
|
log8("process epoch", {
|
|
1285
1335
|
epoch
|
|
1286
1336
|
}, {
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1337
|
+
F: __dxlog_file8,
|
|
1338
|
+
L: 319,
|
|
1339
|
+
S: this,
|
|
1340
|
+
C: (f, a) => f(...a)
|
|
1291
1341
|
});
|
|
1292
1342
|
await this._processEpoch(ctx, epoch.subject.assertion);
|
|
1293
1343
|
this.appliedEpoch = epoch;
|
|
@@ -1295,38 +1345,38 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1295
1345
|
});
|
|
1296
1346
|
}
|
|
1297
1347
|
async _processEpoch(ctx, epoch) {
|
|
1298
|
-
|
|
1299
|
-
|
|
1348
|
+
invariant8(this._isOpen, "Space is closed.");
|
|
1349
|
+
invariant8(this._pipeline);
|
|
1300
1350
|
this._lastProcessedEpoch = epoch.number;
|
|
1301
1351
|
log8("Processing epoch", {
|
|
1302
1352
|
epoch
|
|
1303
1353
|
}, {
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1354
|
+
F: __dxlog_file8,
|
|
1355
|
+
L: 333,
|
|
1356
|
+
S: this,
|
|
1357
|
+
C: (f, a) => f(...a)
|
|
1308
1358
|
});
|
|
1309
1359
|
if (epoch.snapshotCid) {
|
|
1310
1360
|
const snapshot = await this._params.snapshotManager.load(ctx, epoch.snapshotCid);
|
|
1311
1361
|
this.databaseHost._itemDemuxer.restoreFromSnapshot(snapshot.database);
|
|
1312
1362
|
}
|
|
1313
|
-
log8("restarting pipeline for epoch",
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1363
|
+
log8("restarting pipeline for epoch", void 0, {
|
|
1364
|
+
F: __dxlog_file8,
|
|
1365
|
+
L: 341,
|
|
1366
|
+
S: this,
|
|
1367
|
+
C: (f, a) => f(...a)
|
|
1318
1368
|
});
|
|
1319
1369
|
await this._pipeline.pause();
|
|
1320
1370
|
await this._pipeline.setCursor(epoch.timeframe);
|
|
1321
1371
|
await this._pipeline.unpause();
|
|
1322
1372
|
}
|
|
1323
1373
|
async waitUntilTimeframe(timeframe) {
|
|
1324
|
-
|
|
1374
|
+
invariant8(this._pipeline, "Pipeline is not initialized.");
|
|
1325
1375
|
await this._pipeline.state.waitUntilTimeframe(timeframe);
|
|
1326
1376
|
}
|
|
1327
1377
|
async createEpoch() {
|
|
1328
|
-
|
|
1329
|
-
|
|
1378
|
+
invariant8(this._pipeline);
|
|
1379
|
+
invariant8(this.currentEpoch);
|
|
1330
1380
|
await this._pipeline.pause();
|
|
1331
1381
|
const snapshot = await this._createSnapshot();
|
|
1332
1382
|
const snapshotCid = await this._params.snapshotManager.store(snapshot);
|
|
@@ -1343,24 +1393,24 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1343
1393
|
await this.onNewEpoch.waitForCondition(() => !!this.currentEpoch);
|
|
1344
1394
|
}
|
|
1345
1395
|
};
|
|
1346
|
-
|
|
1396
|
+
_ts_decorate5([
|
|
1347
1397
|
synchronized3
|
|
1348
1398
|
], DataPipeline.prototype, "open", null);
|
|
1349
|
-
|
|
1399
|
+
_ts_decorate5([
|
|
1350
1400
|
synchronized3
|
|
1351
1401
|
], DataPipeline.prototype, "close", null);
|
|
1352
|
-
|
|
1402
|
+
_ts_decorate5([
|
|
1353
1403
|
synchronized3
|
|
1354
1404
|
], DataPipeline.prototype, "_processEpoch", null);
|
|
1355
|
-
|
|
1405
|
+
_ts_decorate5([
|
|
1356
1406
|
synchronized3
|
|
1357
1407
|
], DataPipeline.prototype, "createEpoch", null);
|
|
1358
|
-
DataPipeline =
|
|
1408
|
+
DataPipeline = _ts_decorate5([
|
|
1359
1409
|
trackLeaks2("open", "close")
|
|
1360
1410
|
], DataPipeline);
|
|
1361
1411
|
|
|
1362
1412
|
// packages/core/echo/echo-pipeline/src/space/space.ts
|
|
1363
|
-
import
|
|
1413
|
+
import invariant9 from "tiny-invariant";
|
|
1364
1414
|
import { Event as Event5, synchronized as synchronized4, trackLeaks as trackLeaks3, Lock } from "@dxos/async";
|
|
1365
1415
|
import { log as log10, logInfo } from "@dxos/log";
|
|
1366
1416
|
import { AdmittedFeed as AdmittedFeed2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
@@ -1373,6 +1423,7 @@ import { log as log9 } from "@dxos/log";
|
|
|
1373
1423
|
import { AdmittedFeed } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
1374
1424
|
import { Timeframe as Timeframe4 } from "@dxos/timeframe";
|
|
1375
1425
|
import { Callback } from "@dxos/util";
|
|
1426
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/control-pipeline.ts";
|
|
1376
1427
|
var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2 = 500;
|
|
1377
1428
|
var ControlPipeline = class {
|
|
1378
1429
|
constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }) {
|
|
@@ -1387,21 +1438,21 @@ var ControlPipeline = class {
|
|
|
1387
1438
|
log9("feed admitted", {
|
|
1388
1439
|
key: info.key
|
|
1389
1440
|
}, {
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1441
|
+
F: __dxlog_file9,
|
|
1442
|
+
L: 51,
|
|
1443
|
+
S: this,
|
|
1444
|
+
C: (f, a) => f(...a)
|
|
1394
1445
|
});
|
|
1395
1446
|
if (info.assertion.designation === AdmittedFeed.Designation.CONTROL && !info.key.equals(genesisFeed.key)) {
|
|
1396
1447
|
try {
|
|
1397
1448
|
const feed = await feedProvider(info.key);
|
|
1398
1449
|
await this._pipeline.addFeed(feed);
|
|
1399
1450
|
} catch (err) {
|
|
1400
|
-
log9.catch(err,
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1451
|
+
log9.catch(err, void 0, {
|
|
1452
|
+
F: __dxlog_file9,
|
|
1453
|
+
L: 59,
|
|
1454
|
+
S: this,
|
|
1455
|
+
C: (f, a) => f(...a)
|
|
1405
1456
|
});
|
|
1406
1457
|
}
|
|
1407
1458
|
}
|
|
@@ -1420,11 +1471,11 @@ var ControlPipeline = class {
|
|
|
1420
1471
|
this._pipeline.setWriteFeed(feed);
|
|
1421
1472
|
}
|
|
1422
1473
|
async start() {
|
|
1423
|
-
log9("starting...",
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1474
|
+
log9("starting...", void 0, {
|
|
1475
|
+
F: __dxlog_file9,
|
|
1476
|
+
L: 83,
|
|
1477
|
+
S: this,
|
|
1478
|
+
C: (f, a) => f(...a)
|
|
1428
1479
|
});
|
|
1429
1480
|
setTimeout(async () => {
|
|
1430
1481
|
for await (const msg of this._pipeline.consume()) {
|
|
@@ -1433,10 +1484,10 @@ var ControlPipeline = class {
|
|
|
1433
1484
|
key: msg.feedKey,
|
|
1434
1485
|
seq: msg.seq
|
|
1435
1486
|
}, {
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1487
|
+
F: __dxlog_file9,
|
|
1488
|
+
L: 88,
|
|
1489
|
+
S: this,
|
|
1490
|
+
C: (f, a) => f(...a)
|
|
1440
1491
|
});
|
|
1441
1492
|
if (msg.data.payload.credential) {
|
|
1442
1493
|
const result = await this._spaceStateMachine.process(msg.data.payload.credential.credential, PublicKey4.from(msg.feedKey));
|
|
@@ -1444,31 +1495,31 @@ var ControlPipeline = class {
|
|
|
1444
1495
|
log9.warn("processing failed", {
|
|
1445
1496
|
msg
|
|
1446
1497
|
}, {
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1498
|
+
F: __dxlog_file9,
|
|
1499
|
+
L: 95,
|
|
1500
|
+
S: this,
|
|
1501
|
+
C: (f, a) => f(...a)
|
|
1451
1502
|
});
|
|
1452
1503
|
} else {
|
|
1453
1504
|
await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
|
|
1454
1505
|
}
|
|
1455
1506
|
}
|
|
1456
1507
|
} catch (err) {
|
|
1457
|
-
log9.catch(err,
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1508
|
+
log9.catch(err, void 0, {
|
|
1509
|
+
F: __dxlog_file9,
|
|
1510
|
+
L: 101,
|
|
1511
|
+
S: this,
|
|
1512
|
+
C: (f, a) => f(...a)
|
|
1462
1513
|
});
|
|
1463
1514
|
}
|
|
1464
1515
|
}
|
|
1465
1516
|
});
|
|
1466
1517
|
await this._pipeline.start();
|
|
1467
|
-
log9("started",
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1518
|
+
log9("started", void 0, {
|
|
1519
|
+
F: __dxlog_file9,
|
|
1520
|
+
L: 107,
|
|
1521
|
+
S: this,
|
|
1522
|
+
C: (f, a) => f(...a)
|
|
1472
1523
|
});
|
|
1473
1524
|
}
|
|
1474
1525
|
async _noteTargetStateIfNeeded(timeframe) {
|
|
@@ -1478,19 +1529,19 @@ var ControlPipeline = class {
|
|
|
1478
1529
|
}
|
|
1479
1530
|
}
|
|
1480
1531
|
async stop() {
|
|
1481
|
-
log9("stopping...",
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1532
|
+
log9("stopping...", void 0, {
|
|
1533
|
+
F: __dxlog_file9,
|
|
1534
|
+
L: 121,
|
|
1535
|
+
S: this,
|
|
1536
|
+
C: (f, a) => f(...a)
|
|
1486
1537
|
});
|
|
1487
1538
|
await this._pipeline.stop();
|
|
1488
1539
|
await this._saveTargetTimeframe(this._pipeline.state.timeframe);
|
|
1489
|
-
log9("stopped",
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1540
|
+
log9("stopped", void 0, {
|
|
1541
|
+
F: __dxlog_file9,
|
|
1542
|
+
L: 124,
|
|
1543
|
+
S: this,
|
|
1544
|
+
C: (f, a) => f(...a)
|
|
1494
1545
|
});
|
|
1495
1546
|
}
|
|
1496
1547
|
async _saveTargetTimeframe(timeframe) {
|
|
@@ -1500,18 +1551,18 @@ var ControlPipeline = class {
|
|
|
1500
1551
|
await this._metadata.setSpaceControlLatestTimeframe(this._spaceKey, newTimeframe);
|
|
1501
1552
|
this._targetTimeframe = newTimeframe;
|
|
1502
1553
|
} catch (err) {
|
|
1503
|
-
log9(err,
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1554
|
+
log9(err, void 0, {
|
|
1555
|
+
F: __dxlog_file9,
|
|
1556
|
+
L: 133,
|
|
1557
|
+
S: this,
|
|
1558
|
+
C: (f, a) => f(...a)
|
|
1508
1559
|
});
|
|
1509
1560
|
}
|
|
1510
1561
|
}
|
|
1511
1562
|
};
|
|
1512
1563
|
|
|
1513
1564
|
// packages/core/echo/echo-pipeline/src/space/space.ts
|
|
1514
|
-
|
|
1565
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
1515
1566
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1516
1567
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1517
1568
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1520,16 +1571,15 @@ var __decorate6 = function(decorators, target, key, desc) {
|
|
|
1520
1571
|
if (d = decorators[i])
|
|
1521
1572
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1522
1573
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1523
|
-
}
|
|
1574
|
+
}
|
|
1575
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space.ts";
|
|
1524
1576
|
var Space = class Space2 {
|
|
1525
1577
|
constructor(params) {
|
|
1526
1578
|
this._addFeedLock = new Lock();
|
|
1527
1579
|
this.onCredentialProcessed = new Callback2();
|
|
1528
1580
|
this.stateUpdate = new Event5();
|
|
1529
|
-
// Processes epoch credentials.
|
|
1530
|
-
this._dataPipelineCredentialConsumer = void 0;
|
|
1531
1581
|
this._isOpen = false;
|
|
1532
|
-
|
|
1582
|
+
invariant9(params.spaceKey && params.feedProvider);
|
|
1533
1583
|
this._key = params.spaceKey;
|
|
1534
1584
|
this._genesisFeedKey = params.genesisFeed.key;
|
|
1535
1585
|
this._feedProvider = params.feedProvider;
|
|
@@ -1564,10 +1614,10 @@ var Space = class Space2 {
|
|
|
1564
1614
|
log10("onCredentialProcessed", {
|
|
1565
1615
|
credential
|
|
1566
1616
|
}, {
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1617
|
+
F: __dxlog_file10,
|
|
1618
|
+
L: 107,
|
|
1619
|
+
S: this,
|
|
1620
|
+
C: (f, a) => f(...a)
|
|
1571
1621
|
});
|
|
1572
1622
|
this.stateUpdate.emit();
|
|
1573
1623
|
});
|
|
@@ -1630,14 +1680,14 @@ var Space = class Space2 {
|
|
|
1630
1680
|
return this._snapshotManager;
|
|
1631
1681
|
}
|
|
1632
1682
|
setControlFeed(feed) {
|
|
1633
|
-
|
|
1683
|
+
invariant9(!this._controlFeed, "Control feed already set.");
|
|
1634
1684
|
this._controlFeed = feed;
|
|
1635
1685
|
this._controlPipeline.setWriteFeed(feed);
|
|
1636
1686
|
return this;
|
|
1637
1687
|
}
|
|
1638
1688
|
setDataFeed(feed) {
|
|
1639
1689
|
var _a;
|
|
1640
|
-
|
|
1690
|
+
invariant9(!this._dataFeed, "Data feed already set.");
|
|
1641
1691
|
this._dataFeed = feed;
|
|
1642
1692
|
(_a = this._dataPipeline.pipeline) == null ? void 0 : _a.setWriteFeed(feed);
|
|
1643
1693
|
return this;
|
|
@@ -1655,82 +1705,79 @@ var Space = class Space2 {
|
|
|
1655
1705
|
// return this._dataPipeline?.getFeeds();
|
|
1656
1706
|
// }
|
|
1657
1707
|
async open() {
|
|
1658
|
-
log10("opening...",
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1708
|
+
log10("opening...", void 0, {
|
|
1709
|
+
F: __dxlog_file10,
|
|
1710
|
+
L: 209,
|
|
1711
|
+
S: this,
|
|
1712
|
+
C: (f, a) => f(...a)
|
|
1663
1713
|
});
|
|
1664
1714
|
if (this._isOpen) {
|
|
1665
1715
|
return;
|
|
1666
1716
|
}
|
|
1667
1717
|
await this._controlPipeline.start();
|
|
1668
1718
|
await this.protocol.start();
|
|
1669
|
-
|
|
1670
|
-
await this._dataPipelineCredentialConsumer.open();
|
|
1719
|
+
await this._controlPipeline.spaceState.addCredentialProcessor(this._dataPipeline);
|
|
1671
1720
|
this._isOpen = true;
|
|
1672
|
-
log10("opened",
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1721
|
+
log10("opened", void 0, {
|
|
1722
|
+
F: __dxlog_file10,
|
|
1723
|
+
L: 220,
|
|
1724
|
+
S: this,
|
|
1725
|
+
C: (f, a) => f(...a)
|
|
1677
1726
|
});
|
|
1678
1727
|
}
|
|
1679
1728
|
async close() {
|
|
1680
|
-
var _a;
|
|
1681
1729
|
log10("closing...", {
|
|
1682
1730
|
key: this._key
|
|
1683
1731
|
}, {
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1732
|
+
F: __dxlog_file10,
|
|
1733
|
+
L: 225,
|
|
1734
|
+
S: this,
|
|
1735
|
+
C: (f, a) => f(...a)
|
|
1688
1736
|
});
|
|
1689
1737
|
if (!this._isOpen) {
|
|
1690
1738
|
return;
|
|
1691
1739
|
}
|
|
1692
|
-
await
|
|
1693
|
-
this._dataPipelineCredentialConsumer = void 0;
|
|
1740
|
+
await this._controlPipeline.spaceState.removeCredentialProcessor(this._dataPipeline);
|
|
1694
1741
|
await this._dataPipeline.close();
|
|
1695
1742
|
await this.protocol.stop();
|
|
1696
1743
|
await this._controlPipeline.stop();
|
|
1697
1744
|
this._isOpen = false;
|
|
1698
|
-
log10("closed",
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1745
|
+
log10("closed", void 0, {
|
|
1746
|
+
F: __dxlog_file10,
|
|
1747
|
+
L: 238,
|
|
1748
|
+
S: this,
|
|
1749
|
+
C: (f, a) => f(...a)
|
|
1703
1750
|
});
|
|
1704
1751
|
}
|
|
1705
1752
|
async initializeDataPipeline() {
|
|
1706
|
-
log10("initializeDataPipeline",
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1753
|
+
log10("initializeDataPipeline", void 0, {
|
|
1754
|
+
F: __dxlog_file10,
|
|
1755
|
+
L: 243,
|
|
1756
|
+
S: this,
|
|
1757
|
+
C: (f, a) => f(...a)
|
|
1711
1758
|
});
|
|
1712
|
-
|
|
1759
|
+
invariant9(this._isOpen, "Space must be open to initialize data pipeline.");
|
|
1713
1760
|
await this._dataPipeline.open();
|
|
1714
1761
|
}
|
|
1715
1762
|
};
|
|
1716
|
-
|
|
1763
|
+
_ts_decorate6([
|
|
1717
1764
|
logInfo
|
|
1718
1765
|
], Space.prototype, "key", null);
|
|
1719
|
-
|
|
1766
|
+
_ts_decorate6([
|
|
1720
1767
|
synchronized4
|
|
1721
1768
|
], Space.prototype, "open", null);
|
|
1722
|
-
|
|
1769
|
+
_ts_decorate6([
|
|
1723
1770
|
synchronized4
|
|
1724
1771
|
], Space.prototype, "close", null);
|
|
1725
|
-
|
|
1772
|
+
_ts_decorate6([
|
|
1726
1773
|
synchronized4
|
|
1727
1774
|
], Space.prototype, "initializeDataPipeline", null);
|
|
1728
|
-
Space =
|
|
1775
|
+
Space = _ts_decorate6([
|
|
1729
1776
|
trackLeaks3("open", "close")
|
|
1730
1777
|
], Space);
|
|
1731
1778
|
|
|
1732
1779
|
// packages/core/echo/echo-pipeline/src/space/space-protocol.ts
|
|
1733
|
-
import { discoveryKey,
|
|
1780
|
+
import { discoveryKey, subtleCrypto as subtleCrypto2 } from "@dxos/crypto";
|
|
1734
1781
|
import { PublicKey as PublicKey5 } from "@dxos/keys";
|
|
1735
1782
|
import { log as log11, logInfo as logInfo2 } from "@dxos/log";
|
|
1736
1783
|
import { MMSTTopology } from "@dxos/network-manager";
|
|
@@ -1738,7 +1785,7 @@ import { Teleport } from "@dxos/teleport";
|
|
|
1738
1785
|
import { BlobSync } from "@dxos/teleport-extension-object-sync";
|
|
1739
1786
|
import { ReplicatorExtension } from "@dxos/teleport-extension-replicator";
|
|
1740
1787
|
import { ComplexMap as ComplexMap4 } from "@dxos/util";
|
|
1741
|
-
|
|
1788
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
1742
1789
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1743
1790
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1744
1791
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1747,7 +1794,8 @@ var __decorate7 = function(decorators, target, key, desc) {
|
|
|
1747
1794
|
if (d = decorators[i])
|
|
1748
1795
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1749
1796
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1750
|
-
}
|
|
1797
|
+
}
|
|
1798
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-protocol.ts";
|
|
1751
1799
|
var MOCK_AUTH_PROVIDER = async (nonce) => Buffer.from("mock");
|
|
1752
1800
|
var MOCK_AUTH_VERIFIER = async (nonce, credential) => true;
|
|
1753
1801
|
var SpaceProtocol = class {
|
|
@@ -1761,7 +1809,7 @@ var SpaceProtocol = class {
|
|
|
1761
1809
|
this.blobSync = new BlobSync({
|
|
1762
1810
|
blobStore
|
|
1763
1811
|
});
|
|
1764
|
-
this._topic =
|
|
1812
|
+
this._topic = subtleCrypto2.digest("SHA-256", topic.asBuffer()).then(discoveryKey).then(PublicKey5.from);
|
|
1765
1813
|
}
|
|
1766
1814
|
get sessions() {
|
|
1767
1815
|
return this._sessions;
|
|
@@ -1777,10 +1825,10 @@ var SpaceProtocol = class {
|
|
|
1777
1825
|
log11("addFeed", {
|
|
1778
1826
|
key: feed.key
|
|
1779
1827
|
}, {
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1828
|
+
F: __dxlog_file11,
|
|
1829
|
+
L: 96,
|
|
1830
|
+
S: this,
|
|
1831
|
+
C: (f, a) => f(...a)
|
|
1784
1832
|
});
|
|
1785
1833
|
this._feeds.add(feed);
|
|
1786
1834
|
for (const session of this._sessions.values()) {
|
|
@@ -1798,41 +1846,41 @@ var SpaceProtocol = class {
|
|
|
1798
1846
|
sampleSize: 20
|
|
1799
1847
|
};
|
|
1800
1848
|
await this.blobSync.open();
|
|
1801
|
-
log11("starting...",
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1849
|
+
log11("starting...", void 0, {
|
|
1850
|
+
F: __dxlog_file11,
|
|
1851
|
+
L: 121,
|
|
1852
|
+
S: this,
|
|
1853
|
+
C: (f, a) => f(...a)
|
|
1806
1854
|
});
|
|
1807
1855
|
this._connection = await this._networkManager.joinSwarm({
|
|
1808
1856
|
protocolProvider: this._createProtocolProvider(credentials),
|
|
1809
1857
|
peerId: this._swarmIdentity.peerKey,
|
|
1810
|
-
topic: this._topic,
|
|
1858
|
+
topic: await this._topic,
|
|
1811
1859
|
topology: new MMSTTopology(topologyConfig),
|
|
1812
1860
|
label: `Protocol swarm: ${this._topic}`
|
|
1813
1861
|
});
|
|
1814
|
-
log11("started",
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1862
|
+
log11("started", void 0, {
|
|
1863
|
+
F: __dxlog_file11,
|
|
1864
|
+
L: 130,
|
|
1865
|
+
S: this,
|
|
1866
|
+
C: (f, a) => f(...a)
|
|
1819
1867
|
});
|
|
1820
1868
|
}
|
|
1821
1869
|
async stop() {
|
|
1822
1870
|
await this.blobSync.close();
|
|
1823
1871
|
if (this._connection) {
|
|
1824
|
-
log11("stopping...",
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1872
|
+
log11("stopping...", void 0, {
|
|
1873
|
+
F: __dxlog_file11,
|
|
1874
|
+
L: 137,
|
|
1875
|
+
S: this,
|
|
1876
|
+
C: (f, a) => f(...a)
|
|
1829
1877
|
});
|
|
1830
1878
|
await this._connection.close();
|
|
1831
|
-
log11("stopped",
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1879
|
+
log11("stopped", void 0, {
|
|
1880
|
+
F: __dxlog_file11,
|
|
1881
|
+
L: 139,
|
|
1882
|
+
S: this,
|
|
1883
|
+
C: (f, a) => f(...a)
|
|
1836
1884
|
});
|
|
1837
1885
|
}
|
|
1838
1886
|
}
|
|
@@ -1853,10 +1901,10 @@ var SpaceProtocol = class {
|
|
|
1853
1901
|
};
|
|
1854
1902
|
}
|
|
1855
1903
|
};
|
|
1856
|
-
|
|
1904
|
+
_ts_decorate7([
|
|
1857
1905
|
logInfo2
|
|
1858
1906
|
], SpaceProtocol.prototype, "_topic", void 0);
|
|
1859
|
-
|
|
1907
|
+
_ts_decorate7([
|
|
1860
1908
|
logInfo2
|
|
1861
1909
|
], SpaceProtocol.prototype, "_ownPeerKey", null);
|
|
1862
1910
|
var AuthStatus;
|
|
@@ -1883,6 +1931,9 @@ var SpaceProtocolSession = class {
|
|
|
1883
1931
|
get authStatus() {
|
|
1884
1932
|
return this._authStatus;
|
|
1885
1933
|
}
|
|
1934
|
+
get stats() {
|
|
1935
|
+
return this._teleport.stats;
|
|
1936
|
+
}
|
|
1886
1937
|
get stream() {
|
|
1887
1938
|
return this._teleport.stream;
|
|
1888
1939
|
}
|
|
@@ -1893,11 +1944,11 @@ var SpaceProtocolSession = class {
|
|
|
1893
1944
|
verifier: this._swarmIdentity.credentialAuthenticator,
|
|
1894
1945
|
onAuthSuccess: () => {
|
|
1895
1946
|
var _a;
|
|
1896
|
-
log11("Peer authenticated",
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1947
|
+
log11("Peer authenticated", void 0, {
|
|
1948
|
+
F: __dxlog_file11,
|
|
1949
|
+
L: 236,
|
|
1950
|
+
S: this,
|
|
1951
|
+
C: (f, a) => f(...a)
|
|
1901
1952
|
});
|
|
1902
1953
|
this._authStatus = AuthStatus.SUCCESS;
|
|
1903
1954
|
(_a = this._onSessionAuth) == null ? void 0 : _a.call(this, this._teleport);
|
|
@@ -1915,10 +1966,10 @@ var SpaceProtocolSession = class {
|
|
|
1915
1966
|
await this._teleport.close();
|
|
1916
1967
|
}
|
|
1917
1968
|
};
|
|
1918
|
-
|
|
1969
|
+
_ts_decorate7([
|
|
1919
1970
|
logInfo2
|
|
1920
1971
|
], SpaceProtocolSession.prototype, "_wireParams", void 0);
|
|
1921
|
-
|
|
1972
|
+
_ts_decorate7([
|
|
1922
1973
|
logInfo2
|
|
1923
1974
|
], SpaceProtocolSession.prototype, "authStatus", null);
|
|
1924
1975
|
|
|
@@ -1929,7 +1980,7 @@ import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
|
1929
1980
|
import { log as log12 } from "@dxos/log";
|
|
1930
1981
|
import { trace } from "@dxos/protocols";
|
|
1931
1982
|
import { ComplexMap as ComplexMap5 } from "@dxos/util";
|
|
1932
|
-
|
|
1983
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
1933
1984
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1934
1985
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1935
1986
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1938,7 +1989,8 @@ var __decorate8 = function(decorators, target, key, desc) {
|
|
|
1938
1989
|
if (d = decorators[i])
|
|
1939
1990
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1940
1991
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1941
|
-
}
|
|
1992
|
+
}
|
|
1993
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
|
|
1942
1994
|
var SpaceManager = class SpaceManager2 {
|
|
1943
1995
|
constructor({ feedStore, networkManager, modelFactory, metadataStore, snapshotStore, blobStore }) {
|
|
1944
1996
|
this._spaces = new ComplexMap5(PublicKey6.hash);
|
|
@@ -1966,18 +2018,18 @@ var SpaceManager = class SpaceManager2 {
|
|
|
1966
2018
|
log12.trace("dxos.echo.space-manager.construct-space", trace.begin({
|
|
1967
2019
|
id: this._instanceId
|
|
1968
2020
|
}), {
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
2021
|
+
F: __dxlog_file12,
|
|
2022
|
+
L: 97,
|
|
2023
|
+
S: this,
|
|
2024
|
+
C: (f, a) => f(...a)
|
|
1973
2025
|
});
|
|
1974
2026
|
log12("constructing space...", {
|
|
1975
2027
|
spaceKey: metadata.genesisFeedKey
|
|
1976
2028
|
}, {
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
2029
|
+
F: __dxlog_file12,
|
|
2030
|
+
L: 98,
|
|
2031
|
+
S: this,
|
|
2032
|
+
C: (f, a) => f(...a)
|
|
1981
2033
|
});
|
|
1982
2034
|
const genesisFeed = await this._feedStore.openFeed((_a = metadata.genesisFeedKey) != null ? _a : failUndefined2());
|
|
1983
2035
|
const spaceKey = metadata.key;
|
|
@@ -2004,21 +2056,21 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2004
2056
|
log12.trace("dxos.echo.space-manager.construct-space", trace.end({
|
|
2005
2057
|
id: this._instanceId
|
|
2006
2058
|
}), {
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2059
|
+
F: __dxlog_file12,
|
|
2060
|
+
L: 125,
|
|
2061
|
+
S: this,
|
|
2062
|
+
C: (f, a) => f(...a)
|
|
2011
2063
|
});
|
|
2012
2064
|
return space;
|
|
2013
2065
|
}
|
|
2014
2066
|
};
|
|
2015
|
-
|
|
2067
|
+
_ts_decorate8([
|
|
2016
2068
|
synchronized5
|
|
2017
2069
|
], SpaceManager.prototype, "open", null);
|
|
2018
|
-
|
|
2070
|
+
_ts_decorate8([
|
|
2019
2071
|
synchronized5
|
|
2020
2072
|
], SpaceManager.prototype, "close", null);
|
|
2021
|
-
SpaceManager =
|
|
2073
|
+
SpaceManager = _ts_decorate8([
|
|
2022
2074
|
trackLeaks4("open", "close")
|
|
2023
2075
|
], SpaceManager);
|
|
2024
2076
|
|
|
@@ -2048,4 +2100,4 @@ export {
|
|
|
2048
2100
|
SpaceProtocolSession,
|
|
2049
2101
|
SpaceManager
|
|
2050
2102
|
};
|
|
2051
|
-
//# sourceMappingURL=chunk-
|
|
2103
|
+
//# sourceMappingURL=chunk-RFRZMQ5T.mjs.map
|