UNPKG

@remcostoeten/fync

Version:

A unified TypeScript library for easy access to popular APIs (GitHub, Spotify, GitLab, etc.)

37 lines 1.31 kB
type THttpClient = { get<T>(path: string, params?: Record<string, string | number | boolean>): Promise<{ data: T; }>; getPaginated?<T>(path: string, params?: Record<string, string | number | boolean>): Promise<{ data: T[]; nextUrl?: string; }>; }; type TBaseConfig = { cache?: boolean; cacheTTL?: number; baseUrl?: string; }; type TRequestOptions = { params?: Record<string, string | number | boolean>; cache?: boolean; cacheTTL?: number; paginate?: boolean; allPages?: boolean; }; type TChainableClient = { [key: string]: TChainableClient; } & { get<T = unknown>(options?: TRequestOptions): Promise<T>; paginate<T = unknown>(options?: TRequestOptions): Promise<T[]>; stream<T = unknown>(options?: TRequestOptions): AsyncGenerator<T, void, unknown>; path(): string; }; type TServiceConfig = { cacheKeyPrefix: string; supportsPagination?: boolean; defaultOptions?: Partial<TRequestOptions>; }; export declare function createChainableClient<TConfig extends TBaseConfig>(config: TConfig, httpClient: THttpClient, serviceConfig: TServiceConfig, pathSegments?: string[]): TChainableClient; export type { TChainableClient, TRequestOptions, TBaseConfig, TServiceConfig }; //# sourceMappingURL=factory.d.ts.map