hive-bedrock-api 2.1.3 → 2.1.5

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.
@@ -66,6 +66,7 @@ function fetchEndpoint(endpoint, init) {
66
66
  response = _a.sent();
67
67
  return [2 /*return*/, {
68
68
  status: request.status,
69
+ headers: request.headers,
69
70
  data: response,
70
71
  error: null,
71
72
  duration: duration,
@@ -1,4 +1,4 @@
1
1
  import { Game } from "hive-bedrock-data";
2
2
  import { APIResponse, Options } from "../types/types";
3
3
  import { AllTimeProcessedLeaderboard } from "../types/output";
4
- export default function getAllTimeLeaderboard<G extends Game>(game_id: G, options?: Options): Promise<APIResponse<AllTimeProcessedLeaderboard<G>>>;
4
+ export default function getAllTimeLeaderboard<G extends Game>(game_id: G, options?: Partial<Options>): Promise<APIResponse<AllTimeProcessedLeaderboard<G>>>;
@@ -5,6 +5,6 @@ import { Processed_Player_Statistics } from "../processors/player";
5
5
  type AllGameStatisticsPlayer = AllTimeProcessedStatistics & {
6
6
  player: Processed_Player_Statistics;
7
7
  };
8
- export default function getAllTimeStatistics(identifier: string, options?: Options): Promise<APIResponse<AllGameStatisticsPlayer>>;
9
- export default function getAllTimeStatistics<G extends Game>(identifier: string, game_id: G, options?: Options): Promise<APIResponse<AllTimeProcessedStatistics[G]>>;
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
10
  export {};
@@ -1,3 +1,3 @@
1
1
  import { GlobalStatisticsMetadata } from "hive-bedrock-data";
2
2
  import { APIResponse, Options } from "../types/types";
3
- export default function getGlobalStatistics(options?: Options): Promise<APIResponse<GlobalStatisticsMetadata>>;
3
+ export default function getGlobalStatistics(options?: Partial<Options>): Promise<APIResponse<GlobalStatisticsMetadata>>;
@@ -1,3 +1,3 @@
1
1
  import { Game, MapMetadata } from "hive-bedrock-data";
2
2
  import { APIResponse, Options } from "../types/types";
3
- export default function getMaps<G extends Game>(game_id: G, options?: Options): Promise<APIResponse<MapMetadata[]>>;
3
+ export default function getMaps<G extends Game>(game_id: G, options?: Partial<Options>): Promise<APIResponse<MapMetadata[]>>;
@@ -1,3 +1,3 @@
1
1
  import { Game, GameMetadata } from "hive-bedrock-data";
2
2
  import { APIResponse, Options } from "../types/types";
3
- export default function getMetdata<G extends Game>(game_id: G, options?: Options): Promise<APIResponse<GameMetadata>>;
3
+ export default function getMetdata<G extends Game>(game_id: G, options?: Partial<Options>): Promise<APIResponse<GameMetadata>>;
@@ -5,6 +5,6 @@ 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<MonthlyProcessedStatistics>>;
9
- export default function getMonthlyStatistics<G extends Game>(identifier: string, game_id: G, options?: MonthlyOptions): Promise<APIResponse<MonthlyProcessedStatistics[G]>>;
8
+ export default function getMonthlyStatistics(identifier: string, options?: Partial<MonthlyOptions>): Promise<APIResponse<MonthlyProcessedStatistics>>;
9
+ export default function getMonthlyStatistics<G extends Game>(identifier: string, game_id: G, options?: Partial<MonthlyOptions>): Promise<APIResponse<MonthlyProcessedStatistics[G]>>;
10
10
  export {};
@@ -74,9 +74,8 @@ var processors_1 = require("../processors");
74
74
  function getMonthlyStatistics(identifier, game_or_options, options) {
75
75
  return __awaiter(this, void 0, void 0, function () {
76
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) {
77
+ return __generator(this, function (_a) {
78
+ switch (_a.label) {
80
79
  case 0:
81
80
  game_id = "all";
82
81
  method_options = game_or_options;
@@ -94,17 +93,24 @@ function getMonthlyStatistics(identifier, game_or_options, options) {
94
93
  data: null,
95
94
  }];
96
95
  current_date = new Date();
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);
96
+ endpoint = "/game/monthly/player/".concat(game_id, "/").concat(identifier, "/").concat(typeof (method_options === null || method_options === void 0 ? void 0 : method_options.year) === "number"
97
+ ? method_options === null || method_options === void 0 ? void 0 : method_options.year
98
+ : current_date.getFullYear(), "/").concat(typeof (method_options === null || method_options === void 0 ? void 0 : method_options.month) === "number"
99
+ ? method_options === null || method_options === void 0 ? void 0 : method_options.month
100
+ : current_date.getMonth() + 1);
101
+ console.log(endpoint);
98
102
  return [4 /*yield*/, (0, fetchEndpoint_1.default)(endpoint, method_options === null || method_options === void 0 ? void 0 : method_options.init)];
99
103
  case 1:
100
- response = _c.sent();
104
+ response = _a.sent();
101
105
  if (response.error)
102
106
  return [2 /*return*/, response];
103
107
  if (game_id === "all") {
104
108
  response_data_1 = Object.entries(response.data);
105
109
  processed_data_1 = Object.fromEntries(response_data_1.map(function (_a) {
106
110
  var _b = __read(_a, 2), id = _b[0], statistics = _b[1];
107
- if (!statistics || !(0, isGame_1.default)(id) || Array.isArray(statistics))
111
+ if (!statistics ||
112
+ !(0, isGame_1.default)(id) ||
113
+ Array.isArray(statistics))
108
114
  return [id, null];
109
115
  var e = processors_1.MonthlyProcessors[hive_bedrock_data_1.Game.ParkourWorlds];
110
116
  return [
@@ -1,3 +1,3 @@
1
1
  import { APIResponse, Options } from "../types/types";
2
2
  import { Processed_Player_Statistics } from "../processors/player";
3
- export default function getPlayerInfomation(identifier: string, options?: Options): Promise<APIResponse<Processed_Player_Statistics>>;
3
+ export default function getPlayerInfomation(identifier: string, options?: Partial<Options>): Promise<APIResponse<Processed_Player_Statistics>>;
@@ -6,5 +6,5 @@ interface SeasonOptions extends Options {
6
6
  month: number;
7
7
  year: number;
8
8
  }
9
- export default function getSeasonStatistics<G extends Game>(identifier: string, game_id: G, options?: SeasonOptions): Promise<APIResponse<MonthlyProcessedStatistics[G]>>;
9
+ export default function getSeasonStatistics<G extends Game>(identifier: string, game_id: G, options?: Partial<SeasonOptions>): Promise<APIResponse<MonthlyProcessedStatistics[G]>>;
10
10
  export {};
@@ -2,6 +2,7 @@ import { Game, Statistics, Timeframe } from "hive-bedrock-data";
2
2
  interface APIResponse_Base {
3
3
  duration?: number;
4
4
  status: number;
5
+ headers?: Headers;
5
6
  }
6
7
  interface APIResponse_Error {
7
8
  code: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hive-bedrock-api",
3
- "version": "2.1.3",
3
+ "version": "2.1.5",
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",