@dxos/echo-db 2.33.4-dev.a837734c → 2.33.4

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 (57) hide show
  1. package/dist/src/echo.d.ts +4 -12
  2. package/dist/src/echo.d.ts.map +1 -1
  3. package/dist/src/echo.js +5 -5
  4. package/dist/src/echo.js.map +1 -1
  5. package/dist/src/halo/halo.test.js +4 -4
  6. package/dist/src/halo/halo.test.js.map +1 -1
  7. package/dist/src/index.d.ts +0 -1
  8. package/dist/src/index.d.ts.map +1 -1
  9. package/dist/src/index.js +0 -1
  10. package/dist/src/index.js.map +1 -1
  11. package/dist/src/parties/data-party.test.js +3 -4
  12. package/dist/src/parties/data-party.test.js.map +1 -1
  13. package/dist/src/parties/party-manager.test.js +5 -6
  14. package/dist/src/parties/party-manager.test.js.map +1 -1
  15. package/dist/src/pipeline/message-selector.d.ts.map +1 -1
  16. package/dist/src/pipeline/message-selector.js +0 -10
  17. package/dist/src/pipeline/message-selector.js.map +1 -1
  18. package/dist/src/pipeline/metadata-store.d.ts +2 -2
  19. package/dist/src/pipeline/metadata-store.d.ts.map +1 -1
  20. package/dist/src/pipeline/metadata-store.js.map +1 -1
  21. package/dist/src/pipeline/metadata-store.test.js +5 -5
  22. package/dist/src/pipeline/metadata-store.test.js.map +1 -1
  23. package/dist/src/pipeline/party-core.test.js +6 -33
  24. package/dist/src/pipeline/party-core.test.js.map +1 -1
  25. package/dist/src/snapshots/snapshot-store.d.ts +2 -2
  26. package/dist/src/snapshots/snapshot-store.d.ts.map +1 -1
  27. package/dist/src/snapshots/snapshot-store.js.map +1 -1
  28. package/dist/src/snapshots/snapshot-store.test.js +2 -2
  29. package/dist/src/snapshots/snapshot-store.test.js.map +1 -1
  30. package/dist/src/testing/testing.d.ts +3 -4
  31. package/dist/src/testing/testing.d.ts.map +1 -1
  32. package/dist/src/testing/testing.js +3 -4
  33. package/dist/src/testing/testing.js.map +1 -1
  34. package/dist/tsconfig.tsbuildinfo +1 -1
  35. package/package.json +20 -20
  36. package/src/echo.ts +8 -20
  37. package/src/halo/halo.test.ts +4 -4
  38. package/src/index.ts +0 -1
  39. package/src/parties/data-party.test.ts +3 -4
  40. package/src/parties/party-manager.test.ts +5 -6
  41. package/src/pipeline/message-selector.ts +1 -10
  42. package/src/pipeline/metadata-store.test.ts +5 -5
  43. package/src/pipeline/metadata-store.ts +2 -2
  44. package/src/pipeline/party-core.test.ts +6 -44
  45. package/src/snapshots/snapshot-store.test.ts +2 -2
  46. package/src/snapshots/snapshot-store.ts +2 -2
  47. package/src/testing/testing.ts +4 -8
  48. package/dist/src/util/index.d.ts +0 -2
  49. package/dist/src/util/index.d.ts.map +0 -1
  50. package/dist/src/util/index.js +0 -17
  51. package/dist/src/util/index.js.map +0 -1
  52. package/dist/src/util/persistant-ram-storage.d.ts +0 -6
  53. package/dist/src/util/persistant-ram-storage.d.ts.map +0 -1
  54. package/dist/src/util/persistant-ram-storage.js +0 -32
  55. package/dist/src/util/persistant-ram-storage.js.map +0 -1
  56. package/src/util/index.ts +0 -5
  57. package/src/util/persistant-ram-storage.ts +0 -33
package/src/echo.ts CHANGED
@@ -15,7 +15,7 @@ import { FeedStore } from '@dxos/feed-store';
15
15
  import { ModelFactory } from '@dxos/model-factory';
16
16
  import { NetworkManager, NetworkManagerOptions } from '@dxos/network-manager';
17
17
  import { ObjectModel } from '@dxos/object-model';
18
- import { IStorage } from '@dxos/random-access-multi-storage';
18
+ import { Storage, createStorage, StorageType } from '@dxos/random-access-multi-storage';
19
19
  import { SubscriptionGroup } from '@dxos/util';
20
20
 
21
21
  import { ResultSet } from './api';
@@ -27,7 +27,6 @@ import { InvitationDescriptor, OfflineInvitationClaimer } from './invitations';
27
27
  import { OpenProgress, PartyFactory, DataParty, PartyManager } from './parties';
28
28
  import { MetadataStore, STORAGE_VERSION, PartyFeedProvider } from './pipeline';
29
29
  import { SnapshotStore } from './snapshots';
30
- import { createRamStorage } from './util';
31
30
 
32
31
  const log = debug('dxos:echo');
33
32
  const error = log.extend('error');
@@ -39,26 +38,17 @@ export interface PartyFilter { }
39
38
  * Various options passed to `ECHO.create`.
40
39
  */
41
40
  export interface EchoCreationOptions {
41
+
42
42
  /**
43
- * Storage used for feeds. Defaults to in-memory.
43
+ * Storage to persist data. Defaults to in-memory.
44
44
  */
45
- feedStorage?: IStorage
45
+ storage?: Storage
46
46
 
47
47
  /**
48
48
  * Storage used for keys. Defaults to in-memory.
49
49
  */
50
50
  keyStorage?: any
51
51
 
52
- /**
53
- * Storage used for snapshots. Defaults to in-memory.
54
- */
55
- snapshotStorage?: IStorage
56
-
57
- /**
58
- * Storage used for snapshots. Defaults to in-memory.
59
- */
60
- metadataStorage?: IStorage
61
-
62
52
  /**
63
53
  * Networking provider. Defaults to in-memory networking.
64
54
  */
@@ -113,9 +103,7 @@ export class ECHO {
113
103
  // TODO(burdon): Factor out config an define type.
114
104
  constructor ({
115
105
  keyStorage = memdown(),
116
- feedStorage = createRamStorage(),
117
- snapshotStorage = createRamStorage(),
118
- metadataStorage = createRamStorage(),
106
+ storage = createStorage('', StorageType.RAM),
119
107
  networkManagerOptions,
120
108
  /// TODO(burdon): See options below.
121
109
  snapshots = true,
@@ -127,10 +115,10 @@ export class ECHO {
127
115
  .registerModel(ObjectModel);
128
116
 
129
117
  this._networkManager = new NetworkManager(networkManagerOptions);
130
- this._snapshotStore = new SnapshotStore(snapshotStorage);
131
- this._metadataStore = new MetadataStore(metadataStorage);
118
+ this._snapshotStore = new SnapshotStore(storage.subDir('snapshots'));
119
+ this._metadataStore = new MetadataStore(storage.subDir('metadata'));
132
120
  this._keyring = new Keyring(new KeyStore(keyStorage));
133
- this._feedStore = new FeedStore(feedStorage, { valueEncoding: codec });
121
+ this._feedStore = new FeedStore(storage.subDir('feeds'), { valueEncoding: codec });
134
122
 
135
123
  const feedProviderFactory = (partyKey: PublicKey) => new PartyFeedProvider(
136
124
  this._metadataStore,
@@ -12,12 +12,12 @@ import { FeedStore } from '@dxos/feed-store';
12
12
  import { ModelFactory } from '@dxos/model-factory';
13
13
  import { NetworkManager } from '@dxos/network-manager';
14
14
  import { ObjectModel } from '@dxos/object-model';
15
+ import { createStorage, StorageType } from '@dxos/random-access-multi-storage';
15
16
  import { afterTest, testTimeout } from '@dxos/testutils';
16
17
 
17
18
  import { defaultInvitationAuthenticator } from '../invitations';
18
19
  import { MetadataStore, PartyFeedProvider } from '../pipeline';
19
20
  import { SnapshotStore } from '../snapshots';
20
- import { createRamStorage } from '../util';
21
21
  import { HALO } from './halo';
22
22
 
23
23
  describe('HALO', () => {
@@ -26,10 +26,10 @@ describe('HALO', () => {
26
26
  .registerModel(ObjectModel);
27
27
 
28
28
  const networkManager = new NetworkManager();
29
- const snapshotStore = new SnapshotStore(createRamStorage());
30
- const metadataStore = new MetadataStore(createRamStorage());
29
+ const snapshotStore = new SnapshotStore(createStorage('snapshots', StorageType.RAM));
30
+ const metadataStore = new MetadataStore(createStorage('metadata', StorageType.RAM));
31
31
  const keyring = new Keyring();
32
- const feedStore = new FeedStore(createRamStorage(), { valueEncoding: codec });
32
+ const feedStore = new FeedStore(createStorage('feed', StorageType.RAM), { valueEncoding: codec });
33
33
 
34
34
  const feedProviderFactory = (partyKey: PublicKey) => new PartyFeedProvider(
35
35
  metadataStore,
package/src/index.ts CHANGED
@@ -15,4 +15,3 @@ export * from './parties';
15
15
  export * from './pipeline';
16
16
  export * from './snapshots';
17
17
  export * from './testing';
18
- export * from './util';
@@ -19,14 +19,13 @@ import { MetadataStore, PartyFeedProvider } from '../pipeline';
19
19
  import { createAuthenticator, createCredentialsProvider } from '../protocol';
20
20
  import { createTestIdentityCredentials, deriveTestDeviceCredentials, IdentityCredentials } from '../protocol/identity-credentials';
21
21
  import { SnapshotStore } from '../snapshots';
22
- import { createRamStorage } from '../util';
23
22
  import { DataParty } from './data-party';
24
23
 
25
24
  describe('DataParty', () => {
26
25
  const createParty = async (identity: IdentityCredentials, partyKey: PublicKey, hints: KeyHint[]) => {
27
- const metadataStore = new MetadataStore(createRamStorage());
28
- const feedStore = new FeedStore(createStorage('', StorageType.RAM), { valueEncoding: codec });
29
- const snapshotStore = new SnapshotStore(createStorage('', StorageType.RAM));
26
+ const metadataStore = new MetadataStore(createStorage('metadata', StorageType.RAM));
27
+ const feedStore = new FeedStore(createStorage('feed', StorageType.RAM), { valueEncoding: codec });
28
+ const snapshotStore = new SnapshotStore(createStorage('snapshots', StorageType.RAM));
30
29
  const modelFactory = new ModelFactory().registerModel(ObjectModel);
31
30
  const networkManager = new NetworkManager();
32
31
  const partyFeedProvider = new PartyFeedProvider(metadataStore, identity.keyring, feedStore, partyKey);
@@ -38,7 +38,6 @@ import { MetadataStore, PartyFeedProvider } from '../pipeline';
38
38
  import { createTestIdentityCredentials } from '../protocol/identity-credentials';
39
39
  import { SnapshotStore } from '../snapshots';
40
40
  import { messageLogger } from '../testing';
41
- import { createRamStorage } from '../util';
42
41
  import { PARTY_ITEM_TYPE } from './data-party';
43
42
  import { PartyFactory } from './party-factory';
44
43
  import { PartyManager } from './party-manager';
@@ -56,9 +55,9 @@ const log = debug('dxos:echo:parties:party-manager:test');
56
55
  */
57
56
  const setup = async () => {
58
57
  const keyring = new Keyring();
59
- const metadataStore = new MetadataStore(createRamStorage());
60
- const feedStore = new FeedStore(createStorage('', StorageType.RAM), { valueEncoding: codec });
61
- const snapshotStore = new SnapshotStore(createStorage('', StorageType.RAM));
58
+ const metadataStore = new MetadataStore(createStorage('metadata', StorageType.RAM));
59
+ const feedStore = new FeedStore(createStorage('feed', StorageType.RAM), { valueEncoding: codec });
60
+ const snapshotStore = new SnapshotStore(createStorage('snapshots', StorageType.RAM));
62
61
  const modelFactory = new ModelFactory().registerModel(ObjectModel);
63
62
  const networkManager = new NetworkManager();
64
63
  const feedProviderFactory = (partyKey: PublicKey) => new PartyFeedProvider(metadataStore, keyring, feedStore, partyKey);
@@ -151,9 +150,9 @@ describe('Party manager', () => {
151
150
  const storage = createStorage('', StorageType.RAM);
152
151
  const feedStore = new FeedStore(storage, { valueEncoding: codec });
153
152
  const keyring = new Keyring();
154
- const metadataStore = new MetadataStore(createRamStorage());
153
+ const metadataStore = new MetadataStore(createStorage('metadata', StorageType.RAM));
155
154
  const modelFactory = new ModelFactory().registerModel(ObjectModel);
156
- const snapshotStore = new SnapshotStore(createStorage('', StorageType.RAM));
155
+ const snapshotStore = new SnapshotStore(createStorage('snapshots', StorageType.RAM));
157
156
  const networkManager = new NetworkManager();
158
157
  const feedProviderFactory = (partyKey: PublicKey) => new PartyFeedProvider(metadataStore, keyring, feedStore, partyKey);
159
158
 
@@ -5,7 +5,7 @@
5
5
  import assert from 'assert';
6
6
  import debug from 'debug';
7
7
 
8
- import { Keyring, getPartyCredentialMessageType, PartyCredential, admitsKeys } from '@dxos/credentials';
8
+ import { getPartyCredentialMessageType, PartyCredential } from '@dxos/credentials';
9
9
  import { PublicKey } from '@dxos/crypto';
10
10
  import { MessageSelector } from '@dxos/echo-protocol';
11
11
 
@@ -60,15 +60,6 @@ export function createMessageSelector (
60
60
  if (getPartyCredentialMessageType(halo) === PartyCredential.Type.PARTY_GENESIS) {
61
61
  return i;
62
62
  }
63
- } else if (getPartyCredentialMessageType(halo) === PartyCredential.Type.FEED_ADMIT) {
64
- if (admitsKeys(halo).find(key => key.equals(feedKey))) {
65
- // TODO(marik-d): Calling `Keyring.signingKeys` is expensive. Is there any way to optimize/cache this?
66
- for (const signedBy of Keyring.signingKeys(halo)) {
67
- if (partyProcessor.isMemberKey(signedBy) || signedBy.equals(partyProcessor.partyKey)) {
68
- return i;
69
- }
70
- }
71
- }
72
63
  }
73
64
  }
74
65
 
@@ -5,13 +5,13 @@
5
5
  import expect from 'expect';
6
6
 
7
7
  import { PublicKey } from '@dxos/crypto';
8
+ import { createStorage, StorageType } from '@dxos/random-access-multi-storage';
8
9
 
9
- import { createRamStorage } from '../util';
10
10
  import { MetadataStore } from './metadata-store';
11
11
 
12
12
  describe('MetadataStore in-memory', () => {
13
13
  it('Creates party and adds feeds to it', async () => {
14
- const store = new MetadataStore(createRamStorage());
14
+ const store = new MetadataStore(createStorage('metadata', StorageType.RAM));
15
15
  await store.load();
16
16
  expect(store.parties?.length).toBe(0);
17
17
 
@@ -33,7 +33,7 @@ describe('MetadataStore in-memory', () => {
33
33
  });
34
34
 
35
35
  it('Creates party when adding feed', async () => {
36
- const store = new MetadataStore(createRamStorage());
36
+ const store = new MetadataStore(createStorage('metadata', StorageType.RAM));
37
37
  await store.load();
38
38
 
39
39
  const partyKey = PublicKey.random();
@@ -45,7 +45,7 @@ describe('MetadataStore in-memory', () => {
45
45
  });
46
46
 
47
47
  it('Doesn\'t add same feed twice', async () => {
48
- const store = new MetadataStore(createRamStorage());
48
+ const store = new MetadataStore(createStorage('metadata', StorageType.RAM));
49
49
  await store.load();
50
50
 
51
51
  const partyKey = PublicKey.random();
@@ -60,7 +60,7 @@ describe('MetadataStore in-memory', () => {
60
60
 
61
61
  // TODO(yivlad): Doesn't work for now.
62
62
  it.skip('Resets storage', async () => {
63
- const store = new MetadataStore(createRamStorage());
63
+ const store = new MetadataStore(createStorage('snapshots', StorageType.RAM));
64
64
 
65
65
  const partyKey = PublicKey.random();
66
66
  const feedKey = PublicKey.random();
@@ -8,7 +8,7 @@ import debug from 'debug';
8
8
  import { PublicKey } from '@dxos/crypto';
9
9
  import { failUndefined } from '@dxos/debug';
10
10
  import { EchoMetadata, PartyMetadata, schema } from '@dxos/echo-protocol';
11
- import { IStorage } from '@dxos/random-access-multi-storage';
11
+ import { Storage } from '@dxos/random-access-multi-storage';
12
12
 
13
13
  /**
14
14
  * Version for the schema of the stored data as defined in dxos.echo.metadata.EchoMetadata.
@@ -28,7 +28,7 @@ export class MetadataStore {
28
28
  };
29
29
 
30
30
  constructor (
31
- private readonly _storage: IStorage
31
+ private readonly _storage: Storage
32
32
  ) {}
33
33
 
34
34
  get version (): number {
@@ -18,7 +18,6 @@ import { afterTest } from '@dxos/testutils';
18
18
 
19
19
  import { MetadataStore, PartyFeedProvider, ReplicatorProtocolPluginFactory } from '../pipeline';
20
20
  import { SnapshotStore } from '../snapshots';
21
- import { createRamStorage } from '../util';
22
21
  import { PartyCore } from './party-core';
23
22
 
24
23
  describe('PartyCore', () => {
@@ -29,10 +28,10 @@ describe('PartyCore', () => {
29
28
 
30
29
  const keyring = new Keyring();
31
30
 
32
- const metadataStore = new MetadataStore(createRamStorage());
31
+ const metadataStore = new MetadataStore(createStorage('metadata', StorageType.RAM));
33
32
 
34
33
  const modelFactory = new ModelFactory().registerModel(ObjectModel);
35
- const snapshotStore = new SnapshotStore(createStorage('', StorageType.RAM));
34
+ const snapshotStore = new SnapshotStore(createStorage('snapshots', StorageType.RAM));
36
35
 
37
36
  const partyKey = await keyring.createKeyRecord({ type: KeyType.PARTY });
38
37
 
@@ -137,10 +136,10 @@ describe('PartyCore', () => {
137
136
 
138
137
  const keyring = new Keyring();
139
138
 
140
- const metadataStore = new MetadataStore(createRamStorage());
139
+ const metadataStore = new MetadataStore(createStorage('metadata', StorageType.RAM));
141
140
 
142
141
  const modelFactory = new ModelFactory().registerModel(ObjectModel);
143
- const snapshotStore = new SnapshotStore(createStorage('', StorageType.RAM));
142
+ const snapshotStore = new SnapshotStore(createStorage('snapshots', StorageType.RAM));
144
143
 
145
144
  const partyKey = await keyring.createKeyRecord({ type: KeyType.PARTY });
146
145
 
@@ -249,43 +248,6 @@ describe('PartyCore', () => {
249
248
  await promiseTimeout(party.database.waitForItem({ id: itemId }), 1000, new Error('timeout'));
250
249
  });
251
250
 
252
- test('self-admitting feed with a hint', async () => {
253
- const { party, keyring, partyKey, feedStore } = await setup();
254
- await party.open();
255
-
256
- const feedKey = await keyring.createKeyRecord({ type: KeyType.FEED });
257
- const fullKey = keyring.getFullKey(feedKey.publicKey);
258
- const feed2 = await feedStore.openReadWriteFeed(fullKey!.publicKey, fullKey!.secretKey!);
259
-
260
- await party.processor.takeHints([{
261
- type: KeyType.FEED,
262
- publicKey: feedKey.publicKey
263
- }]);
264
-
265
- await feed2.append({
266
- halo: createFeedAdmitMessage(
267
- keyring,
268
- party.key,
269
- feedKey.publicKey,
270
- [partyKey]
271
- )
272
- });
273
-
274
- const itemId = createId();
275
- await feed2.append({
276
- echo: {
277
- itemId,
278
- genesis: {
279
- itemType: 'dxos:example',
280
- modelType: ObjectModel.meta.type
281
- },
282
- timeframe: new Timeframe()
283
- }
284
- });
285
-
286
- await promiseTimeout(party.database.waitForItem({ id: itemId }), 1000, new Error('timeout'));
287
- });
288
-
289
251
  test('two instances replicating', async () => {
290
252
  const peer1 = await setup();
291
253
 
@@ -293,10 +255,10 @@ describe('PartyCore', () => {
293
255
  const feedStore = new FeedStore(storage, { valueEncoding: codec });
294
256
  afterTest(async () => feedStore.close());
295
257
 
296
- const metadataStore = new MetadataStore(createRamStorage());
258
+ const metadataStore = new MetadataStore(createStorage('metadata', StorageType.RAM));
297
259
 
298
260
  const modelFactory = new ModelFactory().registerModel(ObjectModel);
299
- const snapshotStore = new SnapshotStore(createStorage('', StorageType.RAM));
261
+ const snapshotStore = new SnapshotStore(createStorage('snapshots', StorageType.RAM));
300
262
 
301
263
  const partyFeedProvider = new PartyFeedProvider(metadataStore, peer1.keyring, feedStore, peer1.party.key);
302
264
 
@@ -7,15 +7,15 @@ import { it as test } from 'mocha';
7
7
 
8
8
  import { createId, createKeyPair, PublicKey } from '@dxos/crypto';
9
9
  import { PartySnapshot } from '@dxos/echo-protocol';
10
+ import { createStorage, StorageType } from '@dxos/random-access-multi-storage';
10
11
 
11
- import { createRamStorage } from '../util';
12
12
  import { SnapshotStore } from './snapshot-store';
13
13
 
14
14
  const createPublicKey = () => PublicKey.from(createKeyPair().publicKey);
15
15
 
16
16
  describe('SnapshotStore', () => {
17
17
  test('in-memory', async () => {
18
- const store = new SnapshotStore(createRamStorage());
18
+ const store = new SnapshotStore(createStorage('snapshots', StorageType.RAM));
19
19
 
20
20
  const key1 = createPublicKey();
21
21
  const key2 = createPublicKey();
@@ -7,7 +7,7 @@ import debug from 'debug';
7
7
 
8
8
  import { keyToString } from '@dxos/crypto';
9
9
  import { schema, PartyKey, PartySnapshot } from '@dxos/echo-protocol';
10
- import { IStorage } from '@dxos/random-access-multi-storage';
10
+ import { Storage } from '@dxos/random-access-multi-storage';
11
11
 
12
12
  const log = debug('dxos:snapshot-store');
13
13
 
@@ -18,7 +18,7 @@ const log = debug('dxos:snapshot-store');
18
18
  */
19
19
  export class SnapshotStore {
20
20
  constructor (
21
- private readonly _storage: IStorage
21
+ private readonly _storage: Storage
22
22
  ) {}
23
23
 
24
24
  async load (partyKey: PartyKey): Promise<PartySnapshot | undefined> {
@@ -5,12 +5,11 @@
5
5
  import debug from 'debug';
6
6
 
7
7
  import { NetworkManagerOptions } from '@dxos/network-manager';
8
- import { IStorage } from '@dxos/random-access-multi-storage';
8
+ import { Storage, createStorage, StorageType } from '@dxos/random-access-multi-storage';
9
9
  import { jsonReplacer } from '@dxos/util';
10
10
 
11
11
  import { ECHO } from '../echo';
12
12
  import { DataParty } from '../parties';
13
- import { createRamStorage } from '../util';
14
13
 
15
14
  export const log = debug('dxos:echo-db:testing');
16
15
 
@@ -21,13 +20,12 @@ export const messageLogger = (tag: string) => (message: any) => {
21
20
  export interface TestOptions {
22
21
  verboseLogging?: boolean
23
22
  initialize?: boolean
24
- storage?: any
23
+ storage?: Storage
25
24
  keyStorage?: any
26
25
  networkManagerOptions?: NetworkManagerOptions
27
26
  // TODO(burdon): Group properties by hierarchical object.
28
27
  snapshots?: boolean
29
28
  snapshotInterval?: number
30
- snapshotStorage?: IStorage
31
29
  }
32
30
 
33
31
  /**
@@ -36,17 +34,15 @@ export interface TestOptions {
36
34
  export const createTestInstance = async ({
37
35
  verboseLogging = false,
38
36
  initialize = false,
39
- storage = createRamStorage(),
37
+ storage = createStorage('', StorageType.RAM),
40
38
  keyStorage = undefined,
41
39
  networkManagerOptions,
42
- snapshotStorage = createRamStorage(),
43
40
  snapshots = true,
44
41
  snapshotInterval
45
42
  }: TestOptions = {}) => {
46
43
  const echo = new ECHO({
47
- feedStorage: storage,
44
+ storage,
48
45
  keyStorage,
49
- snapshotStorage,
50
46
  snapshotInterval,
51
47
  snapshots,
52
48
  networkManagerOptions,
@@ -1,2 +0,0 @@
1
- export * from './persistant-ram-storage';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/util/index.ts"],"names":[],"mappings":"AAIA,cAAc,0BAA0B,CAAC"}
@@ -1,17 +0,0 @@
1
- "use strict";
2
- //
3
- // Copyright 2020 DXOS.org
4
- //
5
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
8
- }) : (function(o, m, k, k2) {
9
- if (k2 === undefined) k2 = k;
10
- o[k2] = m[k];
11
- }));
12
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
13
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
14
- };
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- __exportStar(require("./persistant-ram-storage"), exports);
17
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/util/index.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;;;;;;;;;;AAEF,2DAAyC"}
@@ -1,6 +0,0 @@
1
- import { IStorage } from '@dxos/random-access-multi-storage';
2
- /**
3
- * A wrapper around RAM storage that preserves file data when closing and re-opening files.
4
- */
5
- export declare function createRamStorage(): IStorage;
6
- //# sourceMappingURL=persistant-ram-storage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"persistant-ram-storage.d.ts","sourceRoot":"","sources":["../../../src/util/persistant-ram-storage.ts"],"names":[],"mappings":"AAIA,OAAO,EAAoC,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAE/F;;GAEG;AAEH,wBAAgB,gBAAgB,IAAK,QAAQ,CAsB5C"}
@@ -1,32 +0,0 @@
1
- "use strict";
2
- //
3
- // Copyright 2020 DXOS.org
4
- //
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createRamStorage = void 0;
7
- const random_access_multi_storage_1 = require("@dxos/random-access-multi-storage");
8
- /**
9
- * A wrapper around RAM storage that preserves file data when closing and re-opening files.
10
- */
11
- // TODO(burdon): Factor out?
12
- function createRamStorage() {
13
- const root = 'snapshots';
14
- const storage = (0, random_access_multi_storage_1.createStorage)(root, random_access_multi_storage_1.StorageType.RAM);
15
- const files = new Map();
16
- const fn = {};
17
- fn.createOrOpen = (name) => {
18
- if (files.has(name)) {
19
- return files.get(name);
20
- }
21
- const file = storage.createOrOpen(name);
22
- file.close = (cb) => cb === null || cb === void 0 ? void 0 : cb(null); // Fix.
23
- files.set(name, file);
24
- return file;
25
- };
26
- fn.root = root;
27
- fn.type = storage.type;
28
- fn.destroy = storage.destroy.bind(storage);
29
- return fn;
30
- }
31
- exports.createRamStorage = createRamStorage;
32
- //# sourceMappingURL=persistant-ram-storage.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"persistant-ram-storage.js","sourceRoot":"","sources":["../../../src/util/persistant-ram-storage.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;AAEF,mFAA+F;AAE/F;;GAEG;AACH,4BAA4B;AAC5B,SAAgB,gBAAgB;IAC9B,MAAM,IAAI,GAAG,WAAW,CAAC;IACzB,MAAM,OAAO,GAAG,IAAA,2CAAa,EAAC,IAAI,EAAE,yCAAW,CAAC,GAAG,CAAC,CAAC;IACrD,MAAM,KAAK,GAAG,IAAI,GAAG,EAAgB,CAAC;IAEtC,MAAM,EAAE,GAAQ,EAAE,CAAC;IAEnB,EAAE,CAAC,YAAY,GAAG,CAAC,IAAY,EAAE,EAAE;QACjC,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YACnB,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC;SACzB;QACD,MAAM,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QACxC,IAAI,CAAC,KAAK,GAAG,CAAC,EAAO,EAAE,EAAE,CAAC,EAAE,aAAF,EAAE,uBAAF,EAAE,CAAG,IAAI,CAAC,CAAC,CAAC,OAAO;QAC7C,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IAEF,EAAE,CAAC,IAAI,GAAG,IAAI,CAAC;IACf,EAAE,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IACvB,EAAE,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAE3C,OAAO,EAAE,CAAC;AACZ,CAAC;AAtBD,4CAsBC"}
package/src/util/index.ts DELETED
@@ -1,5 +0,0 @@
1
- //
2
- // Copyright 2020 DXOS.org
3
- //
4
-
5
- export * from './persistant-ram-storage';
@@ -1,33 +0,0 @@
1
- //
2
- // Copyright 2020 DXOS.org
3
- //
4
-
5
- import { StorageType, createStorage, File, IStorage } from '@dxos/random-access-multi-storage';
6
-
7
- /**
8
- * A wrapper around RAM storage that preserves file data when closing and re-opening files.
9
- */
10
- // TODO(burdon): Factor out?
11
- export function createRamStorage (): IStorage {
12
- const root = 'snapshots';
13
- const storage = createStorage(root, StorageType.RAM);
14
- const files = new Map<string, File>();
15
-
16
- const fn: any = {};
17
-
18
- fn.createOrOpen = (name: string) => {
19
- if (files.has(name)) {
20
- return files.get(name)!;
21
- }
22
- const file = storage.createOrOpen(name);
23
- file.close = (cb: any) => cb?.(null); // Fix.
24
- files.set(name, file);
25
- return file;
26
- };
27
-
28
- fn.root = root;
29
- fn.type = storage.type;
30
- fn.destroy = storage.destroy.bind(storage);
31
-
32
- return fn;
33
- }