@bringg/dashboard-sdk 4.2.3 → 4.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.
@@ -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.0';
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;
@@ -93462,6 +93546,18 @@ var CrudService_1 = __webpack_require__(38);
93462
93546
  var Tasks_consts_1 = __webpack_require__(52);
93463
93547
  var TasksService = /** @class */ (function () {
93464
93548
  function TasksService(session) {
93549
+ var _this = this;
93550
+ this.addTaskNote = function (taskId, wayPointId, note, type, image, commonOptions) {
93551
+ return _this.service.routeGenerator
93552
+ .post(Tasks_consts_1.Routes.CREATE_TASK_NOTE)
93553
+ .withRouteParams({ id: taskId, way_point_id: wayPointId })
93554
+ .withQueryString({ note: note })
93555
+ .withPayload({ type: type, image: image })
93556
+ .setException("failed to add note to task : ".concat(taskId))
93557
+ .withExtractor(Tasks_consts_1.taskExtractor)
93558
+ .withCommonOptions(commonOptions)
93559
+ .invoke();
93560
+ };
93465
93561
  this.service = new CrudService_1.default(session, 'tasks');
93466
93562
  }
93467
93563
  TasksService.prototype.load = function (id) {
@@ -93500,6 +93596,62 @@ var TasksService = /** @class */ (function () {
93500
93596
  .withCommonOptions(commonOptions)
93501
93597
  .invoke();
93502
93598
  };
93599
+ TasksService.prototype.loadInvalid = function (commonOptions) {
93600
+ return this.service.routeGenerator
93601
+ .get(Tasks_consts_1.Routes.GET_INVALID_TASKS)
93602
+ .setException("failed to fetch invalid tasks")
93603
+ .withCommonOptions(commonOptions)
93604
+ .invoke();
93605
+ };
93606
+ TasksService.prototype.loadClosed = function (commonOptions) {
93607
+ return this.service.routeGenerator
93608
+ .get(Tasks_consts_1.Routes.GET_CLOSED_TASKS_SINCE_TIMESTAMP)
93609
+ .setException("failed to fetch closed tasks")
93610
+ .withCommonOptions(commonOptions)
93611
+ .invoke();
93612
+ };
93613
+ TasksService.prototype.broadcastToDrivers = function (id, userIds, message, commonOptions) {
93614
+ return this.service.routeGenerator
93615
+ .post(Tasks_consts_1.Routes.BROADCAST_TO_DRIVERS)
93616
+ .withPayload({ task_id: id, user_ids: userIds, message: message })
93617
+ .withCommonOptions(commonOptions)
93618
+ .setException("failed to broadcast to drivers task : ".concat(id))
93619
+ .invoke();
93620
+ };
93621
+ TasksService.prototype.acknowledgeTask = function (id, commonOptions) {
93622
+ return this.service.routeGenerator
93623
+ .post(Tasks_consts_1.Routes.ACKNOWLEDGE_TASK)
93624
+ .withExtractor(Tasks_consts_1.taskExtractor)
93625
+ .setException("failed to acknowledge task - ".concat(id))
93626
+ .withPayload({ task_id: id })
93627
+ .withCommonOptions(commonOptions)
93628
+ .invoke();
93629
+ };
93630
+ TasksService.prototype.releaseToDrivers = function (ids, commonOptions) {
93631
+ return this.service.routeGenerator
93632
+ .post(Tasks_consts_1.Routes.RELEASE_TASKS_TO_DRIVERS)
93633
+ .setException("failed to release tasks [".concat(ids.join(', '), "] to drivers"))
93634
+ .withPayload({ ids: ids })
93635
+ .withCommonOptions(commonOptions)
93636
+ .invoke();
93637
+ };
93638
+ TasksService.prototype.moveToPlanning = function (ids, commonOptions) {
93639
+ return this.service.routeGenerator
93640
+ .post(Tasks_consts_1.Routes.MOVE_TASKS_TO_PLANNING)
93641
+ .setException("failed to move tasks [".concat(ids.join(', '), "] to planning"))
93642
+ .withPayload({ task_ids: ids })
93643
+ .withCommonOptions(commonOptions)
93644
+ .invoke();
93645
+ };
93646
+ TasksService.prototype.massCancel = function (taskIds, reasonId, text, automaticallyCancelled, commonOptions) {
93647
+ return this.service.routeGenerator
93648
+ .post(Tasks_consts_1.Routes.MASS_TASK_CANCEL)
93649
+ .withExtractor(Tasks_consts_1.successExtractor)
93650
+ .setException("failed to cancel tasks [".concat(taskIds.join(', '), "]"))
93651
+ .withPayload({ task_ids: taskIds, reason: reasonId, text: text, automatically_cancelled: automaticallyCancelled })
93652
+ .withCommonOptions(commonOptions)
93653
+ .invoke();
93654
+ };
93503
93655
  TasksService.prototype.massAssign = function (user_id, ids, options, targetRun) {
93504
93656
  return this.service.routeGenerator
93505
93657
  .post(Tasks_consts_1.Routes.MASS_TASK_ASSIGN)
@@ -93516,6 +93668,39 @@ var TasksService = /** @class */ (function () {
93516
93668
  .withCommonOptions(options)
93517
93669
  .invoke();
93518
93670
  };
93671
+ TasksService.prototype.update = function (task) {
93672
+ return __awaiter(this, void 0, void 0, function () {
93673
+ var result;
93674
+ return __generator(this, function (_a) {
93675
+ switch (_a.label) {
93676
+ case 0: return [4 /*yield*/, this.service.update(task.id, task)];
93677
+ case 1:
93678
+ result = _a.sent();
93679
+ return [2 /*return*/, result.task];
93680
+ }
93681
+ });
93682
+ });
93683
+ };
93684
+ TasksService.prototype.updatePreparationStatus = function (taskId, preparationStatus, commonOptions) {
93685
+ return __awaiter(this, void 0, void 0, function () {
93686
+ return __generator(this, function (_a) {
93687
+ return [2 /*return*/, this.service.routeGenerator
93688
+ .post(Tasks_consts_1.Routes.UPDATE_TASK_PREPARATION_STATUS)
93689
+ .setException("failed to update preparation status taskId: ".concat(taskId, ", status: ").concat(preparationStatus))
93690
+ .withPayload({ task_id: taskId, preparation_status: preparationStatus })
93691
+ .withCommonOptions(commonOptions)
93692
+ .invoke()];
93693
+ });
93694
+ });
93695
+ };
93696
+ TasksService.prototype.rescheduleVirtualTasks = function (taskIds, noLaterThan, noEarlierThan) {
93697
+ return this.service.routeGenerator
93698
+ .post(Tasks_consts_1.Routes.RESCHEDULE_VIRTUAL_TASKS)
93699
+ .withExtractor(Tasks_consts_1.taskIdsExtractor)
93700
+ .withPayload({ task_ids: taskIds, no_later_than: noLaterThan, no_earlier_than: noEarlierThan })
93701
+ .setException("failed to get reschedule virtual tasks for tasks : [".concat(taskIds.join(', '), "]"))
93702
+ .invoke();
93703
+ };
93519
93704
  TasksService.prototype.batchLoad = function (ids, fields, options) {
93520
93705
  return __awaiter(this, void 0, void 0, function () {
93521
93706
  return __generator(this, function (_a) {
@@ -93529,6 +93714,92 @@ var TasksService = /** @class */ (function () {
93529
93714
  });
93530
93715
  });
93531
93716
  };
93717
+ TasksService.prototype.duplicate = function (taskId, commonOptions) {
93718
+ return this.service.routeGenerator
93719
+ .post(Tasks_consts_1.Routes.DUPLICATE_TASK)
93720
+ .withExtractor(Tasks_consts_1.taskExtractor)
93721
+ .withPayload({ id: taskId })
93722
+ .setException("failed to duplicate task ".concat(taskId))
93723
+ .withRouteParams({ id: taskId })
93724
+ .withCommonOptions(commonOptions)
93725
+ .invoke();
93726
+ };
93727
+ TasksService.prototype.getChildTasks = function (taskId, commonOptions) {
93728
+ return this.service.routeGenerator
93729
+ .get(Tasks_consts_1.Routes.GET_CHILD_TASKS)
93730
+ .withExtractor(Tasks_consts_1.childTasksExtractor)
93731
+ .withRouteParams({ id: taskId })
93732
+ .setException("failed to get child tasks for task ".concat(taskId))
93733
+ .withCommonOptions(commonOptions)
93734
+ .invoke();
93735
+ };
93736
+ TasksService.prototype.unlock = function (taskIds, commonOptions) {
93737
+ return this.service.routeGenerator
93738
+ .post(Tasks_consts_1.Routes.UNLOCK_TASK)
93739
+ .withExtractor(Tasks_consts_1.successExtractor)
93740
+ .withPayload({ task_ids: taskIds })
93741
+ .setException("failed to unlock the tasks [".concat(taskIds.join(', '), "]"))
93742
+ .withCommonOptions(commonOptions)
93743
+ .invoke();
93744
+ };
93745
+ TasksService.prototype.lock = function (taskIds, commonOptions) {
93746
+ return this.service.routeGenerator
93747
+ .post(Tasks_consts_1.Routes.LOCK_TASK)
93748
+ .withExtractor(Tasks_consts_1.successExtractor)
93749
+ .withPayload({ task_ids: taskIds })
93750
+ .setException("failed to lock the tasks [".concat(taskIds.join(', '), "]"))
93751
+ .withCommonOptions(commonOptions)
93752
+ .invoke();
93753
+ };
93754
+ TasksService.prototype.finish = function (id, commonOptions) {
93755
+ return this.service.routeGenerator
93756
+ .post(Tasks_consts_1.Routes.FINISH_TASK)
93757
+ .withExtractor(Tasks_consts_1.defaultExtractor)
93758
+ .setException("failed to finish task - ".concat(id))
93759
+ .withRouteParams({ id: id })
93760
+ .withCommonOptions(commonOptions)
93761
+ .invoke();
93762
+ };
93763
+ TasksService.prototype.rescheduleCancelled = function (id, commonOptions) {
93764
+ return this.service.routeGenerator
93765
+ .post(Tasks_consts_1.Routes.RESCHEDULE_CANCELED)
93766
+ .withPayload({ id: id })
93767
+ .setException("failed to reschedule cancelled task ".concat(id))
93768
+ .withCommonOptions(commonOptions)
93769
+ .invoke();
93770
+ };
93771
+ TasksService.prototype.getLocations = function (id) {
93772
+ return this.service.routeGenerator
93773
+ .get(Tasks_consts_1.Routes.GET_TASK_LOCATIONS)
93774
+ .withExtractor(Tasks_consts_1.locationExtractor)
93775
+ .withRouteParams({ id: id })
93776
+ .setException("failed to get location of the task ".concat(id))
93777
+ .invoke();
93778
+ };
93779
+ TasksService.prototype.deleteWayPoint = function (taskId, wayPointId) {
93780
+ return this.service.routeGenerator
93781
+ .delete(Tasks_consts_1.Routes.DELETE_WAYPOINT)
93782
+ .withRouteParams({ id: taskId, way_point_id: wayPointId })
93783
+ .setException("failed to delete waypoint : task ".concat(taskId, ", waypoint ").concat(wayPointId))
93784
+ .invoke();
93785
+ };
93786
+ TasksService.prototype.importTasksCsv = function (file) {
93787
+ var formData = new FormData();
93788
+ formData.append('file', file);
93789
+ return this.service.routeGenerator
93790
+ .post(Tasks_consts_1.Routes.IMPORT_TASKS_CSV)
93791
+ .withHeaders({ 'Content-Type': 'multipart/form-data' })
93792
+ .withPayload(formData)
93793
+ .invoke();
93794
+ };
93795
+ TasksService.prototype.activityLog = function (id) {
93796
+ return this.service.routeGenerator
93797
+ .get(Tasks_consts_1.Routes.GET_TASK_ACTIVITY_LOG)
93798
+ .withExtractor(Tasks_consts_1.defaultExtractor)
93799
+ .withRouteParams({ id: id })
93800
+ .setException("failed to get activity log for task ".concat(id))
93801
+ .invoke();
93802
+ };
93532
93803
  return TasksService;
93533
93804
  }());
93534
93805
  exports.default = TasksService;
@@ -107099,24 +107370,16 @@ var TaskRealtimeSubscriptions = /** @class */ (function () {
107099
107370
  });
107100
107371
  };
107101
107372
  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
- };
107373
+ this.onEvent(Tasks_consts_1.TaskRealTimeEvents.NEW_TASK, callback);
107374
+ };
107375
+ TaskRealtimeSubscriptions.prototype.onDelete = function (callback) {
107376
+ this.onEvent(Tasks_consts_1.TaskRealTimeEvents.TASK_DELETED, callback);
107377
+ };
107378
+ TaskRealtimeSubscriptions.prototype.onWayPointUpdate = function (callback) {
107379
+ this.onEvent(Tasks_consts_1.TaskRealTimeEvents.WAYPOINT_UPDATED, callback);
107380
+ };
107381
+ TaskRealtimeSubscriptions.prototype.onWayPointDelete = function (callback) {
107382
+ this.onEvent(Tasks_consts_1.TaskRealTimeEvents.WAYPOINT_DELETED, callback);
107120
107383
  };
107121
107384
  TaskRealtimeSubscriptions.prototype.onUpdate = function (callback) {
107122
107385
  var subscriptions = [];
@@ -107127,19 +107390,19 @@ var TaskRealtimeSubscriptions = /** @class */ (function () {
107127
107390
  subscriptions.push(this.onEvent(Tasks_consts_1.TaskRealTimeEvents.WAYPOINT_ADDED, callback));
107128
107391
  subscriptions.push(this.onEvent(Tasks_consts_1.TaskRealTimeEvents.WAYPOINT_DELETED, callback));
107129
107392
  return function () {
107130
- var e_2, _a;
107393
+ var e_1, _a;
107131
107394
  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;
107395
+ for (var subscriptions_1 = __values(subscriptions), subscriptions_1_1 = subscriptions_1.next(); !subscriptions_1_1.done; subscriptions_1_1 = subscriptions_1.next()) {
107396
+ var subscription = subscriptions_1_1.value;
107134
107397
  subscription();
107135
107398
  }
107136
107399
  }
107137
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
107400
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
107138
107401
  finally {
107139
107402
  try {
107140
- if (subscriptions_2_1 && !subscriptions_2_1.done && (_a = subscriptions_2.return)) _a.call(subscriptions_2);
107403
+ if (subscriptions_1_1 && !subscriptions_1_1.done && (_a = subscriptions_1.return)) _a.call(subscriptions_1);
107141
107404
  }
107142
- finally { if (e_2) throw e_2.error; }
107405
+ finally { if (e_1) throw e_1.error; }
107143
107406
  }
107144
107407
  };
107145
107408
  };