bruce-models 3.3.2 → 3.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.
@@ -874,19 +874,77 @@
874
874
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
875
875
  return cache.data;
876
876
  }
877
- const req = yield api.GET(`account/${id}`, reqParams);
878
- const resData = {
879
- account: req
880
- };
877
+ const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
878
+ try {
879
+ const data = yield api.GET(`accountbyid/${id}`, reqParams);
880
+ // Update the cache by subdomain as well in case it's different to the ID.
881
+ if ((data === null || data === void 0 ? void 0 : data.ID) && (reqParams === null || reqParams === void 0 ? void 0 : reqParams.noCache) != false) {
882
+ yield api.SetCacheItem({
883
+ key: data.Subdomain,
884
+ value: prom,
885
+ req: reqParams
886
+ });
887
+ }
888
+ res({
889
+ account: data
890
+ });
891
+ }
892
+ catch (e) {
893
+ rej(e);
894
+ }
895
+ }));
881
896
  yield api.SetCacheItem({
882
897
  key: GetCacheKey(id),
883
- value: resData,
898
+ value: prom,
884
899
  req: reqParams
885
900
  });
886
- return resData;
901
+ return prom;
887
902
  });
888
903
  }
889
904
  Account.Get = Get;
905
+ /**
906
+ * Returns a client account record by subdomain or ID.
907
+ * @param params
908
+ * @returns
909
+ */
910
+ function GetBySubdomain(params) {
911
+ return __awaiter(this, void 0, void 0, function* () {
912
+ let { api, subdomain, req: reqParams } = params;
913
+ if (!api) {
914
+ api = exports.ENVIRONMENT.Api().GetGuardianApi();
915
+ }
916
+ const cache = yield api.GetCacheItem(GetCacheKey(subdomain), reqParams);
917
+ if (cache === null || cache === void 0 ? void 0 : cache.found) {
918
+ return cache.data;
919
+ }
920
+ const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
921
+ try {
922
+ const data = yield api.GET(`account/${subdomain}`, reqParams);
923
+ // Update the cache by ID as well in case it's different to the subdomain.
924
+ if ((data === null || data === void 0 ? void 0 : data.ID) && (reqParams === null || reqParams === void 0 ? void 0 : reqParams.noCache) != false) {
925
+ yield api.SetCacheItem({
926
+ key: data.ID,
927
+ value: prom,
928
+ req: reqParams
929
+ });
930
+ }
931
+ res({
932
+ account: data
933
+ });
934
+ }
935
+ catch (e) {
936
+ rej(e);
937
+ }
938
+ }));
939
+ yield api.SetCacheItem({
940
+ key: GetCacheKey(subdomain),
941
+ value: prom,
942
+ req: reqParams
943
+ });
944
+ return prom;
945
+ });
946
+ }
947
+ Account.GetBySubdomain = GetBySubdomain;
890
948
  /**
891
949
  * Gets a list of client accounts related to the current session user.
892
950
  * @param params
@@ -1678,6 +1736,9 @@
1678
1736
  for (const key in this.bruce) {
1679
1737
  this.bruce[key].SetSessionId(sessionId);
1680
1738
  }
1739
+ for (const key in this.guardian) {
1740
+ this.guardian[key].SetSessionId(sessionId);
1741
+ }
1681
1742
  for (const key in this.global) {
1682
1743
  this.global[key].SetSessionId(sessionId);
1683
1744
  }
@@ -10371,7 +10432,7 @@
10371
10432
  DataSource.GetList = GetList;
10372
10433
  })(exports.DataSource || (exports.DataSource = {}));
10373
10434
 
10374
- const VERSION = "3.3.2";
10435
+ const VERSION = "3.3.4";
10375
10436
 
10376
10437
  exports.VERSION = VERSION;
10377
10438
  exports.AbstractApi = AbstractApi;