@bringg/dashboard-sdk 8.26.0 → 8.27.0-pre
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/dist/Services/ServiceRequest.js +1 -1
- package/dist/User/Service/UsersService.d.ts +13 -0
- package/dist/User/Service/UsersService.js +42 -0
- package/dist/User/Service/UsersService.js.map +1 -1
- package/dist/User/Store/UsersStore.d.ts +2 -0
- package/dist/User/Store/UsersStore.js +46 -0
- package/dist/User/Store/UsersStore.js.map +1 -1
- package/dist/User/Users.d.ts +2 -0
- package/dist/User/Users.js +6 -0
- package/dist/User/Users.js.map +1 -1
- package/dist/bringg-dashboard-sdk-cjs2.js +95 -1
- package/dist/bringg-dashboard-sdk-cjs2.js.map +1 -1
- package/dist/bringg-dashboard-sdk.js +4 -4
- package/dist/bringg-dashboard-sdk.min.js +1 -1
- package/dist/bringg-dashboard-sdk.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -2349,7 +2349,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
|
2349
2349
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
2350
2350
|
|
|
2351
2351
|
"use strict";
|
|
2352
|
-
eval("\nvar __assign = (this && this.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n 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;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.AnonymousServiceRequest = exports.AuthorizedServiceRequest = exports.ResponseHandler = exports.RequestOptions = exports.logErrorResponse = void 0;\nvar axios_1 = __webpack_require__(/*! axios */ \"./node_modules/axios/index.js\");\nvar lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nvar BringgException_1 = __webpack_require__(/*! ../Core/BringgException */ \"./dist/Core/BringgException.js\");\nvar Logger_1 = __webpack_require__(/*! ../Core/Logger */ \"./dist/Core/Logger.js\");\nvar abort_1 = __webpack_require__(/*! ../utils/abort */ \"./dist/utils/abort.js\");\nvar version = '8.26.0';\nfunction logErrorResponse(response) {\n var data = response.data, status = response.status;\n try {\n Logger_1.default.error(response.config.method.toUpperCase(), response.config.url, status);\n }\n catch (e) {\n //\n }\n try {\n Logger_1.default.info(response.config.method.toUpperCase(), response.config.url, status, data);\n }\n catch (e) {\n //\n }\n try {\n Logger_1.default.debug(response);\n }\n catch (e) {\n //\n }\n}\nexports.logErrorResponse = logErrorResponse;\nvar DEFAULT_TIMEOUT = 120000;\nvar RequestOptions = /** @class */ (function () {\n function RequestOptions(clientId, timeout, \n // eslint-disable-next-line @typescript-eslint/ban-types\n queryString, authenticationToken, \n // eslint-disable-next-line @typescript-eslint/ban-types\n headers, responseType, signal) {\n // NiceToHave: move headers to HttpHeaders class\n this.headers = __assign(__assign({ 'Content-Type': 'application/json' }, headers), { 'sdk-version': version, Client: clientId });\n this.timeout = timeout;\n this.validateStatus = lodash_1.stubTrue;\n if (queryString) {\n this.params = queryString;\n }\n if (authenticationToken) {\n this.headers['Authorization'] = \"Token token=\".concat(authenticationToken);\n }\n if (responseType) {\n this.responseType = responseType;\n }\n if (signal) {\n this.signal = signal;\n }\n }\n RequestOptions.new = function (_a) {\n var _b = _a === void 0 ? {} : _a, _c = _b.clientId, clientId = _c === void 0 ? 'Bringg Dashboard' : _c, _d = _b.timeout, timeout = _d === void 0 ? DEFAULT_TIMEOUT : _d, queryString = _b.queryString, authenticationToken = _b.authenticationToken, headers = _b.headers, responseType = _b.responseType, signal = _b.signal;\n return new RequestOptions(clientId, timeout || DEFAULT_TIMEOUT, queryString, authenticationToken, headers, responseType, signal);\n };\n return RequestOptions;\n}());\nexports.RequestOptions = RequestOptions;\nvar ResponseHandler = /** @class */ (function () {\n function ResponseHandler(response, signal) {\n this.axiosPromise = response;\n this.signal = signal;\n }\n ResponseHandler.prototype.handle = function (consumer) {\n return __awaiter(this, void 0, void 0, function () {\n var axiosResponse, e_1;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if ((0, lodash_1.isUndefined)(consumer)) {\n throw new Error('consumer must be defined');\n }\n _a.label = 1;\n case 1:\n _a.trys.push([1, 3, , 4]);\n return [4 /*yield*/, this.axiosPromise];\n case 2:\n axiosResponse = _a.sent();\n return [2 /*return*/, consumer(axiosResponse)];\n case 3:\n e_1 = _a.sent();\n if (axios_1.default.isCancel(e_1)) {\n (0, abort_1.throwAbortError)(this.signal, 'Request Aborted');\n }\n if (e_1 instanceof BringgException_1.BringgException) {\n throw e_1;\n }\n return [2 /*return*/, consumer(e_1)];\n case 4: return [2 /*return*/];\n }\n });\n });\n };\n return ResponseHandler;\n}());\nexports.ResponseHandler = ResponseHandler;\nfunction get(axiosInstance, host, uri, queryString, signal) {\n return new ResponseHandler(axiosInstance.get(\"\".concat(host).concat(uri), { params: queryString, signal: signal }), signal);\n}\nfunction post(axiosInstance, host, uri, queryString, payload, signal) {\n return new ResponseHandler(axiosInstance.post(\"\".concat(host).concat(uri), payload, { params: queryString, signal: signal }), signal);\n}\nfunction put(axiosInstance, host, uri, queryString, payload, signal) {\n return new ResponseHandler(axiosInstance.put(\"\".concat(host).concat(uri), payload, { params: queryString, signal: signal }), signal);\n}\nfunction patch(axiosInstance, host, uri, queryString, payload, signal) {\n return new ResponseHandler(axiosInstance.patch(\"\".concat(host).concat(uri), payload, { params: queryString, signal: signal }), signal);\n}\nfunction remove(axiosInstance, host, uri, queryString, payload, signal) {\n return new ResponseHandler(axiosInstance.delete(\"\".concat(host).concat(uri), { params: queryString, data: payload, signal: signal }), signal);\n}\nfunction routify(axiosInstance, endpoint, route, \n// eslint-disable-next-line @typescript-eslint/ban-types\nrouteParams, queryString, payload, signal) {\n switch (route.httpMethod) {\n case 0 /* HttpMethod.GET */:\n return get(axiosInstance, endpoint.encode(), route.applyParams(routeParams), queryString, signal);\n case 1 /* HttpMethod.POST */:\n return post(axiosInstance, endpoint.encode(), route.applyParams(routeParams), queryString, payload, signal);\n case 2 /* HttpMethod.PUT */:\n return put(axiosInstance, endpoint.encode(), route.applyParams(routeParams), queryString, payload, signal);\n case 3 /* HttpMethod.PATCH */:\n return patch(axiosInstance, endpoint.encode(), route.applyParams(routeParams), queryString, payload, signal);\n case 4 /* HttpMethod.DELETE */:\n return remove(axiosInstance, endpoint.encode(), route.applyParams(routeParams), queryString, payload, signal);\n }\n}\nfunction wrapWithInterceptors(axios) {\n axios.interceptors.request.use(function (req) {\n var method = req.method, url = req.url, params = req.params, headers = req.headers, data = req.data;\n try {\n Logger_1.default.debug('REQUEST:', method.toUpperCase(), url);\n }\n catch (e) {\n //\n }\n try {\n Logger_1.default.trace('REQUEST-query-string:', params);\n Logger_1.default.trace('REQUEST-headers:', headers);\n Logger_1.default.trace('REQUEST-data:', data);\n }\n catch (e) {\n //\n }\n return req;\n });\n axios.interceptors.response.use(function (res) {\n var statusText = res.statusText, status = res.status, headers = res.headers, data = res.data;\n try {\n Logger_1.default.debug('RESPONSE:', res.config.url, status, statusText);\n }\n catch (e) {\n //\n }\n try {\n Logger_1.default.trace('RESPONSE-headers:', headers);\n Logger_1.default.trace('RESPONSE-data:', data);\n }\n catch (e) {\n //\n }\n return res;\n });\n return axios;\n}\nfunction axiosInstance(clientId, authenticationToken, \n// eslint-disable-next-line @typescript-eslint/ban-types\nheaders, responseType, timeout, signal) {\n return wrapWithInterceptors(axios_1.default.create(RequestOptions.new({ clientId: clientId, authenticationToken: authenticationToken, headers: headers, responseType: responseType, timeout: timeout, signal: signal })));\n}\n// eslint-disable-next-line @typescript-eslint/ban-types\nfunction anonymousAxiosInstance(clientId, headers, signal) {\n return wrapWithInterceptors(axios_1.default.create(RequestOptions.new({ clientId: clientId, headers: headers, signal: signal })));\n}\nvar AuthorizedServiceRequest = /** @class */ (function () {\n function AuthorizedServiceRequest(clientId, authToken) {\n this.authToken = authToken;\n this.clientId = clientId;\n }\n AuthorizedServiceRequest.prototype.invoke = function (endpoint, route, \n // eslint-disable-next-line @typescript-eslint/ban-types\n routeParams, \n // eslint-disable-next-line @typescript-eslint/ban-types\n queryString, payload, \n // eslint-disable-next-line @typescript-eslint/ban-types\n headers, responseType, timeout, signal) {\n if (signal === null || signal === void 0 ? void 0 : signal.aborted) {\n (0, abort_1.throwAbortError)(signal, 'Request aborted (before even started the request)');\n }\n return routify(axiosInstance(this.clientId, this.authToken, headers, responseType, timeout), endpoint, route, routeParams, queryString, payload, signal);\n };\n return AuthorizedServiceRequest;\n}());\nexports.AuthorizedServiceRequest = AuthorizedServiceRequest;\nvar AnonymousServiceRequest = /** @class */ (function () {\n function AnonymousServiceRequest(clientId, headers) {\n this.clientId = clientId;\n this.headers = headers;\n }\n AnonymousServiceRequest.prototype.invoke = function (endpoint, route, \n // eslint-disable-next-line @typescript-eslint/ban-types\n routeParams, \n // eslint-disable-next-line @typescript-eslint/ban-types\n queryString, payload, signal) {\n if (signal === null || signal === void 0 ? void 0 : signal.aborted) {\n (0, abort_1.throwAbortError)(signal, 'Request aborted (before even started the request)');\n }\n return routify(anonymousAxiosInstance(this.clientId, this.headers, signal), endpoint, route, routeParams, queryString, payload);\n };\n return AnonymousServiceRequest;\n}());\nexports.AnonymousServiceRequest = AnonymousServiceRequest;\n//# sourceMappingURL=ServiceRequest.js.map\n\n//# sourceURL=webpack://BringgDashboardSDK/./dist/Services/ServiceRequest.js?");
|
|
2352
|
+
eval("\nvar __assign = (this && this.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n 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;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.AnonymousServiceRequest = exports.AuthorizedServiceRequest = exports.ResponseHandler = exports.RequestOptions = exports.logErrorResponse = void 0;\nvar axios_1 = __webpack_require__(/*! axios */ \"./node_modules/axios/index.js\");\nvar lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nvar BringgException_1 = __webpack_require__(/*! ../Core/BringgException */ \"./dist/Core/BringgException.js\");\nvar Logger_1 = __webpack_require__(/*! ../Core/Logger */ \"./dist/Core/Logger.js\");\nvar abort_1 = __webpack_require__(/*! ../utils/abort */ \"./dist/utils/abort.js\");\nvar version = '8.27.0-pre';\nfunction logErrorResponse(response) {\n var data = response.data, status = response.status;\n try {\n Logger_1.default.error(response.config.method.toUpperCase(), response.config.url, status);\n }\n catch (e) {\n //\n }\n try {\n Logger_1.default.info(response.config.method.toUpperCase(), response.config.url, status, data);\n }\n catch (e) {\n //\n }\n try {\n Logger_1.default.debug(response);\n }\n catch (e) {\n //\n }\n}\nexports.logErrorResponse = logErrorResponse;\nvar DEFAULT_TIMEOUT = 120000;\nvar RequestOptions = /** @class */ (function () {\n function RequestOptions(clientId, timeout, \n // eslint-disable-next-line @typescript-eslint/ban-types\n queryString, authenticationToken, \n // eslint-disable-next-line @typescript-eslint/ban-types\n headers, responseType, signal) {\n // NiceToHave: move headers to HttpHeaders class\n this.headers = __assign(__assign({ 'Content-Type': 'application/json' }, headers), { 'sdk-version': version, Client: clientId });\n this.timeout = timeout;\n this.validateStatus = lodash_1.stubTrue;\n if (queryString) {\n this.params = queryString;\n }\n if (authenticationToken) {\n this.headers['Authorization'] = \"Token token=\".concat(authenticationToken);\n }\n if (responseType) {\n this.responseType = responseType;\n }\n if (signal) {\n this.signal = signal;\n }\n }\n RequestOptions.new = function (_a) {\n var _b = _a === void 0 ? {} : _a, _c = _b.clientId, clientId = _c === void 0 ? 'Bringg Dashboard' : _c, _d = _b.timeout, timeout = _d === void 0 ? DEFAULT_TIMEOUT : _d, queryString = _b.queryString, authenticationToken = _b.authenticationToken, headers = _b.headers, responseType = _b.responseType, signal = _b.signal;\n return new RequestOptions(clientId, timeout || DEFAULT_TIMEOUT, queryString, authenticationToken, headers, responseType, signal);\n };\n return RequestOptions;\n}());\nexports.RequestOptions = RequestOptions;\nvar ResponseHandler = /** @class */ (function () {\n function ResponseHandler(response, signal) {\n this.axiosPromise = response;\n this.signal = signal;\n }\n ResponseHandler.prototype.handle = function (consumer) {\n return __awaiter(this, void 0, void 0, function () {\n var axiosResponse, e_1;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if ((0, lodash_1.isUndefined)(consumer)) {\n throw new Error('consumer must be defined');\n }\n _a.label = 1;\n case 1:\n _a.trys.push([1, 3, , 4]);\n return [4 /*yield*/, this.axiosPromise];\n case 2:\n axiosResponse = _a.sent();\n return [2 /*return*/, consumer(axiosResponse)];\n case 3:\n e_1 = _a.sent();\n if (axios_1.default.isCancel(e_1)) {\n (0, abort_1.throwAbortError)(this.signal, 'Request Aborted');\n }\n if (e_1 instanceof BringgException_1.BringgException) {\n throw e_1;\n }\n return [2 /*return*/, consumer(e_1)];\n case 4: return [2 /*return*/];\n }\n });\n });\n };\n return ResponseHandler;\n}());\nexports.ResponseHandler = ResponseHandler;\nfunction get(axiosInstance, host, uri, queryString, signal) {\n return new ResponseHandler(axiosInstance.get(\"\".concat(host).concat(uri), { params: queryString, signal: signal }), signal);\n}\nfunction post(axiosInstance, host, uri, queryString, payload, signal) {\n return new ResponseHandler(axiosInstance.post(\"\".concat(host).concat(uri), payload, { params: queryString, signal: signal }), signal);\n}\nfunction put(axiosInstance, host, uri, queryString, payload, signal) {\n return new ResponseHandler(axiosInstance.put(\"\".concat(host).concat(uri), payload, { params: queryString, signal: signal }), signal);\n}\nfunction patch(axiosInstance, host, uri, queryString, payload, signal) {\n return new ResponseHandler(axiosInstance.patch(\"\".concat(host).concat(uri), payload, { params: queryString, signal: signal }), signal);\n}\nfunction remove(axiosInstance, host, uri, queryString, payload, signal) {\n return new ResponseHandler(axiosInstance.delete(\"\".concat(host).concat(uri), { params: queryString, data: payload, signal: signal }), signal);\n}\nfunction routify(axiosInstance, endpoint, route, \n// eslint-disable-next-line @typescript-eslint/ban-types\nrouteParams, queryString, payload, signal) {\n switch (route.httpMethod) {\n case 0 /* HttpMethod.GET */:\n return get(axiosInstance, endpoint.encode(), route.applyParams(routeParams), queryString, signal);\n case 1 /* HttpMethod.POST */:\n return post(axiosInstance, endpoint.encode(), route.applyParams(routeParams), queryString, payload, signal);\n case 2 /* HttpMethod.PUT */:\n return put(axiosInstance, endpoint.encode(), route.applyParams(routeParams), queryString, payload, signal);\n case 3 /* HttpMethod.PATCH */:\n return patch(axiosInstance, endpoint.encode(), route.applyParams(routeParams), queryString, payload, signal);\n case 4 /* HttpMethod.DELETE */:\n return remove(axiosInstance, endpoint.encode(), route.applyParams(routeParams), queryString, payload, signal);\n }\n}\nfunction wrapWithInterceptors(axios) {\n axios.interceptors.request.use(function (req) {\n var method = req.method, url = req.url, params = req.params, headers = req.headers, data = req.data;\n try {\n Logger_1.default.debug('REQUEST:', method.toUpperCase(), url);\n }\n catch (e) {\n //\n }\n try {\n Logger_1.default.trace('REQUEST-query-string:', params);\n Logger_1.default.trace('REQUEST-headers:', headers);\n Logger_1.default.trace('REQUEST-data:', data);\n }\n catch (e) {\n //\n }\n return req;\n });\n axios.interceptors.response.use(function (res) {\n var statusText = res.statusText, status = res.status, headers = res.headers, data = res.data;\n try {\n Logger_1.default.debug('RESPONSE:', res.config.url, status, statusText);\n }\n catch (e) {\n //\n }\n try {\n Logger_1.default.trace('RESPONSE-headers:', headers);\n Logger_1.default.trace('RESPONSE-data:', data);\n }\n catch (e) {\n //\n }\n return res;\n });\n return axios;\n}\nfunction axiosInstance(clientId, authenticationToken, \n// eslint-disable-next-line @typescript-eslint/ban-types\nheaders, responseType, timeout, signal) {\n return wrapWithInterceptors(axios_1.default.create(RequestOptions.new({ clientId: clientId, authenticationToken: authenticationToken, headers: headers, responseType: responseType, timeout: timeout, signal: signal })));\n}\n// eslint-disable-next-line @typescript-eslint/ban-types\nfunction anonymousAxiosInstance(clientId, headers, signal) {\n return wrapWithInterceptors(axios_1.default.create(RequestOptions.new({ clientId: clientId, headers: headers, signal: signal })));\n}\nvar AuthorizedServiceRequest = /** @class */ (function () {\n function AuthorizedServiceRequest(clientId, authToken) {\n this.authToken = authToken;\n this.clientId = clientId;\n }\n AuthorizedServiceRequest.prototype.invoke = function (endpoint, route, \n // eslint-disable-next-line @typescript-eslint/ban-types\n routeParams, \n // eslint-disable-next-line @typescript-eslint/ban-types\n queryString, payload, \n // eslint-disable-next-line @typescript-eslint/ban-types\n headers, responseType, timeout, signal) {\n if (signal === null || signal === void 0 ? void 0 : signal.aborted) {\n (0, abort_1.throwAbortError)(signal, 'Request aborted (before even started the request)');\n }\n return routify(axiosInstance(this.clientId, this.authToken, headers, responseType, timeout), endpoint, route, routeParams, queryString, payload, signal);\n };\n return AuthorizedServiceRequest;\n}());\nexports.AuthorizedServiceRequest = AuthorizedServiceRequest;\nvar AnonymousServiceRequest = /** @class */ (function () {\n function AnonymousServiceRequest(clientId, headers) {\n this.clientId = clientId;\n this.headers = headers;\n }\n AnonymousServiceRequest.prototype.invoke = function (endpoint, route, \n // eslint-disable-next-line @typescript-eslint/ban-types\n routeParams, \n // eslint-disable-next-line @typescript-eslint/ban-types\n queryString, payload, signal) {\n if (signal === null || signal === void 0 ? void 0 : signal.aborted) {\n (0, abort_1.throwAbortError)(signal, 'Request aborted (before even started the request)');\n }\n return routify(anonymousAxiosInstance(this.clientId, this.headers, signal), endpoint, route, routeParams, queryString, payload);\n };\n return AnonymousServiceRequest;\n}());\nexports.AnonymousServiceRequest = AnonymousServiceRequest;\n//# sourceMappingURL=ServiceRequest.js.map\n\n//# sourceURL=webpack://BringgDashboardSDK/./dist/Services/ServiceRequest.js?");
|
|
2353
2353
|
|
|
2354
2354
|
/***/ }),
|
|
2355
2355
|
|
|
@@ -2932,7 +2932,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
|
2932
2932
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
2933
2933
|
|
|
2934
2934
|
"use strict";
|
|
2935
|
-
eval("\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar __assign = (this && this.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n 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;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nvar BringgException_1 = __webpack_require__(/*! ../../Core/BringgException */ \"./dist/Core/BringgException.js\");\nvar PubSubEvents_1 = __webpack_require__(/*! ../../Services/PubSubEvents */ \"./dist/Services/PubSubEvents.js\");\nvar PubSubService_1 = __webpack_require__(/*! ../../Services/PubSubService */ \"./dist/Services/PubSubService.js\");\nvar Route_1 = __webpack_require__(/*! ../../Services/Route */ \"./dist/Services/Route.js\");\nvar keyset_pagination_consts_1 = __webpack_require__(/*! ../../utils/consts/keyset-pagination.consts */ \"./dist/utils/consts/keyset-pagination.consts.js\");\nvar User_consts_1 = __webpack_require__(/*! ../User.consts */ \"./dist/User/User.consts.js\");\nvar ROUTES = {\n GET: new Route_1.Route('/users/{:userId}', 0 /* HttpMethod.GET */),\n GET_ALL: new Route_1.Route('/users/', 0 /* HttpMethod.GET */),\n GET_ALL_DRIVERS: new Route_1.Route('/users/drivers', 0 /* HttpMethod.GET */),\n GET_USERS_WITH_USER_TYPE: new Route_1.Route('/user_types/{:userTypeId}/users', 0 /* HttpMethod.GET */),\n GET_DRIVERS_BY_TEAM: new Route_1.Route('/teams/{:teamId}/users', 0 /* HttpMethod.GET */),\n MAKE_ADMIN: new Route_1.Route('/users/{:userId}/admin', 1 /* HttpMethod.POST */),\n CREATE_USER: new Route_1.Route('/users/', 1 /* HttpMethod.POST */),\n INVITE: new Route_1.Route('/users/{:userId}/reinvite', 1 /* HttpMethod.POST */),\n TOTAL_TASKS: new Route_1.Route('/users/{:userId}/tasks/count', 0 /* HttpMethod.GET */),\n TOTAL_EMPLOYEES: new Route_1.Route('/users/count', 0 /* HttpMethod.GET */),\n TOTAL_DRIVERS: new Route_1.Route('/users/drivers/count', 0 /* HttpMethod.GET */),\n UNLOCK: new Route_1.Route('/users/{:userId}/unlock', 1 /* HttpMethod.POST */),\n INVITE_VIA_EMAIL: new Route_1.Route('/users/{:userId}/reinvite_via_email', 1 /* HttpMethod.POST */),\n VALIDATE_PHONE: new Route_1.Route('/api/user/validate_phone', 0 /* HttpMethod.GET */),\n CLOSED_TASKS: new Route_1.Route('/users/{:userId}/tasks/closed_tasks', 0 /* HttpMethod.GET */),\n UPDATE: new Route_1.Route('/users/{:id}', 3 /* HttpMethod.PATCH */),\n DELETE: new Route_1.Route('/users/{:id}', 4 /* HttpMethod.DELETE */),\n GET_PROFILE_IMAGE: new Route_1.Route('/users/{:userId}/profile_image', 0 /* HttpMethod.GET */),\n MESSAGE_DRIVER: new Route_1.Route('/announcement/user/{:userId}', 2 /* HttpMethod.PUT */)\n};\nvar UsersService = /** @class */ (function (_super) {\n __extends(UsersService, _super);\n function UsersService(session, store) {\n var _this = _super.call(this, session.config.getApiEndpoint(), session) || this;\n _this.store = store;\n return _this;\n }\n UsersService.prototype.create = function (user) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.CREATE_USER,\n extractor: User_consts_1.userExtractor,\n exceptionProducer: BringgException_1.BringgException.serviceException('Could not create user'),\n payload: user\n })];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersService.prototype.getDriversByTeam = function (teamId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.GET_DRIVERS_BY_TEAM,\n extractor: User_consts_1.defaultExtractor,\n exceptionProducer: BringgException_1.BringgException.serviceException('Could not get drivers'),\n routeParams: { teamId: teamId }\n })];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersService.prototype.get = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.GET,\n extractor: User_consts_1.defaultExtractor,\n exceptionProducer: BringgException_1.BringgException.serviceException(function () { return \"Could not get user \".concat(userId); }),\n routeParams: { userId: userId }\n })];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersService.prototype.getAll = function (page, limit) {\n if (page === void 0) { page = 1; }\n if (limit === void 0) { limit = 50; }\n return __awaiter(this, void 0, void 0, function () {\n var response;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.GET_ALL,\n extractor: function (response) { return ({ has_next_page: response.has_next_page, users: response.users }); },\n exceptionProducer: BringgException_1.BringgException.serviceException('Could not get users'),\n queryString: { page: page, limit: limit }\n })];\n case 1:\n response = _a.sent();\n return [2 /*return*/, response];\n }\n });\n });\n };\n UsersService.prototype.getAllKeysetPagination = function (request) {\n return __awaiter(this, void 0, void 0, function () {\n var limit, page_action, cursor, response;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n limit = request.limit, page_action = request.page_action, cursor = request.cursor;\n return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.GET_ALL,\n extractor: function (response) { return ({\n next_page_cursor: response.next_page_cursor,\n previous_page_cursor: response.previous_page_cursor,\n users: response.users\n }); },\n exceptionProducer: BringgException_1.BringgException.serviceException('Could not get users'),\n queryString: { pgver: keyset_pagination_consts_1.KEYSET_PAGINATION_VER, limit: limit, page_action: page_action, cursor: cursor }\n })];\n case 1:\n response = _a.sent();\n return [2 /*return*/, response];\n }\n });\n });\n };\n UsersService.prototype.invite = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.INVITE,\n extractor: User_consts_1.userExtractor,\n exceptionProducer: BringgException_1.BringgException.serviceException(function () { return \"Could not invite user with id: \".concat(userId); }),\n routeParams: { userId: userId }\n })];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersService.prototype.unlock = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.UNLOCK,\n extractor: User_consts_1.successExtractor,\n exceptionProducer: BringgException_1.BringgException.serviceException(function () { return \"Could not unlock user with id: \".concat(userId); }),\n routeParams: { userId: userId }\n })];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersService.prototype.assignedTasksCount = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.TOTAL_TASKS,\n extractor: User_consts_1.countExtractor,\n exceptionProducer: BringgException_1.BringgException.serviceException(function () { return \"Could not get task count for user with id: \".concat(userId); }),\n routeParams: { userId: userId }\n })];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersService.prototype.totalEmployeesCount = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.TOTAL_EMPLOYEES,\n extractor: User_consts_1.countExtractor,\n exceptionProducer: BringgException_1.BringgException.serviceException(function () { return \"Could not get total employee count\"; })\n })];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersService.prototype.totalDriversCount = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.TOTAL_DRIVERS,\n extractor: User_consts_1.countExtractor,\n exceptionProducer: BringgException_1.BringgException.serviceException(function () { return \"Could not get total drivers count\"; })\n })];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersService.prototype.inviteByEmail = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.INVITE_VIA_EMAIL,\n extractor: User_consts_1.userExtractor,\n exceptionProducer: BringgException_1.BringgException.serviceException(function () { return \"Could not invite user with id: \".concat(userId); }),\n routeParams: { userId: userId }\n })];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersService.prototype.validatePhone = function (phone) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.VALIDATE_PHONE,\n extractor: function (response) { return response.phone_valid; },\n exceptionProducer: BringgException_1.BringgException.serviceException(function () { return \"Phone is not valid: \".concat(phone); }),\n queryString: { phone: phone }\n })];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersService.prototype.closedTasks = function (userId, page) {\n if (page === void 0) { page = 0; }\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.CLOSED_TASKS,\n extractor: User_consts_1.defaultExtractor,\n exceptionProducer: BringgException_1.BringgException.serviceException(function () { return \"Could not get tasks for user: \".concat(userId); }),\n routeParams: { userId: userId },\n queryString: { page: page }\n })];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersService.prototype.update = function (id, userDelta) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.UPDATE,\n extractor: User_consts_1.userExtractor,\n exceptionProducer: BringgException_1.BringgException.serviceException(function () { return \"Could not update user: \".concat(id); }),\n payload: __assign({ id: id }, userDelta),\n routeParams: { id: id }\n })];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersService.prototype.getAllAdminsAndDispatchers = function (request) {\n return __awaiter(this, void 0, void 0, function () {\n var limit, page_action, cursor, scopes, response;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n limit = request.limit, page_action = request.page_action, cursor = request.cursor;\n scopes = [User_consts_1.UsersScopes.DISPATCHERS, User_consts_1.UsersScopes.ADMINS];\n return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.GET_ALL,\n extractor: function (response) { return ({\n next_page_cursor: response.next_page_cursor,\n previous_page_cursor: response.previous_page_cursor,\n users: response.users\n }); },\n exceptionProducer: BringgException_1.BringgException.serviceException('Could not get admins and dispatchers'),\n queryString: { pgver: keyset_pagination_consts_1.KEYSET_PAGINATION_VER, scopes: scopes, limit: limit, page_action: page_action, cursor: cursor }\n })];\n case 1:\n response = _a.sent();\n return [2 /*return*/, response];\n }\n });\n });\n };\n UsersService.prototype.getAllDrivers = function (request) {\n return __awaiter(this, void 0, void 0, function () {\n var limit, page_action, cursor, options, scopes;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n limit = request.limit, page_action = request.page_action, cursor = request.cursor, options = request.options;\n scopes = [];\n if ((0, lodash_1.get)(options, 'onlyCustomers')) {\n scopes.push(User_consts_1.UsersScopes.CUSTOMERS);\n }\n else {\n scopes.push(User_consts_1.UsersScopes.DRIVERS);\n }\n if (options.onlyOnlineDriver) {\n scopes.push(User_consts_1.UsersScopes.MARKED_AS_ONLINE);\n }\n return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.GET_ALL,\n extractor: function (response) { return ({\n next_page_cursor: response.next_page_cursor,\n previous_page_cursor: response.previous_page_cursor,\n users: response.users\n }); },\n exceptionProducer: BringgException_1.BringgException.serviceException('Could not get drivers'),\n queryString: { pgver: keyset_pagination_consts_1.KEYSET_PAGINATION_VER, scopes: scopes, limit: limit, page_action: page_action, cursor: cursor }\n })];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersService.prototype.delete = function (id) {\n return __awaiter(this, void 0, void 0, function () {\n var result;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.DELETE,\n extractor: User_consts_1.successExtractor,\n exceptionProducer: BringgException_1.BringgException.serviceException(function () { return \"Could not delete user: \".concat(id); }),\n routeParams: { id: id }\n })];\n case 1:\n result = _a.sent();\n return [2 /*return*/, result];\n }\n });\n });\n };\n UsersService.prototype.getProfileImage = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.GET_PROFILE_IMAGE,\n extractor: function (response) { return response.profile_image; },\n exceptionProducer: BringgException_1.BringgException.serviceException(function () { return \"Could not get user's \".concat(userId, \" profile image\"); }),\n routeParams: { userId: userId }\n })];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersService.prototype.messageDriver = function (userId, message) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.MESSAGE_DRIVER,\n extractor: function (response) { return response.announcement_id; },\n exceptionProducer: BringgException_1.BringgException.serviceException(function () { return \"Could not message to user \".concat(userId); }),\n payload: { user_id: userId, message: message },\n routeParams: { userId: userId }\n })];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersService.prototype.byUserType = function (userTypeId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.GET_USERS_WITH_USER_TYPE,\n extractor: User_consts_1.usersExtractor,\n exceptionProducer: BringgException_1.BringgException.serviceException('Could not get users'),\n routeParams: { userTypeId: userTypeId }\n })];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersService.prototype.makeAdmin = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.MAKE_ADMIN,\n extractor: User_consts_1.userExtractor,\n exceptionProducer: BringgException_1.BringgException.serviceException(function () { return \"Could not set admin on userId: \".concat(userId); }),\n routeParams: { userId: userId }\n })];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersService.prototype.attachSubscriptions = function () {\n var _this = this;\n this.subscribeToEvent(PubSubEvents_1.DELETE_EMPLOYEE, function (user) {\n _this.store.removeFromStore(user.user_id);\n });\n this.subscribeToEvent(PubSubEvents_1.EMPLOYEE_UPDATE_EVENT, function (user) {\n _this.store.updateInStore(user);\n });\n this.subscribeToEvent(PubSubEvents_1.NEW_EMPLOYEE, function (user) {\n _this.store.addToStore(user);\n });\n };\n return UsersService;\n}(PubSubService_1.PubSubService));\nexports[\"default\"] = UsersService;\n//# sourceMappingURL=UsersService.js.map\n\n//# sourceURL=webpack://BringgDashboardSDK/./dist/User/Service/UsersService.js?");
|
|
2935
|
+
eval("\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar __assign = (this && this.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n 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;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nvar BringgException_1 = __webpack_require__(/*! ../../Core/BringgException */ \"./dist/Core/BringgException.js\");\nvar RouteGenerator_1 = __webpack_require__(/*! ../../Core/RouteGenerator */ \"./dist/Core/RouteGenerator.js\");\nvar PubSubEvents_1 = __webpack_require__(/*! ../../Services/PubSubEvents */ \"./dist/Services/PubSubEvents.js\");\nvar PubSubService_1 = __webpack_require__(/*! ../../Services/PubSubService */ \"./dist/Services/PubSubService.js\");\nvar Route_1 = __webpack_require__(/*! ../../Services/Route */ \"./dist/Services/Route.js\");\nvar keyset_pagination_consts_1 = __webpack_require__(/*! ../../utils/consts/keyset-pagination.consts */ \"./dist/utils/consts/keyset-pagination.consts.js\");\nvar User_consts_1 = __webpack_require__(/*! ../User.consts */ \"./dist/User/User.consts.js\");\nvar ROUTES = {\n GET: new Route_1.Route('/users/{:userId}', 0 /* HttpMethod.GET */),\n GET_ALL: new Route_1.Route('/users/', 0 /* HttpMethod.GET */),\n GET_ALL_DRIVERS: new Route_1.Route('/users/drivers', 0 /* HttpMethod.GET */),\n GET_USERS_WITH_USER_TYPE: new Route_1.Route('/user_types/{:userTypeId}/users', 0 /* HttpMethod.GET */),\n GET_DRIVERS_BY_TEAM: new Route_1.Route('/teams/{:teamId}/users', 0 /* HttpMethod.GET */),\n MAKE_ADMIN: new Route_1.Route('/users/{:userId}/admin', 1 /* HttpMethod.POST */),\n CREATE_USER: new Route_1.Route('/users/', 1 /* HttpMethod.POST */),\n INVITE: new Route_1.Route('/users/{:userId}/reinvite', 1 /* HttpMethod.POST */),\n TOTAL_TASKS: new Route_1.Route('/users/{:userId}/tasks/count', 0 /* HttpMethod.GET */),\n TOTAL_EMPLOYEES: new Route_1.Route('/users/count', 0 /* HttpMethod.GET */),\n TOTAL_DRIVERS: new Route_1.Route('/users/drivers/count', 0 /* HttpMethod.GET */),\n UNLOCK: new Route_1.Route('/users/{:userId}/unlock', 1 /* HttpMethod.POST */),\n INVITE_VIA_EMAIL: new Route_1.Route('/users/{:userId}/reinvite_via_email', 1 /* HttpMethod.POST */),\n VALIDATE_PHONE: new Route_1.Route('/api/user/validate_phone', 0 /* HttpMethod.GET */),\n CLOSED_TASKS: new Route_1.Route('/users/{:userId}/tasks/closed_tasks', 0 /* HttpMethod.GET */),\n UPDATE: new Route_1.Route('/users/{:id}', 3 /* HttpMethod.PATCH */),\n DELETE: new Route_1.Route('/users/{:id}', 4 /* HttpMethod.DELETE */),\n GET_PROFILE_IMAGE: new Route_1.Route('/users/{:userId}/profile_image', 0 /* HttpMethod.GET */),\n MESSAGE_DRIVER: new Route_1.Route('/announcement/user/{:userId}', 2 /* HttpMethod.PUT */)\n};\nvar UsersService = /** @class */ (function (_super) {\n __extends(UsersService, _super);\n function UsersService(session, store) {\n var _this = _super.call(this, session.config.getApiEndpoint(), session) || this;\n _this.store = store;\n return _this;\n }\n UsersService.prototype.create = function (user) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.CREATE_USER,\n extractor: User_consts_1.userExtractor,\n exceptionProducer: BringgException_1.BringgException.serviceException('Could not create user'),\n payload: user\n })];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersService.prototype.getDriversByTeam = function (teamId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.GET_DRIVERS_BY_TEAM,\n extractor: User_consts_1.defaultExtractor,\n exceptionProducer: BringgException_1.BringgException.serviceException('Could not get drivers'),\n routeParams: { teamId: teamId }\n })];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersService.prototype.get = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.GET,\n extractor: User_consts_1.defaultExtractor,\n exceptionProducer: BringgException_1.BringgException.serviceException(function () { return \"Could not get user \".concat(userId); }),\n routeParams: { userId: userId }\n })];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersService.prototype.getMany = function (_a, commonOptions) {\n var usersId = _a.usersId, _b = _a.page, page = _b === void 0 ? 1 : _b, _c = _a.limit, limit = _c === void 0 ? 50 : _c;\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_d) {\n return [2 /*return*/, new RouteGenerator_1.Request(this, ROUTES.GET_ALL)\n .withQueryString({ ids: usersId, page: page, limit: limit })\n .withExtractor(function (response) { return ({ has_next_page: response.has_next_page, users: response.users }); })\n .setException('Could not get users by ids')\n .withCommonOptions(commonOptions)\n .invoke()];\n });\n });\n };\n UsersService.prototype.getAll = function (page, limit) {\n if (page === void 0) { page = 1; }\n if (limit === void 0) { limit = 50; }\n return __awaiter(this, void 0, void 0, function () {\n var response;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.GET_ALL,\n extractor: function (response) { return ({ has_next_page: response.has_next_page, users: response.users }); },\n exceptionProducer: BringgException_1.BringgException.serviceException('Could not get users'),\n queryString: { page: page, limit: limit }\n })];\n case 1:\n response = _a.sent();\n return [2 /*return*/, response];\n }\n });\n });\n };\n UsersService.prototype.getAllKeysetPagination = function (request) {\n return __awaiter(this, void 0, void 0, function () {\n var limit, page_action, cursor, response;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n limit = request.limit, page_action = request.page_action, cursor = request.cursor;\n return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.GET_ALL,\n extractor: function (response) { return ({\n next_page_cursor: response.next_page_cursor,\n previous_page_cursor: response.previous_page_cursor,\n users: response.users\n }); },\n exceptionProducer: BringgException_1.BringgException.serviceException('Could not get users'),\n queryString: { pgver: keyset_pagination_consts_1.KEYSET_PAGINATION_VER, limit: limit, page_action: page_action, cursor: cursor }\n })];\n case 1:\n response = _a.sent();\n return [2 /*return*/, response];\n }\n });\n });\n };\n UsersService.prototype.invite = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.INVITE,\n extractor: User_consts_1.userExtractor,\n exceptionProducer: BringgException_1.BringgException.serviceException(function () { return \"Could not invite user with id: \".concat(userId); }),\n routeParams: { userId: userId }\n })];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersService.prototype.unlock = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.UNLOCK,\n extractor: User_consts_1.successExtractor,\n exceptionProducer: BringgException_1.BringgException.serviceException(function () { return \"Could not unlock user with id: \".concat(userId); }),\n routeParams: { userId: userId }\n })];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersService.prototype.assignedTasksCount = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.TOTAL_TASKS,\n extractor: User_consts_1.countExtractor,\n exceptionProducer: BringgException_1.BringgException.serviceException(function () { return \"Could not get task count for user with id: \".concat(userId); }),\n routeParams: { userId: userId }\n })];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersService.prototype.totalEmployeesCount = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.TOTAL_EMPLOYEES,\n extractor: User_consts_1.countExtractor,\n exceptionProducer: BringgException_1.BringgException.serviceException(function () { return \"Could not get total employee count\"; })\n })];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersService.prototype.totalDriversCount = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.TOTAL_DRIVERS,\n extractor: User_consts_1.countExtractor,\n exceptionProducer: BringgException_1.BringgException.serviceException(function () { return \"Could not get total drivers count\"; })\n })];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersService.prototype.inviteByEmail = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.INVITE_VIA_EMAIL,\n extractor: User_consts_1.userExtractor,\n exceptionProducer: BringgException_1.BringgException.serviceException(function () { return \"Could not invite user with id: \".concat(userId); }),\n routeParams: { userId: userId }\n })];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersService.prototype.validatePhone = function (phone) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.VALIDATE_PHONE,\n extractor: function (response) { return response.phone_valid; },\n exceptionProducer: BringgException_1.BringgException.serviceException(function () { return \"Phone is not valid: \".concat(phone); }),\n queryString: { phone: phone }\n })];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersService.prototype.closedTasks = function (userId, page) {\n if (page === void 0) { page = 0; }\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.CLOSED_TASKS,\n extractor: User_consts_1.defaultExtractor,\n exceptionProducer: BringgException_1.BringgException.serviceException(function () { return \"Could not get tasks for user: \".concat(userId); }),\n routeParams: { userId: userId },\n queryString: { page: page }\n })];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersService.prototype.update = function (id, userDelta) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.UPDATE,\n extractor: User_consts_1.userExtractor,\n exceptionProducer: BringgException_1.BringgException.serviceException(function () { return \"Could not update user: \".concat(id); }),\n payload: __assign({ id: id }, userDelta),\n routeParams: { id: id }\n })];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersService.prototype.getAllAdminsAndDispatchers = function (request) {\n return __awaiter(this, void 0, void 0, function () {\n var limit, page_action, cursor, scopes, response;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n limit = request.limit, page_action = request.page_action, cursor = request.cursor;\n scopes = [User_consts_1.UsersScopes.DISPATCHERS, User_consts_1.UsersScopes.ADMINS];\n return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.GET_ALL,\n extractor: function (response) { return ({\n next_page_cursor: response.next_page_cursor,\n previous_page_cursor: response.previous_page_cursor,\n users: response.users\n }); },\n exceptionProducer: BringgException_1.BringgException.serviceException('Could not get admins and dispatchers'),\n queryString: { pgver: keyset_pagination_consts_1.KEYSET_PAGINATION_VER, scopes: scopes, limit: limit, page_action: page_action, cursor: cursor }\n })];\n case 1:\n response = _a.sent();\n return [2 /*return*/, response];\n }\n });\n });\n };\n UsersService.prototype.getAllDrivers = function (request) {\n return __awaiter(this, void 0, void 0, function () {\n var limit, page_action, cursor, options, scopes;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n limit = request.limit, page_action = request.page_action, cursor = request.cursor, options = request.options;\n scopes = [];\n if ((0, lodash_1.get)(options, 'onlyCustomers')) {\n scopes.push(User_consts_1.UsersScopes.CUSTOMERS);\n }\n else {\n scopes.push(User_consts_1.UsersScopes.DRIVERS);\n }\n if (options.onlyOnlineDriver) {\n scopes.push(User_consts_1.UsersScopes.MARKED_AS_ONLINE);\n }\n return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.GET_ALL,\n extractor: function (response) { return ({\n next_page_cursor: response.next_page_cursor,\n previous_page_cursor: response.previous_page_cursor,\n users: response.users\n }); },\n exceptionProducer: BringgException_1.BringgException.serviceException('Could not get drivers'),\n queryString: { pgver: keyset_pagination_consts_1.KEYSET_PAGINATION_VER, scopes: scopes, limit: limit, page_action: page_action, cursor: cursor }\n })];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersService.prototype.delete = function (id) {\n return __awaiter(this, void 0, void 0, function () {\n var result;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.DELETE,\n extractor: User_consts_1.successExtractor,\n exceptionProducer: BringgException_1.BringgException.serviceException(function () { return \"Could not delete user: \".concat(id); }),\n routeParams: { id: id }\n })];\n case 1:\n result = _a.sent();\n return [2 /*return*/, result];\n }\n });\n });\n };\n UsersService.prototype.getProfileImage = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.GET_PROFILE_IMAGE,\n extractor: function (response) { return response.profile_image; },\n exceptionProducer: BringgException_1.BringgException.serviceException(function () { return \"Could not get user's \".concat(userId, \" profile image\"); }),\n routeParams: { userId: userId }\n })];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersService.prototype.messageDriver = function (userId, message) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.MESSAGE_DRIVER,\n extractor: function (response) { return response.announcement_id; },\n exceptionProducer: BringgException_1.BringgException.serviceException(function () { return \"Could not message to user \".concat(userId); }),\n payload: { user_id: userId, message: message },\n routeParams: { userId: userId }\n })];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersService.prototype.byUserType = function (userTypeId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.GET_USERS_WITH_USER_TYPE,\n extractor: User_consts_1.usersExtractor,\n exceptionProducer: BringgException_1.BringgException.serviceException('Could not get users'),\n routeParams: { userTypeId: userTypeId }\n })];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersService.prototype.makeAdmin = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handleAuthorizedRequest({\n route: ROUTES.MAKE_ADMIN,\n extractor: User_consts_1.userExtractor,\n exceptionProducer: BringgException_1.BringgException.serviceException(function () { return \"Could not set admin on userId: \".concat(userId); }),\n routeParams: { userId: userId }\n })];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersService.prototype.fetchAllPages = function (fn, options) {\n var _a;\n return __awaiter(this, void 0, void 0, function () {\n var result, hasMore, cursor, _b, values, hasMoreInPage, nextCursor;\n return __generator(this, function (_c) {\n switch (_c.label) {\n case 0:\n result = [];\n hasMore = true;\n cursor = undefined;\n _c.label = 1;\n case 1:\n if (!hasMore) return [3 /*break*/, 3];\n if ((_a = options === null || options === void 0 ? void 0 : options.signal) === null || _a === void 0 ? void 0 : _a.aborted) {\n throw new Error('Aborted');\n }\n return [4 /*yield*/, fn(cursor)];\n case 2:\n _b = _c.sent(), values = _b.values, hasMoreInPage = _b.hasMore, nextCursor = _b.nextCursor;\n result = result.concat(values);\n hasMore = hasMoreInPage;\n cursor = nextCursor;\n return [3 /*break*/, 1];\n case 3: return [2 /*return*/, result];\n }\n });\n });\n };\n UsersService.prototype.attachSubscriptions = function () {\n var _this = this;\n this.subscribeToEvent(PubSubEvents_1.DELETE_EMPLOYEE, function (user) {\n _this.store.removeFromStore(user.user_id);\n });\n this.subscribeToEvent(PubSubEvents_1.EMPLOYEE_UPDATE_EVENT, function (user) {\n _this.store.updateInStore(user);\n });\n this.subscribeToEvent(PubSubEvents_1.NEW_EMPLOYEE, function (user) {\n _this.store.addToStore(user);\n });\n };\n return UsersService;\n}(PubSubService_1.PubSubService));\nexports[\"default\"] = UsersService;\n//# sourceMappingURL=UsersService.js.map\n\n//# sourceURL=webpack://BringgDashboardSDK/./dist/User/Service/UsersService.js?");
|
|
2936
2936
|
|
|
2937
2937
|
/***/ }),
|
|
2938
2938
|
|
|
@@ -2943,7 +2943,7 @@ eval("\nvar __extends = (this && this.__extends) || (function () {\n var exte
|
|
|
2943
2943
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
2944
2944
|
|
|
2945
2945
|
"use strict";
|
|
2946
|
-
eval("\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n 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;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nvar __values = (this && this.__values) || function(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n};\nvar __read = (this && this.__read) || function (o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n};\nvar __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar types_1 = __webpack_require__(/*! @bringg/types */ \"./node_modules/@bringg/types/index.js\");\nvar lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nvar rxjs_1 = __webpack_require__(/*! rxjs */ \"./node_modules/rxjs/_esm5/index.js\");\nvar operators_1 = __webpack_require__(/*! rxjs/operators */ \"./node_modules/rxjs/_esm5/operators/index.js\");\nvar BaseStore_1 = __webpack_require__(/*! ../../Core/BaseStore */ \"./dist/Core/BaseStore.js\");\nvar UsersService_1 = __webpack_require__(/*! ../Service/UsersService */ \"./dist/User/Service/UsersService.js\");\nvar User_consts_1 = __webpack_require__(/*! ../User.consts */ \"./dist/User/User.consts.js\");\nvar UserHelpers_1 = __webpack_require__(/*! ../UserHelpers */ \"./dist/User/UserHelpers.js\");\nvar THROTTLE_TIME = 500;\nvar UsersStore = /** @class */ (function (_super) {\n __extends(UsersStore, _super);\n function UsersStore(session, throttleTimeValue) {\n var e_1, _a;\n var _this = _super.call(this) || this;\n _this.groupUpdateEvents = [];\n _this.groupedValues = new Map();\n _this.drivers = [];\n _this.fetchedStatus = {\n drivers: false,\n customers: false,\n adminsAndDispatchers: false\n };\n _this.usersService = new UsersService_1.default(session, _this);\n _this.onlineDriversCounterByTeam = new Map();\n try {\n for (var _b = __values(Object.keys(User_consts_1.GROUP_VALUES)), _c = _b.next(); !_c.done; _c = _b.next()) {\n var groupId = _c.value;\n _this.groupedValues.set(User_consts_1.GROUP_VALUES[groupId], new Set());\n }\n }\n catch (e_1_1) { e_1 = { error: e_1_1 }; }\n finally {\n try {\n if (_c && !_c.done && (_a = _b.return)) _a.call(_b);\n }\n finally { if (e_1) throw e_1.error; }\n }\n throttleTimeValue = throttleTimeValue || THROTTLE_TIME;\n _this.onItemRemoved(function (userId, user) {\n var e_2, _a;\n var isDriverOnline = (user === null || user === void 0 ? void 0 : user.status) === types_1.Connection.Online;\n if (isDriverOnline && user.team_ids) {\n try {\n for (var _b = __values(user.team_ids), _c = _b.next(); !_c.done; _c = _b.next()) {\n var teamId = _c.value;\n _this.onlineDriversCounterByTeam.set(teamId, Math.max(_this.onlineDriversCounterByTeam.get(teamId) - 1, 0));\n }\n }\n catch (e_2_1) { e_2 = { error: e_2_1 }; }\n finally {\n try {\n if (_c && !_c.done && (_a = _b.return)) _a.call(_b);\n }\n finally { if (e_2) throw e_2.error; }\n }\n }\n });\n //group by and save ids | can add config to throttle through users( maybe increase if admin )\n _this.state$\n .pipe((0, operators_1.throttleTime)(throttleTimeValue, rxjs_1.asyncScheduler, { trailing: true, leading: false }))\n .subscribe(function (users) {\n _this.initGroups(users.values());\n _this.emitGroupEvents();\n });\n return _this;\n }\n UsersStore.prototype.getRelevantDrivers = function (groupsToInit) {\n if (groupsToInit.length === Object.keys(User_consts_1.GROUP_VALUES).length) {\n return [];\n }\n else {\n return this.drivers.filter(function (driver) {\n return !((UserHelpers_1.UserHelpers.isOnlineDriver(driver) && groupsToInit.includes(User_consts_1.GROUP_VALUES.OnlineDrivers)) ||\n (UserHelpers_1.UserHelpers.isOfflineDriver(driver) && groupsToInit.includes(User_consts_1.GROUP_VALUES.OfflineDrivers)) ||\n (UserHelpers_1.UserHelpers.isOnShiftDriver(driver) && groupsToInit.includes(User_consts_1.GROUP_VALUES.OnShiftDrivers)) ||\n (UserHelpers_1.UserHelpers.isAdmin(driver) && groupsToInit.includes(User_consts_1.GROUP_VALUES.Admins)) ||\n (UserHelpers_1.UserHelpers.isDispatcher(driver) && groupsToInit.includes(User_consts_1.GROUP_VALUES.Dispatchers)) ||\n (UserHelpers_1.UserHelpers.isCustomer(driver) && groupsToInit.includes(User_consts_1.GROUP_VALUES.Customers)));\n });\n }\n };\n UsersStore.prototype.initGroups = function (users, groupsToInit) {\n var e_3, _a, _b, e_4, _c, e_5, _d, e_6, _e, e_7, _f;\n if (groupsToInit === void 0) { groupsToInit = Object.keys(User_consts_1.GROUP_VALUES); }\n var groups = {};\n try {\n for (var groupsToInit_1 = __values(groupsToInit), groupsToInit_1_1 = groupsToInit_1.next(); !groupsToInit_1_1.done; groupsToInit_1_1 = groupsToInit_1.next()) {\n var groupId = groupsToInit_1_1.value;\n groups[groupId] = new Set();\n }\n }\n catch (e_3_1) { e_3 = { error: e_3_1 }; }\n finally {\n try {\n if (groupsToInit_1_1 && !groupsToInit_1_1.done && (_a = groupsToInit_1.return)) _a.call(groupsToInit_1);\n }\n finally { if (e_3) throw e_3.error; }\n }\n var relevantDrivers = this.getRelevantDrivers(groupsToInit);\n this.drivers.length = 0; // do not change drivers ref - manu pointer rely on it on their state on bringg-web\n (_b = this.drivers).push.apply(_b, __spreadArray([], __read(relevantDrivers), false));\n this.onlineDriversCounterByTeam = new Map();\n try {\n for (var users_1 = __values(users), users_1_1 = users_1.next(); !users_1_1.done; users_1_1 = users_1.next()) {\n var user = users_1_1.value;\n if (user.driver) {\n this.drivers.push(user);\n var isDriverOnline = user.status === types_1.Connection.Online;\n if (isDriverOnline && user.team_ids) {\n try {\n for (var _g = (e_5 = void 0, __values(user.team_ids)), _h = _g.next(); !_h.done; _h = _g.next()) {\n var teamId = _h.value;\n this.onlineDriversCounterByTeam.set(teamId, this.onlineDriversCounterByTeam.has(teamId)\n ? this.onlineDriversCounterByTeam.get(teamId) + 1\n : 1);\n }\n }\n catch (e_5_1) { e_5 = { error: e_5_1 }; }\n finally {\n try {\n if (_h && !_h.done && (_d = _g.return)) _d.call(_g);\n }\n finally { if (e_5) throw e_5.error; }\n }\n }\n }\n var groupIds = (0, User_consts_1.userToGroupsMapper)(user);\n try {\n for (var groupIds_1 = (e_6 = void 0, __values(groupIds)), groupIds_1_1 = groupIds_1.next(); !groupIds_1_1.done; groupIds_1_1 = groupIds_1.next()) {\n var groupId = groupIds_1_1.value;\n if (groups[groupId]) {\n groups[groupId].add(user);\n }\n }\n }\n catch (e_6_1) { e_6 = { error: e_6_1 }; }\n finally {\n try {\n if (groupIds_1_1 && !groupIds_1_1.done && (_e = groupIds_1.return)) _e.call(groupIds_1);\n }\n finally { if (e_6) throw e_6.error; }\n }\n }\n }\n catch (e_4_1) { e_4 = { error: e_4_1 }; }\n finally {\n try {\n if (users_1_1 && !users_1_1.done && (_c = users_1.return)) _c.call(users_1);\n }\n finally { if (e_4) throw e_4.error; }\n }\n try {\n for (var groupsToInit_2 = __values(groupsToInit), groupsToInit_2_1 = groupsToInit_2.next(); !groupsToInit_2_1.done; groupsToInit_2_1 = groupsToInit_2.next()) {\n var groupId = groupsToInit_2_1.value;\n this.groupedValues.set(User_consts_1.GROUP_VALUES[groupId], groups[groupId] || new Set());\n }\n }\n catch (e_7_1) { e_7 = { error: e_7_1 }; }\n finally {\n try {\n if (groupsToInit_2_1 && !groupsToInit_2_1.done && (_f = groupsToInit_2.return)) _f.call(groupsToInit_2);\n }\n finally { if (e_7) throw e_7.error; }\n }\n };\n UsersStore.prototype.create = function (user) {\n return __awaiter(this, void 0, void 0, function () {\n var newUser;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.create(user)];\n case 1:\n newUser = _a.sent();\n this.addToStore(newUser);\n return [2 /*return*/, newUser];\n }\n });\n });\n };\n UsersStore.prototype.getDriversByTeam = function (teamId) {\n return __awaiter(this, void 0, void 0, function () {\n var users;\n var _this = this;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.getDriversByTeam(teamId)];\n case 1:\n users = _a.sent();\n users.forEach(function (user) { return _this.addToStore(user); });\n return [2 /*return*/, users];\n }\n });\n });\n };\n UsersStore.prototype.getAll = function (page, limit) {\n if (page === void 0) { page = 1; }\n if (limit === void 0) { limit = 50; }\n return __awaiter(this, void 0, void 0, function () {\n var response;\n var _this = this;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.getAll(page, limit)];\n case 1:\n response = _a.sent();\n (0, lodash_1.forEach)(response.users, function (user) { return (_this.getItem(user.id) ? _this.updateInStore(user) : _this.addToStore(user)); });\n return [2 /*return*/, response];\n }\n });\n });\n };\n UsersStore.prototype.getAllKeysetPagination = function (request) {\n return __awaiter(this, void 0, void 0, function () {\n var response;\n var _this = this;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.getAllKeysetPagination(request)];\n case 1:\n response = _a.sent();\n (0, lodash_1.forEach)(response.users, function (user) { return (_this.getItem(user.id) ? _this.updateInStore(user) : _this.addToStore(user)); });\n this.initGroups(this.getItems());\n return [2 /*return*/, response];\n }\n });\n });\n };\n UsersStore.prototype.invite = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n var user;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.invite(userId)];\n case 1:\n user = _a.sent();\n this.updateInStore(user);\n return [2 /*return*/, user];\n }\n });\n });\n };\n UsersStore.prototype.inviteByEmail = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n var user;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.inviteByEmail(userId)];\n case 1:\n user = _a.sent();\n this.updateInStore(user);\n return [2 /*return*/, user];\n }\n });\n });\n };\n UsersStore.prototype.getAllAdminsAndDispatchers = function (request) {\n return __awaiter(this, void 0, void 0, function () {\n var _this = this;\n return __generator(this, function (_a) {\n return [2 /*return*/, this.getOrFetchUsers(request, this.fetchedStatus.adminsAndDispatchers, function (isAllAdminsAndDispatchersFetched) {\n return (_this.fetchedStatus.adminsAndDispatchers = isAllAdminsAndDispatchersFetched);\n }, function () {\n var _a;\n var args = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n args[_i] = arguments[_i];\n }\n return (_a = _this.usersService).getAllAdminsAndDispatchers.apply(_a, __spreadArray([], __read(args), false));\n }, function () { return _this.getAllLocalAdminsAndDispatchers(); })];\n });\n });\n };\n UsersStore.prototype.getAllDrivers = function (request) {\n return __awaiter(this, void 0, void 0, function () {\n var options, response, isOnlyCustomer, isOnlyOnlineDrivers, groups;\n var _this = this;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n options = request.options;\n isOnlyCustomer = options === null || options === void 0 ? void 0 : options.onlyCustomers;\n isOnlyOnlineDrivers = options === null || options === void 0 ? void 0 : options.onlyOnlineDriver;\n if (!isOnlyCustomer) return [3 /*break*/, 2];\n return [4 /*yield*/, this.getOrFetchUsers(request, this.fetchedStatus.customers, function (isAllCustomersFetched) { return (_this.fetchedStatus.customers = isAllCustomersFetched); }, this.usersService.getAllDrivers, function () { return _this.getCustomers(); })];\n case 1:\n response = _a.sent();\n return [3 /*break*/, 4];\n case 2: return [4 /*yield*/, this.getOrFetchUsers(request, this.fetchedStatus.drivers, function (isAllDriversFetched) { return (_this.fetchedStatus.drivers = isAllDriversFetched); }, function () {\n var _a;\n var args = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n args[_i] = arguments[_i];\n }\n return (_a = _this.usersService).getAllDrivers.apply(_a, __spreadArray([], __read(args), false));\n }, function () { return (isOnlyOnlineDrivers ? __spreadArray([], __read(_this.getOnlineDrivers()), false) : __spreadArray([], __read(_this.getAllLocalDrivers()), false)); })];\n case 3:\n response = _a.sent();\n _a.label = 4;\n case 4:\n groups = isOnlyCustomer\n ? [User_consts_1.GROUP_VALUES.Customers]\n : isOnlyOnlineDrivers\n ? [User_consts_1.GROUP_VALUES.OnlineDrivers]\n : [User_consts_1.GROUP_VALUES.OfflineDrivers, User_consts_1.GROUP_VALUES.OnlineDrivers, User_consts_1.GROUP_VALUES.OnShiftDrivers];\n this.initGroups(response.users, groups);\n return [2 /*return*/, response];\n }\n });\n });\n };\n UsersStore.prototype.getOrFetchUsers = function (request, isFetchedFlag, setIsFetchedFlag, fetchUsers, getLocalUsers) {\n return __awaiter(this, void 0, void 0, function () {\n var response;\n var _this = this;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!!isFetchedFlag) return [3 /*break*/, 2];\n return [4 /*yield*/, fetchUsers(request)];\n case 1:\n response = _a.sent();\n response.users.forEach(function (driver) { return _this.addToStore(driver); });\n if (!response.next_page_cursor && !response.previous_page_cursor) {\n setIsFetchedFlag(true);\n }\n return [2 /*return*/, response];\n case 2: return [2 /*return*/, {\n next_page_cursor: null,\n previous_page_cursor: null,\n users: getLocalUsers()\n }];\n }\n });\n });\n };\n UsersStore.prototype.byUserType = function (userTypeId) {\n return __awaiter(this, void 0, void 0, function () {\n var users;\n var _this = this;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.byUserType(userTypeId)];\n case 1:\n users = _a.sent();\n users.forEach(function (user) { return _this.addToStore(user); });\n return [2 /*return*/, users];\n }\n });\n });\n };\n UsersStore.prototype.makeAdmin = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n var user;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.makeAdmin(userId)];\n case 1:\n user = _a.sent();\n this.updateInStore(user);\n return [2 /*return*/, user];\n }\n });\n });\n };\n UsersStore.prototype.update = function (userId, userDelta) {\n return __awaiter(this, void 0, void 0, function () {\n var user;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.update(userId, userDelta)];\n case 1:\n user = _a.sent();\n this.updateInStore(user);\n return [2 /*return*/, user];\n }\n });\n });\n };\n UsersStore.prototype.delete = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n var success;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.delete(userId)];\n case 1:\n success = _a.sent();\n if (success) {\n this.removeFromStore(userId);\n }\n return [2 /*return*/, success];\n }\n });\n });\n };\n UsersStore.prototype.get = function (id) {\n return __awaiter(this, void 0, void 0, function () {\n var _a;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n _a = this.getItem(id);\n if (_a) return [3 /*break*/, 2];\n return [4 /*yield*/, this.usersService.get(id)];\n case 1:\n _a = (_b.sent());\n _b.label = 2;\n case 2: return [2 /*return*/, _a];\n }\n });\n });\n };\n UsersStore.prototype.unlock = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.unlock(userId)];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersStore.prototype.assignedTasksCount = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.assignedTasksCount(userId)];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersStore.prototype.totalEmployeesCount = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.totalEmployeesCount()];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersStore.prototype.totalDriversCount = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.totalDriversCount()];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersStore.prototype.getProfileImage = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.getProfileImage(userId)];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersStore.prototype.validatePhone = function (phone) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.validatePhone(phone)];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersStore.prototype.closedTasks = function (userId, page) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.closedTasks(userId, page)];\n case 1: return [2 /*return*/, _a.sent()]; // in future - add this tasks to store :)\n }\n });\n });\n };\n UsersStore.prototype.messageDriver = function (userId, message) {\n return this.usersService.messageDriver(userId, message);\n };\n UsersStore.prototype.subscribeToGroupUpdates = function (fn) {\n this.groupUpdateEvents.push(fn);\n };\n UsersStore.prototype.getOfflineDrivers = function () {\n return this.groupedValues.get(User_consts_1.GROUP_VALUES.OfflineDrivers) || new Set();\n };\n UsersStore.prototype.getOnlineDrivers = function () {\n return this.groupedValues.get(User_consts_1.GROUP_VALUES.OnlineDrivers) || new Set();\n };\n UsersStore.prototype.getOnShiftDrivers = function () {\n return Array.from(this.groupedValues.get(User_consts_1.GROUP_VALUES.OnShiftDrivers) || []);\n };\n UsersStore.prototype.getCustomers = function () {\n return Array.from(this.groupedValues.get(User_consts_1.GROUP_VALUES.Customers) || []);\n };\n UsersStore.prototype.getAdmins = function () {\n return Array.from(this.groupedValues.get(User_consts_1.GROUP_VALUES.Admins) || []);\n };\n UsersStore.prototype.getDispatchers = function () {\n return Array.from(this.groupedValues.get(User_consts_1.GROUP_VALUES.Dispatchers) || []);\n };\n UsersStore.prototype.emitGroupEvents = function () {\n var _this = this;\n this.groupUpdateEvents.forEach(function (fn) { return fn(_this.groupedValues); });\n };\n UsersStore.prototype.getAllLocalDrivers = function () {\n return this.drivers;\n };\n UsersStore.prototype.getOnlineDriversCountByTeam = function (teamId) {\n return this.onlineDriversCounterByTeam.get(teamId) || 0;\n };\n UsersStore.prototype.getAllLocalAdminsAndDispatchers = function () {\n return __spreadArray([], __read(new Set(this.getAdmins().concat(this.getDispatchers()))), false);\n };\n return UsersStore;\n}(BaseStore_1.default));\nexports[\"default\"] = UsersStore;\n//# sourceMappingURL=UsersStore.js.map\n\n//# sourceURL=webpack://BringgDashboardSDK/./dist/User/Store/UsersStore.js?");
|
|
2946
|
+
eval("\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n 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;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nvar __values = (this && this.__values) || function(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n};\nvar __read = (this && this.__read) || function (o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n};\nvar __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar types_1 = __webpack_require__(/*! @bringg/types */ \"./node_modules/@bringg/types/index.js\");\nvar lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nvar rxjs_1 = __webpack_require__(/*! rxjs */ \"./node_modules/rxjs/_esm5/index.js\");\nvar operators_1 = __webpack_require__(/*! rxjs/operators */ \"./node_modules/rxjs/_esm5/operators/index.js\");\nvar BaseStore_1 = __webpack_require__(/*! ../../Core/BaseStore */ \"./dist/Core/BaseStore.js\");\nvar UsersService_1 = __webpack_require__(/*! ../Service/UsersService */ \"./dist/User/Service/UsersService.js\");\nvar User_consts_1 = __webpack_require__(/*! ../User.consts */ \"./dist/User/User.consts.js\");\nvar UserHelpers_1 = __webpack_require__(/*! ../UserHelpers */ \"./dist/User/UserHelpers.js\");\nvar THROTTLE_TIME = 500;\nvar UsersStore = /** @class */ (function (_super) {\n __extends(UsersStore, _super);\n function UsersStore(session, throttleTimeValue) {\n var e_1, _a;\n var _this = _super.call(this) || this;\n _this.groupUpdateEvents = [];\n _this.groupedValues = new Map();\n _this.drivers = [];\n _this.fetchedStatus = {\n drivers: false,\n customers: false,\n adminsAndDispatchers: false\n };\n _this.usersService = new UsersService_1.default(session, _this);\n _this.onlineDriversCounterByTeam = new Map();\n try {\n for (var _b = __values(Object.keys(User_consts_1.GROUP_VALUES)), _c = _b.next(); !_c.done; _c = _b.next()) {\n var groupId = _c.value;\n _this.groupedValues.set(User_consts_1.GROUP_VALUES[groupId], new Set());\n }\n }\n catch (e_1_1) { e_1 = { error: e_1_1 }; }\n finally {\n try {\n if (_c && !_c.done && (_a = _b.return)) _a.call(_b);\n }\n finally { if (e_1) throw e_1.error; }\n }\n throttleTimeValue = throttleTimeValue || THROTTLE_TIME;\n _this.onItemRemoved(function (userId, user) {\n var e_2, _a;\n var isDriverOnline = (user === null || user === void 0 ? void 0 : user.status) === types_1.Connection.Online;\n if (isDriverOnline && user.team_ids) {\n try {\n for (var _b = __values(user.team_ids), _c = _b.next(); !_c.done; _c = _b.next()) {\n var teamId = _c.value;\n _this.onlineDriversCounterByTeam.set(teamId, Math.max(_this.onlineDriversCounterByTeam.get(teamId) - 1, 0));\n }\n }\n catch (e_2_1) { e_2 = { error: e_2_1 }; }\n finally {\n try {\n if (_c && !_c.done && (_a = _b.return)) _a.call(_b);\n }\n finally { if (e_2) throw e_2.error; }\n }\n }\n });\n //group by and save ids | can add config to throttle through users( maybe increase if admin )\n _this.state$\n .pipe((0, operators_1.throttleTime)(throttleTimeValue, rxjs_1.asyncScheduler, { trailing: true, leading: false }))\n .subscribe(function (users) {\n _this.initGroups(users.values());\n _this.emitGroupEvents();\n });\n return _this;\n }\n UsersStore.prototype.getRelevantDrivers = function (groupsToInit) {\n if (groupsToInit.length === Object.keys(User_consts_1.GROUP_VALUES).length) {\n return [];\n }\n else {\n return this.drivers.filter(function (driver) {\n return !((UserHelpers_1.UserHelpers.isOnlineDriver(driver) && groupsToInit.includes(User_consts_1.GROUP_VALUES.OnlineDrivers)) ||\n (UserHelpers_1.UserHelpers.isOfflineDriver(driver) && groupsToInit.includes(User_consts_1.GROUP_VALUES.OfflineDrivers)) ||\n (UserHelpers_1.UserHelpers.isOnShiftDriver(driver) && groupsToInit.includes(User_consts_1.GROUP_VALUES.OnShiftDrivers)) ||\n (UserHelpers_1.UserHelpers.isAdmin(driver) && groupsToInit.includes(User_consts_1.GROUP_VALUES.Admins)) ||\n (UserHelpers_1.UserHelpers.isDispatcher(driver) && groupsToInit.includes(User_consts_1.GROUP_VALUES.Dispatchers)) ||\n (UserHelpers_1.UserHelpers.isCustomer(driver) && groupsToInit.includes(User_consts_1.GROUP_VALUES.Customers)));\n });\n }\n };\n UsersStore.prototype.initGroups = function (users, groupsToInit) {\n var e_3, _a, _b, e_4, _c, e_5, _d, e_6, _e, e_7, _f;\n if (groupsToInit === void 0) { groupsToInit = Object.keys(User_consts_1.GROUP_VALUES); }\n var groups = {};\n try {\n for (var groupsToInit_1 = __values(groupsToInit), groupsToInit_1_1 = groupsToInit_1.next(); !groupsToInit_1_1.done; groupsToInit_1_1 = groupsToInit_1.next()) {\n var groupId = groupsToInit_1_1.value;\n groups[groupId] = new Set();\n }\n }\n catch (e_3_1) { e_3 = { error: e_3_1 }; }\n finally {\n try {\n if (groupsToInit_1_1 && !groupsToInit_1_1.done && (_a = groupsToInit_1.return)) _a.call(groupsToInit_1);\n }\n finally { if (e_3) throw e_3.error; }\n }\n var relevantDrivers = this.getRelevantDrivers(groupsToInit);\n this.drivers.length = 0; // do not change drivers ref - manu pointer rely on it on their state on bringg-web\n (_b = this.drivers).push.apply(_b, __spreadArray([], __read(relevantDrivers), false));\n this.onlineDriversCounterByTeam = new Map();\n try {\n for (var users_1 = __values(users), users_1_1 = users_1.next(); !users_1_1.done; users_1_1 = users_1.next()) {\n var user = users_1_1.value;\n if (user.driver) {\n this.drivers.push(user);\n var isDriverOnline = user.status === types_1.Connection.Online;\n if (isDriverOnline && user.team_ids) {\n try {\n for (var _g = (e_5 = void 0, __values(user.team_ids)), _h = _g.next(); !_h.done; _h = _g.next()) {\n var teamId = _h.value;\n this.onlineDriversCounterByTeam.set(teamId, this.onlineDriversCounterByTeam.has(teamId)\n ? this.onlineDriversCounterByTeam.get(teamId) + 1\n : 1);\n }\n }\n catch (e_5_1) { e_5 = { error: e_5_1 }; }\n finally {\n try {\n if (_h && !_h.done && (_d = _g.return)) _d.call(_g);\n }\n finally { if (e_5) throw e_5.error; }\n }\n }\n }\n var groupIds = (0, User_consts_1.userToGroupsMapper)(user);\n try {\n for (var groupIds_1 = (e_6 = void 0, __values(groupIds)), groupIds_1_1 = groupIds_1.next(); !groupIds_1_1.done; groupIds_1_1 = groupIds_1.next()) {\n var groupId = groupIds_1_1.value;\n if (groups[groupId]) {\n groups[groupId].add(user);\n }\n }\n }\n catch (e_6_1) { e_6 = { error: e_6_1 }; }\n finally {\n try {\n if (groupIds_1_1 && !groupIds_1_1.done && (_e = groupIds_1.return)) _e.call(groupIds_1);\n }\n finally { if (e_6) throw e_6.error; }\n }\n }\n }\n catch (e_4_1) { e_4 = { error: e_4_1 }; }\n finally {\n try {\n if (users_1_1 && !users_1_1.done && (_c = users_1.return)) _c.call(users_1);\n }\n finally { if (e_4) throw e_4.error; }\n }\n try {\n for (var groupsToInit_2 = __values(groupsToInit), groupsToInit_2_1 = groupsToInit_2.next(); !groupsToInit_2_1.done; groupsToInit_2_1 = groupsToInit_2.next()) {\n var groupId = groupsToInit_2_1.value;\n this.groupedValues.set(User_consts_1.GROUP_VALUES[groupId], groups[groupId] || new Set());\n }\n }\n catch (e_7_1) { e_7 = { error: e_7_1 }; }\n finally {\n try {\n if (groupsToInit_2_1 && !groupsToInit_2_1.done && (_f = groupsToInit_2.return)) _f.call(groupsToInit_2);\n }\n finally { if (e_7) throw e_7.error; }\n }\n };\n UsersStore.prototype.create = function (user) {\n return __awaiter(this, void 0, void 0, function () {\n var newUser;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.create(user)];\n case 1:\n newUser = _a.sent();\n this.addToStore(newUser);\n return [2 /*return*/, newUser];\n }\n });\n });\n };\n UsersStore.prototype.getDriversByTeam = function (teamId) {\n return __awaiter(this, void 0, void 0, function () {\n var users;\n var _this = this;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.getDriversByTeam(teamId)];\n case 1:\n users = _a.sent();\n users.forEach(function (user) { return _this.addToStore(user); });\n return [2 /*return*/, users];\n }\n });\n });\n };\n UsersStore.prototype.getAll = function (page, limit) {\n if (page === void 0) { page = 1; }\n if (limit === void 0) { limit = 50; }\n return __awaiter(this, void 0, void 0, function () {\n var response;\n var _this = this;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.getAll(page, limit)];\n case 1:\n response = _a.sent();\n (0, lodash_1.forEach)(response.users, function (user) { return (_this.getItem(user.id) ? _this.updateInStore(user) : _this.addToStore(user)); });\n return [2 /*return*/, response];\n }\n });\n });\n };\n UsersStore.prototype.getAllKeysetPagination = function (request) {\n return __awaiter(this, void 0, void 0, function () {\n var response;\n var _this = this;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.getAllKeysetPagination(request)];\n case 1:\n response = _a.sent();\n (0, lodash_1.forEach)(response.users, function (user) { return (_this.getItem(user.id) ? _this.updateInStore(user) : _this.addToStore(user)); });\n this.initGroups(this.getItems());\n return [2 /*return*/, response];\n }\n });\n });\n };\n UsersStore.prototype.invite = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n var user;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.invite(userId)];\n case 1:\n user = _a.sent();\n this.updateInStore(user);\n return [2 /*return*/, user];\n }\n });\n });\n };\n UsersStore.prototype.inviteByEmail = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n var user;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.inviteByEmail(userId)];\n case 1:\n user = _a.sent();\n this.updateInStore(user);\n return [2 /*return*/, user];\n }\n });\n });\n };\n UsersStore.prototype.getAllAdminsAndDispatchers = function (request) {\n return __awaiter(this, void 0, void 0, function () {\n var _this = this;\n return __generator(this, function (_a) {\n return [2 /*return*/, this.getOrFetchUsers(request, this.fetchedStatus.adminsAndDispatchers, function (isAllAdminsAndDispatchersFetched) {\n return (_this.fetchedStatus.adminsAndDispatchers = isAllAdminsAndDispatchersFetched);\n }, function () {\n var _a;\n var args = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n args[_i] = arguments[_i];\n }\n return (_a = _this.usersService).getAllAdminsAndDispatchers.apply(_a, __spreadArray([], __read(args), false));\n }, function () { return _this.getAllLocalAdminsAndDispatchers(); })];\n });\n });\n };\n UsersStore.prototype.getAllDrivers = function (request) {\n return __awaiter(this, void 0, void 0, function () {\n var options, response, isOnlyCustomer, isOnlyOnlineDrivers, groups;\n var _this = this;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n options = request.options;\n isOnlyCustomer = options === null || options === void 0 ? void 0 : options.onlyCustomers;\n isOnlyOnlineDrivers = options === null || options === void 0 ? void 0 : options.onlyOnlineDriver;\n if (!isOnlyCustomer) return [3 /*break*/, 2];\n return [4 /*yield*/, this.getOrFetchUsers(request, this.fetchedStatus.customers, function (isAllCustomersFetched) { return (_this.fetchedStatus.customers = isAllCustomersFetched); }, this.usersService.getAllDrivers, function () { return _this.getCustomers(); })];\n case 1:\n response = _a.sent();\n return [3 /*break*/, 4];\n case 2: return [4 /*yield*/, this.getOrFetchUsers(request, this.fetchedStatus.drivers, function (isAllDriversFetched) { return (_this.fetchedStatus.drivers = isAllDriversFetched); }, function () {\n var _a;\n var args = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n args[_i] = arguments[_i];\n }\n return (_a = _this.usersService).getAllDrivers.apply(_a, __spreadArray([], __read(args), false));\n }, function () { return (isOnlyOnlineDrivers ? __spreadArray([], __read(_this.getOnlineDrivers()), false) : __spreadArray([], __read(_this.getAllLocalDrivers()), false)); })];\n case 3:\n response = _a.sent();\n _a.label = 4;\n case 4:\n groups = isOnlyCustomer\n ? [User_consts_1.GROUP_VALUES.Customers]\n : isOnlyOnlineDrivers\n ? [User_consts_1.GROUP_VALUES.OnlineDrivers]\n : [User_consts_1.GROUP_VALUES.OfflineDrivers, User_consts_1.GROUP_VALUES.OnlineDrivers, User_consts_1.GROUP_VALUES.OnShiftDrivers];\n this.initGroups(response.users, groups);\n return [2 /*return*/, response];\n }\n });\n });\n };\n UsersStore.prototype.getOrFetchUsers = function (request, isFetchedFlag, setIsFetchedFlag, fetchUsers, getLocalUsers) {\n return __awaiter(this, void 0, void 0, function () {\n var response;\n var _this = this;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!!isFetchedFlag) return [3 /*break*/, 2];\n return [4 /*yield*/, fetchUsers(request)];\n case 1:\n response = _a.sent();\n response.users.forEach(function (driver) { return _this.addToStore(driver); });\n if (!response.next_page_cursor && !response.previous_page_cursor) {\n setIsFetchedFlag(true);\n }\n return [2 /*return*/, response];\n case 2: return [2 /*return*/, {\n next_page_cursor: null,\n previous_page_cursor: null,\n users: getLocalUsers()\n }];\n }\n });\n });\n };\n UsersStore.prototype.byUserType = function (userTypeId) {\n return __awaiter(this, void 0, void 0, function () {\n var users;\n var _this = this;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.byUserType(userTypeId)];\n case 1:\n users = _a.sent();\n users.forEach(function (user) { return _this.addToStore(user); });\n return [2 /*return*/, users];\n }\n });\n });\n };\n UsersStore.prototype.makeAdmin = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n var user;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.makeAdmin(userId)];\n case 1:\n user = _a.sent();\n this.updateInStore(user);\n return [2 /*return*/, user];\n }\n });\n });\n };\n UsersStore.prototype.update = function (userId, userDelta) {\n return __awaiter(this, void 0, void 0, function () {\n var user;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.update(userId, userDelta)];\n case 1:\n user = _a.sent();\n this.updateInStore(user);\n return [2 /*return*/, user];\n }\n });\n });\n };\n UsersStore.prototype.delete = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n var success;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.delete(userId)];\n case 1:\n success = _a.sent();\n if (success) {\n this.removeFromStore(userId);\n }\n return [2 /*return*/, success];\n }\n });\n });\n };\n UsersStore.prototype.get = function (id) {\n return __awaiter(this, void 0, void 0, function () {\n var _a;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n _a = this.getItem(id);\n if (_a) return [3 /*break*/, 2];\n return [4 /*yield*/, this.usersService.get(id)];\n case 1:\n _a = (_b.sent());\n _b.label = 2;\n case 2: return [2 /*return*/, _a];\n }\n });\n });\n };\n UsersStore.prototype.getMany = function (ids, commonOptions) {\n return __awaiter(this, void 0, void 0, function () {\n var foundedItems, idsSet, missingIds, missingUsers;\n var _this = this;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n foundedItems = this.getItemsByIds(ids);\n if (foundedItems.length === ids.length) {\n return [2 /*return*/, foundedItems];\n }\n idsSet = new Set(ids);\n foundedItems.forEach(function (user) { return idsSet.delete(user.id); });\n missingIds = Array.from(idsSet);\n return [4 /*yield*/, this.usersService.fetchAllPages(function (page) {\n if (page === void 0) { page = 1; }\n return __awaiter(_this, void 0, void 0, function () {\n var response, fetchedUsers;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.getMany({\n usersId: missingIds,\n page: page,\n limit: 50\n }, commonOptions)];\n case 1:\n response = _a.sent();\n fetchedUsers = response.users;\n // Adding here and not after getting all, so we won't stop the event loop for too long, if we have a lot\n this.addItems(fetchedUsers);\n return [2 /*return*/, {\n values: fetchedUsers,\n hasMore: response.has_next_page,\n nextCursor: page + 1\n }];\n }\n });\n });\n }, { signal: commonOptions === null || commonOptions === void 0 ? void 0 : commonOptions.signal })];\n case 1:\n missingUsers = _a.sent();\n return [2 /*return*/, foundedItems.concat(missingUsers)];\n }\n });\n });\n };\n UsersStore.prototype.unlock = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.unlock(userId)];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersStore.prototype.assignedTasksCount = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.assignedTasksCount(userId)];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersStore.prototype.totalEmployeesCount = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.totalEmployeesCount()];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersStore.prototype.totalDriversCount = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.totalDriversCount()];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersStore.prototype.getProfileImage = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.getProfileImage(userId)];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersStore.prototype.validatePhone = function (phone) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.validatePhone(phone)];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n UsersStore.prototype.closedTasks = function (userId, page) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.closedTasks(userId, page)];\n case 1: return [2 /*return*/, _a.sent()]; // in future - add this tasks to store :)\n }\n });\n });\n };\n UsersStore.prototype.messageDriver = function (userId, message) {\n return this.usersService.messageDriver(userId, message);\n };\n UsersStore.prototype.subscribeToGroupUpdates = function (fn) {\n this.groupUpdateEvents.push(fn);\n };\n UsersStore.prototype.getOfflineDrivers = function () {\n return this.groupedValues.get(User_consts_1.GROUP_VALUES.OfflineDrivers) || new Set();\n };\n UsersStore.prototype.getOnlineDrivers = function () {\n return this.groupedValues.get(User_consts_1.GROUP_VALUES.OnlineDrivers) || new Set();\n };\n UsersStore.prototype.getOnShiftDrivers = function () {\n return Array.from(this.groupedValues.get(User_consts_1.GROUP_VALUES.OnShiftDrivers) || []);\n };\n UsersStore.prototype.getCustomers = function () {\n return Array.from(this.groupedValues.get(User_consts_1.GROUP_VALUES.Customers) || []);\n };\n UsersStore.prototype.getAdmins = function () {\n return Array.from(this.groupedValues.get(User_consts_1.GROUP_VALUES.Admins) || []);\n };\n UsersStore.prototype.getDispatchers = function () {\n return Array.from(this.groupedValues.get(User_consts_1.GROUP_VALUES.Dispatchers) || []);\n };\n UsersStore.prototype.emitGroupEvents = function () {\n var _this = this;\n this.groupUpdateEvents.forEach(function (fn) { return fn(_this.groupedValues); });\n };\n UsersStore.prototype.getAllLocalDrivers = function () {\n return this.drivers;\n };\n UsersStore.prototype.getOnlineDriversCountByTeam = function (teamId) {\n return this.onlineDriversCounterByTeam.get(teamId) || 0;\n };\n UsersStore.prototype.getAllLocalAdminsAndDispatchers = function () {\n return __spreadArray([], __read(new Set(this.getAdmins().concat(this.getDispatchers()))), false);\n };\n return UsersStore;\n}(BaseStore_1.default));\nexports[\"default\"] = UsersStore;\n//# sourceMappingURL=UsersStore.js.map\n\n//# sourceURL=webpack://BringgDashboardSDK/./dist/User/Store/UsersStore.js?");
|
|
2947
2947
|
|
|
2948
2948
|
/***/ }),
|
|
2949
2949
|
|
|
@@ -2976,7 +2976,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
|
2976
2976
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
2977
2977
|
|
|
2978
2978
|
"use strict";
|
|
2979
|
-
eval("\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n 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;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nvar BringgException_1 = __webpack_require__(/*! ../Core/BringgException */ \"./dist/Core/BringgException.js\");\nvar ExceptionReason_1 = __webpack_require__(/*! ../Core/ExceptionReason */ \"./dist/Core/ExceptionReason.js\");\nvar keyset_pagination_consts_1 = __webpack_require__(/*! ../utils/consts/keyset-pagination.consts */ \"./dist/utils/consts/keyset-pagination.consts.js\");\nvar UsersStore_1 = __webpack_require__(/*! ./Store/UsersStore */ \"./dist/User/Store/UsersStore.js\");\nvar User_consts_1 = __webpack_require__(/*! ./User.consts */ \"./dist/User/User.consts.js\");\nvar Users = /** @class */ (function () {\n function Users(session) {\n this.usersStore = new UsersStore_1.default(session);\n //keep previous names for backward compatibility\n this.onListUpdate = this.usersStore.onListUpdate;\n this.onUpdate = this.usersStore.onItemUpdate;\n this.onDelete = this.usersStore.onItemRemoved;\n this.onCreate = this.usersStore.onItemCreated;\n this.unsubscribe = this.usersStore.unsubscribe;\n }\n Users.prototype.create = function (user) {\n if ((0, lodash_1.isNil)(user.email) && (0, lodash_1.isNil)(user.phone)) {\n throw new BringgException_1.BringgException(ExceptionReason_1.ExceptionReason.INVALID_ARGUMENTS, 'Phone or Email is required');\n }\n return this.usersStore.create(user);\n };\n Users.prototype.getAllAdminsAndDispatchers = function (_a) {\n var _b = _a.limit, limit = _b === void 0 ? 25 : _b, _c = _a.page_action, page_action = _c === void 0 ? keyset_pagination_consts_1.KeysetPaginationPageAction.NEXT : _c, cursor = _a.cursor;\n return this.usersStore.getAllAdminsAndDispatchers({ limit: limit, page_action: page_action, cursor: cursor });\n };\n Users.prototype.getAllDrivers = function (_a) {\n var _b = _a.limit, limit = _b === void 0 ? 25 : _b, _c = _a.page_action, page_action = _c === void 0 ? keyset_pagination_consts_1.KeysetPaginationPageAction.NEXT : _c, cursor = _a.cursor, options = _a.options;\n var optionsWithDefaults = (0, lodash_1.defaults)(options, { onlyOnlineDriver: false, onlyCustomers: false });\n return this.usersStore.getAllDrivers({ limit: limit, page_action: page_action, cursor: cursor, options: optionsWithDefaults });\n };\n Users.prototype.byUserType = function (userTypeId) {\n return this.usersStore.byUserType(userTypeId);\n };\n Users.prototype.makeAdmin = function (userId) {\n return this.usersStore.makeAdmin(userId);\n };\n Users.prototype.totalEmployeesCount = function () {\n return this.usersStore.totalEmployeesCount();\n };\n Users.prototype.totalDriversCount = function () {\n return this.usersStore.totalDriversCount();\n };\n Users.prototype.getAdmin = function (adminId) {\n return this.usersStore.get(adminId);\n };\n Users.prototype.getDriver = function (driverId) {\n return this.usersStore.get(driverId);\n };\n Users.prototype.getDispatcher = function (dispatcherId) {\n return this.usersStore.get(dispatcherId);\n };\n Users.prototype.getDriversByTeam = function (teamId) {\n return this.usersStore.getDriversByTeam(teamId);\n };\n Users.prototype.getAll = function (page, limit) {\n if (page === void 0) { page = 1; }\n if (limit === void 0) { limit = 50; }\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersStore.getAll(page, limit)];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n Users.prototype.getAllKeysetPagination = function (_a) {\n var _b = _a.limit, limit = _b === void 0 ? 2500 : _b, _c = _a.page_action, page_action = _c === void 0 ? keyset_pagination_consts_1.KeysetPaginationPageAction.NEXT : _c, cursor = _a.cursor;\n return this.usersStore.getAllKeysetPagination({ limit: limit, page_action: page_action, cursor: cursor });\n };\n Users.prototype.get = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n var user;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersStore.get(userId)];\n case 1:\n user = _a.sent();\n this.usersStore.addToStore(user);\n return [2 /*return*/, user];\n }\n });\n });\n };\n Users.prototype.getLocal = function (userId) {\n return this.usersStore.getItem(userId);\n };\n Users.prototype.invite = function (userId) {\n return this.usersStore.invite(userId);\n };\n Users.prototype.unlock = function (userId) {\n return this.usersStore.unlock(userId);\n };\n Users.prototype.assignedTasksCount = function (userId) {\n return this.usersStore.assignedTasksCount(userId);\n };\n Users.prototype.inviteByEmail = function (userId) {\n return this.usersStore.inviteByEmail(userId);\n };\n Users.prototype.validatePhone = function (phone) {\n return this.usersStore.validatePhone(phone);\n };\n Users.prototype.closedTasks = function (userId, page) {\n return this.usersStore.closedTasks(userId, page);\n };\n Users.prototype.update = function (userId, userDelta) {\n var _this = this;\n return this.usersStore.update(userId, userDelta).then(function (user) { return _this.updateCurrentUserIfNeeded(user); });\n };\n Users.prototype.updateCurrentUserIfNeeded = function (user) {\n var currentUser = this.usersStore.usersService.session.user;\n if (currentUser.id === user.id) {\n this.usersStore.usersService.session.user = (0, lodash_1.merge)(currentUser, user);\n this.usersStore.usersService.session.sendDataEvent(User_consts_1.UserEvents.CURRENT_USER_UPDATED, this.usersStore.usersService.session.user);\n }\n return user;\n };\n Users.prototype.delete = function (userId) {\n return this.usersStore.delete(userId);\n };\n Users.prototype.getProfileImage = function (userId) {\n return this.usersStore.getProfileImage(userId);\n };\n Users.prototype.subscribeToGroupUpdates = function (fn) {\n this.usersStore.subscribeToGroupUpdates(fn);\n };\n Users.prototype.getOfflineDrivers = function () {\n return this.usersStore.getOfflineDrivers();\n };\n Users.prototype.getOnlineDrivers = function () {\n return this.usersStore.getOnlineDrivers();\n };\n Users.prototype.getAllLocalDrivers = function () {\n return this.usersStore.getAllLocalDrivers();\n };\n Users.prototype.getOnShiftDrivers = function () {\n return this.usersStore.getOnShiftDrivers();\n };\n Users.prototype.getAdmins = function () {\n return this.usersStore.getAdmins();\n };\n Users.prototype.getDispatchers = function () {\n return this.usersStore.getDispatchers();\n };\n Users.prototype.messageDriver = function (userId, message) {\n return this.usersStore.messageDriver(userId, message);\n };\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"create\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"getAllAdminsAndDispatchers\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"getAllDrivers\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"byUserType\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"makeAdmin\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"totalEmployeesCount\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"totalDriversCount\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"getAdmin\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"getDriver\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"getDispatcher\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"getDriversByTeam\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"getAll\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"getAllKeysetPagination\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"get\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"invite\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"unlock\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"assignedTasksCount\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"inviteByEmail\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"validatePhone\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"closedTasks\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"update\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"delete\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"getProfileImage\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"subscribeToGroupUpdates\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"getOfflineDrivers\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"getOnlineDrivers\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"getAllLocalDrivers\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"getOnShiftDrivers\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"getAdmins\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"getDispatchers\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"messageDriver\", null);\n return Users;\n}());\nexports[\"default\"] = Users;\n//# sourceMappingURL=Users.js.map\n\n//# sourceURL=webpack://BringgDashboardSDK/./dist/User/Users.js?");
|
|
2979
|
+
eval("\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n 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;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nvar BringgException_1 = __webpack_require__(/*! ../Core/BringgException */ \"./dist/Core/BringgException.js\");\nvar ExceptionReason_1 = __webpack_require__(/*! ../Core/ExceptionReason */ \"./dist/Core/ExceptionReason.js\");\nvar keyset_pagination_consts_1 = __webpack_require__(/*! ../utils/consts/keyset-pagination.consts */ \"./dist/utils/consts/keyset-pagination.consts.js\");\nvar UsersStore_1 = __webpack_require__(/*! ./Store/UsersStore */ \"./dist/User/Store/UsersStore.js\");\nvar User_consts_1 = __webpack_require__(/*! ./User.consts */ \"./dist/User/User.consts.js\");\nvar Users = /** @class */ (function () {\n function Users(session) {\n this.usersStore = new UsersStore_1.default(session);\n //keep previous names for backward compatibility\n this.onListUpdate = this.usersStore.onListUpdate;\n this.onUpdate = this.usersStore.onItemUpdate;\n this.onDelete = this.usersStore.onItemRemoved;\n this.onCreate = this.usersStore.onItemCreated;\n this.unsubscribe = this.usersStore.unsubscribe;\n }\n Users.prototype.create = function (user) {\n if ((0, lodash_1.isNil)(user.email) && (0, lodash_1.isNil)(user.phone)) {\n throw new BringgException_1.BringgException(ExceptionReason_1.ExceptionReason.INVALID_ARGUMENTS, 'Phone or Email is required');\n }\n return this.usersStore.create(user);\n };\n Users.prototype.getAllAdminsAndDispatchers = function (_a) {\n var _b = _a.limit, limit = _b === void 0 ? 25 : _b, _c = _a.page_action, page_action = _c === void 0 ? keyset_pagination_consts_1.KeysetPaginationPageAction.NEXT : _c, cursor = _a.cursor;\n return this.usersStore.getAllAdminsAndDispatchers({ limit: limit, page_action: page_action, cursor: cursor });\n };\n Users.prototype.getAllDrivers = function (_a) {\n var _b = _a.limit, limit = _b === void 0 ? 25 : _b, _c = _a.page_action, page_action = _c === void 0 ? keyset_pagination_consts_1.KeysetPaginationPageAction.NEXT : _c, cursor = _a.cursor, options = _a.options;\n var optionsWithDefaults = (0, lodash_1.defaults)(options, { onlyOnlineDriver: false, onlyCustomers: false });\n return this.usersStore.getAllDrivers({ limit: limit, page_action: page_action, cursor: cursor, options: optionsWithDefaults });\n };\n Users.prototype.byUserType = function (userTypeId) {\n return this.usersStore.byUserType(userTypeId);\n };\n Users.prototype.makeAdmin = function (userId) {\n return this.usersStore.makeAdmin(userId);\n };\n Users.prototype.totalEmployeesCount = function () {\n return this.usersStore.totalEmployeesCount();\n };\n Users.prototype.totalDriversCount = function () {\n return this.usersStore.totalDriversCount();\n };\n Users.prototype.getAdmin = function (adminId) {\n return this.usersStore.get(adminId);\n };\n Users.prototype.getDriver = function (driverId) {\n return this.usersStore.get(driverId);\n };\n Users.prototype.getDispatcher = function (dispatcherId) {\n return this.usersStore.get(dispatcherId);\n };\n Users.prototype.getDriversByTeam = function (teamId) {\n return this.usersStore.getDriversByTeam(teamId);\n };\n Users.prototype.getAll = function (page, limit) {\n if (page === void 0) { page = 1; }\n if (limit === void 0) { limit = 50; }\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersStore.getAll(page, limit)];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n Users.prototype.getAllKeysetPagination = function (_a) {\n var _b = _a.limit, limit = _b === void 0 ? 2500 : _b, _c = _a.page_action, page_action = _c === void 0 ? keyset_pagination_consts_1.KeysetPaginationPageAction.NEXT : _c, cursor = _a.cursor;\n return this.usersStore.getAllKeysetPagination({ limit: limit, page_action: page_action, cursor: cursor });\n };\n Users.prototype.get = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n var user;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersStore.get(userId)];\n case 1:\n user = _a.sent();\n this.usersStore.addToStore(user);\n return [2 /*return*/, user];\n }\n });\n });\n };\n Users.prototype.getMany = function (userIds, commonOptions) {\n return this.usersStore.getMany(userIds, commonOptions);\n };\n Users.prototype.getLocal = function (userId) {\n return this.usersStore.getItem(userId);\n };\n Users.prototype.invite = function (userId) {\n return this.usersStore.invite(userId);\n };\n Users.prototype.unlock = function (userId) {\n return this.usersStore.unlock(userId);\n };\n Users.prototype.assignedTasksCount = function (userId) {\n return this.usersStore.assignedTasksCount(userId);\n };\n Users.prototype.inviteByEmail = function (userId) {\n return this.usersStore.inviteByEmail(userId);\n };\n Users.prototype.validatePhone = function (phone) {\n return this.usersStore.validatePhone(phone);\n };\n Users.prototype.closedTasks = function (userId, page) {\n return this.usersStore.closedTasks(userId, page);\n };\n Users.prototype.update = function (userId, userDelta) {\n var _this = this;\n return this.usersStore.update(userId, userDelta).then(function (user) { return _this.updateCurrentUserIfNeeded(user); });\n };\n Users.prototype.updateCurrentUserIfNeeded = function (user) {\n var currentUser = this.usersStore.usersService.session.user;\n if (currentUser.id === user.id) {\n this.usersStore.usersService.session.user = (0, lodash_1.merge)(currentUser, user);\n this.usersStore.usersService.session.sendDataEvent(User_consts_1.UserEvents.CURRENT_USER_UPDATED, this.usersStore.usersService.session.user);\n }\n return user;\n };\n Users.prototype.delete = function (userId) {\n return this.usersStore.delete(userId);\n };\n Users.prototype.getProfileImage = function (userId) {\n return this.usersStore.getProfileImage(userId);\n };\n Users.prototype.subscribeToGroupUpdates = function (fn) {\n this.usersStore.subscribeToGroupUpdates(fn);\n };\n Users.prototype.getOfflineDrivers = function () {\n return this.usersStore.getOfflineDrivers();\n };\n Users.prototype.getOnlineDrivers = function () {\n return this.usersStore.getOnlineDrivers();\n };\n Users.prototype.getAllLocalDrivers = function () {\n return this.usersStore.getAllLocalDrivers();\n };\n Users.prototype.getOnShiftDrivers = function () {\n return this.usersStore.getOnShiftDrivers();\n };\n Users.prototype.getAdmins = function () {\n return this.usersStore.getAdmins();\n };\n Users.prototype.getDispatchers = function () {\n return this.usersStore.getDispatchers();\n };\n Users.prototype.messageDriver = function (userId, message) {\n return this.usersStore.messageDriver(userId, message);\n };\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"create\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"getAllAdminsAndDispatchers\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"getAllDrivers\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"byUserType\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"makeAdmin\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"totalEmployeesCount\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"totalDriversCount\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"getAdmin\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"getDriver\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"getDispatcher\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"getDriversByTeam\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"getAll\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"getAllKeysetPagination\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"get\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"getMany\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"invite\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"unlock\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"assignedTasksCount\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"inviteByEmail\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"validatePhone\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"closedTasks\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"update\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"delete\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"getProfileImage\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"subscribeToGroupUpdates\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"getOfflineDrivers\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"getOnlineDrivers\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"getAllLocalDrivers\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"getOnShiftDrivers\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"getAdmins\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"getDispatchers\", null);\n __decorate([\n BringgException_1.logOnException\n ], Users.prototype, \"messageDriver\", null);\n return Users;\n}());\nexports[\"default\"] = Users;\n//# sourceMappingURL=Users.js.map\n\n//# sourceURL=webpack://BringgDashboardSDK/./dist/User/Users.js?");
|
|
2980
2980
|
|
|
2981
2981
|
/***/ }),
|
|
2982
2982
|
|