hive-bedrock-api 2.0.4 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/README.md +18 -0
  2. package/lib/helpers/fetchEndpoint.js +1 -1
  3. package/lib/helpers/isGame.js +1 -1
  4. package/lib/helpers/toPoint.js +3 -1
  5. package/lib/index.d.ts +5 -3
  6. package/lib/index.js +20 -1
  7. package/lib/methods/getAllTimeLeaderboard.d.ts +3 -3
  8. package/lib/methods/getAllTimeLeaderboard.js +6 -8
  9. package/lib/methods/getAllTimeStatistics.d.ts +6 -5
  10. package/lib/methods/getAllTimeStatistics.js +23 -88
  11. package/lib/methods/getGlobalStatistics.js +1 -1
  12. package/lib/methods/getMaps.js +1 -1
  13. package/lib/methods/getMetadata.js +1 -1
  14. package/lib/methods/getMonthlyLeaderboard.d.ts +3 -3
  15. package/lib/methods/getMonthlyLeaderboard.js +7 -9
  16. package/lib/methods/getMonthlyStatistics.d.ts +4 -4
  17. package/lib/methods/getMonthlyStatistics.js +24 -50
  18. package/lib/methods/getPlayerInfomation.d.ts +2 -2
  19. package/lib/methods/getPlayerInfomation.js +5 -6
  20. package/lib/methods/getSeasonLeaderboard.d.ts +10 -0
  21. package/lib/methods/getSeasonLeaderboard.js +87 -0
  22. package/lib/methods/getSeasonStatistics.d.ts +10 -0
  23. package/lib/methods/getSeasonStatistics.js +87 -0
  24. package/lib/processors/bed.d.ts +19 -0
  25. package/lib/processors/bed.js +35 -0
  26. package/lib/processors/bridge.d.ts +24 -0
  27. package/lib/processors/bridge.js +40 -0
  28. package/lib/processors/build.d.ts +19 -0
  29. package/lib/processors/build.js +35 -0
  30. package/lib/processors/ctf.d.ts +19 -0
  31. package/lib/processors/ctf.js +35 -0
  32. package/lib/processors/dr.d.ts +19 -0
  33. package/lib/processors/dr.js +35 -0
  34. package/lib/processors/drop.d.ts +17 -0
  35. package/lib/processors/drop.js +34 -0
  36. package/lib/processors/grav.d.ts +17 -0
  37. package/lib/processors/grav.js +34 -0
  38. package/lib/processors/ground.d.ts +19 -0
  39. package/lib/processors/ground.js +35 -0
  40. package/lib/processors/helpers/processBuildRatings.d.ts +8 -0
  41. package/lib/processors/helpers/processBuildRatings.js +23 -0
  42. package/lib/processors/helpers/processGameAndXP.d.ts +6 -0
  43. package/lib/processors/helpers/processGameAndXP.js +10 -0
  44. package/lib/processors/helpers/processHiderKillsAndDeaths.d.ts +5 -0
  45. package/lib/processors/helpers/processHiderKillsAndDeaths.js +13 -0
  46. package/lib/processors/helpers/processKillsAndDeaths.d.ts +5 -0
  47. package/lib/processors/helpers/processKillsAndDeaths.js +13 -0
  48. package/lib/processors/helpers/processMurdersAndDeaths.d.ts +5 -0
  49. package/lib/processors/helpers/processMurdersAndDeaths.js +13 -0
  50. package/lib/processors/helpers/processPlayedAndVictories.d.ts +6 -0
  51. package/lib/processors/helpers/processPlayedAndVictories.js +12 -0
  52. package/lib/processors/hide.d.ts +19 -0
  53. package/lib/processors/hide.js +35 -0
  54. package/lib/processors/index.d.ts +11 -6
  55. package/lib/processors/index.js +70 -136
  56. package/lib/processors/murder.d.ts +19 -0
  57. package/lib/processors/murder.js +35 -0
  58. package/lib/processors/parkour.d.ts +5 -0
  59. package/lib/processors/parkour.js +99 -0
  60. package/lib/processors/party.d.ts +17 -0
  61. package/lib/processors/party.js +34 -0
  62. package/lib/processors/player.d.ts +9 -0
  63. package/lib/processors/player.js +36 -0
  64. package/lib/processors/sg.d.ts +19 -0
  65. package/lib/processors/sg.js +35 -0
  66. package/lib/processors/sky.d.ts +19 -0
  67. package/lib/processors/sky.js +35 -0
  68. package/lib/processors/wars.d.ts +19 -0
  69. package/lib/processors/wars.js +35 -0
  70. package/lib/types/output.d.ts +53 -69
  71. package/lib/types/types.d.ts +2 -0
  72. package/package.json +2 -2
package/README.md CHANGED
@@ -34,6 +34,15 @@ const { data, error } = await getAllTimeStats("player");
34
34
  const { data, error } = await getAllTimeStats("player", Game.HideAndSeek);
35
35
  ```
36
36
 
37
+ ### Fetch Season Player Statistics
38
+
39
+ ```ts
40
+ import { getSeasonStatistics, Game } from "hive-bedrock-api";
41
+
42
+ // Returns a game statistics
43
+ const { data, error } = await getSeasonStatistics("player", Game.BedWars);
44
+ ```
45
+
37
46
  ### Fetch Monthly Player Statistics
38
47
 
39
48
  ```ts
@@ -61,6 +70,15 @@ import { getAllTimeLeaderboard, Game } from "hive-bedrock-api";
61
70
  const { data, error } = await getAllTimeLeaderboard(Game.TreasureWars);
62
71
  ```
63
72
 
73
+ ### Fetch Season Leaderboard
74
+
75
+ ```ts
76
+ import { getSeasonLeaderboard, Game } from "hive-bedrock-api";
77
+
78
+ // Returns a single game
79
+ const { data, error } = await getSeasonLeaderboard(Game.BedWars);
80
+ ```
81
+
64
82
  ### Fetch Monthly Leaderboard
65
83
 
66
84
  ```ts
@@ -36,6 +36,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
36
  }
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.default = fetchEndpoint;
39
40
  var hive_bedrock_data_1 = require("hive-bedrock-data");
40
41
  function fetchEndpoint(endpoint, init) {
41
42
  return __awaiter(this, void 0, void 0, function () {
@@ -84,4 +85,3 @@ function fetchEndpoint(endpoint, init) {
84
85
  });
85
86
  });
86
87
  }
87
- exports.default = fetchEndpoint;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = isGame;
3
4
  var hive_bedrock_data_1 = require("hive-bedrock-data");
4
5
  function isGame(game_id) {
5
6
  return Object.values(hive_bedrock_data_1.Game).includes(game_id);
6
7
  }
7
- exports.default = isGame;
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = toPoint;
3
4
  function toPoint(num, point) {
5
+ if (isNaN(num))
6
+ return 0;
4
7
  return Math.round(num * (10 ^ point)) / (10 ^ point);
5
8
  }
6
- exports.default = toPoint;
package/lib/index.d.ts CHANGED
@@ -6,7 +6,9 @@ import getMetdata from "./methods/getMetadata";
6
6
  import getMonthlyLeaderboard from "./methods/getMonthlyLeaderboard";
7
7
  import getMonthlyStatistics from "./methods/getMonthlyStatistics";
8
8
  import getPlayerInfomation from "./methods/getPlayerInfomation";
9
- import type { AllStatistics, AllLeaderboards } from "./types/output";
10
- export { getAllTimeLeaderboard, getMonthlyLeaderboard, getAllTimeStatistics, getMonthlyStatistics, getGlobalStatistics, getMaps, getMetdata, getPlayerInfomation, };
11
- export type { AllStatistics, AllLeaderboards };
9
+ import getSeasonLeaderboard from "./methods/getSeasonLeaderboard";
10
+ import getSeasonStatistics from "./methods/getSeasonStatistics";
11
+ export { getAllTimeLeaderboard, getMonthlyLeaderboard, getAllTimeStatistics, getMonthlyStatistics, getGlobalStatistics, getMaps, getMetdata, getPlayerInfomation, getSeasonLeaderboard, getSeasonStatistics, };
12
12
  export { Game } from "hive-bedrock-data";
13
+ export type * from "./types/output";
14
+ export * from "./processors/index";
package/lib/index.js CHANGED
@@ -1,9 +1,23 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
18
  };
5
19
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Game = exports.getPlayerInfomation = exports.getMetdata = exports.getMaps = exports.getGlobalStatistics = exports.getMonthlyStatistics = exports.getAllTimeStatistics = exports.getMonthlyLeaderboard = exports.getAllTimeLeaderboard = void 0;
20
+ exports.Game = exports.getSeasonStatistics = exports.getSeasonLeaderboard = exports.getPlayerInfomation = exports.getMetdata = exports.getMaps = exports.getGlobalStatistics = exports.getMonthlyStatistics = exports.getAllTimeStatistics = exports.getMonthlyLeaderboard = exports.getAllTimeLeaderboard = void 0;
7
21
  var getAllTimeLeaderboard_1 = __importDefault(require("./methods/getAllTimeLeaderboard"));
8
22
  exports.getAllTimeLeaderboard = getAllTimeLeaderboard_1.default;
9
23
  var getAllTimeStatistics_1 = __importDefault(require("./methods/getAllTimeStatistics"));
@@ -20,5 +34,10 @@ var getMonthlyStatistics_1 = __importDefault(require("./methods/getMonthlyStatis
20
34
  exports.getMonthlyStatistics = getMonthlyStatistics_1.default;
21
35
  var getPlayerInfomation_1 = __importDefault(require("./methods/getPlayerInfomation"));
22
36
  exports.getPlayerInfomation = getPlayerInfomation_1.default;
37
+ var getSeasonLeaderboard_1 = __importDefault(require("./methods/getSeasonLeaderboard"));
38
+ exports.getSeasonLeaderboard = getSeasonLeaderboard_1.default;
39
+ var getSeasonStatistics_1 = __importDefault(require("./methods/getSeasonStatistics"));
40
+ exports.getSeasonStatistics = getSeasonStatistics_1.default;
23
41
  var hive_bedrock_data_1 = require("hive-bedrock-data");
24
42
  Object.defineProperty(exports, "Game", { enumerable: true, get: function () { return hive_bedrock_data_1.Game; } });
43
+ __exportStar(require("./processors/index"), exports);
@@ -1,4 +1,4 @@
1
- import { Game, Timeframe } from "hive-bedrock-data";
1
+ import { Game } from "hive-bedrock-data";
2
2
  import { APIResponse, Options } from "../types/types";
3
- import { LeaderboardResponse } from "../types/output";
4
- export default function getAllTimeLeaderboard<G extends Game>(game_id: G, options?: Options): Promise<APIResponse<LeaderboardResponse<G, Timeframe.AllTime>>>;
3
+ import { AllTimeProcessedLeaderboard } from "../types/output";
4
+ export default function getAllTimeLeaderboard<G extends Game>(game_id: G, options?: Options): Promise<APIResponse<AllTimeProcessedLeaderboard<G>>>;
@@ -50,13 +50,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
50
50
  return (mod && mod.__esModule) ? mod : { "default": mod };
51
51
  };
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
- var hive_bedrock_data_1 = require("hive-bedrock-data");
53
+ exports.default = getAllTimeLeaderboard;
54
54
  var fetchEndpoint_1 = __importDefault(require("../helpers/fetchEndpoint"));
55
55
  var isGame_1 = __importDefault(require("../helpers/isGame"));
56
- var processors_1 = __importDefault(require("../processors"));
56
+ var processors_1 = require("../processors");
57
57
  function getAllTimeLeaderboard(game_id, options) {
58
58
  return __awaiter(this, void 0, void 0, function () {
59
- var response, response_data, processors;
59
+ var response, response_data, processed_data;
60
60
  return __generator(this, function (_a) {
61
61
  switch (_a.label) {
62
62
  case 0:
@@ -75,13 +75,11 @@ function getAllTimeLeaderboard(game_id, options) {
75
75
  if (response.error)
76
76
  return [2 /*return*/, response];
77
77
  response_data = response.data;
78
- processors = (0, processors_1.default)(game_id, hive_bedrock_data_1.Timeframe.AllTime);
79
- response_data.forEach(function (statistics) {
80
- return processors.forEach(function (processor) { return processor(statistics); });
78
+ processed_data = Array.from(response_data).map(function (statistics) {
79
+ return processors_1.LeaderboardProcessors[game_id](statistics);
81
80
  });
82
- return [2 /*return*/, __assign(__assign({}, response), { data: response_data, error: null })];
81
+ return [2 /*return*/, __assign(__assign({}, response), { data: processed_data, error: null })];
83
82
  }
84
83
  });
85
84
  });
86
85
  }
87
- exports.default = getAllTimeLeaderboard;
@@ -1,9 +1,10 @@
1
- import { Game, PlayerMetadata, Timeframe } from "hive-bedrock-data";
1
+ import { Game } from "hive-bedrock-data";
2
2
  import { APIResponse, Options } from "../types/types";
3
- import { AllGameStatistics, StatisticsResponse } from "../types/output";
4
- type AllGameStatisticsPlayer = AllGameStatistics<Timeframe.AllTime> & {
5
- player: PlayerMetadata;
3
+ import { AllTimeProcessedStatistics } from "../types/output";
4
+ import { Processed_Player_Statistics } from "../processors/player";
5
+ type AllGameStatisticsPlayer = AllTimeProcessedStatistics & {
6
+ player: Processed_Player_Statistics;
6
7
  };
7
8
  export default function getAllTimeStatistics(identifier: string, options?: Options): Promise<APIResponse<AllGameStatisticsPlayer>>;
8
- export default function getAllTimeStatistics<G extends Game>(identifier: string, game_id: G, options?: Options): Promise<APIResponse<StatisticsResponse<G, Timeframe.AllTime>>>;
9
+ export default function getAllTimeStatistics<G extends Game>(identifier: string, game_id: G, options?: Options): Promise<APIResponse<AllTimeProcessedStatistics[G]>>;
9
10
  export {};
@@ -10,29 +10,6 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
- if (k2 === undefined) k2 = k;
15
- var desc = Object.getOwnPropertyDescriptor(m, k);
16
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
- desc = { enumerable: true, get: function() { return m[k]; } };
18
- }
19
- Object.defineProperty(o, k2, desc);
20
- }) : (function(o, m, k, k2) {
21
- if (k2 === undefined) k2 = k;
22
- o[k2] = m[k];
23
- }));
24
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
- Object.defineProperty(o, "default", { enumerable: true, value: v });
26
- }) : function(o, v) {
27
- o["default"] = v;
28
- });
29
- var __importStar = (this && this.__importStar) || function (mod) {
30
- if (mod && mod.__esModule) return mod;
31
- var result = {};
32
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
- __setModuleDefault(result, mod);
34
- return result;
35
- };
36
13
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
14
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
15
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -69,17 +46,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
69
46
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
70
47
  }
71
48
  };
72
- var __values = (this && this.__values) || function(o) {
73
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
74
- if (m) return m.call(o);
75
- if (o && typeof o.length === "number") return {
76
- next: function () {
77
- if (o && i >= o.length) o = void 0;
78
- return { value: o && o[i++], done: !o };
79
- }
80
- };
81
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
82
- };
83
49
  var __read = (this && this.__read) || function (o, n) {
84
50
  var m = typeof Symbol === "function" && o[Symbol.iterator];
85
51
  if (!m) return o;
@@ -100,17 +66,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
100
66
  return (mod && mod.__esModule) ? mod : { "default": mod };
101
67
  };
102
68
  Object.defineProperty(exports, "__esModule", { value: true });
103
- var hive_bedrock_data_1 = require("hive-bedrock-data");
69
+ exports.default = getAllTimeStatistics;
104
70
  var isGame_1 = __importDefault(require("../helpers/isGame"));
105
71
  var fetchEndpoint_1 = __importDefault(require("../helpers/fetchEndpoint"));
106
- var processors_1 = __importStar(require("../processors"));
72
+ var processors_1 = require("../processors");
107
73
  function getAllTimeStatistics(identifier, game_or_options, options) {
108
74
  return __awaiter(this, void 0, void 0, function () {
109
- var game_id, method_options, response, games, output, _loop_1, games_1, games_1_1, _a, g, stats, player_1, processors_2, response_data, processors;
110
- var e_1, _b;
111
- var _c;
112
- return __generator(this, function (_d) {
113
- switch (_d.label) {
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) {
114
78
  case 0:
115
79
  game_id = "all";
116
80
  method_options = game_or_options;
@@ -129,61 +93,32 @@ function getAllTimeStatistics(identifier, game_or_options, options) {
129
93
  }];
130
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)];
131
95
  case 1:
132
- response = _d.sent();
96
+ response = _a.sent();
133
97
  if (response.error)
134
98
  return [2 /*return*/, response];
135
99
  if (game_id === "all") {
136
- games = Object.entries(response.data);
137
- output = {};
138
- _loop_1 = function (g, stats) {
139
- if ((0, isGame_1.default)(g)) {
140
- if (Array.isArray(stats)) {
141
- output[g] = null;
142
- return "continue";
143
- }
144
- var processors_3 = (0, processors_1.default)(g, hive_bedrock_data_1.Timeframe.AllTime);
145
- processors_3.forEach(function (processor) { return processor(stats); });
146
- output[g] = Object.keys(stats).length > 0 ? stats : null;
147
- }
148
- };
149
- try {
150
- for (games_1 = __values(games), games_1_1 = games_1.next(); !games_1_1.done; games_1_1 = games_1.next()) {
151
- _a = __read(games_1_1.value, 2), g = _a[0], stats = _a[1];
152
- _loop_1(g, stats);
153
- }
154
- }
155
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
156
- finally {
157
- try {
158
- if (games_1_1 && !games_1_1.done && (_b = games_1.return)) _b.call(games_1);
159
- }
160
- finally { if (e_1) throw e_1.error; }
161
- }
162
- player_1 = (_c = games.find(function (_a) {
163
- var _b = __read(_a, 1), g = _b[0];
164
- return g === "main";
165
- })) === null || _c === void 0 ? void 0 : _c[1];
166
- if (!player_1)
167
- return [2 /*return*/, {
168
- status: 500,
169
- error: {
170
- code: 500,
171
- message: "Player statistics not returned",
172
- },
173
- data: null,
174
- }];
175
- processors_2 = (0, processors_1.getPlayerProcessors)();
176
- processors_2.forEach(function (processor) { return processor(player_1); });
177
- return [2 /*return*/, __assign(__assign({}, response), { data: __assign(__assign({}, output), { player: player_1 }) })];
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 (!statistics || !(0, isGame_1.default)(id) || Array.isArray(statistics))
104
+ return [id, null];
105
+ if (id === "main")
106
+ return ["player", (0, processors_1.PlayerProcessor)(statistics)];
107
+ return [
108
+ id,
109
+ typeof processors_1.AllTimeProcessors[id] === "function"
110
+ ? processors_1.AllTimeProcessors[id](statistics)
111
+ : null,
112
+ ];
113
+ }));
114
+ return [2 /*return*/, __assign(__assign({}, response), { data: processed_data_1 })];
178
115
  }
179
116
  response_data = response.data;
180
117
  if (Array.isArray(response_data))
181
118
  return [2 /*return*/, __assign(__assign({}, response), { status: 404, data: null, error: { code: 404, message: "Not Found" } })];
182
- processors = (0, processors_1.default)(game_id, hive_bedrock_data_1.Timeframe.AllTime);
183
- processors.forEach(function (processor) { return processor(response_data); });
184
- return [2 /*return*/, __assign(__assign({}, response), { data: Object.keys(response_data).length > 0 ? response_data : null, error: null })];
119
+ processed_data = processors_1.AllTimeProcessors[game_id](response_data);
120
+ return [2 /*return*/, __assign(__assign({}, response), { data: processed_data, error: null })];
185
121
  }
186
122
  });
187
123
  });
188
124
  }
189
- exports.default = getAllTimeStatistics;
@@ -39,6 +39,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
39
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
40
  };
41
41
  Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.default = getGlobalStatistics;
42
43
  var fetchEndpoint_1 = __importDefault(require("../helpers/fetchEndpoint"));
43
44
  function getGlobalStatistics(options) {
44
45
  return __awaiter(this, void 0, void 0, function () {
@@ -53,4 +54,3 @@ function getGlobalStatistics(options) {
53
54
  });
54
55
  });
55
56
  }
56
- exports.default = getGlobalStatistics;
@@ -50,6 +50,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
50
50
  return (mod && mod.__esModule) ? mod : { "default": mod };
51
51
  };
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
+ exports.default = getMaps;
53
54
  var fetchEndpoint_1 = __importDefault(require("../helpers/fetchEndpoint"));
54
55
  var isGame_1 = __importDefault(require("../helpers/isGame"));
55
56
  function getMaps(game_id, options) {
@@ -78,4 +79,3 @@ function getMaps(game_id, options) {
78
79
  });
79
80
  });
80
81
  }
81
- exports.default = getMaps;
@@ -50,6 +50,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
50
50
  return (mod && mod.__esModule) ? mod : { "default": mod };
51
51
  };
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
+ exports.default = getMetdata;
53
54
  var fetchEndpoint_1 = __importDefault(require("../helpers/fetchEndpoint"));
54
55
  var isGame_1 = __importDefault(require("../helpers/isGame"));
55
56
  function getMetdata(game_id, options) {
@@ -78,4 +79,3 @@ function getMetdata(game_id, options) {
78
79
  });
79
80
  });
80
81
  }
81
- exports.default = getMetdata;
@@ -1,11 +1,11 @@
1
- import { Game, Timeframe } from "hive-bedrock-data";
1
+ import { Game } from "hive-bedrock-data";
2
2
  import { APIResponse, Options } from "../types/types";
3
- import { LeaderboardResponse } from "../types/output";
3
+ import { MonthlyProcessedLeaderboard } from "../types/output";
4
4
  interface MonthlyOptions extends Options {
5
5
  month: number;
6
6
  year: number;
7
7
  amount: number;
8
8
  skip: number;
9
9
  }
10
- export default function getMonthlyLeaderboard<G extends Game>(game_id: G, options?: Partial<MonthlyOptions>): Promise<APIResponse<LeaderboardResponse<G, Timeframe.Monthly>>>;
10
+ export default function getMonthlyLeaderboard<G extends Game>(game_id: G, options?: Partial<MonthlyOptions>): Promise<APIResponse<MonthlyProcessedLeaderboard<G>>>;
11
11
  export {};
@@ -50,13 +50,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
50
50
  return (mod && mod.__esModule) ? mod : { "default": mod };
51
51
  };
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
- var hive_bedrock_data_1 = require("hive-bedrock-data");
53
+ exports.default = getMonthlyLeaderboard;
54
54
  var fetchEndpoint_1 = __importDefault(require("../helpers/fetchEndpoint"));
55
55
  var isGame_1 = __importDefault(require("../helpers/isGame"));
56
- var processors_1 = __importDefault(require("../processors"));
56
+ var processors_1 = require("../processors");
57
57
  function getMonthlyLeaderboard(game_id, options) {
58
58
  return __awaiter(this, void 0, void 0, function () {
59
- var current_date, endpoint, response, response_data, processors;
59
+ var current_date, endpoint, response, response_data, processed_data;
60
60
  var _a, _b, _c, _d;
61
61
  return __generator(this, function (_e) {
62
62
  switch (_e.label) {
@@ -77,14 +77,12 @@ function getMonthlyLeaderboard(game_id, options) {
77
77
  response = _e.sent();
78
78
  if (response.error)
79
79
  return [2 /*return*/, response];
80
- response_data = Object.values(response.data);
81
- processors = (0, processors_1.default)(game_id, hive_bedrock_data_1.Timeframe.Monthly);
82
- response_data.forEach(function (statistics) {
83
- return processors.forEach(function (processor) { return processor(statistics); });
80
+ response_data = response.data;
81
+ processed_data = Array.from(response_data).map(function (statistics) {
82
+ return processors_1.LeaderboardProcessors[game_id](statistics);
84
83
  });
85
- return [2 /*return*/, __assign(__assign({}, response), { data: response_data, error: null })];
84
+ return [2 /*return*/, __assign(__assign({}, response), { data: processed_data, error: null })];
86
85
  }
87
86
  });
88
87
  });
89
88
  }
90
- exports.default = getMonthlyLeaderboard;
@@ -1,10 +1,10 @@
1
- import { Game, Timeframe } from "hive-bedrock-data";
1
+ import { Game } from "hive-bedrock-data";
2
2
  import { APIResponse, Options } from "../types/types";
3
- import { AllGameStatistics, StatisticsResponse } from "../types/output";
3
+ import { MonthlyProcessedStatistics } from "../types/output";
4
4
  interface MonthlyOptions extends Options {
5
5
  month: number;
6
6
  year: number;
7
7
  }
8
- export default function getMonthlyStatistics(identifier: string, options?: MonthlyOptions): Promise<APIResponse<AllGameStatistics<Timeframe.Monthly>>>;
9
- export default function getMonthlyStatistics<G extends Game>(identifier: string, game_id: G, options?: MonthlyOptions): Promise<APIResponse<StatisticsResponse<G, Timeframe.Monthly>>>;
8
+ export default function getMonthlyStatistics(identifier: string, options?: MonthlyOptions): Promise<APIResponse<MonthlyProcessedStatistics>>;
9
+ export default function getMonthlyStatistics<G extends Game>(identifier: string, game_id: G, options?: MonthlyOptions): Promise<APIResponse<MonthlyProcessedStatistics[G]>>;
10
10
  export {};
@@ -46,17 +46,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
46
46
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
47
  }
48
48
  };
49
- var __values = (this && this.__values) || function(o) {
50
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
51
- if (m) return m.call(o);
52
- if (o && typeof o.length === "number") return {
53
- next: function () {
54
- if (o && i >= o.length) o = void 0;
55
- return { value: o && o[i++], done: !o };
56
- }
57
- };
58
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
59
- };
60
49
  var __read = (this && this.__read) || function (o, n) {
61
50
  var m = typeof Symbol === "function" && o[Symbol.iterator];
62
51
  if (!m) return o;
@@ -77,17 +66,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
77
66
  return (mod && mod.__esModule) ? mod : { "default": mod };
78
67
  };
79
68
  Object.defineProperty(exports, "__esModule", { value: true });
69
+ exports.default = getMonthlyStatistics;
80
70
  var hive_bedrock_data_1 = require("hive-bedrock-data");
81
71
  var isGame_1 = __importDefault(require("../helpers/isGame"));
82
72
  var fetchEndpoint_1 = __importDefault(require("../helpers/fetchEndpoint"));
83
- var processors_1 = __importDefault(require("../processors"));
73
+ var processors_1 = require("../processors");
84
74
  function getMonthlyStatistics(identifier, game_or_options, options) {
85
75
  return __awaiter(this, void 0, void 0, function () {
86
- var game_id, method_options, current_date, endpoint, response, games, output, _loop_1, games_1, games_1_1, _a, g, stats, response_data, processors;
87
- var e_1, _b;
88
- var _c, _d;
89
- return __generator(this, function (_e) {
90
- switch (_e.label) {
76
+ var game_id, method_options, current_date, endpoint, response, response_data_1, processed_data_1, response_data, processed_data;
77
+ var _a, _b;
78
+ return __generator(this, function (_c) {
79
+ switch (_c.label) {
91
80
  case 0:
92
81
  game_id = "all";
93
82
  method_options = game_or_options;
@@ -105,49 +94,34 @@ function getMonthlyStatistics(identifier, game_or_options, options) {
105
94
  data: null,
106
95
  }];
107
96
  current_date = new Date();
108
- endpoint = "/game/monthly/player/".concat(game_id, "/").concat(identifier, "/").concat((_c = options === null || options === void 0 ? void 0 : options.year) !== null && _c !== void 0 ? _c : current_date.getFullYear(), "/").concat((_d = options === null || options === void 0 ? void 0 : options.month) !== null && _d !== void 0 ? _d : current_date.getMonth() + 1);
97
+ endpoint = "/game/monthly/player/".concat(game_id, "/").concat(identifier, "/").concat((_a = options === null || options === void 0 ? void 0 : options.year) !== null && _a !== void 0 ? _a : current_date.getFullYear(), "/").concat((_b = options === null || options === void 0 ? void 0 : options.month) !== null && _b !== void 0 ? _b : current_date.getMonth() + 1);
109
98
  return [4 /*yield*/, (0, fetchEndpoint_1.default)(endpoint, method_options === null || method_options === void 0 ? void 0 : method_options.init)];
110
99
  case 1:
111
- response = _e.sent();
100
+ response = _c.sent();
112
101
  if (response.error)
113
102
  return [2 /*return*/, response];
114
103
  if (game_id === "all") {
115
- games = Object.entries(response.data);
116
- output = {};
117
- _loop_1 = function (g, stats) {
118
- if ((0, isGame_1.default)(g)) {
119
- if (Array.isArray(stats) || typeof stats["played"] === "undefined") {
120
- output[g] = null;
121
- return "continue";
122
- }
123
- var processors_2 = (0, processors_1.default)(g, hive_bedrock_data_1.Timeframe.Monthly);
124
- processors_2.forEach(function (processor) { return processor(stats); });
125
- output[g] = Object.keys(stats).length > 0 ? stats : null;
126
- }
127
- };
128
- try {
129
- for (games_1 = __values(games), games_1_1 = games_1.next(); !games_1_1.done; games_1_1 = games_1.next()) {
130
- _a = __read(games_1_1.value, 2), g = _a[0], stats = _a[1];
131
- _loop_1(g, stats);
132
- }
133
- }
134
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
135
- finally {
136
- try {
137
- if (games_1_1 && !games_1_1.done && (_b = games_1.return)) _b.call(games_1);
138
- }
139
- finally { if (e_1) throw e_1.error; }
140
- }
141
- return [2 /*return*/, __assign(__assign({}, response), { data: output })];
104
+ response_data_1 = Object.entries(response.data);
105
+ processed_data_1 = Object.fromEntries(response_data_1.map(function (_a) {
106
+ var _b = __read(_a, 2), id = _b[0], statistics = _b[1];
107
+ if (!statistics || !(0, isGame_1.default)(id) || Array.isArray(statistics))
108
+ return [id, null];
109
+ var e = processors_1.MonthlyProcessors[hive_bedrock_data_1.Game.ParkourWorlds];
110
+ return [
111
+ id,
112
+ typeof processors_1.MonthlyProcessors[id] === "function"
113
+ ? processors_1.MonthlyProcessors[id](statistics)
114
+ : null,
115
+ ];
116
+ }));
117
+ return [2 /*return*/, __assign(__assign({}, response), { data: processed_data_1 })];
142
118
  }
143
119
  response_data = response.data;
144
120
  if (Array.isArray(response_data))
145
121
  return [2 /*return*/, __assign(__assign({}, response), { status: 404, data: null, error: { code: 404, message: "Not Found" } })];
146
- processors = (0, processors_1.default)(game_id, hive_bedrock_data_1.Timeframe.Monthly);
147
- processors.forEach(function (processor) { return processor(response_data); });
148
- return [2 /*return*/, __assign(__assign({}, response), { data: Object.keys(response_data).length > 0 ? response_data : null, error: null })];
122
+ processed_data = processors_1.MonthlyProcessors[game_id](response_data);
123
+ return [2 /*return*/, __assign(__assign({}, response), { data: processed_data, error: null })];
149
124
  }
150
125
  });
151
126
  });
152
127
  }
153
- exports.default = getMonthlyStatistics;
@@ -1,3 +1,3 @@
1
- import { PlayerMetadata } from "hive-bedrock-data";
2
1
  import { APIResponse, Options } from "../types/types";
3
- export default function getPlayerInfomation(identifier: string, options?: Options): Promise<APIResponse<PlayerMetadata>>;
2
+ import { Processed_Player_Statistics } from "../processors/player";
3
+ export default function getPlayerInfomation(identifier: string, options?: Options): Promise<APIResponse<Processed_Player_Statistics>>;
@@ -50,11 +50,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
50
50
  return (mod && mod.__esModule) ? mod : { "default": mod };
51
51
  };
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
+ exports.default = getPlayerInfomation;
53
54
  var fetchEndpoint_1 = __importDefault(require("../helpers/fetchEndpoint"));
54
55
  var processors_1 = require("../processors");
55
56
  function getPlayerInfomation(identifier, options) {
56
57
  return __awaiter(this, void 0, void 0, function () {
57
- var response, player, processors;
58
+ var response, response_data, processed_data;
58
59
  return __generator(this, function (_a) {
59
60
  switch (_a.label) {
60
61
  case 0: return [4 /*yield*/, (0, fetchEndpoint_1.default)("/game/all/main/".concat(identifier), options === null || options === void 0 ? void 0 : options.init)];
@@ -62,12 +63,10 @@ function getPlayerInfomation(identifier, options) {
62
63
  response = _a.sent();
63
64
  if (response.error)
64
65
  return [2 /*return*/, response];
65
- player = response.data.main;
66
- processors = (0, processors_1.getPlayerProcessors)();
67
- processors.forEach(function (processor) { return processor(player); });
68
- return [2 /*return*/, __assign(__assign({}, response), { data: player })];
66
+ response_data = response.data.main;
67
+ processed_data = (0, processors_1.PlayerProcessor)(response_data);
68
+ return [2 /*return*/, __assign(__assign({}, response), { data: processed_data })];
69
69
  }
70
70
  });
71
71
  });
72
72
  }
73
- exports.default = getPlayerInfomation;
@@ -0,0 +1,10 @@
1
+ import { Game } from "hive-bedrock-data";
2
+ import { APIResponse, Options } from "../types/types";
3
+ import { MonthlyProcessedLeaderboard } from "../types/output";
4
+ interface SeasonOptions extends Options {
5
+ season: number;
6
+ amount: number;
7
+ skip: number;
8
+ }
9
+ export default function getSeasonLeaderboard<G extends Game>(game_id: G, options?: Partial<SeasonOptions>): Promise<APIResponse<MonthlyProcessedLeaderboard<G>>>;
10
+ export {};