@peacockproject/core
Version:
Type definitions for Peacock's core.
90 lines (89 loc) • 3.74 kB
TypeScript
import { HookMap, SyncHook } from "../hooksImpl";
import { GameVersion, HitsCategoryCategory } from "../types/types";
/**
* The filters supported for HitsCategories.
* Supported for "MyPlaylist" "MyHistory" and "MyContracts".
*/
type ContractFilter = "default" | "all" | "completed" | "failed" | string;
export declare class HitsCategoryService {
/**
* A hook map for all the hits categories.
*/
hitsCategories: HookMap<SyncHook<[
/** contractIds */ string[],
/** gameVersion */ GameVersion,
/** userId */ string,
/** filter */ ContractFilter
]>>;
/**
* Hits categories that should not be automatically paginated.
*/
paginationExempt: string[];
realtimeFetched: string[];
filterSupported: string[];
/**
* The number of hits per page.
*/
hitsPerPage: number;
constructor();
/**
* Enable the default hits categories.
*/
_useDefaultHitsCategories(): void;
private fetchFromOfficial;
/**
* Writes the contracts array with the repoId of all contracts in the contracts folder that meet the player completion requirement specified by the type.
* @param gameVersion The gameVersion the player is playing on.
* @param contracts The array to write into.
* @param userId The Id of the user.
* @param type A filter for the contracts to fetch.
*/
private writeMyContracts;
/**
* Gets the contracts array with the repoId of all contracts of the specified type that is in the player's favorite list.
* @param gameVersion The gameVersion the player is playing on.
* @param userId The Id of the user.
* @param type A filter for the contracts to fetch.
* @returns The resulting array.
*/
private getMyPlaylist;
/**
* This function will get or set the default filter of a category for a user, depending on the "type" passed.
* If the type is "default", then it will get the default filter and return it.
* Otherwise, it will set the default filter to the type passed, and return the type itself.
* @param gameVersion The GameVersion that the user is playing on.
* @param userId The ID of the user.
* @param type The type of the filter.
* @param category The category in question.
* @returns The filter to use for this request.
*/
private getOrSetDefaultFilter;
/**
* Gets the contracts array with the repoId of all contracts of the specified type that the player has played before, sorted by LastPlayedTime.
* @param gameVersion The gameVersion the player is playing on.
* @param userId The Id of the user.
* @param type A filter for the contracts to fetch.
* @returns The resulting array.
*/
private getMyHistory;
/**
* For a user, returns whether a contract is of the given type of completion.
* @param played The user's played contracts.
* @param type The type of completion in question.
* @param contractId The id of the contract.
* @returns A boolean, denoting the result.
*/
private isContractOfType;
/**
* Generate a {@link HitsCategoryCategory} object for the current page.
*
* @param categoryName The hits category's ID (the key for the hooks map).
* @param pageNumber The current page's number.
* @param gameVersion The game version being used for the request.
* @param userId The current user's ID.
* @returns The hits category object.
*/
paginateHitsCategory(categoryName: string, pageNumber: number, gameVersion: GameVersion, userId: string): Promise<HitsCategoryCategory | undefined>;
}
export declare const hitsCategoryService: HitsCategoryService;
export {};