feat: route product commands through backend targets

This commit is contained in:
2026-08-22 19:16:14 +09:00
parent 1a1e3c286f
commit 30e4985f9a
19 changed files with 1650 additions and 180 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ path = "src/main.rs"
[features]
default = ["typescript"]
typescript = ["dep:ts-rs"]
typescript = ["dep:ts-rs", "workspace-api/typescript"]
[dependencies]
async-trait.workspace = true
+4 -69
View File
@@ -1,5 +1,9 @@
use project_record::validate_record_id;
use serde::{Deserialize, Serialize};
pub use workspace_api::{
ObjectiveDetail, ObjectiveEventDetail, ObjectiveLinkedTicketSummary, ObjectiveResourceSummary,
ObjectiveSummary, QueryPage,
};
use crate::{Error, Result};
@@ -226,18 +230,6 @@ impl From<ticket::TicketRelationView> for TicketRelationView {
}
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Default)]
#[cfg_attr(feature = "typescript", derive(ts_rs::TS))]
pub struct QueryPage {
pub limit: usize,
pub returned: usize,
pub has_more: bool,
pub next_cursor: Option<String>,
pub sort: String,
pub source_limit: Option<usize>,
pub source_truncated: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[cfg_attr(feature = "typescript", derive(ts_rs::TS))]
pub struct ObjectiveLinkSummary {
@@ -418,63 +410,6 @@ pub struct ObjectiveShowRequest {
pub event_cursor: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[cfg_attr(feature = "typescript", derive(ts_rs::TS))]
pub struct ObjectiveEventDetail {
pub event_ref: String,
pub kind: String,
pub body: Option<String>,
pub created_at: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct ObjectiveLinkedTicketSummary {
pub id: String,
pub resource_key: String,
pub title: String,
pub state: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct ObjectiveSummary {
pub id: String,
pub resource_key: String,
pub title: String,
pub state: String,
pub created_at: Option<String>,
pub updated_at: Option<String>,
pub summary: String,
pub linked_tickets: Vec<String>,
pub record_source: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct ObjectiveDetail {
pub id: String,
pub resource_key: String,
pub title: String,
pub state: String,
pub revision: String,
pub created_at: Option<String>,
pub updated_at: Option<String>,
pub linked_tickets: Vec<String>,
pub linked_ticket_summaries: Vec<ObjectiveLinkedTicketSummary>,
pub resources: Vec<ObjectiveResourceSummary>,
pub body: String,
pub body_truncated: bool,
pub events: Vec<ObjectiveEventDetail>,
pub event_page: QueryPage,
pub record_source: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct ObjectiveResourceSummary {
pub path: String,
pub media_type: Option<String>,
pub bytes: usize,
pub updated_at: String,
}
#[cfg(feature = "typescript")]
pub fn ticket_api_typescript() -> String {
use ts_rs::TS;
+3 -34
View File
@@ -57,6 +57,9 @@ use workdir::workspace::{
use worker::feature::builtin::{WorkerObservationSubject, WorkerObservationSubjectRef};
use worker_runtime::resource::{BackendResourceError, BackendResourceFetchRequest};
use worker_runtime::worker_backend::{ProfileRuntimeWorkerFactory, WorkerRuntimeExecutionBackend};
use workspace_api::{
ObjectiveCreateRequest, ObjectiveEditRequest, ObjectiveLinkTicketRequest, ObjectiveStateRequest,
};
use crate::auth::{
AuthPublicConfig, AuthenticatedUser, RequestActor, auth_error, is_expired, mint_secret, new_id,
@@ -2648,26 +2651,6 @@ struct ObjectiveListQuery {
limit: Option<usize>,
}
#[derive(Debug, Deserialize)]
struct ObjectiveCreateRequest {
title: String,
#[serde(default)]
body_md: String,
#[serde(default = "default_objective_state")]
state: String,
#[serde(default)]
linked_tickets: Vec<String>,
}
#[derive(Debug, Deserialize)]
struct ObjectiveEditRequest {
title: Option<String>,
old_string: Option<String>,
new_string: Option<String>,
#[serde(default)]
replace_all: bool,
}
#[derive(Debug, Deserialize)]
struct TicketListQuery {
limit: Option<usize>,
@@ -2676,16 +2659,6 @@ struct TicketListQuery {
states: Option<String>,
}
#[derive(Debug, Deserialize)]
struct ObjectiveStateRequest {
state: String,
}
#[derive(Debug, Deserialize)]
struct ObjectiveLinkTicketRequest {
ticket_id: String,
}
#[derive(Debug, Deserialize)]
struct ScopedObjectivePath {
workspace_id: String,
@@ -2699,10 +2672,6 @@ struct ScopedObjectiveTicketPath {
ticket_id: String,
}
fn default_objective_state() -> String {
"active".to_string()
}
#[derive(Debug, Deserialize)]
struct TranscriptQuery {
start: Option<usize>,