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