Skip to main content
Version: 3.x.x

Request Extractors

The request generic type is huge, but essential. For this reason, to facilitate the work of you and ours, we have created special type extractors.


ExtractResponseType

type ResponseType = ExtractResponseType<typeof getUser>; // { id: number, name: string, email: string }

ExtractPayloadType

type PayloadType = ExtractPayloadType<typeof postFile>; // { id: number, file: string }

ExtractQueryParamsType

type QueryParamsType = ExtractQueryParamsType<typeof getUsers>; // { search?: string, roles: "Admin" | "User" }

ExtractErrorType

It will extract both - global and local error types.

type ErrorType = ExtractErrorType<typeof postUser>; // GlobalErrorType & LocalErrorType

ExtractGlobalErrorType

type ErrorType = ExtractGlobalErrorType<typeof postUser>; // GlobalErrorType

ExtractLocalErrorType

type ErrorType = ExtractLocalErrorType<typeof postUser>; // GlobalErrorType

ExtractParamsType

type UrlParamsType = ExtractParamsType<typeof patchUser>; // { userId: ParamType }

ExtractEndpointType

type EndpointType = ExtractEndpointType<typeof patchUser>; // "/users/:userId"

ExtractAdapterOptionsType

type AdapterOptionsType = ExtractAdapterOptionsType<typeof patchUser>; // { timeout?: number, ... }

ExtractAdapterReturnType

It will extract exact adapter response format with [response, error, status].

type AdapterReturnType = ExtractAdapterReturnType<typeof patchUser>; // [ResponseType, ErrorType, number]

ExtractHasDataType

If data was already added to the request.

type HasDataType = ExtractHasDataType<typeof patchUser>; // true | false

ExtractHasParamsType

If params were already added to the request.

type HasParamsType = ExtractHasParamsType<typeof patchUser>; // true | false

ExtractHasQueryParamsType

If query params were already added to the request.

type HasQueryParamsType = ExtractHasQueryParamsType<typeof patchUser>; // true | false