fix(etcd): preserve raw key identity in browser actions

This commit is contained in:
二丫讲梵 authored and GitHub committed 2026-07-27 13:18:53 +08:00
1 parent 122853d089
commit 39d0f5b30f
69 files changed
+6577 -742

No files matched your search

+76 -11
View File
@@ -2,12 +2,11 @@ use std::sync::Arc;
use tauri::State;
use crate::commands::connection::{ensure_connection_writable, AppState};
use dbx_core::agent_kv::{KvDeleteResponse, KvGetResponse, KvListPrefixResponse, KvPutOptions, KvPutResponse, KvValue};
#[tauri::command]
pub async fn etcd_supports_ttl(state: State<'_, Arc<AppState>>, connection_id: String) -> Result<bool, String> {
dbx_core::agent_kv::kv_supports_ttl_core(&state, &connection_id).await
}
use dbx_core::agent_kv::{
KvDeleteOptions, KvDeleteResponse, KvGetOptions, KvGetResponse, KvHistoryRequest, KvHistoryResponse, KvInt64,
KvListPrefixResponse, KvPutOptions, KvPutResponse, KvRangeOptions, KvRenameRequest, KvRenameResponse,
KvStatusResponse, KvValue,
};
#[tauri::command]
pub async fn etcd_list_prefix(
@@ -16,8 +15,23 @@ pub async fn etcd_list_prefix(
prefix: String,
limit: usize,
continuation: Option<String>,
revision: Option<KvInt64>,
include_values: Option<bool>,
) -> Result<KvListPrefixResponse, String> {
dbx_core::agent_kv::kv_list_prefix_core(&state, &connection_id, &prefix, limit, continuation.as_deref()).await
dbx_core::agent_kv::kv_list_prefix_core_with_range_options(
&state,
&connection_id,
&prefix,
limit,
continuation.as_deref(),
KvRangeOptions { revision, include_values },
)
.await
}
#[tauri::command]
pub async fn etcd_supports_ttl(state: State<'_, Arc<AppState>>, connection_id: String) -> Result<bool, String> {
dbx_core::agent_kv::kv_supports_ttl_core(&state, &connection_id).await
}
#[tauri::command]
@@ -25,9 +39,17 @@ pub async fn etcd_get(
state: State<'_, Arc<AppState>>,
connection_id: String,
key: String,
key_bytes: Option<KvValue>,
revision: Option<KvInt64>,
metadata_only: Option<bool>,
) -> Result<KvGetResponse, String> {
dbx_core::agent_kv::kv_get_core_with_options(&state, &connection_id, &key, metadata_only.unwrap_or(false)).await
dbx_core::agent_kv::kv_get_core_with_options(
&state,
&connection_id,
&key,
KvGetOptions { key_bytes, revision, metadata_only },
)
.await
}
#[tauri::command]
@@ -36,9 +58,12 @@ pub async fn etcd_put(
connection_id: String,
key: String,
value: KvValue,
lease: Option<i64>,
lease: Option<KvInt64>,
ttl: Option<i64>,
preserve_lease: Option<bool>,
key_bytes: Option<KvValue>,
expected_mod_revision: Option<KvInt64>,
expected_create_revision: Option<KvInt64>,
) -> Result<KvPutResponse, String> {
ensure_connection_writable(&state, &connection_id, "Put").await?;
dbx_core::agent_kv::kv_put_core_with_options(
@@ -46,7 +71,15 @@ pub async fn etcd_put(
&connection_id,
&key,
value,
KvPutOptions { lease, ttl, preserve_lease, ..KvPutOptions::default() },
KvPutOptions {
lease,
ttl,
preserve_lease,
key_bytes,
expected_mod_revision,
expected_create_revision,
..KvPutOptions::default()
},
)
.await
}
@@ -56,7 +89,39 @@ pub async fn etcd_delete(
state: State<'_, Arc<AppState>>,
connection_id: String,
key: String,
key_bytes: Option<KvValue>,
expected_mod_revision: Option<KvInt64>,
) -> Result<KvDeleteResponse, String> {
ensure_connection_writable(&state, &connection_id, "Delete").await?;
dbx_core::agent_kv::kv_delete_core(&state, &connection_id, &key).await
dbx_core::agent_kv::kv_delete_core_with_options(
&state,
&connection_id,
&key,
KvDeleteOptions { key_bytes, expected_mod_revision },
)
.await
}
#[tauri::command]
pub async fn etcd_rename(
state: State<'_, Arc<AppState>>,
connection_id: String,
request: KvRenameRequest,
) -> Result<KvRenameResponse, String> {
ensure_connection_writable(&state, &connection_id, "Rename").await?;
dbx_core::agent_kv::kv_rename_core(&state, &connection_id, request).await
}
#[tauri::command]
pub async fn etcd_history(
state: State<'_, Arc<AppState>>,
connection_id: String,
request: KvHistoryRequest,
) -> Result<KvHistoryResponse, String> {
dbx_core::agent_kv::kv_history_core(&state, &connection_id, request).await
}
#[tauri::command]
pub async fn etcd_status(state: State<'_, Arc<AppState>>, connection_id: String) -> Result<KvStatusResponse, String> {
dbx_core::agent_kv::kv_status_core(&state, &connection_id).await
}