@escapenavigator/services 1.10.115 → 1.10.117

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,8 +1,7 @@
1
- import { DashboardQueryDto } from '@escapenavigator/types/dist/statistics/pnl';
2
- import { PromocodesReportRO } from '@escapenavigator/types/dist/statistics/promocodes';
1
+ import { PromocodesQueryDto, PromocodesReportRO } from '@escapenavigator/types/dist/statistics/promocodes';
3
2
  import { ApiMethodDeclaration } from '..';
4
3
  type ParamsData = {
5
- data: DashboardQueryDto;
4
+ data: PromocodesQueryDto;
6
5
  };
7
6
  type ResponseData = PromocodesReportRO;
8
7
  export declare const promocodesReport: ApiMethodDeclaration<ParamsData, ResponseData>;
@@ -63,39 +63,56 @@ var useApiMethod = function (_a) {
63
63
  successCallbackRef.current = successCallback;
64
64
  errorCallbackRef.current = errorCallback;
65
65
  var fetch = (0, react_1.useCallback)(function (params) { return __awaiter(void 0, void 0, void 0, function () {
66
- var response, error_1, err;
67
- var _a;
68
- return __generator(this, function (_b) {
69
- switch (_b.label) {
66
+ var response, error_1, text, _a, err;
67
+ var _b, _c, _d, _e;
68
+ return __generator(this, function (_f) {
69
+ switch (_f.label) {
70
70
  case 0:
71
- (_a = source.current) === null || _a === void 0 ? void 0 : _a.cancel();
71
+ (_b = source.current) === null || _b === void 0 ? void 0 : _b.cancel();
72
72
  source.current = axios_1.default.CancelToken.source();
73
- _b.label = 1;
73
+ _f.label = 1;
74
74
  case 1:
75
- _b.trys.push([1, 3, , 4]);
75
+ _f.trys.push([1, 3, , 8]);
76
76
  dispatch((0, api_1.fetchStart)());
77
77
  return [4 /*yield*/, api(params, {
78
78
  cancelToken: source.current.token,
79
79
  })];
80
80
  case 2:
81
- response = _b.sent();
81
+ response = _f.sent();
82
82
  if (successCallbackRef.current)
83
83
  successCallbackRef.current(response, params);
84
84
  dispatch((0, api_1.fetchSuccess)(response));
85
85
  return [2 /*return*/, response];
86
86
  case 3:
87
- error_1 = _b.sent();
87
+ error_1 = _f.sent();
88
88
  if (axios_1.default.isCancel(error_1))
89
89
  return [2 /*return*/, null];
90
90
  if (!mounted.current)
91
91
  return [2 /*return*/, null];
92
+ if (!(axios_1.default.isAxiosError(error_1) &&
93
+ ((_c = error_1.response) === null || _c === void 0 ? void 0 : _c.data) instanceof Blob &&
94
+ (((_d = error_1.response.data.type) === null || _d === void 0 ? void 0 : _d.includes('application/json')) ||
95
+ ((_e = error_1.response.data.type) === null || _e === void 0 ? void 0 : _e.includes('application/problem+json'))))) return [3 /*break*/, 7];
96
+ _f.label = 4;
97
+ case 4:
98
+ _f.trys.push([4, 6, , 7]);
99
+ return [4 /*yield*/, error_1.response.data.text()];
100
+ case 5:
101
+ text = _f.sent();
102
+ // Перетираем `data` — getServiceError рассчитывает на объект.
103
+ error_1.response.data = JSON.parse(text);
104
+ return [3 /*break*/, 7];
105
+ case 6:
106
+ _a = _f.sent();
107
+ return [3 /*break*/, 7];
108
+ case 7:
92
109
  err = (0, get_service_error_1.getServiceError)(error_1);
93
110
  if (errorCallbackRef.current)
94
111
  errorCallbackRef.current(err);
95
112
  dispatch((0, api_1.fetchFailure)(err));
96
113
  // eslint-disable-next-line @typescript-eslint/no-throw-literal
97
114
  throw err;
98
- case 4: return [2 /*return*/];
115
+ case 8: return [2 /*return*/];
99
116
  }
100
117
  });
101
118
  }); }, [api]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@escapenavigator/services",
3
- "version": "1.10.115",
3
+ "version": "1.10.117",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -12,10 +12,10 @@
12
12
  "scripts": {
13
13
  "build": "rm -rf dist && tsc --project tsconfig.json"
14
14
  },
15
- "gitHead": "1224f2af8858d8339e46d67041b7cbbce5dc7920",
15
+ "gitHead": "d95804850eb38fdcf09cf48ef4bfcdf933c53e88",
16
16
  "dependencies": {
17
- "@escapenavigator/types": "^1.10.106",
18
- "@escapenavigator/utils": "^1.10.110",
17
+ "@escapenavigator/types": "^1.10.108",
18
+ "@escapenavigator/utils": "^1.10.112",
19
19
  "axios": "^0.21.4",
20
20
  "class-transformer": "^0.5.1",
21
21
  "class-validator": "^0.13.2",