hive-bedrock-api 4.0.1 → 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.
package/lib/index.js CHANGED
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
3
  if (k2 === undefined) k2 = k;
15
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -24,472 +13,18 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
24
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
25
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
26
15
  };
27
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
28
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
29
- return new (P || (P = Promise))(function (resolve, reject) {
30
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
31
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
32
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
33
- step((generator = generator.apply(thisArg, _arguments || [])).next());
34
- });
35
- };
36
- var __generator = (this && this.__generator) || function (thisArg, body) {
37
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
38
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
39
- function verb(n) { return function (v) { return step([n, v]); }; }
40
- function step(op) {
41
- if (f) throw new TypeError("Generator is already executing.");
42
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
43
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
44
- if (y = 0, t) op = [op[0] & 2, t.value];
45
- switch (op[0]) {
46
- case 0: case 1: t = op; break;
47
- case 4: _.label++; return { value: op[1], done: false };
48
- case 5: _.label++; y = op[1]; op = [0]; continue;
49
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
50
- default:
51
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
52
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
53
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
54
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
55
- if (t[2]) _.ops.pop();
56
- _.trys.pop(); continue;
57
- }
58
- op = body.call(thisArg, _);
59
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
60
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
61
- }
62
- };
63
- var __read = (this && this.__read) || function (o, n) {
64
- var m = typeof Symbol === "function" && o[Symbol.iterator];
65
- if (!m) return o;
66
- var i = m.call(o), r, ar = [], e;
67
- try {
68
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
69
- }
70
- catch (error) { e = { error: error }; }
71
- finally {
72
- try {
73
- if (r && !r.done && (m = i["return"])) m.call(i);
74
- }
75
- finally { if (e) throw e.error; }
76
- }
77
- return ar;
78
- };
79
16
  var __importDefault = (this && this.__importDefault) || function (mod) {
80
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
81
18
  };
82
19
  Object.defineProperty(exports, "__esModule", { value: true });
83
- var hive_bedrock_data_1 = require("hive-bedrock-data");
84
- var player_1 = __importDefault(require("./processors/player"));
85
- var player_search_1 = __importDefault(require("./processors/player_search"));
86
- var game_1 = require("./processors/game");
20
+ exports.HiveAPI = void 0;
21
+ const HiveAPI_1 = __importDefault(require("./HiveAPI"));
22
+ exports.HiveAPI = HiveAPI_1.default;
87
23
  __exportStar(require("./processors/game"), exports);
88
24
  __exportStar(require("./processors/global_statistics"), exports);
89
25
  __exportStar(require("./processors/map"), exports);
90
26
  __exportStar(require("./processors/meta"), exports);
91
27
  __exportStar(require("./processors/player"), exports);
92
28
  __exportStar(require("./processors/player_search"), exports);
93
- var HiveAPI = /** @class */ (function () {
94
- function HiveAPI(options) {
95
- if (options === void 0) { options = {}; }
96
- var _a;
97
- this.options = options;
98
- this.options = options;
99
- this.options.apiBaseEndpoint = (_a = this.options.apiBaseEndpoint) !== null && _a !== void 0 ? _a : hive_bedrock_data_1.API_BASE_ENDPOINT;
100
- }
101
- HiveAPI.prototype._fetchAPI = function (endpoint) {
102
- return __awaiter(this, void 0, void 0, function () {
103
- var url, start, request, meta, response, err_1;
104
- var _a, _b;
105
- return __generator(this, function (_c) {
106
- switch (_c.label) {
107
- case 0:
108
- url = this.options.apiBaseEndpoint + endpoint;
109
- _c.label = 1;
110
- case 1:
111
- _c.trys.push([1, 4, , 5]);
112
- start = performance.now();
113
- return [4 /*yield*/, fetch(url, __assign(__assign({}, this.options.requestInit), { headers: __assign({ "X-Hive-Resolve-Stat-Track": ((_a = this.options.resolveDynamicTitles) !== null && _a !== void 0 ? _a : true).toString(), "X-Hive-Leaderboard-Source": this.options.useModernLeaderboardSource ? "modern" : "legacy" }, (_b = this.options.requestInit) === null || _b === void 0 ? void 0 : _b.headers) }))];
114
- case 2:
115
- request = _c.sent();
116
- if (!request.ok)
117
- return [2 /*return*/, { data: null, error: { status: request.status } }];
118
- meta = {
119
- duration: Math.ceil(performance.now() - start),
120
- ratelimit: {
121
- limit: Number(request.headers.get("X-Ratelimit-Limit")),
122
- remaining: Number(request.headers.get("X-Ratelimit-Remaining")),
123
- reset: Number(request.headers.get("X-Ratelimit-Reset")),
124
- },
125
- retryAfter: Number(request.headers.get("Retry-After")),
126
- };
127
- return [4 /*yield*/, request.json()];
128
- case 3:
129
- response = _c.sent();
130
- return [2 /*return*/, { data: response, error: null, meta: meta }];
131
- case 4:
132
- err_1 = _c.sent();
133
- return [2 /*return*/, { data: null, error: { status: 500, message: err_1.message } }];
134
- case 5: return [2 /*return*/];
135
- }
136
- });
137
- });
138
- };
139
- /**
140
- * `/game/all/main/{identifier}` Gets information about a player
141
- * @param identifier Username or UUID of the player
142
- * @returns The player information
143
- */
144
- HiveAPI.prototype.getPlayer = function (identifier) {
145
- return __awaiter(this, void 0, void 0, function () {
146
- var _a, response, error, meta, data;
147
- return __generator(this, function (_b) {
148
- switch (_b.label) {
149
- case 0: return [4 /*yield*/, this._fetchAPI("/game/all/main/".concat(identifier))];
150
- case 1:
151
- _a = _b.sent(), response = _a.data, error = _a.error, meta = _a.meta;
152
- if (error)
153
- return [2 /*return*/, { data: null, error: error, meta: meta }];
154
- data = (0, player_1.default)(response);
155
- if (!data)
156
- return [2 /*return*/, { data: null, error: { status: 500, message: "Failed to process player data" }, meta: meta }];
157
- return [2 /*return*/, { data: data, error: null, meta: meta }];
158
- }
159
- });
160
- });
161
- };
162
- /**
163
- * `/player/search/{prefix}` Gets a list of players that match the prefix
164
- * @param prefix The prefix to search for (must be at least 4 characters long)
165
- * @returns A list of players that match the prefix
166
- */
167
- HiveAPI.prototype.getPlayerSearch = function (prefix) {
168
- return __awaiter(this, void 0, void 0, function () {
169
- var _a, response, error, meta, data;
170
- return __generator(this, function (_b) {
171
- switch (_b.label) {
172
- case 0: return [4 /*yield*/, this._fetchAPI("/player/search/".concat(prefix))];
173
- case 1:
174
- _a = _b.sent(), response = _a.data, error = _a.error, meta = _a.meta;
175
- if (error)
176
- return [2 /*return*/, { data: null, error: error, meta: meta }];
177
- data = (0, player_search_1.default)(response);
178
- if (!data)
179
- return [2 /*return*/, { data: null, error: { status: 500, message: "Failed to process player search data" }, meta: meta }];
180
- return [2 /*return*/, { data: data, error: null, meta: meta }];
181
- }
182
- });
183
- });
184
- };
185
- HiveAPI.prototype.getStatistics = function (identifier, timeframe, options) {
186
- return __awaiter(this, void 0, void 0, function () {
187
- return __generator(this, function (_a) {
188
- if (timeframe === hive_bedrock_data_1.Timeframe.AllTime) {
189
- if (options === null || options === void 0 ? void 0 : options.game) {
190
- if (!hive_bedrock_data_1.Games[options.game].statistics)
191
- throw new Error("Statistics are not available for the game: ".concat(options.game));
192
- return [2 /*return*/, this._getStatisticsAllTime(identifier, options.game)];
193
- }
194
- return [2 /*return*/, this._getStatisticsAllTime(identifier)];
195
- }
196
- else if (timeframe === hive_bedrock_data_1.Timeframe.Seasonal) {
197
- if (!(options === null || options === void 0 ? void 0 : options.game))
198
- throw new Error("Game must be specified for seasonal statistics");
199
- if (!hive_bedrock_data_1.Games[options.game].statistics)
200
- throw new Error("Statistics are not available for the game: ".concat(options.game));
201
- return [2 /*return*/, this._getStatisticsSeasonal(identifier, options === null || options === void 0 ? void 0 : options.game, (options === null || options === void 0 ? void 0 : options.season) || 1)];
202
- }
203
- if (options === null || options === void 0 ? void 0 : options.game)
204
- return [2 /*return*/, this._getStatisticsMonthly(identifier, options.game, options.month, options.year)];
205
- return [2 /*return*/, this._getStatisticsMonthly(identifier, undefined, options === null || options === void 0 ? void 0 : options.month, options === null || options === void 0 ? void 0 : options.year)];
206
- });
207
- });
208
- };
209
- HiveAPI.prototype._getStatisticsAllTime = function (identifier, game) {
210
- return __awaiter(this, void 0, void 0, function () {
211
- var _a, response, error, meta, data;
212
- return __generator(this, function (_b) {
213
- switch (_b.label) {
214
- case 0: return [4 /*yield*/, this._fetchAPI("/game/all/".concat(game !== null && game !== void 0 ? game : "all", "/").concat(identifier))];
215
- case 1:
216
- _a = _b.sent(), response = _a.data, error = _a.error, meta = _a.meta;
217
- if (error)
218
- return [2 /*return*/, { data: null, error: error, meta: meta }];
219
- if (game)
220
- return [2 /*return*/, { data: (0, game_1.processGame)(game, hive_bedrock_data_1.Timeframe.AllTime, false, response), error: null, meta: meta }];
221
- data = Object.fromEntries(Object.entries(response).map(function (_a) {
222
- var _b;
223
- var _c = __read(_a, 2), id = _c[0], res = _c[1];
224
- return [id, id === "main" ? null : (_b = (0, game_1.processGame)(id, hive_bedrock_data_1.Timeframe.AllTime, false, res)) !== null && _b !== void 0 ? _b : null];
225
- }));
226
- delete data.main;
227
- return [2 /*return*/, {
228
- data: {
229
- player: (0, player_1.default)(response),
230
- statistics: data,
231
- },
232
- error: null,
233
- meta: meta,
234
- }];
235
- }
236
- });
237
- });
238
- };
239
- HiveAPI.prototype._getStatisticsMonthly = function (identifier, game, month, year) {
240
- return __awaiter(this, void 0, void 0, function () {
241
- var _a, response, error, meta, data;
242
- return __generator(this, function (_b) {
243
- switch (_b.label) {
244
- case 0:
245
- if (game && !hive_bedrock_data_1.Games[game].statistics)
246
- throw new Error("Statistics are not available for the game: ".concat(game));
247
- return [4 /*yield*/, this._fetchAPI("/game/monthly/player/".concat(game !== null && game !== void 0 ? game : "all", "/").concat(identifier, "/").concat(year !== null && year !== void 0 ? year : new Date().getFullYear(), "/").concat(month !== null && month !== void 0 ? month : new Date().getMonth() + 1))];
248
- case 1:
249
- _a = _b.sent(), response = _a.data, error = _a.error, meta = _a.meta;
250
- if (error)
251
- return [2 /*return*/, { data: null, error: error, meta: meta }];
252
- if (game)
253
- return [2 /*return*/, { data: (0, game_1.processGame)(game, hive_bedrock_data_1.Timeframe.Monthly, false, response), error: null, meta: meta }];
254
- data = Object.fromEntries(Object.entries(response).map(function (_a) {
255
- var _b;
256
- var _c = __read(_a, 2), id = _c[0], res = _c[1];
257
- return [id, id === "main" ? null : (_b = (0, game_1.processGame)(id, hive_bedrock_data_1.Timeframe.Monthly, false, res)) !== null && _b !== void 0 ? _b : null];
258
- }));
259
- delete data.main;
260
- return [2 /*return*/, {
261
- data: {
262
- statistics: data,
263
- },
264
- error: null,
265
- meta: meta,
266
- }];
267
- }
268
- });
269
- });
270
- };
271
- HiveAPI.prototype._getStatisticsSeasonal = function (identifier, game, season) {
272
- return __awaiter(this, void 0, void 0, function () {
273
- var _a, response, error, meta;
274
- return __generator(this, function (_b) {
275
- switch (_b.label) {
276
- case 0:
277
- if (!hive_bedrock_data_1.Games[game].statistics)
278
- throw new Error("Statistics are not available for the game: ".concat(game));
279
- return [4 /*yield*/, this._fetchAPI("/game/season/player/".concat(game, "/").concat(identifier, "/").concat(season !== null && season !== void 0 ? season : 1))];
280
- case 1:
281
- _a = _b.sent(), response = _a.data, error = _a.error, meta = _a.meta;
282
- if (error)
283
- return [2 /*return*/, { data: null, error: error, meta: meta }];
284
- return [2 /*return*/, { data: (0, game_1.processGame)(game, hive_bedrock_data_1.Timeframe.Seasonal, false, response), error: null, meta: meta }];
285
- }
286
- });
287
- });
288
- };
289
- HiveAPI.prototype.getAvailableMonthlyLeaderboards = function (game) {
290
- return __awaiter(this, void 0, void 0, function () {
291
- var _a, response, error, meta;
292
- return __generator(this, function (_b) {
293
- switch (_b.label) {
294
- case 0: return [4 /*yield*/, this._fetchAPI("/game/monthly/".concat(game, "/available"))];
295
- case 1:
296
- _a = _b.sent(), response = _a.data, error = _a.error, meta = _a.meta;
297
- if (error)
298
- return [2 /*return*/, { data: null, error: error, meta: meta }];
299
- return [2 /*return*/, { data: response, error: null, meta: meta }];
300
- }
301
- });
302
- });
303
- };
304
- /**
305
- * `/game/season/player/{game}/{player}/{season}` Gets seasonal statistics for a player
306
- * @param identifier Username or UUID of the player
307
- * @param game The game to get the statistics for
308
- * @param season The season to get the statistics for
309
- * @returns The player's seasonal statistics
310
- */
311
- HiveAPI.prototype.getSeasonalStatistics = function (identifier_1, game_2) {
312
- return __awaiter(this, arguments, void 0, function (identifier, game, season) {
313
- var _a, response, error, meta, data;
314
- if (season === void 0) { season = 1; }
315
- return __generator(this, function (_b) {
316
- switch (_b.label) {
317
- case 0:
318
- if (game && !hive_bedrock_data_1.Games[game].statistics)
319
- throw new Error("Statistics are not available for the game: ".concat(game));
320
- return [4 /*yield*/, this._fetchAPI("/game/season/player/".concat(game, "/").concat(identifier, "/").concat(season))];
321
- case 1:
322
- _a = _b.sent(), response = _a.data, error = _a.error, meta = _a.meta;
323
- if (error)
324
- return [2 /*return*/, { data: null, error: error, meta: meta }];
325
- data = (0, game_1.processGame)(game, hive_bedrock_data_1.Timeframe.Monthly, true, response);
326
- return [2 /*return*/, { data: data, error: null, meta: meta }];
327
- }
328
- });
329
- });
330
- };
331
- HiveAPI.prototype.getLeaderboard = function (timeframe, game, options) {
332
- return __awaiter(this, void 0, void 0, function () {
333
- return __generator(this, function (_a) {
334
- if (game && !hive_bedrock_data_1.Games[game].statistics)
335
- throw new Error("Statistics are not available for the game: ".concat(game));
336
- if (timeframe === hive_bedrock_data_1.Timeframe.Monthly)
337
- return [2 /*return*/, this._getLeaderboardMonthly(game, (options === null || options === void 0 ? void 0 : options.month) || new Date().getMonth() + 1, (options === null || options === void 0 ? void 0 : options.year) || new Date().getFullYear())];
338
- if (timeframe === hive_bedrock_data_1.Timeframe.Seasonal)
339
- return [2 /*return*/, this._getLeaderboardSeasonal(game, (options === null || options === void 0 ? void 0 : options.season) || 1)];
340
- return [2 /*return*/, this._getLeaderboardAllTime(game)];
341
- });
342
- });
343
- };
344
- // /game/all/{game}
345
- HiveAPI.prototype._getLeaderboardAllTime = function (game) {
346
- return __awaiter(this, void 0, void 0, function () {
347
- var _a, response, error, meta, data;
348
- return __generator(this, function (_b) {
349
- switch (_b.label) {
350
- case 0: return [4 /*yield*/, this._fetchAPI("/game/all/".concat(game))];
351
- case 1:
352
- _a = _b.sent(), response = _a.data, error = _a.error, meta = _a.meta;
353
- if (error)
354
- return [2 /*return*/, { data: null, error: error, meta: meta }];
355
- data = response.map(function (res) { return (0, game_1.processGame)(game, hive_bedrock_data_1.Timeframe.AllTime, true, res); });
356
- return [2 /*return*/, { data: data, error: null, meta: meta }];
357
- }
358
- });
359
- });
360
- };
361
- // /game/monthly/{game}/{year}/{month}
362
- HiveAPI.prototype._getLeaderboardMonthly = function (game, month, year) {
363
- return __awaiter(this, void 0, void 0, function () {
364
- var _a, response, error, meta, data;
365
- return __generator(this, function (_b) {
366
- switch (_b.label) {
367
- case 0:
368
- if (game && !hive_bedrock_data_1.Games[game].statistics)
369
- throw new Error("Statistics are not available for the game: ".concat(game));
370
- return [4 /*yield*/, this._fetchAPI("/game/monthly/".concat(game, "/").concat(year, "/").concat(month))];
371
- case 1:
372
- _a = _b.sent(), response = _a.data, error = _a.error, meta = _a.meta;
373
- if (error)
374
- return [2 /*return*/, { data: null, error: error, meta: meta }];
375
- data = response.map(function (res) { return (0, game_1.processGame)(game, hive_bedrock_data_1.Timeframe.Monthly, true, res); });
376
- return [2 /*return*/, { data: data, error: null, meta: meta }];
377
- }
378
- });
379
- });
380
- };
381
- // /game/season/{game}/season
382
- HiveAPI.prototype._getLeaderboardSeasonal = function (game_2) {
383
- return __awaiter(this, arguments, void 0, function (game, season) {
384
- var _a, response, error, meta, data;
385
- if (season === void 0) { season = 1; }
386
- return __generator(this, function (_b) {
387
- switch (_b.label) {
388
- case 0:
389
- if (game && !hive_bedrock_data_1.Games[game].statistics)
390
- throw new Error("Statistics are not available for the game: ".concat(game));
391
- return [4 /*yield*/, this._fetchAPI("/game/season/".concat(game, "/").concat(season))];
392
- case 1:
393
- _a = _b.sent(), response = _a.data, error = _a.error, meta = _a.meta;
394
- if (error)
395
- return [2 /*return*/, { data: null, error: error, meta: meta }];
396
- data = response.map(function (res) { return (0, game_1.processGame)(game, hive_bedrock_data_1.Timeframe.Seasonal, true, res); });
397
- return [2 /*return*/, { data: data, error: null, meta: meta }];
398
- }
399
- });
400
- });
401
- };
402
- /**
403
- * `/game/season/{game}/{season}` Gets seasonal statistics for a game
404
- * @param game The game to get the statistics for
405
- * @param season The season to get the statistics for
406
- * @returns The seasonal statistics for the game
407
- */
408
- HiveAPI.prototype.getSeasonalLeaderboard = function (game_2) {
409
- return __awaiter(this, arguments, void 0, function (game, season) {
410
- var _a, response, error, meta, data;
411
- if (season === void 0) { season = 1; }
412
- return __generator(this, function (_b) {
413
- switch (_b.label) {
414
- case 0:
415
- if (game && !hive_bedrock_data_1.Games[game].statistics)
416
- throw new Error("Statistics are not available for the game: ".concat(game));
417
- return [4 /*yield*/, this._fetchAPI("/game/season/".concat(game, "/").concat(season !== null && season !== void 0 ? season : 1))];
418
- case 1:
419
- _a = _b.sent(), response = _a.data, error = _a.error, meta = _a.meta;
420
- if (error)
421
- return [2 /*return*/, { data: null, error: error, meta: meta }];
422
- data = response.map(function (res) { return (0, game_1.processGame)(game, hive_bedrock_data_1.Timeframe.Monthly, true, res); });
423
- return [2 /*return*/, { data: data, error: null, meta: meta }];
424
- }
425
- });
426
- });
427
- };
428
- /**
429
- * `/global/statistics` Gets global statistics
430
- * @returns The global statistics
431
- */
432
- HiveAPI.prototype.getGlobalStatistics = function () {
433
- return __awaiter(this, void 0, void 0, function () {
434
- var _a, response, error, meta;
435
- return __generator(this, function (_b) {
436
- switch (_b.label) {
437
- case 0: return [4 /*yield*/, this._fetchAPI("/global/statistics")];
438
- case 1:
439
- _a = _b.sent(), response = _a.data, error = _a.error, meta = _a.meta;
440
- if (error)
441
- return [2 /*return*/, { data: null, error: error, meta: meta }];
442
- return [2 /*return*/, { data: response, error: null, meta: meta }];
443
- }
444
- });
445
- });
446
- };
447
- /**
448
- * `/game/map/{game}` Gets information about the maps in a game
449
- * @param game The game to get the maps for (fails for games without maps)
450
- * @returns A list of maps in the game
451
- */
452
- HiveAPI.prototype.getGameMaps = function (game) {
453
- return __awaiter(this, void 0, void 0, function () {
454
- var _a, response, error, meta;
455
- return __generator(this, function (_b) {
456
- switch (_b.label) {
457
- case 0:
458
- if (game && !hive_bedrock_data_1.Games[game].statistics)
459
- throw new Error("Statistics are not available for the game: ".concat(game));
460
- return [4 /*yield*/, this._fetchAPI("/game/map/".concat(game))];
461
- case 1:
462
- _a = _b.sent(), response = _a.data, error = _a.error, meta = _a.meta;
463
- if (error)
464
- return [2 /*return*/, { data: null, error: error, meta: meta }];
465
- return [2 /*return*/, { data: response, error: null, meta: meta }];
466
- }
467
- });
468
- });
469
- };
470
- /**
471
- * `/game/meta/{game}` Gets metadata about a game
472
- * @param game The game to get the metadata for
473
- * @returns The metadata for the game
474
- */
475
- HiveAPI.prototype.getGameMetadata = function (game) {
476
- return __awaiter(this, void 0, void 0, function () {
477
- var _a, response, error, meta;
478
- return __generator(this, function (_b) {
479
- switch (_b.label) {
480
- case 0:
481
- if (game && !hive_bedrock_data_1.Games[game].statistics)
482
- throw new Error("Statistics are not available for the game: ".concat(game));
483
- return [4 /*yield*/, this._fetchAPI("/game/meta/".concat(game))];
484
- case 1:
485
- _a = _b.sent(), response = _a.data, error = _a.error, meta = _a.meta;
486
- if (error)
487
- return [2 /*return*/, { data: null, error: error, meta: meta }];
488
- return [2 /*return*/, { data: response, error: null, meta: meta }];
489
- }
490
- });
491
- });
492
- };
493
- return HiveAPI;
494
- }());
495
- exports.default = HiveAPI;
29
+ exports.default = HiveAPI_1.default;
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
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"}
@@ -291,3 +291,4 @@ export interface AvailableLeaderboard {
291
291
  resource: string;
292
292
  }
293
293
  export type AvailableLeaderboardResponse = AvailableLeaderboard[];
294
+ //# sourceMappingURL=game.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"game.d.ts","sourceRoot":"","sources":["../../src/processors/game.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,IAAI,EAAE,SA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