@bringg/dashboard-sdk 10.2.3-pre.2 → 10.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/Customer/Customer.consts.d.ts +0 -2
  2. package/dist/Customer/Customer.consts.js +1 -3
  3. package/dist/Customer/Customer.consts.js.map +1 -1
  4. package/dist/Customer/v2/customers-api.d.ts +0 -6
  5. package/dist/Customer/v2/customers-api.js +3 -18
  6. package/dist/Customer/v2/customers-api.js.map +1 -1
  7. package/dist/Data/merge-mapper.d.ts +2 -2
  8. package/dist/Data/merge-mapper.js.map +1 -1
  9. package/dist/Data/storable-realtime-subscriptions.d.ts +2 -2
  10. package/dist/Data/storable-realtime-subscriptions.js.map +1 -1
  11. package/dist/Vehicle/Vehicle.consts.d.ts +23 -0
  12. package/dist/Vehicle/Vehicle.consts.js.map +1 -1
  13. package/dist/Vehicle/v2/vehicles-api.d.ts +10 -2
  14. package/dist/Vehicle/v2/vehicles-api.js +8 -0
  15. package/dist/Vehicle/v2/vehicles-api.js.map +1 -1
  16. package/dist/Vehicle/v2/vehicles-service.d.ts +2 -2
  17. package/dist/Vehicle/v2/vehicles-service.js +7 -1
  18. package/dist/Vehicle/v2/vehicles-service.js.map +1 -1
  19. package/dist/bringg-dashboard-sdk-cjs2.js +20 -269
  20. package/dist/bringg-dashboard-sdk-cjs2.js.map +1 -1
  21. package/dist/bringg-dashboard-sdk.js +5 -27
  22. package/dist/bringg-dashboard-sdk.min.js +1 -1
  23. package/dist/bringg-dashboard-sdk.min.js.map +1 -1
  24. package/dist/index.d.ts +1 -1
  25. package/dist/index.js.map +1 -1
  26. package/dist/storable-data-service.d.ts +2 -2
  27. package/dist/storable-data-service.js.map +1 -1
  28. package/package.json +2 -2
  29. package/dist/Data/data-store-with-signals.d.ts +0 -33
  30. package/dist/Data/data-store-with-signals.js +0 -80
  31. package/dist/Data/data-store-with-signals.js.map +0 -1
  32. package/dist/Data/item-change-signals.d.ts +0 -27
  33. package/dist/Data/item-change-signals.js +0 -152
  34. package/dist/Data/item-change-signals.js.map +0 -1
  35. package/dist/Data/main-data-store.d.ts +0 -11
  36. package/dist/Data/main-data-store.js +0 -3
  37. package/dist/Data/main-data-store.js.map +0 -1
@@ -8300,15 +8300,13 @@ exports["default"] = CustomAttributesEntity;
8300
8300
  "use strict";
8301
8301
 
8302
8302
  Object.defineProperty(exports, "__esModule", ({ value: true }));
8303
- exports.WAYPOINT_CUSTOMER_FROM_STORE_FF = exports.RealtimeEvents = void 0;
8303
+ exports.RealtimeEvents = void 0;
8304
8304
  var RealtimeEvents;
8305
8305
  (function (RealtimeEvents) {
8306
8306
  RealtimeEvents["Created"] = "customer created";
8307
8307
  RealtimeEvents["Updated"] = "customer update";
8308
8308
  RealtimeEvents["Deleted"] = "customer delete";
8309
8309
  })(RealtimeEvents = exports.RealtimeEvents || (exports.RealtimeEvents = {}));
8310
- /** Feature flag of the waypoint customer from the customers store (bringg-frontend, Angular, dashboard-sdk). */
8311
- exports.WAYPOINT_CUSTOMER_FROM_STORE_FF = 'enable_waypoint_customer_from_store';
8312
8310
  //# sourceMappingURL=Customer.consts.js.map
8313
8311
 
8314
8312
  /***/ }),
@@ -8370,10 +8368,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
8370
8368
  };
8371
8369
  Object.defineProperty(exports, "__esModule", ({ value: true }));
8372
8370
  var lodash_1 = __importDefault(__webpack_require__(96486));
8373
- var data_store_with_signals_1 = __importDefault(__webpack_require__(56692));
8374
8371
  var merge_mapper_1 = __webpack_require__(59200);
8375
8372
  var storable_realtime_subscriptions_1 = __importDefault(__webpack_require__(1227));
8376
8373
  var data_entity_1 = __webpack_require__(91083);
8374
+ var data_store_1 = __importDefault(__webpack_require__(73135));
8377
8375
  var storable_data_service_1 = __importDefault(__webpack_require__(45297));
8378
8376
  var array_utils_1 = __webpack_require__(43052);
8379
8377
  var Customer_consts_1 = __webpack_require__(85240);
@@ -8381,8 +8379,7 @@ var customers_service_1 = __importDefault(__webpack_require__(52639));
8381
8379
  var CustomersApi = /** @class */ (function () {
8382
8380
  function CustomersApi(session) {
8383
8381
  var _this = this;
8384
- this.session = session;
8385
- this.customersStore = new data_store_with_signals_1.default('customersStore');
8382
+ this.customersStore = new data_store_1.default(undefined, { shallow: true });
8386
8383
  this.customersService = new customers_service_1.default(session);
8387
8384
  this.storableDataService = new storable_data_service_1.default(this.customersStore, function (customer) {
8388
8385
  return merge_mapper_1.mergeMapper.mergeIntoExisting(_this.customersStore, customer);
@@ -8401,18 +8398,8 @@ var CustomersApi = /** @class */ (function () {
8401
8398
  CustomersApi.prototype.onCreate = function (callback) {
8402
8399
  return this.storableRealtimeSubscriptions.onEvent(Customer_consts_1.RealtimeEvents.Created, function (item) { return callback(item.current); });
8403
8400
  };
8404
- /**
8405
- * Self-push: Angular pushes back the stored customer object after the tasks merge changed it in place, so the merge
8406
- * finds no diff and `set` reports the change. Cost: every such push re-renders that customer's views even with no
8407
- * change. Remove it with the Angular pushes once customer realtime events and this flag are on.
8408
- */
8409
8401
  CustomersApi.prototype.add = function (customer) {
8410
- var isSelfPush = this.customersStore.allItems[customer.id] === customer;
8411
- var mapped = this.storableDataService.updateInStores(customer);
8412
- if (isSelfPush && isWaypointCustomerFromStoreEnabled(this.session)) {
8413
- this.customersStore.set(customer);
8414
- }
8415
- return mapped;
8402
+ return this.storableDataService.updateInStores(customer);
8416
8403
  };
8417
8404
  CustomersApi.prototype.getAll = function () {
8418
8405
  return this.customersStore.getAll();
@@ -8493,10 +8480,6 @@ var CustomersApi = /** @class */ (function () {
8493
8480
  return CustomersApi;
8494
8481
  }());
8495
8482
  exports["default"] = CustomersApi;
8496
- function isWaypointCustomerFromStoreEnabled(session) {
8497
- var _a, _b;
8498
- return Boolean((_b = (_a = session.user) === null || _a === void 0 ? void 0 : _a.feature_flags) === null || _b === void 0 ? void 0 : _b[Customer_consts_1.WAYPOINT_CUSTOMER_FROM_STORE_FF]);
8499
- }
8500
8483
  //# sourceMappingURL=customers-api.js.map
8501
8484
 
8502
8485
  /***/ }),
@@ -8996,252 +8979,6 @@ exports["default"] = Dashboard;
8996
8979
 
8997
8980
  /***/ }),
8998
8981
 
8999
- /***/ 56692:
9000
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
9001
-
9002
- "use strict";
9003
-
9004
- var __importDefault = (this && this.__importDefault) || function (mod) {
9005
- return (mod && mod.__esModule) ? mod : { "default": mod };
9006
- };
9007
- Object.defineProperty(exports, "__esModule", ({ value: true }));
9008
- var data_store_1 = __importDefault(__webpack_require__(73135));
9009
- var item_change_signals_1 = __importDefault(__webpack_require__(5508));
9010
- /**
9011
- * A shallow `DataStore` whose MobX reactions re-run when an item they read is added, changed or removed.
9012
- * Items stay plain objects. Readers report what they read, writers fire the signals, the inner store holds the data.
9013
- */
9014
- var DataStoreWithSignals = /** @class */ (function () {
9015
- /**
9016
- * @param storeId - Store name for the MobX atom names, for example `customersStore`
9017
- * @param groupFilters - Passed to the inner `DataStore`
9018
- */
9019
- function DataStoreWithSignals(storeId, groupFilters) {
9020
- if (groupFilters === void 0) { groupFilters = []; }
9021
- this.store = new data_store_1.default(groupFilters, { shallow: true });
9022
- this.signals = new item_change_signals_1.default(storeId);
9023
- }
9024
- Object.defineProperty(DataStoreWithSignals.prototype, "allItems", {
9025
- /** The inner items by id. Reading it subscribes nothing: use it in writers, never in views. */
9026
- get: function () {
9027
- return this.store.allItems;
9028
- },
9029
- enumerable: false,
9030
- configurable: true
9031
- });
9032
- DataStoreWithSignals.prototype.get = function (id) {
9033
- this.signals.observe(id);
9034
- return this.store.get(id);
9035
- };
9036
- DataStoreWithSignals.prototype.getAll = function () {
9037
- this.signals.observeAll();
9038
- return this.store.getAll();
9039
- };
9040
- DataStoreWithSignals.prototype.getGroup = function (group, groupValue) {
9041
- this.signals.observeAll();
9042
- return this.store.getGroup(group, groupValue);
9043
- };
9044
- DataStoreWithSignals.prototype.isGroupInitialized = function (groupType, groupValue) {
9045
- return this.store.isGroupInitialized(groupType, groupValue);
9046
- };
9047
- DataStoreWithSignals.prototype.set = function (item) {
9048
- this.store.set(item);
9049
- this.signals.notify([item.id]);
9050
- };
9051
- DataStoreWithSignals.prototype.remove = function (id) {
9052
- this.store.remove(id);
9053
- this.signals.notify([id]);
9054
- };
9055
- DataStoreWithSignals.prototype.setMany = function (items) {
9056
- this.store.setMany(items);
9057
- this.signals.notify(items.filter(isChanged).map(function (item) { return item.current.id; }));
9058
- };
9059
- DataStoreWithSignals.prototype.setAll = function (items) {
9060
- this.store.setAll(items);
9061
- this.signals.notifyAllObserved();
9062
- };
9063
- DataStoreWithSignals.prototype.setGroup = function (groupType, groupValue, items) {
9064
- this.store.setGroup(groupType, groupValue, items);
9065
- this.signals.notifyAllObserved();
9066
- };
9067
- Object.defineProperty(DataStoreWithSignals.prototype, "observedItemsCount", {
9068
- /** @internal Number of items that reactions observe right now. For tests. */
9069
- get: function () {
9070
- return this.signals.observedCount;
9071
- },
9072
- enumerable: false,
9073
- configurable: true
9074
- });
9075
- return DataStoreWithSignals;
9076
- }());
9077
- exports["default"] = DataStoreWithSignals;
9078
- // No diff = a new item. An empty diff = nothing changed.
9079
- function isChanged(item) {
9080
- return !item.diff || Object.keys(item.diff).length > 0;
9081
- }
9082
- //# sourceMappingURL=data-store-with-signals.js.map
9083
-
9084
- /***/ }),
9085
-
9086
- /***/ 5508:
9087
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
9088
-
9089
- "use strict";
9090
-
9091
- var __values = (this && this.__values) || function(o) {
9092
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
9093
- if (m) return m.call(o);
9094
- if (o && typeof o.length === "number") return {
9095
- next: function () {
9096
- if (o && i >= o.length) o = void 0;
9097
- return { value: o && o[i++], done: !o };
9098
- }
9099
- };
9100
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
9101
- };
9102
- Object.defineProperty(exports, "__esModule", ({ value: true }));
9103
- var BringgDashboardSDK_1 = __webpack_require__(5655);
9104
- /**
9105
- * Per-item change signals for a shallow DataStore: a reaction that reads an id re-runs when that id changes.
9106
- * Id signals live only while a reaction reads them; other reads watch `anyChange`, so no change is lost (mobx >= 6.7).
9107
- * Uses only the MobX instance passed at login, so the host app's reactions track it.
9108
- */
9109
- var ItemChangeSignals = /** @class */ (function () {
9110
- /** @param storeId - Store name for the MobX atom names (devtools and spy only), for example `customersStore`. */
9111
- function ItemChangeSignals(storeId) {
9112
- this.storeId = storeId;
9113
- // Keyed by Number(id): stores accept number-like string ids too.
9114
- this.atoms = new Map();
9115
- }
9116
- /** Reports a read of `id`. Subscribes the current reaction to changes of that id. */
9117
- ItemChangeSignals.prototype.observe = function (id) {
9118
- if (id === undefined || id === null || !getMobx()) {
9119
- return;
9120
- }
9121
- id = Number(id);
9122
- // Cheap filter, the probe never fires: false for a read outside any derivation, so no per-id atom is created on the
9123
- // hot path. Such a read reports only the shared `anyChange` atom.
9124
- if (!this.getProbe().reportObserved()) {
9125
- this.getAnyChange().reportObserved();
9126
- return;
9127
- }
9128
- var atom = this.atoms.get(id);
9129
- var isNew = !atom;
9130
- if (isNew) {
9131
- atom = this.createAtom(id);
9132
- }
9133
- // Exact check: false for a new atom read by a computed evaluated inside an action (no reaction behind it).
9134
- // MobX never calls the unobserve callback of such an atom, so it would leak; watch `anyChange` instead.
9135
- if (!atom.reportObserved()) {
9136
- if (isNew) {
9137
- this.atoms.delete(id);
9138
- }
9139
- this.getAnyChange().reportObserved();
9140
- }
9141
- };
9142
- /** Reports a read of the whole store (list readers). Subscribes the current reaction to every change. */
9143
- ItemChangeSignals.prototype.observeAll = function () {
9144
- if (getMobx()) {
9145
- this.getAnyChange().reportObserved();
9146
- }
9147
- };
9148
- /** Reports a change of each id, in one MobX action, then fires `anyChange` once. */
9149
- ItemChangeSignals.prototype.notify = function (ids) {
9150
- var _this = this;
9151
- if (!ids.length || !this.hasBeenRead()) {
9152
- return;
9153
- }
9154
- getMobx().runInAction(function () {
9155
- var e_1, _a;
9156
- var _b;
9157
- try {
9158
- for (var ids_1 = __values(ids), ids_1_1 = ids_1.next(); !ids_1_1.done; ids_1_1 = ids_1.next()) {
9159
- var id = ids_1_1.value;
9160
- (_b = _this.atoms.get(Number(id))) === null || _b === void 0 ? void 0 : _b.reportChanged();
9161
- }
9162
- }
9163
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
9164
- finally {
9165
- try {
9166
- if (ids_1_1 && !ids_1_1.done && (_a = ids_1.return)) _a.call(ids_1);
9167
- }
9168
- finally { if (e_1) throw e_1.error; }
9169
- }
9170
- _this.getAnyChange().reportChanged();
9171
- });
9172
- };
9173
- /** Reports a change of every observed id (a store reload or a bulk remove). */
9174
- ItemChangeSignals.prototype.notifyAllObserved = function () {
9175
- var _this = this;
9176
- if (!this.hasBeenRead()) {
9177
- return;
9178
- }
9179
- getMobx().runInAction(function () {
9180
- var e_2, _a;
9181
- try {
9182
- for (var _b = __values(_this.atoms.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
9183
- var atom = _c.value;
9184
- atom.reportChanged();
9185
- }
9186
- }
9187
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
9188
- finally {
9189
- try {
9190
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
9191
- }
9192
- finally { if (e_2) throw e_2.error; }
9193
- }
9194
- _this.getAnyChange().reportChanged();
9195
- });
9196
- };
9197
- Object.defineProperty(ItemChangeSignals.prototype, "observedCount", {
9198
- /** Number of live id atoms. For tests only. */
9199
- get: function () {
9200
- return this.atoms.size;
9201
- },
9202
- enumerable: false,
9203
- configurable: true
9204
- });
9205
- // False until the first read: before it, no reaction can be watching.
9206
- ItemChangeSignals.prototype.hasBeenRead = function () {
9207
- return Boolean(this.anyChange) || this.atoms.size > 0;
9208
- };
9209
- ItemChangeSignals.prototype.createAtom = function (id) {
9210
- var _this = this;
9211
- // The callback reads `atom` only when MobX calls it, at the end of a batch after the last observer left,
9212
- // never during `createAtom`.
9213
- var atom = getMobx().createAtom("".concat(this.storeId, ".item.").concat(id), undefined, function () {
9214
- if (_this.atoms.get(id) === atom) {
9215
- _this.atoms.delete(id);
9216
- }
9217
- });
9218
- this.atoms.set(id, atom);
9219
- return atom;
9220
- };
9221
- ItemChangeSignals.prototype.getProbe = function () {
9222
- if (!this.probe) {
9223
- this.probe = getMobx().createAtom("".concat(this.storeId, ".probe"));
9224
- }
9225
- return this.probe;
9226
- };
9227
- ItemChangeSignals.prototype.getAnyChange = function () {
9228
- if (!this.anyChange) {
9229
- this.anyChange = getMobx().createAtom("".concat(this.storeId, ".anyChange"));
9230
- }
9231
- return this.anyChange;
9232
- };
9233
- return ItemChangeSignals;
9234
- }());
9235
- exports["default"] = ItemChangeSignals;
9236
- // Null before login (globals are set by `BringgDashboardSDK.login`): no MobX, so no reaction can observe anything.
9237
- function getMobx() {
9238
- var _a;
9239
- return (_a = (0, BringgDashboardSDK_1.getGlobals)()) === null || _a === void 0 ? void 0 : _a.mobx;
9240
- }
9241
- //# sourceMappingURL=item-change-signals.js.map
9242
-
9243
- /***/ }),
9244
-
9245
8982
  /***/ 93670:
9246
8983
  /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
9247
8984
 
@@ -25494,7 +25231,7 @@ var BringgException_1 = __webpack_require__(43605);
25494
25231
  var client_page_1 = __webpack_require__(16573);
25495
25232
  var Logger_1 = __importDefault(__webpack_require__(55860));
25496
25233
  var abort_1 = __webpack_require__(34179);
25497
- var version = '10.2.3-pre.2';
25234
+ var version = '10.3.0';
25498
25235
  function logErrorResponse(response) {
25499
25236
  var data = response.data, status = response.status;
25500
25237
  try {
@@ -33917,6 +33654,14 @@ var VehiclesApi = /** @class */ (function () {
33917
33654
  var _this = this;
33918
33655
  return this.storableDataService.modify('update', function () { return _this.vehiclesService.update(id, vehicleData); });
33919
33656
  };
33657
+ /**
33658
+ * Updates many vehicles in one request. Does not update the store.
33659
+ * @param vehicles - Vehicles to update, each with its `id`
33660
+ * @returns Resolves when 1 or more vehicles are saved; `errors` lists the vehicles that failed
33661
+ * (empty when all are saved)
33662
+ * @throws {BringgException} When no vehicle is saved: `errors` holds the server errors.
33663
+ * On an HTTP or network error it has no `errors`; `statusCode` is set when the server answered.
33664
+ */
33920
33665
  VehiclesApi.prototype.batchUpdate = function (vehicles) {
33921
33666
  return this.vehiclesService.batchUpdate(vehicles);
33922
33667
  };
@@ -34137,7 +33882,13 @@ var VehiclesService = /** @class */ (function () {
34137
33882
  .patch(VehicleEntity_1.Routes.BATCH_UPDATE)
34138
33883
  .withPayload({ vehicles: vehicles })
34139
33884
  .setException('failed to batch update vehicles')
34140
- .withExtractor(Vehicle_consts_1.vehiclesExtractor)
33885
+ .withExtractor(function (response) {
33886
+ var _a;
33887
+ return ({
33888
+ success: response.success,
33889
+ errors: (_a = response.errors) !== null && _a !== void 0 ? _a : []
33890
+ });
33891
+ })
34141
33892
  .invoke()];
34142
33893
  case 1: return [2 /*return*/, _a.sent()];
34143
33894
  }