UNPKG

enka-network-api

Version:

Enka-network API wrapper for Genshin Impact.

150 lines (149 loc) 5.88 kB
import { GenshinUser } from "../models/GenshinUser"; import { CachedAssetsManager } from "./CachedAssetsManager"; import { CharacterData } from "../models/character/CharacterData"; import { WeaponData } from "../models/weapon/WeaponData"; import { Costume } from "../models/character/Costume"; import { NameCard } from "../models/material/Material"; import { ArtifactData } from "../models/artifact/ArtifactData"; import { DetailedGenshinUser } from "../models/DetailedGenshinUser"; import { EnkaGameAccount, EnkaSystem, EnkaLibrary } from "enka-system"; import { GenshinCharacterBuild } from "../models/enka/GenshinCharacterBuild"; import { Material } from "../models/material/Material"; import { ArtifactSet } from "../models/artifact/ArtifactSet"; import { LanguageCode } from "./CachedAssetsManager"; import { JsonObject } from "config_file.js"; import { DynamicData } from "../models/assets/DynamicTextAssets"; import { Overwrite } from "../utils/ts_utils"; import { CustomImageBaseUrl, ImageBaseUrl } from "../models/assets/ImageAssets"; export declare const defaultImageBaseUrls: (ImageBaseUrl | CustomImageBaseUrl)[]; export interface UserCacheOptions { isEnabled: boolean; getter: ((key: string) => Promise<JsonObject>) | null; setter: ((key: string, data: JsonObject) => Promise<void>) | null; deleter: ((key: string) => Promise<void>) | null; } export interface EnkaClientOptions { enkaUrl: string; imageBaseUrls: ImageBaseUrl[]; userAgent: string; requestTimeout: number; defaultLanguage: LanguageCode; textAssetsDynamicData: DynamicData; cacheDirectory: string | null; showFetchCacheLog: boolean; userCache: UserCacheOptions; gameDataBaseUrl: string; /** For less rate limited cache update checking */ githubToken: string | null; readonly enkaSystem: EnkaSystem; } export declare const defaultEnkaClientOptions: Overwrite<EnkaClientOptions, { "enkaSystem": EnkaSystem | null; }>; export declare class EnkaClient implements EnkaLibrary<GenshinUser, GenshinCharacterBuild> { readonly hoyoType: 0; getUser(data: JsonObject): GenshinUser; getCharacterBuild(data: JsonObject, username: string, hash: string): GenshinCharacterBuild; /** The options the client was instantiated with */ readonly options: EnkaClientOptions; /** The genshin cache data manager of the client */ readonly cachedAssetsManager: CachedAssetsManager; private _tasks; /** @param options Options for the client */ constructor(options?: Partial<EnkaClientOptions>); /** * @param uid In-game UID of the user * @param collapse Whether to fetch rough user information (Very fast) * @returns DetailedGenshinUser if collapse is false, GenshinUser if collapse is true * @throws {EnkaNetworkError} */ _fetchUser<T extends boolean>(uid: number | string, collapse: T): Promise<T extends true ? GenshinUser : DetailedGenshinUser>; /** * @param uid In-game UID of the user */ fetchUser(uid: number | string): Promise<DetailedGenshinUser>; /** * @param uid In-game UID of the user */ fetchCollapsedUser(uid: number | string): Promise<GenshinUser>; /** * @param username enka.network username, not in-game nickname * @returns the genshin accounts added to the Enka.Network account */ fetchEnkaGenshinAccounts(username: string): Promise<EnkaGameAccount<EnkaClient>[]>; /** * @param username enka.network username, not in-game nickname * @param hash EnkaGameAccount hash * @returns the genshin account with provided hash */ fetchEnkaGenshinAccount(username: string, hash: string): Promise<EnkaGameAccount<EnkaClient>>; /** * @param username enka.network username, not in-game nickname * @param hash EnkaGameAccount hash * @returns the genshin character builds including saved builds in Enka.Network account */ fetchEnkaGenshinBuilds(username: string, hash: string): Promise<Record<string, GenshinCharacterBuild[]>>; /** * @returns all playable character data */ getAllCharacters(): CharacterData[]; /** * @param id The id of the character * @param skillDepotId Specifies one or zero elements for Traveler */ getCharacterById(id: number | string, skillDepotId?: number | string): CharacterData; /** * @returns all weapon data */ getAllWeapons(excludeInvalidWeapons?: boolean, filterByCodex?: boolean): WeaponData[]; /** * @param id The id of the weapon */ getWeaponById(id: number | string): WeaponData; /** * @param includeDefaults Whether to include default costumes * @returns all costume data */ getAllCostumes(includeDefaults?: boolean): Costume[]; /** * @param id The id of the costume */ getCostumeById(id: number | string): Costume; /** * @returns all material data */ getAllMaterials(): Material[]; /** * @param id The id of the material */ getMaterialById(id: number | string): Material; /** * @returns all name card data */ getAllNameCards(): NameCard[]; /** * @param id The id of the name card */ getNameCardById(id: number | string): NameCard; /** * @param highestRarityOnly Whether to return only the rarest of artifacts of the same type * @returns all artifact data */ getAllArtifacts(highestRarityOnly?: boolean): ArtifactData[]; /** * @param id The id of the artifact */ getArtifactById(id: number | string): ArtifactData; /** * @returns all artifact set data */ getAllArtifactSets(): ArtifactSet[]; /** * @param id The id of artifact set */ getArtifactSetById(id: number | string): ArtifactSet; /** * Clear all running tasks in the client. */ close(): void; }