@dxos/echo-db 2.33.5-dev.ea3876ba → 2.33.5-dev.fee8f5fe
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/src/api/index.d.ts +0 -5
- package/dist/src/api/index.d.ts.map +1 -1
- package/dist/src/api/index.js +5 -6
- package/dist/src/api/index.js.map +1 -1
- package/dist/src/api/schema.test.js +1 -1
- package/dist/src/api/schema.test.js.map +1 -1
- package/dist/src/echo.d.ts +1 -0
- package/dist/src/echo.d.ts.map +1 -1
- package/dist/src/echo.js +10 -21
- package/dist/src/echo.js.map +1 -1
- package/dist/src/echo.test.js +12 -4
- package/dist/src/echo.test.js.map +1 -1
- package/dist/src/halo/contact-manager.d.ts +2 -1
- package/dist/src/halo/contact-manager.d.ts.map +1 -1
- package/dist/src/halo/contact-manager.js +1 -1
- package/dist/src/halo/contact-manager.js.map +1 -1
- package/dist/src/halo/halo-factory.d.ts +4 -4
- package/dist/src/halo/halo-factory.d.ts.map +1 -1
- package/dist/src/halo/halo-factory.js +8 -13
- package/dist/src/halo/halo-factory.js.map +1 -1
- package/dist/src/halo/halo-party.d.ts +5 -4
- package/dist/src/halo/halo-party.d.ts.map +1 -1
- package/dist/src/halo/halo-party.js +16 -10
- package/dist/src/halo/halo-party.js.map +1 -1
- package/dist/src/halo/halo.d.ts +2 -2
- package/dist/src/halo/halo.d.ts.map +1 -1
- package/dist/src/halo/halo.test.js +4 -3
- package/dist/src/halo/halo.test.js.map +1 -1
- package/dist/src/halo/identity.js +2 -2
- package/dist/src/halo/identity.js.map +1 -1
- package/dist/src/halo/index.js +5 -1
- package/dist/src/halo/index.js.map +1 -1
- package/dist/src/halo/party-opener.d.ts +1 -1
- package/dist/src/halo/party-opener.d.ts.map +1 -1
- package/dist/src/halo/party-opener.js +5 -3
- package/dist/src/halo/party-opener.js.map +1 -1
- package/dist/src/halo/preferences.d.ts +1 -1
- package/dist/src/halo/preferences.d.ts.map +1 -1
- package/dist/src/halo/preferences.js +8 -11
- package/dist/src/halo/preferences.js.map +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +7 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/invitations/greeting-initiator.d.ts +4 -5
- package/dist/src/invitations/greeting-initiator.d.ts.map +1 -1
- package/dist/src/invitations/greeting-initiator.js +4 -4
- package/dist/src/invitations/greeting-initiator.js.map +1 -1
- package/dist/src/invitations/greeting-protocol-provider.d.ts.map +1 -1
- package/dist/src/invitations/greeting-protocol-provider.js +5 -9
- package/dist/src/invitations/greeting-protocol-provider.js.map +1 -1
- package/dist/src/invitations/greeting-responder.d.ts +6 -4
- package/dist/src/invitations/greeting-responder.d.ts.map +1 -1
- package/dist/src/invitations/greeting-responder.js +11 -14
- package/dist/src/invitations/greeting-responder.js.map +1 -1
- package/dist/src/invitations/halo-recovery-initiator.d.ts +1 -1
- package/dist/src/invitations/halo-recovery-initiator.d.ts.map +1 -1
- package/dist/src/invitations/halo-recovery-initiator.js +2 -2
- package/dist/src/invitations/halo-recovery-initiator.js.map +1 -1
- package/dist/src/invitations/index.js +5 -1
- package/dist/src/invitations/index.js.map +1 -1
- package/dist/src/invitations/invitation-descriptor.js +6 -2
- package/dist/src/invitations/invitation-descriptor.js.map +1 -1
- package/dist/src/invitations/invitation-factory.d.ts +5 -2
- package/dist/src/invitations/invitation-factory.d.ts.map +1 -1
- package/dist/src/invitations/invitation-factory.js +4 -3
- package/dist/src/invitations/invitation-factory.js.map +1 -1
- package/dist/src/invitations/offline-invitation-claimer.d.ts.map +1 -1
- package/dist/src/invitations/offline-invitation-claimer.js +7 -9
- package/dist/src/invitations/offline-invitation-claimer.js.map +1 -1
- package/dist/src/{database → packlets/database}/data-mirror.d.ts +0 -0
- package/dist/src/packlets/database/data-mirror.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/data-mirror.js +0 -0
- package/dist/src/packlets/database/data-mirror.js.map +1 -0
- package/dist/src/{database → packlets/database}/data-mirror.test.d.ts +0 -0
- package/dist/src/packlets/database/data-mirror.test.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/data-mirror.test.js +2 -2
- package/dist/src/packlets/database/data-mirror.test.js.map +1 -0
- package/dist/src/{database → packlets/database}/data-service-host.d.ts +0 -0
- package/dist/src/packlets/database/data-service-host.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/data-service-host.js +4 -3
- package/dist/src/packlets/database/data-service-host.js.map +1 -0
- package/dist/src/{database → packlets/database}/data-service-router.d.ts +0 -0
- package/dist/src/packlets/database/data-service-router.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/data-service-router.js +0 -0
- package/dist/src/packlets/database/data-service-router.js.map +1 -0
- package/dist/src/{database → packlets/database}/database-backend.d.ts +4 -5
- package/dist/src/packlets/database/database-backend.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/database-backend.js +5 -6
- package/dist/src/packlets/database/database-backend.js.map +1 -0
- package/dist/src/{api → packlets/database}/database.d.ts +2 -1
- package/dist/src/packlets/database/database.d.ts.map +1 -0
- package/dist/src/{api → packlets/database}/database.js +2 -2
- package/dist/src/packlets/database/database.js.map +1 -0
- package/dist/src/{api → packlets/database}/database.test.d.ts +0 -0
- package/dist/src/packlets/database/database.test.d.ts.map +1 -0
- package/dist/src/{api → packlets/database}/database.test.js +3 -3
- package/dist/src/packlets/database/database.test.js.map +1 -0
- package/dist/src/{api → packlets/database}/entity.d.ts +1 -1
- package/dist/src/packlets/database/entity.d.ts.map +1 -0
- package/dist/src/{api → packlets/database}/entity.js +0 -0
- package/dist/src/packlets/database/entity.js.map +1 -0
- package/dist/src/{database → packlets/database}/index.d.ts +5 -0
- package/dist/src/packlets/database/index.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/index.js +10 -1
- package/dist/src/packlets/database/index.js.map +1 -0
- package/dist/src/{database → packlets/database}/item-demuxer.d.ts +5 -4
- package/dist/src/packlets/database/item-demuxer.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/item-demuxer.js +5 -8
- package/dist/src/packlets/database/item-demuxer.js.map +1 -0
- package/dist/src/{database → packlets/database}/item-demuxer.test.d.ts +0 -0
- package/dist/src/packlets/database/item-demuxer.test.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/item-demuxer.test.js +15 -11
- package/dist/src/packlets/database/item-demuxer.test.js.map +1 -0
- package/dist/src/{database → packlets/database}/item-manager.d.ts +3 -1
- package/dist/src/packlets/database/item-manager.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/item-manager.js +13 -12
- package/dist/src/packlets/database/item-manager.js.map +1 -0
- package/dist/src/{database → packlets/database}/item-manager.test.d.ts +0 -0
- package/dist/src/packlets/database/item-manager.test.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/item-manager.test.js +0 -0
- package/dist/src/packlets/database/item-manager.test.js.map +1 -0
- package/dist/src/{api → packlets/database}/item.d.ts +1 -1
- package/dist/src/packlets/database/item.d.ts.map +1 -0
- package/dist/src/{api → packlets/database}/item.js +0 -0
- package/dist/src/packlets/database/item.js.map +1 -0
- package/dist/src/{api → packlets/database}/link.d.ts +1 -1
- package/dist/src/packlets/database/link.d.ts.map +1 -0
- package/dist/src/{api → packlets/database}/link.js +0 -0
- package/dist/src/packlets/database/link.js.map +1 -0
- package/dist/src/{api → packlets/database}/selection/index.d.ts +0 -0
- package/dist/src/packlets/database/selection/index.d.ts.map +1 -0
- package/dist/src/{api → packlets/database}/selection/index.js +5 -1
- package/dist/src/packlets/database/selection/index.js.map +1 -0
- package/dist/src/{api → packlets/database}/selection/queries.d.ts +0 -0
- package/dist/src/packlets/database/selection/queries.d.ts.map +1 -0
- package/dist/src/{api → packlets/database}/selection/queries.js +13 -17
- package/dist/src/packlets/database/selection/queries.js.map +1 -0
- package/dist/src/{api → packlets/database}/selection/result.d.ts +0 -0
- package/dist/src/packlets/database/selection/result.d.ts.map +1 -0
- package/dist/src/{api → packlets/database}/selection/result.js +0 -0
- package/dist/src/packlets/database/selection/result.js.map +1 -0
- package/dist/src/{api → packlets/database}/selection/selection.d.ts +0 -0
- package/dist/src/packlets/database/selection/selection.d.ts.map +1 -0
- package/dist/src/{api → packlets/database}/selection/selection.js +1 -3
- package/dist/src/packlets/database/selection/selection.js.map +1 -0
- package/dist/src/{api → packlets/database}/selection/selection.test.d.ts +0 -0
- package/dist/src/packlets/database/selection/selection.test.d.ts.map +1 -0
- package/dist/src/{api → packlets/database}/selection/selection.test.js +4 -12
- package/dist/src/packlets/database/selection/selection.test.js.map +1 -0
- package/dist/src/{api → packlets/database}/selection/util.d.ts +0 -0
- package/dist/src/packlets/database/selection/util.d.ts.map +1 -0
- package/dist/src/{api → packlets/database}/selection/util.js +0 -0
- package/dist/src/packlets/database/selection/util.js.map +1 -0
- package/dist/src/{database → packlets/database}/testing.d.ts +1 -1
- package/dist/src/packlets/database/testing.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/testing.js +5 -6
- package/dist/src/packlets/database/testing.js.map +1 -0
- package/dist/src/{database → packlets/database}/timeframe-clock.d.ts +1 -0
- package/dist/src/packlets/database/timeframe-clock.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/timeframe-clock.js +3 -0
- package/dist/src/packlets/database/timeframe-clock.js.map +1 -0
- package/dist/src/{errors.d.ts → packlets/errors/index.d.ts} +1 -1
- package/dist/src/packlets/errors/index.d.ts.map +1 -0
- package/dist/src/{errors.js → packlets/errors/index.js} +1 -1
- package/dist/src/packlets/errors/index.js.map +1 -0
- package/dist/src/parties/data-party.d.ts +14 -10
- package/dist/src/parties/data-party.d.ts.map +1 -1
- package/dist/src/parties/data-party.js +39 -15
- package/dist/src/parties/data-party.js.map +1 -1
- package/dist/src/parties/data-party.test.js +42 -22
- package/dist/src/parties/data-party.test.js.map +1 -1
- package/dist/src/parties/index.js +5 -1
- package/dist/src/parties/index.js.map +1 -1
- package/dist/src/parties/party-factory.d.ts +5 -10
- package/dist/src/parties/party-factory.d.ts.map +1 -1
- package/dist/src/parties/party-factory.js +30 -54
- package/dist/src/parties/party-factory.js.map +1 -1
- package/dist/src/parties/party-manager.d.ts +3 -4
- package/dist/src/parties/party-manager.d.ts.map +1 -1
- package/dist/src/parties/party-manager.js +9 -7
- package/dist/src/parties/party-manager.js.map +1 -1
- package/dist/src/parties/party-manager.test.js +16 -15
- package/dist/src/parties/party-manager.test.js.map +1 -1
- package/dist/src/pipeline/{pipeline.d.ts → feed-muxer.d.ts} +10 -15
- package/dist/src/pipeline/feed-muxer.d.ts.map +1 -0
- package/dist/src/pipeline/{pipeline.js → feed-muxer.js} +34 -44
- package/dist/src/pipeline/feed-muxer.js.map +1 -0
- package/dist/src/pipeline/feed-muxer.test.d.ts +2 -0
- package/dist/src/pipeline/feed-muxer.test.d.ts.map +1 -0
- package/dist/src/pipeline/{pipeline.test.js → feed-muxer.test.js} +20 -18
- package/dist/src/pipeline/feed-muxer.test.js.map +1 -0
- package/dist/src/pipeline/index.d.ts +2 -2
- package/dist/src/pipeline/index.d.ts.map +1 -1
- package/dist/src/pipeline/index.js +7 -3
- package/dist/src/pipeline/index.js.map +1 -1
- package/dist/src/pipeline/message-selector.d.ts +3 -3
- package/dist/src/pipeline/message-selector.d.ts.map +1 -1
- package/dist/src/pipeline/message-selector.js +30 -29
- package/dist/src/pipeline/message-selector.js.map +1 -1
- package/dist/src/pipeline/metadata-store.d.ts +5 -4
- package/dist/src/pipeline/metadata-store.d.ts.map +1 -1
- package/dist/src/pipeline/metadata-store.js +11 -5
- package/dist/src/pipeline/metadata-store.js.map +1 -1
- package/dist/src/pipeline/metadata-store.test.js +8 -4
- package/dist/src/pipeline/metadata-store.test.js.map +1 -1
- package/dist/src/pipeline/party-feed-provider.d.ts +2 -3
- package/dist/src/pipeline/party-feed-provider.d.ts.map +1 -1
- package/dist/src/pipeline/party-feed-provider.js +2 -17
- package/dist/src/pipeline/party-feed-provider.js.map +1 -1
- package/dist/src/pipeline/{party-core.d.ts → party-pipeline.d.ts} +26 -11
- package/dist/src/pipeline/party-pipeline.d.ts.map +1 -0
- package/dist/src/pipeline/{party-core.js → party-pipeline.js} +32 -31
- package/dist/src/pipeline/party-pipeline.js.map +1 -0
- package/dist/src/pipeline/party-pipeline.test.d.ts +2 -0
- package/dist/src/pipeline/party-pipeline.test.d.ts.map +1 -0
- package/dist/src/pipeline/{party-core.test.js → party-pipeline.test.js} +64 -46
- package/dist/src/pipeline/party-pipeline.test.js.map +1 -0
- package/dist/src/pipeline/party-processor.d.ts +21 -9
- package/dist/src/pipeline/party-processor.d.ts.map +1 -1
- package/dist/src/pipeline/party-processor.js +0 -8
- package/dist/src/pipeline/party-processor.js.map +1 -1
- package/dist/src/protocol/auth-plugin.d.ts +1 -1
- package/dist/src/protocol/auth-plugin.d.ts.map +1 -1
- package/dist/src/protocol/auth-plugin.js +1 -3
- package/dist/src/protocol/auth-plugin.js.map +1 -1
- package/dist/src/protocol/authenticator.d.ts +4 -4
- package/dist/src/protocol/authenticator.d.ts.map +1 -1
- package/dist/src/protocol/authenticator.js +12 -16
- package/dist/src/protocol/authenticator.js.map +1 -1
- package/dist/src/protocol/authenticator.test.js +1 -4
- package/dist/src/protocol/authenticator.test.js.map +1 -1
- package/dist/src/protocol/halo-recovery-plugin.d.ts +1 -1
- package/dist/src/protocol/halo-recovery-plugin.d.ts.map +1 -1
- package/dist/src/protocol/halo-recovery-plugin.js +1 -3
- package/dist/src/protocol/halo-recovery-plugin.js.map +1 -1
- package/dist/src/protocol/identity-credentials.d.ts +2 -2
- package/dist/src/protocol/identity-credentials.d.ts.map +1 -1
- package/dist/src/protocol/identity-credentials.js +4 -4
- package/dist/src/protocol/identity-credentials.js.map +1 -1
- package/dist/src/protocol/index.js +5 -1
- package/dist/src/protocol/index.js.map +1 -1
- package/dist/src/protocol/offline-invitation-plugin.d.ts +1 -1
- package/dist/src/protocol/offline-invitation-plugin.d.ts.map +1 -1
- package/dist/src/protocol/offline-invitation-plugin.js +1 -3
- package/dist/src/protocol/offline-invitation-plugin.js.map +1 -1
- package/dist/src/protocol/party-protocol-factory.d.ts +1 -14
- package/dist/src/protocol/party-protocol-factory.d.ts.map +1 -1
- package/dist/src/protocol/party-protocol-factory.js +2 -55
- package/dist/src/protocol/party-protocol-factory.js.map +1 -1
- package/dist/src/protocol/replicator-plugin.d.ts +7 -0
- package/dist/src/protocol/replicator-plugin.d.ts.map +1 -0
- package/dist/src/protocol/replicator-plugin.js +36 -0
- package/dist/src/protocol/replicator-plugin.js.map +1 -0
- package/dist/src/snapshots/index.js +5 -1
- package/dist/src/snapshots/index.js.map +1 -1
- package/dist/src/snapshots/snapshot-generator.d.ts +3 -3
- package/dist/src/snapshots/snapshot-generator.d.ts.map +1 -1
- package/dist/src/snapshots/snapshot-generator.js +13 -15
- package/dist/src/snapshots/snapshot-generator.js.map +1 -1
- package/dist/src/snapshots/snapshot-store.d.ts +3 -3
- package/dist/src/snapshots/snapshot-store.d.ts.map +1 -1
- package/dist/src/snapshots/snapshot-store.js +5 -5
- package/dist/src/snapshots/snapshot-store.js.map +1 -1
- package/dist/src/snapshots/snapshot-store.test.js +1 -1
- package/dist/src/snapshots/snapshot-store.test.js.map +1 -1
- package/dist/src/snapshots/snapshot.test.js +1 -1
- package/dist/src/snapshots/snapshot.test.js.map +1 -1
- package/dist/src/testing/benchmark.test.d.ts +2 -0
- package/dist/src/testing/benchmark.test.d.ts.map +1 -0
- package/dist/src/testing/benchmark.test.js +25 -0
- package/dist/src/testing/benchmark.test.js.map +1 -0
- package/dist/src/testing/index.js +5 -1
- package/dist/src/testing/index.js.map +1 -1
- package/dist/src/testing/testing-factories.d.ts +1 -1
- package/dist/src/testing/testing-factories.d.ts.map +1 -1
- package/dist/src/testing/testing-factories.js +2 -2
- package/dist/src/testing/testing-factories.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +19 -19
- package/src/api/index.ts +0 -5
- package/src/api/schema.test.ts +1 -2
- package/src/echo.test.ts +16 -5
- package/src/echo.ts +11 -20
- package/src/halo/contact-manager.ts +3 -2
- package/src/halo/halo-factory.ts +11 -23
- package/src/halo/halo-party.ts +22 -14
- package/src/halo/halo.test.ts +4 -3
- package/src/halo/halo.ts +2 -2
- package/src/halo/identity.ts +2 -2
- package/src/halo/party-opener.ts +5 -3
- package/src/halo/preferences.ts +10 -12
- package/src/index.ts +3 -2
- package/src/invitations/greeting-initiator.ts +10 -9
- package/src/invitations/greeting-protocol-provider.ts +5 -9
- package/src/invitations/greeting-responder.ts +15 -17
- package/src/invitations/halo-recovery-initiator.ts +4 -4
- package/src/invitations/invitation-descriptor.ts +1 -1
- package/src/invitations/invitation-factory.ts +8 -5
- package/src/invitations/offline-invitation-claimer.ts +8 -10
- package/src/{database → packlets/database}/data-mirror.test.ts +3 -3
- package/src/{database → packlets/database}/data-mirror.ts +1 -1
- package/src/{database → packlets/database}/data-service-host.ts +2 -1
- package/src/{database → packlets/database}/data-service-router.ts +0 -0
- package/src/{database → packlets/database}/database-backend.ts +7 -6
- package/src/{api → packlets/database}/database.test.ts +2 -1
- package/src/{api → packlets/database}/database.ts +3 -1
- package/src/{api → packlets/database}/entity.ts +1 -1
- package/src/{database → packlets/database}/index.ts +5 -0
- package/src/{database → packlets/database}/item-demuxer.test.ts +21 -19
- package/src/{database → packlets/database}/item-demuxer.ts +10 -9
- package/src/{database → packlets/database}/item-manager.test.ts +0 -0
- package/src/{database → packlets/database}/item-manager.ts +5 -3
- package/src/{api → packlets/database}/item.ts +2 -2
- package/src/{api → packlets/database}/link.ts +1 -1
- package/src/{api → packlets/database}/selection/index.ts +0 -0
- package/src/{api → packlets/database}/selection/queries.ts +14 -18
- package/src/{api → packlets/database}/selection/result.ts +0 -0
- package/src/{api → packlets/database}/selection/selection.test.ts +4 -12
- package/src/{api → packlets/database}/selection/selection.ts +1 -7
- package/src/{api → packlets/database}/selection/util.ts +0 -0
- package/src/{database → packlets/database}/testing.ts +4 -7
- package/src/{database → packlets/database}/timeframe-clock.ts +4 -0
- package/src/{errors.ts → packlets/errors/index.ts} +0 -0
- package/src/parties/data-party.test.ts +58 -25
- package/src/parties/data-party.ts +48 -20
- package/src/parties/party-factory.ts +40 -84
- package/src/parties/party-manager.test.ts +24 -15
- package/src/parties/party-manager.ts +10 -6
- package/src/pipeline/{pipeline.test.ts → feed-muxer.test.ts} +23 -19
- package/src/pipeline/{pipeline.ts → feed-muxer.ts} +39 -55
- package/src/pipeline/index.ts +2 -2
- package/src/pipeline/message-selector.ts +32 -35
- package/src/pipeline/metadata-store.test.ts +8 -4
- package/src/pipeline/metadata-store.ts +12 -6
- package/src/pipeline/party-feed-provider.ts +3 -16
- package/src/pipeline/{party-core.test.ts → party-pipeline.test.ts} +67 -48
- package/src/pipeline/{party-core.ts → party-pipeline.ts} +59 -31
- package/src/pipeline/party-processor.ts +23 -15
- package/src/protocol/auth-plugin.ts +1 -3
- package/src/protocol/authenticator.test.ts +1 -4
- package/src/protocol/authenticator.ts +33 -33
- package/src/protocol/halo-recovery-plugin.ts +4 -6
- package/src/protocol/identity-credentials.ts +4 -4
- package/src/protocol/offline-invitation-plugin.ts +4 -6
- package/src/protocol/party-protocol-factory.ts +3 -56
- package/src/protocol/replicator-plugin.ts +37 -0
- package/src/snapshots/snapshot-generator.ts +14 -18
- package/src/snapshots/snapshot-store.test.ts +1 -1
- package/src/snapshots/snapshot-store.ts +5 -6
- package/src/snapshots/snapshot.test.ts +1 -1
- package/src/testing/benchmark.test.ts +30 -0
- package/src/testing/testing-factories.ts +3 -3
- package/dist/src/api/database.d.ts.map +0 -1
- package/dist/src/api/database.js.map +0 -1
- package/dist/src/api/database.test.d.ts.map +0 -1
- package/dist/src/api/database.test.js.map +0 -1
- package/dist/src/api/entity.d.ts.map +0 -1
- package/dist/src/api/entity.js.map +0 -1
- package/dist/src/api/item.d.ts.map +0 -1
- package/dist/src/api/item.js.map +0 -1
- package/dist/src/api/link.d.ts.map +0 -1
- package/dist/src/api/link.js.map +0 -1
- package/dist/src/api/selection/index.d.ts.map +0 -1
- package/dist/src/api/selection/index.js.map +0 -1
- package/dist/src/api/selection/queries.d.ts.map +0 -1
- package/dist/src/api/selection/queries.js.map +0 -1
- package/dist/src/api/selection/result.d.ts.map +0 -1
- package/dist/src/api/selection/result.js.map +0 -1
- package/dist/src/api/selection/selection.d.ts.map +0 -1
- package/dist/src/api/selection/selection.js.map +0 -1
- package/dist/src/api/selection/selection.test.d.ts.map +0 -1
- package/dist/src/api/selection/selection.test.js.map +0 -1
- package/dist/src/api/selection/util.d.ts.map +0 -1
- package/dist/src/api/selection/util.js.map +0 -1
- package/dist/src/database/data-mirror.d.ts.map +0 -1
- package/dist/src/database/data-mirror.js.map +0 -1
- package/dist/src/database/data-mirror.test.d.ts.map +0 -1
- package/dist/src/database/data-mirror.test.js.map +0 -1
- package/dist/src/database/data-service-host.d.ts.map +0 -1
- package/dist/src/database/data-service-host.js.map +0 -1
- package/dist/src/database/data-service-router.d.ts.map +0 -1
- package/dist/src/database/data-service-router.js.map +0 -1
- package/dist/src/database/database-backend.d.ts.map +0 -1
- package/dist/src/database/database-backend.js.map +0 -1
- package/dist/src/database/index.d.ts.map +0 -1
- package/dist/src/database/index.js.map +0 -1
- package/dist/src/database/item-demuxer.d.ts.map +0 -1
- package/dist/src/database/item-demuxer.js.map +0 -1
- package/dist/src/database/item-demuxer.test.d.ts.map +0 -1
- package/dist/src/database/item-demuxer.test.js.map +0 -1
- package/dist/src/database/item-manager.d.ts.map +0 -1
- package/dist/src/database/item-manager.js.map +0 -1
- package/dist/src/database/item-manager.test.d.ts.map +0 -1
- package/dist/src/database/item-manager.test.js.map +0 -1
- package/dist/src/database/testing.d.ts.map +0 -1
- package/dist/src/database/testing.js.map +0 -1
- package/dist/src/database/timeframe-clock.d.ts.map +0 -1
- package/dist/src/database/timeframe-clock.js.map +0 -1
- package/dist/src/errors.d.ts.map +0 -1
- package/dist/src/errors.js.map +0 -1
- package/dist/src/pipeline/party-core.d.ts.map +0 -1
- package/dist/src/pipeline/party-core.js.map +0 -1
- package/dist/src/pipeline/party-core.test.d.ts +0 -2
- package/dist/src/pipeline/party-core.test.d.ts.map +0 -1
- package/dist/src/pipeline/party-core.test.js.map +0 -1
- package/dist/src/pipeline/pipeline.d.ts.map +0 -1
- package/dist/src/pipeline/pipeline.js.map +0 -1
- package/dist/src/pipeline/pipeline.test.d.ts +0 -2
- package/dist/src/pipeline/pipeline.test.d.ts.map +0 -1
- package/dist/src/pipeline/pipeline.test.js.map +0 -1
|
@@ -32,8 +32,8 @@ import { ObjectModel } from '@dxos/object-model';
|
|
|
32
32
|
import { createStorage, StorageType } from '@dxos/random-access-multi-storage';
|
|
33
33
|
import { afterTest, testTimeout } from '@dxos/testutils';
|
|
34
34
|
|
|
35
|
-
import { Item } from '../api';
|
|
36
35
|
import { defaultInvitationAuthenticator, OfflineInvitationClaimer } from '../invitations';
|
|
36
|
+
import { Item } from '../packlets/database';
|
|
37
37
|
import { MetadataStore, PartyFeedProvider } from '../pipeline';
|
|
38
38
|
import { createTestIdentityCredentials } from '../protocol/identity-credentials';
|
|
39
39
|
import { SnapshotStore } from '../snapshots';
|
|
@@ -55,9 +55,11 @@ const log = debug('dxos:echo:parties:party-manager:test');
|
|
|
55
55
|
*/
|
|
56
56
|
const setup = async () => {
|
|
57
57
|
const keyring = new Keyring();
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
const snapshotStore = new SnapshotStore(
|
|
58
|
+
|
|
59
|
+
const storage = createStorage('', StorageType.RAM);
|
|
60
|
+
const snapshotStore = new SnapshotStore(storage.directory('snapshots'));
|
|
61
|
+
const metadataStore = new MetadataStore(storage.directory('metadata'));
|
|
62
|
+
const feedStore = new FeedStore(storage.directory('feed'), { valueEncoding: codec });
|
|
61
63
|
const modelFactory = new ModelFactory().registerModel(ObjectModel);
|
|
62
64
|
const networkManager = new NetworkManager();
|
|
63
65
|
const feedProviderFactory = (partyKey: PublicKey) => new PartyFeedProvider(metadataStore, keyring, feedStore, partyKey);
|
|
@@ -69,6 +71,7 @@ const setup = async () => {
|
|
|
69
71
|
modelFactory,
|
|
70
72
|
snapshotStore,
|
|
71
73
|
feedProviderFactory,
|
|
74
|
+
metadataStore,
|
|
72
75
|
{
|
|
73
76
|
writeLogger: messageLogger('<<<'),
|
|
74
77
|
readLogger: messageLogger('>>>')
|
|
@@ -138,21 +141,18 @@ describe('Party manager', () => {
|
|
|
138
141
|
const feedStream = createWritableFeedStream(feed);
|
|
139
142
|
feedStream.write(createPartyGenesisMessage(keyring, partyKey, feedKey.publicKey, identityKey));
|
|
140
143
|
|
|
141
|
-
await partyManager.addParty(partyKey.publicKey, [
|
|
142
|
-
type: KeyType.FEED,
|
|
143
|
-
publicKey: PublicKey.from(feed.key)
|
|
144
|
-
}]);
|
|
144
|
+
await partyManager.addParty(partyKey.publicKey, [PublicKey.from(feed.key)]);
|
|
145
145
|
|
|
146
146
|
await update;
|
|
147
147
|
});
|
|
148
148
|
|
|
149
149
|
test('Create from cold start', async () => {
|
|
150
150
|
const storage = createStorage('', StorageType.RAM);
|
|
151
|
-
const feedStore = new FeedStore(storage, { valueEncoding: codec });
|
|
151
|
+
const feedStore = new FeedStore(storage.directory('feed'), { valueEncoding: codec });
|
|
152
152
|
const keyring = new Keyring();
|
|
153
|
-
const
|
|
153
|
+
const snapshotStore = new SnapshotStore(storage.directory('snapshots'));
|
|
154
|
+
const metadataStore = new MetadataStore(storage.directory('metadata'));
|
|
154
155
|
const modelFactory = new ModelFactory().registerModel(ObjectModel);
|
|
155
|
-
const snapshotStore = new SnapshotStore(createStorage('snapshots', StorageType.RAM));
|
|
156
156
|
const networkManager = new NetworkManager();
|
|
157
157
|
const feedProviderFactory = (partyKey: PublicKey) => new PartyFeedProvider(metadataStore, keyring, feedStore, partyKey);
|
|
158
158
|
|
|
@@ -162,7 +162,8 @@ describe('Party manager', () => {
|
|
|
162
162
|
networkManager,
|
|
163
163
|
modelFactory,
|
|
164
164
|
snapshotStore,
|
|
165
|
-
feedProviderFactory
|
|
165
|
+
feedProviderFactory,
|
|
166
|
+
metadataStore
|
|
166
167
|
);
|
|
167
168
|
const partyManager = new PartyManager(metadataStore, snapshotStore, () => identity, partyFactory);
|
|
168
169
|
|
|
@@ -188,15 +189,23 @@ describe('Party manager', () => {
|
|
|
188
189
|
assert(feedKey);
|
|
189
190
|
|
|
190
191
|
const feedStream = createWritableFeedStream(feed);
|
|
191
|
-
feedStream.write({ halo: createPartyGenesisMessage(keyring, partyKey, feedKey.publicKey, identity.identityKey) });
|
|
192
192
|
feedStream.write({
|
|
193
|
+
timeframe: new Timeframe(),
|
|
194
|
+
halo: createPartyGenesisMessage(
|
|
195
|
+
keyring,
|
|
196
|
+
partyKey,
|
|
197
|
+
feedKey.publicKey,
|
|
198
|
+
identity.identityKey
|
|
199
|
+
)
|
|
200
|
+
});
|
|
201
|
+
feedStream.write({
|
|
202
|
+
timeframe: new Timeframe(),
|
|
193
203
|
echo: checkType<EchoEnvelope>({
|
|
194
204
|
itemId: 'foo',
|
|
195
205
|
genesis: {
|
|
196
206
|
itemType: PARTY_ITEM_TYPE,
|
|
197
207
|
modelType: ObjectModel.meta.type
|
|
198
|
-
}
|
|
199
|
-
timeframe: new Timeframe()
|
|
208
|
+
}
|
|
200
209
|
})
|
|
201
210
|
});
|
|
202
211
|
}
|
|
@@ -9,7 +9,7 @@ import unionWith from 'lodash.unionwith';
|
|
|
9
9
|
import { Event, synchronized } from '@dxos/async';
|
|
10
10
|
import { KeyHint, KeyType, SecretProvider } from '@dxos/credentials';
|
|
11
11
|
import { PublicKey } from '@dxos/crypto';
|
|
12
|
-
import { timed } from '@dxos/debug';
|
|
12
|
+
import { failUndefined, timed } from '@dxos/debug';
|
|
13
13
|
import { PartyKey, PartySnapshot } from '@dxos/echo-protocol';
|
|
14
14
|
import { ComplexMap, boolGuard } from '@dxos/util';
|
|
15
15
|
|
|
@@ -94,9 +94,13 @@ export class PartyManager {
|
|
|
94
94
|
const partyKey = partyKeys[i];
|
|
95
95
|
if (!this._parties.has(partyKey)) {
|
|
96
96
|
const snapshot = await this._snapshotStore.load(partyKey);
|
|
97
|
+
|
|
98
|
+
const metadata = this._metadataStore.getParty(partyKey) ?? failUndefined();
|
|
99
|
+
|
|
97
100
|
const party = snapshot
|
|
98
101
|
? await this._partyFactory.constructPartyFromSnapshot(snapshot)
|
|
99
102
|
: await this._partyFactory.constructParty(partyKey);
|
|
103
|
+
party._setFeedHints(metadata.feedKeys ?? []);
|
|
100
104
|
|
|
101
105
|
const isActive = identity?.preferences?.isPartyActive(partyKey) ?? true;
|
|
102
106
|
if (isActive) {
|
|
@@ -157,11 +161,9 @@ export class PartyManager {
|
|
|
157
161
|
|
|
158
162
|
/**
|
|
159
163
|
* Construct a party object and start replicating with the remote peer that created that party.
|
|
160
|
-
* @param partyKey
|
|
161
|
-
* @param hints
|
|
162
164
|
*/
|
|
163
165
|
@synchronized
|
|
164
|
-
async addParty (partyKey: PartyKey,
|
|
166
|
+
async addParty (partyKey: PartyKey, feedHints: PublicKey[] = []) {
|
|
165
167
|
assert(this._open, 'PartyManager is not open.');
|
|
166
168
|
|
|
167
169
|
/*
|
|
@@ -174,8 +176,10 @@ export class PartyManager {
|
|
|
174
176
|
return this._parties.get(partyKey);
|
|
175
177
|
}
|
|
176
178
|
|
|
177
|
-
log(`Adding party partyKey=${partyKey.toHex()} hints=${
|
|
178
|
-
const party = await this._partyFactory.
|
|
179
|
+
log(`Adding party partyKey=${partyKey.toHex()} hints=${feedHints.length}`);
|
|
180
|
+
const party = await this._partyFactory.constructParty(partyKey);
|
|
181
|
+
party._setFeedHints(feedHints);
|
|
182
|
+
await party.open();
|
|
179
183
|
await this._metadataStore.addParty(party.key);
|
|
180
184
|
this._setParty(party);
|
|
181
185
|
return party;
|
|
@@ -10,22 +10,22 @@ import { waitForCondition, latch } from '@dxos/async';
|
|
|
10
10
|
import { createPartyGenesisMessage, Keyring, KeyType } from '@dxos/credentials';
|
|
11
11
|
import { createId, createKeyPair, PublicKey } from '@dxos/crypto';
|
|
12
12
|
import { codec, createFeedWriter, FeedSelector, FeedStoreIterator, IEchoStream, Timeframe } from '@dxos/echo-protocol';
|
|
13
|
-
import { FeedStore, createWritableFeedStream
|
|
13
|
+
import { FeedStore, createWritableFeedStream } from '@dxos/feed-store';
|
|
14
14
|
import { createSetPropertyMutation } from '@dxos/model-factory';
|
|
15
15
|
import { createStorage, StorageType } from '@dxos/random-access-multi-storage';
|
|
16
16
|
import { jsonReplacer } from '@dxos/util';
|
|
17
17
|
|
|
18
|
-
import { TimeframeClock } from '../database';
|
|
18
|
+
import { TimeframeClock } from '../packlets/database';
|
|
19
|
+
import { FeedMuxer } from './feed-muxer';
|
|
19
20
|
import { PartyProcessor } from './party-processor';
|
|
20
|
-
import { Pipeline } from './pipeline';
|
|
21
21
|
|
|
22
22
|
const log = debug('dxos:echo:pipeline:test');
|
|
23
23
|
|
|
24
24
|
// TODO(burdon): Test read-only.
|
|
25
|
-
describe('
|
|
25
|
+
describe('FeedMuxer', () => {
|
|
26
26
|
test('streams', async () => {
|
|
27
27
|
const storage = createStorage('', StorageType.RAM);
|
|
28
|
-
const feedStore = new FeedStore(storage, { valueEncoding: codec });
|
|
28
|
+
const feedStore = new FeedStore(storage.directory('feed'), { valueEncoding: codec });
|
|
29
29
|
const feedKeys: Uint8Array[] = [];
|
|
30
30
|
const feedSelector: FeedSelector = descriptor => !!feedKeys.find(key => descriptor.key.equals(key));
|
|
31
31
|
const feedReadStream = new FeedStoreIterator(feedSelector, () => 0, new Timeframe());
|
|
@@ -56,9 +56,6 @@ describe('pipeline', () => {
|
|
|
56
56
|
seq: 0
|
|
57
57
|
}
|
|
58
58
|
});
|
|
59
|
-
const pipeline = new Pipeline(partyProcessor, feedReadStream, new TimeframeClock());
|
|
60
|
-
const [readStream] = await pipeline.open();
|
|
61
|
-
expect(readStream).toBeTruthy();
|
|
62
59
|
|
|
63
60
|
//
|
|
64
61
|
// Pipeline consumer.
|
|
@@ -66,10 +63,14 @@ describe('pipeline', () => {
|
|
|
66
63
|
//
|
|
67
64
|
const numMessages = 5;
|
|
68
65
|
const [counter, updateCounter] = latch(numMessages);
|
|
69
|
-
|
|
66
|
+
const echoProcessor = async (message: IEchoStream) => {
|
|
70
67
|
log('Processed:', JSON.stringify(message, jsonReplacer, 2));
|
|
71
68
|
updateCounter();
|
|
72
|
-
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const pipeline = new FeedMuxer(partyProcessor, feedReadStream, new TimeframeClock());
|
|
72
|
+
pipeline.setEchoProcessor(echoProcessor);
|
|
73
|
+
await pipeline.open();
|
|
73
74
|
|
|
74
75
|
//
|
|
75
76
|
// Write directly to feed store.
|
|
@@ -87,7 +88,7 @@ describe('pipeline', () => {
|
|
|
87
88
|
|
|
88
89
|
test('writing', async () => {
|
|
89
90
|
const storage = createStorage('', StorageType.RAM);
|
|
90
|
-
const feedStore = new FeedStore(storage, { valueEncoding: codec });
|
|
91
|
+
const feedStore = new FeedStore(storage.directory('feed'), { valueEncoding: codec });
|
|
91
92
|
const feedReadStream = new FeedStoreIterator(() => true, () => 0, new Timeframe());
|
|
92
93
|
|
|
93
94
|
const { publicKey, secretKey } = createKeyPair();
|
|
@@ -105,17 +106,21 @@ describe('pipeline', () => {
|
|
|
105
106
|
});
|
|
106
107
|
|
|
107
108
|
const partyProcessor = new PartyProcessor(partyKey.publicKey);
|
|
108
|
-
|
|
109
|
+
|
|
110
|
+
const echoMessages: IEchoStream[] = [];
|
|
111
|
+
const echoProcessor = async (msg: IEchoStream) => {
|
|
112
|
+
echoMessages.push(msg);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const pipeline = new FeedMuxer(
|
|
109
116
|
partyProcessor,
|
|
110
117
|
feedReadStream,
|
|
111
118
|
new TimeframeClock(),
|
|
112
119
|
createFeedWriter(feed)
|
|
113
120
|
);
|
|
121
|
+
pipeline.setEchoProcessor(echoProcessor);
|
|
114
122
|
await pipeline.open();
|
|
115
123
|
|
|
116
|
-
const writable = new WritableArray();
|
|
117
|
-
pipeline.inboundEchoStream!.pipe(writable);
|
|
118
|
-
|
|
119
124
|
await pipeline.outboundHaloStream!.write(createPartyGenesisMessage(keyring, partyKey, feedKey.publicKey, identityKey));
|
|
120
125
|
await waitForCondition(() => !partyProcessor.genesisRequired);
|
|
121
126
|
|
|
@@ -126,15 +131,14 @@ describe('pipeline', () => {
|
|
|
126
131
|
}
|
|
127
132
|
});
|
|
128
133
|
|
|
129
|
-
await waitForCondition(() =>
|
|
134
|
+
await waitForCondition(() => echoMessages.length === 1);
|
|
130
135
|
|
|
131
136
|
expect(partyProcessor.genesisRequired).toEqual(false);
|
|
132
|
-
expect((
|
|
137
|
+
expect((echoMessages[0] as any).data).toEqual({
|
|
133
138
|
itemId: '123',
|
|
134
139
|
genesis: {
|
|
135
140
|
itemType: 'foo'
|
|
136
|
-
}
|
|
137
|
-
timeframe: expect.any(Timeframe)
|
|
141
|
+
}
|
|
138
142
|
});
|
|
139
143
|
});
|
|
140
144
|
});
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
import assert from 'assert';
|
|
6
6
|
import debug from 'debug';
|
|
7
|
-
import { Readable } from 'stream';
|
|
8
7
|
|
|
9
8
|
import { Event } from '@dxos/async';
|
|
10
9
|
import { Message as HaloMessage } from '@dxos/credentials';
|
|
@@ -13,11 +12,10 @@ import { checkType } from '@dxos/debug';
|
|
|
13
12
|
import {
|
|
14
13
|
createFeedMeta, EchoEnvelope, FeedMessage, FeedStoreIterator, FeedWriter, IEchoStream, mapFeedWriter, Timeframe
|
|
15
14
|
} from '@dxos/echo-protocol';
|
|
16
|
-
import { createReadable } from '@dxos/feed-store';
|
|
17
15
|
import { jsonReplacer } from '@dxos/util';
|
|
18
16
|
|
|
19
|
-
import { TimeframeClock } from '../database';
|
|
20
|
-
import {
|
|
17
|
+
import { EchoProcessor, TimeframeClock } from '../packlets/database';
|
|
18
|
+
import { CredentialProcessor, PartyStateProvider } from './party-processor';
|
|
21
19
|
|
|
22
20
|
interface Options {
|
|
23
21
|
readLogger?: (msg: any) => void
|
|
@@ -28,14 +26,12 @@ const log = debug('dxos:echo-db:pipeline');
|
|
|
28
26
|
|
|
29
27
|
/**
|
|
30
28
|
* Manages the inbound and outbound message streams for an individual party.
|
|
29
|
+
* Reads messages from individual feeds and splits them into ECHO and HALO streams.
|
|
31
30
|
*/
|
|
32
|
-
export class
|
|
31
|
+
export class FeedMuxer {
|
|
33
32
|
private readonly _errors = new Event<Error>();
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
* Messages to be consumed from the pipeline (e.g., mutations to model).
|
|
37
|
-
*/
|
|
38
|
-
private _inboundEchoStream: Readable | undefined;
|
|
34
|
+
private _isOpen = false;
|
|
39
35
|
|
|
40
36
|
/**
|
|
41
37
|
* Messages to write into pipeline (e.g., mutations from model).
|
|
@@ -47,6 +43,8 @@ export class Pipeline {
|
|
|
47
43
|
*/
|
|
48
44
|
private _outboundHaloStream: FeedWriter<HaloMessage> | undefined;
|
|
49
45
|
|
|
46
|
+
private _echoProcessor: EchoProcessor | undefined
|
|
47
|
+
|
|
50
48
|
/**
|
|
51
49
|
* @param _partyProcessor Processes HALO messages to update party state.
|
|
52
50
|
* @param _feedStorIterator Inbound messages from the feed store.
|
|
@@ -55,29 +53,37 @@ export class Pipeline {
|
|
|
55
53
|
* @param _options
|
|
56
54
|
*/
|
|
57
55
|
constructor (
|
|
58
|
-
private readonly _partyProcessor:
|
|
56
|
+
private readonly _partyProcessor: CredentialProcessor & PartyStateProvider,
|
|
59
57
|
private readonly _feedStorIterator: FeedStoreIterator,
|
|
60
58
|
private readonly _timeframeClock: TimeframeClock,
|
|
61
59
|
private readonly _feedWriter?: FeedWriter<FeedMessage>,
|
|
62
60
|
private readonly _options: Options = {}
|
|
63
|
-
) {
|
|
61
|
+
) {
|
|
62
|
+
if (this._feedWriter) {
|
|
63
|
+
const loggingWriter = mapFeedWriter<FeedMessage, FeedMessage>(async msg => {
|
|
64
|
+
this._options.writeLogger?.(msg);
|
|
65
|
+
return msg;
|
|
66
|
+
}, this._feedWriter);
|
|
64
67
|
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
this._outboundEchoStream = mapFeedWriter<EchoEnvelope, FeedMessage>(async message => ({
|
|
69
|
+
timeframe: this._timeframeClock.timeframe,
|
|
70
|
+
echo: message
|
|
71
|
+
}), loggingWriter);
|
|
72
|
+
this._outboundHaloStream = mapFeedWriter<HaloMessage, FeedMessage>(async message => ({
|
|
73
|
+
timeframe: this._timeframeClock.timeframe,
|
|
74
|
+
halo: message
|
|
75
|
+
}), loggingWriter);
|
|
76
|
+
}
|
|
67
77
|
}
|
|
68
78
|
|
|
69
79
|
get isOpen () {
|
|
70
|
-
return this.
|
|
80
|
+
return this._isOpen;
|
|
71
81
|
}
|
|
72
82
|
|
|
73
83
|
get readOnly () {
|
|
74
84
|
return this._outboundEchoStream === undefined;
|
|
75
85
|
}
|
|
76
86
|
|
|
77
|
-
get inboundEchoStream () {
|
|
78
|
-
return this._inboundEchoStream;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
87
|
get outboundEchoStream () {
|
|
82
88
|
return this._outboundEchoStream;
|
|
83
89
|
}
|
|
@@ -90,6 +96,10 @@ export class Pipeline {
|
|
|
90
96
|
return this._errors;
|
|
91
97
|
}
|
|
92
98
|
|
|
99
|
+
setEchoProcessor (processor: EchoProcessor) {
|
|
100
|
+
this._echoProcessor = processor;
|
|
101
|
+
}
|
|
102
|
+
|
|
93
103
|
/**
|
|
94
104
|
* Create inbound and outbound pipielines.
|
|
95
105
|
* https://nodejs.org/api/stream.html#stream_stream_pipeline_source_transforms_destination_callback
|
|
@@ -100,10 +110,8 @@ export class Pipeline {
|
|
|
100
110
|
* Transform(dxos.echo.IEchoEnvelope => dxos.IFeedMessage): update clock
|
|
101
111
|
* Feed
|
|
102
112
|
*/
|
|
103
|
-
async open (): Promise<
|
|
104
|
-
const { readLogger
|
|
105
|
-
|
|
106
|
-
this._inboundEchoStream = createReadable();
|
|
113
|
+
async open (): Promise<FeedWriter<EchoEnvelope> | undefined> {
|
|
114
|
+
const { readLogger } = this._options;
|
|
107
115
|
|
|
108
116
|
// This will exit cleanly once FeedStoreIterator is closed.
|
|
109
117
|
setImmediate(async () => {
|
|
@@ -129,20 +137,19 @@ export class Pipeline {
|
|
|
129
137
|
//
|
|
130
138
|
|
|
131
139
|
if (message.echo) {
|
|
132
|
-
this._timeframeClock.updateTimeframe(PublicKey.from(block.key), block.seq);
|
|
133
140
|
const memberKey = this._partyProcessor.getFeedOwningMember(PublicKey.from(block.key));
|
|
134
141
|
assert(memberKey, `Ownership of feed ${keyToString(block.key)} could not be determined.`);
|
|
135
142
|
|
|
136
143
|
// Validate messge.
|
|
137
144
|
const { itemId } = message.echo;
|
|
138
145
|
if (itemId) {
|
|
139
|
-
assert(this.
|
|
140
|
-
this.
|
|
146
|
+
assert(this._echoProcessor);
|
|
147
|
+
await this._echoProcessor(checkType<IEchoStream>({
|
|
141
148
|
meta: {
|
|
142
149
|
seq: block.seq,
|
|
143
150
|
feedKey: block.key,
|
|
144
151
|
memberKey,
|
|
145
|
-
timeframe: message.
|
|
152
|
+
timeframe: message.timeframe ?? new Timeframe()
|
|
146
153
|
},
|
|
147
154
|
data: message.echo
|
|
148
155
|
}));
|
|
@@ -153,6 +160,8 @@ export class Pipeline {
|
|
|
153
160
|
// TODO(burdon): Can we throw and have the pipeline log (without breaking the stream)?
|
|
154
161
|
log(`Skipping invalid message: ${JSON.stringify(message, jsonReplacer)}`);
|
|
155
162
|
}
|
|
163
|
+
|
|
164
|
+
this._timeframeClock.updateTimeframe(PublicKey.from(block.key), block.seq);
|
|
156
165
|
} catch (err: any) {
|
|
157
166
|
console.error('Error in message processing.');
|
|
158
167
|
console.error(err);
|
|
@@ -160,30 +169,7 @@ export class Pipeline {
|
|
|
160
169
|
}
|
|
161
170
|
});
|
|
162
171
|
|
|
163
|
-
|
|
164
|
-
// Processes outbound messages (piped to the feed).
|
|
165
|
-
// Sets the current timeframe.
|
|
166
|
-
//
|
|
167
|
-
if (this._feedWriter) {
|
|
168
|
-
const loggingWriter = mapFeedWriter<FeedMessage, FeedMessage>(async msg => {
|
|
169
|
-
writeLogger?.(msg);
|
|
170
|
-
return msg;
|
|
171
|
-
}, this._feedWriter);
|
|
172
|
-
|
|
173
|
-
this._outboundEchoStream = mapFeedWriter<EchoEnvelope, FeedMessage>(async message => ({
|
|
174
|
-
echo: {
|
|
175
|
-
...message,
|
|
176
|
-
timeframe: this._timeframeClock.timeframe
|
|
177
|
-
}
|
|
178
|
-
}), loggingWriter);
|
|
179
|
-
this._outboundHaloStream =
|
|
180
|
-
mapFeedWriter<HaloMessage, FeedMessage>(async message => ({ halo: message }), loggingWriter);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
return [
|
|
184
|
-
this._inboundEchoStream,
|
|
185
|
-
this._outboundEchoStream
|
|
186
|
-
];
|
|
172
|
+
return this._outboundEchoStream;
|
|
187
173
|
}
|
|
188
174
|
|
|
189
175
|
/**
|
|
@@ -193,11 +179,9 @@ export class Pipeline {
|
|
|
193
179
|
async close () {
|
|
194
180
|
await this._feedStorIterator.close();
|
|
195
181
|
|
|
196
|
-
if (this._inboundEchoStream) {
|
|
197
|
-
this._inboundEchoStream.destroy();
|
|
198
|
-
this._inboundEchoStream = undefined;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
182
|
this._outboundEchoStream = undefined;
|
|
183
|
+
this._outboundHaloStream = undefined;
|
|
184
|
+
this._echoProcessor = undefined;
|
|
185
|
+
this._isOpen = false;
|
|
202
186
|
}
|
|
203
187
|
}
|
package/src/pipeline/index.ts
CHANGED
|
@@ -6,6 +6,6 @@ export * from './message-selector';
|
|
|
6
6
|
export * from './party-feed-provider';
|
|
7
7
|
export * from './party-processor';
|
|
8
8
|
export * from '../protocol/party-protocol-factory';
|
|
9
|
-
export * from './
|
|
10
|
-
export * from './party-
|
|
9
|
+
export * from './feed-muxer';
|
|
10
|
+
export * from './party-pipeline';
|
|
11
11
|
export * from './metadata-store';
|
|
@@ -9,8 +9,8 @@ import { getPartyCredentialMessageType, PartyCredential } from '@dxos/credential
|
|
|
9
9
|
import { PublicKey } from '@dxos/crypto';
|
|
10
10
|
import { MessageSelector } from '@dxos/echo-protocol';
|
|
11
11
|
|
|
12
|
-
import { TimeframeClock } from '../database';
|
|
13
|
-
import {
|
|
12
|
+
import { TimeframeClock } from '../packlets/database';
|
|
13
|
+
import { PartyStateProvider } from './party-processor';
|
|
14
14
|
|
|
15
15
|
const log = debug('dxos:echo-db:message-selector');
|
|
16
16
|
|
|
@@ -23,47 +23,44 @@ const log = debug('dxos:echo-db:message-selector');
|
|
|
23
23
|
* @param partyProcessor
|
|
24
24
|
* @param timeframeClock
|
|
25
25
|
*/
|
|
26
|
-
export
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const { data: { echo } } = candidates[i];
|
|
35
|
-
const feedKey = PublicKey.from(candidates[i].key);
|
|
36
|
-
if (!echo) {
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
26
|
+
export const createMessageSelector = (partyProcessor: PartyStateProvider, timeframeClock: TimeframeClock): MessageSelector => candidates => {
|
|
27
|
+
// Check ECHO message candidates first since they are less expensive than HALO cancidates.
|
|
28
|
+
for (let i = 0; i < candidates.length; i++) {
|
|
29
|
+
const { data: { timeframe, echo } } = candidates[i];
|
|
30
|
+
const feedKey = PublicKey.from(candidates[i].key);
|
|
31
|
+
if (!echo) {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
39
34
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
35
|
+
assert(timeframe);
|
|
36
|
+
if (partyProcessor.isFeedAdmitted(feedKey) && !timeframeClock.hasGaps(timeframe)) {
|
|
37
|
+
return i;
|
|
44
38
|
}
|
|
39
|
+
}
|
|
45
40
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
41
|
+
// Check HALO message candidates.
|
|
42
|
+
for (let i = 0; i < candidates.length; i++) {
|
|
43
|
+
const { data: { timeframe, halo } } = candidates[i];
|
|
44
|
+
const feedKey = PublicKey.from(candidates[i].key);
|
|
45
|
+
if (!halo) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
53
48
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
49
|
+
assert(timeframe);
|
|
50
|
+
if (partyProcessor.isFeedAdmitted(feedKey) && !timeframeClock.hasGaps(timeframe)) {
|
|
51
|
+
return i;
|
|
52
|
+
}
|
|
57
53
|
|
|
58
|
-
|
|
54
|
+
if (partyProcessor.genesisRequired) {
|
|
55
|
+
try { // TODO(dmaretskyi): Get getPartyCredentialMessageType crashes for some reason.
|
|
59
56
|
// TODO(telackey): Add check that this is for the right Party.
|
|
60
57
|
if (getPartyCredentialMessageType(halo) === PartyCredential.Type.PARTY_GENESIS) {
|
|
61
58
|
return i;
|
|
62
59
|
}
|
|
63
|
-
}
|
|
60
|
+
} catch { }
|
|
64
61
|
}
|
|
62
|
+
}
|
|
65
63
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
64
|
+
// Not ready for this message yet.
|
|
65
|
+
log('Skipping...');
|
|
66
|
+
};
|
|
@@ -11,7 +11,8 @@ import { MetadataStore } from './metadata-store';
|
|
|
11
11
|
|
|
12
12
|
describe('MetadataStore in-memory', () => {
|
|
13
13
|
it('Creates party and adds feeds to it', async () => {
|
|
14
|
-
const
|
|
14
|
+
const storage = createStorage('', StorageType.RAM);
|
|
15
|
+
const store = new MetadataStore(storage.directory('metadata'));
|
|
15
16
|
await store.load();
|
|
16
17
|
expect(store.parties?.length).toBe(0);
|
|
17
18
|
|
|
@@ -33,7 +34,8 @@ describe('MetadataStore in-memory', () => {
|
|
|
33
34
|
});
|
|
34
35
|
|
|
35
36
|
it('Creates party when adding feed', async () => {
|
|
36
|
-
const
|
|
37
|
+
const storage = createStorage('', StorageType.RAM);
|
|
38
|
+
const store = new MetadataStore(storage.directory('metadata'));
|
|
37
39
|
await store.load();
|
|
38
40
|
|
|
39
41
|
const partyKey = PublicKey.random();
|
|
@@ -45,7 +47,8 @@ describe('MetadataStore in-memory', () => {
|
|
|
45
47
|
});
|
|
46
48
|
|
|
47
49
|
it('Doesn\'t add same feed twice', async () => {
|
|
48
|
-
const
|
|
50
|
+
const storage = createStorage('', StorageType.RAM);
|
|
51
|
+
const store = new MetadataStore(storage.directory('metadata'));
|
|
49
52
|
await store.load();
|
|
50
53
|
|
|
51
54
|
const partyKey = PublicKey.random();
|
|
@@ -60,7 +63,8 @@ describe('MetadataStore in-memory', () => {
|
|
|
60
63
|
|
|
61
64
|
// TODO(yivlad): Doesn't work for now.
|
|
62
65
|
it.skip('Resets storage', async () => {
|
|
63
|
-
const
|
|
66
|
+
const storage = createStorage('snapshots', StorageType.RAM);
|
|
67
|
+
const store = new MetadataStore(storage.directory(''));
|
|
64
68
|
|
|
65
69
|
const partyKey = PublicKey.random();
|
|
66
70
|
const feedKey = PublicKey.random();
|
|
@@ -7,8 +7,8 @@ import debug from 'debug';
|
|
|
7
7
|
|
|
8
8
|
import { PublicKey } from '@dxos/crypto';
|
|
9
9
|
import { failUndefined } from '@dxos/debug';
|
|
10
|
-
import { EchoMetadata, PartyMetadata, schema } from '@dxos/echo-protocol';
|
|
11
|
-
import {
|
|
10
|
+
import { EchoMetadata, PartyMetadata, schema, Timeframe } from '@dxos/echo-protocol';
|
|
11
|
+
import { Directory } from '@dxos/random-access-multi-storage';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Version for the schema of the stored data as defined in dxos.echo.metadata.EchoMetadata.
|
|
@@ -28,7 +28,7 @@ export class MetadataStore {
|
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
constructor (
|
|
31
|
-
private readonly
|
|
31
|
+
private readonly _directory: Directory
|
|
32
32
|
) {}
|
|
33
33
|
|
|
34
34
|
get version (): number {
|
|
@@ -47,7 +47,7 @@ export class MetadataStore {
|
|
|
47
47
|
* Loads metadata from persistent storage.
|
|
48
48
|
*/
|
|
49
49
|
async load (): Promise<void> {
|
|
50
|
-
const file = this.
|
|
50
|
+
const file = this._directory.createOrOpen('EchoMetadata');
|
|
51
51
|
try {
|
|
52
52
|
const { size } = await file.stat();
|
|
53
53
|
if (size === 0) {
|
|
@@ -75,7 +75,7 @@ export class MetadataStore {
|
|
|
75
75
|
updated: new Date()
|
|
76
76
|
};
|
|
77
77
|
|
|
78
|
-
const file = this.
|
|
78
|
+
const file = this._directory.createOrOpen('EchoMetadata');
|
|
79
79
|
|
|
80
80
|
try {
|
|
81
81
|
const encoded = Buffer.from(schema.getCodecForType('dxos.echo.metadata.EchoMetadata').encode(data));
|
|
@@ -90,7 +90,7 @@ export class MetadataStore {
|
|
|
90
90
|
*/
|
|
91
91
|
async clear (): Promise<void> {
|
|
92
92
|
log('Clearing all echo metadata...');
|
|
93
|
-
await this.
|
|
93
|
+
await this._directory.delete();
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
/**
|
|
@@ -158,4 +158,10 @@ export class MetadataStore {
|
|
|
158
158
|
}
|
|
159
159
|
return !!party.feedKeys?.find(fk => feedKey.equals(fk));
|
|
160
160
|
}
|
|
161
|
+
|
|
162
|
+
async setTimeframe (partyKey: PublicKey, timeframe: Timeframe) {
|
|
163
|
+
const party = this.getParty(partyKey) ?? failUndefined();
|
|
164
|
+
party.latestTimeframe = timeframe;
|
|
165
|
+
await this._save();
|
|
166
|
+
}
|
|
161
167
|
}
|