import { z } from 'zod';
import { FilterGroupSchema } from './filter-group.schema';
import { FilterInputSchema } from './filter-input.schema';
import { OrderByOptionSchema } from './order-by-option.schema';

/**
 * Top-level schema representing the complete filter configuration.
 * Combines filter groups, input fields, and ordering options into a unified structure.
 *
 * @property groups - Collection of filter groups for organizing inputs into categories
 * @property inputs - All filter input controls available to the user
 * @property orderBy - Available sorting options for the filtered results
 */
export const FilterSchema = z
  .object({
    groups: z
      .array(FilterGroupSchema)
      .describe(
        'Collection of filter groups that organize inputs into logical categories for better user experience.',
      ),
    inputs: z
      .array(FilterInputSchema)
      .describe(
        'Array of all filter input controls available to the user across all groups.',
      ),
    orderBy: z
      .array(OrderByOptionSchema)
      .describe(
        'Available sorting options that users can apply to the filtered results.',
      ),
  })
  .describe('Filter');

export type Filter = z.infer<typeof FilterSchema>;
