1use serde::{Deserialize, Serialize};
4
5pub use crate::events::Event;
6pub use crate::hosting::{Provider, RemoteRepo};
7pub use crate::jobs::{JobRecord, Status};
8
9#[derive(Debug, Clone, Serialize, Deserialize)]
11pub struct Repos {
12 pub repos: Vec<RepoRow>,
13 pub unlisted: Vec<UnlistedRepo>,
14 pub team_missing: Vec<String>,
16 pub root: Option<String>,
17}
18
19#[derive(Debug, Clone, Serialize, Deserialize)]
21pub struct RepoRow {
22 pub path: String,
23 pub name: String,
24 pub exists: bool,
25 pub branch: Option<String>,
26 pub managed: bool,
28 pub cloned: bool,
29 pub your_branch: Option<String>,
30 pub remote: Option<String>,
31 pub symbols: Option<usize>,
32 pub indexed_commit: Option<String>,
33}
34
35#[derive(Debug, Clone, Serialize, Deserialize)]
37pub struct UnlistedRepo {
38 pub name: String,
39 pub symbols: Option<usize>,
40 pub commit: Option<String>,
41 pub remote: Option<String>,
42}
43
44#[derive(Debug, Clone, Serialize, Deserialize)]
46pub struct ScanRequest {
47 pub dir: String,
48 #[serde(default, skip_serializing_if = "Option::is_none")]
49 pub depth: Option<usize>,
50}
51
52#[derive(Debug, Clone, Serialize, Deserialize)]
53pub struct Scan {
54 pub ok: bool,
55 pub found: Vec<ScanHit>,
56}
57
58#[derive(Debug, Clone, Serialize, Deserialize)]
60pub struct ScanHit {
61 pub name: String,
62 pub listed: bool,
63 pub remote: Option<String>,
64 pub path: String,
65}
66
67#[derive(Debug, Clone, Default, Serialize, Deserialize)]
69pub struct RepoChange {
70 #[serde(default)]
71 pub add: Vec<String>,
72 #[serde(default)]
73 pub remove: Vec<String>,
74 #[serde(default)]
76 pub teams: Vec<String>,
77}
78
79#[derive(Debug, Clone, Serialize, Deserialize)]
81pub struct RemoteListRequest {
82 pub url: String,
83 #[serde(default, skip_serializing_if = "Option::is_none")]
84 pub username: Option<String>,
85 #[serde(default, skip_serializing_if = "Option::is_none")]
86 pub token: Option<String>,
87}
88
89#[derive(Debug, Clone, Serialize, Deserialize)]
91pub struct RemoteList {
92 pub ok: bool,
93 pub provider: Provider,
94 pub host: String,
95 pub owner: String,
96 pub repos: Vec<RemoteRow>,
97 pub warning: Option<String>,
98}
99
100#[derive(Debug, Clone, Serialize, Deserialize)]
101pub struct RemoteRow {
102 #[serde(flatten)]
103 pub repo: RemoteRepo,
104 pub listed: bool,
105}
106
107#[derive(Debug, Clone, Serialize, Deserialize)]
109pub struct RemoteAddRequest {
110 pub urls: Vec<String>,
111 #[serde(default)]
112 pub share: bool,
113 #[serde(default)]
115 pub teams: Vec<String>,
116}
117
118#[derive(Debug, Clone, Default, Serialize, Deserialize)]
120pub struct IndexRequest {
121 #[serde(default)]
122 pub llm: bool,
123 #[serde(default)]
125 pub drop_unlisted: bool,
126 #[serde(default)]
128 pub rewrite: Vec<crate::prompts::Task>,
129 #[serde(default, skip_serializing_if = "Vec::is_empty")]
131 pub paths: Vec<String>,
132}
133
134#[derive(Debug, Clone, Serialize, Deserialize)]
136pub struct IndexStarted {
137 pub ok: bool,
138 pub message: String,
139 pub id: String,
140 pub status: Status,
141 pub position: Option<usize>,
142}
143
144#[derive(Debug, Clone, Serialize, Deserialize)]
146#[serde(untagged)]
147pub enum IndexState {
148 Latest(LatestJob),
149 Idle {
150 running: bool,
151 events: Vec<Event>,
152 queued: Vec<QueuedJob>,
153 },
154}
155
156#[derive(Debug, Clone, Serialize, Deserialize)]
157pub struct LatestJob {
158 pub id: String,
159 pub running: bool,
160 pub cancelled: bool,
161 pub ok: Option<bool>,
163 pub status: Status,
164 pub events: Vec<Event>,
165 pub started: String,
166 pub finished: Option<String>,
167 pub queued: Vec<QueuedJob>,
168}
169
170#[derive(Debug, Clone, Serialize, Deserialize)]
172pub struct QueuedJob {
173 pub id: String,
174 pub kind: String,
175 pub position: usize,
176 pub started_by: Option<String>,
177 pub created: String,
178}
179
180#[derive(Debug, Clone, Serialize, Deserialize)]
182pub struct IndexWatch {
183 pub enabled: bool,
184 pub minutes: u64,
186 pub last: WatchResult,
187}
188
189#[derive(Debug, Clone, Default, Serialize, Deserialize)]
190pub struct WatchResult {
191 pub checked: Option<String>,
192 pub result: String,
193}
194
195#[derive(Debug, Clone, Serialize, Deserialize)]
197pub struct Jobs {
198 pub jobs: Vec<JobRow>,
199}
200
201#[derive(Debug, Clone, Serialize, Deserialize)]
203pub struct JobRow {
204 #[serde(flatten)]
205 pub job: JobRecord,
206 #[serde(default, skip_serializing_if = "Option::is_none")]
207 pub position: Option<usize>,
208}
209
210#[derive(Debug, Clone, Serialize, Deserialize)]
212pub struct JobDetail {
213 pub job: JobRecord,
214 pub events: Vec<Event>,
215 pub position: Option<usize>,
216}