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

export const {{ modelUpperCase }}UpdateBodySchema = z.object({
{{#mutateFields}}
	{{ name }}: z.string().min(1).max(200).optional(), // TODO: adjust validation rules (type, min, max, etc.)
{{/mutateFields}}
}).openapi('{{ modelUpperCase }}UpdateBody');

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

export const {{ modelUpperCase }}ListDataSchema = z.object({
	count: z.number(),
	rows: z.array({{ modelUpperCase }}Schema),
	page: z.number(),
	pageSize: z.number(),
}).openapi('{{ modelUpperCase }}ListData');

export const {{ modelUpperCase }}ResponseSchema = ApiResponseSchema({{ modelUpperCase }}Schema).openapi('{{ modelUpperCase }}Response');

export const {{ modelUpperCase }}ListResponseSchema = ApiResponseSchema({{ modelUpperCase }}ListDataSchema).openapi('{{ modelUpperCase }}ListResponse');
