bruce-models 1.3.8 → 1.4.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.
@@ -1564,7 +1564,9 @@ var Entity;
1564
1564
  try {
1565
1565
  const data = yield req;
1566
1566
  const item = data.Items.find(x => x.Bruce.ID == entityId);
1567
- res(item);
1567
+ res({
1568
+ entity: item
1569
+ });
1568
1570
  }
1569
1571
  catch (e) {
1570
1572
  // No showing error as we don't want to see it 2000 times.
@@ -1576,7 +1578,7 @@ var Entity;
1576
1578
  }
1577
1579
  }
1578
1580
  return {
1579
- entities: (yield Promise.all(reqs)).filter(x => !!x)
1581
+ entities: (yield Promise.all(reqs)).map(x => x === null || x === void 0 ? void 0 : x.entity).filter(x => !!x)
1580
1582
  };
1581
1583
  });
1582
1584
  }
@@ -1748,7 +1750,9 @@ var Entity;
1748
1750
  for (let i = 0; i < entities.length; i++) {
1749
1751
  const entity = entities[i];
1750
1752
  const id = entity.Bruce.ID;
1751
- api.Cache.Set(GetCacheKey(id), entity, Api.DEFAULT_CACHE_DURATION);
1753
+ api.Cache.Set(GetCacheKey(id), {
1754
+ entity: entity
1755
+ }, Api.DEFAULT_CACHE_DURATION);
1752
1756
  }
1753
1757
  return {
1754
1758
  entities: entities
@@ -6060,11 +6064,19 @@ var User;
6060
6064
  if (cacheData) {
6061
6065
  return cacheData;
6062
6066
  }
6063
- const req = yield api.GET(`user/${id}${accountId ? `?clientAccountID=${accountId}` : ""}`, reqParams);
6064
- api.Cache.Set(GetCacheKey(id, accountId), req, Api.DEFAULT_CACHE_DURATION);
6065
- return {
6066
- user: req
6067
- };
6067
+ const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
6068
+ try {
6069
+ const data = yield api.GET(`user/${id}${accountId ? `?clientAccountID=${accountId}` : ""}`, reqParams);
6070
+ res({
6071
+ user: data
6072
+ });
6073
+ }
6074
+ catch (e) {
6075
+ rej(e);
6076
+ }
6077
+ }));
6078
+ api.Cache.Set(GetCacheKey(id, accountId), prom, Api.DEFAULT_CACHE_DURATION);
6079
+ return prom;
6068
6080
  });
6069
6081
  }
6070
6082
  User.Get = Get;
@@ -6205,11 +6217,19 @@ var User;
6205
6217
  if (cacheData) {
6206
6218
  return cacheData;
6207
6219
  }
6208
- const req = yield api.GET(`userByEmail/${email}${accountId ? `?clientAccountID=${accountId}` : ""}`, reqParams);
6209
- api.Cache.Set(GetEmailCacheKey(email, accountId), req, Api.DEFAULT_CACHE_DURATION);
6210
- return {
6211
- user: req
6212
- };
6220
+ const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
6221
+ try {
6222
+ const data = yield api.GET(`userByEmail/${email}${accountId ? `?clientAccountID=${accountId}` : ""}`, reqParams);
6223
+ res({
6224
+ user: data
6225
+ });
6226
+ }
6227
+ catch (e) {
6228
+ rej(e);
6229
+ }
6230
+ }));
6231
+ api.Cache.Set(GetEmailCacheKey(email, accountId), prom, Api.DEFAULT_CACHE_DURATION);
6232
+ return prom;
6213
6233
  });
6214
6234
  }
6215
6235
  LoginUser.GetByEmail = GetByEmail;
@@ -6240,7 +6260,9 @@ var User;
6240
6260
  req.then((data) => {
6241
6261
  const users = data.users;
6242
6262
  for (let i = 0; i < users.length; i++) {
6243
- api.Cache.Set(GetCacheKey(users[i].ID, accountId), users[i]);
6263
+ api.Cache.Set(GetCacheKey(users[i].ID, accountId), {
6264
+ user: users[i]
6265
+ });
6244
6266
  }
6245
6267
  });
6246
6268
  if (!exclusive) {
@@ -6382,7 +6404,7 @@ var User;
6382
6404
  try {
6383
6405
  const data = yield api.GET("usersByClientAccount/accessTokens", reqParams);
6384
6406
  res({
6385
- tokens: data.Items
6407
+ users: data.Items
6386
6408
  });
6387
6409
  }
6388
6410
  catch (e) {
@@ -6392,7 +6414,9 @@ var User;
6392
6414
  req.then((data) => {
6393
6415
  const users = data.tokens;
6394
6416
  for (let i = 0; i < users.length; i++) {
6395
- api.Cache.Set(GetCacheKey(users[i].ID, accountId), users[i]);
6417
+ api.Cache.Set(GetCacheKey(users[i].ID, accountId), {
6418
+ user: users[i]
6419
+ });
6396
6420
  }
6397
6421
  });
6398
6422
  api.Cache.Set(GetListCacheKey(accountId), req, Api.DEFAULT_CACHE_DURATION);
@@ -6424,7 +6448,7 @@ var User;
6424
6448
  data = yield api.POST("accessToken", data, reqParams);
6425
6449
  api.Cache.RemoveByStartsWith(Api.ECacheKey.AccessToken + Api.ECacheKey.Account);
6426
6450
  return {
6427
- token: data
6451
+ user: data
6428
6452
  };
6429
6453
  });
6430
6454
  }