bruce-models 2.6.1 → 2.6.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.
@@ -44,6 +44,7 @@
44
44
  ECacheKey["Session"] = "session";
45
45
  ECacheKey["PendingAction"] = "pendingaction";
46
46
  ECacheKey["EntitySource"] = "entitysource";
47
+ ECacheKey["DataSource"] = "datasource";
47
48
  ECacheKey["ProgramKey"] = "programkey";
48
49
  ECacheKey["EntityCoords"] = "entitycoords";
49
50
  ECacheKey["Tag"] = "tag";
@@ -4939,6 +4940,10 @@
4939
4940
  return `${exports.Api.ECacheKey.Entity}${exports.Api.ECacheKey.Id}${entityId}${String(entityTypeId)}${String(Boolean(expandLocation))}`;
4940
4941
  }
4941
4942
  Entity.GetCacheKey = GetCacheKey;
4943
+ function GetStartsWithKey(entityId) {
4944
+ return `${exports.Api.ECacheKey.Entity}${exports.Api.ECacheKey.Id}${entityId}`;
4945
+ }
4946
+ Entity.GetStartsWithKey = GetStartsWithKey;
4942
4947
  function Get(params) {
4943
4948
  return __awaiter(this, void 0, void 0, function* () {
4944
4949
  let { api, entityId, req: reqParams, expandLocation, entityTypeId } = params;
@@ -5052,7 +5057,7 @@
5052
5057
  throw ("Entity ID is required.");
5053
5058
  }
5054
5059
  yield api.DELETE(`entity/${entityId}`, exports.Api.PrepReqParams(reqParams));
5055
- api.Cache.Remove(GetCacheKey(entityId));
5060
+ api.Cache.RemoveByStartsWith(GetStartsWithKey(entityId));
5056
5061
  });
5057
5062
  }
5058
5063
  Entity.Delete = Delete;
@@ -5070,7 +5075,7 @@
5070
5075
  }, exports.Api.PrepReqParams(reqParams));
5071
5076
  for (let i = 0; i < entityIds.length; i++) {
5072
5077
  const entityId = entityIds[i];
5073
- api.Cache.Remove(GetCacheKey(entityId));
5078
+ api.Cache.RemoveByStartsWith(GetStartsWithKey(entityId));
5074
5079
  }
5075
5080
  });
5076
5081
  }
@@ -5090,7 +5095,7 @@
5090
5095
  }
5091
5096
  const reqUrl = `entity/${data.Bruce.ID}/?dataoverride=${override}&BruceEntityType=${data.Bruce["EntityType.ID"]}`;
5092
5097
  const res = yield api.POST(reqUrl, data, exports.Api.PrepReqParams(reqParams));
5093
- api.Cache.Remove(GetCacheKey(data.Bruce.ID));
5098
+ api.Cache.RemoveByStartsWith(GetStartsWithKey(data.Bruce.ID));
5094
5099
  return {
5095
5100
  entity: res
5096
5101
  };
@@ -11546,7 +11551,112 @@
11546
11551
  Plugin.GetRunFunction = GetRunFunction;
11547
11552
  })(exports.Plugin || (exports.Plugin = {}));
11548
11553
 
11549
- const VERSION$1 = "2.6.1";
11554
+ (function (DataSource) {
11555
+ function GetCacheKey(id) {
11556
+ return exports.Api.ECacheKey.DataSource + exports.Api.ECacheKey.Id + id;
11557
+ }
11558
+ DataSource.GetCacheKey = GetCacheKey;
11559
+ function GetListCacheKey() {
11560
+ return exports.Api.ECacheKey.DataSource;
11561
+ }
11562
+ DataSource.GetListCacheKey = GetListCacheKey;
11563
+ let EType;
11564
+ (function (EType) {
11565
+ EType["IDMapping"] = "IDMapping";
11566
+ })(EType = DataSource.EType || (DataSource.EType = {}));
11567
+ function Update(params) {
11568
+ return __awaiter(this, void 0, void 0, function* () {
11569
+ let { source: data, api, req: reqParams } = params;
11570
+ if (!api) {
11571
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
11572
+ }
11573
+ const url = `source` + (data.ID == null ? "" : "/" + data.ID);
11574
+ const res = yield api.POST(url, data, exports.Api.PrepReqParams(reqParams));
11575
+ yield api.Cache.Remove(GetCacheKey(data.ID));
11576
+ yield api.Cache.Remove(GetListCacheKey());
11577
+ return {
11578
+ source: res
11579
+ };
11580
+ });
11581
+ }
11582
+ DataSource.Update = Update;
11583
+ function Delete(params) {
11584
+ return __awaiter(this, void 0, void 0, function* () {
11585
+ let { id, api, req: reqParams } = params;
11586
+ if (!api) {
11587
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
11588
+ }
11589
+ yield api.DELETE(`source/${id}`, exports.Api.PrepReqParams(reqParams));
11590
+ yield api.Cache.Remove(GetCacheKey(id));
11591
+ yield api.Cache.Remove(GetListCacheKey());
11592
+ });
11593
+ }
11594
+ DataSource.Delete = Delete;
11595
+ function Get(params) {
11596
+ return __awaiter(this, void 0, void 0, function* () {
11597
+ let { id, api, req: reqParams } = params;
11598
+ if (!api) {
11599
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
11600
+ }
11601
+ reqParams = exports.Api.PrepReqParams(reqParams);
11602
+ const cacheData = yield api.GetCacheItem(GetCacheKey(id), reqParams);
11603
+ if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.found) {
11604
+ return cacheData.data;
11605
+ }
11606
+ const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
11607
+ try {
11608
+ const data = yield api.GET(`source/${id}`, exports.Api.PrepReqParams(reqParams));
11609
+ res({
11610
+ source: data
11611
+ });
11612
+ }
11613
+ catch (e) {
11614
+ rej(e);
11615
+ }
11616
+ }));
11617
+ api.SetCacheItem({
11618
+ key: GetCacheKey(id),
11619
+ value: prom,
11620
+ req: reqParams
11621
+ });
11622
+ return prom;
11623
+ });
11624
+ }
11625
+ DataSource.Get = Get;
11626
+ function GetList(params) {
11627
+ return __awaiter(this, void 0, void 0, function* () {
11628
+ let { api, req: reqParams } = params;
11629
+ if (!api) {
11630
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
11631
+ }
11632
+ reqParams = exports.Api.PrepReqParams(reqParams);
11633
+ const cacheData = yield api.GetCacheItem(GetListCacheKey(), reqParams);
11634
+ if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.found) {
11635
+ return cacheData.data;
11636
+ }
11637
+ const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
11638
+ try {
11639
+ const data = yield api.GET("sources", exports.Api.PrepReqParams(reqParams));
11640
+ res({
11641
+ sources: data === null || data === void 0 ? void 0 : data.Items
11642
+ });
11643
+ }
11644
+ catch (e) {
11645
+ rej(e);
11646
+ }
11647
+ }));
11648
+ api.SetCacheItem({
11649
+ key: GetListCacheKey(),
11650
+ value: prom,
11651
+ req: reqParams
11652
+ });
11653
+ return prom;
11654
+ });
11655
+ }
11656
+ DataSource.GetList = GetList;
11657
+ })(exports.DataSource || (exports.DataSource = {}));
11658
+
11659
+ const VERSION$1 = "2.6.2";
11550
11660
 
11551
11661
  exports.VERSION = VERSION$1;
11552
11662
  exports.AbstractApi = AbstractApi;