bruce-models 6.4.6 → 6.4.8

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.
@@ -8204,20 +8204,20 @@
8204
8204
  */
8205
8205
  function Get(params) {
8206
8206
  return __awaiter(this, void 0, void 0, function* () {
8207
- let { api, styleId: id, req: reqParams } = params;
8208
- if (!id) {
8209
- throw ("Style ID is required.");
8207
+ let { api, styleId, req: reqParams } = params;
8208
+ if (!styleId) {
8209
+ throw ("styleId is required.");
8210
8210
  }
8211
8211
  if (!api) {
8212
8212
  api = exports.ENVIRONMENT.Api().GetBruceApi();
8213
8213
  }
8214
- const cache = api.GetCacheItem(GetCacheKey(id), reqParams);
8214
+ const cache = api.GetCacheItem(GetCacheKey(styleId), reqParams);
8215
8215
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
8216
8216
  return cache.data;
8217
8217
  }
8218
8218
  const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
8219
8219
  try {
8220
- const data = yield api.GET(`ui.entityDisplaySetting/${id}`, exports.Api.PrepReqParams(reqParams));
8220
+ const data = yield api.GET(`ui.entityDisplaySetting/${styleId}`, exports.Api.PrepReqParams(reqParams));
8221
8221
  res({
8222
8222
  style: data
8223
8223
  });
@@ -8227,7 +8227,7 @@
8227
8227
  }
8228
8228
  }));
8229
8229
  api.SetCacheItem({
8230
- key: GetCacheKey(id),
8230
+ key: GetCacheKey(styleId),
8231
8231
  value: prom,
8232
8232
  req: reqParams
8233
8233
  });
@@ -12466,6 +12466,41 @@
12466
12466
  // Access token. Used to gain access to related permissions.
12467
12467
  EType["AccessToken"] = "ACCESS_TOKEN";
12468
12468
  })(EType = User.EType || (User.EType = {}));
12469
+ /**
12470
+ * Returns an array of User Group IDs for the User that have been loaded.
12471
+ * Note, this does not perform an API lookup if the User instance hasn't loaded the specific account's details.
12472
+ * @param params
12473
+ * @returns
12474
+ */
12475
+ function UnpackRelatedUserGroupIDs(params) {
12476
+ var _a, _b;
12477
+ const { user, accountId } = params;
12478
+ if (!user || !accountId) {
12479
+ throw ("User and accountId are required.");
12480
+ }
12481
+ let accessPerms = user.AccessPermissions;
12482
+ if (!accessPerms || !Array.isArray(accessPerms) || accessPerms.length === 0) {
12483
+ return [];
12484
+ }
12485
+ for (const perm of accessPerms) {
12486
+ if (!perm || perm["ClientAccount.ID"] !== accountId) {
12487
+ continue;
12488
+ }
12489
+ else if ((_a = perm["UserGroup.ID"]) === null || _a === void 0 ? void 0 : _a.length) {
12490
+ return perm["UserGroup.ID"];
12491
+ }
12492
+ else if ((_b = perm.UserGroups) === null || _b === void 0 ? void 0 : _b.length) {
12493
+ if (typeof perm.UserGroups[0] === "string") {
12494
+ return perm.UserGroups;
12495
+ }
12496
+ else if (typeof perm.UserGroups[0] === "object") {
12497
+ return perm.UserGroups.map(group => group.ID);
12498
+ }
12499
+ }
12500
+ }
12501
+ return [];
12502
+ }
12503
+ User.UnpackRelatedUserGroupIDs = UnpackRelatedUserGroupIDs;
12469
12504
  /**
12470
12505
  * Gets a user record.
12471
12506
  * @param params
@@ -14389,8 +14424,8 @@
14389
14424
  function Get(params) {
14390
14425
  return __awaiter(this, void 0, void 0, function* () {
14391
14426
  let { api, queryId, req } = params;
14392
- if (!queryId || queryId <= 0) {
14393
- throw new Error("queryId is required.");
14427
+ if (!queryId) {
14428
+ throw new Error("queryId must be provided.");
14394
14429
  }
14395
14430
  if (!api) {
14396
14431
  api = exports.ENVIRONMENT.Api().GetBruceApi();
@@ -15715,7 +15750,7 @@
15715
15750
  })(exports.Tracking || (exports.Tracking = {}));
15716
15751
 
15717
15752
  // This is updated with the package.json version on build.
15718
- const VERSION = "6.4.6";
15753
+ const VERSION = "6.4.8";
15719
15754
 
15720
15755
  exports.VERSION = VERSION;
15721
15756
  exports.AbstractApi = AbstractApi;