/**
 * cli:readiness-report — types.ts
 * Source de verite unique : Zod schemas + types inferes
 * Contrat JSON pour le rapport de readiness SmartStack (score /100)
 */
import { z } from 'zod'

// ─── Input : parametres du rapport ───

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

export type ReadinessInput = z.infer<typeof ReadinessInputSchema>

// ─── Statuts possibles pour une source ───

export const SOURCE_STATUSES = ['ok', 'warning', 'error', 'skipped'] as const

// ─── Score individuel d'une source de validation ───

export const SourceScoreSchema = z.object({
  score: z.number().int().min(0),
  max: z.number().int().min(0),
  status: z.enum(SOURCE_STATUSES),
  errors: z.number().int().min(0),
  details: z.array(z.string()).default([]),
})

export type SourceScore = z.infer<typeof SourceScoreSchema>

// ─── Recommandations possibles ───

export const RECOMMENDATIONS = ['GO', 'NO-GO', 'STOP'] as const

// ─── Rapport complet ───

export const ReadinessReportSchema = z.object({
  timestamp: z.string(),
  scores: z.object({
    roslyn: SourceScoreSchema,
    eslint: SourceScoreSchema,
    'cross-validate': SourceScoreSchema,
  }),
  total: z.number().int().min(0).max(100),
  max: z.literal(100),
  recommendation: z.enum(RECOMMENDATIONS),
  blockers: z.array(z.string()).default([]),
})

export type ReadinessReport = z.infer<typeof ReadinessReportSchema>

// ─── Resultat de validation d'input ───

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