@dxos/echo-db 2.33.8 → 2.33.9-dev.7c8c6a09

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.
Files changed (166) hide show
  1. package/dist/src/api/result-set.js +4 -4
  2. package/dist/src/api/result-set.js.map +1 -1
  3. package/dist/src/echo.js +2 -2
  4. package/dist/src/echo.js.map +1 -1
  5. package/dist/src/echo.test.js +2 -2
  6. package/dist/src/echo.test.js.map +1 -1
  7. package/dist/src/halo/halo-factory.d.ts +1 -1
  8. package/dist/src/halo/halo-factory.d.ts.map +1 -1
  9. package/dist/src/halo/halo-factory.js +15 -14
  10. package/dist/src/halo/halo-factory.js.map +1 -1
  11. package/dist/src/halo/halo-party.d.ts +4 -6
  12. package/dist/src/halo/halo-party.d.ts.map +1 -1
  13. package/dist/src/halo/halo-party.js +12 -6
  14. package/dist/src/halo/halo-party.js.map +1 -1
  15. package/dist/src/halo/halo.js +9 -9
  16. package/dist/src/halo/halo.js.map +1 -1
  17. package/dist/src/halo/identity-manager.d.ts.map +1 -1
  18. package/dist/src/halo/identity-manager.js +13 -7
  19. package/dist/src/halo/identity-manager.js.map +1 -1
  20. package/dist/src/halo/identity.js +2 -2
  21. package/dist/src/halo/identity.js.map +1 -1
  22. package/dist/src/halo/party-opener.d.ts.map +1 -1
  23. package/dist/src/halo/party-opener.js +2 -4
  24. package/dist/src/halo/party-opener.js.map +1 -1
  25. package/dist/src/halo/preferences.d.ts.map +1 -1
  26. package/dist/src/halo/preferences.js +9 -12
  27. package/dist/src/halo/preferences.js.map +1 -1
  28. package/dist/src/invitations/greeting-initiator.d.ts +5 -4
  29. package/dist/src/invitations/greeting-initiator.d.ts.map +1 -1
  30. package/dist/src/invitations/greeting-initiator.js +7 -7
  31. package/dist/src/invitations/greeting-initiator.js.map +1 -1
  32. package/dist/src/invitations/greeting-responder.d.ts +4 -7
  33. package/dist/src/invitations/greeting-responder.d.ts.map +1 -1
  34. package/dist/src/invitations/greeting-responder.js +9 -23
  35. package/dist/src/invitations/greeting-responder.js.map +1 -1
  36. package/dist/src/invitations/halo-recovery-initiator.js +6 -6
  37. package/dist/src/invitations/halo-recovery-initiator.js.map +1 -1
  38. package/dist/src/invitations/invitation-descriptor.js +9 -9
  39. package/dist/src/invitations/invitation-descriptor.js.map +1 -1
  40. package/dist/src/invitations/invitation-factory.d.ts +2 -1
  41. package/dist/src/invitations/invitation-factory.d.ts.map +1 -1
  42. package/dist/src/invitations/invitation-factory.js +6 -8
  43. package/dist/src/invitations/invitation-factory.js.map +1 -1
  44. package/dist/src/invitations/offline-invitation-claimer.js +7 -7
  45. package/dist/src/invitations/offline-invitation-claimer.js.map +1 -1
  46. package/dist/src/packlets/database/data-mirror.js +8 -8
  47. package/dist/src/packlets/database/data-mirror.js.map +1 -1
  48. package/dist/src/packlets/database/data-mirror.test.js +1 -1
  49. package/dist/src/packlets/database/data-mirror.test.js.map +1 -1
  50. package/dist/src/packlets/database/data-service-host.js +3 -3
  51. package/dist/src/packlets/database/data-service-host.js.map +1 -1
  52. package/dist/src/packlets/database/data-service-router.js +5 -5
  53. package/dist/src/packlets/database/data-service-router.js.map +1 -1
  54. package/dist/src/packlets/database/database-backend.js +3 -3
  55. package/dist/src/packlets/database/database-backend.js.map +1 -1
  56. package/dist/src/packlets/database/database.js +2 -2
  57. package/dist/src/packlets/database/database.js.map +1 -1
  58. package/dist/src/packlets/database/item-demuxer.js +14 -14
  59. package/dist/src/packlets/database/item-demuxer.js.map +1 -1
  60. package/dist/src/packlets/database/item-demuxer.test.js +1 -1
  61. package/dist/src/packlets/database/item-demuxer.test.js.map +1 -1
  62. package/dist/src/packlets/database/item-manager.js +18 -18
  63. package/dist/src/packlets/database/item-manager.js.map +1 -1
  64. package/dist/src/packlets/database/link.js +3 -3
  65. package/dist/src/packlets/database/link.js.map +1 -1
  66. package/dist/src/packlets/database/selection/result.js +2 -2
  67. package/dist/src/packlets/database/selection/result.js.map +1 -1
  68. package/dist/src/packlets/database/testing.js +1 -1
  69. package/dist/src/packlets/database/testing.js.map +1 -1
  70. package/dist/src/packlets/database/timeframe-clock.d.ts +2 -1
  71. package/dist/src/packlets/database/timeframe-clock.d.ts.map +1 -1
  72. package/dist/src/packlets/database/timeframe-clock.js +15 -5
  73. package/dist/src/packlets/database/timeframe-clock.js.map +1 -1
  74. package/dist/src/parties/data-party.d.ts +4 -3
  75. package/dist/src/parties/data-party.d.ts.map +1 -1
  76. package/dist/src/parties/data-party.js +18 -14
  77. package/dist/src/parties/data-party.js.map +1 -1
  78. package/dist/src/parties/data-party.test.js +12 -12
  79. package/dist/src/parties/data-party.test.js.map +1 -1
  80. package/dist/src/parties/party-factory.d.ts +2 -4
  81. package/dist/src/parties/party-factory.d.ts.map +1 -1
  82. package/dist/src/parties/party-factory.js +15 -12
  83. package/dist/src/parties/party-factory.js.map +1 -1
  84. package/dist/src/parties/party-manager.d.ts +1 -1
  85. package/dist/src/parties/party-manager.d.ts.map +1 -1
  86. package/dist/src/parties/party-manager.js +19 -19
  87. package/dist/src/parties/party-manager.js.map +1 -1
  88. package/dist/src/parties/party-manager.test.js +15 -12
  89. package/dist/src/parties/party-manager.test.js.map +1 -1
  90. package/dist/src/parties/party-preferences.js +2 -2
  91. package/dist/src/parties/party-preferences.js.map +1 -1
  92. package/dist/src/pipeline/feed-muxer.js +4 -4
  93. package/dist/src/pipeline/feed-muxer.js.map +1 -1
  94. package/dist/src/pipeline/feed-muxer.test.js +2 -2
  95. package/dist/src/pipeline/feed-muxer.test.js.map +1 -1
  96. package/dist/src/pipeline/message-selector.d.ts +1 -2
  97. package/dist/src/pipeline/message-selector.d.ts.map +1 -1
  98. package/dist/src/pipeline/message-selector.js +6 -33
  99. package/dist/src/pipeline/message-selector.js.map +1 -1
  100. package/dist/src/pipeline/metadata-store.d.ts +7 -2
  101. package/dist/src/pipeline/metadata-store.d.ts.map +1 -1
  102. package/dist/src/pipeline/metadata-store.js +12 -3
  103. package/dist/src/pipeline/metadata-store.js.map +1 -1
  104. package/dist/src/pipeline/party-feed-provider.d.ts +2 -2
  105. package/dist/src/pipeline/party-feed-provider.d.ts.map +1 -1
  106. package/dist/src/pipeline/party-feed-provider.js +5 -4
  107. package/dist/src/pipeline/party-feed-provider.js.map +1 -1
  108. package/dist/src/pipeline/party-pipeline.d.ts +5 -5
  109. package/dist/src/pipeline/party-pipeline.d.ts.map +1 -1
  110. package/dist/src/pipeline/party-pipeline.js +19 -20
  111. package/dist/src/pipeline/party-pipeline.js.map +1 -1
  112. package/dist/src/pipeline/party-pipeline.test.js +13 -18
  113. package/dist/src/pipeline/party-pipeline.test.js.map +1 -1
  114. package/dist/src/pipeline/party-processor.js +3 -3
  115. package/dist/src/pipeline/party-processor.js.map +1 -1
  116. package/dist/src/snapshots/snapshot-store.js +2 -2
  117. package/dist/src/snapshots/snapshot-store.js.map +1 -1
  118. package/dist/src/testing/testing-factories.js +2 -2
  119. package/dist/src/testing/testing-factories.js.map +1 -1
  120. package/dist/tsconfig.tsbuildinfo +1 -1
  121. package/package.json +21 -17
  122. package/src/api/result-set.ts +1 -1
  123. package/src/echo.test.ts +1 -1
  124. package/src/echo.ts +1 -1
  125. package/src/halo/halo-factory.ts +7 -7
  126. package/src/halo/halo-party.ts +15 -7
  127. package/src/halo/halo.ts +1 -1
  128. package/src/halo/identity-manager.ts +12 -3
  129. package/src/halo/identity.ts +1 -1
  130. package/src/halo/party-opener.ts +2 -4
  131. package/src/halo/preferences.ts +5 -9
  132. package/src/invitations/greeting-initiator.ts +9 -3
  133. package/src/invitations/greeting-responder.ts +8 -27
  134. package/src/invitations/halo-recovery-initiator.ts +1 -1
  135. package/src/invitations/invitation-descriptor.ts +1 -1
  136. package/src/invitations/invitation-factory.ts +3 -3
  137. package/src/invitations/offline-invitation-claimer.ts +1 -1
  138. package/src/packlets/database/data-mirror.test.ts +2 -2
  139. package/src/packlets/database/data-mirror.ts +1 -1
  140. package/src/packlets/database/data-service-host.ts +1 -1
  141. package/src/packlets/database/data-service-router.ts +1 -1
  142. package/src/packlets/database/database-backend.ts +1 -1
  143. package/src/packlets/database/database.ts +1 -1
  144. package/src/packlets/database/item-demuxer.test.ts +2 -2
  145. package/src/packlets/database/item-demuxer.ts +1 -1
  146. package/src/packlets/database/item-manager.ts +1 -1
  147. package/src/packlets/database/link.ts +1 -1
  148. package/src/packlets/database/selection/result.ts +1 -1
  149. package/src/packlets/database/testing.ts +2 -2
  150. package/src/packlets/database/timeframe-clock.ts +4 -1
  151. package/src/parties/data-party.test.ts +12 -12
  152. package/src/parties/data-party.ts +15 -7
  153. package/src/parties/party-factory.ts +18 -10
  154. package/src/parties/party-manager.test.ts +10 -7
  155. package/src/parties/party-manager.ts +15 -13
  156. package/src/parties/party-preferences.ts +1 -1
  157. package/src/pipeline/feed-muxer.test.ts +2 -2
  158. package/src/pipeline/feed-muxer.ts +3 -3
  159. package/src/pipeline/message-selector.ts +5 -36
  160. package/src/pipeline/metadata-store.ts +16 -3
  161. package/src/pipeline/party-feed-provider.ts +3 -3
  162. package/src/pipeline/party-pipeline.test.ts +13 -19
  163. package/src/pipeline/party-pipeline.ts +14 -13
  164. package/src/pipeline/party-processor.ts +1 -1
  165. package/src/snapshots/snapshot-store.ts +1 -1
  166. 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, Timeframe } from '@dxos/echo-protocol';
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({ feedHints: [feed.key] });
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({ feedHints: [feedKey] });
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('opens feed from hints', async () => {
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
- const feedOpened = feedStore.feedOpenedEvent.waitForCount(1);
164
-
165
- await party.open({ feedHints: [otherFeedKey] });
163
+ await party.open({ genesisFeedKey: writeFeed.key });
166
164
  afterTest(async () => party.close());
167
165
 
168
- await feedOpened;
166
+ // Wait for events to be processed.
167
+ await sleep(5);
169
168
 
170
- expect(partyFeedProvider.getFeeds().some(k => k.key.equals(otherFeedKey))).toEqual(true);
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({ feedHints: [feedKey], targetTimeframe: timeframe });
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 { createFeedWriter, DatabaseSnapshot, FeedSelector, FeedWriter, PartyKey, PartySnapshot, Timeframe } from '@dxos/echo-protocol';
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
- * Keys of initial feeds needed to bootstrap the party.
35
+ * Initial feed that contains PartyGenesis message and acts as the root for the feed DAG.
34
36
  */
35
- feedHints?: PublicKey[]
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
- feedHints = [],
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
- if (feedHints.length > 0) {
151
- await this._partyProcessor.takeHints(feedHints.map(publicKey => ({ publicKey, type: KeyType.FEED })));
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._partyProcessor, this._timeframeClock),
160
- createFeedSelector(this._partyProcessor, feedHints),
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, hints: PublicKey[]): FeedSelector => feed => hints.some(hint => hint.equals(feed.key)) || partyProcessor.isFeedAdmitted(feed.key);
260
+ const createFeedSelector = (partyProcessor: PartyProcessor, genesisFeed: PublicKey): FeedSelector => feed => genesisFeed.equals(feed.key) || partyProcessor.isFeedAdmitted(feed.key);
@@ -2,8 +2,8 @@
2
2
  // Copyright 2020 DXOS.org
3
3
  //
4
4
 
5
- import assert from 'assert';
6
5
  import debug from 'debug';
6
+ import assert from 'node:assert';
7
7
 
8
8
  import { Event } from '@dxos/async';
9
9
  import {
@@ -2,8 +2,8 @@
2
2
  // Copyright 2020 DXOS.org
3
3
  //
4
4
 
5
- import assert from 'assert';
6
5
  import debug from 'debug';
6
+ import assert from 'node:assert';
7
7
 
8
8
  import { schema, PartyKey, PartySnapshot } from '@dxos/echo-protocol';
9
9
  import { PublicKey } from '@dxos/protocols';
@@ -2,7 +2,7 @@
2
2
  // Copyright 2020 DXOS.org
3
3
  //
4
4
 
5
- import assert from 'assert';
5
+ import assert from 'node:assert';
6
6
 
7
7
  import { Model } from '@dxos/model-factory';
8
8
  import { ObjectModel } from '@dxos/object-model';