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.
@@ -1779,24 +1779,24 @@
1779
1779
  })(exports.PathUtils || (exports.PathUtils = {}));
1780
1780
 
1781
1781
  (function (Entity) {
1782
- function GetCacheKey(entityId) {
1783
- return `${exports.Api.ECacheKey.Entity}${exports.Api.ECacheKey.Id}${entityId}`;
1782
+ function GetCacheKey(entityId, expandLocation) {
1783
+ return `${exports.Api.ECacheKey.Entity}${exports.Api.ECacheKey.Id}${entityId}${String(Boolean(expandLocation))}`;
1784
1784
  }
1785
1785
  Entity.GetCacheKey = GetCacheKey;
1786
1786
  function Get(params) {
1787
1787
  return __awaiter(this, void 0, void 0, function* () {
1788
- const { api, entityId, req: reqParams } = params;
1788
+ const { api, entityId, req: reqParams, expandLocation } = params;
1789
1789
  if (!entityId) {
1790
1790
  throw ("Entity ID is required.");
1791
1791
  }
1792
- const key = GetCacheKey(entityId);
1792
+ const key = GetCacheKey(entityId, expandLocation);
1793
1793
  const cacheData = api.GetCacheItem(key, reqParams);
1794
1794
  if (cacheData) {
1795
1795
  return cacheData;
1796
1796
  }
1797
1797
  const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
1798
1798
  try {
1799
- const data = yield api.GET(`entity/${entityId}`, exports.Api.PrepReqParams(reqParams));
1799
+ const data = yield api.GET(`entity/${entityId}${expandLocation ? "?$expand=location" : ""}`, exports.Api.PrepReqParams(reqParams));
1800
1800
  res({
1801
1801
  entity: data
1802
1802
  });
@@ -3684,6 +3684,23 @@
3684
3684
  });
3685
3685
  }
3686
3686
  EntityRelation.Create = Create;
3687
+ function Delete(params) {
3688
+ return __awaiter(this, void 0, void 0, function* () {
3689
+ const { api, principalEntityId, relatedEntityId, relationTypeId, req: reqParams } = params;
3690
+ if (!principalEntityId || !relatedEntityId || !relationTypeId) {
3691
+ throw new Error("Principal Entity ID, Related Entity ID, and Relation Type ID are required.");
3692
+ }
3693
+ const url = `entity/${principalEntityId}/relation/${relationTypeId}/delete`;
3694
+ yield api.POST(url, {
3695
+ "Related.Entity.ID": [relatedEntityId]
3696
+ }, exports.Api.PrepReqParams(reqParams));
3697
+ // Remove related cache entries
3698
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Relation + exports.Api.ECacheKey.Id + principalEntityId);
3699
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Relation + exports.Api.ECacheKey.Id + relatedEntityId);
3700
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Relation + exports.Api.ECacheKey.RelationType + exports.Api.ECacheKey.Id + relationTypeId);
3701
+ });
3702
+ }
3703
+ EntityRelation.Delete = Delete;
3687
3704
  function Update(params) {
3688
3705
  return __awaiter(this, void 0, void 0, function* () {
3689
3706
  const { api, relation: data, req: reqParams } = params;
@@ -6258,6 +6275,13 @@
6258
6275
  EStatus["Complete"] = "COMPLETE";
6259
6276
  EStatus["Failed"] = "FAILED";
6260
6277
  })(EStatus = PendingAction.EStatus || (PendingAction.EStatus = {}));
6278
+ let EMessageType;
6279
+ (function (EMessageType) {
6280
+ EMessageType["Warn"] = "WARNING";
6281
+ EMessageType["Error"] = "ERROR";
6282
+ EMessageType["Status"] = "STATUS";
6283
+ EMessageType["Info"] = "INFO";
6284
+ })(EMessageType = PendingAction.EMessageType || (PendingAction.EMessageType = {}));
6261
6285
  function Get(params) {
6262
6286
  return __awaiter(this, void 0, void 0, function* () {
6263
6287
  const { api, actionId, req: reqParams } = params;
@@ -6283,7 +6307,7 @@
6283
6307
  PendingAction.GetRelevantList = GetRelevantList;
6284
6308
  function GetMessages(params) {
6285
6309
  return __awaiter(this, void 0, void 0, function* () {
6286
- let { api, actionId, order, startIndex, amount, req: reqParams } = params;
6310
+ let { api, actionId, order, startIndex, amount, req: reqParams, types } = params;
6287
6311
  if (amount == null) {
6288
6312
  amount = 500;
6289
6313
  }
@@ -6293,7 +6317,12 @@
6293
6317
  if (order == null) {
6294
6318
  order = exports.Api.ESortOrder.Asc;
6295
6319
  }
6296
- const args = `?SortOrder=${order == exports.Api.ESortOrder.Desc ? "DESC" : "ASC"}&PageSize=${amount}&PageIndex=${startIndex}`;
6320
+ let args = `?SortOrder=${order == exports.Api.ESortOrder.Desc ? "DESC" : "ASC"}&PageSize=${amount}&PageIndex=${startIndex}`;
6321
+ if (types === null || types === void 0 ? void 0 : types.length) {
6322
+ for (let i = 0; i < types.length; i++) {
6323
+ args += `&Type=${types[i]}`;
6324
+ }
6325
+ }
6297
6326
  const data = yield api.GET(`pendingAction/${actionId}/progressMessages` + args, exports.Api.PrepReqParams(reqParams));
6298
6327
  return {
6299
6328
  messages: data.Items