@kiminix/tp-client 1.13.0 → 1.15.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.
@@ -1,11 +1,16 @@
1
- import { ReservationStatus } from "../enum";
1
+ import { ReservationStatus, TimelineDirection } from "../enum";
2
2
  import { GetTransitionsRequest } from "../reservations/types/admin/get-available-transitions";
3
3
  import { GetByIdRequest } from "./types/admin/get-id";
4
- import { GetPageRequest } from "./types/admin/get-page";
5
4
  import { PatchStatusRequest } from "./types/admin/patch-status";
6
5
  import { Reservation } from "./types/shared";
7
6
  export declare class ReservationsAdminAPIs {
8
- static getPage({ token, page, size, direction }: GetPageRequest): Promise<Reservation[]>;
7
+ static getPage(props: {
8
+ token?: string;
9
+ page: number;
10
+ size: number;
11
+ status?: ReservationStatus;
12
+ direction?: TimelineDirection;
13
+ }): Promise<Reservation[]>;
9
14
  static getById({ token, id }: GetByIdRequest): Promise<Reservation>;
10
15
  static getAvailableTransitions({ token, reservationId }: GetTransitionsRequest): Promise<ReservationStatus[]>;
11
16
  static patchStatus({ token, id, status }: PatchStatusRequest): Promise<any>;
@@ -39,25 +39,34 @@ import { base } from "../constants";
39
39
  var ReservationsAdminAPIs = /** @class */ (function () {
40
40
  function ReservationsAdminAPIs() {
41
41
  }
42
- ReservationsAdminAPIs.getPage = function (_a) {
43
- var token = _a.token, _b = _a.page, page = _b === void 0 ? 1 : _b, _c = _a.size, size = _c === void 0 ? 10 : _c, direction = _a.direction;
42
+ ReservationsAdminAPIs.getPage = function (props) {
44
43
  return __awaiter(this, void 0, void 0, function () {
45
- return __generator(this, function (_d) {
46
- switch (_d.label) {
47
- case 0: return [4 /*yield*/, axios.get(base + "/reservations/admin?page=".concat(page, "&size=").concat(size, "&direction=").concat(direction), {
48
- headers: {
49
- 'Authorization': "".concat(token)
50
- }
51
- })
52
- .then(function (response) { return response.data; })
53
- .catch(function (error) {
54
- // handle error
55
- if (error.response.status == 401)
56
- throw new Error("unauthorized");
57
- else
58
- throw new Error('internal_error', error);
59
- })];
60
- case 1: return [2 /*return*/, _d.sent()];
44
+ var queryParams;
45
+ return __generator(this, function (_a) {
46
+ switch (_a.label) {
47
+ case 0:
48
+ queryParams = [
49
+ "page=".concat(props.page),
50
+ "size=".concat(props.size),
51
+ props.direction ? "direction=".concat(props.direction) : undefined,
52
+ props.status ? "status=".concat(props.status) : undefined
53
+ ]
54
+ .filter(function (value) { return value; })
55
+ .join("&");
56
+ return [4 /*yield*/, axios.get(base + "/reservations/admin?".concat(queryParams), {
57
+ headers: {
58
+ 'Authorization': "".concat(props.token)
59
+ }
60
+ })
61
+ .then(function (response) { return response.data; })
62
+ .catch(function (error) {
63
+ // handle error
64
+ if (error.response.status == 401)
65
+ throw new Error("unauthorized");
66
+ else
67
+ throw new Error('internal_error', error);
68
+ })];
69
+ case 1: return [2 /*return*/, _a.sent()];
61
70
  }
62
71
  });
63
72
  });
@@ -1,6 +1,18 @@
1
1
  import { CountReservationByStatusRequest, CountReservationByStatusResponse } from "./types/reservations-by-status";
2
2
  import { MenuStatisticResponse, MenusStatisticRequest } from "./types/menus-statistic";
3
+ import { CountByDay } from "./types/count-day";
4
+ import { LocalDate } from "../types";
5
+ import { ReservationStatus } from "../enum";
3
6
  export declare class StatisticsAdminAPIs {
4
7
  static countReservationByStatus({ token, date }: CountReservationByStatusRequest): Promise<CountReservationByStatusResponse[]>;
5
8
  static menusStatistic({ token, date }: MenusStatisticRequest): Promise<MenuStatisticResponse[]>;
9
+ static countReservationsByMonth(props: {
10
+ token?: string;
11
+ date: LocalDate;
12
+ status?: ReservationStatus;
13
+ }): Promise<CountByDay[]>;
14
+ static lastReservations(props: {
15
+ token?: string;
16
+ limit: number;
17
+ }): Promise<CountByDay[]>;
6
18
  }
@@ -85,6 +85,50 @@ var StatisticsAdminAPIs = /** @class */ (function () {
85
85
  });
86
86
  });
87
87
  };
88
+ StatisticsAdminAPIs.countReservationsByMonth = function (props) {
89
+ return __awaiter(this, void 0, void 0, function () {
90
+ return __generator(this, function (_a) {
91
+ switch (_a.label) {
92
+ case 0: return [4 /*yield*/, axios.get(base + "/statistics/reservations-by-month/".concat(props.date, "?").concat(props.status ? "status=".concat(props.status) : ''), {
93
+ headers: {
94
+ 'Authorization': "".concat(props.token)
95
+ }
96
+ })
97
+ .then(function (response) { return response.data; })
98
+ .catch(function (error) {
99
+ // handle error
100
+ if (error.response.status == 401)
101
+ throw new Error("unauthorized");
102
+ else
103
+ throw new Error('internal_error', error);
104
+ })];
105
+ case 1: return [2 /*return*/, _a.sent()];
106
+ }
107
+ });
108
+ });
109
+ };
110
+ StatisticsAdminAPIs.lastReservations = function (props) {
111
+ return __awaiter(this, void 0, void 0, function () {
112
+ return __generator(this, function (_a) {
113
+ switch (_a.label) {
114
+ case 0: return [4 /*yield*/, axios.get(base + "/statistics/last-reservations?limit=".concat(props.limit), {
115
+ headers: {
116
+ 'Authorization': "".concat(props.token)
117
+ }
118
+ })
119
+ .then(function (response) { return response.data; })
120
+ .catch(function (error) {
121
+ // handle error
122
+ if (error.response.status == 401)
123
+ throw new Error("unauthorized");
124
+ else
125
+ throw new Error('internal_error', error);
126
+ })];
127
+ case 1: return [2 /*return*/, _a.sent()];
128
+ }
129
+ });
130
+ });
131
+ };
88
132
  return StatisticsAdminAPIs;
89
133
  }());
90
134
  export { StatisticsAdminAPIs };
@@ -0,0 +1,5 @@
1
+ import { LocalDate } from "../../types";
2
+ export interface CountByDay {
3
+ day: LocalDate;
4
+ count: number;
5
+ }
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kiminix/tp-client",
3
- "version": "1.13.0",
3
+ "version": "1.15.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [