export type CollectionItem = { [key: string]: any; }; export type SortFunction = (a: T, b: T) => number; export type Sort = string | [string, 'asc' | 'desc'] | SortFunction; export type Range = [number, number] | [number]; export type FilterFunction = (item: T) => boolean; export type FilterObject = CollectionItem & { q?: string; }; export type Filter = FilterObject | FilterFunction; export type Query = { filter?: Filter; sort?: Sort; range?: Range; embed?: Embed; }; export type QueryFunction = (name: string) => Query; export type Predicate = (item: T) => boolean; export type Embed = string | string[]; export type BaseResponse = { status: number; body?: Record | Record[]; headers: { [key: string]: string; }; }; export type FakeRestContext = { url?: string; headers?: Headers; method?: string; collection?: string; single?: string; requestBody: Record | undefined; params: { [key: string]: any; }; }; export type NormalizedRequest = Pick; export type APIServer = { baseUrl?: string; handle: (context: FakeRestContext) => Promise; };