bruce-models 2.0.3 → 2.0.5

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.
@@ -1808,24 +1808,24 @@ var PathUtils;
1808
1808
  */
1809
1809
  var Entity;
1810
1810
  (function (Entity) {
1811
- function GetCacheKey(entityId) {
1812
- return `${Api.ECacheKey.Entity}${Api.ECacheKey.Id}${entityId}`;
1811
+ function GetCacheKey(entityId, expandLocation) {
1812
+ return `${Api.ECacheKey.Entity}${Api.ECacheKey.Id}${entityId}${String(Boolean(expandLocation))}`;
1813
1813
  }
1814
1814
  Entity.GetCacheKey = GetCacheKey;
1815
1815
  function Get(params) {
1816
1816
  return __awaiter(this, void 0, void 0, function* () {
1817
- const { api, entityId, req: reqParams } = params;
1817
+ const { api, entityId, req: reqParams, expandLocation } = params;
1818
1818
  if (!entityId) {
1819
1819
  throw ("Entity ID is required.");
1820
1820
  }
1821
- const key = GetCacheKey(entityId);
1821
+ const key = GetCacheKey(entityId, expandLocation);
1822
1822
  const cacheData = api.GetCacheItem(key, reqParams);
1823
1823
  if (cacheData) {
1824
1824
  return cacheData;
1825
1825
  }
1826
1826
  const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
1827
1827
  try {
1828
- const data = yield api.GET(`entity/${entityId}`, Api.PrepReqParams(reqParams));
1828
+ const data = yield api.GET(`entity/${entityId}${expandLocation ? "?$expand=location" : ""}`, Api.PrepReqParams(reqParams));
1829
1829
  res({
1830
1830
  entity: data
1831
1831
  });
@@ -3771,6 +3771,23 @@ var EntityRelation;
3771
3771
  });
3772
3772
  }
3773
3773
  EntityRelation.Create = Create;
3774
+ function Delete(params) {
3775
+ return __awaiter(this, void 0, void 0, function* () {
3776
+ const { api, principalEntityId, relatedEntityId, relationTypeId, req: reqParams } = params;
3777
+ if (!principalEntityId || !relatedEntityId || !relationTypeId) {
3778
+ throw new Error("Principal Entity ID, Related Entity ID, and Relation Type ID are required.");
3779
+ }
3780
+ const url = `entity/${principalEntityId}/relation/${relationTypeId}/delete`;
3781
+ yield api.POST(url, {
3782
+ "Related.Entity.ID": [relatedEntityId]
3783
+ }, Api.PrepReqParams(reqParams));
3784
+ // Remove related cache entries
3785
+ api.Cache.RemoveByStartsWith(Api.ECacheKey.Relation + Api.ECacheKey.Id + principalEntityId);
3786
+ api.Cache.RemoveByStartsWith(Api.ECacheKey.Relation + Api.ECacheKey.Id + relatedEntityId);
3787
+ api.Cache.RemoveByStartsWith(Api.ECacheKey.Relation + Api.ECacheKey.RelationType + Api.ECacheKey.Id + relationTypeId);
3788
+ });
3789
+ }
3790
+ EntityRelation.Delete = Delete;
3774
3791
  function Update(params) {
3775
3792
  return __awaiter(this, void 0, void 0, function* () {
3776
3793
  const { api, relation: data, req: reqParams } = params;
@@ -6434,6 +6451,13 @@ var PendingAction;
6434
6451
  EStatus["Complete"] = "COMPLETE";
6435
6452
  EStatus["Failed"] = "FAILED";
6436
6453
  })(EStatus = PendingAction.EStatus || (PendingAction.EStatus = {}));
6454
+ let EMessageType;
6455
+ (function (EMessageType) {
6456
+ EMessageType["Warn"] = "WARNING";
6457
+ EMessageType["Error"] = "ERROR";
6458
+ EMessageType["Status"] = "STATUS";
6459
+ EMessageType["Info"] = "INFO";
6460
+ })(EMessageType = PendingAction.EMessageType || (PendingAction.EMessageType = {}));
6437
6461
  function Get(params) {
6438
6462
  return __awaiter(this, void 0, void 0, function* () {
6439
6463
  const { api, actionId, req: reqParams } = params;
@@ -6459,7 +6483,7 @@ var PendingAction;
6459
6483
  PendingAction.GetRelevantList = GetRelevantList;
6460
6484
  function GetMessages(params) {
6461
6485
  return __awaiter(this, void 0, void 0, function* () {
6462
- let { api, actionId, order, startIndex, amount, req: reqParams } = params;
6486
+ let { api, actionId, order, startIndex, amount, req: reqParams, types } = params;
6463
6487
  if (amount == null) {
6464
6488
  amount = 500;
6465
6489
  }
@@ -6469,7 +6493,12 @@ var PendingAction;
6469
6493
  if (order == null) {
6470
6494
  order = Api.ESortOrder.Asc;
6471
6495
  }
6472
- const args = `?SortOrder=${order == Api.ESortOrder.Desc ? "DESC" : "ASC"}&PageSize=${amount}&PageIndex=${startIndex}`;
6496
+ let args = `?SortOrder=${order == Api.ESortOrder.Desc ? "DESC" : "ASC"}&PageSize=${amount}&PageIndex=${startIndex}`;
6497
+ if (types === null || types === void 0 ? void 0 : types.length) {
6498
+ for (let i = 0; i < types.length; i++) {
6499
+ args += `&Type=${types[i]}`;
6500
+ }
6501
+ }
6473
6502
  const data = yield api.GET(`pendingAction/${actionId}/progressMessages` + args, Api.PrepReqParams(reqParams));
6474
6503
  return {
6475
6504
  messages: data.Items