mirror of
https://github.com/movie-web/providers.git
synced 2025-09-13 14:53:24 +00:00
Better types for fetchers
This commit is contained in:
@@ -28,12 +28,12 @@ export type FetcherResponse<T = any> = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// This is the version that will be inputted by library users
|
// This is the version that will be inputted by library users
|
||||||
export type Fetcher<T = any> = {
|
export type Fetcher = {
|
||||||
(url: string, ops: DefaultedFetcherOptions): Promise<FetcherResponse<T>>;
|
<T = any>(url: string, ops: DefaultedFetcherOptions): Promise<FetcherResponse<T>>;
|
||||||
};
|
};
|
||||||
|
|
||||||
// This is the version that scrapers will be interacting with
|
// This is the version that scrapers will be interacting with
|
||||||
export type UseableFetcher<T = any> = {
|
export type UseableFetcher = {
|
||||||
(url: string, ops?: FetcherOptions): Promise<T>;
|
<T = any>(url: string, ops?: FetcherOptions): Promise<T>;
|
||||||
full: (url: string, ops?: FetcherOptions) => Promise<FetcherResponse<T>>;
|
full: <T = any>(url: string, ops?: FetcherOptions) => Promise<FetcherResponse<T>>;
|
||||||
};
|
};
|
||||||
|
@@ -2,14 +2,8 @@ import { MovieMedia, ShowMedia } from '@/entrypoint/utils/media';
|
|||||||
import { UseableFetcher } from '@/fetchers/types';
|
import { UseableFetcher } from '@/fetchers/types';
|
||||||
|
|
||||||
export type ScrapeContext = {
|
export type ScrapeContext = {
|
||||||
proxiedFetcher: {
|
proxiedFetcher: UseableFetcher;
|
||||||
<T>(...params: Parameters<UseableFetcher<T>>): ReturnType<UseableFetcher<T>>;
|
fetcher: UseableFetcher;
|
||||||
full<T>(...params: Parameters<UseableFetcher<T>['full']>): ReturnType<UseableFetcher<T>['full']>;
|
|
||||||
};
|
|
||||||
fetcher: {
|
|
||||||
<T>(...params: Parameters<UseableFetcher<T>>): ReturnType<UseableFetcher<T>>;
|
|
||||||
full<T>(...params: Parameters<UseableFetcher<T>['full']>): ReturnType<UseableFetcher<T>['full']>;
|
|
||||||
};
|
|
||||||
progress(val: number): void;
|
progress(val: number): void;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user