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 #[serde(default, skip_serializing_if = "Vec::is_empty")]
134 pub steps: Vec<crate::prompts::Task>,
135}
136
137#[derive(Debug, Clone, Serialize, Deserialize)]
139pub struct IndexStarted {
140 pub ok: bool,
141 pub message: String,
142 pub id: String,
143 pub status: Status,
144 pub position: Option<usize>,
145}
146
147#[derive(Debug, Clone, Serialize, Deserialize)]
149#[serde(untagged)]
150pub enum IndexState {
151 Latest(LatestJob),
152 Idle {
153 running: bool,
154 events: Vec<Event>,
155 queued: Vec<QueuedJob>,
156 },
157}
158
159#[derive(Debug, Clone, Serialize, Deserialize)]
160pub struct LatestJob {
161 pub id: String,
162 pub running: bool,
163 pub cancelled: bool,
164 pub ok: Option<bool>,
166 pub status: Status,
167 pub events: Vec<Event>,
168 pub started: String,
169 pub finished: Option<String>,
170 pub queued: Vec<QueuedJob>,
171}
172
173#[derive(Debug, Clone, Serialize, Deserialize)]
175pub struct QueuedJob {
176 pub id: String,
177 pub kind: String,
178 pub position: usize,
179 pub started_by: Option<String>,
180 pub created: String,
181}
182
183#[derive(Debug, Clone, Serialize, Deserialize)]
185pub struct IndexWatch {
186 pub enabled: bool,
187 pub minutes: u64,
189 pub last: WatchResult,
190}
191
192#[derive(Debug, Clone, Default, Serialize, Deserialize)]
193pub struct WatchResult {
194 pub checked: Option<String>,
195 pub result: String,
196}
197
198#[derive(Debug, Clone, Serialize, Deserialize)]
200pub struct Jobs {
201 pub jobs: Vec<JobRow>,
202}
203
204#[derive(Debug, Clone, Serialize, Deserialize)]
206pub struct JobRow {
207 #[serde(flatten)]
208 pub job: JobRecord,
209 #[serde(default, skip_serializing_if = "Option::is_none")]
210 pub position: Option<usize>,
211}
212
213#[derive(Debug, Clone, Serialize, Deserialize)]
215pub struct JobDetail {
216 pub job: JobRecord,
217 pub events: Vec<Event>,
218 pub position: Option<usize>,
219}