feat(sdk,plugins): API publique d'accès fichiers/workspace + analyse structure (#124,#129)
This commit is contained in:
@ -5,8 +5,16 @@ use std::path::{Path, PathBuf};
|
||||
|
||||
use application::{ReviewPluginPackageInput, SetPluginEnabledInput, UninstallPluginInput};
|
||||
use backend::dto::{
|
||||
ErrorDto, PluginAdminDto, PluginInstallResultDto, PluginReviewDto,
|
||||
PluginRuntimeContributionCatalogDto, PluginUninstallResultDto, ReviewPluginPackageDto,
|
||||
ErrorDto, PluginAdminDto, PluginConfigDocumentDto, PluginConfigDocumentReadDto,
|
||||
PluginConfigDocumentUpdateDto, PluginConfigDocumentWriteResultDto, PluginEventBatchDto,
|
||||
PluginEventPollDto, PluginEventSubscribeDto, PluginEventSubscriptionDto,
|
||||
PluginEventUnsubscribeDto, PluginInstallResultDto, PluginProjectStructureDto,
|
||||
PluginProjectStructureQueryDto, PluginReviewDto, PluginRunCommandDto,
|
||||
PluginRuntimeContributionCatalogDto, PluginTaskDto, PluginTaskStatusDto,
|
||||
PluginToolchainDiagnosticDto, PluginToolchainDiagnosticRequestDto, PluginUninstallResultDto,
|
||||
PluginWorkspaceBinaryFileDto, PluginWorkspaceDirectoryListingDto, PluginWorkspacePathDto,
|
||||
PluginWorkspaceStatDto, PluginWorkspaceTextFileDto, PluginWorkspaceWriteBinaryDto,
|
||||
PluginWorkspaceWriteTextDto, ReviewPluginPackageDto,
|
||||
};
|
||||
use domain::ports::{PluginManifestValidator, PluginPackageStore, PluginRegistryStore};
|
||||
use domain::{PluginId, RelativePath};
|
||||
@ -156,6 +164,198 @@ pub async fn plugin_list_runtime_contributions(
|
||||
.map_err(ErrorDto::from)
|
||||
}
|
||||
|
||||
/// Reads a UTF-8 workspace file for the public plugin API.
|
||||
#[tauri::command]
|
||||
pub async fn plugin_workspace_read_text(
|
||||
input: PluginWorkspacePathDto,
|
||||
state: State<'_, AppState>,
|
||||
) -> Result<PluginWorkspaceTextFileDto, ErrorDto> {
|
||||
state
|
||||
.plugin_workspace_access
|
||||
.read_text(input.into())
|
||||
.await
|
||||
.map_err(ErrorDto::from)
|
||||
}
|
||||
|
||||
/// Reads a binary workspace file for the public plugin API.
|
||||
#[tauri::command]
|
||||
pub async fn plugin_workspace_read_binary(
|
||||
input: PluginWorkspacePathDto,
|
||||
state: State<'_, AppState>,
|
||||
) -> Result<PluginWorkspaceBinaryFileDto, ErrorDto> {
|
||||
state
|
||||
.plugin_workspace_access
|
||||
.read_binary(input.into())
|
||||
.await
|
||||
.map_err(ErrorDto::from)
|
||||
}
|
||||
|
||||
/// Writes a UTF-8 workspace file for the public plugin API.
|
||||
#[tauri::command]
|
||||
pub async fn plugin_workspace_write_text(
|
||||
input: PluginWorkspaceWriteTextDto,
|
||||
state: State<'_, AppState>,
|
||||
) -> Result<(), ErrorDto> {
|
||||
state
|
||||
.plugin_workspace_access
|
||||
.write_text(input.into())
|
||||
.await
|
||||
.map_err(ErrorDto::from)
|
||||
}
|
||||
|
||||
/// Writes a binary workspace file for the public plugin API.
|
||||
#[tauri::command]
|
||||
pub async fn plugin_workspace_write_binary(
|
||||
input: PluginWorkspaceWriteBinaryDto,
|
||||
state: State<'_, AppState>,
|
||||
) -> Result<(), ErrorDto> {
|
||||
state
|
||||
.plugin_workspace_access
|
||||
.write_binary(input.into())
|
||||
.await
|
||||
.map_err(ErrorDto::from)
|
||||
}
|
||||
|
||||
/// Lists a workspace directory for the public plugin API.
|
||||
#[tauri::command]
|
||||
pub async fn plugin_workspace_list_dir(
|
||||
input: PluginWorkspacePathDto,
|
||||
state: State<'_, AppState>,
|
||||
) -> Result<PluginWorkspaceDirectoryListingDto, ErrorDto> {
|
||||
state
|
||||
.plugin_workspace_access
|
||||
.list_dir(input.into())
|
||||
.await
|
||||
.map_err(ErrorDto::from)
|
||||
}
|
||||
|
||||
/// Stats a workspace path for the public plugin API.
|
||||
#[tauri::command]
|
||||
pub async fn plugin_workspace_stat(
|
||||
input: PluginWorkspacePathDto,
|
||||
state: State<'_, AppState>,
|
||||
) -> Result<PluginWorkspaceStatDto, ErrorDto> {
|
||||
state
|
||||
.plugin_workspace_access
|
||||
.stat(input.into())
|
||||
.await
|
||||
.map_err(ErrorDto::from)
|
||||
}
|
||||
|
||||
/// Queries a bounded generic project structure for the public plugin API.
|
||||
#[tauri::command]
|
||||
pub async fn plugin_query_project_structure(
|
||||
input: PluginProjectStructureQueryDto,
|
||||
state: State<'_, AppState>,
|
||||
) -> Result<PluginProjectStructureDto, ErrorDto> {
|
||||
state
|
||||
.query_project_structure
|
||||
.execute(input.into())
|
||||
.await
|
||||
.map_err(ErrorDto::from)
|
||||
}
|
||||
|
||||
/// Reads a structured configuration document for the public plugin API.
|
||||
#[tauri::command]
|
||||
pub async fn plugin_config_read_document(
|
||||
input: PluginConfigDocumentReadDto,
|
||||
state: State<'_, AppState>,
|
||||
) -> Result<PluginConfigDocumentDto, ErrorDto> {
|
||||
state
|
||||
.plugin_config_documents
|
||||
.read(input.into())
|
||||
.await
|
||||
.map_err(ErrorDto::from)
|
||||
}
|
||||
|
||||
/// Updates a structured configuration document for the public plugin API.
|
||||
#[tauri::command]
|
||||
pub async fn plugin_config_update_document(
|
||||
input: PluginConfigDocumentUpdateDto,
|
||||
state: State<'_, AppState>,
|
||||
) -> Result<PluginConfigDocumentWriteResultDto, ErrorDto> {
|
||||
state
|
||||
.plugin_config_documents
|
||||
.update(input.into())
|
||||
.await
|
||||
.map_err(ErrorDto::from)
|
||||
}
|
||||
|
||||
/// Launches a command-backed background task for the public plugin API.
|
||||
#[tauri::command]
|
||||
pub async fn plugin_task_run_command(
|
||||
input: PluginRunCommandDto,
|
||||
state: State<'_, AppState>,
|
||||
) -> Result<PluginTaskDto, ErrorDto> {
|
||||
state
|
||||
.plugin_command_tasks
|
||||
.run_command(input.into())
|
||||
.await
|
||||
.map(PluginTaskDto::from)
|
||||
.map_err(ErrorDto::from)
|
||||
}
|
||||
|
||||
/// Reads one command task status for the public plugin API.
|
||||
#[tauri::command]
|
||||
pub async fn plugin_task_get_status(
|
||||
input: PluginTaskStatusDto,
|
||||
state: State<'_, AppState>,
|
||||
) -> Result<Option<PluginTaskDto>, ErrorDto> {
|
||||
state
|
||||
.plugin_command_tasks
|
||||
.get_status(input.into())
|
||||
.await
|
||||
.map(|task| task.map(PluginTaskDto::from))
|
||||
.map_err(ErrorDto::from)
|
||||
}
|
||||
|
||||
/// Diagnoses generic external toolchain prerequisites for the public plugin API.
|
||||
#[tauri::command]
|
||||
pub async fn plugin_toolchain_diagnose(
|
||||
input: PluginToolchainDiagnosticRequestDto,
|
||||
state: State<'_, AppState>,
|
||||
) -> Result<PluginToolchainDiagnosticDto, ErrorDto> {
|
||||
state
|
||||
.plugin_toolchain_diagnostics
|
||||
.diagnose(input.into())
|
||||
.await
|
||||
.map_err(ErrorDto::from)
|
||||
}
|
||||
|
||||
/// Subscribes to stable public plugin events.
|
||||
#[tauri::command]
|
||||
pub async fn plugin_events_subscribe(
|
||||
input: PluginEventSubscribeDto,
|
||||
state: State<'_, AppState>,
|
||||
) -> Result<PluginEventSubscriptionDto, ErrorDto> {
|
||||
state
|
||||
.plugin_event_subscriptions
|
||||
.subscribe(input.into())
|
||||
.await
|
||||
.map_err(ErrorDto::from)
|
||||
}
|
||||
|
||||
/// Drains retained public plugin events for one subscription.
|
||||
#[tauri::command]
|
||||
pub fn plugin_events_poll(
|
||||
input: PluginEventPollDto,
|
||||
state: State<'_, AppState>,
|
||||
) -> Result<PluginEventBatchDto, ErrorDto> {
|
||||
state
|
||||
.plugin_event_subscriptions
|
||||
.poll(input.into())
|
||||
.map_err(ErrorDto::from)
|
||||
}
|
||||
|
||||
/// Disposes a public plugin event subscription.
|
||||
#[tauri::command]
|
||||
pub fn plugin_events_unsubscribe(
|
||||
input: PluginEventUnsubscribeDto,
|
||||
state: State<'_, AppState>,
|
||||
) -> PluginEventSubscriptionDto {
|
||||
state.plugin_event_subscriptions.unsubscribe(input.into())
|
||||
}
|
||||
|
||||
/// Opens the plugin store folder, or one plugin folder when an id is provided.
|
||||
#[tauri::command]
|
||||
pub fn plugin_open_plugins_folder(
|
||||
|
||||
Reference in New Issue
Block a user