bruce-models 0.4.6 → 0.4.8

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.
@@ -1363,7 +1363,7 @@ var Entity;
1363
1363
  // Attribute filter.
1364
1364
  (!requestFilter ? "" : "&Filter=" + Api.Encode(JSON.stringify(requestFilter))) +
1365
1365
  // Order by attribute + sort order.
1366
- (!filter.orderBy ? "" : "&OrderBy=" + Api.Encode(JSON.stringify(filter.orderBy))) +
1366
+ (!filter.orderBy ? "" : "&OrderBy=" + JSON.stringify(filter.orderBy)) +
1367
1367
  (filter.sortOrder ? "&SortOrder=" + (filter.sortOrder == Api.ESortOrder.Asc ? "ASC" : "DESC") : "");
1368
1368
  return [4 /*yield*/, api.GET(url, Api.PrepReqParams())];
1369
1369
  case 1:
@@ -2677,6 +2677,34 @@ var EntityRelation;
2677
2677
  return Api.ECacheKey.Relation + Api.ECacheKey.RelationType + Api.ECacheKey.Id + params.typeId + Api.ECacheKey.Id + params.oneWayOnly + Api.ECacheKey.Id + params.loadEntityData;
2678
2678
  }
2679
2679
  EntityRelation.GetListCacheKey = GetListCacheKey;
2680
+ function Create(api, data) {
2681
+ return __awaiter(this, void 0, void 0, function () {
2682
+ var reqData, url;
2683
+ return __generator(this, function (_a) {
2684
+ switch (_a.label) {
2685
+ case 0:
2686
+ if (!data["Principal.Entity.ID"] || !data["Related.Entity.ID"] || !data["Relation.Type.ID"]) {
2687
+ throw ("Principal Entity ID, Related Entity ID, and Relation Type ID are required.");
2688
+ }
2689
+ reqData = {
2690
+ "Related.Entity.ID": [data["Related.Entity.ID"]]
2691
+ };
2692
+ url = "entity/" + data["Principal.Entity.ID"] + "/relation/" + data["Relation.Type.ID"] + "/add";
2693
+ return [4 /*yield*/, api.POST(url, reqData, Api.PrepReqParams())];
2694
+ case 1:
2695
+ data = _a.sent();
2696
+ api.Cache.RemoveByStartsWith(Api.ECacheKey.Relation + Api.ECacheKey.Id + data["Principal.Entity.ID"]);
2697
+ api.Cache.RemoveByStartsWith(Api.ECacheKey.Relation + Api.ECacheKey.Id + data["Related.Entity.ID"]);
2698
+ api.Cache.RemoveByStartsWith(Api.ECacheKey.Relation + Api.ECacheKey.RelationType + Api.ECacheKey.Id + data["Relation.Type.ID"]);
2699
+ if (data["Data.Entity.ID"]) {
2700
+ api.Cache.RemoveByStartsWith(Api.ECacheKey.Relation + Api.ECacheKey.Entity + Api.ECacheKey.Id + data["Data.Entity.ID"]);
2701
+ }
2702
+ return [2 /*return*/, data];
2703
+ }
2704
+ });
2705
+ });
2706
+ }
2707
+ EntityRelation.Create = Create;
2680
2708
  function Update(api, data) {
2681
2709
  return __awaiter(this, void 0, void 0, function () {
2682
2710
  var url;