feat: add operations mutation api for alpine ui

This commit is contained in:
a.tolmachev
2026-03-30 00:42:41 +03:00
parent 4721bc1948
commit 23ca2cda59
14 changed files with 907 additions and 56 deletions
+52 -2
View File
@@ -12,7 +12,7 @@ use crate::{
error::ApiError,
service::{
ExportQuery, GenerateDraftPayload, ImportQuery, NewVersionPayload, OperationPayload,
PublishPayload, TestRunPayload,
PublishPayload, TestRunPayload, UpdateOperationPayload,
},
state::AppState,
};
@@ -43,7 +43,13 @@ pub async fn list_operations(
.service
.list_operations(&path.workspace_id.as_str().into())
.await?;
Ok(Json(json!({ "items": items })))
let total = items.len();
Ok(Json(json!({
"items": items,
"page": 1,
"page_size": total,
"total": total
})))
}
pub async fn create_operation(
@@ -72,6 +78,36 @@ pub async fn get_operation(
Ok(Json(json!(operation)))
}
pub async fn update_operation(
Path(path): Path<WorkspaceOperationPath>,
State(state): State<AppState>,
Json(payload): Json<UpdateOperationPayload>,
) -> Result<Json<Value>, ApiError> {
let result = state
.service
.update_operation(
&path.workspace_id.as_str().into(),
&path.operation_id.as_str().into(),
payload,
)
.await?;
Ok(Json(json!(result)))
}
pub async fn delete_operation(
Path(path): Path<WorkspaceOperationPath>,
State(state): State<AppState>,
) -> Result<Json<Value>, ApiError> {
let result = state
.service
.delete_operation(
&path.workspace_id.as_str().into(),
&path.operation_id.as_str().into(),
)
.await?;
Ok(Json(json!(result)))
}
pub async fn get_operation_version(
Path(path): Path<WorkspaceOperationVersionPath>,
State(state): State<AppState>,
@@ -119,6 +155,20 @@ pub async fn publish_operation(
Ok(Json(json!(published)))
}
pub async fn archive_operation(
Path(path): Path<WorkspaceOperationPath>,
State(state): State<AppState>,
) -> Result<Json<Value>, ApiError> {
let archived = state
.service
.archive_operation(
&path.workspace_id.as_str().into(),
&path.operation_id.as_str().into(),
)
.await?;
Ok(Json(json!(archived)))
}
pub async fn run_test(
Path(path): Path<WorkspaceOperationPath>,
State(state): State<AppState>,