@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,16 +2,22 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import * as Option from 'effect/Option';
|
|
7
|
+
import * as Runtime from 'effect/Runtime';
|
|
8
|
+
import * as Stream from 'effect/Stream';
|
|
9
|
+
import { beforeEach, describe, expect, onTestFinished, test } from 'vitest';
|
|
6
10
|
|
|
7
11
|
import { Event, Trigger } from '@dxos/async';
|
|
8
12
|
import { Config } from '@dxos/config';
|
|
9
|
-
import {
|
|
13
|
+
import { EffectEx } from '@dxos/effect';
|
|
14
|
+
import { subscribeStream } from '@dxos/protocols';
|
|
15
|
+
import { SystemStatus } from '@dxos/protocols/proto/dxos/client/services';
|
|
10
16
|
|
|
11
17
|
import { SystemServiceImpl } from './system-service';
|
|
12
18
|
|
|
13
19
|
describe('SystemService', () => {
|
|
14
|
-
let systemService:
|
|
20
|
+
let systemService: SystemServiceImpl;
|
|
15
21
|
let config: Config;
|
|
16
22
|
let statusUpdate: Event<void>;
|
|
17
23
|
let currentStatus: SystemStatus;
|
|
@@ -45,35 +51,47 @@ describe('SystemService', () => {
|
|
|
45
51
|
});
|
|
46
52
|
|
|
47
53
|
test('getConfig returns config', async () => {
|
|
48
|
-
expect(await systemService.getConfig()).to.deep.equal(config.values);
|
|
54
|
+
expect(await EffectEx.runPromise(systemService['SystemService.getConfig']())).to.deep.equal(config.values);
|
|
49
55
|
});
|
|
50
56
|
|
|
51
57
|
test('updateStatus triggers callback', async () => {
|
|
52
|
-
await systemService.updateStatus({ status: SystemStatus.INACTIVE });
|
|
58
|
+
await EffectEx.runPromise(systemService['SystemService.updateStatus']({ status: SystemStatus.INACTIVE }));
|
|
53
59
|
const result = await updateStatus.wait();
|
|
54
60
|
expect(result).to.equal(SystemStatus.INACTIVE);
|
|
55
61
|
});
|
|
56
62
|
|
|
57
63
|
test('queryStatus returns initial status', async () => {
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
});
|
|
62
|
-
expect(await status.wait()).to.deep.equal({ status: SystemStatus.ACTIVE });
|
|
64
|
+
const response = await EffectEx.runPromise(
|
|
65
|
+
systemService['SystemService.queryStatus']({}).pipe(Stream.runHead, Effect.map(Option.getOrThrow)),
|
|
66
|
+
);
|
|
67
|
+
expect(response).to.deep.equal({ status: SystemStatus.ACTIVE });
|
|
63
68
|
});
|
|
64
69
|
|
|
65
70
|
test('queryStatus streams status changes', async () => {
|
|
66
71
|
const statuses: SystemStatus[] = [];
|
|
67
|
-
|
|
68
|
-
|
|
72
|
+
const first = new Trigger();
|
|
73
|
+
const done = new Trigger();
|
|
74
|
+
const cleanup = subscribeStream(Runtime.defaultRuntime, systemService['SystemService.queryStatus']({}), {
|
|
75
|
+
onData: ({ status }) => {
|
|
76
|
+
statuses.push(status);
|
|
77
|
+
first.wake();
|
|
78
|
+
if (statuses.length === 3) {
|
|
79
|
+
done.wake();
|
|
80
|
+
}
|
|
81
|
+
},
|
|
69
82
|
});
|
|
83
|
+
onTestFinished(cleanup);
|
|
84
|
+
|
|
85
|
+
// Wait for the initial emission so the status subscription is active before mutating.
|
|
86
|
+
await first.wait();
|
|
70
87
|
changeStatus(SystemStatus.INACTIVE);
|
|
71
88
|
changeStatus(SystemStatus.ACTIVE);
|
|
89
|
+
await done.wait();
|
|
72
90
|
expect(statuses).to.deep.equal([SystemStatus.ACTIVE, SystemStatus.INACTIVE, SystemStatus.ACTIVE]);
|
|
73
91
|
});
|
|
74
92
|
|
|
75
93
|
test('reset triggers callback', async () => {
|
|
76
|
-
await systemService.reset();
|
|
94
|
+
await EffectEx.runPromise(systemService['SystemService.reset']());
|
|
77
95
|
const result = await reset.wait();
|
|
78
96
|
expect(result).to.be.true;
|
|
79
97
|
});
|
|
@@ -2,18 +2,22 @@
|
|
|
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 { type Event } from '@dxos/async';
|
|
6
|
-
import { Stream } from '@dxos/codec-protobuf/stream';
|
|
7
9
|
import { type Config } from '@dxos/config';
|
|
8
10
|
import {
|
|
9
11
|
GetDiagnosticsRequest,
|
|
12
|
+
type GetDiagnosticsResponse,
|
|
10
13
|
type Platform,
|
|
11
14
|
type QueryStatusRequest,
|
|
12
15
|
type QueryStatusResponse,
|
|
13
|
-
type SystemService,
|
|
14
16
|
type SystemStatus,
|
|
15
17
|
type UpdateStatusRequest,
|
|
16
18
|
} from '@dxos/protocols/proto/dxos/client/services';
|
|
19
|
+
import { type Config as ConfigProto } from '@dxos/protocols/proto/dxos/config';
|
|
20
|
+
import { type SystemService } from '@dxos/protocols/rpc';
|
|
17
21
|
import { type MaybePromise, jsonKeyReplacer } from '@dxos/util';
|
|
18
22
|
|
|
19
23
|
import { type Diagnostics } from '../diagnostics';
|
|
@@ -28,15 +32,15 @@ export type SystemServiceOptions = {
|
|
|
28
32
|
onReset: () => MaybePromise<void>;
|
|
29
33
|
};
|
|
30
34
|
|
|
31
|
-
export class SystemServiceImpl implements SystemService {
|
|
32
|
-
private readonly _config?: SystemServiceOptions['config'];
|
|
33
|
-
private readonly _statusUpdate: SystemServiceOptions['statusUpdate'];
|
|
34
|
-
private readonly _getCurrentStatus: SystemServiceOptions['getCurrentStatus'];
|
|
35
|
-
private readonly _onUpdateStatus: SystemServiceOptions['onUpdateStatus'];
|
|
36
|
-
private readonly _onReset: SystemServiceOptions['onReset'];
|
|
37
|
-
private readonly _getDiagnostics: SystemServiceOptions['getDiagnostics'];
|
|
35
|
+
export class SystemServiceImpl implements SystemService.Handlers {
|
|
36
|
+
private readonly '_config'?: SystemServiceOptions['config'];
|
|
37
|
+
private readonly '_statusUpdate': SystemServiceOptions['statusUpdate'];
|
|
38
|
+
private readonly '_getCurrentStatus': SystemServiceOptions['getCurrentStatus'];
|
|
39
|
+
private readonly '_onUpdateStatus': SystemServiceOptions['onUpdateStatus'];
|
|
40
|
+
private readonly '_onReset': SystemServiceOptions['onReset'];
|
|
41
|
+
private readonly '_getDiagnostics': SystemServiceOptions['getDiagnostics'];
|
|
38
42
|
|
|
39
|
-
constructor({
|
|
43
|
+
'constructor'({
|
|
40
44
|
config,
|
|
41
45
|
statusUpdate,
|
|
42
46
|
getDiagnostics,
|
|
@@ -52,55 +56,79 @@ export class SystemServiceImpl implements SystemService {
|
|
|
52
56
|
this._onReset = onReset;
|
|
53
57
|
}
|
|
54
58
|
|
|
55
|
-
|
|
56
|
-
return
|
|
59
|
+
['SystemService.getConfig'](): Effect.Effect<ConfigProto, Error> {
|
|
60
|
+
return Effect.tryPromise({
|
|
61
|
+
try: async () => (await this._config?.())?.values ?? {},
|
|
62
|
+
catch: (error) => error as Error,
|
|
63
|
+
});
|
|
57
64
|
}
|
|
58
65
|
|
|
59
66
|
/**
|
|
60
67
|
* NOTE: Since this is serialized as a JSON object, we allow the option to serialize keys.
|
|
61
68
|
*/
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
diagnostics
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
69
|
+
['SystemService.getDiagnostics']({ keys }: GetDiagnosticsRequest = {}): Effect.Effect<GetDiagnosticsResponse, Error> {
|
|
70
|
+
return Effect.tryPromise({
|
|
71
|
+
try: async () => {
|
|
72
|
+
const diagnostics = await this._getDiagnostics();
|
|
73
|
+
return {
|
|
74
|
+
timestamp: new Date(),
|
|
75
|
+
diagnostics: JSON.parse(
|
|
76
|
+
JSON.stringify(
|
|
77
|
+
diagnostics,
|
|
78
|
+
jsonKeyReplacer({
|
|
79
|
+
truncate: keys === GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
|
|
80
|
+
humanize: keys === GetDiagnosticsRequest.KEY_OPTION.HUMANIZE,
|
|
81
|
+
}),
|
|
82
|
+
),
|
|
83
|
+
),
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
catch: (error) => error as Error,
|
|
87
|
+
});
|
|
76
88
|
}
|
|
77
89
|
|
|
78
|
-
|
|
79
|
-
return
|
|
90
|
+
['SystemService.getPlatform'](): Effect.Effect<Platform, Error> {
|
|
91
|
+
return Effect.tryPromise({
|
|
92
|
+
try: async () => getPlatform(),
|
|
93
|
+
catch: (error) => error as Error,
|
|
94
|
+
});
|
|
80
95
|
}
|
|
81
96
|
|
|
82
|
-
|
|
83
|
-
|
|
97
|
+
['SystemService.updateStatus']({ status }: UpdateStatusRequest): Effect.Effect<void, Error> {
|
|
98
|
+
return Effect.tryPromise({
|
|
99
|
+
try: async () => {
|
|
100
|
+
await this._onUpdateStatus(status);
|
|
101
|
+
},
|
|
102
|
+
catch: (error) => error as Error,
|
|
103
|
+
});
|
|
84
104
|
}
|
|
85
105
|
|
|
86
106
|
// TODO(burdon): Standardize interval option in stream request?
|
|
87
|
-
queryStatus({ interval = 3_000 }: QueryStatusRequest = {}): Stream<
|
|
88
|
-
|
|
107
|
+
['SystemService.queryStatus']({ interval = 3_000 }: QueryStatusRequest = {}): EffectStream.Stream<
|
|
108
|
+
QueryStatusResponse,
|
|
109
|
+
Error
|
|
110
|
+
> {
|
|
111
|
+
return EffectStream.async<QueryStatusResponse, Error>((emit) => {
|
|
89
112
|
const update = () => {
|
|
90
|
-
|
|
113
|
+
void emit.single({ status: this._getCurrentStatus() });
|
|
91
114
|
};
|
|
92
115
|
|
|
93
116
|
update();
|
|
94
117
|
const unsubscribe = this._statusUpdate.on(() => update());
|
|
95
118
|
const i = setInterval(update, interval);
|
|
96
|
-
return () => {
|
|
119
|
+
return Effect.sync(() => {
|
|
97
120
|
clearInterval(i);
|
|
98
121
|
unsubscribe();
|
|
99
|
-
};
|
|
122
|
+
});
|
|
100
123
|
});
|
|
101
124
|
}
|
|
102
125
|
|
|
103
|
-
|
|
104
|
-
|
|
126
|
+
['SystemService.reset'](): Effect.Effect<void, Error> {
|
|
127
|
+
return Effect.tryPromise({
|
|
128
|
+
try: async () => {
|
|
129
|
+
await this._onReset();
|
|
130
|
+
},
|
|
131
|
+
catch: (error) => error as Error,
|
|
132
|
+
});
|
|
105
133
|
}
|
|
106
134
|
}
|
|
@@ -9,7 +9,7 @@ import { invariant } from '@dxos/invariant';
|
|
|
9
9
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
10
10
|
import { type DeviceProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
11
11
|
|
|
12
|
-
import { ServiceContext } from '../services';
|
|
12
|
+
import { ClientServicesHost, type ServiceContext } from '../services';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Strip secrets from invitation before giving it to the peer.
|
|
@@ -229,7 +229,7 @@ export const createInvitation = async (
|
|
|
229
229
|
...(options ?? {}),
|
|
230
230
|
};
|
|
231
231
|
|
|
232
|
-
if (host instanceof
|
|
232
|
+
if (host instanceof ClientServicesHost) {
|
|
233
233
|
return host.invitationsManager.createInvitation(new Context(), {
|
|
234
234
|
kind: Invitation.Kind.SPACE,
|
|
235
235
|
...options,
|
|
@@ -246,7 +246,7 @@ export const acceptInvitation = (
|
|
|
246
246
|
): AuthenticatingInvitation => {
|
|
247
247
|
invitation = sanitizeInvitation(invitation);
|
|
248
248
|
|
|
249
|
-
if (guest instanceof
|
|
249
|
+
if (guest instanceof ClientServicesHost) {
|
|
250
250
|
return guest.invitationsManager.acceptInvitation(new Context(), {
|
|
251
251
|
invitation,
|
|
252
252
|
deviceProfile: guestDeviceProfile,
|
|
@@ -7,12 +7,11 @@ import * as Effect from 'effect/Effect';
|
|
|
7
7
|
import * as Layer from 'effect/Layer';
|
|
8
8
|
import * as ManagedRuntime from 'effect/ManagedRuntime';
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { Config } from '@dxos/config';
|
|
11
11
|
import { Context } from '@dxos/context';
|
|
12
12
|
import { CredentialGenerator, createCredentialSignerWithChain } from '@dxos/credentials';
|
|
13
13
|
import { failUndefined } from '@dxos/debug';
|
|
14
|
-
import { EchoHost, MeshEchoReplicator
|
|
15
|
-
import { SqliteMetadataStore } from '@dxos/echo-host';
|
|
14
|
+
import { EchoHost, MeshEchoReplicator } from '@dxos/echo-host';
|
|
16
15
|
import { RuntimeProvider } from '@dxos/effect';
|
|
17
16
|
import { FeedFactory, FeedStore } from '@dxos/feed-store';
|
|
18
17
|
import { SqliteKeyring } from '@dxos/keyring';
|
|
@@ -25,8 +24,11 @@ import * as SqlTransaction from '@dxos/sql-sqlite/SqlTransaction';
|
|
|
25
24
|
import { SqliteBlobStore } from '@dxos/teleport-extension-object-sync';
|
|
26
25
|
|
|
27
26
|
import { InvitationsHandler, InvitationsManager, SpaceInvitationProtocol } from '../invitations';
|
|
28
|
-
import {
|
|
27
|
+
import { SqliteMetadataStore } from '../metadata';
|
|
28
|
+
import { valueEncoding } from '../pipeline';
|
|
29
|
+
import { ClientServicesHost, type ServiceContext, type ServiceContextRuntimeProps } from '../services';
|
|
29
30
|
import { SqliteStorage } from '../services/sqlite-storage';
|
|
31
|
+
import { SpaceManager } from '../space';
|
|
30
32
|
import { DataSpaceManager, type DataSpaceManagerRuntimeProps, type SigningContext } from '../spaces';
|
|
31
33
|
|
|
32
34
|
//
|
|
@@ -55,23 +57,35 @@ export const createServiceContext = async ({
|
|
|
55
57
|
}: {
|
|
56
58
|
signalManagerFactory?: () => Promise<SignalManager>;
|
|
57
59
|
runtimeProps?: ServiceContextRuntimeProps;
|
|
58
|
-
} = {}) => {
|
|
60
|
+
} = {}): Promise<ServiceContext> => {
|
|
59
61
|
const signalManager = await signalManagerFactory();
|
|
60
|
-
const networkManager = new SwarmNetworkManager({
|
|
61
|
-
signalManager,
|
|
62
|
-
transportFactory: MemoryTransportFactory,
|
|
63
|
-
});
|
|
64
62
|
|
|
63
|
+
// The host builds its component stack over this SQLite runtime; dispose it once the host closes so
|
|
64
|
+
// the layer-scoped finalizers (e.g. EchoHost) do not leak across tests.
|
|
65
65
|
const runtime = ManagedRuntime.make(
|
|
66
66
|
SqlTransaction.layer
|
|
67
67
|
.pipe(Layer.provideMerge(sqliteLayerMemory), Layer.provideMerge(Reactivity.layer))
|
|
68
68
|
.pipe(Layer.orDie),
|
|
69
|
-
)
|
|
69
|
+
);
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
const host = new ClientServicesHost({
|
|
72
|
+
config: new Config(),
|
|
73
|
+
signalManager,
|
|
74
|
+
transportFactory: MemoryTransportFactory,
|
|
75
|
+
runtime: runtime.runtimeEffect,
|
|
76
|
+
runtimeProps: {
|
|
77
|
+
invitationConnectionDefaultProps: { teleport: { controlHeartbeatInterval: 200 } },
|
|
78
|
+
...runtimeProps,
|
|
79
|
+
},
|
|
74
80
|
});
|
|
81
|
+
|
|
82
|
+
const closeHost = host.close.bind(host);
|
|
83
|
+
host.close = async (ctx = new Context()) => {
|
|
84
|
+
await closeHost(ctx);
|
|
85
|
+
await runtime.dispose();
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
return host;
|
|
75
89
|
};
|
|
76
90
|
|
|
77
91
|
export const createPeers = async (numPeers: number, signalManagerFactory?: () => Promise<SignalManager>) => {
|
|
@@ -204,7 +218,7 @@ export class TestPeer {
|
|
|
204
218
|
spaceManager: this.spaceManager,
|
|
205
219
|
metadataStore: this.metadataStore,
|
|
206
220
|
keyring: this.keyring,
|
|
207
|
-
|
|
221
|
+
signingContextProvider: () => this.identity,
|
|
208
222
|
feedStore: this.feedStore,
|
|
209
223
|
echoHost: this.echoHost,
|
|
210
224
|
invitationsManager: this.invitationsManager,
|
|
@@ -216,17 +230,18 @@ export class TestPeer {
|
|
|
216
230
|
}
|
|
217
231
|
|
|
218
232
|
get invitationsManager() {
|
|
219
|
-
|
|
220
|
-
new InvitationsHandler(this.networkManager),
|
|
221
|
-
(invitation) => {
|
|
233
|
+
if (!this._props.invitationsManager) {
|
|
234
|
+
const manager = new InvitationsManager(new InvitationsHandler(this.networkManager), this.metadataStore);
|
|
235
|
+
manager.setInvitationHandlerFactory((invitation) => {
|
|
222
236
|
if (invitation.kind === Invitation.Kind.SPACE) {
|
|
223
237
|
return new SpaceInvitationProtocol(this.dataSpaceManager, this.identity!, this.keyring, invitation.spaceKey!);
|
|
224
238
|
} else {
|
|
225
239
|
throw new Error('not implemented');
|
|
226
240
|
}
|
|
227
|
-
}
|
|
228
|
-
this.
|
|
229
|
-
|
|
241
|
+
});
|
|
242
|
+
this._props.invitationsManager = manager;
|
|
243
|
+
}
|
|
244
|
+
return this._props.invitationsManager;
|
|
230
245
|
}
|
|
231
246
|
|
|
232
247
|
async createIdentity(): Promise<void> {
|