@bringg/dashboard-sdk 10.2.3-pre.2 → 10.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Customer/Customer.consts.d.ts +0 -2
- package/dist/Customer/Customer.consts.js +1 -3
- package/dist/Customer/Customer.consts.js.map +1 -1
- package/dist/Customer/v2/customers-api.d.ts +0 -6
- package/dist/Customer/v2/customers-api.js +3 -18
- package/dist/Customer/v2/customers-api.js.map +1 -1
- package/dist/Data/merge-mapper.d.ts +2 -2
- package/dist/Data/merge-mapper.js.map +1 -1
- package/dist/Data/storable-realtime-subscriptions.d.ts +2 -2
- package/dist/Data/storable-realtime-subscriptions.js.map +1 -1
- package/dist/Vehicle/Vehicle.consts.d.ts +23 -0
- package/dist/Vehicle/Vehicle.consts.js.map +1 -1
- package/dist/Vehicle/v2/vehicles-api.d.ts +10 -2
- package/dist/Vehicle/v2/vehicles-api.js +8 -0
- package/dist/Vehicle/v2/vehicles-api.js.map +1 -1
- package/dist/Vehicle/v2/vehicles-service.d.ts +2 -2
- package/dist/Vehicle/v2/vehicles-service.js +7 -1
- package/dist/Vehicle/v2/vehicles-service.js.map +1 -1
- package/dist/bringg-dashboard-sdk-cjs2.js +20 -269
- package/dist/bringg-dashboard-sdk-cjs2.js.map +1 -1
- package/dist/bringg-dashboard-sdk.js +5 -27
- package/dist/bringg-dashboard-sdk.min.js +1 -1
- package/dist/bringg-dashboard-sdk.min.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/storable-data-service.d.ts +2 -2
- package/dist/storable-data-service.js.map +1 -1
- package/package.json +2 -2
- package/dist/Data/data-store-with-signals.d.ts +0 -33
- package/dist/Data/data-store-with-signals.js +0 -80
- package/dist/Data/data-store-with-signals.js.map +0 -1
- package/dist/Data/item-change-signals.d.ts +0 -27
- package/dist/Data/item-change-signals.js +0 -152
- package/dist/Data/item-change-signals.js.map +0 -1
- package/dist/Data/main-data-store.d.ts +0 -11
- package/dist/Data/main-data-store.js +0 -3
- package/dist/Data/main-data-store.js.map +0 -1
|
@@ -787,7 +787,7 @@ eval("\nvar __extends = (this && this.__extends) || (function () {\n var exte
|
|
|
787
787
|
/***/ ((__unused_webpack_module, exports) => {
|
|
788
788
|
|
|
789
789
|
"use strict";
|
|
790
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.
|
|
790
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.RealtimeEvents = void 0;\nvar RealtimeEvents;\n(function (RealtimeEvents) {\n RealtimeEvents[\"Created\"] = \"customer created\";\n RealtimeEvents[\"Updated\"] = \"customer update\";\n RealtimeEvents[\"Deleted\"] = \"customer delete\";\n})(RealtimeEvents = exports.RealtimeEvents || (exports.RealtimeEvents = {}));\n//# sourceMappingURL=Customer.consts.js.map\n\n//# sourceURL=webpack://BringgDashboardSDK/./dist/Customer/Customer.consts.js?");
|
|
791
791
|
|
|
792
792
|
/***/ }),
|
|
793
793
|
|
|
@@ -798,7 +798,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
|
798
798
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
799
799
|
|
|
800
800
|
"use strict";
|
|
801
|
-
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 = __importDefault(__webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\"));\nvar data_store_with_signals_1 = __importDefault(__webpack_require__(/*! ../../Data/data-store-with-signals */ \"./dist/Data/data-store-with-signals.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 storable_data_service_1 = __importDefault(__webpack_require__(/*! ../../storable-data-service */ \"./dist/storable-data-service.js\"));\nvar array_utils_1 = __webpack_require__(/*! ../../utils/array-utils */ \"./dist/utils/array-utils.js\");\nvar Customer_consts_1 = __webpack_require__(/*! ../Customer.consts */ \"./dist/Customer/Customer.consts.js\");\nvar customers_service_1 = __importDefault(__webpack_require__(/*! ./customers-service */ \"./dist/Customer/v2/customers-service.js\"));\nvar CustomersApi = /** @class */ (function () {\n function CustomersApi(session) {\n var _this = this;\n this.session = session;\n this.customersStore = new data_store_with_signals_1.default('customersStore');\n this.customersService = new customers_service_1.default(session);\n this.storableDataService = new storable_data_service_1.default(this.customersStore, function (customer) {\n return merge_mapper_1.mergeMapper.mergeIntoExisting(_this.customersStore, customer);\n });\n this.storableRealtimeSubscriptions = new storable_realtime_subscriptions_1.default(session, this.customersStore, this.storableDataService);\n this.storableRealtimeSubscriptions.updateStoreOnEvents([\n { name: Customer_consts_1.RealtimeEvents.Created, isDelete: false },\n { name: Customer_consts_1.RealtimeEvents.Updated, isDelete: false },\n {\n name: Customer_consts_1.RealtimeEvents.Deleted,\n isDelete: true,\n itemExtractor: function (payload) { return ({ id: payload.customer_id }); }\n }\n ]);\n }\n CustomersApi.prototype.onCreate = function (callback) {\n return this.storableRealtimeSubscriptions.onEvent(Customer_consts_1.RealtimeEvents.Created, function (item) { return callback(item.current); });\n };\n /**\n * Self-push: Angular pushes back the stored customer object after the tasks merge changed it in place, so the merge\n * finds no diff and `set` reports the change. Cost: every such push re-renders that customer's views even with no\n * change. Remove it with the Angular pushes once customer realtime events and this flag are on.\n */\n CustomersApi.prototype.add = function (customer) {\n var isSelfPush = this.customersStore.allItems[customer.id] === customer;\n var mapped = this.storableDataService.updateInStores(customer);\n if (isSelfPush && isWaypointCustomerFromStoreEnabled(this.session)) {\n this.customersStore.set(customer);\n }\n return mapped;\n };\n CustomersApi.prototype.getAll = function () {\n return this.customersStore.getAll();\n };\n CustomersApi.prototype.get = function (id) {\n return this.customersStore.get(id);\n };\n CustomersApi.prototype.loadAll = function (params, options) {\n var _this = this;\n if (options === void 0) { options = data_entity_1.DEFAULT_OPTIONS; }\n var loadResult;\n var 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.customersService.loadAll(params)];\n case 1:\n result = _a.sent();\n loadResult = result;\n return [2 /*return*/, result.items];\n }\n });\n }); };\n var promise = params\n ? this.storableDataService.loadMany('loadAll', loadFunc, [], options)\n : this.storableDataService.loadAll('loadAll', loadFunc, options);\n return promise.then(function (customers) {\n return __assign(__assign({}, loadResult), { items: customers });\n });\n };\n CustomersApi.prototype.loadMany = function (ids, 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.loadMany('batchGet', function (idsToLoad) { return __awaiter(_this, void 0, void 0, function () {\n var results;\n var _this = this;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!!options.chunkSize) return [3 /*break*/, 1];\n return [2 /*return*/, this.customersService.loadMany(idsToLoad)];\n case 1: return [4 /*yield*/, Promise.all(array_utils_1.arrayUtils.splitToChunks(idsToLoad, options.chunkSize).map(function (idsChunk) {\n return _this.customersService.loadMany(idsChunk);\n }))];\n case 2:\n results = _a.sent();\n return [2 /*return*/, lodash_1.default.flatten(results)];\n }\n });\n }); }, ids, options)];\n });\n });\n };\n CustomersApi.prototype.load = function (id, options) {\n var _this = this;\n if (options === void 0) { options = data_entity_1.DEFAULT_OPTIONS; }\n return this.storableDataService.load('load', function () { return _this.customersService.load(id); }, id, options);\n };\n CustomersApi.prototype.find = function (params) {\n return this.customersService.find(params);\n };\n CustomersApi.prototype.getTasks = function (id, page) {\n return this.customersService.getTasks(id, page);\n };\n CustomersApi.prototype.getTotalTasks = function (id) {\n return this.customersService.getTotalTasks(id);\n };\n CustomersApi.prototype.update = function (customerData) {\n var _this = this;\n return this.storableDataService.modify('update', function () { return _this.customersService.update(customerData); });\n };\n CustomersApi.prototype.create = function (customerData) {\n var _this = this;\n return this.storableDataService.modify('create', function () { return _this.customersService.create(customerData); });\n };\n return CustomersApi;\n}());\nexports[\"default\"] = CustomersApi;\nfunction isWaypointCustomerFromStoreEnabled(session) {\n var _a, _b;\n return Boolean((_b = (_a = session.user) === null || _a === void 0 ? void 0 : _a.feature_flags) === null || _b === void 0 ? void 0 : _b[Customer_consts_1.WAYPOINT_CUSTOMER_FROM_STORE_FF]);\n}\n//# sourceMappingURL=customers-api.js.map\n\n//# sourceURL=webpack://BringgDashboardSDK/./dist/Customer/v2/customers-api.js?");
|
|
801
|
+
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 = __importDefault(__webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.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 array_utils_1 = __webpack_require__(/*! ../../utils/array-utils */ \"./dist/utils/array-utils.js\");\nvar Customer_consts_1 = __webpack_require__(/*! ../Customer.consts */ \"./dist/Customer/Customer.consts.js\");\nvar customers_service_1 = __importDefault(__webpack_require__(/*! ./customers-service */ \"./dist/Customer/v2/customers-service.js\"));\nvar CustomersApi = /** @class */ (function () {\n function CustomersApi(session) {\n var _this = this;\n this.customersStore = new data_store_1.default(undefined, { shallow: true });\n this.customersService = new customers_service_1.default(session);\n this.storableDataService = new storable_data_service_1.default(this.customersStore, function (customer) {\n return merge_mapper_1.mergeMapper.mergeIntoExisting(_this.customersStore, customer);\n });\n this.storableRealtimeSubscriptions = new storable_realtime_subscriptions_1.default(session, this.customersStore, this.storableDataService);\n this.storableRealtimeSubscriptions.updateStoreOnEvents([\n { name: Customer_consts_1.RealtimeEvents.Created, isDelete: false },\n { name: Customer_consts_1.RealtimeEvents.Updated, isDelete: false },\n {\n name: Customer_consts_1.RealtimeEvents.Deleted,\n isDelete: true,\n itemExtractor: function (payload) { return ({ id: payload.customer_id }); }\n }\n ]);\n }\n CustomersApi.prototype.onCreate = function (callback) {\n return this.storableRealtimeSubscriptions.onEvent(Customer_consts_1.RealtimeEvents.Created, function (item) { return callback(item.current); });\n };\n CustomersApi.prototype.add = function (customer) {\n return this.storableDataService.updateInStores(customer);\n };\n CustomersApi.prototype.getAll = function () {\n return this.customersStore.getAll();\n };\n CustomersApi.prototype.get = function (id) {\n return this.customersStore.get(id);\n };\n CustomersApi.prototype.loadAll = function (params, options) {\n var _this = this;\n if (options === void 0) { options = data_entity_1.DEFAULT_OPTIONS; }\n var loadResult;\n var 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.customersService.loadAll(params)];\n case 1:\n result = _a.sent();\n loadResult = result;\n return [2 /*return*/, result.items];\n }\n });\n }); };\n var promise = params\n ? this.storableDataService.loadMany('loadAll', loadFunc, [], options)\n : this.storableDataService.loadAll('loadAll', loadFunc, options);\n return promise.then(function (customers) {\n return __assign(__assign({}, loadResult), { items: customers });\n });\n };\n CustomersApi.prototype.loadMany = function (ids, 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.loadMany('batchGet', function (idsToLoad) { return __awaiter(_this, void 0, void 0, function () {\n var results;\n var _this = this;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!!options.chunkSize) return [3 /*break*/, 1];\n return [2 /*return*/, this.customersService.loadMany(idsToLoad)];\n case 1: return [4 /*yield*/, Promise.all(array_utils_1.arrayUtils.splitToChunks(idsToLoad, options.chunkSize).map(function (idsChunk) {\n return _this.customersService.loadMany(idsChunk);\n }))];\n case 2:\n results = _a.sent();\n return [2 /*return*/, lodash_1.default.flatten(results)];\n }\n });\n }); }, ids, options)];\n });\n });\n };\n CustomersApi.prototype.load = function (id, options) {\n var _this = this;\n if (options === void 0) { options = data_entity_1.DEFAULT_OPTIONS; }\n return this.storableDataService.load('load', function () { return _this.customersService.load(id); }, id, options);\n };\n CustomersApi.prototype.find = function (params) {\n return this.customersService.find(params);\n };\n CustomersApi.prototype.getTasks = function (id, page) {\n return this.customersService.getTasks(id, page);\n };\n CustomersApi.prototype.getTotalTasks = function (id) {\n return this.customersService.getTotalTasks(id);\n };\n CustomersApi.prototype.update = function (customerData) {\n var _this = this;\n return this.storableDataService.modify('update', function () { return _this.customersService.update(customerData); });\n };\n CustomersApi.prototype.create = function (customerData) {\n var _this = this;\n return this.storableDataService.modify('create', function () { return _this.customersService.create(customerData); });\n };\n return CustomersApi;\n}());\nexports[\"default\"] = CustomersApi;\n//# sourceMappingURL=customers-api.js.map\n\n//# sourceURL=webpack://BringgDashboardSDK/./dist/Customer/v2/customers-api.js?");
|
|
802
802
|
|
|
803
803
|
/***/ }),
|
|
804
804
|
|
|
@@ -857,28 +857,6 @@ eval("\nvar __decorate = (this && this.__decorate) || function (decorators, targ
|
|
|
857
857
|
|
|
858
858
|
/***/ }),
|
|
859
859
|
|
|
860
|
-
/***/ "./dist/Data/data-store-with-signals.js":
|
|
861
|
-
/*!**********************************************!*\
|
|
862
|
-
!*** ./dist/Data/data-store-with-signals.js ***!
|
|
863
|
-
\**********************************************/
|
|
864
|
-
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
865
|
-
|
|
866
|
-
"use strict";
|
|
867
|
-
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar data_store_1 = __importDefault(__webpack_require__(/*! ../data-store */ \"./dist/data-store.js\"));\nvar item_change_signals_1 = __importDefault(__webpack_require__(/*! ./item-change-signals */ \"./dist/Data/item-change-signals.js\"));\n/**\n * A shallow `DataStore` whose MobX reactions re-run when an item they read is added, changed or removed.\n * Items stay plain objects. Readers report what they read, writers fire the signals, the inner store holds the data.\n */\nvar DataStoreWithSignals = /** @class */ (function () {\n /**\n * @param storeId - Store name for the MobX atom names, for example `customersStore`\n * @param groupFilters - Passed to the inner `DataStore`\n */\n function DataStoreWithSignals(storeId, groupFilters) {\n if (groupFilters === void 0) { groupFilters = []; }\n this.store = new data_store_1.default(groupFilters, { shallow: true });\n this.signals = new item_change_signals_1.default(storeId);\n }\n Object.defineProperty(DataStoreWithSignals.prototype, \"allItems\", {\n /** The inner items by id. Reading it subscribes nothing: use it in writers, never in views. */\n get: function () {\n return this.store.allItems;\n },\n enumerable: false,\n configurable: true\n });\n DataStoreWithSignals.prototype.get = function (id) {\n this.signals.observe(id);\n return this.store.get(id);\n };\n DataStoreWithSignals.prototype.getAll = function () {\n this.signals.observeAll();\n return this.store.getAll();\n };\n DataStoreWithSignals.prototype.getGroup = function (group, groupValue) {\n this.signals.observeAll();\n return this.store.getGroup(group, groupValue);\n };\n DataStoreWithSignals.prototype.isGroupInitialized = function (groupType, groupValue) {\n return this.store.isGroupInitialized(groupType, groupValue);\n };\n DataStoreWithSignals.prototype.set = function (item) {\n this.store.set(item);\n this.signals.notify([item.id]);\n };\n DataStoreWithSignals.prototype.remove = function (id) {\n this.store.remove(id);\n this.signals.notify([id]);\n };\n DataStoreWithSignals.prototype.setMany = function (items) {\n this.store.setMany(items);\n this.signals.notify(items.filter(isChanged).map(function (item) { return item.current.id; }));\n };\n DataStoreWithSignals.prototype.setAll = function (items) {\n this.store.setAll(items);\n this.signals.notifyAllObserved();\n };\n DataStoreWithSignals.prototype.setGroup = function (groupType, groupValue, items) {\n this.store.setGroup(groupType, groupValue, items);\n this.signals.notifyAllObserved();\n };\n Object.defineProperty(DataStoreWithSignals.prototype, \"observedItemsCount\", {\n /** @internal Number of items that reactions observe right now. For tests. */\n get: function () {\n return this.signals.observedCount;\n },\n enumerable: false,\n configurable: true\n });\n return DataStoreWithSignals;\n}());\nexports[\"default\"] = DataStoreWithSignals;\n// No diff = a new item. An empty diff = nothing changed.\nfunction isChanged(item) {\n return !item.diff || Object.keys(item.diff).length > 0;\n}\n//# sourceMappingURL=data-store-with-signals.js.map\n\n//# sourceURL=webpack://BringgDashboardSDK/./dist/Data/data-store-with-signals.js?");
|
|
868
|
-
|
|
869
|
-
/***/ }),
|
|
870
|
-
|
|
871
|
-
/***/ "./dist/Data/item-change-signals.js":
|
|
872
|
-
/*!******************************************!*\
|
|
873
|
-
!*** ./dist/Data/item-change-signals.js ***!
|
|
874
|
-
\******************************************/
|
|
875
|
-
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
876
|
-
|
|
877
|
-
"use strict";
|
|
878
|
-
eval("\nvar __values = (this && this.__values) || function(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar BringgDashboardSDK_1 = __webpack_require__(/*! ../BringgDashboardSDK */ \"./dist/BringgDashboardSDK.js\");\n/**\n * Per-item change signals for a shallow DataStore: a reaction that reads an id re-runs when that id changes.\n * Id signals live only while a reaction reads them; other reads watch `anyChange`, so no change is lost (mobx >= 6.7).\n * Uses only the MobX instance passed at login, so the host app's reactions track it.\n */\nvar ItemChangeSignals = /** @class */ (function () {\n /** @param storeId - Store name for the MobX atom names (devtools and spy only), for example `customersStore`. */\n function ItemChangeSignals(storeId) {\n this.storeId = storeId;\n // Keyed by Number(id): stores accept number-like string ids too.\n this.atoms = new Map();\n }\n /** Reports a read of `id`. Subscribes the current reaction to changes of that id. */\n ItemChangeSignals.prototype.observe = function (id) {\n if (id === undefined || id === null || !getMobx()) {\n return;\n }\n id = Number(id);\n // Cheap filter, the probe never fires: false for a read outside any derivation, so no per-id atom is created on the\n // hot path. Such a read reports only the shared `anyChange` atom.\n if (!this.getProbe().reportObserved()) {\n this.getAnyChange().reportObserved();\n return;\n }\n var atom = this.atoms.get(id);\n var isNew = !atom;\n if (isNew) {\n atom = this.createAtom(id);\n }\n // Exact check: false for a new atom read by a computed evaluated inside an action (no reaction behind it).\n // MobX never calls the unobserve callback of such an atom, so it would leak; watch `anyChange` instead.\n if (!atom.reportObserved()) {\n if (isNew) {\n this.atoms.delete(id);\n }\n this.getAnyChange().reportObserved();\n }\n };\n /** Reports a read of the whole store (list readers). Subscribes the current reaction to every change. */\n ItemChangeSignals.prototype.observeAll = function () {\n if (getMobx()) {\n this.getAnyChange().reportObserved();\n }\n };\n /** Reports a change of each id, in one MobX action, then fires `anyChange` once. */\n ItemChangeSignals.prototype.notify = function (ids) {\n var _this = this;\n if (!ids.length || !this.hasBeenRead()) {\n return;\n }\n getMobx().runInAction(function () {\n var e_1, _a;\n var _b;\n try {\n for (var ids_1 = __values(ids), ids_1_1 = ids_1.next(); !ids_1_1.done; ids_1_1 = ids_1.next()) {\n var id = ids_1_1.value;\n (_b = _this.atoms.get(Number(id))) === null || _b === void 0 ? void 0 : _b.reportChanged();\n }\n }\n catch (e_1_1) { e_1 = { error: e_1_1 }; }\n finally {\n try {\n if (ids_1_1 && !ids_1_1.done && (_a = ids_1.return)) _a.call(ids_1);\n }\n finally { if (e_1) throw e_1.error; }\n }\n _this.getAnyChange().reportChanged();\n });\n };\n /** Reports a change of every observed id (a store reload or a bulk remove). */\n ItemChangeSignals.prototype.notifyAllObserved = function () {\n var _this = this;\n if (!this.hasBeenRead()) {\n return;\n }\n getMobx().runInAction(function () {\n var e_2, _a;\n try {\n for (var _b = __values(_this.atoms.values()), _c = _b.next(); !_c.done; _c = _b.next()) {\n var atom = _c.value;\n atom.reportChanged();\n }\n }\n catch (e_2_1) { e_2 = { error: e_2_1 }; }\n finally {\n try {\n if (_c && !_c.done && (_a = _b.return)) _a.call(_b);\n }\n finally { if (e_2) throw e_2.error; }\n }\n _this.getAnyChange().reportChanged();\n });\n };\n Object.defineProperty(ItemChangeSignals.prototype, \"observedCount\", {\n /** Number of live id atoms. For tests only. */\n get: function () {\n return this.atoms.size;\n },\n enumerable: false,\n configurable: true\n });\n // False until the first read: before it, no reaction can be watching.\n ItemChangeSignals.prototype.hasBeenRead = function () {\n return Boolean(this.anyChange) || this.atoms.size > 0;\n };\n ItemChangeSignals.prototype.createAtom = function (id) {\n var _this = this;\n // The callback reads `atom` only when MobX calls it, at the end of a batch after the last observer left,\n // never during `createAtom`.\n var atom = getMobx().createAtom(\"\".concat(this.storeId, \".item.\").concat(id), undefined, function () {\n if (_this.atoms.get(id) === atom) {\n _this.atoms.delete(id);\n }\n });\n this.atoms.set(id, atom);\n return atom;\n };\n ItemChangeSignals.prototype.getProbe = function () {\n if (!this.probe) {\n this.probe = getMobx().createAtom(\"\".concat(this.storeId, \".probe\"));\n }\n return this.probe;\n };\n ItemChangeSignals.prototype.getAnyChange = function () {\n if (!this.anyChange) {\n this.anyChange = getMobx().createAtom(\"\".concat(this.storeId, \".anyChange\"));\n }\n return this.anyChange;\n };\n return ItemChangeSignals;\n}());\nexports[\"default\"] = ItemChangeSignals;\n// Null before login (globals are set by `BringgDashboardSDK.login`): no MobX, so no reaction can observe anything.\nfunction getMobx() {\n var _a;\n return (_a = (0, BringgDashboardSDK_1.getGlobals)()) === null || _a === void 0 ? void 0 : _a.mobx;\n}\n//# sourceMappingURL=item-change-signals.js.map\n\n//# sourceURL=webpack://BringgDashboardSDK/./dist/Data/item-change-signals.js?");
|
|
879
|
-
|
|
880
|
-
/***/ }),
|
|
881
|
-
|
|
882
860
|
/***/ "./dist/Data/light-data-store.js":
|
|
883
861
|
/*!***************************************!*\
|
|
884
862
|
!*** ./dist/Data/light-data-store.js ***!
|
|
@@ -2723,7 +2701,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
|
2723
2701
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
2724
2702
|
|
|
2725
2703
|
"use strict";
|
|
2726
|
-
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 client_page_1 = __webpack_require__(/*! ../Core/Http/client-page */ \"./dist/Core/Http/client-page.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 = '10.2.3-pre.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 var clientPage = (0, client_page_1.currentClientPage)();\n if (clientPage) {\n this.headers[client_page_1.CLIENT_PAGE_HEADER] = clientPage;\n }\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?");
|
|
2704
|
+
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 client_page_1 = __webpack_require__(/*! ../Core/Http/client-page */ \"./dist/Core/Http/client-page.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 = '10.3.0';\nfunction logErrorResponse(response) {\n var data = response.data, status = response.status;\n try {\n Logger_1.default.error(response.config.method.toUpperCase(), response.config.url, status);\n }\n catch (e) {\n //\n }\n try {\n Logger_1.default.info(response.config.method.toUpperCase(), response.config.url, status, data);\n }\n catch (e) {\n //\n }\n try {\n Logger_1.default.debug(response);\n }\n catch (e) {\n //\n }\n}\nexports.logErrorResponse = logErrorResponse;\nvar DEFAULT_TIMEOUT = 120000;\nvar RequestOptions = /** @class */ (function () {\n function RequestOptions(clientId, timeout, 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 var clientPage = (0, client_page_1.currentClientPage)();\n if (clientPage) {\n this.headers[client_page_1.CLIENT_PAGE_HEADER] = clientPage;\n }\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?");
|
|
2727
2705
|
|
|
2728
2706
|
/***/ }),
|
|
2729
2707
|
|
|
@@ -3537,7 +3515,7 @@ eval("\nvar __assign = (this && this.__assign) || function () {\n __assign =
|
|
|
3537
3515
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
3538
3516
|
|
|
3539
3517
|
"use strict";
|
|
3540
|
-
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 __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.MISSING_VEHICLES_CACHE_TTL = void 0;\nvar types_1 = __webpack_require__(/*! @bringg/types */ \"./node_modules/@bringg/types/index.js\");\nvar lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nvar 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 negative_cache_1 = __importDefault(__webpack_require__(/*! ../../utils/decorators/negative-cache */ \"./dist/utils/decorators/negative-cache.js\"));\nvar Vehicle_consts_1 = __webpack_require__(/*! ../Vehicle.consts */ \"./dist/Vehicle/Vehicle.consts.js\");\nvar vehicle_realtime_subscriptions_1 = __importDefault(__webpack_require__(/*! ./vehicle-realtime-subscriptions */ \"./dist/Vehicle/v2/vehicle-realtime-subscriptions.js\"));\nvar vehicles_service_1 = __importDefault(__webpack_require__(/*! ./vehicles-service */ \"./dist/Vehicle/v2/vehicles-service.js\"));\n// How long a vehicle id the server did not return stays out of `batch_get` requests.\nexports.MISSING_VEHICLES_CACHE_TTL = 1000 * 60 * 10; // 10 minutes\nvar MAX_VEHICLES_CHUNK_SIZE = 500;\nvar SERVER_DEFAULT_VEHICLES_CHUNK_SIZE = 50;\nvar getSafeChunkSize = function (chunkSize) {\n if ((0, lodash_1.isNil)(chunkSize) || chunkSize > MAX_VEHICLES_CHUNK_SIZE) {\n return MAX_VEHICLES_CHUNK_SIZE;\n }\n if (chunkSize <= 0) {\n return SERVER_DEFAULT_VEHICLES_CHUNK_SIZE;\n }\n return chunkSize;\n};\nvar VehiclesApi = /** @class */ (function () {\n function VehiclesApi(session) {\n var _this = this;\n var groupFilters = [\n { groupType: Vehicle_consts_1.VehicleGroup.Team, keyFunc: function (vehicle) { return vehicle.team_id; } },\n { groupType: Vehicle_consts_1.VehicleGroup.IsTrailer, keyFunc: function (vehicle) { return !!vehicle.is_trailer; } }\n ];\n this.vehiclesStore = new data_store_1.default(groupFilters);\n this.vehiclesService = new vehicles_service_1.default(session);\n this.storableDataService = new storable_data_service_1.default(this.vehiclesStore, function (vehicle) { return _this.mapVehicle(vehicle); });\n this.vehicleRealtimeSubscriptions = new vehicle_realtime_subscriptions_1.default(session, this.vehiclesStore, this.storableDataService);\n }\n VehiclesApi.prototype.load = function (id, options) {\n var _this = this;\n return this.storableDataService.load('load', function () { return _this.vehiclesService.load(id); }, id, options);\n };\n VehiclesApi.prototype.loadAll = function (options) {\n var _this = this;\n return this.storableDataService.loadAll('loadAll', function () { return _this.vehiclesService.loadAll(); }, options);\n };\n VehiclesApi.prototype.loadAllByTeam = function (teamId, options) {\n var _this = this;\n return this.storableDataService.loadAll('loadAllByTeam', function () { return _this.vehiclesService.loadAllByTeam(teamId); }, __assign(__assign({}, options), { groupType: Vehicle_consts_1.VehicleGroup.Team, groupValue: teamId }));\n };\n // Suppression assumes an id absent from the response is ones the backend can not return for the current user.\n // Note! Items dropped by the server because of limit / chunkSize also fall in this bucket.\n VehiclesApi.prototype.loadMany = function (ids, options) {\n if (options === void 0) { options = data_entity_1.DEFAULT_OPTIONS; }\n return __awaiter(this, void 0, void 0, function () {\n var optionsWithDefaults, chunkSize;\n var _this = this;\n return __generator(this, function (_a) {\n optionsWithDefaults = (0, lodash_1.defaults)({}, options, __assign({}, data_entity_1.DEFAULT_OPTIONS));\n chunkSize = getSafeChunkSize(optionsWithDefaults.chunkSize);\n optionsWithDefaults.chunkSize = chunkSize;\n return [2 /*return*/, this.storableDataService.loadMany('batchGet', function (idsToLoad) {\n if (idsToLoad.length === 0) {\n return Promise.resolve([]);\n }\n return _this.vehiclesService.loadMany(idsToLoad, chunkSize, {\n signal: optionsWithDefaults.signal\n });\n }, ids, optionsWithDefaults)];\n });\n });\n };\n // When requesting by team_ids we don't know how many results will be returned\n // If all pages requested from the API result in a very big array which is set to the store within one sync operation\n // This may choke the main thread.\n // Request / set to the store page by page and let the consumer decide if it loads the next page.\n VehiclesApi.prototype.loadAllByTeamsPaged = function (teamIds, options) {\n var _a;\n return __awaiter(this, void 0, void 0, function () {\n var optionsWithDefaults, shouldUseCache, isFirstPageRequest, teamsIdsToLoad, response;\n var _this = this;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n optionsWithDefaults = (0, lodash_1.defaults)(options, { useCache: true });\n shouldUseCache = Boolean(optionsWithDefaults.useCache);\n isFirstPageRequest = (0, lodash_1.isNil)(optionsWithDefaults.cursor);\n teamsIdsToLoad = shouldUseCache && isFirstPageRequest\n ? teamIds.filter(function (teamId) { return !_this.vehiclesStore.isGroupInitialized(Vehicle_consts_1.VehicleGroup.Team, teamId); })\n : teamIds;\n if (isFirstPageRequest && teamsIdsToLoad.length === 0) {\n return [2 /*return*/, {\n next_page_cursor: null,\n vehicles: this.vehiclesStore.getGroup(Vehicle_consts_1.VehicleGroup.Team, teamIds)\n }];\n }\n return [4 /*yield*/, this.vehiclesService.loadAllByTeamsPaged({\n team_ids: teamsIdsToLoad,\n cursor: optionsWithDefaults.cursor,\n limit: optionsWithDefaults.chunkSize,\n page_action: types_1.KeysetPaginationPageAction.NEXT_ONLY\n }, {\n signal: optionsWithDefaults.signal\n })];\n case 1:\n response = _b.sent();\n if ((_a = response.vehicles) === null || _a === void 0 ? void 0 : _a.length) {\n this.storableDataService.updateManyInStores(response.vehicles, 'loadAllByTeamsPaged');\n }\n if (!response.next_page_cursor) {\n this.vehiclesStore.setGroupInitialized(Vehicle_consts_1.VehicleGroup.Team, teamsIdsToLoad);\n }\n return [2 /*return*/, {\n next_page_cursor: response.next_page_cursor,\n vehicles: response.vehicles.map(function (vehicle) { return _this.vehiclesStore.get(vehicle.id); })\n }];\n }\n });\n });\n };\n VehiclesApi.prototype.delete = function (id) {\n var _this = this;\n return this.storableDataService.delete('delete', function () { return _this.vehiclesService.delete(id); }, id);\n };\n VehiclesApi.prototype.update = function (id, vehicleData) {\n var _this = this;\n return this.storableDataService.modify('update', function () { return _this.vehiclesService.update(id, vehicleData); });\n };\n VehiclesApi.prototype.batchUpdate = function (vehicles) {\n return this.vehiclesService.batchUpdate(vehicles);\n };\n VehiclesApi.prototype.create = function (vehicleData) {\n var _this = this;\n return this.storableDataService.modify('create', function () { return _this.vehiclesService.create(vehicleData); });\n };\n VehiclesApi.prototype.updateStoreOnEvents = function () {\n this.vehicleRealtimeSubscriptions.updateStoreOnEvents();\n };\n // `trailer` is a derived field the reconciler maintains on trucks. Realtime vehicle payloads don't\n // carry it, so a plain truck update would otherwise REPLACE the cached truck and wipe its trailer.\n // Preserve the cached `trailer` whenever the incoming payload omits the key; take it from the payload\n // only when explicitly present (HTTP loads, PUT responses, reconciler writes).\n VehiclesApi.prototype.mapVehicle = function (vehicle) {\n var existing = this.vehiclesStore.get(vehicle.id);\n var current = existing && 'trailer' in existing && !('trailer' in vehicle)\n ? __assign(__assign({}, vehicle), { trailer: existing.trailer }) : vehicle;\n return { current: current, diff: existing };\n };\n VehiclesApi.prototype.onUpdate = function (callback) {\n return this.vehicleRealtimeSubscriptions.onUpdate(callback);\n };\n VehiclesApi.prototype.onDelete = function (callback) {\n return this.vehicleRealtimeSubscriptions.onDelete(callback);\n };\n VehiclesApi.prototype.onUnassigned = function (callback) {\n return this.vehicleRealtimeSubscriptions.onUnassigned(callback);\n };\n VehiclesApi.prototype.get = function (id) {\n return this.vehiclesStore.get(id);\n };\n VehiclesApi.prototype.getAll = function () {\n return this.vehiclesStore.getAll();\n };\n VehiclesApi.prototype.getGroup = function (group, groupValue) {\n return this.vehiclesStore.getGroup(group, groupValue);\n };\n VehiclesApi.prototype.deleteMany = function (ids) {\n return __awaiter(this, void 0, void 0, function () {\n var _this = this;\n return __generator(this, function (_a) {\n return [2 /*return*/, Promise.all(ids.map(function (id) { return _this.delete(id); }))];\n });\n });\n };\n VehiclesApi.prototype.importVehiclesCsv = function (file) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.vehiclesService.importVehiclesCsv(file)];\n });\n });\n };\n VehiclesApi.prototype.getCsvUploadFields = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.vehiclesService.getCsvUploadFields()];\n });\n });\n };\n VehiclesApi.prototype.getAssignmentHistory = function (id, options) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.vehiclesService.getAssignmentHistory(id, options)];\n });\n });\n };\n VehiclesApi.prototype.loadPagedVehicles = function (cursor, limit, filters, page_action) {\n return __awaiter(this, void 0, void 0, function () {\n var response;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.vehiclesService.loadPagedVehicles(cursor, filters, limit, page_action)];\n case 1:\n response = _a.sent();\n if (response && response.vehicles) {\n this.storableDataService.updateManyInStores(response.vehicles);\n }\n return [2 /*return*/, response];\n }\n });\n });\n };\n __decorate([\n (0, negative_cache_1.default)({\n ttlMs: exports.MISSING_VEHICLES_CACHE_TTL,\n hasItem: function (vehiclesApi, id) { return !(0, lodash_1.isNil)(vehiclesApi.get(id)); }\n })\n ], VehiclesApi.prototype, \"loadMany\", null);\n return VehiclesApi;\n}());\nexports[\"default\"] = VehiclesApi;\n//# sourceMappingURL=vehicles-api.js.map\n\n//# sourceURL=webpack://BringgDashboardSDK/./dist/Vehicle/v2/vehicles-api.js?");
|
|
3518
|
+
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 __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.MISSING_VEHICLES_CACHE_TTL = void 0;\nvar types_1 = __webpack_require__(/*! @bringg/types */ \"./node_modules/@bringg/types/index.js\");\nvar lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nvar 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 negative_cache_1 = __importDefault(__webpack_require__(/*! ../../utils/decorators/negative-cache */ \"./dist/utils/decorators/negative-cache.js\"));\nvar Vehicle_consts_1 = __webpack_require__(/*! ../Vehicle.consts */ \"./dist/Vehicle/Vehicle.consts.js\");\nvar vehicle_realtime_subscriptions_1 = __importDefault(__webpack_require__(/*! ./vehicle-realtime-subscriptions */ \"./dist/Vehicle/v2/vehicle-realtime-subscriptions.js\"));\nvar vehicles_service_1 = __importDefault(__webpack_require__(/*! ./vehicles-service */ \"./dist/Vehicle/v2/vehicles-service.js\"));\n// How long a vehicle id the server did not return stays out of `batch_get` requests.\nexports.MISSING_VEHICLES_CACHE_TTL = 1000 * 60 * 10; // 10 minutes\nvar MAX_VEHICLES_CHUNK_SIZE = 500;\nvar SERVER_DEFAULT_VEHICLES_CHUNK_SIZE = 50;\nvar getSafeChunkSize = function (chunkSize) {\n if ((0, lodash_1.isNil)(chunkSize) || chunkSize > MAX_VEHICLES_CHUNK_SIZE) {\n return MAX_VEHICLES_CHUNK_SIZE;\n }\n if (chunkSize <= 0) {\n return SERVER_DEFAULT_VEHICLES_CHUNK_SIZE;\n }\n return chunkSize;\n};\nvar VehiclesApi = /** @class */ (function () {\n function VehiclesApi(session) {\n var _this = this;\n var groupFilters = [\n { groupType: Vehicle_consts_1.VehicleGroup.Team, keyFunc: function (vehicle) { return vehicle.team_id; } },\n { groupType: Vehicle_consts_1.VehicleGroup.IsTrailer, keyFunc: function (vehicle) { return !!vehicle.is_trailer; } }\n ];\n this.vehiclesStore = new data_store_1.default(groupFilters);\n this.vehiclesService = new vehicles_service_1.default(session);\n this.storableDataService = new storable_data_service_1.default(this.vehiclesStore, function (vehicle) { return _this.mapVehicle(vehicle); });\n this.vehicleRealtimeSubscriptions = new vehicle_realtime_subscriptions_1.default(session, this.vehiclesStore, this.storableDataService);\n }\n VehiclesApi.prototype.load = function (id, options) {\n var _this = this;\n return this.storableDataService.load('load', function () { return _this.vehiclesService.load(id); }, id, options);\n };\n VehiclesApi.prototype.loadAll = function (options) {\n var _this = this;\n return this.storableDataService.loadAll('loadAll', function () { return _this.vehiclesService.loadAll(); }, options);\n };\n VehiclesApi.prototype.loadAllByTeam = function (teamId, options) {\n var _this = this;\n return this.storableDataService.loadAll('loadAllByTeam', function () { return _this.vehiclesService.loadAllByTeam(teamId); }, __assign(__assign({}, options), { groupType: Vehicle_consts_1.VehicleGroup.Team, groupValue: teamId }));\n };\n // Suppression assumes an id absent from the response is ones the backend can not return for the current user.\n // Note! Items dropped by the server because of limit / chunkSize also fall in this bucket.\n VehiclesApi.prototype.loadMany = function (ids, options) {\n if (options === void 0) { options = data_entity_1.DEFAULT_OPTIONS; }\n return __awaiter(this, void 0, void 0, function () {\n var optionsWithDefaults, chunkSize;\n var _this = this;\n return __generator(this, function (_a) {\n optionsWithDefaults = (0, lodash_1.defaults)({}, options, __assign({}, data_entity_1.DEFAULT_OPTIONS));\n chunkSize = getSafeChunkSize(optionsWithDefaults.chunkSize);\n optionsWithDefaults.chunkSize = chunkSize;\n return [2 /*return*/, this.storableDataService.loadMany('batchGet', function (idsToLoad) {\n if (idsToLoad.length === 0) {\n return Promise.resolve([]);\n }\n return _this.vehiclesService.loadMany(idsToLoad, chunkSize, {\n signal: optionsWithDefaults.signal\n });\n }, ids, optionsWithDefaults)];\n });\n });\n };\n // When requesting by team_ids we don't know how many results will be returned\n // If all pages requested from the API result in a very big array which is set to the store within one sync operation\n // This may choke the main thread.\n // Request / set to the store page by page and let the consumer decide if it loads the next page.\n VehiclesApi.prototype.loadAllByTeamsPaged = function (teamIds, options) {\n var _a;\n return __awaiter(this, void 0, void 0, function () {\n var optionsWithDefaults, shouldUseCache, isFirstPageRequest, teamsIdsToLoad, response;\n var _this = this;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n optionsWithDefaults = (0, lodash_1.defaults)(options, { useCache: true });\n shouldUseCache = Boolean(optionsWithDefaults.useCache);\n isFirstPageRequest = (0, lodash_1.isNil)(optionsWithDefaults.cursor);\n teamsIdsToLoad = shouldUseCache && isFirstPageRequest\n ? teamIds.filter(function (teamId) { return !_this.vehiclesStore.isGroupInitialized(Vehicle_consts_1.VehicleGroup.Team, teamId); })\n : teamIds;\n if (isFirstPageRequest && teamsIdsToLoad.length === 0) {\n return [2 /*return*/, {\n next_page_cursor: null,\n vehicles: this.vehiclesStore.getGroup(Vehicle_consts_1.VehicleGroup.Team, teamIds)\n }];\n }\n return [4 /*yield*/, this.vehiclesService.loadAllByTeamsPaged({\n team_ids: teamsIdsToLoad,\n cursor: optionsWithDefaults.cursor,\n limit: optionsWithDefaults.chunkSize,\n page_action: types_1.KeysetPaginationPageAction.NEXT_ONLY\n }, {\n signal: optionsWithDefaults.signal\n })];\n case 1:\n response = _b.sent();\n if ((_a = response.vehicles) === null || _a === void 0 ? void 0 : _a.length) {\n this.storableDataService.updateManyInStores(response.vehicles, 'loadAllByTeamsPaged');\n }\n if (!response.next_page_cursor) {\n this.vehiclesStore.setGroupInitialized(Vehicle_consts_1.VehicleGroup.Team, teamsIdsToLoad);\n }\n return [2 /*return*/, {\n next_page_cursor: response.next_page_cursor,\n vehicles: response.vehicles.map(function (vehicle) { return _this.vehiclesStore.get(vehicle.id); })\n }];\n }\n });\n });\n };\n VehiclesApi.prototype.delete = function (id) {\n var _this = this;\n return this.storableDataService.delete('delete', function () { return _this.vehiclesService.delete(id); }, id);\n };\n VehiclesApi.prototype.update = function (id, vehicleData) {\n var _this = this;\n return this.storableDataService.modify('update', function () { return _this.vehiclesService.update(id, vehicleData); });\n };\n /**\n * Updates many vehicles in one request. Does not update the store.\n * @param vehicles - Vehicles to update, each with its `id`\n * @returns Resolves when 1 or more vehicles are saved; `errors` lists the vehicles that failed\n * (empty when all are saved)\n * @throws {BringgException} When no vehicle is saved: `errors` holds the server errors.\n * On an HTTP or network error it has no `errors`; `statusCode` is set when the server answered.\n */\n VehiclesApi.prototype.batchUpdate = function (vehicles) {\n return this.vehiclesService.batchUpdate(vehicles);\n };\n VehiclesApi.prototype.create = function (vehicleData) {\n var _this = this;\n return this.storableDataService.modify('create', function () { return _this.vehiclesService.create(vehicleData); });\n };\n VehiclesApi.prototype.updateStoreOnEvents = function () {\n this.vehicleRealtimeSubscriptions.updateStoreOnEvents();\n };\n // `trailer` is a derived field the reconciler maintains on trucks. Realtime vehicle payloads don't\n // carry it, so a plain truck update would otherwise REPLACE the cached truck and wipe its trailer.\n // Preserve the cached `trailer` whenever the incoming payload omits the key; take it from the payload\n // only when explicitly present (HTTP loads, PUT responses, reconciler writes).\n VehiclesApi.prototype.mapVehicle = function (vehicle) {\n var existing = this.vehiclesStore.get(vehicle.id);\n var current = existing && 'trailer' in existing && !('trailer' in vehicle)\n ? __assign(__assign({}, vehicle), { trailer: existing.trailer }) : vehicle;\n return { current: current, diff: existing };\n };\n VehiclesApi.prototype.onUpdate = function (callback) {\n return this.vehicleRealtimeSubscriptions.onUpdate(callback);\n };\n VehiclesApi.prototype.onDelete = function (callback) {\n return this.vehicleRealtimeSubscriptions.onDelete(callback);\n };\n VehiclesApi.prototype.onUnassigned = function (callback) {\n return this.vehicleRealtimeSubscriptions.onUnassigned(callback);\n };\n VehiclesApi.prototype.get = function (id) {\n return this.vehiclesStore.get(id);\n };\n VehiclesApi.prototype.getAll = function () {\n return this.vehiclesStore.getAll();\n };\n VehiclesApi.prototype.getGroup = function (group, groupValue) {\n return this.vehiclesStore.getGroup(group, groupValue);\n };\n VehiclesApi.prototype.deleteMany = function (ids) {\n return __awaiter(this, void 0, void 0, function () {\n var _this = this;\n return __generator(this, function (_a) {\n return [2 /*return*/, Promise.all(ids.map(function (id) { return _this.delete(id); }))];\n });\n });\n };\n VehiclesApi.prototype.importVehiclesCsv = function (file) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.vehiclesService.importVehiclesCsv(file)];\n });\n });\n };\n VehiclesApi.prototype.getCsvUploadFields = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.vehiclesService.getCsvUploadFields()];\n });\n });\n };\n VehiclesApi.prototype.getAssignmentHistory = function (id, options) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.vehiclesService.getAssignmentHistory(id, options)];\n });\n });\n };\n VehiclesApi.prototype.loadPagedVehicles = function (cursor, limit, filters, page_action) {\n return __awaiter(this, void 0, void 0, function () {\n var response;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.vehiclesService.loadPagedVehicles(cursor, filters, limit, page_action)];\n case 1:\n response = _a.sent();\n if (response && response.vehicles) {\n this.storableDataService.updateManyInStores(response.vehicles);\n }\n return [2 /*return*/, response];\n }\n });\n });\n };\n __decorate([\n (0, negative_cache_1.default)({\n ttlMs: exports.MISSING_VEHICLES_CACHE_TTL,\n hasItem: function (vehiclesApi, id) { return !(0, lodash_1.isNil)(vehiclesApi.get(id)); }\n })\n ], VehiclesApi.prototype, \"loadMany\", null);\n return VehiclesApi;\n}());\nexports[\"default\"] = VehiclesApi;\n//# sourceMappingURL=vehicles-api.js.map\n\n//# sourceURL=webpack://BringgDashboardSDK/./dist/Vehicle/v2/vehicles-api.js?");
|
|
3541
3519
|
|
|
3542
3520
|
/***/ }),
|
|
3543
3521
|
|
|
@@ -3548,7 +3526,7 @@ eval("\nvar __assign = (this && this.__assign) || function () {\n __assign =
|
|
|
3548
3526
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
3549
3527
|
|
|
3550
3528
|
"use strict";
|
|
3551
|
-
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 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 VehicleEntity_1 = __webpack_require__(/*! ../Entity/VehicleEntity */ \"./dist/Vehicle/Entity/VehicleEntity.js\");\nvar Vehicle_consts_1 = __webpack_require__(/*! ../Vehicle.consts */ \"./dist/Vehicle/Vehicle.consts.js\");\nvar VehiclesService = /** @class */ (function () {\n function VehiclesService(session) {\n this.service = new CrudService_1.default(session, 'vehicles');\n }\n VehiclesService.prototype.load = function (id) {\n return __awaiter(this, void 0, void 0, function () {\n var result;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.service.get(id)];\n case 1:\n result = _a.sent();\n return [2 /*return*/, result.vehicle];\n }\n });\n });\n };\n VehiclesService.prototype.loadAll = function () {\n return __awaiter(this, void 0, void 0, function () {\n var result;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.service.getAll()];\n case 1:\n result = _a.sent();\n return [2 /*return*/, result.vehicles];\n }\n });\n });\n };\n VehiclesService.prototype.create = function (vehicleData) {\n return __awaiter(this, void 0, void 0, function () {\n var result;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.service.create(vehicleData)];\n case 1:\n result = _a.sent();\n return [2 /*return*/, result.vehicle];\n }\n });\n });\n };\n VehiclesService.prototype.update = function (id, vehicleData) {\n return __awaiter(this, void 0, void 0, function () {\n var result;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.service.update(id, vehicleData)];\n case 1:\n result = _a.sent();\n return [2 /*return*/, result.vehicle];\n }\n });\n });\n };\n VehiclesService.prototype.batchUpdate = function (vehicles) {\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.service.routeGenerator\n .patch(VehicleEntity_1.Routes.BATCH_UPDATE)\n .withPayload({ vehicles: vehicles })\n .setException('failed to batch update vehicles')\n .withExtractor(Vehicle_consts_1.vehiclesExtractor)\n .invoke()];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n VehiclesService.prototype.delete = function (id) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.service.delete(id)];\n });\n });\n };\n VehiclesService.prototype.loadAllByTeam = function (teamId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.service.routeGenerator\n .get(VehicleEntity_1.Routes.GET_BY_TEAM)\n .withExtractor(Vehicle_consts_1.vehiclesExtractor)\n .setException(\"failed to load vehicles from team \".concat(teamId))\n .withRouteParams({ teamId: teamId })\n .invoke()];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n VehiclesService.prototype.loadMany = function (ids, limit, commonOptions) {\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.service.routeGenerator\n .post(VehicleEntity_1.Routes.BATCH_GET)\n .withPayload({\n ids: ids,\n limit: limit,\n page_action: types_1.KeysetPaginationPageAction.NEXT_ONLY\n })\n .withCommonOptions(commonOptions)\n .withExtractor(Vehicle_consts_1.vehiclesExtractor)\n .setException(\"failed to load vehicles for ids \".concat(ids.join(',')))\n .invoke()];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n VehiclesService.prototype.getCsvUploadFields = 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(VehicleEntity_1.Routes.GET_CSV_UPLOAD_FIELDS)\n .withExtractor(Vehicle_consts_1.getCsvFieldsExtractor)\n .setException('failed to get vehicles csv upload fields')\n .invoke()];\n });\n });\n };\n VehiclesService.prototype.importVehiclesCsv = function (file) {\n return __awaiter(this, void 0, void 0, function () {\n var formData;\n return __generator(this, function (_a) {\n formData = new FormData();\n formData.append('file', file);\n return [2 /*return*/, this.service.routeGenerator\n .post(VehicleEntity_1.Routes.IMPORT_VEHICLES_CSV)\n .withHeaders({ 'Content-Type': 'multipart/form-data' })\n .setException('failed to import vehicles csv')\n .withPayload(formData)\n .invoke()];\n });\n });\n };\n VehiclesService.prototype.getAssignmentHistory = function (vehicle_id, options) {\n return __awaiter(this, void 0, void 0, function () {\n var request;\n return __generator(this, function (_a) {\n request = this.service.routeGenerator\n .post(VehicleEntity_1.Routes.GET_ASSIGNMENT_HISTORY)\n .withExtractor(Vehicle_consts_1.assignmentHistoryExtractor)\n .setException(\"failed to get vehicle_Id: \".concat(vehicle_id, \" assignment history\"))\n .withPayload({ vehicle_id: vehicle_id });\n if (options) {\n request.withQueryString(options);\n }\n return [2 /*return*/, request.invoke()];\n });\n });\n };\n VehiclesService.prototype.loadPagedVehicles = function (cursor, filters, limit, page_action) {\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.service.routeGenerator\n .get(VehicleEntity_1.Routes.PAGED_VEHICLES)\n .withQueryString(__assign(__assign({}, filters), { cursor: cursor, limit: limit, page_action: page_action }))\n .invoke()];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n VehiclesService.prototype.loadAllByTeamsPaged = function (payload, commonOptions) {\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.service.routeGenerator\n .post(VehicleEntity_1.Routes.BATCH_GET)\n .withPayload(payload)\n .withCommonOptions(commonOptions)\n .withExtractor(function (response) { return response; })\n .setException(\"failed to load vehicles for teams \".concat(payload.team_ids.join(',')))\n .invoke()];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n return VehiclesService;\n}());\nexports[\"default\"] = VehiclesService;\n//# sourceMappingURL=vehicles-service.js.map\n\n//# sourceURL=webpack://BringgDashboardSDK/./dist/Vehicle/v2/vehicles-service.js?");
|
|
3529
|
+
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 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 VehicleEntity_1 = __webpack_require__(/*! ../Entity/VehicleEntity */ \"./dist/Vehicle/Entity/VehicleEntity.js\");\nvar Vehicle_consts_1 = __webpack_require__(/*! ../Vehicle.consts */ \"./dist/Vehicle/Vehicle.consts.js\");\nvar VehiclesService = /** @class */ (function () {\n function VehiclesService(session) {\n this.service = new CrudService_1.default(session, 'vehicles');\n }\n VehiclesService.prototype.load = function (id) {\n return __awaiter(this, void 0, void 0, function () {\n var result;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.service.get(id)];\n case 1:\n result = _a.sent();\n return [2 /*return*/, result.vehicle];\n }\n });\n });\n };\n VehiclesService.prototype.loadAll = function () {\n return __awaiter(this, void 0, void 0, function () {\n var result;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.service.getAll()];\n case 1:\n result = _a.sent();\n return [2 /*return*/, result.vehicles];\n }\n });\n });\n };\n VehiclesService.prototype.create = function (vehicleData) {\n return __awaiter(this, void 0, void 0, function () {\n var result;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.service.create(vehicleData)];\n case 1:\n result = _a.sent();\n return [2 /*return*/, result.vehicle];\n }\n });\n });\n };\n VehiclesService.prototype.update = function (id, vehicleData) {\n return __awaiter(this, void 0, void 0, function () {\n var result;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.service.update(id, vehicleData)];\n case 1:\n result = _a.sent();\n return [2 /*return*/, result.vehicle];\n }\n });\n });\n };\n VehiclesService.prototype.batchUpdate = function (vehicles) {\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.service.routeGenerator\n .patch(VehicleEntity_1.Routes.BATCH_UPDATE)\n .withPayload({ vehicles: vehicles })\n .setException('failed to batch update vehicles')\n .withExtractor(function (response) {\n var _a;\n return ({\n success: response.success,\n errors: (_a = response.errors) !== null && _a !== void 0 ? _a : []\n });\n })\n .invoke()];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n VehiclesService.prototype.delete = function (id) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.service.delete(id)];\n });\n });\n };\n VehiclesService.prototype.loadAllByTeam = function (teamId) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.service.routeGenerator\n .get(VehicleEntity_1.Routes.GET_BY_TEAM)\n .withExtractor(Vehicle_consts_1.vehiclesExtractor)\n .setException(\"failed to load vehicles from team \".concat(teamId))\n .withRouteParams({ teamId: teamId })\n .invoke()];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n VehiclesService.prototype.loadMany = function (ids, limit, commonOptions) {\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.service.routeGenerator\n .post(VehicleEntity_1.Routes.BATCH_GET)\n .withPayload({\n ids: ids,\n limit: limit,\n page_action: types_1.KeysetPaginationPageAction.NEXT_ONLY\n })\n .withCommonOptions(commonOptions)\n .withExtractor(Vehicle_consts_1.vehiclesExtractor)\n .setException(\"failed to load vehicles for ids \".concat(ids.join(',')))\n .invoke()];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n VehiclesService.prototype.getCsvUploadFields = 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(VehicleEntity_1.Routes.GET_CSV_UPLOAD_FIELDS)\n .withExtractor(Vehicle_consts_1.getCsvFieldsExtractor)\n .setException('failed to get vehicles csv upload fields')\n .invoke()];\n });\n });\n };\n VehiclesService.prototype.importVehiclesCsv = function (file) {\n return __awaiter(this, void 0, void 0, function () {\n var formData;\n return __generator(this, function (_a) {\n formData = new FormData();\n formData.append('file', file);\n return [2 /*return*/, this.service.routeGenerator\n .post(VehicleEntity_1.Routes.IMPORT_VEHICLES_CSV)\n .withHeaders({ 'Content-Type': 'multipart/form-data' })\n .setException('failed to import vehicles csv')\n .withPayload(formData)\n .invoke()];\n });\n });\n };\n VehiclesService.prototype.getAssignmentHistory = function (vehicle_id, options) {\n return __awaiter(this, void 0, void 0, function () {\n var request;\n return __generator(this, function (_a) {\n request = this.service.routeGenerator\n .post(VehicleEntity_1.Routes.GET_ASSIGNMENT_HISTORY)\n .withExtractor(Vehicle_consts_1.assignmentHistoryExtractor)\n .setException(\"failed to get vehicle_Id: \".concat(vehicle_id, \" assignment history\"))\n .withPayload({ vehicle_id: vehicle_id });\n if (options) {\n request.withQueryString(options);\n }\n return [2 /*return*/, request.invoke()];\n });\n });\n };\n VehiclesService.prototype.loadPagedVehicles = function (cursor, filters, limit, page_action) {\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.service.routeGenerator\n .get(VehicleEntity_1.Routes.PAGED_VEHICLES)\n .withQueryString(__assign(__assign({}, filters), { cursor: cursor, limit: limit, page_action: page_action }))\n .invoke()];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n VehiclesService.prototype.loadAllByTeamsPaged = function (payload, commonOptions) {\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.service.routeGenerator\n .post(VehicleEntity_1.Routes.BATCH_GET)\n .withPayload(payload)\n .withCommonOptions(commonOptions)\n .withExtractor(function (response) { return response; })\n .setException(\"failed to load vehicles for teams \".concat(payload.team_ids.join(',')))\n .invoke()];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n };\n return VehiclesService;\n}());\nexports[\"default\"] = VehiclesService;\n//# sourceMappingURL=vehicles-service.js.map\n\n//# sourceURL=webpack://BringgDashboardSDK/./dist/Vehicle/v2/vehicles-service.js?");
|
|
3552
3530
|
|
|
3553
3531
|
/***/ }),
|
|
3554
3532
|
|