hive-bedrock-api 4.1.0 → 4.1.1

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.
@@ -0,0 +1,111 @@
1
+ import { Game, Timeframe } from "hive-bedrock-data";
2
+ import { MethodResponse } from "./utils";
3
+ import { ProcessedPlayerResponse } from "./processors/player";
4
+ import { ProcessedGlobalStatisticsResponse } from "./processors/global_statistics";
5
+ import { ProcessedMapResponse } from "./processors/map";
6
+ import { ProcessedGameMetadata } from "./processors/meta";
7
+ import { ProcessedPlayerSearchResponse } from "./processors/player_search";
8
+ import { AvailableLeaderboardResponse, ProcessedAllGamesResponse, ProcessedGame, ProcessedMonthlyGamesResponse } from "./processors/game";
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,SAAS,CAAC;AACzC,OAA0B,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EAAE,iCAAiC,EAAE,MAAM,gCAAgC,CAAC;AACnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD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AW,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,250 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const hive_bedrock_data_1 = require("hive-bedrock-data");
7
+ const player_1 = __importDefault(require("./processors/player"));
8
+ const player_search_1 = __importDefault(require("./processors/player_search"));
9
+ const game_1 = require("./processors/game");
10
+ class HiveAPI {
11
+ options;
12
+ constructor(options = {}) {
13
+ this.options = options;
14
+ this.options = options;
15
+ this.options.apiBaseEndpoint = this.options.apiBaseEndpoint ?? hive_bedrock_data_1.API_BASE_ENDPOINT;
16
+ }
17
+ async _fetchAPI(endpoint) {
18
+ const url = this.options.apiBaseEndpoint + endpoint;
19
+ try {
20
+ const start = performance.now();
21
+ const request = await fetch(url, {
22
+ ...this.options.requestInit,
23
+ headers: {
24
+ "X-Hive-Resolve-Stat-Track": (this.options.resolveDynamicTitles ?? true).toString(),
25
+ "X-Hive-Leaderboard-Source": this.options.useModernLeaderboardSource ? "modern" : "legacy",
26
+ ...this.options.requestInit?.headers,
27
+ },
28
+ });
29
+ if (!request.ok)
30
+ return { data: null, error: { status: request.status } };
31
+ const meta = {
32
+ duration: Math.ceil(performance.now() - start),
33
+ ratelimit: {
34
+ limit: Number(request.headers.get("X-Ratelimit-Limit")),
35
+ remaining: Number(request.headers.get("X-Ratelimit-Remaining")),
36
+ reset: Number(request.headers.get("X-Ratelimit-Reset")),
37
+ },
38
+ retryAfter: Number(request.headers.get("Retry-After")),
39
+ };
40
+ const response = await request.json();
41
+ return { data: response, error: null, meta };
42
+ }
43
+ catch (err) {
44
+ return { data: null, error: { status: 500, message: err.message } };
45
+ }
46
+ }
47
+ /**
48
+ * `/game/all/main/{identifier}` Gets information about a player
49
+ * @param identifier Username or UUID of the player
50
+ * @returns The player information
51
+ */
52
+ async getPlayer(identifier) {
53
+ const { data: response, error, meta } = await this._fetchAPI(`/game/all/main/${identifier}`);
54
+ if (error)
55
+ return { data: null, error, meta };
56
+ const data = (0, player_1.default)(response);
57
+ if (!data)
58
+ return { data: null, error: { status: 500, message: "Failed to process player data" }, meta };
59
+ return { data, error: null, meta };
60
+ }
61
+ /**
62
+ * `/player/search/{prefix}` Gets a list of players that match the prefix
63
+ * @param prefix The prefix to search for (must be at least 4 characters long)
64
+ * @returns A list of players that match the prefix
65
+ */
66
+ async getPlayerSearch(prefix) {
67
+ const { data: response, error, meta } = await this._fetchAPI(`/player/search/${prefix}`);
68
+ if (error)
69
+ return { data: null, error, meta };
70
+ const data = (0, player_search_1.default)(response);
71
+ if (!data)
72
+ return { data: null, error: { status: 500, message: "Failed to process player search data" }, meta };
73
+ return { data, error: null, meta };
74
+ }
75
+ async getStatistics(identifier, timeframe, options) {
76
+ if (timeframe === hive_bedrock_data_1.Timeframe.AllTime) {
77
+ if (options?.game) {
78
+ if (!hive_bedrock_data_1.Games[options.game].statistics)
79
+ throw new Error(`Statistics are not available for the game: ${options.game}`);
80
+ return this._getStatisticsAllTime(identifier, options.game);
81
+ }
82
+ return this._getStatisticsAllTime(identifier);
83
+ }
84
+ else if (timeframe === hive_bedrock_data_1.Timeframe.Seasonal) {
85
+ if (!options?.game)
86
+ throw new Error("Game must be specified for seasonal statistics");
87
+ if (!hive_bedrock_data_1.Games[options.game].statistics)
88
+ throw new Error(`Statistics are not available for the game: ${options.game}`);
89
+ return this._getStatisticsSeasonal(identifier, options?.game, options?.season || 1);
90
+ }
91
+ if (options?.game)
92
+ return this._getStatisticsMonthly(identifier, options.game, options.month, options.year);
93
+ return this._getStatisticsMonthly(identifier, undefined, options?.month, options?.year);
94
+ }
95
+ async _getStatisticsAllTime(identifier, game) {
96
+ const { data: response, error, meta } = await this._fetchAPI(`/game/all/${game ?? "all"}/${identifier}`);
97
+ if (error)
98
+ return { data: null, error, meta };
99
+ if (game)
100
+ return { data: (0, game_1.processGame)(game, hive_bedrock_data_1.Timeframe.AllTime, false, response), error: null, meta };
101
+ let data = Object.fromEntries(Object.entries(response).map(([id, res]) => [id, id === "main" ? null : ((0, game_1.processGame)(id, hive_bedrock_data_1.Timeframe.AllTime, false, res) ?? null)]));
102
+ delete data.main;
103
+ return {
104
+ data: {
105
+ player: (0, player_1.default)(response),
106
+ statistics: data,
107
+ },
108
+ error: null,
109
+ meta,
110
+ };
111
+ }
112
+ async _getStatisticsMonthly(identifier, game, month, year) {
113
+ if (game && !hive_bedrock_data_1.Games[game].statistics)
114
+ throw new Error(`Statistics are not available for the game: ${game}`);
115
+ const { data: response, error, meta, } = await this._fetchAPI(`/game/monthly/player/${game ?? "all"}/${identifier}/${year ?? new Date().getFullYear()}/${month ?? new Date().getMonth() + 1}`);
116
+ if (error)
117
+ return { data: null, error, meta };
118
+ if (game)
119
+ return { data: (0, game_1.processGame)(game, hive_bedrock_data_1.Timeframe.Monthly, false, response), error: null, meta };
120
+ let data = Object.fromEntries(Object.entries(response).map(([id, res]) => [id, id === "main" ? null : ((0, game_1.processGame)(id, hive_bedrock_data_1.Timeframe.Monthly, false, res) ?? null)]));
121
+ delete data.main;
122
+ return {
123
+ data: {
124
+ statistics: data,
125
+ },
126
+ error: null,
127
+ meta,
128
+ };
129
+ }
130
+ async _getStatisticsSeasonal(identifier, game, season) {
131
+ if (!hive_bedrock_data_1.Games[game].statistics)
132
+ throw new Error(`Statistics are not available for the game: ${game}`);
133
+ const { data: response, error, meta } = await this._fetchAPI(`/game/season/player/${game}/${identifier}/${season ?? 1}`);
134
+ if (error)
135
+ return { data: null, error, meta };
136
+ return { data: (0, game_1.processGame)(game, hive_bedrock_data_1.Timeframe.Seasonal, false, response), error: null, meta };
137
+ }
138
+ async getAvailableMonthlyLeaderboards(game) {
139
+ const { data: response, error, meta } = await this._fetchAPI(`/game/monthly/${game}/available`);
140
+ if (error)
141
+ return { data: null, error, meta };
142
+ return { data: response, error: null, meta };
143
+ }
144
+ /**
145
+ * `/game/season/player/{game}/{player}/{season}` Gets seasonal statistics for a player
146
+ * @param identifier Username or UUID of the player
147
+ * @param game The game to get the statistics for
148
+ * @param season The season to get the statistics for
149
+ * @returns The player's seasonal statistics
150
+ */
151
+ async getSeasonalStatistics(identifier, game, season = 1) {
152
+ if (game && !hive_bedrock_data_1.Games[game].statistics)
153
+ throw new Error(`Statistics are not available for the game: ${game}`);
154
+ const { data: response, error, meta } = await this._fetchAPI(`/game/season/player/${game}/${identifier}/${season}`);
155
+ if (error)
156
+ return { data: null, error, meta };
157
+ let data = (0, game_1.processGame)(game, hive_bedrock_data_1.Timeframe.Monthly, true, response);
158
+ return { data, error: null, meta };
159
+ }
160
+ async getLeaderboard(timeframe, game, options) {
161
+ if (game && !hive_bedrock_data_1.Games[game].statistics)
162
+ throw new Error(`Statistics are not available for the game: ${game}`);
163
+ if (timeframe === hive_bedrock_data_1.Timeframe.Monthly)
164
+ return this._getLeaderboardMonthly(game, options?.month || new Date().getMonth() + 1, options?.year || new Date().getFullYear());
165
+ if (timeframe === hive_bedrock_data_1.Timeframe.Seasonal)
166
+ return this._getLeaderboardSeasonal(game, options?.season || 1);
167
+ return this._getLeaderboardAllTime(game);
168
+ }
169
+ // /game/all/{game}
170
+ async _getLeaderboardAllTime(game) {
171
+ const { data: response, error, meta } = await this._fetchAPI(`/game/all/${game}`);
172
+ if (error)
173
+ return { data: null, error, meta };
174
+ let data = response.map((res) => (0, game_1.processGame)(game, hive_bedrock_data_1.Timeframe.AllTime, true, res));
175
+ return { data, error: null, meta };
176
+ }
177
+ // /game/monthly/{game}/{year}/{month}
178
+ async _getLeaderboardMonthly(game, month, year) {
179
+ if (game && !hive_bedrock_data_1.Games[game].statistics)
180
+ throw new Error(`Statistics are not available for the game: ${game}`);
181
+ const { data: response, error, meta } = await this._fetchAPI(`/game/monthly/${game}/${year}/${month}`);
182
+ if (error)
183
+ return { data: null, error, meta };
184
+ let data = response.map((res) => (0, game_1.processGame)(game, hive_bedrock_data_1.Timeframe.Monthly, true, res));
185
+ return { data, error: null, meta };
186
+ }
187
+ // /game/season/{game}/season
188
+ async _getLeaderboardSeasonal(game, season = 1) {
189
+ if (game && !hive_bedrock_data_1.Games[game].statistics)
190
+ throw new Error(`Statistics are not available for the game: ${game}`);
191
+ const { data: response, error, meta } = await this._fetchAPI(`/game/season/${game}/${season}`);
192
+ if (error)
193
+ return { data: null, error, meta };
194
+ let data = response.map((res) => (0, game_1.processGame)(game, hive_bedrock_data_1.Timeframe.Seasonal, true, res));
195
+ return { data, error: null, meta };
196
+ }
197
+ /**
198
+ * `/game/season/{game}/{season}` Gets seasonal statistics for a game
199
+ * @param game The game to get the statistics for
200
+ * @param season The season to get the statistics for
201
+ * @returns The seasonal statistics for the game
202
+ */
203
+ async getSeasonalLeaderboard(game, season = 1) {
204
+ if (game && !hive_bedrock_data_1.Games[game].statistics)
205
+ throw new Error(`Statistics are not available for the game: ${game}`);
206
+ const { data: response, error, meta } = await this._fetchAPI(`/game/season/${game}/${season ?? 1}`);
207
+ if (error)
208
+ return { data: null, error, meta };
209
+ let data = response.map((res) => (0, game_1.processGame)(game, hive_bedrock_data_1.Timeframe.Monthly, true, res));
210
+ return { data, error: null, meta };
211
+ }
212
+ /**
213
+ * `/global/statistics` Gets global statistics
214
+ * @returns The global statistics
215
+ */
216
+ async getGlobalStatistics() {
217
+ const { data: response, error, meta } = await this._fetchAPI("/global/statistics");
218
+ if (error)
219
+ return { data: null, error, meta };
220
+ return { data: response, error: null, meta };
221
+ }
222
+ /**
223
+ * `/game/map/{game}` Gets information about the maps in a game
224
+ * @param game The game to get the maps for (fails for games without maps)
225
+ * @returns A list of maps in the game
226
+ */
227
+ async getGameMaps(game) {
228
+ if (game && !hive_bedrock_data_1.Games[game].statistics)
229
+ throw new Error(`Statistics are not available for the game: ${game}`);
230
+ const { data: response, error, meta } = await this._fetchAPI(`/game/map/${game}`);
231
+ if (error)
232
+ return { data: null, error, meta };
233
+ return { data: response, error: null, meta };
234
+ }
235
+ /**
236
+ * `/game/meta/{game}` Gets metadata about a game
237
+ * @param game The game to get the metadata for
238
+ * @returns The metadata for the game
239
+ */
240
+ async getGameMetadata(game) {
241
+ if (game && !hive_bedrock_data_1.Games[game].statistics)
242
+ throw new Error(`Statistics are not available for the game: ${game}`);
243
+ const { data: response, error, meta } = await this._fetchAPI(`/game/meta/${game}`);
244
+ if (error)
245
+ return { data: null, error, meta };
246
+ return { data: response, error: null, meta };
247
+ }
248
+ }
249
+ exports.default = HiveAPI;
250
+ //# sourceMappingURL=HiveAPI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HiveAPI.js","sourceRoot":"","sources":["../src/HiveAPI.ts"],"names":[],"mappings":";;;;;AAAA,yDAA8E;AAE9E,iEAAiF;AAIjF,+EAAgG;AAChG,4CAAuJ;AAUvJ,MAAqB,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,qCAAiB,CAAC;IACrF,CAAC;IAEO,KAAK,CAAC,SAAS,CAAgB,QAAgB;QACnD,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,GAAG,QAAQ,CAAC;QAEpD,IAAI,CAAC;YACD,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;YAChC,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;gBAC7B,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW;gBAC3B,OAAO,EAAE;oBACL,2BAA2B,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,oBA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./utils";
3
- import { ProcessedPlayerResponse } from "./processors/player";
4
- import { ProcessedGlobalStatisticsResponse } from "./processors/global_statistics";
5
- import { ProcessedMapResponse } from "./processors/map";
6
- import { ProcessedGameMetadata } from "./processors/meta";
7
- import { ProcessedPlayerSearchResponse } from "./processors/player_search";
8
- import { AvailableLeaderboardResponse, ProcessedAllGamesResponse, ProcessedGame, ProcessedMonthlyGamesResponse } from "./processors/game";
9
- interface Options {
10
- resolveDynamicTitles?: boolean;
11
- useModernLeaderboardSource?: boolean;
12
- apiBaseEndpoint?: string;
13
- requestInit?: RequestInit;
14
- }
1
+ import HiveAPI from "./HiveAPI";
15
2
  export * from "./processors/game";
16
3
  export * from "./processors/global_statistics";
17
4
  export * from "./processors/map";
18
5
  export * from "./processors/meta";
19
6
  export * from "./processors/player";
20
7
  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
- }
8
+ export { HiveAPI };
9
+ export default HiveAPI;
116
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,IAAI,EAAS,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAA0B,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EAAE,iCAAiC,EAAE,MAAM,gCAAgC,CAAC;AACnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAA4B,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAChG,OAAO,EAAe,4BAA4B,EAAE,yBAAyB,EAAE,aAAa,E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,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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAE3C,OAAO,EAAE,OAAO,EAAE,CAAC;AACnB,eAAe,OAAO,CAAC"}
package/lib/index.js CHANGED
@@ -17,254 +17,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- const hive_bedrock_data_1 = require("hive-bedrock-data");
21
- const player_1 = __importDefault(require("./processors/player"));
22
- const player_search_1 = __importDefault(require("./processors/player_search"));
23
- const game_1 = require("./processors/game");
20
+ exports.HiveAPI = void 0;
21
+ const HiveAPI_1 = __importDefault(require("./HiveAPI"));
22
+ exports.HiveAPI = HiveAPI_1.default;
24
23
  __exportStar(require("./processors/game"), exports);
25
24
  __exportStar(require("./processors/global_statistics"), exports);
26
25
  __exportStar(require("./processors/map"), exports);
27
26
  __exportStar(require("./processors/meta"), exports);
28
27
  __exportStar(require("./processors/player"), exports);
29
28
  __exportStar(require("./processors/player_search"), exports);
30
- class HiveAPI {
31
- options;
32
- constructor(options = {}) {
33
- this.options = options;
34
- this.options = options;
35
- this.options.apiBaseEndpoint = this.options.apiBaseEndpoint ?? hive_bedrock_data_1.API_BASE_ENDPOINT;
36
- }
37
- async _fetchAPI(endpoint) {
38
- const url = this.options.apiBaseEndpoint + endpoint;
39
- try {
40
- const start = performance.now();
41
- const request = await fetch(url, {
42
- ...this.options.requestInit,
43
- headers: {
44
- "X-Hive-Resolve-Stat-Track": (this.options.resolveDynamicTitles ?? true).toString(),
45
- "X-Hive-Leaderboard-Source": this.options.useModernLeaderboardSource ? "modern" : "legacy",
46
- ...this.options.requestInit?.headers,
47
- },
48
- });
49
- if (!request.ok)
50
- return { data: null, error: { status: request.status } };
51
- const meta = {
52
- duration: Math.ceil(performance.now() - start),
53
- ratelimit: {
54
- limit: Number(request.headers.get("X-Ratelimit-Limit")),
55
- remaining: Number(request.headers.get("X-Ratelimit-Remaining")),
56
- reset: Number(request.headers.get("X-Ratelimit-Reset")),
57
- },
58
- retryAfter: Number(request.headers.get("Retry-After")),
59
- };
60
- const response = await request.json();
61
- return { data: response, error: null, meta };
62
- }
63
- catch (err) {
64
- return { data: null, error: { status: 500, message: err.message } };
65
- }
66
- }
67
- /**
68
- * `/game/all/main/{identifier}` Gets information about a player
69
- * @param identifier Username or UUID of the player
70
- * @returns The player information
71
- */
72
- async getPlayer(identifier) {
73
- const { data: response, error, meta } = await this._fetchAPI(`/game/all/main/${identifier}`);
74
- if (error)
75
- return { data: null, error, meta };
76
- const data = (0, player_1.default)(response);
77
- if (!data)
78
- return { data: null, error: { status: 500, message: "Failed to process player data" }, meta };
79
- return { data, error: null, meta };
80
- }
81
- /**
82
- * `/player/search/{prefix}` Gets a list of players that match the prefix
83
- * @param prefix The prefix to search for (must be at least 4 characters long)
84
- * @returns A list of players that match the prefix
85
- */
86
- async getPlayerSearch(prefix) {
87
- const { data: response, error, meta } = await this._fetchAPI(`/player/search/${prefix}`);
88
- if (error)
89
- return { data: null, error, meta };
90
- const data = (0, player_search_1.default)(response);
91
- if (!data)
92
- return { data: null, error: { status: 500, message: "Failed to process player search data" }, meta };
93
- return { data, error: null, meta };
94
- }
95
- async getStatistics(identifier, timeframe, options) {
96
- if (timeframe === hive_bedrock_data_1.Timeframe.AllTime) {
97
- if (options?.game) {
98
- if (!hive_bedrock_data_1.Games[options.game].statistics)
99
- throw new Error(`Statistics are not available for the game: ${options.game}`);
100
- return this._getStatisticsAllTime(identifier, options.game);
101
- }
102
- return this._getStatisticsAllTime(identifier);
103
- }
104
- else if (timeframe === hive_bedrock_data_1.Timeframe.Seasonal) {
105
- if (!options?.game)
106
- throw new Error("Game must be specified for seasonal statistics");
107
- if (!hive_bedrock_data_1.Games[options.game].statistics)
108
- throw new Error(`Statistics are not available for the game: ${options.game}`);
109
- return this._getStatisticsSeasonal(identifier, options?.game, options?.season || 1);
110
- }
111
- if (options?.game)
112
- return this._getStatisticsMonthly(identifier, options.game, options.month, options.year);
113
- return this._getStatisticsMonthly(identifier, undefined, options?.month, options?.year);
114
- }
115
- async _getStatisticsAllTime(identifier, game) {
116
- const { data: response, error, meta } = await this._fetchAPI(`/game/all/${game ?? "all"}/${identifier}`);
117
- if (error)
118
- return { data: null, error, meta };
119
- if (game)
120
- return { data: (0, game_1.processGame)(game, hive_bedrock_data_1.Timeframe.AllTime, false, response), error: null, meta };
121
- let data = Object.fromEntries(Object.entries(response).map(([id, res]) => [id, id === "main" ? null : (0, game_1.processGame)(id, hive_bedrock_data_1.Timeframe.AllTime, false, res) ?? null]));
122
- delete data.main;
123
- return {
124
- data: {
125
- player: (0, player_1.default)(response),
126
- statistics: data,
127
- },
128
- error: null,
129
- meta,
130
- };
131
- }
132
- async _getStatisticsMonthly(identifier, game, month, year) {
133
- if (game && !hive_bedrock_data_1.Games[game].statistics)
134
- throw new Error(`Statistics are not available for the game: ${game}`);
135
- const { data: response, error, meta, } = await this._fetchAPI(`/game/monthly/player/${game ?? "all"}/${identifier}/${year ?? new Date().getFullYear()}/${month ?? new Date().getMonth() + 1}`);
136
- if (error)
137
- return { data: null, error, meta };
138
- if (game)
139
- return { data: (0, game_1.processGame)(game, hive_bedrock_data_1.Timeframe.Monthly, false, response), error: null, meta };
140
- let data = Object.fromEntries(Object.entries(response).map(([id, res]) => [id, id === "main" ? null : (0, game_1.processGame)(id, hive_bedrock_data_1.Timeframe.Monthly, false, res) ?? null]));
141
- delete data.main;
142
- return {
143
- data: {
144
- statistics: data,
145
- },
146
- error: null,
147
- meta,
148
- };
149
- }
150
- async _getStatisticsSeasonal(identifier, game, season) {
151
- if (!hive_bedrock_data_1.Games[game].statistics)
152
- throw new Error(`Statistics are not available for the game: ${game}`);
153
- const { data: response, error, meta } = await this._fetchAPI(`/game/season/player/${game}/${identifier}/${season ?? 1}`);
154
- if (error)
155
- return { data: null, error, meta };
156
- return { data: (0, game_1.processGame)(game, hive_bedrock_data_1.Timeframe.Seasonal, false, response), error: null, meta };
157
- }
158
- async getAvailableMonthlyLeaderboards(game) {
159
- const { data: response, error, meta } = await this._fetchAPI(`/game/monthly/${game}/available`);
160
- if (error)
161
- return { data: null, error, meta };
162
- return { data: response, error: null, meta };
163
- }
164
- /**
165
- * `/game/season/player/{game}/{player}/{season}` Gets seasonal statistics for a player
166
- * @param identifier Username or UUID of the player
167
- * @param game The game to get the statistics for
168
- * @param season The season to get the statistics for
169
- * @returns The player's seasonal statistics
170
- */
171
- async getSeasonalStatistics(identifier, game, season = 1) {
172
- if (game && !hive_bedrock_data_1.Games[game].statistics)
173
- throw new Error(`Statistics are not available for the game: ${game}`);
174
- const { data: response, error, meta } = await this._fetchAPI(`/game/season/player/${game}/${identifier}/${season}`);
175
- if (error)
176
- return { data: null, error, meta };
177
- let data = (0, game_1.processGame)(game, hive_bedrock_data_1.Timeframe.Monthly, true, response);
178
- return { data, error: null, meta };
179
- }
180
- async getLeaderboard(timeframe, game, options) {
181
- if (game && !hive_bedrock_data_1.Games[game].statistics)
182
- throw new Error(`Statistics are not available for the game: ${game}`);
183
- if (timeframe === hive_bedrock_data_1.Timeframe.Monthly)
184
- return this._getLeaderboardMonthly(game, options?.month || new Date().getMonth() + 1, options?.year || new Date().getFullYear());
185
- if (timeframe === hive_bedrock_data_1.Timeframe.Seasonal)
186
- return this._getLeaderboardSeasonal(game, options?.season || 1);
187
- return this._getLeaderboardAllTime(game);
188
- }
189
- // /game/all/{game}
190
- async _getLeaderboardAllTime(game) {
191
- const { data: response, error, meta } = await this._fetchAPI(`/game/all/${game}`);
192
- if (error)
193
- return { data: null, error, meta };
194
- let data = response.map((res) => (0, game_1.processGame)(game, hive_bedrock_data_1.Timeframe.AllTime, true, res));
195
- return { data, error: null, meta };
196
- }
197
- // /game/monthly/{game}/{year}/{month}
198
- async _getLeaderboardMonthly(game, month, year) {
199
- if (game && !hive_bedrock_data_1.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/monthly/${game}/${year}/${month}`);
202
- if (error)
203
- return { data: null, error, meta };
204
- let data = response.map((res) => (0, game_1.processGame)(game, hive_bedrock_data_1.Timeframe.Monthly, true, res));
205
- return { data, error: null, meta };
206
- }
207
- // /game/season/{game}/season
208
- async _getLeaderboardSeasonal(game, season = 1) {
209
- if (game && !hive_bedrock_data_1.Games[game].statistics)
210
- throw new Error(`Statistics are not available for the game: ${game}`);
211
- const { data: response, error, meta } = await this._fetchAPI(`/game/season/${game}/${season}`);
212
- if (error)
213
- return { data: null, error, meta };
214
- let data = response.map((res) => (0, game_1.processGame)(game, hive_bedrock_data_1.Timeframe.Seasonal, true, res));
215
- return { data, error: null, meta };
216
- }
217
- /**
218
- * `/game/season/{game}/{season}` Gets seasonal statistics for a game
219
- * @param game The game to get the statistics for
220
- * @param season The season to get the statistics for
221
- * @returns The seasonal statistics for the game
222
- */
223
- async getSeasonalLeaderboard(game, season = 1) {
224
- if (game && !hive_bedrock_data_1.Games[game].statistics)
225
- throw new Error(`Statistics are not available for the game: ${game}`);
226
- const { data: response, error, meta } = await this._fetchAPI(`/game/season/${game}/${season ?? 1}`);
227
- if (error)
228
- return { data: null, error, meta };
229
- let data = response.map((res) => (0, game_1.processGame)(game, hive_bedrock_data_1.Timeframe.Monthly, true, res));
230
- return { data, error: null, meta };
231
- }
232
- /**
233
- * `/global/statistics` Gets global statistics
234
- * @returns The global statistics
235
- */
236
- async getGlobalStatistics() {
237
- const { data: response, error, meta } = await this._fetchAPI("/global/statistics");
238
- if (error)
239
- return { data: null, error, meta };
240
- return { data: response, error: null, meta };
241
- }
242
- /**
243
- * `/game/map/{game}` Gets information about the maps in a game
244
- * @param game The game to get the maps for (fails for games without maps)
245
- * @returns A list of maps in the game
246
- */
247
- async getGameMaps(game) {
248
- if (game && !hive_bedrock_data_1.Games[game].statistics)
249
- throw new Error(`Statistics are not available for the game: ${game}`);
250
- const { data: response, error, meta } = await this._fetchAPI(`/game/map/${game}`);
251
- if (error)
252
- return { data: null, error, meta };
253
- return { data: response, error: null, meta };
254
- }
255
- /**
256
- * `/game/meta/{game}` Gets metadata about a game
257
- * @param game The game to get the metadata for
258
- * @returns The metadata for the game
259
- */
260
- async getGameMetadata(game) {
261
- if (game && !hive_bedrock_data_1.Games[game].statistics)
262
- throw new Error(`Statistics are not available for the game: ${game}`);
263
- const { data: response, error, meta } = await this._fetchAPI(`/game/meta/${game}`);
264
- if (error)
265
- return { data: null, error, meta };
266
- return { data: response, error: null, meta };
267
- }
268
- }
269
- exports.default = HiveAPI;
29
+ exports.default = HiveAPI_1.default;
270
30
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,yDAA8E;AAE9E,iEAAiF;AAIjF,+EAAgG;AAChG,4CAAuJ;AAUvJ,oDAAkC;AAClC,iEAA+C;AAC/C,mDAAiC;AACjC,oDAAkC;AAClC,sDAAoC;AACpC,6DAA2C;AAE3C,MAAqB,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,I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E,KAAK,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,SAAS,CAAM,cAAc,IAAI,EAAE,CAAC,CAAC;QACxF,IAAI,KAAK;YAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QAC9C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACjD,CAAC;CACJ;AA7UD,0BA6UC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,wDAAgC;AASvB,kBATF,iBAAO,CASE;AAPhB,oDAAkC;AAClC,iEAA+C;AAC/C,mDAAiC;AACjC,oDAAkC;AAClC,sDAAoC;AACpC,6DAA2C;AAG3C,kBAAe,iBAAO,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hive-bedrock-api",
3
- "version": "4.1.0",
3
+ "version": "4.1.1",
4
4
  "description": "An API wrapper for the Hive Minecraft Bedrock Edition server.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -23,5 +23,5 @@
23
23
  "ts-node": "^10.9.1",
24
24
  "typescript": "^5.1.3"
25
25
  },
26
- "gitHead": "c2b2685b84eb4b55d40472ed70977a816107d561"
26
+ "gitHead": "fdbff37dc306910d6ed9282a37d99d9236b4da10"
27
27
  }