@bringg/dashboard-sdk 8.18.3 → 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 (48) hide show
  1. package/dist/Chat/Service/Chat.service.js +2 -8
  2. package/dist/Chat/Service/Chat.service.js.map +1 -1
  3. package/dist/Core/BaseStore.js +1 -1
  4. package/dist/Core/BaseStore.js.map +1 -1
  5. package/dist/Customer/v2/customers-api.d.ts +5 -4
  6. package/dist/Customer/v2/customers-api.js +12 -8
  7. package/dist/Customer/v2/customers-api.js.map +1 -1
  8. package/dist/Data/storable-realtime-subscriptions.d.ts +18 -0
  9. package/dist/Data/storable-realtime-subscriptions.js +144 -0
  10. package/dist/Data/storable-realtime-subscriptions.js.map +1 -0
  11. package/dist/Data/storable-types.d.ts +19 -0
  12. package/dist/Data/storable-types.js +3 -0
  13. package/dist/Data/storable-types.js.map +1 -0
  14. package/dist/Run/Service/runs.service.d.ts +5 -5
  15. package/dist/Run/Service/runs.service.js +25 -44
  16. package/dist/Run/Service/runs.service.js.map +1 -1
  17. package/dist/Run/Store/RunStore.js +0 -1
  18. package/dist/Run/Store/RunStore.js.map +1 -1
  19. package/dist/Run/runs.consts.d.ts +3 -0
  20. package/dist/Run/runs.consts.js +5 -1
  21. package/dist/Run/runs.consts.js.map +1 -1
  22. package/dist/Run/runs.d.ts +2 -2
  23. package/dist/Run/runs.js +2 -2
  24. package/dist/Run/runs.js.map +1 -1
  25. package/dist/Run/v2/run-realtime-subscriptions.d.ts +25 -0
  26. package/dist/Run/v2/run-realtime-subscriptions.js +152 -0
  27. package/dist/Run/v2/run-realtime-subscriptions.js.map +1 -0
  28. package/dist/Run/v2/runs-api.d.ts +28 -5
  29. package/dist/Run/v2/runs-api.js +180 -30
  30. package/dist/Run/v2/runs-api.js.map +1 -1
  31. package/dist/Services/ServiceRequest.js +1 -1
  32. package/dist/Task/v2/task-realtime-subscriptions.d.ts +7 -13
  33. package/dist/Task/v2/task-realtime-subscriptions.js +61 -122
  34. package/dist/Task/v2/task-realtime-subscriptions.js.map +1 -1
  35. package/dist/Task/v2/tasks-api.d.ts +5 -5
  36. package/dist/Vehicle/v2/vehicles-api.d.ts +5 -7
  37. package/dist/Vehicle/v2/vehicles-api.js +11 -29
  38. package/dist/Vehicle/v2/vehicles-api.js.map +1 -1
  39. package/dist/bringg-dashboard-sdk-cjs2.js +628 -254
  40. package/dist/bringg-dashboard-sdk-cjs2.js.map +1 -1
  41. package/dist/bringg-dashboard-sdk.js +35 -13
  42. package/dist/bringg-dashboard-sdk.min.js +1 -1
  43. package/dist/bringg-dashboard-sdk.min.js.map +1 -1
  44. package/dist/data-entity.d.ts +1 -1
  45. package/dist/storable-data-service.d.ts +2 -2
  46. package/dist/storable-data-service.js +17 -6
  47. package/dist/storable-data-service.js.map +1 -1
  48. package/package.json +1 -1
@@ -3014,11 +3014,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
3014
3014
  }
3015
3015
  };
3016
3016
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3017
- var URLEndpoint_1 = __webpack_require__(77908);
3018
3017
  var RouteGenerator_1 = __webpack_require__(84075);
3019
3018
  var SessionBasedService_1 = __webpack_require__(27826);
3020
- var DEVELOPMENT_URL = 'http://localhost:3080';
3021
- var SERVICE_PREFIX = false ? 0 : '/chat-service/v2';
3019
+ var SERVICE_PREFIX = '/chat-service/v2';
3022
3020
  var Routes = {
3023
3021
  CHAT_MERCHANT_APP: "".concat(SERVICE_PREFIX, "/merchant-apps"),
3024
3022
  CHAT_MERCHANT_APP_EXISTS: "".concat(SERVICE_PREFIX, "/merchant-apps/exists"),
@@ -3028,11 +3026,7 @@ var Routes = {
3028
3026
  var ChatService = /** @class */ (function (_super) {
3029
3027
  __extends(ChatService, _super);
3030
3028
  function ChatService(session) {
3031
- var _this = this;
3032
- var endpoint = false
3033
- ? 0
3034
- : session.config.getApiEndpoint();
3035
- _this = _super.call(this, endpoint, session) || this;
3029
+ var _this = _super.call(this, session.config.getApiEndpoint(), session) || this;
3036
3030
  _this.entityName = 'chat';
3037
3031
  _this.routeGenerator = new RouteGenerator_1.default(_this);
3038
3032
  return _this;
@@ -3769,7 +3763,7 @@ var BaseStore = /** @class */ (function () {
3769
3763
  };
3770
3764
  this.getItemsByIds = function (ids) {
3771
3765
  var idsSet = new Set(ids);
3772
- return _this.getItems().filter(function (runModel) { return idsSet.has(runModel.id); });
3766
+ return _this.getItems().filter(function (item) { return idsSet.has(item.id); });
3773
3767
  };
3774
3768
  this.getItemsMap = function () {
3775
3769
  return _this._items;
@@ -6270,9 +6264,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
6270
6264
  Object.defineProperty(exports, "__esModule", ({ value: true }));
6271
6265
  var _ = __webpack_require__(96486);
6272
6266
  var merge_mapper_1 = __webpack_require__(59200);
6267
+ var storable_realtime_subscriptions_1 = __webpack_require__(1227);
6273
6268
  var data_entity_1 = __webpack_require__(91083);
6274
6269
  var data_store_1 = __webpack_require__(73135);
6275
- var realtime_subscriptions_1 = __webpack_require__(47985);
6276
6270
  var storable_data_service_1 = __webpack_require__(45297);
6277
6271
  var array_utils_1 = __webpack_require__(43052);
6278
6272
  var Customer_consts_1 = __webpack_require__(85240);
@@ -6285,15 +6279,19 @@ var CustomersApi = /** @class */ (function () {
6285
6279
  this.storableDataService = new storable_data_service_1.default(this.customersStore, function (customer) {
6286
6280
  return merge_mapper_1.mergeMapper.mergeIntoExisting(_this.customersStore, customer);
6287
6281
  });
6288
- this.realtimeSubscriptions = new realtime_subscriptions_1.default(session);
6289
- this.realtimeSubscriptions.subscribe(Customer_consts_1.RealtimeEvents.Created, this.storableDataService.updateInStores.bind(this.storableDataService));
6290
- this.realtimeSubscriptions.subscribe(Customer_consts_1.RealtimeEvents.Updated, this.storableDataService.updateInStores.bind(this.storableDataService));
6291
- this.realtimeSubscriptions.subscribe(Customer_consts_1.RealtimeEvents.Deleted, function (data) {
6292
- return _this.storableDataService.removeFromStores(data.customer_id);
6293
- });
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
+ ]);
6294
6292
  }
6295
6293
  CustomersApi.prototype.onCreate = function (callback) {
6296
- 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); });
6297
6295
  };
6298
6296
  CustomersApi.prototype.add = function (customer) {
6299
6297
  return this.storableDataService.updateInStores(customer);
@@ -7307,6 +7305,157 @@ exports.objectMerger = { deepMerge: deepMerge };
7307
7305
 
7308
7306
  /***/ }),
7309
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
+
7310
7459
  /***/ 27774:
7311
7460
  /***/ ((__unused_webpack_module, exports) => {
7312
7461
 
@@ -16892,21 +17041,6 @@ exports["default"] = Rules;
16892
17041
 
16893
17042
  "use strict";
16894
17043
 
16895
- var __extends = (this && this.__extends) || (function () {
16896
- var extendStatics = function (d, b) {
16897
- extendStatics = Object.setPrototypeOf ||
16898
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
16899
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
16900
- return extendStatics(d, b);
16901
- };
16902
- return function (d, b) {
16903
- if (typeof b !== "function" && b !== null)
16904
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
16905
- extendStatics(d, b);
16906
- function __() { this.constructor = d; }
16907
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16908
- };
16909
- })();
16910
17044
  var __assign = (this && this.__assign) || function () {
16911
17045
  __assign = Object.assign || function(t) {
16912
17046
  for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -16957,8 +17091,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
16957
17091
  Object.defineProperty(exports, "__esModule", ({ value: true }));
16958
17092
  exports.RunsService = exports.Routes = void 0;
16959
17093
  var BringgException_1 = __webpack_require__(43605);
17094
+ var CrudService_1 = __webpack_require__(14809);
16960
17095
  var Route_1 = __webpack_require__(92641);
16961
- var SessionBasedService_1 = __webpack_require__(27826);
16962
17096
  var array_utils_1 = __webpack_require__(43052);
16963
17097
  var runs_consts_1 = __webpack_require__(4669);
16964
17098
  exports.Routes = {
@@ -16977,27 +17111,23 @@ exports.Routes = {
16977
17111
  ASSIGN_VEHICLES: new Route_1.Route('/runs/{:id}/vehicles_assignment', 3 /* HttpMethod.PATCH */),
16978
17112
  UNASSIGN_VEHICLES: new Route_1.Route('/runs/{:id}/vehicles_assignment', 4 /* HttpMethod.DELETE */)
16979
17113
  };
16980
- var RunsService = /** @class */ (function (_super) {
16981
- __extends(RunsService, _super);
17114
+ var RunsService = /** @class */ (function () {
16982
17115
  function RunsService(session) {
16983
- return _super.call(this, session.config.getApiEndpoint(), session) || this;
17116
+ this.service = new CrudService_1.default(session, 'runs');
16984
17117
  }
16985
17118
  RunsService.prototype.getAll = function (options, _a) {
16986
17119
  var _b = _a === void 0 ? {} : _a, signal = _b.signal;
16987
17120
  return __awaiter(this, void 0, void 0, function () {
16988
- var runsResponse;
16989
17121
  return __generator(this, function (_c) {
16990
17122
  switch (_c.label) {
16991
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17123
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
16992
17124
  route: exports.Routes.GET_RUNS,
16993
17125
  extractor: runs_consts_1.defaultExtractor,
16994
17126
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to get Runs'),
16995
17127
  queryString: options,
16996
17128
  signal: signal
16997
17129
  })];
16998
- case 1:
16999
- runsResponse = _c.sent();
17000
- return [2 /*return*/, runsResponse];
17130
+ case 1: return [2 /*return*/, _c.sent()];
17001
17131
  }
17002
17132
  });
17003
17133
  });
@@ -17007,7 +17137,7 @@ var RunsService = /** @class */ (function (_super) {
17007
17137
  return __awaiter(this, void 0, void 0, function () {
17008
17138
  return __generator(this, function (_c) {
17009
17139
  switch (_c.label) {
17010
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17140
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17011
17141
  route: exports.Routes.GET_RUN_DATA,
17012
17142
  extractor: runs_consts_1.defaultExtractor,
17013
17143
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to get routes data'),
@@ -17082,22 +17212,19 @@ var RunsService = /** @class */ (function (_super) {
17082
17212
  });
17083
17213
  });
17084
17214
  };
17085
- RunsService.prototype.get = function (id, _a) {
17215
+ RunsService.prototype.load = function (id, _a) {
17086
17216
  var _b = _a === void 0 ? {} : _a, signal = _b.signal;
17087
17217
  return __awaiter(this, void 0, void 0, function () {
17088
- var run;
17089
17218
  return __generator(this, function (_c) {
17090
17219
  switch (_c.label) {
17091
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17220
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17092
17221
  route: exports.Routes.GET_RUN,
17093
17222
  extractor: runs_consts_1.runExtractor,
17094
17223
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to get Run'),
17095
17224
  routeParams: { id: id },
17096
17225
  signal: signal
17097
17226
  })];
17098
- case 1:
17099
- run = _c.sent();
17100
- return [2 /*return*/, run];
17227
+ case 1: return [2 /*return*/, _c.sent()];
17101
17228
  }
17102
17229
  });
17103
17230
  });
@@ -17105,9 +17232,10 @@ var RunsService = /** @class */ (function (_super) {
17105
17232
  RunsService.prototype.update = function (id, options, _a) {
17106
17233
  var _b = _a === void 0 ? {} : _a, signal = _b.signal;
17107
17234
  return __awaiter(this, void 0, void 0, function () {
17235
+ var response;
17108
17236
  return __generator(this, function (_c) {
17109
17237
  switch (_c.label) {
17110
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17238
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17111
17239
  route: exports.Routes.UPDATE_RUN,
17112
17240
  extractor: runs_consts_1.defaultExtractor,
17113
17241
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to update Run'),
@@ -17115,7 +17243,9 @@ var RunsService = /** @class */ (function (_super) {
17115
17243
  routeParams: { id: id },
17116
17244
  signal: signal
17117
17245
  })];
17118
- case 1: return [2 /*return*/, _c.sent()];
17246
+ case 1:
17247
+ response = _c.sent();
17248
+ return [2 /*return*/, response.run];
17119
17249
  }
17120
17250
  });
17121
17251
  });
@@ -17126,7 +17256,7 @@ var RunsService = /** @class */ (function (_super) {
17126
17256
  var runHistory;
17127
17257
  return __generator(this, function (_c) {
17128
17258
  switch (_c.label) {
17129
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17259
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17130
17260
  route: exports.Routes.GET_RUN_HISTORY,
17131
17261
  extractor: runs_consts_1.runsHistoryExtractor,
17132
17262
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to get run history'),
@@ -17146,7 +17276,7 @@ var RunsService = /** @class */ (function (_super) {
17146
17276
  var runLocations;
17147
17277
  return __generator(this, function (_c) {
17148
17278
  switch (_c.label) {
17149
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17279
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17150
17280
  route: exports.Routes.GET_RUN_LOCATIONS,
17151
17281
  extractor: runs_consts_1.runsLocationsExtractor,
17152
17282
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to get run locations'),
@@ -17166,7 +17296,7 @@ var RunsService = /** @class */ (function (_super) {
17166
17296
  var runLocations;
17167
17297
  return __generator(this, function (_c) {
17168
17298
  switch (_c.label) {
17169
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17299
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17170
17300
  route: exports.Routes.GET_RUN_CASHOUT,
17171
17301
  extractor: runs_consts_1.runCashoutExtractor,
17172
17302
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to get run cashout'),
@@ -17186,7 +17316,7 @@ var RunsService = /** @class */ (function (_super) {
17186
17316
  var response;
17187
17317
  return __generator(this, function (_c) {
17188
17318
  switch (_c.label) {
17189
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17319
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17190
17320
  route: exports.Routes.ASSIGN_DRIVER,
17191
17321
  extractor: runs_consts_1.defaultExtractor,
17192
17322
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to assign driver to run'),
@@ -17207,7 +17337,7 @@ var RunsService = /** @class */ (function (_super) {
17207
17337
  var response;
17208
17338
  return __generator(this, function (_c) {
17209
17339
  switch (_c.label) {
17210
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17340
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17211
17341
  route: exports.Routes.UNASSIGN_DRIVER,
17212
17342
  extractor: runs_consts_1.defaultExtractor,
17213
17343
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to assign driver to run'),
@@ -17228,7 +17358,7 @@ var RunsService = /** @class */ (function (_super) {
17228
17358
  var response;
17229
17359
  return __generator(this, function (_c) {
17230
17360
  switch (_c.label) {
17231
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17361
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17232
17362
  route: exports.Routes.ASSIGN_VEHICLES,
17233
17363
  extractor: runs_consts_1.defaultExtractor,
17234
17364
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to assign vehicles to run'),
@@ -17249,7 +17379,7 @@ var RunsService = /** @class */ (function (_super) {
17249
17379
  var response;
17250
17380
  return __generator(this, function (_c) {
17251
17381
  switch (_c.label) {
17252
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17382
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17253
17383
  route: exports.Routes.UNASSIGN_VEHICLES,
17254
17384
  extractor: runs_consts_1.defaultExtractor,
17255
17385
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to unassign vehicles from run'),
@@ -17270,7 +17400,7 @@ var RunsService = /** @class */ (function (_super) {
17270
17400
  var runBulkClose;
17271
17401
  return __generator(this, function (_c) {
17272
17402
  switch (_c.label) {
17273
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17403
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17274
17404
  route: exports.Routes.BULK_CLOSE,
17275
17405
  extractor: runs_consts_1.defaultExtractor,
17276
17406
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to bulk close runs'),
@@ -17290,7 +17420,7 @@ var RunsService = /** @class */ (function (_super) {
17290
17420
  var markDonePlanning;
17291
17421
  return __generator(this, function (_c) {
17292
17422
  switch (_c.label) {
17293
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17423
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17294
17424
  route: exports.Routes.MARK_DONE_PLANNING,
17295
17425
  extractor: runs_consts_1.defaultExtractor,
17296
17426
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to mark done planning for runs'),
@@ -17310,7 +17440,7 @@ var RunsService = /** @class */ (function (_super) {
17310
17440
  var actualBreaksByRunIdResponse;
17311
17441
  return __generator(this, function (_c) {
17312
17442
  switch (_c.label) {
17313
- case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
17443
+ case 0: return [4 /*yield*/, this.service.handleAuthorizedRequest({
17314
17444
  route: exports.Routes.GET_ACTUAL_BREAKS,
17315
17445
  extractor: runs_consts_1.defaultExtractor,
17316
17446
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to get actual breaks of runs'),
@@ -17327,7 +17457,7 @@ var RunsService = /** @class */ (function (_super) {
17327
17457
  });
17328
17458
  };
17329
17459
  return RunsService;
17330
- }(SessionBasedService_1.SessionBasedService));
17460
+ }());
17331
17461
  exports.RunsService = RunsService;
17332
17462
  //# sourceMappingURL=runs.service.js.map
17333
17463
 
@@ -17378,7 +17508,6 @@ var RunStore = /** @class */ (function (_super) {
17378
17508
  _this.updateRun = function (payload) {
17379
17509
  return _this.createOrUpdateRun(payload, _this.onUpdate.bind(_this));
17380
17510
  };
17381
- // eslint-disable-next-line @typescript-eslint/ban-types
17382
17511
  _this.createOrUpdateRun = function (payload, callback) {
17383
17512
  var existingRunModel = _this.store.getItem(payload.run.id);
17384
17513
  var updatedRunModel = { id: payload.run.id, run: payload.run, taskIds: undefined };
@@ -17514,7 +17643,7 @@ exports["default"] = RunStore;
17514
17643
  "use strict";
17515
17644
 
17516
17645
  Object.defineProperty(exports, "__esModule", ({ value: true }));
17517
- 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;
17518
17647
  var RunStatus;
17519
17648
  (function (RunStatus) {
17520
17649
  RunStatus["ALL"] = "all";
@@ -17527,6 +17656,10 @@ var RunEvents;
17527
17656
  RunEvents["DELETED"] = "run deleted";
17528
17657
  RunEvents["CREATED"] = "run created";
17529
17658
  })(RunEvents = exports.RunEvents || (exports.RunEvents = {}));
17659
+ var RunGroupTypes;
17660
+ (function (RunGroupTypes) {
17661
+ RunGroupTypes["TaskIds"] = "taskIds";
17662
+ })(RunGroupTypes = exports.RunGroupTypes || (exports.RunGroupTypes = {}));
17530
17663
  var runExtractor = function (response) { return response.run; };
17531
17664
  exports.runExtractor = runExtractor;
17532
17665
  var runsHistoryExtractor = function (response) { return response; };
@@ -17674,7 +17807,7 @@ var Runs = /** @class */ (function () {
17674
17807
  var run;
17675
17808
  return __generator(this, function (_a) {
17676
17809
  switch (_a.label) {
17677
- case 0: return [4 /*yield*/, this.runsService.get(id, commonOptions)];
17810
+ case 0: return [4 /*yield*/, this.runsService.load(id, commonOptions)];
17678
17811
  case 1:
17679
17812
  run = _a.sent();
17680
17813
  return [2 /*return*/, this.runStore.set(run)];
@@ -17687,7 +17820,7 @@ var Runs = /** @class */ (function () {
17687
17820
  return __awaiter(this, void 0, void 0, function () {
17688
17821
  return __generator(this, function (_a) {
17689
17822
  switch (_a.label) {
17690
- case 0: return [4 /*yield*/, this.runsService.get(id, commonOptions)];
17823
+ case 0: return [4 /*yield*/, this.runsService.load(id, commonOptions)];
17691
17824
  case 1: return [2 /*return*/, _a.sent()];
17692
17825
  }
17693
17826
  });
@@ -17832,6 +17965,165 @@ exports["default"] = Runs;
17832
17965
 
17833
17966
  /***/ }),
17834
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
+
17835
18127
  /***/ 83582:
17836
18128
  /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
17837
18129
 
@@ -17885,56 +18177,82 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
17885
18177
  }
17886
18178
  };
17887
18179
  Object.defineProperty(exports, "__esModule", ({ value: true }));
18180
+ var BringgDashboardSDK_1 = __webpack_require__(5655);
18181
+ var data_entity_1 = __webpack_require__(91083);
17888
18182
  var data_store_1 = __webpack_require__(73135);
17889
- var realtime_subscriptions_1 = __webpack_require__(47985);
18183
+ var storable_data_service_1 = __webpack_require__(45297);
17890
18184
  var runs_consts_1 = __webpack_require__(4669);
17891
18185
  var runs_service_1 = __webpack_require__(34075);
18186
+ var run_realtime_subscriptions_1 = __webpack_require__(30196);
17892
18187
  var RunsApi = /** @class */ (function () {
17893
18188
  function RunsApi(session) {
17894
18189
  var _this = this;
17895
- this.createOrUpdateRun = function (payload) {
17896
- _this.runsStore.set(payload.run);
18190
+ this.onUpdate = function (callback) {
18191
+ return _this.realtimeSubscriptions.onUpdate(callback);
18192
+ };
18193
+ this.onDelete = function (callback) {
18194
+ return _this.realtimeSubscriptions.onDelete(callback);
17897
18195
  };
17898
- this.deleteRun = function (payload) {
17899
- _this.runsStore.remove(payload.id);
18196
+ this.onCreate = function (callback) {
18197
+ return _this.realtimeSubscriptions.onCreate(callback);
17900
18198
  };
17901
- 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
+ ]);
17902
18205
  this.runsService = new runs_service_1.RunsService(session);
17903
- this.realtimeSubscriptions = new realtime_subscriptions_1.default(session);
17904
- this.realtimeSubscriptions.subscribe(runs_consts_1.RunEvents.CREATED, this.createOrUpdateRun);
17905
- this.realtimeSubscriptions.subscribe(runs_consts_1.RunEvents.UPDATED, this.createOrUpdateRun);
17906
- 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);
17907
18224
  }
18225
+ RunsApi.prototype.updateStoreOnEvents = function () {
18226
+ this.realtimeSubscriptions.updateStoreOnEvents();
18227
+ };
18228
+ RunsApi.prototype.get = function (id) {
18229
+ return this.runsStore.get(id);
18230
+ };
17908
18231
  RunsApi.prototype.getAll = function () {
17909
18232
  return this.runsStore.getAll();
17910
18233
  };
18234
+ RunsApi.prototype.getAllMap = function () {
18235
+ return this.runsStore.getAllById();
18236
+ };
17911
18237
  RunsApi.prototype.getByIds = function (ids) {
17912
18238
  var _this = this;
17913
- return ids.map(function (runId) { return _this.runsStore.get(runId); });
18239
+ return ids.map(function (runId) { return _this.runsStore.get(runId); }).filter(Boolean);
18240
+ };
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);
17914
18246
  };
17915
- RunsApi.prototype.loadAll = function (options, commonOptions) {
18247
+ RunsApi.prototype.loadMany = function (queryParams, options, commonOptions) {
18248
+ if (options === void 0) { options = data_entity_1.DEFAULT_OPTIONS; }
17916
18249
  if (commonOptions === void 0) { commonOptions = {}; }
17917
18250
  return __awaiter(this, void 0, void 0, function () {
17918
- var idsToFetch, runs_1, runs;
17919
18251
  var _this = this;
17920
18252
  return __generator(this, function (_a) {
17921
- switch (_a.label) {
17922
- case 0:
17923
- if (!options.ids) return [3 /*break*/, 3];
17924
- idsToFetch = options.ids.filter(function (id) { return !_this.runsStore.get(id); });
17925
- if (!idsToFetch.length) return [3 /*break*/, 2];
17926
- return [4 /*yield*/, this.runsService.loadAll(__assign(__assign({}, options), { ids: idsToFetch }), commonOptions)];
17927
- case 1:
17928
- runs_1 = _a.sent();
17929
- this.runsStore.setMany(runs_1.map(function (run) { return ({ current: run }); }));
17930
- _a.label = 2;
17931
- case 2: return [2 /*return*/, this.getByIds(options.ids)];
17932
- case 3: return [4 /*yield*/, this.runsService.loadAll(options, commonOptions)];
17933
- case 4:
17934
- runs = _a.sent();
17935
- this.runsStore.setAll(runs.map(function (run) { return ({ current: run }); }));
17936
- return [2 /*return*/, runs];
17937
- }
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)];
17938
18256
  });
17939
18257
  });
17940
18258
  };
@@ -17949,6 +18267,130 @@ var RunsApi = /** @class */ (function () {
17949
18267
  });
17950
18268
  });
17951
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
+ };
17952
18394
  return RunsApi;
17953
18395
  }());
17954
18396
  exports["default"] = RunsApi;
@@ -20212,7 +20654,7 @@ var lodash_1 = __webpack_require__(96486);
20212
20654
  var BringgException_1 = __webpack_require__(43605);
20213
20655
  var Logger_1 = __webpack_require__(55860);
20214
20656
  var abort_1 = __webpack_require__(34179);
20215
- var version = '8.18.3';
20657
+ var version = '8.20.0-pre.1';
20216
20658
  function logErrorResponse(response) {
20217
20659
  var data = response.data, status = response.status;
20218
20660
  try {
@@ -22495,151 +22937,90 @@ exports.Routes = {
22495
22937
  /***/ }),
22496
22938
 
22497
22939
  /***/ 52131:
22498
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
22940
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
22499
22941
 
22500
22942
  "use strict";
22501
22943
 
22502
- var __values = (this && this.__values) || function(o) {
22503
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
22504
- if (m) return m.call(o);
22505
- if (o && typeof o.length === "number") return {
22506
- next: function () {
22507
- if (o && i >= o.length) o = void 0;
22508
- return { value: o && o[i++], done: !o };
22509
- }
22510
- };
22511
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
22512
- };
22513
22944
  Object.defineProperty(exports, "__esModule", ({ value: true }));
22514
- var object_merger_1 = __webpack_require__(7262);
22515
- var realtime_subscriptions_1 = __webpack_require__(47985);
22945
+ var storable_realtime_subscriptions_1 = __webpack_require__(1227);
22516
22946
  var Tasks_consts_1 = __webpack_require__(24976);
22517
22947
  var TaskRealtimeSubscriptions = /** @class */ (function () {
22518
22948
  function TaskRealtimeSubscriptions(session, tasksStore, storableDataService) {
22519
- this.realtimeSubscriptions = new realtime_subscriptions_1.default(session);
22520
22949
  this.tasksStore = tasksStore;
22521
- this.storableDataService = storableDataService;
22522
- this.eventCallbacks = {};
22950
+ this.storableRealtimeSubscriptions = new storable_realtime_subscriptions_1.default(session, tasksStore, storableDataService);
22523
22951
  }
22524
22952
  TaskRealtimeSubscriptions.prototype.updateStoreOnEvents = function () {
22525
22953
  var _this = this;
22526
- var ignoreFields = ['way_points'];
22527
- this.realtimeSubscriptions.subscribe(Tasks_consts_1.TaskRealTimeEvents.TASK_UPDATE, function (task) {
22528
- var isPartialUpdate = !task.hasOwnProperty('status');
22529
- if (isPartialUpdate && !_this.tasksStore.get(task.id)) {
22530
- return;
22531
- }
22532
- var mappedStorableItem = _this.storableDataService.updateInStores(task);
22533
- _this.runEventCallbacks(Tasks_consts_1.TaskRealTimeEvents.TASK_UPDATE, mappedStorableItem);
22534
- });
22535
- this.realtimeSubscriptions.subscribe(Tasks_consts_1.TaskRealTimeEvents.NEW_TASK, function (task) {
22536
- var mappedStorableItem = _this.storableDataService.updateInStores(task);
22537
- _this.runEventCallbacks(Tasks_consts_1.TaskRealTimeEvents.NEW_TASK, mappedStorableItem);
22538
- });
22539
- this.realtimeSubscriptions.subscribe(Tasks_consts_1.TaskRealTimeEvents.TASK_DELETED, function (task) {
22540
- var deletedTasks = _this.storableDataService.removeFromStores(task.id);
22541
- _this.runEventCallbacks(Tasks_consts_1.TaskRealTimeEvents.TASK_DELETED, { diff: deletedTasks });
22542
- });
22543
- [
22544
- { event: Tasks_consts_1.TaskRealTimeEvents.NEW_SCAN, field: 'scans', isDelete: false },
22545
- { event: Tasks_consts_1.TaskRealTimeEvents.NEW_NOTE, field: 'task_notes', isDelete: false },
22546
- { event: Tasks_consts_1.TaskRealTimeEvents.WAYPOINT_ADDED, field: 'way_points', isDelete: false },
22547
- { event: Tasks_consts_1.TaskRealTimeEvents.WAYPOINT_UPDATED, field: 'way_points', isDelete: false },
22548
- { event: Tasks_consts_1.TaskRealTimeEvents.WAYPOINT_DELETED, field: 'way_points', isDelete: true }
22549
- ].forEach(function (eventData) {
22550
- _this.realtimeSubscriptions.subscribe(eventData.event, function (subEntity) {
22551
- ignoreFields.forEach(function (field) { return delete subEntity[field]; });
22552
- var eventChangeData = _this.changeSubEntity(subEntity, eventData.field, eventData.isDelete);
22553
- if (eventChangeData.current) {
22554
- _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) };
22555
22961
  }
22556
- });
22557
- });
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);
22558
23009
  };
22559
23010
  TaskRealtimeSubscriptions.prototype.onCreate = function (callback) {
22560
- return this.onEvent(Tasks_consts_1.TaskRealTimeEvents.NEW_TASK, callback);
23011
+ return this.storableRealtimeSubscriptions.onEvent(Tasks_consts_1.TaskRealTimeEvents.NEW_TASK, callback);
22561
23012
  };
22562
23013
  TaskRealtimeSubscriptions.prototype.onDelete = function (callback) {
22563
- return this.onEvent(Tasks_consts_1.TaskRealTimeEvents.TASK_DELETED, callback);
23014
+ return this.storableRealtimeSubscriptions.onEvent(Tasks_consts_1.TaskRealTimeEvents.TASK_DELETED, callback);
22564
23015
  };
22565
23016
  TaskRealtimeSubscriptions.prototype.onWayPointUpdate = function (callback) {
22566
- return this.onEvent(Tasks_consts_1.TaskRealTimeEvents.WAYPOINT_UPDATED, callback);
23017
+ return this.storableRealtimeSubscriptions.onEvent(Tasks_consts_1.TaskRealTimeEvents.WAYPOINT_UPDATED, callback);
22567
23018
  };
22568
23019
  TaskRealtimeSubscriptions.prototype.onWayPointDelete = function (callback) {
22569
- return this.onEvent(Tasks_consts_1.TaskRealTimeEvents.WAYPOINT_DELETED, callback);
23020
+ return this.storableRealtimeSubscriptions.onEvent(Tasks_consts_1.TaskRealTimeEvents.WAYPOINT_DELETED, callback);
22570
23021
  };
22571
23022
  TaskRealtimeSubscriptions.prototype.onUpdate = function (callback) {
22572
- var subscriptions = [];
22573
- subscriptions.push(this.onEvent(Tasks_consts_1.TaskRealTimeEvents.TASK_UPDATE, callback));
22574
- return function () {
22575
- var e_1, _a;
22576
- try {
22577
- for (var subscriptions_1 = __values(subscriptions), subscriptions_1_1 = subscriptions_1.next(); !subscriptions_1_1.done; subscriptions_1_1 = subscriptions_1.next()) {
22578
- var subscription = subscriptions_1_1.value;
22579
- subscription();
22580
- }
22581
- }
22582
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
22583
- finally {
22584
- try {
22585
- if (subscriptions_1_1 && !subscriptions_1_1.done && (_a = subscriptions_1.return)) _a.call(subscriptions_1);
22586
- }
22587
- finally { if (e_1) throw e_1.error; }
22588
- }
22589
- };
22590
- };
22591
- TaskRealtimeSubscriptions.prototype.onEvent = function (event, callback) {
22592
- var _this = this;
22593
- if (!this.eventCallbacks[event]) {
22594
- this.eventCallbacks[event] = [];
22595
- }
22596
- this.eventCallbacks[event].push(callback);
22597
- return function () {
22598
- var indexOfCallback = _this.eventCallbacks[event].indexOf(callback);
22599
- _this.eventCallbacks[event].splice(indexOfCallback, 1);
22600
- };
22601
- };
22602
- TaskRealtimeSubscriptions.prototype.runEventCallbacks = function (event, data) {
22603
- (this.eventCallbacks[event] || []).forEach(function (callback) { return callback(data); });
22604
- };
22605
- TaskRealtimeSubscriptions.prototype.changeSubEntity = function (subEntity, containerField, isDelete) {
22606
- var _a, _b, _c;
22607
- if (isDelete === void 0) { isDelete = false; }
22608
- var task = this.tasksStore.get(subEntity.task_id);
22609
- var diff;
22610
- if (task) {
22611
- if (!task[containerField]) {
22612
- task[containerField] = [];
22613
- }
22614
- var existingIndex = task[containerField].findIndex(function (taskSubEntity) { return taskSubEntity.id === subEntity.id; });
22615
- if (existingIndex > -1) {
22616
- if (isDelete) {
22617
- diff = (_a = { id: task.id }, _a[containerField] = this.createArrayOfEmptyObjects(existingIndex), _a);
22618
- for (var i = existingIndex + 1; i < task[containerField].length; i++) {
22619
- diff[containerField].push(task[containerField][i]);
22620
- }
22621
- task[containerField].splice(existingIndex, 1);
22622
- }
22623
- else {
22624
- var subEntityDiff = object_merger_1.objectMerger.deepMerge(task[containerField][existingIndex], subEntity);
22625
- diff = (_b = {
22626
- id: task.id
22627
- },
22628
- _b[containerField] = this.createArrayOfEmptyObjects(task[containerField].length),
22629
- _b);
22630
- diff[containerField][existingIndex] = subEntityDiff;
22631
- }
22632
- }
22633
- else if (!isDelete) {
22634
- diff = (_c = { id: task.id }, _c[containerField] = this.createArrayOfEmptyObjects(task[containerField].length), _c);
22635
- diff[containerField].push(subEntity);
22636
- task[containerField].push(subEntity);
22637
- }
22638
- }
22639
- return { current: task, diff: diff };
22640
- };
22641
- TaskRealtimeSubscriptions.prototype.createArrayOfEmptyObjects = function (length) {
22642
- return Array.from({ length: length }, function () { return ({}); });
23023
+ return this.storableRealtimeSubscriptions.onEvent(Tasks_consts_1.TaskRealTimeEvents.TASK_UPDATE, callback);
22643
23024
  };
22644
23025
  return TaskRealtimeSubscriptions;
22645
23026
  }());
@@ -27549,8 +27930,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
27549
27930
  }
27550
27931
  };
27551
27932
  Object.defineProperty(exports, "__esModule", ({ value: true }));
27933
+ var storable_realtime_subscriptions_1 = __webpack_require__(1227);
27552
27934
  var data_store_1 = __webpack_require__(73135);
27553
- var realtime_subscriptions_1 = __webpack_require__(47985);
27554
27935
  var storable_data_service_1 = __webpack_require__(45297);
27555
27936
  var Vehicle_consts_1 = __webpack_require__(84010);
27556
27937
  var vehicles_service_1 = __webpack_require__(87386);
@@ -27560,11 +27941,10 @@ var VehiclesApi = /** @class */ (function () {
27560
27941
  { groupType: Vehicle_consts_1.VehicleGroup.Team, keyFunc: function (vehicle) { return vehicle.team_id; } },
27561
27942
  { groupType: Vehicle_consts_1.VehicleGroup.IsTrailer, keyFunc: function (vehicle) { return !!vehicle.is_trailer; } }
27562
27943
  ];
27563
- this.eventCallbacks = {};
27564
27944
  this.vehiclesStore = new data_store_1.default(groupFilters);
27565
27945
  this.vehiclesService = new vehicles_service_1.default(session);
27566
27946
  this.storableDataService = new storable_data_service_1.default(this.vehiclesStore);
27567
- this.realtimeSubscriptions = new realtime_subscriptions_1.default(session);
27947
+ this.storableRealtimeSubscriptions = new storable_realtime_subscriptions_1.default(session, this.vehiclesStore, this.storableDataService);
27568
27948
  }
27569
27949
  VehiclesApi.prototype.load = function (id, options) {
27570
27950
  var _this = this;
@@ -27591,24 +27971,21 @@ var VehiclesApi = /** @class */ (function () {
27591
27971
  return this.storableDataService.modify('create', function () { return _this.vehiclesService.create(vehicleData); });
27592
27972
  };
27593
27973
  VehiclesApi.prototype.updateStoreOnEvents = function () {
27594
- var _this = this;
27595
- this.realtimeSubscriptions.subscribe(Vehicle_consts_1.REAL_TIME_EVENTS.VEHICLE_UPDATE, function (vehicle) {
27596
- _this.storableDataService.updateInStores(vehicle);
27597
- _this.runEventCallbacks(Vehicle_consts_1.REAL_TIME_EVENTS.VEHICLE_UPDATE, vehicle);
27598
- });
27599
- this.realtimeSubscriptions.subscribe(Vehicle_consts_1.REAL_TIME_EVENTS.VEHICLE_DELETE, function (vehicle) {
27600
- _this.storableDataService.removeFromStores(vehicle.id);
27601
- _this.runEventCallbacks(Vehicle_consts_1.REAL_TIME_EVENTS.VEHICLE_DELETE, vehicle);
27602
- });
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
+ ]);
27603
27978
  };
27604
27979
  VehiclesApi.prototype.onUpdate = function (callback) {
27605
- 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); });
27606
27981
  };
27607
27982
  VehiclesApi.prototype.onDelete = function (callback) {
27608
- 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); });
27609
27984
  };
27610
27985
  VehiclesApi.prototype.onUnassigned = function (callback) {
27611
- 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
+ });
27612
27989
  };
27613
27990
  VehiclesApi.prototype.get = function (id) {
27614
27991
  return this.vehiclesStore.get(id);
@@ -27648,20 +28025,6 @@ var VehiclesApi = /** @class */ (function () {
27648
28025
  });
27649
28026
  });
27650
28027
  };
27651
- VehiclesApi.prototype.runEventCallbacks = function (event, data) {
27652
- (this.eventCallbacks[event] || []).forEach(function (callback) { return callback(data); });
27653
- };
27654
- VehiclesApi.prototype.onEvent = function (event, callback) {
27655
- var _this = this;
27656
- if (!this.eventCallbacks[event]) {
27657
- this.eventCallbacks[event] = [];
27658
- }
27659
- this.eventCallbacks[event].push(callback);
27660
- return function () {
27661
- var indexOfCallback = _this.eventCallbacks[event].indexOf(callback);
27662
- _this.eventCallbacks[event].splice(indexOfCallback, 1);
27663
- };
27664
- };
27665
28028
  return VehiclesApi;
27666
28029
  }());
27667
28030
  exports["default"] = VehiclesApi;
@@ -29360,6 +29723,17 @@ exports["default"] = { build: build };
29360
29723
 
29361
29724
  "use strict";
29362
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
+ };
29363
29737
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
29364
29738
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
29365
29739
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -29433,7 +29807,7 @@ var StorableDataService = /** @class */ (function () {
29433
29807
  return [4 /*yield*/, loadFunc(loadFnIdsParams)];
29434
29808
  case 1:
29435
29809
  items = _a.sent();
29436
- mappedItems_1 = items.map(function (item) { return _this.mapper(item, action); });
29810
+ mappedItems_1 = items.map(function (item) { return _this.mapper(item, { action: action }); });
29437
29811
  if (options.groupType) {
29438
29812
  this.dataStore.setGroup(options.groupType, groupValue, mappedItems_1);
29439
29813
  }
@@ -29461,7 +29835,7 @@ var StorableDataService = /** @class */ (function () {
29461
29835
  return [4 /*yield*/, loadFunc(ids)];
29462
29836
  case 1:
29463
29837
  items = _a.sent();
29464
- mappedItems_2 = items.map(function (item) { return _this.mapper(item, action); });
29838
+ mappedItems_2 = items.map(function (item) { return _this.mapper(item, { action: action }); });
29465
29839
  this.dataStore.setMany(mappedItems_2);
29466
29840
  this.extraDataStores.forEach(function (dataStore) { return dataStore.setMany(mappedItems_2, options.fields); });
29467
29841
  return [2 /*return*/, mappedItems_2.map(function (mappedItems) { return mappedItems.current; })];
@@ -29543,13 +29917,13 @@ var StorableDataService = /** @class */ (function () {
29543
29917
  });
29544
29918
  });
29545
29919
  };
29546
- StorableDataService.prototype.updateInStores = function (item, action, fields) {
29547
- 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];
29548
29922
  };
29549
- StorableDataService.prototype.updateManyInStores = function (items, action, fields) {
29923
+ StorableDataService.prototype.updateManyInStores = function (items, action, fields, extraMapperParams) {
29550
29924
  var _this = this;
29551
29925
  return (0, BringgDashboardSDK_1.getGlobals)().mobx.runInAction(function () {
29552
- 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)); });
29553
29927
  _this.dataStore.setMany(clientItems);
29554
29928
  _this.extraDataStores.forEach(function (dataStore) { return dataStore.setMany(clientItems, fields); });
29555
29929
  return clientItems;