import { z } from 'zod';

export const DeploymentSchema = z.object({
  id: z.string(),
  serviceId: z.string(),
  version: z.string(),
  status: z.enum(['running', 'success', 'failed']),
  logs: z.string(),
  triggeredBy: z.string(),
  triggeredAt: z.string(),
  completedAt: z.string().optional(),
  productId: z.string(),
});

export type Deployment = z.infer<typeof DeploymentSchema>;

export const CreateDeploymentSchema = DeploymentSchema.partial({
  id: true,
  status: true,
  logs: true,
  triggeredAt: true,
  completedAt: true,
});

export type CreateDeployment = z.infer<typeof CreateDeploymentSchema>;

export const DeploymentParamsSchema = z.object({
  id: z.string().min(1, 'Deployment ID is required'),
});

export type DeploymentParams = z.infer<typeof DeploymentParamsSchema>;

export const TriggerDeploymentParamsSchema = z.object({
  serviceId: z.string().min(1, 'Service ID is required'),
});

export type TriggerDeploymentParams = z.infer<typeof TriggerDeploymentParamsSchema>;

export const QueryParamsSchema = z.object({
  limit: z.string().optional().transform(val => val ? parseInt(val, 10) : 20),
});

export type QueryParams = z.infer<typeof QueryParamsSchema>;
