@dxos/client-services 0.1.56-main.09ca29d → 0.1.56-main.0e9f69e

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 (73) hide show
  1. package/dist/lib/browser/{chunk-FD4L7N4K.mjs → chunk-II6TDINB.mjs} +782 -511
  2. package/dist/lib/browser/chunk-II6TDINB.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +30 -31
  4. package/dist/lib/browser/index.mjs.map +3 -3
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/packlets/testing/index.mjs +31 -46
  7. package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
  8. package/dist/lib/node/index.cjs +918 -649
  9. package/dist/lib/node/index.cjs.map +4 -4
  10. package/dist/lib/node/meta.json +1 -1
  11. package/dist/lib/node/packlets/testing/index.cjs +1198 -939
  12. package/dist/lib/node/packlets/testing/index.cjs.map +4 -4
  13. package/dist/types/src/packlets/identity/identity-manager.d.ts +7 -1
  14. package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
  15. package/dist/types/src/packlets/identity/identity-service.d.ts +7 -3
  16. package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
  17. package/dist/types/src/packlets/identity/identity.d.ts +3 -2
  18. package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
  19. package/dist/types/src/packlets/logging/logging-service.d.ts +6 -2
  20. package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
  21. package/dist/types/src/packlets/services/client-rpc-server.d.ts.map +1 -1
  22. package/dist/types/src/packlets/services/diagnostics.d.ts +46 -0
  23. package/dist/types/src/packlets/services/diagnostics.d.ts.map +1 -0
  24. package/dist/types/src/packlets/services/index.d.ts +1 -0
  25. package/dist/types/src/packlets/services/index.d.ts.map +1 -1
  26. package/dist/types/src/packlets/services/platform.d.ts +16 -0
  27. package/dist/types/src/packlets/services/platform.d.ts.map +1 -0
  28. package/dist/types/src/packlets/services/service-context.d.ts +2 -1
  29. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  30. package/dist/types/src/packlets/services/service-host.d.ts +7 -3
  31. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  32. package/dist/types/src/packlets/services/util.d.ts +6 -0
  33. package/dist/types/src/packlets/services/util.d.ts.map +1 -0
  34. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  35. package/dist/types/src/packlets/system/system-service.d.ts +12 -2
  36. package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
  37. package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
  38. package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
  39. package/dist/types/src/packlets/vault/worker-session.d.ts.map +1 -1
  40. package/dist/types/src/version.d.ts +2 -0
  41. package/dist/types/src/version.d.ts.map +1 -0
  42. package/package.json +34 -33
  43. package/src/packlets/devices/devices-service.test.ts +2 -1
  44. package/src/packlets/identity/identity-manager.test.ts +15 -3
  45. package/src/packlets/identity/identity-manager.ts +27 -6
  46. package/src/packlets/identity/identity-service.test.ts +17 -2
  47. package/src/packlets/identity/identity-service.ts +23 -14
  48. package/src/packlets/identity/identity.test.ts +7 -6
  49. package/src/packlets/identity/identity.ts +8 -3
  50. package/src/packlets/invitations/device-invitation-protocol.test.ts +2 -1
  51. package/src/packlets/logging/logging-service.ts +17 -9
  52. package/src/packlets/network/network-service.test.ts +2 -1
  53. package/src/packlets/services/client-rpc-server.ts +4 -4
  54. package/src/packlets/services/diagnostics.ts +211 -0
  55. package/src/packlets/services/index.ts +1 -0
  56. package/src/packlets/services/platform.ts +48 -0
  57. package/src/packlets/services/service-context.test.ts +59 -0
  58. package/src/packlets/services/service-context.ts +16 -9
  59. package/src/packlets/services/service-host.test.ts +11 -10
  60. package/src/packlets/services/service-host.ts +38 -18
  61. package/src/packlets/services/service-registry.test.ts +3 -1
  62. package/src/packlets/services/util.ts +33 -0
  63. package/src/packlets/spaces/data-space-manager.test.ts +80 -22
  64. package/src/packlets/spaces/data-space.ts +17 -5
  65. package/src/packlets/spaces/spaces-service.test.ts +2 -1
  66. package/src/packlets/system/system-service.test.ts +1 -0
  67. package/src/packlets/system/system-service.ts +34 -2
  68. package/src/packlets/testing/test-builder.ts +1 -1
  69. package/src/packlets/vault/iframe-host-runtime.ts +2 -1
  70. package/src/packlets/vault/worker-runtime.ts +3 -2
  71. package/src/packlets/vault/worker-session.ts +6 -1
  72. package/src/version.ts +1 -0
  73. package/dist/lib/browser/chunk-FD4L7N4K.mjs.map +0 -7
@@ -55,6 +55,12 @@ export type DataSpaceParams = {
55
55
  cache?: SpaceCache;
56
56
  };
57
57
 
58
+ /**
59
+ * Delete feed blocks after an epoch is created.
60
+ */
61
+ // TODO(dmaretskyi): Disabled till better times https://github.com/dxos/dxos/issues/3949.
62
+ const ENABLE_FEED_PURGE = false;
63
+
58
64
  @trackLeaks('open', 'close')
59
65
  export class DataSpace {
60
66
  private _ctx = new Context();
@@ -145,7 +151,7 @@ export class DataSpace {
145
151
  private async _open() {
146
152
  await this._notarizationPlugin.open();
147
153
  await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
148
- await this._inner.open();
154
+ await this._inner.open(new Context());
149
155
  this._state = SpaceState.CONTROL_ONLY;
150
156
  this.stateUpdate.emit();
151
157
  this.metrics = {};
@@ -323,10 +329,16 @@ export class DataSpace {
323
329
  });
324
330
 
325
331
  await this.inner.controlPipeline.state.waitUntilTimeframe(new Timeframe([[receipt.feedKey, receipt.seq]]));
326
- for (const feed of this.inner.dataPipeline.pipelineState?.feeds ?? []) {
327
- const indexBeforeEpoch = epoch.timeframe.get(feed.key);
328
- if (indexBeforeEpoch) {
329
- await feed.clear(0, indexBeforeEpoch + 1);
332
+
333
+ // Clear feed blocks before epoch.
334
+ if (ENABLE_FEED_PURGE) {
335
+ for (const feed of this.inner.dataPipeline.pipelineState?.feeds ?? []) {
336
+ const indexBeforeEpoch = epoch.timeframe.get(feed.key);
337
+ if (indexBeforeEpoch === undefined) {
338
+ continue;
339
+ }
340
+
341
+ await feed.safeClear(0, indexBeforeEpoch + 1);
330
342
  }
331
343
  }
332
344
  }
@@ -6,6 +6,7 @@ import chai, { expect } from 'chai';
6
6
  import chaiAsPromised from 'chai-as-promised';
7
7
 
8
8
  import { Trigger } from '@dxos/async';
9
+ import { Context } from '@dxos/context';
9
10
  import { PublicKey } from '@dxos/keys';
10
11
  import { Space, SpacesService } from '@dxos/protocols/proto/dxos/client/services';
11
12
  import { afterEach, afterTest, beforeEach, describe, test } from '@dxos/test';
@@ -22,7 +23,7 @@ describe('SpacesService', () => {
22
23
 
23
24
  beforeEach(async () => {
24
25
  serviceContext = createServiceContext();
25
- await serviceContext.open();
26
+ await serviceContext.open(new Context());
26
27
  spacesService = new SpacesServiceImpl(
27
28
  serviceContext.identityManager,
28
29
  serviceContext.spaceManager,
@@ -35,6 +35,7 @@ describe('SystemService', () => {
35
35
  config,
36
36
  statusUpdate,
37
37
  getCurrentStatus: () => currentStatus,
38
+ getDiagnostics: async () => ({}),
38
39
  onUpdateStatus: (status) => {
39
40
  updateStatus.wake(status);
40
41
  },
@@ -6,18 +6,22 @@ import { Event } from '@dxos/async';
6
6
  import { Stream } from '@dxos/codec-protobuf';
7
7
  import { Config } from '@dxos/config';
8
8
  import {
9
+ GetDiagnosticsRequest,
9
10
  SystemService,
10
11
  SystemStatus,
11
12
  UpdateStatusRequest,
12
13
  QueryStatusRequest,
13
14
  QueryStatusResponse,
14
15
  } from '@dxos/protocols/proto/dxos/client/services';
15
- import { MaybePromise } from '@dxos/util';
16
+ import { jsonKeyReplacer, MaybePromise } from '@dxos/util';
17
+
18
+ import { Diagnostics } from '../services';
16
19
 
17
20
  export type SystemServiceOptions = {
18
21
  config?: Config;
19
22
  statusUpdate: Event<void>;
20
23
  getCurrentStatus: () => SystemStatus;
24
+ getDiagnostics: () => Promise<Partial<Diagnostics>>;
21
25
  onUpdateStatus: (status: SystemStatus) => MaybePromise<void>;
22
26
  onReset: () => MaybePromise<void>;
23
27
  };
@@ -28,11 +32,20 @@ export class SystemServiceImpl implements SystemService {
28
32
  private readonly _getCurrentStatus: SystemServiceOptions['getCurrentStatus'];
29
33
  private readonly _onUpdateStatus: SystemServiceOptions['onUpdateStatus'];
30
34
  private readonly _onReset: SystemServiceOptions['onReset'];
35
+ private readonly _getDiagnostics: SystemServiceOptions['getDiagnostics'];
31
36
 
32
- constructor({ config, statusUpdate, onUpdateStatus, getCurrentStatus, onReset }: SystemServiceOptions) {
37
+ constructor({
38
+ config,
39
+ statusUpdate,
40
+ getDiagnostics,
41
+ onUpdateStatus,
42
+ getCurrentStatus,
43
+ onReset,
44
+ }: SystemServiceOptions) {
33
45
  this._config = config;
34
46
  this._statusUpdate = statusUpdate;
35
47
  this._getCurrentStatus = getCurrentStatus;
48
+ this._getDiagnostics = getDiagnostics;
36
49
  this._onUpdateStatus = onUpdateStatus;
37
50
  this._onReset = onReset;
38
51
  }
@@ -41,6 +54,25 @@ export class SystemServiceImpl implements SystemService {
41
54
  return this._config?.values ?? {};
42
55
  }
43
56
 
57
+ /**
58
+ * NOTE: Since this is serialized as a JSON object, we allow the option to serialize keys.
59
+ */
60
+ async getDiagnostics({ keys }: GetDiagnosticsRequest = {}) {
61
+ const diagnostics = await this._getDiagnostics();
62
+ return {
63
+ timestamp: new Date(),
64
+ diagnostics: JSON.parse(
65
+ JSON.stringify(
66
+ diagnostics,
67
+ jsonKeyReplacer({
68
+ truncate: keys === GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
69
+ humanize: keys === GetDiagnosticsRequest.KEY_OPTION.HUMANIZE,
70
+ }),
71
+ ),
72
+ ),
73
+ };
74
+ }
75
+
44
76
  async updateStatus({ status }: UpdateStatusRequest) {
45
77
  await this._onUpdateStatus(status);
46
78
  }
@@ -60,7 +60,7 @@ export const createPeers = async (numPeers: number) => {
60
60
  return await Promise.all(
61
61
  Array.from(Array(numPeers)).map(async () => {
62
62
  const peer = createServiceContext({ signalContext });
63
- await peer.open();
63
+ await peer.open(new Context());
64
64
  return peer;
65
65
  }),
66
66
  );
@@ -5,6 +5,7 @@
5
5
  import { Trigger } from '@dxos/async';
6
6
  import { PROXY_CONNECTION_TIMEOUT, ShellRuntime } from '@dxos/client-protocol';
7
7
  import { Config } from '@dxos/config';
8
+ import { Context } from '@dxos/context';
8
9
  import { log, logInfo } from '@dxos/log';
9
10
  import { MemorySignalManager, MemorySignalManagerContext, WebsocketSignalManager } from '@dxos/messaging';
10
11
  import { createWebRTCTransportFactory, TransportFactory } from '@dxos/network-manager';
@@ -108,7 +109,7 @@ export class IFrameHostRuntime {
108
109
  ...middleware,
109
110
  });
110
111
 
111
- await Promise.all([this._clientServices.open(), this._clientRpc.open(), this._shellRuntime?.open()]);
112
+ await Promise.all([this._clientServices.open(new Context()), this._clientRpc.open(), this._shellRuntime?.open()]);
112
113
  this._ready.wake(undefined);
113
114
  log('started');
114
115
  } catch (err: any) {
@@ -4,6 +4,7 @@
4
4
 
5
5
  import { Trigger } from '@dxos/async';
6
6
  import { Config } from '@dxos/config';
7
+ import { Context } from '@dxos/context';
7
8
  import { log } from '@dxos/log';
8
9
  import { MemorySignalManager, MemorySignalManagerContext, WebsocketSignalManager } from '@dxos/messaging';
9
10
  import { WebRTCTransportProxyFactory } from '@dxos/network-manager';
@@ -57,12 +58,12 @@ export class WorkerRuntime {
57
58
  transportFactory: this._transportFactory,
58
59
  });
59
60
 
60
- await this._clientServices.open();
61
+ await this._clientServices.open(new Context());
61
62
  this._ready.wake(undefined);
62
63
  log('started');
63
64
  } catch (err: any) {
64
65
  this._ready.wake(err);
65
- log.catch(err);
66
+ log.catch('starting', err);
66
67
  }
67
68
  }
68
69
 
@@ -73,6 +73,7 @@ export class WorkerSession {
73
73
  port: appPort,
74
74
  ...middleware,
75
75
  });
76
+
76
77
  this._shellClientRpc = new ClientRpcServer({
77
78
  serviceRegistry: this._serviceHost.serviceRegistry,
78
79
  port: shellPort,
@@ -102,7 +103,7 @@ export class WorkerSession {
102
103
  },
103
104
  },
104
105
  port: systemPort,
105
- timeout: 1000, // With low timeout heartbeat may fail if the tab's thread is saturated.
106
+ timeout: 1_000, // With low timeout heartbeat may fail if the tab's thread is saturated.
106
107
  });
107
108
 
108
109
  this.bridgeService = this._iframeRpc.rpc.BridgeService;
@@ -112,10 +113,14 @@ export class WorkerSession {
112
113
  log.info('opening...');
113
114
  await Promise.all([this._clientRpc.open(), this._iframeRpc.open(), this._maybeOpenShell()]);
114
115
 
116
+ // Wait until the worker's RPC service has started.
115
117
  await this._startTrigger.wait({ timeout: PROXY_CONNECTION_TIMEOUT });
118
+
119
+ // TODO(burdon): Comment required.
116
120
  if (this.lockKey) {
117
121
  void this._afterLockReleases(this.lockKey, () => this.close());
118
122
  }
123
+
119
124
  log.info('opened');
120
125
  }
121
126
 
package/src/version.ts ADDED
@@ -0,0 +1 @@
1
+ export const DXOS_VERSION = "0.1.56-main.0e9f69e";