import { z } from 'zod';
import { OrderByDirectionSchema } from './order-by-direction.schema';

/**
 * Schema for defining sort options available to the user.
 * Each option represents a different field or property that can be used for ordering results.
 *
 * @property by - Field identifier to sort by (corresponds to a property in the data)
 * @property label - Human-readable name for this sort option to display in the UI
 * @property dir - Sort direction ('asc' for ascending or 'desc' for descending)
 * @property selected - Whether this ordering option is currently active
 */
export const OrderByOptionSchema = z
  .object({
    by: z
      .string()
      .describe(
        'Field identifier to sort by, matching a property in the data model.',
      ),
    label: z
      .string()
      .describe(
        'Human-readable name for this sort option to display in the UI.',
      ),
    dir: OrderByDirectionSchema.describe(
      'Sort direction, either "asc" for ascending or "desc" for descending.',
    ),
    selected: z
      .boolean()
      .default(false)
      .describe('Indicates whether this ordering option is currently active.'),
  })
  .describe('OrderByOption');

export type OrderByOption = z.infer<typeof OrderByOptionSchema>;
