/**
 * Screening & Security types
 *
 * SBOM analysis, vulnerability scanning, security issues,
 * and backlog tracking for the screening pipeline.
 */

import type { ScreeningStatus, SecurityIssueSeverity, SecurityIssueStatus } from './core'

// =============================================================================
// SBOM
// =============================================================================

export interface Vulnerability {
  id: string
  cve: string
  severity: SecurityIssueSeverity
  title: string
  description: string
  cvss: number | null
  fixedIn: string | null
}

export interface SBOMComponent {
  name: string
  version: string
  type: 'library' | 'framework' | 'application' | 'container'
  purl: string
  licenses: string[]
  vulnerabilities: Vulnerability[]
}

export interface SBOMDependency {
  from: string
  to: string
}

export interface SBOM {
  format: 'CycloneDX' | 'SPDX'
  version: string
  components: SBOMComponent[]
  dependencies: SBOMDependency[]
  generatedAt: Date
}

// =============================================================================
// SECURITY SCAN
// =============================================================================

export interface SecurityScanResult {
  totalIssues: number
  critical: number
  high: number
  medium: number
  low: number
  issues: SecurityIssue[]
}

export interface SecurityIssue {
  id: string
  severity: SecurityIssueSeverity
  title: string
  description: string
  cve: string | null
  cvss: number | null
  affectedComponent: string
  remediation: string
  status: SecurityIssueStatus
}

// =============================================================================
// SCREENING RESULT
// =============================================================================

export interface ScreeningResult {
  id: string
  status: ScreeningStatus
  startedAt: Date
  completedAt: Date | null
  sbom: SBOM | null
  securityScan: SecurityScanResult | null
  error: string | null
}

// =============================================================================
// BACKLOG
// =============================================================================

export interface BacklogItem {
  id: string
  title: string
  description: string
  severity: SecurityIssueSeverity
  securityIssueId: string
  status: 'OPEN' | 'IN_PROGRESS' | 'DONE'
  assignee: string | null
  dueDate: Date | null
  createdAt: Date
}
