import { BaseSettings, BaseOptions, BaseTemplateOptions, BaseInit, BaseTemplate, BaseCacheOption, ClientEndpoint, BaseRequest, BaseQuery, ResponseOrTypedResponse } from '@dvcol/base-http-client'; import { Primitive, RecursiveRecord } from '@dvcol/common-utils/common/models'; import { CancellablePromise } from '@dvcol/common-utils/http/fetch'; import { TraktApiFilters } from '../api/trakt-api.filters.js'; /** * Pagination data parsed from {@link TraktApiResponse} headers. * * @see [pagination]{@link https://trakt.docs.apiary.io/#introduction/pagination} */ type TraktClientPagination = { itemCount: number; pageCount: number; limit: number; page: number; }; /** * Trakt.tv API client settings. */ type TraktClientSettings = BaseSettings<{ /** Get this from your app settings. */ client_id: string; /** Get this from your app settings. */ client_secret: string; /** URI specified in your app settings. */ redirect_uri: string; /** The consumer client identifier */ useragent: string; }>; /** * Trakt.tv API client options. */ type TraktClientOptions = BaseOptions; /** * By default, all methods will return minimal info for movies, shows, episodes, people, and users. * Minimal info is typically all you need to match locally cached items and includes the title, year, and ids. * However, you can request different extended levels of information by adding ?extended={level} to the URL. * Send a comma separated string to get multiple types of extended info. * * node: This returns a lot of extra data, so please only use extended parameters if you actually need them! * @see [extended-info]{@link https://trakt.docs.apiary.io/#introduction/extended-info} */ declare const TraktApiExtended: { readonly Full: "full"; readonly Metadata: "metadata"; readonly GuestStars: "guest_stars"; readonly Episodes: "episodes"; readonly NoSeasons: "noseasons"; readonly Vip: "vip"; readonly Comments: "comments"; readonly Images: "images"; readonly All: "all"; }; /** * Represents the supported extensions for the Trakt API. * @see {TraktApiExtended} * @see [extended-info]{@link https://trakt.docs.apiary.io/#introduction/extended-info} */ type TraktApiExtends = (typeof TraktApiExtended)[keyof typeof TraktApiExtended]; /** * Represents options that can be used in a Trakt API template. */ type TraktApiTemplateOptions = BaseTemplateOptions & { /** If the method supports or requires vip status */ vip?: boolean | 'enhanced'; /** If the method supports or requires authentication */ auth?: boolean | 'optional'; /** If the method supports or requires pagination */ pagination?: boolean | 'optional'; /** If the method receive or return emoji codes */ emoji?: boolean; /** If the method supports extended information */ extended?: TraktApiExtends[]; /** If the method supports filtering */ filters?: TraktApiFilters[]; }; type TraktApiInit = BaseInit; type TraktApiTemplate = BaseTemplate>; type TraktClientCachedEndpoint, Response = unknown> = { evict: (param?: Parameter, init?: BaseInit) => Promise; } & ((param?: Parameter, init?: BaseInit, cacheOptions?: BaseCacheOption) => CancellablePromise>); interface TraktClientEndpoint, Response = unknown> { (param?: Parameter, init?: TraktApiInit): CancellablePromise>; } declare class TraktClientEndpoint, Response = unknown, Cache extends boolean = true> extends ClientEndpoint> { cached: Cache extends true ? Omit & TraktClientCachedEndpoint : never; } type TraktApiRequest = BaseRequest; type TraktApiQuery = BaseQuery; type TraktApiResponseLimit = { name: 'UNAUTHED_API_GET_LIMIT'; period: 300; limit: 1000; remaining: 0; until: '2020-10-10T00:24:00Z'; }; type TraktApiResponse = ResponseOrTypedResponse & { pagination?: TraktClientPagination; interval?: { start?: string | null; end?: string | null; }; sort?: { by?: string | null; how?: string | null; }; appliedSort?: { by?: string | null; how?: string | null; }; vip?: { url?: string | null; user?: string | null; limit?: string | null; }; limit?: { rate?: TraktApiResponseLimit; retry?: number; }; }; /** * Page defaults to 1 and limit to 10. * * @see [pagination]{@link https://trakt.docs.apiary.io/#introduction/pagination} */ type TraktApiPagination = { /** Number of page of results to be returned. (defaults to 1) */ page?: number; /** Number of results to return per page. (defaults to 10) */ limit?: number; }; /** * Filters are optional parameters you can send to filter the data returned. * * @see [filters]{@link https://trakt.docs.apiary.io/#introduction/filters} */ type TraktApiParamsFilter = F extends TraktApiFilters ? { /** * An optional filter to refine query * * @see [filters]{@link https://trakt.docs.apiary.io/#introduction/filters} */ filters?: Partial>; } : Record; type TraktApiParamsExtended = { /** * Increases the verbosity of the response. * * Note: This returns a lot of extra data, so please only use extended parameters if you actually need them! * * @see [extended-info]{@link https://trakt.docs.apiary.io/#introduction/extended-info} */ extended?: E | E[]; }; type TraktApiParamsPagination = { /** * An empty pagination will load 1 page of 10 items by default on paginated endpoints. * An empty pagination on optionally paginated endpoints will return the full response. * * @see [pagination]{@link https://trakt.docs.apiary.io/#introduction/pagination} */ pagination?: TraktApiPagination; }; type TraktApiParams = TraktApiParamsExtended & TraktApiParamsFilter & (P extends true ? T & TraktApiParamsPagination : T); type PartialTraktApiParams = (T extends void ? Record : T) & (E extends void ? Record : TraktApiParamsExtended) & (F extends void ? Record : TraktApiParamsFilter) & (P extends false ? Record : TraktApiParamsPagination); type ITraktApi = { [key: string]: TraktClientEndpoint | ITraktApi; }; declare const TraktApiHeaders: { /** Interval to wait after rate limit is reached */ readonly RetryAfter: "Retry-After"; /** {"name":"UNAUTHED_API_GET_LIMIT","period":300,"limit":1000,"remaining":0,"until":"2020-10-10T00:24:00Z"} */ readonly XRatelimit: "X-Ratelimit"; /** https://trakt.tv/vip */ readonly XUpgradeURL: "X-Upgrade-URL"; /** true or false */ readonly XVipUser: "X-VIP-User"; /** Limit allowed. */ readonly XAccountLimit: "X-Account-Limit"; /** Current page */ readonly XPaginationPage: "X-Pagination-Page"; /** Items per page. */ readonly XPaginationLimit: "X-Pagination-Limit"; /** Total number of pages. */ readonly XPaginationPageCount: "X-Pagination-Page-Count"; /** Total number of items. */ readonly XPaginationItemCount: "X-Pagination-Item-Count"; /** Version of the Trakt.tv api */ readonly TraktApiVersion: "trakt-api-version"; /** Client id for the trakt app */ readonly TraktApiKey: "trakt-api-key"; /** Start of the queried interval */ readonly XStartDate: "X-Start-Date"; /** End of the queried interval */ readonly XEndDate: "X-End-Date"; /** Desired sort by within possible values: rank, added, title, released, runtime, popularity, percentage, votes, my_rating, random, watched, and collected. */ readonly XSortBy: "X-Sort-By"; /** Desired sort order: asc or desc. */ readonly XSortHow: "X-Sort-How"; /** Actual sort by within possible values: rank, added, title, released, runtime, popularity, percentage, and votes */ readonly XAppliedSortBy: "X-Applied-Sort-By"; /** Actual sort order asc or desc. */ readonly XAppliedSortHow: "X-Applied-Sort-How"; /** The user agent of the consumer client */ readonly UserAgent: "User-Agent"; /** The content type of the payload */ readonly ContentType: "Content-Type"; /** The authorization token bearer */ readonly Authorization: "Authorization"; /** The authentication methods ("challenges") that might be used to gain access to a specific resource. */ readonly Authenticate: "www-authenticate"; }; export { type ITraktApi, type PartialTraktApiParams, TraktApiExtended, type TraktApiExtends, TraktApiHeaders, type TraktApiInit, type TraktApiPagination, type TraktApiParams, type TraktApiParamsExtended, type TraktApiParamsFilter, type TraktApiParamsPagination, type TraktApiQuery, type TraktApiRequest, type TraktApiResponse, type TraktApiResponseLimit, type TraktApiTemplate, type TraktApiTemplateOptions, type TraktClientCachedEndpoint, TraktClientEndpoint, type TraktClientOptions, type TraktClientPagination, type TraktClientSettings };