@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
|
@@ -8,7 +8,7 @@ import debug from 'debug';
|
|
|
8
8
|
import { Event, synchronized } from '@dxos/async';
|
|
9
9
|
import { Keyring, KeyType } from '@dxos/credentials';
|
|
10
10
|
import { PublicKey } from '@dxos/crypto';
|
|
11
|
-
import { FeedStoreIterator, MessageSelector, Timeframe } from '@dxos/echo-protocol';
|
|
11
|
+
import { FeedSelector, FeedStoreIterator, MessageSelector, Timeframe } from '@dxos/echo-protocol';
|
|
12
12
|
import { FeedDescriptor, FeedStore } from '@dxos/feed-store';
|
|
13
13
|
import { ComplexMap } from '@dxos/util';
|
|
14
14
|
|
|
@@ -33,19 +33,6 @@ export class PartyFeedProvider {
|
|
|
33
33
|
return Array.from(this._feeds.values());
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
@synchronized
|
|
37
|
-
async openKnownFeeds () {
|
|
38
|
-
for (const feedKey of this._metadataStore.getParty(this._partyKey)?.feedKeys ?? []) {
|
|
39
|
-
if (!this._feeds.has(feedKey)) {
|
|
40
|
-
const fullKey = this._keyring.getFullKey(feedKey);
|
|
41
|
-
const feed = fullKey?.secretKey
|
|
42
|
-
? await this._feedStore.openReadWriteFeed(fullKey.publicKey, fullKey.secretKey)
|
|
43
|
-
: await this._feedStore.openReadOnlyFeed(feedKey);
|
|
44
|
-
this._trackFeed(feed);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
36
|
@synchronized
|
|
50
37
|
async createOrOpenWritableFeed () {
|
|
51
38
|
const partyMetadata = this._metadataStore.getParty(this._partyKey);
|
|
@@ -103,8 +90,8 @@ export class PartyFeedProvider {
|
|
|
103
90
|
return feed;
|
|
104
91
|
}
|
|
105
92
|
|
|
106
|
-
async createIterator (messageSelector: MessageSelector, initialTimeframe?: Timeframe) {
|
|
107
|
-
const iterator = new FeedStoreIterator(
|
|
93
|
+
async createIterator (messageSelector: MessageSelector, feedSelector: FeedSelector, initialTimeframe?: Timeframe) {
|
|
94
|
+
const iterator = new FeedStoreIterator(feedSelector, messageSelector, initialTimeframe ?? new Timeframe());
|
|
108
95
|
for (const feed of this._feeds.values()) {
|
|
109
96
|
iterator.addFeedDescriptor(feed);
|
|
110
97
|
}
|
|
@@ -8,7 +8,8 @@ import { it as test } from 'mocha';
|
|
|
8
8
|
import { promiseTimeout } from '@dxos/async';
|
|
9
9
|
import { createFeedAdmitMessage, createPartyGenesisMessage, Keyring, KeyType } from '@dxos/credentials';
|
|
10
10
|
import { createId, PublicKey } from '@dxos/crypto';
|
|
11
|
-
import {
|
|
11
|
+
import { checkType } from '@dxos/debug';
|
|
12
|
+
import { codec, FeedMessage, Timeframe } from '@dxos/echo-protocol';
|
|
12
13
|
import { FeedStore } from '@dxos/feed-store';
|
|
13
14
|
import { createTestProtocolPair } from '@dxos/mesh-protocol';
|
|
14
15
|
import { ModelFactory } from '@dxos/model-factory';
|
|
@@ -16,28 +17,29 @@ import { ObjectModel } from '@dxos/object-model';
|
|
|
16
17
|
import { createStorage, StorageType } from '@dxos/random-access-multi-storage';
|
|
17
18
|
import { afterTest } from '@dxos/testutils';
|
|
18
19
|
|
|
19
|
-
import { MetadataStore, PartyFeedProvider
|
|
20
|
+
import { MetadataStore, PartyFeedProvider } from '.';
|
|
21
|
+
import { createReplicatorPlugin } from '../protocol/replicator-plugin';
|
|
20
22
|
import { SnapshotStore } from '../snapshots';
|
|
21
|
-
import {
|
|
23
|
+
import { PartyPipeline } from './party-pipeline';
|
|
22
24
|
|
|
23
|
-
describe('
|
|
25
|
+
describe('PartyPipeline', () => {
|
|
24
26
|
const setup = async () => {
|
|
25
27
|
const storage = createStorage('', StorageType.RAM);
|
|
26
|
-
const feedStore = new FeedStore(storage, { valueEncoding: codec });
|
|
28
|
+
const feedStore = new FeedStore(storage.directory('feed'), { valueEncoding: codec });
|
|
27
29
|
afterTest(async () => feedStore.close());
|
|
28
30
|
|
|
29
31
|
const keyring = new Keyring();
|
|
30
32
|
|
|
31
|
-
const metadataStore = new MetadataStore(
|
|
33
|
+
const metadataStore = new MetadataStore(storage.directory('metadata'));
|
|
32
34
|
|
|
33
35
|
const modelFactory = new ModelFactory().registerModel(ObjectModel);
|
|
34
|
-
const snapshotStore = new SnapshotStore(
|
|
36
|
+
const snapshotStore = new SnapshotStore(storage.directory('snapshots'));
|
|
35
37
|
|
|
36
38
|
const partyKey = await keyring.createKeyRecord({ type: KeyType.PARTY });
|
|
37
39
|
|
|
38
40
|
const partyFeedProvider = new PartyFeedProvider(metadataStore, keyring, feedStore, partyKey.publicKey);
|
|
39
41
|
|
|
40
|
-
const party = new
|
|
42
|
+
const party = new PartyPipeline(
|
|
41
43
|
partyKey.publicKey,
|
|
42
44
|
partyFeedProvider,
|
|
43
45
|
modelFactory,
|
|
@@ -46,11 +48,11 @@ describe('PartyCore', () => {
|
|
|
46
48
|
);
|
|
47
49
|
|
|
48
50
|
const feed = await partyFeedProvider.createOrOpenWritableFeed();
|
|
49
|
-
await party.open();
|
|
51
|
+
await party.open({ feedHints: [feed.key] });
|
|
50
52
|
afterTest(async () => party.close());
|
|
51
53
|
|
|
52
54
|
// PartyGenesis (self-signed by Party).
|
|
53
|
-
await party.
|
|
55
|
+
await party.credentialsWriter.write(createPartyGenesisMessage(
|
|
54
56
|
keyring,
|
|
55
57
|
partyKey,
|
|
56
58
|
feed.key,
|
|
@@ -58,7 +60,7 @@ describe('PartyCore', () => {
|
|
|
58
60
|
);
|
|
59
61
|
|
|
60
62
|
// FeedAdmit (signed by the Device KeyChain).
|
|
61
|
-
await party.
|
|
63
|
+
await party.credentialsWriter.write(createFeedAdmitMessage(
|
|
62
64
|
keyring,
|
|
63
65
|
partyKey.publicKey,
|
|
64
66
|
feed.key,
|
|
@@ -86,7 +88,7 @@ describe('PartyCore', () => {
|
|
|
86
88
|
});
|
|
87
89
|
|
|
88
90
|
test('create item with parent and then reload', async () => {
|
|
89
|
-
const { party } = await setup();
|
|
91
|
+
const { party, feedKey } = await setup();
|
|
90
92
|
|
|
91
93
|
{
|
|
92
94
|
const parent = await party.database.createItem({ model: ObjectModel, type: 'parent' });
|
|
@@ -101,7 +103,7 @@ describe('PartyCore', () => {
|
|
|
101
103
|
}
|
|
102
104
|
|
|
103
105
|
await party.close();
|
|
104
|
-
await party.open();
|
|
106
|
+
await party.open({ feedHints: [feedKey] });
|
|
105
107
|
|
|
106
108
|
{
|
|
107
109
|
await party.database.select().exec().update.waitFor(result => result.entities.length === 2);
|
|
@@ -119,7 +121,7 @@ describe('PartyCore', () => {
|
|
|
119
121
|
const feedKey = await keyring.createKeyRecord({ type: KeyType.FEED });
|
|
120
122
|
|
|
121
123
|
const eventFired = feedStore.feedOpenedEvent.waitForCount(1);
|
|
122
|
-
await party.
|
|
124
|
+
await party.credentialsWriter.write(createFeedAdmitMessage(
|
|
123
125
|
keyring,
|
|
124
126
|
party.key,
|
|
125
127
|
feedKey.publicKey,
|
|
@@ -131,15 +133,15 @@ describe('PartyCore', () => {
|
|
|
131
133
|
|
|
132
134
|
test('opens feed from hints', async () => {
|
|
133
135
|
const storage = createStorage('', StorageType.RAM);
|
|
134
|
-
const feedStore = new FeedStore(storage, { valueEncoding: codec });
|
|
136
|
+
const feedStore = new FeedStore(storage.directory('feed'), { valueEncoding: codec });
|
|
135
137
|
afterTest(async () => feedStore.close());
|
|
136
138
|
|
|
137
139
|
const keyring = new Keyring();
|
|
138
140
|
|
|
139
|
-
const metadataStore = new MetadataStore(
|
|
141
|
+
const metadataStore = new MetadataStore(storage.directory('metadata'));
|
|
140
142
|
|
|
141
143
|
const modelFactory = new ModelFactory().registerModel(ObjectModel);
|
|
142
|
-
const snapshotStore = new SnapshotStore(
|
|
144
|
+
const snapshotStore = new SnapshotStore(storage.directory('snapshots'));
|
|
143
145
|
|
|
144
146
|
const partyKey = await keyring.createKeyRecord({ type: KeyType.PARTY });
|
|
145
147
|
|
|
@@ -147,7 +149,7 @@ describe('PartyCore', () => {
|
|
|
147
149
|
|
|
148
150
|
const otherFeedKey = PublicKey.random();
|
|
149
151
|
|
|
150
|
-
const party = new
|
|
152
|
+
const party = new PartyPipeline(
|
|
151
153
|
partyKey.publicKey,
|
|
152
154
|
partyFeedProvider,
|
|
153
155
|
modelFactory,
|
|
@@ -159,7 +161,7 @@ describe('PartyCore', () => {
|
|
|
159
161
|
|
|
160
162
|
const feedOpened = feedStore.feedOpenedEvent.waitForCount(1);
|
|
161
163
|
|
|
162
|
-
await party.open(
|
|
164
|
+
await party.open({ feedHints: [otherFeedKey] });
|
|
163
165
|
afterTest(async () => party.close());
|
|
164
166
|
|
|
165
167
|
await feedOpened;
|
|
@@ -174,16 +176,16 @@ describe('PartyCore', () => {
|
|
|
174
176
|
const feed = await partyFeedProvider.createOrOpenWritableFeed();
|
|
175
177
|
|
|
176
178
|
const itemId = createId();
|
|
177
|
-
await feed.feed.append({
|
|
179
|
+
await feed.feed.append(checkType<FeedMessage>({
|
|
180
|
+
timeframe: new Timeframe(),
|
|
178
181
|
echo: {
|
|
179
182
|
itemId,
|
|
180
183
|
genesis: {
|
|
181
184
|
itemType: 'dxos:example',
|
|
182
185
|
modelType: ObjectModel.meta.type
|
|
183
|
-
}
|
|
184
|
-
timeframe: new Timeframe()
|
|
186
|
+
}
|
|
185
187
|
}
|
|
186
|
-
});
|
|
188
|
+
}));
|
|
187
189
|
|
|
188
190
|
await promiseTimeout(party.database.waitForItem({ id: itemId }), 1000, new Error('timeout'));
|
|
189
191
|
});
|
|
@@ -196,7 +198,7 @@ describe('PartyCore', () => {
|
|
|
196
198
|
const fullKey = keyring.getFullKey(feedKey.publicKey);
|
|
197
199
|
const feed2 = await feedStore.openReadWriteFeed(fullKey!.publicKey, fullKey!.secretKey!);
|
|
198
200
|
|
|
199
|
-
await party.
|
|
201
|
+
await party.credentialsWriter.write(createFeedAdmitMessage(
|
|
200
202
|
keyring,
|
|
201
203
|
party.key,
|
|
202
204
|
feed2.key,
|
|
@@ -204,16 +206,16 @@ describe('PartyCore', () => {
|
|
|
204
206
|
));
|
|
205
207
|
|
|
206
208
|
const itemId = createId();
|
|
207
|
-
await feed2.append({
|
|
209
|
+
await feed2.append(checkType<FeedMessage>({
|
|
210
|
+
timeframe: new Timeframe(),
|
|
208
211
|
echo: {
|
|
209
212
|
itemId,
|
|
210
213
|
genesis: {
|
|
211
214
|
itemType: 'dxos:example',
|
|
212
215
|
modelType: ObjectModel.meta.type
|
|
213
|
-
}
|
|
214
|
-
timeframe: new Timeframe()
|
|
216
|
+
}
|
|
215
217
|
}
|
|
216
|
-
});
|
|
218
|
+
}));
|
|
217
219
|
|
|
218
220
|
await promiseTimeout(party.database.waitForItem({ id: itemId }), 1000, new Error('timeout'));
|
|
219
221
|
});
|
|
@@ -225,7 +227,7 @@ describe('PartyCore', () => {
|
|
|
225
227
|
const feedKey = await keyring.createKeyRecord({ type: KeyType.FEED });
|
|
226
228
|
const fullKey = keyring.getFullKey(feedKey.publicKey);
|
|
227
229
|
|
|
228
|
-
await party.
|
|
230
|
+
await party.credentialsWriter.write(createFeedAdmitMessage(
|
|
229
231
|
keyring,
|
|
230
232
|
party.key,
|
|
231
233
|
feedKey.publicKey,
|
|
@@ -234,35 +236,57 @@ describe('PartyCore', () => {
|
|
|
234
236
|
|
|
235
237
|
const feed2 = await feedStore.openReadWriteFeed(fullKey!.publicKey, fullKey!.secretKey!);
|
|
236
238
|
const itemId = createId();
|
|
237
|
-
await feed2.append({
|
|
239
|
+
await feed2.append(checkType<FeedMessage>({
|
|
240
|
+
timeframe: new Timeframe(),
|
|
238
241
|
echo: {
|
|
239
242
|
itemId,
|
|
240
243
|
genesis: {
|
|
241
244
|
itemType: 'dxos:example',
|
|
242
245
|
modelType: ObjectModel.meta.type
|
|
243
|
-
}
|
|
244
|
-
timeframe: new Timeframe()
|
|
246
|
+
}
|
|
245
247
|
}
|
|
246
|
-
});
|
|
248
|
+
}));
|
|
247
249
|
|
|
248
250
|
await promiseTimeout(party.database.waitForItem({ id: itemId }), 1000, new Error('timeout'));
|
|
249
251
|
});
|
|
250
252
|
|
|
253
|
+
test('wait to reach specific timeframe', async () => {
|
|
254
|
+
const { party, feedKey } = await setup();
|
|
255
|
+
|
|
256
|
+
{
|
|
257
|
+
const parent = await party.database.createItem({ model: ObjectModel, type: 'parent' });
|
|
258
|
+
const child = await party.database.createItem({
|
|
259
|
+
model: ObjectModel,
|
|
260
|
+
parent: parent.id,
|
|
261
|
+
type: 'child'
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
expect(child.parent).toEqual(parent);
|
|
265
|
+
expect(parent.children).toContain(child);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
const timeframe = party.timeframe;
|
|
269
|
+
expect(timeframe.isEmpty()).toBeFalsy();
|
|
270
|
+
|
|
271
|
+
await party.close();
|
|
272
|
+
await party.open({ feedHints: [feedKey], targetTimeframe: timeframe });
|
|
273
|
+
});
|
|
274
|
+
|
|
251
275
|
test('two instances replicating', async () => {
|
|
252
276
|
const peer1 = await setup();
|
|
253
277
|
|
|
254
278
|
const storage = createStorage('', StorageType.RAM);
|
|
255
|
-
const feedStore = new FeedStore(storage, { valueEncoding: codec });
|
|
279
|
+
const feedStore = new FeedStore(storage.directory('feed'), { valueEncoding: codec });
|
|
256
280
|
afterTest(async () => feedStore.close());
|
|
257
281
|
|
|
258
|
-
const metadataStore = new MetadataStore(
|
|
282
|
+
const metadataStore = new MetadataStore(storage.directory('metadata'));
|
|
259
283
|
|
|
260
284
|
const modelFactory = new ModelFactory().registerModel(ObjectModel);
|
|
261
|
-
const snapshotStore = new SnapshotStore(
|
|
285
|
+
const snapshotStore = new SnapshotStore(storage.directory('snapshots'));
|
|
262
286
|
|
|
263
287
|
const partyFeedProvider = new PartyFeedProvider(metadataStore, peer1.keyring, feedStore, peer1.party.key);
|
|
264
288
|
|
|
265
|
-
const party2 = new
|
|
289
|
+
const party2 = new PartyPipeline(
|
|
266
290
|
peer1.party.key,
|
|
267
291
|
partyFeedProvider,
|
|
268
292
|
modelFactory,
|
|
@@ -272,26 +296,21 @@ describe('PartyCore', () => {
|
|
|
272
296
|
|
|
273
297
|
const feed2 = await partyFeedProvider.createOrOpenWritableFeed();
|
|
274
298
|
|
|
275
|
-
await peer1.party.
|
|
299
|
+
await peer1.party.credentialsWriter.write(createFeedAdmitMessage(
|
|
276
300
|
peer1.keyring,
|
|
277
301
|
peer1.party.key,
|
|
278
302
|
feed2.key,
|
|
279
303
|
[peer1.partyKey]
|
|
280
304
|
));
|
|
281
305
|
|
|
282
|
-
await party2.open(
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
}]);
|
|
306
|
+
await party2.open({
|
|
307
|
+
feedHints: [peer1.feedKey]
|
|
308
|
+
});
|
|
286
309
|
afterTest(async () => party2.close());
|
|
287
310
|
|
|
288
311
|
createTestProtocolPair(
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
).createPlugins().map(r => r.createExtension()),
|
|
292
|
-
new ReplicatorProtocolPluginFactory(
|
|
293
|
-
partyFeedProvider
|
|
294
|
-
).createPlugins().map(r => r.createExtension())
|
|
312
|
+
[createReplicatorPlugin(peer1.partyFeedProvider).createExtension()],
|
|
313
|
+
[createReplicatorPlugin(partyFeedProvider).createExtension()]
|
|
295
314
|
);
|
|
296
315
|
|
|
297
316
|
const item1 = await peer1.party.database.createItem();
|
|
@@ -5,21 +5,20 @@
|
|
|
5
5
|
import assert from 'assert';
|
|
6
6
|
|
|
7
7
|
import { synchronized } from '@dxos/async';
|
|
8
|
-
import {
|
|
8
|
+
import { KeyType, Message as HaloMessage } from '@dxos/credentials';
|
|
9
9
|
import { PublicKey } from '@dxos/crypto';
|
|
10
10
|
import { timed } from '@dxos/debug';
|
|
11
|
-
import { createFeedWriter, DatabaseSnapshot, PartyKey, PartySnapshot, Timeframe } from '@dxos/echo-protocol';
|
|
11
|
+
import { createFeedWriter, DatabaseSnapshot, FeedSelector, FeedWriter, PartyKey, PartySnapshot, Timeframe } from '@dxos/echo-protocol';
|
|
12
12
|
import { ModelFactory } from '@dxos/model-factory';
|
|
13
13
|
import { SubscriptionGroup } from '@dxos/util';
|
|
14
14
|
|
|
15
|
-
import {
|
|
16
|
-
import { FeedDatabaseBackend, TimeframeClock } from '../database';
|
|
17
|
-
import { createMessageSelector, PartyProcessor, PartyFeedProvider, Pipeline } from '../pipeline';
|
|
15
|
+
import { createMessageSelector, PartyProcessor, PartyFeedProvider, FeedMuxer } from '.';
|
|
16
|
+
import { Database, FeedDatabaseBackend, TimeframeClock } from '../packlets/database';
|
|
18
17
|
import { createAutomaticSnapshots, SnapshotStore } from '../snapshots';
|
|
19
18
|
|
|
20
19
|
const DEFAULT_SNAPSHOT_INTERVAL = 100; // Every 100 messages.
|
|
21
20
|
|
|
22
|
-
export interface
|
|
21
|
+
export interface PipelineOptions {
|
|
23
22
|
readLogger?: (msg: any) => void;
|
|
24
23
|
writeLogger?: (msg: any) => void;
|
|
25
24
|
readOnly?: boolean;
|
|
@@ -29,6 +28,22 @@ export interface PartyOptions {
|
|
|
29
28
|
snapshotInterval?: number;
|
|
30
29
|
}
|
|
31
30
|
|
|
31
|
+
export interface OpenOptions {
|
|
32
|
+
/**
|
|
33
|
+
* Keys of initial feeds needed to bootstrap the party.
|
|
34
|
+
*/
|
|
35
|
+
feedHints?: PublicKey[]
|
|
36
|
+
/**
|
|
37
|
+
* Timeframe to start processing feed messages from.
|
|
38
|
+
*/
|
|
39
|
+
initialTimeframe?: Timeframe
|
|
40
|
+
/**
|
|
41
|
+
* Timeframe which must be reached until further processing.
|
|
42
|
+
* PartyCore.open will block until this timeframe is reached.
|
|
43
|
+
*/
|
|
44
|
+
targetTimeframe?: Timeframe
|
|
45
|
+
}
|
|
46
|
+
|
|
32
47
|
/**
|
|
33
48
|
* Encapsulates core components needed by a party:
|
|
34
49
|
* - ECHO database with item-manager & item-demuxer.
|
|
@@ -37,7 +52,7 @@ export interface PartyOptions {
|
|
|
37
52
|
*
|
|
38
53
|
* The core class also handles the combined ECHO and HALO state snapshots.
|
|
39
54
|
*/
|
|
40
|
-
export class
|
|
55
|
+
export class PartyPipeline {
|
|
41
56
|
/**
|
|
42
57
|
* Snapshot to be restored from when party.open() is called.
|
|
43
58
|
*/
|
|
@@ -46,7 +61,7 @@ export class PartyCore {
|
|
|
46
61
|
private readonly _subscriptions = new SubscriptionGroup();
|
|
47
62
|
|
|
48
63
|
private _database?: Database;
|
|
49
|
-
private _pipeline?:
|
|
64
|
+
private _pipeline?: FeedMuxer;
|
|
50
65
|
private _partyProcessor?: PartyProcessor;
|
|
51
66
|
private _timeframeClock?: TimeframeClock;
|
|
52
67
|
|
|
@@ -56,8 +71,7 @@ export class PartyCore {
|
|
|
56
71
|
private readonly _modelFactory: ModelFactory,
|
|
57
72
|
private readonly _snapshotStore: SnapshotStore,
|
|
58
73
|
private readonly _memberKey: PublicKey,
|
|
59
|
-
private readonly
|
|
60
|
-
private readonly _options: PartyOptions = {}
|
|
74
|
+
private readonly _options: PipelineOptions = {}
|
|
61
75
|
) { }
|
|
62
76
|
|
|
63
77
|
get key (): PartyKey {
|
|
@@ -99,20 +113,29 @@ export class PartyCore {
|
|
|
99
113
|
return feed;
|
|
100
114
|
}
|
|
101
115
|
|
|
116
|
+
get credentialsWriter (): FeedWriter<HaloMessage> {
|
|
117
|
+
assert(this._pipeline?.outboundHaloStream, 'Party not open');
|
|
118
|
+
return this._pipeline?.outboundHaloStream;
|
|
119
|
+
}
|
|
120
|
+
|
|
102
121
|
/**
|
|
103
122
|
* Opens the pipeline and connects the streams.
|
|
104
123
|
*/
|
|
105
124
|
@synchronized
|
|
106
125
|
@timed(1_000)
|
|
107
|
-
async open (
|
|
126
|
+
async open (options: OpenOptions = {}) {
|
|
127
|
+
const {
|
|
128
|
+
feedHints = [],
|
|
129
|
+
initialTimeframe,
|
|
130
|
+
targetTimeframe
|
|
131
|
+
} = options;
|
|
132
|
+
|
|
108
133
|
if (this.isOpen) {
|
|
109
134
|
return this;
|
|
110
135
|
}
|
|
111
136
|
|
|
112
|
-
this._timeframeClock = new TimeframeClock(
|
|
137
|
+
this._timeframeClock = new TimeframeClock(initialTimeframe);
|
|
113
138
|
|
|
114
|
-
// Open all feeds known from metadata and open or create a writable feed to the party.
|
|
115
|
-
await this._feedProvider.openKnownFeeds();
|
|
116
139
|
const writableFeed = await this._feedProvider.createOrOpenWritableFeed();
|
|
117
140
|
|
|
118
141
|
if (!this._partyProcessor) {
|
|
@@ -124,12 +147,8 @@ export class PartyCore {
|
|
|
124
147
|
void this._feedProvider.createOrOpenReadOnlyFeed(feed);
|
|
125
148
|
}));
|
|
126
149
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
await this._partyProcessor.takeHints([{ type: KeyType.FEED, publicKey: writableFeed.key }]);
|
|
130
|
-
|
|
131
|
-
if (keyHints.length > 0) {
|
|
132
|
-
await this._partyProcessor.takeHints(keyHints);
|
|
150
|
+
if (feedHints.length > 0) {
|
|
151
|
+
await this._partyProcessor.takeHints(feedHints.map(publicKey => ({ publicKey, type: KeyType.FEED })));
|
|
133
152
|
}
|
|
134
153
|
|
|
135
154
|
//
|
|
@@ -138,31 +157,34 @@ export class PartyCore {
|
|
|
138
157
|
|
|
139
158
|
const iterator = await this._feedProvider.createIterator(
|
|
140
159
|
createMessageSelector(this._partyProcessor, this._timeframeClock),
|
|
141
|
-
this.
|
|
160
|
+
createFeedSelector(this._partyProcessor, feedHints),
|
|
161
|
+
initialTimeframe
|
|
142
162
|
);
|
|
143
163
|
|
|
144
|
-
this._pipeline = new
|
|
145
|
-
this._partyProcessor,
|
|
164
|
+
this._pipeline = new FeedMuxer(
|
|
165
|
+
this._partyProcessor,
|
|
146
166
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
this._partyProcessor.setOutboundStream(this._pipeline.outboundHaloStream);
|
|
153
|
-
}
|
|
167
|
+
iterator,
|
|
168
|
+
this._timeframeClock,
|
|
169
|
+
createFeedWriter(writableFeed.feed),
|
|
170
|
+
this._options
|
|
171
|
+
);
|
|
154
172
|
|
|
155
173
|
//
|
|
156
174
|
// Database
|
|
157
175
|
//
|
|
158
176
|
|
|
177
|
+
const databaseBackend = new FeedDatabaseBackend(this._pipeline.outboundEchoStream, this._databaseSnapshot, { snapshots: true });
|
|
159
178
|
this._database = new Database(
|
|
160
179
|
this._modelFactory,
|
|
161
|
-
|
|
180
|
+
databaseBackend,
|
|
162
181
|
this._memberKey
|
|
163
182
|
);
|
|
164
183
|
|
|
184
|
+
// Open pipeline and connect it to the database.
|
|
165
185
|
await this._database.initialize();
|
|
186
|
+
this._pipeline.setEchoProcessor(databaseBackend.echoProcessor);
|
|
187
|
+
await this._pipeline.open();
|
|
166
188
|
|
|
167
189
|
// TODO(burdon): Propagate errors.
|
|
168
190
|
this._subscriptions.push(this._pipeline.errors.on(err => console.error(err)));
|
|
@@ -176,6 +198,10 @@ export class PartyCore {
|
|
|
176
198
|
);
|
|
177
199
|
}
|
|
178
200
|
|
|
201
|
+
if (targetTimeframe) {
|
|
202
|
+
await this._timeframeClock.waitUntilReached(targetTimeframe);
|
|
203
|
+
}
|
|
204
|
+
|
|
179
205
|
return this;
|
|
180
206
|
}
|
|
181
207
|
|
|
@@ -229,3 +255,5 @@ export class PartyCore {
|
|
|
229
255
|
this._databaseSnapshot = snapshot.database;
|
|
230
256
|
}
|
|
231
257
|
}
|
|
258
|
+
|
|
259
|
+
const createFeedSelector = (partyProcessor: PartyProcessor, hints: PublicKey[]): FeedSelector => feed => hints.some(hint => hint.equals(feed.key)) || partyProcessor.isFeedAdmitted(feed.key);
|
|
@@ -12,22 +12,40 @@ import {
|
|
|
12
12
|
PartyState,
|
|
13
13
|
Message as HaloMessage,
|
|
14
14
|
IdentityEventType,
|
|
15
|
-
PartyEventType
|
|
15
|
+
PartyEventType,
|
|
16
|
+
SignedMessage
|
|
16
17
|
} from '@dxos/credentials';
|
|
17
18
|
import { PublicKey } from '@dxos/crypto';
|
|
18
|
-
import { FeedKey,
|
|
19
|
+
import { FeedKey, IHaloStream, PartyKey, HaloStateSnapshot } from '@dxos/echo-protocol';
|
|
19
20
|
import { jsonReplacer } from '@dxos/util';
|
|
20
21
|
|
|
21
22
|
const log = debug('dxos:echo-db:party-processor');
|
|
22
23
|
|
|
24
|
+
export interface CredentialProcessor {
|
|
25
|
+
processMessage (message: IHaloStream): Promise<void>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface PartyStateProvider {
|
|
29
|
+
partyKey: PublicKey
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Whether PartyGenesis was already processed.
|
|
33
|
+
*/
|
|
34
|
+
genesisRequired: boolean
|
|
35
|
+
memberKeys: PublicKey[]
|
|
36
|
+
feedKeys: PublicKey[]
|
|
37
|
+
getFeedOwningMember (feedKey: FeedKey): PublicKey | undefined
|
|
38
|
+
isFeedAdmitted (feedKey: FeedKey): boolean
|
|
39
|
+
|
|
40
|
+
getOfflineInvitation (invitationID: Buffer): SignedMessage | undefined
|
|
41
|
+
}
|
|
42
|
+
|
|
23
43
|
/**
|
|
24
44
|
* TODO(burdon): Wrapper/Bridge between HALO APIs.
|
|
25
45
|
*/
|
|
26
|
-
export class PartyProcessor {
|
|
46
|
+
export class PartyProcessor implements CredentialProcessor, PartyStateProvider {
|
|
27
47
|
private readonly _state: PartyState;
|
|
28
48
|
|
|
29
|
-
private _outboundHaloStream: FeedWriter<HaloMessage> | undefined;
|
|
30
|
-
|
|
31
49
|
readonly feedAdded = new Event<FeedKey>()
|
|
32
50
|
|
|
33
51
|
public readonly keyOrInfoAdded = new Event<PublicKey>();
|
|
@@ -124,16 +142,6 @@ export class PartyProcessor {
|
|
|
124
142
|
await this._state.processMessages([data]);
|
|
125
143
|
}
|
|
126
144
|
|
|
127
|
-
setOutboundStream (stream: FeedWriter<HaloMessage>) {
|
|
128
|
-
this._outboundHaloStream = stream;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
async writeHaloMessage (message: HaloMessage): Promise<WriteReceipt> {
|
|
132
|
-
assert(this._outboundHaloStream, 'Party is closed or read-only');
|
|
133
|
-
// TODO(marik-d): Wait for the message to be processed?
|
|
134
|
-
return this._outboundHaloStream.write(message);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
145
|
makeSnapshot (): HaloStateSnapshot {
|
|
138
146
|
return {
|
|
139
147
|
messages: this._haloMessages
|
|
@@ -9,6 +9,4 @@ import { Replicator } from '@dxos/protocol-plugin-replicator';
|
|
|
9
9
|
/**
|
|
10
10
|
* Creates authenticator network-protocol plugin that guards access to the replicator.
|
|
11
11
|
*/
|
|
12
|
-
export
|
|
13
|
-
return new AuthPlugin(peerId.asBuffer(), authenticator, [Replicator.extension]);
|
|
14
|
-
}
|
|
12
|
+
export const createAuthPlugin = (authenticator: Authenticator, peerId: PublicKey) => new AuthPlugin(peerId.asBuffer(), authenticator, [Replicator.extension]);
|
|
@@ -6,7 +6,6 @@ import expect from 'expect';
|
|
|
6
6
|
import { it as test } from 'mocha';
|
|
7
7
|
|
|
8
8
|
import { createAuthMessage, createKeyAdmitMessage, createPartyGenesisMessage, Keyring, KeyType } from '@dxos/credentials';
|
|
9
|
-
import { MockFeedWriter } from '@dxos/echo-protocol';
|
|
10
9
|
|
|
11
10
|
import { PartyProcessor } from '../pipeline';
|
|
12
11
|
import { createAuthenticator } from './authenticator';
|
|
@@ -23,8 +22,6 @@ describe('authenticator', () => {
|
|
|
23
22
|
const signer = CredentialsSigner.createDirectDeviceSigner(keyring);
|
|
24
23
|
|
|
25
24
|
const partyProcessor = new PartyProcessor(partyKey.publicKey);
|
|
26
|
-
const feed = new MockFeedWriter();
|
|
27
|
-
partyProcessor.setOutboundStream(feed);
|
|
28
25
|
await partyProcessor.processMessage({
|
|
29
26
|
data: createPartyGenesisMessage(
|
|
30
27
|
keyring,
|
|
@@ -53,7 +50,7 @@ describe('authenticator', () => {
|
|
|
53
50
|
meta: {} as any
|
|
54
51
|
});
|
|
55
52
|
|
|
56
|
-
const authenticator = createAuthenticator(partyProcessor, signer);
|
|
53
|
+
const authenticator = createAuthenticator(partyProcessor, signer, null as any);
|
|
57
54
|
const credential = createAuthMessage(
|
|
58
55
|
keyring,
|
|
59
56
|
partyKey.publicKey,
|