Remove adapter-specific message types from automerge-repo #214
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
automerge-repo
currently exposes two union types for messages:RepoMessage
includes all message types that a network adapter emits to theRepo
.Message
includes all of these plusArriveMessage
andWelcomeMessage
, which are message types used by some network adapters but not others.In anticipation of the AuthProvider work, I'm introducing an
AuthMessage
type, which doesn't fit into either of these categories: It's notMessage
, because all network adapters need to be able to handle it, not just the ones that havearrive
andwelcome
; and it's not aRepoMessage
because it's not surfaced to theRepo
.The abstract
NetworkAdapter
needs a message type thatautomerge-repo
expects every adapter implementation to accept, and that should beMessage
.This PR removes
arrive
andwelcome
messages fromautomerge-repo
, leaving it entirely up to each network adapter what kind of internal messages to use. That means that we have some duplicate type definitions betweenMessageChannelNetworkAdapter
andBroadcastChannelNetworkAdapter
but that's OK.Message
is redefined asRepoMessage | AuthMessage
, and each adapter extends that type with its own internal message types.