@dxos/echo-db 2.33.5-dev.97a81dd0 → 2.33.5-dev.a55bfd40
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 +7 -6
- package/dist/src/halo/halo-factory.js.map +1 -1
- package/dist/src/halo/halo-party.d.ts +7 -6
- package/dist/src/halo/halo-party.d.ts.map +1 -1
- package/dist/src/halo/halo-party.js +13 -9
- 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/index.js +5 -1
- package/dist/src/halo/index.js.map +1 -1
- package/dist/src/halo/party-opener.d.ts.map +1 -1
- package/dist/src/halo/party-opener.js +3 -1
- 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 +1 -1
- 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 +2 -2
- package/dist/src/invitations/greeting-initiator.d.ts.map +1 -1
- package/dist/src/invitations/greeting-initiator.js +2 -1
- package/dist/src/invitations/greeting-initiator.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 +3 -2
- package/dist/src/invitations/greeting-responder.js.map +1 -1
- package/dist/src/invitations/halo-recovery-initiator.js +1 -1
- 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.js +1 -1
- 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 +4 -3
- package/dist/src/packlets/database/item-demuxer.d.ts.map +1 -0
- package/dist/src/{database → packlets/database}/item-demuxer.js +2 -3
- 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 +11 -10
- 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 +0 -0
- 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 +0 -0
- 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 +0 -0
- 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 +11 -9
- package/dist/src/parties/data-party.d.ts.map +1 -1
- package/dist/src/parties/data-party.js +31 -10
- package/dist/src/parties/data-party.js.map +1 -1
- package/dist/src/parties/data-party.test.js +37 -17
- 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 -4
- package/dist/src/parties/party-factory.d.ts.map +1 -1
- package/dist/src/parties/party-factory.js +25 -21
- 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 +8 -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} +8 -11
- package/dist/src/pipeline/feed-muxer.d.ts.map +1 -0
- package/dist/src/pipeline/{pipeline.js → feed-muxer.js} +34 -41
- 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 +1 -1
- package/dist/src/pipeline/message-selector.d.ts.map +1 -1
- package/dist/src/pipeline/message-selector.js +6 -5
- 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 -12
- package/dist/src/pipeline/party-pipeline.d.ts.map +1 -0
- package/dist/src/pipeline/{party-core.js → party-pipeline.js} +32 -36
- 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} +62 -45
- package/dist/src/pipeline/party-pipeline.test.js.map +1 -0
- package/dist/src/pipeline/party-processor.d.ts +3 -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/authenticator.d.ts +3 -3
- package/dist/src/protocol/authenticator.d.ts.map +1 -1
- package/dist/src/protocol/authenticator.js +2 -2
- 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/index.js +5 -1
- package/dist/src/protocol/index.js.map +1 -1
- 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.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/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/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 +10 -10
- package/src/halo/halo-party.ts +22 -15
- package/src/halo/halo.test.ts +4 -3
- package/src/halo/halo.ts +2 -2
- package/src/halo/party-opener.ts +3 -1
- package/src/halo/preferences.ts +3 -2
- package/src/index.ts +3 -2
- package/src/invitations/greeting-initiator.ts +5 -4
- package/src/invitations/greeting-responder.ts +7 -5
- package/src/invitations/halo-recovery-initiator.ts +1 -1
- package/src/invitations/invitation-descriptor.ts +1 -1
- package/src/invitations/invitation-factory.ts +8 -5
- package/src/invitations/offline-invitation-claimer.ts +1 -1
- 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 +8 -5
- package/src/{database → packlets/database}/item-manager.test.ts +0 -0
- package/src/{database → packlets/database}/item-manager.ts +3 -1
- 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 +0 -0
- package/src/{api → packlets/database}/selection/result.ts +0 -0
- package/src/{api → packlets/database}/selection/selection.test.ts +0 -0
- package/src/{api → packlets/database}/selection/selection.ts +0 -0
- 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 +53 -20
- package/src/parties/data-party.ts +40 -16
- package/src/parties/party-factory.ts +29 -27
- package/src/parties/party-manager.test.ts +24 -15
- package/src/parties/party-manager.ts +9 -6
- package/src/pipeline/{pipeline.test.ts → feed-muxer.test.ts} +23 -19
- package/src/pipeline/{pipeline.ts → feed-muxer.ts} +39 -51
- package/src/pipeline/index.ts +2 -2
- package/src/pipeline/message-selector.ts +7 -6
- 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} +64 -42
- package/src/pipeline/{party-core.ts → party-pipeline.ts} +59 -36
- package/src/pipeline/party-processor.ts +2 -18
- package/src/protocol/authenticator.test.ts +1 -4
- package/src/protocol/authenticator.ts +8 -4
- package/src/snapshots/snapshot-generator.ts +3 -3
- 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/testing-factories.ts +1 -1
- 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
|
@@ -10,7 +10,7 @@ import { failUndefined } from '@dxos/debug';
|
|
|
10
10
|
import { DataService } from '@dxos/echo-protocol';
|
|
11
11
|
import { Model } from '@dxos/model-factory';
|
|
12
12
|
|
|
13
|
-
import { Entity } from '
|
|
13
|
+
import { Entity } from './entity';
|
|
14
14
|
import { ItemManager } from './item-manager';
|
|
15
15
|
|
|
16
16
|
const log = debug('dxos:echo-db:data-mirror');
|
|
@@ -18,10 +18,11 @@ import {
|
|
|
18
18
|
SubscribeEntityStreamResponse
|
|
19
19
|
} from '@dxos/echo-protocol';
|
|
20
20
|
|
|
21
|
-
import { Item, Link } from '../api';
|
|
22
21
|
import { EntityNotFoundError } from '../errors';
|
|
22
|
+
import { Item } from './item';
|
|
23
23
|
import { ItemDemuxer } from './item-demuxer';
|
|
24
24
|
import { ItemManager } from './item-manager';
|
|
25
|
+
import { Link } from './link';
|
|
25
26
|
|
|
26
27
|
const log = debug('dxos:echo-db:data-service-host');
|
|
27
28
|
|
|
File without changes
|
|
@@ -10,7 +10,7 @@ import { ModelFactory } from '@dxos/model-factory';
|
|
|
10
10
|
|
|
11
11
|
import { DataMirror } from './data-mirror';
|
|
12
12
|
import { DataServiceHost } from './data-service-host';
|
|
13
|
-
import { ItemDemuxer, ItemDemuxerOptions } from './item-demuxer';
|
|
13
|
+
import { EchoProcessor, ItemDemuxer, ItemDemuxerOptions } from './item-demuxer';
|
|
14
14
|
import { ItemManager } from './item-manager';
|
|
15
15
|
|
|
16
16
|
const log = debug('dxos:echo-db:database-backend');
|
|
@@ -42,12 +42,11 @@ export interface DatabaseBackend {
|
|
|
42
42
|
* Write operations result in mutations being written to the outgoing stream.
|
|
43
43
|
*/
|
|
44
44
|
export class FeedDatabaseBackend implements DatabaseBackend {
|
|
45
|
-
private
|
|
45
|
+
private _echoProcessor!: EchoProcessor;
|
|
46
46
|
private _itemManager!: ItemManager;
|
|
47
47
|
private _itemDemuxer!: ItemDemuxer;
|
|
48
48
|
|
|
49
49
|
constructor (
|
|
50
|
-
private readonly _inboundStream: NodeJS.ReadableStream,
|
|
51
50
|
private readonly _outboundStream: FeedWriter<EchoEnvelope> | undefined,
|
|
52
51
|
private readonly _snapshot?: DatabaseSnapshot,
|
|
53
52
|
private readonly _options: ItemDemuxerOptions = {}
|
|
@@ -56,16 +55,18 @@ export class FeedDatabaseBackend implements DatabaseBackend {
|
|
|
56
55
|
async open (itemManager: ItemManager, modelFactory: ModelFactory) {
|
|
57
56
|
this._itemManager = itemManager;
|
|
58
57
|
this._itemDemuxer = new ItemDemuxer(itemManager, modelFactory, this._options);
|
|
59
|
-
this.
|
|
60
|
-
this._inboundStream.pipe(this._itemDemuxerInboundStream);
|
|
58
|
+
this._echoProcessor = this._itemDemuxer.open();
|
|
61
59
|
|
|
62
60
|
if (this._snapshot) {
|
|
63
61
|
await this._itemDemuxer.restoreFromSnapshot(this._snapshot);
|
|
64
62
|
}
|
|
65
63
|
}
|
|
66
64
|
|
|
65
|
+
get echoProcessor () {
|
|
66
|
+
return this._echoProcessor;
|
|
67
|
+
}
|
|
68
|
+
|
|
67
69
|
async close () {
|
|
68
|
-
this._inboundStream?.unpipe(this._itemDemuxerInboundStream);
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
get isReadOnly (): boolean {
|
|
@@ -10,9 +10,10 @@ import { ModelFactory, TestListModel } from '@dxos/model-factory';
|
|
|
10
10
|
import { ObjectModel } from '@dxos/object-model';
|
|
11
11
|
import { afterTest } from '@dxos/testutils';
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import { DataServiceHost } from './data-service-host';
|
|
14
14
|
import { Item } from './item';
|
|
15
15
|
import { ItemFilterDeleted } from './selection';
|
|
16
|
+
import { createInMemoryDatabase, createRemoteDatabaseFromDataServiceHost } from './testing';
|
|
16
17
|
|
|
17
18
|
const OBJECT_ORG = 'example:object/org';
|
|
18
19
|
const OBJECT_PERSON = 'example:object/person';
|
|
@@ -10,9 +10,11 @@ import { ItemID, ItemType } from '@dxos/echo-protocol';
|
|
|
10
10
|
import { Model, ModelConstructor, ModelFactory, validateModelClass } from '@dxos/model-factory';
|
|
11
11
|
import { ObjectModel } from '@dxos/object-model';
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import { DataServiceHost } from './data-service-host';
|
|
14
|
+
import { DatabaseBackend } from './database-backend';
|
|
14
15
|
import { Entity } from './entity';
|
|
15
16
|
import { Item } from './item';
|
|
17
|
+
import { ItemManager } from './item-manager';
|
|
16
18
|
import { Link } from './link';
|
|
17
19
|
import { RootFilter, Selection, createSelection } from './selection';
|
|
18
20
|
|
|
@@ -7,7 +7,7 @@ import { ItemID, ItemType } from '@dxos/echo-protocol';
|
|
|
7
7
|
import { Model, ModelMeta, StateManager } from '@dxos/model-factory';
|
|
8
8
|
import { SubscriptionGroup } from '@dxos/util';
|
|
9
9
|
|
|
10
|
-
import { ItemManager } from '
|
|
10
|
+
import { ItemManager } from './item-manager';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Base class for all ECHO entitities.
|
|
@@ -10,3 +10,8 @@ export * from './item-demuxer';
|
|
|
10
10
|
export * from './item-manager';
|
|
11
11
|
export * from './testing';
|
|
12
12
|
export * from './timeframe-clock';
|
|
13
|
+
export * from './item';
|
|
14
|
+
export * from './link';
|
|
15
|
+
export * from './entity';
|
|
16
|
+
export * from './selection';
|
|
17
|
+
export * from './database';
|
|
@@ -9,12 +9,11 @@ import { it as test } from 'mocha';
|
|
|
9
9
|
import { latch } from '@dxos/async';
|
|
10
10
|
import { createId, PublicKey } from '@dxos/crypto';
|
|
11
11
|
import { checkType } from '@dxos/debug';
|
|
12
|
-
import {
|
|
13
|
-
import { createTransform } from '@dxos/feed-store';
|
|
12
|
+
import { EchoEnvelope, MockFeedWriter, Timeframe } from '@dxos/echo-protocol';
|
|
14
13
|
import { ModelFactory, TestModel } from '@dxos/model-factory';
|
|
15
14
|
import { ObjectModel } from '@dxos/object-model';
|
|
16
15
|
|
|
17
|
-
import { Item } from '
|
|
16
|
+
import { Item } from './item';
|
|
18
17
|
import { ItemDemuxer } from './item-demuxer';
|
|
19
18
|
import { ItemManager } from './item-manager';
|
|
20
19
|
|
|
@@ -32,7 +31,7 @@ describe('Item demuxer', () => {
|
|
|
32
31
|
const itemDemuxer = new ItemDemuxer(itemManager, modelFactory);
|
|
33
32
|
|
|
34
33
|
const inboundStream = itemDemuxer.open();
|
|
35
|
-
feedWriter.written.on(([msg, meta]) => inboundStream
|
|
34
|
+
feedWriter.written.on(([msg, meta]) => inboundStream({
|
|
36
35
|
data: msg,
|
|
37
36
|
meta: { ...meta, memberKey }
|
|
38
37
|
} as any));
|
|
@@ -96,28 +95,31 @@ describe('Item demuxer', () => {
|
|
|
96
95
|
const modelFactory = new ModelFactory()
|
|
97
96
|
.registerModel(ObjectModel);
|
|
98
97
|
|
|
99
|
-
const
|
|
100
|
-
async (message
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
timeframe: new Timeframe()
|
|
106
|
-
},
|
|
107
|
-
data: message
|
|
108
|
-
})
|
|
109
|
-
);
|
|
110
|
-
const itemManager = new ItemManager(modelFactory, PublicKey.random(), createMockFeedWriterFromStream(writeStream));
|
|
98
|
+
const itemManager = new ItemManager(modelFactory, PublicKey.random(), {
|
|
99
|
+
write: async (message) => {
|
|
100
|
+
void processEchoMessage(message);
|
|
101
|
+
return { feedKey: PublicKey.random(), seq: 0 };
|
|
102
|
+
}
|
|
103
|
+
});
|
|
111
104
|
const itemDemuxer = new ItemDemuxer(itemManager, modelFactory);
|
|
112
|
-
|
|
105
|
+
const processor = itemDemuxer.open();
|
|
106
|
+
const processEchoMessage = (message: EchoEnvelope) => processor({
|
|
107
|
+
meta: {
|
|
108
|
+
feedKey: PublicKey.random(),
|
|
109
|
+
memberKey: PublicKey.random(),
|
|
110
|
+
seq: 0,
|
|
111
|
+
timeframe: new Timeframe()
|
|
112
|
+
},
|
|
113
|
+
data: message
|
|
114
|
+
});
|
|
113
115
|
|
|
114
|
-
|
|
116
|
+
void processEchoMessage(checkType<EchoEnvelope>({
|
|
115
117
|
itemId: 'foo',
|
|
116
118
|
genesis: {
|
|
117
119
|
modelType: TestModel.meta.type
|
|
118
120
|
}
|
|
119
121
|
}));
|
|
120
|
-
|
|
122
|
+
void processEchoMessage(checkType<EchoEnvelope>({
|
|
121
123
|
itemId: 'bar',
|
|
122
124
|
genesis: {
|
|
123
125
|
modelType: ObjectModel.meta.type
|
|
@@ -8,11 +8,12 @@ import debug from 'debug';
|
|
|
8
8
|
import { Event } from '@dxos/async';
|
|
9
9
|
import { failUndefined } from '@dxos/debug';
|
|
10
10
|
import { DatabaseSnapshot, IEchoStream, ItemID, ItemSnapshot, LinkSnapshot } from '@dxos/echo-protocol';
|
|
11
|
-
import { createWritable } from '@dxos/feed-store';
|
|
12
11
|
import { Model, ModelFactory, ModelMessage } from '@dxos/model-factory';
|
|
13
12
|
|
|
14
|
-
import { Entity
|
|
13
|
+
import { Entity } from './entity';
|
|
14
|
+
import { Item } from './item';
|
|
15
15
|
import { ItemManager, ModelConstructionOptions } from './item-manager';
|
|
16
|
+
import { Link } from './link';
|
|
16
17
|
|
|
17
18
|
const log = debug('dxos:echo-db:item-demuxer');
|
|
18
19
|
|
|
@@ -20,6 +21,8 @@ export interface ItemDemuxerOptions {
|
|
|
20
21
|
snapshots?: boolean
|
|
21
22
|
}
|
|
22
23
|
|
|
24
|
+
export type EchoProcessor = (message: IEchoStream) => Promise<void>
|
|
25
|
+
|
|
23
26
|
/**
|
|
24
27
|
* Creates a stream that consumes `IEchoStream` messages and routes them to the associated items.
|
|
25
28
|
* @param itemManager
|
|
@@ -33,7 +36,7 @@ export class ItemDemuxer {
|
|
|
33
36
|
private readonly _options: ItemDemuxerOptions = {}
|
|
34
37
|
) {}
|
|
35
38
|
|
|
36
|
-
open ():
|
|
39
|
+
open (): EchoProcessor {
|
|
37
40
|
this._modelFactory.registered.on(async model => {
|
|
38
41
|
for (const item of this._itemManager.getUninitializedEntities()) {
|
|
39
42
|
if (item._stateManager.modelType === model.meta.type) {
|
|
@@ -44,7 +47,7 @@ export class ItemDemuxer {
|
|
|
44
47
|
|
|
45
48
|
// TODO(burdon): Factor out.
|
|
46
49
|
// TODO(burdon): Should this implement some "back-pressure" (hints) to the PartyProcessor?
|
|
47
|
-
return
|
|
50
|
+
return async (message: IEchoStream) => {
|
|
48
51
|
const { data: { itemId, genesis, itemMutation, mutation, snapshot }, meta } = message;
|
|
49
52
|
assert(itemId);
|
|
50
53
|
|
|
@@ -109,7 +112,7 @@ export class ItemDemuxer {
|
|
|
109
112
|
}
|
|
110
113
|
|
|
111
114
|
this.mutation.emit(message);
|
|
112
|
-
}
|
|
115
|
+
};
|
|
113
116
|
}
|
|
114
117
|
|
|
115
118
|
createSnapshot (): DatabaseSnapshot {
|
|
File without changes
|
|
@@ -11,8 +11,10 @@ import { timed } from '@dxos/debug';
|
|
|
11
11
|
import { EchoEnvelope, FeedWriter, ItemID, ItemType, mapFeedWriter, ModelSnapshot } from '@dxos/echo-protocol';
|
|
12
12
|
import { Model, ModelFactory, ModelMessage, ModelType, StateManager } from '@dxos/model-factory';
|
|
13
13
|
|
|
14
|
-
import { Entity, Item, Link } from '../api';
|
|
15
14
|
import { UnknownModelError } from '../errors';
|
|
15
|
+
import { Entity } from './entity';
|
|
16
|
+
import { Item } from './item';
|
|
17
|
+
import { Link } from './link';
|
|
16
18
|
|
|
17
19
|
const log = debug('dxos:echo-db:item-manager');
|
|
18
20
|
|
|
@@ -7,10 +7,10 @@ import debug from 'debug';
|
|
|
7
7
|
import { EchoEnvelope, ItemID, ItemMutation, ItemType, FeedWriter } from '@dxos/echo-protocol';
|
|
8
8
|
import { Model, StateManager } from '@dxos/model-factory';
|
|
9
9
|
|
|
10
|
-
import { ItemManager } from '../database';
|
|
11
10
|
import { Entity } from './entity';
|
|
11
|
+
import { ItemManager } from './item-manager';
|
|
12
12
|
import type { Link } from './link';
|
|
13
|
-
import {
|
|
13
|
+
import { createItemSelection, Selection } from './selection';
|
|
14
14
|
|
|
15
15
|
const log = debug('dxos:echo-db:item');
|
|
16
16
|
|
|
@@ -7,9 +7,9 @@ import assert from 'assert';
|
|
|
7
7
|
import { ItemID, ItemType } from '@dxos/echo-protocol';
|
|
8
8
|
import { Model, StateManager } from '@dxos/model-factory';
|
|
9
9
|
|
|
10
|
-
import { ItemManager } from '../database';
|
|
11
10
|
import { Entity } from './entity';
|
|
12
11
|
import { Item } from './item';
|
|
12
|
+
import { ItemManager } from './item-manager';
|
|
13
13
|
|
|
14
14
|
export interface LinkData {
|
|
15
15
|
sourceId: ItemID
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -2,25 +2,22 @@
|
|
|
2
2
|
// Copyright 2021 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Readable } from 'stream';
|
|
6
|
-
|
|
7
5
|
import { PublicKey } from '@dxos/crypto';
|
|
8
6
|
import { EchoEnvelope, MockFeedWriter, Timeframe } from '@dxos/echo-protocol';
|
|
9
7
|
import { ModelFactory } from '@dxos/model-factory';
|
|
10
8
|
|
|
11
|
-
import { Database } from '../api';
|
|
12
9
|
import { DataServiceHost } from './data-service-host';
|
|
13
10
|
import { DataServiceRouter } from './data-service-router';
|
|
11
|
+
import { Database } from './database';
|
|
14
12
|
import { FeedDatabaseBackend, RemoteDatabaseBackend } from './database-backend';
|
|
15
13
|
|
|
16
14
|
export const createInMemoryDatabase = async (modelFactory: ModelFactory) => {
|
|
17
15
|
const feed = new MockFeedWriter<EchoEnvelope>();
|
|
18
|
-
const
|
|
19
|
-
feed.written.on(([data, meta]) =>
|
|
20
|
-
|
|
16
|
+
const backend = new FeedDatabaseBackend(feed, undefined, { snapshots: true });
|
|
17
|
+
feed.written.on(([data, meta]) => backend.echoProcessor({ data, meta: { ...meta, memberKey: PublicKey.random(), timeframe: new Timeframe([[meta.feedKey, meta.seq]]) } }));
|
|
21
18
|
const database = new Database(
|
|
22
19
|
modelFactory,
|
|
23
|
-
|
|
20
|
+
backend,
|
|
24
21
|
PublicKey.random()
|
|
25
22
|
);
|
|
26
23
|
|
|
@@ -28,4 +28,8 @@ export class TimeframeClock {
|
|
|
28
28
|
const gaps = Timeframe.dependencies(timeframe, this._timeframe);
|
|
29
29
|
return !gaps.isEmpty();
|
|
30
30
|
}
|
|
31
|
+
|
|
32
|
+
async waitUntilReached (target: Timeframe) {
|
|
33
|
+
await this.update.waitForCondition(() => Timeframe.dependencies(target, this._timeframe).isEmpty());
|
|
34
|
+
}
|
|
31
35
|
}
|
|
File without changes
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import expect from 'expect';
|
|
6
6
|
import { it as test } from 'mocha';
|
|
7
7
|
|
|
8
|
-
import { createKeyAdmitMessage, createPartyGenesisMessage, defaultSecretProvider,
|
|
8
|
+
import { createKeyAdmitMessage, createPartyGenesisMessage, defaultSecretProvider, Keyring, KeyType, codec as haloCodec } from '@dxos/credentials';
|
|
9
9
|
import { PublicKey } from '@dxos/crypto';
|
|
10
10
|
import { codec } from '@dxos/echo-protocol';
|
|
11
11
|
import { FeedStore } from '@dxos/feed-store';
|
|
@@ -22,24 +22,29 @@ import { SnapshotStore } from '../snapshots';
|
|
|
22
22
|
import { DataParty } from './data-party';
|
|
23
23
|
|
|
24
24
|
describe('DataParty', () => {
|
|
25
|
-
const createParty = async (identity: IdentityCredentials, partyKey: PublicKey,
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
const snapshotStore = new SnapshotStore(
|
|
25
|
+
const createParty = async (identity: IdentityCredentials, partyKey: PublicKey, feedHints: PublicKey[]) => {
|
|
26
|
+
|
|
27
|
+
const storage = createStorage('', StorageType.RAM);
|
|
28
|
+
const snapshotStore = new SnapshotStore(storage.directory('snapshots'));
|
|
29
|
+
const metadataStore = new MetadataStore(storage.directory('metadata'));
|
|
30
|
+
const feedStore = new FeedStore(storage.directory('feed'), { valueEncoding: codec });
|
|
29
31
|
const modelFactory = new ModelFactory().registerModel(ObjectModel);
|
|
30
32
|
const networkManager = new NetworkManager();
|
|
31
33
|
const partyFeedProvider = new PartyFeedProvider(metadataStore, identity.keyring, feedStore, partyKey);
|
|
34
|
+
const writableFeed = await partyFeedProvider.createOrOpenWritableFeed();
|
|
32
35
|
|
|
33
|
-
|
|
36
|
+
const party = new DataParty(
|
|
34
37
|
partyKey,
|
|
35
38
|
modelFactory,
|
|
36
39
|
snapshotStore,
|
|
37
40
|
partyFeedProvider,
|
|
41
|
+
metadataStore,
|
|
38
42
|
identity.createCredentialsSigner(),
|
|
39
43
|
identity.preferences,
|
|
40
|
-
networkManager
|
|
41
|
-
hints
|
|
44
|
+
networkManager
|
|
42
45
|
);
|
|
46
|
+
party._setFeedHints([...feedHints, writableFeed.key]);
|
|
47
|
+
return party;
|
|
43
48
|
};
|
|
44
49
|
|
|
45
50
|
test('open & close', async () => {
|
|
@@ -60,7 +65,7 @@ describe('DataParty', () => {
|
|
|
60
65
|
await party.open();
|
|
61
66
|
|
|
62
67
|
const feed = await party.getWriteFeed();
|
|
63
|
-
await party.
|
|
68
|
+
await party.credentialsWriter.write(createPartyGenesisMessage(
|
|
64
69
|
keyring,
|
|
65
70
|
partyKey,
|
|
66
71
|
feed.key,
|
|
@@ -72,6 +77,33 @@ describe('DataParty', () => {
|
|
|
72
77
|
await party.close();
|
|
73
78
|
});
|
|
74
79
|
|
|
80
|
+
test('data is immediately available after re-opening', async () => {
|
|
81
|
+
const keyring = new Keyring();
|
|
82
|
+
const identity = await createTestIdentityCredentials(keyring);
|
|
83
|
+
const partyKey = await keyring.createKeyRecord({ type: KeyType.PARTY });
|
|
84
|
+
const party = await createParty(identity, partyKey.publicKey, []);
|
|
85
|
+
await party.open();
|
|
86
|
+
|
|
87
|
+
const feed = await party.getWriteFeed();
|
|
88
|
+
await party.credentialsWriter.write(createPartyGenesisMessage(
|
|
89
|
+
keyring,
|
|
90
|
+
partyKey,
|
|
91
|
+
feed.key,
|
|
92
|
+
partyKey
|
|
93
|
+
));
|
|
94
|
+
|
|
95
|
+
for (let i = 0; i < 10; i++) {
|
|
96
|
+
await party.database.createItem({ type: 'test:item' });
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
await party.close();
|
|
100
|
+
await party.open();
|
|
101
|
+
|
|
102
|
+
expect(party.database.select({ type: 'test:item' }).exec().entities).toHaveLength(10);
|
|
103
|
+
|
|
104
|
+
await party.close();
|
|
105
|
+
});
|
|
106
|
+
|
|
75
107
|
test('authenticates its own credentials', async () => {
|
|
76
108
|
const keyring = new Keyring();
|
|
77
109
|
const identity = await createTestIdentityCredentials(keyring);
|
|
@@ -80,14 +112,15 @@ describe('DataParty', () => {
|
|
|
80
112
|
const party = await createParty(identity, partyKey.publicKey, []);
|
|
81
113
|
await party.open();
|
|
82
114
|
const feed = await party.getWriteFeed();
|
|
83
|
-
await party.
|
|
115
|
+
await party.credentialsWriter.write(createPartyGenesisMessage(
|
|
84
116
|
keyring,
|
|
85
117
|
partyKey,
|
|
86
118
|
feed.key,
|
|
87
119
|
partyKey
|
|
88
120
|
));
|
|
121
|
+
await party.processor.feedAdded.waitForCount(1);
|
|
89
122
|
|
|
90
|
-
const authenticator = createAuthenticator(party.processor, identity.createCredentialsSigner());
|
|
123
|
+
const authenticator = createAuthenticator(party.processor, identity.createCredentialsSigner(), party.credentialsWriter);
|
|
91
124
|
const credentialsProvider = createCredentialsProvider(identity.createCredentialsSigner(), party.key, feed.key);
|
|
92
125
|
|
|
93
126
|
const wrappedCredentials = haloCodec.decode(credentialsProvider.get());
|
|
@@ -104,13 +137,15 @@ describe('DataParty', () => {
|
|
|
104
137
|
const party = await createParty(identityA, partyKey.publicKey, []);
|
|
105
138
|
await party.open();
|
|
106
139
|
const feed = await party.getWriteFeed();
|
|
107
|
-
await party.
|
|
140
|
+
await party.credentialsWriter.write(createPartyGenesisMessage(
|
|
108
141
|
keyring,
|
|
109
142
|
partyKey,
|
|
110
143
|
feed.key,
|
|
111
144
|
partyKey
|
|
112
145
|
));
|
|
113
|
-
|
|
146
|
+
await party.processor.feedAdded.waitForCount(1);
|
|
147
|
+
|
|
148
|
+
const authenticator = createAuthenticator(party.processor, identityA.createCredentialsSigner(), party.credentialsWriter);
|
|
114
149
|
|
|
115
150
|
const identityB = await deriveTestDeviceCredentials(identityA);
|
|
116
151
|
const credentialsProvider = createCredentialsProvider(identityB.createCredentialsSigner(), party.key, feed.key);
|
|
@@ -129,13 +164,13 @@ describe('DataParty', () => {
|
|
|
129
164
|
const partyA = await createParty(identityA, partyKey.publicKey, []);
|
|
130
165
|
await partyA.open();
|
|
131
166
|
const feedA = await partyA.getWriteFeed();
|
|
132
|
-
await partyA.
|
|
167
|
+
await partyA.credentialsWriter.write(createPartyGenesisMessage(
|
|
133
168
|
keyring,
|
|
134
169
|
partyKey,
|
|
135
170
|
feedA.key,
|
|
136
171
|
partyKey
|
|
137
172
|
));
|
|
138
|
-
await partyA.
|
|
173
|
+
await partyA.credentialsWriter.write(createKeyAdmitMessage(
|
|
139
174
|
keyring,
|
|
140
175
|
partyKey.publicKey,
|
|
141
176
|
identityA.identityKey,
|
|
@@ -143,9 +178,7 @@ describe('DataParty', () => {
|
|
|
143
178
|
));
|
|
144
179
|
|
|
145
180
|
const identityB = await deriveTestDeviceCredentials(identityA);
|
|
146
|
-
const partyB = await createParty(identityB, partyKey.publicKey, [
|
|
147
|
-
{ type: KeyType.FEED, publicKey: feedA.key }
|
|
148
|
-
]);
|
|
181
|
+
const partyB = await createParty(identityB, partyKey.publicKey, [feedA.key]);
|
|
149
182
|
await partyB.open();
|
|
150
183
|
|
|
151
184
|
await partyA.database.createItem({ type: 'test:item-a' });
|
|
@@ -165,13 +198,13 @@ describe('DataParty', () => {
|
|
|
165
198
|
const partyA = await createParty(identityA, partyKeyA.publicKey, []);
|
|
166
199
|
await partyA.open();
|
|
167
200
|
const feedA = await partyA.getWriteFeed();
|
|
168
|
-
await partyA.
|
|
201
|
+
await partyA.credentialsWriter.write(createPartyGenesisMessage(
|
|
169
202
|
identityA.keyring,
|
|
170
203
|
partyKeyA,
|
|
171
204
|
feedA.key,
|
|
172
205
|
partyKeyA
|
|
173
206
|
));
|
|
174
|
-
await partyA.
|
|
207
|
+
await partyA.credentialsWriter.write(createKeyAdmitMessage(
|
|
175
208
|
identityA.keyring,
|
|
176
209
|
partyKeyA.publicKey,
|
|
177
210
|
identityA.identityKey,
|
|
@@ -5,19 +5,19 @@
|
|
|
5
5
|
import assert from 'assert';
|
|
6
6
|
|
|
7
7
|
import { synchronized, Event } from '@dxos/async';
|
|
8
|
-
import { KeyHint, Message as HaloMessage } from '@dxos/credentials';
|
|
9
8
|
import { PublicKey } from '@dxos/crypto';
|
|
10
9
|
import { timed } from '@dxos/debug';
|
|
11
|
-
import { PartyKey, PartySnapshot, Timeframe
|
|
10
|
+
import { PartyKey, PartySnapshot, Timeframe } from '@dxos/echo-protocol';
|
|
12
11
|
import { FeedDescriptor } from '@dxos/feed-store';
|
|
13
12
|
import { ModelFactory } from '@dxos/model-factory';
|
|
14
13
|
import { NetworkManager } from '@dxos/network-manager';
|
|
15
14
|
import { ObjectModel } from '@dxos/object-model';
|
|
16
15
|
|
|
17
|
-
import {
|
|
16
|
+
import { ResultSet } from '../api';
|
|
18
17
|
import { ActivationOptions, PartyPreferences, Preferences } from '../halo';
|
|
19
18
|
import { InvitationFactory } from '../invitations';
|
|
20
|
-
import {
|
|
19
|
+
import { Database, Item } from '../packlets/database';
|
|
20
|
+
import { PartyFeedProvider, PartyProtocolFactory, PartyPipeline, PipelineOptions, MetadataStore } from '../pipeline';
|
|
21
21
|
import { createAuthPlugin, createOfflineInvitationPlugin, createAuthenticator, createCredentialsProvider } from '../protocol';
|
|
22
22
|
import { CredentialsSigner } from '../protocol/credentials-signer';
|
|
23
23
|
import { createReplicatorPlugin } from '../protocol/replicator-plugin';
|
|
@@ -42,31 +42,31 @@ export interface PartyMember {
|
|
|
42
42
|
export class DataParty {
|
|
43
43
|
public readonly update = new Event<void>();
|
|
44
44
|
|
|
45
|
-
private readonly _partyCore:
|
|
45
|
+
private readonly _partyCore: PartyPipeline;
|
|
46
46
|
private readonly _preferences?: PartyPreferences;
|
|
47
47
|
private _invitationManager?: InvitationFactory;
|
|
48
48
|
private _protocol?: PartyProtocolFactory;
|
|
49
|
+
private _feedHints: PublicKey[] = []
|
|
49
50
|
|
|
50
51
|
constructor (
|
|
51
52
|
partyKey: PartyKey,
|
|
52
53
|
modelFactory: ModelFactory,
|
|
53
54
|
snapshotStore: SnapshotStore,
|
|
54
55
|
private readonly _feedProvider: PartyFeedProvider,
|
|
56
|
+
private readonly _metadataStore: MetadataStore,
|
|
55
57
|
private readonly _credentialsSigner: CredentialsSigner,
|
|
56
58
|
// TODO(dmaretskyi): Pull this out to a higher level. Should preferences be part of client API instead?
|
|
57
59
|
private readonly _profilePreferences: Preferences | undefined,
|
|
58
60
|
private readonly _networkManager: NetworkManager,
|
|
59
|
-
private readonly
|
|
60
|
-
|
|
61
|
-
_options: PartyOptions = {}
|
|
61
|
+
private readonly _initialTimeframe?: Timeframe,
|
|
62
|
+
_options: PipelineOptions = {}
|
|
62
63
|
) {
|
|
63
|
-
this._partyCore = new
|
|
64
|
+
this._partyCore = new PartyPipeline(
|
|
64
65
|
partyKey,
|
|
65
66
|
_feedProvider,
|
|
66
67
|
modelFactory,
|
|
67
68
|
snapshotStore,
|
|
68
69
|
this._credentialsSigner.getIdentityKey().publicKey,
|
|
69
|
-
_initialTimeframe,
|
|
70
70
|
_options
|
|
71
71
|
);
|
|
72
72
|
|
|
@@ -127,6 +127,10 @@ export class DataParty {
|
|
|
127
127
|
return this._invitationManager;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
+
get credentialsWriter () {
|
|
131
|
+
return this._partyCore.credentialsWriter;
|
|
132
|
+
}
|
|
133
|
+
|
|
130
134
|
get title () {
|
|
131
135
|
return this._preferences?.getLastKnownTitle();
|
|
132
136
|
}
|
|
@@ -137,6 +141,13 @@ export class DataParty {
|
|
|
137
141
|
await this._preferences?.setLastKnownTitle(title);
|
|
138
142
|
}
|
|
139
143
|
|
|
144
|
+
/**
|
|
145
|
+
* @internal
|
|
146
|
+
*/
|
|
147
|
+
_setFeedHints (feedHints: PublicKey[]) {
|
|
148
|
+
this._feedHints = feedHints;
|
|
149
|
+
}
|
|
150
|
+
|
|
140
151
|
/**
|
|
141
152
|
* Opens the pipeline and connects the streams.
|
|
142
153
|
*/
|
|
@@ -147,11 +158,25 @@ export class DataParty {
|
|
|
147
158
|
return this;
|
|
148
159
|
}
|
|
149
160
|
|
|
150
|
-
|
|
161
|
+
// TODO(dmaretskyi): May be undefined in some tests.
|
|
162
|
+
const party = this._metadataStore.getParty(this._partyCore.key);
|
|
163
|
+
|
|
164
|
+
await this._partyCore.open({
|
|
165
|
+
feedHints: this._feedHints,
|
|
166
|
+
initialTimeframe: this._initialTimeframe,
|
|
167
|
+
targetTimeframe: party?.latestTimeframe
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
// Keep updating latest reached timeframe in the metadata.
|
|
171
|
+
// This timeframe will be waited for when opening the party next time.
|
|
172
|
+
this._partyCore.timeframeUpdate.on(timeframe => {
|
|
173
|
+
void this._metadataStore.setTimeframe(this._partyCore.key, timeframe);
|
|
174
|
+
});
|
|
151
175
|
|
|
152
176
|
this._invitationManager = new InvitationFactory(
|
|
153
177
|
this._partyCore.processor,
|
|
154
178
|
this._credentialsSigner,
|
|
179
|
+
this._partyCore.credentialsWriter,
|
|
155
180
|
this._networkManager
|
|
156
181
|
);
|
|
157
182
|
|
|
@@ -171,7 +196,7 @@ export class DataParty {
|
|
|
171
196
|
|
|
172
197
|
await this._protocol.start([
|
|
173
198
|
createReplicatorPlugin(this._feedProvider),
|
|
174
|
-
createAuthPlugin(createAuthenticator(this._partyCore.processor, this._credentialsSigner), deviceKey.publicKey),
|
|
199
|
+
createAuthPlugin(createAuthenticator(this._partyCore.processor, this._credentialsSigner, this.credentialsWriter), deviceKey.publicKey),
|
|
175
200
|
createOfflineInvitationPlugin(this._invitationManager, deviceKey.publicKey)
|
|
176
201
|
]);
|
|
177
202
|
|
|
@@ -191,6 +216,9 @@ export class DataParty {
|
|
|
191
216
|
return this;
|
|
192
217
|
}
|
|
193
218
|
|
|
219
|
+
// Save the latest reached timeframe.
|
|
220
|
+
await this._metadataStore.setTimeframe(this._partyCore.key, this._partyCore.timeframe);
|
|
221
|
+
|
|
194
222
|
await this._partyCore.close();
|
|
195
223
|
await this._protocol?.stop();
|
|
196
224
|
|
|
@@ -210,10 +238,6 @@ export class DataParty {
|
|
|
210
238
|
return this._feedProvider.getFeeds();
|
|
211
239
|
}
|
|
212
240
|
|
|
213
|
-
writeCredentialsMessage (message: HaloMessage): Promise<WriteReceipt> {
|
|
214
|
-
return this._partyCore.writeCredentialsMessage(message);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
241
|
get isActive (): boolean {
|
|
218
242
|
assert(this._preferences, 'PartyActivator required');
|
|
219
243
|
return this._preferences.isActive;
|