@dxos/client-services 0.1.48 → 0.1.49-next.55d8a92

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.
@@ -1 +1 @@
1
- {"version":3,"file":"service-host.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/services/service-host.ts"],"names":[],"mappings":"AAOA,OAAO,EAAuB,cAAc,EAA6B,MAAM,uBAAuB,CAAC;AACvG,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAItC,OAAO,EAAE,aAAa,EAA0B,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAgD,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAGvG,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAYtD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,MAAM,MAAM,wBAAwB,GAAG;IACrC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAoB;IACnD,O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6B;IAgDhC,IAAI,MAAM,YAET;IAED,IAAI,eAAe,oCAElB;IAED,IAAI,WAAW,sDAEd;IAED,IAAI,QAAQ,4BAEX;IAED;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,EAAE,iBAAiB;IA6B9C,IAAI;IAyEJ,KAAK;IAeL,KAAK;CAUZ"}
@@ -4,7 +4,7 @@ import { FeedStore } from '@dxos/feed-store';
4
4
  import { Keyring } from '@dxos/keyring';
5
5
  import { MemorySignalManagerContext } from '@dxos/messaging';
6
6
  import { NetworkManager } from '@dxos/network-manager';
7
- import { Storage } from '@dxos/random-access-storage';
7
+ import { Storage, StorageType } from '@dxos/random-access-storage';
8
8
  import { ClientServicesHost, ServiceContext } from '../services';
9
9
  import { SigningContext } from '../spaces';
10
10
  export declare const createServiceHost: (config: Config, signalManagerContext: MemorySignalManagerContext) => ClientServicesHost;
@@ -17,8 +17,13 @@ export declare const createIdentity: (peer: ServiceContext) => Promise<ServiceCo
17
17
  export declare const syncItemsLocal: (db1: DataPipeline, db2: DataPipeline) => Promise<void>;
18
18
  export declare class TestBuilder {
19
19
  readonly signalContext: MemorySignalManagerContext;
20
- createPeer(): TestPeer;
20
+ private readonly _ctx;
21
+ createPeer(peerOptions?: TestPeerOpts): TestPeer;
22
+ destroy(): Promise<void>;
21
23
  }
24
+ export type TestPeerOpts = {
25
+ storageType?: StorageType;
26
+ };
22
27
  export type TestPeerProps = {
23
28
  storage?: Storage;
24
29
  feedStore?: FeedStore<any>;
@@ -30,8 +35,9 @@ export type TestPeerProps = {
30
35
  };
31
36
  export declare class TestPeer {
32
37
  private readonly signalContext;
38
+ private readonly opts;
33
39
  private _props;
34
- constructor(signalContext: MemorySignalManagerContext);
40
+ constructor(signalContext: MemorySignalManagerContext, opts?: TestPeerOpts);
35
41
  get storage(): Storage;
36
42
  get keyring(): Keyring;
37
43
  get feedStore(): FeedStore<any>;
@@ -39,6 +45,7 @@ export declare class TestPeer {
39
45
  get snapshotStore(): SnapshotStore;
40
46
  get networkManager(): NetworkManager;
41
47
  get spaceManager(): SpaceManager;
48
+ destroy(): Promise<void>;
42
49
  }
43
50
  export declare const createSigningContext: (keyring: Keyring) => Promise<SigningContext>;
44
51
  //# sourceMappingURL=test-builder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"test-builder.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/testing/test-builder.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAiB,MAAM,qBAAqB,CAAC;AAE9G,OAAO,EAAe,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAuB,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAClF,OAAO,EAA0B,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAiB,OAAO,EAAe,MAAM,6BAA6B,CAAC;AAElF,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAM3C,eAAO,MAAM,iBAAiB,WAAY,MAAM,wBAAwB,0BAA0B,uBAMjG,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;oBAehC,CAAC;AAEF,eAAO,MAAM,WAAW,aAAoB,MAAM,8BAUjD,CAAC;AAEF,eAAO,MAAM,cAAc,SAAgB,cAAc,4BAGxD,CAAC;AAIF,eAAO,MAAM,cAAc,QAAe,YAAY,OAAO,YAAY,kBAGxE,CAAC;AAEF,qBAAa,WAAW;IACtB,SAAgB,aAAa,6BAAoC;IAEjE,UAAU,IAAI,QAAQ;CAGvB;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,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O,KAAG,QAAQ,cAAc,CAgBnF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/client-services",
3
- "version": "0.1.48",
3
+ "version": "0.1.49-next.55d8a92",
4
4
  "description": "DXOS client services implementation",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -20,38 +20,38 @@
20
20
  "src"
21
21
  ],
22
22
  "dependencies": {
23
- "@dxos/async": "0.1.48",
24
- "@dxos/client-protocol": "0.1.48",
25
- "@dxos/codec-protobuf": "0.1.48",
26
- "@dxos/config": "0.1.48",
27
- "@dxos/context": "0.1.48",
28
- "@dxos/credentials": "0.1.48",
29
- "@dxos/crypto": "0.1.48",
30
- "@dxos/debug": "0.1.48",
31
- "@dxos/document-model": "0.1.48",
32
- "@dxos/echo-db": "0.1.48",
33
- "@dxos/echo-pipeline": "0.1.48",
34
- "@dxos/errors": "0.1.48",
35
- "@dxos/feed-store": "0.1.48",
36
- "@dxos/keyring": "0.1.48",
37
- "@dxos/keys": "0.1.48",
38
- "@dxos/log": "0.1.48",
39
- "@dxos/messaging": "0.1.48",
40
- "@dxos/model-factory": "0.1.48",
41
- "@dxos/network-manager": "0.1.48",
42
- "@dxos/node-std": "0.1.48",
43
- "@dxos/protocols": "0.1.48",
44
- "@dxos/random-access-storage": "0.1.48",
45
- "@dxos/rpc": "0.1.48",
46
- "@dxos/teleport": "0.1.48",
47
- "@dxos/teleport-extension-gossip": "0.1.48",
48
- "@dxos/text-model": "0.1.48",
49
- "@dxos/timeframe": "0.1.48",
50
- "@dxos/util": "0.1.48"
23
+ "@dxos/async": "0.1.49-next.55d8a92",
24
+ "@dxos/client-protocol": "0.1.49-next.55d8a92",
25
+ "@dxos/codec-protobuf": "0.1.49-next.55d8a92",
26
+ "@dxos/config": "0.1.49-next.55d8a92",
27
+ "@dxos/context": "0.1.49-next.55d8a92",
28
+ "@dxos/credentials": "0.1.49-next.55d8a92",
29
+ "@dxos/crypto": "0.1.49-next.55d8a92",
30
+ "@dxos/debug": "0.1.49-next.55d8a92",
31
+ "@dxos/document-model": "0.1.49-next.55d8a92",
32
+ "@dxos/echo-db": "0.1.49-next.55d8a92",
33
+ "@dxos/echo-pipeline": "0.1.49-next.55d8a92",
34
+ "@dxos/errors": "0.1.49-next.55d8a92",
35
+ "@dxos/feed-store": "0.1.49-next.55d8a92",
36
+ "@dxos/keyring": "0.1.49-next.55d8a92",
37
+ "@dxos/keys": "0.1.49-next.55d8a92",
38
+ "@dxos/log": "0.1.49-next.55d8a92",
39
+ "@dxos/messaging": "0.1.49-next.55d8a92",
40
+ "@dxos/model-factory": "0.1.49-next.55d8a92",
41
+ "@dxos/network-manager": "0.1.49-next.55d8a92",
42
+ "@dxos/node-std": "0.1.49-next.55d8a92",
43
+ "@dxos/protocols": "0.1.49-next.55d8a92",
44
+ "@dxos/random-access-storage": "0.1.49-next.55d8a92",
45
+ "@dxos/rpc": "0.1.49-next.55d8a92",
46
+ "@dxos/teleport": "0.1.49-next.55d8a92",
47
+ "@dxos/teleport-extension-gossip": "0.1.49-next.55d8a92",
48
+ "@dxos/text-model": "0.1.49-next.55d8a92",
49
+ "@dxos/timeframe": "0.1.49-next.55d8a92",
50
+ "@dxos/util": "0.1.49-next.55d8a92"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/readable-stream": "^2.3.9",
54
- "@dxos/signal": "0.1.48"
54
+ "@dxos/signal": "0.1.49-next.55d8a92"
55
55
  },
56
56
  "publishConfig": {
57
57
  "access": "public"
@@ -39,7 +39,7 @@ export const subscribeToFeeds = (
39
39
  feeds: Array.from(feedMap.values()).map((feed) => ({
40
40
  feedKey: feed.key,
41
41
  length: feed.properties.length,
42
- diskUsage: feed.core.byteLength,
42
+ bytes: feed.core.byteLength,
43
43
  })),
44
44
  });
45
45
  };
@@ -182,6 +182,7 @@ export class ClientServicesHost {
182
182
  if (this._open) {
183
183
  return;
184
184
  }
185
+
185
186
  const traceId = PublicKey.random().toHex();
186
187
  log.trace('dxos.sdk.client-services-host.open', trace.begin({ id: traceId }));
187
188
 
@@ -3,13 +3,17 @@
3
3
  //
4
4
 
5
5
  import { expect } from 'chai';
6
+ import path from 'node:path';
6
7
 
7
8
  import { latch } from '@dxos/async';
8
9
  import { createAdmissionCredentials } from '@dxos/credentials';
9
10
  import { AuthStatus, DataServiceSubscriptions } from '@dxos/echo-pipeline';
11
+ import { testLocalDatabase } from '@dxos/echo-pipeline/testing';
10
12
  import { writeMessages } from '@dxos/feed-store';
11
13
  import { log } from '@dxos/log';
14
+ import { StorageType } from '@dxos/random-access-storage';
12
15
  import { afterTest, describe, test } from '@dxos/test';
16
+ import { range } from '@dxos/util';
13
17
 
14
18
  import { createSigningContext, TestBuilder, syncItemsLocal } from '../testing';
15
19
  import { DataSpaceManager } from './data-space-manager';
@@ -191,4 +195,43 @@ describe('DataSpaceManager', () => {
191
195
  await space1.postMessage('test', { '@type': 'google.protobuf.Any', test: true });
192
196
  await receivedMessage();
193
197
  });
198
+
199
+ describe('Epochs', () => {
200
+ test('Epoch truncates feeds', async () => {
201
+ const builder = new TestBuilder();
202
+ afterTest(async () => builder.destroy());
203
+
204
+ const peer = builder.createPeer({
205
+ storageType: typeof window === 'undefined' ? StorageType.NODE : StorageType.WEBFS,
206
+ });
207
+ const identity = await createSigningContext(peer.keyring);
208
+ const dataSpaceManager = new DataSpaceManager(
209
+ peer.spaceManager,
210
+ peer.metadataStore,
211
+ new DataServiceSubscriptions(),
212
+ peer.keyring,
213
+ identity,
214
+ peer.feedStore,
215
+ );
216
+ await dataSpaceManager.open();
217
+ afterTest(() => dataSpaceManager.close());
218
+ const space = await dataSpaceManager.createSpace();
219
+ await space.inner.controlPipeline.state.waitUntilTimeframe(space.inner.controlPipeline.state.endTimeframe);
220
+
221
+ const feedDataPath = path.join(space.inner.dataPipeline.pipelineState!.feeds[0].key.toHex(), 'data');
222
+ const directory = peer.storage.createDirectory('feeds');
223
+ const file = directory.getOrCreateFile(feedDataPath);
224
+ afterTest(() => file.close());
225
+
226
+ expect((await file.stat()).size === 0).to.be.true;
227
+
228
+ for (const _ in range(10)) {
229
+ await testLocalDatabase(space.dataPipeline);
230
+ }
231
+
232
+ expect((await file.stat()).size !== 0).to.be.true;
233
+ await space.createEpoch();
234
+ expect((await file.stat()).size === 0).to.be.true;
235
+ }).onlyEnvironments('nodejs', 'chromium', 'firefox');
236
+ });
194
237
  });
@@ -4,6 +4,7 @@
4
4
 
5
5
  import { createDefaultModelFactory } from '@dxos/client-protocol';
6
6
  import { Config } from '@dxos/config';
7
+ import { Context } from '@dxos/context';
7
8
  import { createCredentialSignerWithChain, CredentialGenerator } from '@dxos/credentials';
8
9
  import { SnapshotStore, DataPipeline, MetadataStore, SpaceManager, valueEncoding } from '@dxos/echo-pipeline';
9
10
  import { testLocalDatabase } from '@dxos/echo-pipeline/testing';
@@ -71,12 +72,23 @@ export const syncItemsLocal = async (db1: DataPipeline, db2: DataPipeline) => {
71
72
 
72
73
  export class TestBuilder {
73
74
  public readonly signalContext = new MemorySignalManagerContext();
75
+ private readonly _ctx = new Context();
74
76
 
75
- createPeer(): TestPeer {
76
- return new TestPeer(this.signalContext);
77
+ createPeer(peerOptions?: TestPeerOpts): TestPeer {
78
+ const peer = new TestPeer(this.signalContext, peerOptions);
79
+ this._ctx.onDispose(async () => peer.destroy());
80
+ return peer;
81
+ }
82
+
83
+ async destroy() {
84
+ await this._ctx.dispose();
77
85
  }
78
86
  }
79
87
 
88
+ export type TestPeerOpts = {
89
+ storageType?: StorageType;
90
+ };
91
+
80
92
  export type TestPeerProps = {
81
93
  storage?: Storage;
82
94
  feedStore?: FeedStore<any>;
@@ -90,10 +102,13 @@ export type TestPeerProps = {
90
102
  export class TestPeer {
91
103
  private _props: TestPeerProps = {};
92
104
 
93
- constructor(private readonly signalContext: MemorySignalManagerContext) {}
105
+ constructor(
106
+ private readonly signalContext: MemorySignalManagerContext,
107
+ private readonly opts: TestPeerOpts = { storageType: StorageType.RAM },
108
+ ) {}
94
109
 
95
110
  get storage() {
96
- return (this._props.storage ??= createStorage({ type: StorageType.RAM }));
111
+ return (this._props.storage ??= createStorage({ type: this.opts.storageType }));
97
112
  }
98
113
 
99
114
  get keyring() {
@@ -136,6 +151,10 @@ export class TestPeer {
136
151
  snapshotStore: this.snapshotStore,
137
152
  }));
138
153
  }
154
+
155
+ async destroy() {
156
+ await this.storage.reset();
157
+ }
139
158
  }
140
159
 
141
160
  export const createSigningContext = async (keyring: Keyring): Promise<SigningContext> => {