// ═══════════════════════════════════════════════════════════
// Task Zod Schemas — Runtime validation
// ═══════════════════════════════════════════════════════════

import { z } from "zod";

export const TaskDecisionSchema = z.enum(["approved", "rejected", "deferred", "escalated"]);
export const TaskTypeSchema = z.enum(["approval", "review", "decision", "manual_action", "fix_required"]);
export const TaskStatusSchema = z.enum(["pending", "claimed", "in_progress", "completed", "expired", "escalated"]);

export const CompleteTaskSchema = z.object({
  decision: TaskDecisionSchema,
  notes: z.string().optional(),
  decisionData: z.record(z.unknown()).optional(),
});

export const ReassignTaskSchema = z.object({
  assigneeId: z.string().uuid(),
  reason: z.string().optional(),
});

export const BulkTaskSchema = z.object({
  action: z.enum(["approve", "reject", "defer"]),
  taskIds: z.array(z.string().uuid()).min(1),
  notes: z.string().optional(),
});

export const ApproveBodySchema = z.object({
  notes: z.string().optional(),
  conditions: z.array(z.string()).optional(),
});

export const RejectBodySchema = z.object({
  reason: z.string().min(1),
  requestedChanges: z.array(z.string()).optional(),
});

export const EscalateBodySchema = z.object({
  escalateTo: z.string().uuid().optional(),
  reason: z.string().min(1),
});
