import { z } from 'zod';
import { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
import { ApiResponseSchema } from '#contracts/shared';

extendZodWithOpenApi(z);

// Request body schemas for validation and OpenAPI documentation
export const IncidentFileCreateBodySchema = z.object({
	incident_id: z.string().min(1).max(200), // TODO: adjust validation rules (type, min, max, etc.)
	file_ids: z.array(z.string().min(1).max(200)).min(1), // TODO: adjust validation rules (type, min, max, etc.)
}).openapi('IncidentFileCreateBody');

export const IncidentFileUpdateBodySchema = z.object({
	incident_id: z.string().min(1).max(200).optional(), // TODO: adjust validation rules (type, min, max, etc.)
	file_id: z.string().min(1).max(200).optional(), // TODO: adjust validation rules (type, min, max, etc.)
}).openapi('IncidentFileUpdateBody');

// Response schemas for OpenAPI documentation
export const IncidentFileSchema = z.object({
	id: z.uuid(),
	incident_id: z.string().min(1).max(200), // TODO: adjust validation rules (type, min, max, etc.)
	file_id: z.string().min(1).max(200), // TODO: adjust validation rules (type, min, max, etc.)
	created_at: z.iso.datetime(),
	updated_at: z.iso.datetime().nullable(),
	deleted_at: z.iso.datetime().nullable(),
}).openapi('IncidentFile');

export const IncidentFileListDataSchema = z.object({
	count: z.number(),
	rows: z.array(IncidentFileSchema),
	page: z.number(),
	pageSize: z.number(),
}).openapi('IncidentFileListData');

export const IncidentFileResponseSchema = ApiResponseSchema(IncidentFileSchema).openapi('IncidentFileResponse');

export const IncidentFileListResponseSchema = ApiResponseSchema(IncidentFileListDataSchema).openapi('IncidentFileListResponse');
