import { z } from 'zod';

export const SquashSpecSchema = z.object({
  cwd: z.string().min(1),
  contextName: z.string().min(1),
  description: z.string().min(1),
  /** Target a single assembly; otherwise all assemblies of the context. */
  assembly: z.string().optional(),
  /** Base branch to squash onto. Defaults to origin/develop, falling back to origin/main. */
  baseBranch: z.string().optional(),
  /** Dry-run: plan without mutating files. */
  dryRun: z.boolean().optional().default(false),
  /** When true, skip git-based detection and assume every .cs file in the migrations dir except parent's is branch-only (dangerous). Default false. */
  aggressive: z.boolean().optional().default(false),
});
export type SquashSpec = z.infer<typeof SquashSpecSchema>;

export interface SquashAssemblyResult {
  assemblyName: string;
  contextName: string;
  backupDir: string | null;
  deletedFiles: string[];
  resetSnapshot: boolean;
  newMigrationName: string | null;
  dotnetOutput: string;
  success: boolean;
  error?: string;
}

export interface SquashResult {
  success: boolean;
  cwd: string;
  baseBranch: string;
  currentBranch: string;
  assemblies: SquashAssemblyResult[];
  warnings: string[];
  error?: string;
}
