Skip to main content

bitwarden_pm/
migrations.rs

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