Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Update camelcase notation formatting (#2159)

Leendert de Borst13f441b2353b
diff --git a/apps/browser-extension/src/utils/RustCore.ts b/apps/browser-extension/src/utils/RustCore.ts
index db2d09f18..5877d1fd0 100644
--- a/apps/browser-extension/src/utils/RustCore.ts
+++ b/apps/browser-extension/src/utils/RustCore.ts
@@ -398,6 +398,39 @@ export async function vaultCodecMaterializeAsSqlite(
return core.vaultCodecMaterializeAsSqlite({ manifests, dataBuckets, schemaColumns }) as CodecMaterialized;
}
+/** Input of the canonical merge: server side is the base, local side the incoming changes. */
+export type CodecCanonicalMergeInput = {
+ serverManifests: CodecManifest[];
+ serverBuckets: CodecDataBucket[];
+ contentlessServerManifestIds: string[];
+ localManifests: CodecManifest[];
+ localBuckets: CodecDataBucket[];
+ schemaColumns: Record<string, string[]>;
+};
+
+/** One manifest's merged result: the server manifest with merged tables, plus its merged buckets. */
+export type CodecCanonicalManifestMerge = {
+ manifestId: string;
+ manifest: CodecManifest;
+ buckets: CodecDataBucket[];
+ stats: { tablesProcessed: number; recordsFromLocal: number; recordsFromServer: number; recordsCreatedLocally: number; conflicts: number; recordsInserted: number };
+};
+
+/** Output of the canonical merge. */
+export type CodecCanonicalMergeOutput = {
+ manifests: CodecCanonicalManifestMerge[];
+ droppedLocalManifestIds: string[];
+};
+
+/**
+ * Merge the local canonical vault onto the server canonical vault (the base), one manifest at a
+ * time, rows out.
+ */
+export async function vaultCodecMergeCanonical(input: CodecCanonicalMergeInput): Promise<CodecCanonicalMergeOutput> {
+ await initRustCore();
+ return core.mergeCanonical(input) as CodecCanonicalMergeOutput;
+}
+
/**
* Extract the encryption-key row whose `PublicKey` matches `publicKey` from a decrypted manifest.
*/
diff --git a/apps/browser-extension/src/utils/VaultMergeService.ts b/apps/browser-extension/src/utils/VaultMergeService.ts
index e533230d4..5a9c7d1b7 100644
--- a/apps/browser-extension/src/utils/VaultMergeService.ts
+++ b/apps/browser-extension/src/utils/VaultMergeService.ts
@@ -49,12 +49,12 @@ type SqlStatement = {
* Statistics from Rust merge.
*/
type RustMergeStats = {
- tables_processed: number;
- records_from_local: number;
- records_from_server: number;
- records_created_locally: number;
+ tablesProcessed: number;
+ recordsFromLocal: number;
+ recordsFromServer: number;
+ recordsCreatedLocally: number;
conflicts: number;
- records_inserted: number;
+ recordsInserted: number;
}
/**
@@ -228,10 +228,10 @@ export class VaultMergeService {
success: mergeOutput.success,
mergedVaultBase64,
stats: {
- tablesProcessed: mergeOutput.stats.tables_processed,
- recordsFromLocal: mergeOutput.stats.records_from_local,
- recordsFromServer: mergeOutput.stats.records_from_server,
- recordsCreatedLocally: mergeOutput.stats.records_created_locally,
+ tablesProcessed: mergeOutput.stats.tablesProcessed,
+ recordsFromLocal: mergeOutput.stats.recordsFromLocal,
+ recordsFromServer: mergeOutput.stats.recordsFromServer,
+ recordsCreatedLocally: mergeOutput.stats.recordsCreatedLocally,
conflicts: mergeOutput.stats.conflicts,
},
};
diff --git a/apps/browser-extension/src/utils/VaultSyncService.ts b/apps/browser-extension/src/utils/VaultSyncService.ts
index 560d8c258..b9879ebae 100644
--- a/apps/browser-extension/src/utils/VaultSyncService.ts
+++ b/apps/browser-extension/src/utils/VaultSyncService.ts
@@ -510,12 +510,12 @@ export class VaultSyncService {
}
manifests.push(entry.manifest);
dataBuckets.push(...entry.buckets);
- stats.tablesProcessed += entry.stats.tables_processed;
- stats.recordsFromLocal += entry.stats.records_from_local;
- stats.recordsFromServer += entry.stats.records_from_server;
- stats.recordsCreatedLocally += entry.stats.records_created_locally;
+ stats.tablesProcessed += entry.stats.tablesProcessed;
+ stats.recordsFromLocal += entry.stats.recordsFromLocal;
+ stats.recordsFromServer += entry.stats.recordsFromServer;
+ stats.recordsCreatedLocally += entry.stats.recordsCreatedLocally;
stats.conflicts += entry.stats.conflicts;
- stats.recordsInserted += entry.stats.records_inserted;
+ stats.recordsInserted += entry.stats.recordsInserted;
}
for (const dropped of mergeOutput.droppedLocalManifestIds) {
devWarn(`[V2Merge] Local manifest ${dropped} is no longer served; its rows are dropped from the merged vault.`);
diff --git a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/MergeStats.cs b/apps/server/AliasVault.Client/Services/JsInterop/RustCore/MergeStats.cs
index a779d76ce..36cece9ea 100644
--- a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/MergeStats.cs
+++ b/apps/server/AliasVault.Client/Services/JsInterop/RustCore/MergeStats.cs
@@ -17,25 +17,25 @@ public class MergeStats
/// <summary>
/// Gets or sets the number of tables processed.
/// </summary>
- [JsonPropertyName("tables_processed")]
+ [JsonPropertyName("tablesProcessed")]
public int TablesProcessed { get; set; }
/// <summary>
/// Gets or sets records where local version was kept.
/// </summary>
- [JsonPropertyName("records_from_local")]
+ [JsonPropertyName("recordsFromLocal")]
public int RecordsFromLocal { get; set; }
/// <summary>
/// Gets or sets records where server version was used (updates).
/// </summary>
- [JsonPropertyName("records_from_server")]
+ [JsonPropertyName("recordsFromServer")]
public int RecordsFromServer { get; set; }
/// <summary>
/// Gets or sets records that only existed locally (created offline).
/// </summary>
- [JsonPropertyName("records_created_locally")]
+ [JsonPropertyName("recordsCreatedLocally")]
public int RecordsCreatedLocally { get; set; }
/// <summary>
@@ -47,6 +47,6 @@ public class MergeStats
/// <summary>
/// Gets or sets records inserted from server (server-only records).
/// </summary>
- [JsonPropertyName("records_inserted")]
+ [JsonPropertyName("recordsInserted")]
public int RecordsInserted { get; set; }
}
diff --git a/core/rust/src/uniffi_api.rs b/core/rust/src/uniffi_api.rs
index 472842d2b..c4ddc0145 100644
--- a/core/rust/src/uniffi_api.rs
+++ b/core/rust/src/uniffi_api.rs
@@ -34,7 +34,7 @@ pub fn get_syncable_table_names() -> Vec<String> {
/// {
/// "success": true,
/// "statements": [{"sql": "UPDATE ...", "params": [...]}],
-/// "stats": {"tables_processed": 11, "conflicts": 0, ...}
+/// "stats": {"tablesProcessed": 11, "conflicts": 0, ...}
/// }
/// ```
#[uniffi::export]
diff --git a/core/rust/src/vault_merge/mod.rs b/core/rust/src/vault_merge/mod.rs
index 6eac0ed0e..01f736ff7 100644
--- a/core/rust/src/vault_merge/mod.rs
+++ b/core/rust/src/vault_merge/mod.rs
@@ -47,6 +47,7 @@ pub struct SqlStatement {
/// Statistics about what was merged.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
pub struct MergeStats {
/// Number of tables processed