34 lines
978 B
TypeScript
34 lines
978 B
TypeScript
import { z } from 'zod';
|
|
|
|
/**
|
|
* Schema for querying module records via the module_query() RPC.
|
|
*/
|
|
export const FilterSchema = z.object({
|
|
field: z.string().min(1),
|
|
operator: z.enum(['eq', 'neq', 'gt', 'gte', 'lt', 'lte', 'like', 'is_null', 'not_null']),
|
|
value: z.string().optional(),
|
|
});
|
|
|
|
export type FilterInput = z.infer<typeof FilterSchema>;
|
|
|
|
export const ModuleQuerySchema = z.object({
|
|
moduleId: z.string().uuid(),
|
|
filters: z.array(FilterSchema).default([]),
|
|
sortField: z.string().optional(),
|
|
sortDirection: z.enum(['asc', 'desc']).default('asc'),
|
|
page: z.number().int().min(1).default(1),
|
|
pageSize: z.number().int().min(5).max(200).default(25),
|
|
search: z.string().optional(),
|
|
});
|
|
|
|
export type ModuleQueryInput = z.infer<typeof ModuleQuerySchema>;
|
|
|
|
export const PaginationSchema = z.object({
|
|
page: z.number(),
|
|
pageSize: z.number(),
|
|
total: z.number(),
|
|
totalPages: z.number(),
|
|
});
|
|
|
|
export type PaginationResult = z.infer<typeof PaginationSchema>;
|