import { defineCollection, z } from 'astro:content';

const cars = defineCollection({
  type: 'content',
  schema: ({ image }) =>
    z.object({
      make: z.string(),
      model: z.string(),
      year: z.number().int().min(1990).max(2030),
      price: z.number().int().positive(),
      mileage: z.number().int().nonnegative(),
      fuel: z.enum(['benzinas', 'dyzelinas', 'hibridas', 'elektra', 'dujos']),
      transmission: z.enum(['mechaninė', 'automatinė']),
      bodyType: z.enum(['sedanas', 'universalas', 'hečbekas', 'visureigis', 'kupė', 'kabrioletas', 'vienatūris']),
      color: z.string(),
      city: z.string(),
      drivetrain: z.enum(['priekiniai', 'galiniai', 'visi']).optional(),
      power: z.number().int().optional(),
      engineSize: z.number().optional(),
      firstRegistration: z.string().optional(),
      vin: z.string().optional(),
      photos: z.array(image()).min(1),
      sold: z.boolean().default(false),
      featured: z.boolean().default(false),
      publishedAt: z.date(),
    }),
});

export const collections = { cars };
