-
Notifications
You must be signed in to change notification settings - Fork 20
[PM-22591] Unify client repository initialization #484
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Great job! No new security vulnerabilities introduced in this pull request |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #484 +/- ##
==========================================
- Coverage 78.04% 77.98% -0.06%
==========================================
Files 287 287
Lines 27651 27672 +21
==========================================
Hits 21579 21579
- Misses 6072 6093 +21 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
```rust | ||
macro_rules! create_client_managed_repositories { | ||
($container_name:ident, $macro:ident) => { | ||
$macro! { | ||
$container_name; | ||
// List any SDK-managed repositories here. The format is: | ||
// <fully qualified path to the item>, <item type idenfier>, <field name>, <name of the repository implementation> | ||
::bitwarden_vault::Cipher, Cipher, cipher, CipherRepository; | ||
::bitwarden_vault::Folder, Folder, folder, FolderRepository; | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
praise: Nice idea! Using macros do define the repositories in a place where we're not actually able to depend on them 👍
|
…client repository initialization (bitwarden/sdk-internal#484)
🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-22591
📔 Objective
Currently, all app crates (wasm, uniffi) need to declare all the client managed repositories that they allow clients to implement. This means that all the crates need to be updated when adding more repositories, which adds more steps to implementations and can lead to things being out of sync. This PR unifies the declaration of client managed repositories so that there's only one place where they are defined.
While I was at it, I've changed slightly the way we register the repositories. Rather than provide one function for each (
register_cipher_repository
/register_folder_repository
) I provide a single function that takes an object that contains all the repos. This is easier to generate and should make it easier to know if any of the repos are missing (you should get a compile error). I left the previous ones for backwards-compatSadly both wasm and uniffi have a lot of compile time type shenanigans and macros which don't make this easy, so this solution contains multiple parts:
bitwarden_wasm
andbitwarden_uniffi
we already have a macro that creates the repository implementations based on a type. This has been expanded to take multiple types and also create theRepositories
struct which is just a grouping of all of them. Now, instead of manually calling these macros manually for each type, they instead get passed to thebitwarden_pm::create_client_managed_repositories!
macro.bitwarden_pm::create_client_managed_repositories!
macro's only purpose is to call the passed macro repeatedly with all the types that need to be created. This is the only way I found to lazily define the types inbitwarden-pm
so that they would be usable in macros in the other crates. The definition is fairly repetitive with the types, because we don't have easy ways to change the case of identifiers or merge them together. We could use thepaste
crate to avoid the repetition but didn't seem worth it at the momentNote that in the past we placed the sdk-managed definitions in a shared
bitwarden-state-migrations
crate, but now that we have the newbitwarden-pm
crate as a shared crate focused on password manager functionality I don't thinkbitwarden-state-migrations
is needed. Instead this PR moves the sdk-managed definitions tobitwarden-pm
(next to the new client managed repositories macro) and deletes thebitwarden-state-migrations
crate.⏰ Reminders before review
team
🦮 Reviewer guidelines
:+1:
) or similar for great changes:memo:
) or ℹ️ (:information_source:
) for notes or general info:question:
) for questions:thinking:
) or 💭 (:thought_balloon:
) for more open inquiry that's not quite a confirmedissue and could potentially benefit from discussion
:art:
) for suggestions / improvements:x:
) or:warning:
) for more significant problems or concerns needing attention:seedling:
) or ♻️ (:recycle:
) for future improvements or indications of technical debt:pick:
) for minor or nitpick changes