Rust backend: SQLite (WAL mode, 8 tables), vault encryption (Argon2id + AES-256-GCM), settings/connections/credentials services, 19 Tauri command wrappers. 46/46 tests passing. Vue 3 frontend: unlock/create vault flow, Pinia app store, Tailwind CSS v4 dark theme with Wraith branding. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
95 lines
2.8 KiB
Rust
95 lines
2.8 KiB
Rust
use tauri::State;
|
|
|
|
use crate::connections::{
|
|
ConnectionGroup, ConnectionRecord, CreateConnectionInput, UpdateConnectionInput,
|
|
};
|
|
use crate::AppState;
|
|
|
|
/// Return all connections ordered by group then sort_order.
|
|
#[tauri::command]
|
|
pub fn list_connections(state: State<'_, AppState>) -> Result<Vec<ConnectionRecord>, String> {
|
|
state.connections.list_connections()
|
|
}
|
|
|
|
/// Create a new connection and return the persisted record.
|
|
#[tauri::command]
|
|
pub fn create_connection(
|
|
input: CreateConnectionInput,
|
|
state: State<'_, AppState>,
|
|
) -> Result<ConnectionRecord, String> {
|
|
state.connections.create_connection(input)
|
|
}
|
|
|
|
/// Fetch a single connection by id.
|
|
#[tauri::command]
|
|
pub fn get_connection(id: i64, state: State<'_, AppState>) -> Result<ConnectionRecord, String> {
|
|
state.connections.get_connection(id)
|
|
}
|
|
|
|
/// Apply a partial update to a connection.
|
|
///
|
|
/// Only fields present (i.e. `Some`) in `input` are written; all others are
|
|
/// left unchanged. Returns `Err` if the connection id does not exist.
|
|
#[tauri::command]
|
|
pub fn update_connection(
|
|
id: i64,
|
|
input: UpdateConnectionInput,
|
|
state: State<'_, AppState>,
|
|
) -> Result<(), String> {
|
|
state.connections.update_connection(id, input)
|
|
}
|
|
|
|
/// Delete a connection by id.
|
|
///
|
|
/// Returns `Err` if the id does not exist.
|
|
#[tauri::command]
|
|
pub fn delete_connection(id: i64, state: State<'_, AppState>) -> Result<(), String> {
|
|
state.connections.delete_connection(id)
|
|
}
|
|
|
|
/// Return all connection groups ordered by parent then sort_order.
|
|
#[tauri::command]
|
|
pub fn list_groups(state: State<'_, AppState>) -> Result<Vec<ConnectionGroup>, String> {
|
|
state.connections.list_groups()
|
|
}
|
|
|
|
/// Create a new connection group.
|
|
///
|
|
/// `parent_id` is `None` for top-level groups.
|
|
#[tauri::command]
|
|
pub fn create_group(
|
|
name: String,
|
|
parent_id: Option<i64>,
|
|
state: State<'_, AppState>,
|
|
) -> Result<ConnectionGroup, String> {
|
|
state.connections.create_group(&name, parent_id)
|
|
}
|
|
|
|
/// Delete a connection group by id.
|
|
///
|
|
/// Connections in the deleted group have their `group_id` set to NULL by the
|
|
/// database's `ON DELETE SET NULL` constraint.
|
|
#[tauri::command]
|
|
pub fn delete_group(id: i64, state: State<'_, AppState>) -> Result<(), String> {
|
|
state.connections.delete_group(id)
|
|
}
|
|
|
|
/// Rename a connection group.
|
|
///
|
|
/// Returns `Err` if the id does not exist.
|
|
#[tauri::command]
|
|
pub fn rename_group(id: i64, name: String, state: State<'_, AppState>) -> Result<(), String> {
|
|
state.connections.rename_group(id, &name)
|
|
}
|
|
|
|
/// Search connections across name, hostname, tags, and notes.
|
|
///
|
|
/// Uses case-insensitive LIKE matching. Returns results ordered by name.
|
|
#[tauri::command]
|
|
pub fn search_connections(
|
|
query: String,
|
|
state: State<'_, AppState>,
|
|
) -> Result<Vec<ConnectionRecord>, String> {
|
|
state.connections.search(&query)
|
|
}
|