/**
 * cli:roslyn-validator — types.ts
 * Source de verite unique : Zod schemas + types inferes
 * Contrat JSON pour l'analyse statique C# SmartStack (SS001-SS010)
 */
import { z } from 'zod'

// ─── Layers supportes ───
export const LAYERS = ['controller', 'service', 'repository', 'entity', 'all'] as const

// ─── Input : parametres de la validation ───
export const RoslynInputSchema = z.object({
  src: z.string().min(1, 'src directory is required'),
  layer: z.enum(LAYERS).default('all'),
})

export type RoslynInput = z.infer<typeof RoslynInputSchema>

// ─── Statuts possibles pour un check ───
export const CHECK_STATUSES = ['ok', 'error', 'warning', 'skipped'] as const

// ─── Resultat individuel d'un check ───
export const CheckResultSchema = z.object({
  code: z.string().regex(/^SS\d{3}$/),
  status: z.enum(CHECK_STATUSES),
  file: z.string().optional(),
  line: z.number().int().optional(),
  message: z.string().optional(),
  count: z.number().int().optional(),
})

export type CheckResult = z.infer<typeof CheckResultSchema>

// ─── Rapport complet ───
export const RoslynReportSchema = z.object({
  timestamp: z.string(),
  checks: z.array(CheckResultSchema),
  errors: z.number().int().min(0),
  warnings: z.number().int().min(0),
})

export type RoslynReport = z.infer<typeof RoslynReportSchema>

// ─── Resultat de validation d'input ───
export interface ValidationResult {
  valid: boolean
  data?: RoslynInput
  blockers: string[]
  warnings: string[]
}
