Files
core/packages/api-client/interfaces/adapter.ts
Innei e5ac04a650 chore: lint with sxzz config
Signed-off-by: Innei <i@innei.in>
2024-04-29 16:00:20 +08:00

37 lines
945 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>
}
>