bruce-models 1.3.3 → 1.3.5

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.
@@ -5606,10 +5606,24 @@ var User;
5606
5606
  }
5607
5607
  User.Get = Get;
5608
5608
  function Update(api, data, reqParams) {
5609
+ var _a;
5609
5610
  return __awaiter(this, void 0, void 0, function* () {
5610
5611
  if (!(data === null || data === void 0 ? void 0 : data.ID) || !(data === null || data === void 0 ? void 0 : data.Type)) {
5611
5612
  throw ("ID and Type are required.");
5612
5613
  }
5614
+ // When getting a user it is structured slightly different to when we update it.
5615
+ // We can make up the difference here.
5616
+ if ((_a = data.AccessPermissions) === null || _a === void 0 ? void 0 : _a.length) {
5617
+ for (let i = 0; i < data.AccessPermissions.length; i++) {
5618
+ const perm = data.AccessPermissions[i];
5619
+ if (!perm["UserGroup.ID"] && perm.UserGroups) {
5620
+ perm["UserGroup.ID"] = [];
5621
+ for (let j = 0; j < perm.UserGroups.length; j++) {
5622
+ perm["UserGroup.ID"].push(perm.UserGroups[j].ID);
5623
+ }
5624
+ }
5625
+ }
5626
+ }
5613
5627
  data = yield api.POST(`user/${data.ID}`, data, reqParams);
5614
5628
  api.Cache.RemoveByContains(Api.ECacheKey.User + Api.ECacheKey.Id + data.ID);
5615
5629
  if (data.Type == EType.AccessToken) {
@@ -5648,7 +5662,7 @@ var User;
5648
5662
  // We need to suppress that error.
5649
5663
  if (e && typeof e == "object") {
5650
5664
  if (e.ERROR && typeof e.ERROR == "object" && e.ERROR.Type == "NotFound") {
5651
- res(null);
5665
+ res({});
5652
5666
  return;
5653
5667
  }
5654
5668
  }
@@ -5683,12 +5697,12 @@ var User;
5683
5697
  });
5684
5698
  }
5685
5699
  User.UpdateSettings = UpdateSettings;
5686
- function GetUsernameAvailable(api, username, reqParams) {
5700
+ function GetUsernameAvailable(api, username, excludeUserId, reqParams) {
5687
5701
  return __awaiter(this, void 0, void 0, function* () {
5688
5702
  if (!username) {
5689
5703
  throw ("Username is required.");
5690
5704
  }
5691
- const req = api.GET(`user/loginavailable/${username}`, reqParams);
5705
+ const req = api.GET(`user/loginavailable/${username}${excludeUserId ? "?excludeUserId=" + excludeUserId : ""}`, reqParams);
5692
5706
  const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
5693
5707
  try {
5694
5708
  const data = yield req;