wowup-lib-core
Version:
682 lines (680 loc) • 21.3 kB
TypeScript
import { CustomError } from "ts-custom-error";
export interface GitHubUploader {
login: string;
id: number;
node_id: string;
avatar_url: string;
gravatar_id: string;
url: string;
html_url: string;
followers_url: string;
following_url: string;
gists_url: string;
starred_url: string;
subscriptions_url: string;
organizations_url: string;
repos_url: string;
events_url: string;
received_events_url: string;
type: string;
site_admin: boolean;
}
export interface GitHubRepository {
id: number;
node_id: string;
name: string;
full_name: string;
private: boolean;
owner: GitHubUploader;
html_url: string;
description: string;
fork: boolean;
url: string;
}
export interface GitHubAsset {
url: string;
id: number;
node_id: string;
name: string;
label: string;
uploader: GitHubUploader;
content_type: string;
state: string;
size: number;
download_count: number;
created_at: string;
updated_at: string;
browser_download_url: string;
}
export interface GitHubRelease {
url: string;
assets_url: string;
upload_url: string;
html_url: string;
id: number;
node_id: string;
tag_name: string;
target_commitish: string;
name: string;
draft: boolean;
author: GitHubUploader;
prerelease: boolean;
created_at: string;
published_at: string;
assets: GitHubAsset[];
tarball_url: string;
zipball_url: string;
body: string;
}
export interface TukUiAddon {
id: string;
slug: string;
author: string;
name: string;
url: string;
version: string;
changelog_url: string;
ticket_url: string;
git_url: string;
patch: string[];
last_update: string;
web_url: string;
donate_url: string;
small_desc: string;
screenshot_url: string;
directories: string[];
}
export type AddonProviderType = 'Unknown' | 'Curse' | 'CurseV2' | 'GitHub' | 'TukUI' | 'WowInterface' | 'WowUpHub' | 'RaiderIO' | 'Zip' | 'WowUpCompanion' | 'Wago';
export type AddonScanType = 'wowup' | 'curseforge';
export enum AddonChannelType {
Stable = 0,
Beta = 1,
Alpha = 2
}
export enum AddonDependencyType {
Embedded = 1,
Required = 2,
Optional = 3,
Other = 4
}
export enum AddonWarningType {
GameVersionTocMissing = "game-version-toc-missing",
MissingOnProvider = "missing-on-provider",
NoProviderFiles = "no-provider-files",
TocNameMismatch = "toc-name-mismatch"
}
export type AddonIgnoreReason = 'git_repo' | 'missing_dependency' | 'unknown';
export enum AddonCategory {
Unknown = 0,
AllAddons = 1,
Achievements = 2,
ActionBars = 3,
AuctionEconomy = 4,
BagsInventory = 5,
BossEncounters = 6,
BuffsDebuffs = 7,
Bundles = 8,
ChatCommunication = 9,
Class = 10,
Combat = 11,
Companions = 12,
DataExport = 13,
DevelopmentTools = 14,
Guild = 15,
Libraries = 16,
Mail = 17,
MapMinimap = 18,
Miscellaneous = 19,
Missions = 20,
Plugins = 21,
Professions = 22,
PVP = 23,
QuestsLeveling = 24,
Roleplay = 25,
Tooltips = 26,
UnitFrames = 27
}
export enum WowClientType {
Retail = 0,
Classic = 1,
RetailPtr = 2,
ClassicPtr = 3,
Beta = 4,
ClassicBeta = 5,
ClassicEra = 6,
ClassicEraPtr = 7,
RetailXPtr = 8,
None = 9
}
export enum WowClientGroup {
Retail = 0,
BurningCrusade = 1,
Classic = 2,
WOTLK = 3,
Cata = 4,
Mists = 5
}
export enum WowGameType {
Retail = "retail",
Classic = "classic",
BurningCrusade = "burningCrusade",
WOTLK = "wotlk",
Cata = "cata",
Mists = "mists"
}
export class WowMajorVersion {
static readonly RetailBeta = 11;
static readonly Retail = 11;
static readonly Mists = 5;
static readonly Cata = 4;
static readonly Wrath = 3;
static readonly BurningCrusade = 2;
static readonly Classic = 1;
}
export interface InstalledProduct {
name: string;
location: string;
clientType: WowClientType;
}
export interface WowInstallation {
id: string;
clientType: WowClientType;
location: string;
label: string;
displayName: string;
selected: boolean;
defaultAddonChannelType: AddonChannelType;
defaultAutoUpdate: boolean;
availableUpdateCount?: number;
}
export interface AddonDetailsResponseV4 {
id: number;
categoryId: number;
version: string;
lastUpdate: number;
checksum: string;
fileName: string;
downloadUri: string;
pendingUpdate: string;
title: string;
author: string;
description: string;
changeLog: string;
downloads: number;
downloadsMonthly: number;
favorites: number;
images: Image[];
}
export interface AddonDetailsResponseV3 {
UID: string;
UICATID: string;
UIVersion: string;
UIDate: number;
UIMD5: string;
UIFileName: string;
UIDownload: string;
UIPending: string;
UIName: string;
UIAuthorName: string;
UIDescription: string;
UIChangeLog: string;
UIHitCount: string;
UIHitCountMonthly: string;
UIFavoriteTotal: string;
}
export interface Image {
thumbUrl: string;
imageUrl: string;
description: string;
}
export interface WowUpAddonFundingLinkRepresentation {
platform: string;
url: string;
}
export interface WowUpAddonReleaseFolderRepresentation {
id: number;
folder_name: string;
fingerprint: string;
}
export interface WowUpAddonReleaseRepresentation {
id: number;
url: string;
name: string;
tag_name: string;
external_id: string;
prerelease: boolean;
body: string;
game_versions: AddonReleaseGameVersion[];
toc_title?: string;
download_url: string;
published_at: Date;
addonFolders?: WowUpAddonReleaseFolderRepresentation[];
previews?: AddonPreviewRepresentation[];
}
export interface AddonReleaseGameVersion {
interface: string;
title: string;
game_type: WowGameType;
version: string;
authors: string;
}
export interface AddonPreviewRepresentation {
url: string;
preview_type: string;
}
export interface WowUpAddonRepresentation {
id: number;
repository: string;
repository_name: string;
source: string;
owner_name?: string;
owner_image_url?: string;
image_url?: string;
description?: string;
homepage?: string;
total_download_count: number;
current_release?: WowUpAddonReleaseRepresentation;
matched_release?: WowUpAddonReleaseRepresentation;
releases?: WowUpAddonReleaseRepresentation[];
funding_links?: WowUpAddonFundingLinkRepresentation[];
}
export interface WowUpGetAddonResponse {
addon: WowUpAddonRepresentation;
}
export interface WowUpGetAddonReleaseResponse {
release: WowUpAddonReleaseRepresentation;
}
export interface WowUpGetAddonResponse {
addon: WowUpAddonRepresentation;
}
export interface WowUpGetAddonsResponse {
addons: WowUpAddonRepresentation[];
count: number;
}
export interface GetFeaturedAddonsResponse {
addons: WowUpAddonRepresentation[];
recent: WowUpAddonRepresentation[];
count: number;
recentCount: number;
}
export interface WowUpSearchAddonsResponse {
addons: WowUpAddonRepresentation[];
count: number;
}
export interface GetAddonsByFingerprintResponse {
exactMatches: WowUpAddonRepresentation[];
}
export interface WowUpGetAccountResponse {
displayName: string;
patreonTier: string;
config: WowUpAccountConfig;
}
export interface WowUpAccountConfig {
pushAppId: string;
pushChannels: {
addonUpdates: string;
alerts: string;
};
}
export interface CurseAuthorBlockRepresentation {
authorId: string;
}
export interface CurseBlocksRepresentation {
authors: CurseAuthorBlockRepresentation[];
}
export interface BlockListRepresentation {
curse: CurseBlocksRepresentation;
}
export interface FsStats {
isFile: boolean;
isDirectory: boolean;
isBlockDevice: boolean;
isCharacterDevice: boolean;
isSymbolicLink: boolean;
isFIFO: boolean;
isSocket: boolean;
dev: number;
ino: number;
mode: number;
nlink: number;
uid: number;
gid: number;
rdev: number;
size: number;
blksize: number;
blocks: number;
atimeMs: number;
mtimeMs: number;
ctimeMs: number;
birthtimeMs: number;
atime: Date;
mtime: Date;
ctime: Date;
birthtime: Date;
}
export const TOC_AUTHOR = "Author";
export const TOC_DEPENDENCIES = "Dependencies";
export const TOC_INTERFACE = "Interface";
export const TOC_NOTES = "Notes";
export const TOC_REQUIRED_DEPS = "RequiredDeps";
export const TOC_TITLE = "Title";
export const TOC_VERSION = "Version";
export const TOC_WEBSITE = "Website";
export const TOC_X_ADDON_PROVIDER = "X-AddonProvider";
export const TOC_X_CATEGORY = "X-Category";
export const TOC_X_CURSE_PROJECT_ID = "X-Curse-Project-ID";
export const TOC_X_LOADONDEMAND = "LoadOnDemand";
export const TOC_X_LOCALIZATIONS = "X-Localizations";
export const TOC_X_PART_OF = "X-Part-Of";
export const TOC_X_TUKUI_PROJECTID = "X-Tukui-ProjectID";
export const TOC_X_TUKUI_PROJECTFOLDERS = "X-Tukui-ProjectFolders";
export const TOC_X_WEBSITE = "X-Website";
export const TOC_X_WOWI_ID = "X-WoWI-ID";
export const TOC_X_WAGO_ID = "X-Wago-ID";
export interface Toc {
fileName: string;
filePath: string;
interface: string[];
title?: string;
author?: string;
website?: string;
version?: string;
partOf?: string;
category?: string;
localizations?: string;
dependencies?: string;
curseProjectId?: string;
wowInterfaceId?: string;
wagoAddonId?: string;
tukUiProjectId?: string;
tukUiProjectFolders?: string;
loadOnDemand?: string;
dependencyList: string[];
addonProvider?: string;
notes?: string;
}
export interface AddonSearchResultDependency {
externalAddonId: string;
type: AddonDependencyType;
}
export interface AddonSearchResultFile {
externalId?: string;
channelType: AddonChannelType;
version: string;
folders: string[];
gameVersion: string;
downloadUrl: string;
releaseDate: Date;
dependencies?: AddonSearchResultDependency[];
changelog?: string;
title?: string;
authors?: string;
}
export interface AddonFundingLink {
platform: string;
url: string;
}
export interface AddonSearchResult {
author: string;
downloadCount?: number;
externalId: string;
externalUrl: string;
files?: AddonSearchResultFile[];
name: string;
providerName: string;
screenshotUrls?: string[];
summary?: string;
thumbnailUrl: string;
releasedAt?: Date;
fundingLinks?: AddonFundingLink[];
changelog?: string;
externallyBlocked?: boolean;
}
export interface AddonExternalId {
providerName: string;
id: string;
}
export interface AddonDependency {
externalAddonId: string;
type: AddonDependencyType;
}
export interface Addon {
id?: string;
name: string;
downloadUrl?: string;
installedVersion?: string;
installedExternalReleaseId?: string;
latestVersion?: string;
installedAt?: Date;
externalId?: string;
externalChannel?: string;
providerName?: string;
providerSource?: string;
externalUrl?: string;
thumbnailUrl?: string;
gameVersion?: string[];
author?: string;
installedFolders?: string;
installedFolderList?: string[];
isIgnored: boolean;
isLoadOnDemand: boolean;
warningType?: AddonWarningType;
autoUpdateEnabled: boolean;
autoUpdateNotificationsEnabled: boolean;
clientType: WowClientType;
channelType: AddonChannelType;
updatedAt?: Date;
fundingLinks?: AddonFundingLink[];
downloadCount?: number;
summary?: string;
screenshotUrls?: string[];
releasedAt?: Date;
externalIds?: AddonExternalId[];
externalLatestReleaseId?: string;
latestChangelogVersion?: string;
latestChangelog?: string;
dependencies?: AddonDependency[];
missingDependencies?: string[];
ignoreReason?: AddonIgnoreReason;
installationId?: string;
}
export interface ProtocolSearchResult extends AddonSearchResult {
protocol: string;
protocolAddonId?: string;
protocolReleaseId?: string;
validClientTypes?: WowClientType[];
validClientGroups?: WowClientGroup[];
}
export interface AddonScanResult {
source: AddonScanType;
fileCount: number;
fileFingerprints?: string[];
fingerprint: string;
fingerprintNum: number;
folderName: string;
path?: string;
}
export interface AddonFolder {
name: string;
path: string;
status: string;
ignoreReason?: AddonIgnoreReason;
thumbnailUrl?: string;
latestVersion?: string;
tocs: Toc[];
matchingAddon?: Addon;
fileStats?: FsStats;
cfScanResults?: AddonScanResult;
wowUpScanResults?: AddonScanResult;
}
export interface GetAllBatchResult {
installationResults: {
[installationId: string]: AddonSearchResult[];
};
errors: {
[installationId: string]: Error[];
};
}
export interface GetAllResult {
searchResults: AddonSearchResult[];
errors: Error[];
}
export interface SearchByUrlResult {
searchResult?: AddonSearchResult;
errors?: Error[];
}
export interface AdPageOptions {
pageUrl: string;
referrer?: string;
userAgent?: string;
partition?: string;
preloadFilePath?: string;
explanationKey?: string;
}
export interface DownloadAuth {
headers?: {
[key: string]: string;
};
queryParams?: {
[key: string]: string;
};
}
export abstract class AddonProvider {
name: AddonProviderType;
enabled: boolean;
forceIgnore: boolean;
allowReinstall: boolean;
allowChannelChange: boolean;
allowEdit: boolean;
allowViewAtSource: boolean;
allowReScan: boolean;
canShowChangelog: boolean;
canBatchFetch: boolean;
authRequired: boolean;
adRequired: boolean;
providerNote: string;
getAllBatch(installations: WowInstallation[], addonIds: string[]): Promise<GetAllBatchResult>;
getAll(installation: WowInstallation, addonIds: string[]): Promise<GetAllResult>;
getFeaturedAddons(installation: WowInstallation, channelType?: AddonChannelType): Promise<AddonSearchResult[]>;
shouldMigrate(addon: Addon): boolean;
searchByQuery(query: string, installation: WowInstallation, channelType?: AddonChannelType): Promise<AddonSearchResult[]>;
searchByUrl(addonUri: URL, installation: WowInstallation): Promise<SearchByUrlResult | undefined>;
searchProtocol(protocol: string): Promise<ProtocolSearchResult | undefined>;
getCategory(category: AddonCategory, installation: WowInstallation): Promise<AddonSearchResult[]>;
getById(addonId: string, installation: WowInstallation): Promise<AddonSearchResult | undefined>;
isValidAddonUri(addonUri: URL): boolean;
isValidAddonId(addonId: string): boolean;
isValidProtocol(protocol: string): boolean;
scan(installation: WowInstallation, addonChannelType: AddonChannelType, addonFolders: AddonFolder[]): Promise<void>;
getChangelog(installation: WowInstallation, externalId: string, externalReleaseId: string): Promise<string>;
getDescription(installation: WowInstallation, externalId: string, addon?: Addon): Promise<string>;
getAdPageParams(): AdPageOptions | undefined;
getDownloadAuth(): Promise<DownloadAuth | undefined>;
}
export class ErrorContainer extends CustomError {
readonly innerError?: Error;
readonly warningType?: AddonWarningType;
constructor(innerError?: Error, message?: string, warningType?: AddonWarningType);
}
export class GenericProviderError extends ErrorContainer {
}
export class SourceRemovedAddonError extends GenericProviderError {
addonId: string;
constructor(addonId: string, innerError?: Error);
}
export function getGameVersionList(interfaceStrs: string[]): string[];
export function getGameVersion(interfaceStr: string | undefined): string;
export function convertBbcode(str: string): string;
export function getEnumKeys(enume: Record<string, unknown>): string[];
export function getEnumList<T>(enume: Record<string, unknown>): T[];
export function getEnumName(enume: Record<string, unknown>, value: number | undefined): string;
export interface PostConfig {
body: unknown;
headers?: {
[header: string]: string | string[];
};
timeoutMs?: number;
cache?: boolean;
}
export interface GetConfig {
headers?: {
[header: string]: string | string[];
};
timeoutMs?: number;
}
export interface NetworkInterface {
getJson<T>(url: URL | string, config?: GetConfig): Promise<T>;
getText(url: URL | string, config?: GetConfig): Promise<string>;
postJson<T>(url: URL | string, config: PostConfig): Promise<T>;
}
export function removeExtension(str: string): string;
/**
* Given a list of toc file names, select the one that goes with the given client type
* Use a similar priority switch as the actual wow client, if a targeted one exists use that, if not check for a base toc and try that
*/
export function getTocForGameType(tocFileNames: string[], clientType: WowClientType): string;
export function getTocForGameType2(addonFolder: AddonFolder, clientType: WowClientType): Toc | undefined;
export function convertMarkdown(markdown: string): string;
export function getWowClientGroup(gameType: WowGameType): WowClientGroup;
export function getWowClientGroupForType(clientType: WowClientType): WowClientGroup;
export function getWowGameType(clientType: WowClientType): WowGameType;
export function getWowMajorVersion(clientType: WowClientType): number;
export class WowUpAddonProvider extends AddonProvider {
readonly name = "WowUpHub";
readonly forceIgnore = false;
readonly allowReinstall = true;
readonly allowChannelChange = true;
readonly allowEdit = true;
readonly canBatchFetch = true;
enabled: boolean;
constructor(_baseUrl: string, _websiteUrl: string, _networkInterface: NetworkInterface);
scan(installation: WowInstallation, addonChannelType: AddonChannelType, addonFolders: AddonFolder[]): Promise<void>;
getDescription(installation: WowInstallation, externalId: string): Promise<string>;
shouldMigrate(addon: Addon): boolean;
isValidProtocol(protocol: string): boolean;
searchProtocol(protocol: string): Promise<ProtocolSearchResult | undefined>;
getAllBatch(installations: WowInstallation[], addonIds: string[]): Promise<GetAllBatchResult>;
getAll(installation: WowInstallation, addonIds: string[]): Promise<GetAllResult>;
getFeaturedAddons(installation: WowInstallation): Promise<AddonSearchResult[]>;
searchByQuery(query: string, installation: WowInstallation): Promise<AddonSearchResult[]>;
isValidAddonId(addonId: string): boolean;
getCategory(category: AddonCategory, installation: WowInstallation): Promise<AddonSearchResult[]>;
getById(addonId: string, installation: WowInstallation): Promise<AddonSearchResult | undefined>;
getChangelog(installation: WowInstallation, externalId: string, externalReleaseId: string): Promise<string>;
}
export class WowInterfaceAddonProvider extends AddonProvider {
readonly name = "WowInterface";
readonly forceIgnore = false;
readonly allowReinstall = true;
readonly allowChannelChange = false;
readonly allowEdit = true;
enabled: boolean;
constructor(_networkInterface: NetworkInterface);
getDescription(installation: WowInstallation, externalId: string): Promise<string>;
getAll(installation: WowInstallation, addonIds: string[]): Promise<GetAllResult>;
getChangelog(installation: WowInstallation, externalId: string): Promise<string>;
searchByUrl(addonUri: URL): Promise<SearchByUrlResult>;
getById(addonId: string): Promise<AddonSearchResult | undefined>;
isValidAddonUri(addonUri: URL): boolean;
isValidAddonId(addonId: string): boolean;
scan(installation: WowInstallation, addonChannelType: AddonChannelType, addonFolders: AddonFolder[]): Promise<void>;
}
export class TukUiAddonProvider extends AddonProvider {
readonly name = "TukUI";
readonly forceIgnore = false;
readonly allowReinstall = true;
readonly allowChannelChange = false;
readonly allowEdit = true;
enabled: boolean;
constructor(_networkInterface: NetworkInterface);
getCategory(category: AddonCategory, installation: WowInstallation): Promise<AddonSearchResult[]>;
getDescription(installation: WowInstallation, externalId: string): Promise<string>;
getChangelog(installation: WowInstallation, externalId: string): Promise<string>;
getAll(installation: WowInstallation, addonIds: string[]): Promise<GetAllResult>;
getFeaturedAddons(installation: WowInstallation): Promise<AddonSearchResult[]>;
searchByQuery(query: string, installation: WowInstallation): Promise<AddonSearchResult[]>;
getById(addonId: string, installation: WowInstallation): Promise<AddonSearchResult | undefined>;
isValidAddonId(addonId: string): boolean;
scan(installation: WowInstallation, addonChannelType: AddonChannelType, addonFolders: AddonFolder[]): Promise<void>;
}
//# sourceMappingURL=index.d.ts.map