// ═══════════════════════════════════════════════════════════
// Pipeline Zod Schemas — Runtime validation
// ═══════════════════════════════════════════════════════════

import { z } from "zod";

export const PipelineStatusSchema = z.enum(["active", "paused", "completed", "failed", "archived"]);
export const PrioritySchema = z.enum(["critical", "high", "medium", "low"]);
export const PipelineTemplateSchema = z.enum(["mcp-server-standard", "mcp-server-minimal", "mcp-server-enterprise"]);
export const PipelineStageSchema = z.enum([
  "intake", "scaffolding", "building", "testing",
  "review", "staging", "production", "published",
]);

export const CreatePipelineSchema = z.object({
  name: z.string().min(1).max(200),
  platform: z.string().min(1).max(100),
  template: PipelineTemplateSchema.optional().default("mcp-server-standard"),
  priority: PrioritySchema.optional().default("medium"),
  config: z.record(z.unknown()).optional(),
  assigneeId: z.string().uuid().optional(),
});

export const UpdatePipelineSchema = z.object({
  priority: PrioritySchema.optional(),
  status: PipelineStatusSchema.optional(),
  config: z.record(z.unknown()).optional(),
  assigneeId: z.string().uuid().nullable().optional(),
  metadata: z.record(z.unknown()).optional(),
});

export const AdvanceStageSchema = z.object({
  targetStage: PipelineStageSchema.optional(),
  skipValidation: z.boolean().optional().default(false),
  notes: z.string().optional(),
});
