import { z } from 'zod';

/**
 * Schema representing a sorting criterion in a query.
 * This defines how results should be ordered when returned from a data source.
 *
 * @property by - Field identifier to sort by (corresponds to a property in the data)
 * @property label - Human-readable name for this sort option
 * @property desc - Whether the sort should be in descending order (true) or ascending (false)
 * @property selected - Whether this ordering option is currently active
 */
export const QueryOrderBySchema = z.object({
  by: z
    .string()
    .describe(
      'Field identifier to sort by, matching a property name in the data model.',
    ),
  label: z
    .string()
    .describe('Human-readable name for this sort option to display in the UI.'),
  desc: z
    .boolean()
    .describe(
      'Sort direction flag: true for descending order (Z-A, newest first), false for ascending (A-Z, oldest first).',
    ),
  selected: z
    .boolean()
    .describe(
      'Indicates whether this ordering option is currently active in the query.',
    ),
});

export type QueryOrderBy = z.infer<typeof QueryOrderBySchema>;
