use serde::{Deserialize, Serialize};
pub use crate::events::Event;
pub use crate::hosting::{Provider, RemoteRepo};
pub use crate::jobs::{JobRecord, Status};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Repos {
pub repos: Vec<RepoRow>,
pub unlisted: Vec<UnlistedRepo>,
pub team_missing: Vec<String>,
pub root: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RepoRow {
pub path: String,
pub name: String,
pub exists: bool,
pub branch: Option<String>,
pub managed: bool,
pub cloned: bool,
pub your_branch: Option<String>,
pub remote: Option<String>,
pub symbols: Option<usize>,
pub indexed_commit: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UnlistedRepo {
pub name: String,
pub symbols: Option<usize>,
pub commit: Option<String>,
pub remote: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ScanRequest {
pub dir: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub depth: Option<usize>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Scan {
pub ok: bool,
pub found: Vec<ScanHit>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ScanHit {
pub name: String,
pub listed: bool,
pub remote: Option<String>,
pub path: String,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct RepoChange {
#[serde(default)]
pub add: Vec<String>,
#[serde(default)]
pub remove: Vec<String>,
#[serde(default)]
pub teams: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RemoteListRequest {
pub url: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub username: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub token: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RemoteList {
pub ok: bool,
pub provider: Provider,
pub host: String,
pub owner: String,
pub repos: Vec<RemoteRow>,
pub warning: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RemoteRow {
#[serde(flatten)]
pub repo: RemoteRepo,
pub listed: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RemoteAddRequest {
pub urls: Vec<String>,
#[serde(default)]
pub share: bool,
#[serde(default)]
pub teams: Vec<String>,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct IndexRequest {
#[serde(default)]
pub llm: bool,
#[serde(default)]
pub drop_unlisted: bool,
#[serde(default)]
pub rewrite: Vec<crate::prompts::Task>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub paths: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct IndexStarted {
pub ok: bool,
pub message: String,
pub id: String,
pub status: Status,
pub position: Option<usize>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum IndexState {
Latest(LatestJob),
Idle {
running: bool,
events: Vec<Event>,
queued: Vec<QueuedJob>,
},
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LatestJob {
pub id: String,
pub running: bool,
pub cancelled: bool,
pub ok: Option<bool>,
pub status: Status,
pub events: Vec<Event>,
pub started: String,
pub finished: Option<String>,
pub queued: Vec<QueuedJob>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct QueuedJob {
pub id: String,
pub kind: String,
pub position: usize,
pub started_by: Option<String>,
pub created: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct IndexWatch {
pub enabled: bool,
pub minutes: u64,
pub last: WatchResult,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct WatchResult {
pub checked: Option<String>,
pub result: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Jobs {
pub jobs: Vec<JobRow>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct JobRow {
#[serde(flatten)]
pub job: JobRecord,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub position: Option<usize>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct JobDetail {
pub job: JobRecord,
pub events: Vec<Event>,
pub position: Option<usize>,
}