/**
 * Public roadmap types — schemas for unauthenticated endpoints.
 */

import { z } from 'zod';
import { ITEM_TYPES, ITEM_PRIORITIES } from '../items/types.js';

export const PublicSubmitSchema = z.object({
  productId: z.string().min(1).optional(),
  type: z.enum(ITEM_TYPES).default('feature'),
  priority: z.enum(ITEM_PRIORITIES).default('medium'),
  title: z.string().min(1).max(500),
  description: z.string().max(5000).default(''),
  email: z.string().email(),
  name: z.string().min(1).max(200),
});

export const PublicVoteSchema = z.object({
  email: z.string().email(),
});

export const PublicRoadmapQuerySchema = z.object({
  productId: z.string().optional(),
  type: z.enum(ITEM_TYPES).optional(),
  status: z.enum(['open', 'in_progress', 'done'] as const).optional(),
  q: z.string().optional(),
  sortBy: z.enum(['createdAt', 'voteCount']).default('voteCount'),
  sortOrder: z.enum(['asc', 'desc']).default('desc'),
  limit: z.coerce.number().min(1).max(100).default(50),
  offset: z.coerce.number().min(0).default(0),
});

export type PublicSubmitInput = z.infer<typeof PublicSubmitSchema>;
export type PublicVoteInput = z.infer<typeof PublicVoteSchema>;
export type PublicRoadmapQuery = z.infer<typeof PublicRoadmapQuerySchema>;
