bitwarden_pm/migrations.rs
1//! Manages repository migrations for the Bitwarden SDK.
2
3use bitwarden_state::{
4 SettingItem,
5 repository::{RepositoryItem, RepositoryMigrationStep, RepositoryMigrations},
6};
7use bitwarden_vault::{Cipher, Folder};
8
9/// Returns a list of all SDK-managed repository migrations.
10pub fn get_sdk_managed_migrations() -> RepositoryMigrations {
11 use RepositoryMigrationStep::*;
12 RepositoryMigrations::new(vec![
13 // Add any new migrations here. Note that order matters, and that removing a repository
14 // requires a separate migration step using `Remove(...)`.
15 Add(Cipher::data()),
16 Add(Folder::data()),
17 Add(SettingItem::data()),
18 ])
19}
20
21/// Macro to create the client managed repositories for the SDK.
22/// To add a new repository, add it to the list in the macro invocation.
23/// This is meant to be used by the final application crates (e.g., bitwarden-uniffi,
24/// bitwarden-wasm-internal, bw).
25#[macro_export]
26macro_rules! create_client_managed_repositories {
27 ($container_name:ident, $macro:ident) => {
28 $macro! {
29 $container_name;
30 // List any SDK-managed repositories here. The format is:
31 // <fully qualified path to the item>, <item type idenfier>, <field name>, <name of the repository implementation>
32 ::bitwarden_vault::Cipher, Cipher, cipher, CipherRepository;
33 ::bitwarden_vault::Folder, Folder, folder, FolderRepository;
34 }
35 };
36}