bruce-models 2.6.1 → 2.6.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.
@@ -39,6 +39,7 @@ var Api;
39
39
  ECacheKey["Session"] = "session";
40
40
  ECacheKey["PendingAction"] = "pendingaction";
41
41
  ECacheKey["EntitySource"] = "entitysource";
42
+ ECacheKey["DataSource"] = "datasource";
42
43
  ECacheKey["ProgramKey"] = "programkey";
43
44
  ECacheKey["EntityCoords"] = "entitycoords";
44
45
  ECacheKey["Tag"] = "tag";
@@ -4983,6 +4984,10 @@ var Entity;
4983
4984
  return `${Api.ECacheKey.Entity}${Api.ECacheKey.Id}${entityId}${String(entityTypeId)}${String(Boolean(expandLocation))}`;
4984
4985
  }
4985
4986
  Entity.GetCacheKey = GetCacheKey;
4987
+ function GetStartsWithKey(entityId) {
4988
+ return `${Api.ECacheKey.Entity}${Api.ECacheKey.Id}${entityId}`;
4989
+ }
4990
+ Entity.GetStartsWithKey = GetStartsWithKey;
4986
4991
  function Get(params) {
4987
4992
  return __awaiter(this, void 0, void 0, function* () {
4988
4993
  let { api, entityId, req: reqParams, expandLocation, entityTypeId } = params;
@@ -5096,7 +5101,7 @@ var Entity;
5096
5101
  throw ("Entity ID is required.");
5097
5102
  }
5098
5103
  yield api.DELETE(`entity/${entityId}`, Api.PrepReqParams(reqParams));
5099
- api.Cache.Remove(GetCacheKey(entityId));
5104
+ api.Cache.RemoveByStartsWith(GetStartsWithKey(entityId));
5100
5105
  });
5101
5106
  }
5102
5107
  Entity.Delete = Delete;
@@ -5114,7 +5119,7 @@ var Entity;
5114
5119
  }, Api.PrepReqParams(reqParams));
5115
5120
  for (let i = 0; i < entityIds.length; i++) {
5116
5121
  const entityId = entityIds[i];
5117
- api.Cache.Remove(GetCacheKey(entityId));
5122
+ api.Cache.RemoveByStartsWith(GetStartsWithKey(entityId));
5118
5123
  }
5119
5124
  });
5120
5125
  }
@@ -5134,7 +5139,7 @@ var Entity;
5134
5139
  }
5135
5140
  const reqUrl = `entity/${data.Bruce.ID}/?dataoverride=${override}&BruceEntityType=${data.Bruce["EntityType.ID"]}`;
5136
5141
  const res = yield api.POST(reqUrl, data, Api.PrepReqParams(reqParams));
5137
- api.Cache.Remove(GetCacheKey(data.Bruce.ID));
5142
+ api.Cache.RemoveByStartsWith(GetStartsWithKey(data.Bruce.ID));
5138
5143
  return {
5139
5144
  entity: res
5140
5145
  };
@@ -11780,7 +11785,113 @@ var Plugin;
11780
11785
  Plugin.GetRunFunction = GetRunFunction;
11781
11786
  })(Plugin || (Plugin = {}));
11782
11787
 
11783
- const VERSION$1 = "2.6.1";
11788
+ var DataSource;
11789
+ (function (DataSource) {
11790
+ function GetCacheKey(id) {
11791
+ return Api.ECacheKey.DataSource + Api.ECacheKey.Id + id;
11792
+ }
11793
+ DataSource.GetCacheKey = GetCacheKey;
11794
+ function GetListCacheKey() {
11795
+ return Api.ECacheKey.DataSource;
11796
+ }
11797
+ DataSource.GetListCacheKey = GetListCacheKey;
11798
+ let EType;
11799
+ (function (EType) {
11800
+ EType["IDMapping"] = "IDMapping";
11801
+ })(EType = DataSource.EType || (DataSource.EType = {}));
11802
+ function Update(params) {
11803
+ return __awaiter(this, void 0, void 0, function* () {
11804
+ let { source: data, api, req: reqParams } = params;
11805
+ if (!api) {
11806
+ api = ENVIRONMENT.Api().GetBruceApi();
11807
+ }
11808
+ const url = `source` + (data.ID == null ? "" : "/" + data.ID);
11809
+ const res = yield api.POST(url, data, Api.PrepReqParams(reqParams));
11810
+ yield api.Cache.Remove(GetCacheKey(data.ID));
11811
+ yield api.Cache.Remove(GetListCacheKey());
11812
+ return {
11813
+ source: res
11814
+ };
11815
+ });
11816
+ }
11817
+ DataSource.Update = Update;
11818
+ function Delete(params) {
11819
+ return __awaiter(this, void 0, void 0, function* () {
11820
+ let { id, api, req: reqParams } = params;
11821
+ if (!api) {
11822
+ api = ENVIRONMENT.Api().GetBruceApi();
11823
+ }
11824
+ yield api.DELETE(`source/${id}`, Api.PrepReqParams(reqParams));
11825
+ yield api.Cache.Remove(GetCacheKey(id));
11826
+ yield api.Cache.Remove(GetListCacheKey());
11827
+ });
11828
+ }
11829
+ DataSource.Delete = Delete;
11830
+ function Get(params) {
11831
+ return __awaiter(this, void 0, void 0, function* () {
11832
+ let { id, api, req: reqParams } = params;
11833
+ if (!api) {
11834
+ api = ENVIRONMENT.Api().GetBruceApi();
11835
+ }
11836
+ reqParams = Api.PrepReqParams(reqParams);
11837
+ const cacheData = yield api.GetCacheItem(GetCacheKey(id), reqParams);
11838
+ if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.found) {
11839
+ return cacheData.data;
11840
+ }
11841
+ const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
11842
+ try {
11843
+ const data = yield api.GET(`source/${id}`, Api.PrepReqParams(reqParams));
11844
+ res({
11845
+ source: data
11846
+ });
11847
+ }
11848
+ catch (e) {
11849
+ rej(e);
11850
+ }
11851
+ }));
11852
+ api.SetCacheItem({
11853
+ key: GetCacheKey(id),
11854
+ value: prom,
11855
+ req: reqParams
11856
+ });
11857
+ return prom;
11858
+ });
11859
+ }
11860
+ DataSource.Get = Get;
11861
+ function GetList(params) {
11862
+ return __awaiter(this, void 0, void 0, function* () {
11863
+ let { api, req: reqParams } = params;
11864
+ if (!api) {
11865
+ api = ENVIRONMENT.Api().GetBruceApi();
11866
+ }
11867
+ reqParams = Api.PrepReqParams(reqParams);
11868
+ const cacheData = yield api.GetCacheItem(GetListCacheKey(), reqParams);
11869
+ if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.found) {
11870
+ return cacheData.data;
11871
+ }
11872
+ const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
11873
+ try {
11874
+ const data = yield api.GET("sources", Api.PrepReqParams(reqParams));
11875
+ res({
11876
+ sources: data === null || data === void 0 ? void 0 : data.Items
11877
+ });
11878
+ }
11879
+ catch (e) {
11880
+ rej(e);
11881
+ }
11882
+ }));
11883
+ api.SetCacheItem({
11884
+ key: GetListCacheKey(),
11885
+ value: prom,
11886
+ req: reqParams
11887
+ });
11888
+ return prom;
11889
+ });
11890
+ }
11891
+ DataSource.GetList = GetList;
11892
+ })(DataSource || (DataSource = {}));
11893
+
11894
+ const VERSION$1 = "2.6.3";
11784
11895
 
11785
- export { VERSION$1 as VERSION, AnnDocument, CustomForm, CustomFormContent, AbstractApi, Api, BruceApi, CamApi, IdmApi, 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, EntityGlobe, EntityFilterGetter, BatchedDataGetter, EntityCoords, EntityTypeVisualSettings, EntityAttribute, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, ProjectViewLegacyTile, ProjectViewTile, 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 };
11896
+ export { VERSION$1 as VERSION, AnnDocument, CustomForm, CustomFormContent, AbstractApi, Api, BruceApi, CamApi, IdmApi, 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, EntityGlobe, EntityFilterGetter, BatchedDataGetter, EntityCoords, EntityTypeVisualSettings, EntityAttribute, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, ProjectViewLegacyTile, ProjectViewTile, 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 };
11786
11897
  //# sourceMappingURL=bruce-models.es5.js.map