gitscope
← marzneshin / v0.3.0-alpha11 / dashboard/src/components/entity-table/hooks/use-entity-query.ts
https://dev.kronoz.win/r/marzneshin.git
dashboard/src/components/entity-table/hooks/use-entity-query.ts · TypeScript
Blame Raw
 1import { z } from "zod";
 2
 3const UseEntityQueryPropsSchema = z.object({
 4    page: z.number().gte(1),
 5    size: z.number().gte(1).lte(100),
 6    search: z.string().optional()
 7})
 8
 9export interface SortableEntitySortQueryProps {
10    sortBy: string
11    desc: boolean
12}
13
14export type UseEntityQueryProps = z.infer<typeof UseEntityQueryPropsSchema & SortableEntitySortQueryProps>
15
16export type QueryKey = [string, number, number, string]
17export type SortableQueryKey = [string, number, number, string, string, boolean]
18
19export interface QueryKeyType<QT> {
20    queryKey: QT
21}
22
23export type EntityQueryKeyType = QueryKeyType<SortableQueryKey | QueryKey>
24
25interface FetchEntityResult<T> {
26    pageCount: number
27    entity: T[]
28}
29
30export type FetchEntityReturn<T> = Promise<FetchEntityResult<T>>