From 65e4ef52860cf07b9cb6a5a6fcc48f1915ec1f43 Mon Sep 17 00:00:00 2001 From: Joshua Hall Date: Mon, 25 Jun 2018 16:36:50 -0500 Subject: [PATCH 1/7] Added type definitions for overwatch-api --- types/overwatch-api/index.d.ts | 328 +++++++++++++++++++++ types/overwatch-api/overwatch-api-tests.ts | 25 ++ types/overwatch-api/tsconfig.json | 57 ++++ types/overwatch-api/tslint.json | 17 ++ 4 files changed, 427 insertions(+) create mode 100644 types/overwatch-api/index.d.ts create mode 100644 types/overwatch-api/overwatch-api-tests.ts create mode 100644 types/overwatch-api/tsconfig.json create mode 100644 types/overwatch-api/tslint.json diff --git a/types/overwatch-api/index.d.ts b/types/overwatch-api/index.d.ts new file mode 100644 index 0000000000..f2e05c8ed2 --- /dev/null +++ b/types/overwatch-api/index.d.ts @@ -0,0 +1,328 @@ +// Type definitions for overwatch-api +// Project: https://github.com/alfg/overwatch-api +// Definitions by: JoshuaHall +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module "overwatch-api" { + type callbackFunc = (err: Error | null, data: T) => void; + + type OverwatchPlatform = "pc" | "xbl" | "psn"; + type OverwatchServerRegion = "us" | "eu" | "kr" | "cn" | "global"; + type OverwatchHero = + | "Zarya" + | "Mercy" + | "Reinhardt" + | "Zenyatta" + | "Hanzo" + | "Orisa" + | "Genji" + | "Roadhog" + | "McCree" + | "Tracer" + | "Ana" + | "Winston" + | "D.Va" + | "Moira" + | "Junkrat" + | "Soldier: 76" + | "Brigitte" + | "Lúcio" + | "Torbjörn" + | "Reaper" + | "Pharah" + | "Widowmaker" + | "Bastion" + | "Symmetra" + | "Mei" + | "Sombra" + | "Doomfist"; + + interface GameType { + won: number; + played: number; + } + + type QuickplayGameType = GameType; + + interface CompetitiveGameType extends GameType { + lost: number; + draw: number; + win_rate: number; + } + + interface GameTypes { + quickplay: QuickplayGameType; + competitive: CompetitiveGameType; + } + + interface Playtime { + quickplay: string; + competitive: string; + } + + interface CompetitiveRankInfo { + rank: number; + rank_img: string; + } + + interface OverwatchApiResponse { + username: string; + level: number; + portrait: string; + } + + interface ProfileApiResponse extends OverwatchApiResponse { + games: GameTypes; + playtime: Playtime; + competitive: CompetitiveRankInfo; + levelFrame: string; + star: string; + } + + interface TopHeroStats { + hero: OverwatchHero; + img: string; + } + + interface HeroTimePlayed extends TopHeroStats { + played: string; + } + + interface HeroGamesWon extends TopHeroStats { + games_won: string; + } + + interface HeroWinRate extends TopHeroStats { + win_rate: string; + } + + interface Stat { + title: string; + value: string; + } + + interface StatsByGameType { + quickplay: T[]; + competitive: T[]; + } + + interface StatByGameType { + quickplay: T; + competitive: U; + } + + interface QuickplayTopHeroData { + played: HeroTimePlayed[]; + games_won: HeroGamesWon[]; + } + + interface CompetitiveTopHeroData extends QuickplayTopHeroData { + win_rate: HeroWinRate[]; + } + + interface StatsCategories { + top_heroes: StatByGameType< + QuickplayTopHeroData, + CompetitiveTopHeroData + >; + combat: StatsByGameType; + match_awards: StatsByGameType; + assists: StatsByGameType; + average: StatsByGameType; + miscellaneous: StatsByGameType; + best: StatsByGameType; + game: StatsByGameType; + } + + interface StatsApiResponse extends OverwatchApiResponse { + stats: StatsCategories; + } + + function getProfile( + platform: OverwatchPlatform, + region: OverwatchServerRegion, + tag: string, + callback: callbackFunc, + ): void; + function getStats( + platform: OverwatchPlatform, + region: OverwatchServerRegion, + tag: string, + callback: callbackFunc, + ): void; + namespace owl { + interface ApiResponse { + data: T; + } + + interface StandingInfo { + matchWin: number; + matchLoss: number; + matchDraw: number; + matchBye: number; + gameWin: number; + gameLoss: number; + gameTie: number; + gamePointsFor: number; + gamePointsAgainst: number; + placement: number; + } + + interface StandingComparison { + key: string; + value: number; + } + + interface StageStandingInfo extends PreseasonStandingInfo { + isPlayoffWinner: boolean; + } + + interface Stages { + stage1: StageStandingInfo; + stage2: StageStandingInfo; + stage3: StageStandingInfo; + stage4: StageStandingInfo; + } + + interface PreseasonStandingInfo extends StandingInfo { + comparisons: StandingComparison[]; + } + + interface TeamStandingInfo { + id: number; + divisionId: number; + name: string; + abbreviatedName: string; + league: StandingInfo; + stages: Stages; + preseason: PreseasonStandingInfo; + } + + interface LiveMatchData { + liveMatch: {}; + } + + interface TournamentData { + id: number; + type: string; + } + + interface MatchScores { + value: number; + } + + interface TeamData { + id: number; + availableLanguages: string[]; + handle: string; + name: string; + homeLocation: string; + primaryColor: string; + secondaryColor: string; + game: string; + abbreviatedName: string; + addressCountry: string; + logo: string; + icon: string; + secondaryPhoto: string; + type: string; + } + + interface MatchGameScore { + team1: number; + team2: number; + } + + interface MatchGameAttributeData { + instanceID: string; + map: string; + mapScore: MatchGameScore; + } + + type ScoreTuple = [number, number]; + + interface MatchGameData { + id: number; + points: ScoreTuple; + attributes: MatchGameAttributeData; + attributesVersion: string; + state: string; + status: string; + statusReason: string; + stats: null; + handle: string; + } + + interface MatchVideoData { + name: number; + description: string; + vodLink: string; + youtubeId: string; + thumbnailUrl: string; + } + + interface MatchTournamentData { + id: number; + type: string; + location: string; + } + + interface MatchData { + id: number; + competitors: TeamData[]; + scores: MatchScores[]; + conclusionValue: number; + conclusionStrategy: string; + winner: TeamData; + state: string; + status: string; + statusReason: string; + attributes: {}; + games: MatchGameData[]; + clientHints: any[]; + dateCreated: number; + flags: any[]; + handle: string; + startDate: string; + endDate: string; + showStartTime: boolean; + showEndTime: boolean; + startDateTS: number; + endDateTS: number; + youtubeId: string; + wins: ScoreTuple; + ties: ScoreTuple; + losses: ScoreTuple; + videos: MatchVideoData[]; + tournament: MatchTournamentData; + } + + interface WeekData { + id: number; + startDate: number; + endDate: number; + matches: MatchData[]; + name: string; + } + + interface StageScheduleInfo { + id: number; + slug: string; + enabled: boolean; + name: string; + tournament: TournamentData[]; + matches: MatchData[]; + weeks: WeekData[]; + } + + interface ScheduleInfo { + startDate: string; + endDate: string; + stages: StageScheduleInfo[]; + } + + function getLiveMatch(callback: callbackFunc>): void; + function getStandings(callback: callbackFunc>): void; + function getSchedule(callback: callbackFunc>): void; + } +} diff --git a/types/overwatch-api/overwatch-api-tests.ts b/types/overwatch-api/overwatch-api-tests.ts new file mode 100644 index 0000000000..4dc1e2ede1 --- /dev/null +++ b/types/overwatch-api/overwatch-api-tests.ts @@ -0,0 +1,25 @@ +import { getProfile, OverwatchPlatform, OverwatchServerRegion, ProfileApiResponse, owl } from 'overwatch-api'; + +const platform: OverwatchPlatform = 'pc'; +const region: OverwatchServerRegion = 'us'; +const battleTag: string = 'sparK#12434'; + +getProfile(platform, region, battleTag, (err: Error | null, data: ProfileApiResponse) => { + if (err === null) { + console.log(`Username: ${data.username}`); + console.log(`Level: ${data.level}`); + console.log(`Rank: ${data.competitive.rank} SR`); + console.log(`Win Rate in Competitive: ${data.games.competitive.win_rate}`); + } else { + console.log(err); + } +}); + +owl.getStandings((err: Error | null, data: owl.ApiResponse) => { + if (err === null) { + const standingInfo: owl.TeamStandingInfo = data.data[0]; + console.log(`${standingInfo.name} - ${standingInfo.abbreviatedName}`); + } else { + console.log(err); + } +}); diff --git a/types/overwatch-api/tsconfig.json b/types/overwatch-api/tsconfig.json new file mode 100644 index 0000000000..14727c493e --- /dev/null +++ b/types/overwatch-api/tsconfig.json @@ -0,0 +1,57 @@ +{ + "compilerOptions": { + /* Basic Options */ + "target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */ + "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ + // "lib": [], /* Specify library files to be included in the compilation. */ + // "allowJs": true, /* Allow javascript files to be compiled. */ + // "checkJs": true, /* Report errors in .js files. */ + // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ + // "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./", /* Concatenate and emit output to single file. */ + // "outDir": "./", /* Redirect output structure to the directory. */ + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ + // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ + + /* Strict Type-Checking Options */ + "strict": true, /* Enable all strict type-checking options. */ + // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* Enable strict null checks. */ + // "strictFunctionTypes": true, /* Enable strict checking of function types. */ + // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ + // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + + /* Additional Checks */ + // "noUnusedLocals": true, /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + /* Module Resolution Options */ + // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + // "types": [], /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ + // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ + + /* Source Map Options */ + // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + } +} diff --git a/types/overwatch-api/tslint.json b/types/overwatch-api/tslint.json new file mode 100644 index 0000000000..df53b47156 --- /dev/null +++ b/types/overwatch-api/tslint.json @@ -0,0 +1,17 @@ +{ + "defaultSeverity": "error", + "extends": [ + "tslint:recommended" + ], + "jsRules": {}, + "rules": { + "interface-name": false, + "quotemark": [ + true, + "single" + ], + "no-console": false, + "ordered-imports": false + }, + "rulesDirectory": [] +} From c660bbc25ef091c85472a935ca89343113dfabd9 Mon Sep 17 00:00:00 2001 From: Joshua Hall Date: Mon, 25 Jun 2018 16:57:15 -0500 Subject: [PATCH 2/7] updated tsconfig.json to not include comments --- types/overwatch-api/tsconfig.json | 57 +++---------------------------- 1 file changed, 4 insertions(+), 53 deletions(-) diff --git a/types/overwatch-api/tsconfig.json b/types/overwatch-api/tsconfig.json index 14727c493e..8bb50b5443 100644 --- a/types/overwatch-api/tsconfig.json +++ b/types/overwatch-api/tsconfig.json @@ -1,57 +1,8 @@ { "compilerOptions": { - /* Basic Options */ - "target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */ - "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ - // "lib": [], /* Specify library files to be included in the compilation. */ - // "allowJs": true, /* Allow javascript files to be compiled. */ - // "checkJs": true, /* Report errors in .js files. */ - // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ - // "declaration": true, /* Generates corresponding '.d.ts' file. */ - // "sourceMap": true, /* Generates corresponding '.map' file. */ - // "outFile": "./", /* Concatenate and emit output to single file. */ - // "outDir": "./", /* Redirect output structure to the directory. */ - // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ - // "removeComments": true, /* Do not emit comments to output. */ - // "noEmit": true, /* Do not emit outputs. */ - // "importHelpers": true, /* Import emit helpers from 'tslib'. */ - // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ - // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ - - /* Strict Type-Checking Options */ - "strict": true, /* Enable all strict type-checking options. */ - // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* Enable strict null checks. */ - // "strictFunctionTypes": true, /* Enable strict checking of function types. */ - // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ - // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ - // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ - - /* Additional Checks */ - // "noUnusedLocals": true, /* Report errors on unused locals. */ - // "noUnusedParameters": true, /* Report errors on unused parameters. */ - // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ - // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ - - /* Module Resolution Options */ - // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ - // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ - // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ - // "typeRoots": [], /* List of folders to include type definitions from. */ - // "types": [], /* Type declaration files to be included in compilation. */ - // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ - // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ - - /* Source Map Options */ - // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ - // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ - - /* Experimental Options */ - // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ - // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + "target": "es6", + "module": "commonjs", + "strict": true, + "esModuleInterop": true } } From ff9baf1643450556e613606e815a2e1484920178 Mon Sep 17 00:00:00 2001 From: Joshua Hall Date: Tue, 26 Jun 2018 08:30:09 -0500 Subject: [PATCH 3/7] updated tsconfig --- types/overwatch-api/tsconfig.json | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/types/overwatch-api/tsconfig.json b/types/overwatch-api/tsconfig.json index 8bb50b5443..9a25f93e31 100644 --- a/types/overwatch-api/tsconfig.json +++ b/types/overwatch-api/tsconfig.json @@ -3,6 +3,11 @@ "target": "es6", "module": "commonjs", "strict": true, - "esModuleInterop": true - } + "esModuleInterop": true, + "moduleResolution": "node" + }, + "files": [ + "index.d.ts", + "overwatch-api.tests.ts" + ] } From 7957afa728e3f3fd69e5e5c6402a2265450bf32c Mon Sep 17 00:00:00 2001 From: Joshua Hall Date: Tue, 26 Jun 2018 08:36:08 -0500 Subject: [PATCH 4/7] fixed typo in tsconfig --- types/overwatch-api/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/overwatch-api/tsconfig.json b/types/overwatch-api/tsconfig.json index 9a25f93e31..b8b1fdd6e4 100644 --- a/types/overwatch-api/tsconfig.json +++ b/types/overwatch-api/tsconfig.json @@ -8,6 +8,6 @@ }, "files": [ "index.d.ts", - "overwatch-api.tests.ts" + "overwatch-api-tests.ts" ] } From ba730c67d15604a3964dfb8221686b28a1cbf562 Mon Sep 17 00:00:00 2001 From: Joshua Hall Date: Tue, 26 Jun 2018 08:49:32 -0500 Subject: [PATCH 5/7] used generated files --- types/overwatch-api/overwatch-api-tests.ts | 2 +- types/overwatch-api/tsconfig.json | 32 ++++++++++++++-------- types/overwatch-api/tslint.json | 18 +----------- 3 files changed, 23 insertions(+), 29 deletions(-) diff --git a/types/overwatch-api/overwatch-api-tests.ts b/types/overwatch-api/overwatch-api-tests.ts index 4dc1e2ede1..bd4df128a0 100644 --- a/types/overwatch-api/overwatch-api-tests.ts +++ b/types/overwatch-api/overwatch-api-tests.ts @@ -2,7 +2,7 @@ import { getProfile, OverwatchPlatform, OverwatchServerRegion, ProfileApiRespons const platform: OverwatchPlatform = 'pc'; const region: OverwatchServerRegion = 'us'; -const battleTag: string = 'sparK#12434'; +const battleTag = 'sparK#12434'; getProfile(platform, region, battleTag, (err: Error | null, data: ProfileApiResponse) => { if (err === null) { diff --git a/types/overwatch-api/tsconfig.json b/types/overwatch-api/tsconfig.json index b8b1fdd6e4..7e9d4284a3 100644 --- a/types/overwatch-api/tsconfig.json +++ b/types/overwatch-api/tsconfig.json @@ -1,13 +1,23 @@ { - "compilerOptions": { - "target": "es6", - "module": "commonjs", - "strict": true, - "esModuleInterop": true, - "moduleResolution": "node" - }, - "files": [ - "index.d.ts", - "overwatch-api-tests.ts" - ] + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "overwatch-api-tests.ts" + ] } diff --git a/types/overwatch-api/tslint.json b/types/overwatch-api/tslint.json index df53b47156..3db14f85ea 100644 --- a/types/overwatch-api/tslint.json +++ b/types/overwatch-api/tslint.json @@ -1,17 +1 @@ -{ - "defaultSeverity": "error", - "extends": [ - "tslint:recommended" - ], - "jsRules": {}, - "rules": { - "interface-name": false, - "quotemark": [ - true, - "single" - ], - "no-console": false, - "ordered-imports": false - }, - "rulesDirectory": [] -} +{ "extends": "dtslint/dt.json" } From e8f05cf44ca0279c3f509c9fd84a05e06308e475 Mon Sep 17 00:00:00 2001 From: Joshua Hall Date: Tue, 26 Jun 2018 08:55:25 -0500 Subject: [PATCH 6/7] added strictFunctionType rule to tsconfig --- types/overwatch-api/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/types/overwatch-api/tsconfig.json b/types/overwatch-api/tsconfig.json index 7e9d4284a3..284f7c4d4c 100644 --- a/types/overwatch-api/tsconfig.json +++ b/types/overwatch-api/tsconfig.json @@ -8,6 +8,7 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, + "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../" From 933aa88ea184db4b7f5727ae459309b756ea3544 Mon Sep 17 00:00:00 2001 From: Joshua Hall Date: Tue, 26 Jun 2018 09:04:39 -0500 Subject: [PATCH 7/7] Updated type declaration file based on guidelines/travis ci error messages --- types/overwatch-api/index.d.ts | 568 ++++++++++++++++----------------- 1 file changed, 284 insertions(+), 284 deletions(-) diff --git a/types/overwatch-api/index.d.ts b/types/overwatch-api/index.d.ts index f2e05c8ed2..8eaac311c8 100644 --- a/types/overwatch-api/index.d.ts +++ b/types/overwatch-api/index.d.ts @@ -1,328 +1,328 @@ -// Type definitions for overwatch-api +// Type definitions for overwatch-api 0.4 // Project: https://github.com/alfg/overwatch-api // Definitions by: JoshuaHall // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare module "overwatch-api" { - type callbackFunc = (err: Error | null, data: T) => void; +// TypeScript Version: 2.1 - type OverwatchPlatform = "pc" | "xbl" | "psn"; - type OverwatchServerRegion = "us" | "eu" | "kr" | "cn" | "global"; - type OverwatchHero = - | "Zarya" - | "Mercy" - | "Reinhardt" - | "Zenyatta" - | "Hanzo" - | "Orisa" - | "Genji" - | "Roadhog" - | "McCree" - | "Tracer" - | "Ana" - | "Winston" - | "D.Va" - | "Moira" - | "Junkrat" - | "Soldier: 76" - | "Brigitte" - | "Lúcio" - | "Torbjörn" - | "Reaper" - | "Pharah" - | "Widowmaker" - | "Bastion" - | "Symmetra" - | "Mei" - | "Sombra" - | "Doomfist"; +export type callbackFunc = (err: Error | null, data: T) => void; - interface GameType { - won: number; - played: number; - } +export type OverwatchPlatform = "pc" | "xbl" | "psn"; +export type OverwatchServerRegion = "us" | "eu" | "kr" | "cn" | "global"; +export type OverwatchHero = + | "Zarya" + | "Mercy" + | "Reinhardt" + | "Zenyatta" + | "Hanzo" + | "Orisa" + | "Genji" + | "Roadhog" + | "McCree" + | "Tracer" + | "Ana" + | "Winston" + | "D.Va" + | "Moira" + | "Junkrat" + | "Soldier: 76" + | "Brigitte" + | "Lúcio" + | "Torbjörn" + | "Reaper" + | "Pharah" + | "Widowmaker" + | "Bastion" + | "Symmetra" + | "Mei" + | "Sombra" + | "Doomfist"; - type QuickplayGameType = GameType; +export interface GameType { + won: number; + played: number; +} + +export type QuickplayGameType = GameType; + +export interface CompetitiveGameType extends GameType { + lost: number; + draw: number; + win_rate: number; +} + +export interface GameTypes { + quickplay: QuickplayGameType; + competitive: CompetitiveGameType; +} + +export interface Playtime { + quickplay: string; + competitive: string; +} + +export interface CompetitiveRankInfo { + rank: number; + rank_img: string; +} + +export interface OverwatchApiResponse { + username: string; + level: number; + portrait: string; +} + +export interface ProfileApiResponse extends OverwatchApiResponse { + games: GameTypes; + playtime: Playtime; + competitive: CompetitiveRankInfo; + levelFrame: string; + star: string; +} + +export interface TopHeroStats { + hero: OverwatchHero; + img: string; +} + +export interface HeroTimePlayed extends TopHeroStats { + played: string; +} + +export interface HeroGamesWon extends TopHeroStats { + games_won: string; +} + +export interface HeroWinRate extends TopHeroStats { + win_rate: string; +} + +export interface Stat { + title: string; + value: string; +} + +export interface StatsByGameType { + quickplay: T[]; + competitive: T[]; +} + +export interface StatByGameType { + quickplay: T; + competitive: U; +} + +export interface QuickplayTopHeroData { + played: HeroTimePlayed[]; + games_won: HeroGamesWon[]; +} + +export interface CompetitiveTopHeroData extends QuickplayTopHeroData { + win_rate: HeroWinRate[]; +} + +export interface StatsCategories { + top_heroes: StatByGameType< + QuickplayTopHeroData, + CompetitiveTopHeroData + >; + combat: StatsByGameType; + match_awards: StatsByGameType; + assists: StatsByGameType; + average: StatsByGameType; + miscellaneous: StatsByGameType; + best: StatsByGameType; + game: StatsByGameType; +} + +export interface StatsApiResponse extends OverwatchApiResponse { + stats: StatsCategories; +} + +export function getProfile( + platform: OverwatchPlatform, + region: OverwatchServerRegion, + tag: string, + callback: callbackFunc, +): void; +export function getStats( + platform: OverwatchPlatform, + region: OverwatchServerRegion, + tag: string, + callback: callbackFunc, +): void; +export namespace owl { + interface ApiResponse { + data: T; + } + + interface StandingInfo { + matchWin: number; + matchLoss: number; + matchDraw: number; + matchBye: number; + gameWin: number; + gameLoss: number; + gameTie: number; + gamePointsFor: number; + gamePointsAgainst: number; + placement: number; + } - interface CompetitiveGameType extends GameType { - lost: number; - draw: number; - win_rate: number; + interface StandingComparison { + key: string; + value: number; } - interface GameTypes { - quickplay: QuickplayGameType; - competitive: CompetitiveGameType; + interface StageStandingInfo extends PreseasonStandingInfo { + isPlayoffWinner: boolean; } - interface Playtime { - quickplay: string; - competitive: string; + interface Stages { + stage1: StageStandingInfo; + stage2: StageStandingInfo; + stage3: StageStandingInfo; + stage4: StageStandingInfo; } - interface CompetitiveRankInfo { - rank: number; - rank_img: string; + interface PreseasonStandingInfo extends StandingInfo { + comparisons: StandingComparison[]; } - interface OverwatchApiResponse { - username: string; - level: number; - portrait: string; + interface TeamStandingInfo { + id: number; + divisionId: number; + name: string; + abbreviatedName: string; + league: StandingInfo; + stages: Stages; + preseason: PreseasonStandingInfo; } - interface ProfileApiResponse extends OverwatchApiResponse { - games: GameTypes; - playtime: Playtime; - competitive: CompetitiveRankInfo; - levelFrame: string; - star: string; + interface LiveMatchData { + liveMatch: {}; } - interface TopHeroStats { - hero: OverwatchHero; - img: string; + interface TournamentData { + id: number; + type: string; } - interface HeroTimePlayed extends TopHeroStats { - played: string; + interface MatchScores { + value: number; } - interface HeroGamesWon extends TopHeroStats { - games_won: string; + interface TeamData { + id: number; + availableLanguages: string[]; + handle: string; + name: string; + homeLocation: string; + primaryColor: string; + secondaryColor: string; + game: string; + abbreviatedName: string; + addressCountry: string; + logo: string; + icon: string; + secondaryPhoto: string; + type: string; } - interface HeroWinRate extends TopHeroStats { - win_rate: string; + interface MatchGameScore { + team1: number; + team2: number; } - interface Stat { - title: string; - value: string; + interface MatchGameAttributeData { + instanceID: string; + map: string; + mapScore: MatchGameScore; } - interface StatsByGameType { - quickplay: T[]; - competitive: T[]; + type ScoreTuple = [number, number]; + + interface MatchGameData { + id: number; + points: ScoreTuple; + attributes: MatchGameAttributeData; + attributesVersion: string; + state: string; + status: string; + statusReason: string; + stats: null; + handle: string; } - interface StatByGameType { - quickplay: T; - competitive: U; + interface MatchVideoData { + name: number; + description: string; + vodLink: string; + youtubeId: string; + thumbnailUrl: string; } - interface QuickplayTopHeroData { - played: HeroTimePlayed[]; - games_won: HeroGamesWon[]; + interface MatchTournamentData { + id: number; + type: string; + location: string; } - interface CompetitiveTopHeroData extends QuickplayTopHeroData { - win_rate: HeroWinRate[]; + interface MatchData { + id: number; + competitors: TeamData[]; + scores: MatchScores[]; + conclusionValue: number; + conclusionStrategy: string; + winner: TeamData; + state: string; + status: string; + statusReason: string; + attributes: {}; + games: MatchGameData[]; + clientHints: any[]; + dateCreated: number; + flags: any[]; + handle: string; + startDate: string; + endDate: string; + showStartTime: boolean; + showEndTime: boolean; + startDateTS: number; + endDateTS: number; + youtubeId: string; + wins: ScoreTuple; + ties: ScoreTuple; + losses: ScoreTuple; + videos: MatchVideoData[]; + tournament: MatchTournamentData; } - interface StatsCategories { - top_heroes: StatByGameType< - QuickplayTopHeroData, - CompetitiveTopHeroData - >; - combat: StatsByGameType; - match_awards: StatsByGameType; - assists: StatsByGameType; - average: StatsByGameType; - miscellaneous: StatsByGameType; - best: StatsByGameType; - game: StatsByGameType; + interface WeekData { + id: number; + startDate: number; + endDate: number; + matches: MatchData[]; + name: string; } - interface StatsApiResponse extends OverwatchApiResponse { - stats: StatsCategories; + interface StageScheduleInfo { + id: number; + slug: string; + enabled: boolean; + name: string; + tournament: TournamentData[]; + matches: MatchData[]; + weeks: WeekData[]; } - function getProfile( - platform: OverwatchPlatform, - region: OverwatchServerRegion, - tag: string, - callback: callbackFunc, - ): void; - function getStats( - platform: OverwatchPlatform, - region: OverwatchServerRegion, - tag: string, - callback: callbackFunc, - ): void; - namespace owl { - interface ApiResponse { - data: T; - } - - interface StandingInfo { - matchWin: number; - matchLoss: number; - matchDraw: number; - matchBye: number; - gameWin: number; - gameLoss: number; - gameTie: number; - gamePointsFor: number; - gamePointsAgainst: number; - placement: number; - } - - interface StandingComparison { - key: string; - value: number; - } - - interface StageStandingInfo extends PreseasonStandingInfo { - isPlayoffWinner: boolean; - } - - interface Stages { - stage1: StageStandingInfo; - stage2: StageStandingInfo; - stage3: StageStandingInfo; - stage4: StageStandingInfo; - } - - interface PreseasonStandingInfo extends StandingInfo { - comparisons: StandingComparison[]; - } - - interface TeamStandingInfo { - id: number; - divisionId: number; - name: string; - abbreviatedName: string; - league: StandingInfo; - stages: Stages; - preseason: PreseasonStandingInfo; - } - - interface LiveMatchData { - liveMatch: {}; - } - - interface TournamentData { - id: number; - type: string; - } - - interface MatchScores { - value: number; - } - - interface TeamData { - id: number; - availableLanguages: string[]; - handle: string; - name: string; - homeLocation: string; - primaryColor: string; - secondaryColor: string; - game: string; - abbreviatedName: string; - addressCountry: string; - logo: string; - icon: string; - secondaryPhoto: string; - type: string; - } - - interface MatchGameScore { - team1: number; - team2: number; - } - - interface MatchGameAttributeData { - instanceID: string; - map: string; - mapScore: MatchGameScore; - } - - type ScoreTuple = [number, number]; - - interface MatchGameData { - id: number; - points: ScoreTuple; - attributes: MatchGameAttributeData; - attributesVersion: string; - state: string; - status: string; - statusReason: string; - stats: null; - handle: string; - } - - interface MatchVideoData { - name: number; - description: string; - vodLink: string; - youtubeId: string; - thumbnailUrl: string; - } - - interface MatchTournamentData { - id: number; - type: string; - location: string; - } - - interface MatchData { - id: number; - competitors: TeamData[]; - scores: MatchScores[]; - conclusionValue: number; - conclusionStrategy: string; - winner: TeamData; - state: string; - status: string; - statusReason: string; - attributes: {}; - games: MatchGameData[]; - clientHints: any[]; - dateCreated: number; - flags: any[]; - handle: string; - startDate: string; - endDate: string; - showStartTime: boolean; - showEndTime: boolean; - startDateTS: number; - endDateTS: number; - youtubeId: string; - wins: ScoreTuple; - ties: ScoreTuple; - losses: ScoreTuple; - videos: MatchVideoData[]; - tournament: MatchTournamentData; - } - - interface WeekData { - id: number; - startDate: number; - endDate: number; - matches: MatchData[]; - name: string; - } - - interface StageScheduleInfo { - id: number; - slug: string; - enabled: boolean; - name: string; - tournament: TournamentData[]; - matches: MatchData[]; - weeks: WeekData[]; - } - - interface ScheduleInfo { - startDate: string; - endDate: string; - stages: StageScheduleInfo[]; - } - - function getLiveMatch(callback: callbackFunc>): void; - function getStandings(callback: callbackFunc>): void; - function getSchedule(callback: callbackFunc>): void; + interface ScheduleInfo { + startDate: string; + endDate: string; + stages: StageScheduleInfo[]; } + + function getLiveMatch(callback: callbackFunc>): void; + function getStandings(callback: callbackFunc>): void; + function getSchedule(callback: callbackFunc>): void; }