import { z } from 'zod';

const listContentQuerySchema = z.object({
  slug: z.string().optional(),
  limit: z.coerce.number().min(1).max(100).optional().default(20),
  offset: z.coerce.number().min(0).optional().default(0)
});
z.object({
  slug: z.string().min(1, "Slug is required"),
  // Use passthrough object instead of z.record(z.unknown()) due to Zod v4 bug
  data: z.object({}).passthrough()
});
z.object({
  slug: z.string().min(1, "Slug is required").optional(),
  // Use passthrough object instead of z.record(z.unknown()) due to Zod v4 bug
  data: z.object({}).passthrough().optional()
});
const contentTypeResponseSchema = z.object({
  id: z.string(),
  name: z.string(),
  slug: z.string(),
  description: z.string().nullable().optional(),
  jsonSchema: z.string(),
  createdAt: z.string(),
  updatedAt: z.string()
});
const contentItemResponseSchema = z.object({
  id: z.string(),
  contentTypeId: z.string(),
  slug: z.string(),
  data: z.string(),
  authorId: z.string().nullable().optional(),
  createdAt: z.string(),
  updatedAt: z.string()
});
const contentItemWithDataResponseSchema = contentItemResponseSchema.extend({
  // Use passthrough object instead of z.record(z.unknown()) due to Zod v4 bug
  parsedData: z.object({}).passthrough(),
  contentType: contentTypeResponseSchema.optional()
});
z.object({
  items: z.array(contentItemWithDataResponseSchema),
  total: z.number(),
  limit: z.number(),
  offset: z.number()
});

export { contentItemResponseSchema, contentItemWithDataResponseSchema, contentTypeResponseSchema, listContentQuerySchema };
