@dxos/echo-pipeline 0.4.8-next.fff1521 → 0.4.8
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-3FVT6KX6.mjs → chunk-WAN2XUWE.mjs} +38 -698
- package/dist/lib/browser/chunk-WAN2XUWE.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +633 -6
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +2 -274
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node/{chunk-WZ4WTAN6.cjs → chunk-U6J2HC4T.cjs} +39 -689
- package/dist/lib/node/chunk-U6J2HC4T.cjs.map +7 -0
- package/dist/lib/node/index.cjs +647 -30
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +12 -282
- package/dist/lib/node/testing/index.cjs.map +4 -4
- package/dist/types/src/space/control-pipeline.d.ts.map +1 -1
- package/dist/types/src/space/data-pipeline.d.ts +0 -1
- package/dist/types/src/space/data-pipeline.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +0 -1
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/util.d.ts +2 -6
- package/dist/types/src/testing/util.d.ts.map +1 -1
- package/package.json +33 -33
- package/src/space/control-pipeline.ts +3 -1
- package/src/space/data-pipeline.ts +1 -44
- package/src/testing/index.ts +0 -1
- package/src/testing/util.ts +2 -26
- package/dist/lib/browser/chunk-3FVT6KX6.mjs.map +0 -7
- package/dist/lib/node/chunk-WZ4WTAN6.cjs.map +0 -7
- package/dist/types/src/testing/database-test-rig.d.ts +0 -67
- package/dist/types/src/testing/database-test-rig.d.ts.map +0 -1
- package/dist/types/src/tests/database.test.d.ts +0 -2
- package/dist/types/src/tests/database.test.d.ts.map +0 -1
- package/src/testing/database-test-rig.ts +0 -289
- package/src/tests/database.test.ts +0 -100
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/echo-pipeline",
|
|
3
|
-
"version": "0.4.8
|
|
3
|
+
"version": "0.4.8",
|
|
4
4
|
"description": "ECHO database.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -36,38 +36,38 @@
|
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"crc-32": "^1.2.2",
|
|
39
|
-
"@dxos/async": "0.4.8
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/codec-protobuf": "0.4.8
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/crypto": "0.4.8
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/hypercore": "0.4.8
|
|
50
|
-
"@dxos/invariant": "0.4.8
|
|
51
|
-
"@dxos/keyring": "0.4.8
|
|
52
|
-
"@dxos/keys": "0.4.8
|
|
53
|
-
"@dxos/log": "0.4.8
|
|
54
|
-
"@dxos/
|
|
55
|
-
"@dxos/
|
|
56
|
-
"@dxos/
|
|
57
|
-
"@dxos/
|
|
58
|
-
"@dxos/
|
|
59
|
-
"@dxos/random-access-storage": "0.4.8
|
|
60
|
-
"@dxos/rpc": "0.4.8
|
|
61
|
-
"@dxos/teleport": "0.4.8
|
|
62
|
-
"@dxos/teleport-extension-automerge-replicator": "0.4.8
|
|
63
|
-
"@dxos/teleport-extension-
|
|
64
|
-
"@dxos/teleport-extension-
|
|
65
|
-
"@dxos/teleport-extension-replicator": "0.4.8
|
|
66
|
-
"@dxos/text-model": "0.4.8
|
|
67
|
-
"@dxos/timeframe": "0.4.8
|
|
68
|
-
"@dxos/tracing": "0.4.8
|
|
69
|
-
"@dxos/typings": "0.4.8
|
|
70
|
-
"@dxos/util": "0.4.8
|
|
39
|
+
"@dxos/async": "0.4.8",
|
|
40
|
+
"@dxos/context": "0.4.8",
|
|
41
|
+
"@dxos/codec-protobuf": "0.4.8",
|
|
42
|
+
"@dxos/credentials": "0.4.8",
|
|
43
|
+
"@dxos/automerge": "0.4.8",
|
|
44
|
+
"@dxos/crypto": "0.4.8",
|
|
45
|
+
"@dxos/debug": "0.4.8",
|
|
46
|
+
"@dxos/echo-db": "0.4.8",
|
|
47
|
+
"@dxos/feed-store": "0.4.8",
|
|
48
|
+
"@dxos/document-model": "0.4.8",
|
|
49
|
+
"@dxos/hypercore": "0.4.8",
|
|
50
|
+
"@dxos/invariant": "0.4.8",
|
|
51
|
+
"@dxos/keyring": "0.4.8",
|
|
52
|
+
"@dxos/keys": "0.4.8",
|
|
53
|
+
"@dxos/log": "0.4.8",
|
|
54
|
+
"@dxos/messaging": "0.4.8",
|
|
55
|
+
"@dxos/model-factory": "0.4.8",
|
|
56
|
+
"@dxos/network-manager": "0.4.8",
|
|
57
|
+
"@dxos/protocols": "0.4.8",
|
|
58
|
+
"@dxos/node-std": "0.4.8",
|
|
59
|
+
"@dxos/random-access-storage": "0.4.8",
|
|
60
|
+
"@dxos/rpc": "0.4.8",
|
|
61
|
+
"@dxos/teleport": "0.4.8",
|
|
62
|
+
"@dxos/teleport-extension-automerge-replicator": "0.4.8",
|
|
63
|
+
"@dxos/teleport-extension-object-sync": "0.4.8",
|
|
64
|
+
"@dxos/teleport-extension-gossip": "0.4.8",
|
|
65
|
+
"@dxos/teleport-extension-replicator": "0.4.8",
|
|
66
|
+
"@dxos/text-model": "0.4.8",
|
|
67
|
+
"@dxos/timeframe": "0.4.8",
|
|
68
|
+
"@dxos/tracing": "0.4.8",
|
|
69
|
+
"@dxos/typings": "0.4.8",
|
|
70
|
+
"@dxos/util": "0.4.8"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"fast-check": "^3.15.1",
|
|
@@ -78,7 +78,9 @@ export class ControlPipeline {
|
|
|
78
78
|
queueMicrotask(async () => {
|
|
79
79
|
try {
|
|
80
80
|
const feed = await feedProvider(info.key);
|
|
81
|
-
|
|
81
|
+
if (!this._pipeline.hasFeed(feed.key)) {
|
|
82
|
+
await this._pipeline.addFeed(feed);
|
|
83
|
+
}
|
|
82
84
|
} catch (err: any) {
|
|
83
85
|
log.catch(err);
|
|
84
86
|
}
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
type SpecificCredential,
|
|
11
11
|
checkCredentialType,
|
|
12
12
|
} from '@dxos/credentials';
|
|
13
|
-
import {
|
|
13
|
+
import { ItemManager } from '@dxos/echo-db';
|
|
14
14
|
import { type FeedWriter } from '@dxos/feed-store';
|
|
15
15
|
import { invariant } from '@dxos/invariant';
|
|
16
16
|
import { type PublicKey } from '@dxos/keys';
|
|
@@ -19,8 +19,6 @@ import { type ModelFactory } from '@dxos/model-factory';
|
|
|
19
19
|
import { CancelledError, type DataPipelineProcessed } from '@dxos/protocols';
|
|
20
20
|
import { type CreateEpochRequest } from '@dxos/protocols/proto/dxos/client/services';
|
|
21
21
|
import { type DataMessage } from '@dxos/protocols/proto/dxos/echo/feed';
|
|
22
|
-
import { type SpaceCache } from '@dxos/protocols/proto/dxos/echo/metadata';
|
|
23
|
-
import { type ObjectSnapshot } from '@dxos/protocols/proto/dxos/echo/model/document';
|
|
24
22
|
import { type SpaceSnapshot } from '@dxos/protocols/proto/dxos/echo/snapshot';
|
|
25
23
|
import { type Credential, type Epoch } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
26
24
|
import { Timeframe } from '@dxos/timeframe';
|
|
@@ -50,16 +48,6 @@ export type DataPipelineParams = {
|
|
|
50
48
|
onPipelineCreated: (pipeline: Pipeline) => Promise<void>;
|
|
51
49
|
};
|
|
52
50
|
|
|
53
|
-
/**
|
|
54
|
-
* Number of mutations since the last snapshot before we automatically create another snapshot.
|
|
55
|
-
*/
|
|
56
|
-
const MESSAGES_PER_SNAPSHOT = 10;
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Minimum time between automatic snapshots.
|
|
60
|
-
*/
|
|
61
|
-
const AUTOMATIC_SNAPSHOT_DEBOUNCE_INTERVAL = 5_000;
|
|
62
|
-
|
|
63
51
|
/**
|
|
64
52
|
* Minimum time in MS between recording latest timeframe in metadata.
|
|
65
53
|
*/
|
|
@@ -194,7 +182,6 @@ export class DataPipeline implements CredentialProcessor {
|
|
|
194
182
|
|
|
195
183
|
// NOTE: Make sure the processing is stopped BEFORE we save the snapshot.
|
|
196
184
|
try {
|
|
197
|
-
await this._saveCache();
|
|
198
185
|
if (this._pipeline) {
|
|
199
186
|
await this._saveTargetTimeframe(this._pipeline.state.timeframe);
|
|
200
187
|
}
|
|
@@ -293,28 +280,6 @@ export class DataPipeline implements CredentialProcessor {
|
|
|
293
280
|
this._targetTimeframe = newTimeframe;
|
|
294
281
|
}
|
|
295
282
|
|
|
296
|
-
private async _saveCache() {
|
|
297
|
-
const cache: SpaceCache = {};
|
|
298
|
-
|
|
299
|
-
try {
|
|
300
|
-
// Add properties to cache.
|
|
301
|
-
const propertiesItem = this.itemManager.items.find(
|
|
302
|
-
(item) =>
|
|
303
|
-
item.modelMeta?.type === 'dxos.org/model/document' &&
|
|
304
|
-
// TODO(burdon): Document?
|
|
305
|
-
(getStateMachineFromItem(item)?.snapshot() as ObjectSnapshot).type === TYPE_PROPERTIES,
|
|
306
|
-
);
|
|
307
|
-
if (propertiesItem) {
|
|
308
|
-
cache.properties = getStateMachineFromItem(propertiesItem)?.snapshot() as ObjectSnapshot;
|
|
309
|
-
}
|
|
310
|
-
} catch (err) {
|
|
311
|
-
log.warn('Failed to cache properties', err);
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
// Save cache.
|
|
315
|
-
await this._params.metadataStore.setCache(this._params.spaceKey, cache);
|
|
316
|
-
}
|
|
317
|
-
|
|
318
283
|
private async _noteTargetStateIfNeeded(timeframe: Timeframe) {
|
|
319
284
|
if (!this._pipeline?.state.reachedTarget) {
|
|
320
285
|
return;
|
|
@@ -327,13 +292,6 @@ export class DataPipeline implements CredentialProcessor {
|
|
|
327
292
|
|
|
328
293
|
await this._saveTargetTimeframe(timeframe);
|
|
329
294
|
}
|
|
330
|
-
|
|
331
|
-
if (
|
|
332
|
-
Date.now() - this._lastSnapshotSaveTime > AUTOMATIC_SNAPSHOT_DEBOUNCE_INTERVAL &&
|
|
333
|
-
timeframe.totalMessages() - this._lastAutomaticSnapshotTimeframe.totalMessages() > MESSAGES_PER_SNAPSHOT
|
|
334
|
-
) {
|
|
335
|
-
await this._saveCache();
|
|
336
|
-
}
|
|
337
295
|
}
|
|
338
296
|
|
|
339
297
|
private async _processEpochInSeparateTask(epoch: SpecificCredential<Epoch>) {
|
|
@@ -419,7 +377,6 @@ export class DataPipeline implements CredentialProcessor {
|
|
|
419
377
|
|
|
420
378
|
private async _flush() {
|
|
421
379
|
try {
|
|
422
|
-
await this._saveCache();
|
|
423
380
|
if (this._pipeline) {
|
|
424
381
|
await this._saveTargetTimeframe(this._pipeline.state.timeframe);
|
|
425
382
|
}
|
package/src/testing/index.ts
CHANGED
package/src/testing/util.ts
CHANGED
|
@@ -4,16 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
import { asyncTimeout } from '@dxos/async';
|
|
6
6
|
import { DocumentModel } from '@dxos/document-model';
|
|
7
|
-
import {
|
|
7
|
+
import { ItemManager } from '@dxos/echo-db';
|
|
8
8
|
import { MockFeedWriter } from '@dxos/feed-store/testing';
|
|
9
9
|
import { PublicKey } from '@dxos/keys';
|
|
10
10
|
import { ModelFactory } from '@dxos/model-factory';
|
|
11
11
|
import { type DataMessage } from '@dxos/protocols/proto/dxos/echo/feed';
|
|
12
|
-
import { StorageType, createStorage } from '@dxos/random-access-storage';
|
|
13
12
|
import { Timeframe } from '@dxos/timeframe';
|
|
14
13
|
|
|
15
|
-
import {
|
|
16
|
-
import { DatabaseHost, type DataServiceHost, DataServiceImpl, DataServiceSubscriptions } from '../db-host';
|
|
14
|
+
import { DatabaseHost } from '../db-host';
|
|
17
15
|
import { type DataPipeline } from '../space';
|
|
18
16
|
|
|
19
17
|
export const createMemoryDatabase = async (modelFactory: ModelFactory) => {
|
|
@@ -41,28 +39,6 @@ export const createMemoryDatabase = async (modelFactory: ModelFactory) => {
|
|
|
41
39
|
};
|
|
42
40
|
};
|
|
43
41
|
|
|
44
|
-
export const createRemoteDatabaseFromDataServiceHost = async (
|
|
45
|
-
modelFactory: ModelFactory,
|
|
46
|
-
dataServiceHost: DataServiceHost,
|
|
47
|
-
) => {
|
|
48
|
-
const dataServiceSubscriptions = new DataServiceSubscriptions();
|
|
49
|
-
const automergeHost = new AutomergeHost({
|
|
50
|
-
directory: createStorage({ type: StorageType.RAM }).createDirectory(),
|
|
51
|
-
});
|
|
52
|
-
const dataService = new DataServiceImpl(dataServiceSubscriptions, automergeHost);
|
|
53
|
-
|
|
54
|
-
const spaceKey = PublicKey.random();
|
|
55
|
-
await dataServiceSubscriptions.registerSpace(spaceKey, dataServiceHost);
|
|
56
|
-
|
|
57
|
-
const itemManager = new ItemManager(modelFactory);
|
|
58
|
-
const backend = new DatabaseProxy({ service: dataService, itemManager, spaceKey });
|
|
59
|
-
await backend.open(new ModelFactory().registerModel(DocumentModel));
|
|
60
|
-
return {
|
|
61
|
-
itemManager,
|
|
62
|
-
backend,
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
|
|
66
42
|
export const testLocalDatabase = async (create: DataPipeline, check: DataPipeline = create) => {
|
|
67
43
|
const objectId = PublicKey.random().toHex();
|
|
68
44
|
await create.databaseHost!.getWriteStream()?.write({
|