import { z } from 'zod' export type IPaginatedRespose = { cursor: string | null items: T[] } export const QueryParamFilter = z.object({ limit: z.coerce.number().optional(), cursor: z.coerce.string().nullable().optional(), includeDeleted: z.coerce.boolean().optional(), }) export type IQueryParamFilter = z.infer export const defaultQueryParamFilter = { limit: 10, sortBy: [{ name: 'created_by', order: 'ACS' }], } export const createQueryParamFilter = ( entitySchema: z.ZodObject, ) => { return entitySchema .partial() .merge(QueryParamFilter) .transform((data) => { const { limit, includeDeleted, cursor, ...search } = data return { limit, includeDeleted, cursor, search, } }) }