@bringg/dashboard-sdk 8.26.0 → 8.27.0-pre.1

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.
Files changed (46) hide show
  1. package/dist/Core/BaseStore.js +1 -1
  2. package/dist/Core/BaseStore.js.map +1 -1
  3. package/dist/Customer/v2/customers-api.d.ts +5 -4
  4. package/dist/Customer/v2/customers-api.js +12 -8
  5. package/dist/Customer/v2/customers-api.js.map +1 -1
  6. package/dist/Data/storable-realtime-subscriptions.d.ts +18 -0
  7. package/dist/Data/storable-realtime-subscriptions.js +144 -0
  8. package/dist/Data/storable-realtime-subscriptions.js.map +1 -0
  9. package/dist/Data/storable-types.d.ts +19 -0
  10. package/dist/Data/storable-types.js +3 -0
  11. package/dist/Data/storable-types.js.map +1 -0
  12. package/dist/Run/Service/runs.service.d.ts +5 -5
  13. package/dist/Run/Service/runs.service.js +25 -44
  14. package/dist/Run/Service/runs.service.js.map +1 -1
  15. package/dist/Run/Store/RunStore.js +0 -1
  16. package/dist/Run/Store/RunStore.js.map +1 -1
  17. package/dist/Run/runs.consts.d.ts +3 -0
  18. package/dist/Run/runs.consts.js +5 -1
  19. package/dist/Run/runs.consts.js.map +1 -1
  20. package/dist/Run/runs.d.ts +2 -2
  21. package/dist/Run/runs.js +2 -2
  22. package/dist/Run/runs.js.map +1 -1
  23. package/dist/Run/v2/run-realtime-subscriptions.d.ts +25 -0
  24. package/dist/Run/v2/run-realtime-subscriptions.js +152 -0
  25. package/dist/Run/v2/run-realtime-subscriptions.js.map +1 -0
  26. package/dist/Run/v2/runs-api.d.ts +28 -5
  27. package/dist/Run/v2/runs-api.js +180 -30
  28. package/dist/Run/v2/runs-api.js.map +1 -1
  29. package/dist/Services/ServiceRequest.js +1 -1
  30. package/dist/Task/v2/task-realtime-subscriptions.d.ts +7 -13
  31. package/dist/Task/v2/task-realtime-subscriptions.js +61 -122
  32. package/dist/Task/v2/task-realtime-subscriptions.js.map +1 -1
  33. package/dist/Task/v2/tasks-api.d.ts +5 -5
  34. package/dist/Vehicle/v2/vehicles-api.d.ts +5 -7
  35. package/dist/Vehicle/v2/vehicles-api.js +11 -29
  36. package/dist/Vehicle/v2/vehicles-api.js.map +1 -1
  37. package/dist/bringg-dashboard-sdk-cjs2.js +626 -246
  38. package/dist/bringg-dashboard-sdk-cjs2.js.map +1 -1
  39. package/dist/bringg-dashboard-sdk.js +34 -12
  40. package/dist/bringg-dashboard-sdk.min.js +1 -1
  41. package/dist/bringg-dashboard-sdk.min.js.map +1 -1
  42. package/dist/data-entity.d.ts +1 -1
  43. package/dist/storable-data-service.d.ts +2 -2
  44. package/dist/storable-data-service.js +17 -6
  45. package/dist/storable-data-service.js.map +1 -1
  46. package/package.json +1 -1
@@ -3949,7 +3949,7 @@ var BaseStore = /** @class */ (function () {
3949
3949
  };
3950
3950
  this.getItemsByIds = function (ids) {
3951
3951
  var idsSet = new Set(ids);
3952
- return _this.getItems().filter(function (runModel) { return idsSet.has(runModel.id); });
3952
+ return _this.getItems().filter(function (item) { return idsSet.has(item.id); });
3953
3953
  };
3954
3954
  this.getItemsMap = function () {
3955
3955
  return _this._items;
@@ -6451,9 +6451,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
6451
6451
  Object.defineProperty(exports, "__esModule", ({ value: true }));
6452
6452
  var _ = __webpack_require__(96486);
6453
6453
  var merge_mapper_1 = __webpack_require__(59200);
6454
+ var storable_realtime_subscriptions_1 = __webpack_require__(1227);
6454
6455
  var data_entity_1 = __webpack_require__(91083);
6455
6456
  var data_store_1 = __webpack_require__(73135);
6456
- var realtime_subscriptions_1 = __webpack_require__(47985);
6457
6457
  var storable_data_service_1 = __webpack_require__(45297);
6458
6458
  var array_utils_1 = __webpack_require__(43052);
6459
6459
  var Customer_consts_1 = __webpack_require__(85240);
@@ -6466,15 +6466,19 @@ var CustomersApi = /** @class */ (function () {
6466
6466
  this.storableDataService = new storable_data_service_1.default(this.customersStore, function (customer) {
6467
6467
  return merge_mapper_1.mergeMapper.mergeIntoExisting(_this.customersStore, customer);
6468
6468
  });
6469
- this.realtimeSubscriptions = new realtime_subscriptions_1.default(session);
6470
- this.realtimeSubscriptions.subscribe(Customer_consts_1.RealtimeEvents.Created, this.storableDataService.updateInStores.bind(this.storableDataService));
6471
- this.realtimeSubscriptions.subscribe(Customer_consts_1.RealtimeEvents.Updated, this.storableDataService.updateInStores.bind(this.storableDataService));
6472
- this.realtimeSubscriptions.subscribe(Customer_consts_1.RealtimeEvents.Deleted, function (data) {
6473
- return _this.storableDataService.removeFromStores(data.customer_id);
6474
- });
6469
+ this.storableRealtimeSubscriptions = new storable_realtime_subscriptions_1.default(session, this.customersStore, this.storableDataService);
6470
+ this.storableRealtimeSubscriptions.updateStoreOnEvents([
6471
+ { name: Customer_consts_1.RealtimeEvents.Created, isDelete: false },
6472
+ { name: Customer_consts_1.RealtimeEvents.Updated, isDelete: false },
6473
+ {
6474
+ name: Customer_consts_1.RealtimeEvents.Deleted,
6475
+ isDelete: true,
6476
+ itemExtractor: function (payload) { return ({ id: payload.customer_id }); }
6477
+ }
6478
+ ]);
6475
6479
  }
6476
6480
  CustomersApi.prototype.onCreate = function (callback) {
6477
- this.realtimeSubscriptions.subscribe(Customer_consts_1.RealtimeEvents.Created, callback);
6481
+ return this.storableRealtimeSubscriptions.onEvent(Customer_consts_1.RealtimeEvents.Created, function (item) { return callback(item.current); });
6478
6482
  };
6479
6483
  CustomersApi.prototype.add = function (customer) {
6480
6484
  return this.storableDataService.updateInStores(customer);
@@ -7488,6 +7492,157 @@ exports.objectMerger = { deepMerge: deepMerge };
7488
7492
 
7489
7493
  /***/ }),
7490
7494
 
7495
+ /***/ 1227:
7496
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
7497
+
7498
+ "use strict";
7499
+
7500
+ var __values = (this && this.__values) || function(o) {
7501
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
7502
+ if (m) return m.call(o);
7503
+ if (o && typeof o.length === "number") return {
7504
+ next: function () {
7505
+ if (o && i >= o.length) o = void 0;
7506
+ return { value: o && o[i++], done: !o };
7507
+ }
7508
+ };
7509
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
7510
+ };
7511
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
7512
+ var realtime_subscriptions_1 = __webpack_require__(47985);
7513
+ var object_merger_1 = __webpack_require__(7262);
7514
+ var StorableRealtimeSubscriptions = /** @class */ (function () {
7515
+ function StorableRealtimeSubscriptions(session, dataStore, storableDataService) {
7516
+ this.realtimeSubscriptions = new realtime_subscriptions_1.default(session);
7517
+ this.dataStore = dataStore;
7518
+ this.storableDataService = storableDataService;
7519
+ this.eventCallbacks = {};
7520
+ }
7521
+ StorableRealtimeSubscriptions.prototype.updateStoreOnEvents = function (events, subEntityEvents) {
7522
+ var e_1, _a, e_2, _b;
7523
+ var _this = this;
7524
+ if (subEntityEvents === void 0) { subEntityEvents = []; }
7525
+ var _loop_1 = function (event_1) {
7526
+ this_1.realtimeSubscriptions.subscribe(event_1.name, function (item) {
7527
+ item = event_1.itemExtractor ? event_1.itemExtractor(item) : item;
7528
+ var data = event_1.extraDataFunc && event_1.extraDataFunc(item);
7529
+ if (data === null || data === void 0 ? void 0 : data.ignore) {
7530
+ return;
7531
+ }
7532
+ if (event_1.isDelete) {
7533
+ var deletedItem = _this.storableDataService.removeFromStores(item.id);
7534
+ _this.runEventCallbacks(event_1.name, { diff: deletedItem });
7535
+ }
7536
+ else {
7537
+ var mappedStorableItem = _this.storableDataService.updateInStores(item, undefined, undefined, data === null || data === void 0 ? void 0 : data.params);
7538
+ _this.runEventCallbacks(event_1.name, mappedStorableItem);
7539
+ }
7540
+ });
7541
+ };
7542
+ var this_1 = this;
7543
+ try {
7544
+ for (var events_1 = __values(events), events_1_1 = events_1.next(); !events_1_1.done; events_1_1 = events_1.next()) {
7545
+ var event_1 = events_1_1.value;
7546
+ _loop_1(event_1);
7547
+ }
7548
+ }
7549
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
7550
+ finally {
7551
+ try {
7552
+ if (events_1_1 && !events_1_1.done && (_a = events_1.return)) _a.call(events_1);
7553
+ }
7554
+ finally { if (e_1) throw e_1.error; }
7555
+ }
7556
+ var _loop_2 = function (subEntityEvent) {
7557
+ this_2.realtimeSubscriptions.subscribe(subEntityEvent.name, function (subEntity) {
7558
+ subEntityEvent.ignoreFields.forEach(function (field) { return delete subEntity[field]; });
7559
+ var eventChangeData = _this.changeSubEntity(subEntity, subEntityEvent.parentField, subEntityEvent.field, subEntityEvent.isDelete);
7560
+ if (eventChangeData.current) {
7561
+ _this.runEventCallbacks(subEntityEvent.eventToRaise, eventChangeData);
7562
+ }
7563
+ });
7564
+ };
7565
+ var this_2 = this;
7566
+ try {
7567
+ for (var subEntityEvents_1 = __values(subEntityEvents), subEntityEvents_1_1 = subEntityEvents_1.next(); !subEntityEvents_1_1.done; subEntityEvents_1_1 = subEntityEvents_1.next()) {
7568
+ var subEntityEvent = subEntityEvents_1_1.value;
7569
+ _loop_2(subEntityEvent);
7570
+ }
7571
+ }
7572
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
7573
+ finally {
7574
+ try {
7575
+ if (subEntityEvents_1_1 && !subEntityEvents_1_1.done && (_b = subEntityEvents_1.return)) _b.call(subEntityEvents_1);
7576
+ }
7577
+ finally { if (e_2) throw e_2.error; }
7578
+ }
7579
+ };
7580
+ StorableRealtimeSubscriptions.prototype.onAnyEvent = function (event, callback) {
7581
+ return this.realtimeSubscriptions.subscribe(event, callback);
7582
+ };
7583
+ StorableRealtimeSubscriptions.prototype.onEvent = function (event, callback) {
7584
+ var _this = this;
7585
+ if (!this.eventCallbacks[event]) {
7586
+ this.eventCallbacks[event] = [];
7587
+ }
7588
+ this.eventCallbacks[event].push(callback);
7589
+ return function () {
7590
+ var indexOfCallback = _this.eventCallbacks[event].indexOf(callback);
7591
+ _this.eventCallbacks[event].splice(indexOfCallback, 1);
7592
+ };
7593
+ };
7594
+ StorableRealtimeSubscriptions.prototype.runEventCallbacks = function (event, data) {
7595
+ (this.eventCallbacks[event] || []).forEach(function (callback) { return callback(data); });
7596
+ };
7597
+ StorableRealtimeSubscriptions.prototype.changeSubEntity = function (subEntity, parentField, containerField, isDelete) {
7598
+ var _a, _b, _c;
7599
+ var current = this.dataStore.get(subEntity[parentField]);
7600
+ var diff;
7601
+ if (current) {
7602
+ if (!current[containerField]) {
7603
+ current[containerField] = [];
7604
+ }
7605
+ var existingIndex = current[containerField].findIndex(function (taskSubEntity) { return taskSubEntity.id === subEntity.id; });
7606
+ if (existingIndex > -1) {
7607
+ if (isDelete) {
7608
+ diff = (_a = { id: current.id }, _a[containerField] = this.createArrayOfEmptyObjects(existingIndex), _a);
7609
+ for (var i = existingIndex + 1; i < current[containerField].length; i++) {
7610
+ diff[containerField].push(current[containerField][i]);
7611
+ }
7612
+ current[containerField].splice(existingIndex, 1);
7613
+ }
7614
+ else {
7615
+ var subEntityDiff = object_merger_1.objectMerger.deepMerge(current[containerField][existingIndex], subEntity);
7616
+ diff = (_b = {
7617
+ id: current.id
7618
+ },
7619
+ _b[containerField] = this.createArrayOfEmptyObjects(current[containerField].length),
7620
+ _b);
7621
+ diff[containerField][existingIndex] = subEntityDiff;
7622
+ }
7623
+ }
7624
+ else if (!isDelete) {
7625
+ diff = (_c = {
7626
+ id: current.id
7627
+ },
7628
+ _c[containerField] = this.createArrayOfEmptyObjects(current[containerField].length),
7629
+ _c);
7630
+ diff[containerField].push(subEntity);
7631
+ current[containerField].push(subEntity);
7632
+ }
7633
+ }
7634
+ return { current: current, diff: diff };
7635
+ };
7636
+ StorableRealtimeSubscriptions.prototype.createArrayOfEmptyObjects = function (length) {
7637
+ return Array.from({ length: length }, function () { return ({}); });
7638
+ };
7639
+ return StorableRealtimeSubscriptions;
7640
+ }());
7641
+ exports["default"] = StorableRealtimeSubscriptions;
7642
+ //# sourceMappingURL=storable-realtime-subscriptions.js.map
7643
+
7644
+ /***/ }),
7645
+
7491
7646
  /***/ 27774:
7492
7647
  /***/ ((__unused_webpack_module, exports) => {
7493
7648
 
@@ -17363,21 +17518,6 @@ exports["default"] = Rules;
17363
17518
 
17364
17519
  "use strict";
17365
17520
 
17366
- var __extends = (this && this.__extends) || (function () {
17367
- var extendStatics = function (d, b) {
17368
- extendStatics = Object.setPrototypeOf ||
17369
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
17370
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
17371
- return extendStatics(d, b);
17372
- };
17373
- return function (d, b) {
17374
- if (typeof b !== "function" && b !== null)
17375
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
17376
- extendStatics(d, b);
17377
- function __() { this.constructor = d; }
17378
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
17379
- };
17380
- })();
17381
17521
  var __assign = (this && this.__assign) || function () {
17382
17522
  __assign = Object.assign || function(t) {
17383
17523
  for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -17428,8 +17568,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
17428
17568
  Object.defineProperty(exports, "__esModule", ({ value: true }));
17429
17569
  exports.RunsService = exports.Routes = void 0;
17430
17570
  var BringgException_1 = __webpack_require__(43605);
17571
+ var CrudService_1 = __webpack_require__(14809);
17431
17572
  var Route_1 = __webpack_require__(92641);
17432
- var SessionBasedService_1 = __webpack_require__(27826);
17433
17573
  var array_utils_1 = __webpack_require__(43052);
17434
17574
  var runs_consts_1 = __webpack_require__(4669);
17435
17575
  exports.Routes = {
@@ -17448,27 +17588,23 @@ exports.Routes = {
17448
17588
  ASSIGN_VEHICLES: new Route_1.Route('/runs/{:id}/vehicles_assignment', 3 /* HttpMethod.PATCH */),
17449
17589
  UNASSIGN_VEHICLES: new Route_1.Route('/runs/{:id}/vehicles_assignment', 4 /* HttpMethod.DELETE */)
17450
17590
  };
17451
- var RunsService = /** @class */ (function (_super) {
17452
- __extends(RunsService, _super);
17591
+ var RunsService = /** @class */ (function () {
17453
17592
  function RunsService(session) {
17454
- return _super.call(this, session.config.getApiEndpoint(), session) || this;
17593
+ this.service = new CrudService_1.default(session, 'runs');
17455
17594
  }
17456
17595
  RunsService.prototype.getAll = function (options, _a) {
17457
17596
  var _b = _a === void 0 ? {} : _a, signal = _b.signal;
17458
17597
  return __awaiter(this, void 0, void 0, function () {
17459
- var runsResponse;
17460
17598
  return __generator(this, function (_c) {
17461
17599
  switch (_c.label) {
17462
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17600
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17463
17601
  route: exports.Routes.GET_RUNS,
17464
17602
  extractor: runs_consts_1.defaultExtractor,
17465
17603
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to get Runs'),
17466
17604
  queryString: options,
17467
17605
  signal: signal
17468
17606
  })];
17469
- case 1:
17470
- runsResponse = _c.sent();
17471
- return [2 /*return*/, runsResponse];
17607
+ case 1: return [2 /*return*/, _c.sent()];
17472
17608
  }
17473
17609
  });
17474
17610
  });
@@ -17478,7 +17614,7 @@ var RunsService = /** @class */ (function (_super) {
17478
17614
  return __awaiter(this, void 0, void 0, function () {
17479
17615
  return __generator(this, function (_c) {
17480
17616
  switch (_c.label) {
17481
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17617
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17482
17618
  route: exports.Routes.GET_RUN_DATA,
17483
17619
  extractor: runs_consts_1.defaultExtractor,
17484
17620
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to get routes data'),
@@ -17553,22 +17689,19 @@ var RunsService = /** @class */ (function (_super) {
17553
17689
  });
17554
17690
  });
17555
17691
  };
17556
- RunsService.prototype.get = function (id, _a) {
17692
+ RunsService.prototype.load = function (id, _a) {
17557
17693
  var _b = _a === void 0 ? {} : _a, signal = _b.signal;
17558
17694
  return __awaiter(this, void 0, void 0, function () {
17559
- var run;
17560
17695
  return __generator(this, function (_c) {
17561
17696
  switch (_c.label) {
17562
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17697
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17563
17698
  route: exports.Routes.GET_RUN,
17564
17699
  extractor: runs_consts_1.runExtractor,
17565
17700
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to get Run'),
17566
17701
  routeParams: { id: id },
17567
17702
  signal: signal
17568
17703
  })];
17569
- case 1:
17570
- run = _c.sent();
17571
- return [2 /*return*/, run];
17704
+ case 1: return [2 /*return*/, _c.sent()];
17572
17705
  }
17573
17706
  });
17574
17707
  });
@@ -17576,9 +17709,10 @@ var RunsService = /** @class */ (function (_super) {
17576
17709
  RunsService.prototype.update = function (id, options, _a) {
17577
17710
  var _b = _a === void 0 ? {} : _a, signal = _b.signal;
17578
17711
  return __awaiter(this, void 0, void 0, function () {
17712
+ var response;
17579
17713
  return __generator(this, function (_c) {
17580
17714
  switch (_c.label) {
17581
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17715
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17582
17716
  route: exports.Routes.UPDATE_RUN,
17583
17717
  extractor: runs_consts_1.defaultExtractor,
17584
17718
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to update Run'),
@@ -17586,7 +17720,9 @@ var RunsService = /** @class */ (function (_super) {
17586
17720
  routeParams: { id: id },
17587
17721
  signal: signal
17588
17722
  })];
17589
- case 1: return [2 /*return*/, _c.sent()];
17723
+ case 1:
17724
+ response = _c.sent();
17725
+ return [2 /*return*/, response.run];
17590
17726
  }
17591
17727
  });
17592
17728
  });
@@ -17597,7 +17733,7 @@ var RunsService = /** @class */ (function (_super) {
17597
17733
  var runHistory;
17598
17734
  return __generator(this, function (_c) {
17599
17735
  switch (_c.label) {
17600
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17736
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17601
17737
  route: exports.Routes.GET_RUN_HISTORY,
17602
17738
  extractor: runs_consts_1.runsHistoryExtractor,
17603
17739
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to get run history'),
@@ -17617,7 +17753,7 @@ var RunsService = /** @class */ (function (_super) {
17617
17753
  var runLocations;
17618
17754
  return __generator(this, function (_c) {
17619
17755
  switch (_c.label) {
17620
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17756
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17621
17757
  route: exports.Routes.GET_RUN_LOCATIONS,
17622
17758
  extractor: runs_consts_1.runsLocationsExtractor,
17623
17759
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to get run locations'),
@@ -17637,7 +17773,7 @@ var RunsService = /** @class */ (function (_super) {
17637
17773
  var runLocations;
17638
17774
  return __generator(this, function (_c) {
17639
17775
  switch (_c.label) {
17640
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17776
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17641
17777
  route: exports.Routes.GET_RUN_CASHOUT,
17642
17778
  extractor: runs_consts_1.runCashoutExtractor,
17643
17779
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to get run cashout'),
@@ -17657,7 +17793,7 @@ var RunsService = /** @class */ (function (_super) {
17657
17793
  var response;
17658
17794
  return __generator(this, function (_c) {
17659
17795
  switch (_c.label) {
17660
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17796
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17661
17797
  route: exports.Routes.ASSIGN_DRIVER,
17662
17798
  extractor: runs_consts_1.defaultExtractor,
17663
17799
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to assign driver to run'),
@@ -17678,7 +17814,7 @@ var RunsService = /** @class */ (function (_super) {
17678
17814
  var response;
17679
17815
  return __generator(this, function (_c) {
17680
17816
  switch (_c.label) {
17681
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17817
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17682
17818
  route: exports.Routes.UNASSIGN_DRIVER,
17683
17819
  extractor: runs_consts_1.defaultExtractor,
17684
17820
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to assign driver to run'),
@@ -17699,7 +17835,7 @@ var RunsService = /** @class */ (function (_super) {
17699
17835
  var response;
17700
17836
  return __generator(this, function (_c) {
17701
17837
  switch (_c.label) {
17702
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17838
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17703
17839
  route: exports.Routes.ASSIGN_VEHICLES,
17704
17840
  extractor: runs_consts_1.defaultExtractor,
17705
17841
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to assign vehicles to run'),
@@ -17720,7 +17856,7 @@ var RunsService = /** @class */ (function (_super) {
17720
17856
  var response;
17721
17857
  return __generator(this, function (_c) {
17722
17858
  switch (_c.label) {
17723
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17859
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17724
17860
  route: exports.Routes.UNASSIGN_VEHICLES,
17725
17861
  extractor: runs_consts_1.defaultExtractor,
17726
17862
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to unassign vehicles from run'),
@@ -17741,7 +17877,7 @@ var RunsService = /** @class */ (function (_super) {
17741
17877
  var runBulkClose;
17742
17878
  return __generator(this, function (_c) {
17743
17879
  switch (_c.label) {
17744
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17880
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17745
17881
  route: exports.Routes.BULK_CLOSE,
17746
17882
  extractor: runs_consts_1.defaultExtractor,
17747
17883
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to bulk close runs'),
@@ -17761,7 +17897,7 @@ var RunsService = /** @class */ (function (_super) {
17761
17897
  var markDonePlanning;
17762
17898
  return __generator(this, function (_c) {
17763
17899
  switch (_c.label) {
17764
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17900
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17765
17901
  route: exports.Routes.MARK_DONE_PLANNING,
17766
17902
  extractor: runs_consts_1.defaultExtractor,
17767
17903
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to mark done planning for runs'),
@@ -17781,7 +17917,7 @@ var RunsService = /** @class */ (function (_super) {
17781
17917
  var actualBreaksByRunIdResponse;
17782
17918
  return __generator(this, function (_c) {
17783
17919
  switch (_c.label) {
17784
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17920
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17785
17921
  route: exports.Routes.GET_ACTUAL_BREAKS,
17786
17922
  extractor: runs_consts_1.defaultExtractor,
17787
17923
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to get actual breaks of runs'),
@@ -17798,7 +17934,7 @@ var RunsService = /** @class */ (function (_super) {
17798
17934
  });
17799
17935
  };
17800
17936
  return RunsService;
17801
- }(SessionBasedService_1.SessionBasedService));
17937
+ }());
17802
17938
  exports.RunsService = RunsService;
17803
17939
  //# sourceMappingURL=runs.service.js.map
17804
17940
 
@@ -17849,7 +17985,6 @@ var RunStore = /** @class */ (function (_super) {
17849
17985
  _this.updateRun = function (payload) {
17850
17986
  return _this.createOrUpdateRun(payload, _this.onUpdate.bind(_this));
17851
17987
  };
17852
- // eslint-disable-next-line @typescript-eslint/ban-types
17853
17988
  _this.createOrUpdateRun = function (payload, callback) {
17854
17989
  var existingRunModel = _this.store.getItem(payload.run.id);
17855
17990
  var updatedRunModel = { id: payload.run.id, run: payload.run, taskIds: undefined };
@@ -17985,7 +18120,7 @@ exports["default"] = RunStore;
17985
18120
  "use strict";
17986
18121
 
17987
18122
  Object.defineProperty(exports, "__esModule", ({ value: true }));
17988
- exports.GetAllChunkSize = exports.defaultExtractor = exports.runCashoutExtractor = exports.runsLocationsExtractor = exports.runsHistoryExtractor = exports.runExtractor = exports.RunEvents = exports.RunStatus = void 0;
18123
+ exports.GetAllChunkSize = exports.defaultExtractor = exports.runCashoutExtractor = exports.runsLocationsExtractor = exports.runsHistoryExtractor = exports.runExtractor = exports.RunGroupTypes = exports.RunEvents = exports.RunStatus = void 0;
17989
18124
  var RunStatus;
17990
18125
  (function (RunStatus) {
17991
18126
  RunStatus["ALL"] = "all";
@@ -17998,6 +18133,10 @@ var RunEvents;
17998
18133
  RunEvents["DELETED"] = "run deleted";
17999
18134
  RunEvents["CREATED"] = "run created";
18000
18135
  })(RunEvents = exports.RunEvents || (exports.RunEvents = {}));
18136
+ var RunGroupTypes;
18137
+ (function (RunGroupTypes) {
18138
+ RunGroupTypes["TaskIds"] = "taskIds";
18139
+ })(RunGroupTypes = exports.RunGroupTypes || (exports.RunGroupTypes = {}));
18001
18140
  var runExtractor = function (response) { return response.run; };
18002
18141
  exports.runExtractor = runExtractor;
18003
18142
  var runsHistoryExtractor = function (response) { return response; };
@@ -18145,7 +18284,7 @@ var Runs = /** @class */ (function () {
18145
18284
  var run;
18146
18285
  return __generator(this, function (_a) {
18147
18286
  switch (_a.label) {
18148
- case 0: return [4 /*yield*/, this.runsService.get(id, commonOptions)];
18287
+ case 0: return [4 /*yield*/, this.runsService.load(id, commonOptions)];
18149
18288
  case 1:
18150
18289
  run = _a.sent();
18151
18290
  return [2 /*return*/, this.runStore.set(run)];
@@ -18158,7 +18297,7 @@ var Runs = /** @class */ (function () {
18158
18297
  return __awaiter(this, void 0, void 0, function () {
18159
18298
  return __generator(this, function (_a) {
18160
18299
  switch (_a.label) {
18161
- case 0: return [4 /*yield*/, this.runsService.get(id, commonOptions)];
18300
+ case 0: return [4 /*yield*/, this.runsService.load(id, commonOptions)];
18162
18301
  case 1: return [2 /*return*/, _a.sent()];
18163
18302
  }
18164
18303
  });
@@ -18303,6 +18442,165 @@ exports["default"] = Runs;
18303
18442
 
18304
18443
  /***/ }),
18305
18444
 
18445
+ /***/ 30196:
18446
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
18447
+
18448
+ "use strict";
18449
+
18450
+ var __read = (this && this.__read) || function (o, n) {
18451
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
18452
+ if (!m) return o;
18453
+ var i = m.call(o), r, ar = [], e;
18454
+ try {
18455
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
18456
+ }
18457
+ catch (error) { e = { error: error }; }
18458
+ finally {
18459
+ try {
18460
+ if (r && !r.done && (m = i["return"])) m.call(i);
18461
+ }
18462
+ finally { if (e) throw e.error; }
18463
+ }
18464
+ return ar;
18465
+ };
18466
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
18467
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
18468
+ if (ar || !(i in from)) {
18469
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
18470
+ ar[i] = from[i];
18471
+ }
18472
+ }
18473
+ return to.concat(ar || Array.prototype.slice.call(from));
18474
+ };
18475
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
18476
+ var storable_realtime_subscriptions_1 = __webpack_require__(1227);
18477
+ var Tasks_consts_1 = __webpack_require__(24976);
18478
+ var runs_consts_1 = __webpack_require__(4669);
18479
+ var RunRealtimeSubscriptions = /** @class */ (function () {
18480
+ function RunRealtimeSubscriptions(session, runsStore, storableDataService) {
18481
+ var _this = this;
18482
+ this.runsStore = runsStore;
18483
+ this.storableDataService = storableDataService;
18484
+ this.updateTaskIdsOnDelete = function (task) {
18485
+ var existingRun = _this.runsStore.get(task.run_id);
18486
+ if (!existingRun) {
18487
+ return;
18488
+ }
18489
+ var updatedTaskIds = new Set(existingRun.task_ids);
18490
+ updatedTaskIds.delete(task.id);
18491
+ _this.updateRunInStore(existingRun, updatedTaskIds);
18492
+ };
18493
+ this.storableRealtimeSubscriptions = new storable_realtime_subscriptions_1.default(session, runsStore, storableDataService);
18494
+ this.taskIdsWaitingForRun = new Map();
18495
+ }
18496
+ RunRealtimeSubscriptions.prototype.updateStoreOnEvents = function () {
18497
+ var runExtractor = function (_a) {
18498
+ var run = _a.run;
18499
+ return run;
18500
+ };
18501
+ this.storableRealtimeSubscriptions.updateStoreOnEvents([
18502
+ {
18503
+ name: runs_consts_1.RunEvents.CREATED,
18504
+ isDelete: false,
18505
+ extraDataFunc: this.addTaskIdsOnCreateOrUpdate.bind(this),
18506
+ itemExtractor: runExtractor
18507
+ },
18508
+ {
18509
+ name: runs_consts_1.RunEvents.UPDATED,
18510
+ isDelete: false,
18511
+ extraDataFunc: this.addTaskIdsOnCreateOrUpdate.bind(this),
18512
+ itemExtractor: runExtractor
18513
+ },
18514
+ { name: runs_consts_1.RunEvents.DELETED, isDelete: true }
18515
+ ]);
18516
+ this.storableRealtimeSubscriptions.onAnyEvent(Tasks_consts_1.TaskRealTimeEvents.TASK_DELETED, this.updateTaskIdsOnDelete.bind(this));
18517
+ this.storableRealtimeSubscriptions.onAnyEvent(Tasks_consts_1.TaskRealTimeEvents.TASK_UPDATE, this.updateTaskIds.bind(this));
18518
+ this.storableRealtimeSubscriptions.onAnyEvent(Tasks_consts_1.TaskRealTimeEvents.NEW_TASK, this.updateTaskIds.bind(this));
18519
+ };
18520
+ RunRealtimeSubscriptions.prototype.onUpdate = function (callback) {
18521
+ return this.storableRealtimeSubscriptions.onEvent(runs_consts_1.RunEvents.UPDATED, callback);
18522
+ };
18523
+ RunRealtimeSubscriptions.prototype.onDelete = function (callback) {
18524
+ return this.storableRealtimeSubscriptions.onEvent(runs_consts_1.RunEvents.DELETED, callback);
18525
+ };
18526
+ RunRealtimeSubscriptions.prototype.onCreate = function (callback) {
18527
+ return this.storableRealtimeSubscriptions.onEvent(runs_consts_1.RunEvents.CREATED, callback);
18528
+ };
18529
+ RunRealtimeSubscriptions.prototype.addTaskIdsOnCreateOrUpdate = function (run) {
18530
+ if (run.task_ids || run.tasks) {
18531
+ return;
18532
+ }
18533
+ var existingRun = this.runsStore.get(run.id);
18534
+ var taskIdsWaitingForRun = this.taskIdsWaitingForRun.get(run.id) || new Set();
18535
+ var taskIds = existingRun
18536
+ ? Array.from(new Set(__spreadArray(__spreadArray([], __read(existingRun.task_ids), false), __read(taskIdsWaitingForRun), false)))
18537
+ : Array.from(taskIdsWaitingForRun);
18538
+ this.taskIdsWaitingForRun.delete(run.id);
18539
+ return { params: { taskIds: taskIds } };
18540
+ };
18541
+ RunRealtimeSubscriptions.prototype.updateTaskIds = function (task) {
18542
+ var existingRun = this.runsStore.getGroup(runs_consts_1.RunGroupTypes.TaskIds, task.id)[0];
18543
+ if (task.run_id) {
18544
+ var newRun = this.runsStore.get(task.run_id);
18545
+ if (!newRun) {
18546
+ this.backupTasksUntilRunIsCreated(task);
18547
+ }
18548
+ else if (this.taskAddedToRun(task, newRun)) {
18549
+ var updatedTaskIds = new Set(newRun.task_ids);
18550
+ updatedTaskIds.add(task.id);
18551
+ this.updateRunInStore(newRun, updatedTaskIds);
18552
+ }
18553
+ }
18554
+ else if (this.taskRemovedFromRun(task, existingRun)) {
18555
+ var updatedTaskIds = new Set(existingRun.task_ids);
18556
+ updatedTaskIds.delete(task.id);
18557
+ this.updateRunInStore(existingRun, updatedTaskIds);
18558
+ }
18559
+ this.updatePreviousRun(task, existingRun === null || existingRun === void 0 ? void 0 : existingRun.id);
18560
+ };
18561
+ RunRealtimeSubscriptions.prototype.updatePreviousRun = function (task, previousRunId) {
18562
+ if (previousRunId && previousRunId != task.run_id) {
18563
+ if (this.taskIdsWaitingForRun.has(previousRunId)) {
18564
+ this.taskIdsWaitingForRun.get(previousRunId).delete(task.id);
18565
+ }
18566
+ var previousRunOfTask = this.runsStore.get(previousRunId);
18567
+ if (previousRunOfTask) {
18568
+ var updatedTaskIds = new Set(previousRunOfTask.task_ids);
18569
+ updatedTaskIds.delete(task.id);
18570
+ this.updateRunInStore(previousRunOfTask, updatedTaskIds);
18571
+ }
18572
+ }
18573
+ };
18574
+ RunRealtimeSubscriptions.prototype.updateRunInStore = function (newRun, taskIds) {
18575
+ var mappedItem = this.storableDataService.updateInStores(newRun, undefined, undefined, {
18576
+ taskIds: Array.from(taskIds)
18577
+ });
18578
+ this.storableRealtimeSubscriptions.runEventCallbacks(runs_consts_1.RunEvents.UPDATED, mappedItem);
18579
+ };
18580
+ RunRealtimeSubscriptions.prototype.taskRemovedFromRun = function (task, existingRun) {
18581
+ var _a;
18582
+ return !task.run_id && ((_a = existingRun === null || existingRun === void 0 ? void 0 : existingRun.task_ids) === null || _a === void 0 ? void 0 : _a.includes(task.id));
18583
+ };
18584
+ RunRealtimeSubscriptions.prototype.taskAddedToRun = function (task, existingRun) {
18585
+ var _a;
18586
+ return task.run_id && !((_a = existingRun.task_ids) === null || _a === void 0 ? void 0 : _a.includes(task.id));
18587
+ };
18588
+ RunRealtimeSubscriptions.prototype.backupTasksUntilRunIsCreated = function (task) {
18589
+ if (!task.run_id) {
18590
+ return;
18591
+ }
18592
+ if (!this.taskIdsWaitingForRun.has(task.run_id)) {
18593
+ this.taskIdsWaitingForRun.set(task.run_id, new Set());
18594
+ }
18595
+ this.taskIdsWaitingForRun.get(task.run_id).add(task.id);
18596
+ };
18597
+ return RunRealtimeSubscriptions;
18598
+ }());
18599
+ exports["default"] = RunRealtimeSubscriptions;
18600
+ //# sourceMappingURL=run-realtime-subscriptions.js.map
18601
+
18602
+ /***/ }),
18603
+
18306
18604
  /***/ 83582:
18307
18605
  /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
18308
18606
 
@@ -18356,56 +18654,82 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
18356
18654
  }
18357
18655
  };
18358
18656
  Object.defineProperty(exports, "__esModule", ({ value: true }));
18657
+ var BringgDashboardSDK_1 = __webpack_require__(5655);
18658
+ var data_entity_1 = __webpack_require__(91083);
18359
18659
  var data_store_1 = __webpack_require__(73135);
18360
- var realtime_subscriptions_1 = __webpack_require__(47985);
18660
+ var storable_data_service_1 = __webpack_require__(45297);
18361
18661
  var runs_consts_1 = __webpack_require__(4669);
18362
18662
  var runs_service_1 = __webpack_require__(34075);
18663
+ var run_realtime_subscriptions_1 = __webpack_require__(30196);
18363
18664
  var RunsApi = /** @class */ (function () {
18364
18665
  function RunsApi(session) {
18365
18666
  var _this = this;
18366
- this.createOrUpdateRun = function (payload) {
18367
- _this.runsStore.set(payload.run);
18667
+ this.onUpdate = function (callback) {
18668
+ return _this.realtimeSubscriptions.onUpdate(callback);
18368
18669
  };
18369
- this.deleteRun = function (payload) {
18370
- _this.runsStore.remove(payload.id);
18670
+ this.onDelete = function (callback) {
18671
+ return _this.realtimeSubscriptions.onDelete(callback);
18672
+ };
18673
+ this.onCreate = function (callback) {
18674
+ return _this.realtimeSubscriptions.onCreate(callback);
18371
18675
  };
18372
- this.runsStore = new data_store_1.default();
18676
+ this.runsStore = new data_store_1.default([
18677
+ {
18678
+ groupType: runs_consts_1.RunGroupTypes.TaskIds,
18679
+ keyFunc: function (runModel) { return runModel.task_ids; }
18680
+ }
18681
+ ]);
18373
18682
  this.runsService = new runs_service_1.RunsService(session);
18374
- this.realtimeSubscriptions = new realtime_subscriptions_1.default(session);
18375
- this.realtimeSubscriptions.subscribe(runs_consts_1.RunEvents.CREATED, this.createOrUpdateRun);
18376
- this.realtimeSubscriptions.subscribe(runs_consts_1.RunEvents.UPDATED, this.createOrUpdateRun);
18377
- this.realtimeSubscriptions.subscribe(runs_consts_1.RunEvents.DELETED, this.deleteRun);
18683
+ var mapper = function (run, params) {
18684
+ var existing = _this.runsStore.get(run.id);
18685
+ var taskIds;
18686
+ if (params.taskIds || run.task_ids || run.tasks) {
18687
+ taskIds = params.taskIds || run.task_ids || run.tasks.map(function (task) { return task.id; });
18688
+ }
18689
+ if (existing) {
18690
+ var previous = (0, BringgDashboardSDK_1.getGlobals)().mobx.toJS(existing);
18691
+ run.task_ids = taskIds || existing.task_ids;
18692
+ return { current: run, previous: previous };
18693
+ }
18694
+ else {
18695
+ run.task_ids = taskIds || [];
18696
+ return { current: run };
18697
+ }
18698
+ };
18699
+ this.storableDataService = new storable_data_service_1.default(this.runsStore, mapper);
18700
+ this.realtimeSubscriptions = new run_realtime_subscriptions_1.default(session, this.runsStore, this.storableDataService);
18378
18701
  }
18702
+ RunsApi.prototype.updateStoreOnEvents = function () {
18703
+ this.realtimeSubscriptions.updateStoreOnEvents();
18704
+ };
18705
+ RunsApi.prototype.get = function (id) {
18706
+ return this.runsStore.get(id);
18707
+ };
18379
18708
  RunsApi.prototype.getAll = function () {
18380
18709
  return this.runsStore.getAll();
18381
18710
  };
18711
+ RunsApi.prototype.getAllMap = function () {
18712
+ return this.runsStore.getAllById();
18713
+ };
18382
18714
  RunsApi.prototype.getByIds = function (ids) {
18383
18715
  var _this = this;
18384
- return ids.map(function (runId) { return _this.runsStore.get(runId); });
18716
+ return ids.map(function (runId) { return _this.runsStore.get(runId); }).filter(Boolean);
18385
18717
  };
18386
- RunsApi.prototype.loadAll = function (options, commonOptions) {
18718
+ RunsApi.prototype.add = function (run) {
18719
+ return this.storableDataService.updateInStores(run);
18720
+ };
18721
+ RunsApi.prototype.remove = function (id) {
18722
+ return this.storableDataService.removeFromStores(id);
18723
+ };
18724
+ RunsApi.prototype.loadMany = function (queryParams, options, commonOptions) {
18725
+ if (options === void 0) { options = data_entity_1.DEFAULT_OPTIONS; }
18387
18726
  if (commonOptions === void 0) { commonOptions = {}; }
18388
18727
  return __awaiter(this, void 0, void 0, function () {
18389
- var idsToFetch, runs_1, runs;
18390
18728
  var _this = this;
18391
18729
  return __generator(this, function (_a) {
18392
- switch (_a.label) {
18393
- case 0:
18394
- if (!options.ids) return [3 /*break*/, 3];
18395
- idsToFetch = options.ids.filter(function (id) { return !_this.runsStore.get(id); });
18396
- if (!idsToFetch.length) return [3 /*break*/, 2];
18397
- return [4 /*yield*/, this.runsService.loadAll(__assign(__assign({}, options), { ids: idsToFetch }), commonOptions)];
18398
- case 1:
18399
- runs_1 = _a.sent();
18400
- this.runsStore.setMany(runs_1.map(function (run) { return ({ current: run }); }));
18401
- _a.label = 2;
18402
- case 2: return [2 /*return*/, this.getByIds(options.ids)];
18403
- case 3: return [4 /*yield*/, this.runsService.loadAll(options, commonOptions)];
18404
- case 4:
18405
- runs = _a.sent();
18406
- this.runsStore.setAll(runs.map(function (run) { return ({ current: run }); }));
18407
- return [2 /*return*/, runs];
18408
- }
18730
+ return [2 /*return*/, this.storableDataService.loadMany('loadMany', function (idsToLoad) {
18731
+ return _this.runsService.loadAll(__assign(__assign({}, options), { ids: idsToLoad }), commonOptions);
18732
+ }, queryParams.ids, options)];
18409
18733
  });
18410
18734
  });
18411
18735
  };
@@ -18420,6 +18744,130 @@ var RunsApi = /** @class */ (function () {
18420
18744
  });
18421
18745
  });
18422
18746
  };
18747
+ RunsApi.prototype.load = function (id, options) {
18748
+ var _this = this;
18749
+ if (options === void 0) { options = data_entity_1.DEFAULT_OPTIONS; }
18750
+ return this.storableDataService.load('load', function () { return _this.runsService.load(id); }, id, options);
18751
+ };
18752
+ RunsApi.prototype.update = function (id, options, commonOptions) {
18753
+ if (commonOptions === void 0) { commonOptions = {}; }
18754
+ return __awaiter(this, void 0, void 0, function () {
18755
+ var _this = this;
18756
+ return __generator(this, function (_a) {
18757
+ return [2 /*return*/, this.storableDataService.modify('update', function () { return _this.runsService.update(id, options, commonOptions); })];
18758
+ });
18759
+ });
18760
+ };
18761
+ RunsApi.prototype.getHistory = function (id, commonOptions) {
18762
+ if (commonOptions === void 0) { commonOptions = {}; }
18763
+ return __awaiter(this, void 0, void 0, function () {
18764
+ return __generator(this, function (_a) {
18765
+ switch (_a.label) {
18766
+ case 0: return [4 /*yield*/, this.runsService.getHistory(id, commonOptions)];
18767
+ case 1: return [2 /*return*/, _a.sent()];
18768
+ }
18769
+ });
18770
+ });
18771
+ };
18772
+ RunsApi.prototype.getLocations = function (id, commonOptions) {
18773
+ if (commonOptions === void 0) { commonOptions = {}; }
18774
+ return __awaiter(this, void 0, void 0, function () {
18775
+ return __generator(this, function (_a) {
18776
+ switch (_a.label) {
18777
+ case 0: return [4 /*yield*/, this.runsService.getLocations(id, commonOptions)];
18778
+ case 1: return [2 /*return*/, _a.sent()];
18779
+ }
18780
+ });
18781
+ });
18782
+ };
18783
+ RunsApi.prototype.getCashout = function (id, commonOptions) {
18784
+ if (commonOptions === void 0) { commonOptions = {}; }
18785
+ return __awaiter(this, void 0, void 0, function () {
18786
+ return __generator(this, function (_a) {
18787
+ switch (_a.label) {
18788
+ case 0: return [4 /*yield*/, this.runsService.getCashout(id, commonOptions)];
18789
+ case 1: return [2 /*return*/, _a.sent()];
18790
+ }
18791
+ });
18792
+ });
18793
+ };
18794
+ RunsApi.prototype.assignDriver = function (id, userId, targetRun, commonOptions) {
18795
+ if (commonOptions === void 0) { commonOptions = {}; }
18796
+ return __awaiter(this, void 0, void 0, function () {
18797
+ return __generator(this, function (_a) {
18798
+ switch (_a.label) {
18799
+ case 0: return [4 /*yield*/, this.runsService.assignDriver(id, userId, targetRun, commonOptions)];
18800
+ case 1: return [2 /*return*/, _a.sent()];
18801
+ }
18802
+ });
18803
+ });
18804
+ };
18805
+ RunsApi.prototype.unassignDriver = function (id, userId, commonOptions) {
18806
+ if (commonOptions === void 0) { commonOptions = {}; }
18807
+ return __awaiter(this, void 0, void 0, function () {
18808
+ return __generator(this, function (_a) {
18809
+ switch (_a.label) {
18810
+ case 0: return [4 /*yield*/, this.runsService.unassignDriver(id, userId, commonOptions)];
18811
+ case 1: return [2 /*return*/, _a.sent()];
18812
+ }
18813
+ });
18814
+ });
18815
+ };
18816
+ RunsApi.prototype.assignVehicles = function (id, vehicleId, tasks, commonOptions) {
18817
+ if (commonOptions === void 0) { commonOptions = {}; }
18818
+ return __awaiter(this, void 0, void 0, function () {
18819
+ return __generator(this, function (_a) {
18820
+ switch (_a.label) {
18821
+ case 0: return [4 /*yield*/, this.runsService.assignVehicles(id, vehicleId, tasks, commonOptions)];
18822
+ case 1: return [2 /*return*/, _a.sent()];
18823
+ }
18824
+ });
18825
+ });
18826
+ };
18827
+ RunsApi.prototype.unassignVehicles = function (id, commonOptions) {
18828
+ if (commonOptions === void 0) { commonOptions = {}; }
18829
+ return __awaiter(this, void 0, void 0, function () {
18830
+ return __generator(this, function (_a) {
18831
+ switch (_a.label) {
18832
+ case 0: return [4 /*yield*/, this.runsService.unassignVehicles(id, commonOptions)];
18833
+ case 1: return [2 /*return*/, _a.sent()];
18834
+ }
18835
+ });
18836
+ });
18837
+ };
18838
+ RunsApi.prototype.bulkClose = function (runIds, commonOptions) {
18839
+ if (commonOptions === void 0) { commonOptions = {}; }
18840
+ return __awaiter(this, void 0, void 0, function () {
18841
+ return __generator(this, function (_a) {
18842
+ switch (_a.label) {
18843
+ case 0: return [4 /*yield*/, this.runsService.bulkClose(runIds, commonOptions)];
18844
+ case 1: return [2 /*return*/, _a.sent()];
18845
+ }
18846
+ });
18847
+ });
18848
+ };
18849
+ RunsApi.prototype.markDonePlanning = function (runIds, commonOptions) {
18850
+ if (commonOptions === void 0) { commonOptions = {}; }
18851
+ return __awaiter(this, void 0, void 0, function () {
18852
+ return __generator(this, function (_a) {
18853
+ switch (_a.label) {
18854
+ case 0: return [4 /*yield*/, this.runsService.markDonePlanning(runIds, commonOptions)];
18855
+ case 1: return [2 /*return*/, _a.sent()];
18856
+ }
18857
+ });
18858
+ });
18859
+ };
18860
+ RunsApi.prototype.getActualBreaks = function (runIds, commonOptions) {
18861
+ if (commonOptions === void 0) { commonOptions = {}; }
18862
+ return __awaiter(this, void 0, void 0, function () {
18863
+ return __generator(this, function (_a) {
18864
+ switch (_a.label) {
18865
+ case 0: return [4 /*yield*/, this.runsService.getActualBreaks(runIds, commonOptions)];
18866
+ case 1: return [2 /*return*/, _a.sent()];
18867
+ }
18868
+ });
18869
+ });
18870
+ };
18423
18871
  return RunsApi;
18424
18872
  }());
18425
18873
  exports["default"] = RunsApi;
@@ -20711,7 +21159,7 @@ var lodash_1 = __webpack_require__(96486);
20711
21159
  var BringgException_1 = __webpack_require__(43605);
20712
21160
  var Logger_1 = __webpack_require__(55860);
20713
21161
  var abort_1 = __webpack_require__(34179);
20714
- var version = '8.26.0';
21162
+ var version = '8.27.0-pre.1';
20715
21163
  function logErrorResponse(response) {
20716
21164
  var data = response.data, status = response.status;
20717
21165
  try {
@@ -22994,151 +23442,90 @@ exports.Routes = {
22994
23442
  /***/ }),
22995
23443
 
22996
23444
  /***/ 52131:
22997
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
23445
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
22998
23446
 
22999
23447
  "use strict";
23000
23448
 
23001
- var __values = (this && this.__values) || function(o) {
23002
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
23003
- if (m) return m.call(o);
23004
- if (o && typeof o.length === "number") return {
23005
- next: function () {
23006
- if (o && i >= o.length) o = void 0;
23007
- return { value: o && o[i++], done: !o };
23008
- }
23009
- };
23010
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
23011
- };
23012
23449
  Object.defineProperty(exports, "__esModule", ({ value: true }));
23013
- var object_merger_1 = __webpack_require__(7262);
23014
- var realtime_subscriptions_1 = __webpack_require__(47985);
23450
+ var storable_realtime_subscriptions_1 = __webpack_require__(1227);
23015
23451
  var Tasks_consts_1 = __webpack_require__(24976);
23016
23452
  var TaskRealtimeSubscriptions = /** @class */ (function () {
23017
23453
  function TaskRealtimeSubscriptions(session, tasksStore, storableDataService) {
23018
- this.realtimeSubscriptions = new realtime_subscriptions_1.default(session);
23019
23454
  this.tasksStore = tasksStore;
23020
- this.storableDataService = storableDataService;
23021
- this.eventCallbacks = {};
23455
+ this.storableRealtimeSubscriptions = new storable_realtime_subscriptions_1.default(session, tasksStore, storableDataService);
23022
23456
  }
23023
23457
  TaskRealtimeSubscriptions.prototype.updateStoreOnEvents = function () {
23024
23458
  var _this = this;
23025
- var ignoreFields = ['way_points'];
23026
- this.realtimeSubscriptions.subscribe(Tasks_consts_1.TaskRealTimeEvents.TASK_UPDATE, function (task) {
23027
- var isPartialUpdate = !task.hasOwnProperty('status');
23028
- if (isPartialUpdate && !_this.tasksStore.get(task.id)) {
23029
- return;
23030
- }
23031
- var mappedStorableItem = _this.storableDataService.updateInStores(task);
23032
- _this.runEventCallbacks(Tasks_consts_1.TaskRealTimeEvents.TASK_UPDATE, mappedStorableItem);
23033
- });
23034
- this.realtimeSubscriptions.subscribe(Tasks_consts_1.TaskRealTimeEvents.NEW_TASK, function (task) {
23035
- var mappedStorableItem = _this.storableDataService.updateInStores(task);
23036
- _this.runEventCallbacks(Tasks_consts_1.TaskRealTimeEvents.NEW_TASK, mappedStorableItem);
23037
- });
23038
- this.realtimeSubscriptions.subscribe(Tasks_consts_1.TaskRealTimeEvents.TASK_DELETED, function (task) {
23039
- var deletedTasks = _this.storableDataService.removeFromStores(task.id);
23040
- _this.runEventCallbacks(Tasks_consts_1.TaskRealTimeEvents.TASK_DELETED, { diff: deletedTasks });
23041
- });
23042
- [
23043
- { event: Tasks_consts_1.TaskRealTimeEvents.NEW_SCAN, field: 'scans', isDelete: false },
23044
- { event: Tasks_consts_1.TaskRealTimeEvents.NEW_NOTE, field: 'task_notes', isDelete: false },
23045
- { event: Tasks_consts_1.TaskRealTimeEvents.WAYPOINT_ADDED, field: 'way_points', isDelete: false },
23046
- { event: Tasks_consts_1.TaskRealTimeEvents.WAYPOINT_UPDATED, field: 'way_points', isDelete: false },
23047
- { event: Tasks_consts_1.TaskRealTimeEvents.WAYPOINT_DELETED, field: 'way_points', isDelete: true }
23048
- ].forEach(function (eventData) {
23049
- _this.realtimeSubscriptions.subscribe(eventData.event, function (subEntity) {
23050
- ignoreFields.forEach(function (field) { return delete subEntity[field]; });
23051
- var eventChangeData = _this.changeSubEntity(subEntity, eventData.field, eventData.isDelete);
23052
- if (eventChangeData.current) {
23053
- _this.runEventCallbacks(Tasks_consts_1.TaskRealTimeEvents.TASK_UPDATE, eventChangeData);
23459
+ var events = [
23460
+ {
23461
+ name: Tasks_consts_1.TaskRealTimeEvents.TASK_UPDATE,
23462
+ isDelete: false,
23463
+ extraDataFunc: function (task) {
23464
+ var isPartialUpdate = !task.hasOwnProperty('status');
23465
+ return { ignore: isPartialUpdate && !_this.tasksStore.get(task.id) };
23054
23466
  }
23055
- });
23056
- });
23467
+ },
23468
+ { name: Tasks_consts_1.TaskRealTimeEvents.NEW_TASK, isDelete: false },
23469
+ { name: Tasks_consts_1.TaskRealTimeEvents.TASK_DELETED, isDelete: true }
23470
+ ];
23471
+ var subEntityEvents = [
23472
+ {
23473
+ name: Tasks_consts_1.TaskRealTimeEvents.NEW_SCAN,
23474
+ eventToRaise: Tasks_consts_1.TaskRealTimeEvents.TASK_UPDATE,
23475
+ parentField: 'task_id',
23476
+ field: 'scans',
23477
+ ignoreFields: ['way_points'],
23478
+ isDelete: false
23479
+ },
23480
+ {
23481
+ name: Tasks_consts_1.TaskRealTimeEvents.NEW_NOTE,
23482
+ eventToRaise: Tasks_consts_1.TaskRealTimeEvents.TASK_UPDATE,
23483
+ parentField: 'task_id',
23484
+ field: 'task_notes',
23485
+ ignoreFields: ['way_points'],
23486
+ isDelete: false
23487
+ },
23488
+ {
23489
+ name: Tasks_consts_1.TaskRealTimeEvents.WAYPOINT_ADDED,
23490
+ eventToRaise: Tasks_consts_1.TaskRealTimeEvents.TASK_UPDATE,
23491
+ parentField: 'task_id',
23492
+ field: 'way_points',
23493
+ ignoreFields: ['way_points'],
23494
+ isDelete: false
23495
+ },
23496
+ {
23497
+ name: Tasks_consts_1.TaskRealTimeEvents.WAYPOINT_UPDATED,
23498
+ eventToRaise: Tasks_consts_1.TaskRealTimeEvents.TASK_UPDATE,
23499
+ parentField: 'task_id',
23500
+ field: 'way_points',
23501
+ ignoreFields: ['way_points'],
23502
+ isDelete: false
23503
+ },
23504
+ {
23505
+ name: Tasks_consts_1.TaskRealTimeEvents.WAYPOINT_DELETED,
23506
+ eventToRaise: Tasks_consts_1.TaskRealTimeEvents.TASK_UPDATE,
23507
+ parentField: 'task_id',
23508
+ field: 'way_points',
23509
+ ignoreFields: ['way_points'],
23510
+ isDelete: true
23511
+ }
23512
+ ];
23513
+ this.storableRealtimeSubscriptions.updateStoreOnEvents(events, subEntityEvents);
23057
23514
  };
23058
23515
  TaskRealtimeSubscriptions.prototype.onCreate = function (callback) {
23059
- return this.onEvent(Tasks_consts_1.TaskRealTimeEvents.NEW_TASK, callback);
23516
+ return this.storableRealtimeSubscriptions.onEvent(Tasks_consts_1.TaskRealTimeEvents.NEW_TASK, callback);
23060
23517
  };
23061
23518
  TaskRealtimeSubscriptions.prototype.onDelete = function (callback) {
23062
- return this.onEvent(Tasks_consts_1.TaskRealTimeEvents.TASK_DELETED, callback);
23519
+ return this.storableRealtimeSubscriptions.onEvent(Tasks_consts_1.TaskRealTimeEvents.TASK_DELETED, callback);
23063
23520
  };
23064
23521
  TaskRealtimeSubscriptions.prototype.onWayPointUpdate = function (callback) {
23065
- return this.onEvent(Tasks_consts_1.TaskRealTimeEvents.WAYPOINT_UPDATED, callback);
23522
+ return this.storableRealtimeSubscriptions.onEvent(Tasks_consts_1.TaskRealTimeEvents.WAYPOINT_UPDATED, callback);
23066
23523
  };
23067
23524
  TaskRealtimeSubscriptions.prototype.onWayPointDelete = function (callback) {
23068
- return this.onEvent(Tasks_consts_1.TaskRealTimeEvents.WAYPOINT_DELETED, callback);
23525
+ return this.storableRealtimeSubscriptions.onEvent(Tasks_consts_1.TaskRealTimeEvents.WAYPOINT_DELETED, callback);
23069
23526
  };
23070
23527
  TaskRealtimeSubscriptions.prototype.onUpdate = function (callback) {
23071
- var subscriptions = [];
23072
- subscriptions.push(this.onEvent(Tasks_consts_1.TaskRealTimeEvents.TASK_UPDATE, callback));
23073
- return function () {
23074
- var e_1, _a;
23075
- try {
23076
- for (var subscriptions_1 = __values(subscriptions), subscriptions_1_1 = subscriptions_1.next(); !subscriptions_1_1.done; subscriptions_1_1 = subscriptions_1.next()) {
23077
- var subscription = subscriptions_1_1.value;
23078
- subscription();
23079
- }
23080
- }
23081
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
23082
- finally {
23083
- try {
23084
- if (subscriptions_1_1 && !subscriptions_1_1.done && (_a = subscriptions_1.return)) _a.call(subscriptions_1);
23085
- }
23086
- finally { if (e_1) throw e_1.error; }
23087
- }
23088
- };
23089
- };
23090
- TaskRealtimeSubscriptions.prototype.onEvent = function (event, callback) {
23091
- var _this = this;
23092
- if (!this.eventCallbacks[event]) {
23093
- this.eventCallbacks[event] = [];
23094
- }
23095
- this.eventCallbacks[event].push(callback);
23096
- return function () {
23097
- var indexOfCallback = _this.eventCallbacks[event].indexOf(callback);
23098
- _this.eventCallbacks[event].splice(indexOfCallback, 1);
23099
- };
23100
- };
23101
- TaskRealtimeSubscriptions.prototype.runEventCallbacks = function (event, data) {
23102
- (this.eventCallbacks[event] || []).forEach(function (callback) { return callback(data); });
23103
- };
23104
- TaskRealtimeSubscriptions.prototype.changeSubEntity = function (subEntity, containerField, isDelete) {
23105
- var _a, _b, _c;
23106
- if (isDelete === void 0) { isDelete = false; }
23107
- var task = this.tasksStore.get(subEntity.task_id);
23108
- var diff;
23109
- if (task) {
23110
- if (!task[containerField]) {
23111
- task[containerField] = [];
23112
- }
23113
- var existingIndex = task[containerField].findIndex(function (taskSubEntity) { return taskSubEntity.id === subEntity.id; });
23114
- if (existingIndex > -1) {
23115
- if (isDelete) {
23116
- diff = (_a = { id: task.id }, _a[containerField] = this.createArrayOfEmptyObjects(existingIndex), _a);
23117
- for (var i = existingIndex + 1; i < task[containerField].length; i++) {
23118
- diff[containerField].push(task[containerField][i]);
23119
- }
23120
- task[containerField].splice(existingIndex, 1);
23121
- }
23122
- else {
23123
- var subEntityDiff = object_merger_1.objectMerger.deepMerge(task[containerField][existingIndex], subEntity);
23124
- diff = (_b = {
23125
- id: task.id
23126
- },
23127
- _b[containerField] = this.createArrayOfEmptyObjects(task[containerField].length),
23128
- _b);
23129
- diff[containerField][existingIndex] = subEntityDiff;
23130
- }
23131
- }
23132
- else if (!isDelete) {
23133
- diff = (_c = { id: task.id }, _c[containerField] = this.createArrayOfEmptyObjects(task[containerField].length), _c);
23134
- diff[containerField].push(subEntity);
23135
- task[containerField].push(subEntity);
23136
- }
23137
- }
23138
- return { current: task, diff: diff };
23139
- };
23140
- TaskRealtimeSubscriptions.prototype.createArrayOfEmptyObjects = function (length) {
23141
- return Array.from({ length: length }, function () { return ({}); });
23528
+ return this.storableRealtimeSubscriptions.onEvent(Tasks_consts_1.TaskRealTimeEvents.TASK_UPDATE, callback);
23142
23529
  };
23143
23530
  return TaskRealtimeSubscriptions;
23144
23531
  }());
@@ -28510,8 +28897,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
28510
28897
  }
28511
28898
  };
28512
28899
  Object.defineProperty(exports, "__esModule", ({ value: true }));
28900
+ var storable_realtime_subscriptions_1 = __webpack_require__(1227);
28513
28901
  var data_store_1 = __webpack_require__(73135);
28514
- var realtime_subscriptions_1 = __webpack_require__(47985);
28515
28902
  var storable_data_service_1 = __webpack_require__(45297);
28516
28903
  var Vehicle_consts_1 = __webpack_require__(84010);
28517
28904
  var vehicles_service_1 = __webpack_require__(87386);
@@ -28521,11 +28908,10 @@ var VehiclesApi = /** @class */ (function () {
28521
28908
  { groupType: Vehicle_consts_1.VehicleGroup.Team, keyFunc: function (vehicle) { return vehicle.team_id; } },
28522
28909
  { groupType: Vehicle_consts_1.VehicleGroup.IsTrailer, keyFunc: function (vehicle) { return !!vehicle.is_trailer; } }
28523
28910
  ];
28524
- this.eventCallbacks = {};
28525
28911
  this.vehiclesStore = new data_store_1.default(groupFilters);
28526
28912
  this.vehiclesService = new vehicles_service_1.default(session);
28527
28913
  this.storableDataService = new storable_data_service_1.default(this.vehiclesStore);
28528
- this.realtimeSubscriptions = new realtime_subscriptions_1.default(session);
28914
+ this.storableRealtimeSubscriptions = new storable_realtime_subscriptions_1.default(session, this.vehiclesStore, this.storableDataService);
28529
28915
  }
28530
28916
  VehiclesApi.prototype.load = function (id, options) {
28531
28917
  var _this = this;
@@ -28552,24 +28938,21 @@ var VehiclesApi = /** @class */ (function () {
28552
28938
  return this.storableDataService.modify('create', function () { return _this.vehiclesService.create(vehicleData); });
28553
28939
  };
28554
28940
  VehiclesApi.prototype.updateStoreOnEvents = function () {
28555
- var _this = this;
28556
- this.realtimeSubscriptions.subscribe(Vehicle_consts_1.REAL_TIME_EVENTS.VEHICLE_UPDATE, function (vehicle) {
28557
- _this.storableDataService.updateInStores(vehicle);
28558
- _this.runEventCallbacks(Vehicle_consts_1.REAL_TIME_EVENTS.VEHICLE_UPDATE, vehicle);
28559
- });
28560
- this.realtimeSubscriptions.subscribe(Vehicle_consts_1.REAL_TIME_EVENTS.VEHICLE_DELETE, function (vehicle) {
28561
- _this.storableDataService.removeFromStores(vehicle.id);
28562
- _this.runEventCallbacks(Vehicle_consts_1.REAL_TIME_EVENTS.VEHICLE_DELETE, vehicle);
28563
- });
28941
+ this.storableRealtimeSubscriptions.updateStoreOnEvents([
28942
+ { name: Vehicle_consts_1.REAL_TIME_EVENTS.VEHICLE_UPDATE, isDelete: false },
28943
+ { name: Vehicle_consts_1.REAL_TIME_EVENTS.VEHICLE_DELETE, isDelete: true }
28944
+ ]);
28564
28945
  };
28565
28946
  VehiclesApi.prototype.onUpdate = function (callback) {
28566
- return this.onEvent(Vehicle_consts_1.REAL_TIME_EVENTS.VEHICLE_UPDATE, callback);
28947
+ return this.storableRealtimeSubscriptions.onEvent(Vehicle_consts_1.REAL_TIME_EVENTS.VEHICLE_UPDATE, function (item) { return callback(item.current); });
28567
28948
  };
28568
28949
  VehiclesApi.prototype.onDelete = function (callback) {
28569
- return this.onEvent(Vehicle_consts_1.REAL_TIME_EVENTS.VEHICLE_DELETE, callback);
28950
+ return this.storableRealtimeSubscriptions.onEvent(Vehicle_consts_1.REAL_TIME_EVENTS.VEHICLE_DELETE, function (item) { return callback(item.current); });
28570
28951
  };
28571
28952
  VehiclesApi.prototype.onUnassigned = function (callback) {
28572
- return this.realtimeSubscriptions.subscribe(Vehicle_consts_1.REAL_TIME_EVENTS.VEHICLE_UNASSIGNED, callback);
28953
+ return this.storableRealtimeSubscriptions.onAnyEvent(Vehicle_consts_1.REAL_TIME_EVENTS.VEHICLE_UNASSIGNED, function (vehicle) {
28954
+ return callback(vehicle);
28955
+ });
28573
28956
  };
28574
28957
  VehiclesApi.prototype.get = function (id) {
28575
28958
  return this.vehiclesStore.get(id);
@@ -28609,20 +28992,6 @@ var VehiclesApi = /** @class */ (function () {
28609
28992
  });
28610
28993
  });
28611
28994
  };
28612
- VehiclesApi.prototype.runEventCallbacks = function (event, data) {
28613
- (this.eventCallbacks[event] || []).forEach(function (callback) { return callback(data); });
28614
- };
28615
- VehiclesApi.prototype.onEvent = function (event, callback) {
28616
- var _this = this;
28617
- if (!this.eventCallbacks[event]) {
28618
- this.eventCallbacks[event] = [];
28619
- }
28620
- this.eventCallbacks[event].push(callback);
28621
- return function () {
28622
- var indexOfCallback = _this.eventCallbacks[event].indexOf(callback);
28623
- _this.eventCallbacks[event].splice(indexOfCallback, 1);
28624
- };
28625
- };
28626
28995
  return VehiclesApi;
28627
28996
  }());
28628
28997
  exports["default"] = VehiclesApi;
@@ -30244,6 +30613,17 @@ exports["default"] = RealtimeSubscriptions;
30244
30613
 
30245
30614
  "use strict";
30246
30615
 
30616
+ var __assign = (this && this.__assign) || function () {
30617
+ __assign = Object.assign || function(t) {
30618
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
30619
+ s = arguments[i];
30620
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
30621
+ t[p] = s[p];
30622
+ }
30623
+ return t;
30624
+ };
30625
+ return __assign.apply(this, arguments);
30626
+ };
30247
30627
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
30248
30628
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
30249
30629
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -30318,7 +30698,7 @@ var StorableDataService = /** @class */ (function () {
30318
30698
  return [4 /*yield*/, loadFunc(loadFnIdsParams)];
30319
30699
  case 1:
30320
30700
  items = _a.sent();
30321
- mappedItems_1 = items.map(function (item) { return _this.mapper(item, action); });
30701
+ mappedItems_1 = items.map(function (item) { return _this.mapper(item, { action: action }); });
30322
30702
  if (options.groupType) {
30323
30703
  this.dataStore.setGroup(options.groupType, groupValue, mappedItems_1);
30324
30704
  }
@@ -30346,7 +30726,7 @@ var StorableDataService = /** @class */ (function () {
30346
30726
  return [4 /*yield*/, loadFunc(ids)];
30347
30727
  case 1:
30348
30728
  items = _a.sent();
30349
- mappedItems_2 = items.map(function (item) { return _this.mapper(item, action); });
30729
+ mappedItems_2 = items.map(function (item) { return _this.mapper(item, { action: action }); });
30350
30730
  this.dataStore.setMany(mappedItems_2);
30351
30731
  this.extraDataStores.forEach(function (dataStore) { return dataStore.setMany(mappedItems_2, options.fields); });
30352
30732
  return [2 /*return*/, mappedItems_2.map(function (mappedItems) { return mappedItems.current; })];
@@ -30443,13 +30823,13 @@ var StorableDataService = /** @class */ (function () {
30443
30823
  });
30444
30824
  });
30445
30825
  };
30446
- StorableDataService.prototype.updateInStores = function (item, action, fields) {
30447
- return this.updateManyInStores([item], action, fields)[0];
30826
+ StorableDataService.prototype.updateInStores = function (item, action, fields, extraMapperParams) {
30827
+ return this.updateManyInStores([item], action, fields, extraMapperParams)[0];
30448
30828
  };
30449
- StorableDataService.prototype.updateManyInStores = function (items, action, fields) {
30829
+ StorableDataService.prototype.updateManyInStores = function (items, action, fields, extraMapperParams) {
30450
30830
  var _this = this;
30451
30831
  return (0, BringgDashboardSDK_1.getGlobals)().mobx.runInAction(function () {
30452
- var clientItems = items.map(function (item) { return _this.mapper(item, action); });
30832
+ var clientItems = items.map(function (item) { return _this.mapper(item, __assign({ action: action }, extraMapperParams)); });
30453
30833
  _this.dataStore.setMany(clientItems);
30454
30834
  _this.extraDataStores.forEach(function (dataStore) { return dataStore.setMany(clientItems, fields); });
30455
30835
  return clientItems;