use serde::{Deserialize, Serialize}; use crate::model::{ repository::{CommitMetadata, Repository, RepositoryFile, RepositoryView}, user::User, }; use super::issues::IssuesCountResponse; #[derive(Clone, Serialize, Deserialize)] pub struct RepositoryMessage { pub target: Repository, pub command: RepositoryMessageKind, } #[derive(Clone, Serialize, Deserialize)] pub enum RepositoryMessageKind { Request(RepositoryRequest), Response(RepositoryResponse), } #[derive(Clone, Serialize, Deserialize)] pub enum RepositoryRequest { CreateRepository(CreateRepositoryRequest), RepositoryFileInspect(RepositoryFileInspectRequest), RepositoryInfo(RepositoryInfoRequest), IssuesCount(RepositoryIssuesCountRequest), IssueLabels(RepositoryIssueLabelsRequest), Issues(RepositoryIssuesRequest), } #[derive(Clone, Serialize, Deserialize)] pub enum RepositoryResponse { CreateRepository(CreateRepositoryResponse), RepositoryFileInspection(RepositoryFileInspectionResponse), RepositoryInfo(RepositoryView), IssuesCount(RepositoryIssuesCountResponse), IssueLabels(RepositoryIssueLabelsResponse), Issues(RepositoryIssuesResponse), } #[derive(Clone, Serialize, Deserialize)] pub struct CreateRepositoryRequest { pub name: String, pub description: String, pub default_branch: String, pub owner: User, } #[derive(Clone, Serialize, Deserialize)] pub enum CreateRepositoryResponse { Created, Failed, } #[derive(Clone, Serialize, Deserialize)] pub struct RepositoryFileInspectRequest { pub path: RepositoryFile, } #[derive(Clone, Serialize, Deserialize)] pub enum RepositoryFileInspectionResponse { File { commit_metadata: CommitMetadata, }, Folder { commit_metadata: CommitMetadata, members: Vec, }, Invalid { path: RepositoryFile, }, } #[derive(Clone, Serialize, Deserialize)] pub struct RepositoryIssuesCountRequest; #[derive(Clone, Serialize, Deserialize)] pub struct RepositoryIssuesCountResponse { pub count: u64, } #[derive(Clone, Serialize, Deserialize)] pub struct RepositoryIssueLabelsRequest; #[derive(Clone, Serialize, Deserialize)] pub struct RepositoryIssueLabelsResponse { pub labels: Vec, } #[derive(Clone, Serialize, Deserialize)] pub struct IssueLabel { pub name: String, pub color: String, } #[derive(Clone, Serialize, Deserialize)] pub struct RepositoryIssuesRequest; #[derive(Clone, Serialize, Deserialize)] pub struct RepositoryIssuesResponse { pub issues: Vec, } #[derive(Clone, Serialize, Deserialize)] pub struct RepositoryIssue { pub author: User, pub id: u64, pub title: String, pub contents: String, pub labels: Vec, } #[derive(Clone, Serialize, Deserialize)] pub struct RepositoryInfoRequest;