Merge branch 'main' of https://github.com/Abeautifulsnow/dbx into feat/ai-agent-loop-phase1

This commit is contained in:
runstone committed 2026-06-12 08:48:50 +08:00
commit 91f1206783
84 files changed
+4093 -717

No files matched your search

+25
View File
@@ -46,6 +46,31 @@ pub async fn mongo_find_documents(
.await
}
#[tauri::command]
#[allow(clippy::too_many_arguments)]
pub async fn document_find_documents(
state: State<'_, Arc<AppState>>,
connection_id: String,
database: String,
collection: String,
skip: u64,
limit: i64,
filter: Option<String>,
sort: Option<String>,
) -> Result<MongoDocumentResult, String> {
dbx_core::mongo_ops::document_find_documents_core(
&state,
&connection_id,
&database,
&collection,
skip,
limit,
filter.as_deref(),
sort.as_deref(),
)
.await
}
#[tauri::command]
pub async fn mongo_aggregate_documents(
state: State<'_, Arc<AppState>>,
+43 -4
View File
@@ -1,7 +1,8 @@
use std::sync::Arc;
use tauri::State;
use tauri::{Emitter, State};
use dbx_core::jdbc::{self, JdbcDriverInfo, JdbcPluginStatus};
use dbx_core::agent_service::AgentProgressEvent;
use dbx_core::jdbc::{self, JdbcDriverInfo, JdbcMavenBundleInfo, JdbcMavenInstallRequest, JdbcPluginStatus};
use dbx_core::plugins::InstalledPlugin;
use super::connection::AppState;
@@ -20,8 +21,15 @@ pub async fn jdbc_plugin_status(state: State<'_, Arc<AppState>>) -> Result<JdbcP
}
#[tauri::command]
pub async fn install_jdbc_plugin(state: State<'_, Arc<AppState>>) -> Result<JdbcPluginStatus, String> {
jdbc::install_jdbc_plugin(state.plugins.root_dir()).await
pub async fn install_jdbc_plugin(
app: tauri::AppHandle,
state: State<'_, Arc<AppState>>,
) -> Result<JdbcPluginStatus, String> {
let app_handle = app.clone();
jdbc::install_jdbc_plugin_with_progress(state.plugins.root_dir(), move |event| {
emit_agent_progress(&app_handle, event);
})
.await
}
#[tauri::command]
@@ -48,6 +56,22 @@ pub async fn list_jdbc_drivers(state: State<'_, Arc<AppState>>) -> Result<Vec<Jd
.map_err(|err| err.to_string())?
}
#[tauri::command]
pub async fn list_jdbc_maven_bundles(state: State<'_, Arc<AppState>>) -> Result<Vec<JdbcMavenBundleInfo>, String> {
let root_dir = state.plugins.root_dir().to_path_buf();
tauri::async_runtime::spawn_blocking(move || jdbc::list_jdbc_maven_bundles(&root_dir))
.await
.map_err(|err| err.to_string())?
}
#[tauri::command]
pub async fn install_jdbc_driver_from_maven(
state: State<'_, Arc<AppState>>,
request: JdbcMavenInstallRequest,
) -> Result<Vec<JdbcDriverInfo>, String> {
jdbc::install_jdbc_driver_from_maven(state.plugins.root_dir(), request).await
}
#[tauri::command]
pub async fn import_jdbc_drivers(
state: State<'_, Arc<AppState>>,
@@ -66,3 +90,18 @@ pub async fn delete_jdbc_driver(state: State<'_, Arc<AppState>>, path: String) -
.await
.map_err(|err| err.to_string())?
}
#[tauri::command]
pub async fn delete_jdbc_maven_bundle(
state: State<'_, Arc<AppState>>,
bundle_id: String,
) -> Result<Vec<JdbcDriverInfo>, String> {
let root_dir = state.plugins.root_dir().to_path_buf();
tauri::async_runtime::spawn_blocking(move || jdbc::delete_jdbc_maven_bundle(&root_dir, &bundle_id))
.await
.map_err(|err| err.to_string())?
}
fn emit_agent_progress(app: &tauri::AppHandle, event: AgentProgressEvent) {
let _ = app.emit("agent-install-progress", event);
}
+9 -1
View File
@@ -257,6 +257,7 @@ pub async fn redis_execute_command(
connection_id: String,
db: u32,
command: String,
skip_safety_check: Option<bool>,
) -> Result<RedisCommandResult, String> {
// In read-only mode, only allow safe read commands through the raw command interface
if let Some(name) = dbx_core::query::connection_readonly_name(&state, &connection_id).await {
@@ -268,7 +269,14 @@ pub async fn redis_execute_command(
));
}
}
dbx_core::redis_ops::redis_execute_command_core(&state, &connection_id, db, &command).await
dbx_core::redis_ops::redis_execute_command_core(
&state,
&connection_id,
db,
&command,
skip_safety_check.unwrap_or(false),
)
.await
}
#[tauri::command]
+6 -1
View File
@@ -103,7 +103,12 @@ fn sync_saved_sql_directory_blocking(target_dir: &Path, entries: &[SavedSqlSyncE
for entry in entries {
let mut file_dir = sync_root.to_path_buf();
if let Some(folder_name) = entry.folder_name.as_deref().map(str::trim).filter(|name| !name.is_empty()) {
file_dir.push(sanitize_file_segment(folder_name));
for segment in folder_name.split('/') {
let segment = segment.trim();
if !segment.is_empty() {
file_dir.push(sanitize_file_segment(segment));
}
}
}
std::fs::create_dir_all(&file_dir).map_err(|e| e.to_string())?;