UNPKG

@straw-hat/fetcher

Version:
19 lines (18 loc) 758 B
export type PathParam<T> = [T] extends [never] ? {} : { path: T; }; export type QueryParam<T> = [T] extends [never] ? {} : { query: T; }; export type BodyParam<T> = [T] extends [never] ? {} : { body: T; }; export type OptionsParam = { options?: { signal?: AbortSignal; }; }; export type UrlParams<TPath = unknown, TQuery = unknown> = PathParam<TPath> & QueryParam<TQuery>; export type OperationParams<TPath = unknown, TQuery = unknown, TBody = unknown> = OptionsParam & UrlParams<TPath, TQuery> & BodyParam<TBody>; export declare function replacePathParams(urlPath: string, pathParams?: Record<string, any>): string; export declare function createUrlPath<TPath, TQuery>(urlPath: string, params: UrlParams<TPath, TQuery>): string;