import { z } from 'zod'

export const PaginationSchema = z.object({
  page: z.coerce.number().int().min(1).default(1),
  limit: z.coerce.number().int().min(1).max(100).default(25),
  sort: z.string().max(50).optional(),
  order: z.enum(['asc', 'desc']).default('asc'),
  q: z.preprocess((v) => (v === '' ? undefined : v), z.string().max(255).optional()),
})
export type PaginationInput = z.infer<typeof PaginationSchema>

export interface PaginatedResponse<T> {
  data: T[]
  pagination: {
    page: number
    limit: number
    total: number
    totalPages: number
  }
}
