@bringg/dashboard-sdk 9.78.1 → 9.79.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.
@@ -2839,6 +2839,9 @@ var BringgDashboardSDK = /** @class */ (function () {
2839
2839
  this.taskConfigurations = null;
2840
2840
  this.taskInventory = null;
2841
2841
  this.inventory = null;
2842
+ /**
2843
+ * @deprecated Use `v2.tasks` instead. The v1 Tasks API is deprecated and will be removed in a future major version.
2844
+ */
2842
2845
  this.tasks = null;
2843
2846
  this.teamConfiguration = null;
2844
2847
  this.teams = null;
@@ -12510,10 +12513,12 @@ var LookupService = /** @class */ (function () {
12510
12513
  }
12511
12514
  LookupService.prototype.getUsers = function (query, commonOptions) {
12512
12515
  return __awaiter(this, void 0, void 0, function () {
12516
+ var request;
12513
12517
  return __generator(this, function (_a) {
12514
- return [2 /*return*/, this.service.routeGenerator
12515
- .get(exports.Routes.GET_USERS)
12516
- .withQueryString(query)
12518
+ request = (commonOptions === null || commonOptions === void 0 ? void 0 : commonOptions.method) === 'post'
12519
+ ? this.service.routeGenerator.post(exports.Routes.GET_USERS).withPayload(query)
12520
+ : this.service.routeGenerator.get(exports.Routes.GET_USERS).withQueryString(query);
12521
+ return [2 /*return*/, request
12517
12522
  .setException('Failed to get users from lookup service')
12518
12523
  .withCommonOptions(commonOptions)
12519
12524
  .invoke()];
@@ -12522,22 +12527,23 @@ var LookupService = /** @class */ (function () {
12522
12527
  };
12523
12528
  LookupService.prototype.getRuns = function (query, commonOptions) {
12524
12529
  return __awaiter(this, void 0, void 0, function () {
12530
+ var request;
12525
12531
  return __generator(this, function (_a) {
12526
- return [2 /*return*/, this.service.routeGenerator
12527
- .get(exports.Routes.GET_RUNS)
12528
- .withQueryString(query)
12529
- .setException('Failed to get runs from lookup service')
12530
- .withCommonOptions(commonOptions)
12531
- .invoke()];
12532
+ request = (commonOptions === null || commonOptions === void 0 ? void 0 : commonOptions.method) === 'post'
12533
+ ? this.service.routeGenerator.post(exports.Routes.GET_RUNS).withPayload(query)
12534
+ : this.service.routeGenerator.get(exports.Routes.GET_RUNS).withQueryString(query);
12535
+ return [2 /*return*/, request.setException('Failed to get runs from lookup service').withCommonOptions(commonOptions).invoke()];
12532
12536
  });
12533
12537
  });
12534
12538
  };
12535
12539
  LookupService.prototype.getTasksByExternalId = function (query, commonOptions) {
12536
12540
  return __awaiter(this, void 0, void 0, function () {
12541
+ var request;
12537
12542
  return __generator(this, function (_a) {
12538
- return [2 /*return*/, this.service.routeGenerator
12539
- .get(exports.Routes.GET_TASKS_BY_EXTERNAL_ID)
12540
- .withQueryString(query)
12543
+ request = (commonOptions === null || commonOptions === void 0 ? void 0 : commonOptions.method) === 'post'
12544
+ ? this.service.routeGenerator.post(exports.Routes.GET_TASKS_BY_EXTERNAL_ID).withPayload(query)
12545
+ : this.service.routeGenerator.get(exports.Routes.GET_TASKS_BY_EXTERNAL_ID).withQueryString(query);
12546
+ return [2 /*return*/, request
12541
12547
  .setException('Failed to get tasks by external id from lookup service')
12542
12548
  .withCommonOptions(commonOptions)
12543
12549
  .invoke()];
@@ -12546,10 +12552,12 @@ var LookupService = /** @class */ (function () {
12546
12552
  };
12547
12553
  LookupService.prototype.getTasksTitles = function (query, commonOptions) {
12548
12554
  return __awaiter(this, void 0, void 0, function () {
12555
+ var request;
12549
12556
  return __generator(this, function (_a) {
12550
- return [2 /*return*/, this.service.routeGenerator
12551
- .get(exports.Routes.GET_TASKS_TITLES)
12552
- .withQueryString(query)
12557
+ request = (commonOptions === null || commonOptions === void 0 ? void 0 : commonOptions.method) === 'post'
12558
+ ? this.service.routeGenerator.post(exports.Routes.GET_TASKS_TITLES).withPayload(query)
12559
+ : this.service.routeGenerator.get(exports.Routes.GET_TASKS_TITLES).withQueryString(query);
12560
+ return [2 /*return*/, request
12553
12561
  .setException('Failed to get tasks titles from lookup service')
12554
12562
  .withCommonOptions(commonOptions)
12555
12563
  .invoke()];
@@ -12558,10 +12566,12 @@ var LookupService = /** @class */ (function () {
12558
12566
  };
12559
12567
  LookupService.prototype.getPlannedRoutes = function (query, commonOptions) {
12560
12568
  return __awaiter(this, void 0, void 0, function () {
12569
+ var request;
12561
12570
  return __generator(this, function (_a) {
12562
- return [2 /*return*/, this.service.routeGenerator
12563
- .get(exports.Routes.GET_PLANNED_ROUTES)
12564
- .withQueryString(query)
12571
+ request = (commonOptions === null || commonOptions === void 0 ? void 0 : commonOptions.method) === 'post'
12572
+ ? this.service.routeGenerator.post(exports.Routes.GET_PLANNED_ROUTES).withPayload(query)
12573
+ : this.service.routeGenerator.get(exports.Routes.GET_PLANNED_ROUTES).withQueryString(query);
12574
+ return [2 /*return*/, request
12565
12575
  .setException('Failed to get planned routes from lookup service')
12566
12576
  .withCommonOptions(commonOptions)
12567
12577
  .invoke()];
@@ -23848,7 +23858,7 @@ var lodash_1 = __webpack_require__(96486);
23848
23858
  var BringgException_1 = __webpack_require__(43605);
23849
23859
  var Logger_1 = __importDefault(__webpack_require__(55860));
23850
23860
  var abort_1 = __webpack_require__(34179);
23851
- var version = '9.78.1';
23861
+ var version = '9.79.1';
23852
23862
  function logErrorResponse(response) {
23853
23863
  var data = response.data, status = response.status;
23854
23864
  try {
@@ -26176,6 +26186,10 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
26176
26186
  var TaskEntity_1 = __importDefault(__webpack_require__(56130));
26177
26187
  var TaskHelpers_1 = __webpack_require__(73119);
26178
26188
  var Tasks_consts_1 = __webpack_require__(24976);
26189
+ /**
26190
+ * @deprecated The v1 Tasks API is deprecated. Use the v2 Tasks API instead (`sdk.v2.tasks`, see `src/Task/v2/tasks-api.ts`).
26191
+ * This class is kept only for backwards compatibility and will be removed in a future major version.
26192
+ */
26179
26193
  var Tasks = /** @class */ (function () {
26180
26194
  function Tasks(session) {
26181
26195
  var _this = this;
@@ -31382,7 +31396,7 @@ var __values = (this && this.__values) || function(o) {
31382
31396
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
31383
31397
  };
31384
31398
  Object.defineProperty(exports, "__esModule", ({ value: true }));
31385
- exports.RealtimeEvents = exports.userToGroupsMapper = exports.groupFilter = exports.GROUP_VALUES = exports.UserGroupTypes = exports.UserEvents = exports.ROUTES = exports.baseRoute = exports.successExtractor = exports.countExtractor = exports.usersExtractor = exports.userExtractor = exports.defaultExtractor = exports.UsersScopes = void 0;
31399
+ exports.RealtimeEvents = exports.userToGroupsMapper = exports.groupFilter = exports.GROUP_VALUES = exports.UserGroupTypes = exports.UserEvents = exports.ROUTES = exports.ENABLE_USER_GROUPS_CACHE_FEATURE_FLAG = exports.baseRoute = exports.successExtractor = exports.countExtractor = exports.usersExtractor = exports.userExtractor = exports.defaultExtractor = exports.UsersScopes = void 0;
31386
31400
  var UserHelpers_1 = __webpack_require__(2450);
31387
31401
  var UsersScopes;
31388
31402
  (function (UsersScopes) {
@@ -31403,6 +31417,7 @@ exports.countExtractor = countExtractor;
31403
31417
  var successExtractor = function (response) { return response.success; };
31404
31418
  exports.successExtractor = successExtractor;
31405
31419
  exports.baseRoute = '/users';
31420
+ exports.ENABLE_USER_GROUPS_CACHE_FEATURE_FLAG = 'enable_user_groups_cache';
31406
31421
  exports.ROUTES = {
31407
31422
  GET_ALL: exports.baseRoute,
31408
31423
  GET_DRIVERS_BY_TEAM: '/teams/{:teamId}/users',
@@ -31903,6 +31918,11 @@ var users_service_1 = __importDefault(__webpack_require__(38267));
31903
31918
  var UsersApi = /** @class */ (function () {
31904
31919
  function UsersApi(session) {
31905
31920
  var _this = this;
31921
+ this.session = session;
31922
+ // The next_page_cursors that continue an admins+dispatchers pagination which began at cursor=nil.
31923
+ // Server cursors are unique per run, so this stays correct across concurrent runs, and only a run
31924
+ // traceable back to a fresh start ever marks the collection cached (a mid-collection caller can't).
31925
+ this.adminsAndDispatchersFreshPagingCursors = new Set();
31906
31926
  var groupFilters = [
31907
31927
  {
31908
31928
  groupType: User_consts_1.UserGroupTypes.Main,
@@ -32119,11 +32139,25 @@ var UsersApi = /** @class */ (function () {
32119
32139
  UsersApi.prototype.getAllAdminsAndDispatchers = function (_a) {
32120
32140
  var _b = _a.limit, limit = _b === void 0 ? 25 : _b, _c = _a.page_action, page_action = _c === void 0 ? keyset_pagination_consts_1.KeysetPaginationPageAction.NEXT : _c, cursor = _a.cursor, options = _a.options;
32121
32141
  return __awaiter(this, void 0, void 0, function () {
32122
- var loadResult, loadFunc, users;
32142
+ var cacheEnabled, isFreshPagingRun, loadResult, loadFunc, users;
32123
32143
  var _this = this;
32124
32144
  return __generator(this, function (_d) {
32125
32145
  switch (_d.label) {
32126
32146
  case 0:
32147
+ cacheEnabled = this.isUserGroupsCacheEnabled();
32148
+ // A fresh load (no cursor) with the collection fully paged serves the store's Admins+Dispatchers
32149
+ // groups instead of refetching. Only members already in the store surface, so a user promoted into
32150
+ // the set from another session appears on the next uncached load. skipCache forces a server round
32151
+ // trip (e.g. a refetch after a mutation) while still re-warming the store below.
32152
+ if (cacheEnabled && !(options === null || options === void 0 ? void 0 : options.skipCache) && (0, lodash_1.isNil)(cursor) && this.isAdminsAndDispatchersCached()) {
32153
+ return [2 /*return*/, {
32154
+ users: this.userStore.getGroup(User_consts_1.UserGroupTypes.Main, [User_consts_1.GROUP_VALUES.Admins, User_consts_1.GROUP_VALUES.Dispatchers])
32155
+ }];
32156
+ }
32157
+ isFreshPagingRun = cacheEnabled && ((0, lodash_1.isNil)(cursor) || this.adminsAndDispatchersFreshPagingCursors.has(cursor));
32158
+ if (!(0, lodash_1.isNil)(cursor)) {
32159
+ this.adminsAndDispatchersFreshPagingCursors.delete(cursor);
32160
+ }
32127
32161
  loadFunc = function () { return __awaiter(_this, void 0, void 0, function () {
32128
32162
  var result;
32129
32163
  return __generator(this, function (_a) {
@@ -32143,11 +32177,36 @@ var UsersApi = /** @class */ (function () {
32143
32177
  return [4 /*yield*/, this.storableDataService.loadMany('getAllAdminsAndDispatchers', loadFunc, [])];
32144
32178
  case 1:
32145
32179
  users = _d.sent();
32180
+ // Only a fresh run reaching its last page (no next cursor) has the whole collection in the store, so
32181
+ // only then mark it cached; otherwise track the next cursor as belonging to this fresh run.
32182
+ if (isFreshPagingRun) {
32183
+ if ((0, lodash_1.isNil)(loadResult.next_page_cursor)) {
32184
+ this.userStore.setGroupInitialized(User_consts_1.UserGroupTypes.Main, [
32185
+ User_consts_1.GROUP_VALUES.Admins,
32186
+ User_consts_1.GROUP_VALUES.Dispatchers
32187
+ ]);
32188
+ // The collection is cached now, so any in-flight run's tracked cursors are moot (a fresh call
32189
+ // short-circuits to the store). Clearing bounds the set against abandoned runs.
32190
+ this.adminsAndDispatchersFreshPagingCursors.clear();
32191
+ }
32192
+ else {
32193
+ this.adminsAndDispatchersFreshPagingCursors.add(loadResult.next_page_cursor);
32194
+ }
32195
+ }
32146
32196
  return [2 /*return*/, __assign(__assign({}, loadResult), { users: users })];
32147
32197
  }
32148
32198
  });
32149
32199
  });
32150
32200
  };
32201
+ UsersApi.prototype.isUserGroupsCacheEnabled = function () {
32202
+ var _a;
32203
+ var featureFlags = (((_a = this.session.merchant) === null || _a === void 0 ? void 0 : _a.feature_flags) || {});
32204
+ return Boolean(featureFlags[User_consts_1.ENABLE_USER_GROUPS_CACHE_FEATURE_FLAG]);
32205
+ };
32206
+ UsersApi.prototype.isAdminsAndDispatchersCached = function () {
32207
+ return (this.userStore.isGroupInitialized(User_consts_1.UserGroupTypes.Main, User_consts_1.GROUP_VALUES.Admins) &&
32208
+ this.userStore.isGroupInitialized(User_consts_1.UserGroupTypes.Main, User_consts_1.GROUP_VALUES.Dispatchers));
32209
+ };
32151
32210
  // Business logic methods
32152
32211
  UsersApi.prototype.messageDriver = function (userId, message) {
32153
32212
  return __awaiter(this, void 0, void 0, function () {