TBD54566975 / dwn-sdk-js

Decentralized Web Node (DWN) Reference implementation
https://identity.foundation/decentralized-web-node/spec/
Apache License 2.0
324 stars 95 forks source link

EventsQuery by protocol #762

Closed LiranCohen closed 2 months ago

LiranCohen commented 2 months ago

This PR is to implement a protocol filter for the EventsQuery interface which accounts for receiving permission messages scoped to the filtered protocol via tag filters, as well as other messages directly indexed to the protocol.

It also resolves this issue https://github.com/TBD54566975/dwn-sdk-js/issues/663, which simplifies the type of filters EventsQuery implements to reduce complexity of which messages may or may not be returned with the filter.

Since EventsQuery is being used for sync/selective sync, the protocol filter is most important, if further filters are needed down the line, we will implement them according to scenarios put in place so we can make sure the correct messages arrive with the query results.

The Additional filters I left are for interface, method and messageTimestamp which are compatible with all types of messages.

NOTE: I cleaned up something I didn't like with EventsQuery from the prior PR instead of the message descriptor having an undefined filter, it is forced to have an empty filters array.

NOTE2: EventsSubscribe does not yet handle filtering for protocols which include the permissions messages, that will be done in a separate PR.

codecov-commenter commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 98.64%. Comparing base (8446cdb) to head (7e44b50).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #762 +/- ## ======================================= Coverage 98.64% 98.64% ======================================= Files 71 71 Lines 10893 10899 +6 Branches 1577 1564 -13 ======================================= + Hits 10745 10751 +6 Misses 142 142 Partials 6 6 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

LiranCohen commented 2 months ago

@thehenrytsai addressed the review comments, and also created and added a reference to this issue: https://github.com/TBD54566975/dwn-sdk-js/issues/768 for indexing RecordsDelete messages associated with permission requests/grants/revocations.