@dxos/echo-pipeline 0.1.30-next.a4f4fa5 → 0.1.30
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-L44NG4N6.mjs → chunk-QMDRF3NL.mjs} +72 -37
- package/dist/lib/browser/{chunk-L44NG4N6.mjs.map → chunk-QMDRF3NL.mjs.map} +3 -3
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +23 -14
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node/index.cjs +68 -33
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +49 -43
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/types/src/dbhost/data-service-host.d.ts.map +1 -1
- package/dist/types/src/dbhost/database-backend.d.ts +2 -2
- package/dist/types/src/dbhost/database-backend.d.ts.map +1 -1
- package/dist/types/src/space/genesis.d.ts.map +1 -1
- package/dist/types/src/testing/test-agent-builder.d.ts +4 -3
- package/dist/types/src/testing/test-agent-builder.d.ts.map +1 -1
- package/dist/types/src/testing/util.d.ts.map +1 -1
- package/package.json +29 -29
- package/src/dbhost/data-service-host.ts +19 -25
- package/src/dbhost/database-backend.ts +1 -1
- package/src/pipeline/pipeline.test.ts +12 -4
- package/src/space/data-pipeline-controller.ts +1 -1
- package/src/space/genesis.ts +47 -7
- package/src/space/space-protocol.browser.test.ts +8 -6
- package/src/space/space-protocol.test.ts +8 -6
- package/src/testing/database-test-rig.ts +1 -1
- package/src/testing/test-agent-builder.ts +13 -7
- package/src/testing/util.ts +11 -7
- package/src/tests/database-unit.test.ts +25 -0
- package/src/tests/database.test.ts +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-service-host.d.ts","sourceRoot":"","sources":["../../../../src/dbhost/data-service-host.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAuB,WAAW,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"data-service-host.d.ts","sourceRoot":"","sources":["../../../../src/dbhost/data-service-host.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAuB,WAAW,EAAE,WAAW,EAAuB,MAAM,eAAe,CAAC;AACnG,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAGnG;;;GAGG;AAEH,qBAAa,eAAe;IAMxB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;IAPhC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAE5B;gBAGiB,YAAY,EAAE,WAAW,EACzB,YAAY,EAAE,WAAW,EACzB,YAAY,CAAC,qCAAyB;IAGzD;;OAEG;IACH,SAAS,IAAI,MAAM,CAAC,SAAS,CAAC;IAwCxB,KAAK,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,eAAe,CAAC;CAsB7D"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EchoProcessor, ItemManager } from '@dxos/echo-db';
|
|
1
|
+
import { EchoProcessor, ItemDemuxer, ItemManager } from '@dxos/echo-db';
|
|
2
2
|
import { FeedWriter } from '@dxos/feed-store';
|
|
3
3
|
import { ModelFactory } from '@dxos/model-factory';
|
|
4
4
|
import { DataMessage } from '@dxos/protocols/proto/dxos/echo/feed';
|
|
@@ -14,7 +14,7 @@ export declare class DatabaseBackendHost {
|
|
|
14
14
|
private readonly _snapshot?;
|
|
15
15
|
private _echoProcessor;
|
|
16
16
|
private _itemManager;
|
|
17
|
-
|
|
17
|
+
_itemDemuxer: ItemDemuxer;
|
|
18
18
|
constructor(_outboundStream: FeedWriter<DataMessage> | undefined, _snapshot?: EchoSnapshot | undefined);
|
|
19
19
|
get isReadOnly(): boolean;
|
|
20
20
|
get echoProcessor(): EchoProcessor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database-backend.d.ts","sourceRoot":"","sources":["../../../../src/dbhost/database-backend.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"database-backend.d.ts","sourceRoot":"","sources":["../../../../src/dbhost/database-backend.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAExE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD;;;;GAIG;AACH,qBAAa,mBAAmB;IAM5B,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC;IAN7B,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,YAAY,CAAe;IAC5B,YAAY,EAAG,WAAW,CAAC;gBAGf,eAAe,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,SAAS,EACpD,SAAS,CAAC,0BAAc;IAG3C,IAAI,UAAU,IAAI,OAAO,CAExB;IAED,IAAI,aAAa,kBAEhB;IAEK,IAAI,CAAC,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY;IAYzD,KAAK;IAEX,cAAc,IAAI,UAAU,CAAC,WAAW,CAAC,GAAG,SAAS;IAIrD,cAAc;IAId,qBAAqB;CAGtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"genesis.d.ts","sourceRoot":"","sources":["../../../../src/space/genesis.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAGxC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,eAAO,MAAM,YAAY,YAAmB,OAAO,kBAAkB,cAAc,SAAS,KAAK,
|
|
1
|
+
{"version":3,"file":"genesis.d.ts","sourceRoot":"","sources":["../../../../src/space/genesis.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAGxC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,eAAO,MAAM,YAAY,YAAmB,OAAO,kBAAkB,cAAc,SAAS,KAAK,gFAwDhG,CAAC"}
|
|
@@ -5,7 +5,7 @@ import { MemorySignalManagerContext } from '@dxos/messaging';
|
|
|
5
5
|
import { NetworkManager } from '@dxos/network-manager';
|
|
6
6
|
import type { FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
|
|
7
7
|
import { Storage } from '@dxos/random-access-storage';
|
|
8
|
-
import { Presence } from '@dxos/teleport-extension-
|
|
8
|
+
import { Gossip, Presence } from '@dxos/teleport-extension-gossip';
|
|
9
9
|
import { Space, SpaceManager, SpaceProtocol } from '../space';
|
|
10
10
|
import { DataPipelineControllerImpl } from '../space/data-pipeline-controller';
|
|
11
11
|
import { TestFeedBuilder } from './test-feed-builder';
|
|
@@ -46,7 +46,8 @@ export declare class TestAgent {
|
|
|
46
46
|
getSpace(spaceKey: PublicKey): Space | undefined;
|
|
47
47
|
createSpaceManager(): SpaceManager;
|
|
48
48
|
createSpace(identityKey?: PublicKey, spaceKey?: PublicKey, genesisKey?: PublicKey): Promise<[Space, DataPipelineControllerImpl]>;
|
|
49
|
-
createSpaceProtocol(topic: PublicKey,
|
|
50
|
-
|
|
49
|
+
createSpaceProtocol(topic: PublicKey, gossip?: Gossip): SpaceProtocol;
|
|
50
|
+
createGossip(): Gossip;
|
|
51
|
+
createPresence(gossip?: Gossip): Presence;
|
|
51
52
|
}
|
|
52
53
|
//# sourceMappingURL=test-agent-builder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-agent-builder.d.ts","sourceRoot":"","sources":["../../../../src/testing/test-agent-builder.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAuB,0BAA0B,EAA0B,MAAM,iBAAiB,CAAC;AAE1G,OAAO,EAAwD,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC7G,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAiB,OAAO,EAAe,MAAM,6BAA6B,CAAC;AAClF,OAAO,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"test-agent-builder.d.ts","sourceRoot":"","sources":["../../../../src/testing/test-agent-builder.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAuB,0BAA0B,EAA0B,MAAM,iBAAiB,CAAC;AAE1G,OAAO,EAAwD,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC7G,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAiB,OAAO,EAAe,MAAM,6BAA6B,CAAC;AAClF,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAKnE,OAAO,EAA0C,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACtG,OAAO,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,oBAAY,sBAAsB,GAAG,MAAM,cAAc,CAAC;AAE1D,eAAO,MAAM,4BAA4B,kBACvB,0BAA0B,KAAG,sBAKzC,CAAC;AAEP,eAAO,MAAM,+BAA+B,cAC9B,MAAM,KAAG,sBAKjB,CAAC;AAEP,oBAAY,uBAAuB,GAAG;IACpC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,sBAAsB,CAAC,EAAE,sBAAsB,CAAC;CACjD,CAAC;AAEF;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAwD;IAChF,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;IACnC,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAAyB;gBAErD,EAAE,OAAO,EAAE,sBAAsB,EAAE,GAAE,uBAA4B;IAMvE,KAAK;IAIX,IAAI,MAAM,gBAET;IAED,QAAQ,CAAC,SAAS,EAAE,SAAS;IAIvB,UAAU,IAAI,OAAO,CAAC,SAAS,CAAC;CAYvC;AAED;;GAEG;AACH,qBAAa,SAAS;IAOlB,OAAO,CAAC,QAAQ,CAAC,uBAAuB;IACxC,OAAO,CAAC,QAAQ,CAAC,YAAY;aACb,WAAW,EAAE,SAAS;aACtB,SAAS,EAAE,SAAS;IATtC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoD;IAE5E,SAAgB,OAAO,EAAE,OAAO,CAAC;IACjC,SAAgB,SAAS,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;gBAG/B,uBAAuB,EAAE,sBAAsB,EAC/C,YAAY,EAAE,eAAe,EAC9B,WAAW,EAAE,SAAS,EACtB,SAAS,EAAE,SAAS;IAMhC,KAAK;IAIX,IAAI,MAAM,YAET;IAED,QAAQ,CAAC,QAAQ,EAAE,SAAS;IAI5B,kBAAkB;IAOZ,WAAW,CACf,WAAW,GAAE,SAA4B,EACzC,QAAQ,CAAC,EAAE,SAAS,EACpB,UAAU,CAAC,EAAE,SAAS,GACrB,OAAO,CAAC,CAAC,KAAK,EAAE,0BAA0B,CAAC,CAAC;IAuC/C,mBAAmB,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,MAAM;IAkBrD,YAAY;IAMZ,cAAc,CAAC,MAAM,CAAC,EAAE,MAAM;CAQ/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../../src/testing/util.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGlE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAInD,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAA6C,MAAM,WAAW,CAAC;AAC5G,OAAO,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAC;AAEtD,eAAO,MAAM,oBAAoB,iBAAwB,YAAY;;;EAqBpE,CAAC;AAEF,eAAO,MAAM,uCAAuC,iBACpC,YAAY,mBACT,eAAe;;;EAejC,CAAC;AAEF,eAAO,MAAM,iBAAiB,WACpB,0BAA0B,UAC3B,0BAA0B,
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../../src/testing/util.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGlE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAInD,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAA6C,MAAM,WAAW,CAAC;AAC5G,OAAO,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAC;AAEtD,eAAO,MAAM,oBAAoB,iBAAwB,YAAY;;;EAqBpE,CAAC;AAEF,eAAO,MAAM,uCAAuC,iBACpC,YAAY,mBACT,eAAe;;;EAejC,CAAC;AAEF,eAAO,MAAM,iBAAiB,WACpB,0BAA0B,UAC3B,0BAA0B,kBAoBlC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/echo-pipeline",
|
|
3
|
-
"version": "0.1.30
|
|
3
|
+
"version": "0.1.30",
|
|
4
4
|
"description": "ECHO database.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -20,40 +20,40 @@
|
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"debug": "^4.3.3",
|
|
23
|
-
"@dxos/async": "0.1.30
|
|
24
|
-
"@dxos/codec-protobuf": "0.1.30
|
|
25
|
-
"@dxos/context": "0.1.30
|
|
26
|
-
"@dxos/credentials": "0.1.30
|
|
27
|
-
"@dxos/crypto": "0.1.30
|
|
28
|
-
"@dxos/debug": "0.1.30
|
|
29
|
-
"@dxos/document-model": "0.1.30
|
|
30
|
-
"@dxos/echo-db": "0.1.30
|
|
31
|
-
"@dxos/feed-store": "0.1.30
|
|
32
|
-
"@dxos/hypercore": "0.1.30
|
|
33
|
-
"@dxos/keyring": "0.1.30
|
|
34
|
-
"@dxos/keys": "0.1.30
|
|
35
|
-
"@dxos/log": "0.1.30
|
|
36
|
-
"@dxos/messaging": "0.1.30
|
|
37
|
-
"@dxos/model-factory": "0.1.30
|
|
38
|
-
"@dxos/network-manager": "0.1.30
|
|
39
|
-
"@dxos/node-std": "0.1.30
|
|
40
|
-
"@dxos/protocols": "0.1.30
|
|
41
|
-
"@dxos/random-access-storage": "0.1.30
|
|
42
|
-
"@dxos/rpc": "0.1.30
|
|
43
|
-
"@dxos/teleport": "0.1.30
|
|
44
|
-
"@dxos/teleport-extension-
|
|
45
|
-
"@dxos/teleport-extension-
|
|
46
|
-
"@dxos/teleport-extension-replicator": "0.1.30
|
|
47
|
-
"@dxos/timeframe": "0.1.30
|
|
48
|
-
"@dxos/typings": "0.1.30
|
|
49
|
-
"@dxos/util": "0.1.30
|
|
23
|
+
"@dxos/async": "0.1.30",
|
|
24
|
+
"@dxos/codec-protobuf": "0.1.30",
|
|
25
|
+
"@dxos/context": "0.1.30",
|
|
26
|
+
"@dxos/credentials": "0.1.30",
|
|
27
|
+
"@dxos/crypto": "0.1.30",
|
|
28
|
+
"@dxos/debug": "0.1.30",
|
|
29
|
+
"@dxos/document-model": "0.1.30",
|
|
30
|
+
"@dxos/echo-db": "0.1.30",
|
|
31
|
+
"@dxos/feed-store": "0.1.30",
|
|
32
|
+
"@dxos/hypercore": "0.1.30",
|
|
33
|
+
"@dxos/keyring": "0.1.30",
|
|
34
|
+
"@dxos/keys": "0.1.30",
|
|
35
|
+
"@dxos/log": "0.1.30",
|
|
36
|
+
"@dxos/messaging": "0.1.30",
|
|
37
|
+
"@dxos/model-factory": "0.1.30",
|
|
38
|
+
"@dxos/network-manager": "0.1.30",
|
|
39
|
+
"@dxos/node-std": "0.1.30",
|
|
40
|
+
"@dxos/protocols": "0.1.30",
|
|
41
|
+
"@dxos/random-access-storage": "0.1.30",
|
|
42
|
+
"@dxos/rpc": "0.1.30",
|
|
43
|
+
"@dxos/teleport": "0.1.30",
|
|
44
|
+
"@dxos/teleport-extension-gossip": "0.1.30",
|
|
45
|
+
"@dxos/teleport-extension-object-sync": "0.1.30",
|
|
46
|
+
"@dxos/teleport-extension-replicator": "0.1.30",
|
|
47
|
+
"@dxos/timeframe": "0.1.30",
|
|
48
|
+
"@dxos/typings": "0.1.30",
|
|
49
|
+
"@dxos/util": "0.1.30"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/debug": "^4.1.7",
|
|
53
53
|
"hypercore-protocol": "^8.0.7",
|
|
54
54
|
"source-map-support": "^0.5.12",
|
|
55
55
|
"wait-for-expect": "^3.0.2",
|
|
56
|
-
"@dxos/text-model": "0.1.30
|
|
56
|
+
"@dxos/text-model": "0.1.30"
|
|
57
57
|
},
|
|
58
58
|
"publishConfig": {
|
|
59
59
|
"access": "public"
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import assert from 'node:assert';
|
|
6
6
|
|
|
7
7
|
import { Stream } from '@dxos/codec-protobuf';
|
|
8
|
-
import { tagMutationsInBatch, ItemDemuxer, ItemManager } from '@dxos/echo-db';
|
|
8
|
+
import { tagMutationsInBatch, ItemDemuxer, ItemManager, setMetadataOnObject } from '@dxos/echo-db';
|
|
9
9
|
import { FeedWriter } from '@dxos/feed-store';
|
|
10
10
|
import { PublicKey } from '@dxos/keys';
|
|
11
11
|
import { log } from '@dxos/log';
|
|
@@ -45,25 +45,17 @@ export class DataServiceHost {
|
|
|
45
45
|
|
|
46
46
|
// subscribe to mutations
|
|
47
47
|
|
|
48
|
-
this._itemDemuxer.mutation.on(ctx, (
|
|
49
|
-
|
|
48
|
+
this._itemDemuxer.mutation.on(ctx, (message) => {
|
|
49
|
+
const { batch, meta } = message;
|
|
50
|
+
log('Object update', { batch, meta });
|
|
50
51
|
|
|
51
|
-
const clientTag = this._clientTagMap.get([
|
|
52
|
+
const clientTag = this._clientTagMap.get([message.meta.feedKey, message.meta.seq]);
|
|
52
53
|
// TODO(dmaretskyi): Memorąąy leak with _clientTagMap not getting cleared.
|
|
53
54
|
|
|
54
55
|
// Assign feed metadata
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
...mutation.data,
|
|
59
|
-
mutations: mutation.data.mutations?.map((m, mutationIdx) => ({
|
|
60
|
-
...m,
|
|
61
|
-
meta: mutation.meta
|
|
62
|
-
})),
|
|
63
|
-
meta: mutation.meta
|
|
64
|
-
}
|
|
65
|
-
]
|
|
66
|
-
};
|
|
56
|
+
batch.objects?.forEach((object) => {
|
|
57
|
+
setMetadataOnObject(object, meta);
|
|
58
|
+
});
|
|
67
59
|
|
|
68
60
|
// Assign client tag metadata
|
|
69
61
|
if (clientTag) {
|
|
@@ -72,8 +64,8 @@ export class DataServiceHost {
|
|
|
72
64
|
|
|
73
65
|
next({
|
|
74
66
|
clientTag,
|
|
75
|
-
feedKey:
|
|
76
|
-
seq:
|
|
67
|
+
feedKey: message.meta.feedKey,
|
|
68
|
+
seq: message.meta.seq,
|
|
77
69
|
batch
|
|
78
70
|
});
|
|
79
71
|
});
|
|
@@ -82,16 +74,18 @@ export class DataServiceHost {
|
|
|
82
74
|
|
|
83
75
|
async write(request: WriteRequest): Promise<MutationReceipt> {
|
|
84
76
|
assert(this._writeStream, 'Cannot write mutations in readonly mode');
|
|
85
|
-
assert(request.batch.objects?.length === 1, 'Only single object mutations are supported');
|
|
86
77
|
|
|
78
|
+
// Clear client metadata.
|
|
87
79
|
const receipt = await this._writeStream.write({
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
80
|
+
batch: {
|
|
81
|
+
objects: request.batch.objects?.map((object) => ({
|
|
82
|
+
...object,
|
|
83
|
+
mutations: object.mutations?.map((m) => ({
|
|
84
|
+
...m,
|
|
85
|
+
meta: undefined
|
|
86
|
+
})),
|
|
92
87
|
meta: undefined
|
|
93
|
-
}))
|
|
94
|
-
meta: undefined
|
|
88
|
+
}))
|
|
95
89
|
}
|
|
96
90
|
});
|
|
97
91
|
if (request.clientTag) {
|
|
@@ -20,7 +20,7 @@ import { DataServiceHost } from './data-service-host';
|
|
|
20
20
|
export class DatabaseBackendHost {
|
|
21
21
|
private _echoProcessor!: EchoProcessor;
|
|
22
22
|
private _itemManager!: ItemManager;
|
|
23
|
-
|
|
23
|
+
public _itemDemuxer!: ItemDemuxer;
|
|
24
24
|
|
|
25
25
|
constructor(
|
|
26
26
|
private readonly _outboundStream: FeedWriter<DataMessage> | undefined,
|
|
@@ -34,8 +34,12 @@ describe('pipeline/Pipeline', () => {
|
|
|
34
34
|
timeframe: new Timeframe(),
|
|
35
35
|
payload: {
|
|
36
36
|
data: {
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
batch: {
|
|
38
|
+
objects: [
|
|
39
|
+
{
|
|
40
|
+
objectId: `${feedIdx}-${msgIdx}`
|
|
41
|
+
}
|
|
42
|
+
]
|
|
39
43
|
}
|
|
40
44
|
}
|
|
41
45
|
}
|
|
@@ -54,8 +58,12 @@ describe('pipeline/Pipeline', () => {
|
|
|
54
58
|
for (const msgIdx in range(messagesPerFeed)) {
|
|
55
59
|
await pipeline.writer!.write({
|
|
56
60
|
data: {
|
|
57
|
-
|
|
58
|
-
|
|
61
|
+
batch: {
|
|
62
|
+
objects: [
|
|
63
|
+
{
|
|
64
|
+
objectId: `local-${msgIdx}`
|
|
65
|
+
}
|
|
66
|
+
]
|
|
59
67
|
}
|
|
60
68
|
}
|
|
61
69
|
});
|
package/src/space/genesis.ts
CHANGED
|
@@ -2,21 +2,61 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { createCredential } from '@dxos/credentials';
|
|
6
6
|
import { failUndefined } from '@dxos/debug';
|
|
7
7
|
import { Keyring } from '@dxos/keyring';
|
|
8
|
-
import { AdmittedFeed } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
8
|
+
import { AdmittedFeed, SpaceMember } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
9
9
|
|
|
10
10
|
import { Space } from './space';
|
|
11
11
|
import { SigningContext } from './space-manager';
|
|
12
12
|
|
|
13
13
|
export const spaceGenesis = async (keyring: Keyring, signingContext: SigningContext, space: Space) => {
|
|
14
|
-
//
|
|
15
|
-
const generator = new CredentialGenerator(keyring, signingContext.identityKey, signingContext.deviceKey);
|
|
16
|
-
|
|
14
|
+
// TODO(dmaretskyi): Find a way to reconcile with credential generator.
|
|
17
15
|
const credentials = [
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
await createCredential({
|
|
17
|
+
signer: keyring,
|
|
18
|
+
issuer: space.key,
|
|
19
|
+
subject: space.key,
|
|
20
|
+
assertion: {
|
|
21
|
+
'@type': 'dxos.halo.credentials.SpaceGenesis',
|
|
22
|
+
spaceKey: space.key
|
|
23
|
+
}
|
|
24
|
+
}),
|
|
25
|
+
|
|
26
|
+
await createCredential({
|
|
27
|
+
signer: keyring,
|
|
28
|
+
issuer: space.key,
|
|
29
|
+
subject: signingContext.identityKey,
|
|
30
|
+
assertion: {
|
|
31
|
+
'@type': 'dxos.halo.credentials.SpaceMember',
|
|
32
|
+
spaceKey: space.key,
|
|
33
|
+
role: SpaceMember.Role.ADMIN,
|
|
34
|
+
profile: signingContext.profile,
|
|
35
|
+
genesisFeedKey: space.controlFeedKey ?? failUndefined()
|
|
36
|
+
}
|
|
37
|
+
}),
|
|
38
|
+
|
|
39
|
+
await signingContext.credentialSigner.createCredential({
|
|
40
|
+
subject: space.controlFeedKey ?? failUndefined(),
|
|
41
|
+
assertion: {
|
|
42
|
+
'@type': 'dxos.halo.credentials.AdmittedFeed',
|
|
43
|
+
spaceKey: space.key,
|
|
44
|
+
identityKey: signingContext.identityKey,
|
|
45
|
+
deviceKey: signingContext.deviceKey,
|
|
46
|
+
designation: AdmittedFeed.Designation.CONTROL
|
|
47
|
+
}
|
|
48
|
+
}),
|
|
49
|
+
|
|
50
|
+
await signingContext.credentialSigner.createCredential({
|
|
51
|
+
subject: space.dataFeedKey ?? failUndefined(),
|
|
52
|
+
assertion: {
|
|
53
|
+
'@type': 'dxos.halo.credentials.AdmittedFeed',
|
|
54
|
+
spaceKey: space.key,
|
|
55
|
+
identityKey: signingContext.identityKey,
|
|
56
|
+
deviceKey: signingContext.deviceKey,
|
|
57
|
+
designation: AdmittedFeed.Designation.DATA
|
|
58
|
+
}
|
|
59
|
+
})
|
|
20
60
|
];
|
|
21
61
|
|
|
22
62
|
for (const credential of credentials) {
|
|
@@ -26,12 +26,14 @@ describe('space/space-protocol', () => {
|
|
|
26
26
|
const topic = PublicKey.random();
|
|
27
27
|
|
|
28
28
|
const peer1 = await builder.createPeer();
|
|
29
|
-
const
|
|
30
|
-
const
|
|
29
|
+
const gossip1 = peer1.createGossip();
|
|
30
|
+
const presence1 = peer1.createPresence(gossip1);
|
|
31
|
+
const protocol1 = peer1.createSpaceProtocol(topic, gossip1);
|
|
31
32
|
|
|
32
33
|
const peer2 = await builder.createPeer();
|
|
33
|
-
const
|
|
34
|
-
const
|
|
34
|
+
const gossip2 = peer2.createGossip();
|
|
35
|
+
const presence2 = peer2.createPresence(gossip2);
|
|
36
|
+
const protocol2 = peer2.createSpaceProtocol(topic, gossip2);
|
|
35
37
|
|
|
36
38
|
await protocol1.start();
|
|
37
39
|
await protocol2.start();
|
|
@@ -40,8 +42,8 @@ describe('space/space-protocol', () => {
|
|
|
40
42
|
afterTest(() => protocol2.stop());
|
|
41
43
|
|
|
42
44
|
await waitForExpect(() => {
|
|
43
|
-
expect(presence1.getPeersOnline().map(({
|
|
44
|
-
expect(presence2.getPeersOnline().map(({
|
|
45
|
+
expect(presence1.getPeersOnline().map(({ identityKey }) => identityKey)).toContainEqual(peer2.identityKey);
|
|
46
|
+
expect(presence2.getPeersOnline().map(({ identityKey }) => identityKey)).toContainEqual(peer1.identityKey);
|
|
45
47
|
});
|
|
46
48
|
});
|
|
47
49
|
|
|
@@ -21,12 +21,14 @@ describe('space/space-protocol', () => {
|
|
|
21
21
|
const topic = PublicKey.random();
|
|
22
22
|
|
|
23
23
|
const peer1 = await builder.createPeer();
|
|
24
|
-
const
|
|
25
|
-
const
|
|
24
|
+
const gossip1 = peer1.createGossip();
|
|
25
|
+
const presence1 = peer1.createPresence(gossip1);
|
|
26
|
+
const protocol1 = peer1.createSpaceProtocol(topic, gossip1);
|
|
26
27
|
|
|
27
28
|
const peer2 = await builder.createPeer();
|
|
28
|
-
const
|
|
29
|
-
const
|
|
29
|
+
const gossip2 = peer2.createGossip();
|
|
30
|
+
const presence2 = peer2.createPresence(gossip2);
|
|
31
|
+
const protocol2 = peer2.createSpaceProtocol(topic, gossip2);
|
|
30
32
|
|
|
31
33
|
await protocol1.start();
|
|
32
34
|
afterTest(() => protocol1.stop());
|
|
@@ -35,8 +37,8 @@ describe('space/space-protocol', () => {
|
|
|
35
37
|
afterTest(() => protocol2.stop());
|
|
36
38
|
|
|
37
39
|
await waitForExpect(() => {
|
|
38
|
-
expect(presence1.getPeersOnline().map(({
|
|
39
|
-
expect(presence2.getPeersOnline().map(({
|
|
40
|
+
expect(presence1.getPeersOnline().map(({ identityKey }) => identityKey)).toContainEqual(peer2.identityKey);
|
|
41
|
+
expect(presence2.getPeersOnline().map(({ identityKey }) => identityKey)).toContainEqual(peer1.identityKey);
|
|
40
42
|
}, 1_000);
|
|
41
43
|
});
|
|
42
44
|
|
|
@@ -11,7 +11,7 @@ import { ModelFactory } from '@dxos/model-factory';
|
|
|
11
11
|
import { createWebRTCTransportFactory, MemoryTransportFactory, NetworkManager } from '@dxos/network-manager';
|
|
12
12
|
import type { FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
|
|
13
13
|
import { createStorage, Storage, StorageType } from '@dxos/random-access-storage';
|
|
14
|
-
import { Presence } from '@dxos/teleport-extension-
|
|
14
|
+
import { Gossip, Presence } from '@dxos/teleport-extension-gossip';
|
|
15
15
|
import { ComplexMap } from '@dxos/util';
|
|
16
16
|
|
|
17
17
|
import { SnapshotManager, SnapshotStore } from '../dbhost';
|
|
@@ -164,7 +164,7 @@ export class TestAgent {
|
|
|
164
164
|
return [space, dataPipelineController];
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
createSpaceProtocol(topic: PublicKey,
|
|
167
|
+
createSpaceProtocol(topic: PublicKey, gossip?: Gossip) {
|
|
168
168
|
return new SpaceProtocol({
|
|
169
169
|
topic,
|
|
170
170
|
swarmIdentity: {
|
|
@@ -175,19 +175,25 @@ export class TestAgent {
|
|
|
175
175
|
networkManager: this._networkManagerProvider(),
|
|
176
176
|
onSessionAuth: (session) => {
|
|
177
177
|
session.addExtension(
|
|
178
|
-
'dxos.mesh.teleport.
|
|
179
|
-
(
|
|
178
|
+
'dxos.mesh.teleport.gossip',
|
|
179
|
+
(gossip ?? this.createGossip()).createExtension({ remotePeerId: session.remotePeerId })
|
|
180
180
|
);
|
|
181
181
|
}
|
|
182
182
|
});
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
-
|
|
185
|
+
createGossip() {
|
|
186
|
+
return new Gossip({
|
|
187
|
+
localPeerId: this.deviceKey
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
createPresence(gossip?: Gossip) {
|
|
186
192
|
return new Presence({
|
|
187
|
-
localPeerId: this.deviceKey,
|
|
188
193
|
announceInterval: 30,
|
|
189
194
|
offlineTimeout: 200,
|
|
190
|
-
identityKey: this.identityKey
|
|
195
|
+
identityKey: this.identityKey,
|
|
196
|
+
gossip: gossip ?? this.createGossip()
|
|
191
197
|
});
|
|
192
198
|
}
|
|
193
199
|
}
|
package/src/testing/util.ts
CHANGED
|
@@ -20,7 +20,7 @@ export const createMemoryDatabase = async (modelFactory: ModelFactory) => {
|
|
|
20
20
|
|
|
21
21
|
feed.written.on(([data, meta]) =>
|
|
22
22
|
backend.echoProcessor({
|
|
23
|
-
|
|
23
|
+
batch: data.batch,
|
|
24
24
|
meta: {
|
|
25
25
|
...meta,
|
|
26
26
|
memberKey: PublicKey.random(),
|
|
@@ -62,16 +62,20 @@ export const testLocalDatabase = async (
|
|
|
62
62
|
) => {
|
|
63
63
|
const objectId = PublicKey.random().toHex();
|
|
64
64
|
await create.databaseBackend!.getWriteStream()?.write({
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
batch: {
|
|
66
|
+
objects: [
|
|
67
|
+
{
|
|
68
|
+
objectId,
|
|
69
|
+
genesis: {
|
|
70
|
+
modelType: DocumentModel.meta.type
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
]
|
|
70
74
|
}
|
|
71
75
|
});
|
|
72
76
|
|
|
73
77
|
await asyncTimeout(
|
|
74
|
-
check.
|
|
78
|
+
check.databaseBackend!._itemDemuxer.mutation.waitForCondition(() => check._itemManager.entities.has(objectId)),
|
|
75
79
|
500
|
|
76
80
|
);
|
|
77
81
|
};
|
|
@@ -79,4 +79,29 @@ describe('database (unit)', () => {
|
|
|
79
79
|
// TODO(dmaretskyi): Helper functions to compare state.
|
|
80
80
|
expect(peer1.items.getItem(id)!.state).toEqual(peer1.items.getItem(id)!.state);
|
|
81
81
|
});
|
|
82
|
+
|
|
83
|
+
test('batches', async () => {
|
|
84
|
+
const builder = new DatabaseTestBuilder();
|
|
85
|
+
const peer1 = await builder.createPeer();
|
|
86
|
+
const peer2 = await builder.createPeer();
|
|
87
|
+
|
|
88
|
+
const id = PublicKey.random().toHex();
|
|
89
|
+
peer1.proxy.beginBatch();
|
|
90
|
+
peer1.proxy.mutate(genesisMutation(id, DocumentModel.meta.type));
|
|
91
|
+
peer1.proxy.mutate(
|
|
92
|
+
createModelMutation(id, encodeModelMutation(DocumentModel.meta, new MutationBuilder().set('test', 42).build()))
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
peer1.confirm();
|
|
96
|
+
peer2.replicate(peer1.timeframe);
|
|
97
|
+
|
|
98
|
+
expect(peer2.items.getItem(id)).toBeUndefined();
|
|
99
|
+
|
|
100
|
+
peer1.proxy.commitBatch();
|
|
101
|
+
peer1.confirm();
|
|
102
|
+
peer2.replicate(peer1.timeframe);
|
|
103
|
+
|
|
104
|
+
// TODO(dmaretskyi): Helper functions to compare state.
|
|
105
|
+
expect(peer1.items.getItem(id)!.state).toEqual(peer1.items.getItem(id)!.state);
|
|
106
|
+
});
|
|
82
107
|
});
|
|
@@ -29,11 +29,11 @@ describe('database', () => {
|
|
|
29
29
|
const database = await createDatabase();
|
|
30
30
|
|
|
31
31
|
const result = database.backend.mutate(genesisMutation(PublicKey.random().toHex(), DocumentModel.meta.type));
|
|
32
|
-
expect(result.
|
|
33
|
-
expect(database.itemManager.entities.has(result.
|
|
32
|
+
expect(result.objectsUpdated.length).toEqual(1);
|
|
33
|
+
expect(database.itemManager.entities.has(result.objectsUpdated[0].id));
|
|
34
34
|
|
|
35
|
-
await
|
|
36
|
-
expect(database.itemManager.entities.has(result.
|
|
35
|
+
await result.batch.waitToBeProcessed();
|
|
36
|
+
expect(database.itemManager.entities.has(result.objectsUpdated[0].id));
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
test('mutate document', async () => {
|
|
@@ -46,7 +46,7 @@ describe('database', () => {
|
|
|
46
46
|
);
|
|
47
47
|
expect(database.itemManager.getItem(id)!.state.data.test).toEqual(42);
|
|
48
48
|
|
|
49
|
-
await
|
|
49
|
+
await result.batch.waitToBeProcessed();
|
|
50
50
|
expect(database.itemManager.getItem(id)!.state.data.test).toEqual(42);
|
|
51
51
|
});
|
|
52
52
|
});
|