@dxos/client 2.28.17-dev.f9da0804 → 2.28.18-dev.beef8fb1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/client",
3
- "version": "2.28.17-dev.f9da0804",
3
+ "version": "2.28.18-dev.beef8fb1",
4
4
  "license": "MIT",
5
5
  "author": "DXOS.org",
6
6
  "main": "dist/src/index.js",
@@ -10,21 +10,21 @@
10
10
  "src"
11
11
  ],
12
12
  "dependencies": {
13
- "@dxos/async": "2.28.17-dev.f9da0804",
14
- "@dxos/codec-protobuf": "2.28.17-dev.f9da0804",
15
- "@dxos/config": "2.28.17-dev.f9da0804",
16
- "@dxos/credentials": "2.28.17-dev.f9da0804",
17
- "@dxos/crypto": "2.28.17-dev.f9da0804",
18
- "@dxos/debug": "2.28.17-dev.f9da0804",
19
- "@dxos/echo-db": "2.28.17-dev.f9da0804",
20
- "@dxos/echo-protocol": "2.28.17-dev.f9da0804",
21
- "@dxos/feed-store": "2.28.17-dev.f9da0804",
22
- "@dxos/model-factory": "2.28.17-dev.f9da0804",
23
- "@dxos/network-manager": "2.28.17-dev.f9da0804",
24
- "@dxos/object-model": "2.28.17-dev.f9da0804",
25
- "@dxos/protocols": "2.28.17-dev.f9da0804",
26
- "@dxos/rpc": "2.28.17-dev.f9da0804",
27
- "@dxos/util": "2.28.17-dev.f9da0804",
13
+ "@dxos/async": "2.28.18-dev.beef8fb1",
14
+ "@dxos/codec-protobuf": "2.28.18-dev.beef8fb1",
15
+ "@dxos/config": "2.28.18-dev.beef8fb1",
16
+ "@dxos/credentials": "2.28.18-dev.beef8fb1",
17
+ "@dxos/crypto": "2.28.18-dev.beef8fb1",
18
+ "@dxos/debug": "2.28.18-dev.beef8fb1",
19
+ "@dxos/echo-db": "2.28.18-dev.beef8fb1",
20
+ "@dxos/echo-protocol": "2.28.18-dev.beef8fb1",
21
+ "@dxos/feed-store": "2.28.18-dev.beef8fb1",
22
+ "@dxos/model-factory": "2.28.18-dev.beef8fb1",
23
+ "@dxos/network-manager": "2.28.18-dev.beef8fb1",
24
+ "@dxos/object-model": "2.28.18-dev.beef8fb1",
25
+ "@dxos/protocols": "2.28.18-dev.beef8fb1",
26
+ "@dxos/rpc": "2.28.18-dev.beef8fb1",
27
+ "@dxos/util": "2.28.18-dev.beef8fb1",
28
28
  "@polkadot/keyring": "6.11.1",
29
29
  "@polkadot/util": "6.11.1",
30
30
  "@polkadot/util-crypto": "6.11.1",
@@ -42,9 +42,9 @@
42
42
  },
43
43
  "devDependencies": {
44
44
  "@dxos/eslint-plugin": "~1.0.27",
45
- "@dxos/protocols-toolchain": "2.28.16",
46
- "@dxos/random-access-multi-storage": "2.28.17-dev.f9da0804",
47
- "@dxos/testutils": "2.28.16",
45
+ "@dxos/protocols-toolchain": "2.28.17",
46
+ "@dxos/random-access-multi-storage": "2.28.18-dev.beef8fb1",
47
+ "@dxos/testutils": "2.28.17",
48
48
  "@types/debug": "^4.1.7",
49
49
  "@types/jest": "^26.0.7",
50
50
  "@types/level-js": "~4.0.1",
@@ -81,7 +81,7 @@ export class EchoProxy {
81
81
  await this._haloProxy.profileChanged.waitForCondition(() => !!this._haloProxy.profile);
82
82
 
83
83
  const partyProxy = new Party(this._serviceProvider, this._modelFactory, party, this._haloProxy.profile!.publicKey);
84
- await partyProxy.init();
84
+ await partyProxy.initialize();
85
85
  this._parties.set(partyProxy.key, partyProxy);
86
86
 
87
87
  // TODO(dmaretskyi): Replace with selection API when it has update filtering.
@@ -160,8 +160,10 @@ export class EchoProxy {
160
160
  partyReceived();
161
161
  }
162
162
  };
163
+
163
164
  this._partiesChanged.on(handler);
164
165
  handler();
166
+
165
167
  await partyReceivedPromise;
166
168
  this._partiesChanged.off(handler);
167
169
 
@@ -5,10 +5,11 @@
5
5
  import { PublicKey } from '@dxos/crypto';
6
6
  import { failUndefined } from '@dxos/debug';
7
7
  import {
8
- PARTY_ITEM_TYPE, PARTY_TITLE_PROPERTY, ActivationOptions, Database, RemoteDatabaseBackend
8
+ PARTY_ITEM_TYPE, PARTY_TITLE_PROPERTY, ActivationOptions, Database, Item, RemoteDatabaseBackend
9
9
  } from '@dxos/echo-db';
10
10
  import { PartyKey } from '@dxos/echo-protocol';
11
11
  import { ModelFactory } from '@dxos/model-factory';
12
+ import { ObjectModel, ObjectProperties } from '@dxos/object-model';
12
13
 
13
14
  import { ClientServiceHost } from '../client/service-host';
14
15
  import { ClientServiceProxy } from '../client/service-proxy';
@@ -32,6 +33,7 @@ export class Party {
32
33
  private _key: PartyKey;
33
34
  private _isOpen: boolean;
34
35
  private _isActive: boolean;
36
+ private _item?: Item<ObjectModel>;
35
37
 
36
38
  /**
37
39
  * @internal
@@ -67,30 +69,27 @@ export class Party {
67
69
  return this._invitationProxy;
68
70
  }
69
71
 
70
- async init () {
72
+ /**
73
+ * Called by EchoProxy open.
74
+ */
75
+ async initialize () {
71
76
  if (this._database && this._serviceProvider instanceof ClientServiceProxy) {
72
- await this._database.init();
77
+ await this._database.initialize();
73
78
  }
74
79
 
75
- await this._database?.waitForItem({ type: PARTY_ITEM_TYPE });
80
+ // Root item for properties.
81
+ this._item = await this._database?.waitForItem({ type: PARTY_ITEM_TYPE });
76
82
  }
77
83
 
84
+ /**
85
+ * Called by EchoProxy close.
86
+ */
78
87
  async destroy () {
79
88
  if (this._database && this._serviceProvider instanceof ClientServiceProxy) {
80
89
  await this._database.destroy();
81
90
  }
82
91
  }
83
92
 
84
- /**
85
- * Called by EchoProxy to update this party instance.
86
- * @internal
87
- */
88
- _processPartyUpdate (party: PartyProto) {
89
- this._key = party.publicKey;
90
- this._isOpen = party.isOpen;
91
- this._isActive = party.isActive;
92
- }
93
-
94
93
  get key () {
95
94
  return this._key;
96
95
  }
@@ -103,12 +102,9 @@ export class Party {
103
102
  return this._isActive;
104
103
  }
105
104
 
106
- /**
107
- * Database instance of the current party.
108
- */
109
105
  get database (): Database {
110
106
  if (!this._database) {
111
- throw Error('Party not open');
107
+ throw Error('Party not open.');
112
108
  }
113
109
 
114
110
  return this._database;
@@ -118,6 +114,7 @@ export class Party {
118
114
  return this.setOpen(true);
119
115
  }
120
116
 
117
+ // TODO(burdon): Requires comment.
121
118
  async setOpen (open: boolean) {
122
119
  await this._serviceProvider.services.PartyService.setPartyState({
123
120
  partyKey: this.key,
@@ -125,6 +122,7 @@ export class Party {
125
122
  });
126
123
  }
127
124
 
125
+ // TODO(burdon): Requires comment.
128
126
  async setActive (active: boolean, options: ActivationOptions) {
129
127
  const activeGlobal = options.global ? active : undefined;
130
128
  const activeDevice = options.device ? active : undefined;
@@ -135,6 +133,40 @@ export class Party {
135
133
  });
136
134
  }
137
135
 
136
+ get properties (): ObjectProperties {
137
+ return this._item!.model;
138
+ }
139
+
140
+ /**
141
+ * @deprecated Use party.properties.
142
+ */
143
+ async setTitle (title: string) {
144
+ await this.setProperty(PARTY_TITLE_PROPERTY, title);
145
+ return this;
146
+ }
147
+
148
+ /**
149
+ * @deprecated Use party.properties.
150
+ */
151
+ getTitle () {
152
+ return this.getProperty(PARTY_TITLE_PROPERTY);
153
+ }
154
+
155
+ /**
156
+ * @deprecated Use party.properties.
157
+ */
158
+ async setProperty (key: string, value?: any) {
159
+ await this.properties.set(key, value);
160
+ return this;
161
+ }
162
+
163
+ /**
164
+ * @deprecated Use party.properties.
165
+ */
166
+ getProperty (key: string, defaultValue?: any) {
167
+ return this.properties.get(key, defaultValue);
168
+ }
169
+
138
170
  /**
139
171
  * Returns a selection context, which can be used to traverse the object graph.
140
172
  */
@@ -149,6 +181,17 @@ export class Party {
149
181
  return this.database.reduce.bind(this.database);
150
182
  }
151
183
 
184
+ /**
185
+ * Return set of party members.
186
+ */
187
+ // TODO(burdon): Don't expose result object and provide type.
188
+ queryMembers () {
189
+ return streamToResultSet(
190
+ this._serviceProvider.services.PartyService.subscribeMembers({ partyKey: this.key }),
191
+ (response) => response?.members ?? []
192
+ );
193
+ }
194
+
152
195
  /**
153
196
  * Creates an invitation to a given party.
154
197
  * The Invitation flow requires the inviter and invitee to be online at the same time.
@@ -165,36 +208,17 @@ export class Party {
165
208
  return this._invitationProxy.createInvitationRequest({ stream });
166
209
  }
167
210
 
168
- queryMembers () {
169
- return streamToResultSet(
170
- this._serviceProvider.services.PartyService.subscribeMembers({ partyKey: this.key }),
171
- (response) => response?.members ?? []
172
- );
173
- }
174
-
175
- async setTitle (title: string) {
176
- await this.setProperty(PARTY_TITLE_PROPERTY, title);
177
- return this;
178
- }
179
-
180
- async setProperty (key: string, value?: any) {
181
- await this.database.waitForItem({ type: PARTY_ITEM_TYPE });
182
- const item = this.getPropertiesItem();
183
- await item.model.setProperty(key, value);
184
- return this;
185
- }
186
-
187
- getProperty (key: string) {
188
- const item = this.getPropertiesItem();
189
- return item?.model.getProperty(key);
190
- }
191
-
192
- private getPropertiesItem () {
193
- const items = this.database.select({ type: PARTY_ITEM_TYPE }).query().entities;
194
- return items[0];
195
- }
196
-
197
211
  createSnapshot () {
198
212
  return this._serviceProvider.services.PartyService.createSnapshot({ partyKey: this.key });
199
213
  }
214
+
215
+ /**
216
+ * Called by EchoProxy to update this party instance.
217
+ * @internal
218
+ */
219
+ _processPartyUpdate (party: PartyProto) {
220
+ this._key = party.publicKey;
221
+ this._isOpen = party.isOpen;
222
+ this._isActive = party.isActive;
223
+ }
200
224
  }
@@ -234,9 +234,9 @@ describe('Client', () => {
234
234
  const party = await client.echo.createParty();
235
235
 
236
236
  const item = await party.database.createItem({ model: ObjectModel });
237
- await item.model.setProperty('foo', 'bar');
237
+ await item.model.set('foo', 'bar');
238
238
 
239
- expect(item.model.getProperty('foo')).toEqual('bar');
239
+ expect(item.model.get('foo')).toEqual('bar');
240
240
  });
241
241
 
242
242
  test('set party properties', async () => {
@@ -261,11 +261,11 @@ describe('Client', () => {
261
261
  const party = await client.echo.createParty();
262
262
 
263
263
  const item1 = await party.database.createItem({ model: ObjectModel, type: 'test' });
264
- await item1.model.setProperty('prop1', 'x');
264
+ await item1.model.set('prop1', 'x');
265
265
  const item2 = await party.database.createItem({ model: ObjectModel, type: 'test' });
266
- await item2.model.setProperty('prop1', 'y');
266
+ await item2.model.set('prop1', 'y');
267
267
 
268
- expect(item1.model.getProperty('prop1')).toEqual('x');
268
+ expect(item1.model.get('prop1')).toEqual('x');
269
269
  });
270
270
  });
271
271
  }
@@ -316,7 +316,7 @@ describe('Client', () => {
316
316
  await client.halo.createProfile({ username: 'test-user' });
317
317
  const party = await client.echo.createParty();
318
318
  const item = await party.database.createItem({ model: TestModel, type: 'test' });
319
- await item.model.setProperty('prop', 'value1');
319
+ await item.model.set('prop', 'value1');
320
320
 
321
321
  await client.destroy();
322
322
  }
@@ -334,10 +334,10 @@ describe('Client', () => {
334
334
  await result.update.waitForCondition(() => result.entities.length > 0);
335
335
  const item = result.expectOne();
336
336
 
337
- expect(item.model.getProperty('prop')).toEqual('value1');
337
+ expect(item.model.get('prop')).toEqual('value1');
338
338
 
339
- await item.model.setProperty('prop', 'value2');
340
- expect(item.model.getProperty('prop')).toEqual('value2');
339
+ await item.model.set('prop', 'value2');
340
+ expect(item.model.get('prop')).toEqual('value2');
341
341
 
342
342
  await client.destroy();
343
343
  }
package/src/version.ts CHANGED
@@ -2,4 +2,4 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
- export const DXOS_VERSION = '2.28.14';
5
+ export const DXOS_VERSION = '2.28.15';