import { z } from 'zod';

const actionStatusSchema = z.enum(['PENDING', 'IN_PROGRESS', 'COMPLETED', 'DISMISSED']);
const actionTypeSchema = z.enum(['CALL_BACK', 'SEND_EMAIL', 'BOOK_APPOINTMENT', 'ESCALATE', 'CUSTOM']);

export const listActionsQuerySchema = z.object({
  conversationId: z.string().optional(),
  status: actionStatusSchema.optional(),
  assignedTo: z.string().optional(),
  limit: z.coerce.number().int().min(1).max(100).default(50),
  offset: z.coerce.number().int().min(0).default(0),
});

export const createActionSchema = z.object({
  conversationId: z.string().min(1),
  type: actionTypeSchema,
  title: z.string().min(1).max(200),
  description: z.string().max(2000).optional(),
  dueAt: z.string().datetime().optional(),
  assignedTo: z.string().optional(),
  metadata: z.record(z.unknown()).optional(),
});

export const updateActionSchema = z.object({
  status: actionStatusSchema.optional(),
  title: z.string().min(1).max(200).optional(),
  description: z.string().max(2000).optional().nullable(),
  dueAt: z.string().datetime().optional().nullable(),
  assignedTo: z.string().optional().nullable(),
  metadata: z.record(z.unknown()).optional(),
});

export const actionIdParamSchema = z.object({
  id: z.string().min(1),
});

export const conversationIdParamSchema = z.object({
  id: z.string().min(1),
});

