@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
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2022 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Context } from '@dxos/context';
|
|
6
|
+
import { CredentialGenerator } from '@dxos/credentials';
|
|
7
|
+
import { type FeedStore } from '@dxos/feed-store';
|
|
8
|
+
import { type Keyring } from '@dxos/keyring';
|
|
9
|
+
import { PublicKey } from '@dxos/keys';
|
|
10
|
+
import { MemorySignalManager, MemorySignalManagerContext } from '@dxos/messaging';
|
|
11
|
+
import { MemoryTransportFactory, SwarmNetworkManager } from '@dxos/network-manager';
|
|
12
|
+
import { type FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
|
|
13
|
+
import { type SpaceMetadata } from '@dxos/protocols/proto/dxos/echo/metadata';
|
|
14
|
+
import { AdmittedFeed } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
15
|
+
import { type Storage, StorageType, createStorage } from '@dxos/random-access-storage';
|
|
16
|
+
import { Gossip, Presence } from '@dxos/teleport-extension-gossip';
|
|
17
|
+
import { BlobStore } from '@dxos/teleport-extension-object-sync';
|
|
18
|
+
import { ComplexMap } from '@dxos/util';
|
|
19
|
+
|
|
20
|
+
import { MetadataStore } from '../../metadata';
|
|
21
|
+
import { TestFeedBuilder } from '../../pipeline/testing';
|
|
22
|
+
import { MOCK_AUTH_PROVIDER, MOCK_AUTH_VERIFIER, type Space, SpaceManager, SpaceProtocol } from '../index';
|
|
23
|
+
|
|
24
|
+
export type NetworkManagerProvider = () => SwarmNetworkManager;
|
|
25
|
+
|
|
26
|
+
export const MemoryNetworkManagerProvider =
|
|
27
|
+
(signalContext: MemorySignalManagerContext): NetworkManagerProvider =>
|
|
28
|
+
() =>
|
|
29
|
+
new SwarmNetworkManager({
|
|
30
|
+
signalManager: new MemorySignalManager(signalContext),
|
|
31
|
+
transportFactory: MemoryTransportFactory,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export type TestAgentBuilderOptions = {
|
|
35
|
+
storage?: Storage;
|
|
36
|
+
networkManagerProvider?: NetworkManagerProvider;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Factory for test agents.
|
|
41
|
+
*/
|
|
42
|
+
export class TestAgentBuilder {
|
|
43
|
+
private readonly _agents = new ComplexMap<PublicKey, TestAgent>(PublicKey.hash);
|
|
44
|
+
private readonly _storage: Storage;
|
|
45
|
+
private readonly _networkManagerProvider: NetworkManagerProvider;
|
|
46
|
+
|
|
47
|
+
constructor({ storage, networkManagerProvider }: TestAgentBuilderOptions = {}) {
|
|
48
|
+
this._storage = storage ?? createStorage({ type: StorageType.RAM });
|
|
49
|
+
this._networkManagerProvider =
|
|
50
|
+
networkManagerProvider ?? MemoryNetworkManagerProvider(new MemorySignalManagerContext());
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async close() {
|
|
54
|
+
return Promise.all(this.agents.map((agent) => agent.close()));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
get agents() {
|
|
58
|
+
return Array.from(this._agents.values());
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
getAgent(deviceKey: PublicKey): TestAgent | undefined {
|
|
62
|
+
return this._agents.get(deviceKey);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async createPeer(): Promise<TestAgent> {
|
|
66
|
+
// prettier-ignore
|
|
67
|
+
const feedBuilder = new TestFeedBuilder()
|
|
68
|
+
.setStorage(this._storage, `agent-${this._agents.size}`);
|
|
69
|
+
|
|
70
|
+
const identityKey = await feedBuilder.keyring.createKey();
|
|
71
|
+
const deviceKey = await feedBuilder.keyring.createKey();
|
|
72
|
+
|
|
73
|
+
const agent = new TestAgent(this._networkManagerProvider, feedBuilder, identityKey, deviceKey);
|
|
74
|
+
this._agents.set(deviceKey, agent);
|
|
75
|
+
return agent;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Test agent that enables the creation and replication of multiple spaces.
|
|
81
|
+
*/
|
|
82
|
+
export class TestAgent {
|
|
83
|
+
private readonly _spaces = new ComplexMap<PublicKey, Space>(PublicKey.hash);
|
|
84
|
+
|
|
85
|
+
public readonly storage: Storage;
|
|
86
|
+
public readonly keyring: Keyring;
|
|
87
|
+
public readonly feedStore: FeedStore<FeedMessage>;
|
|
88
|
+
|
|
89
|
+
private _metadataStore?: MetadataStore;
|
|
90
|
+
get metadataStore() {
|
|
91
|
+
return (this._metadataStore ??= new MetadataStore(this.storage.createDirectory('metadata')));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
private _blobStore?: BlobStore;
|
|
95
|
+
get blobStore() {
|
|
96
|
+
return (this._blobStore ??= new BlobStore(this.storage.createDirectory('blobs')));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
constructor(
|
|
100
|
+
private readonly _networkManagerProvider: NetworkManagerProvider,
|
|
101
|
+
private readonly _feedBuilder: TestFeedBuilder,
|
|
102
|
+
public readonly identityKey: PublicKey,
|
|
103
|
+
public readonly deviceKey: PublicKey,
|
|
104
|
+
) {
|
|
105
|
+
this.storage = this._feedBuilder.storage;
|
|
106
|
+
this.keyring = this._feedBuilder.keyring;
|
|
107
|
+
this.feedStore = this._feedBuilder.createFeedStore();
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async close() {
|
|
111
|
+
return Promise.all([...this.spaces.map((space) => space.close())]);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
get spaces() {
|
|
115
|
+
return Array.from(this._spaces.values());
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
getSpace(spaceKey: PublicKey): Space | undefined {
|
|
119
|
+
return this._spaces.get(spaceKey);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
private _networkManager?: SwarmNetworkManager;
|
|
123
|
+
get networkManager() {
|
|
124
|
+
if (this._networkManager) {
|
|
125
|
+
return this._networkManager;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
this._networkManager = this._networkManagerProvider();
|
|
129
|
+
this._networkManager.setPeerInfo({ peerKey: this.deviceKey.toHex(), identityKey: this.identityKey.toHex() });
|
|
130
|
+
|
|
131
|
+
return this._networkManager;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
private _spaceManager?: SpaceManager;
|
|
135
|
+
get spaceManager() {
|
|
136
|
+
return (this._spaceManager ??= new SpaceManager({
|
|
137
|
+
feedStore: this.feedStore,
|
|
138
|
+
networkManager: this.networkManager,
|
|
139
|
+
metadataStore: this.metadataStore,
|
|
140
|
+
blobStore: this.blobStore,
|
|
141
|
+
}));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
async createSpace(
|
|
145
|
+
identityKey: PublicKey = this.identityKey,
|
|
146
|
+
spaceKey?: PublicKey,
|
|
147
|
+
genesisKey?: PublicKey,
|
|
148
|
+
dataKey?: PublicKey,
|
|
149
|
+
saveMetadata = false,
|
|
150
|
+
): Promise<Space> {
|
|
151
|
+
if (!spaceKey) {
|
|
152
|
+
saveMetadata = true;
|
|
153
|
+
spaceKey = await this.keyring.createKey();
|
|
154
|
+
}
|
|
155
|
+
if (!genesisKey) {
|
|
156
|
+
genesisKey = await this.keyring.createKey();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const controlFeed = await this.feedStore.openFeed(genesisKey, { writable: true });
|
|
160
|
+
const dataFeed = await this.feedStore.openFeed(dataKey ?? (await this.keyring.createKey()), {
|
|
161
|
+
writable: true,
|
|
162
|
+
sparse: true,
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
const metadata: SpaceMetadata = {
|
|
166
|
+
key: spaceKey,
|
|
167
|
+
genesisFeedKey: genesisKey,
|
|
168
|
+
controlFeedKey: controlFeed.key,
|
|
169
|
+
dataFeedKey: dataFeed.key,
|
|
170
|
+
};
|
|
171
|
+
if (saveMetadata) {
|
|
172
|
+
await this.metadataStore.addSpace(metadata);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
await this.spaceManager.open();
|
|
176
|
+
const space = await this.spaceManager.constructSpace({
|
|
177
|
+
metadata,
|
|
178
|
+
swarmIdentity: {
|
|
179
|
+
identityKey: this.identityKey,
|
|
180
|
+
peerKey: this.deviceKey,
|
|
181
|
+
credentialProvider: MOCK_AUTH_PROVIDER,
|
|
182
|
+
credentialAuthenticator: MOCK_AUTH_VERIFIER,
|
|
183
|
+
},
|
|
184
|
+
memberKey: identityKey,
|
|
185
|
+
onAuthorizedConnection: (session) => {
|
|
186
|
+
session.addExtension(
|
|
187
|
+
'dxos.mesh.teleport.gossip',
|
|
188
|
+
this.createGossip().createExtension({ remotePeerId: session.remotePeerId }),
|
|
189
|
+
);
|
|
190
|
+
},
|
|
191
|
+
onDelegatedInvitationStatusChange: async () => {},
|
|
192
|
+
onMemberRolesChanged: async () => {},
|
|
193
|
+
});
|
|
194
|
+
await space.setControlFeed(controlFeed);
|
|
195
|
+
await space.setDataFeed(dataFeed);
|
|
196
|
+
|
|
197
|
+
await space.open(new Context());
|
|
198
|
+
|
|
199
|
+
this._spaces.set(spaceKey, space);
|
|
200
|
+
return space;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
createSpaceProtocol(topic: PublicKey, gossip?: Gossip): SpaceProtocol {
|
|
204
|
+
return new SpaceProtocol({
|
|
205
|
+
topic,
|
|
206
|
+
swarmIdentity: {
|
|
207
|
+
identityKey: this.identityKey,
|
|
208
|
+
peerKey: this.deviceKey,
|
|
209
|
+
credentialProvider: MOCK_AUTH_PROVIDER,
|
|
210
|
+
credentialAuthenticator: MOCK_AUTH_VERIFIER,
|
|
211
|
+
},
|
|
212
|
+
networkManager: this.networkManager,
|
|
213
|
+
blobStore: this.blobStore,
|
|
214
|
+
onSessionAuth: (session) => {
|
|
215
|
+
session.addExtension(
|
|
216
|
+
'dxos.mesh.teleport.gossip',
|
|
217
|
+
(gossip ?? this.createGossip()).createExtension({ remotePeerId: session.remotePeerId }),
|
|
218
|
+
);
|
|
219
|
+
},
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
createGossip(): Gossip {
|
|
224
|
+
return new Gossip({
|
|
225
|
+
localPeerId: this.deviceKey,
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
createPresence(gossip?: Gossip): Presence {
|
|
230
|
+
return new Presence({
|
|
231
|
+
announceInterval: 30,
|
|
232
|
+
offlineTimeout: 200,
|
|
233
|
+
identityKey: this.identityKey,
|
|
234
|
+
gossip: gossip ?? this.createGossip(),
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
async spaceGenesis(space: Space): Promise<void> {
|
|
239
|
+
const generator = new CredentialGenerator(this.keyring, this.identityKey, this.deviceKey);
|
|
240
|
+
const credentials = [
|
|
241
|
+
...(await generator.createSpaceGenesis(space.key, space.controlFeedKey!)),
|
|
242
|
+
await generator.createFeedAdmission(space.key, space.dataFeedKey!, AdmittedFeed.Designation.DATA),
|
|
243
|
+
await generator.createEpochCredential(space.key),
|
|
244
|
+
];
|
|
245
|
+
|
|
246
|
+
for (const credential of credentials) {
|
|
247
|
+
await space.controlPipeline.writer.write({
|
|
248
|
+
credential: { credential },
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
@@ -107,6 +107,8 @@ export const objJsonToObjectStructure = (obj: Obj.JSON): EntityStructure => {
|
|
|
107
107
|
// `objectStructureToObjJson`).
|
|
108
108
|
...(meta?.key !== undefined ? { key: meta.key } : {}),
|
|
109
109
|
...(meta?.version !== undefined ? { version: meta.version } : {}),
|
|
110
|
+
// Preserve annotations (see the symmetric write in `objectStructureToObjJson`).
|
|
111
|
+
...(meta?.annotations ? { annotations: meta.annotations } : {}),
|
|
110
112
|
},
|
|
111
113
|
data,
|
|
112
114
|
};
|
|
@@ -114,7 +116,7 @@ export const objJsonToObjectStructure = (obj: Obj.JSON): EntityStructure => {
|
|
|
114
116
|
|
|
115
117
|
/**
|
|
116
118
|
* Build a new {@link DatabaseDirectory} containing every object from the archive,
|
|
117
|
-
* keyed by object id. The caller is responsible for stamping the `access
|
|
119
|
+
* keyed by object id. The caller is responsible for stamping the `access` (space id/key)
|
|
118
120
|
* and version fields after the document is created.
|
|
119
121
|
*/
|
|
120
122
|
export const buildDatabaseDirectoryFromObjects = (objects: readonly Obj.JSON[]): DatabaseDirectory => {
|
|
@@ -3,17 +3,22 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type AutomergeUrl } from '@automerge/automerge-repo';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
import * as Exit from 'effect/Exit';
|
|
8
|
+
import * as Scope from 'effect/Scope';
|
|
6
9
|
|
|
7
10
|
import { Context } from '@dxos/context';
|
|
8
11
|
import { type Obj } from '@dxos/echo';
|
|
9
12
|
import { type SerializedFeed, type SerializedSpace } from '@dxos/echo-client';
|
|
10
13
|
import { type EchoHost } from '@dxos/echo-host';
|
|
11
14
|
import { type DatabaseDirectory, type EntityStructure } from '@dxos/echo-protocol';
|
|
15
|
+
import { EffectEx } from '@dxos/effect';
|
|
12
16
|
import { assertState, invariant } from '@dxos/invariant';
|
|
13
17
|
import { DXN, type EntityId, type IdentityDid, type SpaceId } from '@dxos/keys';
|
|
14
18
|
import { log } from '@dxos/log';
|
|
15
|
-
import { FeedProtocol } from '@dxos/protocols';
|
|
19
|
+
import { FeedProtocol, makeInProcessClient } from '@dxos/protocols';
|
|
16
20
|
import { SpaceArchive } from '@dxos/protocols/proto/dxos/client/services';
|
|
21
|
+
import { FeedService } from '@dxos/protocols/rpc';
|
|
17
22
|
import { createFilename } from '@dxos/util';
|
|
18
23
|
|
|
19
24
|
import { type DataSpace } from '../spaces/data-space';
|
|
@@ -164,6 +169,11 @@ export const objectStructureToObjJson = (objectId: string, structure: EntityStru
|
|
|
164
169
|
// a type loaded from an archive would fall back to its object id.
|
|
165
170
|
...(structure.meta.key !== undefined ? { key: structure.meta.key } : {}),
|
|
166
171
|
...(structure.meta.version !== undefined ? { version: structure.meta.version } : {}),
|
|
172
|
+
// Preserve annotations (e.g. `AppAnnotation.RootCollectionAnnotation` on a space's
|
|
173
|
+
// properties object) so archives round-trip app-level metadata, not just schema data.
|
|
174
|
+
...(structure.meta.annotations && Object.keys(structure.meta.annotations).length > 0
|
|
175
|
+
? { annotations: structure.meta.annotations }
|
|
176
|
+
: {}),
|
|
167
177
|
};
|
|
168
178
|
}
|
|
169
179
|
if (structure.system?.deleted) {
|
|
@@ -201,7 +211,7 @@ const exportFeedData = async (space: DataSpace, echoHost: EchoHost, objects: Obj
|
|
|
201
211
|
const namespace = (obj as any).namespace === 'trace' ? 'trace' : 'data';
|
|
202
212
|
|
|
203
213
|
try {
|
|
204
|
-
const messages = await
|
|
214
|
+
const messages = await collectFeedMessages(echoHost, spaceId, obj.id, namespace);
|
|
205
215
|
if (messages.length > 0) {
|
|
206
216
|
feeds.push({
|
|
207
217
|
feedObjectId: obj.id,
|
|
@@ -217,44 +227,57 @@ const exportFeedData = async (space: DataSpace, echoHost: EchoHost, objects: Obj
|
|
|
217
227
|
return feeds;
|
|
218
228
|
};
|
|
219
229
|
|
|
220
|
-
const
|
|
230
|
+
const collectFeedMessages = async (
|
|
221
231
|
echoHost: EchoHost,
|
|
222
232
|
spaceId: SpaceId,
|
|
223
|
-
|
|
233
|
+
feedId: EntityId,
|
|
224
234
|
namespace: string,
|
|
225
235
|
): Promise<Obj.JSON[]> => {
|
|
226
|
-
const
|
|
236
|
+
const feedNamespace =
|
|
227
237
|
namespace === 'trace' ? FeedProtocol.WellKnownNamespaces.trace : FeedProtocol.WellKnownNamespaces.data;
|
|
228
238
|
|
|
229
239
|
const messages: Obj.JSON[] = [];
|
|
230
240
|
let cursor: string | undefined;
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
241
|
+
|
|
242
|
+
// Bridge the host feed Handlers to a client to call it in-process (Handlers are served, not
|
|
243
|
+
// called directly). The scope owns the client for the duration of the read.
|
|
244
|
+
const scope = Effect.runSync(Scope.make());
|
|
245
|
+
const feedClient = await EffectEx.runPromise(
|
|
246
|
+
makeInProcessClient(FeedService.Rpcs, echoHost.feedService).pipe(Effect.provideService(Scope.Scope, scope)),
|
|
247
|
+
);
|
|
248
|
+
try {
|
|
249
|
+
while (true) {
|
|
250
|
+
const result = await EffectEx.runPromise(
|
|
251
|
+
feedClient.FeedService.queryFeed({
|
|
252
|
+
query: {
|
|
253
|
+
spaceId,
|
|
254
|
+
feedIds: [feedId],
|
|
255
|
+
feedNamespace,
|
|
256
|
+
after: cursor,
|
|
257
|
+
},
|
|
258
|
+
}),
|
|
259
|
+
);
|
|
260
|
+
const batch = (result.objects ?? []).flatMap((encoded): Obj.JSON[] => {
|
|
261
|
+
try {
|
|
262
|
+
return [JSON.parse(encoded) as Obj.JSON];
|
|
263
|
+
} catch (err) {
|
|
264
|
+
log.verbose('feed object JSON parse failed; object ignored', { encoded, error: err });
|
|
265
|
+
return [];
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
if (batch.length === 0) {
|
|
269
|
+
break;
|
|
246
270
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
if (!result.nextCursor || result.nextCursor === cursor) {
|
|
255
|
-
break;
|
|
271
|
+
for (const message of batch) {
|
|
272
|
+
messages.push(orderObjJsonFields(message));
|
|
273
|
+
}
|
|
274
|
+
if (!result.nextCursor || result.nextCursor === cursor) {
|
|
275
|
+
break;
|
|
276
|
+
}
|
|
277
|
+
cursor = result.nextCursor;
|
|
256
278
|
}
|
|
257
|
-
|
|
279
|
+
} finally {
|
|
280
|
+
await EffectEx.runPromise(Scope.close(scope, Exit.void));
|
|
258
281
|
}
|
|
259
282
|
return messages;
|
|
260
283
|
};
|
|
@@ -438,6 +438,36 @@ describe('SpaceArchive', () => {
|
|
|
438
438
|
expect(Object.keys(ordered)).toEqual(['id', '@type', '@custom', 'data']);
|
|
439
439
|
});
|
|
440
440
|
|
|
441
|
+
test('objectStructureToObjJson preserves meta.annotations', () => {
|
|
442
|
+
const id = EntityId.random();
|
|
443
|
+
const obj = objectStructureToObjJson(id, {
|
|
444
|
+
data: { name: 'Bramble Coffee Roasters' },
|
|
445
|
+
meta: { keys: [], annotations: { 'org.dxos.space.rootCollection': { '/': 'dxn:echo:@:example' } } },
|
|
446
|
+
system: { type: { '/': URI.make('dxn:org.dxos.type.spaceProperties') }, kind: 'object' },
|
|
447
|
+
});
|
|
448
|
+
|
|
449
|
+
expect((obj['@meta'] as any).annotations).toEqual({
|
|
450
|
+
'org.dxos.space.rootCollection': { '/': 'dxn:echo:@:example' },
|
|
451
|
+
});
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
test('buildDatabaseDirectoryFromObjects round-trips meta.annotations', () => {
|
|
455
|
+
const id = EntityId.random();
|
|
456
|
+
const objects = [
|
|
457
|
+
{
|
|
458
|
+
id,
|
|
459
|
+
'@type': 'dxn:org.dxos.type.spaceProperties',
|
|
460
|
+
'@meta': { keys: [], annotations: { 'org.dxos.space.rootCollection': { '/': 'dxn:echo:@:example' } } },
|
|
461
|
+
'name': 'Bramble Coffee Roasters',
|
|
462
|
+
},
|
|
463
|
+
];
|
|
464
|
+
const directory = buildDatabaseDirectoryFromObjects(objects as any);
|
|
465
|
+
const structure = directory.objects![id];
|
|
466
|
+
expect(structure.meta?.annotations).toEqual({
|
|
467
|
+
'org.dxos.space.rootCollection': { '/': 'dxn:echo:@:example' },
|
|
468
|
+
});
|
|
469
|
+
});
|
|
470
|
+
|
|
441
471
|
test('buildDatabaseDirectoryFromObjects flags relations', () => {
|
|
442
472
|
const id = EntityId.random();
|
|
443
473
|
const sourceId = EntityId.random();
|
|
@@ -7,13 +7,13 @@ import { describe, expect, test } from 'vitest';
|
|
|
7
7
|
import { asyncTimeout, latch } from '@dxos/async';
|
|
8
8
|
import { Context } from '@dxos/context';
|
|
9
9
|
import { createAdmissionCredentials } from '@dxos/credentials';
|
|
10
|
-
import { AuthStatus } from '@dxos/echo-host';
|
|
11
10
|
import { writeMessages } from '@dxos/feed-store';
|
|
12
11
|
import { PublicKey } from '@dxos/keys';
|
|
13
12
|
import { log } from '@dxos/log';
|
|
14
13
|
import { SpaceState } from '@dxos/protocols/proto/dxos/client/services';
|
|
15
14
|
import { openAndClose } from '@dxos/test-utils';
|
|
16
15
|
|
|
16
|
+
import { AuthStatus } from '../space';
|
|
17
17
|
import { TestBuilder, type TestPeer } from '../testing';
|
|
18
18
|
|
|
19
19
|
describe('DataSpaceManager', () => {
|