@dxos/client-services 0.10.0 → 0.11.0
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/chunk-client-services-layer.mjs +11425 -0
- package/dist/lib/chunk-client-services-layer.mjs.map +1 -0
- package/dist/lib/chunk-decorate.mjs +9 -0
- package/dist/lib/index.mjs +731 -0
- package/dist/lib/index.mjs.map +1 -0
- package/dist/lib/packlets/diagnostics/browser-diagnostics-broadcast.mjs +72 -0
- package/dist/lib/packlets/diagnostics/browser-diagnostics-broadcast.mjs.map +1 -0
- package/dist/lib/packlets/diagnostics/diagnostics-broadcast.mjs +14 -0
- package/dist/lib/packlets/diagnostics/diagnostics-broadcast.mjs.map +1 -0
- package/dist/lib/packlets/locks/browser.mjs +105 -0
- package/dist/lib/packlets/locks/browser.mjs.map +1 -0
- package/dist/lib/packlets/locks/node.mjs +53 -0
- package/dist/lib/packlets/locks/node.mjs.map +1 -0
- package/dist/lib/testing.mjs +570 -0
- package/dist/lib/testing.mjs.map +1 -0
- package/dist/types/src/index.d.ts +2 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/packlets/agents/edge-agent-manager.d.ts +21 -4
- 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 +8 -7
- package/dist/types/src/packlets/agents/edge-agent-service.d.ts.map +1 -1
- package/dist/types/src/packlets/devices/devices-service.d.ts +7 -5
- package/dist/types/src/packlets/devices/devices-service.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/devtools.d.ts +30 -29
- 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 +2 -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/diagnostics-broadcast.d.ts +2 -2
- 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 +1 -8
- package/dist/types/src/packlets/diagnostics/diagnostics.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/authenticator.d.ts +1 -1
- package/dist/types/src/packlets/identity/authenticator.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/contacts-service.d.ts +9 -6
- package/dist/types/src/packlets/identity/contacts-service.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-manager.d.ts +32 -3
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts +23 -4
- package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-service.d.ts +15 -20
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +2 -2
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/edge-invitation-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts +17 -0
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts +25 -4
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-service.d.ts +11 -11
- package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
- package/dist/types/src/packlets/logging/logging-service.d.ts +14 -12
- package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
- package/dist/types/src/packlets/metadata/index.d.ts +3 -0
- package/dist/types/src/packlets/metadata/index.d.ts.map +1 -0
- package/dist/types/src/packlets/metadata/metadata-store.d.ts +107 -0
- package/dist/types/src/packlets/metadata/metadata-store.d.ts.map +1 -0
- package/dist/types/src/packlets/metadata/metadata-store.test.d.ts +2 -0
- package/dist/types/src/packlets/metadata/metadata-store.test.d.ts.map +1 -0
- package/dist/types/src/packlets/metadata/sqlite-metadata-store.d.ts +65 -0
- package/dist/types/src/packlets/metadata/sqlite-metadata-store.d.ts.map +1 -0
- package/dist/types/src/packlets/network/network-service.d.ts +15 -14
- package/dist/types/src/packlets/network/network-service.d.ts.map +1 -1
- package/dist/types/src/packlets/pipeline/codec.d.ts +11 -0
- package/dist/types/src/packlets/pipeline/codec.d.ts.map +1 -0
- package/dist/types/src/packlets/pipeline/feeds.d.ts +7 -0
- package/dist/types/src/packlets/pipeline/feeds.d.ts.map +1 -0
- package/dist/types/src/packlets/pipeline/index.d.ts +5 -0
- package/dist/types/src/packlets/pipeline/index.d.ts.map +1 -0
- package/dist/types/src/packlets/pipeline/message-selector.d.ts +11 -0
- package/dist/types/src/packlets/pipeline/message-selector.d.ts.map +1 -0
- package/dist/types/src/packlets/pipeline/pipeline-stress.test.d.ts +2 -0
- package/dist/types/src/packlets/pipeline/pipeline-stress.test.d.ts.map +1 -0
- package/dist/types/src/packlets/pipeline/pipeline.d.ts +131 -0
- package/dist/types/src/packlets/pipeline/pipeline.d.ts.map +1 -0
- package/dist/types/src/packlets/pipeline/pipeline.test.d.ts +2 -0
- package/dist/types/src/packlets/pipeline/pipeline.test.d.ts.map +1 -0
- package/dist/types/src/packlets/pipeline/testing/index.d.ts +2 -0
- package/dist/types/src/packlets/pipeline/testing/index.d.ts.map +1 -0
- package/dist/types/src/packlets/pipeline/testing/test-feed-builder.d.ts +9 -0
- package/dist/types/src/packlets/pipeline/testing/test-feed-builder.d.ts.map +1 -0
- package/dist/types/src/packlets/pipeline/timeframe-clock.d.ts +31 -0
- package/dist/types/src/packlets/pipeline/timeframe-clock.d.ts.map +1 -0
- package/dist/types/src/packlets/services/client-services-layer.d.ts +21 -0
- package/dist/types/src/packlets/services/client-services-layer.d.ts.map +1 -0
- package/dist/types/src/packlets/services/cross-device-space-synchronizer.d.ts +28 -0
- package/dist/types/src/packlets/services/cross-device-space-synchronizer.d.ts.map +1 -0
- package/dist/types/src/packlets/services/effect-rpc.test.d.ts +2 -0
- package/dist/types/src/packlets/services/effect-rpc.test.d.ts.map +1 -0
- package/dist/types/src/packlets/services/feed-syncer.d.ts +22 -2
- package/dist/types/src/packlets/services/feed-syncer.d.ts.map +1 -1
- package/dist/types/src/packlets/services/index.d.ts +2 -2
- package/dist/types/src/packlets/services/index.d.ts.map +1 -1
- package/dist/types/src/packlets/services/platform.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +38 -57
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +82 -31
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/services/sqlite-storage.d.ts +29 -0
- package/dist/types/src/packlets/services/sqlite-storage.d.ts.map +1 -1
- package/dist/types/src/packlets/services/sqlite-storage.test.d.ts +2 -0
- package/dist/types/src/packlets/services/sqlite-storage.test.d.ts.map +1 -0
- package/dist/types/src/packlets/space/admission-discovery-extension.d.ts +30 -0
- package/dist/types/src/packlets/space/admission-discovery-extension.d.ts.map +1 -0
- package/dist/types/src/packlets/space/auth.d.ts +24 -0
- package/dist/types/src/packlets/space/auth.d.ts.map +1 -0
- package/dist/types/src/packlets/space/control-pipeline.d.ts +46 -0
- package/dist/types/src/packlets/space/control-pipeline.d.ts.map +1 -0
- package/dist/types/src/packlets/space/control-pipeline.test.d.ts +2 -0
- package/dist/types/src/packlets/space/control-pipeline.test.d.ts.map +1 -0
- package/dist/types/src/packlets/space/index.d.ts +6 -0
- package/dist/types/src/packlets/space/index.d.ts.map +1 -0
- package/dist/types/src/packlets/space/replication.browser.test.d.ts +2 -0
- package/dist/types/src/packlets/space/replication.browser.test.d.ts.map +1 -0
- package/dist/types/src/packlets/space/space-manager.browser.test.d.ts +2 -0
- package/dist/types/src/packlets/space/space-manager.browser.test.d.ts.map +1 -0
- package/dist/types/src/packlets/space/space-manager.d.ts +72 -0
- package/dist/types/src/packlets/space/space-manager.d.ts.map +1 -0
- package/dist/types/src/packlets/space/space-protocol.browser.test.d.ts +2 -0
- package/dist/types/src/packlets/space/space-protocol.browser.test.d.ts.map +1 -0
- package/dist/types/src/packlets/space/space-protocol.d.ts +99 -0
- package/dist/types/src/packlets/space/space-protocol.d.ts.map +1 -0
- package/dist/types/src/packlets/space/space-protocol.test.d.ts +2 -0
- package/dist/types/src/packlets/space/space-protocol.test.d.ts.map +1 -0
- package/dist/types/src/packlets/space/space.d.ts +65 -0
- package/dist/types/src/packlets/space/space.d.ts.map +1 -0
- package/dist/types/src/packlets/space/space.test.d.ts +2 -0
- package/dist/types/src/packlets/space/space.test.d.ts.map +1 -0
- package/dist/types/src/packlets/space/testing/change-metadata.d.ts +8 -0
- package/dist/types/src/packlets/space/testing/change-metadata.d.ts.map +1 -0
- package/dist/types/src/packlets/space/testing/index.d.ts +4 -0
- package/dist/types/src/packlets/space/testing/index.d.ts.map +1 -0
- package/dist/types/src/packlets/space/testing/test-agent-builder.d.ts +62 -0
- package/dist/types/src/packlets/space/testing/test-agent-builder.d.ts.map +1 -0
- package/dist/types/src/packlets/space-export/serialized-space-reader.d.ts +1 -1
- package/dist/types/src/packlets/space-export/serialized-space-reader.d.ts.map +1 -1
- package/dist/types/src/packlets/space-export/serialized-space-writer.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +40 -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 +3 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/genesis.d.ts +1 -1
- package/dist/types/src/packlets/spaces/genesis.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +25 -23
- 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/system/system-service.d.ts +18 -18
- package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/invitation-utils.d.ts +1 -1
- package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +7 -6
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/worker/worker-runtime.d.ts +41 -58
- package/dist/types/src/packlets/worker/worker-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/worker/worker-session.d.ts +21 -8
- package/dist/types/src/packlets/worker/worker-session.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +1 -0
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +52 -48
- package/src/index.ts +2 -0
- package/src/packlets/agents/edge-agent-manager.ts +56 -15
- package/src/packlets/agents/edge-agent-service.ts +25 -15
- package/src/packlets/devices/devices-service.test.ts +20 -19
- package/src/packlets/devices/devices-service.ts +17 -17
- package/src/packlets/devtools/devtools.ts +133 -75
- package/src/packlets/devtools/feeds.ts +2 -1
- package/src/packlets/devtools/network.ts +42 -12
- package/src/packlets/devtools/spaces.ts +1 -1
- package/src/packlets/diagnostics/diagnostics-broadcast.ts +4 -2
- package/src/packlets/diagnostics/diagnostics-collector.ts +5 -18
- package/src/packlets/diagnostics/diagnostics.ts +0 -11
- package/src/packlets/identity/authenticator.ts +2 -1
- package/src/packlets/identity/contacts-service.ts +46 -37
- package/src/packlets/identity/identity-manager.test.ts +3 -1
- package/src/packlets/identity/identity-manager.ts +73 -5
- package/src/packlets/identity/identity-recovery-manager.ts +56 -7
- package/src/packlets/identity/identity-service.test.ts +27 -18
- package/src/packlets/identity/identity-service.ts +114 -71
- package/src/packlets/identity/identity.test.ts +4 -9
- package/src/packlets/identity/identity.ts +1 -2
- package/src/packlets/invitations/edge-invitation-handler.ts +0 -1
- package/src/packlets/invitations/invitations-handler.ts +39 -3
- package/src/packlets/invitations/invitations-manager.ts +52 -4
- package/src/packlets/invitations/invitations-service.ts +54 -28
- package/src/packlets/logging/logging-service.ts +41 -29
- package/src/packlets/logging/logging.test.ts +28 -15
- package/src/packlets/metadata/index.ts +6 -0
- package/src/packlets/metadata/metadata-store.test.ts +49 -0
- package/src/packlets/metadata/metadata-store.ts +446 -0
- package/src/packlets/metadata/sqlite-metadata-store.ts +409 -0
- package/src/packlets/network/network-service.test.ts +19 -12
- package/src/packlets/network/network-service.ts +96 -29
- package/src/packlets/pipeline/codec.ts +18 -0
- package/src/packlets/pipeline/feeds.ts +22 -0
- package/src/packlets/pipeline/index.ts +8 -0
- package/src/packlets/pipeline/message-selector.ts +35 -0
- package/src/packlets/pipeline/pipeline-stress.test.ts +230 -0
- package/src/packlets/pipeline/pipeline.test.ts +140 -0
- package/src/packlets/pipeline/pipeline.ts +439 -0
- package/src/packlets/pipeline/testing/index.ts +5 -0
- package/src/packlets/pipeline/testing/test-feed-builder.ts +19 -0
- package/src/packlets/pipeline/timeframe-clock.ts +81 -0
- package/src/packlets/services/client-services-layer.ts +186 -0
- package/src/packlets/services/cross-device-space-synchronizer.ts +132 -0
- package/src/packlets/services/effect-rpc.test.ts +314 -0
- package/src/packlets/services/feed-syncer.ts +57 -3
- package/src/packlets/services/index.ts +2 -2
- package/src/packlets/services/platform.ts +0 -6
- package/src/packlets/services/service-context.ts +219 -522
- package/src/packlets/services/service-host.test.ts +34 -11
- package/src/packlets/services/service-host.ts +693 -213
- package/src/packlets/services/spec.md +106 -0
- package/src/packlets/services/sqlite-storage.test.ts +48 -0
- package/src/packlets/services/sqlite-storage.ts +117 -20
- package/src/packlets/space/admission-discovery-extension.ts +91 -0
- package/src/packlets/space/auth.ts +92 -0
- package/src/packlets/space/control-pipeline.test.ts +165 -0
- package/src/packlets/space/control-pipeline.ts +229 -0
- package/src/packlets/space/index.ts +9 -0
- package/src/packlets/space/replication.browser.test.ts +58 -0
- package/src/packlets/space/space-manager.browser.test.ts +40 -0
- package/src/packlets/space/space-manager.ts +224 -0
- package/src/packlets/space/space-protocol.browser.test.ts +129 -0
- package/src/packlets/space/space-protocol.test.ts +158 -0
- package/src/packlets/space/space-protocol.ts +308 -0
- package/src/packlets/space/space.test.ts +181 -0
- package/src/packlets/space/space.ts +196 -0
- package/src/packlets/space/testing/change-metadata.ts +27 -0
- package/src/packlets/space/testing/index.ts +7 -0
- package/src/packlets/space/testing/test-agent-builder.ts +252 -0
- package/src/packlets/space-export/serialized-space-reader.ts +3 -1
- package/src/packlets/space-export/serialized-space-writer.ts +53 -30
- package/src/packlets/space-export/space-archive.test.ts +30 -0
- package/src/packlets/spaces/data-space-manager.test.ts +1 -1
- package/src/packlets/spaces/data-space-manager.ts +148 -33
- package/src/packlets/spaces/data-space.ts +29 -18
- package/src/packlets/spaces/edge-feed-replicator.test.ts +1 -1
- package/src/packlets/spaces/genesis.ts +1 -1
- package/src/packlets/spaces/spaces-service.test.ts +35 -22
- package/src/packlets/spaces/spaces-service.ts +259 -180
- package/src/packlets/storage/level.ts +3 -1
- package/src/packlets/system/system-service.test.ts +31 -13
- package/src/packlets/system/system-service.ts +65 -37
- package/src/packlets/testing/invitation-utils.ts +3 -3
- package/src/packlets/testing/test-builder.ts +35 -20
- package/src/packlets/worker/worker-runtime.ts +222 -260
- package/src/packlets/worker/worker-session.ts +108 -91
- package/src/testing/index.ts +1 -0
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-QCWEHHJW.mjs +0 -24
- package/dist/lib/browser/chunk-QCWEHHJW.mjs.map +0 -7
- package/dist/lib/browser/chunk-XJRPB3GA.mjs +0 -22
- package/dist/lib/browser/chunk-XJRPB3GA.mjs.map +0 -7
- package/dist/lib/browser/chunk-XU5R2BMF.mjs +0 -8837
- package/dist/lib/browser/chunk-XU5R2BMF.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -876
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/packlets/diagnostics/browser-diagnostics-broadcast.mjs +0 -88
- package/dist/lib/browser/packlets/diagnostics/browser-diagnostics-broadcast.mjs.map +0 -7
- package/dist/lib/browser/packlets/diagnostics/diagnostics-broadcast.mjs +0 -11
- package/dist/lib/browser/packlets/diagnostics/diagnostics-broadcast.mjs.map +0 -7
- package/dist/lib/browser/packlets/locks/browser.mjs +0 -86
- package/dist/lib/browser/packlets/locks/browser.mjs.map +0 -7
- package/dist/lib/browser/packlets/locks/node.mjs +0 -48
- package/dist/lib/browser/packlets/locks/node.mjs.map +0 -7
- package/dist/lib/browser/testing/index.mjs +0 -436
- package/dist/lib/browser/testing/index.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2DT3MZRL.mjs +0 -22
- package/dist/lib/node-esm/chunk-2DT3MZRL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2SZHAWBN.mjs +0 -24
- package/dist/lib/node-esm/chunk-2SZHAWBN.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-H5YTUD35.mjs +0 -8837
- package/dist/lib/node-esm/chunk-H5YTUD35.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -876
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/packlets/diagnostics/browser-diagnostics-broadcast.mjs +0 -88
- package/dist/lib/node-esm/packlets/diagnostics/browser-diagnostics-broadcast.mjs.map +0 -7
- package/dist/lib/node-esm/packlets/diagnostics/diagnostics-broadcast.mjs +0 -11
- package/dist/lib/node-esm/packlets/diagnostics/diagnostics-broadcast.mjs.map +0 -7
- package/dist/lib/node-esm/packlets/locks/browser.mjs +0 -86
- package/dist/lib/node-esm/packlets/locks/browser.mjs.map +0 -7
- package/dist/lib/node-esm/packlets/locks/node.mjs +0 -48
- package/dist/lib/node-esm/packlets/locks/node.mjs.map +0 -7
- package/dist/lib/node-esm/testing/index.mjs +0 -436
- package/dist/lib/node-esm/testing/index.mjs.map +0 -7
- package/dist/types/src/packlets/services/client-rpc-server.d.ts +0 -24
- package/dist/types/src/packlets/services/client-rpc-server.d.ts.map +0 -1
- package/dist/types/src/packlets/services/service-registry.d.ts +0 -15
- package/dist/types/src/packlets/services/service-registry.d.ts.map +0 -1
- package/dist/types/src/packlets/services/service-registry.test.d.ts +0 -2
- package/dist/types/src/packlets/services/service-registry.test.d.ts.map +0 -1
- package/dist/types/src/testing/setup.d.ts +0 -3
- package/dist/types/src/testing/setup.d.ts.map +0 -1
- package/src/packlets/services/client-rpc-server.ts +0 -111
- package/src/packlets/services/service-registry.test.ts +0 -78
- package/src/packlets/services/service-registry.ts +0 -36
- package/src/testing/setup.ts +0 -11
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import * as EffectStream from 'effect/Stream';
|
|
7
|
+
|
|
5
8
|
import { Event as AsyncEvent } from '@dxos/async';
|
|
6
9
|
import { Stream } from '@dxos/codec-protobuf/stream';
|
|
7
10
|
import { type Config } from '@dxos/config';
|
|
11
|
+
import { Context } from '@dxos/context';
|
|
8
12
|
import {
|
|
9
13
|
type ClearSnapshotsRequest,
|
|
10
|
-
type DevtoolsHost, // TODO(burdon): Rename DevtoolsService
|
|
11
14
|
type EnableDebugLoggingRequest,
|
|
12
15
|
type EnableDebugLoggingResponse,
|
|
13
16
|
type Event,
|
|
@@ -41,8 +44,10 @@ import {
|
|
|
41
44
|
type SubscribeToSignalStatusResponse,
|
|
42
45
|
type SubscribeToSpacesRequest,
|
|
43
46
|
type SubscribeToSpacesResponse,
|
|
47
|
+
type SubscribeToSwarmInfoRequest,
|
|
44
48
|
type SubscribeToSwarmInfoResponse,
|
|
45
49
|
} from '@dxos/protocols/proto/dxos/devtools/host';
|
|
50
|
+
import { type DevtoolsHost } from '@dxos/protocols/rpc';
|
|
46
51
|
|
|
47
52
|
import { type ServiceContext } from '../services';
|
|
48
53
|
import { subscribeToFeedBlocks, subscribeToFeeds } from './feeds';
|
|
@@ -66,134 +71,187 @@ export type DevtoolsServiceProps = {
|
|
|
66
71
|
/**
|
|
67
72
|
* @deprecated
|
|
68
73
|
*/
|
|
69
|
-
export class DevtoolsServiceImpl implements DevtoolsHost {
|
|
70
|
-
constructor(private readonly params: DevtoolsServiceProps) {}
|
|
74
|
+
export class DevtoolsServiceImpl implements DevtoolsHost.Handlers {
|
|
75
|
+
'constructor'(private readonly params: DevtoolsServiceProps) {}
|
|
71
76
|
|
|
72
|
-
events(
|
|
73
|
-
return
|
|
74
|
-
|
|
75
|
-
|
|
77
|
+
['DevtoolsHost.events'](): EffectStream.Stream<Event, Error> {
|
|
78
|
+
return EffectStream.async<Event, Error>((emit) => {
|
|
79
|
+
const ctx = Context.default();
|
|
80
|
+
this.params.events.ready.on(ctx, () => {
|
|
81
|
+
void emit.single({ ready: {} });
|
|
76
82
|
});
|
|
83
|
+
|
|
84
|
+
return Effect.promise(() => ctx.dispose());
|
|
77
85
|
});
|
|
78
86
|
}
|
|
79
87
|
|
|
80
|
-
|
|
81
|
-
return { config: JSON.stringify(this.params.config.values) }; // 😨
|
|
88
|
+
['DevtoolsHost.getConfig'](): Effect.Effect<GetConfigResponse, Error> {
|
|
89
|
+
return Effect.sync(() => ({ config: JSON.stringify(this.params.config.values) })); // 😨
|
|
82
90
|
}
|
|
83
91
|
|
|
84
|
-
|
|
85
|
-
|
|
92
|
+
['DevtoolsHost.getStorageInfo'](): Effect.Effect<StorageInfo, Error> {
|
|
93
|
+
return Effect.tryPromise({
|
|
94
|
+
try: async () => {
|
|
95
|
+
const navigatorInfo = typeof navigator === 'object' ? await navigator.storage.estimate() : undefined;
|
|
86
96
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
97
|
+
return {
|
|
98
|
+
type: 'sqlite',
|
|
99
|
+
storageUsage: navigatorInfo?.usage ?? 0,
|
|
100
|
+
originUsage: navigatorInfo?.usage ?? 0,
|
|
101
|
+
usageQuota: navigatorInfo?.quota ?? 0,
|
|
102
|
+
};
|
|
103
|
+
},
|
|
104
|
+
catch: (error) => error as Error,
|
|
105
|
+
});
|
|
93
106
|
}
|
|
94
107
|
|
|
95
|
-
|
|
96
|
-
return {
|
|
97
|
-
|
|
98
|
-
|
|
108
|
+
['DevtoolsHost.getBlobs'](): Effect.Effect<GetBlobsResponse, Error> {
|
|
109
|
+
return Effect.tryPromise({
|
|
110
|
+
try: async () => ({
|
|
111
|
+
blobs: await this.params.context.blobStore.list(),
|
|
112
|
+
}),
|
|
113
|
+
catch: (error) => error as Error,
|
|
114
|
+
});
|
|
99
115
|
}
|
|
100
116
|
|
|
101
|
-
|
|
102
|
-
return {
|
|
117
|
+
['DevtoolsHost.getSnapshots'](): Effect.Effect<GetSnapshotsResponse, Error> {
|
|
118
|
+
return Effect.sync(() => ({
|
|
103
119
|
snapshots: [],
|
|
104
|
-
};
|
|
120
|
+
}));
|
|
105
121
|
}
|
|
106
122
|
|
|
107
|
-
resetStorage(_request: ResetStorageRequest):
|
|
108
|
-
|
|
123
|
+
['DevtoolsHost.resetStorage'](_request: ResetStorageRequest): Effect.Effect<void, Error> {
|
|
124
|
+
return Effect.fail(new Error());
|
|
109
125
|
}
|
|
110
126
|
|
|
111
|
-
enableDebugLogging(
|
|
112
|
-
|
|
127
|
+
['DevtoolsHost.enableDebugLogging'](
|
|
128
|
+
_request: EnableDebugLoggingRequest,
|
|
129
|
+
): Effect.Effect<EnableDebugLoggingResponse, Error> {
|
|
130
|
+
return Effect.fail(new Error());
|
|
113
131
|
}
|
|
114
132
|
|
|
115
|
-
disableDebugLogging(
|
|
116
|
-
|
|
133
|
+
['DevtoolsHost.disableDebugLogging'](
|
|
134
|
+
_request: EnableDebugLoggingRequest,
|
|
135
|
+
): Effect.Effect<EnableDebugLoggingResponse, Error> {
|
|
136
|
+
return Effect.fail(new Error());
|
|
117
137
|
}
|
|
118
138
|
|
|
119
|
-
subscribeToKeyringKeys(
|
|
120
|
-
|
|
139
|
+
['DevtoolsHost.subscribeToKeyringKeys'](
|
|
140
|
+
_request: SubscribeToKeyringKeysRequest,
|
|
141
|
+
): EffectStream.Stream<SubscribeToKeyringKeysResponse, Error> {
|
|
142
|
+
return toEffectStream(subscribeToKeyringKeys({ keyring: this.params.context.keyring }));
|
|
121
143
|
}
|
|
122
144
|
|
|
123
|
-
subscribeToCredentialMessages(
|
|
145
|
+
['DevtoolsHost.subscribeToCredentialMessages'](
|
|
124
146
|
_request: SubscribeToCredentialMessagesRequest,
|
|
125
|
-
): Stream<SubscribeToCredentialMessagesResponse> {
|
|
126
|
-
|
|
147
|
+
): EffectStream.Stream<SubscribeToCredentialMessagesResponse, Error> {
|
|
148
|
+
return EffectStream.fail(new Error());
|
|
127
149
|
}
|
|
128
150
|
|
|
129
|
-
subscribeToSpaces(
|
|
130
|
-
|
|
151
|
+
['DevtoolsHost.subscribeToSpaces'](
|
|
152
|
+
request: SubscribeToSpacesRequest,
|
|
153
|
+
): EffectStream.Stream<SubscribeToSpacesResponse, Error> {
|
|
154
|
+
return toEffectStream(subscribeToSpaces(this.params.context, request));
|
|
131
155
|
}
|
|
132
156
|
|
|
133
|
-
subscribeToItems(
|
|
134
|
-
|
|
157
|
+
['DevtoolsHost.subscribeToItems'](
|
|
158
|
+
_request: SubscribeToItemsRequest,
|
|
159
|
+
): EffectStream.Stream<SubscribeToItemsResponse, Error> {
|
|
160
|
+
return EffectStream.fail(new Error());
|
|
135
161
|
}
|
|
136
162
|
|
|
137
|
-
subscribeToFeeds(
|
|
138
|
-
|
|
163
|
+
['DevtoolsHost.subscribeToFeeds'](
|
|
164
|
+
request: SubscribeToFeedsRequest,
|
|
165
|
+
): EffectStream.Stream<SubscribeToFeedsResponse, Error> {
|
|
166
|
+
return toEffectStream(subscribeToFeeds(this.params.context, request));
|
|
139
167
|
}
|
|
140
168
|
|
|
141
|
-
subscribeToFeedBlocks(
|
|
142
|
-
|
|
169
|
+
['DevtoolsHost.subscribeToFeedBlocks'](
|
|
170
|
+
request: SubscribeToFeedBlocksRequest,
|
|
171
|
+
): EffectStream.Stream<SubscribeToFeedBlocksResponse, Error> {
|
|
172
|
+
return toEffectStream(subscribeToFeedBlocks({ feedStore: this.params.context.feedStore }, request));
|
|
143
173
|
}
|
|
144
174
|
|
|
145
|
-
|
|
146
|
-
|
|
175
|
+
['DevtoolsHost.subscribeToMetadata'](): EffectStream.Stream<SubscribeToMetadataResponse, Error> {
|
|
176
|
+
return toEffectStream(subscribeToMetadata({ context: this.params.context }));
|
|
147
177
|
}
|
|
148
178
|
|
|
149
|
-
|
|
150
|
-
|
|
179
|
+
['DevtoolsHost.getSpaceSnapshot'](_request: GetSpaceSnapshotRequest): Effect.Effect<GetSpaceSnapshotResponse, Error> {
|
|
180
|
+
return Effect.fail(new Error());
|
|
151
181
|
}
|
|
152
182
|
|
|
153
|
-
|
|
154
|
-
|
|
183
|
+
['DevtoolsHost.saveSpaceSnapshot'](
|
|
184
|
+
_request: SaveSpaceSnapshotRequest,
|
|
185
|
+
): Effect.Effect<SaveSpaceSnapshotResponse, Error> {
|
|
186
|
+
return Effect.fail(new Error());
|
|
155
187
|
}
|
|
156
188
|
|
|
157
|
-
|
|
158
|
-
|
|
189
|
+
['DevtoolsHost.clearSnapshots'](_request: ClearSnapshotsRequest): Effect.Effect<void, Error> {
|
|
190
|
+
return Effect.fail(new Error());
|
|
159
191
|
}
|
|
160
192
|
|
|
161
|
-
|
|
162
|
-
|
|
193
|
+
['DevtoolsHost.getNetworkPeers'](_request: GetNetworkPeersRequest): Effect.Effect<GetNetworkPeersResponse, Error> {
|
|
194
|
+
return Effect.fail(new Error());
|
|
163
195
|
}
|
|
164
196
|
|
|
165
|
-
|
|
166
|
-
return
|
|
197
|
+
['DevtoolsHost.subscribeToNetworkTopics'](): EffectStream.Stream<SubscribeToNetworkTopicsResponse, Error> {
|
|
198
|
+
return EffectStream.fail(new Error());
|
|
167
199
|
}
|
|
168
200
|
|
|
169
|
-
|
|
170
|
-
return
|
|
201
|
+
['DevtoolsHost.subscribeToSignalStatus'](): EffectStream.Stream<SubscribeToSignalStatusResponse, Error> {
|
|
202
|
+
return toEffectStream(subscribeToNetworkStatus({ signalManager: this.params.context.signalManager }));
|
|
171
203
|
}
|
|
172
204
|
|
|
173
|
-
|
|
174
|
-
return
|
|
205
|
+
['DevtoolsHost.subscribeToSignal'](): EffectStream.Stream<SignalResponse, Error> {
|
|
206
|
+
return toEffectStream(
|
|
207
|
+
subscribeToSignal({
|
|
208
|
+
signalManager: this.params.context.signalManager,
|
|
209
|
+
networkManager: this.params.context.networkManager,
|
|
210
|
+
}),
|
|
211
|
+
);
|
|
175
212
|
}
|
|
176
213
|
|
|
177
|
-
|
|
178
|
-
|
|
214
|
+
['DevtoolsHost.subscribeToSwarmInfo'](
|
|
215
|
+
_request: SubscribeToSwarmInfoRequest,
|
|
216
|
+
): EffectStream.Stream<SubscribeToSwarmInfoResponse, Error> {
|
|
217
|
+
return toEffectStream(subscribeToSwarmInfo({ networkManager: this.params.context.networkManager }));
|
|
179
218
|
}
|
|
180
219
|
|
|
181
|
-
|
|
182
|
-
return {
|
|
183
|
-
|
|
184
|
-
|
|
220
|
+
['DevtoolsHost.exportSqliteDatabase'](): Effect.Effect<ExportSqliteDatabaseResponse, Error> {
|
|
221
|
+
return Effect.tryPromise({
|
|
222
|
+
try: async () => ({
|
|
223
|
+
data: await this.params.exportSqliteDatabase(),
|
|
224
|
+
}),
|
|
225
|
+
catch: (error) => error as Error,
|
|
226
|
+
});
|
|
185
227
|
}
|
|
186
228
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
229
|
+
['DevtoolsHost.runSqliteQuery'](request: RunSqliteQueryRequest): Effect.Effect<RunSqliteQueryResponse, Error> {
|
|
230
|
+
return Effect.promise(async () => {
|
|
231
|
+
try {
|
|
232
|
+
const parsedParams = request.params ? JSON.parse(request.params) : undefined;
|
|
233
|
+
if (parsedParams !== undefined && !Array.isArray(parsedParams)) {
|
|
234
|
+
throw new Error('Query params must be a JSON array.');
|
|
235
|
+
}
|
|
236
|
+
const rows = await this.params.runSqliteQuery(request.query, parsedParams);
|
|
237
|
+
return { rows: JSON.stringify(rows) };
|
|
238
|
+
} catch (err) {
|
|
239
|
+
return { rows: '[]', error: err instanceof Error ? err.message : String(err) };
|
|
192
240
|
}
|
|
193
|
-
|
|
194
|
-
return { rows: JSON.stringify(rows) };
|
|
195
|
-
} catch (err) {
|
|
196
|
-
return { rows: '[]', error: err instanceof Error ? err.message : String(err) };
|
|
197
|
-
}
|
|
241
|
+
});
|
|
198
242
|
}
|
|
199
243
|
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Bridges a codec-protobuf {@link Stream} into an Effect {@link EffectStream.Stream}.
|
|
247
|
+
* The underlying stream is closed (disposing its resources) when the Effect stream terminates.
|
|
248
|
+
*/
|
|
249
|
+
const toEffectStream = <T>(stream: Stream<T>): EffectStream.Stream<T, Error> =>
|
|
250
|
+
EffectStream.async<T, Error>((emit) => {
|
|
251
|
+
stream.subscribe(
|
|
252
|
+
(message) => void emit.single(message),
|
|
253
|
+
(error) => (error ? void emit.fail(error) : void emit.end()),
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
return Effect.promise(() => stream.close());
|
|
257
|
+
});
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
import { SubscriptionList } from '@dxos/async';
|
|
6
6
|
import { Stream } from '@dxos/codec-protobuf/stream';
|
|
7
|
-
import { type SpaceManager } from '@dxos/echo-host';
|
|
8
7
|
import { FeedIterator, type FeedStore, type FeedWrapper } from '@dxos/feed-store';
|
|
9
8
|
import { PublicKey } from '@dxos/keys';
|
|
10
9
|
import { log } from '@dxos/log';
|
|
@@ -17,6 +16,8 @@ import {
|
|
|
17
16
|
import { type FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
|
|
18
17
|
import { ComplexMap } from '@dxos/util';
|
|
19
18
|
|
|
19
|
+
import { type SpaceManager } from '../space';
|
|
20
|
+
|
|
20
21
|
type FeedInfo = {
|
|
21
22
|
feed: FeedWrapper<FeedMessage>;
|
|
22
23
|
owner?: SubscribeToFeedsResponse.FeedOwner;
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
import { Stream } from '@dxos/codec-protobuf/stream';
|
|
6
6
|
import { Context } from '@dxos/context';
|
|
7
7
|
import { PublicKey } from '@dxos/keys';
|
|
8
|
-
import {
|
|
8
|
+
import { log } from '@dxos/log';
|
|
9
|
+
import { type SignalManager, type UnsubscribeCallback } from '@dxos/messaging';
|
|
9
10
|
import { type SwarmNetworkManager } from '@dxos/network-manager';
|
|
10
11
|
import {
|
|
11
12
|
type GetNetworkPeersRequest,
|
|
@@ -31,19 +32,47 @@ export const subscribeToNetworkStatus = ({ signalManager }: { signalManager: Sig
|
|
|
31
32
|
update();
|
|
32
33
|
});
|
|
33
34
|
|
|
34
|
-
export const subscribeToSignal = ({
|
|
35
|
+
export const subscribeToSignal = ({
|
|
36
|
+
signalManager,
|
|
37
|
+
networkManager,
|
|
38
|
+
}: {
|
|
39
|
+
signalManager: SignalManager;
|
|
40
|
+
networkManager: SwarmNetworkManager;
|
|
41
|
+
}) =>
|
|
35
42
|
new Stream<SignalResponse>(({ next }) => {
|
|
36
43
|
const ctx = new Context();
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
|
|
45
|
+
// Observe point-to-point messages delivered to this node's own peer. The subscription owns its
|
|
46
|
+
// routing and teardown (DX-1125); with no local peer yet there is nothing to observe.
|
|
47
|
+
let unsubscribe: UnsubscribeCallback | undefined;
|
|
48
|
+
const peer = networkManager.getPeerInfo();
|
|
49
|
+
if (peer) {
|
|
50
|
+
void signalManager
|
|
51
|
+
.subscribeMessages({
|
|
52
|
+
peer,
|
|
53
|
+
onMessage: (message) => {
|
|
54
|
+
next({
|
|
55
|
+
message: {
|
|
56
|
+
author: PublicKey.from(message.author.peerKey).asUint8Array(),
|
|
57
|
+
recipient: message.recipient
|
|
58
|
+
? PublicKey.from(message.recipient.peerKey).asUint8Array()
|
|
59
|
+
: new Uint8Array(),
|
|
60
|
+
payload: message.payload,
|
|
61
|
+
},
|
|
62
|
+
receivedAt: new Date(),
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
})
|
|
66
|
+
.then((unsub) => {
|
|
67
|
+
if (ctx.disposed) {
|
|
68
|
+
void unsub();
|
|
69
|
+
} else {
|
|
70
|
+
unsubscribe = unsub;
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
.catch((err) => log.catch(err));
|
|
74
|
+
}
|
|
75
|
+
|
|
47
76
|
signalManager.swarmEvent.on(ctx, (swarmEvent) => {
|
|
48
77
|
next({
|
|
49
78
|
swarmEvent: swarmEvent.peerAvailable
|
|
@@ -59,6 +88,7 @@ export const subscribeToSignal = ({ signalManager }: { signalManager: SignalMana
|
|
|
59
88
|
});
|
|
60
89
|
});
|
|
61
90
|
return () => {
|
|
91
|
+
void unsubscribe?.();
|
|
62
92
|
return ctx.dispose();
|
|
63
93
|
};
|
|
64
94
|
});
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Stream } from '@dxos/codec-protobuf/stream';
|
|
6
|
-
import { type Space } from '@dxos/echo-host';
|
|
7
6
|
import {
|
|
8
7
|
type SubscribeToSpacesRequest,
|
|
9
8
|
type SubscribeToSpacesResponse,
|
|
@@ -11,6 +10,7 @@ import {
|
|
|
11
10
|
import { type SpaceMetadata } from '@dxos/protocols/proto/dxos/echo/metadata';
|
|
12
11
|
|
|
13
12
|
import { type ServiceContext } from '../services';
|
|
13
|
+
import { type Space } from '../space';
|
|
14
14
|
|
|
15
15
|
export const subscribeToSpaces = (context: ServiceContext, { spaceKeys = [] }: SubscribeToSpacesRequest) => {
|
|
16
16
|
return new Stream<SubscribeToSpacesResponse>(({ next }) => {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type SystemService } from '@dxos/protocols/
|
|
5
|
+
import { type SystemService } from '@dxos/protocols/rpc';
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
type CollectDiagnosticsBroadcastHandler,
|
|
@@ -13,7 +13,9 @@ export const createCollectDiagnosticsBroadcastSender = (): CollectDiagnosticsBro
|
|
|
13
13
|
return { broadcastDiagnosticsRequest: async () => undefined };
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
export const createCollectDiagnosticsBroadcastHandler = (
|
|
16
|
+
export const createCollectDiagnosticsBroadcastHandler = (
|
|
17
|
+
_: SystemService.Handlers,
|
|
18
|
+
): CollectDiagnosticsBroadcastHandler => {
|
|
17
19
|
return {
|
|
18
20
|
start: () => {},
|
|
19
21
|
stop: () => {},
|
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type ClientServicesProvider
|
|
6
|
-
import { type Config
|
|
5
|
+
import { type ClientServicesProvider } from '@dxos/client-protocol';
|
|
6
|
+
import { type Config } from '@dxos/config';
|
|
7
7
|
import { GetDiagnosticsRequest } from '@dxos/protocols/proto/dxos/client/services';
|
|
8
|
-
import {
|
|
9
|
-
import { type JsonKeyOptions, isNonNullable, jsonKeyReplacer } from '@dxos/util';
|
|
8
|
+
import { type JsonKeyOptions, jsonKeyReplacer } from '@dxos/util';
|
|
10
9
|
|
|
11
10
|
import { createCollectDiagnosticsBroadcastSender } from './diagnostics-broadcast';
|
|
12
11
|
|
|
@@ -25,8 +24,8 @@ export class DiagnosticsCollector {
|
|
|
25
24
|
private static broadcastSender = createCollectDiagnosticsBroadcastSender();
|
|
26
25
|
|
|
27
26
|
public static async collect(
|
|
28
|
-
config: Config | Config[] =
|
|
29
|
-
services: ClientServicesProvider | null =
|
|
27
|
+
config: Config | Config[] = [],
|
|
28
|
+
services: ClientServicesProvider | null = null,
|
|
30
29
|
options: JsonKeyOptions = {},
|
|
31
30
|
): Promise<any> {
|
|
32
31
|
const serviceDiagnostics = await services?.services?.SystemService?.getDiagnostics(
|
|
@@ -42,7 +41,6 @@ export class DiagnosticsCollector {
|
|
|
42
41
|
|
|
43
42
|
const clientDiagnostics = {
|
|
44
43
|
config,
|
|
45
|
-
trace: TRACE_PROCESSOR.getDiagnostics(),
|
|
46
44
|
};
|
|
47
45
|
|
|
48
46
|
const diagnostics =
|
|
@@ -56,14 +54,3 @@ export class DiagnosticsCollector {
|
|
|
56
54
|
return JSON.parse(JSON.stringify(diagnostics, jsonKeyReplacer(options)));
|
|
57
55
|
}
|
|
58
56
|
}
|
|
59
|
-
|
|
60
|
-
const findSystemServiceProvider = (): ClientServicesProvider | null => {
|
|
61
|
-
const serviceProviders = TRACE_PROCESSOR.findResourcesByAnnotation(ClientServicesProviderResource);
|
|
62
|
-
const providerResource = serviceProviders.find((r) => r.instance.deref()?.services?.SystemService != null);
|
|
63
|
-
return providerResource?.instance?.deref() ?? null;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const findConfigs = (): Config[] => {
|
|
67
|
-
const configs = TRACE_PROCESSOR.findResourcesByAnnotation(ConfigResource);
|
|
68
|
-
return configs.map((r) => r.instance.deref()).filter(isNonNullable);
|
|
69
|
-
};
|
|
@@ -13,7 +13,6 @@ import { STORAGE_VERSION } from '@dxos/protocols';
|
|
|
13
13
|
import {
|
|
14
14
|
type Device,
|
|
15
15
|
type Identity,
|
|
16
|
-
type LogEntry,
|
|
17
16
|
type Metrics,
|
|
18
17
|
type NetworkStatus,
|
|
19
18
|
type Platform,
|
|
@@ -23,8 +22,6 @@ import {
|
|
|
23
22
|
import { type SubscribeToFeedsResponse } from '@dxos/protocols/proto/dxos/devtools/host';
|
|
24
23
|
import { type SwarmInfo } from '@dxos/protocols/proto/dxos/devtools/swarm';
|
|
25
24
|
import { type Epoch } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
26
|
-
import { type Resource } from '@dxos/protocols/proto/dxos/tracing';
|
|
27
|
-
import { TRACE_PROCESSOR } from '@dxos/tracing';
|
|
28
25
|
|
|
29
26
|
import { DXOS_VERSION } from '../../version';
|
|
30
27
|
import { type ServiceContext } from '../services';
|
|
@@ -36,10 +33,8 @@ const DEFAULT_TIMEOUT = 1_000;
|
|
|
36
33
|
export type Diagnostics = {
|
|
37
34
|
client: {
|
|
38
35
|
config: ConfigProto;
|
|
39
|
-
trace: TraceDiagnostic;
|
|
40
36
|
};
|
|
41
37
|
services: {
|
|
42
|
-
trace: TraceDiagnostic;
|
|
43
38
|
created: string;
|
|
44
39
|
platform: Platform;
|
|
45
40
|
config?: ConfigProto;
|
|
@@ -60,11 +55,6 @@ export type Diagnostics = {
|
|
|
60
55
|
};
|
|
61
56
|
};
|
|
62
57
|
|
|
63
|
-
export type TraceDiagnostic = {
|
|
64
|
-
resources: Record<string, Resource>;
|
|
65
|
-
logs: LogEntry[];
|
|
66
|
-
};
|
|
67
|
-
|
|
68
58
|
// TODO(burdon): Normalize for ECHO/HALO.
|
|
69
59
|
export type SpaceStats = {
|
|
70
60
|
key: PublicKey;
|
|
@@ -99,7 +89,6 @@ export const createDiagnostics = async (
|
|
|
99
89
|
version: STORAGE_VERSION,
|
|
100
90
|
},
|
|
101
91
|
},
|
|
102
|
-
trace: TRACE_PROCESSOR.getDiagnostics(),
|
|
103
92
|
};
|
|
104
93
|
|
|
105
94
|
await Promise.all([
|
|
@@ -5,12 +5,13 @@
|
|
|
5
5
|
import { type Event, Trigger } from '@dxos/async';
|
|
6
6
|
import { Context } from '@dxos/context';
|
|
7
7
|
import { type CredentialSigner, verifyCredential } from '@dxos/credentials';
|
|
8
|
-
import { type AuthProvider, type AuthVerifier } from '@dxos/echo-host';
|
|
9
8
|
import { type PublicKey } from '@dxos/keys';
|
|
10
9
|
import { log } from '@dxos/log';
|
|
11
10
|
import { schema } from '@dxos/protocols/proto';
|
|
12
11
|
import { type ComplexSet } from '@dxos/util';
|
|
13
12
|
|
|
13
|
+
import { type AuthProvider, type AuthVerifier } from '../space';
|
|
14
|
+
|
|
14
15
|
const Credential = schema.getCodecForType('dxos.halo.credentials.Credential');
|
|
15
16
|
|
|
16
17
|
export const createAuthProvider =
|
|
@@ -2,62 +2,40 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import * as EffectStream from 'effect/Stream';
|
|
7
|
+
|
|
5
8
|
import { SubscriptionList, UpdateScheduler, scheduleTask } from '@dxos/async';
|
|
6
|
-
import {
|
|
9
|
+
import { Context } from '@dxos/context';
|
|
7
10
|
import { type MemberInfo } from '@dxos/credentials';
|
|
8
|
-
import { type SpaceManager } from '@dxos/echo-host';
|
|
9
11
|
import { PublicKey } from '@dxos/keys';
|
|
10
|
-
import { type Contact, type ContactBook
|
|
12
|
+
import { type Contact, type ContactBook } from '@dxos/protocols/proto/dxos/client/services';
|
|
13
|
+
import { type ContactsService } from '@dxos/protocols/rpc';
|
|
11
14
|
import { ComplexMap, ComplexSet } from '@dxos/util';
|
|
12
15
|
|
|
16
|
+
import { type SpaceManager } from '../space';
|
|
13
17
|
import { type DataSpaceManager } from '../spaces';
|
|
14
18
|
import { type IdentityManager } from './identity-manager';
|
|
15
19
|
|
|
16
|
-
export class ContactsServiceImpl implements ContactsService {
|
|
17
|
-
constructor(
|
|
20
|
+
export class ContactsServiceImpl implements ContactsService.Handlers {
|
|
21
|
+
'constructor'(
|
|
18
22
|
private readonly _identityManager: IdentityManager,
|
|
19
23
|
private readonly _spaceManager: SpaceManager,
|
|
20
24
|
private readonly _dataSpaceManagerProvider: () => Promise<DataSpaceManager>,
|
|
21
25
|
) {}
|
|
22
26
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (identity == null) {
|
|
26
|
-
return { contacts: [] };
|
|
27
|
-
}
|
|
28
|
-
const contacts = [...this._spaceManager.spaces.values()]
|
|
29
|
-
.flatMap((s) => [...s.spaceState.members.values()].map((m) => [s.key, m]))
|
|
30
|
-
.reduce((acc, v) => {
|
|
31
|
-
const [spaceKey, memberInfo] = v as [PublicKey, MemberInfo];
|
|
32
|
-
if (memberInfo.key.equals(identity.identityKey)) {
|
|
33
|
-
return acc;
|
|
34
|
-
}
|
|
35
|
-
const existing = acc.get(memberInfo.key);
|
|
36
|
-
if (existing != null) {
|
|
37
|
-
existing.profile ??= memberInfo.profile;
|
|
38
|
-
existing.commonSpaces?.push(spaceKey);
|
|
39
|
-
} else {
|
|
40
|
-
acc.set(memberInfo.key, {
|
|
41
|
-
identityKey: memberInfo.key,
|
|
42
|
-
profile: memberInfo.profile,
|
|
43
|
-
commonSpaces: [spaceKey],
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
return acc;
|
|
47
|
-
}, new ComplexMap<PublicKey, Contact>(PublicKey.hash));
|
|
48
|
-
return {
|
|
49
|
-
contacts: [...contacts.values()],
|
|
50
|
-
};
|
|
27
|
+
['ContactsService.getContacts'](): Effect.Effect<ContactBook, Error> {
|
|
28
|
+
return Effect.sync(() => this.#getContacts());
|
|
51
29
|
}
|
|
52
30
|
|
|
53
|
-
queryContacts(): Stream<ContactBook> {
|
|
31
|
+
['ContactsService.queryContacts'](): EffectStream.Stream<ContactBook, Error> {
|
|
54
32
|
const subscribedSpaceKeySet = new ComplexSet(PublicKey.hash);
|
|
55
|
-
return
|
|
33
|
+
return EffectStream.async<ContactBook, Error>((emit) => {
|
|
34
|
+
const ctx = Context.default();
|
|
56
35
|
const pushUpdateTask = new UpdateScheduler(
|
|
57
36
|
ctx,
|
|
58
37
|
async () => {
|
|
59
|
-
|
|
60
|
-
next(contacts);
|
|
38
|
+
void emit.single(this.#getContacts());
|
|
61
39
|
},
|
|
62
40
|
{ maxFrequency: 2 },
|
|
63
41
|
);
|
|
@@ -80,6 +58,37 @@ export class ContactsServiceImpl implements ContactsService {
|
|
|
80
58
|
ctx.onDispose(unsubscribe);
|
|
81
59
|
subscribeToSpaceAndUpdate();
|
|
82
60
|
});
|
|
61
|
+
return Effect.promise(() => ctx.dispose());
|
|
83
62
|
});
|
|
84
63
|
}
|
|
64
|
+
|
|
65
|
+
#getContacts(): ContactBook {
|
|
66
|
+
const identity = this._identityManager.identity;
|
|
67
|
+
if (identity == null) {
|
|
68
|
+
return { contacts: [] };
|
|
69
|
+
}
|
|
70
|
+
const contacts = [...this._spaceManager.spaces.values()]
|
|
71
|
+
.flatMap((s) => [...s.spaceState.members.values()].map((m) => [s.key, m]))
|
|
72
|
+
.reduce((acc, v) => {
|
|
73
|
+
const [spaceKey, memberInfo] = v as [PublicKey, MemberInfo];
|
|
74
|
+
if (memberInfo.key.equals(identity.identityKey)) {
|
|
75
|
+
return acc;
|
|
76
|
+
}
|
|
77
|
+
const existing = acc.get(memberInfo.key);
|
|
78
|
+
if (existing != null) {
|
|
79
|
+
existing.profile ??= memberInfo.profile;
|
|
80
|
+
existing.commonSpaces?.push(spaceKey);
|
|
81
|
+
} else {
|
|
82
|
+
acc.set(memberInfo.key, {
|
|
83
|
+
identityKey: memberInfo.key,
|
|
84
|
+
profile: memberInfo.profile,
|
|
85
|
+
commonSpaces: [spaceKey],
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
return acc;
|
|
89
|
+
}, new ComplexMap<PublicKey, Contact>(PublicKey.hash));
|
|
90
|
+
return {
|
|
91
|
+
contacts: [...contacts.values()],
|
|
92
|
+
};
|
|
93
|
+
}
|
|
85
94
|
}
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
import { describe, expect, onTestFinished, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { Context } from '@dxos/context';
|
|
8
|
-
import { AuthStatus, MetadataStore, SpaceManager, valueEncoding } from '@dxos/echo-host';
|
|
9
8
|
import { FeedFactory, FeedStore } from '@dxos/feed-store';
|
|
10
9
|
import { Keyring } from '@dxos/keyring';
|
|
11
10
|
import { MemorySignalManager, MemorySignalManagerContext } from '@dxos/messaging';
|
|
@@ -14,6 +13,9 @@ import type { FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
|
|
|
14
13
|
import { type Storage, StorageType, createStorage } from '@dxos/random-access-storage';
|
|
15
14
|
import { BlobStore } from '@dxos/teleport-extension-object-sync';
|
|
16
15
|
|
|
16
|
+
import { MetadataStore } from '../metadata';
|
|
17
|
+
import { valueEncoding } from '../pipeline';
|
|
18
|
+
import { AuthStatus, SpaceManager } from '../space';
|
|
17
19
|
import { IdentityManager } from './identity-manager';
|
|
18
20
|
|
|
19
21
|
describe('identity/identity-manager', () => {
|