@bringg/dashboard-sdk 4.2.3 → 4.3.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.
@@ -35589,7 +35589,7 @@ var Logger_1 = __webpack_require__(48);
35589
35589
  var lodash_1 = __webpack_require__(11);
35590
35590
  var BringgException_1 = __webpack_require__(15);
35591
35591
  var abort_1 = __webpack_require__(169);
35592
- var version = '4.2.3';
35592
+ var version = '4.3.1';
35593
35593
  function logErrorResponse(response) {
35594
35594
  var data = response.data, status = response.status;
35595
35595
  try {
@@ -44814,6 +44814,15 @@ var TasksApi = /** @class */ (function () {
44814
44814
  TasksApi.prototype.onCreate = function (callback) {
44815
44815
  this.taskRealtimeSubscriptions.onCreate(callback);
44816
44816
  };
44817
+ TasksApi.prototype.onDelete = function (callback) {
44818
+ this.taskRealtimeSubscriptions.onDelete(callback);
44819
+ };
44820
+ TasksApi.prototype.onWayPointUpdate = function (callback) {
44821
+ this.taskRealtimeSubscriptions.onWayPointUpdate(callback);
44822
+ };
44823
+ TasksApi.prototype.onWayPointDelete = function (callback) {
44824
+ this.taskRealtimeSubscriptions.onWayPointDelete(callback);
44825
+ };
44817
44826
  TasksApi.prototype.get = function (id, fields) {
44818
44827
  return this.getMany([id], this.getFieldsToLoad(fields))[0];
44819
44828
  };
@@ -44826,6 +44835,11 @@ var TasksApi = /** @class */ (function () {
44826
44835
  TasksApi.prototype.getAllById = function () {
44827
44836
  return this.tasksStore.getAllById();
44828
44837
  };
44838
+ TasksApi.prototype.load = function (id, options) {
44839
+ var _this = this;
44840
+ if (options === void 0) { options = data_entity_1.DEFAULT_OPTIONS; }
44841
+ return this.storableDataService.load('load', function () { return _this.tasksService.load(id); }, id, options);
44842
+ };
44829
44843
  TasksApi.prototype.loadMany = function (ids, fields, options) {
44830
44844
  if (options === void 0) { options = data_entity_1.DEFAULT_OPTIONS; }
44831
44845
  return __awaiter(this, void 0, void 0, function () {
@@ -44893,6 +44907,76 @@ var TasksApi = /** @class */ (function () {
44893
44907
  TasksApi.prototype.massUnassign = function (taskIds, options) {
44894
44908
  return this.tasksService.massUnassign(taskIds, options);
44895
44909
  };
44910
+ TasksApi.prototype.massCancel = function (taskIds, reasonId, text, automaticallyCancelled) {
44911
+ return this.tasksService.massCancel(taskIds, reasonId, text, automaticallyCancelled);
44912
+ };
44913
+ TasksApi.prototype.loadInvalid = function (options) {
44914
+ var _this = this;
44915
+ if (options === void 0) { options = data_entity_1.DEFAULT_OPTIONS; }
44916
+ return this.storableDataService.loadAll('loadInvalid', function () { return _this.tasksService.loadInvalid(); }, __assign(__assign({}, options), { groupType: Tasks_consts_1.TaskGroupTypes.Main, groupValue: Tasks_consts_1.GROUP_VALUES.Invalid }));
44917
+ };
44918
+ TasksApi.prototype.loadClosed = function (options) {
44919
+ var _this = this;
44920
+ if (options === void 0) { options = data_entity_1.DEFAULT_OPTIONS; }
44921
+ return this.storableDataService.loadAll('loadClosed', function () { return _this.tasksService.loadClosed(); }, __assign(__assign({}, options), { groupType: Tasks_consts_1.TaskGroupTypes.Main, groupValue: Tasks_consts_1.GROUP_VALUES.Closed }));
44922
+ };
44923
+ TasksApi.prototype.broadcastToDrivers = function (id, userIds, message) {
44924
+ return this.tasksService.broadcastToDrivers(id, userIds, message);
44925
+ };
44926
+ TasksApi.prototype.acknowledgeTask = function (id) {
44927
+ var _this = this;
44928
+ return this.storableDataService.modify('acknowledgeTask', function () { return _this.tasksService.acknowledgeTask(id); });
44929
+ };
44930
+ TasksApi.prototype.releaseToDrivers = function (ids) {
44931
+ return this.tasksService.releaseToDrivers(ids);
44932
+ };
44933
+ TasksApi.prototype.moveToPlanning = function (ids) {
44934
+ return this.tasksService.moveToPlanning(ids);
44935
+ };
44936
+ TasksApi.prototype.update = function (task) {
44937
+ var _this = this;
44938
+ return this.storableDataService.modify('update', function () { return _this.tasksService.update(task); });
44939
+ };
44940
+ TasksApi.prototype.updatePreparationStatus = function (taskId, preparationStatus) {
44941
+ return this.tasksService.updatePreparationStatus(taskId, preparationStatus);
44942
+ };
44943
+ TasksApi.prototype.rescheduleVirtualTasks = function (taskIds, noLaterThan, noEarlierThan) {
44944
+ return this.tasksService.rescheduleVirtualTasks(taskIds, noLaterThan, noEarlierThan);
44945
+ };
44946
+ TasksApi.prototype.duplicate = function (taskId) {
44947
+ return this.tasksService.duplicate(taskId);
44948
+ };
44949
+ TasksApi.prototype.getChildTasks = function (taskId) {
44950
+ return this.tasksService.getChildTasks(taskId);
44951
+ };
44952
+ TasksApi.prototype.lock = function (taskIds) {
44953
+ return this.tasksService.lock(taskIds);
44954
+ };
44955
+ TasksApi.prototype.unlock = function (taskIds) {
44956
+ return this.tasksService.unlock(taskIds);
44957
+ };
44958
+ TasksApi.prototype.finish = function (id) {
44959
+ var _this = this;
44960
+ return this.storableDataService.modify('finish', function () { return _this.tasksService.finish(id); });
44961
+ };
44962
+ TasksApi.prototype.rescheduleCancelled = function (taskId) {
44963
+ return this.tasksService.rescheduleCancelled(taskId);
44964
+ };
44965
+ TasksApi.prototype.addTaskNote = function (taskId, wayPointId, note, type, image) {
44966
+ return this.tasksService.addTaskNote(taskId, wayPointId, note, type, image);
44967
+ };
44968
+ TasksApi.prototype.getLocations = function (taskId) {
44969
+ return this.tasksService.getLocations(taskId);
44970
+ };
44971
+ TasksApi.prototype.deleteWayPoint = function (taskId, wayPointId) {
44972
+ return this.tasksService.deleteWayPoint(taskId, wayPointId);
44973
+ };
44974
+ TasksApi.prototype.importTasksCsv = function (file) {
44975
+ return this.tasksService.importTasksCsv(file);
44976
+ };
44977
+ TasksApi.prototype.activityLog = function (taskId) {
44978
+ return this.tasksService.activityLog(taskId);
44979
+ };
44896
44980
  TasksApi.prototype.getFieldsToLoad = function (fields) {
44897
44981
  if (!fields) {
44898
44982
  return fields;
@@ -76805,26 +76889,20 @@ var VehicleTypeEntity = /** @class */ (function (_super) {
76805
76889
  };
76806
76890
  VehicleTypeEntity.prototype.createVehicleType = function (vehicle_type) {
76807
76891
  return __awaiter(this, void 0, void 0, function () {
76808
- var response;
76809
76892
  return __generator(this, function (_a) {
76810
76893
  switch (_a.label) {
76811
- case 0: return [4 /*yield*/, this.create(vehicle_type)];
76812
- case 1:
76813
- response = _a.sent();
76814
- return [2 /*return*/, (0, exports.singleExtractor)(response)];
76894
+ case 0: return [4 /*yield*/, this.create(vehicle_type, exports.singleExtractor, exports.singleExtractor)];
76895
+ case 1: return [2 /*return*/, _a.sent()];
76815
76896
  }
76816
76897
  });
76817
76898
  });
76818
76899
  };
76819
76900
  VehicleTypeEntity.prototype.updateVehicleType = function (id, vehicle_type) {
76820
76901
  return __awaiter(this, void 0, void 0, function () {
76821
- var response;
76822
76902
  return __generator(this, function (_a) {
76823
76903
  switch (_a.label) {
76824
- case 0: return [4 /*yield*/, this.update(id, vehicle_type)];
76825
- case 1:
76826
- response = _a.sent();
76827
- return [2 /*return*/, (0, exports.singleExtractor)(response)];
76904
+ case 0: return [4 /*yield*/, this.update(id, vehicle_type, exports.singleExtractor, exports.singleExtractor)];
76905
+ case 1: return [2 /*return*/, _a.sent()];
76828
76906
  }
76829
76907
  });
76830
76908
  });
@@ -93462,6 +93540,18 @@ var CrudService_1 = __webpack_require__(38);
93462
93540
  var Tasks_consts_1 = __webpack_require__(52);
93463
93541
  var TasksService = /** @class */ (function () {
93464
93542
  function TasksService(session) {
93543
+ var _this = this;
93544
+ this.addTaskNote = function (taskId, wayPointId, note, type, image, commonOptions) {
93545
+ return _this.service.routeGenerator
93546
+ .post(Tasks_consts_1.Routes.CREATE_TASK_NOTE)
93547
+ .withRouteParams({ id: taskId, way_point_id: wayPointId })
93548
+ .withQueryString({ note: note })
93549
+ .withPayload({ type: type, image: image })
93550
+ .setException("failed to add note to task : ".concat(taskId))
93551
+ .withExtractor(Tasks_consts_1.taskExtractor)
93552
+ .withCommonOptions(commonOptions)
93553
+ .invoke();
93554
+ };
93465
93555
  this.service = new CrudService_1.default(session, 'tasks');
93466
93556
  }
93467
93557
  TasksService.prototype.load = function (id) {
@@ -93500,6 +93590,62 @@ var TasksService = /** @class */ (function () {
93500
93590
  .withCommonOptions(commonOptions)
93501
93591
  .invoke();
93502
93592
  };
93593
+ TasksService.prototype.loadInvalid = function (commonOptions) {
93594
+ return this.service.routeGenerator
93595
+ .get(Tasks_consts_1.Routes.GET_INVALID_TASKS)
93596
+ .setException("failed to fetch invalid tasks")
93597
+ .withCommonOptions(commonOptions)
93598
+ .invoke();
93599
+ };
93600
+ TasksService.prototype.loadClosed = function (commonOptions) {
93601
+ return this.service.routeGenerator
93602
+ .get(Tasks_consts_1.Routes.GET_CLOSED_TASKS_SINCE_TIMESTAMP)
93603
+ .setException("failed to fetch closed tasks")
93604
+ .withCommonOptions(commonOptions)
93605
+ .invoke();
93606
+ };
93607
+ TasksService.prototype.broadcastToDrivers = function (id, userIds, message, commonOptions) {
93608
+ return this.service.routeGenerator
93609
+ .post(Tasks_consts_1.Routes.BROADCAST_TO_DRIVERS)
93610
+ .withPayload({ task_id: id, user_ids: userIds, message: message })
93611
+ .withCommonOptions(commonOptions)
93612
+ .setException("failed to broadcast to drivers task : ".concat(id))
93613
+ .invoke();
93614
+ };
93615
+ TasksService.prototype.acknowledgeTask = function (id, commonOptions) {
93616
+ return this.service.routeGenerator
93617
+ .post(Tasks_consts_1.Routes.ACKNOWLEDGE_TASK)
93618
+ .withExtractor(Tasks_consts_1.taskExtractor)
93619
+ .setException("failed to acknowledge task - ".concat(id))
93620
+ .withPayload({ task_id: id })
93621
+ .withCommonOptions(commonOptions)
93622
+ .invoke();
93623
+ };
93624
+ TasksService.prototype.releaseToDrivers = function (ids, commonOptions) {
93625
+ return this.service.routeGenerator
93626
+ .post(Tasks_consts_1.Routes.RELEASE_TASKS_TO_DRIVERS)
93627
+ .setException("failed to release tasks [".concat(ids.join(', '), "] to drivers"))
93628
+ .withPayload({ ids: ids })
93629
+ .withCommonOptions(commonOptions)
93630
+ .invoke();
93631
+ };
93632
+ TasksService.prototype.moveToPlanning = function (ids, commonOptions) {
93633
+ return this.service.routeGenerator
93634
+ .post(Tasks_consts_1.Routes.MOVE_TASKS_TO_PLANNING)
93635
+ .setException("failed to move tasks [".concat(ids.join(', '), "] to planning"))
93636
+ .withPayload({ task_ids: ids })
93637
+ .withCommonOptions(commonOptions)
93638
+ .invoke();
93639
+ };
93640
+ TasksService.prototype.massCancel = function (taskIds, reasonId, text, automaticallyCancelled, commonOptions) {
93641
+ return this.service.routeGenerator
93642
+ .post(Tasks_consts_1.Routes.MASS_TASK_CANCEL)
93643
+ .withExtractor(Tasks_consts_1.successExtractor)
93644
+ .setException("failed to cancel tasks [".concat(taskIds.join(', '), "]"))
93645
+ .withPayload({ task_ids: taskIds, reason: reasonId, text: text, automatically_cancelled: automaticallyCancelled })
93646
+ .withCommonOptions(commonOptions)
93647
+ .invoke();
93648
+ };
93503
93649
  TasksService.prototype.massAssign = function (user_id, ids, options, targetRun) {
93504
93650
  return this.service.routeGenerator
93505
93651
  .post(Tasks_consts_1.Routes.MASS_TASK_ASSIGN)
@@ -93516,6 +93662,39 @@ var TasksService = /** @class */ (function () {
93516
93662
  .withCommonOptions(options)
93517
93663
  .invoke();
93518
93664
  };
93665
+ TasksService.prototype.update = function (task) {
93666
+ return __awaiter(this, void 0, void 0, function () {
93667
+ var result;
93668
+ return __generator(this, function (_a) {
93669
+ switch (_a.label) {
93670
+ case 0: return [4 /*yield*/, this.service.update(task.id, task)];
93671
+ case 1:
93672
+ result = _a.sent();
93673
+ return [2 /*return*/, result.task];
93674
+ }
93675
+ });
93676
+ });
93677
+ };
93678
+ TasksService.prototype.updatePreparationStatus = function (taskId, preparationStatus, commonOptions) {
93679
+ return __awaiter(this, void 0, void 0, function () {
93680
+ return __generator(this, function (_a) {
93681
+ return [2 /*return*/, this.service.routeGenerator
93682
+ .post(Tasks_consts_1.Routes.UPDATE_TASK_PREPARATION_STATUS)
93683
+ .setException("failed to update preparation status taskId: ".concat(taskId, ", status: ").concat(preparationStatus))
93684
+ .withPayload({ task_id: taskId, preparation_status: preparationStatus })
93685
+ .withCommonOptions(commonOptions)
93686
+ .invoke()];
93687
+ });
93688
+ });
93689
+ };
93690
+ TasksService.prototype.rescheduleVirtualTasks = function (taskIds, noLaterThan, noEarlierThan) {
93691
+ return this.service.routeGenerator
93692
+ .post(Tasks_consts_1.Routes.RESCHEDULE_VIRTUAL_TASKS)
93693
+ .withExtractor(Tasks_consts_1.taskIdsExtractor)
93694
+ .withPayload({ task_ids: taskIds, no_later_than: noLaterThan, no_earlier_than: noEarlierThan })
93695
+ .setException("failed to get reschedule virtual tasks for tasks : [".concat(taskIds.join(', '), "]"))
93696
+ .invoke();
93697
+ };
93519
93698
  TasksService.prototype.batchLoad = function (ids, fields, options) {
93520
93699
  return __awaiter(this, void 0, void 0, function () {
93521
93700
  return __generator(this, function (_a) {
@@ -93529,6 +93708,92 @@ var TasksService = /** @class */ (function () {
93529
93708
  });
93530
93709
  });
93531
93710
  };
93711
+ TasksService.prototype.duplicate = function (taskId, commonOptions) {
93712
+ return this.service.routeGenerator
93713
+ .post(Tasks_consts_1.Routes.DUPLICATE_TASK)
93714
+ .withExtractor(Tasks_consts_1.taskExtractor)
93715
+ .withPayload({ id: taskId })
93716
+ .setException("failed to duplicate task ".concat(taskId))
93717
+ .withRouteParams({ id: taskId })
93718
+ .withCommonOptions(commonOptions)
93719
+ .invoke();
93720
+ };
93721
+ TasksService.prototype.getChildTasks = function (taskId, commonOptions) {
93722
+ return this.service.routeGenerator
93723
+ .get(Tasks_consts_1.Routes.GET_CHILD_TASKS)
93724
+ .withExtractor(Tasks_consts_1.childTasksExtractor)
93725
+ .withRouteParams({ id: taskId })
93726
+ .setException("failed to get child tasks for task ".concat(taskId))
93727
+ .withCommonOptions(commonOptions)
93728
+ .invoke();
93729
+ };
93730
+ TasksService.prototype.unlock = function (taskIds, commonOptions) {
93731
+ return this.service.routeGenerator
93732
+ .post(Tasks_consts_1.Routes.UNLOCK_TASK)
93733
+ .withExtractor(Tasks_consts_1.successExtractor)
93734
+ .withPayload({ task_ids: taskIds })
93735
+ .setException("failed to unlock the tasks [".concat(taskIds.join(', '), "]"))
93736
+ .withCommonOptions(commonOptions)
93737
+ .invoke();
93738
+ };
93739
+ TasksService.prototype.lock = function (taskIds, commonOptions) {
93740
+ return this.service.routeGenerator
93741
+ .post(Tasks_consts_1.Routes.LOCK_TASK)
93742
+ .withExtractor(Tasks_consts_1.successExtractor)
93743
+ .withPayload({ task_ids: taskIds })
93744
+ .setException("failed to lock the tasks [".concat(taskIds.join(', '), "]"))
93745
+ .withCommonOptions(commonOptions)
93746
+ .invoke();
93747
+ };
93748
+ TasksService.prototype.finish = function (id, commonOptions) {
93749
+ return this.service.routeGenerator
93750
+ .post(Tasks_consts_1.Routes.FINISH_TASK)
93751
+ .withExtractor(Tasks_consts_1.defaultExtractor)
93752
+ .setException("failed to finish task - ".concat(id))
93753
+ .withRouteParams({ id: id })
93754
+ .withCommonOptions(commonOptions)
93755
+ .invoke();
93756
+ };
93757
+ TasksService.prototype.rescheduleCancelled = function (id, commonOptions) {
93758
+ return this.service.routeGenerator
93759
+ .post(Tasks_consts_1.Routes.RESCHEDULE_CANCELED)
93760
+ .withPayload({ id: id })
93761
+ .setException("failed to reschedule cancelled task ".concat(id))
93762
+ .withCommonOptions(commonOptions)
93763
+ .invoke();
93764
+ };
93765
+ TasksService.prototype.getLocations = function (id) {
93766
+ return this.service.routeGenerator
93767
+ .get(Tasks_consts_1.Routes.GET_TASK_LOCATIONS)
93768
+ .withExtractor(Tasks_consts_1.locationExtractor)
93769
+ .withRouteParams({ id: id })
93770
+ .setException("failed to get location of the task ".concat(id))
93771
+ .invoke();
93772
+ };
93773
+ TasksService.prototype.deleteWayPoint = function (taskId, wayPointId) {
93774
+ return this.service.routeGenerator
93775
+ .delete(Tasks_consts_1.Routes.DELETE_WAYPOINT)
93776
+ .withRouteParams({ id: taskId, way_point_id: wayPointId })
93777
+ .setException("failed to delete waypoint : task ".concat(taskId, ", waypoint ").concat(wayPointId))
93778
+ .invoke();
93779
+ };
93780
+ TasksService.prototype.importTasksCsv = function (file) {
93781
+ var formData = new FormData();
93782
+ formData.append('file', file);
93783
+ return this.service.routeGenerator
93784
+ .post(Tasks_consts_1.Routes.IMPORT_TASKS_CSV)
93785
+ .withHeaders({ 'Content-Type': 'multipart/form-data' })
93786
+ .withPayload(formData)
93787
+ .invoke();
93788
+ };
93789
+ TasksService.prototype.activityLog = function (id) {
93790
+ return this.service.routeGenerator
93791
+ .get(Tasks_consts_1.Routes.GET_TASK_ACTIVITY_LOG)
93792
+ .withExtractor(Tasks_consts_1.defaultExtractor)
93793
+ .withRouteParams({ id: id })
93794
+ .setException("failed to get activity log for task ".concat(id))
93795
+ .invoke();
93796
+ };
93532
93797
  return TasksService;
93533
93798
  }());
93534
93799
  exports.default = TasksService;
@@ -107099,24 +107364,16 @@ var TaskRealtimeSubscriptions = /** @class */ (function () {
107099
107364
  });
107100
107365
  };
107101
107366
  TaskRealtimeSubscriptions.prototype.onCreate = function (callback) {
107102
- var subscriptions = [];
107103
- subscriptions.push(this.onEvent(Tasks_consts_1.TaskRealTimeEvents.NEW_TASK, callback));
107104
- return function () {
107105
- var e_1, _a;
107106
- try {
107107
- for (var subscriptions_1 = __values(subscriptions), subscriptions_1_1 = subscriptions_1.next(); !subscriptions_1_1.done; subscriptions_1_1 = subscriptions_1.next()) {
107108
- var subscription = subscriptions_1_1.value;
107109
- subscription();
107110
- }
107111
- }
107112
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
107113
- finally {
107114
- try {
107115
- if (subscriptions_1_1 && !subscriptions_1_1.done && (_a = subscriptions_1.return)) _a.call(subscriptions_1);
107116
- }
107117
- finally { if (e_1) throw e_1.error; }
107118
- }
107119
- };
107367
+ this.onEvent(Tasks_consts_1.TaskRealTimeEvents.NEW_TASK, callback);
107368
+ };
107369
+ TaskRealtimeSubscriptions.prototype.onDelete = function (callback) {
107370
+ this.onEvent(Tasks_consts_1.TaskRealTimeEvents.TASK_DELETED, callback);
107371
+ };
107372
+ TaskRealtimeSubscriptions.prototype.onWayPointUpdate = function (callback) {
107373
+ this.onEvent(Tasks_consts_1.TaskRealTimeEvents.WAYPOINT_UPDATED, callback);
107374
+ };
107375
+ TaskRealtimeSubscriptions.prototype.onWayPointDelete = function (callback) {
107376
+ this.onEvent(Tasks_consts_1.TaskRealTimeEvents.WAYPOINT_DELETED, callback);
107120
107377
  };
107121
107378
  TaskRealtimeSubscriptions.prototype.onUpdate = function (callback) {
107122
107379
  var subscriptions = [];
@@ -107127,19 +107384,19 @@ var TaskRealtimeSubscriptions = /** @class */ (function () {
107127
107384
  subscriptions.push(this.onEvent(Tasks_consts_1.TaskRealTimeEvents.WAYPOINT_ADDED, callback));
107128
107385
  subscriptions.push(this.onEvent(Tasks_consts_1.TaskRealTimeEvents.WAYPOINT_DELETED, callback));
107129
107386
  return function () {
107130
- var e_2, _a;
107387
+ var e_1, _a;
107131
107388
  try {
107132
- for (var subscriptions_2 = __values(subscriptions), subscriptions_2_1 = subscriptions_2.next(); !subscriptions_2_1.done; subscriptions_2_1 = subscriptions_2.next()) {
107133
- var subscription = subscriptions_2_1.value;
107389
+ for (var subscriptions_1 = __values(subscriptions), subscriptions_1_1 = subscriptions_1.next(); !subscriptions_1_1.done; subscriptions_1_1 = subscriptions_1.next()) {
107390
+ var subscription = subscriptions_1_1.value;
107134
107391
  subscription();
107135
107392
  }
107136
107393
  }
107137
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
107394
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
107138
107395
  finally {
107139
107396
  try {
107140
- if (subscriptions_2_1 && !subscriptions_2_1.done && (_a = subscriptions_2.return)) _a.call(subscriptions_2);
107397
+ if (subscriptions_1_1 && !subscriptions_1_1.done && (_a = subscriptions_1.return)) _a.call(subscriptions_1);
107141
107398
  }
107142
- finally { if (e_2) throw e_2.error; }
107399
+ finally { if (e_1) throw e_1.error; }
107143
107400
  }
107144
107401
  };
107145
107402
  };