@dxos/echo-db 2.33.8 → 2.33.9-dev.65528f0b
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/src/api/result-set.js +4 -4
- package/dist/src/api/result-set.js.map +1 -1
- package/dist/src/echo.js +2 -2
- package/dist/src/echo.js.map +1 -1
- package/dist/src/echo.test.js +2 -2
- package/dist/src/echo.test.js.map +1 -1
- package/dist/src/halo/halo-factory.d.ts +1 -1
- package/dist/src/halo/halo-factory.d.ts.map +1 -1
- package/dist/src/halo/halo-factory.js +15 -14
- package/dist/src/halo/halo-factory.js.map +1 -1
- package/dist/src/halo/halo-party.d.ts +4 -6
- package/dist/src/halo/halo-party.d.ts.map +1 -1
- package/dist/src/halo/halo-party.js +12 -6
- package/dist/src/halo/halo-party.js.map +1 -1
- package/dist/src/halo/halo.js +9 -9
- package/dist/src/halo/halo.js.map +1 -1
- package/dist/src/halo/identity-manager.d.ts.map +1 -1
- package/dist/src/halo/identity-manager.js +13 -7
- package/dist/src/halo/identity-manager.js.map +1 -1
- package/dist/src/halo/identity.js +2 -2
- package/dist/src/halo/identity.js.map +1 -1
- package/dist/src/halo/party-opener.d.ts.map +1 -1
- package/dist/src/halo/party-opener.js +2 -4
- package/dist/src/halo/party-opener.js.map +1 -1
- package/dist/src/halo/preferences.d.ts.map +1 -1
- package/dist/src/halo/preferences.js +9 -12
- package/dist/src/halo/preferences.js.map +1 -1
- package/dist/src/invitations/greeting-initiator.d.ts +5 -4
- package/dist/src/invitations/greeting-initiator.d.ts.map +1 -1
- package/dist/src/invitations/greeting-initiator.js +7 -7
- package/dist/src/invitations/greeting-initiator.js.map +1 -1
- package/dist/src/invitations/greeting-responder.d.ts +4 -7
- package/dist/src/invitations/greeting-responder.d.ts.map +1 -1
- package/dist/src/invitations/greeting-responder.js +9 -23
- package/dist/src/invitations/greeting-responder.js.map +1 -1
- package/dist/src/invitations/halo-recovery-initiator.js +6 -6
- package/dist/src/invitations/halo-recovery-initiator.js.map +1 -1
- package/dist/src/invitations/invitation-descriptor.js +9 -9
- package/dist/src/invitations/invitation-descriptor.js.map +1 -1
- package/dist/src/invitations/invitation-factory.d.ts +2 -1
- package/dist/src/invitations/invitation-factory.d.ts.map +1 -1
- package/dist/src/invitations/invitation-factory.js +6 -8
- package/dist/src/invitations/invitation-factory.js.map +1 -1
- package/dist/src/invitations/offline-invitation-claimer.js +7 -7
- package/dist/src/invitations/offline-invitation-claimer.js.map +1 -1
- package/dist/src/packlets/database/data-mirror.js +8 -8
- package/dist/src/packlets/database/data-mirror.js.map +1 -1
- package/dist/src/packlets/database/data-mirror.test.js +1 -1
- package/dist/src/packlets/database/data-mirror.test.js.map +1 -1
- package/dist/src/packlets/database/data-service-host.js +3 -3
- package/dist/src/packlets/database/data-service-host.js.map +1 -1
- package/dist/src/packlets/database/data-service-router.js +5 -5
- package/dist/src/packlets/database/data-service-router.js.map +1 -1
- package/dist/src/packlets/database/database-backend.js +3 -3
- package/dist/src/packlets/database/database-backend.js.map +1 -1
- package/dist/src/packlets/database/database.js +2 -2
- package/dist/src/packlets/database/database.js.map +1 -1
- package/dist/src/packlets/database/item-demuxer.js +14 -14
- package/dist/src/packlets/database/item-demuxer.js.map +1 -1
- package/dist/src/packlets/database/item-demuxer.test.js +1 -1
- package/dist/src/packlets/database/item-demuxer.test.js.map +1 -1
- package/dist/src/packlets/database/item-manager.js +18 -18
- package/dist/src/packlets/database/item-manager.js.map +1 -1
- package/dist/src/packlets/database/link.js +3 -3
- package/dist/src/packlets/database/link.js.map +1 -1
- package/dist/src/packlets/database/selection/result.js +2 -2
- package/dist/src/packlets/database/selection/result.js.map +1 -1
- package/dist/src/packlets/database/testing.js +1 -1
- package/dist/src/packlets/database/testing.js.map +1 -1
- package/dist/src/packlets/database/timeframe-clock.d.ts +2 -1
- package/dist/src/packlets/database/timeframe-clock.d.ts.map +1 -1
- package/dist/src/packlets/database/timeframe-clock.js +15 -5
- package/dist/src/packlets/database/timeframe-clock.js.map +1 -1
- package/dist/src/parties/data-party.d.ts +4 -3
- package/dist/src/parties/data-party.d.ts.map +1 -1
- package/dist/src/parties/data-party.js +18 -14
- package/dist/src/parties/data-party.js.map +1 -1
- package/dist/src/parties/data-party.test.js +12 -12
- package/dist/src/parties/data-party.test.js.map +1 -1
- package/dist/src/parties/party-factory.d.ts +2 -4
- package/dist/src/parties/party-factory.d.ts.map +1 -1
- package/dist/src/parties/party-factory.js +15 -12
- package/dist/src/parties/party-factory.js.map +1 -1
- package/dist/src/parties/party-manager.d.ts +1 -1
- package/dist/src/parties/party-manager.d.ts.map +1 -1
- package/dist/src/parties/party-manager.js +19 -19
- package/dist/src/parties/party-manager.js.map +1 -1
- package/dist/src/parties/party-manager.test.js +15 -12
- package/dist/src/parties/party-manager.test.js.map +1 -1
- package/dist/src/parties/party-preferences.js +2 -2
- package/dist/src/parties/party-preferences.js.map +1 -1
- package/dist/src/pipeline/feed-muxer.js +4 -4
- package/dist/src/pipeline/feed-muxer.js.map +1 -1
- package/dist/src/pipeline/feed-muxer.test.js +2 -2
- package/dist/src/pipeline/feed-muxer.test.js.map +1 -1
- package/dist/src/pipeline/message-selector.d.ts +1 -2
- package/dist/src/pipeline/message-selector.d.ts.map +1 -1
- package/dist/src/pipeline/message-selector.js +6 -33
- package/dist/src/pipeline/message-selector.js.map +1 -1
- package/dist/src/pipeline/metadata-store.d.ts +7 -2
- package/dist/src/pipeline/metadata-store.d.ts.map +1 -1
- package/dist/src/pipeline/metadata-store.js +12 -3
- package/dist/src/pipeline/metadata-store.js.map +1 -1
- package/dist/src/pipeline/party-feed-provider.d.ts +2 -2
- package/dist/src/pipeline/party-feed-provider.d.ts.map +1 -1
- package/dist/src/pipeline/party-feed-provider.js +5 -4
- package/dist/src/pipeline/party-feed-provider.js.map +1 -1
- package/dist/src/pipeline/party-pipeline.d.ts +5 -5
- package/dist/src/pipeline/party-pipeline.d.ts.map +1 -1
- package/dist/src/pipeline/party-pipeline.js +19 -20
- package/dist/src/pipeline/party-pipeline.js.map +1 -1
- package/dist/src/pipeline/party-pipeline.test.js +13 -18
- package/dist/src/pipeline/party-pipeline.test.js.map +1 -1
- package/dist/src/pipeline/party-processor.js +3 -3
- package/dist/src/pipeline/party-processor.js.map +1 -1
- package/dist/src/snapshots/snapshot-store.js +2 -2
- package/dist/src/snapshots/snapshot-store.js.map +1 -1
- package/dist/src/testing/testing-factories.js +2 -2
- package/dist/src/testing/testing-factories.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +21 -17
- package/src/api/result-set.ts +1 -1
- package/src/echo.test.ts +1 -1
- package/src/echo.ts +1 -1
- package/src/halo/halo-factory.ts +7 -7
- package/src/halo/halo-party.ts +15 -7
- package/src/halo/halo.ts +1 -1
- package/src/halo/identity-manager.ts +12 -3
- package/src/halo/identity.ts +1 -1
- package/src/halo/party-opener.ts +2 -4
- package/src/halo/preferences.ts +5 -9
- package/src/invitations/greeting-initiator.ts +9 -3
- package/src/invitations/greeting-responder.ts +8 -27
- package/src/invitations/halo-recovery-initiator.ts +1 -1
- package/src/invitations/invitation-descriptor.ts +1 -1
- package/src/invitations/invitation-factory.ts +3 -3
- package/src/invitations/offline-invitation-claimer.ts +1 -1
- package/src/packlets/database/data-mirror.test.ts +2 -2
- package/src/packlets/database/data-mirror.ts +1 -1
- package/src/packlets/database/data-service-host.ts +1 -1
- package/src/packlets/database/data-service-router.ts +1 -1
- package/src/packlets/database/database-backend.ts +1 -1
- package/src/packlets/database/database.ts +1 -1
- package/src/packlets/database/item-demuxer.test.ts +2 -2
- package/src/packlets/database/item-demuxer.ts +1 -1
- package/src/packlets/database/item-manager.ts +1 -1
- package/src/packlets/database/link.ts +1 -1
- package/src/packlets/database/selection/result.ts +1 -1
- package/src/packlets/database/testing.ts +2 -2
- package/src/packlets/database/timeframe-clock.ts +4 -1
- package/src/parties/data-party.test.ts +12 -12
- package/src/parties/data-party.ts +15 -7
- package/src/parties/party-factory.ts +18 -10
- package/src/parties/party-manager.test.ts +10 -7
- package/src/parties/party-manager.ts +15 -13
- package/src/parties/party-preferences.ts +1 -1
- package/src/pipeline/feed-muxer.test.ts +2 -2
- package/src/pipeline/feed-muxer.ts +3 -3
- package/src/pipeline/message-selector.ts +5 -36
- package/src/pipeline/metadata-store.ts +16 -3
- package/src/pipeline/party-feed-provider.ts +3 -3
- package/src/pipeline/party-pipeline.test.ts +13 -19
- package/src/pipeline/party-pipeline.ts +14 -13
- package/src/pipeline/party-processor.ts +1 -1
- package/src/snapshots/snapshot-store.ts +1 -1
- package/src/testing/testing-factories.ts +1 -1
|
@@ -5,16 +5,16 @@
|
|
|
5
5
|
import expect from 'expect';
|
|
6
6
|
import { it as test } from 'mocha';
|
|
7
7
|
|
|
8
|
-
import { promiseTimeout } from '@dxos/async';
|
|
8
|
+
import { promiseTimeout, sleep } from '@dxos/async';
|
|
9
9
|
import { createFeedAdmitMessage, createPartyGenesisMessage, Keyring, KeyType } from '@dxos/credentials';
|
|
10
10
|
import { createId } from '@dxos/crypto';
|
|
11
11
|
import { checkType } from '@dxos/debug';
|
|
12
|
-
import { codec, FeedMessage
|
|
12
|
+
import { codec, FeedMessage } from '@dxos/echo-protocol';
|
|
13
13
|
import { FeedStore } from '@dxos/feed-store';
|
|
14
14
|
import { createTestProtocolPair } from '@dxos/mesh-protocol';
|
|
15
15
|
import { ModelFactory } from '@dxos/model-factory';
|
|
16
16
|
import { ObjectModel } from '@dxos/object-model';
|
|
17
|
-
import { PublicKey } from '@dxos/protocols';
|
|
17
|
+
import { PublicKey, Timeframe } from '@dxos/protocols';
|
|
18
18
|
import { createStorage, StorageType } from '@dxos/random-access-multi-storage';
|
|
19
19
|
import { afterTest } from '@dxos/testutils';
|
|
20
20
|
|
|
@@ -49,7 +49,7 @@ describe('PartyPipeline', () => {
|
|
|
49
49
|
);
|
|
50
50
|
|
|
51
51
|
const feed = await partyFeedProvider.createOrOpenWritableFeed();
|
|
52
|
-
await party.open({
|
|
52
|
+
await party.open({ genesisFeedKey: feed.key });
|
|
53
53
|
afterTest(async () => party.close());
|
|
54
54
|
|
|
55
55
|
// PartyGenesis (self-signed by Party).
|
|
@@ -104,7 +104,7 @@ describe('PartyPipeline', () => {
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
await party.close();
|
|
107
|
-
await party.open({
|
|
107
|
+
await party.open({ genesisFeedKey: feedKey });
|
|
108
108
|
|
|
109
109
|
{
|
|
110
110
|
await party.database.select().exec().update.waitFor(result => result.entities.length === 2);
|
|
@@ -132,7 +132,7 @@ describe('PartyPipeline', () => {
|
|
|
132
132
|
expect(partyFeedProvider.getFeeds().find(k => k.key.equals(feedKey.publicKey))).toBeTruthy();
|
|
133
133
|
});
|
|
134
134
|
|
|
135
|
-
test('
|
|
135
|
+
test('does not open unrelated feeds', async () => {
|
|
136
136
|
const storage = createStorage('', StorageType.RAM);
|
|
137
137
|
const feedStore = new FeedStore(storage.directory('feed'), { valueEncoding: codec });
|
|
138
138
|
afterTest(async () => feedStore.close());
|
|
@@ -158,21 +158,19 @@ describe('PartyPipeline', () => {
|
|
|
158
158
|
PublicKey.random()
|
|
159
159
|
);
|
|
160
160
|
|
|
161
|
-
await partyFeedProvider.createOrOpenWritableFeed();
|
|
161
|
+
const writeFeed = await partyFeedProvider.createOrOpenWritableFeed();
|
|
162
162
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
await party.open({ feedHints: [otherFeedKey] });
|
|
163
|
+
await party.open({ genesisFeedKey: writeFeed.key });
|
|
166
164
|
afterTest(async () => party.close());
|
|
167
165
|
|
|
168
|
-
|
|
166
|
+
// Wait for events to be processed.
|
|
167
|
+
await sleep(5);
|
|
169
168
|
|
|
170
|
-
expect(partyFeedProvider.getFeeds().some(k => k.key.equals(otherFeedKey))).toEqual(
|
|
169
|
+
expect(partyFeedProvider.getFeeds().some(k => k.key.equals(otherFeedKey))).toEqual(false);
|
|
171
170
|
});
|
|
172
171
|
|
|
173
172
|
test('manually create item', async () => {
|
|
174
173
|
const { party, partyFeedProvider } = await setup();
|
|
175
|
-
await party.open();
|
|
176
174
|
|
|
177
175
|
const feed = await partyFeedProvider.createOrOpenWritableFeed();
|
|
178
176
|
|
|
@@ -193,7 +191,6 @@ describe('PartyPipeline', () => {
|
|
|
193
191
|
|
|
194
192
|
test('admit a second feed to the party', async () => {
|
|
195
193
|
const { party, keyring, partyKey, feedStore } = await setup();
|
|
196
|
-
await party.open();
|
|
197
194
|
|
|
198
195
|
const feedKey = await keyring.createKeyRecord({ type: KeyType.FEED });
|
|
199
196
|
const fullKey = keyring.getFullKey(feedKey.publicKey);
|
|
@@ -223,7 +220,6 @@ describe('PartyPipeline', () => {
|
|
|
223
220
|
|
|
224
221
|
test('admit feed and then open it', async () => {
|
|
225
222
|
const { party, keyring, partyKey, feedStore } = await setup();
|
|
226
|
-
await party.open();
|
|
227
223
|
|
|
228
224
|
const feedKey = await keyring.createKeyRecord({ type: KeyType.FEED });
|
|
229
225
|
const fullKey = keyring.getFullKey(feedKey.publicKey);
|
|
@@ -270,7 +266,7 @@ describe('PartyPipeline', () => {
|
|
|
270
266
|
expect(timeframe.isEmpty()).toBeFalsy();
|
|
271
267
|
|
|
272
268
|
await party.close();
|
|
273
|
-
await party.open({
|
|
269
|
+
await party.open({ genesisFeedKey: feedKey, targetTimeframe: timeframe });
|
|
274
270
|
});
|
|
275
271
|
|
|
276
272
|
test('two instances replicating', async () => {
|
|
@@ -304,9 +300,7 @@ describe('PartyPipeline', () => {
|
|
|
304
300
|
[peer1.partyKey]
|
|
305
301
|
));
|
|
306
302
|
|
|
307
|
-
await party2.open({
|
|
308
|
-
feedHints: [peer1.feedKey]
|
|
309
|
-
});
|
|
303
|
+
await party2.open({ genesisFeedKey: peer1.feedKey });
|
|
310
304
|
afterTest(async () => party2.close());
|
|
311
305
|
|
|
312
306
|
createTestProtocolPair(
|
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
// Copyright 2021 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import assert from 'assert';
|
|
5
|
+
import assert from 'node:assert';
|
|
6
6
|
|
|
7
7
|
import { synchronized } from '@dxos/async';
|
|
8
8
|
import { KeyType, Message as HaloMessage } from '@dxos/credentials';
|
|
9
9
|
import { timed } from '@dxos/debug';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
createFeedWriter, DatabaseSnapshot, FeedSelector, FeedWriter, PartyKey, PartySnapshot
|
|
12
|
+
} from '@dxos/echo-protocol';
|
|
11
13
|
import { ModelFactory } from '@dxos/model-factory';
|
|
12
|
-
import { PublicKey } from '@dxos/protocols';
|
|
14
|
+
import { PublicKey, Timeframe } from '@dxos/protocols';
|
|
13
15
|
import { SubscriptionGroup } from '@dxos/util';
|
|
14
16
|
|
|
15
17
|
import { createMessageSelector, PartyProcessor, PartyFeedProvider, FeedMuxer } from '.';
|
|
@@ -30,9 +32,9 @@ export interface PipelineOptions {
|
|
|
30
32
|
|
|
31
33
|
export interface OpenOptions {
|
|
32
34
|
/**
|
|
33
|
-
*
|
|
35
|
+
* Initial feed that contains PartyGenesis message and acts as the root for the feed DAG.
|
|
34
36
|
*/
|
|
35
|
-
|
|
37
|
+
genesisFeedKey: PublicKey
|
|
36
38
|
/**
|
|
37
39
|
* Timeframe to start processing feed messages from.
|
|
38
40
|
*/
|
|
@@ -123,9 +125,9 @@ export class PartyPipeline {
|
|
|
123
125
|
*/
|
|
124
126
|
@synchronized
|
|
125
127
|
@timed(1_000)
|
|
126
|
-
async open (options: OpenOptions
|
|
128
|
+
async open (options: OpenOptions) {
|
|
127
129
|
const {
|
|
128
|
-
|
|
130
|
+
genesisFeedKey,
|
|
129
131
|
initialTimeframe,
|
|
130
132
|
targetTimeframe
|
|
131
133
|
} = options;
|
|
@@ -147,17 +149,16 @@ export class PartyPipeline {
|
|
|
147
149
|
void this._feedProvider.createOrOpenReadOnlyFeed(feed);
|
|
148
150
|
}));
|
|
149
151
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
152
|
+
// TODO(dmaretskyi): We still need to hint at the genesis feed for some reason, not doing this breaks invitation tests.
|
|
153
|
+
await this._partyProcessor.takeHints([{ type: KeyType.FEED, publicKey: genesisFeedKey }]);
|
|
153
154
|
|
|
154
155
|
//
|
|
155
156
|
// Pipeline
|
|
156
157
|
//
|
|
157
158
|
|
|
158
159
|
const iterator = await this._feedProvider.createIterator(
|
|
159
|
-
createMessageSelector(this.
|
|
160
|
-
createFeedSelector(this._partyProcessor,
|
|
160
|
+
createMessageSelector(this._timeframeClock),
|
|
161
|
+
createFeedSelector(this._partyProcessor, genesisFeedKey),
|
|
161
162
|
initialTimeframe
|
|
162
163
|
);
|
|
163
164
|
|
|
@@ -256,4 +257,4 @@ export class PartyPipeline {
|
|
|
256
257
|
}
|
|
257
258
|
}
|
|
258
259
|
|
|
259
|
-
const createFeedSelector = (partyProcessor: PartyProcessor,
|
|
260
|
+
const createFeedSelector = (partyProcessor: PartyProcessor, genesisFeed: PublicKey): FeedSelector => feed => genesisFeed.equals(feed.key) || partyProcessor.isFeedAdmitted(feed.key);
|