bruce-models 6.7.7 → 6.7.9

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.
@@ -1083,9 +1083,11 @@
1083
1083
  });
1084
1084
  }
1085
1085
  if (!account) {
1086
- account = (yield exports.Account.GetBySubdomain({
1087
- subdomain: this.accountId,
1088
- api: guardian
1086
+ account = (yield exports.Account.Get({
1087
+ accountId: this.accountId,
1088
+ api: guardian,
1089
+ appId: exports.ENVIRONMENT.PARAMS.appId,
1090
+ expand: ["limit"]
1089
1091
  })).account;
1090
1092
  }
1091
1093
  if (!this.loadCancelled) {
@@ -1778,7 +1780,9 @@
1778
1780
  // Default environment.
1779
1781
  env: exports.Api.EEnv.PROD,
1780
1782
  // Default session ID.
1781
- sessionId: ENVIRONMENT.GetPageLoadSessionId()
1783
+ sessionId: ENVIRONMENT.GetPageLoadSessionId(),
1784
+ // Default app ID to use when loading account data.
1785
+ appId: null
1782
1786
  };
1783
1787
  // Subscribe to get notified when someone calls Reset.
1784
1788
  // If you are manually updating params, call OnParamsChange.Trigger() to notify others.
@@ -1811,6 +1815,12 @@
1811
1815
  if (ENVIRONMENT.IS_SELF_MANAGED) {
1812
1816
  throw ("Self managed mode ON. You are getting this error because you didn't pass an Api instance to a function.");
1813
1817
  }
1818
+ if (params.appId) {
1819
+ ENVIRONMENT.PARAMS.appId = params.appId;
1820
+ }
1821
+ if (params.env) {
1822
+ ENVIRONMENT.PARAMS.env = params.env;
1823
+ }
1814
1824
  if (_getters) {
1815
1825
  _getters.ClearCache();
1816
1826
  if (params.accountId) {
@@ -11830,18 +11840,29 @@
11830
11840
  */
11831
11841
  function Get(params) {
11832
11842
  return __awaiter(this, void 0, void 0, function* () {
11833
- let { api, accountId: id, req: reqParams } = params;
11843
+ let { api, accountId: id, req: reqParams, expand, appId } = params;
11834
11844
  if (!api) {
11835
11845
  api = exports.ENVIRONMENT.Api().GetGuardianApi();
11836
11846
  }
11837
- const cacheKey = GetCacheKey(api.GetSessionId(), id);
11847
+ const expandParam = (expand === null || expand === void 0 ? void 0 : expand.length) ? expand.join(",") : undefined;
11848
+ const cacheKey = GetCacheKey(api.GetSessionId(), id, appId, expandParam);
11838
11849
  const cache = api.GetCacheItem(cacheKey, reqParams);
11839
11850
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
11840
11851
  return cache.data;
11841
11852
  }
11842
11853
  const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
11843
11854
  try {
11844
- const data = yield api.GET(`accountbyid/${id}`, reqParams);
11855
+ let url = `accountbyid/${id}`;
11856
+ let added = false;
11857
+ if (expandParam) {
11858
+ url += (added ? "&" : "?") + `Expand=${expandParam}`;
11859
+ added = true;
11860
+ }
11861
+ if (appId) {
11862
+ url += (added ? "&" : "?") + `App=${encodeURIComponent(appId)}`;
11863
+ added = true;
11864
+ }
11865
+ const data = yield api.GET(url, reqParams);
11845
11866
  // Update the cache by subdomain as well in case it's different to the ID.
11846
11867
  if ((data === null || data === void 0 ? void 0 : data.ID) && (reqParams === null || reqParams === void 0 ? void 0 : reqParams.noCache) != false) {
11847
11868
  api.SetCacheItem({
@@ -11869,6 +11890,7 @@
11869
11890
  Account.Get = Get;
11870
11891
  /**
11871
11892
  * Returns a client account record by subdomain or ID.
11893
+ * @deprecated use Get() as both will check against ID and subdomain.
11872
11894
  * @param params
11873
11895
  * @returns
11874
11896
  */
@@ -12078,16 +12100,22 @@
12078
12100
  * @param sessionId
12079
12101
  * @param accountId
12080
12102
  * @param appSettingsId
12103
+ * @param expandParam Comma delimited list of expand params.
12081
12104
  * @returns
12082
12105
  */
12083
- function GetCacheKey(sessionId, accountId, appSettingsId) {
12106
+ function GetCacheKey(sessionId, accountId, appSettingsId, expandParam) {
12084
12107
  if (!sessionId) {
12085
12108
  sessionId = "anonymous";
12086
12109
  }
12110
+ let cacheKey = [exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + accountId];
12111
+ if (expandParam) {
12112
+ cacheKey.push(exports.Api.ECacheKey.Id + expandParam);
12113
+ }
12087
12114
  if (appSettingsId) {
12088
- return exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + accountId + exports.Api.ECacheKey + appSettingsId + exports.Api.ECacheKey.Session + exports.Api.ECacheKey.Id + sessionId;
12115
+ cacheKey.push(exports.Api.ECacheKey + appSettingsId);
12089
12116
  }
12090
- return exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + accountId + exports.Api.ECacheKey.Session + exports.Api.ECacheKey.Id + sessionId;
12117
+ cacheKey.push(exports.Api.ECacheKey.Session + exports.Api.ECacheKey.Id + sessionId);
12118
+ return cacheKey.join("");
12091
12119
  }
12092
12120
  Account.GetCacheKey = GetCacheKey;
12093
12121
  /**
@@ -13957,28 +13985,16 @@
13957
13985
  api = exports.ENVIRONMENT.Api().GetGuardianApi();
13958
13986
  }
13959
13987
  req = exports.Api.PrepReqParams(req);
13960
- const cacheData = api.GetCacheItem(GetLimitsCacheKey(accountId));
13961
- if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.found) {
13962
- return cacheData.data;
13963
- }
13964
- const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
13965
- try {
13966
- const data = yield api.GET(`account/${accountId}?WithLimits=true`);
13967
- const limits = data.Limits ? data.Limits : {};
13968
- res({
13969
- limits: limits
13970
- });
13971
- }
13972
- catch (e) {
13973
- rej(e);
13974
- }
13975
- }));
13976
- api.SetCacheItem({
13977
- key: GetLimitsCacheKey(accountId),
13978
- value: prom,
13979
- req: req
13988
+ const { account } = yield exports.Account.Get({
13989
+ accountId: accountId,
13990
+ api: api,
13991
+ expand: ["limit"],
13992
+ appId: exports.ENVIRONMENT.PARAMS.appId
13980
13993
  });
13981
- return prom;
13994
+ const limits = account["Limits"] || {};
13995
+ return {
13996
+ limits: limits
13997
+ };
13982
13998
  });
13983
13999
  }
13984
14000
  AccountLimits.GetLimits = GetLimits;
@@ -14568,14 +14584,6 @@
14568
14584
  }
14569
14585
  Assert.GetDenyPublicAccess = GetDenyPublicAccess;
14570
14586
  })(Assert = AccountLimits.Assert || (AccountLimits.Assert = {}));
14571
- /**
14572
- * Cache key for requesting account limits for a specific account.
14573
- * @param accountId
14574
- */
14575
- function GetLimitsCacheKey(accountId) {
14576
- return exports.Api.ECacheKey.AccountLimits + exports.Api.ECacheKey.Id + accountId;
14577
- }
14578
- AccountLimits.GetLimitsCacheKey = GetLimitsCacheKey;
14579
14587
  })(exports.AccountLimits || (exports.AccountLimits = {}));
14580
14588
 
14581
14589
  (function (AccountTemplate) {
@@ -16144,7 +16152,7 @@
16144
16152
  })(exports.Tracking || (exports.Tracking = {}));
16145
16153
 
16146
16154
  // This is updated with the package.json version on build.
16147
- const VERSION = "6.7.7";
16155
+ const VERSION = "6.7.9";
16148
16156
 
16149
16157
  exports.VERSION = VERSION;
16150
16158
  exports.AbstractApi = AbstractApi;