mirror of
https://wget.la/https://github.com/leookun/cursor-byok
synced 2026-12-01 01:05:10 +08:00
feat(desktop): add plugin resource actions
This commit is contained in:
1 parent
8fbbcd5ae9
commit
2cb15b541b
24 files changed
+1110
-254
No files matched your search
@@ -172,6 +172,10 @@ pub fn api_router(service: ControlService) -> Router {
|
||||
"/__byok-api__/api/plugins/{plugin_id}/resources/{resource_type}/{resource_id}",
|
||||
axum::routing::delete(plugins::delete_resource),
|
||||
)
|
||||
.route(
|
||||
"/__byok-api__/api/plugins/{plugin_id}/resources/{resource_type}/{resource_id}/actions/{action_id}",
|
||||
post(plugins::action),
|
||||
)
|
||||
.route(
|
||||
"/__byok-api__/api/plugins/{plugin_id}/resources/{resource_type}/{resource_id}/refresh",
|
||||
post(plugins::refresh_resource),
|
||||
|
||||
@@ -87,6 +87,23 @@ pub async fn refresh_resource(
|
||||
Ok(StatusCode::NO_CONTENT)
|
||||
}
|
||||
|
||||
pub async fn action(
|
||||
State(service): State<ControlService>,
|
||||
Path((plugin_id, resource_type, resource_id, action_id)): Path<(
|
||||
String,
|
||||
String,
|
||||
String,
|
||||
String,
|
||||
)>,
|
||||
Json(input): Json<serde_json::Value>,
|
||||
) -> Result<Json<serde_json::Value>> {
|
||||
Ok(Json(
|
||||
service
|
||||
.plugin_resource_action(&plugin_id, &resource_type, &resource_id, &action_id, input)
|
||||
.await?,
|
||||
))
|
||||
}
|
||||
|
||||
pub async fn delete_resource(
|
||||
State(service): State<ControlService>,
|
||||
Path((plugin_id, resource_type, resource_id)): Path<(String, String, String)>,
|
||||
|
||||
@@ -226,6 +226,19 @@ impl ControlService {
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn plugin_resource_action(
|
||||
&self,
|
||||
plugin_id: &str,
|
||||
resource_type: &str,
|
||||
resource_id: &str,
|
||||
action_id: &str,
|
||||
input: serde_json::Value,
|
||||
) -> Result<serde_json::Value> {
|
||||
self.plugins
|
||||
.resource_action(plugin_id, resource_type, resource_id, action_id, input)
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn plugin_delete_resource(
|
||||
&self,
|
||||
plugin_id: &str,
|
||||
|
||||
Reference in new issue
Block a user