hive-bedrock-api 4.1.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/HiveAPI.d.ts +111 -0
- package/lib/HiveAPI.d.ts.map +1 -0
- package/lib/HiveAPI.js +244 -0
- package/lib/HiveAPI.js.map +1 -0
- package/lib/index.d.ts +9 -115
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +9 -269
- package/lib/index.js.map +1 -1
- package/lib/processors/game.d.ts +1 -1
- package/lib/processors/game.d.ts.map +1 -1
- package/lib/processors/game.js +44 -47
- package/lib/processors/game.js.map +1 -1
- package/lib/processors/global_statistics.js +1 -2
- package/lib/processors/map.js +1 -2
- package/lib/processors/meta.js +1 -2
- package/lib/processors/player.js +3 -7
- package/lib/processors/player.js.map +1 -1
- package/lib/processors/player_search.js +1 -4
- package/lib/processors/player_search.js.map +1 -1
- package/lib/utils.js +1 -2
- package/package.json +11 -4
package/lib/HiveAPI.d.ts
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { Game, Timeframe } from "hive-bedrock-data";
|
|
2
|
+
import { MethodResponse } from "./utils.js";
|
|
3
|
+
import { ProcessedPlayerResponse } from "./processors/player.js";
|
|
4
|
+
import { ProcessedGlobalStatisticsResponse } from "./processors/global_statistics.js";
|
|
5
|
+
import { ProcessedMapResponse } from "./processors/map.js";
|
|
6
|
+
import { ProcessedGameMetadata } from "./processors/meta.js";
|
|
7
|
+
import { ProcessedPlayerSearchResponse } from "./processors/player_search.js";
|
|
8
|
+
import { AvailableLeaderboardResponse, ProcessedAllGamesResponse, ProcessedGame, ProcessedMonthlyGamesResponse } from "./processors/game.js";
|
|
9
|
+
interface Options {
|
|
10
|
+
resolveDynamicTitles?: boolean;
|
|
11
|
+
useModernLeaderboardSource?: boolean;
|
|
12
|
+
apiBaseEndpoint?: string;
|
|
13
|
+
requestInit?: RequestInit;
|
|
14
|
+
}
|
|
15
|
+
export default class HiveAPI {
|
|
16
|
+
options: Options;
|
|
17
|
+
constructor(options?: Options);
|
|
18
|
+
private _fetchAPI;
|
|
19
|
+
/**
|
|
20
|
+
* `/game/all/main/{identifier}` Gets information about a player
|
|
21
|
+
* @param identifier Username or UUID of the player
|
|
22
|
+
* @returns The player information
|
|
23
|
+
*/
|
|
24
|
+
getPlayer(identifier: string): Promise<MethodResponse<ProcessedPlayerResponse>>;
|
|
25
|
+
/**
|
|
26
|
+
* `/player/search/{prefix}` Gets a list of players that match the prefix
|
|
27
|
+
* @param prefix The prefix to search for (must be at least 4 characters long)
|
|
28
|
+
* @returns A list of players that match the prefix
|
|
29
|
+
*/
|
|
30
|
+
getPlayerSearch(prefix: string): Promise<MethodResponse<ProcessedPlayerSearchResponse>>;
|
|
31
|
+
/**
|
|
32
|
+
* Gets statistics for a player
|
|
33
|
+
* @param identifier Username or UUID of the player
|
|
34
|
+
* @param timeframe The timeframe to get the statistics for
|
|
35
|
+
* @param options Additional options including specific game, month, and year
|
|
36
|
+
* @returns The player statistics
|
|
37
|
+
*/
|
|
38
|
+
getStatistics(identifier: string, timeframe: Timeframe.AllTime): Promise<MethodResponse<ProcessedAllGamesResponse>>;
|
|
39
|
+
getStatistics<G extends Game>(identifier: string, timeframe: Timeframe.AllTime, options: {
|
|
40
|
+
game: G;
|
|
41
|
+
}): Promise<MethodResponse<ProcessedGame<Timeframe.AllTime, false>[G]>>;
|
|
42
|
+
getStatistics(identifier: string, timeframe: Timeframe.Monthly, options?: {
|
|
43
|
+
month?: number;
|
|
44
|
+
year?: number;
|
|
45
|
+
}): Promise<MethodResponse<ProcessedMonthlyGamesResponse>>;
|
|
46
|
+
getStatistics<G extends Game>(identifier: string, timeframe: Timeframe.Monthly, options: {
|
|
47
|
+
game: G;
|
|
48
|
+
month?: number;
|
|
49
|
+
year?: number;
|
|
50
|
+
}): Promise<MethodResponse<ProcessedGame<Timeframe.Monthly, false>[G]>>;
|
|
51
|
+
getStatistics<G extends Game>(identifier: string, timeframe: Timeframe.Seasonal, options: {
|
|
52
|
+
game: G;
|
|
53
|
+
season: number;
|
|
54
|
+
}): Promise<MethodResponse<ProcessedMonthlyGamesResponse>>;
|
|
55
|
+
private _getStatisticsAllTime;
|
|
56
|
+
private _getStatisticsMonthly;
|
|
57
|
+
private _getStatisticsSeasonal;
|
|
58
|
+
getAvailableMonthlyLeaderboards<G extends Game>(game: G): Promise<MethodResponse<AvailableLeaderboardResponse>>;
|
|
59
|
+
/**
|
|
60
|
+
* `/game/season/player/{game}/{player}/{season}` Gets seasonal statistics for a player
|
|
61
|
+
* @param identifier Username or UUID of the player
|
|
62
|
+
* @param game The game to get the statistics for
|
|
63
|
+
* @param season The season to get the statistics for
|
|
64
|
+
* @returns The player's seasonal statistics
|
|
65
|
+
*/
|
|
66
|
+
getSeasonalStatistics<G extends Game>(identifier: string, game: G, season?: number): Promise<MethodResponse<ProcessedMonthlyGamesResponse["statistics"][G] | null>>;
|
|
67
|
+
/**
|
|
68
|
+
* `/game/all/{game}` Gets statistics for a game
|
|
69
|
+
* @param timeframe The timeframe to get the statistics for
|
|
70
|
+
* @param game The game to get the statistics for
|
|
71
|
+
* @param options Additional options including specific month and year
|
|
72
|
+
*/
|
|
73
|
+
getLeaderboard<G extends Game>(timeframe: Timeframe.AllTime, game: G): Promise<MethodResponse<ProcessedGame<Timeframe.AllTime, true>[G][] | null>>;
|
|
74
|
+
getLeaderboard<G extends Game>(timeframe: Timeframe.Monthly, game: G): Promise<MethodResponse<ProcessedGame<Timeframe.Monthly, true>[G][] | null>>;
|
|
75
|
+
getLeaderboard<G extends Game>(timeframe: Timeframe.Monthly, game: G, options: {
|
|
76
|
+
month?: number;
|
|
77
|
+
year?: number;
|
|
78
|
+
}): Promise<MethodResponse<ProcessedGame<Timeframe.Monthly, true>[G][] | null>>;
|
|
79
|
+
getLeaderboard<G extends Game>(timeframe: Timeframe.Seasonal, game: G, options: {
|
|
80
|
+
season: number;
|
|
81
|
+
}): Promise<MethodResponse<ProcessedGame<Timeframe.Seasonal, true>[G][] | null>>;
|
|
82
|
+
private _getLeaderboardAllTime;
|
|
83
|
+
private _getLeaderboardMonthly;
|
|
84
|
+
private _getLeaderboardSeasonal;
|
|
85
|
+
/**
|
|
86
|
+
* `/game/season/{game}/{season}` Gets seasonal statistics for a game
|
|
87
|
+
* @param game The game to get the statistics for
|
|
88
|
+
* @param season The season to get the statistics for
|
|
89
|
+
* @returns The seasonal statistics for the game
|
|
90
|
+
*/
|
|
91
|
+
getSeasonalLeaderboard<G extends Game>(game: G, season?: number): Promise<MethodResponse<ProcessedGame<Timeframe.Monthly, true>[G][]>>;
|
|
92
|
+
/**
|
|
93
|
+
* `/global/statistics` Gets global statistics
|
|
94
|
+
* @returns The global statistics
|
|
95
|
+
*/
|
|
96
|
+
getGlobalStatistics(): Promise<MethodResponse<ProcessedGlobalStatisticsResponse>>;
|
|
97
|
+
/**
|
|
98
|
+
* `/game/map/{game}` Gets information about the maps in a game
|
|
99
|
+
* @param game The game to get the maps for (fails for games without maps)
|
|
100
|
+
* @returns A list of maps in the game
|
|
101
|
+
*/
|
|
102
|
+
getGameMaps(game: Game): Promise<MethodResponse<ProcessedMapResponse>>;
|
|
103
|
+
/**
|
|
104
|
+
* `/game/meta/{game}` Gets metadata about a game
|
|
105
|
+
* @param game The game to get the metadata for
|
|
106
|
+
* @returns The metadata for the game
|
|
107
|
+
*/
|
|
108
|
+
getGameMetadata(game: Game): Promise<MethodResponse<ProcessedGameMetadata>>;
|
|
109
|
+
}
|
|
110
|
+
export {};
|
|
111
|
+
//# sourceMappingURL=HiveAPI.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HiveAPI.d.ts","sourceRoot":"","sources":["../src/HiveAPI.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,IAAI,EAAS,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAA0B,EAAE,uBAAuB,E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,CAAC,CAAC,EAAE,CAAC,CAAC;IAQtJ;;;OAGG;IACU,mBAAmB,IAAI,OAAO,CAAC,cAAc,CAAC,iCAAiC,CAAC,CAAC;IAK9F;;;;OAIG;IACU,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,cAAc,CAAC,oBAAoB,CAAC,CAAC;IAMnF;;;;OAIG;IACU,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,cAAc,CAAC,qBAAqB,CAAC,CAAC;CAM3F"}
|
package/lib/HiveAPI.js
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { API_BASE_ENDPOINT, Games, Timeframe } from "hive-bedrock-data";
|
|
2
|
+
import processPlayerInfo from "./processors/player.js";
|
|
3
|
+
import processPlayerSearch from "./processors/player_search.js";
|
|
4
|
+
import { processGame } from "./processors/game.js";
|
|
5
|
+
export default class HiveAPI {
|
|
6
|
+
options;
|
|
7
|
+
constructor(options = {}) {
|
|
8
|
+
this.options = options;
|
|
9
|
+
this.options = options;
|
|
10
|
+
this.options.apiBaseEndpoint = this.options.apiBaseEndpoint ?? API_BASE_ENDPOINT;
|
|
11
|
+
}
|
|
12
|
+
async _fetchAPI(endpoint) {
|
|
13
|
+
const url = this.options.apiBaseEndpoint + endpoint;
|
|
14
|
+
try {
|
|
15
|
+
const start = performance.now();
|
|
16
|
+
const request = await fetch(url, {
|
|
17
|
+
...this.options.requestInit,
|
|
18
|
+
headers: {
|
|
19
|
+
"X-Hive-Resolve-Stat-Track": (this.options.resolveDynamicTitles ?? true).toString(),
|
|
20
|
+
"X-Hive-Leaderboard-Source": this.options.useModernLeaderboardSource ? "modern" : "legacy",
|
|
21
|
+
...this.options.requestInit?.headers,
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
if (!request.ok)
|
|
25
|
+
return { data: null, error: { status: request.status } };
|
|
26
|
+
const meta = {
|
|
27
|
+
duration: Math.ceil(performance.now() - start),
|
|
28
|
+
ratelimit: {
|
|
29
|
+
limit: Number(request.headers.get("X-Ratelimit-Limit")),
|
|
30
|
+
remaining: Number(request.headers.get("X-Ratelimit-Remaining")),
|
|
31
|
+
reset: Number(request.headers.get("X-Ratelimit-Reset")),
|
|
32
|
+
},
|
|
33
|
+
retryAfter: Number(request.headers.get("Retry-After")),
|
|
34
|
+
};
|
|
35
|
+
const response = await request.json();
|
|
36
|
+
return { data: response, error: null, meta };
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
return { data: null, error: { status: 500, message: err.message } };
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* `/game/all/main/{identifier}` Gets information about a player
|
|
44
|
+
* @param identifier Username or UUID of the player
|
|
45
|
+
* @returns The player information
|
|
46
|
+
*/
|
|
47
|
+
async getPlayer(identifier) {
|
|
48
|
+
const { data: response, error, meta } = await this._fetchAPI(`/game/all/main/${identifier}`);
|
|
49
|
+
if (error)
|
|
50
|
+
return { data: null, error, meta };
|
|
51
|
+
const data = processPlayerInfo(response);
|
|
52
|
+
if (!data)
|
|
53
|
+
return { data: null, error: { status: 500, message: "Failed to process player data" }, meta };
|
|
54
|
+
return { data, error: null, meta };
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* `/player/search/{prefix}` Gets a list of players that match the prefix
|
|
58
|
+
* @param prefix The prefix to search for (must be at least 4 characters long)
|
|
59
|
+
* @returns A list of players that match the prefix
|
|
60
|
+
*/
|
|
61
|
+
async getPlayerSearch(prefix) {
|
|
62
|
+
const { data: response, error, meta } = await this._fetchAPI(`/player/search/${prefix}`);
|
|
63
|
+
if (error)
|
|
64
|
+
return { data: null, error, meta };
|
|
65
|
+
const data = processPlayerSearch(response);
|
|
66
|
+
if (!data)
|
|
67
|
+
return { data: null, error: { status: 500, message: "Failed to process player search data" }, meta };
|
|
68
|
+
return { data, error: null, meta };
|
|
69
|
+
}
|
|
70
|
+
async getStatistics(identifier, timeframe, options) {
|
|
71
|
+
if (timeframe === Timeframe.AllTime) {
|
|
72
|
+
if (options?.game) {
|
|
73
|
+
if (!Games[options.game].statistics)
|
|
74
|
+
throw new Error(`Statistics are not available for the game: ${options.game}`);
|
|
75
|
+
return this._getStatisticsAllTime(identifier, options.game);
|
|
76
|
+
}
|
|
77
|
+
return this._getStatisticsAllTime(identifier);
|
|
78
|
+
}
|
|
79
|
+
else if (timeframe === Timeframe.Seasonal) {
|
|
80
|
+
if (!options?.game)
|
|
81
|
+
throw new Error("Game must be specified for seasonal statistics");
|
|
82
|
+
if (!Games[options.game].statistics)
|
|
83
|
+
throw new Error(`Statistics are not available for the game: ${options.game}`);
|
|
84
|
+
return this._getStatisticsSeasonal(identifier, options?.game, options?.season || 1);
|
|
85
|
+
}
|
|
86
|
+
if (options?.game)
|
|
87
|
+
return this._getStatisticsMonthly(identifier, options.game, options.month, options.year);
|
|
88
|
+
return this._getStatisticsMonthly(identifier, undefined, options?.month, options?.year);
|
|
89
|
+
}
|
|
90
|
+
async _getStatisticsAllTime(identifier, game) {
|
|
91
|
+
const { data: response, error, meta } = await this._fetchAPI(`/game/all/${game ?? "all"}/${identifier}`);
|
|
92
|
+
if (error)
|
|
93
|
+
return { data: null, error, meta };
|
|
94
|
+
if (game)
|
|
95
|
+
return { data: processGame(game, Timeframe.AllTime, false, response), error: null, meta };
|
|
96
|
+
let data = Object.fromEntries(Object.entries(response).map(([id, res]) => [id, id === "main" ? null : (processGame(id, Timeframe.AllTime, false, res) ?? null)]));
|
|
97
|
+
delete data.main;
|
|
98
|
+
return {
|
|
99
|
+
data: {
|
|
100
|
+
player: processPlayerInfo(response),
|
|
101
|
+
statistics: data,
|
|
102
|
+
},
|
|
103
|
+
error: null,
|
|
104
|
+
meta,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
async _getStatisticsMonthly(identifier, game, month, year) {
|
|
108
|
+
if (game && !Games[game].statistics)
|
|
109
|
+
throw new Error(`Statistics are not available for the game: ${game}`);
|
|
110
|
+
const { data: response, error, meta, } = await this._fetchAPI(`/game/monthly/player/${game ?? "all"}/${identifier}/${year ?? new Date().getFullYear()}/${month ?? new Date().getMonth() + 1}`);
|
|
111
|
+
if (error)
|
|
112
|
+
return { data: null, error, meta };
|
|
113
|
+
if (game)
|
|
114
|
+
return { data: processGame(game, Timeframe.Monthly, false, response), error: null, meta };
|
|
115
|
+
let data = Object.fromEntries(Object.entries(response).map(([id, res]) => [id, id === "main" ? null : (processGame(id, Timeframe.Monthly, false, res) ?? null)]));
|
|
116
|
+
delete data.main;
|
|
117
|
+
return {
|
|
118
|
+
data: {
|
|
119
|
+
statistics: data,
|
|
120
|
+
},
|
|
121
|
+
error: null,
|
|
122
|
+
meta,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
async _getStatisticsSeasonal(identifier, game, season) {
|
|
126
|
+
if (!Games[game].statistics)
|
|
127
|
+
throw new Error(`Statistics are not available for the game: ${game}`);
|
|
128
|
+
const { data: response, error, meta } = await this._fetchAPI(`/game/season/player/${game}/${identifier}/${season ?? 1}`);
|
|
129
|
+
if (error)
|
|
130
|
+
return { data: null, error, meta };
|
|
131
|
+
return { data: processGame(game, Timeframe.Seasonal, false, response), error: null, meta };
|
|
132
|
+
}
|
|
133
|
+
async getAvailableMonthlyLeaderboards(game) {
|
|
134
|
+
const { data: response, error, meta } = await this._fetchAPI(`/game/monthly/${game}/available`);
|
|
135
|
+
if (error)
|
|
136
|
+
return { data: null, error, meta };
|
|
137
|
+
return { data: response, error: null, meta };
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* `/game/season/player/{game}/{player}/{season}` Gets seasonal statistics for a player
|
|
141
|
+
* @param identifier Username or UUID of the player
|
|
142
|
+
* @param game The game to get the statistics for
|
|
143
|
+
* @param season The season to get the statistics for
|
|
144
|
+
* @returns The player's seasonal statistics
|
|
145
|
+
*/
|
|
146
|
+
async getSeasonalStatistics(identifier, game, season = 1) {
|
|
147
|
+
if (game && !Games[game].statistics)
|
|
148
|
+
throw new Error(`Statistics are not available for the game: ${game}`);
|
|
149
|
+
const { data: response, error, meta } = await this._fetchAPI(`/game/season/player/${game}/${identifier}/${season}`);
|
|
150
|
+
if (error)
|
|
151
|
+
return { data: null, error, meta };
|
|
152
|
+
let data = processGame(game, Timeframe.Monthly, true, response);
|
|
153
|
+
return { data, error: null, meta };
|
|
154
|
+
}
|
|
155
|
+
async getLeaderboard(timeframe, game, options) {
|
|
156
|
+
if (game && !Games[game].statistics)
|
|
157
|
+
throw new Error(`Statistics are not available for the game: ${game}`);
|
|
158
|
+
if (timeframe === Timeframe.Monthly)
|
|
159
|
+
return this._getLeaderboardMonthly(game, options?.month || new Date().getMonth() + 1, options?.year || new Date().getFullYear());
|
|
160
|
+
if (timeframe === Timeframe.Seasonal)
|
|
161
|
+
return this._getLeaderboardSeasonal(game, options?.season || 1);
|
|
162
|
+
return this._getLeaderboardAllTime(game);
|
|
163
|
+
}
|
|
164
|
+
// /game/all/{game}
|
|
165
|
+
async _getLeaderboardAllTime(game) {
|
|
166
|
+
const { data: response, error, meta } = await this._fetchAPI(`/game/all/${game}`);
|
|
167
|
+
if (error)
|
|
168
|
+
return { data: null, error, meta };
|
|
169
|
+
let data = response.map((res) => processGame(game, Timeframe.AllTime, true, res));
|
|
170
|
+
return { data, error: null, meta };
|
|
171
|
+
}
|
|
172
|
+
// /game/monthly/{game}/{year}/{month}
|
|
173
|
+
async _getLeaderboardMonthly(game, month, year) {
|
|
174
|
+
if (game && !Games[game].statistics)
|
|
175
|
+
throw new Error(`Statistics are not available for the game: ${game}`);
|
|
176
|
+
const { data: response, error, meta } = await this._fetchAPI(`/game/monthly/${game}/${year}/${month}`);
|
|
177
|
+
if (error)
|
|
178
|
+
return { data: null, error, meta };
|
|
179
|
+
let data = response.map((res) => processGame(game, Timeframe.Monthly, true, res));
|
|
180
|
+
return { data, error: null, meta };
|
|
181
|
+
}
|
|
182
|
+
// /game/season/{game}/season
|
|
183
|
+
async _getLeaderboardSeasonal(game, season = 1) {
|
|
184
|
+
if (game && !Games[game].statistics)
|
|
185
|
+
throw new Error(`Statistics are not available for the game: ${game}`);
|
|
186
|
+
const { data: response, error, meta } = await this._fetchAPI(`/game/season/${game}/${season}`);
|
|
187
|
+
if (error)
|
|
188
|
+
return { data: null, error, meta };
|
|
189
|
+
let data = response.map((res) => processGame(game, Timeframe.Seasonal, true, res));
|
|
190
|
+
return { data, error: null, meta };
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* `/game/season/{game}/{season}` Gets seasonal statistics for a game
|
|
194
|
+
* @param game The game to get the statistics for
|
|
195
|
+
* @param season The season to get the statistics for
|
|
196
|
+
* @returns The seasonal statistics for the game
|
|
197
|
+
*/
|
|
198
|
+
async getSeasonalLeaderboard(game, season = 1) {
|
|
199
|
+
if (game && !Games[game].statistics)
|
|
200
|
+
throw new Error(`Statistics are not available for the game: ${game}`);
|
|
201
|
+
const { data: response, error, meta } = await this._fetchAPI(`/game/season/${game}/${season ?? 1}`);
|
|
202
|
+
if (error)
|
|
203
|
+
return { data: null, error, meta };
|
|
204
|
+
let data = response.map((res) => processGame(game, Timeframe.Monthly, true, res));
|
|
205
|
+
return { data, error: null, meta };
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* `/global/statistics` Gets global statistics
|
|
209
|
+
* @returns The global statistics
|
|
210
|
+
*/
|
|
211
|
+
async getGlobalStatistics() {
|
|
212
|
+
const { data: response, error, meta } = await this._fetchAPI("/global/statistics");
|
|
213
|
+
if (error)
|
|
214
|
+
return { data: null, error, meta };
|
|
215
|
+
return { data: response, error: null, meta };
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* `/game/map/{game}` Gets information about the maps in a game
|
|
219
|
+
* @param game The game to get the maps for (fails for games without maps)
|
|
220
|
+
* @returns A list of maps in the game
|
|
221
|
+
*/
|
|
222
|
+
async getGameMaps(game) {
|
|
223
|
+
if (game && !Games[game].statistics)
|
|
224
|
+
throw new Error(`Statistics are not available for the game: ${game}`);
|
|
225
|
+
const { data: response, error, meta } = await this._fetchAPI(`/game/map/${game}`);
|
|
226
|
+
if (error)
|
|
227
|
+
return { data: null, error, meta };
|
|
228
|
+
return { data: response, error: null, meta };
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* `/game/meta/{game}` Gets metadata about a game
|
|
232
|
+
* @param game The game to get the metadata for
|
|
233
|
+
* @returns The metadata for the game
|
|
234
|
+
*/
|
|
235
|
+
async getGameMetadata(game) {
|
|
236
|
+
if (game && !Games[game].statistics)
|
|
237
|
+
throw new Error(`Statistics are not available for the game: ${game}`);
|
|
238
|
+
const { data: response, error, meta } = await this._fetchAPI(`/game/meta/${game}`);
|
|
239
|
+
if (error)
|
|
240
|
+
return { data: null, error, meta };
|
|
241
|
+
return { data: response, error: null, meta };
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
//# sourceMappingURL=HiveAPI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HiveAPI.js","sourceRoot":"","sources":["../src/HiveAPI.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAQ,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9E,OAAO,iBAA8C,MAAM,wBAAwB,CAAC;AAIpF,OAAO,mBAAsD,MAAM,+BAA+B,CAAC;AACnG,OAAO,EAAE,WAAW,EAAyG,MAAM,sBAAsB,CAAC;AAU1J,MAAM,CAAC,OAAO,OAAO,OAAO;IACL;IAAnB,YAAmB,UAAmB,EAAE;QAArB,YAAO,GAAP,OAAO,CAAc;QACpC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,IAAI,iBAAiB,CAAC;IACrF,CAAC;IAEO,KAAK,CAAC,SAAS,CAAgB,QAAgB;QACnD,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,GAAG,QAAQ,CAAC;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IACjD,CAAC;CACJ"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,116 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
resolveDynamicTitles?: boolean;
|
|
11
|
-
useModernLeaderboardSource?: boolean;
|
|
12
|
-
apiBaseEndpoint?: string;
|
|
13
|
-
requestInit?: RequestInit;
|
|
14
|
-
}
|
|
15
|
-
export * from "./processors/game";
|
|
16
|
-
export * from "./processors/global_statistics";
|
|
17
|
-
export * from "./processors/map";
|
|
18
|
-
export * from "./processors/meta";
|
|
19
|
-
export * from "./processors/player";
|
|
20
|
-
export * from "./processors/player_search";
|
|
21
|
-
export default class HiveAPI {
|
|
22
|
-
options: Options;
|
|
23
|
-
constructor(options?: Options);
|
|
24
|
-
private _fetchAPI;
|
|
25
|
-
/**
|
|
26
|
-
* `/game/all/main/{identifier}` Gets information about a player
|
|
27
|
-
* @param identifier Username or UUID of the player
|
|
28
|
-
* @returns The player information
|
|
29
|
-
*/
|
|
30
|
-
getPlayer(identifier: string): Promise<MethodResponse<ProcessedPlayerResponse>>;
|
|
31
|
-
/**
|
|
32
|
-
* `/player/search/{prefix}` Gets a list of players that match the prefix
|
|
33
|
-
* @param prefix The prefix to search for (must be at least 4 characters long)
|
|
34
|
-
* @returns A list of players that match the prefix
|
|
35
|
-
*/
|
|
36
|
-
getPlayerSearch(prefix: string): Promise<MethodResponse<ProcessedPlayerSearchResponse>>;
|
|
37
|
-
/**
|
|
38
|
-
* Gets statistics for a player
|
|
39
|
-
* @param identifier Username or UUID of the player
|
|
40
|
-
* @param timeframe The timeframe to get the statistics for
|
|
41
|
-
* @param options Additional options including specific game, month, and year
|
|
42
|
-
* @returns The player statistics
|
|
43
|
-
*/
|
|
44
|
-
getStatistics(identifier: string, timeframe: Timeframe.AllTime): Promise<MethodResponse<ProcessedAllGamesResponse>>;
|
|
45
|
-
getStatistics<G extends Game>(identifier: string, timeframe: Timeframe.AllTime, options: {
|
|
46
|
-
game: G;
|
|
47
|
-
}): Promise<MethodResponse<ProcessedGame<Timeframe.AllTime, false>[G]>>;
|
|
48
|
-
getStatistics(identifier: string, timeframe: Timeframe.Monthly, options?: {
|
|
49
|
-
month?: number;
|
|
50
|
-
year?: number;
|
|
51
|
-
}): Promise<MethodResponse<ProcessedMonthlyGamesResponse>>;
|
|
52
|
-
getStatistics<G extends Game>(identifier: string, timeframe: Timeframe.Monthly, options: {
|
|
53
|
-
game: G;
|
|
54
|
-
month?: number;
|
|
55
|
-
year?: number;
|
|
56
|
-
}): Promise<MethodResponse<ProcessedGame<Timeframe.Monthly, false>[G]>>;
|
|
57
|
-
getStatistics<G extends Game>(identifier: string, timeframe: Timeframe.Seasonal, options: {
|
|
58
|
-
game: G;
|
|
59
|
-
season: number;
|
|
60
|
-
}): Promise<MethodResponse<ProcessedMonthlyGamesResponse>>;
|
|
61
|
-
private _getStatisticsAllTime;
|
|
62
|
-
private _getStatisticsMonthly;
|
|
63
|
-
private _getStatisticsSeasonal;
|
|
64
|
-
getAvailableMonthlyLeaderboards<G extends Game>(game: G): Promise<MethodResponse<AvailableLeaderboardResponse>>;
|
|
65
|
-
/**
|
|
66
|
-
* `/game/season/player/{game}/{player}/{season}` Gets seasonal statistics for a player
|
|
67
|
-
* @param identifier Username or UUID of the player
|
|
68
|
-
* @param game The game to get the statistics for
|
|
69
|
-
* @param season The season to get the statistics for
|
|
70
|
-
* @returns The player's seasonal statistics
|
|
71
|
-
*/
|
|
72
|
-
getSeasonalStatistics<G extends Game>(identifier: string, game: G, season?: number): Promise<MethodResponse<ProcessedMonthlyGamesResponse["statistics"][G] | null>>;
|
|
73
|
-
/**
|
|
74
|
-
* `/game/all/{game}` Gets statistics for a game
|
|
75
|
-
* @param timeframe The timeframe to get the statistics for
|
|
76
|
-
* @param game The game to get the statistics for
|
|
77
|
-
* @param options Additional options including specific month and year
|
|
78
|
-
*/
|
|
79
|
-
getLeaderboard<G extends Game>(timeframe: Timeframe.AllTime, game: G): Promise<MethodResponse<ProcessedGame<Timeframe.AllTime, true>[G][] | null>>;
|
|
80
|
-
getLeaderboard<G extends Game>(timeframe: Timeframe.Monthly, game: G): Promise<MethodResponse<ProcessedGame<Timeframe.Monthly, true>[G][] | null>>;
|
|
81
|
-
getLeaderboard<G extends Game>(timeframe: Timeframe.Monthly, game: G, options: {
|
|
82
|
-
month?: number;
|
|
83
|
-
year?: number;
|
|
84
|
-
}): Promise<MethodResponse<ProcessedGame<Timeframe.Monthly, true>[G][] | null>>;
|
|
85
|
-
getLeaderboard<G extends Game>(timeframe: Timeframe.Seasonal, game: G, options: {
|
|
86
|
-
season: number;
|
|
87
|
-
}): Promise<MethodResponse<ProcessedGame<Timeframe.Seasonal, true>[G][] | null>>;
|
|
88
|
-
private _getLeaderboardAllTime;
|
|
89
|
-
private _getLeaderboardMonthly;
|
|
90
|
-
private _getLeaderboardSeasonal;
|
|
91
|
-
/**
|
|
92
|
-
* `/game/season/{game}/{season}` Gets seasonal statistics for a game
|
|
93
|
-
* @param game The game to get the statistics for
|
|
94
|
-
* @param season The season to get the statistics for
|
|
95
|
-
* @returns The seasonal statistics for the game
|
|
96
|
-
*/
|
|
97
|
-
getSeasonalLeaderboard<G extends Game>(game: G, season?: number): Promise<MethodResponse<ProcessedGame<Timeframe.Monthly, true>[G][]>>;
|
|
98
|
-
/**
|
|
99
|
-
* `/global/statistics` Gets global statistics
|
|
100
|
-
* @returns The global statistics
|
|
101
|
-
*/
|
|
102
|
-
getGlobalStatistics(): Promise<MethodResponse<ProcessedGlobalStatisticsResponse>>;
|
|
103
|
-
/**
|
|
104
|
-
* `/game/map/{game}` Gets information about the maps in a game
|
|
105
|
-
* @param game The game to get the maps for (fails for games without maps)
|
|
106
|
-
* @returns A list of maps in the game
|
|
107
|
-
*/
|
|
108
|
-
getGameMaps(game: Game): Promise<MethodResponse<ProcessedMapResponse>>;
|
|
109
|
-
/**
|
|
110
|
-
* `/game/meta/{game}` Gets metadata about a game
|
|
111
|
-
* @param game The game to get the metadata for
|
|
112
|
-
* @returns The metadata for the game
|
|
113
|
-
*/
|
|
114
|
-
getGameMetadata(game: Game): Promise<MethodResponse<ProcessedGameMetadata>>;
|
|
115
|
-
}
|
|
1
|
+
import HiveAPI from "./HiveAPI.js";
|
|
2
|
+
export * from "./processors/game.js";
|
|
3
|
+
export * from "./processors/global_statistics.js";
|
|
4
|
+
export * from "./processors/map.js";
|
|
5
|
+
export * from "./processors/meta.js";
|
|
6
|
+
export * from "./processors/player.js";
|
|
7
|
+
export * from "./processors/player_search.js";
|
|
8
|
+
export { HiveAPI };
|
|
9
|
+
export default HiveAPI;
|
|
116
10
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mCAAmC,CAAC;AAClD,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAE9C,OAAO,EAAE,OAAO,EAAE,CAAC;AACnB,eAAe,OAAO,CAAC"}
|