1use std::collections::HashMap;
4
5use anyhow::Result;
6use serde::{Deserialize, Serialize};
7
8#[derive(Debug, Clone, Serialize, Deserialize)]
10pub struct ReviewSummary {
11 pub review_id: String,
12 pub title: String,
13 pub author: String,
14 pub status: String,
15 pub thread_count: i64,
16 pub open_thread_count: i64,
17 #[serde(default)]
18 pub reviewers: Vec<String>,
19}
20
21#[derive(Debug, Clone, Serialize, Deserialize)]
23pub struct ReviewDetail {
24 pub review_id: String,
25 pub jj_change_id: String,
26 pub scm_kind: String,
27 pub scm_anchor: String,
28 pub initial_commit: String,
29 pub final_commit: Option<String>,
30 pub title: String,
31 pub description: Option<String>,
32 pub author: String,
33 pub created_at: String,
34 pub status: String,
35 pub status_changed_at: Option<String>,
36 pub status_changed_by: Option<String>,
37 pub abandon_reason: Option<String>,
38 pub thread_count: i64,
39 pub open_thread_count: i64,
40}
41
42#[derive(Debug, Clone, Serialize, Deserialize)]
44pub struct ThreadSummary {
45 pub thread_id: String,
46 pub file_path: String,
47 pub selection_start: i64,
48 pub selection_end: Option<i64>,
49 pub status: String,
50 pub comment_count: i64,
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
55pub struct ThreadDetail {
56 pub thread_id: String,
57 pub review_id: String,
58 pub file_path: String,
59 pub selection_type: String,
60 pub selection_start: i64,
61 pub selection_end: Option<i64>,
62 pub commit_hash: String,
63 pub author: String,
64 pub created_at: String,
65 pub status: String,
66 pub status_changed_at: Option<String>,
67 pub status_changed_by: Option<String>,
68 pub resolve_reason: Option<String>,
69 pub reopen_reason: Option<String>,
70}
71
72#[derive(Debug, Clone, Serialize, Deserialize)]
74pub struct Comment {
75 pub comment_id: String,
76 pub author: String,
77 pub body: String,
78 pub created_at: String,
79}
80
81pub struct FileData {
83 pub path: String,
84 pub diff: Option<String>,
86 pub content: Option<FileContentData>,
88}
89
90pub struct FileContentData {
92 pub start_line: i64,
94 pub lines: Vec<String>,
95}
96
97pub struct ReviewData {
99 pub detail: ReviewDetail,
100 pub threads: Vec<ThreadSummary>,
101 pub comments: HashMap<String, Vec<Comment>>,
102 pub files: Vec<FileData>,
104}
105
106pub trait SealClient {
108 fn list_reviews(&self, status: Option<&str>) -> Result<Vec<ReviewSummary>>;
114
115 fn load_review_data(&self, review_id: &str) -> Result<Option<ReviewData>>;
121
122 fn comment(
128 &self,
129 review_id: &str,
130 file_path: &str,
131 start_line: i64,
132 end_line: Option<i64>,
133 body: &str,
134 ) -> Result<()>;
135
136 fn reply(&self, thread_id: &str, body: &str) -> Result<()>;
142}