hive-bedrock-api 3.0.0-alpha.1 → 3.0.0-alpha.10
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.d.ts +5 -1
- package/lib/processors/game.d.ts +8 -8
- package/lib/processors/game.js +53 -49
- package/package.json +2 -2
- package/lib/helpers/fetchEndpoint.d.ts +0 -3
- package/lib/helpers/fetchEndpoint.js +0 -88
- package/lib/helpers/isGame.d.ts +0 -2
- package/lib/helpers/isGame.js +0 -7
- package/lib/helpers/toPoint.d.ts +0 -1
- package/lib/helpers/toPoint.js +0 -10
- package/lib/methods/getAllTimeLeaderboard.d.ts +0 -4
- package/lib/methods/getAllTimeLeaderboard.js +0 -85
- package/lib/methods/getAllTimeStatistics.d.ts +0 -10
- package/lib/methods/getAllTimeStatistics.js +0 -126
- package/lib/methods/getGlobalStatistics.d.ts +0 -3
- package/lib/methods/getGlobalStatistics.js +0 -56
- package/lib/methods/getMaps.d.ts +0 -3
- package/lib/methods/getMaps.js +0 -81
- package/lib/methods/getMetadata.d.ts +0 -3
- package/lib/methods/getMetadata.js +0 -81
- package/lib/methods/getMonthlyLeaderboard.d.ts +0 -11
- package/lib/methods/getMonthlyLeaderboard.js +0 -88
- package/lib/methods/getMonthlyStatistics.d.ts +0 -10
- package/lib/methods/getMonthlyStatistics.js +0 -132
- package/lib/methods/getPlayerInfomation.d.ts +0 -3
- package/lib/methods/getPlayerInfomation.js +0 -72
- package/lib/methods/getSeasonLeaderboard.d.ts +0 -10
- package/lib/methods/getSeasonLeaderboard.js +0 -87
- package/lib/methods/getSeasonStatistics.d.ts +0 -10
- package/lib/methods/getSeasonStatistics.js +0 -87
- package/lib/processors/bed.d.ts +0 -19
- package/lib/processors/bed.js +0 -35
- package/lib/processors/bridge.d.ts +0 -24
- package/lib/processors/bridge.js +0 -40
- package/lib/processors/build.d.ts +0 -19
- package/lib/processors/build.js +0 -35
- package/lib/processors/ctf.d.ts +0 -19
- package/lib/processors/ctf.js +0 -35
- package/lib/processors/dr.d.ts +0 -19
- package/lib/processors/dr.js +0 -35
- package/lib/processors/drop.d.ts +0 -17
- package/lib/processors/drop.js +0 -34
- package/lib/processors/grav.d.ts +0 -17
- package/lib/processors/grav.js +0 -34
- package/lib/processors/ground.d.ts +0 -19
- package/lib/processors/ground.js +0 -35
- package/lib/processors/helpers/processBuildRatings.d.ts +0 -8
- package/lib/processors/helpers/processBuildRatings.js +0 -23
- package/lib/processors/helpers/processGameAndXP.d.ts +0 -6
- package/lib/processors/helpers/processGameAndXP.js +0 -10
- package/lib/processors/helpers/processHiderKillsAndDeaths.d.ts +0 -5
- package/lib/processors/helpers/processHiderKillsAndDeaths.js +0 -13
- package/lib/processors/helpers/processKillsAndDeaths.d.ts +0 -5
- package/lib/processors/helpers/processKillsAndDeaths.js +0 -13
- package/lib/processors/helpers/processMurdersAndDeaths.d.ts +0 -5
- package/lib/processors/helpers/processMurdersAndDeaths.js +0 -13
- package/lib/processors/helpers/processPlayedAndVictories.d.ts +0 -6
- package/lib/processors/helpers/processPlayedAndVictories.js +0 -12
- package/lib/processors/hide.d.ts +0 -19
- package/lib/processors/hide.js +0 -35
- package/lib/processors/index.d.ts +0 -12
- package/lib/processors/index.js +0 -73
- package/lib/processors/murder.d.ts +0 -19
- package/lib/processors/murder.js +0 -35
- package/lib/processors/parkour.d.ts +0 -5
- package/lib/processors/parkour.js +0 -99
- package/lib/processors/party.d.ts +0 -17
- package/lib/processors/party.js +0 -34
- package/lib/processors/sg.d.ts +0 -19
- package/lib/processors/sg.js +0 -35
- package/lib/processors/sky.d.ts +0 -19
- package/lib/processors/sky.js +0 -35
- package/lib/processors/wars.d.ts +0 -19
- package/lib/processors/wars.js +0 -35
- package/lib/types/output.d.ts +0 -62
- package/lib/types/output.js +0 -3
- package/lib/types/types.d.ts +0 -24
- package/lib/types/types.js +0 -2
package/lib/index.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ export default class HiveAPI {
|
|
|
46
46
|
game: G;
|
|
47
47
|
month?: number;
|
|
48
48
|
year?: number;
|
|
49
|
-
}): Promise<MethodResponse<ProcessedGame<Timeframe.
|
|
49
|
+
}): Promise<MethodResponse<ProcessedGame<Timeframe.Monthly, false>[G]>>;
|
|
50
50
|
private _getStatisticsAllTime;
|
|
51
51
|
private _getStatisticsMonthly;
|
|
52
52
|
/**
|
|
@@ -65,6 +65,10 @@ export default class HiveAPI {
|
|
|
65
65
|
*/
|
|
66
66
|
getLeaderboard<G extends Game>(timeframe: Timeframe.AllTime, game: G): Promise<MethodResponse<ProcessedGame<Timeframe.AllTime, true>[G][] | null>>;
|
|
67
67
|
getLeaderboard<G extends Game>(timeframe: Timeframe.Monthly, game: G): Promise<MethodResponse<ProcessedGame<Timeframe.Monthly, true>[G][] | null>>;
|
|
68
|
+
getLeaderboard<G extends Game>(timeframe: Timeframe.Monthly, game: G, options: {
|
|
69
|
+
month?: number;
|
|
70
|
+
year?: number;
|
|
71
|
+
}): Promise<MethodResponse<ProcessedGame<Timeframe.Monthly, true>[G][] | null>>;
|
|
68
72
|
private _getLeaderboardAllTime;
|
|
69
73
|
private _getLeaderboardMonthly;
|
|
70
74
|
/**
|
package/lib/processors/game.d.ts
CHANGED
|
@@ -128,7 +128,7 @@ export interface ProcessedGameMURDER {
|
|
|
128
128
|
prestige: number;
|
|
129
129
|
}
|
|
130
130
|
export interface ProcessedGameSKY {
|
|
131
|
-
id: Game.
|
|
131
|
+
id: Game.SkyWars;
|
|
132
132
|
xp: number;
|
|
133
133
|
played: number;
|
|
134
134
|
victories: number;
|
|
@@ -142,7 +142,7 @@ export interface ProcessedGameSKY {
|
|
|
142
142
|
spells_used: number;
|
|
143
143
|
}
|
|
144
144
|
export interface ProcessedGameSKYKITS {
|
|
145
|
-
id: Game.
|
|
145
|
+
id: Game.SkyWarsKits;
|
|
146
146
|
xp: number;
|
|
147
147
|
played: number;
|
|
148
148
|
victories: number;
|
|
@@ -157,7 +157,7 @@ export interface ProcessedGameSKYKITS {
|
|
|
157
157
|
selected_kit: string;
|
|
158
158
|
}
|
|
159
159
|
export interface ProcessedGameSKYCLASSIC {
|
|
160
|
-
id: Game.
|
|
160
|
+
id: Game.SkyWarsClassic;
|
|
161
161
|
xp: number;
|
|
162
162
|
played: number;
|
|
163
163
|
victories: number;
|
|
@@ -257,13 +257,13 @@ export interface ProcessedGame<T extends Timeframe, L extends boolean> {
|
|
|
257
257
|
[Game.JustBuild]: ProcessedGameBUILD & AdditionalStatistics<T, L>;
|
|
258
258
|
[Game.HideAndSeek]: ProcessedGameHIDE & AdditionalStatistics<T, L>;
|
|
259
259
|
[Game.MurderMystery]: ProcessedGameMURDER & AdditionalStatistics<T, L>;
|
|
260
|
-
[Game.
|
|
261
|
-
[Game.
|
|
262
|
-
[Game.
|
|
260
|
+
[Game.SkyWars]: ProcessedGameSKY & AdditionalStatistics<T, L>;
|
|
261
|
+
[Game.SkyWarsClassic]: ProcessedGameSKYCLASSIC & AdditionalStatistics<T, L>;
|
|
262
|
+
[Game.SkyWarsKits]: ProcessedGameSKYKITS & AdditionalStatistics<T, L>;
|
|
263
263
|
[Game.SurvivalGames]: ProcessedGameSG & AdditionalStatistics<T, L>;
|
|
264
264
|
[Game.TheBridge]: ProcessedGameBRIDGE & AdditionalStatistics<T, L>;
|
|
265
265
|
[Game.TreasureWars]: ProcessedGameWARS & AdditionalStatistics<T, L>;
|
|
266
|
-
[Game.ParkourWorlds]: ProcessedGamePARKOUR;
|
|
266
|
+
[Game.ParkourWorlds]: L extends true ? never : T extends Timeframe.Monthly ? never : ProcessedGamePARKOUR;
|
|
267
267
|
}
|
|
268
268
|
export default function processGame<G extends Game, T extends Timeframe, L extends boolean>(game: G, timeframe: T, isLeaderboard: L, response: any): ProcessedGame<T, L>[G] | null;
|
|
269
269
|
export declare const processors: {
|
|
@@ -283,7 +283,7 @@ export declare const processors: {
|
|
|
283
283
|
sg: (response: any) => ProcessedGameSG;
|
|
284
284
|
bridge: (response: any) => ProcessedGameBRIDGE;
|
|
285
285
|
wars: (response: any) => ProcessedGameWARS;
|
|
286
|
-
parkour: (response: any) => ProcessedGamePARKOUR;
|
|
286
|
+
parkour: (response: any) => ProcessedGamePARKOUR | null;
|
|
287
287
|
};
|
|
288
288
|
export declare function validateNumber(value: number, def?: number): number;
|
|
289
289
|
export declare function calculateKDR(kills: number, deaths: number): number;
|
package/lib/processors/game.js
CHANGED
|
@@ -35,6 +35,8 @@ function processGame(game, timeframe, isLeaderboard, response) {
|
|
|
35
35
|
if (Array.isArray(response))
|
|
36
36
|
return null;
|
|
37
37
|
var data = exports.processors[game](response);
|
|
38
|
+
if (!data)
|
|
39
|
+
return null;
|
|
38
40
|
if ("played" in data && data.played === 0)
|
|
39
41
|
return null;
|
|
40
42
|
if (timeframe === hive_bedrock_data_1.Timeframe.AllTime && "xp" in data)
|
|
@@ -213,10 +215,10 @@ exports.processors = (_a = {},
|
|
|
213
215
|
prestige: (_h = response.prestige) !== null && _h !== void 0 ? _h : 0,
|
|
214
216
|
});
|
|
215
217
|
},
|
|
216
|
-
_a[hive_bedrock_data_1.Game.
|
|
218
|
+
_a[hive_bedrock_data_1.Game.SkyWars] = function (response) {
|
|
217
219
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
218
220
|
return ({
|
|
219
|
-
id: hive_bedrock_data_1.Game.
|
|
221
|
+
id: hive_bedrock_data_1.Game.SkyWars,
|
|
220
222
|
xp: (_a = response.xp) !== null && _a !== void 0 ? _a : 0,
|
|
221
223
|
played: (_b = response.played) !== null && _b !== void 0 ? _b : 0,
|
|
222
224
|
victories: (_c = response.victories) !== null && _c !== void 0 ? _c : 0,
|
|
@@ -230,10 +232,10 @@ exports.processors = (_a = {},
|
|
|
230
232
|
spells_used: (_h = response.spells_used) !== null && _h !== void 0 ? _h : 0,
|
|
231
233
|
});
|
|
232
234
|
},
|
|
233
|
-
_a[hive_bedrock_data_1.Game.
|
|
235
|
+
_a[hive_bedrock_data_1.Game.SkyWarsKits] = function (response) {
|
|
234
236
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
235
237
|
return ({
|
|
236
|
-
id: hive_bedrock_data_1.Game.
|
|
238
|
+
id: hive_bedrock_data_1.Game.SkyWarsKits,
|
|
237
239
|
xp: (_a = response.xp) !== null && _a !== void 0 ? _a : 0,
|
|
238
240
|
played: (_b = response.played) !== null && _b !== void 0 ? _b : 0,
|
|
239
241
|
victories: (_c = response.victories) !== null && _c !== void 0 ? _c : 0,
|
|
@@ -248,10 +250,10 @@ exports.processors = (_a = {},
|
|
|
248
250
|
selected_kit: response.selected_kit,
|
|
249
251
|
});
|
|
250
252
|
},
|
|
251
|
-
_a[hive_bedrock_data_1.Game.
|
|
253
|
+
_a[hive_bedrock_data_1.Game.SkyWarsClassic] = function (response) {
|
|
252
254
|
var _a, _b, _c, _d, _e;
|
|
253
255
|
return ({
|
|
254
|
-
id: hive_bedrock_data_1.Game.
|
|
256
|
+
id: hive_bedrock_data_1.Game.SkyWarsClassic,
|
|
255
257
|
xp: (_a = response.xp) !== null && _a !== void 0 ? _a : 0,
|
|
256
258
|
played: (_b = response.played) !== null && _b !== void 0 ? _b : 0,
|
|
257
259
|
victories: (_c = response.victories) !== null && _c !== void 0 ? _c : 0,
|
|
@@ -317,49 +319,51 @@ exports.processors = (_a = {},
|
|
|
317
319
|
},
|
|
318
320
|
_a[hive_bedrock_data_1.Game.ParkourWorlds] = function (response) {
|
|
319
321
|
var _a;
|
|
320
|
-
return
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
.
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
.
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
322
|
+
return response.parkours
|
|
323
|
+
? {
|
|
324
|
+
id: hive_bedrock_data_1.Game.ParkourWorlds,
|
|
325
|
+
worlds: Object.entries(response.parkours)
|
|
326
|
+
.filter(function (_a) {
|
|
327
|
+
var _b = __read(_a, 2), _ = _b[0], value = _b[1];
|
|
328
|
+
return typeof value === "object";
|
|
329
|
+
})
|
|
330
|
+
.map(function (_a) {
|
|
331
|
+
var _b;
|
|
332
|
+
var _c = __read(_a, 2), key = _c[0], value = _c[1];
|
|
333
|
+
return ({
|
|
334
|
+
name: key,
|
|
335
|
+
parkour_stars: (_b = value.parkour_stars) !== null && _b !== void 0 ? _b : 0,
|
|
336
|
+
courses: Object.entries(value)
|
|
337
|
+
.filter(function (_a) {
|
|
338
|
+
var _b = __read(_a, 2), _ = _b[0], value = _b[1];
|
|
339
|
+
return typeof value === "object";
|
|
340
|
+
})
|
|
341
|
+
.map(function (_a) {
|
|
342
|
+
var _b;
|
|
343
|
+
var _c = __read(_a, 2), key = _c[0], value = _c[1];
|
|
344
|
+
return ({
|
|
345
|
+
name: key,
|
|
346
|
+
best_run_time: value.best_run_time,
|
|
347
|
+
best_checkpoint_times: Object.entries(value.best_checkpoint_times).map(function (_a) {
|
|
348
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
349
|
+
return ({
|
|
350
|
+
position: { x: Number(key.split(",")[0]), y: Number(key.split(",")[1]), z: Number(key.split(",")[2]) },
|
|
351
|
+
time: value,
|
|
352
|
+
});
|
|
353
|
+
}),
|
|
354
|
+
collected_stars: value.collected_stars.map(function (value) { return ({
|
|
355
|
+
x: Number(value.split(",")[0]),
|
|
356
|
+
y: Number(value.split(",")[1]),
|
|
357
|
+
z: Number(value.split(",")[2]),
|
|
358
|
+
}); }),
|
|
359
|
+
course_stars: (_b = value.course_stars) !== null && _b !== void 0 ? _b : 0,
|
|
360
|
+
});
|
|
361
|
+
}),
|
|
362
|
+
});
|
|
363
|
+
}),
|
|
364
|
+
total_stars: (_a = response.parkours.total_stars) !== null && _a !== void 0 ? _a : 0,
|
|
365
|
+
}
|
|
366
|
+
: null;
|
|
363
367
|
},
|
|
364
368
|
_a);
|
|
365
369
|
function validateNumber(value, def) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hive-bedrock-api",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.10",
|
|
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",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"author": "Cubeedge Studios",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"hive-bedrock-data": "^2.0.0-alpha.
|
|
14
|
+
"hive-bedrock-data": "^2.0.0-alpha.6"
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
17
|
"build": "tsc"
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
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);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
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;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.default = fetchEndpoint;
|
|
40
|
-
var hive_bedrock_data_1 = require("hive-bedrock-data");
|
|
41
|
-
function fetchEndpoint(endpoint, init) {
|
|
42
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
43
|
-
var time_start, request, time_end, duration, response, err_1;
|
|
44
|
-
return __generator(this, function (_a) {
|
|
45
|
-
switch (_a.label) {
|
|
46
|
-
case 0:
|
|
47
|
-
_a.trys.push([0, 3, , 4]);
|
|
48
|
-
time_start = performance.now();
|
|
49
|
-
return [4 /*yield*/, fetch(hive_bedrock_data_1.API_BASE_ENDPOINT + endpoint, init)];
|
|
50
|
-
case 1:
|
|
51
|
-
request = _a.sent();
|
|
52
|
-
time_end = performance.now();
|
|
53
|
-
duration = Math.round(time_end - time_start);
|
|
54
|
-
if (!request.ok)
|
|
55
|
-
return [2 /*return*/, {
|
|
56
|
-
status: request.status,
|
|
57
|
-
data: null,
|
|
58
|
-
error: {
|
|
59
|
-
code: request.status,
|
|
60
|
-
message: request.statusText,
|
|
61
|
-
},
|
|
62
|
-
duration: duration,
|
|
63
|
-
}];
|
|
64
|
-
return [4 /*yield*/, request.json()];
|
|
65
|
-
case 2:
|
|
66
|
-
response = _a.sent();
|
|
67
|
-
return [2 /*return*/, {
|
|
68
|
-
status: request.status,
|
|
69
|
-
headers: request.headers,
|
|
70
|
-
data: response,
|
|
71
|
-
error: null,
|
|
72
|
-
duration: duration,
|
|
73
|
-
}];
|
|
74
|
-
case 3:
|
|
75
|
-
err_1 = _a.sent();
|
|
76
|
-
return [2 /*return*/, {
|
|
77
|
-
status: 500,
|
|
78
|
-
data: null,
|
|
79
|
-
error: {
|
|
80
|
-
code: 500,
|
|
81
|
-
message: "Failed to fetch endpoint data.",
|
|
82
|
-
},
|
|
83
|
-
}];
|
|
84
|
-
case 4: return [2 /*return*/];
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
}
|
package/lib/helpers/isGame.d.ts
DELETED
package/lib/helpers/isGame.js
DELETED
package/lib/helpers/toPoint.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function toPoint(num: number, point: number): number;
|
package/lib/helpers/toPoint.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = toPoint;
|
|
4
|
-
function toPoint(num, point) {
|
|
5
|
-
if (isNaN(num))
|
|
6
|
-
return 0;
|
|
7
|
-
if (num === Infinity)
|
|
8
|
-
return 0;
|
|
9
|
-
return Math.round(num * (10 ^ point)) / (10 ^ point);
|
|
10
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { Game } from "hive-bedrock-data";
|
|
2
|
-
import { APIResponse, Options } from "../types/types";
|
|
3
|
-
import { AllTimeProcessedLeaderboard } from "../types/output";
|
|
4
|
-
export default function getAllTimeLeaderboard<G extends Game>(game_id: G, options?: Partial<Options>): Promise<APIResponse<AllTimeProcessedLeaderboard<G>>>;
|
|
@@ -1,85 +0,0 @@
|
|
|
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
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
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);
|
|
24
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
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;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
-
};
|
|
52
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
-
exports.default = getAllTimeLeaderboard;
|
|
54
|
-
var fetchEndpoint_1 = __importDefault(require("../helpers/fetchEndpoint"));
|
|
55
|
-
var isGame_1 = __importDefault(require("../helpers/isGame"));
|
|
56
|
-
var processors_1 = require("../processors");
|
|
57
|
-
function getAllTimeLeaderboard(game_id, options) {
|
|
58
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
59
|
-
var response, response_data, processed_data;
|
|
60
|
-
return __generator(this, function (_a) {
|
|
61
|
-
switch (_a.label) {
|
|
62
|
-
case 0:
|
|
63
|
-
if (!(0, isGame_1.default)(game_id))
|
|
64
|
-
return [2 /*return*/, {
|
|
65
|
-
status: 404,
|
|
66
|
-
error: {
|
|
67
|
-
code: 404,
|
|
68
|
-
message: "Game not found.",
|
|
69
|
-
},
|
|
70
|
-
data: null,
|
|
71
|
-
}];
|
|
72
|
-
return [4 /*yield*/, (0, fetchEndpoint_1.default)("/game/all/".concat(game_id), options === null || options === void 0 ? void 0 : options.init)];
|
|
73
|
-
case 1:
|
|
74
|
-
response = _a.sent();
|
|
75
|
-
if (response.error)
|
|
76
|
-
return [2 /*return*/, response];
|
|
77
|
-
response_data = response.data;
|
|
78
|
-
processed_data = Array.from(response_data).map(function (statistics) {
|
|
79
|
-
return processors_1.LeaderboardProcessors[game_id](statistics);
|
|
80
|
-
});
|
|
81
|
-
return [2 /*return*/, __assign(__assign({}, response), { data: processed_data, error: null })];
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Game } from "hive-bedrock-data";
|
|
2
|
-
import { APIResponse, Options } from "../types/types";
|
|
3
|
-
import { AllTimeProcessedStatistics } from "../types/output";
|
|
4
|
-
import { Processed_Player_Statistics } from "../processors/player";
|
|
5
|
-
type AllGameStatisticsPlayer = AllTimeProcessedStatistics & {
|
|
6
|
-
player: Processed_Player_Statistics;
|
|
7
|
-
};
|
|
8
|
-
export default function getAllTimeStatistics(identifier: string, options?: Partial<Options>): Promise<APIResponse<AllGameStatisticsPlayer>>;
|
|
9
|
-
export default function getAllTimeStatistics<G extends Game>(identifier: string, game_id: G, options?: Partial<Options>): Promise<APIResponse<AllTimeProcessedStatistics[G]>>;
|
|
10
|
-
export {};
|
|
@@ -1,126 +0,0 @@
|
|
|
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
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
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);
|
|
24
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
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;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
50
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
51
|
-
if (!m) return o;
|
|
52
|
-
var i = m.call(o), r, ar = [], e;
|
|
53
|
-
try {
|
|
54
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
55
|
-
}
|
|
56
|
-
catch (error) { e = { error: error }; }
|
|
57
|
-
finally {
|
|
58
|
-
try {
|
|
59
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
60
|
-
}
|
|
61
|
-
finally { if (e) throw e.error; }
|
|
62
|
-
}
|
|
63
|
-
return ar;
|
|
64
|
-
};
|
|
65
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
66
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
67
|
-
};
|
|
68
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
69
|
-
exports.default = getAllTimeStatistics;
|
|
70
|
-
var isGame_1 = __importDefault(require("../helpers/isGame"));
|
|
71
|
-
var fetchEndpoint_1 = __importDefault(require("../helpers/fetchEndpoint"));
|
|
72
|
-
var processors_1 = require("../processors");
|
|
73
|
-
function getAllTimeStatistics(identifier, game_or_options, options) {
|
|
74
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
75
|
-
var game_id, method_options, response, response_data_1, processed_data_1, response_data, processed_data;
|
|
76
|
-
return __generator(this, function (_a) {
|
|
77
|
-
switch (_a.label) {
|
|
78
|
-
case 0:
|
|
79
|
-
game_id = "all";
|
|
80
|
-
method_options = game_or_options;
|
|
81
|
-
if (typeof game_or_options === "string") {
|
|
82
|
-
game_id = game_or_options;
|
|
83
|
-
method_options = options;
|
|
84
|
-
}
|
|
85
|
-
if (!(0, isGame_1.default)(game_id) && game_id !== "all")
|
|
86
|
-
return [2 /*return*/, {
|
|
87
|
-
status: 404,
|
|
88
|
-
error: {
|
|
89
|
-
code: 404,
|
|
90
|
-
message: "Game not found.",
|
|
91
|
-
},
|
|
92
|
-
data: null,
|
|
93
|
-
}];
|
|
94
|
-
return [4 /*yield*/, (0, fetchEndpoint_1.default)("/game/all/".concat(game_id, "/").concat(identifier), method_options === null || method_options === void 0 ? void 0 : method_options.init)];
|
|
95
|
-
case 1:
|
|
96
|
-
response = _a.sent();
|
|
97
|
-
if (response.error)
|
|
98
|
-
return [2 /*return*/, response];
|
|
99
|
-
if (game_id === "all") {
|
|
100
|
-
response_data_1 = Object.entries(response.data);
|
|
101
|
-
processed_data_1 = Object.fromEntries(response_data_1.map(function (_a) {
|
|
102
|
-
var _b = __read(_a, 2), id = _b[0], statistics = _b[1];
|
|
103
|
-
if (id === "main")
|
|
104
|
-
return ["player", (0, processors_1.PlayerProcessor)(statistics)];
|
|
105
|
-
if (!statistics ||
|
|
106
|
-
!(0, isGame_1.default)(id) ||
|
|
107
|
-
Array.isArray(statistics))
|
|
108
|
-
return [id, null];
|
|
109
|
-
return [
|
|
110
|
-
id,
|
|
111
|
-
typeof processors_1.AllTimeProcessors[id] === "function"
|
|
112
|
-
? processors_1.AllTimeProcessors[id](statistics)
|
|
113
|
-
: null,
|
|
114
|
-
];
|
|
115
|
-
}));
|
|
116
|
-
return [2 /*return*/, __assign(__assign({}, response), { data: processed_data_1 })];
|
|
117
|
-
}
|
|
118
|
-
response_data = response.data;
|
|
119
|
-
if (Array.isArray(response_data))
|
|
120
|
-
return [2 /*return*/, __assign(__assign({}, response), { status: 404, data: null, error: { code: 404, message: "Not Found" } })];
|
|
121
|
-
processed_data = processors_1.AllTimeProcessors[game_id](response_data);
|
|
122
|
-
return [2 /*return*/, __assign(__assign({}, response), { data: processed_data, error: null })];
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
}
|