@escapenavigator/services 1.2.7 → 1.4.2
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/README.md +1 -1
- package/dist/api/admins-api/get-profile-token.js +3 -3
- package/dist/api/admins-api/index.js +4 -4
- package/dist/api/admins-api/login.js +8 -5
- package/dist/api/admins-api/logout.js +2 -2
- package/dist/api/admins-api/me.js +2 -2
- package/dist/api/agb-api/get-one.js +3 -3
- package/dist/api/agb-api/index.js +2 -2
- package/dist/api/agb-api/update.js +8 -5
- package/dist/api/agregator-api/find-cities-by-country.d.ts +7 -0
- package/dist/api/agregator-api/find-cities-by-country.js +8 -0
- package/dist/api/agregator-api/find-city-by-slug.d.ts +6 -0
- package/dist/api/agregator-api/find-city-by-slug.js +8 -0
- package/dist/api/agregator-api/find-current-city.d.ts +6 -0
- package/dist/api/agregator-api/find-current-city.js +8 -0
- package/dist/api/agregator-api/find-locations-by-coordinates.d.ts +6 -0
- package/dist/api/agregator-api/find-locations-by-coordinates.js +8 -0
- package/dist/api/agregator-api/find-popular-cities-near.d.ts +6 -0
- package/dist/api/agregator-api/find-popular-cities-near.js +8 -0
- package/dist/api/agregator-api/find-questrooms-by-city-slug.d.ts +6 -0
- package/dist/api/agregator-api/find-questrooms-by-city-slug.js +8 -0
- package/dist/api/agregator-api/find-questrooms-by-location-id.d.ts +6 -0
- package/dist/api/agregator-api/find-questrooms-by-location-id.js +8 -0
- package/dist/api/agregator-api/find-questrooms-by-organization-id.d.ts +6 -0
- package/dist/api/agregator-api/find-questrooms-by-organization-id.js +8 -0
- package/dist/api/agregator-api/find-questrooms-by-tag.d.ts +6 -0
- package/dist/api/agregator-api/find-questrooms-by-tag.js +8 -0
- package/dist/api/agregator-api/find-questrooms-by-title.d.ts +6 -0
- package/dist/api/agregator-api/find-questrooms-by-title.js +8 -0
- package/dist/api/agregator-api/find-similar-questrooms.d.ts +6 -0
- package/dist/api/agregator-api/find-similar-questrooms.js +8 -0
- package/dist/api/agregator-api/index.d.ts +26 -0
- package/dist/api/agregator-api/index.js +27 -0
- package/dist/api/cashboxes-api/create.js +8 -5
- package/dist/api/cashboxes-api/get-one.js +3 -3
- package/dist/api/cashboxes-api/index.js +5 -5
- package/dist/api/cashboxes-api/query.js +2 -2
- package/dist/api/cashboxes-api/recover.js +3 -3
- package/dist/api/cashboxes-api/remove.js +3 -3
- package/dist/api/cashboxes-api/update.js +8 -5
- package/dist/api/certificates-api/create.js +8 -5
- package/dist/api/certificates-api/get-one.js +3 -3
- package/dist/api/certificates-api/index.js +6 -6
- package/dist/api/certificates-api/query.js +2 -2
- package/dist/api/certificates-api/recover.js +3 -3
- package/dist/api/certificates-api/remove.js +3 -3
- package/dist/api/certificates-api/update.js +8 -5
- package/dist/api/certificatesales-api/annul.js +8 -5
- package/dist/api/certificatesales-api/create.js +8 -5
- package/dist/api/certificatesales-api/get-one-by-code.js +3 -3
- package/dist/api/certificatesales-api/get-one.js +3 -3
- package/dist/api/certificatesales-api/index.js +9 -9
- package/dist/api/certificatesales-api/paginate.js +3 -3
- package/dist/api/certificatesales-api/query.js +3 -3
- package/dist/api/certificatesales-api/update-expire-date.js +8 -5
- package/dist/api/certificatesales-api/update-status.js +8 -5
- package/dist/api/certificatesales-api/update.js +8 -5
- package/dist/api/cities-api/get-one.js +3 -3
- package/dist/api/cities-api/index.d.ts +0 -8
- package/dist/api/cities-api/index.js +3 -11
- package/dist/api/cities-api/query.js +3 -3
- package/dist/api/cities-api/remove.js +3 -3
- package/dist/api/cities-api/update.js +8 -5
- package/dist/api/clients-api/create-from-widget.js +8 -5
- package/dist/api/clients-api/create.js +8 -5
- package/dist/api/clients-api/get-all.js +3 -3
- package/dist/api/clients-api/get-one.js +3 -3
- package/dist/api/clients-api/index.js +6 -6
- package/dist/api/clients-api/query.js +3 -3
- package/dist/api/clients-api/update.js +8 -5
- package/dist/api/emails-api/index.js +1 -1
- package/dist/api/emails-api/query.js +3 -3
- package/dist/api/financeitems-api/create.js +8 -5
- package/dist/api/financeitems-api/get-all.js +3 -3
- package/dist/api/financeitems-api/get-one.js +3 -3
- package/dist/api/financeitems-api/index.js +5 -5
- package/dist/api/financeitems-api/query.js +3 -3
- package/dist/api/financeitems-api/remove.js +3 -3
- package/dist/api/images-api/create.js +8 -5
- package/dist/api/images-api/index.js +1 -1
- package/dist/api/index.js +71 -20
- package/dist/api/init-client-api.js +33 -33
- package/dist/api/locations-api/create.js +8 -5
- package/dist/api/locations-api/get-by-coordinates.js +3 -3
- package/dist/api/locations-api/get-one.js +3 -3
- package/dist/api/locations-api/index.js +7 -7
- package/dist/api/locations-api/query.js +3 -3
- package/dist/api/locations-api/recover.js +3 -3
- package/dist/api/locations-api/remove.js +3 -3
- package/dist/api/locations-api/update.js +8 -5
- package/dist/api/order-discounts-api/create.js +8 -5
- package/dist/api/order-discounts-api/index.js +2 -2
- package/dist/api/order-discounts-api/remove.js +3 -3
- package/dist/api/order-penalties-api/create.js +8 -5
- package/dist/api/order-penalties-api/index.js +2 -2
- package/dist/api/order-penalties-api/remove.js +3 -3
- package/dist/api/order-upsellings-api/create.js +8 -5
- package/dist/api/order-upsellings-api/index.js +2 -2
- package/dist/api/order-upsellings-api/remove.js +3 -3
- package/dist/api/orders-api/add-certificate.js +8 -5
- package/dist/api/orders-api/create-from-widget.js +8 -5
- package/dist/api/orders-api/create.js +8 -5
- package/dist/api/orders-api/get-one.js +3 -3
- package/dist/api/orders-api/index.js +11 -11
- package/dist/api/orders-api/paginate.js +3 -3
- package/dist/api/orders-api/query.js +3 -3
- package/dist/api/orders-api/remove-certificate.js +8 -5
- package/dist/api/orders-api/remove.js +3 -3
- package/dist/api/orders-api/update-slot.js +8 -5
- package/dist/api/orders-api/update-status.js +8 -5
- package/dist/api/orders-api/update.js +8 -5
- package/dist/api/partners-api/create.js +8 -5
- package/dist/api/partners-api/get-all.js +3 -3
- package/dist/api/partners-api/get-one.js +3 -3
- package/dist/api/partners-api/index.js +7 -7
- package/dist/api/partners-api/query.js +3 -3
- package/dist/api/partners-api/recover.js +3 -3
- package/dist/api/partners-api/remove.js +3 -3
- package/dist/api/partners-api/update.js +8 -5
- package/dist/api/profiles-api/create.js +8 -5
- package/dist/api/profiles-api/current.js +2 -2
- package/dist/api/profiles-api/get-by-slug.js +3 -3
- package/dist/api/profiles-api/get-one.js +3 -3
- package/dist/api/profiles-api/index.js +7 -7
- package/dist/api/profiles-api/query.js +3 -3
- package/dist/api/profiles-api/remove.js +3 -3
- package/dist/api/profiles-api/update-current.js +8 -5
- package/dist/api/profiles-api/update.js +8 -5
- package/dist/api/questrooms-api/create.js +8 -5
- package/dist/api/questrooms-api/get-by-coordinates.js +3 -3
- package/dist/api/questrooms-api/get-by-location.js +3 -3
- package/dist/api/questrooms-api/get-by-slug.js +3 -3
- package/dist/api/questrooms-api/get-by-title.js +3 -3
- package/dist/api/questrooms-api/get-one.js +3 -3
- package/dist/api/questrooms-api/index.js +9 -9
- package/dist/api/questrooms-api/query.js +3 -3
- package/dist/api/questrooms-api/recover.js +3 -3
- package/dist/api/questrooms-api/remove.js +3 -3
- package/dist/api/questrooms-api/update.js +8 -5
- package/dist/api/registration-requests-api/create.js +8 -5
- package/dist/api/registration-requests-api/get-one.js +3 -3
- package/dist/api/registration-requests-api/index.js +5 -5
- package/dist/api/registration-requests-api/query.js +3 -3
- package/dist/api/registration-requests-api/remove.js +3 -3
- package/dist/api/registration-requests-api/update.js +8 -5
- package/dist/api/roles-api/create.js +8 -5
- package/dist/api/roles-api/get-one.js +3 -3
- package/dist/api/roles-api/index.js +5 -5
- package/dist/api/roles-api/query.js +3 -3
- package/dist/api/roles-api/remove.js +3 -3
- package/dist/api/roles-api/update.js +8 -5
- package/dist/api/slot-templates-api/get.js +3 -3
- package/dist/api/slot-templates-api/index.js +2 -2
- package/dist/api/slot-templates-api/update.js +8 -5
- package/dist/api/slots-api/add-breaks.js +8 -5
- package/dist/api/slots-api/add-or-remove-break.js +8 -5
- package/dist/api/slots-api/calendar.js +3 -3
- package/dist/api/slots-api/create.js +8 -5
- package/dist/api/slots-api/daily.js +3 -3
- package/dist/api/slots-api/index.js +8 -8
- package/dist/api/slots-api/remove-breaks.js +8 -5
- package/dist/api/slots-api/remove.js +3 -3
- package/dist/api/slots-api/weekly.js +3 -3
- package/dist/api/support/create.js +8 -5
- package/dist/api/support/index.js +1 -1
- package/dist/api/tariffs-api/create.js +8 -5
- package/dist/api/tariffs-api/get-one.js +3 -3
- package/dist/api/tariffs-api/index.js +5 -5
- package/dist/api/tariffs-api/query.js +3 -3
- package/dist/api/tariffs-api/remove.js +3 -3
- package/dist/api/tariffs-api/update.js +8 -5
- package/dist/api/transactions-api/create-certificate-payment.js +8 -5
- package/dist/api/transactions-api/create-certificate-refund.js +8 -5
- package/dist/api/transactions-api/create-order-payment.js +8 -5
- package/dist/api/transactions-api/create-order-refund.js +8 -5
- package/dist/api/transactions-api/create.js +8 -5
- package/dist/api/transactions-api/get-one.js +3 -3
- package/dist/api/transactions-api/index.js +13 -13
- package/dist/api/transactions-api/query.js +3 -3
- package/dist/api/transactions-api/remove-certificate-payment.js +3 -3
- package/dist/api/transactions-api/remove-certificate-refund.js +3 -3
- package/dist/api/transactions-api/remove-order-payment.js +3 -3
- package/dist/api/transactions-api/remove-order-refund.js +3 -3
- package/dist/api/transactions-api/remove.js +3 -3
- package/dist/api/transactions-api/update.js +8 -5
- package/dist/api/uploads-api/index.js +1 -1
- package/dist/api/uploads-api/upload-image.js +12 -9
- package/dist/api/upsellings-api/create.js +8 -5
- package/dist/api/upsellings-api/get-one.js +3 -3
- package/dist/api/upsellings-api/index.js +5 -5
- package/dist/api/upsellings-api/query.js +3 -3
- package/dist/api/upsellings-api/remove.js +3 -3
- package/dist/api/upsellings-api/update.js +8 -5
- package/dist/api/user-messages-api/create.js +8 -5
- package/dist/api/user-messages-api/get-one.js +3 -3
- package/dist/api/user-messages-api/index.js +4 -4
- package/dist/api/user-messages-api/query.js +3 -3
- package/dist/api/user-messages-api/remove.js +3 -3
- package/dist/api/users-api/check-token.js +7 -4
- package/dist/api/users-api/create.js +8 -5
- package/dist/api/users-api/current-update-password.js +8 -5
- package/dist/api/users-api/current-update.js +8 -5
- package/dist/api/users-api/get-one.js +3 -3
- package/dist/api/users-api/index.js +15 -15
- package/dist/api/users-api/login.js +8 -5
- package/dist/api/users-api/logout.js +2 -2
- package/dist/api/users-api/me.js +2 -2
- package/dist/api/users-api/query.js +3 -3
- package/dist/api/users-api/recover.js +3 -3
- package/dist/api/users-api/remove.js +3 -3
- package/dist/api/users-api/send-invite.js +3 -3
- package/dist/api/users-api/send-recover-link.js +3 -3
- package/dist/api/users-api/update-password.js +8 -5
- package/dist/api/users-api/update.js +8 -5
- package/dist/api/widgets-api/create.js +8 -5
- package/dist/api/widgets-api/get-one.js +3 -3
- package/dist/api/widgets-api/index.js +5 -5
- package/dist/api/widgets-api/query.js +3 -3
- package/dist/api/widgets-api/remove.js +3 -3
- package/dist/api/widgets-api/update.js +8 -5
- package/dist/api/widgets-openapi/create-certificate.d.ts +9 -0
- package/dist/api/widgets-openapi/create-certificate.js +12 -0
- package/dist/api/widgets-openapi/create-order.d.ts +9 -0
- package/dist/api/widgets-openapi/create-order.js +12 -0
- package/dist/api/widgets-openapi/find-certificate.d.ts +6 -0
- package/dist/api/widgets-openapi/find-certificate.js +8 -0
- package/dist/api/widgets-openapi/get-widget-info.js +3 -3
- package/dist/api/widgets-openapi/index.d.ts +6 -0
- package/dist/api/widgets-openapi/index.js +9 -3
- package/dist/api/widgets-openapi/widget-daily.js +3 -3
- package/dist/api/widgets-openapi/widget-weekly.d.ts +2 -2
- package/dist/api/widgets-openapi/widget-weekly.js +3 -3
- package/dist/hooks/use-api-method/actions/creators/api.js +9 -9
- package/dist/hooks/use-api-method/index.js +83 -43
- package/dist/hooks/use-api-method/reducers/api.js +17 -5
- package/dist/utils/convert-to-options.js +3 -3
- package/dist/utils/define-status.js +4 -4
- package/dist/utils/enum-to-options.js +3 -3
- package/dist/utils/get-handled-error-message.js +1 -1
- package/dist/utils/get-many.js +4 -3
- package/dist/utils/get-one.js +3 -2
- package/dist/utils/get-service-error.js +18 -17
- package/dist/utils/is-network-error.js +3 -3
- package/dist/utils/redirect.js +1 -1
- package/dist/utils/serialize-record.js +4 -2
- package/dist/utils/validate-by-dto.js +8 -7
- package/package.json +4 -4
- package/dist/api/cities-api/get-cities-by-country.d.ts +0 -7
- package/dist/api/cities-api/get-cities-by-country.js +0 -8
- package/dist/api/cities-api/get-city-by-ip.d.ts +0 -6
- package/dist/api/cities-api/get-city-by-ip.js +0 -8
- package/dist/api/cities-api/get-city-by-slug.d.ts +0 -6
- package/dist/api/cities-api/get-city-by-slug.js +0 -8
- package/dist/api/cities-api/get-popular-cities-near.d.ts +0 -6
- package/dist/api/cities-api/get-popular-cities-near.js +0 -8
|
@@ -8,60 +8,100 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
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;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "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 (_) 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
|
+
};
|
|
11
38
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
40
|
};
|
|
14
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
42
|
exports.useApiMethod = void 0;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
var react_1 = require("react");
|
|
44
|
+
var axios_1 = __importDefault(require("axios"));
|
|
45
|
+
var get_service_error_1 = require("../../utils/get-service-error");
|
|
46
|
+
var api_1 = require("./actions/creators/api");
|
|
47
|
+
var api_2 = require("./reducers/api");
|
|
48
|
+
var useApiMethod = function (_a) {
|
|
49
|
+
var _b;
|
|
50
|
+
var api = _a.api, successCallback = _a.successCallback, errorCallback = _a.errorCallback, delay = _a.delay;
|
|
51
|
+
var mounted = (0, react_1.useRef)(false);
|
|
52
|
+
var source = (0, react_1.useRef)(null);
|
|
53
|
+
var _c = (0, react_1.useReducer)(api_2.apiReducer, api_2.initialState), state = _c[0], dispatch = _c[1];
|
|
54
|
+
var fetch = (0, react_1.useCallback)(function (params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
55
|
+
var startTime, response_1, deltaTime, delta, error_1, err;
|
|
56
|
+
return __generator(this, function (_a) {
|
|
57
|
+
switch (_a.label) {
|
|
58
|
+
case 0:
|
|
59
|
+
source.current = axios_1.default.CancelToken.source();
|
|
60
|
+
startTime = Date.now();
|
|
61
|
+
_a.label = 1;
|
|
62
|
+
case 1:
|
|
63
|
+
_a.trys.push([1, 3, , 4]);
|
|
64
|
+
dispatch((0, api_1.fetchStart)());
|
|
65
|
+
return [4 /*yield*/, api(params)];
|
|
66
|
+
case 2:
|
|
67
|
+
response_1 = _a.sent();
|
|
68
|
+
deltaTime = Date.now() - startTime;
|
|
69
|
+
delta = delay && deltaTime < delay ? 500 - deltaTime : 0;
|
|
70
|
+
setTimeout(function () {
|
|
71
|
+
if (successCallback)
|
|
72
|
+
successCallback(response_1);
|
|
73
|
+
dispatch((0, api_1.fetchSuccess)(response_1));
|
|
74
|
+
}, delta);
|
|
75
|
+
return [3 /*break*/, 4];
|
|
76
|
+
case 3:
|
|
77
|
+
error_1 = _a.sent();
|
|
78
|
+
if (!mounted.current)
|
|
79
|
+
return [2 /*return*/];
|
|
80
|
+
err = (0, get_service_error_1.getServiceError)(error_1);
|
|
81
|
+
if (errorCallback)
|
|
82
|
+
errorCallback(err);
|
|
83
|
+
dispatch((0, api_1.fetchFailure)(err));
|
|
84
|
+
throw error_1;
|
|
85
|
+
case 4: return [2 /*return*/];
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}); }, [api, successCallback, errorCallback, delay]);
|
|
89
|
+
(0, react_1.useEffect)(function () {
|
|
50
90
|
mounted.current = true;
|
|
51
|
-
return ()
|
|
91
|
+
return function () {
|
|
52
92
|
var _a;
|
|
53
93
|
mounted.current = false;
|
|
54
94
|
(_a = source.current) === null || _a === void 0 ? void 0 : _a.cancel();
|
|
55
95
|
};
|
|
56
96
|
}, [mounted]);
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
[
|
|
60
|
-
[
|
|
61
|
-
[
|
|
62
|
-
[
|
|
63
|
-
[
|
|
64
|
-
|
|
97
|
+
var name = api.displayName;
|
|
98
|
+
var res = (_b = {},
|
|
99
|
+
_b["".concat(name, "Fetch")] = fetch,
|
|
100
|
+
_b["".concat(name, "Data")] = state.data,
|
|
101
|
+
_b["".concat(name, "Loading")] = state.loading,
|
|
102
|
+
_b["".concat(name, "Error")] = state.error,
|
|
103
|
+
_b["".concat(name, "StatusOk")] = state.statusOk,
|
|
104
|
+
_b);
|
|
65
105
|
return res;
|
|
66
106
|
};
|
|
67
107
|
exports.useApiMethod = useApiMethod;
|
|
@@ -1,7 +1,18 @@
|
|
|
1
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
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
14
|
exports.apiReducer = exports.initialState = void 0;
|
|
4
|
-
|
|
15
|
+
var api_1 = require("../actions/types/api");
|
|
5
16
|
exports.initialState = {
|
|
6
17
|
data: null,
|
|
7
18
|
loading: false,
|
|
@@ -9,14 +20,15 @@ exports.initialState = {
|
|
|
9
20
|
response: null,
|
|
10
21
|
statusOk: null,
|
|
11
22
|
};
|
|
12
|
-
|
|
23
|
+
var apiReducer = function (state, action) {
|
|
24
|
+
if (state === void 0) { state = exports.initialState; }
|
|
13
25
|
switch (action.type) {
|
|
14
26
|
case api_1.ActionTypes.FETCH_START:
|
|
15
|
-
return
|
|
27
|
+
return __assign(__assign({}, exports.initialState), { loading: true });
|
|
16
28
|
case api_1.ActionTypes.FETCH_SUCCESS:
|
|
17
|
-
return
|
|
29
|
+
return __assign(__assign({}, state), { loading: false, data: action.payload.response.data, response: action.payload.response, statusOk: true });
|
|
18
30
|
case api_1.ActionTypes.FETCH_FAILURE:
|
|
19
|
-
return
|
|
31
|
+
return __assign(__assign({}, state), { loading: false, error: action.payload.error, statusOk: false });
|
|
20
32
|
default:
|
|
21
33
|
return state;
|
|
22
34
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.convertToOptions = void 0;
|
|
4
|
-
|
|
4
|
+
var convertToOptions = function (data, field) { return data.map(function (item) { return ({
|
|
5
5
|
key: item.id,
|
|
6
|
-
content: (field && item[field]) || item.title || item.name,
|
|
7
|
-
}));
|
|
6
|
+
content: (field && item[field]) || item.title || item.surname ? "".concat(item.name, " ").concat(item.surname) : item.name,
|
|
7
|
+
}); }); };
|
|
8
8
|
exports.convertToOptions = convertToOptions;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.defineStatusForOrder = exports.defineStatusForCertificate = void 0;
|
|
4
|
-
|
|
4
|
+
var defineStatusForCertificate = function (t) { return ({
|
|
5
5
|
new: {
|
|
6
6
|
view: 'accent',
|
|
7
7
|
text: t('statusComponent.new'),
|
|
@@ -26,9 +26,9 @@ const defineStatusForCertificate = (t) => ({
|
|
|
26
26
|
view: 'negative',
|
|
27
27
|
text: t('statusComponent.expired'),
|
|
28
28
|
},
|
|
29
|
-
});
|
|
29
|
+
}); };
|
|
30
30
|
exports.defineStatusForCertificate = defineStatusForCertificate;
|
|
31
|
-
|
|
31
|
+
var defineStatusForOrder = function (t) { return ({
|
|
32
32
|
new: {
|
|
33
33
|
view: 'accent',
|
|
34
34
|
text: t('statusComponent.new'),
|
|
@@ -53,5 +53,5 @@ const defineStatusForOrder = (t) => ({
|
|
|
53
53
|
view: 'negative',
|
|
54
54
|
text: t('statusComponent.failed_payment'),
|
|
55
55
|
},
|
|
56
|
-
});
|
|
56
|
+
}); };
|
|
57
57
|
exports.defineStatusForOrder = defineStatusForOrder;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.enumToOptions = void 0;
|
|
4
|
-
|
|
4
|
+
var enumToOptions = function (options, t, modelName) { return Object.values(options).map(function (option) { return ({
|
|
5
5
|
key: option,
|
|
6
|
-
content: t(
|
|
7
|
-
}));
|
|
6
|
+
content: t("options.".concat(modelName, ".").concat(option)),
|
|
7
|
+
}); }); };
|
|
8
8
|
exports.enumToOptions = enumToOptions;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getHandledErrorMessage = void 0;
|
|
4
|
-
|
|
4
|
+
var getHandledErrorMessage = function (error) { return (error.response ? error.response.data.message : error.message); };
|
|
5
5
|
exports.getHandledErrorMessage = getHandledErrorMessage;
|
package/dist/utils/get-many.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getMany = void 0;
|
|
4
|
-
function getMany(ids, records, field
|
|
4
|
+
function getMany(ids, records, field) {
|
|
5
|
+
if (field === void 0) { field = 'title'; }
|
|
5
6
|
if (!Array.isArray(ids) || !Array.isArray(records))
|
|
6
7
|
return null;
|
|
7
|
-
|
|
8
|
+
var filtred = records.filter(function (r) { return ids.includes(r.id); });
|
|
8
9
|
if (!filtred.length)
|
|
9
10
|
return null;
|
|
10
|
-
return filtred.map((r)
|
|
11
|
+
return filtred.map(function (r) { return r[field] || r.title; });
|
|
11
12
|
}
|
|
12
13
|
exports.getMany = getMany;
|
package/dist/utils/get-one.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getOne = void 0;
|
|
4
|
-
function getOne(id, records, field
|
|
4
|
+
function getOne(id, records, field) {
|
|
5
|
+
if (field === void 0) { field = 'title'; }
|
|
5
6
|
if (!id || !Array.isArray(records))
|
|
6
7
|
return null;
|
|
7
|
-
|
|
8
|
+
var record = records.filter(function (r) { return r.id === id; })[0];
|
|
8
9
|
if (!record)
|
|
9
10
|
return null;
|
|
10
11
|
return record[field] || record.title;
|
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var _a, _b;
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
4
|
exports.getServiceError = exports.ErrorType = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
var is_axios_error_1 = require("./is-axios-error");
|
|
6
|
+
var is_network_error_1 = require("./is-network-error");
|
|
6
7
|
var ErrorType;
|
|
7
8
|
(function (ErrorType) {
|
|
8
9
|
ErrorType["NETWORK"] = "NETWORK";
|
|
9
10
|
ErrorType["BUSINESS"] = "BUSINESS";
|
|
10
11
|
ErrorType["INTERNAL"] = "INTERNAL";
|
|
11
12
|
})(ErrorType = exports.ErrorType || (exports.ErrorType = {}));
|
|
12
|
-
|
|
13
|
-
[ErrorType.INTERNAL]
|
|
14
|
-
[ErrorType.NETWORK]
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
[ErrorType.INTERNAL]
|
|
18
|
-
[ErrorType.NETWORK]
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
var ERROR_CODES = (_a = {},
|
|
14
|
+
_a[ErrorType.INTERNAL] = 'INTERNAL_ERROR',
|
|
15
|
+
_a[ErrorType.NETWORK] = 'NETWORK_ERROR',
|
|
16
|
+
_a);
|
|
17
|
+
var ERROR_MESSAGES = (_b = {},
|
|
18
|
+
_b[ErrorType.INTERNAL] = 'Пожалуйста, попробуйте ещё раз позже.',
|
|
19
|
+
_b[ErrorType.NETWORK] = 'Проверьте подключение и попробуйте ещё раз позже.',
|
|
20
|
+
_b);
|
|
21
|
+
var INTERNAL_SERVICE_ERROR_CODES = [
|
|
21
22
|
'BAD_REQUEST',
|
|
22
23
|
'INTERNAL_SERVER_ERROR',
|
|
23
24
|
'INTERNAL_ERROR',
|
|
@@ -38,9 +39,9 @@ function getServiceError(error) {
|
|
|
38
39
|
};
|
|
39
40
|
}
|
|
40
41
|
if ((0, is_axios_error_1.isAxiosError)(error)) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
var _a = error.response.data, errorCode = _a.errorCode, originalErrorCode = _a.originalErrorCode, message = _a.message;
|
|
43
|
+
var code = errorCode;
|
|
44
|
+
var errorType = ErrorType.BUSINESS;
|
|
44
45
|
if (INTERNAL_SERVICE_ERROR_CODES.includes(code)) {
|
|
45
46
|
if (typeof originalErrorCode === 'undefined') {
|
|
46
47
|
errorType = ErrorType.INTERNAL;
|
|
@@ -50,9 +51,9 @@ function getServiceError(error) {
|
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
53
|
return {
|
|
53
|
-
code,
|
|
54
|
-
message,
|
|
55
|
-
errorType,
|
|
54
|
+
code: code,
|
|
55
|
+
message: message,
|
|
56
|
+
errorType: errorType,
|
|
56
57
|
originalError: error,
|
|
57
58
|
};
|
|
58
59
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isNetworkError = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
var is_axios_error_1 = require("./is-axios-error");
|
|
5
|
+
var NETWORK_ERROR_CODES = ['ENETUNREACH', 'ECONNABORTED', 'ENOTCONN'];
|
|
6
6
|
/**
|
|
7
7
|
* Возвращает `true`, если ошибка возникла из-за проблем с интернетом
|
|
8
8
|
* @param error Ошибка от сервиса
|
|
9
9
|
*/
|
|
10
10
|
function isNetworkError(error) {
|
|
11
11
|
if ((0, is_axios_error_1.isAxiosError)(error)) {
|
|
12
|
-
|
|
12
|
+
var response = error.response, code = error.code, message = error.message;
|
|
13
13
|
return (typeof response === 'undefined' &&
|
|
14
14
|
(NETWORK_ERROR_CODES.includes(code) || message === 'Network Error'));
|
|
15
15
|
}
|
package/dist/utils/redirect.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.serializeRecord = void 0;
|
|
4
|
-
|
|
4
|
+
var class_transformer_1 = require("class-transformer");
|
|
5
5
|
// export const serializeRecord = <T extends ClassConstructor<unknown>>(Dto: T, data): T =>
|
|
6
6
|
// plainToClass(Dto, data, { strategy: 'excludeAll' }) as unknown as T;
|
|
7
|
-
|
|
7
|
+
var serializeRecord = function (Dto, data) {
|
|
8
|
+
return (0, class_transformer_1.plainToClass)(Dto, data, { strategy: 'excludeAll' });
|
|
9
|
+
};
|
|
8
10
|
exports.serializeRecord = serializeRecord;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.validateByDto = void 0;
|
|
4
|
-
|
|
4
|
+
var class_validator_1 = require("class-validator");
|
|
5
5
|
function validateByDto(t) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return Object.fromEntries(errors.map((
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
var validate = function (data) {
|
|
7
|
+
var errors = (0, class_validator_1.validateSync)(typeof data === 'object' ? data : {});
|
|
8
|
+
return Object.fromEntries(errors.map(function (_a) {
|
|
9
|
+
var property = _a.property, constraints = _a.constraints;
|
|
10
|
+
var err = (constraints === null || constraints === void 0 ? void 0 : constraints.IsNotEmpty) || Object.values(constraints)[0];
|
|
11
|
+
var errorText = err.substr(err.indexOf(' ') + 1);
|
|
12
|
+
return [property, "".concat(t("validationErrors.".concat(errorText)))];
|
|
12
13
|
}));
|
|
13
14
|
};
|
|
14
15
|
return validate;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@escapenavigator/services",
|
|
3
|
-
"version": "1.2
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
"dist"
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
13
|
-
"build": "rm -rf dist && tsc --project tsconfig.
|
|
13
|
+
"build": "rm -rf dist && tsc --project tsconfig.json"
|
|
14
14
|
},
|
|
15
|
-
"gitHead": "
|
|
15
|
+
"gitHead": "5f91449a5bddf892253dafeba5751354a0e7aff3",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@escapenavigator/types": "^1.2
|
|
17
|
+
"@escapenavigator/types": "^1.4.2",
|
|
18
18
|
"axios": "^0.21.4",
|
|
19
19
|
"class-transformer": "^0.5.1",
|
|
20
20
|
"class-validator": "^0.13.1",
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { CountriesEnum } from '@escapenavigator/types/dist/shared/enum/countries.enum';
|
|
2
|
-
import { CityResponseObject } from '@escapenavigator/types/dist/city/city.ro';
|
|
3
|
-
import { ApiMethodDeclaration } from '..';
|
|
4
|
-
declare type ParamsData = CountriesEnum;
|
|
5
|
-
declare type ResponseData = CityResponseObject[];
|
|
6
|
-
export declare const getCitiesByCountry: ApiMethodDeclaration<ParamsData, ResponseData>;
|
|
7
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCitiesByCountry = void 0;
|
|
4
|
-
const getCitiesByCountry = (country) => ({
|
|
5
|
-
url: '/cities/country/' + country,
|
|
6
|
-
method: 'GET'
|
|
7
|
-
});
|
|
8
|
-
exports.getCitiesByCountry = getCitiesByCountry;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { CityResponseObject } from '@escapenavigator/types/dist/city/city.ro';
|
|
2
|
-
import { ApiMethodDeclaration } from '..';
|
|
3
|
-
declare type ParamsData = string;
|
|
4
|
-
declare type ResponseData = CityResponseObject;
|
|
5
|
-
export declare const getCityByIp: ApiMethodDeclaration<ParamsData, ResponseData>;
|
|
6
|
-
export {};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { CityResponseObject } from '@escapenavigator/types/dist/city/city.ro';
|
|
2
|
-
import { ApiMethodDeclaration } from '..';
|
|
3
|
-
declare type ParamsData = string;
|
|
4
|
-
declare type ResponseData = CityResponseObject;
|
|
5
|
-
export declare const getCityBySlug: ApiMethodDeclaration<ParamsData, ResponseData>;
|
|
6
|
-
export {};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { CityResponseObject } from '@escapenavigator/types/dist/city/city.ro';
|
|
2
|
-
import { ApiMethodDeclaration } from '..';
|
|
3
|
-
declare type ParamsData = string;
|
|
4
|
-
declare type ResponseData = CityResponseObject[];
|
|
5
|
-
export declare const getPopularCitiesNear: ApiMethodDeclaration<ParamsData, ResponseData>;
|
|
6
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPopularCitiesNear = void 0;
|
|
4
|
-
const getPopularCitiesNear = (slug) => ({
|
|
5
|
-
url: '/cities/near/' + slug,
|
|
6
|
-
method: 'GET'
|
|
7
|
-
});
|
|
8
|
-
exports.getPopularCitiesNear = getPopularCitiesNear;
|