bruce-models 0.4.6 → 0.4.7

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.
@@ -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;