bruce-models 1.3.2 → 1.3.4

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) {
@@ -5644,6 +5658,14 @@ var User;
5644
5658
  res(settings);
5645
5659
  }
5646
5660
  catch (e) {
5661
+ // It will complain if an app id hasn't been used yet.
5662
+ // We need to suppress that error.
5663
+ if (e && typeof e == "object") {
5664
+ if (e.ERROR && typeof e.ERROR == "object" && e.ERROR.Type == "NotFound") {
5665
+ res({});
5666
+ return;
5667
+ }
5668
+ }
5647
5669
  rej(e);
5648
5670
  }
5649
5671
  }));