@dxos/client-services 0.4.10-main.93fda5f → 0.4.10-main.94e3e06
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.
- package/dist/lib/browser/{chunk-ULO2U4N6.mjs → chunk-WRFCA2FV.mjs} +123 -56
- package/dist/lib/browser/{chunk-ULO2U4N6.mjs.map → chunk-WRFCA2FV.mjs.map} +3 -3
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +1 -1
- package/dist/lib/node/{chunk-4TLGRMKO.cjs → chunk-6Y6HFXWD.cjs} +128 -61
- package/dist/lib/node/chunk-6Y6HFXWD.cjs.map +7 -0
- package/dist/lib/node/index.cjs +37 -37
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +6 -6
- package/dist/types/src/packlets/indexing/util.d.ts +2 -2
- package/dist/types/src/packlets/indexing/util.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +34 -34
- package/src/packlets/indexing/util.ts +4 -4
- package/src/packlets/services/service-context.ts +3 -3
- package/src/packlets/services/service-host.ts +12 -8
- package/src/packlets/spaces/data-space.ts +51 -2
- package/src/version.ts +1 -1
- package/dist/lib/node/chunk-4TLGRMKO.cjs.map +0 -7
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const DXOS_VERSION = "0.4.10-main.
|
|
1
|
+
export declare const DXOS_VERSION = "0.4.10-main.94e3e06";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/client-services",
|
|
3
|
-
"version": "0.4.10-main.
|
|
3
|
+
"version": "0.4.10-main.94e3e06",
|
|
4
4
|
"description": "DXOS client services implementation",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -22,43 +22,43 @@
|
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"platform": "^1.3.6",
|
|
25
|
-
"@dxos/
|
|
26
|
-
"@dxos/
|
|
27
|
-
"@dxos/
|
|
28
|
-
"@dxos/config": "0.4.10-main.
|
|
29
|
-
"@dxos/
|
|
30
|
-
"@dxos/
|
|
31
|
-
"@dxos/credentials": "0.4.10-main.
|
|
32
|
-
"@dxos/crypto": "0.4.10-main.
|
|
33
|
-
"@dxos/debug": "0.4.10-main.
|
|
34
|
-
"@dxos/echo-pipeline": "0.4.10-main.
|
|
35
|
-
"@dxos/echo-schema": "0.4.10-main.
|
|
36
|
-
"@dxos/echo-db": "0.4.10-main.
|
|
37
|
-
"@dxos/feed-store": "0.4.10-main.
|
|
38
|
-
"@dxos/indexing": "0.4.10-main.
|
|
39
|
-
"@dxos/invariant": "0.4.10-main.
|
|
40
|
-
"@dxos/keyring": "0.4.10-main.
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/tracing": "0.4.10-main.
|
|
55
|
-
"@dxos/
|
|
56
|
-
"@dxos/websocket-rpc": "0.4.10-main.
|
|
25
|
+
"@dxos/async": "0.4.10-main.94e3e06",
|
|
26
|
+
"@dxos/client-protocol": "0.4.10-main.94e3e06",
|
|
27
|
+
"@dxos/automerge": "0.4.10-main.94e3e06",
|
|
28
|
+
"@dxos/config": "0.4.10-main.94e3e06",
|
|
29
|
+
"@dxos/context": "0.4.10-main.94e3e06",
|
|
30
|
+
"@dxos/codec-protobuf": "0.4.10-main.94e3e06",
|
|
31
|
+
"@dxos/credentials": "0.4.10-main.94e3e06",
|
|
32
|
+
"@dxos/crypto": "0.4.10-main.94e3e06",
|
|
33
|
+
"@dxos/debug": "0.4.10-main.94e3e06",
|
|
34
|
+
"@dxos/echo-pipeline": "0.4.10-main.94e3e06",
|
|
35
|
+
"@dxos/echo-schema": "0.4.10-main.94e3e06",
|
|
36
|
+
"@dxos/echo-db": "0.4.10-main.94e3e06",
|
|
37
|
+
"@dxos/feed-store": "0.4.10-main.94e3e06",
|
|
38
|
+
"@dxos/indexing": "0.4.10-main.94e3e06",
|
|
39
|
+
"@dxos/invariant": "0.4.10-main.94e3e06",
|
|
40
|
+
"@dxos/keyring": "0.4.10-main.94e3e06",
|
|
41
|
+
"@dxos/keys": "0.4.10-main.94e3e06",
|
|
42
|
+
"@dxos/lock-file": "0.4.10-main.94e3e06",
|
|
43
|
+
"@dxos/log": "0.4.10-main.94e3e06",
|
|
44
|
+
"@dxos/messaging": "0.4.10-main.94e3e06",
|
|
45
|
+
"@dxos/network-manager": "0.4.10-main.94e3e06",
|
|
46
|
+
"@dxos/protocols": "0.4.10-main.94e3e06",
|
|
47
|
+
"@dxos/rpc": "0.4.10-main.94e3e06",
|
|
48
|
+
"@dxos/random-access-storage": "0.4.10-main.94e3e06",
|
|
49
|
+
"@dxos/teleport": "0.4.10-main.94e3e06",
|
|
50
|
+
"@dxos/node-std": "0.4.10-main.94e3e06",
|
|
51
|
+
"@dxos/timeframe": "0.4.10-main.94e3e06",
|
|
52
|
+
"@dxos/teleport-extension-gossip": "0.4.10-main.94e3e06",
|
|
53
|
+
"@dxos/util": "0.4.10-main.94e3e06",
|
|
54
|
+
"@dxos/tracing": "0.4.10-main.94e3e06",
|
|
55
|
+
"@dxos/teleport-extension-object-sync": "0.4.10-main.94e3e06",
|
|
56
|
+
"@dxos/websocket-rpc": "0.4.10-main.94e3e06"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@types/platform": "^1.3.4",
|
|
60
60
|
"@types/readable-stream": "^2.3.9",
|
|
61
|
-
"@dxos/signal": "0.4.10-main.
|
|
61
|
+
"@dxos/signal": "0.4.10-main.94e3e06"
|
|
62
62
|
},
|
|
63
63
|
"publishConfig": {
|
|
64
64
|
"access": "public"
|
|
@@ -12,7 +12,7 @@ import { idCodec } from '@dxos/protocols';
|
|
|
12
12
|
/**
|
|
13
13
|
* Factory for `loadDocuments` iterator.
|
|
14
14
|
*/
|
|
15
|
-
export const
|
|
15
|
+
export const createSelectedDocumentsIterator = (automergeHost: AutomergeHost) =>
|
|
16
16
|
/**
|
|
17
17
|
* Get object data blobs from Automerge Repo by ids.
|
|
18
18
|
* @param ids
|
|
@@ -25,14 +25,14 @@ export const createLoadDocuments = (automergeHost: AutomergeHost) =>
|
|
|
25
25
|
await warnAfterTimeout(5000, 'to long to load doc', () => handle.whenReady());
|
|
26
26
|
const doc = handle.docSync();
|
|
27
27
|
const hash = getHeads(doc).join('');
|
|
28
|
-
yield [{ id, object: doc.objects[objectId], currentHash: hash }];
|
|
28
|
+
yield doc.objects?.[objectId] ? [{ id, object: doc.objects[objectId], currentHash: hash }] : [];
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Factory for `getAllDocuments` iterator.
|
|
34
34
|
*/
|
|
35
|
-
export const
|
|
35
|
+
export const createDocumentsIterator = (automergeHost: AutomergeHost) =>
|
|
36
36
|
/**
|
|
37
37
|
* Recursively get all object data blobs from Automerge Repo.
|
|
38
38
|
* @param ids
|
|
@@ -57,7 +57,7 @@ export const createGetAllDocuments = (automergeHost: AutomergeHost) =>
|
|
|
57
57
|
return {
|
|
58
58
|
id: idCodec.encode({ documentId: handle.documentId, objectId }),
|
|
59
59
|
object,
|
|
60
|
-
currentHash: heads.
|
|
60
|
+
currentHash: heads.join(''),
|
|
61
61
|
};
|
|
62
62
|
});
|
|
63
63
|
}
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
type IdentityManagerRuntimeParams,
|
|
31
31
|
type JoinIdentityParams,
|
|
32
32
|
} from '../identity';
|
|
33
|
-
import {
|
|
33
|
+
import { createDocumentsIterator, createSelectedDocumentsIterator } from '../indexing';
|
|
34
34
|
import {
|
|
35
35
|
DeviceInvitationProtocol,
|
|
36
36
|
InvitationsHandler,
|
|
@@ -125,8 +125,8 @@ export class ServiceContext {
|
|
|
125
125
|
this.indexer = new Indexer({
|
|
126
126
|
indexStore: new IndexStore({ directory: storage.createDirectory('index-store') }),
|
|
127
127
|
metadataStore: this.indexMetadata,
|
|
128
|
-
loadDocuments:
|
|
129
|
-
getAllDocuments:
|
|
128
|
+
loadDocuments: createSelectedDocumentsIterator(this.automergeHost),
|
|
129
|
+
getAllDocuments: createDocumentsIterator(this.automergeHost),
|
|
130
130
|
});
|
|
131
131
|
|
|
132
132
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
// Copyright 2021 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Event, synchronized } from '@dxos/async';
|
|
6
|
-
import {
|
|
5
|
+
import { Event, sleep, synchronized } from '@dxos/async';
|
|
6
|
+
import { clientServiceBundle, defaultKey, type ClientServices, PropertiesSchema } from '@dxos/client-protocol';
|
|
7
7
|
import { type Config } from '@dxos/config';
|
|
8
8
|
import { Context } from '@dxos/context';
|
|
9
|
-
import { DataServiceImpl } from '@dxos/echo-pipeline';
|
|
10
|
-
import
|
|
9
|
+
import { DataServiceImpl, type SpaceDoc } from '@dxos/echo-pipeline';
|
|
10
|
+
import * as E from '@dxos/echo-schema';
|
|
11
|
+
import { createRawObjectDoc } from '@dxos/echo-schema';
|
|
11
12
|
import { IndexServiceImpl } from '@dxos/indexing';
|
|
12
13
|
import { invariant } from '@dxos/invariant';
|
|
13
14
|
import { PublicKey } from '@dxos/keys';
|
|
@@ -347,17 +348,20 @@ export class ClientServicesHost {
|
|
|
347
348
|
await this._serviceContext.initialized.wait();
|
|
348
349
|
const space = await this._serviceContext.dataSpaceManager!.createSpace();
|
|
349
350
|
|
|
350
|
-
const obj: TypedObject = new Properties(undefined);
|
|
351
|
-
obj[defaultKey] = identity.identityKey.toHex();
|
|
352
|
-
|
|
353
351
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
354
352
|
invariant(automergeIndex);
|
|
355
353
|
const document = await this._serviceContext.automergeHost.repo.find<SpaceDoc>(automergeIndex as any);
|
|
356
354
|
await document.whenReady();
|
|
357
355
|
|
|
356
|
+
const objectDocument = createRawObjectDoc(
|
|
357
|
+
{ [defaultKey]: identity.identityKey.toHex() },
|
|
358
|
+
{ type: E.getTypeReference(PropertiesSchema) },
|
|
359
|
+
);
|
|
358
360
|
document.change((doc: SpaceDoc) => {
|
|
359
|
-
assignDeep(doc, ['objects',
|
|
361
|
+
assignDeep(doc, ['objects', objectDocument.id], objectDocument.handle.docSync());
|
|
360
362
|
});
|
|
363
|
+
// TODO: replace with flush when supported by automerge-repo
|
|
364
|
+
await sleep(200);
|
|
361
365
|
|
|
362
366
|
return identity;
|
|
363
367
|
}
|
|
@@ -6,7 +6,15 @@ import { Event, asyncTimeout, scheduleTask, sleep, synchronized, trackLeaks } fr
|
|
|
6
6
|
import { AUTH_TIMEOUT } from '@dxos/client-protocol';
|
|
7
7
|
import { cancelWithContext, Context, ContextDisposedError } from '@dxos/context';
|
|
8
8
|
import { timed, warnAfterTimeout } from '@dxos/debug';
|
|
9
|
-
import {
|
|
9
|
+
import { TYPE_PROPERTIES } from '@dxos/echo-db';
|
|
10
|
+
import {
|
|
11
|
+
type MetadataStore,
|
|
12
|
+
type Space,
|
|
13
|
+
createMappedFeedWriter,
|
|
14
|
+
type AutomergeHost,
|
|
15
|
+
type SpaceDoc,
|
|
16
|
+
} from '@dxos/echo-pipeline';
|
|
17
|
+
import { AutomergeDocumentLoaderImpl } from '@dxos/echo-pipeline';
|
|
10
18
|
import { type FeedStore } from '@dxos/feed-store';
|
|
11
19
|
import { failedInvariant, invariant } from '@dxos/invariant';
|
|
12
20
|
import { type Keyring } from '@dxos/keyring';
|
|
@@ -26,7 +34,7 @@ import { type GossipMessage } from '@dxos/protocols/proto/dxos/mesh/teleport/gos
|
|
|
26
34
|
import { type Gossip, type Presence } from '@dxos/teleport-extension-gossip';
|
|
27
35
|
import { Timeframe } from '@dxos/timeframe';
|
|
28
36
|
import { trace } from '@dxos/tracing';
|
|
29
|
-
import { ComplexSet } from '@dxos/util';
|
|
37
|
+
import { ComplexSet, assignDeep } from '@dxos/util';
|
|
30
38
|
|
|
31
39
|
import { AutomergeSpaceState } from './automerge-space-state';
|
|
32
40
|
import { type SigningContext } from './data-space-manager';
|
|
@@ -437,6 +445,47 @@ export class DataSpace {
|
|
|
437
445
|
};
|
|
438
446
|
}
|
|
439
447
|
break;
|
|
448
|
+
case CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
|
|
449
|
+
{
|
|
450
|
+
log.info('Fragmenting');
|
|
451
|
+
|
|
452
|
+
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
453
|
+
const rootHandle = this._automergeHost.repo.find<SpaceDoc>(currentRootUrl as any);
|
|
454
|
+
await cancelWithContext(this._ctx, asyncTimeout(rootHandle.whenReady(), 10_000));
|
|
455
|
+
|
|
456
|
+
// Find properties object.
|
|
457
|
+
const objects = Object.entries((rootHandle.docSync() as SpaceDoc).objects!);
|
|
458
|
+
const properties = objects.find(([_, value]) => value.system.type?.itemId === TYPE_PROPERTIES);
|
|
459
|
+
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
460
|
+
invariant(properties, 'Properties not found');
|
|
461
|
+
|
|
462
|
+
// Create a new space doc with the properties object.
|
|
463
|
+
const newSpaceDoc: SpaceDoc = { ...rootHandle.docSync(), objects: Object.fromEntries([properties]) };
|
|
464
|
+
const newRoot = this._automergeHost.repo.create(newSpaceDoc);
|
|
465
|
+
invariant(typeof newRoot.url === 'string' && newRoot.url.length > 0);
|
|
466
|
+
|
|
467
|
+
// Create new automerge documents for all objects.
|
|
468
|
+
const docLoader = new AutomergeDocumentLoaderImpl(this.key, this._automergeHost.repo);
|
|
469
|
+
await docLoader.loadSpaceRootDocHandle(this._ctx, { rootUrl: newRoot.url });
|
|
470
|
+
|
|
471
|
+
otherObjects.forEach(([key, value]) => {
|
|
472
|
+
const handle = docLoader.createDocumentForObject(key);
|
|
473
|
+
handle.change((doc: any) => {
|
|
474
|
+
assignDeep(doc, ['objects', key], value);
|
|
475
|
+
});
|
|
476
|
+
});
|
|
477
|
+
|
|
478
|
+
// TODO(mykola): Delete old root.
|
|
479
|
+
|
|
480
|
+
// TODO(dmaretskyi): Unify epoch construction.
|
|
481
|
+
epoch = {
|
|
482
|
+
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
483
|
+
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
484
|
+
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe(),
|
|
485
|
+
automergeRoot: newRoot.url,
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
break;
|
|
440
489
|
}
|
|
441
490
|
|
|
442
491
|
if (!epoch) {
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const DXOS_VERSION = "0.4.10-main.
|
|
1
|
+
export const DXOS_VERSION = "0.4.10-main.94e3e06";
|