import { StringMap, Primitive, TypeResult } from "./common"; import { PopulateClause, StrapiUser } from "./core"; import { OnlyStrings } from "./utils"; type SendStrapiContextFunction = (...args: unknown[]) => void; type ThrowStrapiContextFunction = (...args: unknown[]) => void; type StrapiHTTPErrorConstructor> = (message?: string, details?: T) => any export type StrapiRequestContext< TBody extends {} = StringMap, TQuery extends {} = StringMap, TParams extends {} = StringMap > = { request: StrapiRequest; query: TQuery; params: TParams; pagination: StrapiPagination; sort: StringMap; state: StrapiRequestContextState; send: SendStrapiContextFunction; throw: ThrowStrapiContextFunction; // @see {https://github.com/jshttp/http-errors#list-of-all-constructors} notFound: StrapiHTTPErrorConstructor; badRequest: StrapiHTTPErrorConstructor; unauthorized: StrapiHTTPErrorConstructor; methodNotAllowed: StrapiHTTPErrorConstructor; internalServerError: StrapiHTTPErrorConstructor; notImplemented: StrapiHTTPErrorConstructor; }; export type StrapiRequest = { body?: TBody; }; export type StrapiRequestContextState = { user?: StrapiUser }; export type StrapiRequestQuery = { filters?: { threadOf?: number | string | null; [key: string]: any; } & {}; populate?: StrapiRequestQueryPopulateClause>; sort?: StringMap; fields?: StrapiRequestQueryFieldsClause>; pagination?: StrapiPagination; } export type StrapiRequestQueryFieldsClause = Array | '*'; export type StrapiRequestQueryPopulateClause = PopulateClause; export type StrapiPagination = { page?: number; pageSize?: number; start?: number; limit?: number; withCount?: boolean | string; }; export type StrapiResponseMetaPagination = TypeResult< Pick & { pageCount?: number; total?: number; } >; export type StrapiResponseMeta = { pagination: StrapiResponseMetaPagination; }; export type StrapiPaginatedResponse = { data: Array; meta?: StrapiResponseMeta; }; export type StrapiQueryParams = StringMap; export type StrapiQueryParamsParsed = StringMap; export type StrapiQueryParamsParsedOrderBy = string | Array; type StrapiQueryParamsParsedFilterValue = | Primitive | Partial>; export type StrapiQueryParamsParsedFilters = Partial, StrapiQueryParamsParsedFilterValue>>>;