@dxos/echo-db 2.33.7-dev.848c0285 → 2.33.7

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 (184) hide show
  1. package/dist/src/echo.d.ts +20 -17
  2. package/dist/src/echo.d.ts.map +1 -1
  3. package/dist/src/echo.js +33 -20
  4. package/dist/src/echo.js.map +1 -1
  5. package/dist/src/echo.test.js +9 -9
  6. package/dist/src/echo.test.js.map +1 -1
  7. package/dist/src/halo/contact-manager.d.ts.map +1 -1
  8. package/dist/src/halo/contact-manager.js +2 -2
  9. package/dist/src/halo/contact-manager.js.map +1 -1
  10. package/dist/src/halo/halo-factory.d.ts +1 -1
  11. package/dist/src/halo/halo-factory.d.ts.map +1 -1
  12. package/dist/src/halo/halo-factory.js +2 -1
  13. package/dist/src/halo/halo-factory.js.map +1 -1
  14. package/dist/src/halo/halo-party.d.ts +1 -1
  15. package/dist/src/halo/halo-party.d.ts.map +1 -1
  16. package/dist/src/halo/halo-party.js.map +1 -1
  17. package/dist/src/halo/halo.d.ts +1 -1
  18. package/dist/src/halo/halo.d.ts.map +1 -1
  19. package/dist/src/halo/halo.js +3 -2
  20. package/dist/src/halo/halo.js.map +1 -1
  21. package/dist/src/halo/halo.test.js +7 -6
  22. package/dist/src/halo/halo.test.js.map +1 -1
  23. package/dist/src/halo/preferences.d.ts +1 -1
  24. package/dist/src/halo/preferences.d.ts.map +1 -1
  25. package/dist/src/halo/preferences.js +3 -3
  26. package/dist/src/halo/preferences.js.map +1 -1
  27. package/dist/src/invitations/greeting-initiator.d.ts +1 -1
  28. package/dist/src/invitations/greeting-initiator.d.ts.map +1 -1
  29. package/dist/src/invitations/greeting-initiator.js +5 -4
  30. package/dist/src/invitations/greeting-initiator.js.map +1 -1
  31. package/dist/src/invitations/greeting-responder.d.ts.map +1 -1
  32. package/dist/src/invitations/greeting-responder.js +4 -3
  33. package/dist/src/invitations/greeting-responder.js.map +1 -1
  34. package/dist/src/invitations/halo-recovery-initiator.d.ts +1 -1
  35. package/dist/src/invitations/halo-recovery-initiator.d.ts.map +1 -1
  36. package/dist/src/invitations/halo-recovery-initiator.js +4 -3
  37. package/dist/src/invitations/halo-recovery-initiator.js.map +1 -1
  38. package/dist/src/invitations/invitation-descriptor.d.ts +1 -1
  39. package/dist/src/invitations/invitation-descriptor.d.ts.map +1 -1
  40. package/dist/src/invitations/invitation-descriptor.js +4 -3
  41. package/dist/src/invitations/invitation-descriptor.js.map +1 -1
  42. package/dist/src/invitations/invitation-factory.d.ts +1 -1
  43. package/dist/src/invitations/invitation-factory.d.ts.map +1 -1
  44. package/dist/src/invitations/offline-invitation-claimer.d.ts.map +1 -1
  45. package/dist/src/invitations/offline-invitation-claimer.js +4 -3
  46. package/dist/src/invitations/offline-invitation-claimer.js.map +1 -1
  47. package/dist/src/packlets/database/data-mirror.d.ts +1 -1
  48. package/dist/src/packlets/database/data-mirror.d.ts.map +1 -1
  49. package/dist/src/packlets/database/data-mirror.js.map +1 -1
  50. package/dist/src/packlets/database/data-mirror.test.js +5 -5
  51. package/dist/src/packlets/database/data-mirror.test.js.map +1 -1
  52. package/dist/src/packlets/database/data-service-host.d.ts.map +1 -1
  53. package/dist/src/packlets/database/data-service-host.js +3 -3
  54. package/dist/src/packlets/database/data-service-host.js.map +1 -1
  55. package/dist/src/packlets/database/database.d.ts +1 -1
  56. package/dist/src/packlets/database/database.d.ts.map +1 -1
  57. package/dist/src/packlets/database/database.js.map +1 -1
  58. package/dist/src/packlets/database/item-demuxer.test.js +7 -6
  59. package/dist/src/packlets/database/item-demuxer.test.js.map +1 -1
  60. package/dist/src/packlets/database/item-manager.d.ts +1 -1
  61. package/dist/src/packlets/database/item-manager.d.ts.map +1 -1
  62. package/dist/src/packlets/database/item-manager.js.map +1 -1
  63. package/dist/src/packlets/database/item-manager.test.js +11 -10
  64. package/dist/src/packlets/database/item-manager.test.js.map +1 -1
  65. package/dist/src/packlets/database/selection/selection.test.js +2 -2
  66. package/dist/src/packlets/database/selection/selection.test.js.map +1 -1
  67. package/dist/src/packlets/database/testing.d.ts.map +1 -1
  68. package/dist/src/packlets/database/testing.js +5 -5
  69. package/dist/src/packlets/database/testing.js.map +1 -1
  70. package/dist/src/packlets/errors/errors.d.ts +22 -0
  71. package/dist/src/packlets/errors/errors.d.ts.map +1 -0
  72. package/dist/src/packlets/errors/errors.js +44 -0
  73. package/dist/src/packlets/errors/errors.js.map +1 -0
  74. package/dist/src/packlets/errors/index.d.ts +1 -21
  75. package/dist/src/packlets/errors/index.d.ts.map +1 -1
  76. package/dist/src/packlets/errors/index.js +16 -39
  77. package/dist/src/packlets/errors/index.js.map +1 -1
  78. package/dist/src/parties/data-party.d.ts +1 -1
  79. package/dist/src/parties/data-party.d.ts.map +1 -1
  80. package/dist/src/parties/data-party.js.map +1 -1
  81. package/dist/src/parties/data-party.test.js.map +1 -1
  82. package/dist/src/parties/party-factory.d.ts +1 -1
  83. package/dist/src/parties/party-factory.d.ts.map +1 -1
  84. package/dist/src/parties/party-factory.js +2 -1
  85. package/dist/src/parties/party-factory.js.map +1 -1
  86. package/dist/src/parties/party-manager.d.ts +1 -1
  87. package/dist/src/parties/party-manager.d.ts.map +1 -1
  88. package/dist/src/parties/party-manager.js +2 -2
  89. package/dist/src/parties/party-manager.js.map +1 -1
  90. package/dist/src/parties/party-manager.test.js +10 -9
  91. package/dist/src/parties/party-manager.test.js.map +1 -1
  92. package/dist/src/pipeline/feed-muxer.d.ts.map +1 -1
  93. package/dist/src/pipeline/feed-muxer.js +3 -2
  94. package/dist/src/pipeline/feed-muxer.js.map +1 -1
  95. package/dist/src/pipeline/feed-muxer.test.js +5 -4
  96. package/dist/src/pipeline/feed-muxer.test.js.map +1 -1
  97. package/dist/src/pipeline/message-selector.d.ts.map +1 -1
  98. package/dist/src/pipeline/message-selector.js +3 -3
  99. package/dist/src/pipeline/message-selector.js.map +1 -1
  100. package/dist/src/pipeline/metadata-store.d.ts +1 -1
  101. package/dist/src/pipeline/metadata-store.d.ts.map +1 -1
  102. package/dist/src/pipeline/metadata-store.js +26 -0
  103. package/dist/src/pipeline/metadata-store.js.map +1 -1
  104. package/dist/src/pipeline/metadata-store.test.js +24 -10
  105. package/dist/src/pipeline/metadata-store.test.js.map +1 -1
  106. package/dist/src/pipeline/party-feed-provider.d.ts +1 -1
  107. package/dist/src/pipeline/party-feed-provider.d.ts.map +1 -1
  108. package/dist/src/pipeline/party-feed-provider.js.map +1 -1
  109. package/dist/src/pipeline/party-pipeline.d.ts +1 -1
  110. package/dist/src/pipeline/party-pipeline.d.ts.map +1 -1
  111. package/dist/src/pipeline/party-pipeline.js.map +1 -1
  112. package/dist/src/pipeline/party-pipeline.test.js +5 -4
  113. package/dist/src/pipeline/party-pipeline.test.js.map +1 -1
  114. package/dist/src/pipeline/party-processor.d.ts +1 -1
  115. package/dist/src/pipeline/party-processor.d.ts.map +1 -1
  116. package/dist/src/protocol/auth-plugin.d.ts +1 -1
  117. package/dist/src/protocol/auth-plugin.d.ts.map +1 -1
  118. package/dist/src/protocol/auth-plugin.js.map +1 -1
  119. package/dist/src/protocol/halo-recovery-plugin.d.ts +1 -1
  120. package/dist/src/protocol/halo-recovery-plugin.d.ts.map +1 -1
  121. package/dist/src/protocol/identity-credentials.d.ts.map +1 -1
  122. package/dist/src/protocol/identity-credentials.js +2 -1
  123. package/dist/src/protocol/identity-credentials.js.map +1 -1
  124. package/dist/src/protocol/offline-invitation-plugin.d.ts +1 -1
  125. package/dist/src/protocol/offline-invitation-plugin.d.ts.map +1 -1
  126. package/dist/src/protocol/party-protocol-factory.d.ts +1 -1
  127. package/dist/src/protocol/party-protocol-factory.d.ts.map +1 -1
  128. package/dist/src/protocol/party-protocol-factory.js.map +1 -1
  129. package/dist/src/snapshots/snapshot-generator.d.ts.map +1 -1
  130. package/dist/src/snapshots/snapshot-generator.js +2 -1
  131. package/dist/src/snapshots/snapshot-generator.js.map +1 -1
  132. package/dist/src/snapshots/snapshot-store.test.js +2 -1
  133. package/dist/src/snapshots/snapshot-store.test.js.map +1 -1
  134. package/dist/src/snapshots/snapshot.test.js +4 -4
  135. package/dist/src/snapshots/snapshot.test.js.map +1 -1
  136. package/dist/tsconfig.tsbuildinfo +1 -1
  137. package/package.json +21 -21
  138. package/src/echo.test.ts +10 -10
  139. package/src/echo.ts +41 -25
  140. package/src/halo/contact-manager.ts +1 -1
  141. package/src/halo/halo-factory.ts +2 -1
  142. package/src/halo/halo-party.ts +1 -1
  143. package/src/halo/halo.test.ts +7 -6
  144. package/src/halo/halo.ts +3 -2
  145. package/src/halo/preferences.ts +1 -1
  146. package/src/invitations/greeting-initiator.ts +2 -1
  147. package/src/invitations/greeting-responder.ts +2 -1
  148. package/src/invitations/halo-recovery-initiator.ts +2 -1
  149. package/src/invitations/invitation-descriptor.ts +2 -1
  150. package/src/invitations/invitation-factory.ts +1 -1
  151. package/src/invitations/offline-invitation-claimer.ts +2 -1
  152. package/src/packlets/database/data-mirror.test.ts +1 -1
  153. package/src/packlets/database/data-mirror.ts +1 -1
  154. package/src/packlets/database/data-service-host.ts +1 -1
  155. package/src/packlets/database/database.ts +1 -1
  156. package/src/packlets/database/item-demuxer.test.ts +2 -1
  157. package/src/packlets/database/item-manager.test.ts +2 -1
  158. package/src/packlets/database/item-manager.ts +2 -1
  159. package/src/packlets/database/selection/selection.test.ts +1 -1
  160. package/src/packlets/database/testing.ts +1 -1
  161. package/src/packlets/errors/errors.ts +43 -0
  162. package/src/packlets/errors/index.ts +2 -40
  163. package/src/parties/data-party.test.ts +1 -1
  164. package/src/parties/data-party.ts +2 -2
  165. package/src/parties/party-factory.ts +2 -1
  166. package/src/parties/party-manager.test.ts +9 -7
  167. package/src/parties/party-manager.ts +1 -1
  168. package/src/pipeline/feed-muxer.test.ts +2 -1
  169. package/src/pipeline/feed-muxer.ts +2 -1
  170. package/src/pipeline/message-selector.ts +1 -1
  171. package/src/pipeline/metadata-store.test.ts +18 -1
  172. package/src/pipeline/metadata-store.ts +19 -1
  173. package/src/pipeline/party-feed-provider.ts +1 -1
  174. package/src/pipeline/party-pipeline.test.ts +2 -1
  175. package/src/pipeline/party-pipeline.ts +1 -1
  176. package/src/pipeline/party-processor.ts +1 -1
  177. package/src/protocol/auth-plugin.ts +1 -1
  178. package/src/protocol/halo-recovery-plugin.ts +1 -1
  179. package/src/protocol/identity-credentials.ts +2 -1
  180. package/src/protocol/offline-invitation-plugin.ts +1 -1
  181. package/src/protocol/party-protocol-factory.ts +2 -1
  182. package/src/snapshots/snapshot-generator.ts +3 -1
  183. package/src/snapshots/snapshot-store.test.ts +2 -1
  184. package/src/snapshots/snapshot.test.ts +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/echo-db",
3
- "version": "2.33.7-dev.848c0285",
3
+ "version": "2.33.7",
4
4
  "description": "ECHO database.",
5
5
  "license": "MIT",
6
6
  "main": "dist/src/index.js",
@@ -10,22 +10,22 @@
10
10
  "src"
11
11
  ],
12
12
  "dependencies": {
13
- "@dxos/async": "2.33.7-dev.848c0285",
14
- "@dxos/codec-protobuf": "2.33.7-dev.848c0285",
15
- "@dxos/credentials": "2.33.7-dev.848c0285",
16
- "@dxos/crypto": "2.33.7-dev.848c0285",
17
- "@dxos/debug": "2.33.7-dev.848c0285",
18
- "@dxos/echo-protocol": "2.33.7-dev.848c0285",
19
- "@dxos/feed-store": "2.33.7-dev.848c0285",
20
- "@dxos/mesh-protocol": "2.33.7-dev.848c0285",
21
- "@dxos/model-factory": "2.33.7-dev.848c0285",
22
- "@dxos/network-manager": "2.33.7-dev.848c0285",
23
- "@dxos/object-model": "2.33.7-dev.848c0285",
24
- "@dxos/protocol-plugin-presence": "2.33.7-dev.848c0285",
25
- "@dxos/protocol-plugin-replicator": "2.33.7-dev.848c0285",
26
- "@dxos/protocols": "2.33.7-dev.848c0285",
27
- "@dxos/random-access-multi-storage": "2.33.7-dev.848c0285",
28
- "@dxos/util": "2.33.7-dev.848c0285",
13
+ "@dxos/async": "2.33.7",
14
+ "@dxos/codec-protobuf": "2.33.7",
15
+ "@dxos/credentials": "2.33.7",
16
+ "@dxos/crypto": "2.33.7",
17
+ "@dxos/debug": "2.33.7",
18
+ "@dxos/echo-protocol": "2.33.7",
19
+ "@dxos/feed-store": "2.33.7",
20
+ "@dxos/mesh-protocol": "2.33.7",
21
+ "@dxos/model-factory": "2.33.7",
22
+ "@dxos/network-manager": "2.33.7",
23
+ "@dxos/object-model": "2.33.7",
24
+ "@dxos/protocol-plugin-presence": "2.33.7",
25
+ "@dxos/protocol-plugin-replicator": "2.33.7",
26
+ "@dxos/protocols": "2.33.7",
27
+ "@dxos/random-access-multi-storage": "2.33.7",
28
+ "@dxos/util": "2.33.7",
29
29
  "base-x": "~3.0.9",
30
30
  "buffer-json-encoding": "^1.0.2",
31
31
  "debug": "^4.3.3",
@@ -35,10 +35,10 @@
35
35
  "pify": "~5.0.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@dxos/browser-mocha": "2.33.6",
39
- "@dxos/eslint-plugin": "~1.0.33",
40
- "@dxos/protocols-toolchain": "2.33.6",
41
- "@dxos/testutils": "2.33.6",
38
+ "@dxos/browser-mocha": "2.33.7",
39
+ "@dxos/eslint-plugin": "~1.0.34",
40
+ "@dxos/protocols-toolchain": "2.33.7",
41
+ "@dxos/testutils": "2.33.7",
42
42
  "@types/columnify": "^1.5.1",
43
43
  "@types/debug": "^4.1.7",
44
44
  "@types/faker": "^5.5.1",
package/src/echo.test.ts CHANGED
@@ -9,7 +9,7 @@ import { it as test } from 'mocha';
9
9
 
10
10
  import { latch, promiseTimeout, waitForCondition } from '@dxos/async';
11
11
  import { defaultSecretProvider, defaultSecretValidator } from '@dxos/credentials';
12
- import { generateSeedPhrase, keyPairFromSeedPhrase } from '@dxos/crypto';
12
+ import { generateSeedPhrase, humanize, keyPairFromSeedPhrase } from '@dxos/crypto';
13
13
  import { ObjectModel } from '@dxos/object-model';
14
14
  import { afterTest } from '@dxos/testutils';
15
15
 
@@ -43,7 +43,7 @@ describe('ECHO', () => {
43
43
  test('create party and update properties.', async () => {
44
44
  const echo = await setup({ createProfile: true });
45
45
  const parties = echo.queryParties({ open: true });
46
- log('Parties:', parties.value.map(party => party.key.humanize()));
46
+ log('Parties:', parties.value.map(party => humanize(party.key)));
47
47
  expect(parties.value).toHaveLength(0);
48
48
 
49
49
  const party = await echo.createParty();
@@ -55,12 +55,12 @@ describe('ECHO', () => {
55
55
  test('create party and items.', async () => {
56
56
  const echo = await setup({ createProfile: true });
57
57
  const parties = echo.queryParties({ open: true });
58
- log('Parties:', parties.value.map(party => party.key.humanize()));
58
+ log('Parties:', parties.value.map(party => humanize(party.key)));
59
59
  expect(parties.value).toHaveLength(0);
60
60
 
61
61
  const [updated, onUpdate] = latch();
62
62
  const unsubscribe = parties.subscribe(async parties => {
63
- log('Updated:', parties.map(party => party.key.humanize()));
63
+ log('Updated:', parties.map(party => humanize(party.key)));
64
64
 
65
65
  // TODO(burdon): Update currently called after all mutations below have completed?
66
66
  expect(parties).toHaveLength(1);
@@ -83,7 +83,7 @@ describe('ECHO', () => {
83
83
  const members = party.queryMembers().value;
84
84
  expect(members.length).toBe(1);
85
85
  // Within this test, we use the humanized key as the name.
86
- expect(members[0].displayName).toEqual(members[0].publicKey.humanize());
86
+ expect(members[0].displayName).toEqual(humanize(members[0].publicKey));
87
87
 
88
88
  // TODO(burdon): Test item mutations.
89
89
  await party.database.createItem({ model: ObjectModel, type: 'example:item/document' });
@@ -98,12 +98,12 @@ describe('ECHO', () => {
98
98
  const echo = await setup({ createProfile: true });
99
99
 
100
100
  const parties = echo.queryParties({ open: true });
101
- log('Parties:', parties.value.map(party => party.key.humanize()));
101
+ log('Parties:', parties.value.map(party => humanize(party.key)));
102
102
  expect(parties.value).toHaveLength(0);
103
103
 
104
104
  const [updated, onUpdate] = latch();
105
105
  const unsubscribe = parties.subscribe(async parties => {
106
- log('Updated:', parties.map(party => party.key.humanize()));
106
+ log('Updated:', parties.map(party => humanize(party.key)));
107
107
 
108
108
  expect(parties).toHaveLength(1);
109
109
  parties.map(async party => {
@@ -126,7 +126,7 @@ describe('ECHO', () => {
126
126
  const members = party.queryMembers().value;
127
127
  expect(members.length).toBe(1);
128
128
  // Within this test, we use the humanized key as the name.
129
- expect(members[0].displayName).toEqual(members[0].publicKey.humanize());
129
+ expect(members[0].displayName).toEqual(humanize(members[0].publicKey));
130
130
 
131
131
  const parent = await party.database.createItem({ model: ObjectModel, type: 'example:item/document' });
132
132
  await party.database.createItem({ model: ObjectModel, parent: parent.id });
@@ -139,7 +139,7 @@ describe('ECHO', () => {
139
139
  const echo = await setup({ createProfile: true });
140
140
 
141
141
  const parties = echo.queryParties({ open: true });
142
- log('Parties:', parties.value.map(party => party.key.humanize()));
142
+ log('Parties:', parties.value.map(party => humanize(party.key)));
143
143
  expect(parties.value).toHaveLength(0);
144
144
 
145
145
  const party = await echo.createParty();
@@ -148,7 +148,7 @@ describe('ECHO', () => {
148
148
  const members = party.queryMembers().value;
149
149
  expect(members.length).toBe(1);
150
150
  // Within this test, we use the humanized key as the name.
151
- expect(members[0].displayName).toEqual(members[0].publicKey.humanize());
151
+ expect(members[0].displayName).toEqual(humanize(members[0].publicKey));
152
152
 
153
153
  const parentA = await party.database.createItem({ model: ObjectModel, type: 'example:item/document' });
154
154
  const childA = await party.database.createItem({ model: ObjectModel, parent: parentA.id });
package/src/echo.ts CHANGED
@@ -8,13 +8,13 @@ import memdown from 'memdown';
8
8
 
9
9
  import { synchronized } from '@dxos/async';
10
10
  import { Keyring, KeyStore, SecretProvider } from '@dxos/credentials';
11
- import { PublicKey } from '@dxos/crypto';
12
11
  import { InvalidStateError, raise } from '@dxos/debug';
13
12
  import { codec, DataService, PartyKey, PartySnapshot } from '@dxos/echo-protocol';
14
13
  import { FeedStore } from '@dxos/feed-store';
15
14
  import { ModelFactory } from '@dxos/model-factory';
16
15
  import { NetworkManager, NetworkManagerOptions } from '@dxos/network-manager';
17
16
  import { ObjectModel } from '@dxos/object-model';
17
+ import { PublicKey } from '@dxos/protocols';
18
18
  import { Storage, createStorage, StorageType } from '@dxos/random-access-multi-storage';
19
19
  import { SubscriptionGroup } from '@dxos/util';
20
20
 
@@ -32,7 +32,10 @@ const log = debug('dxos:echo');
32
32
  const error = log.extend('error');
33
33
 
34
34
  // eslint-disable-next-line @typescript-eslint/no-empty-interface
35
- export interface PartyFilter { }
35
+ export interface PartyFilter {
36
+ open?: boolean
37
+ partyKeys?: PublicKey[]
38
+ }
36
39
 
37
40
  /**
38
41
  * Various options passed to `ECHO.create`.
@@ -262,17 +265,16 @@ export class ECHO {
262
265
  await this.halo.close();
263
266
 
264
267
  await this._partyManager.close();
265
-
266
268
  await this._feedStore.close();
267
269
 
268
270
  await this.networkManager.destroy();
269
271
  }
270
272
 
271
273
  /**
272
- * Removes all data and closes this ECHO instance.
273
- *
274
- * The instance will be in an unusable state at this point and a page refresh is recommended.
275
- */
274
+ * Removes all data and closes this ECHO instance.
275
+ *
276
+ * The instance will be in an unusable state at this point and a page refresh is recommended.
277
+ */
276
278
  // TODO(burdon): Enable re-open.
277
279
  async reset () {
278
280
  await this.close();
@@ -300,40 +302,37 @@ export class ECHO {
300
302
 
301
303
  const party = await this._partyManager.createParty();
302
304
  await party.open();
303
-
304
305
  return party;
305
306
  }
306
307
 
307
308
  /**
308
- * Clones an existing party from a snapshot.
309
- * @param snapshot
310
- */
309
+ * Clones an existing party from a snapshot.
310
+ * @param snapshot
311
+ */
311
312
  async cloneParty (snapshot: PartySnapshot) {
312
313
  await this.open();
313
314
 
314
315
  const party = await this._partyManager.cloneParty(snapshot);
315
316
  await party.open();
316
-
317
317
  return party;
318
318
  }
319
319
 
320
320
  /**
321
- * Returns an individual party by it's key.
322
- * @param {PartyKey} partyKey
323
- */
321
+ * Returns an individual party by it's key.
322
+ * @param {PartyKey} partyKey
323
+ */
324
324
  getParty (partyKey: PartyKey): DataParty | undefined {
325
325
  if (!this._partyManager.isOpen) {
326
326
  throw new InvalidStateError();
327
327
  }
328
328
 
329
- const party = this._partyManager.parties.find(party => party.key.equals(partyKey));
330
- return party;
329
+ return this._partyManager.parties.find(party => party.key.equals(partyKey));
331
330
  }
332
331
 
333
332
  /**
334
- * Queries for a set of Parties matching the optional filter.
335
- * @param {PartyFilter} filter
336
- */
333
+ * Queries for a set of Parties matching the optional filter.
334
+ * @param {PartyFilter} filter
335
+ */
337
336
  // eslint-disable-next-line unused-imports/no-unused-vars
338
337
  queryParties (filter?: PartyFilter): ResultSet<DataParty> {
339
338
  if (!this._partyManager.isOpen) {
@@ -342,15 +341,32 @@ export class ECHO {
342
341
 
343
342
  return new ResultSet(
344
343
  this._partyManager.update.discardParameter(),
345
- () => this._partyManager.parties
344
+ () => {
345
+ const parties = this._partyManager.parties;
346
+ if (filter) {
347
+ return parties.filter(party => {
348
+ if (filter.open !== undefined && Boolean(filter.open) !== Boolean(party.isOpen)) {
349
+ return false;
350
+ }
351
+
352
+ if (filter.partyKeys && !filter.partyKeys.some(partyKey => partyKey.equals(party.key))) {
353
+ return false;
354
+ }
355
+
356
+ return true;
357
+ });
358
+ }
359
+
360
+ return parties;
361
+ }
346
362
  );
347
363
  }
348
364
 
349
365
  /**
350
- * Joins a party that was created by another peer and starts replicating with it.
351
- * @param invitationDescriptor Invitation descriptor passed from another peer.
352
- * @param secretProvider Shared secret provider, the other peer creating the invitation must have the same secret.
353
- */
366
+ * Joins a party that was created by another peer and starts replicating with it.
367
+ * @param invitationDescriptor Invitation descriptor passed from another peer.
368
+ * @param secretProvider Shared secret provider, the other peer creating the invitation must have the same secret.
369
+ */
354
370
  async joinParty (invitationDescriptor: InvitationDescriptor, secretProvider?: SecretProvider): Promise<DataParty> {
355
371
  assert(this._partyManager.isOpen, new InvalidStateError());
356
372
 
@@ -3,9 +3,9 @@
3
3
  //
4
4
 
5
5
  import { Event } from '@dxos/async';
6
- import { PublicKey } from '@dxos/crypto';
7
6
  import { raise } from '@dxos/debug';
8
7
  import { ObjectModel } from '@dxos/object-model';
8
+ import { PublicKey } from '@dxos/protocols';
9
9
 
10
10
  import { ResultSet } from '../api';
11
11
  import { Database, Item } from '../packlets/database';
@@ -15,10 +15,11 @@ import {
15
15
  Filter,
16
16
  SecretProvider
17
17
  } from '@dxos/credentials';
18
- import { keyToString, PublicKey, keyPairFromSeedPhrase } from '@dxos/crypto';
18
+ import { keyToString, keyPairFromSeedPhrase } from '@dxos/crypto';
19
19
  import { ModelFactory } from '@dxos/model-factory';
20
20
  import { NetworkManager } from '@dxos/network-manager';
21
21
  import { ObjectModel } from '@dxos/object-model';
22
+ import { PublicKey } from '@dxos/protocols';
22
23
 
23
24
  import { createHaloPartyAdmissionMessage, GreetingInitiator, HaloRecoveryInitiator, InvitationDescriptor, InvitationDescriptorType, OfflineInvitationClaimer } from '../invitations';
24
25
  import { PARTY_ITEM_TYPE } from '../parties';
@@ -6,11 +6,11 @@ import assert from 'assert';
6
6
 
7
7
  import { Event, synchronized } from '@dxos/async';
8
8
  import { KeyHint } from '@dxos/credentials';
9
- import { PublicKey } from '@dxos/crypto';
10
9
  import { timed } from '@dxos/debug';
11
10
  import { Timeframe } from '@dxos/echo-protocol';
12
11
  import { ModelFactory } from '@dxos/model-factory';
13
12
  import { NetworkManager } from '@dxos/network-manager';
13
+ import { PublicKey } from '@dxos/protocols';
14
14
 
15
15
  import { InvitationAuthenticator, InvitationDescriptor, InvitationFactory, InvitationOptions } from '../invitations';
16
16
  import { PARTY_ITEM_TYPE } from '../parties';
@@ -6,12 +6,13 @@ import expect from 'expect';
6
6
  import { it as test } from 'mocha';
7
7
 
8
8
  import { defaultSecretProvider, Keyring } from '@dxos/credentials';
9
- import { generateSeedPhrase, keyPairFromSeedPhrase, PublicKey } from '@dxos/crypto';
9
+ import { generateSeedPhrase, keyPairFromSeedPhrase } from '@dxos/crypto';
10
10
  import { codec } from '@dxos/echo-protocol';
11
11
  import { FeedStore } from '@dxos/feed-store';
12
12
  import { ModelFactory } from '@dxos/model-factory';
13
13
  import { NetworkManager } from '@dxos/network-manager';
14
14
  import { ObjectModel } from '@dxos/object-model';
15
+ import { PublicKey } from '@dxos/protocols';
15
16
  import { createStorage, StorageType } from '@dxos/random-access-multi-storage';
16
17
  import { afterTest, testTimeout } from '@dxos/testutils';
17
18
 
@@ -40,12 +41,12 @@ describe('HALO', () => {
40
41
  );
41
42
 
42
43
  return new HALO({
43
- keyring: keyring,
44
- networkManager: networkManager,
45
- metadataStore: metadataStore,
44
+ keyring,
45
+ networkManager,
46
+ metadataStore,
46
47
  feedProviderFactory,
47
- modelFactory: modelFactory,
48
- snapshotStore: snapshotStore,
48
+ modelFactory,
49
+ snapshotStore,
49
50
  options: {}
50
51
  });
51
52
  };
package/src/halo/halo.ts CHANGED
@@ -7,10 +7,11 @@ import debug from 'debug';
7
7
 
8
8
  import { synchronized } from '@dxos/async';
9
9
  import { KeyRecord, Keyring, KeyType, SecretProvider } from '@dxos/credentials';
10
- import { createKeyPair, KeyPair, PublicKey } from '@dxos/crypto';
10
+ import { createKeyPair, humanize, KeyPair } from '@dxos/crypto';
11
11
  import { raise } from '@dxos/debug';
12
12
  import { ModelFactory } from '@dxos/model-factory';
13
13
  import { NetworkManager } from '@dxos/network-manager';
14
+ import { PublicKey } from '@dxos/protocols';
14
15
 
15
16
  import { ResultSet } from '../api';
16
17
  import { InvitationAuthenticator, InvitationDescriptor, InvitationOptions } from '../invitations';
@@ -194,7 +195,7 @@ export class HALO {
194
195
 
195
196
  const identityKey = this._identityManager.getIdentityKey() ?? raise(new Error('Cannot create HALO. Identity key not found.'));
196
197
  await this._identityManager.createHalo({
197
- identityDisplayName: displayName || identityKey.publicKey.humanize()
198
+ identityDisplayName: displayName || humanize(identityKey.publicKey)
198
199
  });
199
200
  }
200
201
 
@@ -8,9 +8,9 @@ import defaultsDeep from 'lodash.defaultsdeep';
8
8
 
9
9
  import { Event } from '@dxos/async';
10
10
  import { KeyHint } from '@dxos/credentials';
11
- import { PublicKey } from '@dxos/crypto';
12
11
  import { raise } from '@dxos/debug';
13
12
  import { ObjectModel } from '@dxos/object-model';
13
+ import { PublicKey } from '@dxos/protocols';
14
14
 
15
15
  import { ResultSet } from '../api';
16
16
  import { Database, Item } from '../packlets/database';
@@ -23,8 +23,9 @@ import {
23
23
  SignedMessage,
24
24
  NotarizeResponse
25
25
  } from '@dxos/credentials';
26
- import { keyToString, PublicKey } from '@dxos/crypto';
26
+ import { keyToString } from '@dxos/crypto';
27
27
  import { FullyConnectedTopology, NetworkManager } from '@dxos/network-manager';
28
+ import { PublicKey } from '@dxos/protocols';
28
29
 
29
30
  import { CredentialsSigner } from '../protocol/credentials-signer';
30
31
  import { greetingProtocolProvider } from './greeting-protocol-provider';
@@ -16,9 +16,10 @@ import {
16
16
  SecretValidator
17
17
  , Message as HaloMessage
18
18
  } from '@dxos/credentials';
19
- import { keyToString, randomBytes, PublicKey } from '@dxos/crypto';
19
+ import { keyToString, randomBytes } from '@dxos/crypto';
20
20
  import { FeedWriter, SwarmKey } from '@dxos/echo-protocol';
21
21
  import { FullyConnectedTopology, NetworkManager } from '@dxos/network-manager';
22
+ import { PublicKey } from '@dxos/protocols';
22
23
 
23
24
  import { PartyStateProvider } from '../pipeline';
24
25
  import { CredentialsSigner } from '../protocol/credentials-signer';
@@ -19,8 +19,9 @@ import {
19
19
  SignedMessage,
20
20
  codec
21
21
  } from '@dxos/credentials';
22
- import { keyToBuffer, keyToString, PublicKey, randomBytes, verify } from '@dxos/crypto';
22
+ import { keyToBuffer, keyToString, randomBytes, verify } from '@dxos/crypto';
23
23
  import { FullyConnectedTopology, NetworkManager } from '@dxos/network-manager';
24
+ import { PublicKey } from '@dxos/protocols';
24
25
 
25
26
  import { InvalidInvitationError } from '../packlets/errors';
26
27
  import { CredentialsSigner } from '../protocol';
@@ -6,9 +6,10 @@ import assert from 'assert';
6
6
  import base from 'base-x';
7
7
  import stableStringify from 'json-stable-stringify';
8
8
 
9
- import { keyToBuffer, keyToString, ripemd160, PublicKey } from '@dxos/crypto';
9
+ import { keyToBuffer, keyToString, ripemd160 } from '@dxos/crypto';
10
10
  import { SwarmKey } from '@dxos/echo-protocol';
11
11
  import * as proto from '@dxos/echo-protocol';
12
+ import { PublicKey } from '@dxos/protocols';
12
13
 
13
14
  import { InvalidInvitationError } from '../packlets/errors';
14
15
 
@@ -5,9 +5,9 @@
5
5
  import assert from 'assert';
6
6
 
7
7
  import { createPartyInvitationMessage, Message as HaloMessage } from '@dxos/credentials';
8
- import { PublicKey } from '@dxos/crypto';
9
8
  import { FeedWriter } from '@dxos/echo-protocol';
10
9
  import { NetworkManager } from '@dxos/network-manager';
10
+ import { PublicKey } from '@dxos/protocols';
11
11
 
12
12
  import { PartyStateProvider } from '../pipeline';
13
13
  import { CredentialsSigner } from '../protocol/credentials-signer';
@@ -20,8 +20,9 @@ import {
20
20
  SignedMessage,
21
21
  codec
22
22
  } from '@dxos/credentials';
23
- import { keyToBuffer, keyToString, PublicKey, randomBytes } from '@dxos/crypto';
23
+ import { keyToBuffer, keyToString, randomBytes } from '@dxos/crypto';
24
24
  import { FullyConnectedTopology, NetworkManager } from '@dxos/network-manager';
25
+ import { PublicKey } from '@dxos/protocols';
25
26
 
26
27
  import { InvalidInvitationError } from '../packlets/errors';
27
28
  import { CredentialsSigner } from '../protocol';
@@ -6,10 +6,10 @@ import expect from 'expect';
6
6
  import { it as test } from 'mocha';
7
7
 
8
8
  import { promiseTimeout } from '@dxos/async';
9
- import { PublicKey } from '@dxos/crypto';
10
9
  import { EchoEnvelope, MockFeedWriter, Timeframe } from '@dxos/echo-protocol';
11
10
  import { ModelFactory } from '@dxos/model-factory';
12
11
  import { ObjectModel } from '@dxos/object-model';
12
+ import { PublicKey } from '@dxos/protocols';
13
13
 
14
14
  import { DataMirror } from './data-mirror';
15
15
  import { DataServiceHost } from './data-service-host';
@@ -5,10 +5,10 @@
5
5
  import assert from 'assert';
6
6
  import debug from 'debug';
7
7
 
8
- import { PublicKey } from '@dxos/crypto';
9
8
  import { failUndefined } from '@dxos/debug';
10
9
  import { DataService } from '@dxos/echo-protocol';
11
10
  import { Model } from '@dxos/model-factory';
11
+ import { PublicKey } from '@dxos/protocols';
12
12
 
13
13
  import { Entity } from './entity';
14
14
  import { ItemManager } from './item-manager';
@@ -6,7 +6,6 @@ import assert from 'assert';
6
6
  import debug from 'debug';
7
7
 
8
8
  import { Stream } from '@dxos/codec-protobuf';
9
- import { PublicKey } from '@dxos/crypto';
10
9
  import { failUndefined, raise } from '@dxos/debug';
11
10
  import {
12
11
  EchoEnvelope,
@@ -17,6 +16,7 @@ import {
17
16
  SubscribeEntityStreamRequest,
18
17
  SubscribeEntityStreamResponse
19
18
  } from '@dxos/echo-protocol';
19
+ import { PublicKey } from '@dxos/protocols';
20
20
 
21
21
  import { EntityNotFoundError } from '../errors';
22
22
  import { Item } from './item';
@@ -5,10 +5,10 @@
5
5
  import assert from 'assert';
6
6
 
7
7
  import { Event, synchronized } from '@dxos/async';
8
- import { PublicKey } from '@dxos/crypto';
9
8
  import { ItemID, ItemType } from '@dxos/echo-protocol';
10
9
  import { Model, ModelConstructor, ModelFactory, validateModelClass } from '@dxos/model-factory';
11
10
  import { ObjectModel } from '@dxos/object-model';
11
+ import { PublicKey } from '@dxos/protocols';
12
12
 
13
13
  import { DataServiceHost } from './data-service-host';
14
14
  import { DatabaseBackend } from './database-backend';
@@ -7,11 +7,12 @@ import expect from 'expect';
7
7
  import { it as test } from 'mocha';
8
8
 
9
9
  import { latch } from '@dxos/async';
10
- import { createId, PublicKey } from '@dxos/crypto';
10
+ import { createId } from '@dxos/crypto';
11
11
  import { checkType } from '@dxos/debug';
12
12
  import { EchoEnvelope, MockFeedWriter, Timeframe } from '@dxos/echo-protocol';
13
13
  import { ModelFactory, TestModel } from '@dxos/model-factory';
14
14
  import { ObjectModel } from '@dxos/object-model';
15
+ import { PublicKey } from '@dxos/protocols';
15
16
 
16
17
  import { Item } from './item';
17
18
  import { ItemDemuxer } from './item-demuxer';
@@ -5,10 +5,11 @@
5
5
  import expect from 'expect';
6
6
  import { it as test } from 'mocha';
7
7
 
8
- import { createId, PublicKey } from '@dxos/crypto';
8
+ import { createId } from '@dxos/crypto';
9
9
  import { MockFeedWriter } from '@dxos/echo-protocol';
10
10
  import { ModelFactory } from '@dxos/model-factory';
11
11
  import { ObjectModel } from '@dxos/object-model';
12
+ import { PublicKey } from '@dxos/protocols';
12
13
 
13
14
  import { ItemManager } from './item-manager';
14
15
 
@@ -6,10 +6,11 @@ import assert from 'assert';
6
6
  import debug from 'debug';
7
7
 
8
8
  import { Event, trigger } from '@dxos/async';
9
- import { createId, PublicKey } from '@dxos/crypto';
9
+ import { createId } from '@dxos/crypto';
10
10
  import { timed } from '@dxos/debug';
11
11
  import { EchoEnvelope, FeedWriter, ItemID, ItemType, mapFeedWriter, ModelSnapshot } from '@dxos/echo-protocol';
12
12
  import { Model, ModelFactory, ModelMessage, ModelType, StateManager } from '@dxos/model-factory';
13
+ import { PublicKey } from '@dxos/protocols';
13
14
 
14
15
  import { UnknownModelError } from '../errors';
15
16
  import { Entity } from './entity';
@@ -6,10 +6,10 @@ import expect from 'expect';
6
6
  import { it as test } from 'mocha';
7
7
 
8
8
  import { Event, promiseTimeout } from '@dxos/async';
9
- import { PublicKey } from '@dxos/crypto';
10
9
  import { ItemID, ItemType } from '@dxos/echo-protocol';
11
10
  import { ModelFactory } from '@dxos/model-factory';
12
11
  import { ObjectModel } from '@dxos/object-model';
12
+ import { PublicKey } from '@dxos/protocols';
13
13
 
14
14
  import { Entity } from '../entity';
15
15
  import { Item } from '../item';
@@ -2,9 +2,9 @@
2
2
  // Copyright 2021 DXOS.org
3
3
  //
4
4
 
5
- import { PublicKey } from '@dxos/crypto';
6
5
  import { EchoEnvelope, MockFeedWriter, Timeframe } from '@dxos/echo-protocol';
7
6
  import { ModelFactory } from '@dxos/model-factory';
7
+ import { PublicKey } from '@dxos/protocols';
8
8
 
9
9
  import { DataServiceHost } from './data-service-host';
10
10
  import { DataServiceRouter } from './data-service-router';
@@ -0,0 +1,43 @@
1
+ //
2
+ // Copyright 2021 DXOS.org
3
+ //
4
+
5
+ import { DXOSError } from '@dxos/debug';
6
+ import { ItemID } from '@dxos/echo-protocol';
7
+ import { PublicKey } from '@dxos/protocols';
8
+
9
+ export class PartyNotFoundError extends DXOSError {
10
+ constructor (partyKey: PublicKey) {
11
+ super('PARTY_NOT_FOUND', `Party with key not found: ${partyKey}`);
12
+ }
13
+ }
14
+
15
+ export class EntityNotFoundError extends DXOSError {
16
+ constructor (entityId: ItemID) {
17
+ super('ENTITY_NOT_FOUND', `Entitiy not found: ${entityId}`);
18
+ }
19
+ }
20
+
21
+ export class UnknownModelError extends DXOSError {
22
+ constructor (model: string) {
23
+ super('UNKNOWN_MODEL', `Unknown model ${model}.`);
24
+ }
25
+ }
26
+
27
+ export class IdentityNotInitializedError extends DXOSError {
28
+ constructor () {
29
+ super('IDENTITY_NOT_INITIALIZED', 'Identity not initialized.');
30
+ }
31
+ }
32
+
33
+ export class InvalidInvitationError extends DXOSError {
34
+ constructor () {
35
+ super('INVALID_INVITATION', 'Invitation is invalid.');
36
+ }
37
+ }
38
+
39
+ export class InvalidStorageVersionError extends DXOSError {
40
+ constructor (expected: number, actual: number) {
41
+ super('INVALID_STORAGE_VERSION', `Invalid storage version: Expected ${expected}, actual ${actual}.`);
42
+ }
43
+ }