fix: share ticket query route contracts

This commit is contained in:
2026-08-22 20:20:38 +09:00
parent 9dc6d8f144
commit 4017992c7d
3 changed files with 35 additions and 7 deletions
+5 -4
View File
@@ -11,6 +11,7 @@ use ticket::{
use workspace_api::{
ListResponse, ObjectiveCreateRequest, ObjectiveDetail, ObjectiveEditRequest,
ObjectiveLinkTicketRequest, ObjectiveStateRequest, ObjectiveSummary,
TICKET_ORCHESTRATION_PLANS_QUERY_PATH, TICKET_RELATIONS_QUERY_PATH,
};
use crate::BackendWorkspaceClientError;
@@ -173,7 +174,7 @@ impl BackendWorkspaceProductClient {
}
self.send_json(
Method::POST,
"/ticket-relations/query",
TICKET_RELATIONS_QUERY_PATH,
Some(&Query { ticket, kind }),
)
}
@@ -568,7 +569,7 @@ impl TicketBackend for BackendWorkspaceProductClient {
}
self.send_json(
Method::POST,
"/ticket-orchestration-plans/query",
TICKET_ORCHESTRATION_PLANS_QUERY_PATH,
Some(&Query { ticket, kind }),
)
.map_err(ticket_client_error)
@@ -745,7 +746,7 @@ mod tests {
assert!(relations.is_empty());
let request = request.recv().unwrap();
assert!(request.starts_with("POST /api/w/workspace-a/ticket-relations/query "));
assert!(request.starts_with("POST /api/w/workspace-a/tickets/relations/search "));
assert!(request.contains("\"ticket\":{\"Query\":\"T-1\"}"));
handle.join().unwrap();
}
@@ -762,7 +763,7 @@ mod tests {
request
.recv()
.unwrap()
.starts_with("POST /api/w/workspace-a/ticket-orchestration-plans/query ")
.starts_with("POST /api/w/workspace-a/tickets/orchestration-plans/search ")
);
handle.join().unwrap();
}
+3
View File
@@ -7,6 +7,9 @@
use serde::{Deserialize, Serialize};
use workdir::workspace::WorkingDirectorySummary;
pub const TICKET_RELATIONS_QUERY_PATH: &str = "/tickets/relations/search";
pub const TICKET_ORCHESTRATION_PLANS_QUERY_PATH: &str = "/tickets/orchestration-plans/search";
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum DiagnosticSeverity {
+27 -3
View File
@@ -58,7 +58,8 @@ use worker::feature::builtin::{WorkerObservationSubject, WorkerObservationSubjec
use worker_runtime::resource::{BackendResourceError, BackendResourceFetchRequest};
use worker_runtime::worker_backend::{ProfileRuntimeWorkerFactory, WorkerRuntimeExecutionBackend};
use workspace_api::{
ObjectiveCreateRequest, ObjectiveEditRequest, ObjectiveLinkTicketRequest, ObjectiveStateRequest,
ObjectiveCreateRequest, ObjectiveEditRequest, ObjectiveLinkTicketRequest,
ObjectiveStateRequest, TICKET_ORCHESTRATION_PLANS_QUERY_PATH, TICKET_RELATIONS_QUERY_PATH,
};
use crate::auth::{
@@ -1603,6 +1604,10 @@ fn build_server_auth_router(api: ServerAuthApi) -> Router {
pub fn build_router(api: WorkspaceApi) -> Router {
let auth = build_server_auth_router(ServerAuthApi::from(&api));
let scoped_ticket_relations_query_path =
format!("/api/w/{{workspace_id}}{TICKET_RELATIONS_QUERY_PATH}");
let scoped_ticket_orchestration_plans_query_path =
format!("/api/w/{{workspace_id}}{TICKET_ORCHESTRATION_PLANS_QUERY_PATH}");
let workspace = Router::new()
.route("/api/workspace", get(get_workspace))
.route("/api/w/{workspace_id}/workspace", get(scoped_get_workspace))
@@ -1697,11 +1702,11 @@ pub fn build_router(api: WorkspaceApi) -> Router {
get(scoped_ticket_doctor),
)
.route(
"/api/w/{workspace_id}/tickets/relations/search",
scoped_ticket_relations_query_path.as_str(),
post(scoped_query_ticket_relations),
)
.route(
"/api/w/{workspace_id}/tickets/orchestration-plans/search",
scoped_ticket_orchestration_plans_query_path.as_str(),
post(scoped_query_ticket_orchestration_plans),
)
.route(
@@ -18203,6 +18208,25 @@ mod tests {
.unwrap();
assert_eq!(response.status(), StatusCode::OK);
for path in [
TICKET_RELATIONS_QUERY_PATH,
TICKET_ORCHESTRATION_PLANS_QUERY_PATH,
] {
let response = app
.clone()
.oneshot(
Request::builder()
.method("POST")
.uri(format!("/api/w/{TEST_WORKSPACE_ID}{path}"))
.header("content-type", "application/json")
.body(Body::from(r#"{"ticket":null,"kind":null}"#))
.unwrap(),
)
.await
.unwrap();
assert_eq!(response.status(), StatusCode::OK, "path: {path}");
}
let response = app
.clone()
.oneshot(