bruce-models 1.2.1 → 1.2.2

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.
@@ -2781,6 +2781,10 @@ var EntityLod;
2781
2781
  return Api.ECacheKey.Lod + Api.ECacheKey.EntityType + typeId + Api.ECacheKey.Id + group;
2782
2782
  }
2783
2783
  EntityLod.GetTypeListKey = GetTypeListKey;
2784
+ function GetEntityListKey(entityId) {
2785
+ return Api.ECacheKey.Lod + Api.ECacheKey.Entity + entityId;
2786
+ }
2787
+ EntityLod.GetEntityListKey = GetEntityListKey;
2784
2788
  function GetUrl(api, entityId, categoryId, level, strict) {
2785
2789
  if (!entityId) {
2786
2790
  throw ("Entity ID is required.");
@@ -2832,6 +2836,30 @@ var EntityLod;
2832
2836
  });
2833
2837
  }
2834
2838
  EntityLod.GetLods = GetLods;
2839
+ function GetEntityLods(api, entityId, reqParams) {
2840
+ return __awaiter(this, void 0, void 0, function* () {
2841
+ if (!entityId) {
2842
+ throw ("Entity id is required.");
2843
+ }
2844
+ const cacheData = api.GetCacheItem(GetEntityListKey(entityId), reqParams);
2845
+ if (cacheData) {
2846
+ return cacheData;
2847
+ }
2848
+ const req = api.GET(`entity/${entityId}/lods?includeClientFiles=yes`);
2849
+ const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
2850
+ try {
2851
+ const data = yield req;
2852
+ res(data.Items);
2853
+ }
2854
+ catch (e) {
2855
+ rej(e);
2856
+ }
2857
+ }));
2858
+ api.Cache.Set(GetEntityListKey(entityId), prom, Api.DEFAULT_CACHE_DURATION);
2859
+ return prom;
2860
+ });
2861
+ }
2862
+ EntityLod.GetEntityLods = GetEntityLods;
2835
2863
  /**
2836
2864
  * Returns lods for a specified entity type.
2837
2865
  * @param api
@@ -2869,10 +2897,12 @@ var EntityLod;
2869
2897
  if (!params["ClientFile.ID"] || !params["LODCategory.Key"] || (!params.Level && params.Level !== 0)) {
2870
2898
  throw ("ClientFile.ID, LODCategory.Key and Level are required.");
2871
2899
  }
2872
- return api.POST(`entity/${entityId}/lod/${params["LODCategory.Key"]}/${params.Level}`, {
2900
+ const res = yield api.POST(`entity/${entityId}/lod/${params["LODCategory.Key"]}/${params.Level}`, {
2873
2901
  "Level": 0,
2874
2902
  "ClientFile.ID": params["ClientFile.ID"]
2875
2903
  }, Api.PrepReqParams(reqParams));
2904
+ api.Cache.Remove(GetEntityListKey(entityId));
2905
+ return res;
2876
2906
  });
2877
2907
  }
2878
2908
  EntityLod.Update = Update;