@dxos/client-services 0.8.3 → 0.8.4-main.1068cf700f
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-NQSC7HOE.mjs +22 -0
- package/dist/lib/browser/chunk-NQSC7HOE.mjs.map +7 -0
- package/dist/lib/browser/{chunk-LBG3C332.mjs → chunk-OZGICTH7.mjs} +3864 -3786
- package/dist/lib/browser/chunk-OZGICTH7.mjs.map +7 -0
- package/dist/lib/browser/chunk-QCWEHHJW.mjs +24 -0
- package/dist/lib/browser/chunk-QCWEHHJW.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +474 -80
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/diagnostics/browser-diagnostics-broadcast.mjs +93 -0
- package/dist/lib/browser/packlets/diagnostics/browser-diagnostics-broadcast.mjs.map +7 -0
- package/dist/lib/browser/packlets/diagnostics/diagnostics-broadcast.mjs +11 -0
- package/dist/lib/browser/packlets/diagnostics/diagnostics-broadcast.mjs.map +7 -0
- package/dist/lib/browser/packlets/locks/browser.mjs +126 -0
- package/dist/lib/browser/packlets/locks/browser.mjs.map +7 -0
- package/dist/lib/browser/packlets/locks/node.mjs +66 -0
- package/dist/lib/browser/packlets/locks/node.mjs.map +7 -0
- package/dist/lib/browser/testing/index.mjs +39 -27
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/chunk-2SZHAWBN.mjs +24 -0
- package/dist/lib/node-esm/chunk-2SZHAWBN.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-PKEGMOQ4.mjs +22 -0
- package/dist/lib/node-esm/chunk-PKEGMOQ4.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-SKGQLRKS.mjs → chunk-RXHISBCS.mjs} +3551 -3341
- package/dist/lib/node-esm/chunk-RXHISBCS.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +474 -80
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/packlets/diagnostics/browser-diagnostics-broadcast.mjs +93 -0
- package/dist/lib/node-esm/packlets/diagnostics/browser-diagnostics-broadcast.mjs.map +7 -0
- package/dist/lib/node-esm/packlets/diagnostics/diagnostics-broadcast.mjs +11 -0
- package/dist/lib/node-esm/packlets/diagnostics/diagnostics-broadcast.mjs.map +7 -0
- package/dist/lib/node-esm/packlets/locks/browser.mjs +126 -0
- package/dist/lib/node-esm/packlets/locks/browser.mjs.map +7 -0
- package/dist/lib/node-esm/packlets/locks/node.mjs +66 -0
- package/dist/lib/node-esm/packlets/locks/node.mjs.map +7 -0
- package/dist/lib/node-esm/testing/index.mjs +39 -27
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/packlets/agents/edge-agent-service.d.ts +1 -1
- package/dist/types/src/packlets/agents/edge-agent-service.d.ts.map +1 -1
- package/dist/types/src/packlets/devices/devices-service.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/devtools.d.ts +20 -20
- package/dist/types/src/packlets/devtools/devtools.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/feeds.d.ts +1 -1
- package/dist/types/src/packlets/devtools/feeds.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/network.d.ts +1 -1
- package/dist/types/src/packlets/devtools/network.d.ts.map +1 -1
- package/dist/types/src/packlets/diagnostics/browser-diagnostics-broadcast.d.ts +1 -1
- package/dist/types/src/packlets/diagnostics/browser-diagnostics-broadcast.d.ts.map +1 -1
- package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts +1 -1
- package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts.map +1 -1
- package/dist/types/src/packlets/diagnostics/diagnostics.d.ts +1 -1
- package/dist/types/src/packlets/diagnostics/diagnostics.d.ts.map +1 -1
- package/dist/types/src/packlets/diagnostics/index.d.ts +1 -1
- package/dist/types/src/packlets/diagnostics/index.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/authenticator.d.ts +2 -2
- package/dist/types/src/packlets/identity/authenticator.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/contacts-service.d.ts +1 -1
- package/dist/types/src/packlets/identity/contacts-service.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/default-space-state-machine.d.ts +3 -3
- package/dist/types/src/packlets/identity/default-space-state-machine.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-manager.d.ts +5 -5
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts +2 -2
- package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-service.d.ts +1 -1
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +3 -3
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts +4 -4
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/edge-invitation-handler.d.ts +1 -1
- package/dist/types/src/packlets/invitations/edge-invitation-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/index.d.ts +1 -1
- package/dist/types/src/packlets/invitations/index.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-guest-extenstion.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-host-extension.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts +3 -4
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts +4 -4
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-service.d.ts +1 -1
- package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +3 -3
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/utils.d.ts.map +1 -1
- package/dist/types/src/packlets/locks/index.d.ts +2 -2
- package/dist/types/src/packlets/locks/index.d.ts.map +1 -1
- package/dist/types/src/packlets/logging/logging-service.d.ts +5 -1
- package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
- package/dist/types/src/packlets/network/network-service.d.ts +2 -2
- package/dist/types/src/packlets/network/network-service.d.ts.map +1 -1
- package/dist/types/src/packlets/services/client-rpc-server.d.ts +2 -2
- package/dist/types/src/packlets/services/client-rpc-server.d.ts.map +1 -1
- package/dist/types/src/packlets/services/feed-syncer.d.ts +41 -0
- package/dist/types/src/packlets/services/feed-syncer.d.ts.map +1 -0
- package/dist/types/src/packlets/services/platform.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +14 -8
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +20 -6
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/space-export/space-archive-writer.d.ts +1 -1
- package/dist/types/src/packlets/space-export/space-archive-writer.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/automerge-space-state.d.ts +1 -1
- package/dist/types/src/packlets/spaces/automerge-space-state.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +12 -7
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +6 -6
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts +2 -2
- package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +6 -6
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +2 -2
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/profile-archive.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/storage.d.ts.map +1 -1
- package/dist/types/src/packlets/system/system-service.d.ts +1 -1
- package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/invitation-utils.d.ts +6 -3
- package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +8 -7
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/worker/worker-runtime.d.ts +31 -4
- package/dist/types/src/packlets/worker/worker-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/worker/worker-session.d.ts +2 -2
- package/dist/types/src/packlets/worker/worker-session.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/dist/types/src/version.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +72 -48
- package/src/packlets/agents/edge-agent-manager.ts +2 -2
- package/src/packlets/agents/edge-agent-service.ts +13 -3
- package/src/packlets/devices/devices-service.test.ts +4 -3
- package/src/packlets/devices/devices-service.ts +2 -2
- package/src/packlets/devtools/devtools.ts +30 -29
- package/src/packlets/devtools/feeds.ts +2 -2
- package/src/packlets/devtools/network.ts +1 -1
- package/src/packlets/diagnostics/browser-diagnostics-broadcast.ts +1 -1
- package/src/packlets/diagnostics/diagnostics-broadcast.ts +1 -1
- package/src/packlets/diagnostics/diagnostics-collector.ts +1 -1
- package/src/packlets/diagnostics/diagnostics.ts +1 -1
- package/src/packlets/diagnostics/index.ts +1 -1
- package/src/packlets/identity/authenticator.node.test.ts +1 -1
- package/src/packlets/identity/authenticator.ts +3 -3
- package/src/packlets/identity/contacts-service.ts +3 -2
- package/src/packlets/identity/default-space-state-machine.ts +3 -3
- package/src/packlets/identity/identity-manager.test.ts +3 -3
- package/src/packlets/identity/identity-manager.ts +9 -9
- package/src/packlets/identity/identity-recovery-manager.ts +2 -2
- package/src/packlets/identity/identity-service.test.ts +3 -2
- package/src/packlets/identity/identity-service.ts +2 -1
- package/src/packlets/identity/identity.test.ts +9 -9
- package/src/packlets/identity/identity.ts +9 -8
- package/src/packlets/invitations/device-invitation-protocol.test.ts +4 -4
- package/src/packlets/invitations/device-invitation-protocol.ts +6 -5
- package/src/packlets/invitations/edge-invitation-handler.ts +1 -1
- package/src/packlets/invitations/index.ts +1 -1
- package/src/packlets/invitations/invitation-guest-extenstion.ts +7 -5
- package/src/packlets/invitations/invitation-host-extension.ts +8 -6
- package/src/packlets/invitations/invitation-protocol.ts +3 -4
- package/src/packlets/invitations/invitations-handler.test.ts +302 -292
- package/src/packlets/invitations/invitations-handler.ts +10 -10
- package/src/packlets/invitations/invitations-manager.ts +3 -3
- package/src/packlets/invitations/invitations-service.ts +1 -1
- package/src/packlets/invitations/space-invitation-protocol.test.ts +9 -9
- package/src/packlets/invitations/space-invitation-protocol.ts +10 -15
- package/src/packlets/invitations/utils.ts +1 -1
- package/src/packlets/locks/browser.ts +1 -1
- package/src/packlets/locks/index.ts +2 -2
- package/src/packlets/logging/logging-service.ts +8 -3
- package/src/packlets/logging/logging.test.ts +1 -1
- package/src/packlets/network/network-service.test.ts +4 -3
- package/src/packlets/network/network-service.ts +2 -2
- package/src/packlets/services/client-rpc-server.ts +5 -5
- package/src/packlets/services/feed-syncer.ts +227 -0
- package/src/packlets/services/platform.ts +7 -1
- package/src/packlets/services/service-context.test.ts +1 -1
- package/src/packlets/services/service-context.ts +56 -29
- package/src/packlets/services/service-host.test.ts +3 -2
- package/src/packlets/services/service-host.ts +78 -29
- package/src/packlets/services/service-registry.test.ts +2 -1
- package/src/packlets/space-export/space-archive-reader.ts +2 -2
- package/src/packlets/space-export/space-archive-writer.ts +7 -5
- package/src/packlets/space-export/tar.test.ts +1 -1
- package/src/packlets/spaces/automerge-space-state.ts +1 -1
- package/src/packlets/spaces/data-space-manager.ts +76 -36
- package/src/packlets/spaces/data-space.ts +18 -13
- package/src/packlets/spaces/edge-feed-replicator.test.ts +3 -3
- package/src/packlets/spaces/edge-feed-replicator.ts +4 -4
- package/src/packlets/spaces/epoch-migrations.ts +2 -2
- package/src/packlets/spaces/notarization-plugin.test.ts +3 -3
- package/src/packlets/spaces/notarization-plugin.ts +11 -11
- package/src/packlets/spaces/spaces-service.test.ts +3 -2
- package/src/packlets/spaces/spaces-service.ts +27 -23
- package/src/packlets/storage/profile-archive.ts +1 -1
- package/src/packlets/storage/storage.ts +7 -8
- package/src/packlets/system/system-service.test.ts +1 -1
- package/src/packlets/system/system-service.ts +4 -4
- package/src/packlets/testing/invitation-utils.ts +8 -5
- package/src/packlets/testing/test-builder.ts +39 -13
- package/src/packlets/worker/worker-runtime.ts +151 -12
- package/src/packlets/worker/worker-session.ts +7 -7
- package/src/version.ts +1 -5
- package/README.yml +0 -5
- package/dist/lib/browser/chunk-LBG3C332.mjs.map +0 -7
- package/dist/lib/node/chunk-LMGLGOUU.cjs +0 -9311
- package/dist/lib/node/chunk-LMGLGOUU.cjs.map +0 -7
- package/dist/lib/node/index.cjs +0 -437
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
- package/dist/lib/node/testing/index.cjs +0 -452
- package/dist/lib/node/testing/index.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-SKGQLRKS.mjs.map +0 -7
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { describe, test } from 'vitest';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { MemorySignalManager, MemorySignalManagerContext } from '@dxos/messaging';
|
|
8
8
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
9
9
|
import { openAndClose } from '@dxos/test-utils';
|
|
10
10
|
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import type * as SqlClient from '@effect/sql/SqlClient';
|
|
6
|
+
|
|
5
7
|
import { Mutex, Trigger } from '@dxos/async';
|
|
6
8
|
import { Context, Resource } from '@dxos/context';
|
|
7
|
-
import {
|
|
9
|
+
import { type CredentialProcessor, getCredentialAssertion } from '@dxos/credentials';
|
|
8
10
|
import { failUndefined, warnAfterTimeout } from '@dxos/debug';
|
|
9
11
|
import {
|
|
10
12
|
EchoEdgeReplicator,
|
|
@@ -15,7 +17,8 @@ import {
|
|
|
15
17
|
valueEncoding,
|
|
16
18
|
} from '@dxos/echo-pipeline';
|
|
17
19
|
import { createChainEdgeIdentity, createEphemeralEdgeIdentity } from '@dxos/edge-client';
|
|
18
|
-
import type {
|
|
20
|
+
import type { EdgeConnection, EdgeHttpClient, EdgeIdentity } from '@dxos/edge-client';
|
|
21
|
+
import { type RuntimeProvider } from '@dxos/effect';
|
|
19
22
|
import { FeedFactory, FeedStore } from '@dxos/feed-store';
|
|
20
23
|
import { invariant } from '@dxos/invariant';
|
|
21
24
|
import { Keyring } from '@dxos/keyring';
|
|
@@ -25,41 +28,46 @@ import { log } from '@dxos/log';
|
|
|
25
28
|
import { type SignalManager } from '@dxos/messaging';
|
|
26
29
|
import { type SwarmNetworkManager } from '@dxos/network-manager';
|
|
27
30
|
import { InvalidStorageVersionError, STORAGE_VERSION, trace } from '@dxos/protocols';
|
|
31
|
+
import { FeedProtocol } from '@dxos/protocols';
|
|
28
32
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
29
33
|
import { type Runtime } from '@dxos/protocols/proto/dxos/config';
|
|
30
34
|
import type { FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
|
|
31
35
|
import { type Credential, type ProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
32
36
|
import { type Storage } from '@dxos/random-access-storage';
|
|
37
|
+
import type * as SqlTransaction from '@dxos/sql-sqlite/SqlTransaction';
|
|
33
38
|
import { BlobStore } from '@dxos/teleport-extension-object-sync';
|
|
34
39
|
import { trace as Trace } from '@dxos/tracing';
|
|
35
40
|
import { safeInstanceof } from '@dxos/util';
|
|
36
41
|
|
|
37
42
|
import { EdgeAgentManager } from '../agents';
|
|
38
43
|
import {
|
|
39
|
-
IdentityManager,
|
|
40
44
|
type CreateIdentityOptions,
|
|
41
|
-
|
|
42
|
-
type
|
|
45
|
+
IdentityManager,
|
|
46
|
+
type IdentityManagerProps,
|
|
47
|
+
type JoinIdentityProps,
|
|
43
48
|
} from '../identity';
|
|
44
49
|
import { EdgeIdentityRecoveryManager } from '../identity/identity-recovery-manager';
|
|
45
50
|
import {
|
|
46
51
|
DeviceInvitationProtocol,
|
|
47
|
-
type
|
|
52
|
+
type InvitationConnectionProps,
|
|
53
|
+
type InvitationProtocol,
|
|
48
54
|
InvitationsHandler,
|
|
49
55
|
InvitationsManager,
|
|
50
56
|
SpaceInvitationProtocol,
|
|
51
|
-
type InvitationProtocol,
|
|
52
57
|
} from '../invitations';
|
|
53
|
-
import { DataSpaceManager, type
|
|
58
|
+
import { DataSpaceManager, type DataSpaceManagerRuntimeProps, type SigningContext } from '../spaces';
|
|
59
|
+
|
|
60
|
+
import { FeedSyncer } from './feed-syncer';
|
|
54
61
|
|
|
55
|
-
export type
|
|
56
|
-
|
|
62
|
+
export type ServiceContextRuntimeProps = Pick<
|
|
63
|
+
IdentityManagerProps,
|
|
57
64
|
'devicePresenceOfflineTimeout' | 'devicePresenceAnnounceInterval'
|
|
58
65
|
> &
|
|
59
|
-
|
|
60
|
-
|
|
66
|
+
DataSpaceManagerRuntimeProps & {
|
|
67
|
+
invitationConnectionDefaultProps?: InvitationConnectionProps;
|
|
61
68
|
disableP2pReplication?: boolean;
|
|
62
69
|
enableVectorIndexing?: boolean;
|
|
70
|
+
enableLocalQueues?: boolean;
|
|
63
71
|
};
|
|
64
72
|
/**
|
|
65
73
|
* Shared backend for all client services.
|
|
@@ -84,6 +92,7 @@ export class ServiceContext extends Resource {
|
|
|
84
92
|
public readonly echoHost: EchoHost;
|
|
85
93
|
private readonly _meshReplicator?: MeshEchoReplicator = undefined;
|
|
86
94
|
private readonly _echoEdgeReplicator?: EchoEdgeReplicator = undefined;
|
|
95
|
+
private readonly _feedSyncer?: FeedSyncer = undefined;
|
|
87
96
|
|
|
88
97
|
// Initialized after identity is initialized.
|
|
89
98
|
public dataSpaceManager?: DataSpaceManager;
|
|
@@ -105,11 +114,15 @@ export class ServiceContext extends Resource {
|
|
|
105
114
|
public readonly signalManager: SignalManager,
|
|
106
115
|
private readonly _edgeConnection: EdgeConnection | undefined,
|
|
107
116
|
private readonly _edgeHttpClient: EdgeHttpClient | undefined,
|
|
108
|
-
|
|
117
|
+
private readonly _runtime: RuntimeProvider.RuntimeProvider<SqlClient.SqlClient | SqlTransaction.SqlTransaction>,
|
|
118
|
+
public readonly _runtimeProps?: ServiceContextRuntimeProps,
|
|
109
119
|
private readonly _edgeFeatures?: Runtime.Client.EdgeFeatures,
|
|
110
120
|
) {
|
|
111
121
|
super();
|
|
112
122
|
|
|
123
|
+
log('runtimeProps', this._runtimeProps);
|
|
124
|
+
log('edgeFeatures', this._edgeFeatures);
|
|
125
|
+
|
|
113
126
|
// TODO(burdon): Move strings to constants.
|
|
114
127
|
this.metadataStore = new MetadataStore(storage.createDirectory('metadata'));
|
|
115
128
|
this.blobStore = new BlobStore(storage.createDirectory('blobs'));
|
|
@@ -131,7 +144,7 @@ export class ServiceContext extends Resource {
|
|
|
131
144
|
networkManager: this.networkManager,
|
|
132
145
|
blobStore: this.blobStore,
|
|
133
146
|
metadataStore: this.metadataStore,
|
|
134
|
-
disableP2pReplication: this.
|
|
147
|
+
disableP2pReplication: this._runtimeProps?.disableP2pReplication,
|
|
135
148
|
});
|
|
136
149
|
|
|
137
150
|
this.identityManager = new IdentityManager({
|
|
@@ -139,8 +152,8 @@ export class ServiceContext extends Resource {
|
|
|
139
152
|
keyring: this.keyring,
|
|
140
153
|
feedStore: this.feedStore,
|
|
141
154
|
spaceManager: this.spaceManager,
|
|
142
|
-
devicePresenceOfflineTimeout: this.
|
|
143
|
-
devicePresenceAnnounceInterval: this.
|
|
155
|
+
devicePresenceOfflineTimeout: this._runtimeProps?.devicePresenceOfflineTimeout,
|
|
156
|
+
devicePresenceAnnounceInterval: this._runtimeProps?.devicePresenceAnnounceInterval,
|
|
144
157
|
edgeConnection: this._edgeConnection,
|
|
145
158
|
edgeFeatures: this._edgeFeatures,
|
|
146
159
|
});
|
|
@@ -156,17 +169,14 @@ export class ServiceContext extends Resource {
|
|
|
156
169
|
kv: this.level,
|
|
157
170
|
peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex(),
|
|
158
171
|
getSpaceKeyByRootDocumentId: (documentId) => this.spaceManager.findSpaceByRootDocumentId(documentId)?.key,
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
},
|
|
172
|
+
runtime: this._runtime,
|
|
173
|
+
localQueues: this._runtimeProps?.enableLocalQueues,
|
|
162
174
|
});
|
|
163
175
|
|
|
164
|
-
this._meshReplicator = new MeshEchoReplicator();
|
|
165
|
-
|
|
166
176
|
this.invitations = new InvitationsHandler(
|
|
167
177
|
this.networkManager, //
|
|
168
178
|
this._edgeHttpClient,
|
|
169
|
-
|
|
179
|
+
_runtimeProps?.invitationConnectionDefaultProps,
|
|
170
180
|
);
|
|
171
181
|
this.invitationsManager = new InvitationsManager(
|
|
172
182
|
this.invitations,
|
|
@@ -186,12 +196,24 @@ export class ServiceContext extends Resource {
|
|
|
186
196
|
),
|
|
187
197
|
);
|
|
188
198
|
|
|
189
|
-
if (!this.
|
|
199
|
+
if (!this._runtimeProps?.disableP2pReplication) {
|
|
190
200
|
this._meshReplicator = new MeshEchoReplicator();
|
|
191
201
|
}
|
|
192
|
-
if (this._edgeConnection && this._edgeFeatures?.echoReplicator) {
|
|
202
|
+
if (this._edgeConnection && this._edgeFeatures?.echoReplicator && this._edgeHttpClient) {
|
|
193
203
|
this._echoEdgeReplicator = new EchoEdgeReplicator({
|
|
194
204
|
edgeConnection: this._edgeConnection,
|
|
205
|
+
edgeHttpClient: this._edgeHttpClient,
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (this.echoHost.feedStore && this._edgeConnection) {
|
|
210
|
+
this._feedSyncer = new FeedSyncer({
|
|
211
|
+
runtime: this._runtime,
|
|
212
|
+
feedStore: this.echoHost.feedStore,
|
|
213
|
+
edgeClient: this._edgeConnection,
|
|
214
|
+
peerId: this.identityManager.identity?.deviceKey?.toHex() ?? '',
|
|
215
|
+
getSpaceIds: () => this.echoHost!.spaceIds,
|
|
216
|
+
syncNamespace: FeedProtocol.WellKnownNamespaces.data,
|
|
195
217
|
});
|
|
196
218
|
}
|
|
197
219
|
}
|
|
@@ -228,6 +250,8 @@ export class ServiceContext extends Resource {
|
|
|
228
250
|
await this._initialize(ctx);
|
|
229
251
|
}
|
|
230
252
|
|
|
253
|
+
await this._feedSyncer?.open();
|
|
254
|
+
|
|
231
255
|
const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
|
|
232
256
|
log('loaded persistent invitations', { count: loadedInvitations.invitations?.length });
|
|
233
257
|
|
|
@@ -237,6 +261,9 @@ export class ServiceContext extends Resource {
|
|
|
237
261
|
|
|
238
262
|
protected override async _close(ctx: Context): Promise<void> {
|
|
239
263
|
log('closing...');
|
|
264
|
+
|
|
265
|
+
await this._feedSyncer?.close();
|
|
266
|
+
|
|
240
267
|
if (this._deviceSpaceSync && this.identityManager.identity) {
|
|
241
268
|
await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
|
|
242
269
|
}
|
|
@@ -244,13 +271,13 @@ export class ServiceContext extends Resource {
|
|
|
244
271
|
await this.edgeAgentManager?.close();
|
|
245
272
|
await this.identityManager.close();
|
|
246
273
|
await this.spaceManager.close();
|
|
247
|
-
await this.feedStore.close();
|
|
248
|
-
await this.metadataStore.close();
|
|
249
|
-
|
|
250
274
|
await this.echoHost.close(ctx);
|
|
275
|
+
|
|
251
276
|
await this.networkManager.close();
|
|
252
277
|
await this.signalManager.close();
|
|
253
278
|
await this._edgeConnection?.close();
|
|
279
|
+
await this.feedStore.close();
|
|
280
|
+
await this.metadataStore.close();
|
|
254
281
|
|
|
255
282
|
log('closed');
|
|
256
283
|
}
|
|
@@ -282,7 +309,7 @@ export class ServiceContext extends Resource {
|
|
|
282
309
|
}
|
|
283
310
|
}
|
|
284
311
|
|
|
285
|
-
private async _acceptIdentity(params:
|
|
312
|
+
private async _acceptIdentity(params: JoinIdentityProps) {
|
|
286
313
|
const { identity, identityRecord } = await this.identityManager.prepareIdentity(params);
|
|
287
314
|
await this._setNetworkIdentity({ deviceCredential: params.authorizedDeviceCredential! });
|
|
288
315
|
await identity.joinNetwork();
|
|
@@ -326,7 +353,7 @@ export class ServiceContext extends Resource {
|
|
|
326
353
|
edgeHttpClient: this._edgeHttpClient,
|
|
327
354
|
echoEdgeReplicator: this._echoEdgeReplicator,
|
|
328
355
|
meshReplicator: this._meshReplicator,
|
|
329
|
-
|
|
356
|
+
runtimeProps: this._runtimeProps as DataSpaceManagerRuntimeProps,
|
|
330
357
|
edgeFeatures: this._edgeFeatures,
|
|
331
358
|
});
|
|
332
359
|
await this.dataSpaceManager.open();
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { rmSync } from 'node:fs';
|
|
6
|
-
import { afterEach, onTestFinished, describe, expect, test } from 'vitest';
|
|
7
6
|
|
|
8
|
-
import {
|
|
7
|
+
import { afterEach, describe, expect, onTestFinished, test } from 'vitest';
|
|
8
|
+
|
|
9
|
+
import { Trigger, asyncTimeout, latch } from '@dxos/async';
|
|
9
10
|
import { Config } from '@dxos/config';
|
|
10
11
|
import { Context } from '@dxos/context';
|
|
11
12
|
import { verifyPresentation } from '@dxos/credentials';
|
|
@@ -2,39 +2,43 @@
|
|
|
2
2
|
// Copyright 2021 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import * as SqlClient from '@effect/sql/SqlClient';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
|
|
5
8
|
import { Event, synchronized } from '@dxos/async';
|
|
6
|
-
import {
|
|
9
|
+
import { type ClientServices, clientServiceBundle } from '@dxos/client-protocol';
|
|
7
10
|
import { type Config } from '@dxos/config';
|
|
8
11
|
import { Context } from '@dxos/context';
|
|
9
|
-
import { EdgeClient, EdgeHttpClient, createStubEdgeIdentity
|
|
12
|
+
import { EdgeClient, type EdgeConnection, EdgeHttpClient, createStubEdgeIdentity } from '@dxos/edge-client';
|
|
13
|
+
import { RuntimeProvider } from '@dxos/effect';
|
|
10
14
|
import { invariant } from '@dxos/invariant';
|
|
11
15
|
import { PublicKey } from '@dxos/keys';
|
|
12
16
|
import { type LevelDB } from '@dxos/kv-store';
|
|
13
17
|
import { log } from '@dxos/log';
|
|
14
|
-
import { EdgeSignalManager,
|
|
18
|
+
import { EdgeSignalManager, type SignalManager, WebsocketSignalManager } from '@dxos/messaging';
|
|
15
19
|
import {
|
|
16
20
|
SwarmNetworkManager,
|
|
21
|
+
type TransportFactory,
|
|
17
22
|
createIceProvider,
|
|
18
23
|
createRtcTransportFactory,
|
|
19
|
-
type TransportFactory,
|
|
20
24
|
} from '@dxos/network-manager';
|
|
21
25
|
import { trace } from '@dxos/protocols';
|
|
22
26
|
import { SystemStatus } from '@dxos/protocols/proto/dxos/client/services';
|
|
23
27
|
import { type Storage } from '@dxos/random-access-storage';
|
|
28
|
+
import * as SqlExport from '@dxos/sql-sqlite/SqlExport';
|
|
29
|
+
import type * as SqlTransaction from '@dxos/sql-sqlite/SqlTransaction';
|
|
24
30
|
import { TRACE_PROCESSOR, trace as Trace } from '@dxos/tracing';
|
|
25
31
|
import { WebsocketRpcClient } from '@dxos/websocket-rpc';
|
|
26
32
|
|
|
27
|
-
import { ServiceContext, type ServiceContextRuntimeParams } from './service-context';
|
|
28
|
-
import { ServiceRegistry } from './service-registry';
|
|
29
33
|
import { EdgeAgentServiceImpl } from '../agents';
|
|
30
34
|
import { DevicesServiceImpl } from '../devices';
|
|
31
35
|
import { DevtoolsHostEvents, DevtoolsServiceImpl } from '../devtools';
|
|
32
36
|
import {
|
|
37
|
+
type CollectDiagnosticsBroadcastHandler,
|
|
33
38
|
createCollectDiagnosticsBroadcastHandler,
|
|
34
39
|
createDiagnostics,
|
|
35
|
-
type CollectDiagnosticsBroadcastHandler,
|
|
36
40
|
} from '../diagnostics';
|
|
37
|
-
import {
|
|
41
|
+
import { type CreateIdentityOptions, IdentityServiceImpl } from '../identity';
|
|
38
42
|
import { ContactsServiceImpl } from '../identity/contacts-service';
|
|
39
43
|
import { InvitationsServiceImpl } from '../invitations';
|
|
40
44
|
import { Lock, type ResourceLock } from '../locks';
|
|
@@ -44,7 +48,10 @@ import { SpacesServiceImpl } from '../spaces';
|
|
|
44
48
|
import { createLevel, createStorageObjects } from '../storage';
|
|
45
49
|
import { SystemServiceImpl } from '../system';
|
|
46
50
|
|
|
47
|
-
|
|
51
|
+
import { ServiceContext, type ServiceContextRuntimeProps } from './service-context';
|
|
52
|
+
import { ServiceRegistry } from './service-registry';
|
|
53
|
+
|
|
54
|
+
export type ClientServicesHostProps = {
|
|
48
55
|
/**
|
|
49
56
|
* Can be omitted if `initialize` is later called.
|
|
50
57
|
*/
|
|
@@ -56,7 +63,8 @@ export type ClientServicesHostParams = {
|
|
|
56
63
|
level?: LevelDB;
|
|
57
64
|
lockKey?: string;
|
|
58
65
|
callbacks?: ClientServicesHostCallbacks;
|
|
59
|
-
|
|
66
|
+
runtime: RuntimeProvider.RuntimeProvider<SqlClient.SqlClient | SqlExport.SqlExport | SqlTransaction.SqlTransaction>;
|
|
67
|
+
runtimeProps?: ServiceContextRuntimeProps;
|
|
60
68
|
};
|
|
61
69
|
|
|
62
70
|
export type ClientServicesHostCallbacks = {
|
|
@@ -81,8 +89,9 @@ export class ClientServicesHost {
|
|
|
81
89
|
private readonly _loggingService: LoggingServiceImpl;
|
|
82
90
|
private readonly _tracingService = TRACE_PROCESSOR.createTraceSender();
|
|
83
91
|
|
|
84
|
-
private _config?: Config;
|
|
85
92
|
private readonly _statusUpdate = new Event<void>();
|
|
93
|
+
|
|
94
|
+
private _config?: Config;
|
|
86
95
|
private _signalManager?: SignalManager;
|
|
87
96
|
private _networkManager?: SwarmNetworkManager;
|
|
88
97
|
private _storage?: Storage;
|
|
@@ -93,7 +102,10 @@ export class ClientServicesHost {
|
|
|
93
102
|
private _edgeHttpClient?: EdgeHttpClient = undefined;
|
|
94
103
|
|
|
95
104
|
private _serviceContext!: ServiceContext;
|
|
96
|
-
private readonly
|
|
105
|
+
private readonly _runtime: RuntimeProvider.RuntimeProvider<
|
|
106
|
+
SqlClient.SqlClient | SqlExport.SqlExport | SqlTransaction.SqlTransaction
|
|
107
|
+
>;
|
|
108
|
+
private readonly _runtimeProps: ServiceContextRuntimeProps;
|
|
97
109
|
private diagnosticsBroadcastHandler: CollectDiagnosticsBroadcastHandler;
|
|
98
110
|
|
|
99
111
|
@Trace.info()
|
|
@@ -114,20 +126,14 @@ export class ClientServicesHost {
|
|
|
114
126
|
// TODO(wittjosiah): Turn this on by default.
|
|
115
127
|
lockKey,
|
|
116
128
|
callbacks,
|
|
117
|
-
|
|
118
|
-
|
|
129
|
+
runtime,
|
|
130
|
+
runtimeProps,
|
|
131
|
+
}: ClientServicesHostProps) {
|
|
119
132
|
this._storage = storage;
|
|
120
133
|
this._level = level;
|
|
121
134
|
this._callbacks = callbacks;
|
|
122
|
-
this.
|
|
123
|
-
|
|
124
|
-
if (this._runtimeParams.disableP2pReplication === undefined) {
|
|
125
|
-
this._runtimeParams.disableP2pReplication = config?.get('runtime.client.disableP2pReplication', false);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
if (this._runtimeParams.enableVectorIndexing === undefined) {
|
|
129
|
-
this._runtimeParams.enableVectorIndexing = config?.get('runtime.client.enableVectorIndexing', false);
|
|
130
|
-
}
|
|
135
|
+
this._runtime = runtime;
|
|
136
|
+
this._runtimeProps = runtimeProps ?? {};
|
|
131
137
|
|
|
132
138
|
if (config) {
|
|
133
139
|
this.initialize({ config, transportFactory, signalManager });
|
|
@@ -198,6 +204,30 @@ export class ClientServicesHost {
|
|
|
198
204
|
return this._serviceRegistry.services;
|
|
199
205
|
}
|
|
200
206
|
|
|
207
|
+
/**
|
|
208
|
+
* Debugging util.
|
|
209
|
+
*/
|
|
210
|
+
async exportSqliteDatabase(): Promise<Uint8Array> {
|
|
211
|
+
return await RuntimeProvider.runPromise(this._runtime)(
|
|
212
|
+
Effect.gen(function* () {
|
|
213
|
+
const sql = yield* SqlExport.SqlExport;
|
|
214
|
+
return yield* sql.export;
|
|
215
|
+
}),
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Debugging util.
|
|
221
|
+
*/
|
|
222
|
+
async runSqliteQuery(query: string, params?: any[]): Promise<readonly Record<string, unknown>[]> {
|
|
223
|
+
return await RuntimeProvider.runPromise(this._runtime)(
|
|
224
|
+
Effect.gen(function* () {
|
|
225
|
+
const sql = yield* SqlClient.SqlClient;
|
|
226
|
+
return yield* sql`${sql.unsafe(query, params)}`;
|
|
227
|
+
}),
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
|
|
201
231
|
/**
|
|
202
232
|
* Initialize the service host with the config.
|
|
203
233
|
* Config can also be provided in the constructor.
|
|
@@ -208,6 +238,16 @@ export class ClientServicesHost {
|
|
|
208
238
|
log('initializing...');
|
|
209
239
|
|
|
210
240
|
if (config) {
|
|
241
|
+
if (this._runtimeProps.disableP2pReplication === undefined) {
|
|
242
|
+
this._runtimeProps.disableP2pReplication = config?.get('runtime.client.disableP2pReplication', false);
|
|
243
|
+
}
|
|
244
|
+
if (this._runtimeProps.enableVectorIndexing === undefined) {
|
|
245
|
+
this._runtimeProps.enableVectorIndexing = config?.get('runtime.client.enableVectorIndexing', false);
|
|
246
|
+
}
|
|
247
|
+
if (this._runtimeProps.enableLocalQueues === undefined) {
|
|
248
|
+
this._runtimeProps.enableLocalQueues = config?.get('runtime.client.enableLocalQueues', false);
|
|
249
|
+
}
|
|
250
|
+
|
|
211
251
|
invariant(!this._config, 'config already set');
|
|
212
252
|
this._config = config;
|
|
213
253
|
if (!this._storage) {
|
|
@@ -215,14 +255,15 @@ export class ClientServicesHost {
|
|
|
215
255
|
}
|
|
216
256
|
}
|
|
217
257
|
|
|
258
|
+
// TODO(wittjosiah): This is quite noisy during tests. Make configurable? Remove?
|
|
218
259
|
if (!options.signalManager) {
|
|
219
|
-
log.warn('running signaling without telemetry metadata.');
|
|
260
|
+
// log.warn('running signaling without telemetry metadata.');
|
|
220
261
|
}
|
|
221
262
|
|
|
222
|
-
const
|
|
223
|
-
if (
|
|
224
|
-
this._edgeConnection = new EdgeClient(createStubEdgeIdentity(), { socketEndpoint:
|
|
225
|
-
this._edgeHttpClient = new EdgeHttpClient(
|
|
263
|
+
const endpoint = config?.get('runtime.services.edge.url');
|
|
264
|
+
if (endpoint) {
|
|
265
|
+
this._edgeConnection = new EdgeClient(createStubEdgeIdentity(), { socketEndpoint: endpoint });
|
|
266
|
+
this._edgeHttpClient = new EdgeHttpClient(endpoint);
|
|
226
267
|
}
|
|
227
268
|
|
|
228
269
|
const {
|
|
@@ -288,7 +329,8 @@ export class ClientServicesHost {
|
|
|
288
329
|
this._signalManager,
|
|
289
330
|
this._edgeConnection,
|
|
290
331
|
this._edgeHttpClient,
|
|
291
|
-
this.
|
|
332
|
+
this._runtime,
|
|
333
|
+
this._runtimeProps,
|
|
292
334
|
this._config.get('runtime.client.edgeFeatures'),
|
|
293
335
|
);
|
|
294
336
|
|
|
@@ -332,6 +374,7 @@ export class ClientServicesHost {
|
|
|
332
374
|
|
|
333
375
|
DataService: this._serviceContext.echoHost.dataService,
|
|
334
376
|
QueryService: this._serviceContext.echoHost.queryService,
|
|
377
|
+
QueueService: this._serviceContext.echoHost.queuesService,
|
|
335
378
|
|
|
336
379
|
NetworkService: new NetworkServiceImpl(
|
|
337
380
|
this._serviceContext.networkManager,
|
|
@@ -405,6 +448,12 @@ export class ClientServicesHost {
|
|
|
405
448
|
this._resetting = true;
|
|
406
449
|
this._statusUpdate.emit();
|
|
407
450
|
await this._serviceContext?.close();
|
|
451
|
+
// Clear LevelDB contents to remove all persisted Echo/Automerge/index data.
|
|
452
|
+
try {
|
|
453
|
+
await this._level!.clear();
|
|
454
|
+
} catch (err) {
|
|
455
|
+
log.warn('failed to clear leveldb during reset', { err });
|
|
456
|
+
}
|
|
408
457
|
await this._storage!.reset();
|
|
409
458
|
log.info('reset');
|
|
410
459
|
log.trace('dxos.sdk.client-services-host.reset', trace.end({ id: traceId }));
|
|
@@ -13,10 +13,11 @@ import { schema } from '@dxos/protocols/proto';
|
|
|
13
13
|
import { type SystemService, SystemStatus } from '@dxos/protocols/proto/dxos/client/services';
|
|
14
14
|
import { createLinkedPorts, createProtoRpcPeer, createServiceBundle } from '@dxos/rpc';
|
|
15
15
|
|
|
16
|
-
import { ServiceRegistry } from './service-registry';
|
|
17
16
|
import { SystemServiceImpl } from '../system';
|
|
18
17
|
import { createServiceContext } from '../testing';
|
|
19
18
|
|
|
19
|
+
import { ServiceRegistry } from './service-registry';
|
|
20
|
+
|
|
20
21
|
// TODO(burdon): Create TestService (that doesn't require peers).
|
|
21
22
|
|
|
22
23
|
type TestServices = {
|
|
@@ -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}/`))) {
|
|
@@ -29,6 +29,6 @@ export const extractSpaceArchive = async (archive: SpaceArchive): Promise<Extrac
|
|
|
29
29
|
documents[documentId] = entry.content ?? failedInvariant();
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
log
|
|
32
|
+
log('extracted space archive', { metadata, documents });
|
|
33
33
|
return { metadata, documents };
|
|
34
34
|
};
|
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
import type * as tar from '@obsidize/tar-browserify';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { type Context, Resource } from '@dxos/context';
|
|
8
8
|
import { assertArgument, assertState } from '@dxos/invariant';
|
|
9
9
|
import type { IdentityDid, SpaceId } from '@dxos/keys';
|
|
10
|
-
import { SpaceArchiveFileStructure,
|
|
10
|
+
import { SpaceArchiveFileStructure, type SpaceArchiveMetadata, SpaceArchiveVersion } from '@dxos/protocols';
|
|
11
11
|
import type { SpaceArchive } from '@dxos/protocols/proto/dxos/client/services';
|
|
12
|
+
import { createFilename } from '@dxos/util';
|
|
12
13
|
|
|
13
14
|
export type SpaceArchiveBeginProps = {
|
|
14
15
|
spaceId?: SpaceId;
|
|
@@ -44,14 +45,14 @@ export class SpaceArchiveWriter extends Resource {
|
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
async setCurrentRootUrl(url: string): Promise<void> {
|
|
47
|
-
assertArgument(url.startsWith('automerge:'), 'Invalid root URL');
|
|
48
|
+
assertArgument(url.startsWith('automerge:'), 'url', 'Invalid root URL');
|
|
48
49
|
assertState(this._tar, 'Not open');
|
|
49
50
|
assertState(this._meta, 'Not started');
|
|
50
51
|
this._currentRootUrl = url;
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
async writeDocument(documentId: string, data: Uint8Array): Promise<void> {
|
|
54
|
-
assertArgument(!documentId.startsWith('automerge:'), 'Invalid document ID');
|
|
55
|
+
assertArgument(!documentId.startsWith('automerge:'), 'documentId', 'Invalid document ID');
|
|
55
56
|
assertState(this._archive, 'Not open');
|
|
56
57
|
this._archive.addBinaryFile(`${SpaceArchiveFileStructure.documents}/${documentId}.bin`, data);
|
|
57
58
|
}
|
|
@@ -59,6 +60,7 @@ export class SpaceArchiveWriter extends Resource {
|
|
|
59
60
|
async finish(): Promise<SpaceArchive> {
|
|
60
61
|
assertState(this._archive, 'Not open');
|
|
61
62
|
assertState(this._meta, 'Not started');
|
|
63
|
+
assertState(this._meta.spaceId, 'No space ID set');
|
|
62
64
|
assertState(this._currentRootUrl, 'No root URL set');
|
|
63
65
|
|
|
64
66
|
const metadata: SpaceArchiveMetadata = {
|
|
@@ -76,7 +78,7 @@ export class SpaceArchiveWriter extends Resource {
|
|
|
76
78
|
const binary = this._archive.toUint8Array();
|
|
77
79
|
|
|
78
80
|
return {
|
|
79
|
-
filename:
|
|
81
|
+
filename: createFilename({ parts: [this._meta.spaceId], ext: 'tar' }),
|
|
80
82
|
contents: binary,
|
|
81
83
|
};
|
|
82
84
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Event } from '@dxos/async';
|
|
6
|
-
import {
|
|
6
|
+
import { type Context, Resource } from '@dxos/context';
|
|
7
7
|
import { type CredentialProcessor, type SpecificCredential, checkCredentialType } from '@dxos/credentials';
|
|
8
8
|
import { type Credential, type Epoch } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
9
9
|
|