@bringg/dashboard-sdk 9.59.2 → 9.59.4
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/Privileges/PrivilegeService.d.ts +6 -0
- package/dist/Privileges/PrivilegeService.js +14 -0
- package/dist/Privileges/PrivilegeService.js.map +1 -1
- package/dist/Privileges/PrivilegesApi.d.ts +5 -1
- package/dist/Privileges/PrivilegesApi.js +8 -1
- package/dist/Privileges/PrivilegesApi.js.map +1 -1
- package/dist/Services/ServiceRequest.js +1 -1
- package/dist/User/v2/users-api.js +1 -1
- package/dist/User/v2/users-api.js.map +1 -1
- package/dist/User/v2/users-service.js +1 -0
- package/dist/User/v2/users-service.js.map +1 -1
- package/dist/bringg-dashboard-sdk-cjs2.js +26 -3
- package/dist/bringg-dashboard-sdk-cjs2.js.map +1 -1
- package/dist/bringg-dashboard-sdk.js +6 -6
- package/dist/bringg-dashboard-sdk.min.js +1 -1
- package/dist/bringg-dashboard-sdk.min.js.map +1 -1
- package/dist/storable-data-service.js +1 -0
- package/dist/storable-data-service.js.map +1 -1
- package/package.json +2 -2
|
@@ -1766,7 +1766,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
|
1766
1766
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
1767
1767
|
|
|
1768
1768
|
"use strict";
|
|
1769
|
-
eval("\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 __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar CrudService_1 = __importDefault(__webpack_require__(/*! ../Core/CrudService */ \"./dist/Core/CrudService.js\"));\nvar entityName = 'privileges';\nvar PrivilegeService = /** @class */ (function () {\n function PrivilegeService(session) {\n this.service = new CrudService_1.default(session, entityName);\n }\n PrivilegeService.prototype.create = function (payload) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.service.routeGenerator\n .post(\"/\".concat(entityName))\n .withPayload(payload)\n .setException('failed to create privilege')\n .invoke()];\n });\n });\n };\n PrivilegeService.prototype.getList = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.service.routeGenerator\n .get(\"/\".concat(entityName, \"/get_list\"))\n .withExtractor(function (response) { return response.privileges; })\n .setException('failed to get list of privileges')\n .invoke()];\n });\n });\n };\n return PrivilegeService;\n}());\nexports[\"default\"] = PrivilegeService;\n//# sourceMappingURL=PrivilegeService.js.map\n\n//# sourceURL=webpack://BringgDashboardSDK/./dist/Privileges/PrivilegeService.js?");
|
|
1769
|
+
eval("\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 __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar CrudService_1 = __importDefault(__webpack_require__(/*! ../Core/CrudService */ \"./dist/Core/CrudService.js\"));\nvar entityName = 'privileges';\nvar PrivilegeService = /** @class */ (function () {\n function PrivilegeService(session) {\n this.service = new CrudService_1.default(session, entityName);\n }\n PrivilegeService.prototype.get = function (id) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.service.get(id)];\n });\n });\n };\n PrivilegeService.prototype.create = function (payload) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.service.routeGenerator\n .post(\"/\".concat(entityName))\n .withPayload(payload)\n .setException('failed to create privilege')\n .invoke()];\n });\n });\n };\n PrivilegeService.prototype.getList = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.service.routeGenerator\n .get(\"/\".concat(entityName, \"/get_list\"))\n .withExtractor(function (response) { return response.privileges; })\n .setException('failed to get list of privileges')\n .invoke()];\n });\n });\n };\n PrivilegeService.prototype.update = function (id, payload) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.service.update(id, payload)];\n });\n });\n };\n return PrivilegeService;\n}());\nexports[\"default\"] = PrivilegeService;\n//# sourceMappingURL=PrivilegeService.js.map\n\n//# sourceURL=webpack://BringgDashboardSDK/./dist/Privileges/PrivilegeService.js?");
|
|
1770
1770
|
|
|
1771
1771
|
/***/ }),
|
|
1772
1772
|
|
|
@@ -1777,7 +1777,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
|
1777
1777
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
1778
1778
|
|
|
1779
1779
|
"use strict";
|
|
1780
|
-
eval("\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 __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar PrivilegeEntity_1 = __importDefault(__webpack_require__(/*! ./Entity/PrivilegeEntity */ \"./dist/Privileges/Entity/PrivilegeEntity.js\"));\nvar Privilege_consts_1 = __webpack_require__(/*! ./Privilege.consts */ \"./dist/Privileges/Privilege.consts.js\");\nvar PrivilegeService_1 = __importDefault(__webpack_require__(/*! ./PrivilegeService */ \"./dist/Privileges/PrivilegeService.js\"));\nvar PrivilegesApi = /** @class */ (function () {\n function PrivilegesApi(session) {\n this.privilegeEntity = new PrivilegeEntity_1.default(session);\n this.privilegeService = new PrivilegeService_1.default(session);\n }\n PrivilegesApi.prototype.getAll = function () {\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 = Privilege_consts_1.privilegeExtractor;\n return [4 /*yield*/, this.privilegeEntity.service.getAll()];\n case 1: return [2 /*return*/, _a.apply(void 0, [_b.sent()])];\n }\n });\n });\n };\n PrivilegesApi.prototype.getById = function (id) {\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.
|
|
1780
|
+
eval("\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 __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar PrivilegeEntity_1 = __importDefault(__webpack_require__(/*! ./Entity/PrivilegeEntity */ \"./dist/Privileges/Entity/PrivilegeEntity.js\"));\nvar Privilege_consts_1 = __webpack_require__(/*! ./Privilege.consts */ \"./dist/Privileges/Privilege.consts.js\");\nvar PrivilegeService_1 = __importDefault(__webpack_require__(/*! ./PrivilegeService */ \"./dist/Privileges/PrivilegeService.js\"));\nvar PrivilegesApi = /** @class */ (function () {\n function PrivilegesApi(session) {\n this.privilegeEntity = new PrivilegeEntity_1.default(session);\n this.privilegeService = new PrivilegeService_1.default(session);\n }\n PrivilegesApi.prototype.getAll = function () {\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 = Privilege_consts_1.privilegeExtractor;\n return [4 /*yield*/, this.privilegeEntity.service.getAll()];\n case 1: return [2 /*return*/, _a.apply(void 0, [_b.sent()])];\n }\n });\n });\n };\n PrivilegesApi.prototype.getById = function (id) {\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.privilegeService.get(id)];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n PrivilegesApi.prototype.create = function (payload) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.privilegeService.create(payload)];\n });\n });\n };\n PrivilegesApi.prototype.getList = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.privilegeService.getList()];\n });\n });\n };\n PrivilegesApi.prototype.update = function (id, payload) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.privilegeService.update(id, payload)];\n });\n });\n };\n return PrivilegesApi;\n}());\nexports[\"default\"] = PrivilegesApi;\n//# sourceMappingURL=PrivilegesApi.js.map\n\n//# sourceURL=webpack://BringgDashboardSDK/./dist/Privileges/PrivilegesApi.js?");
|
|
1781
1781
|
|
|
1782
1782
|
/***/ }),
|
|
1783
1783
|
|
|
@@ -2404,7 +2404,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
|
2404
2404
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
2405
2405
|
|
|
2406
2406
|
"use strict";
|
|
2407
|
-
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};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.AnonymousServiceRequest = exports.AuthorizedServiceRequest = exports.ResponseHandler = exports.RequestOptions = exports.logErrorResponse = void 0;\nvar axios_1 = __importDefault(__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 = __importDefault(__webpack_require__(/*! ../Core/Logger */ \"./dist/Core/Logger.js\"));\nvar abort_1 = __webpack_require__(/*! ../utils/abort */ \"./dist/utils/abort.js\");\nvar version = '9.59.2';\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, queryString, authenticationToken, 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, routeParams, 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, headers, 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}\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, routeParams, queryString, payload, 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, routeParams, 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?");
|
|
2407
|
+
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};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.AnonymousServiceRequest = exports.AuthorizedServiceRequest = exports.ResponseHandler = exports.RequestOptions = exports.logErrorResponse = void 0;\nvar axios_1 = __importDefault(__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 = __importDefault(__webpack_require__(/*! ../Core/Logger */ \"./dist/Core/Logger.js\"));\nvar abort_1 = __webpack_require__(/*! ../utils/abort */ \"./dist/utils/abort.js\");\nvar version = '9.59.4';\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, queryString, authenticationToken, 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, routeParams, 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, headers, 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}\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, routeParams, queryString, payload, 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, routeParams, 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?");
|
|
2408
2408
|
|
|
2409
2409
|
/***/ }),
|
|
2410
2410
|
|
|
@@ -3086,7 +3086,7 @@ eval("\nvar __decorate = (this && this.__decorate) || function (decorators, targ
|
|
|
3086
3086
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
3087
3087
|
|
|
3088
3088
|
"use strict";
|
|
3089
|
-
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};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\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 merge_mapper_1 = __webpack_require__(/*! ../../Data/merge-mapper */ \"./dist/Data/merge-mapper.js\");\nvar storable_realtime_subscriptions_1 = __importDefault(__webpack_require__(/*! ../../Data/storable-realtime-subscriptions */ \"./dist/Data/storable-realtime-subscriptions.js\"));\nvar data_entity_1 = __webpack_require__(/*! ../../data-entity */ \"./dist/data-entity.js\");\nvar data_store_1 = __importDefault(__webpack_require__(/*! ../../data-store */ \"./dist/data-store.js\"));\nvar storable_data_service_1 = __importDefault(__webpack_require__(/*! ../../storable-data-service */ \"./dist/storable-data-service.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 users_service_1 = __importDefault(__webpack_require__(/*! ./users-service */ \"./dist/User/v2/users-service.js\"));\nvar UsersApi = /** @class */ (function () {\n function UsersApi(session) {\n var _this = this;\n var groupFilters = [\n {\n groupType: User_consts_1.UserGroupTypes.Main,\n keyFunc: function (user) { return (0, User_consts_1.userToGroupsMapper)(user); }\n },\n {\n groupType: 'teamAndDriver',\n keyFunc: function (user) { return (user.driver && user.team_ids) || []; }\n }\n ];\n this.userStore = new data_store_1.default(groupFilters, { shallow: true });\n this.usersService = new users_service_1.default(session);\n this.storableDataService = new storable_data_service_1.default(this.userStore, function (user) {\n return merge_mapper_1.mergeMapper.mergeIntoExisting(_this.userStore, user);\n });\n this.storableRealtimeSubscriptions = new storable_realtime_subscriptions_1.default(session, this.userStore, this.storableDataService);\n this.storableRealtimeSubscriptions.updateStoreOnEvents([\n {\n name: User_consts_1.RealtimeEvents.Update,\n isDelete: false,\n extraDataFunc: function (user) {\n return { ignore: !_this.userStore.get(user.id) };\n }\n },\n { name: User_consts_1.RealtimeEvents.Create, isDelete: false },\n { name: User_consts_1.RealtimeEvents.Delete, isDelete: true }\n ]);\n }\n UsersApi.prototype.delete = function (userId) {\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.storableDataService.delete('delete', function () { 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.delete(userId)];\n case 1:\n response = _a.sent();\n return [2 /*return*/, response];\n }\n });\n }); }, userId)];\n case 1:\n _a.sent();\n return [2 /*return*/, response];\n }\n });\n });\n };\n UsersApi.prototype.deleteMany = function (userIds) {\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.storableDataService.deleteMany('deleteMany', function () { 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.deleteMany(userIds)];\n case 1:\n response = _a.sent();\n return [2 /*return*/, response];\n }\n });\n }); }, userIds)];\n case 1:\n _a.sent();\n return [2 /*return*/, response];\n }\n });\n });\n };\n UsersApi.prototype.create = function (user) {\n return __awaiter(this, void 0, void 0, function () {\n var _this = this;\n return __generator(this, function (_a) {\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 [2 /*return*/, this.storableDataService.modify('create', function () { return _this.usersService.create(user); })];\n });\n });\n };\n UsersApi.prototype.update = function (userId, userDelta) {\n return __awaiter(this, void 0, void 0, function () {\n var _this = this;\n return __generator(this, function (_a) {\n return [2 /*return*/, this.storableDataService.modify('update', function () { return _this.usersService.update(userId, userDelta); }, function (modifiedUser) {\n var currentUser = _this.usersService.session.user;\n if (currentUser.id === modifiedUser.current.id) {\n _this.usersService.session.user = (0, lodash_1.merge)(currentUser, modifiedUser.current);\n _this.usersService.session.sendDataEvent(User_consts_1.UserEvents.CURRENT_USER_UPDATED, _this.usersService.session.user);\n }\n })];\n });\n });\n };\n UsersApi.prototype.load = function (userId, options) {\n if (options === void 0) { options = data_entity_1.DEFAULT_OPTIONS; }\n return __awaiter(this, void 0, void 0, function () {\n var _this = this;\n return __generator(this, function (_a) {\n return [2 /*return*/, this.storableDataService.load('load', function () { return _this.usersService.get(userId); }, userId, options)];\n });\n });\n };\n UsersApi.prototype.loadMany = function (ids, options) {\n if (options === void 0) { options = { useCache: true }; }\n return __awaiter(this, void 0, void 0, function () {\n var chunkSize;\n var _this = this;\n return __generator(this, function (_a) {\n if (ids.length === 0) {\n return [2 /*return*/, []];\n }\n chunkSize = options.chunkSize || 500;\n return [2 /*return*/, this.storableDataService.loadMany('loadMany', function (idsToLoad) { return __awaiter(_this, void 0, void 0, function () {\n var users;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.loadMany({ ids: idsToLoad, limit: chunkSize })];\n case 1:\n users = _a.sent();\n return [2 /*return*/, users];\n }\n });\n }); }, ids, __assign(__assign({}, options), { chunkSize: chunkSize }))];\n });\n });\n };\n UsersApi.prototype.loadAllByTeam = function (teamId, options) {\n return __awaiter(this, void 0, void 0, function () {\n var _this = this;\n return __generator(this, function (_a) {\n return [2 /*return*/, this.storableDataService.loadAll('loadDriversByTeam', function () { return __awaiter(_this, void 0, void 0, function () {\n var users;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.loadAllByTeams(teamId)];\n case 1:\n users = _a.sent();\n return [2 /*return*/, users];\n }\n });\n }); }, __assign(__assign({}, options), { groupType: 'teamAndDriver', groupValue: teamId }))];\n });\n });\n };\n // Pagination methods\n UsersApi.prototype.loadAll = function (_a) {\n var _b = _a === void 0 ? {} : _a, _c = _b.limit, limit = _c === void 0 ? 2500 : _c, page = _b.page, _d = _b.page_action, page_action = _d === void 0 ? keyset_pagination_consts_1.KeysetPaginationPageAction.NEXT : _d, cursor = _b.cursor, options = _b.options;\n return __awaiter(this, void 0, void 0, function () {\n var loadResult, loadFunc, users;\n var _this = this;\n return __generator(this, function (_e) {\n switch (_e.label) {\n case 0:\n loadFunc = function () { 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.usersService.loadAll({ limit: limit, page: page, page_action: page_action, cursor: cursor }, { signal: options === null || options === void 0 ? void 0 : options.signal })];\n case 1:\n response = _a.sent();\n loadResult = response;\n return [2 /*return*/, response.users];\n }\n });\n }); };\n return [4 /*yield*/, this.storableDataService.loadMany('loadAll', loadFunc, [], options)];\n case 1:\n users = _e.sent();\n return [2 /*return*/, __assign(__assign({}, loadResult), { users: users })];\n }\n });\n });\n };\n UsersApi.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 return __awaiter(this, void 0, void 0, function () {\n var optionsWithDefaults, loadResult, loadFunc, users;\n var _this = this;\n return __generator(this, function (_d) {\n switch (_d.label) {\n case 0:\n optionsWithDefaults = (0, lodash_1.defaults)(options, { onlyOnlineDriver: false, onlyCustomers: false });\n loadFunc = function () { 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.usersService.getAllDrivers({\n limit: limit,\n page_action: page_action,\n cursor: cursor,\n options: optionsWithDefaults\n })];\n case 1:\n result = _a.sent();\n loadResult = result;\n return [2 /*return*/, result.users];\n }\n });\n }); };\n return [4 /*yield*/, this.storableDataService.loadMany('getAllDrivers', loadFunc, [])];\n case 1:\n users = _d.sent();\n return [2 /*return*/, __assign(__assign({}, loadResult), { users: users })];\n }\n });\n });\n };\n UsersApi.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, options = _a.options;\n return __awaiter(this, void 0, void 0, function () {\n var loadResult, loadFunc, users;\n var _this = this;\n return __generator(this, function (_d) {\n switch (_d.label) {\n case 0:\n loadFunc = function () { 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.usersService.getAllAdminsAndDispatchers({\n limit: limit,\n page_action: page_action,\n cursor: cursor\n })];\n case 1:\n result = _a.sent();\n loadResult = result;\n return [2 /*return*/, result.users];\n }\n });\n }); };\n return [4 /*yield*/, this.storableDataService.loadMany('getAllAdminsAndDispatchers', loadFunc, [])];\n case 1:\n users = _d.sent();\n return [2 /*return*/, __assign(__assign({}, loadResult), { users: users })];\n }\n });\n });\n };\n // Business logic methods\n UsersApi.prototype.messageDriver = function (userId, message) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.usersService.messageDriver(userId, message)];\n });\n });\n };\n UsersApi.prototype.unlock = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.usersService.unlock(userId)];\n });\n });\n };\n UsersApi.prototype.validatePhone = function (phone) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.usersService.validatePhone(phone)];\n });\n });\n };\n UsersApi.prototype.getDriverCost = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.usersService.getDriverCost(userId)];\n });\n });\n };\n UsersApi.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.storableDataService.updateInStores(user);\n return [2 /*return*/, user];\n }\n });\n });\n };\n UsersApi.prototype.closedTasks = function (userId, page) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.usersService.closedTasks(userId, page)];\n });\n });\n };\n UsersApi.prototype.assignedTasksCount = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.usersService.assignedTasksCount(userId)];\n });\n });\n };\n UsersApi.prototype.byUserType = function (userTypeId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.usersService.byUserType(userTypeId)];\n });\n });\n };\n // Store query methods - direct access to local store without API calls\n UsersApi.prototype.getGroup = function (group) {\n return this.userStore.getGroup(User_consts_1.UserGroupTypes.Main, group);\n };\n UsersApi.prototype.getTeamGroup = function (teamId) {\n return this.userStore.getGroup('teamAndDriver', teamId);\n };\n UsersApi.prototype.get = function (id) {\n return this.userStore.get(id);\n };\n UsersApi.prototype.getMany = function (ids) {\n return this.userStore.getMany(ids);\n };\n UsersApi.prototype.getAll = function () {\n return this.userStore.getAll();\n };\n UsersApi.prototype.getOfflineDrivers = function () {\n var group = this.userStore.getGroup(User_consts_1.UserGroupTypes.Main, User_consts_1.GROUP_VALUES.OfflineDrivers);\n return group ? Array.from(group) : [];\n };\n UsersApi.prototype.getOnlineDrivers = function () {\n var group = this.userStore.getGroup(User_consts_1.UserGroupTypes.Main, User_consts_1.GROUP_VALUES.OnlineDrivers);\n return group ? Array.from(group) : [];\n };\n UsersApi.prototype.getAllLocalDrivers = function () {\n var group = this.userStore.getGroup(User_consts_1.UserGroupTypes.Main, User_consts_1.GROUP_VALUES.Drivers);\n return group ? Array.from(group) : [];\n };\n UsersApi.prototype.getOnShiftDrivers = function () {\n var group = this.userStore.getGroup(User_consts_1.UserGroupTypes.Main, User_consts_1.GROUP_VALUES.OnShiftDrivers);\n return group ? Array.from(group) : [];\n };\n // Additional callback methods\n UsersApi.prototype.onCreate = function (callback) {\n return this.storableRealtimeSubscriptions.onEvent(User_consts_1.RealtimeEvents.Create, callback);\n };\n UsersApi.prototype.onUpdate = function (callback) {\n return this.storableRealtimeSubscriptions.onEvent(User_consts_1.RealtimeEvents.Update, callback);\n };\n UsersApi.prototype.onDelete = function (callback) {\n return this.storableRealtimeSubscriptions.onEvent(User_consts_1.RealtimeEvents.Delete, callback);\n };\n return UsersApi;\n}());\nexports[\"default\"] = UsersApi;\n//# sourceMappingURL=users-api.js.map\n\n//# sourceURL=webpack://BringgDashboardSDK/./dist/User/v2/users-api.js?");
|
|
3089
|
+
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};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\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 merge_mapper_1 = __webpack_require__(/*! ../../Data/merge-mapper */ \"./dist/Data/merge-mapper.js\");\nvar storable_realtime_subscriptions_1 = __importDefault(__webpack_require__(/*! ../../Data/storable-realtime-subscriptions */ \"./dist/Data/storable-realtime-subscriptions.js\"));\nvar data_entity_1 = __webpack_require__(/*! ../../data-entity */ \"./dist/data-entity.js\");\nvar data_store_1 = __importDefault(__webpack_require__(/*! ../../data-store */ \"./dist/data-store.js\"));\nvar storable_data_service_1 = __importDefault(__webpack_require__(/*! ../../storable-data-service */ \"./dist/storable-data-service.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 users_service_1 = __importDefault(__webpack_require__(/*! ./users-service */ \"./dist/User/v2/users-service.js\"));\nvar UsersApi = /** @class */ (function () {\n function UsersApi(session) {\n var _this = this;\n var groupFilters = [\n {\n groupType: User_consts_1.UserGroupTypes.Main,\n keyFunc: function (user) { return (0, User_consts_1.userToGroupsMapper)(user); }\n },\n {\n groupType: 'teamAndDriver',\n keyFunc: function (user) { return (user.driver && user.team_ids) || []; }\n }\n ];\n this.userStore = new data_store_1.default(groupFilters, { shallow: true });\n this.usersService = new users_service_1.default(session);\n this.storableDataService = new storable_data_service_1.default(this.userStore, function (user) {\n return merge_mapper_1.mergeMapper.mergeIntoExisting(_this.userStore, user);\n });\n this.storableRealtimeSubscriptions = new storable_realtime_subscriptions_1.default(session, this.userStore, this.storableDataService);\n this.storableRealtimeSubscriptions.updateStoreOnEvents([\n {\n name: User_consts_1.RealtimeEvents.Update,\n isDelete: false,\n extraDataFunc: function (user) {\n return { ignore: !_this.userStore.get(user.id) };\n }\n },\n { name: User_consts_1.RealtimeEvents.Create, isDelete: false },\n { name: User_consts_1.RealtimeEvents.Delete, isDelete: true }\n ]);\n }\n UsersApi.prototype.delete = function (userId) {\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.storableDataService.delete('delete', function () { 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.delete(userId)];\n case 1:\n response = _a.sent();\n return [2 /*return*/, response];\n }\n });\n }); }, userId)];\n case 1:\n _a.sent();\n return [2 /*return*/, response];\n }\n });\n });\n };\n UsersApi.prototype.deleteMany = function (userIds) {\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.storableDataService.deleteMany('deleteMany', function () { 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.deleteMany(userIds)];\n case 1:\n response = _a.sent();\n return [2 /*return*/, response];\n }\n });\n }); }, userIds)];\n case 1:\n _a.sent();\n return [2 /*return*/, response];\n }\n });\n });\n };\n UsersApi.prototype.create = function (user) {\n return __awaiter(this, void 0, void 0, function () {\n var _this = this;\n return __generator(this, function (_a) {\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 [2 /*return*/, this.storableDataService.modify('create', function () { return _this.usersService.create(user); })];\n });\n });\n };\n UsersApi.prototype.update = function (userId, userDelta) {\n return __awaiter(this, void 0, void 0, function () {\n var _this = this;\n return __generator(this, function (_a) {\n return [2 /*return*/, this.storableDataService.modify('update', function () { return _this.usersService.update(userId, userDelta); }, function (modifiedUser) {\n var currentUser = _this.usersService.session.user;\n if (currentUser.id === modifiedUser.current.id) {\n _this.usersService.session.user = (0, lodash_1.merge)(currentUser, modifiedUser.current);\n _this.usersService.session.sendDataEvent(User_consts_1.UserEvents.CURRENT_USER_UPDATED, _this.usersService.session.user);\n }\n })];\n });\n });\n };\n UsersApi.prototype.load = function (userId, options) {\n if (options === void 0) { options = data_entity_1.DEFAULT_OPTIONS; }\n return __awaiter(this, void 0, void 0, function () {\n var _this = this;\n return __generator(this, function (_a) {\n return [2 /*return*/, this.storableDataService.load('load', function () { return _this.usersService.get(userId); }, userId, options)];\n });\n });\n };\n UsersApi.prototype.loadMany = function (ids, options) {\n if (options === void 0) { options = { useCache: true }; }\n return __awaiter(this, void 0, void 0, function () {\n var chunkSize;\n var _this = this;\n return __generator(this, function (_a) {\n if (ids.length === 0) {\n return [2 /*return*/, []];\n }\n chunkSize = options.chunkSize || 500;\n return [2 /*return*/, this.storableDataService.loadMany('loadMany', function (idsToLoad) { return __awaiter(_this, void 0, void 0, function () {\n var users;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.loadMany({ ids: idsToLoad, limit: chunkSize, page: 1 })];\n case 1:\n users = _a.sent();\n return [2 /*return*/, users];\n }\n });\n }); }, ids, __assign(__assign({}, options), { chunkSize: chunkSize }))];\n });\n });\n };\n UsersApi.prototype.loadAllByTeam = function (teamId, options) {\n return __awaiter(this, void 0, void 0, function () {\n var _this = this;\n return __generator(this, function (_a) {\n return [2 /*return*/, this.storableDataService.loadAll('loadDriversByTeam', function () { return __awaiter(_this, void 0, void 0, function () {\n var users;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.usersService.loadAllByTeams(teamId)];\n case 1:\n users = _a.sent();\n return [2 /*return*/, users];\n }\n });\n }); }, __assign(__assign({}, options), { groupType: 'teamAndDriver', groupValue: teamId }))];\n });\n });\n };\n // Pagination methods\n UsersApi.prototype.loadAll = function (_a) {\n var _b = _a === void 0 ? {} : _a, _c = _b.limit, limit = _c === void 0 ? 2500 : _c, page = _b.page, _d = _b.page_action, page_action = _d === void 0 ? keyset_pagination_consts_1.KeysetPaginationPageAction.NEXT : _d, cursor = _b.cursor, options = _b.options;\n return __awaiter(this, void 0, void 0, function () {\n var loadResult, loadFunc, users;\n var _this = this;\n return __generator(this, function (_e) {\n switch (_e.label) {\n case 0:\n loadFunc = function () { 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.usersService.loadAll({ limit: limit, page: page, page_action: page_action, cursor: cursor }, { signal: options === null || options === void 0 ? void 0 : options.signal })];\n case 1:\n response = _a.sent();\n loadResult = response;\n return [2 /*return*/, response.users];\n }\n });\n }); };\n return [4 /*yield*/, this.storableDataService.loadMany('loadAll', loadFunc, [], options)];\n case 1:\n users = _e.sent();\n return [2 /*return*/, __assign(__assign({}, loadResult), { users: users })];\n }\n });\n });\n };\n UsersApi.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 return __awaiter(this, void 0, void 0, function () {\n var optionsWithDefaults, loadResult, loadFunc, users;\n var _this = this;\n return __generator(this, function (_d) {\n switch (_d.label) {\n case 0:\n optionsWithDefaults = (0, lodash_1.defaults)(options, { onlyOnlineDriver: false, onlyCustomers: false });\n loadFunc = function () { 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.usersService.getAllDrivers({\n limit: limit,\n page_action: page_action,\n cursor: cursor,\n options: optionsWithDefaults\n })];\n case 1:\n result = _a.sent();\n loadResult = result;\n return [2 /*return*/, result.users];\n }\n });\n }); };\n return [4 /*yield*/, this.storableDataService.loadMany('getAllDrivers', loadFunc, [])];\n case 1:\n users = _d.sent();\n return [2 /*return*/, __assign(__assign({}, loadResult), { users: users })];\n }\n });\n });\n };\n UsersApi.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, options = _a.options;\n return __awaiter(this, void 0, void 0, function () {\n var loadResult, loadFunc, users;\n var _this = this;\n return __generator(this, function (_d) {\n switch (_d.label) {\n case 0:\n loadFunc = function () { 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.usersService.getAllAdminsAndDispatchers({\n limit: limit,\n page_action: page_action,\n cursor: cursor\n })];\n case 1:\n result = _a.sent();\n loadResult = result;\n return [2 /*return*/, result.users];\n }\n });\n }); };\n return [4 /*yield*/, this.storableDataService.loadMany('getAllAdminsAndDispatchers', loadFunc, [])];\n case 1:\n users = _d.sent();\n return [2 /*return*/, __assign(__assign({}, loadResult), { users: users })];\n }\n });\n });\n };\n // Business logic methods\n UsersApi.prototype.messageDriver = function (userId, message) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.usersService.messageDriver(userId, message)];\n });\n });\n };\n UsersApi.prototype.unlock = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.usersService.unlock(userId)];\n });\n });\n };\n UsersApi.prototype.validatePhone = function (phone) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.usersService.validatePhone(phone)];\n });\n });\n };\n UsersApi.prototype.getDriverCost = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.usersService.getDriverCost(userId)];\n });\n });\n };\n UsersApi.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.storableDataService.updateInStores(user);\n return [2 /*return*/, user];\n }\n });\n });\n };\n UsersApi.prototype.closedTasks = function (userId, page) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.usersService.closedTasks(userId, page)];\n });\n });\n };\n UsersApi.prototype.assignedTasksCount = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.usersService.assignedTasksCount(userId)];\n });\n });\n };\n UsersApi.prototype.byUserType = function (userTypeId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.usersService.byUserType(userTypeId)];\n });\n });\n };\n // Store query methods - direct access to local store without API calls\n UsersApi.prototype.getGroup = function (group) {\n return this.userStore.getGroup(User_consts_1.UserGroupTypes.Main, group);\n };\n UsersApi.prototype.getTeamGroup = function (teamId) {\n return this.userStore.getGroup('teamAndDriver', teamId);\n };\n UsersApi.prototype.get = function (id) {\n return this.userStore.get(id);\n };\n UsersApi.prototype.getMany = function (ids) {\n return this.userStore.getMany(ids);\n };\n UsersApi.prototype.getAll = function () {\n return this.userStore.getAll();\n };\n UsersApi.prototype.getOfflineDrivers = function () {\n var group = this.userStore.getGroup(User_consts_1.UserGroupTypes.Main, User_consts_1.GROUP_VALUES.OfflineDrivers);\n return group ? Array.from(group) : [];\n };\n UsersApi.prototype.getOnlineDrivers = function () {\n var group = this.userStore.getGroup(User_consts_1.UserGroupTypes.Main, User_consts_1.GROUP_VALUES.OnlineDrivers);\n return group ? Array.from(group) : [];\n };\n UsersApi.prototype.getAllLocalDrivers = function () {\n var group = this.userStore.getGroup(User_consts_1.UserGroupTypes.Main, User_consts_1.GROUP_VALUES.Drivers);\n return group ? Array.from(group) : [];\n };\n UsersApi.prototype.getOnShiftDrivers = function () {\n var group = this.userStore.getGroup(User_consts_1.UserGroupTypes.Main, User_consts_1.GROUP_VALUES.OnShiftDrivers);\n return group ? Array.from(group) : [];\n };\n // Additional callback methods\n UsersApi.prototype.onCreate = function (callback) {\n return this.storableRealtimeSubscriptions.onEvent(User_consts_1.RealtimeEvents.Create, callback);\n };\n UsersApi.prototype.onUpdate = function (callback) {\n return this.storableRealtimeSubscriptions.onEvent(User_consts_1.RealtimeEvents.Update, callback);\n };\n UsersApi.prototype.onDelete = function (callback) {\n return this.storableRealtimeSubscriptions.onEvent(User_consts_1.RealtimeEvents.Delete, callback);\n };\n return UsersApi;\n}());\nexports[\"default\"] = UsersApi;\n//# sourceMappingURL=users-api.js.map\n\n//# sourceURL=webpack://BringgDashboardSDK/./dist/User/v2/users-api.js?");
|
|
3090
3090
|
|
|
3091
3091
|
/***/ }),
|
|
3092
3092
|
|
|
@@ -3097,7 +3097,7 @@ eval("\nvar __assign = (this && this.__assign) || function () {\n __assign =
|
|
|
3097
3097
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
3098
3098
|
|
|
3099
3099
|
"use strict";
|
|
3100
|
-
eval("\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 __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar types_1 = __webpack_require__(/*! @bringg/types */ \"./node_modules/@bringg/types/index.js\");\nvar CrudService_1 = __importDefault(__webpack_require__(/*! ../../Core/CrudService */ \"./dist/Core/CrudService.js\"));\nvar User_consts_1 = __webpack_require__(/*! ../User.consts */ \"./dist/User/User.consts.js\");\nvar UsersService = /** @class */ (function () {\n function UsersService(session) {\n this.service = new CrudService_1.default(session, 'users');\n }\n Object.defineProperty(UsersService.prototype, \"session\", {\n get: function () {\n return this.service.session;\n },\n enumerable: false,\n configurable: true\n });\n UsersService.prototype.delete = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.service.delete(userId)];\n });\n });\n };\n UsersService.prototype.deleteMany = function (userIds) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.service.routeGenerator\n .delete(User_consts_1.ROUTES.DELETE_MANY)\n .withPayload({ ids: userIds })\n .withExtractor(function (response) { return response; })\n .setException('Could not delete users')\n .invoke()];\n });\n });\n };\n UsersService.prototype.closedTasks = function (userId, page) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.service.routeGenerator\n .get(User_consts_1.ROUTES.CLOSED_TASKS)\n .withRouteParams({ userId: userId })\n .withQueryString({ page: page })\n .withExtractor(function (response) { return response; })\n .setException(\"Could not get closed tasks for user \".concat(userId))\n .invoke()];\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 return [2 /*return*/, this.service.routeGenerator\n .get(User_consts_1.ROUTES.TOTAL_TASKS)\n .withRouteParams({ userId: userId })\n .withExtractor(function (response) { return response.count; })\n .setException(\"Could not get assigned tasks count for user \".concat(userId))\n .invoke()];\n });\n });\n };\n UsersService.prototype.create = function (user) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.service.create(user).then(function (response) { return response.user; })];\n });\n });\n };\n UsersService.prototype.update = function (userId, userDelta) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.service.update(userId, userDelta).then(function (response) { return response.user; })];\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 return [2 /*return*/, this.service.get(userId).then(function (user) { return user; })];\n });\n });\n };\n UsersService.prototype.loadAll = function (request, commonOptions) {\n return __awaiter(this, void 0, void 0, function () {\n var limit, page_action, cursor;\n return __generator(this, function (_a) {\n limit = request.limit, page_action = request.page_action, cursor = request.cursor;\n return [2 /*return*/, this.service.routeGenerator\n .get(User_consts_1.ROUTES.GET_ALL)\n .withQueryString({ pgver: types_1.KEYSET_PAGINATION_VER, limit: limit, page_action: page_action, cursor: cursor })\n .withExtractor(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 .setException('Could not get users')\n .withCommonOptions(commonOptions)\n .invoke()];\n });\n });\n };\n UsersService.prototype.loadMany = function (query, commonOptions) {\n if (query === void 0) { query = {}; }\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.service.routeGenerator\n .get(User_consts_1.ROUTES.GET_ALL)\n .withQueryString(query)\n .setException('Could not get users by ids')\n .withCommonOptions(commonOptions)\n .invoke()];\n });\n });\n };\n UsersService.prototype.loadAllByTeams = function (teamId, commonOptions) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.service.routeGenerator\n .get(User_consts_1.ROUTES.GET_DRIVERS_BY_TEAM)\n .withRouteParams({ teamId: teamId })\n .setException(\"failed to get teams drivers for team \".concat(teamId))\n .withCommonOptions(commonOptions)\n .invoke()];\n });\n });\n };\n /**\n * Generic method for keyset pagination with optional scoping\n */\n UsersService.prototype.getAllUsersWithKeysetPagination = function (request, scopes, exceptionMessage) {\n if (scopes === void 0) { scopes = []; }\n if (exceptionMessage === void 0) { exceptionMessage = 'Could not get users'; }\n return __awaiter(this, void 0, void 0, function () {\n var limit, page_action, cursor, options, queryParams;\n return __generator(this, function (_a) {\n limit = request.limit, page_action = request.page_action, cursor = request.cursor, options = request.options;\n // Add driver-specific scopes if options are provided\n if (options) {\n if (options.onlyCustomers) {\n scopes.push(User_consts_1.UsersScopes.CUSTOMERS);\n }\n else if (!scopes.includes(User_consts_1.UsersScopes.ADMINS) && !scopes.includes(User_consts_1.UsersScopes.DISPATCHERS)) {\n // Only add DRIVERS scope if we're not already dealing with admins/dispatchers\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 }\n queryParams = { pgver: '2', limit: limit, page_action: page_action, cursor: cursor };\n if (scopes.length > 0) {\n queryParams.scopes = scopes;\n }\n return [2 /*return*/, this.service.routeGenerator\n .get(User_consts_1.ROUTES.GET_ALL)\n .withQueryString(queryParams)\n .withExtractor(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 .setException(exceptionMessage)\n .invoke()];\n });\n });\n };\n UsersService.prototype.getAllDrivers = function (request) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.getAllUsersWithKeysetPagination(request, [], 'Could not get all drivers')];\n });\n });\n };\n UsersService.prototype.getAllAdminsAndDispatchers = function (request) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.getAllUsersWithKeysetPagination(request, [User_consts_1.UsersScopes.DISPATCHERS, User_consts_1.UsersScopes.ADMINS], 'Could not get all admins and dispatchers')];\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 return [2 /*return*/, this.service.routeGenerator\n .post(User_consts_1.ROUTES.UNLOCK)\n .withRouteParams({ userId: userId })\n .withExtractor(User_consts_1.successExtractor)\n .setException(\"Could not unlock user with id: \".concat(userId))\n .invoke()];\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 return [2 /*return*/, this.service.routeGenerator\n .get(User_consts_1.ROUTES.VALIDATE_PHONE)\n .withQueryString({ phone: phone })\n .withExtractor(function (response) { return response.phone_valid; })\n .setException(\"Phone is not valid: \".concat(phone))\n .invoke()];\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 return [2 /*return*/, this.service.routeGenerator\n .put(User_consts_1.ROUTES.MESSAGE_DRIVER)\n .withRouteParams({ userId: userId })\n .withPayload({ user_id: userId, message: message })\n .withExtractor(function (response) { return response.announcement_id; })\n .setException(\"Could not message to user \".concat(userId))\n .invoke()];\n });\n });\n };\n UsersService.prototype.getDriverCost = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.service.routeGenerator\n .get(User_consts_1.ROUTES.DRIVER_COST)\n .withRouteParams({ userId: userId })\n .withExtractor(function (response) { return response; })\n .setException(\"Could not get driver cost for user \".concat(userId))\n .invoke()];\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 return [2 /*return*/, this.service.routeGenerator\n .get(User_consts_1.ROUTES.GET_USERS_WITH_USER_TYPE)\n .withRouteParams({ userTypeId: userTypeId })\n .withExtractor(function (response) { return response.users; })\n .setException(\"Could not get users with user type \".concat(userTypeId))\n .invoke()];\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 return [2 /*return*/, this.service.routeGenerator\n .post(User_consts_1.ROUTES.INVITE)\n .withRouteParams({ userId: userId })\n .withExtractor(function (response) { return response.user; })\n .setException(\"Could not invite user with id: \".concat(userId))\n .invoke()];\n });\n });\n };\n return UsersService;\n}());\nexports[\"default\"] = UsersService;\n//# sourceMappingURL=users-service.js.map\n\n//# sourceURL=webpack://BringgDashboardSDK/./dist/User/v2/users-service.js?");
|
|
3100
|
+
eval("\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 __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar types_1 = __webpack_require__(/*! @bringg/types */ \"./node_modules/@bringg/types/index.js\");\nvar CrudService_1 = __importDefault(__webpack_require__(/*! ../../Core/CrudService */ \"./dist/Core/CrudService.js\"));\nvar User_consts_1 = __webpack_require__(/*! ../User.consts */ \"./dist/User/User.consts.js\");\nvar UsersService = /** @class */ (function () {\n function UsersService(session) {\n this.service = new CrudService_1.default(session, 'users');\n }\n Object.defineProperty(UsersService.prototype, \"session\", {\n get: function () {\n return this.service.session;\n },\n enumerable: false,\n configurable: true\n });\n UsersService.prototype.delete = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.service.delete(userId)];\n });\n });\n };\n UsersService.prototype.deleteMany = function (userIds) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.service.routeGenerator\n .delete(User_consts_1.ROUTES.DELETE_MANY)\n .withPayload({ ids: userIds })\n .withExtractor(function (response) { return response; })\n .setException('Could not delete users')\n .invoke()];\n });\n });\n };\n UsersService.prototype.closedTasks = function (userId, page) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.service.routeGenerator\n .get(User_consts_1.ROUTES.CLOSED_TASKS)\n .withRouteParams({ userId: userId })\n .withQueryString({ page: page })\n .withExtractor(function (response) { return response; })\n .setException(\"Could not get closed tasks for user \".concat(userId))\n .invoke()];\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 return [2 /*return*/, this.service.routeGenerator\n .get(User_consts_1.ROUTES.TOTAL_TASKS)\n .withRouteParams({ userId: userId })\n .withExtractor(function (response) { return response.count; })\n .setException(\"Could not get assigned tasks count for user \".concat(userId))\n .invoke()];\n });\n });\n };\n UsersService.prototype.create = function (user) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.service.create(user).then(function (response) { return response.user; })];\n });\n });\n };\n UsersService.prototype.update = function (userId, userDelta) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.service.update(userId, userDelta).then(function (response) { return response.user; })];\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 return [2 /*return*/, this.service.get(userId).then(function (user) { return user; })];\n });\n });\n };\n UsersService.prototype.loadAll = function (request, commonOptions) {\n return __awaiter(this, void 0, void 0, function () {\n var limit, page_action, cursor;\n return __generator(this, function (_a) {\n limit = request.limit, page_action = request.page_action, cursor = request.cursor;\n return [2 /*return*/, this.service.routeGenerator\n .get(User_consts_1.ROUTES.GET_ALL)\n .withQueryString({ pgver: types_1.KEYSET_PAGINATION_VER, limit: limit, page_action: page_action, cursor: cursor })\n .withExtractor(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 .setException('Could not get users')\n .withCommonOptions(commonOptions)\n .invoke()];\n });\n });\n };\n UsersService.prototype.loadMany = function (query, commonOptions) {\n if (query === void 0) { query = {}; }\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.service.routeGenerator\n .get(User_consts_1.ROUTES.GET_ALL)\n .withQueryString(query)\n .withExtractor(function (response) { return response.users; })\n .setException('Could not get users by ids')\n .withCommonOptions(commonOptions)\n .invoke()];\n });\n });\n };\n UsersService.prototype.loadAllByTeams = function (teamId, commonOptions) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.service.routeGenerator\n .get(User_consts_1.ROUTES.GET_DRIVERS_BY_TEAM)\n .withRouteParams({ teamId: teamId })\n .setException(\"failed to get teams drivers for team \".concat(teamId))\n .withCommonOptions(commonOptions)\n .invoke()];\n });\n });\n };\n /**\n * Generic method for keyset pagination with optional scoping\n */\n UsersService.prototype.getAllUsersWithKeysetPagination = function (request, scopes, exceptionMessage) {\n if (scopes === void 0) { scopes = []; }\n if (exceptionMessage === void 0) { exceptionMessage = 'Could not get users'; }\n return __awaiter(this, void 0, void 0, function () {\n var limit, page_action, cursor, options, queryParams;\n return __generator(this, function (_a) {\n limit = request.limit, page_action = request.page_action, cursor = request.cursor, options = request.options;\n // Add driver-specific scopes if options are provided\n if (options) {\n if (options.onlyCustomers) {\n scopes.push(User_consts_1.UsersScopes.CUSTOMERS);\n }\n else if (!scopes.includes(User_consts_1.UsersScopes.ADMINS) && !scopes.includes(User_consts_1.UsersScopes.DISPATCHERS)) {\n // Only add DRIVERS scope if we're not already dealing with admins/dispatchers\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 }\n queryParams = { pgver: '2', limit: limit, page_action: page_action, cursor: cursor };\n if (scopes.length > 0) {\n queryParams.scopes = scopes;\n }\n return [2 /*return*/, this.service.routeGenerator\n .get(User_consts_1.ROUTES.GET_ALL)\n .withQueryString(queryParams)\n .withExtractor(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 .setException(exceptionMessage)\n .invoke()];\n });\n });\n };\n UsersService.prototype.getAllDrivers = function (request) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.getAllUsersWithKeysetPagination(request, [], 'Could not get all drivers')];\n });\n });\n };\n UsersService.prototype.getAllAdminsAndDispatchers = function (request) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.getAllUsersWithKeysetPagination(request, [User_consts_1.UsersScopes.DISPATCHERS, User_consts_1.UsersScopes.ADMINS], 'Could not get all admins and dispatchers')];\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 return [2 /*return*/, this.service.routeGenerator\n .post(User_consts_1.ROUTES.UNLOCK)\n .withRouteParams({ userId: userId })\n .withExtractor(User_consts_1.successExtractor)\n .setException(\"Could not unlock user with id: \".concat(userId))\n .invoke()];\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 return [2 /*return*/, this.service.routeGenerator\n .get(User_consts_1.ROUTES.VALIDATE_PHONE)\n .withQueryString({ phone: phone })\n .withExtractor(function (response) { return response.phone_valid; })\n .setException(\"Phone is not valid: \".concat(phone))\n .invoke()];\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 return [2 /*return*/, this.service.routeGenerator\n .put(User_consts_1.ROUTES.MESSAGE_DRIVER)\n .withRouteParams({ userId: userId })\n .withPayload({ user_id: userId, message: message })\n .withExtractor(function (response) { return response.announcement_id; })\n .setException(\"Could not message to user \".concat(userId))\n .invoke()];\n });\n });\n };\n UsersService.prototype.getDriverCost = function (userId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.service.routeGenerator\n .get(User_consts_1.ROUTES.DRIVER_COST)\n .withRouteParams({ userId: userId })\n .withExtractor(function (response) { return response; })\n .setException(\"Could not get driver cost for user \".concat(userId))\n .invoke()];\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 return [2 /*return*/, this.service.routeGenerator\n .get(User_consts_1.ROUTES.GET_USERS_WITH_USER_TYPE)\n .withRouteParams({ userTypeId: userTypeId })\n .withExtractor(function (response) { return response.users; })\n .setException(\"Could not get users with user type \".concat(userTypeId))\n .invoke()];\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 return [2 /*return*/, this.service.routeGenerator\n .post(User_consts_1.ROUTES.INVITE)\n .withRouteParams({ userId: userId })\n .withExtractor(function (response) { return response.user; })\n .setException(\"Could not invite user with id: \".concat(userId))\n .invoke()];\n });\n });\n };\n return UsersService;\n}());\nexports[\"default\"] = UsersService;\n//# sourceMappingURL=users-service.js.map\n\n//# sourceURL=webpack://BringgDashboardSDK/./dist/User/v2/users-service.js?");
|
|
3101
3101
|
|
|
3102
3102
|
/***/ }),
|
|
3103
3103
|
|
|
@@ -3504,7 +3504,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar
|
|
|
3504
3504
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
3505
3505
|
|
|
3506
3506
|
"use strict";
|
|
3507
|
-
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};\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 lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nvar BringgDashboardSDK_1 = __webpack_require__(/*! ./BringgDashboardSDK */ \"./dist/BringgDashboardSDK.js\");\nvar data_entity_1 = __webpack_require__(/*! ./data-entity */ \"./dist/data-entity.js\");\nvar StorableDataService = /** @class */ (function () {\n function StorableDataService(dataStore, mapper, extraDataStores) {\n var _this = this;\n this.dataStore = dataStore;\n this.extraDataStores = extraDataStores || [];\n this.mapper = mapper || (function (item) { return ({ current: item, diff: _this.dataStore.get(item.id) }); });\n }\n StorableDataService.prototype.loadAll = function (action, loadFunc, options) {\n return __awaiter(this, void 0, void 0, function () {\n var unloadedItems, shouldLoad, groupValue, loadFnIdsParams, items, mappedItems_1;\n var _this = this;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n options = (0, lodash_1.defaults)(options, data_entity_1.DEFAULT_OPTIONS);\n unloadedItems = [];\n shouldLoad = false;\n if (Array.isArray(options.groupValue)) {\n unloadedItems = options.groupValue.filter(function (value) { return !_this.dataStore.isGroupInitialized(options.groupType, value); });\n shouldLoad = unloadedItems.length > 0;\n groupValue = unloadedItems;\n }\n else {\n shouldLoad = !this.dataStore.isGroupInitialized(options.groupType, options.groupValue);\n groupValue = options.groupValue;\n }\n if (!(!options.useCache || shouldLoad)) return [3 /*break*/, 2];\n loadFnIdsParams = groupValue;\n if (!options.useCache) {\n loadFnIdsParams = options.groupValue;\n }\n return [4 /*yield*/, loadFunc(loadFnIdsParams)];\n case 1:\n items = _a.sent();\n mappedItems_1 = items.map(function (item) { return _this.mapper(item, { action: action }); });\n if (options.groupType) {\n this.dataStore.setGroup(options.groupType, groupValue, mappedItems_1);\n }\n else {\n this.dataStore.setAll(mappedItems_1);\n }\n this.extraDataStores.forEach(function (dataStore) { return dataStore.setMany(mappedItems_1, options.fields); });\n _a.label = 2;\n case 2: return [2 /*return*/, options.groupType\n ? this.dataStore.getGroup(options.groupType, options.groupValue)\n : this.dataStore.getAll()];\n }\n });\n });\n };\n StorableDataService.prototype.loadMany = function (action, loadFunc, ids, options) {\n return __awaiter(this, void 0, void 0, function () {\n var unloadedIds, clientItems;\n var _this = this;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n options = (0, lodash_1.defaults)(options, data_entity_1.DEFAULT_OPTIONS);\n if (!options.useCache) {\n return [2 /*return*/, this.loadInChunks(ids, loadFunc, action, options)];\n }\n unloadedIds = ids.filter(function (id) {\n var item = _this.dataStore.get(id);\n if (!item) {\n return true;\n }\n return _this.extraDataStores.some(function (dataStore) { return !dataStore.has(item, options.fields); });\n });\n if (!(ids.length === 0 || unloadedIds.length > 0)) return [3 /*break*/, 2];\n return [4 /*yield*/, this.loadInChunks(unloadedIds, loadFunc, action, options)];\n case 1:\n clientItems = _a.sent();\n if (ids.length === 0) {\n return [2 /*return*/, clientItems];\n }\n _a.label = 2;\n case 2: return [2 /*return*/, ids.map(function (id) { return _this.dataStore.get(id); }).filter(Boolean)];\n }\n });\n });\n };\n StorableDataService.prototype.loadInChunks = function (idsToLoad, loadFunc, action, options) {\n var _a;\n return __awaiter(this, void 0, void 0, function () {\n var allClientItems, items, clientItems, chunkSize, i, chunkIds, items, clientItems;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n allClientItems = [];\n if (!(idsToLoad.length === 0)) return [3 /*break*/, 2];\n return [4 /*yield*/, loadFunc([])];\n case 1:\n items = _b.sent();\n clientItems = this.updateManyInStores(items, action, options.fields);\n allClientItems.push.apply(allClientItems, __spreadArray([], __read(clientItems), false));\n return [3 /*break*/, 6];\n case 2:\n chunkSize = options.chunkSize || idsToLoad.length;\n i = 0;\n _b.label = 3;\n case 3:\n if (!(i < idsToLoad.length)) return [3 /*break*/, 6];\n if ((_a = options === null || options === void 0 ? void 0 : options.signal) === null || _a === void 0 ? void 0 : _a.aborted) {\n throw new Error('Operation was aborted');\n }\n chunkIds = idsToLoad.slice(i, i + chunkSize);\n return [4 /*yield*/, loadFunc(chunkIds)];\n case 4:\n items = _b.sent();\n clientItems = this.updateManyInStores(items, action, options.fields);\n allClientItems.push.apply(allClientItems, __spreadArray([], __read(clientItems), false));\n _b.label = 5;\n case 5:\n i += chunkSize;\n return [3 /*break*/, 3];\n case 6: return [2 /*return*/, allClientItems.map(function (mappedItems) { return mappedItems.current; })];\n }\n });\n });\n };\n StorableDataService.prototype.load = function (action, loadFunc, id, options) {\n return __awaiter(this, void 0, void 0, function () {\n var item;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n options = (0, lodash_1.defaults)(options, data_entity_1.DEFAULT_OPTIONS);\n if (!(!options.useCache || !this.dataStore.get(id))) return [3 /*break*/, 2];\n return [4 /*yield*/, loadFunc()];\n case 1:\n item = _a.sent();\n this.updateInStores(item, action);\n _a.label = 2;\n case 2: return [2 /*return*/, this.dataStore.get(id)];\n }\n });\n });\n };\n StorableDataService.prototype.modify = function (action, updateFunc, onUpdate) {\n return __awaiter(this, void 0, void 0, function () {\n var item, modifiedItems;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, updateFunc()];\n case 1:\n item = _a.sent();\n modifiedItems = this.updateInStores(item, action);\n onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate(modifiedItems);\n return [2 /*return*/, modifiedItems.current];\n }\n });\n });\n };\n StorableDataService.prototype.modifyMany = function (action, updateFunc, fields, onUpdate) {\n return __awaiter(this, void 0, void 0, function () {\n var items, modifiedItems;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, updateFunc()];\n case 1:\n items = _a.sent();\n modifiedItems = this.updateManyInStores(items, action, fields);\n onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate(modifiedItems);\n return [2 /*return*/, modifiedItems.map(function (mappedItems) { return mappedItems.current; })];\n }\n });\n });\n };\n StorableDataService.prototype.delete = function (action, deleteFunc, id) {\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*/, deleteFunc()];\n case 1:\n _a.sent();\n return [2 /*return*/, this.removeFromStores(id)];\n }\n });\n });\n };\n StorableDataService.prototype.deleteMany = function (action, deleteFunc, ids) {\n return __awaiter(this, void 0, void 0, function () {\n var _this = this;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, deleteFunc()];\n case 1:\n _a.sent();\n return [2 /*return*/, (0, BringgDashboardSDK_1.getGlobals)().mobx.runInAction(function () {\n return ids.map(function (id) { return _this.removeFromStores(id); });\n })];\n }\n });\n });\n };\n StorableDataService.prototype.updateInStores = function (item, action, fields, extraMapperParams) {\n return this.updateManyInStores([item], action, fields, extraMapperParams)[0];\n };\n StorableDataService.prototype.updateManyInStores = function (items, action, fields, extraMapperParams) {\n var _this = this;\n return (0, BringgDashboardSDK_1.getGlobals)().mobx.runInAction(function () {\n var clientItems = items.map(function (item) { return _this.mapper(item, __assign({ action: action }, extraMapperParams)); });\n _this.dataStore.setMany(clientItems);\n _this.extraDataStores.forEach(function (dataStore) { return dataStore.setMany(clientItems, fields); });\n return clientItems;\n });\n };\n StorableDataService.prototype.removeFromStores = function (id) {\n var item = this.dataStore.get(id);\n this.dataStore.remove(id);\n this.extraDataStores.forEach(function (dataStore) { return dataStore.remove(id); });\n return item;\n };\n StorableDataService.prototype.getFromStores = function (ids, fields) {\n var _this = this;\n return ids\n .map(function (id) {\n var item = _this.dataStore.get(id);\n return item && (!fields || _this.extraDataStores.every(function (dataStore) { return dataStore.has(item, fields); }))\n ? item\n : undefined;\n })\n .filter(Boolean);\n };\n return StorableDataService;\n}());\nexports[\"default\"] = StorableDataService;\n//# sourceMappingURL=storable-data-service.js.map\n\n//# sourceURL=webpack://BringgDashboardSDK/./dist/storable-data-service.js?");
|
|
3507
|
+
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};\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 lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nvar BringgDashboardSDK_1 = __webpack_require__(/*! ./BringgDashboardSDK */ \"./dist/BringgDashboardSDK.js\");\nvar data_entity_1 = __webpack_require__(/*! ./data-entity */ \"./dist/data-entity.js\");\nvar StorableDataService = /** @class */ (function () {\n function StorableDataService(dataStore, mapper, extraDataStores) {\n var _this = this;\n this.dataStore = dataStore;\n this.extraDataStores = extraDataStores || [];\n this.mapper = mapper || (function (item) { return ({ current: item, diff: _this.dataStore.get(item.id) }); });\n }\n StorableDataService.prototype.loadAll = function (action, loadFunc, options) {\n return __awaiter(this, void 0, void 0, function () {\n var unloadedItems, shouldLoad, groupValue, loadFnIdsParams, items, mappedItems_1;\n var _this = this;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n options = (0, lodash_1.defaults)(options, data_entity_1.DEFAULT_OPTIONS);\n unloadedItems = [];\n shouldLoad = false;\n if (Array.isArray(options.groupValue)) {\n unloadedItems = options.groupValue.filter(function (value) { return !_this.dataStore.isGroupInitialized(options.groupType, value); });\n shouldLoad = unloadedItems.length > 0;\n groupValue = unloadedItems;\n }\n else {\n // The same storable-data-service method is used for loadAll group key in this case is undefined-undefined\n shouldLoad = !this.dataStore.isGroupInitialized(options.groupType, options.groupValue);\n groupValue = options.groupValue;\n }\n if (!(!options.useCache || shouldLoad)) return [3 /*break*/, 2];\n loadFnIdsParams = groupValue;\n if (!options.useCache) {\n loadFnIdsParams = options.groupValue;\n }\n return [4 /*yield*/, loadFunc(loadFnIdsParams)];\n case 1:\n items = _a.sent();\n mappedItems_1 = items.map(function (item) { return _this.mapper(item, { action: action }); });\n if (options.groupType) {\n this.dataStore.setGroup(options.groupType, groupValue, mappedItems_1);\n }\n else {\n this.dataStore.setAll(mappedItems_1);\n }\n this.extraDataStores.forEach(function (dataStore) { return dataStore.setMany(mappedItems_1, options.fields); });\n _a.label = 2;\n case 2: return [2 /*return*/, options.groupType\n ? this.dataStore.getGroup(options.groupType, options.groupValue)\n : this.dataStore.getAll()];\n }\n });\n });\n };\n StorableDataService.prototype.loadMany = function (action, loadFunc, ids, options) {\n return __awaiter(this, void 0, void 0, function () {\n var unloadedIds, clientItems;\n var _this = this;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n options = (0, lodash_1.defaults)(options, data_entity_1.DEFAULT_OPTIONS);\n if (!options.useCache) {\n return [2 /*return*/, this.loadInChunks(ids, loadFunc, action, options)];\n }\n unloadedIds = ids.filter(function (id) {\n var item = _this.dataStore.get(id);\n if (!item) {\n return true;\n }\n return _this.extraDataStores.some(function (dataStore) { return !dataStore.has(item, options.fields); });\n });\n if (!(ids.length === 0 || unloadedIds.length > 0)) return [3 /*break*/, 2];\n return [4 /*yield*/, this.loadInChunks(unloadedIds, loadFunc, action, options)];\n case 1:\n clientItems = _a.sent();\n if (ids.length === 0) {\n return [2 /*return*/, clientItems];\n }\n _a.label = 2;\n case 2: return [2 /*return*/, ids.map(function (id) { return _this.dataStore.get(id); }).filter(Boolean)];\n }\n });\n });\n };\n StorableDataService.prototype.loadInChunks = function (idsToLoad, loadFunc, action, options) {\n var _a;\n return __awaiter(this, void 0, void 0, function () {\n var allClientItems, items, clientItems, chunkSize, i, chunkIds, items, clientItems;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n allClientItems = [];\n if (!(idsToLoad.length === 0)) return [3 /*break*/, 2];\n return [4 /*yield*/, loadFunc([])];\n case 1:\n items = _b.sent();\n clientItems = this.updateManyInStores(items, action, options.fields);\n allClientItems.push.apply(allClientItems, __spreadArray([], __read(clientItems), false));\n return [3 /*break*/, 6];\n case 2:\n chunkSize = options.chunkSize || idsToLoad.length;\n i = 0;\n _b.label = 3;\n case 3:\n if (!(i < idsToLoad.length)) return [3 /*break*/, 6];\n if ((_a = options === null || options === void 0 ? void 0 : options.signal) === null || _a === void 0 ? void 0 : _a.aborted) {\n throw new Error('Operation was aborted');\n }\n chunkIds = idsToLoad.slice(i, i + chunkSize);\n return [4 /*yield*/, loadFunc(chunkIds)];\n case 4:\n items = _b.sent();\n clientItems = this.updateManyInStores(items, action, options.fields);\n allClientItems.push.apply(allClientItems, __spreadArray([], __read(clientItems), false));\n _b.label = 5;\n case 5:\n i += chunkSize;\n return [3 /*break*/, 3];\n case 6: return [2 /*return*/, allClientItems.map(function (mappedItems) { return mappedItems.current; })];\n }\n });\n });\n };\n StorableDataService.prototype.load = function (action, loadFunc, id, options) {\n return __awaiter(this, void 0, void 0, function () {\n var item;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n options = (0, lodash_1.defaults)(options, data_entity_1.DEFAULT_OPTIONS);\n if (!(!options.useCache || !this.dataStore.get(id))) return [3 /*break*/, 2];\n return [4 /*yield*/, loadFunc()];\n case 1:\n item = _a.sent();\n this.updateInStores(item, action);\n _a.label = 2;\n case 2: return [2 /*return*/, this.dataStore.get(id)];\n }\n });\n });\n };\n StorableDataService.prototype.modify = function (action, updateFunc, onUpdate) {\n return __awaiter(this, void 0, void 0, function () {\n var item, modifiedItems;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, updateFunc()];\n case 1:\n item = _a.sent();\n modifiedItems = this.updateInStores(item, action);\n onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate(modifiedItems);\n return [2 /*return*/, modifiedItems.current];\n }\n });\n });\n };\n StorableDataService.prototype.modifyMany = function (action, updateFunc, fields, onUpdate) {\n return __awaiter(this, void 0, void 0, function () {\n var items, modifiedItems;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, updateFunc()];\n case 1:\n items = _a.sent();\n modifiedItems = this.updateManyInStores(items, action, fields);\n onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate(modifiedItems);\n return [2 /*return*/, modifiedItems.map(function (mappedItems) { return mappedItems.current; })];\n }\n });\n });\n };\n StorableDataService.prototype.delete = function (action, deleteFunc, id) {\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*/, deleteFunc()];\n case 1:\n _a.sent();\n return [2 /*return*/, this.removeFromStores(id)];\n }\n });\n });\n };\n StorableDataService.prototype.deleteMany = function (action, deleteFunc, ids) {\n return __awaiter(this, void 0, void 0, function () {\n var _this = this;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, deleteFunc()];\n case 1:\n _a.sent();\n return [2 /*return*/, (0, BringgDashboardSDK_1.getGlobals)().mobx.runInAction(function () {\n return ids.map(function (id) { return _this.removeFromStores(id); });\n })];\n }\n });\n });\n };\n StorableDataService.prototype.updateInStores = function (item, action, fields, extraMapperParams) {\n return this.updateManyInStores([item], action, fields, extraMapperParams)[0];\n };\n StorableDataService.prototype.updateManyInStores = function (items, action, fields, extraMapperParams) {\n var _this = this;\n return (0, BringgDashboardSDK_1.getGlobals)().mobx.runInAction(function () {\n var clientItems = items.map(function (item) { return _this.mapper(item, __assign({ action: action }, extraMapperParams)); });\n _this.dataStore.setMany(clientItems);\n _this.extraDataStores.forEach(function (dataStore) { return dataStore.setMany(clientItems, fields); });\n return clientItems;\n });\n };\n StorableDataService.prototype.removeFromStores = function (id) {\n var item = this.dataStore.get(id);\n this.dataStore.remove(id);\n this.extraDataStores.forEach(function (dataStore) { return dataStore.remove(id); });\n return item;\n };\n StorableDataService.prototype.getFromStores = function (ids, fields) {\n var _this = this;\n return ids\n .map(function (id) {\n var item = _this.dataStore.get(id);\n return item && (!fields || _this.extraDataStores.every(function (dataStore) { return dataStore.has(item, fields); }))\n ? item\n : undefined;\n })\n .filter(Boolean);\n };\n return StorableDataService;\n}());\nexports[\"default\"] = StorableDataService;\n//# sourceMappingURL=storable-data-service.js.map\n\n//# sourceURL=webpack://BringgDashboardSDK/./dist/storable-data-service.js?");
|
|
3508
3508
|
|
|
3509
3509
|
/***/ }),
|
|
3510
3510
|
|