bruce-models 3.3.1 → 3.3.3

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.
@@ -883,19 +883,77 @@ var Account;
883
883
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
884
884
  return cache.data;
885
885
  }
886
- const req = yield api.GET(`account/${id}`, reqParams);
887
- const resData = {
888
- account: req
889
- };
886
+ const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
887
+ try {
888
+ const data = yield api.GET(`accountbyid/${id}`, reqParams);
889
+ // Update the cache by subdomain as well in case it's different to the ID.
890
+ if ((data === null || data === void 0 ? void 0 : data.ID) && (reqParams === null || reqParams === void 0 ? void 0 : reqParams.noCache) != false) {
891
+ yield api.SetCacheItem({
892
+ key: data.Subdomain,
893
+ value: prom,
894
+ req: reqParams
895
+ });
896
+ }
897
+ res({
898
+ account: data
899
+ });
900
+ }
901
+ catch (e) {
902
+ rej(e);
903
+ }
904
+ }));
890
905
  yield api.SetCacheItem({
891
906
  key: GetCacheKey(id),
892
- value: resData,
907
+ value: prom,
893
908
  req: reqParams
894
909
  });
895
- return resData;
910
+ return prom;
896
911
  });
897
912
  }
898
913
  Account.Get = Get;
914
+ /**
915
+ * Returns a client account record by subdomain or ID.
916
+ * @param params
917
+ * @returns
918
+ */
919
+ function GetBySubdomain(params) {
920
+ return __awaiter(this, void 0, void 0, function* () {
921
+ let { api, subdomain, req: reqParams } = params;
922
+ if (!api) {
923
+ api = ENVIRONMENT.Api().GetGuardianApi();
924
+ }
925
+ const cache = yield api.GetCacheItem(GetCacheKey(subdomain), reqParams);
926
+ if (cache === null || cache === void 0 ? void 0 : cache.found) {
927
+ return cache.data;
928
+ }
929
+ const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
930
+ try {
931
+ const data = yield api.GET(`account/${subdomain}`, reqParams);
932
+ // Update the cache by ID as well in case it's different to the subdomain.
933
+ if ((data === null || data === void 0 ? void 0 : data.ID) && (reqParams === null || reqParams === void 0 ? void 0 : reqParams.noCache) != false) {
934
+ yield api.SetCacheItem({
935
+ key: data.ID,
936
+ value: prom,
937
+ req: reqParams
938
+ });
939
+ }
940
+ res({
941
+ account: data
942
+ });
943
+ }
944
+ catch (e) {
945
+ rej(e);
946
+ }
947
+ }));
948
+ yield api.SetCacheItem({
949
+ key: GetCacheKey(subdomain),
950
+ value: prom,
951
+ req: reqParams
952
+ });
953
+ return prom;
954
+ });
955
+ }
956
+ Account.GetBySubdomain = GetBySubdomain;
899
957
  /**
900
958
  * Gets a list of client accounts related to the current session user.
901
959
  * @param params
@@ -2770,7 +2828,7 @@ var Entity;
2770
2828
  */
2771
2829
  function GetListByIds(params) {
2772
2830
  return __awaiter(this, void 0, void 0, function* () {
2773
- let { api, entityIds, req: reqParams, expandRelations } = params;
2831
+ let { api, entityIds, req: reqParams, expandRelations, expandLocation } = params;
2774
2832
  if (!entityIds.length) {
2775
2833
  throw ("Entity IDs are required.");
2776
2834
  }
@@ -2781,7 +2839,7 @@ var Entity;
2781
2839
  const reqIds = [];
2782
2840
  for (let i = 0; i < entityIds.length; i++) {
2783
2841
  const entityId = entityIds[i];
2784
- const key = GetCacheKey({ entityId, expandRelations });
2842
+ const key = GetCacheKey({ entityId, expandRelations, expandLocation });
2785
2843
  const cache = api.GetCacheItem(key, reqParams);
2786
2844
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
2787
2845
  reqs.push(cache.data);
@@ -2798,15 +2856,17 @@ var Entity;
2798
2856
  },
2799
2857
  PageSize: reqIds.length
2800
2858
  };
2859
+ if (expandRelations) {
2860
+ reqData["Expand"] = "relation";
2861
+ }
2862
+ else if (expandLocation) {
2863
+ reqData["Expand"] = "location";
2864
+ }
2801
2865
  if (reqIds.length > 0) {
2802
- const urlParams = new URLSearchParams();
2803
- if (expandRelations) {
2804
- urlParams.append("$expand", "relation");
2805
- }
2806
- const req = api.POST("entities?" + urlParams.toString(), reqData, Api.PrepReqParams(reqParams));
2866
+ const req = api.POST("entities", reqData, Api.PrepReqParams(reqParams));
2807
2867
  for (let i = 0; i < reqIds.length; i++) {
2808
2868
  const entityId = reqIds[i];
2809
- const key = GetCacheKey({ entityId });
2869
+ const key = GetCacheKey({ entityId, expandLocation, expandRelations });
2810
2870
  const prom = new Promise((res) => __awaiter(this, void 0, void 0, function* () {
2811
2871
  try {
2812
2872
  const data = yield req;
@@ -10622,7 +10682,7 @@ var DataSource;
10622
10682
  DataSource.GetList = GetList;
10623
10683
  })(DataSource || (DataSource = {}));
10624
10684
 
10625
- const VERSION = "3.3.1";
10685
+ const VERSION = "3.3.3";
10626
10686
 
10627
10687
  export { VERSION, AnnDocument, CustomForm, AbstractApi, Api, BruceApi, GlobalApi, GuardianApi, ApiGetters, Calculator, Bounds, BruceEvent, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, Geometry, UTC, BruceVariable, LRUCache, EntityAttachmentType, EntityAttachment, EntityComment, EntityLink, EntityLod, EntityLodCategory, EntityRelationType, EntityRelation, EntitySource, EntityTag, EntityType, Entity, EntityCoords, EntityTypeVisualSettings, EntityAttribute, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, ProjectViewLegacyTile, ProjectViewTile, ProjectViewLegacy, ProjectViewLegacyBookmark, PendingAction, MessageBroker, HostingLocation, Style, Tileset, Permission, Session, UserGroup, User, Account, AccountInvite, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, DataLab, ImportCad, ImportCsv, ImportJson, ImportKml, ImportedFile, Markup, Uploader, Plugin, ENVIRONMENT, DataSource };
10628
10688
  //# sourceMappingURL=bruce-models.es5.js.map