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 IncidentTypeCreateBodySchema = z.object({
	name: z.string().min(1).max(200), // TODO: adjust validation rules (type, min, max, etc.)
	description: z.string().min(1).max(200), // TODO: adjust validation rules (type, min, max, etc.)
}).openapi('IncidentTypeCreateBody');

export const IncidentTypeUpdateBodySchema = z.object({
	name: z.string().min(1).max(200).optional(), // TODO: adjust validation rules (type, min, max, etc.)
	description: z.string().min(1).max(200).optional(), // TODO: adjust validation rules (type, min, max, etc.)
}).openapi('IncidentTypeUpdateBody');

// Response schemas for OpenAPI documentation
export const IncidentTypeSchema = z.object({
	id: z.uuid(),
	name: z.string().min(1).max(200), // TODO: adjust validation rules (type, min, max, etc.)
	description: 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('IncidentType');

export const IncidentTypeListDataSchema = z.object({
	count: z.number(),
	rows: z.array(IncidentTypeSchema),
	page: z.number(),
	pageSize: z.number(),
}).openapi('IncidentTypeListData');

export const IncidentTypeResponseSchema = ApiResponseSchema(IncidentTypeSchema).openapi('IncidentTypeResponse');

export const IncidentTypeListResponseSchema = ApiResponseSchema(IncidentTypeListDataSchema).openapi('IncidentTypeListResponse');
