Files
core/packages/api-client/interfaces/adapter.ts
Innei b22666694a chore: lint
Signed-off-by: Innei <tukon479@gmail.com>
2023-06-10 16:36:14 +08:00

37 lines
925 B
TypeScript

import type { RequestOptions } from './instance'
export type IAdaptorRequestResponseType<P> = Promise<
Record<string, any> & { data: P }
>
export type IRequestAdapter<T = any, Response = undefined> = Readonly<
(Response extends undefined ? {} : { responseWrapper: Response }) & {
default: T
get<P = unknown>(
url: string,
options?: Omit<RequestOptions, 'data'>,
): IAdaptorRequestResponseType<P>
post<P = unknown>(
url: string,
options: Partial<RequestOptions>,
): IAdaptorRequestResponseType<P>
patch<P = unknown>(
url: string,
options: Partial<RequestOptions>,
): IAdaptorRequestResponseType<P>
delete<P = unknown>(
url: string,
options?: Omit<RequestOptions, 'data'>,
): IAdaptorRequestResponseType<P>
put<P = unknown>(
url: string,
options: Partial<RequestOptions>,
): IAdaptorRequestResponseType<P>
}
>