@dxos/client-services 0.8.4-main.fd6878d → 0.8.4-main.fffef41

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 (36) hide show
  1. package/dist/lib/browser/{chunk-6C7MTZLC.mjs → chunk-I2RGLVJF.mjs} +157 -146
  2. package/dist/lib/browser/chunk-I2RGLVJF.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +1 -1
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/browser/testing/index.mjs +2 -3
  6. package/dist/lib/browser/testing/index.mjs.map +1 -1
  7. package/dist/lib/node-esm/{chunk-YOHACH7G.mjs → chunk-QTUURCR4.mjs} +157 -146
  8. package/dist/lib/node-esm/chunk-QTUURCR4.mjs.map +7 -0
  9. package/dist/lib/node-esm/index.mjs +1 -1
  10. package/dist/lib/node-esm/meta.json +1 -1
  11. package/dist/lib/node-esm/testing/index.mjs +2 -3
  12. package/dist/lib/node-esm/testing/index.mjs.map +1 -1
  13. package/dist/types/src/packlets/agents/edge-agent-service.d.ts.map +1 -1
  14. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  15. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  16. package/dist/types/src/packlets/space-export/space-archive-writer.d.ts.map +1 -1
  17. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  18. package/dist/types/src/version.d.ts +1 -1
  19. package/dist/types/tsconfig.tsbuildinfo +1 -1
  20. package/package.json +39 -39
  21. package/src/packlets/agents/edge-agent-manager.ts +2 -2
  22. package/src/packlets/agents/edge-agent-service.ts +11 -1
  23. package/src/packlets/devices/devices-service.ts +1 -1
  24. package/src/packlets/identity/identity.test.ts +4 -4
  25. package/src/packlets/logging/logging-service.ts +1 -1
  26. package/src/packlets/services/service-context.ts +5 -4
  27. package/src/packlets/services/service-host.ts +8 -1
  28. package/src/packlets/space-export/space-archive-reader.ts +1 -1
  29. package/src/packlets/space-export/space-archive-writer.ts +4 -3
  30. package/src/packlets/spaces/data-space-manager.ts +19 -3
  31. package/src/packlets/spaces/edge-feed-replicator.test.ts +1 -1
  32. package/src/packlets/spaces/edge-feed-replicator.ts +1 -1
  33. package/src/packlets/spaces/spaces-service.ts +1 -1
  34. package/src/version.ts +1 -1
  35. package/dist/lib/browser/chunk-6C7MTZLC.mjs.map +0 -7
  36. package/dist/lib/node-esm/chunk-YOHACH7G.mjs.map +0 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/client-services",
3
- "version": "0.8.4-main.fd6878d",
3
+ "version": "0.8.4-main.fffef41",
4
4
  "description": "DXOS client services implementation",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -43,52 +43,52 @@
43
43
  "src"
44
44
  ],
45
45
  "dependencies": {
46
- "@automerge/automerge": "3.1.1",
47
- "@automerge/automerge-repo": "2.3.0-alpha.0",
46
+ "@automerge/automerge": "3.1.2",
47
+ "@automerge/automerge-repo": "2.4.0",
48
48
  "@obsidize/tar-browserify": "^5.2.0",
49
49
  "cbor-x": "^1.5.4",
50
50
  "platform": "^1.3.6",
51
- "@dxos/async": "0.8.4-main.fd6878d",
52
- "@dxos/client-protocol": "0.8.4-main.fd6878d",
53
- "@dxos/codec-protobuf": "0.8.4-main.fd6878d",
54
- "@dxos/credentials": "0.8.4-main.fd6878d",
55
- "@dxos/crypto": "0.8.4-main.fd6878d",
56
- "@dxos/context": "0.8.4-main.fd6878d",
57
- "@dxos/debug": "0.8.4-main.fd6878d",
58
- "@dxos/echo-pipeline": "0.8.4-main.fd6878d",
59
- "@dxos/echo-db": "0.8.4-main.fd6878d",
60
- "@dxos/echo-protocol": "0.8.4-main.fd6878d",
61
- "@dxos/echo-schema": "0.8.4-main.fd6878d",
62
- "@dxos/config": "0.8.4-main.fd6878d",
63
- "@dxos/feed-store": "0.8.4-main.fd6878d",
64
- "@dxos/indexing": "0.8.4-main.fd6878d",
65
- "@dxos/invariant": "0.8.4-main.fd6878d",
66
- "@dxos/keyring": "0.8.4-main.fd6878d",
67
- "@dxos/keys": "0.8.4-main.fd6878d",
68
- "@dxos/kv-store": "0.8.4-main.fd6878d",
69
- "@dxos/edge-client": "0.8.4-main.fd6878d",
70
- "@dxos/lock-file": "0.8.4-main.fd6878d",
71
- "@dxos/log": "0.8.4-main.fd6878d",
72
- "@dxos/messaging": "0.8.4-main.fd6878d",
73
- "@dxos/network-manager": "0.8.4-main.fd6878d",
74
- "@dxos/node-std": "0.8.4-main.fd6878d",
75
- "@dxos/protocols": "0.8.4-main.fd6878d",
76
- "@dxos/random-access-storage": "0.8.4-main.fd6878d",
77
- "@dxos/teleport": "0.8.4-main.fd6878d",
78
- "@dxos/teleport-extension-gossip": "0.8.4-main.fd6878d",
79
- "@dxos/rpc": "0.8.4-main.fd6878d",
80
- "@dxos/timeframe": "0.8.4-main.fd6878d",
81
- "@dxos/util": "0.8.4-main.fd6878d",
82
- "@dxos/tracing": "0.8.4-main.fd6878d",
83
- "@dxos/websocket-rpc": "0.8.4-main.fd6878d",
84
- "@dxos/teleport-extension-object-sync": "0.8.4-main.fd6878d"
51
+ "@dxos/async": "0.8.4-main.fffef41",
52
+ "@dxos/client-protocol": "0.8.4-main.fffef41",
53
+ "@dxos/config": "0.8.4-main.fffef41",
54
+ "@dxos/codec-protobuf": "0.8.4-main.fffef41",
55
+ "@dxos/credentials": "0.8.4-main.fffef41",
56
+ "@dxos/crypto": "0.8.4-main.fffef41",
57
+ "@dxos/context": "0.8.4-main.fffef41",
58
+ "@dxos/debug": "0.8.4-main.fffef41",
59
+ "@dxos/echo": "0.8.4-main.fffef41",
60
+ "@dxos/echo-pipeline": "0.8.4-main.fffef41",
61
+ "@dxos/edge-client": "0.8.4-main.fffef41",
62
+ "@dxos/echo-protocol": "0.8.4-main.fffef41",
63
+ "@dxos/indexing": "0.8.4-main.fffef41",
64
+ "@dxos/invariant": "0.8.4-main.fffef41",
65
+ "@dxos/echo-db": "0.8.4-main.fffef41",
66
+ "@dxos/feed-store": "0.8.4-main.fffef41",
67
+ "@dxos/keyring": "0.8.4-main.fffef41",
68
+ "@dxos/keys": "0.8.4-main.fffef41",
69
+ "@dxos/kv-store": "0.8.4-main.fffef41",
70
+ "@dxos/lock-file": "0.8.4-main.fffef41",
71
+ "@dxos/messaging": "0.8.4-main.fffef41",
72
+ "@dxos/log": "0.8.4-main.fffef41",
73
+ "@dxos/network-manager": "0.8.4-main.fffef41",
74
+ "@dxos/protocols": "0.8.4-main.fffef41",
75
+ "@dxos/random-access-storage": "0.8.4-main.fffef41",
76
+ "@dxos/rpc": "0.8.4-main.fffef41",
77
+ "@dxos/node-std": "0.8.4-main.fffef41",
78
+ "@dxos/teleport": "0.8.4-main.fffef41",
79
+ "@dxos/teleport-extension-gossip": "0.8.4-main.fffef41",
80
+ "@dxos/teleport-extension-object-sync": "0.8.4-main.fffef41",
81
+ "@dxos/tracing": "0.8.4-main.fffef41",
82
+ "@dxos/util": "0.8.4-main.fffef41",
83
+ "@dxos/websocket-rpc": "0.8.4-main.fffef41",
84
+ "@dxos/timeframe": "0.8.4-main.fffef41"
85
85
  },
86
86
  "devDependencies": {
87
87
  "@types/platform": "^1.3.4",
88
88
  "@types/readable-stream": "^2.3.9",
89
89
  "get-port-please": "^3.1.1",
90
- "@dxos/signal": "0.8.4-main.fd6878d",
91
- "@dxos/test-utils": "0.8.4-main.fd6878d"
90
+ "@dxos/signal": "0.8.4-main.fffef41",
91
+ "@dxos/test-utils": "0.8.4-main.fffef41"
92
92
  },
93
93
  "publishConfig": {
94
94
  "access": "public"
@@ -162,7 +162,7 @@ export class EdgeAgentManager extends Resource {
162
162
  space.notarizationPlugin.setActiveEdgePollingEnabled(agentFeedNeedsNotarization);
163
163
  activePollingEnabled = activePollingEnabled || agentFeedNeedsNotarization;
164
164
 
165
- log.info('set active edge polling', { enabled: agentFeedNeedsNotarization, spaceId: space.id });
165
+ log.verbose('set active edge polling', { enabled: agentFeedNeedsNotarization, spaceId: space.id });
166
166
  }
167
167
 
168
168
  if (activePollingEnabled) {
@@ -178,6 +178,6 @@ export class EdgeAgentManager extends Resource {
178
178
  if (deviceKey) {
179
179
  this._ensureAgentIsInSpaces(deviceKey);
180
180
  }
181
- log.info('agent status update', { status });
181
+ log.verbose('agent status update', { status });
182
182
  }
183
183
  }
@@ -25,7 +25,17 @@ export class EdgeAgentServiceImpl implements EdgeAgentService {
25
25
  queryEdgeStatus(): Stream<QueryEdgeStatusResponse> {
26
26
  return new Stream(({ ctx, next }) => {
27
27
  const update = () => {
28
- next({ status: this._edgeConnection?.status ?? EdgeStatus.NOT_CONNECTED });
28
+ next({
29
+ status: this._edgeConnection?.status ?? {
30
+ state: EdgeStatus.ConnectionState.NOT_CONNECTED,
31
+ rtt: 0,
32
+ uptime: 0,
33
+ rateBytesUp: 0,
34
+ rateBytesDown: 0,
35
+ messagesSent: 0,
36
+ messagesReceived: 0,
37
+ },
38
+ });
29
39
  };
30
40
 
31
41
  this._edgeConnection?.statusChanged.on(ctx, update);
@@ -44,7 +44,7 @@ export class DevicesServiceImpl implements DevicesService {
44
44
  presence = Device.PresenceState.ONLINE;
45
45
  } else if (profile.os?.toUpperCase() === 'EDGE') {
46
46
  presence =
47
- this._edgeConnection?.status === EdgeStatus.CONNECTED
47
+ this._edgeConnection?.status.state === EdgeStatus.ConnectionState.CONNECTED
48
48
  ? Device.PresenceState.ONLINE
49
49
  : Device.PresenceState.OFFLINE;
50
50
  } else {
@@ -109,16 +109,16 @@ describe('identity/identity', () => {
109
109
 
110
110
  test('edge feed replicator', async () => {
111
111
  let replicationStarted = false;
112
- let status = EdgeStatus.NOT_CONNECTED;
112
+ let status = EdgeStatus.ConnectionState.NOT_CONNECTED;
113
113
  const listeners: Array<() => void> = [];
114
114
  const setup = await setupIdentity({
115
115
  edgeConnection: {
116
116
  statusChanged: new Event(),
117
117
  get status() {
118
- return status;
118
+ return { state: status };
119
119
  },
120
120
  onReconnected: (listener) => {
121
- if (status === EdgeStatus.CONNECTED) {
121
+ if (status === EdgeStatus.ConnectionState.CONNECTED) {
122
122
  listener();
123
123
  } else {
124
124
  listeners.push(listener);
@@ -138,7 +138,7 @@ describe('identity/identity', () => {
138
138
 
139
139
  await writeGenesisCredential(setup);
140
140
  listeners.forEach((callback) => callback());
141
- status = EdgeStatus.CONNECTED;
141
+ status = EdgeStatus.ConnectionState.CONNECTED;
142
142
 
143
143
  await expect.poll(() => replicationStarted).toBeTruthy();
144
144
  });
@@ -37,7 +37,7 @@ export class LoggingServiceImpl implements LoggingService {
37
37
  }
38
38
 
39
39
  async close(): Promise<void> {
40
- const index = log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
40
+ const index = log.runtimeConfig.processors.findIndex((processor: LogProcessor) => processor === this._logProcessor);
41
41
  log.runtimeConfig.processors.splice(index, 1);
42
42
  }
43
43
 
@@ -189,9 +189,10 @@ export class ServiceContext extends Resource {
189
189
  if (!this._runtimeParams?.disableP2pReplication) {
190
190
  this._meshReplicator = new MeshEchoReplicator();
191
191
  }
192
- if (this._edgeConnection && this._edgeFeatures?.echoReplicator) {
192
+ if (this._edgeConnection && this._edgeFeatures?.echoReplicator && this._edgeHttpClient) {
193
193
  this._echoEdgeReplicator = new EchoEdgeReplicator({
194
194
  edgeConnection: this._edgeConnection,
195
+ edgeHttpClient: this._edgeHttpClient,
195
196
  });
196
197
  }
197
198
  }
@@ -244,13 +245,13 @@ export class ServiceContext extends Resource {
244
245
  await this.edgeAgentManager?.close();
245
246
  await this.identityManager.close();
246
247
  await this.spaceManager.close();
247
- await this.feedStore.close();
248
- await this.metadataStore.close();
249
-
250
248
  await this.echoHost.close(ctx);
249
+
251
250
  await this.networkManager.close();
252
251
  await this.signalManager.close();
253
252
  await this._edgeConnection?.close();
253
+ await this.feedStore.close();
254
+ await this.metadataStore.close();
254
255
 
255
256
  log('closed');
256
257
  }
@@ -217,8 +217,9 @@ export class ClientServicesHost {
217
217
  }
218
218
  }
219
219
 
220
+ // TODO(wittjosiah): This is quite noisy during tests. Make configurable? Remove?
220
221
  if (!options.signalManager) {
221
- log.warn('running signaling without telemetry metadata.');
222
+ // log.warn('running signaling without telemetry metadata.');
222
223
  }
223
224
 
224
225
  const endpoint = config?.get('runtime.services.edge.url');
@@ -407,6 +408,12 @@ export class ClientServicesHost {
407
408
  this._resetting = true;
408
409
  this._statusUpdate.emit();
409
410
  await this._serviceContext?.close();
411
+ // Clear LevelDB contents to remove all persisted Echo/Automerge/index data.
412
+ try {
413
+ await this._level!.clear();
414
+ } catch (err) {
415
+ log.warn('failed to clear leveldb during reset', { err });
416
+ }
410
417
  await this._storage!.reset();
411
418
  log.info('reset');
412
419
  log.trace('dxos.sdk.client-services-host.reset', trace.end({ id: traceId }));
@@ -18,7 +18,7 @@ export const extractSpaceArchive = async (archive: SpaceArchive): Promise<Extrac
18
18
  const { Archive } = await import('@obsidize/tar-browserify');
19
19
  const { entries } = await Archive.extract(archive.contents);
20
20
  const metadataEntry = entries.find((entry) => entry.fileName === SpaceArchiveFileStructure.metadata);
21
- assertArgument(metadataEntry, 'Metadata entry not found');
21
+ assertArgument(metadataEntry, 'metadataEntry', 'Metadata entry not found');
22
22
  const metadata = JSON.parse(metadataEntry.getContentAsText());
23
23
  const documents: Record<DocumentId, Uint8Array> = {};
24
24
  for (const entry of entries.filter((entry) => entry.fileName.startsWith(`${SpaceArchiveFileStructure.documents}/`))) {
@@ -44,14 +44,14 @@ export class SpaceArchiveWriter extends Resource {
44
44
  }
45
45
 
46
46
  async setCurrentRootUrl(url: string): Promise<void> {
47
- assertArgument(url.startsWith('automerge:'), 'Invalid root URL');
47
+ assertArgument(url.startsWith('automerge:'), 'url', 'Invalid root URL');
48
48
  assertState(this._tar, 'Not open');
49
49
  assertState(this._meta, 'Not started');
50
50
  this._currentRootUrl = url;
51
51
  }
52
52
 
53
53
  async writeDocument(documentId: string, data: Uint8Array): Promise<void> {
54
- assertArgument(!documentId.startsWith('automerge:'), 'Invalid document ID');
54
+ assertArgument(!documentId.startsWith('automerge:'), 'documentId', 'Invalid document ID');
55
55
  assertState(this._archive, 'Not open');
56
56
  this._archive.addBinaryFile(`${SpaceArchiveFileStructure.documents}/${documentId}.bin`, data);
57
57
  }
@@ -76,7 +76,8 @@ export class SpaceArchiveWriter extends Resource {
76
76
  const binary = this._archive.toUint8Array();
77
77
 
78
78
  return {
79
- filename: `${this._meta.spaceId}.tar`,
79
+ // TODO(wittjosiah): Factor out file name construction.
80
+ filename: `${new Date().toISOString()}-${this._meta.spaceId}.tar`,
80
81
  contents: binary,
81
82
  };
82
83
  }
@@ -15,6 +15,7 @@ import {
15
15
  createAdmissionCredentials,
16
16
  getCredentialAssertion,
17
17
  } from '@dxos/credentials';
18
+ import { ObjectId, getTypeReference } from '@dxos/echo/internal';
18
19
  import {
19
20
  AuthStatus,
20
21
  CredentialServerExtension,
@@ -37,7 +38,6 @@ import {
37
38
  createIdFromSpaceKey,
38
39
  encodeReference,
39
40
  } from '@dxos/echo-protocol';
40
- import { ObjectId, getTypeReference } from '@dxos/echo-schema';
41
41
  import type { EdgeConnection, EdgeHttpClient } from '@dxos/edge-client';
42
42
  import { type FeedStore, writeMessages } from '@dxos/feed-store';
43
43
  import { assertArgument, assertState, failedInvariant, invariant } from '@dxos/invariant';
@@ -245,7 +245,11 @@ export class DataSpaceManager extends Resource {
245
245
  */
246
246
  @synchronized
247
247
  async createSpace(options: CreateSpaceOptions = {}): Promise<DataSpace> {
248
- assertArgument(!!options.rootUrl === !!options.documents, 'root url must be required when providing documents');
248
+ assertArgument(
249
+ !!options.rootUrl === !!options.documents,
250
+ 'options',
251
+ 'root url must be required when providing documents',
252
+ );
249
253
 
250
254
  assertState(this._lifecycleState === LifecycleState.OPEN, 'Not open.');
251
255
  const spaceKey = await this._keyring.createKey();
@@ -275,7 +279,18 @@ export class DataSpaceManager extends Resource {
275
279
  await Promise.all(
276
280
  Object.entries(options.documents).map(async ([documentId, data]) => {
277
281
  log('creating document...', { documentId });
278
- const newDoc = await this._echoHost.createDoc(data, { preserveHistory: true });
282
+ // TODO(dmaretskyi): Broken types -- the bytes get interpreted as CRDT data.
283
+ const newDoc = await this._echoHost.createDoc(data as any as DatabaseDirectory, {
284
+ preserveHistory: true,
285
+ });
286
+
287
+ // The archived documents might have the spaceKey from the space they were expored from, we need to update it to the new spaceKey.
288
+ if (newDoc.doc().access !== undefined && newDoc.doc().access!.spaceKey !== spaceKey.toHex()) {
289
+ newDoc.change((doc) => {
290
+ doc.access!.spaceKey = spaceKey.toHex();
291
+ });
292
+ }
293
+
279
294
  documentIdMapping[documentId as DocumentId] = newDoc.documentId;
280
295
  }),
281
296
  );
@@ -293,6 +308,7 @@ export class DataSpaceManager extends Resource {
293
308
  } else {
294
309
  root = await this._echoHost.createSpaceRoot(spaceKey);
295
310
  }
311
+ await this._echoHost.flush();
296
312
 
297
313
  log('constructing space...', { spaceKey });
298
314
 
@@ -45,7 +45,7 @@ describe('EdgeFeedReplicator', () => {
45
45
  const { endpoint, admitConnection, messageSink } = await createEdge();
46
46
  const { messenger } = await createClient(endpoint);
47
47
  admitConnection.wake();
48
- await expect.poll(() => messenger.status).toBe(EdgeStatus.CONNECTED);
48
+ await expect.poll(() => messenger.status.state).toBe(EdgeStatus.ConnectionState.CONNECTED);
49
49
 
50
50
  await attachReplicator(messenger);
51
51
  await expect.poll(() => messageSink.length).toEqual(1);
@@ -87,7 +87,7 @@ export class EdgeFeedReplicator extends Resource {
87
87
 
88
88
  private async _handleReconnect(): Promise<void> {
89
89
  await this._resetConnection();
90
- if (this._messenger.status === EdgeStatus.CONNECTED) {
90
+ if (this._messenger.status.state === EdgeStatus.ConnectionState.CONNECTED) {
91
91
  this._startReplication();
92
92
  }
93
93
  }
@@ -267,7 +267,7 @@ export class SpacesServiceImpl implements SpacesService {
267
267
 
268
268
  async exportSpace(request: ExportSpaceRequest): Promise<ExportSpaceResponse> {
269
269
  await using writer = await new SpaceArchiveWriter().open();
270
- assertArgument(SpaceId.isValid(request.spaceId), 'Invalid space ID');
270
+ assertArgument(SpaceId.isValid(request.spaceId), 'spaceId', 'Invalid space ID');
271
271
 
272
272
  const dataSpaceManager = await this._getDataSpaceManager();
273
273
  const space = dataSpaceManager.getSpaceById(request.spaceId) ?? raise(new Error('Space not found'));
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const DXOS_VERSION = "0.8.4-main.fd6878d";
1
+ export const DXOS_VERSION = "0.8.4-main.fffef41";