/**
 * cli:eslint-validator — types.ts
 * Source de verite unique : Zod schemas + types inferes
 */
import { z } from 'zod'

// ─── Input schema ───

export const ESLintInputSchema = z.object({
  src: z.string().min(1, 'src directory is required'),
})

export type ESLintInput = z.infer<typeof ESLintInputSchema>

// ─── Check result (une violation ou un ok) ───

export const CheckStatusSchema = z.enum(['ok', 'error', 'warning'])

export const CheckResultSchema = z.object({
  code: z.string(),
  status: CheckStatusSchema,
  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>

// ─── Report (output final) ───

export const ESLintReportSchema = z.object({
  timestamp: z.string(),
  checks: z.array(CheckResultSchema),
  errors: z.number().int(),
  warnings: z.number().int(),
})

export type ESLintReport = z.infer<typeof ESLintReportSchema>

// ─── Validation result ───

export interface ValidationResult {
  valid: boolean
  data?: ESLintInput
  blockers: string[]
  warnings: string[]
}
