@bringg/dashboard-sdk 8.19.0 → 8.20.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
@@ -3763,7 +3763,7 @@ var BaseStore = /** @class */ (function () {
3763
3763
  };
3764
3764
  this.getItemsByIds = function (ids) {
3765
3765
  var idsSet = new Set(ids);
3766
- return _this.getItems().filter(function (runModel) { return idsSet.has(runModel.id); });
3766
+ return _this.getItems().filter(function (item) { return idsSet.has(item.id); });
3767
3767
  };
3768
3768
  this.getItemsMap = function () {
3769
3769
  return _this._items;
@@ -6264,9 +6264,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
6264
6264
  Object.defineProperty(exports, "__esModule", ({ value: true }));
6265
6265
  var _ = __webpack_require__(96486);
6266
6266
  var merge_mapper_1 = __webpack_require__(59200);
6267
+ var storable_realtime_subscriptions_1 = __webpack_require__(1227);
6267
6268
  var data_entity_1 = __webpack_require__(91083);
6268
6269
  var data_store_1 = __webpack_require__(73135);
6269
- var realtime_subscriptions_1 = __webpack_require__(47985);
6270
6270
  var storable_data_service_1 = __webpack_require__(45297);
6271
6271
  var array_utils_1 = __webpack_require__(43052);
6272
6272
  var Customer_consts_1 = __webpack_require__(85240);
@@ -6279,15 +6279,19 @@ var CustomersApi = /** @class */ (function () {
6279
6279
  this.storableDataService = new storable_data_service_1.default(this.customersStore, function (customer) {
6280
6280
  return merge_mapper_1.mergeMapper.mergeIntoExisting(_this.customersStore, customer);
6281
6281
  });
6282
- this.realtimeSubscriptions = new realtime_subscriptions_1.default(session);
6283
- this.realtimeSubscriptions.subscribe(Customer_consts_1.RealtimeEvents.Created, this.storableDataService.updateInStores.bind(this.storableDataService));
6284
- this.realtimeSubscriptions.subscribe(Customer_consts_1.RealtimeEvents.Updated, this.storableDataService.updateInStores.bind(this.storableDataService));
6285
- this.realtimeSubscriptions.subscribe(Customer_consts_1.RealtimeEvents.Deleted, function (data) {
6286
- return _this.storableDataService.removeFromStores(data.customer_id);
6287
- });
6282
+ this.storableRealtimeSubscriptions = new storable_realtime_subscriptions_1.default(session, this.customersStore, this.storableDataService);
6283
+ this.storableRealtimeSubscriptions.updateStoreOnEvents([
6284
+ { name: Customer_consts_1.RealtimeEvents.Created, isDelete: false },
6285
+ { name: Customer_consts_1.RealtimeEvents.Updated, isDelete: false },
6286
+ {
6287
+ name: Customer_consts_1.RealtimeEvents.Deleted,
6288
+ isDelete: true,
6289
+ itemExtractor: function (payload) { return ({ id: payload.customer_id }); }
6290
+ }
6291
+ ]);
6288
6292
  }
6289
6293
  CustomersApi.prototype.onCreate = function (callback) {
6290
- this.realtimeSubscriptions.subscribe(Customer_consts_1.RealtimeEvents.Created, callback);
6294
+ return this.storableRealtimeSubscriptions.onEvent(Customer_consts_1.RealtimeEvents.Created, function (item) { return callback(item.current); });
6291
6295
  };
6292
6296
  CustomersApi.prototype.add = function (customer) {
6293
6297
  return this.storableDataService.updateInStores(customer);
@@ -7301,6 +7305,157 @@ exports.objectMerger = { deepMerge: deepMerge };
7301
7305
 
7302
7306
  /***/ }),
7303
7307
 
7308
+ /***/ 1227:
7309
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
7310
+
7311
+ "use strict";
7312
+
7313
+ var __values = (this && this.__values) || function(o) {
7314
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
7315
+ if (m) return m.call(o);
7316
+ if (o && typeof o.length === "number") return {
7317
+ next: function () {
7318
+ if (o && i >= o.length) o = void 0;
7319
+ return { value: o && o[i++], done: !o };
7320
+ }
7321
+ };
7322
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
7323
+ };
7324
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
7325
+ var realtime_subscriptions_1 = __webpack_require__(47985);
7326
+ var object_merger_1 = __webpack_require__(7262);
7327
+ var StorableRealtimeSubscriptions = /** @class */ (function () {
7328
+ function StorableRealtimeSubscriptions(session, dataStore, storableDataService) {
7329
+ this.realtimeSubscriptions = new realtime_subscriptions_1.default(session);
7330
+ this.dataStore = dataStore;
7331
+ this.storableDataService = storableDataService;
7332
+ this.eventCallbacks = {};
7333
+ }
7334
+ StorableRealtimeSubscriptions.prototype.updateStoreOnEvents = function (events, subEntityEvents) {
7335
+ var e_1, _a, e_2, _b;
7336
+ var _this = this;
7337
+ if (subEntityEvents === void 0) { subEntityEvents = []; }
7338
+ var _loop_1 = function (event_1) {
7339
+ this_1.realtimeSubscriptions.subscribe(event_1.name, function (item) {
7340
+ item = event_1.itemExtractor ? event_1.itemExtractor(item) : item;
7341
+ var data = event_1.extraDataFunc && event_1.extraDataFunc(item);
7342
+ if (data === null || data === void 0 ? void 0 : data.ignore) {
7343
+ return;
7344
+ }
7345
+ if (event_1.isDelete) {
7346
+ var deletedItem = _this.storableDataService.removeFromStores(item.id);
7347
+ _this.runEventCallbacks(event_1.name, { diff: deletedItem });
7348
+ }
7349
+ else {
7350
+ var mappedStorableItem = _this.storableDataService.updateInStores(item, undefined, undefined, data === null || data === void 0 ? void 0 : data.params);
7351
+ _this.runEventCallbacks(event_1.name, mappedStorableItem);
7352
+ }
7353
+ });
7354
+ };
7355
+ var this_1 = this;
7356
+ try {
7357
+ for (var events_1 = __values(events), events_1_1 = events_1.next(); !events_1_1.done; events_1_1 = events_1.next()) {
7358
+ var event_1 = events_1_1.value;
7359
+ _loop_1(event_1);
7360
+ }
7361
+ }
7362
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
7363
+ finally {
7364
+ try {
7365
+ if (events_1_1 && !events_1_1.done && (_a = events_1.return)) _a.call(events_1);
7366
+ }
7367
+ finally { if (e_1) throw e_1.error; }
7368
+ }
7369
+ var _loop_2 = function (subEntityEvent) {
7370
+ this_2.realtimeSubscriptions.subscribe(subEntityEvent.name, function (subEntity) {
7371
+ subEntityEvent.ignoreFields.forEach(function (field) { return delete subEntity[field]; });
7372
+ var eventChangeData = _this.changeSubEntity(subEntity, subEntityEvent.parentField, subEntityEvent.field, subEntityEvent.isDelete);
7373
+ if (eventChangeData.current) {
7374
+ _this.runEventCallbacks(subEntityEvent.eventToRaise, eventChangeData);
7375
+ }
7376
+ });
7377
+ };
7378
+ var this_2 = this;
7379
+ try {
7380
+ for (var subEntityEvents_1 = __values(subEntityEvents), subEntityEvents_1_1 = subEntityEvents_1.next(); !subEntityEvents_1_1.done; subEntityEvents_1_1 = subEntityEvents_1.next()) {
7381
+ var subEntityEvent = subEntityEvents_1_1.value;
7382
+ _loop_2(subEntityEvent);
7383
+ }
7384
+ }
7385
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
7386
+ finally {
7387
+ try {
7388
+ if (subEntityEvents_1_1 && !subEntityEvents_1_1.done && (_b = subEntityEvents_1.return)) _b.call(subEntityEvents_1);
7389
+ }
7390
+ finally { if (e_2) throw e_2.error; }
7391
+ }
7392
+ };
7393
+ StorableRealtimeSubscriptions.prototype.onAnyEvent = function (event, callback) {
7394
+ return this.realtimeSubscriptions.subscribe(event, callback);
7395
+ };
7396
+ StorableRealtimeSubscriptions.prototype.onEvent = function (event, callback) {
7397
+ var _this = this;
7398
+ if (!this.eventCallbacks[event]) {
7399
+ this.eventCallbacks[event] = [];
7400
+ }
7401
+ this.eventCallbacks[event].push(callback);
7402
+ return function () {
7403
+ var indexOfCallback = _this.eventCallbacks[event].indexOf(callback);
7404
+ _this.eventCallbacks[event].splice(indexOfCallback, 1);
7405
+ };
7406
+ };
7407
+ StorableRealtimeSubscriptions.prototype.runEventCallbacks = function (event, data) {
7408
+ (this.eventCallbacks[event] || []).forEach(function (callback) { return callback(data); });
7409
+ };
7410
+ StorableRealtimeSubscriptions.prototype.changeSubEntity = function (subEntity, parentField, containerField, isDelete) {
7411
+ var _a, _b, _c;
7412
+ var current = this.dataStore.get(subEntity[parentField]);
7413
+ var diff;
7414
+ if (current) {
7415
+ if (!current[containerField]) {
7416
+ current[containerField] = [];
7417
+ }
7418
+ var existingIndex = current[containerField].findIndex(function (taskSubEntity) { return taskSubEntity.id === subEntity.id; });
7419
+ if (existingIndex > -1) {
7420
+ if (isDelete) {
7421
+ diff = (_a = { id: current.id }, _a[containerField] = this.createArrayOfEmptyObjects(existingIndex), _a);
7422
+ for (var i = existingIndex + 1; i < current[containerField].length; i++) {
7423
+ diff[containerField].push(current[containerField][i]);
7424
+ }
7425
+ current[containerField].splice(existingIndex, 1);
7426
+ }
7427
+ else {
7428
+ var subEntityDiff = object_merger_1.objectMerger.deepMerge(current[containerField][existingIndex], subEntity);
7429
+ diff = (_b = {
7430
+ id: current.id
7431
+ },
7432
+ _b[containerField] = this.createArrayOfEmptyObjects(current[containerField].length),
7433
+ _b);
7434
+ diff[containerField][existingIndex] = subEntityDiff;
7435
+ }
7436
+ }
7437
+ else if (!isDelete) {
7438
+ diff = (_c = {
7439
+ id: current.id
7440
+ },
7441
+ _c[containerField] = this.createArrayOfEmptyObjects(current[containerField].length),
7442
+ _c);
7443
+ diff[containerField].push(subEntity);
7444
+ current[containerField].push(subEntity);
7445
+ }
7446
+ }
7447
+ return { current: current, diff: diff };
7448
+ };
7449
+ StorableRealtimeSubscriptions.prototype.createArrayOfEmptyObjects = function (length) {
7450
+ return Array.from({ length: length }, function () { return ({}); });
7451
+ };
7452
+ return StorableRealtimeSubscriptions;
7453
+ }());
7454
+ exports["default"] = StorableRealtimeSubscriptions;
7455
+ //# sourceMappingURL=storable-realtime-subscriptions.js.map
7456
+
7457
+ /***/ }),
7458
+
7304
7459
  /***/ 27774:
7305
7460
  /***/ ((__unused_webpack_module, exports) => {
7306
7461
 
@@ -16886,21 +17041,6 @@ exports["default"] = Rules;
16886
17041
 
16887
17042
  "use strict";
16888
17043
 
16889
- var __extends = (this && this.__extends) || (function () {
16890
- var extendStatics = function (d, b) {
16891
- extendStatics = Object.setPrototypeOf ||
16892
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
16893
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
16894
- return extendStatics(d, b);
16895
- };
16896
- return function (d, b) {
16897
- if (typeof b !== "function" && b !== null)
16898
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
16899
- extendStatics(d, b);
16900
- function __() { this.constructor = d; }
16901
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16902
- };
16903
- })();
16904
17044
  var __assign = (this && this.__assign) || function () {
16905
17045
  __assign = Object.assign || function(t) {
16906
17046
  for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -16951,8 +17091,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
16951
17091
  Object.defineProperty(exports, "__esModule", ({ value: true }));
16952
17092
  exports.RunsService = exports.Routes = void 0;
16953
17093
  var BringgException_1 = __webpack_require__(43605);
17094
+ var CrudService_1 = __webpack_require__(14809);
16954
17095
  var Route_1 = __webpack_require__(92641);
16955
- var SessionBasedService_1 = __webpack_require__(27826);
16956
17096
  var array_utils_1 = __webpack_require__(43052);
16957
17097
  var runs_consts_1 = __webpack_require__(4669);
16958
17098
  exports.Routes = {
@@ -16971,27 +17111,23 @@ exports.Routes = {
16971
17111
  ASSIGN_VEHICLES: new Route_1.Route('/runs/{:id}/vehicles_assignment', 3 /* HttpMethod.PATCH */),
16972
17112
  UNASSIGN_VEHICLES: new Route_1.Route('/runs/{:id}/vehicles_assignment', 4 /* HttpMethod.DELETE */)
16973
17113
  };
16974
- var RunsService = /** @class */ (function (_super) {
16975
- __extends(RunsService, _super);
17114
+ var RunsService = /** @class */ (function () {
16976
17115
  function RunsService(session) {
16977
- return _super.call(this, session.config.getApiEndpoint(), session) || this;
17116
+ this.service = new CrudService_1.default(session, 'runs');
16978
17117
  }
16979
17118
  RunsService.prototype.getAll = function (options, _a) {
16980
17119
  var _b = _a === void 0 ? {} : _a, signal = _b.signal;
16981
17120
  return __awaiter(this, void 0, void 0, function () {
16982
- var runsResponse;
16983
17121
  return __generator(this, function (_c) {
16984
17122
  switch (_c.label) {
16985
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17123
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
16986
17124
  route: exports.Routes.GET_RUNS,
16987
17125
  extractor: runs_consts_1.defaultExtractor,
16988
17126
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to get Runs'),
16989
17127
  queryString: options,
16990
17128
  signal: signal
16991
17129
  })];
16992
- case 1:
16993
- runsResponse = _c.sent();
16994
- return [2 /*return*/, runsResponse];
17130
+ case 1: return [2 /*return*/, _c.sent()];
16995
17131
  }
16996
17132
  });
16997
17133
  });
@@ -17001,7 +17137,7 @@ var RunsService = /** @class */ (function (_super) {
17001
17137
  return __awaiter(this, void 0, void 0, function () {
17002
17138
  return __generator(this, function (_c) {
17003
17139
  switch (_c.label) {
17004
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17140
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17005
17141
  route: exports.Routes.GET_RUN_DATA,
17006
17142
  extractor: runs_consts_1.defaultExtractor,
17007
17143
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to get routes data'),
@@ -17076,22 +17212,19 @@ var RunsService = /** @class */ (function (_super) {
17076
17212
  });
17077
17213
  });
17078
17214
  };
17079
- RunsService.prototype.get = function (id, _a) {
17215
+ RunsService.prototype.load = function (id, _a) {
17080
17216
  var _b = _a === void 0 ? {} : _a, signal = _b.signal;
17081
17217
  return __awaiter(this, void 0, void 0, function () {
17082
- var run;
17083
17218
  return __generator(this, function (_c) {
17084
17219
  switch (_c.label) {
17085
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17220
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17086
17221
  route: exports.Routes.GET_RUN,
17087
17222
  extractor: runs_consts_1.runExtractor,
17088
17223
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to get Run'),
17089
17224
  routeParams: { id: id },
17090
17225
  signal: signal
17091
17226
  })];
17092
- case 1:
17093
- run = _c.sent();
17094
- return [2 /*return*/, run];
17227
+ case 1: return [2 /*return*/, _c.sent()];
17095
17228
  }
17096
17229
  });
17097
17230
  });
@@ -17099,9 +17232,10 @@ var RunsService = /** @class */ (function (_super) {
17099
17232
  RunsService.prototype.update = function (id, options, _a) {
17100
17233
  var _b = _a === void 0 ? {} : _a, signal = _b.signal;
17101
17234
  return __awaiter(this, void 0, void 0, function () {
17235
+ var response;
17102
17236
  return __generator(this, function (_c) {
17103
17237
  switch (_c.label) {
17104
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17238
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17105
17239
  route: exports.Routes.UPDATE_RUN,
17106
17240
  extractor: runs_consts_1.defaultExtractor,
17107
17241
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to update Run'),
@@ -17109,7 +17243,9 @@ var RunsService = /** @class */ (function (_super) {
17109
17243
  routeParams: { id: id },
17110
17244
  signal: signal
17111
17245
  })];
17112
- case 1: return [2 /*return*/, _c.sent()];
17246
+ case 1:
17247
+ response = _c.sent();
17248
+ return [2 /*return*/, response.run];
17113
17249
  }
17114
17250
  });
17115
17251
  });
@@ -17120,7 +17256,7 @@ var RunsService = /** @class */ (function (_super) {
17120
17256
  var runHistory;
17121
17257
  return __generator(this, function (_c) {
17122
17258
  switch (_c.label) {
17123
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17259
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17124
17260
  route: exports.Routes.GET_RUN_HISTORY,
17125
17261
  extractor: runs_consts_1.runsHistoryExtractor,
17126
17262
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to get run history'),
@@ -17140,7 +17276,7 @@ var RunsService = /** @class */ (function (_super) {
17140
17276
  var runLocations;
17141
17277
  return __generator(this, function (_c) {
17142
17278
  switch (_c.label) {
17143
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17279
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17144
17280
  route: exports.Routes.GET_RUN_LOCATIONS,
17145
17281
  extractor: runs_consts_1.runsLocationsExtractor,
17146
17282
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to get run locations'),
@@ -17160,7 +17296,7 @@ var RunsService = /** @class */ (function (_super) {
17160
17296
  var runLocations;
17161
17297
  return __generator(this, function (_c) {
17162
17298
  switch (_c.label) {
17163
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17299
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17164
17300
  route: exports.Routes.GET_RUN_CASHOUT,
17165
17301
  extractor: runs_consts_1.runCashoutExtractor,
17166
17302
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to get run cashout'),
@@ -17180,7 +17316,7 @@ var RunsService = /** @class */ (function (_super) {
17180
17316
  var response;
17181
17317
  return __generator(this, function (_c) {
17182
17318
  switch (_c.label) {
17183
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17319
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17184
17320
  route: exports.Routes.ASSIGN_DRIVER,
17185
17321
  extractor: runs_consts_1.defaultExtractor,
17186
17322
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to assign driver to run'),
@@ -17201,7 +17337,7 @@ var RunsService = /** @class */ (function (_super) {
17201
17337
  var response;
17202
17338
  return __generator(this, function (_c) {
17203
17339
  switch (_c.label) {
17204
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17340
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17205
17341
  route: exports.Routes.UNASSIGN_DRIVER,
17206
17342
  extractor: runs_consts_1.defaultExtractor,
17207
17343
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to assign driver to run'),
@@ -17222,7 +17358,7 @@ var RunsService = /** @class */ (function (_super) {
17222
17358
  var response;
17223
17359
  return __generator(this, function (_c) {
17224
17360
  switch (_c.label) {
17225
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17361
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17226
17362
  route: exports.Routes.ASSIGN_VEHICLES,
17227
17363
  extractor: runs_consts_1.defaultExtractor,
17228
17364
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to assign vehicles to run'),
@@ -17243,7 +17379,7 @@ var RunsService = /** @class */ (function (_super) {
17243
17379
  var response;
17244
17380
  return __generator(this, function (_c) {
17245
17381
  switch (_c.label) {
17246
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17382
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17247
17383
  route: exports.Routes.UNASSIGN_VEHICLES,
17248
17384
  extractor: runs_consts_1.defaultExtractor,
17249
17385
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to unassign vehicles from run'),
@@ -17264,7 +17400,7 @@ var RunsService = /** @class */ (function (_super) {
17264
17400
  var runBulkClose;
17265
17401
  return __generator(this, function (_c) {
17266
17402
  switch (_c.label) {
17267
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17403
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17268
17404
  route: exports.Routes.BULK_CLOSE,
17269
17405
  extractor: runs_consts_1.defaultExtractor,
17270
17406
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to bulk close runs'),
@@ -17284,7 +17420,7 @@ var RunsService = /** @class */ (function (_super) {
17284
17420
  var markDonePlanning;
17285
17421
  return __generator(this, function (_c) {
17286
17422
  switch (_c.label) {
17287
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17423
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17288
17424
  route: exports.Routes.MARK_DONE_PLANNING,
17289
17425
  extractor: runs_consts_1.defaultExtractor,
17290
17426
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to mark done planning for runs'),
@@ -17304,7 +17440,7 @@ var RunsService = /** @class */ (function (_super) {
17304
17440
  var actualBreaksByRunIdResponse;
17305
17441
  return __generator(this, function (_c) {
17306
17442
  switch (_c.label) {
17307
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17443
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17308
17444
  route: exports.Routes.GET_ACTUAL_BREAKS,
17309
17445
  extractor: runs_consts_1.defaultExtractor,
17310
17446
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to get actual breaks of runs'),
@@ -17321,7 +17457,7 @@ var RunsService = /** @class */ (function (_super) {
17321
17457
  });
17322
17458
  };
17323
17459
  return RunsService;
17324
- }(SessionBasedService_1.SessionBasedService));
17460
+ }());
17325
17461
  exports.RunsService = RunsService;
17326
17462
  //# sourceMappingURL=runs.service.js.map
17327
17463
 
@@ -17372,7 +17508,6 @@ var RunStore = /** @class */ (function (_super) {
17372
17508
  _this.updateRun = function (payload) {
17373
17509
  return _this.createOrUpdateRun(payload, _this.onUpdate.bind(_this));
17374
17510
  };
17375
- // eslint-disable-next-line @typescript-eslint/ban-types
17376
17511
  _this.createOrUpdateRun = function (payload, callback) {
17377
17512
  var existingRunModel = _this.store.getItem(payload.run.id);
17378
17513
  var updatedRunModel = { id: payload.run.id, run: payload.run, taskIds: undefined };
@@ -17508,7 +17643,7 @@ exports["default"] = RunStore;
17508
17643
  "use strict";
17509
17644
 
17510
17645
  Object.defineProperty(exports, "__esModule", ({ value: true }));
17511
- exports.GetAllChunkSize = exports.defaultExtractor = exports.runCashoutExtractor = exports.runsLocationsExtractor = exports.runsHistoryExtractor = exports.runExtractor = exports.RunEvents = exports.RunStatus = void 0;
17646
+ exports.GetAllChunkSize = exports.defaultExtractor = exports.runCashoutExtractor = exports.runsLocationsExtractor = exports.runsHistoryExtractor = exports.runExtractor = exports.RunGroupTypes = exports.RunEvents = exports.RunStatus = void 0;
17512
17647
  var RunStatus;
17513
17648
  (function (RunStatus) {
17514
17649
  RunStatus["ALL"] = "all";
@@ -17521,6 +17656,10 @@ var RunEvents;
17521
17656
  RunEvents["DELETED"] = "run deleted";
17522
17657
  RunEvents["CREATED"] = "run created";
17523
17658
  })(RunEvents = exports.RunEvents || (exports.RunEvents = {}));
17659
+ var RunGroupTypes;
17660
+ (function (RunGroupTypes) {
17661
+ RunGroupTypes["TaskIds"] = "taskIds";
17662
+ })(RunGroupTypes = exports.RunGroupTypes || (exports.RunGroupTypes = {}));
17524
17663
  var runExtractor = function (response) { return response.run; };
17525
17664
  exports.runExtractor = runExtractor;
17526
17665
  var runsHistoryExtractor = function (response) { return response; };
@@ -17668,7 +17807,7 @@ var Runs = /** @class */ (function () {
17668
17807
  var run;
17669
17808
  return __generator(this, function (_a) {
17670
17809
  switch (_a.label) {
17671
- case 0: return [4 /*yield*/, this.runsService.get(id, commonOptions)];
17810
+ case 0: return [4 /*yield*/, this.runsService.load(id, commonOptions)];
17672
17811
  case 1:
17673
17812
  run = _a.sent();
17674
17813
  return [2 /*return*/, this.runStore.set(run)];
@@ -17681,7 +17820,7 @@ var Runs = /** @class */ (function () {
17681
17820
  return __awaiter(this, void 0, void 0, function () {
17682
17821
  return __generator(this, function (_a) {
17683
17822
  switch (_a.label) {
17684
- case 0: return [4 /*yield*/, this.runsService.get(id, commonOptions)];
17823
+ case 0: return [4 /*yield*/, this.runsService.load(id, commonOptions)];
17685
17824
  case 1: return [2 /*return*/, _a.sent()];
17686
17825
  }
17687
17826
  });
@@ -17826,6 +17965,165 @@ exports["default"] = Runs;
17826
17965
 
17827
17966
  /***/ }),
17828
17967
 
17968
+ /***/ 30196:
17969
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
17970
+
17971
+ "use strict";
17972
+
17973
+ var __read = (this && this.__read) || function (o, n) {
17974
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
17975
+ if (!m) return o;
17976
+ var i = m.call(o), r, ar = [], e;
17977
+ try {
17978
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
17979
+ }
17980
+ catch (error) { e = { error: error }; }
17981
+ finally {
17982
+ try {
17983
+ if (r && !r.done && (m = i["return"])) m.call(i);
17984
+ }
17985
+ finally { if (e) throw e.error; }
17986
+ }
17987
+ return ar;
17988
+ };
17989
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
17990
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
17991
+ if (ar || !(i in from)) {
17992
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
17993
+ ar[i] = from[i];
17994
+ }
17995
+ }
17996
+ return to.concat(ar || Array.prototype.slice.call(from));
17997
+ };
17998
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
17999
+ var storable_realtime_subscriptions_1 = __webpack_require__(1227);
18000
+ var Tasks_consts_1 = __webpack_require__(24976);
18001
+ var runs_consts_1 = __webpack_require__(4669);
18002
+ var RunRealtimeSubscriptions = /** @class */ (function () {
18003
+ function RunRealtimeSubscriptions(session, runsStore, storableDataService) {
18004
+ var _this = this;
18005
+ this.runsStore = runsStore;
18006
+ this.storableDataService = storableDataService;
18007
+ this.updateTaskIdsOnDelete = function (task) {
18008
+ var existingRun = _this.runsStore.get(task.run_id);
18009
+ if (!existingRun) {
18010
+ return;
18011
+ }
18012
+ var updatedTaskIds = new Set(existingRun.task_ids);
18013
+ updatedTaskIds.delete(task.id);
18014
+ _this.updateRunInStore(existingRun, updatedTaskIds);
18015
+ };
18016
+ this.storableRealtimeSubscriptions = new storable_realtime_subscriptions_1.default(session, runsStore, storableDataService);
18017
+ this.taskIdsWaitingForRun = new Map();
18018
+ }
18019
+ RunRealtimeSubscriptions.prototype.updateStoreOnEvents = function () {
18020
+ var runExtractor = function (_a) {
18021
+ var run = _a.run;
18022
+ return run;
18023
+ };
18024
+ this.storableRealtimeSubscriptions.updateStoreOnEvents([
18025
+ {
18026
+ name: runs_consts_1.RunEvents.CREATED,
18027
+ isDelete: false,
18028
+ extraDataFunc: this.addTaskIdsOnCreateOrUpdate.bind(this),
18029
+ itemExtractor: runExtractor
18030
+ },
18031
+ {
18032
+ name: runs_consts_1.RunEvents.UPDATED,
18033
+ isDelete: false,
18034
+ extraDataFunc: this.addTaskIdsOnCreateOrUpdate.bind(this),
18035
+ itemExtractor: runExtractor
18036
+ },
18037
+ { name: runs_consts_1.RunEvents.DELETED, isDelete: true }
18038
+ ]);
18039
+ this.storableRealtimeSubscriptions.onAnyEvent(Tasks_consts_1.TaskRealTimeEvents.TASK_DELETED, this.updateTaskIdsOnDelete.bind(this));
18040
+ this.storableRealtimeSubscriptions.onAnyEvent(Tasks_consts_1.TaskRealTimeEvents.TASK_UPDATE, this.updateTaskIds.bind(this));
18041
+ this.storableRealtimeSubscriptions.onAnyEvent(Tasks_consts_1.TaskRealTimeEvents.NEW_TASK, this.updateTaskIds.bind(this));
18042
+ };
18043
+ RunRealtimeSubscriptions.prototype.onUpdate = function (callback) {
18044
+ return this.storableRealtimeSubscriptions.onEvent(runs_consts_1.RunEvents.UPDATED, callback);
18045
+ };
18046
+ RunRealtimeSubscriptions.prototype.onDelete = function (callback) {
18047
+ return this.storableRealtimeSubscriptions.onEvent(runs_consts_1.RunEvents.DELETED, callback);
18048
+ };
18049
+ RunRealtimeSubscriptions.prototype.onCreate = function (callback) {
18050
+ return this.storableRealtimeSubscriptions.onEvent(runs_consts_1.RunEvents.CREATED, callback);
18051
+ };
18052
+ RunRealtimeSubscriptions.prototype.addTaskIdsOnCreateOrUpdate = function (run) {
18053
+ if (run.task_ids || run.tasks) {
18054
+ return;
18055
+ }
18056
+ var existingRun = this.runsStore.get(run.id);
18057
+ var taskIdsWaitingForRun = this.taskIdsWaitingForRun.get(run.id) || new Set();
18058
+ var taskIds = existingRun
18059
+ ? Array.from(new Set(__spreadArray(__spreadArray([], __read(existingRun.task_ids), false), __read(taskIdsWaitingForRun), false)))
18060
+ : Array.from(taskIdsWaitingForRun);
18061
+ this.taskIdsWaitingForRun.delete(run.id);
18062
+ return { params: { taskIds: taskIds } };
18063
+ };
18064
+ RunRealtimeSubscriptions.prototype.updateTaskIds = function (task) {
18065
+ var existingRun = this.runsStore.getGroup(runs_consts_1.RunGroupTypes.TaskIds, task.id)[0];
18066
+ if (task.run_id) {
18067
+ var newRun = this.runsStore.get(task.run_id);
18068
+ if (!newRun) {
18069
+ this.backupTasksUntilRunIsCreated(task);
18070
+ }
18071
+ else if (this.taskAddedToRun(task, newRun)) {
18072
+ var updatedTaskIds = new Set(newRun.task_ids);
18073
+ updatedTaskIds.add(task.id);
18074
+ this.updateRunInStore(newRun, updatedTaskIds);
18075
+ }
18076
+ }
18077
+ else if (this.taskRemovedFromRun(task, existingRun)) {
18078
+ var updatedTaskIds = new Set(existingRun.task_ids);
18079
+ updatedTaskIds.delete(task.id);
18080
+ this.updateRunInStore(existingRun, updatedTaskIds);
18081
+ }
18082
+ this.updatePreviousRun(task, existingRun === null || existingRun === void 0 ? void 0 : existingRun.id);
18083
+ };
18084
+ RunRealtimeSubscriptions.prototype.updatePreviousRun = function (task, previousRunId) {
18085
+ if (previousRunId && previousRunId != task.run_id) {
18086
+ if (this.taskIdsWaitingForRun.has(previousRunId)) {
18087
+ this.taskIdsWaitingForRun.get(previousRunId).delete(task.id);
18088
+ }
18089
+ var previousRunOfTask = this.runsStore.get(previousRunId);
18090
+ if (previousRunOfTask) {
18091
+ var updatedTaskIds = new Set(previousRunOfTask.task_ids);
18092
+ updatedTaskIds.delete(task.id);
18093
+ this.updateRunInStore(previousRunOfTask, updatedTaskIds);
18094
+ }
18095
+ }
18096
+ };
18097
+ RunRealtimeSubscriptions.prototype.updateRunInStore = function (newRun, taskIds) {
18098
+ var mappedItem = this.storableDataService.updateInStores(newRun, undefined, undefined, {
18099
+ taskIds: Array.from(taskIds)
18100
+ });
18101
+ this.storableRealtimeSubscriptions.runEventCallbacks(runs_consts_1.RunEvents.UPDATED, mappedItem);
18102
+ };
18103
+ RunRealtimeSubscriptions.prototype.taskRemovedFromRun = function (task, existingRun) {
18104
+ var _a;
18105
+ 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));
18106
+ };
18107
+ RunRealtimeSubscriptions.prototype.taskAddedToRun = function (task, existingRun) {
18108
+ var _a;
18109
+ return task.run_id && !((_a = existingRun.task_ids) === null || _a === void 0 ? void 0 : _a.includes(task.id));
18110
+ };
18111
+ RunRealtimeSubscriptions.prototype.backupTasksUntilRunIsCreated = function (task) {
18112
+ if (!task.run_id) {
18113
+ return;
18114
+ }
18115
+ if (!this.taskIdsWaitingForRun.has(task.run_id)) {
18116
+ this.taskIdsWaitingForRun.set(task.run_id, new Set());
18117
+ }
18118
+ this.taskIdsWaitingForRun.get(task.run_id).add(task.id);
18119
+ };
18120
+ return RunRealtimeSubscriptions;
18121
+ }());
18122
+ exports["default"] = RunRealtimeSubscriptions;
18123
+ //# sourceMappingURL=run-realtime-subscriptions.js.map
18124
+
18125
+ /***/ }),
18126
+
17829
18127
  /***/ 83582:
17830
18128
  /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
17831
18129
 
@@ -17879,56 +18177,82 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
17879
18177
  }
17880
18178
  };
17881
18179
  Object.defineProperty(exports, "__esModule", ({ value: true }));
18180
+ var BringgDashboardSDK_1 = __webpack_require__(5655);
18181
+ var data_entity_1 = __webpack_require__(91083);
17882
18182
  var data_store_1 = __webpack_require__(73135);
17883
- var realtime_subscriptions_1 = __webpack_require__(47985);
18183
+ var storable_data_service_1 = __webpack_require__(45297);
17884
18184
  var runs_consts_1 = __webpack_require__(4669);
17885
18185
  var runs_service_1 = __webpack_require__(34075);
18186
+ var run_realtime_subscriptions_1 = __webpack_require__(30196);
17886
18187
  var RunsApi = /** @class */ (function () {
17887
18188
  function RunsApi(session) {
17888
18189
  var _this = this;
17889
- this.createOrUpdateRun = function (payload) {
17890
- _this.runsStore.set(payload.run);
18190
+ this.onUpdate = function (callback) {
18191
+ return _this.realtimeSubscriptions.onUpdate(callback);
17891
18192
  };
17892
- this.deleteRun = function (payload) {
17893
- _this.runsStore.remove(payload.id);
18193
+ this.onDelete = function (callback) {
18194
+ return _this.realtimeSubscriptions.onDelete(callback);
18195
+ };
18196
+ this.onCreate = function (callback) {
18197
+ return _this.realtimeSubscriptions.onCreate(callback);
17894
18198
  };
17895
- this.runsStore = new data_store_1.default();
18199
+ this.runsStore = new data_store_1.default([
18200
+ {
18201
+ groupType: runs_consts_1.RunGroupTypes.TaskIds,
18202
+ keyFunc: function (runModel) { return runModel.task_ids; }
18203
+ }
18204
+ ]);
17896
18205
  this.runsService = new runs_service_1.RunsService(session);
17897
- this.realtimeSubscriptions = new realtime_subscriptions_1.default(session);
17898
- this.realtimeSubscriptions.subscribe(runs_consts_1.RunEvents.CREATED, this.createOrUpdateRun);
17899
- this.realtimeSubscriptions.subscribe(runs_consts_1.RunEvents.UPDATED, this.createOrUpdateRun);
17900
- this.realtimeSubscriptions.subscribe(runs_consts_1.RunEvents.DELETED, this.deleteRun);
18206
+ var mapper = function (run, params) {
18207
+ var existing = _this.runsStore.get(run.id);
18208
+ var taskIds;
18209
+ if (params.taskIds || run.task_ids || run.tasks) {
18210
+ taskIds = params.taskIds || run.task_ids || run.tasks.map(function (task) { return task.id; });
18211
+ }
18212
+ if (existing) {
18213
+ var previous = (0, BringgDashboardSDK_1.getGlobals)().mobx.toJS(existing);
18214
+ run.task_ids = taskIds || existing.task_ids;
18215
+ return { current: run, previous: previous };
18216
+ }
18217
+ else {
18218
+ run.task_ids = taskIds || [];
18219
+ return { current: run };
18220
+ }
18221
+ };
18222
+ this.storableDataService = new storable_data_service_1.default(this.runsStore, mapper);
18223
+ this.realtimeSubscriptions = new run_realtime_subscriptions_1.default(session, this.runsStore, this.storableDataService);
17901
18224
  }
18225
+ RunsApi.prototype.updateStoreOnEvents = function () {
18226
+ this.realtimeSubscriptions.updateStoreOnEvents();
18227
+ };
18228
+ RunsApi.prototype.get = function (id) {
18229
+ return this.runsStore.get(id);
18230
+ };
17902
18231
  RunsApi.prototype.getAll = function () {
17903
18232
  return this.runsStore.getAll();
17904
18233
  };
18234
+ RunsApi.prototype.getAllMap = function () {
18235
+ return this.runsStore.getAllById();
18236
+ };
17905
18237
  RunsApi.prototype.getByIds = function (ids) {
17906
18238
  var _this = this;
17907
- return ids.map(function (runId) { return _this.runsStore.get(runId); });
18239
+ return ids.map(function (runId) { return _this.runsStore.get(runId); }).filter(Boolean);
17908
18240
  };
17909
- RunsApi.prototype.loadAll = function (options, commonOptions) {
18241
+ RunsApi.prototype.add = function (run) {
18242
+ return this.storableDataService.updateInStores(run);
18243
+ };
18244
+ RunsApi.prototype.remove = function (id) {
18245
+ return this.storableDataService.removeFromStores(id);
18246
+ };
18247
+ RunsApi.prototype.loadMany = function (queryParams, options, commonOptions) {
18248
+ if (options === void 0) { options = data_entity_1.DEFAULT_OPTIONS; }
17910
18249
  if (commonOptions === void 0) { commonOptions = {}; }
17911
18250
  return __awaiter(this, void 0, void 0, function () {
17912
- var idsToFetch, runs_1, runs;
17913
18251
  var _this = this;
17914
18252
  return __generator(this, function (_a) {
17915
- switch (_a.label) {
17916
- case 0:
17917
- if (!options.ids) return [3 /*break*/, 3];
17918
- idsToFetch = options.ids.filter(function (id) { return !_this.runsStore.get(id); });
17919
- if (!idsToFetch.length) return [3 /*break*/, 2];
17920
- return [4 /*yield*/, this.runsService.loadAll(__assign(__assign({}, options), { ids: idsToFetch }), commonOptions)];
17921
- case 1:
17922
- runs_1 = _a.sent();
17923
- this.runsStore.setMany(runs_1.map(function (run) { return ({ current: run }); }));
17924
- _a.label = 2;
17925
- case 2: return [2 /*return*/, this.getByIds(options.ids)];
17926
- case 3: return [4 /*yield*/, this.runsService.loadAll(options, commonOptions)];
17927
- case 4:
17928
- runs = _a.sent();
17929
- this.runsStore.setAll(runs.map(function (run) { return ({ current: run }); }));
17930
- return [2 /*return*/, runs];
17931
- }
18253
+ return [2 /*return*/, this.storableDataService.loadMany('loadMany', function (idsToLoad) {
18254
+ return _this.runsService.loadAll(__assign(__assign({}, options), { ids: idsToLoad }), commonOptions);
18255
+ }, queryParams.ids, options)];
17932
18256
  });
17933
18257
  });
17934
18258
  };
@@ -17943,6 +18267,130 @@ var RunsApi = /** @class */ (function () {
17943
18267
  });
17944
18268
  });
17945
18269
  };
18270
+ RunsApi.prototype.load = function (id, options) {
18271
+ var _this = this;
18272
+ if (options === void 0) { options = data_entity_1.DEFAULT_OPTIONS; }
18273
+ return this.storableDataService.load('load', function () { return _this.runsService.load(id); }, id, options);
18274
+ };
18275
+ RunsApi.prototype.update = function (id, options, commonOptions) {
18276
+ if (commonOptions === void 0) { commonOptions = {}; }
18277
+ return __awaiter(this, void 0, void 0, function () {
18278
+ var _this = this;
18279
+ return __generator(this, function (_a) {
18280
+ return [2 /*return*/, this.storableDataService.modify('update', function () { return _this.runsService.update(id, options, commonOptions); })];
18281
+ });
18282
+ });
18283
+ };
18284
+ RunsApi.prototype.getHistory = function (id, commonOptions) {
18285
+ if (commonOptions === void 0) { commonOptions = {}; }
18286
+ return __awaiter(this, void 0, void 0, function () {
18287
+ return __generator(this, function (_a) {
18288
+ switch (_a.label) {
18289
+ case 0: return [4 /*yield*/, this.runsService.getHistory(id, commonOptions)];
18290
+ case 1: return [2 /*return*/, _a.sent()];
18291
+ }
18292
+ });
18293
+ });
18294
+ };
18295
+ RunsApi.prototype.getLocations = function (id, commonOptions) {
18296
+ if (commonOptions === void 0) { commonOptions = {}; }
18297
+ return __awaiter(this, void 0, void 0, function () {
18298
+ return __generator(this, function (_a) {
18299
+ switch (_a.label) {
18300
+ case 0: return [4 /*yield*/, this.runsService.getLocations(id, commonOptions)];
18301
+ case 1: return [2 /*return*/, _a.sent()];
18302
+ }
18303
+ });
18304
+ });
18305
+ };
18306
+ RunsApi.prototype.getCashout = function (id, commonOptions) {
18307
+ if (commonOptions === void 0) { commonOptions = {}; }
18308
+ return __awaiter(this, void 0, void 0, function () {
18309
+ return __generator(this, function (_a) {
18310
+ switch (_a.label) {
18311
+ case 0: return [4 /*yield*/, this.runsService.getCashout(id, commonOptions)];
18312
+ case 1: return [2 /*return*/, _a.sent()];
18313
+ }
18314
+ });
18315
+ });
18316
+ };
18317
+ RunsApi.prototype.assignDriver = function (id, userId, targetRun, commonOptions) {
18318
+ if (commonOptions === void 0) { commonOptions = {}; }
18319
+ return __awaiter(this, void 0, void 0, function () {
18320
+ return __generator(this, function (_a) {
18321
+ switch (_a.label) {
18322
+ case 0: return [4 /*yield*/, this.runsService.assignDriver(id, userId, targetRun, commonOptions)];
18323
+ case 1: return [2 /*return*/, _a.sent()];
18324
+ }
18325
+ });
18326
+ });
18327
+ };
18328
+ RunsApi.prototype.unassignDriver = function (id, userId, commonOptions) {
18329
+ if (commonOptions === void 0) { commonOptions = {}; }
18330
+ return __awaiter(this, void 0, void 0, function () {
18331
+ return __generator(this, function (_a) {
18332
+ switch (_a.label) {
18333
+ case 0: return [4 /*yield*/, this.runsService.unassignDriver(id, userId, commonOptions)];
18334
+ case 1: return [2 /*return*/, _a.sent()];
18335
+ }
18336
+ });
18337
+ });
18338
+ };
18339
+ RunsApi.prototype.assignVehicles = function (id, vehicleId, tasks, commonOptions) {
18340
+ if (commonOptions === void 0) { commonOptions = {}; }
18341
+ return __awaiter(this, void 0, void 0, function () {
18342
+ return __generator(this, function (_a) {
18343
+ switch (_a.label) {
18344
+ case 0: return [4 /*yield*/, this.runsService.assignVehicles(id, vehicleId, tasks, commonOptions)];
18345
+ case 1: return [2 /*return*/, _a.sent()];
18346
+ }
18347
+ });
18348
+ });
18349
+ };
18350
+ RunsApi.prototype.unassignVehicles = function (id, commonOptions) {
18351
+ if (commonOptions === void 0) { commonOptions = {}; }
18352
+ return __awaiter(this, void 0, void 0, function () {
18353
+ return __generator(this, function (_a) {
18354
+ switch (_a.label) {
18355
+ case 0: return [4 /*yield*/, this.runsService.unassignVehicles(id, commonOptions)];
18356
+ case 1: return [2 /*return*/, _a.sent()];
18357
+ }
18358
+ });
18359
+ });
18360
+ };
18361
+ RunsApi.prototype.bulkClose = function (runIds, commonOptions) {
18362
+ if (commonOptions === void 0) { commonOptions = {}; }
18363
+ return __awaiter(this, void 0, void 0, function () {
18364
+ return __generator(this, function (_a) {
18365
+ switch (_a.label) {
18366
+ case 0: return [4 /*yield*/, this.runsService.bulkClose(runIds, commonOptions)];
18367
+ case 1: return [2 /*return*/, _a.sent()];
18368
+ }
18369
+ });
18370
+ });
18371
+ };
18372
+ RunsApi.prototype.markDonePlanning = function (runIds, commonOptions) {
18373
+ if (commonOptions === void 0) { commonOptions = {}; }
18374
+ return __awaiter(this, void 0, void 0, function () {
18375
+ return __generator(this, function (_a) {
18376
+ switch (_a.label) {
18377
+ case 0: return [4 /*yield*/, this.runsService.markDonePlanning(runIds, commonOptions)];
18378
+ case 1: return [2 /*return*/, _a.sent()];
18379
+ }
18380
+ });
18381
+ });
18382
+ };
18383
+ RunsApi.prototype.getActualBreaks = function (runIds, commonOptions) {
18384
+ if (commonOptions === void 0) { commonOptions = {}; }
18385
+ return __awaiter(this, void 0, void 0, function () {
18386
+ return __generator(this, function (_a) {
18387
+ switch (_a.label) {
18388
+ case 0: return [4 /*yield*/, this.runsService.getActualBreaks(runIds, commonOptions)];
18389
+ case 1: return [2 /*return*/, _a.sent()];
18390
+ }
18391
+ });
18392
+ });
18393
+ };
17946
18394
  return RunsApi;
17947
18395
  }());
17948
18396
  exports["default"] = RunsApi;
@@ -20206,7 +20654,7 @@ var lodash_1 = __webpack_require__(96486);
20206
20654
  var BringgException_1 = __webpack_require__(43605);
20207
20655
  var Logger_1 = __webpack_require__(55860);
20208
20656
  var abort_1 = __webpack_require__(34179);
20209
- var version = '8.19.0';
20657
+ var version = '8.20.0-pre.1';
20210
20658
  function logErrorResponse(response) {
20211
20659
  var data = response.data, status = response.status;
20212
20660
  try {
@@ -22489,151 +22937,90 @@ exports.Routes = {
22489
22937
  /***/ }),
22490
22938
 
22491
22939
  /***/ 52131:
22492
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
22940
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
22493
22941
 
22494
22942
  "use strict";
22495
22943
 
22496
- var __values = (this && this.__values) || function(o) {
22497
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
22498
- if (m) return m.call(o);
22499
- if (o && typeof o.length === "number") return {
22500
- next: function () {
22501
- if (o && i >= o.length) o = void 0;
22502
- return { value: o && o[i++], done: !o };
22503
- }
22504
- };
22505
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
22506
- };
22507
22944
  Object.defineProperty(exports, "__esModule", ({ value: true }));
22508
- var object_merger_1 = __webpack_require__(7262);
22509
- var realtime_subscriptions_1 = __webpack_require__(47985);
22945
+ var storable_realtime_subscriptions_1 = __webpack_require__(1227);
22510
22946
  var Tasks_consts_1 = __webpack_require__(24976);
22511
22947
  var TaskRealtimeSubscriptions = /** @class */ (function () {
22512
22948
  function TaskRealtimeSubscriptions(session, tasksStore, storableDataService) {
22513
- this.realtimeSubscriptions = new realtime_subscriptions_1.default(session);
22514
22949
  this.tasksStore = tasksStore;
22515
- this.storableDataService = storableDataService;
22516
- this.eventCallbacks = {};
22950
+ this.storableRealtimeSubscriptions = new storable_realtime_subscriptions_1.default(session, tasksStore, storableDataService);
22517
22951
  }
22518
22952
  TaskRealtimeSubscriptions.prototype.updateStoreOnEvents = function () {
22519
22953
  var _this = this;
22520
- var ignoreFields = ['way_points'];
22521
- this.realtimeSubscriptions.subscribe(Tasks_consts_1.TaskRealTimeEvents.TASK_UPDATE, function (task) {
22522
- var isPartialUpdate = !task.hasOwnProperty('status');
22523
- if (isPartialUpdate && !_this.tasksStore.get(task.id)) {
22524
- return;
22525
- }
22526
- var mappedStorableItem = _this.storableDataService.updateInStores(task);
22527
- _this.runEventCallbacks(Tasks_consts_1.TaskRealTimeEvents.TASK_UPDATE, mappedStorableItem);
22528
- });
22529
- this.realtimeSubscriptions.subscribe(Tasks_consts_1.TaskRealTimeEvents.NEW_TASK, function (task) {
22530
- var mappedStorableItem = _this.storableDataService.updateInStores(task);
22531
- _this.runEventCallbacks(Tasks_consts_1.TaskRealTimeEvents.NEW_TASK, mappedStorableItem);
22532
- });
22533
- this.realtimeSubscriptions.subscribe(Tasks_consts_1.TaskRealTimeEvents.TASK_DELETED, function (task) {
22534
- var deletedTasks = _this.storableDataService.removeFromStores(task.id);
22535
- _this.runEventCallbacks(Tasks_consts_1.TaskRealTimeEvents.TASK_DELETED, { diff: deletedTasks });
22536
- });
22537
- [
22538
- { event: Tasks_consts_1.TaskRealTimeEvents.NEW_SCAN, field: 'scans', isDelete: false },
22539
- { event: Tasks_consts_1.TaskRealTimeEvents.NEW_NOTE, field: 'task_notes', isDelete: false },
22540
- { event: Tasks_consts_1.TaskRealTimeEvents.WAYPOINT_ADDED, field: 'way_points', isDelete: false },
22541
- { event: Tasks_consts_1.TaskRealTimeEvents.WAYPOINT_UPDATED, field: 'way_points', isDelete: false },
22542
- { event: Tasks_consts_1.TaskRealTimeEvents.WAYPOINT_DELETED, field: 'way_points', isDelete: true }
22543
- ].forEach(function (eventData) {
22544
- _this.realtimeSubscriptions.subscribe(eventData.event, function (subEntity) {
22545
- ignoreFields.forEach(function (field) { return delete subEntity[field]; });
22546
- var eventChangeData = _this.changeSubEntity(subEntity, eventData.field, eventData.isDelete);
22547
- if (eventChangeData.current) {
22548
- _this.runEventCallbacks(Tasks_consts_1.TaskRealTimeEvents.TASK_UPDATE, eventChangeData);
22954
+ var events = [
22955
+ {
22956
+ name: Tasks_consts_1.TaskRealTimeEvents.TASK_UPDATE,
22957
+ isDelete: false,
22958
+ extraDataFunc: function (task) {
22959
+ var isPartialUpdate = !task.hasOwnProperty('status');
22960
+ return { ignore: isPartialUpdate && !_this.tasksStore.get(task.id) };
22549
22961
  }
22550
- });
22551
- });
22962
+ },
22963
+ { name: Tasks_consts_1.TaskRealTimeEvents.NEW_TASK, isDelete: false },
22964
+ { name: Tasks_consts_1.TaskRealTimeEvents.TASK_DELETED, isDelete: true }
22965
+ ];
22966
+ var subEntityEvents = [
22967
+ {
22968
+ name: Tasks_consts_1.TaskRealTimeEvents.NEW_SCAN,
22969
+ eventToRaise: Tasks_consts_1.TaskRealTimeEvents.TASK_UPDATE,
22970
+ parentField: 'task_id',
22971
+ field: 'scans',
22972
+ ignoreFields: ['way_points'],
22973
+ isDelete: false
22974
+ },
22975
+ {
22976
+ name: Tasks_consts_1.TaskRealTimeEvents.NEW_NOTE,
22977
+ eventToRaise: Tasks_consts_1.TaskRealTimeEvents.TASK_UPDATE,
22978
+ parentField: 'task_id',
22979
+ field: 'task_notes',
22980
+ ignoreFields: ['way_points'],
22981
+ isDelete: false
22982
+ },
22983
+ {
22984
+ name: Tasks_consts_1.TaskRealTimeEvents.WAYPOINT_ADDED,
22985
+ eventToRaise: Tasks_consts_1.TaskRealTimeEvents.TASK_UPDATE,
22986
+ parentField: 'task_id',
22987
+ field: 'way_points',
22988
+ ignoreFields: ['way_points'],
22989
+ isDelete: false
22990
+ },
22991
+ {
22992
+ name: Tasks_consts_1.TaskRealTimeEvents.WAYPOINT_UPDATED,
22993
+ eventToRaise: Tasks_consts_1.TaskRealTimeEvents.TASK_UPDATE,
22994
+ parentField: 'task_id',
22995
+ field: 'way_points',
22996
+ ignoreFields: ['way_points'],
22997
+ isDelete: false
22998
+ },
22999
+ {
23000
+ name: Tasks_consts_1.TaskRealTimeEvents.WAYPOINT_DELETED,
23001
+ eventToRaise: Tasks_consts_1.TaskRealTimeEvents.TASK_UPDATE,
23002
+ parentField: 'task_id',
23003
+ field: 'way_points',
23004
+ ignoreFields: ['way_points'],
23005
+ isDelete: true
23006
+ }
23007
+ ];
23008
+ this.storableRealtimeSubscriptions.updateStoreOnEvents(events, subEntityEvents);
22552
23009
  };
22553
23010
  TaskRealtimeSubscriptions.prototype.onCreate = function (callback) {
22554
- return this.onEvent(Tasks_consts_1.TaskRealTimeEvents.NEW_TASK, callback);
23011
+ return this.storableRealtimeSubscriptions.onEvent(Tasks_consts_1.TaskRealTimeEvents.NEW_TASK, callback);
22555
23012
  };
22556
23013
  TaskRealtimeSubscriptions.prototype.onDelete = function (callback) {
22557
- return this.onEvent(Tasks_consts_1.TaskRealTimeEvents.TASK_DELETED, callback);
23014
+ return this.storableRealtimeSubscriptions.onEvent(Tasks_consts_1.TaskRealTimeEvents.TASK_DELETED, callback);
22558
23015
  };
22559
23016
  TaskRealtimeSubscriptions.prototype.onWayPointUpdate = function (callback) {
22560
- return this.onEvent(Tasks_consts_1.TaskRealTimeEvents.WAYPOINT_UPDATED, callback);
23017
+ return this.storableRealtimeSubscriptions.onEvent(Tasks_consts_1.TaskRealTimeEvents.WAYPOINT_UPDATED, callback);
22561
23018
  };
22562
23019
  TaskRealtimeSubscriptions.prototype.onWayPointDelete = function (callback) {
22563
- return this.onEvent(Tasks_consts_1.TaskRealTimeEvents.WAYPOINT_DELETED, callback);
23020
+ return this.storableRealtimeSubscriptions.onEvent(Tasks_consts_1.TaskRealTimeEvents.WAYPOINT_DELETED, callback);
22564
23021
  };
22565
23022
  TaskRealtimeSubscriptions.prototype.onUpdate = function (callback) {
22566
- var subscriptions = [];
22567
- subscriptions.push(this.onEvent(Tasks_consts_1.TaskRealTimeEvents.TASK_UPDATE, callback));
22568
- return function () {
22569
- var e_1, _a;
22570
- try {
22571
- for (var subscriptions_1 = __values(subscriptions), subscriptions_1_1 = subscriptions_1.next(); !subscriptions_1_1.done; subscriptions_1_1 = subscriptions_1.next()) {
22572
- var subscription = subscriptions_1_1.value;
22573
- subscription();
22574
- }
22575
- }
22576
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
22577
- finally {
22578
- try {
22579
- if (subscriptions_1_1 && !subscriptions_1_1.done && (_a = subscriptions_1.return)) _a.call(subscriptions_1);
22580
- }
22581
- finally { if (e_1) throw e_1.error; }
22582
- }
22583
- };
22584
- };
22585
- TaskRealtimeSubscriptions.prototype.onEvent = function (event, callback) {
22586
- var _this = this;
22587
- if (!this.eventCallbacks[event]) {
22588
- this.eventCallbacks[event] = [];
22589
- }
22590
- this.eventCallbacks[event].push(callback);
22591
- return function () {
22592
- var indexOfCallback = _this.eventCallbacks[event].indexOf(callback);
22593
- _this.eventCallbacks[event].splice(indexOfCallback, 1);
22594
- };
22595
- };
22596
- TaskRealtimeSubscriptions.prototype.runEventCallbacks = function (event, data) {
22597
- (this.eventCallbacks[event] || []).forEach(function (callback) { return callback(data); });
22598
- };
22599
- TaskRealtimeSubscriptions.prototype.changeSubEntity = function (subEntity, containerField, isDelete) {
22600
- var _a, _b, _c;
22601
- if (isDelete === void 0) { isDelete = false; }
22602
- var task = this.tasksStore.get(subEntity.task_id);
22603
- var diff;
22604
- if (task) {
22605
- if (!task[containerField]) {
22606
- task[containerField] = [];
22607
- }
22608
- var existingIndex = task[containerField].findIndex(function (taskSubEntity) { return taskSubEntity.id === subEntity.id; });
22609
- if (existingIndex > -1) {
22610
- if (isDelete) {
22611
- diff = (_a = { id: task.id }, _a[containerField] = this.createArrayOfEmptyObjects(existingIndex), _a);
22612
- for (var i = existingIndex + 1; i < task[containerField].length; i++) {
22613
- diff[containerField].push(task[containerField][i]);
22614
- }
22615
- task[containerField].splice(existingIndex, 1);
22616
- }
22617
- else {
22618
- var subEntityDiff = object_merger_1.objectMerger.deepMerge(task[containerField][existingIndex], subEntity);
22619
- diff = (_b = {
22620
- id: task.id
22621
- },
22622
- _b[containerField] = this.createArrayOfEmptyObjects(task[containerField].length),
22623
- _b);
22624
- diff[containerField][existingIndex] = subEntityDiff;
22625
- }
22626
- }
22627
- else if (!isDelete) {
22628
- diff = (_c = { id: task.id }, _c[containerField] = this.createArrayOfEmptyObjects(task[containerField].length), _c);
22629
- diff[containerField].push(subEntity);
22630
- task[containerField].push(subEntity);
22631
- }
22632
- }
22633
- return { current: task, diff: diff };
22634
- };
22635
- TaskRealtimeSubscriptions.prototype.createArrayOfEmptyObjects = function (length) {
22636
- return Array.from({ length: length }, function () { return ({}); });
23023
+ return this.storableRealtimeSubscriptions.onEvent(Tasks_consts_1.TaskRealTimeEvents.TASK_UPDATE, callback);
22637
23024
  };
22638
23025
  return TaskRealtimeSubscriptions;
22639
23026
  }());
@@ -27543,8 +27930,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
27543
27930
  }
27544
27931
  };
27545
27932
  Object.defineProperty(exports, "__esModule", ({ value: true }));
27933
+ var storable_realtime_subscriptions_1 = __webpack_require__(1227);
27546
27934
  var data_store_1 = __webpack_require__(73135);
27547
- var realtime_subscriptions_1 = __webpack_require__(47985);
27548
27935
  var storable_data_service_1 = __webpack_require__(45297);
27549
27936
  var Vehicle_consts_1 = __webpack_require__(84010);
27550
27937
  var vehicles_service_1 = __webpack_require__(87386);
@@ -27554,11 +27941,10 @@ var VehiclesApi = /** @class */ (function () {
27554
27941
  { groupType: Vehicle_consts_1.VehicleGroup.Team, keyFunc: function (vehicle) { return vehicle.team_id; } },
27555
27942
  { groupType: Vehicle_consts_1.VehicleGroup.IsTrailer, keyFunc: function (vehicle) { return !!vehicle.is_trailer; } }
27556
27943
  ];
27557
- this.eventCallbacks = {};
27558
27944
  this.vehiclesStore = new data_store_1.default(groupFilters);
27559
27945
  this.vehiclesService = new vehicles_service_1.default(session);
27560
27946
  this.storableDataService = new storable_data_service_1.default(this.vehiclesStore);
27561
- this.realtimeSubscriptions = new realtime_subscriptions_1.default(session);
27947
+ this.storableRealtimeSubscriptions = new storable_realtime_subscriptions_1.default(session, this.vehiclesStore, this.storableDataService);
27562
27948
  }
27563
27949
  VehiclesApi.prototype.load = function (id, options) {
27564
27950
  var _this = this;
@@ -27585,24 +27971,21 @@ var VehiclesApi = /** @class */ (function () {
27585
27971
  return this.storableDataService.modify('create', function () { return _this.vehiclesService.create(vehicleData); });
27586
27972
  };
27587
27973
  VehiclesApi.prototype.updateStoreOnEvents = function () {
27588
- var _this = this;
27589
- this.realtimeSubscriptions.subscribe(Vehicle_consts_1.REAL_TIME_EVENTS.VEHICLE_UPDATE, function (vehicle) {
27590
- _this.storableDataService.updateInStores(vehicle);
27591
- _this.runEventCallbacks(Vehicle_consts_1.REAL_TIME_EVENTS.VEHICLE_UPDATE, vehicle);
27592
- });
27593
- this.realtimeSubscriptions.subscribe(Vehicle_consts_1.REAL_TIME_EVENTS.VEHICLE_DELETE, function (vehicle) {
27594
- _this.storableDataService.removeFromStores(vehicle.id);
27595
- _this.runEventCallbacks(Vehicle_consts_1.REAL_TIME_EVENTS.VEHICLE_DELETE, vehicle);
27596
- });
27974
+ this.storableRealtimeSubscriptions.updateStoreOnEvents([
27975
+ { name: Vehicle_consts_1.REAL_TIME_EVENTS.VEHICLE_UPDATE, isDelete: false },
27976
+ { name: Vehicle_consts_1.REAL_TIME_EVENTS.VEHICLE_DELETE, isDelete: true }
27977
+ ]);
27597
27978
  };
27598
27979
  VehiclesApi.prototype.onUpdate = function (callback) {
27599
- return this.onEvent(Vehicle_consts_1.REAL_TIME_EVENTS.VEHICLE_UPDATE, callback);
27980
+ return this.storableRealtimeSubscriptions.onEvent(Vehicle_consts_1.REAL_TIME_EVENTS.VEHICLE_UPDATE, function (item) { return callback(item.current); });
27600
27981
  };
27601
27982
  VehiclesApi.prototype.onDelete = function (callback) {
27602
- return this.onEvent(Vehicle_consts_1.REAL_TIME_EVENTS.VEHICLE_DELETE, callback);
27983
+ return this.storableRealtimeSubscriptions.onEvent(Vehicle_consts_1.REAL_TIME_EVENTS.VEHICLE_DELETE, function (item) { return callback(item.current); });
27603
27984
  };
27604
27985
  VehiclesApi.prototype.onUnassigned = function (callback) {
27605
- return this.realtimeSubscriptions.subscribe(Vehicle_consts_1.REAL_TIME_EVENTS.VEHICLE_UNASSIGNED, callback);
27986
+ return this.storableRealtimeSubscriptions.onAnyEvent(Vehicle_consts_1.REAL_TIME_EVENTS.VEHICLE_UNASSIGNED, function (vehicle) {
27987
+ return callback(vehicle);
27988
+ });
27606
27989
  };
27607
27990
  VehiclesApi.prototype.get = function (id) {
27608
27991
  return this.vehiclesStore.get(id);
@@ -27642,20 +28025,6 @@ var VehiclesApi = /** @class */ (function () {
27642
28025
  });
27643
28026
  });
27644
28027
  };
27645
- VehiclesApi.prototype.runEventCallbacks = function (event, data) {
27646
- (this.eventCallbacks[event] || []).forEach(function (callback) { return callback(data); });
27647
- };
27648
- VehiclesApi.prototype.onEvent = function (event, callback) {
27649
- var _this = this;
27650
- if (!this.eventCallbacks[event]) {
27651
- this.eventCallbacks[event] = [];
27652
- }
27653
- this.eventCallbacks[event].push(callback);
27654
- return function () {
27655
- var indexOfCallback = _this.eventCallbacks[event].indexOf(callback);
27656
- _this.eventCallbacks[event].splice(indexOfCallback, 1);
27657
- };
27658
- };
27659
28028
  return VehiclesApi;
27660
28029
  }());
27661
28030
  exports["default"] = VehiclesApi;
@@ -29354,6 +29723,17 @@ exports["default"] = { build: build };
29354
29723
 
29355
29724
  "use strict";
29356
29725
 
29726
+ var __assign = (this && this.__assign) || function () {
29727
+ __assign = Object.assign || function(t) {
29728
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
29729
+ s = arguments[i];
29730
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
29731
+ t[p] = s[p];
29732
+ }
29733
+ return t;
29734
+ };
29735
+ return __assign.apply(this, arguments);
29736
+ };
29357
29737
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
29358
29738
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
29359
29739
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -29427,7 +29807,7 @@ var StorableDataService = /** @class */ (function () {
29427
29807
  return [4 /*yield*/, loadFunc(loadFnIdsParams)];
29428
29808
  case 1:
29429
29809
  items = _a.sent();
29430
- mappedItems_1 = items.map(function (item) { return _this.mapper(item, action); });
29810
+ mappedItems_1 = items.map(function (item) { return _this.mapper(item, { action: action }); });
29431
29811
  if (options.groupType) {
29432
29812
  this.dataStore.setGroup(options.groupType, groupValue, mappedItems_1);
29433
29813
  }
@@ -29455,7 +29835,7 @@ var StorableDataService = /** @class */ (function () {
29455
29835
  return [4 /*yield*/, loadFunc(ids)];
29456
29836
  case 1:
29457
29837
  items = _a.sent();
29458
- mappedItems_2 = items.map(function (item) { return _this.mapper(item, action); });
29838
+ mappedItems_2 = items.map(function (item) { return _this.mapper(item, { action: action }); });
29459
29839
  this.dataStore.setMany(mappedItems_2);
29460
29840
  this.extraDataStores.forEach(function (dataStore) { return dataStore.setMany(mappedItems_2, options.fields); });
29461
29841
  return [2 /*return*/, mappedItems_2.map(function (mappedItems) { return mappedItems.current; })];
@@ -29537,13 +29917,13 @@ var StorableDataService = /** @class */ (function () {
29537
29917
  });
29538
29918
  });
29539
29919
  };
29540
- StorableDataService.prototype.updateInStores = function (item, action, fields) {
29541
- return this.updateManyInStores([item], action, fields)[0];
29920
+ StorableDataService.prototype.updateInStores = function (item, action, fields, extraMapperParams) {
29921
+ return this.updateManyInStores([item], action, fields, extraMapperParams)[0];
29542
29922
  };
29543
- StorableDataService.prototype.updateManyInStores = function (items, action, fields) {
29923
+ StorableDataService.prototype.updateManyInStores = function (items, action, fields, extraMapperParams) {
29544
29924
  var _this = this;
29545
29925
  return (0, BringgDashboardSDK_1.getGlobals)().mobx.runInAction(function () {
29546
- var clientItems = items.map(function (item) { return _this.mapper(item, action); });
29926
+ var clientItems = items.map(function (item) { return _this.mapper(item, __assign({ action: action }, extraMapperParams)); });
29547
29927
  _this.dataStore.setMany(clientItems);
29548
29928
  _this.extraDataStores.forEach(function (dataStore) { return dataStore.setMany(clientItems, fields); });
29549
29929
  return clientItems;