feat(jdbc): install drivers from Maven bundles

This commit is contained in:
t8y2 committed 2026-06-11 21:41:37 +08:00
1 parent f969db571c
commit 70f7b464b7
19 files changed
+1039 -51

No files matched your search

+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);
}