import { z } from "zod";

const MetaDataSchema = z.object({
  limit: z.number(),
  offset: z.number(),
  page: z.number(),
  pages: z.number(),
  total: z.number(),
  has_more: z.boolean().optional(),
  next_cursor: z.string().optional(),
  prev_cursor: z.string().optional(),
});

export function createApiResponseSchema<T extends z.ZodTypeAny>(dataSchema: T) {
  return z.object({
    data: dataSchema,
    meta: MetaDataSchema.optional(),
    message: z.string(),
    code: z.number().optional(),
    success: z.boolean(),
  });
}

export type IMetaData = z.infer<typeof MetaDataSchema>;
