@bringg/dashboard-sdk 9.13.3 → 9.14.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.
@@ -2676,6 +2676,7 @@ var SkillsApi_1 = __importDefault(__webpack_require__(28855));
2676
2676
  var SpeedFactor_1 = __importDefault(__webpack_require__(89808));
2677
2677
  var SupportTicketApi_1 = __importDefault(__webpack_require__(28002));
2678
2678
  var Tag_1 = __importDefault(__webpack_require__(78847));
2679
+ var tags_api_1 = __importDefault(__webpack_require__(40244));
2679
2680
  var TagCustomerConfiguration_1 = __importDefault(__webpack_require__(87798));
2680
2681
  var TagMerchantConfiguration_1 = __importDefault(__webpack_require__(2889));
2681
2682
  var TaskApi_1 = __importDefault(__webpack_require__(41550));
@@ -2938,6 +2939,7 @@ function init(session) {
2938
2939
  bringg.v2 = {
2939
2940
  vehicles: new vehicles_api_1.default(session),
2940
2941
  tasks: new tasks_api_1.default(session),
2942
+ tags: new tags_api_1.default(session),
2941
2943
  customers: new customers_api_1.default(session),
2942
2944
  plannedDeliveryWindows: new planned_delivery_windows_api_1.default(session),
2943
2945
  optimizationResultApi: new optimization_result_api_1.default(session),
@@ -22367,7 +22369,7 @@ var lodash_1 = __webpack_require__(96486);
22367
22369
  var BringgException_1 = __webpack_require__(43605);
22368
22370
  var Logger_1 = __importDefault(__webpack_require__(55860));
22369
22371
  var abort_1 = __webpack_require__(34179);
22370
- var version = '9.13.3';
22372
+ var version = '9.14.0';
22371
22373
  function logErrorResponse(response) {
22372
22374
  var data = response.data, status = response.status;
22373
22375
  try {
@@ -23568,6 +23570,230 @@ exports["default"] = Tag;
23568
23570
 
23569
23571
  /***/ }),
23570
23572
 
23573
+ /***/ 40244:
23574
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
23575
+
23576
+ "use strict";
23577
+
23578
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
23579
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23580
+ return new (P || (P = Promise))(function (resolve, reject) {
23581
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
23582
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
23583
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23584
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
23585
+ });
23586
+ };
23587
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23588
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23589
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
23590
+ function verb(n) { return function (v) { return step([n, v]); }; }
23591
+ function step(op) {
23592
+ if (f) throw new TypeError("Generator is already executing.");
23593
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
23594
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
23595
+ if (y = 0, t) op = [op[0] & 2, t.value];
23596
+ switch (op[0]) {
23597
+ case 0: case 1: t = op; break;
23598
+ case 4: _.label++; return { value: op[1], done: false };
23599
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23600
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
23601
+ default:
23602
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
23603
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
23604
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
23605
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
23606
+ if (t[2]) _.ops.pop();
23607
+ _.trys.pop(); continue;
23608
+ }
23609
+ op = body.call(thisArg, _);
23610
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
23611
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
23612
+ }
23613
+ };
23614
+ var __rest = (this && this.__rest) || function (s, e) {
23615
+ var t = {};
23616
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
23617
+ t[p] = s[p];
23618
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
23619
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
23620
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
23621
+ t[p[i]] = s[p[i]];
23622
+ }
23623
+ return t;
23624
+ };
23625
+ var __importDefault = (this && this.__importDefault) || function (mod) {
23626
+ return (mod && mod.__esModule) ? mod : { "default": mod };
23627
+ };
23628
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
23629
+ var BringgDashboardSDK_1 = __webpack_require__(5655);
23630
+ var object_merger_1 = __webpack_require__(7262);
23631
+ var data_store_1 = __importDefault(__webpack_require__(73135));
23632
+ var storable_data_service_1 = __importDefault(__webpack_require__(45297));
23633
+ var TagEntity_1 = __importDefault(__webpack_require__(94415));
23634
+ var tagIdGroup = 'tagIds';
23635
+ var TagsApi = /** @class */ (function () {
23636
+ function TagsApi(session) {
23637
+ var _this = this;
23638
+ this.updateConfigurationStore = function (store, tagId, configuration) {
23639
+ if (configuration) {
23640
+ store.set(configuration);
23641
+ }
23642
+ else {
23643
+ _this.removeConfigurationByTagId(store, tagId);
23644
+ }
23645
+ };
23646
+ this.removeAllConfigurationsByTagId = function (tagId) {
23647
+ [
23648
+ _this.tagMerchantConfigurationsStore,
23649
+ _this.tagCustomerConfigurationsStore,
23650
+ _this.tagRulesConfigurationsStore
23651
+ ].forEach(function (store) {
23652
+ _this.removeConfigurationByTagId(store, tagId);
23653
+ });
23654
+ };
23655
+ this.removeConfigurationByTagId = function (store, tagId) {
23656
+ store.getGroup(tagIdGroup, tagId).forEach(function (_a) {
23657
+ var id = _a.id;
23658
+ return store.remove(id);
23659
+ });
23660
+ };
23661
+ this.tagsEntity = new TagEntity_1.default(session);
23662
+ this.tagsStore = new data_store_1.default();
23663
+ this.tagMerchantConfigurationsStore = new data_store_1.default([
23664
+ {
23665
+ groupType: tagIdGroup,
23666
+ keyFunc: function (tagMerchantConfiguration) { return tagMerchantConfiguration.tag_id; }
23667
+ }
23668
+ ]);
23669
+ this.tagCustomerConfigurationsStore = new data_store_1.default([
23670
+ {
23671
+ groupType: tagIdGroup,
23672
+ keyFunc: function (tagCustomerConfiguration) { return tagCustomerConfiguration.tag_id; }
23673
+ }
23674
+ ]);
23675
+ this.tagRulesConfigurationsStore = new data_store_1.default([
23676
+ {
23677
+ groupType: tagIdGroup,
23678
+ keyFunc: function (tagRulesConfiguration) { return tagRulesConfiguration.tag_id; }
23679
+ }
23680
+ ]);
23681
+ var mapper = function (tagConfiguration) {
23682
+ var tagMerchantConfiguration = tagConfiguration.tag_merchant_configuration, tagCustomerConfiguration = tagConfiguration.tag_customer_configuration, tagRulesConfiguration = tagConfiguration.tag_rules_configuration, tagStoreContent = __rest(tagConfiguration, ["tag_merchant_configuration", "tag_customer_configuration", "tag_rules_configuration"]);
23683
+ var existing = _this.tagsStore.get(tagStoreContent.id);
23684
+ _this.updateConfigurationStore(_this.tagMerchantConfigurationsStore, tagStoreContent.id, tagMerchantConfiguration);
23685
+ _this.updateConfigurationStore(_this.tagCustomerConfigurationsStore, tagStoreContent.id, tagCustomerConfiguration);
23686
+ _this.updateConfigurationStore(_this.tagRulesConfigurationsStore, tagStoreContent.id, tagRulesConfiguration);
23687
+ if (existing) {
23688
+ var previous = (0, BringgDashboardSDK_1.getGlobals)().mobx.toJS(existing);
23689
+ var diff = object_merger_1.objectMerger.deepMerge(previous, tagStoreContent);
23690
+ return { current: tagStoreContent, diff: diff };
23691
+ }
23692
+ else {
23693
+ return { current: tagStoreContent };
23694
+ }
23695
+ };
23696
+ this.tagsStorableDataService = new storable_data_service_1.default(this.tagsStore, mapper);
23697
+ }
23698
+ TagsApi.prototype.getTag = function (id) {
23699
+ return this.tagsStore.get(id);
23700
+ };
23701
+ TagsApi.prototype.getTagMerchantConfiguration = function (tagId) {
23702
+ var _a;
23703
+ return (_a = this.tagMerchantConfigurationsStore.getGroup(tagIdGroup, tagId)) === null || _a === void 0 ? void 0 : _a[0];
23704
+ };
23705
+ TagsApi.prototype.getTagCustomerConfiguration = function (tagId) {
23706
+ var _a;
23707
+ return (_a = this.tagCustomerConfigurationsStore.getGroup(tagIdGroup, tagId)) === null || _a === void 0 ? void 0 : _a[0];
23708
+ };
23709
+ TagsApi.prototype.getTagRulesConfiguration = function (tagId) {
23710
+ var _a;
23711
+ return (_a = this.tagRulesConfigurationsStore.getGroup(tagIdGroup, tagId)) === null || _a === void 0 ? void 0 : _a[0];
23712
+ };
23713
+ TagsApi.prototype.loadAll = function () {
23714
+ return __awaiter(this, void 0, void 0, function () {
23715
+ var _this = this;
23716
+ return __generator(this, function (_a) {
23717
+ switch (_a.label) {
23718
+ case 0: return [4 /*yield*/, this.tagsStorableDataService.loadAll('loadAll', function () { return __awaiter(_this, void 0, void 0, function () {
23719
+ var response;
23720
+ return __generator(this, function (_a) {
23721
+ switch (_a.label) {
23722
+ case 0: return [4 /*yield*/, this.tagsEntity.service.getAll()];
23723
+ case 1:
23724
+ response = _a.sent();
23725
+ return [2 /*return*/, response.tags];
23726
+ }
23727
+ });
23728
+ }); })];
23729
+ case 1: return [2 /*return*/, _a.sent()];
23730
+ }
23731
+ });
23732
+ });
23733
+ };
23734
+ TagsApi.prototype.update = function (id, options) {
23735
+ return __awaiter(this, void 0, void 0, function () {
23736
+ var _this = this;
23737
+ return __generator(this, function (_a) {
23738
+ switch (_a.label) {
23739
+ case 0: return [4 /*yield*/, this.tagsStorableDataService.modify('update', function () { return __awaiter(_this, void 0, void 0, function () {
23740
+ var response;
23741
+ return __generator(this, function (_a) {
23742
+ switch (_a.label) {
23743
+ case 0: return [4 /*yield*/, this.tagsEntity.service.update(id, options)];
23744
+ case 1:
23745
+ response = _a.sent();
23746
+ return [2 /*return*/, response.tag];
23747
+ }
23748
+ });
23749
+ }); })];
23750
+ case 1: return [2 /*return*/, _a.sent()];
23751
+ }
23752
+ });
23753
+ });
23754
+ };
23755
+ TagsApi.prototype.create = function (options) {
23756
+ return __awaiter(this, void 0, void 0, function () {
23757
+ var _this = this;
23758
+ return __generator(this, function (_a) {
23759
+ switch (_a.label) {
23760
+ case 0: return [4 /*yield*/, this.tagsStorableDataService.modify('create', function () { return __awaiter(_this, void 0, void 0, function () {
23761
+ var response;
23762
+ return __generator(this, function (_a) {
23763
+ switch (_a.label) {
23764
+ case 0: return [4 /*yield*/, this.tagsEntity.service.create(options)];
23765
+ case 1:
23766
+ response = _a.sent();
23767
+ return [2 /*return*/, response.tag];
23768
+ }
23769
+ });
23770
+ }); })];
23771
+ case 1: return [2 /*return*/, _a.sent()];
23772
+ }
23773
+ });
23774
+ });
23775
+ };
23776
+ TagsApi.prototype.delete = function (id) {
23777
+ return __awaiter(this, void 0, void 0, function () {
23778
+ var _this = this;
23779
+ return __generator(this, function (_a) {
23780
+ switch (_a.label) {
23781
+ case 0: return [4 /*yield*/, this.tagsStorableDataService.delete('delete', function () { return _this.tagsEntity.service.delete(id); }, id)];
23782
+ case 1:
23783
+ _a.sent();
23784
+ this.removeAllConfigurationsByTagId(id);
23785
+ return [2 /*return*/];
23786
+ }
23787
+ });
23788
+ });
23789
+ };
23790
+ return TagsApi;
23791
+ }());
23792
+ exports["default"] = TagsApi;
23793
+ //# sourceMappingURL=tags-api.js.map
23794
+
23795
+ /***/ }),
23796
+
23571
23797
  /***/ 31450:
23572
23798
  /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
23573
23799