/**
 * cli:scaffold-tests — types.ts
 * Source de vérité unique : test generation schemas
 */
import { z } from 'zod'

export const TestLayerEnum = z.enum(['seed', 'domain', 'business', 'api', 'frontend'])

export const BusinessRuleTestSchema = z.object({
  id: z.string(),
  entityName: z.string(),
  description: z.string(),
  validExamples: z.array(z.string()).default([]),
  invalidExamples: z.array(z.string()).default([]),
})

export const EntityTestSpecSchema = z.object({
  name: z.string(),
  pluralName: z.string(),
  fields: z.array(z.object({
    name: z.string(),
    type: z.string(),
    required: z.boolean().default(true),
  })),
})

export const ScaffoldTestsInputSchema = z.object({
  layer: TestLayerEnum,
  module: z.string().min(1),
  appCode: z.string().min(1),
  entities: z.array(EntityTestSpecSchema).min(1),
  businessRules: z.array(BusinessRuleTestSchema).default([]),
  projectPath: z.string().min(1),
  namespace: z.string().optional(),
})

export type TestLayer = z.infer<typeof TestLayerEnum>
export type BusinessRuleTest = z.infer<typeof BusinessRuleTestSchema>
export type EntityTestSpec = z.infer<typeof EntityTestSpecSchema>
export type ScaffoldTestsInput = z.infer<typeof ScaffoldTestsInputSchema>

export interface GeneratedFile {
  path: string
  content: string
}

export interface ValidationResult {
  valid: boolean
  errors: string[]
  warnings: string[]
}
