UNPKG

rapiq

Version:

A tiny library which provides utility types/functions for request and response query handling.

32 lines 1.59 kB
import type { Parameter, URLParameter } from '../constants'; import type { FieldsParseOptions, FieldsParseOutput, FiltersParseOptions, FiltersParseOutput, PaginationParseOptions, PaginationParseOutput, RelationsParseOptions, RelationsParseOutput, SortParseOptions, SortParseOutput } from '../parameter'; import type { ObjectLiteral, ObjectLiteralKeys } from '../types'; export type ParseInput = { [K in `${Parameter}` | `${URLParameter}`]?: unknown; }; export type ParseParametersOptions<T extends ObjectLiteral = ObjectLiteral> = ObjectLiteralKeys<{ [Parameter.FIELDS]?: FieldsParseOptions<T> | boolean; [Parameter.FILTERS]?: FiltersParseOptions<T> | boolean; [Parameter.RELATIONS]?: RelationsParseOptions<T> | boolean; [Parameter.PAGINATION]?: PaginationParseOptions | boolean; [Parameter.SORT]?: SortParseOptions<T> | boolean; }>; export type ParseParametersOutput = ObjectLiteralKeys<{ [Parameter.FIELDS]?: FieldsParseOutput; [Parameter.FILTERS]?: FiltersParseOutput; [Parameter.RELATIONS]?: RelationsParseOutput; [Parameter.PAGINATION]?: PaginationParseOutput; [Parameter.SORT]?: SortParseOutput; }>; export type ParseOptions<T extends ObjectLiteral = ObjectLiteral> = ParseParametersOptions<T> & { defaultPath?: string; throwOnFailure?: boolean; }; export type ParseOutput = ParseParametersOutput & { defaultPath?: string; }; export type QueryParserOptions<T extends ObjectLiteral = ObjectLiteral> = { defaultPath?: string; throwOnFailure?: boolean; } & ParseParametersOptions<T>; //# sourceMappingURL=types.d.ts.map