@dxos/echo-pipeline 0.1.56-main.e47dfd1 → 0.1.56-main.ed2f871
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-7U2NXI2P.mjs → chunk-3OTHGQEY.mjs} +531 -251
- package/dist/lib/browser/chunk-3OTHGQEY.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +14 -18
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node/index.cjs +530 -250
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +527 -251
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/types/src/common/feeds.d.ts.map +1 -1
- package/dist/types/src/db-host/data-service-host.d.ts.map +1 -1
- package/dist/types/src/db-host/data-service.d.ts.map +1 -1
- package/dist/types/src/db-host/snapshot-manager.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/types/src/space/auth.d.ts.map +1 -1
- package/dist/types/src/space/data-pipeline.d.ts.map +1 -1
- package/dist/types/src/space/space.d.ts +2 -1
- package/dist/types/src/space/space.d.ts.map +1 -1
- package/dist/types/src/testing/test-agent-builder.d.ts.map +1 -1
- package/package.json +32 -31
- package/src/common/feeds.ts +1 -2
- package/src/db-host/data-service-host.ts +1 -2
- package/src/db-host/data-service.ts +1 -2
- package/src/db-host/snapshot-manager.ts +0 -2
- package/src/metadata/metadata-store.ts +2 -2
- package/src/pipeline/message-selector.ts +1 -2
- package/src/pipeline/pipeline.test.ts +37 -1
- package/src/pipeline/pipeline.ts +3 -2
- package/src/space/auth.ts +1 -2
- package/src/space/data-pipeline.ts +1 -2
- package/src/space/space.test.ts +18 -17
- package/src/space/space.ts +6 -3
- package/src/testing/test-agent-builder.ts +2 -1
- package/dist/lib/browser/chunk-7U2NXI2P.mjs.map +0 -7
|
@@ -7,23 +7,40 @@ var codec = schema.getCodecForType("dxos.echo.feed.FeedMessage");
|
|
|
7
7
|
var valueEncoding = createCodecEncoding(codec);
|
|
8
8
|
|
|
9
9
|
// packages/core/echo/echo-pipeline/src/common/feeds.ts
|
|
10
|
-
import invariant from "
|
|
10
|
+
import { invariant } from "@dxos/invariant";
|
|
11
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/common/feeds.ts";
|
|
11
12
|
var createMappedFeedWriter = (mapper, writer) => {
|
|
12
|
-
invariant(mapper
|
|
13
|
-
|
|
13
|
+
invariant(mapper, void 0, {
|
|
14
|
+
F: __dxlog_file,
|
|
15
|
+
L: 16,
|
|
16
|
+
S: void 0,
|
|
17
|
+
A: [
|
|
18
|
+
"mapper",
|
|
19
|
+
""
|
|
20
|
+
]
|
|
21
|
+
});
|
|
22
|
+
invariant(writer, void 0, {
|
|
23
|
+
F: __dxlog_file,
|
|
24
|
+
L: 17,
|
|
25
|
+
S: void 0,
|
|
26
|
+
A: [
|
|
27
|
+
"writer",
|
|
28
|
+
""
|
|
29
|
+
]
|
|
30
|
+
});
|
|
14
31
|
return {
|
|
15
32
|
write: async (data, options) => await writer.write(await mapper(data), options)
|
|
16
33
|
};
|
|
17
34
|
};
|
|
18
35
|
|
|
19
36
|
// packages/core/echo/echo-pipeline/src/db-host/data-service-host.ts
|
|
20
|
-
import invariant2 from "tiny-invariant";
|
|
21
37
|
import { Stream } from "@dxos/codec-protobuf";
|
|
22
38
|
import { Context } from "@dxos/context";
|
|
23
39
|
import { tagMutationsInBatch, setMetadataOnObject } from "@dxos/echo-db";
|
|
40
|
+
import { invariant as invariant2 } from "@dxos/invariant";
|
|
24
41
|
import { log } from "@dxos/log";
|
|
25
42
|
import { ComplexMap } from "@dxos/util";
|
|
26
|
-
var
|
|
43
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/db-host/data-service-host.ts";
|
|
27
44
|
var DataServiceHost = class {
|
|
28
45
|
constructor(_itemManager, _itemDemuxer, _writeStream) {
|
|
29
46
|
this._itemManager = _itemManager;
|
|
@@ -50,15 +67,22 @@ var DataServiceHost = class {
|
|
|
50
67
|
}
|
|
51
68
|
});
|
|
52
69
|
this._itemDemuxer.mutation.on(ctx, (message) => {
|
|
53
|
-
var _a;
|
|
54
70
|
const { batch, meta } = message;
|
|
55
|
-
invariant2(!meta.clientTag, "Unexpected client tag in mutation message"
|
|
71
|
+
invariant2(!meta.clientTag, "Unexpected client tag in mutation message", {
|
|
72
|
+
F: __dxlog_file2,
|
|
73
|
+
L: 61,
|
|
74
|
+
S: this,
|
|
75
|
+
A: [
|
|
76
|
+
"!(meta as any).clientTag",
|
|
77
|
+
"'Unexpected client tag in mutation message'"
|
|
78
|
+
]
|
|
79
|
+
});
|
|
56
80
|
log("message", {
|
|
57
81
|
batch,
|
|
58
82
|
meta
|
|
59
83
|
}, {
|
|
60
|
-
F:
|
|
61
|
-
L:
|
|
84
|
+
F: __dxlog_file2,
|
|
85
|
+
L: 62,
|
|
62
86
|
S: this,
|
|
63
87
|
C: (f, a) => f(...a)
|
|
64
88
|
});
|
|
@@ -66,7 +90,7 @@ var DataServiceHost = class {
|
|
|
66
90
|
message.meta.feedKey,
|
|
67
91
|
message.meta.seq
|
|
68
92
|
]);
|
|
69
|
-
|
|
93
|
+
batch.objects?.forEach((object) => {
|
|
70
94
|
setMetadataOnObject(object, {
|
|
71
95
|
...meta
|
|
72
96
|
});
|
|
@@ -84,15 +108,30 @@ var DataServiceHost = class {
|
|
|
84
108
|
});
|
|
85
109
|
}
|
|
86
110
|
async write(request) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
111
|
+
invariant2(!this._ctx.disposed, "Cannot write to closed DataServiceHost", {
|
|
112
|
+
F: __dxlog_file2,
|
|
113
|
+
L: 88,
|
|
114
|
+
S: this,
|
|
115
|
+
A: [
|
|
116
|
+
"!this._ctx.disposed",
|
|
117
|
+
"'Cannot write to closed DataServiceHost'"
|
|
118
|
+
]
|
|
119
|
+
});
|
|
120
|
+
invariant2(this._writeStream, "Cannot write mutations in readonly mode", {
|
|
121
|
+
F: __dxlog_file2,
|
|
122
|
+
L: 89,
|
|
123
|
+
S: this,
|
|
124
|
+
A: [
|
|
125
|
+
"this._writeStream",
|
|
126
|
+
"'Cannot write mutations in readonly mode'"
|
|
127
|
+
]
|
|
128
|
+
});
|
|
90
129
|
log("write", {
|
|
91
130
|
clientTag: request.clientTag,
|
|
92
|
-
objectCount:
|
|
131
|
+
objectCount: request.batch.objects?.length ?? 0
|
|
93
132
|
}, {
|
|
94
|
-
F:
|
|
95
|
-
L:
|
|
133
|
+
F: __dxlog_file2,
|
|
134
|
+
L: 91,
|
|
96
135
|
S: this,
|
|
97
136
|
C: (f, a) => f(...a)
|
|
98
137
|
});
|
|
@@ -105,8 +144,8 @@ var DataServiceHost = class {
|
|
|
105
144
|
feedKey: receipt2.feedKey,
|
|
106
145
|
seq: receipt2.seq
|
|
107
146
|
}, {
|
|
108
|
-
F:
|
|
109
|
-
L:
|
|
147
|
+
F: __dxlog_file2,
|
|
148
|
+
L: 100,
|
|
110
149
|
S: this,
|
|
111
150
|
C: (f, a) => f(...a)
|
|
112
151
|
});
|
|
@@ -120,24 +159,18 @@ var DataServiceHost = class {
|
|
|
120
159
|
return receipt;
|
|
121
160
|
}
|
|
122
161
|
};
|
|
123
|
-
var createDataMessage = (batch) => {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
meta: void 0
|
|
136
|
-
};
|
|
137
|
-
})
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
};
|
|
162
|
+
var createDataMessage = (batch) => ({
|
|
163
|
+
batch: {
|
|
164
|
+
objects: batch.objects?.map((object) => ({
|
|
165
|
+
...object,
|
|
166
|
+
mutations: object.mutations?.map((mutation) => ({
|
|
167
|
+
...mutation,
|
|
168
|
+
meta: void 0
|
|
169
|
+
})),
|
|
170
|
+
meta: void 0
|
|
171
|
+
}))
|
|
172
|
+
}
|
|
173
|
+
});
|
|
141
174
|
|
|
142
175
|
// packages/core/echo/echo-pipeline/src/db-host/database-host.ts
|
|
143
176
|
import { ItemDemuxer } from "@dxos/echo-db";
|
|
@@ -166,15 +199,13 @@ var DatabaseHost = class {
|
|
|
166
199
|
return this._itemDemuxer.createSnapshot();
|
|
167
200
|
}
|
|
168
201
|
createDataServiceHost() {
|
|
169
|
-
|
|
170
|
-
return new DataServiceHost(this._itemManager, this._itemDemuxer, (_a = this._outboundStream) != null ? _a : void 0);
|
|
202
|
+
return new DataServiceHost(this._itemManager, this._itemDemuxer, this._outboundStream ?? void 0);
|
|
171
203
|
}
|
|
172
204
|
};
|
|
173
205
|
|
|
174
206
|
// packages/core/echo/echo-pipeline/src/db-host/snapshot-manager.ts
|
|
175
207
|
import { trackLeaks } from "@dxos/async";
|
|
176
208
|
import { cancelWithContext } from "@dxos/context";
|
|
177
|
-
import { timed } from "@dxos/debug";
|
|
178
209
|
import { PublicKey } from "@dxos/keys";
|
|
179
210
|
import { schema as schema2 } from "@dxos/protocols";
|
|
180
211
|
import { BlobMeta } from "@dxos/protocols/proto/dxos/echo/blob";
|
|
@@ -219,9 +250,6 @@ var SnapshotManager = class SnapshotManager2 {
|
|
|
219
250
|
return PublicKey.from(id).toHex();
|
|
220
251
|
}
|
|
221
252
|
};
|
|
222
|
-
_ts_decorate([
|
|
223
|
-
timed(1e4)
|
|
224
|
-
], SnapshotManager.prototype, "load", null);
|
|
225
253
|
SnapshotManager = _ts_decorate([
|
|
226
254
|
trackLeaks("open", "close")
|
|
227
255
|
], SnapshotManager);
|
|
@@ -273,12 +301,12 @@ var SnapshotStore = class {
|
|
|
273
301
|
};
|
|
274
302
|
|
|
275
303
|
// packages/core/echo/echo-pipeline/src/db-host/data-service.ts
|
|
276
|
-
import invariant3 from "tiny-invariant";
|
|
277
304
|
import { raise } from "@dxos/debug";
|
|
305
|
+
import { invariant as invariant3 } from "@dxos/invariant";
|
|
278
306
|
import { PublicKey as PublicKey2 } from "@dxos/keys";
|
|
279
307
|
import { log as log2 } from "@dxos/log";
|
|
280
308
|
import { ComplexMap as ComplexMap2 } from "@dxos/util";
|
|
281
|
-
var
|
|
309
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/db-host/data-service.ts";
|
|
282
310
|
var DataServiceSubscriptions = class {
|
|
283
311
|
constructor() {
|
|
284
312
|
this._spaces = new ComplexMap2(PublicKey2.hash);
|
|
@@ -290,12 +318,20 @@ var DataServiceSubscriptions = class {
|
|
|
290
318
|
log2("Registering space", {
|
|
291
319
|
spaceKey
|
|
292
320
|
}, {
|
|
293
|
-
F:
|
|
294
|
-
L:
|
|
321
|
+
F: __dxlog_file3,
|
|
322
|
+
L: 30,
|
|
295
323
|
S: this,
|
|
296
324
|
C: (f, a) => f(...a)
|
|
297
325
|
});
|
|
298
|
-
invariant3(!this._spaces.has(spaceKey)
|
|
326
|
+
invariant3(!this._spaces.has(spaceKey), void 0, {
|
|
327
|
+
F: __dxlog_file3,
|
|
328
|
+
L: 31,
|
|
329
|
+
S: this,
|
|
330
|
+
A: [
|
|
331
|
+
"!this._spaces.has(spaceKey)",
|
|
332
|
+
""
|
|
333
|
+
]
|
|
334
|
+
});
|
|
299
335
|
await host.open();
|
|
300
336
|
this._spaces.set(spaceKey, host);
|
|
301
337
|
}
|
|
@@ -303,13 +339,13 @@ var DataServiceSubscriptions = class {
|
|
|
303
339
|
log2("Unregistering space", {
|
|
304
340
|
spaceKey
|
|
305
341
|
}, {
|
|
306
|
-
F:
|
|
307
|
-
L:
|
|
342
|
+
F: __dxlog_file3,
|
|
343
|
+
L: 37,
|
|
308
344
|
S: this,
|
|
309
345
|
C: (f, a) => f(...a)
|
|
310
346
|
});
|
|
311
347
|
const host = this._spaces.get(spaceKey);
|
|
312
|
-
await
|
|
348
|
+
await host?.close();
|
|
313
349
|
this._spaces.delete(spaceKey);
|
|
314
350
|
}
|
|
315
351
|
getDataService(spaceKey) {
|
|
@@ -321,25 +357,47 @@ var DataServiceImpl = class {
|
|
|
321
357
|
this._subscriptions = _subscriptions;
|
|
322
358
|
}
|
|
323
359
|
subscribe(request) {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
360
|
+
invariant3(request.spaceKey, void 0, {
|
|
361
|
+
F: __dxlog_file3,
|
|
362
|
+
L: 56,
|
|
363
|
+
S: this,
|
|
364
|
+
A: [
|
|
365
|
+
"request.spaceKey",
|
|
366
|
+
""
|
|
367
|
+
]
|
|
368
|
+
});
|
|
369
|
+
const host = this._subscriptions.getDataService(request.spaceKey) ?? raise(new Error(`space not found: ${request.spaceKey}`));
|
|
327
370
|
return host.subscribe();
|
|
328
371
|
}
|
|
329
372
|
write(request) {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
373
|
+
invariant3(request.spaceKey, void 0, {
|
|
374
|
+
F: __dxlog_file3,
|
|
375
|
+
L: 63,
|
|
376
|
+
S: this,
|
|
377
|
+
A: [
|
|
378
|
+
"request.spaceKey",
|
|
379
|
+
""
|
|
380
|
+
]
|
|
381
|
+
});
|
|
382
|
+
invariant3(request.batch, void 0, {
|
|
383
|
+
F: __dxlog_file3,
|
|
384
|
+
L: 64,
|
|
385
|
+
S: this,
|
|
386
|
+
A: [
|
|
387
|
+
"request.batch",
|
|
388
|
+
""
|
|
389
|
+
]
|
|
390
|
+
});
|
|
391
|
+
const host = this._subscriptions.getDataService(request.spaceKey) ?? raise(new Error(`space not found: ${request.spaceKey}`));
|
|
334
392
|
return host.write(request);
|
|
335
393
|
}
|
|
336
394
|
};
|
|
337
395
|
|
|
338
396
|
// packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts
|
|
339
397
|
import CRC32 from "crc-32";
|
|
340
|
-
import invariant4 from "tiny-invariant";
|
|
341
398
|
import { synchronized, Event } from "@dxos/async";
|
|
342
399
|
import { DataCorruptionError } from "@dxos/errors";
|
|
400
|
+
import { invariant as invariant4 } from "@dxos/invariant";
|
|
343
401
|
import { log as log3 } from "@dxos/log";
|
|
344
402
|
import { STORAGE_VERSION, schema as schema4 } from "@dxos/protocols";
|
|
345
403
|
import { SpaceState } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -354,12 +412,12 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
354
412
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
355
413
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
356
414
|
}
|
|
357
|
-
var
|
|
415
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts";
|
|
358
416
|
var emptyEchoMetadata = () => ({
|
|
359
417
|
version: STORAGE_VERSION,
|
|
360
418
|
spaces: [],
|
|
361
|
-
created: new Date(),
|
|
362
|
-
updated: new Date()
|
|
419
|
+
created: /* @__PURE__ */ new Date(),
|
|
420
|
+
updated: /* @__PURE__ */ new Date()
|
|
363
421
|
});
|
|
364
422
|
var EchoMetadata = schema4.getCodecForType("dxos.echo.metadata.EchoMetadata");
|
|
365
423
|
var MetadataStore = class {
|
|
@@ -373,22 +431,19 @@ var MetadataStore = class {
|
|
|
373
431
|
return this._metadata;
|
|
374
432
|
}
|
|
375
433
|
get version() {
|
|
376
|
-
|
|
377
|
-
return (_a = this._metadata.version) != null ? _a : 0;
|
|
434
|
+
return this._metadata.version ?? 0;
|
|
378
435
|
}
|
|
379
436
|
/**
|
|
380
437
|
* Returns a list of currently saved spaces. The list and objects in it can be modified addSpace and
|
|
381
438
|
* addSpaceFeed functions.
|
|
382
439
|
*/
|
|
383
440
|
get spaces() {
|
|
384
|
-
|
|
385
|
-
return (_a = this._metadata.spaces) != null ? _a : [];
|
|
441
|
+
return this._metadata.spaces ?? [];
|
|
386
442
|
}
|
|
387
443
|
/**
|
|
388
444
|
* Loads metadata from persistent storage.
|
|
389
445
|
*/
|
|
390
446
|
async load() {
|
|
391
|
-
var _a;
|
|
392
447
|
const file = this._directory.getOrCreateFile("EchoMetadata");
|
|
393
448
|
try {
|
|
394
449
|
const { size: fileLength } = await file.stat();
|
|
@@ -401,13 +456,16 @@ var MetadataStore = class {
|
|
|
401
456
|
size: dataSize,
|
|
402
457
|
checksum
|
|
403
458
|
}, {
|
|
404
|
-
F:
|
|
459
|
+
F: __dxlog_file4,
|
|
405
460
|
L: 72,
|
|
406
461
|
S: this,
|
|
407
462
|
C: (f, a) => f(...a)
|
|
408
463
|
});
|
|
409
464
|
if (fileLength < dataSize + 8) {
|
|
410
|
-
throw new DataCorruptionError("Metadata size is smaller than expected."
|
|
465
|
+
throw new DataCorruptionError("Metadata size is smaller than expected.", {
|
|
466
|
+
fileLength,
|
|
467
|
+
dataSize
|
|
468
|
+
});
|
|
411
469
|
}
|
|
412
470
|
const data = await file.read(8, dataSize);
|
|
413
471
|
const calculatedChecksum = CRC32.buf(data);
|
|
@@ -415,15 +473,14 @@ var MetadataStore = class {
|
|
|
415
473
|
throw new DataCorruptionError("Metadata checksum is invalid.");
|
|
416
474
|
}
|
|
417
475
|
this._metadata = EchoMetadata.decode(data);
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
(_a2 = space.state) != null ? _a2 : space.state = SpaceState.ACTIVE;
|
|
476
|
+
this._metadata.spaces?.forEach((space) => {
|
|
477
|
+
space.state ??= SpaceState.ACTIVE;
|
|
421
478
|
});
|
|
422
479
|
} catch (err) {
|
|
423
480
|
log3.error("failed to load metadata", {
|
|
424
481
|
err
|
|
425
482
|
}, {
|
|
426
|
-
F:
|
|
483
|
+
F: __dxlog_file4,
|
|
427
484
|
L: 92,
|
|
428
485
|
S: this,
|
|
429
486
|
C: (f, a) => f(...a)
|
|
@@ -434,12 +491,11 @@ var MetadataStore = class {
|
|
|
434
491
|
}
|
|
435
492
|
}
|
|
436
493
|
async _save() {
|
|
437
|
-
var _a;
|
|
438
494
|
const data = {
|
|
439
495
|
...this._metadata,
|
|
440
496
|
version: STORAGE_VERSION,
|
|
441
|
-
created:
|
|
442
|
-
updated: new Date()
|
|
497
|
+
created: this._metadata.created ?? /* @__PURE__ */ new Date(),
|
|
498
|
+
updated: /* @__PURE__ */ new Date()
|
|
443
499
|
};
|
|
444
500
|
this.update.emit(data);
|
|
445
501
|
const file = this._directory.getOrCreateFile("EchoMetadata");
|
|
@@ -455,7 +511,7 @@ var MetadataStore = class {
|
|
|
455
511
|
size: encoded.length,
|
|
456
512
|
checksum
|
|
457
513
|
}, {
|
|
458
|
-
F:
|
|
514
|
+
F: __dxlog_file4,
|
|
459
515
|
L: 124,
|
|
460
516
|
S: this,
|
|
461
517
|
C: (f, a) => f(...a)
|
|
@@ -465,12 +521,19 @@ var MetadataStore = class {
|
|
|
465
521
|
}
|
|
466
522
|
}
|
|
467
523
|
_getSpace(spaceKey) {
|
|
468
|
-
|
|
469
|
-
if ((_a = this._metadata.identity) == null ? void 0 : _a.haloSpace.key.equals(spaceKey)) {
|
|
524
|
+
if (this._metadata.identity?.haloSpace.key.equals(spaceKey)) {
|
|
470
525
|
return this._metadata.identity.haloSpace;
|
|
471
526
|
}
|
|
472
527
|
const space = this.spaces.find((space2) => space2.key === spaceKey);
|
|
473
|
-
invariant4(space, "Space not found"
|
|
528
|
+
invariant4(space, "Space not found", {
|
|
529
|
+
F: __dxlog_file4,
|
|
530
|
+
L: 137,
|
|
531
|
+
S: this,
|
|
532
|
+
A: [
|
|
533
|
+
"space",
|
|
534
|
+
"'Space not found'"
|
|
535
|
+
]
|
|
536
|
+
});
|
|
474
537
|
return space;
|
|
475
538
|
}
|
|
476
539
|
/**
|
|
@@ -478,7 +541,7 @@ var MetadataStore = class {
|
|
|
478
541
|
*/
|
|
479
542
|
async clear() {
|
|
480
543
|
log3("clearing all metadata", void 0, {
|
|
481
|
-
F:
|
|
544
|
+
F: __dxlog_file4,
|
|
482
545
|
L: 145,
|
|
483
546
|
S: this,
|
|
484
547
|
C: (f, a) => f(...a)
|
|
@@ -490,14 +553,29 @@ var MetadataStore = class {
|
|
|
490
553
|
return this._metadata.identity;
|
|
491
554
|
}
|
|
492
555
|
async setIdentityRecord(record) {
|
|
493
|
-
invariant4(!this._metadata.identity, "Cannot overwrite existing identity in metadata"
|
|
556
|
+
invariant4(!this._metadata.identity, "Cannot overwrite existing identity in metadata", {
|
|
557
|
+
F: __dxlog_file4,
|
|
558
|
+
L: 155,
|
|
559
|
+
S: this,
|
|
560
|
+
A: [
|
|
561
|
+
"!this._metadata.identity",
|
|
562
|
+
"'Cannot overwrite existing identity in metadata'"
|
|
563
|
+
]
|
|
564
|
+
});
|
|
494
565
|
this._metadata.identity = record;
|
|
495
566
|
await this._save();
|
|
496
567
|
}
|
|
497
568
|
async addSpace(record) {
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
569
|
+
invariant4(!(this._metadata.spaces ?? []).find((space) => space.key === record.key), "Cannot overwrite existing space in metadata", {
|
|
570
|
+
F: __dxlog_file4,
|
|
571
|
+
L: 162,
|
|
572
|
+
S: this,
|
|
573
|
+
A: [
|
|
574
|
+
"!(this._metadata.spaces ?? []).find((space) => space.key === record.key)",
|
|
575
|
+
"'Cannot overwrite existing space in metadata'"
|
|
576
|
+
]
|
|
577
|
+
});
|
|
578
|
+
(this._metadata.spaces ??= []).push(record);
|
|
501
579
|
await this._save();
|
|
502
580
|
}
|
|
503
581
|
async setSpaceDataLatestTimeframe(spaceKey, timeframe) {
|
|
@@ -533,7 +611,7 @@ var fromBytesInt32 = (buf) => buf.readInt32LE(0);
|
|
|
533
611
|
|
|
534
612
|
// packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts
|
|
535
613
|
import { Event as Event2 } from "@dxos/async";
|
|
536
|
-
import { timed
|
|
614
|
+
import { timed } from "@dxos/debug";
|
|
537
615
|
import { log as log4 } from "@dxos/log";
|
|
538
616
|
import { Timeframe } from "@dxos/timeframe";
|
|
539
617
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
@@ -546,7 +624,7 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
546
624
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
547
625
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
548
626
|
}
|
|
549
|
-
var
|
|
627
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts";
|
|
550
628
|
var mapTimeframeToFeedIndexes = (timeframe) => timeframe.frames().map(([feedKey, index]) => ({
|
|
551
629
|
feedKey,
|
|
552
630
|
index
|
|
@@ -605,7 +683,7 @@ var TimeframeClock = class {
|
|
|
605
683
|
target,
|
|
606
684
|
current: this._timeframe
|
|
607
685
|
}, {
|
|
608
|
-
F:
|
|
686
|
+
F: __dxlog_file5,
|
|
609
687
|
L: 73,
|
|
610
688
|
S: this,
|
|
611
689
|
C: (f, a) => f(...a)
|
|
@@ -616,7 +694,7 @@ var TimeframeClock = class {
|
|
|
616
694
|
current: this._timeframe,
|
|
617
695
|
deps: Timeframe.dependencies(target, this._timeframe)
|
|
618
696
|
}, {
|
|
619
|
-
F:
|
|
697
|
+
F: __dxlog_file5,
|
|
620
698
|
L: 75,
|
|
621
699
|
S: this,
|
|
622
700
|
C: (f, a) => f(...a)
|
|
@@ -626,36 +704,44 @@ var TimeframeClock = class {
|
|
|
626
704
|
}
|
|
627
705
|
};
|
|
628
706
|
_ts_decorate3([
|
|
629
|
-
|
|
707
|
+
timed(5e3)
|
|
630
708
|
], TimeframeClock.prototype, "waitUntilReached", null);
|
|
631
709
|
|
|
632
710
|
// packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts
|
|
633
|
-
import invariant6 from "tiny-invariant";
|
|
634
711
|
import { Event as Event3, sleep, synchronized as synchronized2, Trigger } from "@dxos/async";
|
|
635
712
|
import { Context as Context2, rejectOnDispose } from "@dxos/context";
|
|
636
713
|
import { failUndefined } from "@dxos/debug";
|
|
637
714
|
import { FeedSetIterator } from "@dxos/feed-store";
|
|
715
|
+
import { invariant as invariant6 } from "@dxos/invariant";
|
|
638
716
|
import { PublicKey as PublicKey3 } from "@dxos/keys";
|
|
639
717
|
import { log as log6 } from "@dxos/log";
|
|
640
718
|
import { Timeframe as Timeframe2 } from "@dxos/timeframe";
|
|
641
719
|
import { ComplexMap as ComplexMap3 } from "@dxos/util";
|
|
642
720
|
|
|
643
721
|
// packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts
|
|
644
|
-
import invariant5 from "
|
|
722
|
+
import { invariant as invariant5 } from "@dxos/invariant";
|
|
645
723
|
import { log as log5 } from "@dxos/log";
|
|
646
|
-
var
|
|
724
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts";
|
|
647
725
|
var createMessageSelector = (timeframeClock) => {
|
|
648
726
|
return (messages) => {
|
|
649
727
|
for (let i = 0; i < messages.length; i++) {
|
|
650
728
|
const { data: { timeframe } } = messages[i];
|
|
651
|
-
invariant5(timeframe
|
|
729
|
+
invariant5(timeframe, void 0, {
|
|
730
|
+
F: __dxlog_file6,
|
|
731
|
+
L: 25,
|
|
732
|
+
S: void 0,
|
|
733
|
+
A: [
|
|
734
|
+
"timeframe",
|
|
735
|
+
""
|
|
736
|
+
]
|
|
737
|
+
});
|
|
652
738
|
if (!timeframeClock.hasGaps(timeframe)) {
|
|
653
739
|
return i;
|
|
654
740
|
}
|
|
655
741
|
}
|
|
656
742
|
log5("Skipping...", void 0, {
|
|
657
|
-
F:
|
|
658
|
-
L:
|
|
743
|
+
F: __dxlog_file6,
|
|
744
|
+
L: 33,
|
|
659
745
|
S: void 0,
|
|
660
746
|
C: (f, a) => f(...a)
|
|
661
747
|
});
|
|
@@ -673,7 +759,7 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
673
759
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
674
760
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
675
761
|
}
|
|
676
|
-
var
|
|
762
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts";
|
|
677
763
|
var PipelineState = class {
|
|
678
764
|
// prettier-ignore
|
|
679
765
|
constructor(_feeds, _timeframeClock) {
|
|
@@ -724,18 +810,17 @@ var PipelineState = class {
|
|
|
724
810
|
* @param timeout Timeout in milliseconds to specify the maximum wait time.
|
|
725
811
|
*/
|
|
726
812
|
async waitUntilReachedTargetTimeframe({ ctx = new Context2(), timeout, breakOnStall = true } = {}) {
|
|
727
|
-
var _a;
|
|
728
813
|
log6("waitUntilReachedTargetTimeframe", {
|
|
729
814
|
timeout,
|
|
730
815
|
current: this.timeframe,
|
|
731
816
|
target: this.targetTimeframe
|
|
732
817
|
}, {
|
|
733
|
-
F:
|
|
734
|
-
L:
|
|
818
|
+
F: __dxlog_file7,
|
|
819
|
+
L: 125,
|
|
735
820
|
S: this,
|
|
736
821
|
C: (f, a) => f(...a)
|
|
737
822
|
});
|
|
738
|
-
|
|
823
|
+
this._reachedTargetPromise ??= Promise.race([
|
|
739
824
|
this._timeframeClock.update.waitForCondition(() => {
|
|
740
825
|
return Timeframe2.dependencies(this.targetTimeframe, this.timeframe).isEmpty();
|
|
741
826
|
}),
|
|
@@ -761,8 +846,8 @@ var PipelineState = class {
|
|
|
761
846
|
target: this.targetTimeframe,
|
|
762
847
|
dependencies: Timeframe2.dependencies(this.targetTimeframe, this.timeframe)
|
|
763
848
|
}, {
|
|
764
|
-
F:
|
|
765
|
-
L:
|
|
849
|
+
F: __dxlog_file7,
|
|
850
|
+
L: 152,
|
|
766
851
|
S: this,
|
|
767
852
|
C: (f, a) => f(...a)
|
|
768
853
|
});
|
|
@@ -791,7 +876,15 @@ var Pipeline = class {
|
|
|
791
876
|
return this._state;
|
|
792
877
|
}
|
|
793
878
|
get writer() {
|
|
794
|
-
invariant6(this._writer, "Writer not set."
|
|
879
|
+
invariant6(this._writer, "Writer not set.", {
|
|
880
|
+
F: __dxlog_file7,
|
|
881
|
+
L: 230,
|
|
882
|
+
S: this,
|
|
883
|
+
A: [
|
|
884
|
+
"this._writer",
|
|
885
|
+
"'Writer not set.'"
|
|
886
|
+
]
|
|
887
|
+
});
|
|
795
888
|
return this._writer;
|
|
796
889
|
}
|
|
797
890
|
hasFeed(feedKey) {
|
|
@@ -810,16 +903,41 @@ var Pipeline = class {
|
|
|
810
903
|
this._setFeedDownloadState(feed);
|
|
811
904
|
}
|
|
812
905
|
setWriteFeed(feed) {
|
|
813
|
-
invariant6(!this._writer, "Writer already set."
|
|
814
|
-
|
|
906
|
+
invariant6(!this._writer, "Writer already set.", {
|
|
907
|
+
F: __dxlog_file7,
|
|
908
|
+
L: 253,
|
|
909
|
+
S: this,
|
|
910
|
+
A: [
|
|
911
|
+
"!this._writer",
|
|
912
|
+
"'Writer already set.'"
|
|
913
|
+
]
|
|
914
|
+
});
|
|
915
|
+
invariant6(feed.properties.writable, "Feed must be writable.", {
|
|
916
|
+
F: __dxlog_file7,
|
|
917
|
+
L: 254,
|
|
918
|
+
S: this,
|
|
919
|
+
A: [
|
|
920
|
+
"feed.properties.writable",
|
|
921
|
+
"'Feed must be writable.'"
|
|
922
|
+
]
|
|
923
|
+
});
|
|
815
924
|
this._writer = createMappedFeedWriter((payload) => ({
|
|
816
925
|
timeframe: this._timeframeClock.timeframe,
|
|
817
926
|
payload
|
|
818
927
|
}), feed.createFeedWriter());
|
|
819
928
|
}
|
|
820
929
|
async start() {
|
|
930
|
+
invariant6(!this._isStarted, "Pipeline is already started.", {
|
|
931
|
+
F: __dxlog_file7,
|
|
932
|
+
L: 267,
|
|
933
|
+
S: this,
|
|
934
|
+
A: [
|
|
935
|
+
"!this._isStarted",
|
|
936
|
+
"'Pipeline is already started.'"
|
|
937
|
+
]
|
|
938
|
+
});
|
|
821
939
|
log6("starting...", void 0, {
|
|
822
|
-
F:
|
|
940
|
+
F: __dxlog_file7,
|
|
823
941
|
L: 268,
|
|
824
942
|
S: this,
|
|
825
943
|
C: (f, a) => f(...a)
|
|
@@ -828,29 +946,28 @@ var Pipeline = class {
|
|
|
828
946
|
await this._feedSetIterator.open();
|
|
829
947
|
this._isStarted = true;
|
|
830
948
|
log6("started", void 0, {
|
|
831
|
-
F:
|
|
949
|
+
F: __dxlog_file7,
|
|
832
950
|
L: 272,
|
|
833
951
|
S: this,
|
|
834
952
|
C: (f, a) => f(...a)
|
|
835
953
|
});
|
|
836
954
|
}
|
|
837
955
|
async stop() {
|
|
838
|
-
var _a;
|
|
839
956
|
log6("stopping...", void 0, {
|
|
840
|
-
F:
|
|
957
|
+
F: __dxlog_file7,
|
|
841
958
|
L: 277,
|
|
842
959
|
S: this,
|
|
843
960
|
C: (f, a) => f(...a)
|
|
844
961
|
});
|
|
845
962
|
this._isStopping = true;
|
|
846
|
-
await
|
|
963
|
+
await this._feedSetIterator?.close();
|
|
847
964
|
await this._processingTrigger.wait();
|
|
848
965
|
await this._state._ctx.dispose();
|
|
849
966
|
this._state._ctx = new Context2();
|
|
850
967
|
this._state._reachedTargetPromise = void 0;
|
|
851
968
|
this._isStarted = false;
|
|
852
969
|
log6("stopped", void 0, {
|
|
853
|
-
F:
|
|
970
|
+
F: __dxlog_file7,
|
|
854
971
|
L: 285,
|
|
855
972
|
S: this,
|
|
856
973
|
C: (f, a) => f(...a)
|
|
@@ -861,7 +978,15 @@ var Pipeline = class {
|
|
|
861
978
|
* The pipeline will start processing messages AFTER this timeframe.
|
|
862
979
|
*/
|
|
863
980
|
async setCursor(timeframe) {
|
|
864
|
-
invariant6(!this._isStarted || this._isPaused, "Invalid state."
|
|
981
|
+
invariant6(!this._isStarted || this._isPaused, "Invalid state.", {
|
|
982
|
+
F: __dxlog_file7,
|
|
983
|
+
L: 294,
|
|
984
|
+
S: this,
|
|
985
|
+
A: [
|
|
986
|
+
"!this._isStarted || this._isPaused",
|
|
987
|
+
"'Invalid state.'"
|
|
988
|
+
]
|
|
989
|
+
});
|
|
865
990
|
this._state._startTimeframe = timeframe;
|
|
866
991
|
this._timeframeClock.setTimeframe(timeframe);
|
|
867
992
|
for (const feed of this._feeds.values()) {
|
|
@@ -877,7 +1002,15 @@ var Pipeline = class {
|
|
|
877
1002
|
* Calling pause while processing will cause a deadlock.
|
|
878
1003
|
*/
|
|
879
1004
|
async pause() {
|
|
880
|
-
invariant6(this._isStarted, "Pipeline is not open."
|
|
1005
|
+
invariant6(this._isStarted, "Pipeline is not open.", {
|
|
1006
|
+
F: __dxlog_file7,
|
|
1007
|
+
L: 316,
|
|
1008
|
+
S: this,
|
|
1009
|
+
A: [
|
|
1010
|
+
"this._isStarted",
|
|
1011
|
+
"'Pipeline is not open.'"
|
|
1012
|
+
]
|
|
1013
|
+
});
|
|
881
1014
|
if (this._isPaused) {
|
|
882
1015
|
return;
|
|
883
1016
|
}
|
|
@@ -886,8 +1019,24 @@ var Pipeline = class {
|
|
|
886
1019
|
this._isPaused = true;
|
|
887
1020
|
}
|
|
888
1021
|
async unpause() {
|
|
889
|
-
invariant6(this._isStarted, "Pipeline is not open."
|
|
890
|
-
|
|
1022
|
+
invariant6(this._isStarted, "Pipeline is not open.", {
|
|
1023
|
+
F: __dxlog_file7,
|
|
1024
|
+
L: 328,
|
|
1025
|
+
S: this,
|
|
1026
|
+
A: [
|
|
1027
|
+
"this._isStarted",
|
|
1028
|
+
"'Pipeline is not open.'"
|
|
1029
|
+
]
|
|
1030
|
+
});
|
|
1031
|
+
invariant6(this._isPaused, "Pipeline is not paused.", {
|
|
1032
|
+
F: __dxlog_file7,
|
|
1033
|
+
L: 329,
|
|
1034
|
+
S: this,
|
|
1035
|
+
A: [
|
|
1036
|
+
"this._isPaused",
|
|
1037
|
+
"'Pipeline is not paused.'"
|
|
1038
|
+
]
|
|
1039
|
+
});
|
|
891
1040
|
this._pauseTrigger.wake();
|
|
892
1041
|
this._isPaused = false;
|
|
893
1042
|
}
|
|
@@ -896,21 +1045,45 @@ var Pipeline = class {
|
|
|
896
1045
|
* Updates the timeframe clock after the message has bee processed.
|
|
897
1046
|
*/
|
|
898
1047
|
async *consume() {
|
|
899
|
-
invariant6(!this._isOpen, "Pipeline is already being consumed."
|
|
1048
|
+
invariant6(!this._isOpen, "Pipeline is already being consumed.", {
|
|
1049
|
+
F: __dxlog_file7,
|
|
1050
|
+
L: 340,
|
|
1051
|
+
S: this,
|
|
1052
|
+
A: [
|
|
1053
|
+
"!this._isOpen",
|
|
1054
|
+
"'Pipeline is already being consumed.'"
|
|
1055
|
+
]
|
|
1056
|
+
});
|
|
900
1057
|
this._isOpen = true;
|
|
901
|
-
invariant6(this._feedSetIterator, "Iterator not initialized."
|
|
1058
|
+
invariant6(this._feedSetIterator, "Iterator not initialized.", {
|
|
1059
|
+
F: __dxlog_file7,
|
|
1060
|
+
L: 343,
|
|
1061
|
+
S: this,
|
|
1062
|
+
A: [
|
|
1063
|
+
"this._feedSetIterator",
|
|
1064
|
+
"'Iterator not initialized.'"
|
|
1065
|
+
]
|
|
1066
|
+
});
|
|
902
1067
|
let lastFeedSetIterator = this._feedSetIterator;
|
|
903
1068
|
let iterable = lastFeedSetIterator[Symbol.asyncIterator]();
|
|
904
1069
|
while (!this._isStopping) {
|
|
905
1070
|
await this._pauseTrigger.wait();
|
|
906
1071
|
if (lastFeedSetIterator !== this._feedSetIterator) {
|
|
907
|
-
invariant6(this._feedSetIterator, "Iterator not initialized."
|
|
1072
|
+
invariant6(this._feedSetIterator, "Iterator not initialized.", {
|
|
1073
|
+
F: __dxlog_file7,
|
|
1074
|
+
L: 352,
|
|
1075
|
+
S: this,
|
|
1076
|
+
A: [
|
|
1077
|
+
"this._feedSetIterator",
|
|
1078
|
+
"'Iterator not initialized.'"
|
|
1079
|
+
]
|
|
1080
|
+
});
|
|
908
1081
|
lastFeedSetIterator = this._feedSetIterator;
|
|
909
1082
|
iterable = lastFeedSetIterator[Symbol.asyncIterator]();
|
|
910
1083
|
}
|
|
911
1084
|
const { done, value } = await iterable.next();
|
|
912
1085
|
if (!done) {
|
|
913
|
-
const block = value
|
|
1086
|
+
const block = value ?? failUndefined();
|
|
914
1087
|
this._processingTrigger.reset();
|
|
915
1088
|
this._timeframeClock.updatePendingTimeframe(PublicKey3.from(block.feedKey), block.seq);
|
|
916
1089
|
yield block;
|
|
@@ -921,13 +1094,12 @@ var Pipeline = class {
|
|
|
921
1094
|
this._isOpen = false;
|
|
922
1095
|
}
|
|
923
1096
|
_setFeedDownloadState(feed) {
|
|
924
|
-
var _a;
|
|
925
1097
|
const timeframe = this._state._startTimeframe;
|
|
926
|
-
const seq =
|
|
1098
|
+
const seq = timeframe.get(feed.key) ?? 0;
|
|
927
1099
|
feed.undownload({
|
|
928
1100
|
callback: () => log6("undownload", void 0, {
|
|
929
|
-
F:
|
|
930
|
-
L:
|
|
1101
|
+
F: __dxlog_file7,
|
|
1102
|
+
L: 377,
|
|
931
1103
|
S: this,
|
|
932
1104
|
C: (f, a) => f(...a)
|
|
933
1105
|
})
|
|
@@ -939,8 +1111,8 @@ var Pipeline = class {
|
|
|
939
1111
|
log6("failed to download feed", {
|
|
940
1112
|
err
|
|
941
1113
|
}, {
|
|
942
|
-
F:
|
|
943
|
-
L:
|
|
1114
|
+
F: __dxlog_file7,
|
|
1115
|
+
L: 379,
|
|
944
1116
|
S: this,
|
|
945
1117
|
C: (f, a) => f(...a)
|
|
946
1118
|
});
|
|
@@ -953,8 +1125,8 @@ var Pipeline = class {
|
|
|
953
1125
|
});
|
|
954
1126
|
this._feedSetIterator.stalled.on((iterator) => {
|
|
955
1127
|
log6.warn(`Stalled after ${iterator.options.stallTimeout}ms with ${iterator.size} feeds.`, void 0, {
|
|
956
|
-
F:
|
|
957
|
-
L:
|
|
1128
|
+
F: __dxlog_file7,
|
|
1129
|
+
L: 390,
|
|
958
1130
|
S: this,
|
|
959
1131
|
C: (f, a) => f(...a)
|
|
960
1132
|
});
|
|
@@ -982,14 +1154,14 @@ _ts_decorate4([
|
|
|
982
1154
|
], Pipeline.prototype, "unpause", null);
|
|
983
1155
|
|
|
984
1156
|
// packages/core/echo/echo-pipeline/src/space/auth.ts
|
|
985
|
-
import invariant7 from "tiny-invariant";
|
|
986
1157
|
import { runInContext, scheduleTask } from "@dxos/async";
|
|
987
1158
|
import { Context as Context3 } from "@dxos/context";
|
|
988
1159
|
import { randomBytes } from "@dxos/crypto";
|
|
1160
|
+
import { invariant as invariant7 } from "@dxos/invariant";
|
|
989
1161
|
import { log as log7 } from "@dxos/log";
|
|
990
1162
|
import { schema as schema5 } from "@dxos/protocols";
|
|
991
1163
|
import { RpcExtension } from "@dxos/teleport";
|
|
992
|
-
var
|
|
1164
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/auth.ts";
|
|
993
1165
|
var AuthExtension = class extends RpcExtension {
|
|
994
1166
|
constructor(_authParams) {
|
|
995
1167
|
super({
|
|
@@ -1005,8 +1177,8 @@ var AuthExtension = class extends RpcExtension {
|
|
|
1005
1177
|
this._ctx = new Context3({
|
|
1006
1178
|
onError: (err) => {
|
|
1007
1179
|
log7.catch(err, void 0, {
|
|
1008
|
-
F:
|
|
1009
|
-
L:
|
|
1180
|
+
F: __dxlog_file8,
|
|
1181
|
+
L: 28,
|
|
1010
1182
|
S: this,
|
|
1011
1183
|
C: (f, a) => f(...a)
|
|
1012
1184
|
});
|
|
@@ -1027,8 +1199,8 @@ var AuthExtension = class extends RpcExtension {
|
|
|
1027
1199
|
};
|
|
1028
1200
|
} catch (err) {
|
|
1029
1201
|
log7.error("failed to generate auth credentials", err, {
|
|
1030
|
-
F:
|
|
1031
|
-
L:
|
|
1202
|
+
F: __dxlog_file8,
|
|
1203
|
+
L: 55,
|
|
1032
1204
|
S: this,
|
|
1033
1205
|
C: (f, a) => f(...a)
|
|
1034
1206
|
});
|
|
@@ -1046,14 +1218,30 @@ var AuthExtension = class extends RpcExtension {
|
|
|
1046
1218
|
const { credential } = await this.rpc.AuthService.authenticate({
|
|
1047
1219
|
challenge
|
|
1048
1220
|
});
|
|
1049
|
-
invariant7(
|
|
1221
|
+
invariant7(credential?.length > 0, "invalid credential", {
|
|
1222
|
+
F: __dxlog_file8,
|
|
1223
|
+
L: 69,
|
|
1224
|
+
S: this,
|
|
1225
|
+
A: [
|
|
1226
|
+
"credential?.length > 0",
|
|
1227
|
+
"'invalid credential'"
|
|
1228
|
+
]
|
|
1229
|
+
});
|
|
1050
1230
|
const success = await this._authParams.verifier(challenge, credential);
|
|
1051
|
-
invariant7(success, "credential not verified"
|
|
1231
|
+
invariant7(success, "credential not verified", {
|
|
1232
|
+
F: __dxlog_file8,
|
|
1233
|
+
L: 71,
|
|
1234
|
+
S: this,
|
|
1235
|
+
A: [
|
|
1236
|
+
"success",
|
|
1237
|
+
"'credential not verified'"
|
|
1238
|
+
]
|
|
1239
|
+
});
|
|
1052
1240
|
runInContext(this._ctx, () => this._authParams.onAuthSuccess());
|
|
1053
1241
|
} catch (err) {
|
|
1054
1242
|
log7("auth failed", err, {
|
|
1055
|
-
F:
|
|
1056
|
-
L:
|
|
1243
|
+
F: __dxlog_file8,
|
|
1244
|
+
L: 74,
|
|
1057
1245
|
S: this,
|
|
1058
1246
|
C: (f, a) => f(...a)
|
|
1059
1247
|
});
|
|
@@ -1069,12 +1257,12 @@ var AuthExtension = class extends RpcExtension {
|
|
|
1069
1257
|
};
|
|
1070
1258
|
|
|
1071
1259
|
// packages/core/echo/echo-pipeline/src/space/data-pipeline.ts
|
|
1072
|
-
import invariant8 from "tiny-invariant";
|
|
1073
1260
|
import { Event as Event4, scheduleTask as scheduleTask2, synchronized as synchronized3, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
1074
1261
|
import { Context as Context4 } from "@dxos/context";
|
|
1075
1262
|
import { checkCredentialType } from "@dxos/credentials";
|
|
1076
1263
|
import { getStateMachineFromItem, ItemManager } from "@dxos/echo-db";
|
|
1077
1264
|
import { CancelledError } from "@dxos/errors";
|
|
1265
|
+
import { invariant as invariant8 } from "@dxos/invariant";
|
|
1078
1266
|
import { log as log8 } from "@dxos/log";
|
|
1079
1267
|
import { Timeframe as Timeframe3 } from "@dxos/timeframe";
|
|
1080
1268
|
import { tracer } from "@dxos/util";
|
|
@@ -1088,7 +1276,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
1088
1276
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1089
1277
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1090
1278
|
}
|
|
1091
|
-
var
|
|
1279
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/data-pipeline.ts";
|
|
1092
1280
|
var MESSAGES_PER_SNAPSHOT = 10;
|
|
1093
1281
|
var AUTOMATIC_SNAPSHOT_DEBOUNCE_INTERVAL = 5e3;
|
|
1094
1282
|
var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL = 500;
|
|
@@ -1114,13 +1302,11 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1114
1302
|
return this._pipeline;
|
|
1115
1303
|
}
|
|
1116
1304
|
get pipelineState() {
|
|
1117
|
-
|
|
1118
|
-
return (_a = this._pipeline) == null ? void 0 : _a.state;
|
|
1305
|
+
return this._pipeline?.state;
|
|
1119
1306
|
}
|
|
1120
1307
|
setTargetTimeframe(timeframe) {
|
|
1121
|
-
var _a;
|
|
1122
1308
|
this._targetTimeframe = timeframe;
|
|
1123
|
-
|
|
1309
|
+
this._pipeline?.state.setTargetTimeframe(timeframe);
|
|
1124
1310
|
}
|
|
1125
1311
|
async processCredential(credential) {
|
|
1126
1312
|
if (!checkCredentialType(credential, "dxos.halo.credentials.Epoch")) {
|
|
@@ -1144,8 +1330,24 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1144
1330
|
}
|
|
1145
1331
|
const feedWriter = {
|
|
1146
1332
|
write: (data, options) => {
|
|
1147
|
-
invariant8(this._pipeline, "Pipeline is not initialized."
|
|
1148
|
-
|
|
1333
|
+
invariant8(this._pipeline, "Pipeline is not initialized.", {
|
|
1334
|
+
F: __dxlog_file9,
|
|
1335
|
+
L: 145,
|
|
1336
|
+
S: this,
|
|
1337
|
+
A: [
|
|
1338
|
+
"this._pipeline",
|
|
1339
|
+
"'Pipeline is not initialized.'"
|
|
1340
|
+
]
|
|
1341
|
+
});
|
|
1342
|
+
invariant8(this.currentEpoch, "Epoch is not initialized.", {
|
|
1343
|
+
F: __dxlog_file9,
|
|
1344
|
+
L: 146,
|
|
1345
|
+
S: this,
|
|
1346
|
+
A: [
|
|
1347
|
+
"this.currentEpoch",
|
|
1348
|
+
"'Epoch is not initialized.'"
|
|
1349
|
+
]
|
|
1350
|
+
});
|
|
1149
1351
|
return this._pipeline.writer.write({
|
|
1150
1352
|
data
|
|
1151
1353
|
}, options);
|
|
@@ -1160,19 +1362,18 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1160
1362
|
this._isOpen = true;
|
|
1161
1363
|
}
|
|
1162
1364
|
async close() {
|
|
1163
|
-
var _a, _b, _c;
|
|
1164
1365
|
if (!this._isOpen) {
|
|
1165
1366
|
return;
|
|
1166
1367
|
}
|
|
1167
1368
|
log8("close", void 0, {
|
|
1168
|
-
F:
|
|
1169
|
-
L:
|
|
1369
|
+
F: __dxlog_file9,
|
|
1370
|
+
L: 170,
|
|
1170
1371
|
S: this,
|
|
1171
1372
|
C: (f, a) => f(...a)
|
|
1172
1373
|
});
|
|
1173
1374
|
this._isOpen = false;
|
|
1174
1375
|
await this._ctx.dispose();
|
|
1175
|
-
await
|
|
1376
|
+
await this._pipeline?.stop();
|
|
1176
1377
|
try {
|
|
1177
1378
|
await this._saveCache();
|
|
1178
1379
|
if (this._pipeline) {
|
|
@@ -1180,14 +1381,14 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1180
1381
|
}
|
|
1181
1382
|
} catch (err) {
|
|
1182
1383
|
log8.catch(err, void 0, {
|
|
1183
|
-
F:
|
|
1184
|
-
L:
|
|
1384
|
+
F: __dxlog_file9,
|
|
1385
|
+
L: 183,
|
|
1185
1386
|
S: this,
|
|
1186
1387
|
C: (f, a) => f(...a)
|
|
1187
1388
|
});
|
|
1188
1389
|
}
|
|
1189
|
-
await
|
|
1190
|
-
await
|
|
1390
|
+
await this.databaseHost?.close();
|
|
1391
|
+
await this.itemManager?.destroy();
|
|
1191
1392
|
this._ctx = new Context4();
|
|
1192
1393
|
this._pipeline = void 0;
|
|
1193
1394
|
this._targetTimeframe = void 0;
|
|
@@ -1203,15 +1404,23 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1203
1404
|
await this._processEpochInSeparateTask(this.currentEpoch);
|
|
1204
1405
|
await waitForOneEpoch;
|
|
1205
1406
|
}
|
|
1206
|
-
invariant8(this._pipeline, "Pipeline is not initialized."
|
|
1407
|
+
invariant8(this._pipeline, "Pipeline is not initialized.", {
|
|
1408
|
+
F: __dxlog_file9,
|
|
1409
|
+
L: 206,
|
|
1410
|
+
S: this,
|
|
1411
|
+
A: [
|
|
1412
|
+
"this._pipeline",
|
|
1413
|
+
"'Pipeline is not initialized.'"
|
|
1414
|
+
]
|
|
1415
|
+
});
|
|
1207
1416
|
for await (const msg of this._pipeline.consume()) {
|
|
1208
1417
|
const { feedKey, seq, data } = msg;
|
|
1209
1418
|
log8("processing message", {
|
|
1210
1419
|
feedKey,
|
|
1211
1420
|
seq
|
|
1212
1421
|
}, {
|
|
1213
|
-
F:
|
|
1214
|
-
L:
|
|
1422
|
+
F: __dxlog_file9,
|
|
1423
|
+
L: 209,
|
|
1215
1424
|
S: this,
|
|
1216
1425
|
C: (f, a) => f(...a)
|
|
1217
1426
|
});
|
|
@@ -1222,8 +1431,8 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1222
1431
|
log8.warn("Could not find feed", {
|
|
1223
1432
|
feedKey
|
|
1224
1433
|
}, {
|
|
1225
|
-
F:
|
|
1226
|
-
L:
|
|
1434
|
+
F: __dxlog_file9,
|
|
1435
|
+
L: 215,
|
|
1227
1436
|
S: this,
|
|
1228
1437
|
C: (f, a) => f(...a)
|
|
1229
1438
|
});
|
|
@@ -1245,8 +1454,8 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1245
1454
|
seq,
|
|
1246
1455
|
spaceKey: this._params.spaceKey.toHex()
|
|
1247
1456
|
}, {
|
|
1248
|
-
F:
|
|
1249
|
-
L:
|
|
1457
|
+
F: __dxlog_file9,
|
|
1458
|
+
L: 232,
|
|
1250
1459
|
S: this,
|
|
1251
1460
|
C: (f, a) => f(...a)
|
|
1252
1461
|
});
|
|
@@ -1254,8 +1463,8 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1254
1463
|
}
|
|
1255
1464
|
} catch (err) {
|
|
1256
1465
|
log8.catch(err, void 0, {
|
|
1257
|
-
F:
|
|
1258
|
-
L:
|
|
1466
|
+
F: __dxlog_file9,
|
|
1467
|
+
L: 242,
|
|
1259
1468
|
S: this,
|
|
1260
1469
|
C: (f, a) => f(...a)
|
|
1261
1470
|
});
|
|
@@ -1263,7 +1472,15 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1263
1472
|
}
|
|
1264
1473
|
}
|
|
1265
1474
|
_createSnapshot() {
|
|
1266
|
-
invariant8(this.databaseHost, "Database backend is not initialized."
|
|
1475
|
+
invariant8(this.databaseHost, "Database backend is not initialized.", {
|
|
1476
|
+
F: __dxlog_file9,
|
|
1477
|
+
L: 248,
|
|
1478
|
+
S: this,
|
|
1479
|
+
A: [
|
|
1480
|
+
"this.databaseHost",
|
|
1481
|
+
"'Database backend is not initialized.'"
|
|
1482
|
+
]
|
|
1483
|
+
});
|
|
1267
1484
|
return {
|
|
1268
1485
|
spaceKey: this._params.spaceKey.asUint8Array(),
|
|
1269
1486
|
timeframe: this._pipeline.state.timeframe,
|
|
@@ -1271,26 +1488,22 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1271
1488
|
};
|
|
1272
1489
|
}
|
|
1273
1490
|
async _saveTargetTimeframe(timeframe) {
|
|
1274
|
-
|
|
1275
|
-
const newTimeframe = Timeframe3.merge((_a = this._targetTimeframe) != null ? _a : new Timeframe3(), timeframe);
|
|
1491
|
+
const newTimeframe = Timeframe3.merge(this._targetTimeframe ?? new Timeframe3(), timeframe);
|
|
1276
1492
|
await this._params.metadataStore.setSpaceDataLatestTimeframe(this._params.spaceKey, newTimeframe);
|
|
1277
1493
|
this._targetTimeframe = newTimeframe;
|
|
1278
1494
|
}
|
|
1279
1495
|
async _saveCache() {
|
|
1280
|
-
var _a;
|
|
1281
1496
|
const cache = {};
|
|
1282
1497
|
try {
|
|
1283
|
-
const propertiesItem = this.itemManager.items.find((item) =>
|
|
1284
|
-
|
|
1285
|
-
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";
|
|
1286
|
-
});
|
|
1498
|
+
const propertiesItem = this.itemManager.items.find((item) => item.modelMeta?.type === "dxos:model/document" && // TODO(burdon): Document?
|
|
1499
|
+
(getStateMachineFromItem(item)?.snapshot()).type === "dxos.sdk.client.Properties");
|
|
1287
1500
|
if (propertiesItem) {
|
|
1288
|
-
cache.properties =
|
|
1501
|
+
cache.properties = getStateMachineFromItem(propertiesItem)?.snapshot();
|
|
1289
1502
|
}
|
|
1290
1503
|
} catch (err) {
|
|
1291
1504
|
log8.warn("Failed to cache properties", err, {
|
|
1292
|
-
F:
|
|
1293
|
-
L:
|
|
1505
|
+
F: __dxlog_file9,
|
|
1506
|
+
L: 277,
|
|
1294
1507
|
S: this,
|
|
1295
1508
|
C: (f, a) => f(...a)
|
|
1296
1509
|
});
|
|
@@ -1307,24 +1520,23 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1307
1520
|
}
|
|
1308
1521
|
}
|
|
1309
1522
|
async _processEpochInSeparateTask(epoch) {
|
|
1310
|
-
var _a;
|
|
1311
1523
|
if (epoch.subject.assertion.number <= this._lastProcessedEpoch) {
|
|
1312
1524
|
return;
|
|
1313
1525
|
}
|
|
1314
|
-
await
|
|
1526
|
+
await this._epochCtx?.dispose();
|
|
1315
1527
|
const ctx = new Context4({
|
|
1316
1528
|
onError: (err) => {
|
|
1317
1529
|
if (err instanceof CancelledError) {
|
|
1318
1530
|
log8("Epoch processing cancelled.", void 0, {
|
|
1319
|
-
F:
|
|
1320
|
-
L:
|
|
1531
|
+
F: __dxlog_file9,
|
|
1532
|
+
L: 309,
|
|
1321
1533
|
S: this,
|
|
1322
1534
|
C: (f, a) => f(...a)
|
|
1323
1535
|
});
|
|
1324
1536
|
} else {
|
|
1325
1537
|
log8.catch(err, void 0, {
|
|
1326
|
-
F:
|
|
1327
|
-
L:
|
|
1538
|
+
F: __dxlog_file9,
|
|
1539
|
+
L: 311,
|
|
1328
1540
|
S: this,
|
|
1329
1541
|
C: (f, a) => f(...a)
|
|
1330
1542
|
});
|
|
@@ -1339,8 +1551,8 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1339
1551
|
log8("process epoch", {
|
|
1340
1552
|
epoch
|
|
1341
1553
|
}, {
|
|
1342
|
-
F:
|
|
1343
|
-
L:
|
|
1554
|
+
F: __dxlog_file9,
|
|
1555
|
+
L: 321,
|
|
1344
1556
|
S: this,
|
|
1345
1557
|
C: (f, a) => f(...a)
|
|
1346
1558
|
});
|
|
@@ -1350,14 +1562,30 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1350
1562
|
});
|
|
1351
1563
|
}
|
|
1352
1564
|
async _processEpoch(ctx, epoch) {
|
|
1353
|
-
invariant8(this._isOpen, "Space is closed."
|
|
1354
|
-
|
|
1565
|
+
invariant8(this._isOpen, "Space is closed.", {
|
|
1566
|
+
F: __dxlog_file9,
|
|
1567
|
+
L: 331,
|
|
1568
|
+
S: this,
|
|
1569
|
+
A: [
|
|
1570
|
+
"this._isOpen",
|
|
1571
|
+
"'Space is closed.'"
|
|
1572
|
+
]
|
|
1573
|
+
});
|
|
1574
|
+
invariant8(this._pipeline, void 0, {
|
|
1575
|
+
F: __dxlog_file9,
|
|
1576
|
+
L: 332,
|
|
1577
|
+
S: this,
|
|
1578
|
+
A: [
|
|
1579
|
+
"this._pipeline",
|
|
1580
|
+
""
|
|
1581
|
+
]
|
|
1582
|
+
});
|
|
1355
1583
|
this._lastProcessedEpoch = epoch.number;
|
|
1356
1584
|
log8("Processing epoch", {
|
|
1357
1585
|
epoch
|
|
1358
1586
|
}, {
|
|
1359
|
-
F:
|
|
1360
|
-
L:
|
|
1587
|
+
F: __dxlog_file9,
|
|
1588
|
+
L: 335,
|
|
1361
1589
|
S: this,
|
|
1362
1590
|
C: (f, a) => f(...a)
|
|
1363
1591
|
});
|
|
@@ -1366,8 +1594,8 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1366
1594
|
this.databaseHost._itemDemuxer.restoreFromSnapshot(snapshot.database);
|
|
1367
1595
|
}
|
|
1368
1596
|
log8("restarting pipeline for epoch", void 0, {
|
|
1369
|
-
F:
|
|
1370
|
-
L:
|
|
1597
|
+
F: __dxlog_file9,
|
|
1598
|
+
L: 343,
|
|
1371
1599
|
S: this,
|
|
1372
1600
|
C: (f, a) => f(...a)
|
|
1373
1601
|
});
|
|
@@ -1376,12 +1604,36 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1376
1604
|
await this._pipeline.unpause();
|
|
1377
1605
|
}
|
|
1378
1606
|
async waitUntilTimeframe(timeframe) {
|
|
1379
|
-
invariant8(this._pipeline, "Pipeline is not initialized."
|
|
1607
|
+
invariant8(this._pipeline, "Pipeline is not initialized.", {
|
|
1608
|
+
F: __dxlog_file9,
|
|
1609
|
+
L: 351,
|
|
1610
|
+
S: this,
|
|
1611
|
+
A: [
|
|
1612
|
+
"this._pipeline",
|
|
1613
|
+
"'Pipeline is not initialized.'"
|
|
1614
|
+
]
|
|
1615
|
+
});
|
|
1380
1616
|
await this._pipeline.state.waitUntilTimeframe(timeframe);
|
|
1381
1617
|
}
|
|
1382
1618
|
async createEpoch() {
|
|
1383
|
-
invariant8(this._pipeline
|
|
1384
|
-
|
|
1619
|
+
invariant8(this._pipeline, void 0, {
|
|
1620
|
+
F: __dxlog_file9,
|
|
1621
|
+
L: 357,
|
|
1622
|
+
S: this,
|
|
1623
|
+
A: [
|
|
1624
|
+
"this._pipeline",
|
|
1625
|
+
""
|
|
1626
|
+
]
|
|
1627
|
+
});
|
|
1628
|
+
invariant8(this.currentEpoch, void 0, {
|
|
1629
|
+
F: __dxlog_file9,
|
|
1630
|
+
L: 358,
|
|
1631
|
+
S: this,
|
|
1632
|
+
A: [
|
|
1633
|
+
"this.currentEpoch",
|
|
1634
|
+
""
|
|
1635
|
+
]
|
|
1636
|
+
});
|
|
1385
1637
|
await this._pipeline.pause();
|
|
1386
1638
|
const snapshot = await this._createSnapshot();
|
|
1387
1639
|
const snapshotCid = await this._params.snapshotManager.store(snapshot);
|
|
@@ -1415,10 +1667,11 @@ DataPipeline = _ts_decorate5([
|
|
|
1415
1667
|
], DataPipeline);
|
|
1416
1668
|
|
|
1417
1669
|
// packages/core/echo/echo-pipeline/src/space/space.ts
|
|
1418
|
-
import invariant9 from "tiny-invariant";
|
|
1419
1670
|
import { Event as Event5, synchronized as synchronized4, trackLeaks as trackLeaks3, Lock } from "@dxos/async";
|
|
1671
|
+
import { invariant as invariant9 } from "@dxos/invariant";
|
|
1420
1672
|
import { log as log10, logInfo } from "@dxos/log";
|
|
1421
1673
|
import { AdmittedFeed as AdmittedFeed2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
1674
|
+
import { trace } from "@dxos/tracing";
|
|
1422
1675
|
import { Callback as Callback2 } from "@dxos/util";
|
|
1423
1676
|
|
|
1424
1677
|
// packages/core/echo/echo-pipeline/src/space/control-pipeline.ts
|
|
@@ -1428,7 +1681,7 @@ import { log as log9 } from "@dxos/log";
|
|
|
1428
1681
|
import { AdmittedFeed } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
1429
1682
|
import { Timeframe as Timeframe4 } from "@dxos/timeframe";
|
|
1430
1683
|
import { Callback, tracer as tracer2 } from "@dxos/util";
|
|
1431
|
-
var
|
|
1684
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/control-pipeline.ts";
|
|
1432
1685
|
var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2 = 500;
|
|
1433
1686
|
var ControlPipeline = class {
|
|
1434
1687
|
constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }) {
|
|
@@ -1443,7 +1696,7 @@ var ControlPipeline = class {
|
|
|
1443
1696
|
log9("feed admitted", {
|
|
1444
1697
|
key: info.key
|
|
1445
1698
|
}, {
|
|
1446
|
-
F:
|
|
1699
|
+
F: __dxlog_file10,
|
|
1447
1700
|
L: 51,
|
|
1448
1701
|
S: this,
|
|
1449
1702
|
C: (f, a) => f(...a)
|
|
@@ -1454,7 +1707,7 @@ var ControlPipeline = class {
|
|
|
1454
1707
|
await this._pipeline.addFeed(feed);
|
|
1455
1708
|
} catch (err) {
|
|
1456
1709
|
log9.catch(err, void 0, {
|
|
1457
|
-
F:
|
|
1710
|
+
F: __dxlog_file10,
|
|
1458
1711
|
L: 59,
|
|
1459
1712
|
S: this,
|
|
1460
1713
|
C: (f, a) => f(...a)
|
|
@@ -1477,7 +1730,7 @@ var ControlPipeline = class {
|
|
|
1477
1730
|
}
|
|
1478
1731
|
async start() {
|
|
1479
1732
|
log9("starting...", void 0, {
|
|
1480
|
-
F:
|
|
1733
|
+
F: __dxlog_file10,
|
|
1481
1734
|
L: 83,
|
|
1482
1735
|
S: this,
|
|
1483
1736
|
C: (f, a) => f(...a)
|
|
@@ -1489,7 +1742,7 @@ var ControlPipeline = class {
|
|
|
1489
1742
|
key: msg.feedKey,
|
|
1490
1743
|
seq: msg.seq
|
|
1491
1744
|
}, {
|
|
1492
|
-
F:
|
|
1745
|
+
F: __dxlog_file10,
|
|
1493
1746
|
L: 88,
|
|
1494
1747
|
S: this,
|
|
1495
1748
|
C: (f, a) => f(...a)
|
|
@@ -1502,7 +1755,7 @@ var ControlPipeline = class {
|
|
|
1502
1755
|
log9.warn("processing failed", {
|
|
1503
1756
|
msg
|
|
1504
1757
|
}, {
|
|
1505
|
-
F:
|
|
1758
|
+
F: __dxlog_file10,
|
|
1506
1759
|
L: 98,
|
|
1507
1760
|
S: this,
|
|
1508
1761
|
C: (f, a) => f(...a)
|
|
@@ -1513,7 +1766,7 @@ var ControlPipeline = class {
|
|
|
1513
1766
|
}
|
|
1514
1767
|
} catch (err) {
|
|
1515
1768
|
log9.catch(err, void 0, {
|
|
1516
|
-
F:
|
|
1769
|
+
F: __dxlog_file10,
|
|
1517
1770
|
L: 104,
|
|
1518
1771
|
S: this,
|
|
1519
1772
|
C: (f, a) => f(...a)
|
|
@@ -1523,7 +1776,7 @@ var ControlPipeline = class {
|
|
|
1523
1776
|
});
|
|
1524
1777
|
await this._pipeline.start();
|
|
1525
1778
|
log9("started", void 0, {
|
|
1526
|
-
F:
|
|
1779
|
+
F: __dxlog_file10,
|
|
1527
1780
|
L: 110,
|
|
1528
1781
|
S: this,
|
|
1529
1782
|
C: (f, a) => f(...a)
|
|
@@ -1537,7 +1790,7 @@ var ControlPipeline = class {
|
|
|
1537
1790
|
}
|
|
1538
1791
|
async stop() {
|
|
1539
1792
|
log9("stopping...", void 0, {
|
|
1540
|
-
F:
|
|
1793
|
+
F: __dxlog_file10,
|
|
1541
1794
|
L: 124,
|
|
1542
1795
|
S: this,
|
|
1543
1796
|
C: (f, a) => f(...a)
|
|
@@ -1545,21 +1798,20 @@ var ControlPipeline = class {
|
|
|
1545
1798
|
await this._pipeline.stop();
|
|
1546
1799
|
await this._saveTargetTimeframe(this._pipeline.state.timeframe);
|
|
1547
1800
|
log9("stopped", void 0, {
|
|
1548
|
-
F:
|
|
1801
|
+
F: __dxlog_file10,
|
|
1549
1802
|
L: 127,
|
|
1550
1803
|
S: this,
|
|
1551
1804
|
C: (f, a) => f(...a)
|
|
1552
1805
|
});
|
|
1553
1806
|
}
|
|
1554
1807
|
async _saveTargetTimeframe(timeframe) {
|
|
1555
|
-
var _a;
|
|
1556
1808
|
try {
|
|
1557
|
-
const newTimeframe = Timeframe4.merge(
|
|
1809
|
+
const newTimeframe = Timeframe4.merge(this._targetTimeframe ?? new Timeframe4(), timeframe);
|
|
1558
1810
|
await this._metadata.setSpaceControlLatestTimeframe(this._spaceKey, newTimeframe);
|
|
1559
1811
|
this._targetTimeframe = newTimeframe;
|
|
1560
1812
|
} catch (err) {
|
|
1561
1813
|
log9(err, void 0, {
|
|
1562
|
-
F:
|
|
1814
|
+
F: __dxlog_file10,
|
|
1563
1815
|
L: 136,
|
|
1564
1816
|
S: this,
|
|
1565
1817
|
C: (f, a) => f(...a)
|
|
@@ -1579,14 +1831,22 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
1579
1831
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1580
1832
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1581
1833
|
}
|
|
1582
|
-
var
|
|
1834
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space.ts";
|
|
1583
1835
|
var Space = class Space2 {
|
|
1584
1836
|
constructor(params) {
|
|
1585
1837
|
this._addFeedLock = new Lock();
|
|
1586
1838
|
this.onCredentialProcessed = new Callback2();
|
|
1587
1839
|
this.stateUpdate = new Event5();
|
|
1588
1840
|
this._isOpen = false;
|
|
1589
|
-
invariant9(params.spaceKey && params.feedProvider
|
|
1841
|
+
invariant9(params.spaceKey && params.feedProvider, void 0, {
|
|
1842
|
+
F: __dxlog_file11,
|
|
1843
|
+
L: 73,
|
|
1844
|
+
S: this,
|
|
1845
|
+
A: [
|
|
1846
|
+
"params.spaceKey && params.feedProvider",
|
|
1847
|
+
""
|
|
1848
|
+
]
|
|
1849
|
+
});
|
|
1590
1850
|
this._key = params.spaceKey;
|
|
1591
1851
|
this._genesisFeedKey = params.genesisFeed.key;
|
|
1592
1852
|
this._feedProvider = params.feedProvider;
|
|
@@ -1621,8 +1881,8 @@ var Space = class Space2 {
|
|
|
1621
1881
|
log10("onCredentialProcessed", {
|
|
1622
1882
|
credential
|
|
1623
1883
|
}, {
|
|
1624
|
-
F:
|
|
1625
|
-
L:
|
|
1884
|
+
F: __dxlog_file11,
|
|
1885
|
+
L: 109,
|
|
1626
1886
|
S: this,
|
|
1627
1887
|
C: (f, a) => f(...a)
|
|
1628
1888
|
});
|
|
@@ -1664,12 +1924,10 @@ var Space = class Space2 {
|
|
|
1664
1924
|
return this._genesisFeedKey;
|
|
1665
1925
|
}
|
|
1666
1926
|
get controlFeedKey() {
|
|
1667
|
-
|
|
1668
|
-
return (_a = this._controlFeed) == null ? void 0 : _a.key;
|
|
1927
|
+
return this._controlFeed?.key;
|
|
1669
1928
|
}
|
|
1670
1929
|
get dataFeedKey() {
|
|
1671
|
-
|
|
1672
|
-
return (_a = this._dataFeed) == null ? void 0 : _a.key;
|
|
1930
|
+
return this._dataFeed?.key;
|
|
1673
1931
|
}
|
|
1674
1932
|
get spaceState() {
|
|
1675
1933
|
return this._controlPipeline.spaceState;
|
|
@@ -1687,16 +1945,31 @@ var Space = class Space2 {
|
|
|
1687
1945
|
return this._snapshotManager;
|
|
1688
1946
|
}
|
|
1689
1947
|
setControlFeed(feed) {
|
|
1690
|
-
invariant9(!this._controlFeed, "Control feed already set."
|
|
1948
|
+
invariant9(!this._controlFeed, "Control feed already set.", {
|
|
1949
|
+
F: __dxlog_file11,
|
|
1950
|
+
L: 183,
|
|
1951
|
+
S: this,
|
|
1952
|
+
A: [
|
|
1953
|
+
"!this._controlFeed",
|
|
1954
|
+
"'Control feed already set.'"
|
|
1955
|
+
]
|
|
1956
|
+
});
|
|
1691
1957
|
this._controlFeed = feed;
|
|
1692
1958
|
this._controlPipeline.setWriteFeed(feed);
|
|
1693
1959
|
return this;
|
|
1694
1960
|
}
|
|
1695
1961
|
setDataFeed(feed) {
|
|
1696
|
-
|
|
1697
|
-
|
|
1962
|
+
invariant9(!this._dataFeed, "Data feed already set.", {
|
|
1963
|
+
F: __dxlog_file11,
|
|
1964
|
+
L: 190,
|
|
1965
|
+
S: this,
|
|
1966
|
+
A: [
|
|
1967
|
+
"!this._dataFeed",
|
|
1968
|
+
"'Data feed already set.'"
|
|
1969
|
+
]
|
|
1970
|
+
});
|
|
1698
1971
|
this._dataFeed = feed;
|
|
1699
|
-
|
|
1972
|
+
this._dataPipeline.pipeline?.setWriteFeed(feed);
|
|
1700
1973
|
return this;
|
|
1701
1974
|
}
|
|
1702
1975
|
/**
|
|
@@ -1711,10 +1984,10 @@ var Space = class Space2 {
|
|
|
1711
1984
|
// getDataFeeds(): FeedInfo[] {
|
|
1712
1985
|
// return this._dataPipeline?.getFeeds();
|
|
1713
1986
|
// }
|
|
1714
|
-
async open() {
|
|
1987
|
+
async open(ctx) {
|
|
1715
1988
|
log10("opening...", void 0, {
|
|
1716
|
-
F:
|
|
1717
|
-
L:
|
|
1989
|
+
F: __dxlog_file11,
|
|
1990
|
+
L: 212,
|
|
1718
1991
|
S: this,
|
|
1719
1992
|
C: (f, a) => f(...a)
|
|
1720
1993
|
});
|
|
@@ -1726,8 +1999,8 @@ var Space = class Space2 {
|
|
|
1726
1999
|
await this._controlPipeline.spaceState.addCredentialProcessor(this._dataPipeline);
|
|
1727
2000
|
this._isOpen = true;
|
|
1728
2001
|
log10("opened", void 0, {
|
|
1729
|
-
F:
|
|
1730
|
-
L:
|
|
2002
|
+
F: __dxlog_file11,
|
|
2003
|
+
L: 223,
|
|
1731
2004
|
S: this,
|
|
1732
2005
|
C: (f, a) => f(...a)
|
|
1733
2006
|
});
|
|
@@ -1736,8 +2009,8 @@ var Space = class Space2 {
|
|
|
1736
2009
|
log10("closing...", {
|
|
1737
2010
|
key: this._key
|
|
1738
2011
|
}, {
|
|
1739
|
-
F:
|
|
1740
|
-
L:
|
|
2012
|
+
F: __dxlog_file11,
|
|
2013
|
+
L: 228,
|
|
1741
2014
|
S: this,
|
|
1742
2015
|
C: (f, a) => f(...a)
|
|
1743
2016
|
});
|
|
@@ -1750,20 +2023,28 @@ var Space = class Space2 {
|
|
|
1750
2023
|
await this._controlPipeline.stop();
|
|
1751
2024
|
this._isOpen = false;
|
|
1752
2025
|
log10("closed", void 0, {
|
|
1753
|
-
F:
|
|
1754
|
-
L:
|
|
2026
|
+
F: __dxlog_file11,
|
|
2027
|
+
L: 241,
|
|
1755
2028
|
S: this,
|
|
1756
2029
|
C: (f, a) => f(...a)
|
|
1757
2030
|
});
|
|
1758
2031
|
}
|
|
1759
2032
|
async initializeDataPipeline() {
|
|
1760
2033
|
log10("initializeDataPipeline", void 0, {
|
|
1761
|
-
F:
|
|
1762
|
-
L:
|
|
2034
|
+
F: __dxlog_file11,
|
|
2035
|
+
L: 246,
|
|
1763
2036
|
S: this,
|
|
1764
2037
|
C: (f, a) => f(...a)
|
|
1765
2038
|
});
|
|
1766
|
-
invariant9(this._isOpen, "Space must be open to initialize data pipeline."
|
|
2039
|
+
invariant9(this._isOpen, "Space must be open to initialize data pipeline.", {
|
|
2040
|
+
F: __dxlog_file11,
|
|
2041
|
+
L: 247,
|
|
2042
|
+
S: this,
|
|
2043
|
+
A: [
|
|
2044
|
+
"this._isOpen",
|
|
2045
|
+
"'Space must be open to initialize data pipeline.'"
|
|
2046
|
+
]
|
|
2047
|
+
});
|
|
1767
2048
|
await this._dataPipeline.open();
|
|
1768
2049
|
}
|
|
1769
2050
|
};
|
|
@@ -1771,7 +2052,8 @@ _ts_decorate6([
|
|
|
1771
2052
|
logInfo
|
|
1772
2053
|
], Space.prototype, "key", null);
|
|
1773
2054
|
_ts_decorate6([
|
|
1774
|
-
synchronized4
|
|
2055
|
+
synchronized4,
|
|
2056
|
+
trace.span()
|
|
1775
2057
|
], Space.prototype, "open", null);
|
|
1776
2058
|
_ts_decorate6([
|
|
1777
2059
|
synchronized4
|
|
@@ -1780,7 +2062,8 @@ _ts_decorate6([
|
|
|
1780
2062
|
synchronized4
|
|
1781
2063
|
], Space.prototype, "initializeDataPipeline", null);
|
|
1782
2064
|
Space = _ts_decorate6([
|
|
1783
|
-
trackLeaks3("open", "close")
|
|
2065
|
+
trackLeaks3("open", "close"),
|
|
2066
|
+
trace.resource()
|
|
1784
2067
|
], Space);
|
|
1785
2068
|
|
|
1786
2069
|
// packages/core/echo/echo-pipeline/src/space/space-protocol.ts
|
|
@@ -1802,7 +2085,7 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
1802
2085
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1803
2086
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1804
2087
|
}
|
|
1805
|
-
var
|
|
2088
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-protocol.ts";
|
|
1806
2089
|
var MOCK_AUTH_PROVIDER = async (nonce) => Buffer.from("mock");
|
|
1807
2090
|
var MOCK_AUTH_VERIFIER = async (nonce, credential) => true;
|
|
1808
2091
|
var SpaceProtocol = class {
|
|
@@ -1832,7 +2115,7 @@ var SpaceProtocol = class {
|
|
|
1832
2115
|
log11("addFeed", {
|
|
1833
2116
|
key: feed.key
|
|
1834
2117
|
}, {
|
|
1835
|
-
F:
|
|
2118
|
+
F: __dxlog_file12,
|
|
1836
2119
|
L: 95,
|
|
1837
2120
|
S: this,
|
|
1838
2121
|
C: (f, a) => f(...a)
|
|
@@ -1854,7 +2137,7 @@ var SpaceProtocol = class {
|
|
|
1854
2137
|
};
|
|
1855
2138
|
await this.blobSync.open();
|
|
1856
2139
|
log11("starting...", void 0, {
|
|
1857
|
-
F:
|
|
2140
|
+
F: __dxlog_file12,
|
|
1858
2141
|
L: 120,
|
|
1859
2142
|
S: this,
|
|
1860
2143
|
C: (f, a) => f(...a)
|
|
@@ -1868,7 +2151,7 @@ var SpaceProtocol = class {
|
|
|
1868
2151
|
label: `Protocol swarm: ${topic}`
|
|
1869
2152
|
});
|
|
1870
2153
|
log11("started", void 0, {
|
|
1871
|
-
F:
|
|
2154
|
+
F: __dxlog_file12,
|
|
1872
2155
|
L: 130,
|
|
1873
2156
|
S: this,
|
|
1874
2157
|
C: (f, a) => f(...a)
|
|
@@ -1878,14 +2161,14 @@ var SpaceProtocol = class {
|
|
|
1878
2161
|
await this.blobSync.close();
|
|
1879
2162
|
if (this._connection) {
|
|
1880
2163
|
log11("stopping...", void 0, {
|
|
1881
|
-
F:
|
|
2164
|
+
F: __dxlog_file12,
|
|
1882
2165
|
L: 137,
|
|
1883
2166
|
S: this,
|
|
1884
2167
|
C: (f, a) => f(...a)
|
|
1885
2168
|
});
|
|
1886
2169
|
await this._connection.close();
|
|
1887
2170
|
log11("stopped", void 0, {
|
|
1888
|
-
F:
|
|
2171
|
+
F: __dxlog_file12,
|
|
1889
2172
|
L: 139,
|
|
1890
2173
|
S: this,
|
|
1891
2174
|
C: (f, a) => f(...a)
|
|
@@ -1951,20 +2234,18 @@ var SpaceProtocolSession = class {
|
|
|
1951
2234
|
provider: this._swarmIdentity.credentialProvider,
|
|
1952
2235
|
verifier: this._swarmIdentity.credentialAuthenticator,
|
|
1953
2236
|
onAuthSuccess: () => {
|
|
1954
|
-
var _a;
|
|
1955
2237
|
log11("Peer authenticated", void 0, {
|
|
1956
|
-
F:
|
|
2238
|
+
F: __dxlog_file12,
|
|
1957
2239
|
L: 236,
|
|
1958
2240
|
S: this,
|
|
1959
2241
|
C: (f, a) => f(...a)
|
|
1960
2242
|
});
|
|
1961
2243
|
this._authStatus = AuthStatus.SUCCESS;
|
|
1962
|
-
|
|
2244
|
+
this._onSessionAuth?.(this._teleport);
|
|
1963
2245
|
},
|
|
1964
2246
|
onAuthFailure: () => {
|
|
1965
|
-
var _a;
|
|
1966
2247
|
this._authStatus = AuthStatus.FAILURE;
|
|
1967
|
-
|
|
2248
|
+
this._onAuthFailure?.(this._teleport);
|
|
1968
2249
|
}
|
|
1969
2250
|
}));
|
|
1970
2251
|
this._teleport.addExtension("dxos.mesh.teleport.replicator", this.replicator);
|
|
@@ -1986,7 +2267,7 @@ import { synchronized as synchronized5, trackLeaks as trackLeaks4 } from "@dxos/
|
|
|
1986
2267
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
1987
2268
|
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
1988
2269
|
import { log as log12 } from "@dxos/log";
|
|
1989
|
-
import { trace } from "@dxos/protocols";
|
|
2270
|
+
import { trace as trace2 } from "@dxos/protocols";
|
|
1990
2271
|
import { ComplexMap as ComplexMap5 } from "@dxos/util";
|
|
1991
2272
|
function _ts_decorate8(decorators, target, key, desc) {
|
|
1992
2273
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -1998,7 +2279,7 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
1998
2279
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1999
2280
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2000
2281
|
}
|
|
2001
|
-
var
|
|
2282
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
|
|
2002
2283
|
var SpaceManager = class SpaceManager2 {
|
|
2003
2284
|
constructor({ feedStore, networkManager, modelFactory, metadataStore, snapshotStore, blobStore }) {
|
|
2004
2285
|
this._spaces = new ComplexMap5(PublicKey6.hash);
|
|
@@ -2022,11 +2303,10 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2022
2303
|
].map((space) => space.close()));
|
|
2023
2304
|
}
|
|
2024
2305
|
async constructSpace({ metadata, swarmIdentity, onNetworkConnection, onAuthFailure, memberKey }) {
|
|
2025
|
-
|
|
2026
|
-
log12.trace("dxos.echo.space-manager.construct-space", trace.begin({
|
|
2306
|
+
log12.trace("dxos.echo.space-manager.construct-space", trace2.begin({
|
|
2027
2307
|
id: this._instanceId
|
|
2028
2308
|
}), {
|
|
2029
|
-
F:
|
|
2309
|
+
F: __dxlog_file13,
|
|
2030
2310
|
L: 97,
|
|
2031
2311
|
S: this,
|
|
2032
2312
|
C: (f, a) => f(...a)
|
|
@@ -2034,12 +2314,12 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2034
2314
|
log12("constructing space...", {
|
|
2035
2315
|
spaceKey: metadata.genesisFeedKey
|
|
2036
2316
|
}, {
|
|
2037
|
-
F:
|
|
2317
|
+
F: __dxlog_file13,
|
|
2038
2318
|
L: 98,
|
|
2039
2319
|
S: this,
|
|
2040
2320
|
C: (f, a) => f(...a)
|
|
2041
2321
|
});
|
|
2042
|
-
const genesisFeed = await this._feedStore.openFeed(
|
|
2322
|
+
const genesisFeed = await this._feedStore.openFeed(metadata.genesisFeedKey ?? failUndefined2());
|
|
2043
2323
|
const spaceKey = metadata.key;
|
|
2044
2324
|
const protocol = new SpaceProtocol({
|
|
2045
2325
|
topic: spaceKey,
|
|
@@ -2061,10 +2341,10 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2061
2341
|
memberKey
|
|
2062
2342
|
});
|
|
2063
2343
|
this._spaces.set(space.key, space);
|
|
2064
|
-
log12.trace("dxos.echo.space-manager.construct-space",
|
|
2344
|
+
log12.trace("dxos.echo.space-manager.construct-space", trace2.end({
|
|
2065
2345
|
id: this._instanceId
|
|
2066
2346
|
}), {
|
|
2067
|
-
F:
|
|
2347
|
+
F: __dxlog_file13,
|
|
2068
2348
|
L: 125,
|
|
2069
2349
|
S: this,
|
|
2070
2350
|
C: (f, a) => f(...a)
|
|
@@ -2108,4 +2388,4 @@ export {
|
|
|
2108
2388
|
SpaceProtocolSession,
|
|
2109
2389
|
SpaceManager
|
|
2110
2390
|
};
|
|
2111
|
-
//# sourceMappingURL=chunk-
|
|
2391
|
+
//# sourceMappingURL=chunk-3OTHGQEY.mjs.map
|