bruce-models 6.7.6 → 6.7.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.
@@ -976,7 +976,7 @@
976
976
  // Indicates if the init process has finished loading.
977
977
  // While this is not resolved requests will be in a pending state.
978
978
  this.loadProm = Promise.resolve();
979
- let { accountId, env, guardian, loadRegionalBaseUrl, loadConfig, loadWebSocket, dummy } = params;
979
+ let { accountId, env, guardian, loadRegionalBaseUrl, loadConfig, loadWebSocket, dummy, account } = params;
980
980
  this.accountId = accountId;
981
981
  this.env = env !== null && env !== void 0 ? env : exports.Api.EEnv.PROD;
982
982
  if (!dummy) {
@@ -988,16 +988,20 @@
988
988
  // Mark it as attempted right away because we don't want any external calls while it gets to that async point.
989
989
  this.configLoadAttempted = true;
990
990
  }
991
- this.loadProm = this.init(guardian, loadConfig, loadWebSocket);
991
+ this.loadProm = this.init(guardian, loadConfig, loadWebSocket, account);
992
992
  }
993
993
  }
994
994
  /**
995
995
  * Loads regional base url and sets up message broker.
996
996
  * @param guardian Required for loading regional base url.
997
997
  * @param loadConfig
998
+ * @param loadWebSocket
999
+ * @param account
998
1000
  * @returns
999
1001
  */
1000
- init(guardian, loadConfig, loadWebSocket) {
1002
+ init(guardian, loadConfig, loadWebSocket,
1003
+ // Preloaded account to save doing an API call.
1004
+ account) {
1001
1005
  return __awaiter(this, void 0, void 0, function* () {
1002
1006
  if (!this.accountId) {
1003
1007
  throw ("accountId is required.");
@@ -1011,7 +1015,8 @@
1011
1015
  guardian: guardian,
1012
1016
  // We marked it as attempted to load outside this method to fight any external calls.
1013
1017
  // So we'll force load it now.
1014
- forceLoad: true
1018
+ forceLoad: true,
1019
+ account: account
1015
1020
  });
1016
1021
  }
1017
1022
  // Get the version.
@@ -1066,7 +1071,7 @@
1066
1071
  */
1067
1072
  LoadConfig(params) {
1068
1073
  return __awaiter(this, void 0, void 0, function* () {
1069
- let { guardian, forceLoad } = (params !== null && params !== void 0 ? params : {});
1074
+ let { guardian, forceLoad, account } = (params !== null && params !== void 0 ? params : {});
1070
1075
  if (this.configLoadAttempted && forceLoad != true) {
1071
1076
  return;
1072
1077
  }
@@ -1077,10 +1082,12 @@
1077
1082
  env: this.env
1078
1083
  });
1079
1084
  }
1080
- const { account } = yield exports.Account.GetBySubdomain({
1081
- subdomain: this.accountId,
1082
- api: guardian
1083
- });
1085
+ if (!account) {
1086
+ account = (yield exports.Account.GetBySubdomain({
1087
+ subdomain: this.accountId,
1088
+ api: guardian
1089
+ })).account;
1090
+ }
1084
1091
  if (!this.loadCancelled) {
1085
1092
  // Set the calculated base url.
1086
1093
  // If this is not available then this is considered a critical failure.
@@ -11823,18 +11830,29 @@
11823
11830
  */
11824
11831
  function Get(params) {
11825
11832
  return __awaiter(this, void 0, void 0, function* () {
11826
- let { api, accountId: id, req: reqParams } = params;
11833
+ let { api, accountId: id, req: reqParams, expand, appId } = params;
11827
11834
  if (!api) {
11828
11835
  api = exports.ENVIRONMENT.Api().GetGuardianApi();
11829
11836
  }
11830
- const cacheKey = GetCacheKey(api.GetSessionId(), id);
11837
+ const expandParam = (expand === null || expand === void 0 ? void 0 : expand.length) ? expand.join(",") : undefined;
11838
+ const cacheKey = GetCacheKey(api.GetSessionId(), id, appId, expandParam);
11831
11839
  const cache = api.GetCacheItem(cacheKey, reqParams);
11832
11840
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
11833
11841
  return cache.data;
11834
11842
  }
11835
11843
  const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
11836
11844
  try {
11837
- const data = yield api.GET(`accountbyid/${id}`, reqParams);
11845
+ let url = `accountbyid/${id}`;
11846
+ let added = false;
11847
+ if (expandParam) {
11848
+ url += (added ? "&" : "?") + `Expand=${expandParam}`;
11849
+ added = true;
11850
+ }
11851
+ if (appId) {
11852
+ url += (added ? "&" : "?") + `App=${encodeURIComponent(appId)}`;
11853
+ added = true;
11854
+ }
11855
+ const data = yield api.GET(url, reqParams);
11838
11856
  // Update the cache by subdomain as well in case it's different to the ID.
11839
11857
  if ((data === null || data === void 0 ? void 0 : data.ID) && (reqParams === null || reqParams === void 0 ? void 0 : reqParams.noCache) != false) {
11840
11858
  api.SetCacheItem({
@@ -11862,6 +11880,7 @@
11862
11880
  Account.Get = Get;
11863
11881
  /**
11864
11882
  * Returns a client account record by subdomain or ID.
11883
+ * @deprecated use Get() as both will check against ID and subdomain.
11865
11884
  * @param params
11866
11885
  * @returns
11867
11886
  */
@@ -12071,16 +12090,22 @@
12071
12090
  * @param sessionId
12072
12091
  * @param accountId
12073
12092
  * @param appSettingsId
12093
+ * @param expandParam Comma delimited list of expand params.
12074
12094
  * @returns
12075
12095
  */
12076
- function GetCacheKey(sessionId, accountId, appSettingsId) {
12096
+ function GetCacheKey(sessionId, accountId, appSettingsId, expandParam) {
12077
12097
  if (!sessionId) {
12078
12098
  sessionId = "anonymous";
12079
12099
  }
12100
+ let cacheKey = [exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + accountId];
12101
+ if (expandParam) {
12102
+ cacheKey.push(exports.Api.ECacheKey.Id + expandParam);
12103
+ }
12080
12104
  if (appSettingsId) {
12081
- return exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + accountId + exports.Api.ECacheKey + appSettingsId + exports.Api.ECacheKey.Session + exports.Api.ECacheKey.Id + sessionId;
12105
+ cacheKey.push(exports.Api.ECacheKey + appSettingsId);
12082
12106
  }
12083
- return exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + accountId + exports.Api.ECacheKey.Session + exports.Api.ECacheKey.Id + sessionId;
12107
+ cacheKey.push(exports.Api.ECacheKey.Session + exports.Api.ECacheKey.Id + sessionId);
12108
+ return cacheKey.join("");
12084
12109
  }
12085
12110
  Account.GetCacheKey = GetCacheKey;
12086
12111
  /**
@@ -16137,7 +16162,7 @@
16137
16162
  })(exports.Tracking || (exports.Tracking = {}));
16138
16163
 
16139
16164
  // This is updated with the package.json version on build.
16140
- const VERSION = "6.7.6";
16165
+ const VERSION = "6.7.8";
16141
16166
 
16142
16167
  exports.VERSION = VERSION;
16143
16168
  exports.AbstractApi = AbstractApi;