@dxos/client-services 0.8.4-main.b97322e → 0.8.4-main.bc674ce
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-WKKP35EC.mjs → chunk-J33W6T4Q.mjs} +3625 -3714
- package/dist/lib/browser/chunk-J33W6T4Q.mjs.map +7 -0
- package/dist/lib/browser/chunk-NQSC7HOE.mjs +22 -0
- package/dist/lib/browser/chunk-NQSC7HOE.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 +462 -76
- 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 +34 -22
- 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-ZE2HYS56.mjs → chunk-34HKLADW.mjs} +2633 -2590
- package/dist/lib/node-esm/chunk-34HKLADW.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/index.mjs +462 -76
- 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 +34 -22
- 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/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 +1 -1
- package/dist/types/src/packlets/locks/index.d.ts.map +1 -1
- package/dist/types/src/packlets/logging/logging-service.d.ts +1 -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/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 +19 -5
- 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 +23 -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/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 +1 -1
- package/src/packlets/invitations/device-invitation-protocol.ts +6 -5
- package/src/packlets/invitations/edge-invitation-handler.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 +4 -3
- 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 +2 -2
- 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 +1 -1
- package/src/packlets/logging/logging-service.ts +3 -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/service-context.test.ts +1 -1
- package/src/packlets/services/service-context.ts +39 -27
- package/src/packlets/services/service-host.test.ts +3 -2
- package/src/packlets/services/service-host.ts +72 -24
- 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 +15 -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 +143 -12
- package/src/packlets/worker/worker-session.ts +7 -7
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-WKKP35EC.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZE2HYS56.mjs.map +0 -7
|
@@ -13,12 +13,12 @@ import {
|
|
|
13
13
|
log,
|
|
14
14
|
} from '@dxos/log';
|
|
15
15
|
import {
|
|
16
|
+
type ControlMetricsRequest,
|
|
17
|
+
type ControlMetricsResponse,
|
|
16
18
|
type LogEntry,
|
|
17
19
|
type LoggingService,
|
|
18
20
|
type Metrics,
|
|
19
21
|
QueryLogsRequest,
|
|
20
|
-
type ControlMetricsRequest,
|
|
21
|
-
type ControlMetricsResponse,
|
|
22
22
|
type QueryMetricsRequest,
|
|
23
23
|
type QueryMetricsResponse,
|
|
24
24
|
} from '@dxos/protocols/proto/dxos/client/services';
|
|
@@ -37,7 +37,7 @@ export class LoggingServiceImpl implements LoggingService {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
async close(): Promise<void> {
|
|
40
|
-
const index = log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
|
|
40
|
+
const index = log.runtimeConfig.processors.findIndex((processor: LogProcessor) => processor === this._logProcessor);
|
|
41
41
|
log.runtimeConfig.processors.splice(index, 1);
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { afterEach, beforeEach, describe, expect, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { Trigger } from '@dxos/async';
|
|
8
|
-
import {
|
|
8
|
+
import { LogLevel, log } from '@dxos/log';
|
|
9
9
|
import { type LogEntry } from '@dxos/protocols/proto/dxos/client/services';
|
|
10
10
|
|
|
11
11
|
import { LoggingServiceImpl } from './logging-service';
|
|
@@ -2,16 +2,17 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { afterEach,
|
|
5
|
+
import { afterEach, beforeEach, describe, expect, onTestFinished, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { Trigger } from '@dxos/async';
|
|
8
8
|
import { Context } from '@dxos/context';
|
|
9
|
-
import { type NetworkService
|
|
9
|
+
import { ConnectionState, type NetworkService } from '@dxos/protocols/proto/dxos/client/services';
|
|
10
10
|
|
|
11
|
-
import { NetworkServiceImpl } from './network-service';
|
|
12
11
|
import { type ServiceContext } from '../services';
|
|
13
12
|
import { createServiceContext } from '../testing';
|
|
14
13
|
|
|
14
|
+
import { NetworkServiceImpl } from './network-service';
|
|
15
|
+
|
|
15
16
|
describe('NetworkService', () => {
|
|
16
17
|
let serviceContext: ServiceContext;
|
|
17
18
|
let networkService: NetworkService;
|
|
@@ -7,15 +7,15 @@ import { type EdgeConnection } from '@dxos/edge-client';
|
|
|
7
7
|
import { type SignalManager } from '@dxos/messaging';
|
|
8
8
|
import { type SwarmNetworkManager } from '@dxos/network-manager';
|
|
9
9
|
import {
|
|
10
|
-
type SubscribeSwarmStateRequest,
|
|
11
10
|
type NetworkService,
|
|
12
11
|
type NetworkStatus,
|
|
12
|
+
type SubscribeSwarmStateRequest,
|
|
13
13
|
type UpdateConfigRequest,
|
|
14
14
|
} from '@dxos/protocols/proto/dxos/client/services';
|
|
15
15
|
import { type Peer, type SwarmResponse } from '@dxos/protocols/proto/dxos/edge/messenger';
|
|
16
16
|
import {
|
|
17
|
-
type LeaveRequest,
|
|
18
17
|
type JoinRequest,
|
|
18
|
+
type LeaveRequest,
|
|
19
19
|
type Message,
|
|
20
20
|
type QueryRequest,
|
|
21
21
|
} from '@dxos/protocols/proto/dxos/edge/signal';
|
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
import { type ClientServices } from '@dxos/client-protocol';
|
|
6
6
|
import { type Any, type ServiceHandler, Stream } from '@dxos/codec-protobuf';
|
|
7
7
|
import { raise } from '@dxos/debug';
|
|
8
|
-
import {
|
|
8
|
+
import { RpcPeer, type RpcPeerOptions, type ServiceBundle, parseMethodName } from '@dxos/rpc';
|
|
9
9
|
import { MapCounter, trace } from '@dxos/tracing';
|
|
10
10
|
import { type MaybePromise } from '@dxos/util';
|
|
11
11
|
|
|
12
12
|
import { type ServiceRegistry } from './service-registry';
|
|
13
13
|
|
|
14
|
-
export type
|
|
14
|
+
export type ClientRpcServerProps = {
|
|
15
15
|
serviceRegistry: ServiceRegistry<ClientServices>;
|
|
16
16
|
handleCall?: (
|
|
17
17
|
method: string,
|
|
@@ -30,8 +30,8 @@ export class ClientRpcServer {
|
|
|
30
30
|
private readonly _serviceRegistry: ServiceRegistry<ClientServices>;
|
|
31
31
|
private readonly _rpcPeer: RpcPeer;
|
|
32
32
|
private readonly _handlerCache = new Map<string, ServiceHandler<any>>();
|
|
33
|
-
private readonly _handleCall:
|
|
34
|
-
private readonly _handleStream:
|
|
33
|
+
private readonly _handleCall: ClientRpcServerProps['handleCall'];
|
|
34
|
+
private readonly _handleStream: ClientRpcServerProps['handleStream'];
|
|
35
35
|
|
|
36
36
|
@trace.metricsCounter()
|
|
37
37
|
private readonly _callMetrics = new MapCounter();
|
|
@@ -41,7 +41,7 @@ export class ClientRpcServer {
|
|
|
41
41
|
return Object.keys(this._serviceRegistry.services);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
constructor(params:
|
|
44
|
+
constructor(params: ClientRpcServerProps) {
|
|
45
45
|
const { serviceRegistry, handleCall, handleStream, ...rpcOptions } = params;
|
|
46
46
|
this._handleCall = handleCall;
|
|
47
47
|
this._handleStream = handleStream;
|
|
@@ -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';
|
|
@@ -30,36 +33,39 @@ import { type Runtime } from '@dxos/protocols/proto/dxos/config';
|
|
|
30
33
|
import type { FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
|
|
31
34
|
import { type Credential, type ProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
32
35
|
import { type Storage } from '@dxos/random-access-storage';
|
|
36
|
+
import type * as SqlTransaction from '@dxos/sql-sqlite/SqlTransaction';
|
|
33
37
|
import { BlobStore } from '@dxos/teleport-extension-object-sync';
|
|
34
38
|
import { trace as Trace } from '@dxos/tracing';
|
|
35
39
|
import { safeInstanceof } from '@dxos/util';
|
|
36
40
|
|
|
37
41
|
import { EdgeAgentManager } from '../agents';
|
|
38
42
|
import {
|
|
39
|
-
IdentityManager,
|
|
40
43
|
type CreateIdentityOptions,
|
|
41
|
-
|
|
42
|
-
type
|
|
44
|
+
IdentityManager,
|
|
45
|
+
type IdentityManagerProps,
|
|
46
|
+
type JoinIdentityProps,
|
|
43
47
|
} from '../identity';
|
|
44
48
|
import { EdgeIdentityRecoveryManager } from '../identity/identity-recovery-manager';
|
|
45
49
|
import {
|
|
46
50
|
DeviceInvitationProtocol,
|
|
47
|
-
type
|
|
51
|
+
type InvitationConnectionProps,
|
|
52
|
+
type InvitationProtocol,
|
|
48
53
|
InvitationsHandler,
|
|
49
54
|
InvitationsManager,
|
|
50
55
|
SpaceInvitationProtocol,
|
|
51
|
-
type InvitationProtocol,
|
|
52
56
|
} from '../invitations';
|
|
53
|
-
import { DataSpaceManager, type
|
|
57
|
+
import { DataSpaceManager, type DataSpaceManagerRuntimeProps, type SigningContext } from '../spaces';
|
|
54
58
|
|
|
55
|
-
export type
|
|
56
|
-
|
|
59
|
+
export type ServiceContextRuntimeProps = Pick<
|
|
60
|
+
IdentityManagerProps,
|
|
57
61
|
'devicePresenceOfflineTimeout' | 'devicePresenceAnnounceInterval'
|
|
58
62
|
> &
|
|
59
|
-
|
|
60
|
-
|
|
63
|
+
DataSpaceManagerRuntimeProps & {
|
|
64
|
+
invitationConnectionDefaultProps?: InvitationConnectionProps;
|
|
61
65
|
disableP2pReplication?: boolean;
|
|
62
66
|
enableVectorIndexing?: boolean;
|
|
67
|
+
enableSqlite?: boolean;
|
|
68
|
+
enableLocalQueues?: boolean;
|
|
63
69
|
};
|
|
64
70
|
/**
|
|
65
71
|
* Shared backend for all client services.
|
|
@@ -105,11 +111,15 @@ export class ServiceContext extends Resource {
|
|
|
105
111
|
public readonly signalManager: SignalManager,
|
|
106
112
|
private readonly _edgeConnection: EdgeConnection | undefined,
|
|
107
113
|
private readonly _edgeHttpClient: EdgeHttpClient | undefined,
|
|
108
|
-
|
|
114
|
+
private readonly _runtime: RuntimeProvider.RuntimeProvider<SqlClient.SqlClient | SqlTransaction.SqlTransaction>,
|
|
115
|
+
public readonly _runtimeProps?: ServiceContextRuntimeProps,
|
|
109
116
|
private readonly _edgeFeatures?: Runtime.Client.EdgeFeatures,
|
|
110
117
|
) {
|
|
111
118
|
super();
|
|
112
119
|
|
|
120
|
+
log('runtimeProps', this._runtimeProps);
|
|
121
|
+
log('edgeFeatures', this._edgeFeatures);
|
|
122
|
+
|
|
113
123
|
// TODO(burdon): Move strings to constants.
|
|
114
124
|
this.metadataStore = new MetadataStore(storage.createDirectory('metadata'));
|
|
115
125
|
this.blobStore = new BlobStore(storage.createDirectory('blobs'));
|
|
@@ -131,7 +141,7 @@ export class ServiceContext extends Resource {
|
|
|
131
141
|
networkManager: this.networkManager,
|
|
132
142
|
blobStore: this.blobStore,
|
|
133
143
|
metadataStore: this.metadataStore,
|
|
134
|
-
disableP2pReplication: this.
|
|
144
|
+
disableP2pReplication: this._runtimeProps?.disableP2pReplication,
|
|
135
145
|
});
|
|
136
146
|
|
|
137
147
|
this.identityManager = new IdentityManager({
|
|
@@ -139,8 +149,8 @@ export class ServiceContext extends Resource {
|
|
|
139
149
|
keyring: this.keyring,
|
|
140
150
|
feedStore: this.feedStore,
|
|
141
151
|
spaceManager: this.spaceManager,
|
|
142
|
-
devicePresenceOfflineTimeout: this.
|
|
143
|
-
devicePresenceAnnounceInterval: this.
|
|
152
|
+
devicePresenceOfflineTimeout: this._runtimeProps?.devicePresenceOfflineTimeout,
|
|
153
|
+
devicePresenceAnnounceInterval: this._runtimeProps?.devicePresenceAnnounceInterval,
|
|
144
154
|
edgeConnection: this._edgeConnection,
|
|
145
155
|
edgeFeatures: this._edgeFeatures,
|
|
146
156
|
});
|
|
@@ -157,16 +167,17 @@ export class ServiceContext extends Resource {
|
|
|
157
167
|
peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex(),
|
|
158
168
|
getSpaceKeyByRootDocumentId: (documentId) => this.spaceManager.findSpaceByRootDocumentId(documentId)?.key,
|
|
159
169
|
indexing: {
|
|
160
|
-
vector: this.
|
|
170
|
+
vector: this._runtimeProps?.enableVectorIndexing,
|
|
171
|
+
sqlIndex: this._runtimeProps?.enableSqlite,
|
|
161
172
|
},
|
|
173
|
+
runtime: this._runtime,
|
|
174
|
+
localQueues: this._runtimeProps?.enableLocalQueues,
|
|
162
175
|
});
|
|
163
176
|
|
|
164
|
-
this._meshReplicator = new MeshEchoReplicator();
|
|
165
|
-
|
|
166
177
|
this.invitations = new InvitationsHandler(
|
|
167
178
|
this.networkManager, //
|
|
168
179
|
this._edgeHttpClient,
|
|
169
|
-
|
|
180
|
+
_runtimeProps?.invitationConnectionDefaultProps,
|
|
170
181
|
);
|
|
171
182
|
this.invitationsManager = new InvitationsManager(
|
|
172
183
|
this.invitations,
|
|
@@ -186,12 +197,13 @@ export class ServiceContext extends Resource {
|
|
|
186
197
|
),
|
|
187
198
|
);
|
|
188
199
|
|
|
189
|
-
if (!this.
|
|
200
|
+
if (!this._runtimeProps?.disableP2pReplication) {
|
|
190
201
|
this._meshReplicator = new MeshEchoReplicator();
|
|
191
202
|
}
|
|
192
|
-
if (this._edgeConnection && this._edgeFeatures?.echoReplicator) {
|
|
203
|
+
if (this._edgeConnection && this._edgeFeatures?.echoReplicator && this._edgeHttpClient) {
|
|
193
204
|
this._echoEdgeReplicator = new EchoEdgeReplicator({
|
|
194
205
|
edgeConnection: this._edgeConnection,
|
|
206
|
+
edgeHttpClient: this._edgeHttpClient,
|
|
195
207
|
});
|
|
196
208
|
}
|
|
197
209
|
}
|
|
@@ -244,13 +256,13 @@ export class ServiceContext extends Resource {
|
|
|
244
256
|
await this.edgeAgentManager?.close();
|
|
245
257
|
await this.identityManager.close();
|
|
246
258
|
await this.spaceManager.close();
|
|
247
|
-
await this.feedStore.close();
|
|
248
|
-
await this.metadataStore.close();
|
|
249
|
-
|
|
250
259
|
await this.echoHost.close(ctx);
|
|
260
|
+
|
|
251
261
|
await this.networkManager.close();
|
|
252
262
|
await this.signalManager.close();
|
|
253
263
|
await this._edgeConnection?.close();
|
|
264
|
+
await this.feedStore.close();
|
|
265
|
+
await this.metadataStore.close();
|
|
254
266
|
|
|
255
267
|
log('closed');
|
|
256
268
|
}
|
|
@@ -282,7 +294,7 @@ export class ServiceContext extends Resource {
|
|
|
282
294
|
}
|
|
283
295
|
}
|
|
284
296
|
|
|
285
|
-
private async _acceptIdentity(params:
|
|
297
|
+
private async _acceptIdentity(params: JoinIdentityProps) {
|
|
286
298
|
const { identity, identityRecord } = await this.identityManager.prepareIdentity(params);
|
|
287
299
|
await this._setNetworkIdentity({ deviceCredential: params.authorizedDeviceCredential! });
|
|
288
300
|
await identity.joinNetwork();
|
|
@@ -326,7 +338,7 @@ export class ServiceContext extends Resource {
|
|
|
326
338
|
edgeHttpClient: this._edgeHttpClient,
|
|
327
339
|
echoEdgeReplicator: this._echoEdgeReplicator,
|
|
328
340
|
meshReplicator: this._meshReplicator,
|
|
329
|
-
|
|
341
|
+
runtimeProps: this._runtimeProps as DataSpaceManagerRuntimeProps,
|
|
330
342
|
edgeFeatures: this._edgeFeatures,
|
|
331
343
|
});
|
|
332
344
|
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 = {
|
|
@@ -94,7 +102,10 @@ export class ClientServicesHost {
|
|
|
94
102
|
private _edgeHttpClient?: EdgeHttpClient = undefined;
|
|
95
103
|
|
|
96
104
|
private _serviceContext!: ServiceContext;
|
|
97
|
-
private readonly
|
|
105
|
+
private readonly _runtime: RuntimeProvider.RuntimeProvider<
|
|
106
|
+
SqlClient.SqlClient | SqlExport.SqlExport | SqlTransaction.SqlTransaction
|
|
107
|
+
>;
|
|
108
|
+
private readonly _runtimeProps: ServiceContextRuntimeProps;
|
|
98
109
|
private diagnosticsBroadcastHandler: CollectDiagnosticsBroadcastHandler;
|
|
99
110
|
|
|
100
111
|
@Trace.info()
|
|
@@ -115,20 +126,14 @@ export class ClientServicesHost {
|
|
|
115
126
|
// TODO(wittjosiah): Turn this on by default.
|
|
116
127
|
lockKey,
|
|
117
128
|
callbacks,
|
|
118
|
-
|
|
119
|
-
|
|
129
|
+
runtime,
|
|
130
|
+
runtimeProps,
|
|
131
|
+
}: ClientServicesHostProps) {
|
|
120
132
|
this._storage = storage;
|
|
121
133
|
this._level = level;
|
|
122
134
|
this._callbacks = callbacks;
|
|
123
|
-
this.
|
|
124
|
-
|
|
125
|
-
if (this._runtimeParams.disableP2pReplication === undefined) {
|
|
126
|
-
this._runtimeParams.disableP2pReplication = config?.get('runtime.client.disableP2pReplication', false);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
if (this._runtimeParams.enableVectorIndexing === undefined) {
|
|
130
|
-
this._runtimeParams.enableVectorIndexing = config?.get('runtime.client.enableVectorIndexing', false);
|
|
131
|
-
}
|
|
135
|
+
this._runtime = runtime;
|
|
136
|
+
this._runtimeProps = runtimeProps ?? {};
|
|
132
137
|
|
|
133
138
|
if (config) {
|
|
134
139
|
this.initialize({ config, transportFactory, signalManager });
|
|
@@ -199,6 +204,30 @@ export class ClientServicesHost {
|
|
|
199
204
|
return this._serviceRegistry.services;
|
|
200
205
|
}
|
|
201
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
|
+
|
|
202
231
|
/**
|
|
203
232
|
* Initialize the service host with the config.
|
|
204
233
|
* Config can also be provided in the constructor.
|
|
@@ -209,6 +238,16 @@ export class ClientServicesHost {
|
|
|
209
238
|
log('initializing...');
|
|
210
239
|
|
|
211
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
|
+
|
|
212
251
|
invariant(!this._config, 'config already set');
|
|
213
252
|
this._config = config;
|
|
214
253
|
if (!this._storage) {
|
|
@@ -216,8 +255,9 @@ export class ClientServicesHost {
|
|
|
216
255
|
}
|
|
217
256
|
}
|
|
218
257
|
|
|
258
|
+
// TODO(wittjosiah): This is quite noisy during tests. Make configurable? Remove?
|
|
219
259
|
if (!options.signalManager) {
|
|
220
|
-
log.warn('running signaling without telemetry metadata.');
|
|
260
|
+
// log.warn('running signaling without telemetry metadata.');
|
|
221
261
|
}
|
|
222
262
|
|
|
223
263
|
const endpoint = config?.get('runtime.services.edge.url');
|
|
@@ -289,7 +329,8 @@ export class ClientServicesHost {
|
|
|
289
329
|
this._signalManager,
|
|
290
330
|
this._edgeConnection,
|
|
291
331
|
this._edgeHttpClient,
|
|
292
|
-
this.
|
|
332
|
+
this._runtime,
|
|
333
|
+
this._runtimeProps,
|
|
293
334
|
this._config.get('runtime.client.edgeFeatures'),
|
|
294
335
|
);
|
|
295
336
|
|
|
@@ -333,6 +374,7 @@ export class ClientServicesHost {
|
|
|
333
374
|
|
|
334
375
|
DataService: this._serviceContext.echoHost.dataService,
|
|
335
376
|
QueryService: this._serviceContext.echoHost.queryService,
|
|
377
|
+
QueueService: this._serviceContext.echoHost.queuesService,
|
|
336
378
|
|
|
337
379
|
NetworkService: new NetworkServiceImpl(
|
|
338
380
|
this._serviceContext.networkManager,
|
|
@@ -406,6 +448,12 @@ export class ClientServicesHost {
|
|
|
406
448
|
this._resetting = true;
|
|
407
449
|
this._statusUpdate.emit();
|
|
408
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
|
+
}
|
|
409
457
|
await this._storage!.reset();
|
|
410
458
|
log.info('reset');
|
|
411
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
|
|