@bringg/dashboard-sdk 9.0.0 → 9.1.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.
@@ -2754,6 +2754,7 @@ var BringgDashboardSDK = /** @class */ (function () {
2754
2754
  this.vehicleTypes = null;
2755
2755
  this.vehicles = null;
2756
2756
  this.session = session;
2757
+ this.session.sdk = this;
2757
2758
  }
2758
2759
  BringgDashboardSDK.setConfigurations = function (apiEndpointURL, monitorEndpointURL, generalEnvApiEndpoint) {
2759
2760
  configurationProvider.getApiEndpoint = function () { return apiEndpointURL; };
@@ -17859,21 +17860,6 @@ var OptimizationEvents;
17859
17860
 
17860
17861
  "use strict";
17861
17862
 
17862
- var __extends = (this && this.__extends) || (function () {
17863
- var extendStatics = function (d, b) {
17864
- extendStatics = Object.setPrototypeOf ||
17865
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
17866
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
17867
- return extendStatics(d, b);
17868
- };
17869
- return function (d, b) {
17870
- if (typeof b !== "function" && b !== null)
17871
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
17872
- extendStatics(d, b);
17873
- function __() { this.constructor = d; }
17874
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
17875
- };
17876
- })();
17877
17863
  var __assign = (this && this.__assign) || function () {
17878
17864
  __assign = Object.assign || function(t) {
17879
17865
  for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -17885,30 +17871,78 @@ var __assign = (this && this.__assign) || function () {
17885
17871
  };
17886
17872
  return __assign.apply(this, arguments);
17887
17873
  };
17874
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17875
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
17876
+ return new (P || (P = Promise))(function (resolve, reject) {
17877
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17878
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17879
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17880
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
17881
+ });
17882
+ };
17883
+ var __generator = (this && this.__generator) || function (thisArg, body) {
17884
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
17885
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
17886
+ function verb(n) { return function (v) { return step([n, v]); }; }
17887
+ function step(op) {
17888
+ if (f) throw new TypeError("Generator is already executing.");
17889
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17890
+ 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;
17891
+ if (y = 0, t) op = [op[0] & 2, t.value];
17892
+ switch (op[0]) {
17893
+ case 0: case 1: t = op; break;
17894
+ case 4: _.label++; return { value: op[1], done: false };
17895
+ case 5: _.label++; y = op[1]; op = [0]; continue;
17896
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
17897
+ default:
17898
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
17899
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
17900
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
17901
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
17902
+ if (t[2]) _.ops.pop();
17903
+ _.trys.pop(); continue;
17904
+ }
17905
+ op = body.call(thisArg, _);
17906
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
17907
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
17908
+ }
17909
+ };
17910
+ var __rest = (this && this.__rest) || function (s, e) {
17911
+ var t = {};
17912
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
17913
+ t[p] = s[p];
17914
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17915
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17916
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
17917
+ t[p[i]] = s[p[i]];
17918
+ }
17919
+ return t;
17920
+ };
17921
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17922
+ return (mod && mod.__esModule) ? mod : { "default": mod };
17923
+ };
17888
17924
  Object.defineProperty(exports, "__esModule", ({ value: true }));
17889
17925
  var BringgException_1 = __webpack_require__(43605);
17926
+ var CrudService_1 = __importDefault(__webpack_require__(14809));
17890
17927
  var RouteGenerator_1 = __webpack_require__(84075);
17891
17928
  var Route_1 = __webpack_require__(92641);
17892
- var SessionBasedService_1 = __webpack_require__(27826);
17893
- var RouteOptimizationApi = /** @class */ (function (_super) {
17894
- __extends(RouteOptimizationApi, _super);
17929
+ var RouteOptimizationApi = /** @class */ (function () {
17895
17930
  function RouteOptimizationApi(session) {
17896
- var _this = _super.call(this, session.config.getApiEndpoint(), session) || this;
17897
- _this.optimization = new Route_1.Route('/route_optimizations/optimize', 1 /* HttpMethod.POST */);
17898
- _this.optimization_v2 = new Route_1.Route('/own-fleet-optimization-service/route_optimization/optimize', 1 /* HttpMethod.POST */);
17899
- _this.get_optimization_result = new Route_1.Route('/route_optimizations/get_optimization_result/{:request_uuid}', 0 /* HttpMethod.GET */);
17900
- _this.get_optimization_result_v2 = new Route_1.Route('/own-fleet-optimization-service/route_optimization/get_optimization_result/{:request_uuid}', 0 /* HttpMethod.GET */);
17901
- _this.cancel_requests = new Route_1.Route('/route_optimizations/optimization', 4 /* HttpMethod.DELETE */);
17902
- _this.cancel_requests_v2 = new Route_1.Route('/own-fleet-optimization-service/route_optimization/optimization', 4 /* HttpMethod.DELETE */);
17903
- _this.assign_users_by_ids = new Route_1.Route('/route_optimizations/assign_users_by_ids', 1 /* HttpMethod.POST */);
17904
- _this.update_user_modified_data = new Route_1.Route('/route_optimizations/update_user_modified_data', 1 /* HttpMethod.POST */);
17905
- _this.update_user_modified_data_v2 = new Route_1.Route('/own-fleet-optimization-service/route_optimization/update_user_modified_data', 1 /* HttpMethod.POST */);
17906
- _this.assign_user_manual_optimization = new Route_1.Route('/route_optimizations/assign_user_manual_optimization', 1 /* HttpMethod.POST */);
17907
- return _this;
17931
+ this.optimization = new Route_1.Route('/route_optimizations/optimize', 1 /* HttpMethod.POST */);
17932
+ this.optimization_v2 = new Route_1.Route('/own-fleet-optimization-service/route_optimization/optimize', 1 /* HttpMethod.POST */);
17933
+ this.get_optimization_result = new Route_1.Route('/route_optimizations/get_optimization_result/{:request_uuid}', 0 /* HttpMethod.GET */);
17934
+ this.get_optimization_result_v2 = new Route_1.Route('/own-fleet-optimization-service/route_optimization/get_optimization_result/{:request_uuid}', 0 /* HttpMethod.GET */);
17935
+ this.cancel_requests = new Route_1.Route('/route_optimizations/optimization', 4 /* HttpMethod.DELETE */);
17936
+ this.cancel_requests_v2 = new Route_1.Route('/own-fleet-optimization-service/route_optimization/optimization', 4 /* HttpMethod.DELETE */);
17937
+ this.assign_users_by_ids = new Route_1.Route('/route_optimizations/assign_users_by_ids', 1 /* HttpMethod.POST */);
17938
+ this.update_user_modified_data = new Route_1.Route('/route_optimizations/update_user_modified_data', 1 /* HttpMethod.POST */);
17939
+ this.update_user_modified_data_v2 = new Route_1.Route('/own-fleet-optimization-service/route_optimization/update_user_modified_data', 1 /* HttpMethod.POST */);
17940
+ this.assign_user_manual_optimization = new Route_1.Route('/route_optimizations/assign_user_manual_optimization', 1 /* HttpMethod.POST */);
17941
+ this.service = new CrudService_1.default(session, '');
17908
17942
  }
17909
17943
  RouteOptimizationApi.prototype.cancelRequests = function (requestUuids, v2) {
17910
17944
  if (v2 === void 0) { v2 = false; }
17911
- return this.handleAuthorizedRequest({
17945
+ return this.service.handleAuthorizedRequest({
17912
17946
  route: v2 ? this.cancel_requests_v2 : this.cancel_requests,
17913
17947
  extractor: RouteGenerator_1.defaultExtractor,
17914
17948
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to call cancel optimization requests'),
@@ -17917,7 +17951,7 @@ var RouteOptimizationApi = /** @class */ (function (_super) {
17917
17951
  };
17918
17952
  RouteOptimizationApi.prototype.optimize = function (optimizationProps, v2) {
17919
17953
  if (v2 === void 0) { v2 = false; }
17920
- return this.handleAuthorizedRequest({
17954
+ return this.service.handleAuthorizedRequest({
17921
17955
  route: v2 ? this.optimization_v2 : this.optimization,
17922
17956
  extractor: RouteGenerator_1.defaultExtractor,
17923
17957
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to call optimization requests'),
@@ -17926,7 +17960,7 @@ var RouteOptimizationApi = /** @class */ (function (_super) {
17926
17960
  };
17927
17961
  RouteOptimizationApi.prototype.optimizationResult = function (request_uuid, v2) {
17928
17962
  if (v2 === void 0) { v2 = false; }
17929
- return this.handleAuthorizedRequest({
17963
+ return this.service.handleAuthorizedRequest({
17930
17964
  route: v2 ? this.get_optimization_result_v2 : this.get_optimization_result,
17931
17965
  extractor: RouteGenerator_1.defaultExtractor,
17932
17966
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to get optimization results'),
@@ -17934,7 +17968,7 @@ var RouteOptimizationApi = /** @class */ (function (_super) {
17934
17968
  });
17935
17969
  };
17936
17970
  RouteOptimizationApi.prototype.assignUsersByIds = function (teams) {
17937
- return this.handleAuthorizedRequest({
17971
+ return this.service.handleAuthorizedRequest({
17938
17972
  route: this.assign_users_by_ids,
17939
17973
  extractor: RouteGenerator_1.defaultExtractor,
17940
17974
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to assign users by id'),
@@ -17943,7 +17977,7 @@ var RouteOptimizationApi = /** @class */ (function (_super) {
17943
17977
  };
17944
17978
  RouteOptimizationApi.prototype.updateOptimizationModifiedData = function (updateData, v2) {
17945
17979
  if (v2 === void 0) { v2 = false; }
17946
- return this.handleAuthorizedRequest({
17980
+ return this.service.handleAuthorizedRequest({
17947
17981
  route: v2 ? this.update_user_modified_data_v2 : this.update_user_modified_data,
17948
17982
  extractor: RouteGenerator_1.defaultExtractor,
17949
17983
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to update optimization user data'),
@@ -17952,7 +17986,7 @@ var RouteOptimizationApi = /** @class */ (function (_super) {
17952
17986
  };
17953
17987
  RouteOptimizationApi.prototype.assignUserManualOptimization = function (updateData) {
17954
17988
  var fiveMinutesInMs = 1000 * 60 * 5;
17955
- return this.handleAuthorizedRequest({
17989
+ return this.service.handleAuthorizedRequest({
17956
17990
  route: this.assign_user_manual_optimization,
17957
17991
  extractor: RouteGenerator_1.defaultExtractor,
17958
17992
  exceptionProducer: BringgException_1.BringgException.serviceException('Failed to assign user manual optimization data'),
@@ -17960,8 +17994,40 @@ var RouteOptimizationApi = /** @class */ (function (_super) {
17960
17994
  timeout: fiveMinutesInMs
17961
17995
  });
17962
17996
  };
17997
+ RouteOptimizationApi.prototype.calculatePlannedEta = function (data, _a) {
17998
+ if (_a === void 0) { _a = {}; }
17999
+ var _b = _a.timeout, timeout = _b === void 0 ? 10000 : _b, options = __rest(_a, ["timeout"]);
18000
+ return __awaiter(this, void 0, void 0, function () {
18001
+ var payload, result, asyncResult;
18002
+ return __generator(this, function (_c) {
18003
+ switch (_c.label) {
18004
+ case 0:
18005
+ payload = {
18006
+ team_id: data.team_id,
18007
+ data: __assign(__assign({}, data), { deadline: Date.now() + timeout })
18008
+ };
18009
+ return [4 /*yield*/, this.service.routeGenerator
18010
+ .post('/own-fleet-optimization-service/route_optimization/calculate_planned_eta')
18011
+ .withPayload(payload)
18012
+ .setException('Failed to calculate planned eta')
18013
+ .withCommonOptions(options)
18014
+ .invoke()];
18015
+ case 1:
18016
+ result = _c.sent();
18017
+ return [4 /*yield*/, this.service.session.sdk.asyncOperationStatus.waitForResponse({
18018
+ requestId: result.uuid,
18019
+ timeoutInMs: timeout,
18020
+ signal: options.signal
18021
+ })];
18022
+ case 2:
18023
+ asyncResult = _c.sent();
18024
+ return [2 /*return*/, asyncResult.data];
18025
+ }
18026
+ });
18027
+ });
18028
+ };
17963
18029
  return RouteOptimizationApi;
17964
- }(SessionBasedService_1.SessionBasedService));
18030
+ }());
17965
18031
  exports["default"] = RouteOptimizationApi;
17966
18032
  //# sourceMappingURL=RouteOptimizationApi.js.map
17967
18033
 
@@ -21971,7 +22037,7 @@ var lodash_1 = __webpack_require__(96486);
21971
22037
  var BringgException_1 = __webpack_require__(43605);
21972
22038
  var Logger_1 = __importDefault(__webpack_require__(55860));
21973
22039
  var abort_1 = __webpack_require__(34179);
21974
- var version = '9.0.0';
22040
+ var version = '9.1.0';
21975
22041
  function logErrorResponse(response) {
21976
22042
  var data = response.data, status = response.status;
21977
22043
  try {