@dxos/client-services 0.8.4-main.b97322e → 0.8.4-main.bc2380dfbc
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/LICENSE +102 -5
- package/README.md +1 -1
- package/dist/lib/browser/chunk-QCWEHHJW.mjs +24 -0
- package/dist/lib/browser/chunk-QCWEHHJW.mjs.map +7 -0
- package/dist/lib/browser/{chunk-WKKP35EC.mjs → chunk-TUCJORVO.mjs} +3173 -4457
- package/dist/lib/browser/chunk-TUCJORVO.mjs.map +7 -0
- package/dist/lib/browser/chunk-XJRPB3GA.mjs +22 -0
- package/dist/lib/browser/chunk-XJRPB3GA.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +451 -145
- 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 +88 -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 +86 -0
- package/dist/lib/browser/packlets/locks/browser.mjs.map +7 -0
- package/dist/lib/browser/packlets/locks/node.mjs +48 -0
- package/dist/lib/browser/packlets/locks/node.mjs.map +7 -0
- package/dist/lib/browser/testing/index.mjs +35 -36
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/chunk-2DT3MZRL.mjs +22 -0
- package/dist/lib/node-esm/chunk-2DT3MZRL.mjs.map +7 -0
- 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-IQLAKNSR.mjs} +3052 -4204
- package/dist/lib/node-esm/chunk-IQLAKNSR.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +451 -145
- 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 +88 -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 +86 -0
- package/dist/lib/node-esm/packlets/locks/browser.mjs.map +7 -0
- package/dist/lib/node-esm/packlets/locks/node.mjs +48 -0
- package/dist/lib/node-esm/packlets/locks/node.mjs.map +7 -0
- package/dist/lib/node-esm/testing/index.mjs +35 -36
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/packlets/agents/edge-agent-manager.d.ts +3 -2
- package/dist/types/src/packlets/agents/edge-agent-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/agents/edge-agent-service.d.ts +3 -2
- 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/keys.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/metadata.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/devtools/spaces.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-collector.d.ts.map +1 -1
- package/dist/types/src/packlets/diagnostics/diagnostics.d.ts +3 -4
- 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/identity-manager.d.ts +7 -7
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts +8 -7
- package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-service.d.ts +6 -10
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +9 -12
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts +6 -5
- 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 +2 -2
- 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 +8 -5
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-state.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-topology.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 +3 -3
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-service.d.ts +4 -4
- package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +5 -4
- 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/browser.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/locks/node.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 +7 -6
- package/dist/types/src/packlets/network/network-service.d.ts.map +1 -1
- package/dist/types/src/packlets/services/client-rpc-server.d.ts +5 -5
- package/dist/types/src/packlets/services/client-rpc-server.d.ts.map +1 -1
- package/dist/types/src/packlets/services/feed-syncer.d.ts +59 -0
- package/dist/types/src/packlets/services/feed-syncer.d.ts.map +1 -0
- package/dist/types/src/packlets/services/feed-syncer.test.d.ts +2 -0
- package/dist/types/src/packlets/services/feed-syncer.test.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 -10
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +20 -7
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-registry.d.ts.map +1 -1
- package/dist/types/src/packlets/services/util.d.ts.map +1 -1
- package/dist/types/src/packlets/space-export/archive-format.d.ts +9 -0
- package/dist/types/src/packlets/space-export/archive-format.d.ts.map +1 -0
- package/dist/types/src/packlets/space-export/index.d.ts +4 -1
- package/dist/types/src/packlets/space-export/index.d.ts.map +1 -1
- package/dist/types/src/packlets/space-export/serialized-space-reader.d.ts +23 -0
- package/dist/types/src/packlets/space-export/serialized-space-reader.d.ts.map +1 -0
- package/dist/types/src/packlets/space-export/serialized-space-writer.d.ts +36 -0
- package/dist/types/src/packlets/space-export/serialized-space-writer.d.ts.map +1 -0
- package/dist/types/src/packlets/space-export/space-archive-reader.d.ts +9 -1
- package/dist/types/src/packlets/space-export/space-archive-reader.d.ts.map +1 -1
- package/dist/types/src/packlets/space-export/space-archive-writer.d.ts +8 -2
- package/dist/types/src/packlets/space-export/space-archive-writer.d.ts.map +1 -1
- package/dist/types/src/packlets/space-export/space-archive.test.d.ts +2 -0
- package/dist/types/src/packlets/space-export/space-archive.test.d.ts.map +1 -0
- 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 +31 -20
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +30 -13
- 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/epoch-migrations.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/genesis.d.ts +2 -1
- package/dist/types/src/packlets/spaces/genesis.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +6 -9
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +11 -8
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/level.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/storage/util.d.ts.map +1 -1
- package/dist/types/src/packlets/system/system-service.d.ts +2 -2
- package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/credential-utils.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 +41 -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 -4
- package/dist/types/src/packlets/worker/worker-session.d.ts.map +1 -1
- package/dist/types/src/testing/setup.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 +73 -56
- package/src/index.ts +1 -0
- package/src/packlets/agents/edge-agent-manager.ts +10 -7
- package/src/packlets/agents/edge-agent-service.ts +17 -5
- package/src/packlets/devices/devices-service.test.ts +3 -3
- package/src/packlets/devices/devices-service.ts +2 -2
- package/src/packlets/devtools/devtools.ts +29 -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 +2 -3
- 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 +2 -2
- package/src/packlets/identity/identity-manager.test.ts +8 -8
- package/src/packlets/identity/identity-manager.ts +25 -24
- package/src/packlets/identity/identity-recovery-manager.ts +22 -18
- package/src/packlets/identity/identity-service.test.ts +8 -28
- package/src/packlets/identity/identity-service.ts +13 -80
- package/src/packlets/identity/identity.test.ts +11 -11
- package/src/packlets/identity/identity.ts +17 -39
- package/src/packlets/invitations/device-invitation-protocol.test.ts +1 -1
- package/src/packlets/invitations/device-invitation-protocol.ts +8 -6
- package/src/packlets/invitations/edge-invitation-handler.ts +10 -6
- package/src/packlets/invitations/invitation-guest-extenstion.ts +7 -5
- package/src/packlets/invitations/invitation-host-extension.ts +15 -16
- package/src/packlets/invitations/invitation-protocol.ts +8 -5
- package/src/packlets/invitations/invitation-state.ts +1 -15
- package/src/packlets/invitations/invitations-handler.test.ts +7 -7
- package/src/packlets/invitations/invitations-handler.ts +77 -25
- package/src/packlets/invitations/invitations-manager.ts +43 -18
- package/src/packlets/invitations/invitations-service.ts +10 -10
- package/src/packlets/invitations/space-invitation-protocol.test.ts +19 -18
- package/src/packlets/invitations/space-invitation-protocol.ts +13 -17
- 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 +22 -18
- package/src/packlets/logging/logging.test.ts +1 -1
- package/src/packlets/network/network-service.test.ts +3 -3
- package/src/packlets/network/network-service.ts +12 -10
- package/src/packlets/services/client-rpc-server.ts +20 -17
- package/src/packlets/services/feed-syncer.test.ts +340 -0
- package/src/packlets/services/feed-syncer.ts +377 -0
- package/src/packlets/services/platform.ts +7 -1
- package/src/packlets/services/service-context.test.ts +4 -3
- package/src/packlets/services/service-context.ts +160 -67
- package/src/packlets/services/service-host.test.ts +10 -9
- package/src/packlets/services/service-host.ts +85 -47
- package/src/packlets/services/service-registry.test.ts +1 -1
- package/src/packlets/space-export/archive-format.ts +42 -0
- package/src/packlets/space-export/index.ts +4 -1
- package/src/packlets/space-export/serialized-space-reader.ts +111 -0
- package/src/packlets/space-export/serialized-space-writer.ts +252 -0
- package/src/packlets/space-export/space-archive-reader.ts +65 -4
- package/src/packlets/space-export/space-archive-writer.ts +44 -6
- package/src/packlets/space-export/space-archive.test.ts +461 -0
- 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.test.ts +79 -13
- package/src/packlets/spaces/data-space-manager.ts +134 -129
- package/src/packlets/spaces/data-space.ts +71 -42
- package/src/packlets/spaces/edge-feed-replicator.test.ts +4 -4
- package/src/packlets/spaces/edge-feed-replicator.ts +13 -11
- package/src/packlets/spaces/epoch-migrations.ts +6 -5
- package/src/packlets/spaces/genesis.ts +6 -1
- package/src/packlets/spaces/notarization-plugin.test.ts +3 -3
- package/src/packlets/spaces/notarization-plugin.ts +13 -12
- package/src/packlets/spaces/spaces-service.test.ts +20 -12
- package/src/packlets/spaces/spaces-service.ts +139 -38
- 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 +11 -7
- package/src/packlets/testing/test-builder.ts +39 -13
- package/src/packlets/worker/worker-runtime.ts +189 -17
- package/src/packlets/worker/worker-session.ts +15 -21
- 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
- package/dist/types/src/packlets/identity/default-space-state-machine.d.ts +0 -19
- package/dist/types/src/packlets/identity/default-space-state-machine.d.ts.map +0 -1
- package/src/packlets/identity/default-space-state-machine.ts +0 -44
|
@@ -2,39 +2,41 @@
|
|
|
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 {
|
|
7
|
-
import { type Config } from '@dxos/config';
|
|
9
|
+
import { type ClientServices, clientServiceBundle } from '@dxos/client-protocol';
|
|
10
|
+
import { type Config, resolveTelemetryTag } 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
|
-
import { PublicKey } from '@dxos/keys';
|
|
12
15
|
import { type LevelDB } from '@dxos/kv-store';
|
|
13
16
|
import { log } from '@dxos/log';
|
|
14
|
-
import { EdgeSignalManager,
|
|
17
|
+
import { EdgeSignalManager, type SignalManager, WebsocketSignalManager } from '@dxos/messaging';
|
|
15
18
|
import {
|
|
16
19
|
SwarmNetworkManager,
|
|
20
|
+
type TransportFactory,
|
|
17
21
|
createIceProvider,
|
|
18
22
|
createRtcTransportFactory,
|
|
19
|
-
type TransportFactory,
|
|
20
23
|
} from '@dxos/network-manager';
|
|
21
|
-
import { trace } from '@dxos/protocols';
|
|
22
24
|
import { SystemStatus } from '@dxos/protocols/proto/dxos/client/services';
|
|
23
25
|
import { type Storage } from '@dxos/random-access-storage';
|
|
24
|
-
import
|
|
26
|
+
import * as SqlExport from '@dxos/sql-sqlite/SqlExport';
|
|
27
|
+
import type * as SqlTransaction from '@dxos/sql-sqlite/SqlTransaction';
|
|
28
|
+
import { trace as Trace } from '@dxos/tracing';
|
|
25
29
|
import { WebsocketRpcClient } from '@dxos/websocket-rpc';
|
|
26
30
|
|
|
27
|
-
import { ServiceContext, type ServiceContextRuntimeParams } from './service-context';
|
|
28
|
-
import { ServiceRegistry } from './service-registry';
|
|
29
31
|
import { EdgeAgentServiceImpl } from '../agents';
|
|
30
32
|
import { DevicesServiceImpl } from '../devices';
|
|
31
33
|
import { DevtoolsHostEvents, DevtoolsServiceImpl } from '../devtools';
|
|
32
34
|
import {
|
|
35
|
+
type CollectDiagnosticsBroadcastHandler,
|
|
33
36
|
createCollectDiagnosticsBroadcastHandler,
|
|
34
37
|
createDiagnostics,
|
|
35
|
-
type CollectDiagnosticsBroadcastHandler,
|
|
36
38
|
} from '../diagnostics';
|
|
37
|
-
import {
|
|
39
|
+
import { type CreateIdentityOptions, IdentityServiceImpl } from '../identity';
|
|
38
40
|
import { ContactsServiceImpl } from '../identity/contacts-service';
|
|
39
41
|
import { InvitationsServiceImpl } from '../invitations';
|
|
40
42
|
import { Lock, type ResourceLock } from '../locks';
|
|
@@ -43,8 +45,10 @@ import { NetworkServiceImpl } from '../network';
|
|
|
43
45
|
import { SpacesServiceImpl } from '../spaces';
|
|
44
46
|
import { createLevel, createStorageObjects } from '../storage';
|
|
45
47
|
import { SystemServiceImpl } from '../system';
|
|
48
|
+
import { ServiceContext, type ServiceContextRuntimeProps } from './service-context';
|
|
49
|
+
import { ServiceRegistry } from './service-registry';
|
|
46
50
|
|
|
47
|
-
export type
|
|
51
|
+
export type ClientServicesHostProps = {
|
|
48
52
|
/**
|
|
49
53
|
* Can be omitted if `initialize` is later called.
|
|
50
54
|
*/
|
|
@@ -56,7 +60,8 @@ export type ClientServicesHostParams = {
|
|
|
56
60
|
level?: LevelDB;
|
|
57
61
|
lockKey?: string;
|
|
58
62
|
callbacks?: ClientServicesHostCallbacks;
|
|
59
|
-
|
|
63
|
+
runtime: RuntimeProvider.RuntimeProvider<SqlClient.SqlClient | SqlExport.SqlExport | SqlTransaction.SqlTransaction>;
|
|
64
|
+
runtimeProps?: ServiceContextRuntimeProps;
|
|
60
65
|
};
|
|
61
66
|
|
|
62
67
|
export type ClientServicesHostCallbacks = {
|
|
@@ -79,8 +84,6 @@ export class ClientServicesHost {
|
|
|
79
84
|
private readonly _serviceRegistry: ServiceRegistry<ClientServices>;
|
|
80
85
|
private readonly _systemService: SystemServiceImpl;
|
|
81
86
|
private readonly _loggingService: LoggingServiceImpl;
|
|
82
|
-
private readonly _tracingService = TRACE_PROCESSOR.createTraceSender();
|
|
83
|
-
|
|
84
87
|
private readonly _statusUpdate = new Event<void>();
|
|
85
88
|
|
|
86
89
|
private _config?: Config;
|
|
@@ -94,7 +97,10 @@ export class ClientServicesHost {
|
|
|
94
97
|
private _edgeHttpClient?: EdgeHttpClient = undefined;
|
|
95
98
|
|
|
96
99
|
private _serviceContext!: ServiceContext;
|
|
97
|
-
private readonly
|
|
100
|
+
private readonly _runtime: RuntimeProvider.RuntimeProvider<
|
|
101
|
+
SqlClient.SqlClient | SqlExport.SqlExport | SqlTransaction.SqlTransaction
|
|
102
|
+
>;
|
|
103
|
+
private readonly _runtimeProps: ServiceContextRuntimeProps;
|
|
98
104
|
private diagnosticsBroadcastHandler: CollectDiagnosticsBroadcastHandler;
|
|
99
105
|
|
|
100
106
|
@Trace.info()
|
|
@@ -115,20 +121,14 @@ export class ClientServicesHost {
|
|
|
115
121
|
// TODO(wittjosiah): Turn this on by default.
|
|
116
122
|
lockKey,
|
|
117
123
|
callbacks,
|
|
118
|
-
|
|
119
|
-
|
|
124
|
+
runtime,
|
|
125
|
+
runtimeProps,
|
|
126
|
+
}: ClientServicesHostProps) {
|
|
120
127
|
this._storage = storage;
|
|
121
128
|
this._level = level;
|
|
122
129
|
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
|
-
}
|
|
130
|
+
this._runtime = runtime;
|
|
131
|
+
this._runtimeProps = runtimeProps ?? {};
|
|
132
132
|
|
|
133
133
|
if (config) {
|
|
134
134
|
this.initialize({ config, transportFactory, signalManager });
|
|
@@ -142,7 +142,7 @@ export class ClientServicesHost {
|
|
|
142
142
|
void this.open(new Context());
|
|
143
143
|
}
|
|
144
144
|
},
|
|
145
|
-
onRelease: () => this.close(),
|
|
145
|
+
onRelease: () => this.close(Context.default()),
|
|
146
146
|
});
|
|
147
147
|
}
|
|
148
148
|
|
|
@@ -171,7 +171,6 @@ export class ClientServicesHost {
|
|
|
171
171
|
|
|
172
172
|
this._serviceRegistry = new ServiceRegistry<ClientServices>(clientServiceBundle, {
|
|
173
173
|
SystemService: this._systemService,
|
|
174
|
-
TracingService: this._tracingService,
|
|
175
174
|
});
|
|
176
175
|
}
|
|
177
176
|
|
|
@@ -199,6 +198,30 @@ export class ClientServicesHost {
|
|
|
199
198
|
return this._serviceRegistry.services;
|
|
200
199
|
}
|
|
201
200
|
|
|
201
|
+
/**
|
|
202
|
+
* Debugging util.
|
|
203
|
+
*/
|
|
204
|
+
async exportSqliteDatabase(): Promise<Uint8Array> {
|
|
205
|
+
return await RuntimeProvider.runPromise(this._runtime)(
|
|
206
|
+
Effect.gen(function* () {
|
|
207
|
+
const sql = yield* SqlExport.SqlExport;
|
|
208
|
+
return yield* sql.export;
|
|
209
|
+
}),
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Debugging util.
|
|
215
|
+
*/
|
|
216
|
+
async runSqliteQuery(query: string, params?: any[]): Promise<readonly Record<string, unknown>[]> {
|
|
217
|
+
return await RuntimeProvider.runPromise(this._runtime)(
|
|
218
|
+
Effect.gen(function* () {
|
|
219
|
+
const sql = yield* SqlClient.SqlClient;
|
|
220
|
+
return yield* sql`${sql.unsafe(query, params)}`;
|
|
221
|
+
}),
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
|
|
202
225
|
/**
|
|
203
226
|
* Initialize the service host with the config.
|
|
204
227
|
* Config can also be provided in the constructor.
|
|
@@ -209,6 +232,13 @@ export class ClientServicesHost {
|
|
|
209
232
|
log('initializing...');
|
|
210
233
|
|
|
211
234
|
if (config) {
|
|
235
|
+
if (this._runtimeProps.disableP2pReplication === undefined) {
|
|
236
|
+
this._runtimeProps.disableP2pReplication = config?.get('runtime.client.disableP2pReplication', false);
|
|
237
|
+
}
|
|
238
|
+
if (this._runtimeProps.enableVectorIndexing === undefined) {
|
|
239
|
+
this._runtimeProps.enableVectorIndexing = config?.get('runtime.client.enableVectorIndexing', false);
|
|
240
|
+
}
|
|
241
|
+
|
|
212
242
|
invariant(!this._config, 'config already set');
|
|
213
243
|
this._config = config;
|
|
214
244
|
if (!this._storage) {
|
|
@@ -216,14 +246,16 @@ export class ClientServicesHost {
|
|
|
216
246
|
}
|
|
217
247
|
}
|
|
218
248
|
|
|
249
|
+
// TODO(wittjosiah): This is quite noisy during tests. Make configurable? Remove?
|
|
219
250
|
if (!options.signalManager) {
|
|
220
|
-
log.warn('running signaling without telemetry metadata.');
|
|
251
|
+
// log.warn('running signaling without telemetry metadata.');
|
|
221
252
|
}
|
|
222
253
|
|
|
223
254
|
const endpoint = config?.get('runtime.services.edge.url');
|
|
224
255
|
if (endpoint) {
|
|
225
|
-
|
|
226
|
-
this.
|
|
256
|
+
const clientTag = resolveTelemetryTag(config);
|
|
257
|
+
this._edgeConnection = new EdgeClient(createStubEdgeIdentity(), { socketEndpoint: endpoint, clientTag });
|
|
258
|
+
this._edgeHttpClient = new EdgeHttpClient(endpoint, { clientTag });
|
|
227
259
|
}
|
|
228
260
|
|
|
229
261
|
const {
|
|
@@ -262,8 +294,7 @@ export class ClientServicesHost {
|
|
|
262
294
|
return;
|
|
263
295
|
}
|
|
264
296
|
|
|
265
|
-
|
|
266
|
-
log.trace('dxos.client-services.host.open', trace.begin({ id: traceId }));
|
|
297
|
+
log('opening service host');
|
|
267
298
|
|
|
268
299
|
invariant(this._config, 'config not set');
|
|
269
300
|
invariant(this._storage, 'storage not set');
|
|
@@ -289,7 +320,8 @@ export class ClientServicesHost {
|
|
|
289
320
|
this._signalManager,
|
|
290
321
|
this._edgeConnection,
|
|
291
322
|
this._edgeHttpClient,
|
|
292
|
-
this.
|
|
323
|
+
this._runtime,
|
|
324
|
+
this._runtimeProps,
|
|
293
325
|
this._config.get('runtime.client.edgeFeatures'),
|
|
294
326
|
);
|
|
295
327
|
|
|
@@ -307,8 +339,7 @@ export class ClientServicesHost {
|
|
|
307
339
|
this._serviceContext.identityManager,
|
|
308
340
|
this._serviceContext.recoveryManager,
|
|
309
341
|
this._serviceContext.keyring,
|
|
310
|
-
() => this.
|
|
311
|
-
(params) => this._createIdentity(params),
|
|
342
|
+
(params, ctx) => this._createIdentity(params, ctx),
|
|
312
343
|
(profile) => this._serviceContext.broadcastProfileUpdate(profile),
|
|
313
344
|
);
|
|
314
345
|
|
|
@@ -328,11 +359,13 @@ export class ClientServicesHost {
|
|
|
328
359
|
SpacesService: new SpacesServiceImpl(
|
|
329
360
|
this._serviceContext.identityManager,
|
|
330
361
|
this._serviceContext.spaceManager,
|
|
362
|
+
this._serviceContext.echoHost,
|
|
331
363
|
dataSpaceManagerProvider,
|
|
332
364
|
),
|
|
333
365
|
|
|
334
366
|
DataService: this._serviceContext.echoHost.dataService,
|
|
335
367
|
QueryService: this._serviceContext.echoHost.queryService,
|
|
368
|
+
QueueService: this._serviceContext.echoHost.queuesService,
|
|
336
369
|
|
|
337
370
|
NetworkService: new NetworkServiceImpl(
|
|
338
371
|
this._serviceContext.networkManager,
|
|
@@ -341,7 +374,6 @@ export class ClientServicesHost {
|
|
|
341
374
|
),
|
|
342
375
|
|
|
343
376
|
LoggingService: this._loggingService,
|
|
344
|
-
TracingService: this._tracingService,
|
|
345
377
|
|
|
346
378
|
// TODO(burdon): Move to new protobuf definitions.
|
|
347
379
|
DevtoolsHost: new DevtoolsServiceImpl({
|
|
@@ -353,8 +385,13 @@ export class ClientServicesHost {
|
|
|
353
385
|
EdgeAgentService: new EdgeAgentServiceImpl(agentManagerProvider, this._edgeConnection),
|
|
354
386
|
});
|
|
355
387
|
|
|
388
|
+
log('service-host: opening service context...');
|
|
356
389
|
await this._serviceContext.open(ctx);
|
|
390
|
+
log('service-host: service context opened');
|
|
391
|
+
|
|
392
|
+
log('service-host: opening identity service...');
|
|
357
393
|
await identityService.open();
|
|
394
|
+
log('service-host: identity service opened');
|
|
358
395
|
|
|
359
396
|
const devtoolsProxy = this._config?.get('runtime.client.devtoolsProxy');
|
|
360
397
|
if (devtoolsProxy) {
|
|
@@ -373,12 +410,11 @@ export class ClientServicesHost {
|
|
|
373
410
|
this._statusUpdate.emit();
|
|
374
411
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
375
412
|
log('opened', { deviceKey });
|
|
376
|
-
log.trace('dxos.client-services.host.open', trace.end({ id: traceId }));
|
|
377
413
|
}
|
|
378
414
|
|
|
379
415
|
@synchronized
|
|
380
416
|
@Trace.span()
|
|
381
|
-
async close(): Promise<void> {
|
|
417
|
+
async close(ctx: Context): Promise<void> {
|
|
382
418
|
if (!this._open) {
|
|
383
419
|
return;
|
|
384
420
|
}
|
|
@@ -397,23 +433,25 @@ export class ClientServicesHost {
|
|
|
397
433
|
}
|
|
398
434
|
|
|
399
435
|
async reset(): Promise<void> {
|
|
400
|
-
const traceId = PublicKey.random().toHex();
|
|
401
|
-
log.trace('dxos.sdk.client-services-host.reset', trace.begin({ id: traceId }));
|
|
402
|
-
|
|
403
436
|
log.info('resetting...');
|
|
404
437
|
// Emit this status update immediately so app returns to fallback.
|
|
405
438
|
// This state is never cleared because the app reloads.
|
|
406
439
|
this._resetting = true;
|
|
407
440
|
this._statusUpdate.emit();
|
|
408
441
|
await this._serviceContext?.close();
|
|
442
|
+
// Clear LevelDB contents to remove all persisted Echo/Automerge/index data.
|
|
443
|
+
try {
|
|
444
|
+
await this._level!.clear();
|
|
445
|
+
} catch (err) {
|
|
446
|
+
log.warn('failed to clear leveldb during reset', { err });
|
|
447
|
+
}
|
|
409
448
|
await this._storage!.reset();
|
|
410
449
|
log.info('reset');
|
|
411
|
-
log.trace('dxos.sdk.client-services-host.reset', trace.end({ id: traceId }));
|
|
412
450
|
await this._callbacks?.onReset?.();
|
|
413
451
|
}
|
|
414
452
|
|
|
415
|
-
private async _createIdentity(params: CreateIdentityOptions) {
|
|
416
|
-
const identity = await this._serviceContext.createIdentity(params);
|
|
453
|
+
private async _createIdentity(params: CreateIdentityOptions, ctx?: Context) {
|
|
454
|
+
const identity = await this._serviceContext.createIdentity(params, ctx);
|
|
417
455
|
await this._serviceContext.initialized.wait();
|
|
418
456
|
return identity;
|
|
419
457
|
}
|
|
@@ -13,9 +13,9 @@ 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';
|
|
18
|
+
import { ServiceRegistry } from './service-registry';
|
|
19
19
|
|
|
20
20
|
// TODO(burdon): Create TestService (that doesn't require peers).
|
|
21
21
|
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { SpaceArchive } from '@dxos/protocols/proto/dxos/client/services';
|
|
6
|
+
|
|
7
|
+
const JSON_EXTENSIONS = ['.dx.json', '.dx.json.gz', '.json'];
|
|
8
|
+
const BINARY_EXTENSIONS = ['.tar', '.tar.gz'];
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Detect the format of a space archive.
|
|
12
|
+
*
|
|
13
|
+
* Uses filename extension as the primary signal, and falls back to sniffing
|
|
14
|
+
* the first bytes of the archive contents to distinguish JSON from tar.
|
|
15
|
+
*/
|
|
16
|
+
export const detectSpaceArchiveFormat = (archive: Pick<SpaceArchive, 'filename' | 'contents'>): SpaceArchive.Format => {
|
|
17
|
+
const filename = archive.filename?.toLowerCase() ?? '';
|
|
18
|
+
if (JSON_EXTENSIONS.some((ext) => filename.endsWith(ext))) {
|
|
19
|
+
return SpaceArchive.Format.JSON;
|
|
20
|
+
}
|
|
21
|
+
if (BINARY_EXTENSIONS.some((ext) => filename.endsWith(ext))) {
|
|
22
|
+
return SpaceArchive.Format.BINARY;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Fall back to byte sniffing: JSON archives start with '{' (0x7B) or whitespace.
|
|
26
|
+
const bytes = archive.contents;
|
|
27
|
+
if (bytes && bytes.length > 0) {
|
|
28
|
+
for (let i = 0; i < Math.min(bytes.length, 16); i++) {
|
|
29
|
+
const byte = bytes[i];
|
|
30
|
+
// Skip whitespace.
|
|
31
|
+
if (byte === 0x20 || byte === 0x09 || byte === 0x0a || byte === 0x0d) {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (byte === 0x7b /* '{' */) {
|
|
35
|
+
return SpaceArchive.Format.JSON;
|
|
36
|
+
}
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return SpaceArchive.Format.BINARY;
|
|
42
|
+
};
|
|
@@ -2,5 +2,8 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
export * from './
|
|
5
|
+
export * from './archive-format';
|
|
6
|
+
export * from './serialized-space-reader';
|
|
7
|
+
export * from './serialized-space-writer';
|
|
6
8
|
export * from './space-archive-reader';
|
|
9
|
+
export * from './space-archive-writer';
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Obj } from '@dxos/echo';
|
|
6
|
+
import { type SerializedSpace } from '@dxos/echo-db';
|
|
7
|
+
import { type DatabaseDirectory, type ObjectStructure } from '@dxos/echo-protocol';
|
|
8
|
+
import { assertArgument } from '@dxos/invariant';
|
|
9
|
+
import { type SpaceArchive } from '@dxos/protocols/proto/dxos/client/services';
|
|
10
|
+
|
|
11
|
+
const ATTR_TYPE = '@type';
|
|
12
|
+
const ATTR_META = '@meta';
|
|
13
|
+
const ATTR_DELETED = '@deleted';
|
|
14
|
+
const ATTR_PARENT = '@parent';
|
|
15
|
+
const ATTR_RELATION_SOURCE = '@relationSource';
|
|
16
|
+
const ATTR_RELATION_TARGET = '@relationTarget';
|
|
17
|
+
|
|
18
|
+
const INTERNAL_KEYS: ReadonlySet<string> = new Set([
|
|
19
|
+
'id',
|
|
20
|
+
ATTR_TYPE,
|
|
21
|
+
ATTR_META,
|
|
22
|
+
ATTR_DELETED,
|
|
23
|
+
ATTR_PARENT,
|
|
24
|
+
ATTR_RELATION_SOURCE,
|
|
25
|
+
ATTR_RELATION_TARGET,
|
|
26
|
+
]);
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Parse a JSON space archive.
|
|
30
|
+
*
|
|
31
|
+
* The archive contents are expected to be the UTF-8 encoding of
|
|
32
|
+
* `JSON.stringify(serializedSpace)`.
|
|
33
|
+
*/
|
|
34
|
+
export const readSerializedSpaceArchive = (archive: SpaceArchive): SerializedSpace => {
|
|
35
|
+
const text = new TextDecoder().decode(archive.contents);
|
|
36
|
+
const parsed = JSON.parse(text) as SerializedSpace;
|
|
37
|
+
assertArgument(typeof parsed === 'object' && parsed !== null, 'archive', 'Invalid JSON archive payload');
|
|
38
|
+
assertArgument(typeof parsed.version === 'number', 'archive', 'Missing SerializedSpace.version');
|
|
39
|
+
assertArgument(Array.isArray(parsed.objects), 'archive', 'Missing SerializedSpace.objects');
|
|
40
|
+
return parsed;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Convert an {@link Obj.JSON} back into an internal {@link ObjectStructure} suitable
|
|
45
|
+
* for embedding into a {@link DatabaseDirectory}.
|
|
46
|
+
*/
|
|
47
|
+
export const objJsonToObjectStructure = (obj: Obj.JSON): ObjectStructure => {
|
|
48
|
+
const data: Record<string, unknown> = {};
|
|
49
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
50
|
+
if (INTERNAL_KEYS.has(key)) {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
data[key] = value;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const system: NonNullable<ObjectStructure['system']> = {};
|
|
57
|
+
|
|
58
|
+
const type = obj[ATTR_TYPE];
|
|
59
|
+
if (type) {
|
|
60
|
+
system.type = { '/': type as string };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const parent = (obj as any)[ATTR_PARENT];
|
|
64
|
+
if (typeof parent === 'string') {
|
|
65
|
+
system.parent = { '/': parent };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const relationSource = (obj as any)[ATTR_RELATION_SOURCE];
|
|
69
|
+
const relationTarget = (obj as any)[ATTR_RELATION_TARGET];
|
|
70
|
+
if (typeof relationSource === 'string' || typeof relationTarget === 'string') {
|
|
71
|
+
system.kind = 'relation';
|
|
72
|
+
if (typeof relationSource === 'string') {
|
|
73
|
+
system.source = { '/': relationSource };
|
|
74
|
+
}
|
|
75
|
+
if (typeof relationTarget === 'string') {
|
|
76
|
+
system.target = { '/': relationTarget };
|
|
77
|
+
}
|
|
78
|
+
} else {
|
|
79
|
+
system.kind = 'object';
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if ((obj as any)[ATTR_DELETED]) {
|
|
83
|
+
system.deleted = true;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const meta = (obj as any)[ATTR_META];
|
|
87
|
+
return {
|
|
88
|
+
system,
|
|
89
|
+
meta: {
|
|
90
|
+
keys: meta?.keys ?? [],
|
|
91
|
+
...(meta?.tags ? { tags: meta.tags } : {}),
|
|
92
|
+
},
|
|
93
|
+
data,
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Build a new {@link DatabaseDirectory} containing every object from the archive,
|
|
99
|
+
* keyed by object id. The caller is responsible for stamping the `access.spaceKey`
|
|
100
|
+
* and version fields after the document is created.
|
|
101
|
+
*/
|
|
102
|
+
export const buildDatabaseDirectoryFromObjects = (objects: readonly Obj.JSON[]): DatabaseDirectory => {
|
|
103
|
+
const map: Record<string, ObjectStructure> = {};
|
|
104
|
+
for (const obj of objects) {
|
|
105
|
+
map[obj.id] = objJsonToObjectStructure(obj);
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
objects: map,
|
|
109
|
+
links: {},
|
|
110
|
+
};
|
|
111
|
+
};
|