// Copyright (C) 2026  The Software Heritage developers
// See the AUTHORS file at the top-level directory of this distribution
// License: GNU General Public License version 3, or any later version
// See top-level LICENSE file for more information

use purl::Purl;
use serde::Deserialize;

#[derive(Deserialize, Debug, Clone)]
pub struct Note {
    pub text: Option<String>,
    pub links: Option<Vec<String>>,
}

#[derive(Deserialize, Debug, Clone)]
pub enum ArtifactReason {
    #[serde(rename = "Reviewed manually")]
    ReviewedManually,
    #[serde(rename = "Assessed with Eclipse Steady (AST_EQUALITY)")]
    AstEquality,
}

#[derive(Deserialize, Debug, Clone)]
pub struct Artifact {
    pub id: Purl,
    pub reason: ArtifactReason,
    pub affected: bool,
}

#[derive(Deserialize, Debug, Clone)]
pub struct RepositoryCommit {
    pub id: String,
    pub repository: String,
}

#[derive(Deserialize, Debug, Clone)]
pub struct Fix {
    /// Either `"DEFAULT_BRANCH"` or a Git branch name
    pub id: String,
    pub commits: Vec<RepositoryCommit>,
}

#[derive(Deserialize, Debug, Clone)]
pub struct Statement {
    pub vulnerability_id: String,
    pub notes: Option<Vec<Note>>,
    pub artifacts: Option<Vec<Artifact>>,
    pub fixes: Option<Vec<Fix>>,
}
