@dxos/client-services 0.8.4-main.5ea62a8 → 0.8.4-main.72ec0f3

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 (34) hide show
  1. package/dist/lib/browser/{chunk-JBVOLD57.mjs → chunk-HJH6BNTN.mjs} +803 -1150
  2. package/dist/lib/browser/chunk-HJH6BNTN.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +110 -135
  4. package/dist/lib/browser/index.mjs.map +2 -2
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +37 -66
  7. package/dist/lib/browser/testing/index.mjs.map +2 -2
  8. package/dist/lib/node-esm/{chunk-AADRC6MD.mjs → chunk-ONQM6RQH.mjs} +803 -1150
  9. package/dist/lib/node-esm/chunk-ONQM6RQH.mjs.map +7 -0
  10. package/dist/lib/node-esm/index.mjs +110 -135
  11. package/dist/lib/node-esm/index.mjs.map +2 -2
  12. package/dist/lib/node-esm/meta.json +1 -1
  13. package/dist/lib/node-esm/testing/index.mjs +37 -66
  14. package/dist/lib/node-esm/testing/index.mjs.map +2 -2
  15. package/dist/types/src/packlets/agents/edge-agent-service.d.ts.map +1 -1
  16. package/dist/types/src/packlets/services/service-host.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-service.ts +11 -1
  22. package/src/packlets/devices/devices-service.ts +1 -1
  23. package/src/packlets/identity/identity.test.ts +4 -4
  24. package/src/packlets/logging/logging-service.ts +1 -1
  25. package/src/packlets/services/service-host.ts +6 -0
  26. package/src/packlets/space-export/space-archive-reader.ts +1 -1
  27. package/src/packlets/space-export/space-archive-writer.ts +3 -3
  28. package/src/packlets/spaces/data-space-manager.ts +19 -3
  29. package/src/packlets/spaces/edge-feed-replicator.test.ts +1 -1
  30. package/src/packlets/spaces/edge-feed-replicator.ts +1 -1
  31. package/src/packlets/spaces/spaces-service.ts +1 -1
  32. package/src/version.ts +1 -1
  33. package/dist/lib/browser/chunk-JBVOLD57.mjs.map +0 -7
  34. package/dist/lib/node-esm/chunk-AADRC6MD.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.5ea62a8",
3
+ "version": "0.8.4-main.72ec0f3",
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.5ea62a8",
52
- "@dxos/codec-protobuf": "0.8.4-main.5ea62a8",
53
- "@dxos/client-protocol": "0.8.4-main.5ea62a8",
54
- "@dxos/context": "0.8.4-main.5ea62a8",
55
- "@dxos/credentials": "0.8.4-main.5ea62a8",
56
- "@dxos/debug": "0.8.4-main.5ea62a8",
57
- "@dxos/crypto": "0.8.4-main.5ea62a8",
58
- "@dxos/config": "0.8.4-main.5ea62a8",
59
- "@dxos/echo-pipeline": "0.8.4-main.5ea62a8",
60
- "@dxos/echo-protocol": "0.8.4-main.5ea62a8",
61
- "@dxos/edge-client": "0.8.4-main.5ea62a8",
62
- "@dxos/echo-schema": "0.8.4-main.5ea62a8",
63
- "@dxos/indexing": "0.8.4-main.5ea62a8",
64
- "@dxos/echo-db": "0.8.4-main.5ea62a8",
65
- "@dxos/invariant": "0.8.4-main.5ea62a8",
66
- "@dxos/keyring": "0.8.4-main.5ea62a8",
67
- "@dxos/kv-store": "0.8.4-main.5ea62a8",
68
- "@dxos/keys": "0.8.4-main.5ea62a8",
69
- "@dxos/lock-file": "0.8.4-main.5ea62a8",
70
- "@dxos/log": "0.8.4-main.5ea62a8",
71
- "@dxos/messaging": "0.8.4-main.5ea62a8",
72
- "@dxos/network-manager": "0.8.4-main.5ea62a8",
73
- "@dxos/node-std": "0.8.4-main.5ea62a8",
74
- "@dxos/protocols": "0.8.4-main.5ea62a8",
75
- "@dxos/random-access-storage": "0.8.4-main.5ea62a8",
76
- "@dxos/teleport": "0.8.4-main.5ea62a8",
77
- "@dxos/teleport-extension-gossip": "0.8.4-main.5ea62a8",
78
- "@dxos/rpc": "0.8.4-main.5ea62a8",
79
- "@dxos/teleport-extension-object-sync": "0.8.4-main.5ea62a8",
80
- "@dxos/timeframe": "0.8.4-main.5ea62a8",
81
- "@dxos/tracing": "0.8.4-main.5ea62a8",
82
- "@dxos/util": "0.8.4-main.5ea62a8",
83
- "@dxos/websocket-rpc": "0.8.4-main.5ea62a8",
84
- "@dxos/feed-store": "0.8.4-main.5ea62a8"
51
+ "@dxos/async": "0.8.4-main.72ec0f3",
52
+ "@dxos/client-protocol": "0.8.4-main.72ec0f3",
53
+ "@dxos/config": "0.8.4-main.72ec0f3",
54
+ "@dxos/context": "0.8.4-main.72ec0f3",
55
+ "@dxos/credentials": "0.8.4-main.72ec0f3",
56
+ "@dxos/codec-protobuf": "0.8.4-main.72ec0f3",
57
+ "@dxos/debug": "0.8.4-main.72ec0f3",
58
+ "@dxos/crypto": "0.8.4-main.72ec0f3",
59
+ "@dxos/echo": "0.8.4-main.72ec0f3",
60
+ "@dxos/echo-db": "0.8.4-main.72ec0f3",
61
+ "@dxos/echo-pipeline": "0.8.4-main.72ec0f3",
62
+ "@dxos/echo-protocol": "0.8.4-main.72ec0f3",
63
+ "@dxos/feed-store": "0.8.4-main.72ec0f3",
64
+ "@dxos/edge-client": "0.8.4-main.72ec0f3",
65
+ "@dxos/indexing": "0.8.4-main.72ec0f3",
66
+ "@dxos/invariant": "0.8.4-main.72ec0f3",
67
+ "@dxos/keyring": "0.8.4-main.72ec0f3",
68
+ "@dxos/lock-file": "0.8.4-main.72ec0f3",
69
+ "@dxos/messaging": "0.8.4-main.72ec0f3",
70
+ "@dxos/keys": "0.8.4-main.72ec0f3",
71
+ "@dxos/kv-store": "0.8.4-main.72ec0f3",
72
+ "@dxos/network-manager": "0.8.4-main.72ec0f3",
73
+ "@dxos/node-std": "0.8.4-main.72ec0f3",
74
+ "@dxos/protocols": "0.8.4-main.72ec0f3",
75
+ "@dxos/random-access-storage": "0.8.4-main.72ec0f3",
76
+ "@dxos/rpc": "0.8.4-main.72ec0f3",
77
+ "@dxos/log": "0.8.4-main.72ec0f3",
78
+ "@dxos/teleport": "0.8.4-main.72ec0f3",
79
+ "@dxos/teleport-extension-gossip": "0.8.4-main.72ec0f3",
80
+ "@dxos/teleport-extension-object-sync": "0.8.4-main.72ec0f3",
81
+ "@dxos/timeframe": "0.8.4-main.72ec0f3",
82
+ "@dxos/tracing": "0.8.4-main.72ec0f3",
83
+ "@dxos/websocket-rpc": "0.8.4-main.72ec0f3",
84
+ "@dxos/util": "0.8.4-main.72ec0f3"
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.5ea62a8",
91
- "@dxos/test-utils": "0.8.4-main.5ea62a8"
90
+ "@dxos/signal": "0.8.4-main.72ec0f3",
91
+ "@dxos/test-utils": "0.8.4-main.72ec0f3"
92
92
  },
93
93
  "publishConfig": {
94
94
  "access": "public"
@@ -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
 
@@ -408,6 +408,12 @@ export class ClientServicesHost {
408
408
  this._resetting = true;
409
409
  this._statusUpdate.emit();
410
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
+ }
411
417
  await this._storage!.reset();
412
418
  log.info('reset');
413
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,7 @@ export class SpaceArchiveWriter extends Resource {
76
76
  const binary = this._archive.toUint8Array();
77
77
 
78
78
  return {
79
- filename: `${this._meta.spaceId}.tar`,
79
+ filename: `${new Date().toISOString()}-${this._meta.spaceId}.tar`,
80
80
  contents: binary,
81
81
  };
82
82
  }
@@ -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.5ea62a8";
1
+ export const DXOS_VERSION = "0.8.4-main.72ec0f3";