bruce-models 0.4.5 → 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.
@@ -1570,8 +1570,16 @@ var Calculator;
1570
1570
  value = BruceVariable.SwapValues(value, entity);
1571
1571
  return eval(value);
1572
1572
  }
1573
- catch (e) {
1574
- console.error(e);
1573
+ catch (exception) {
1574
+ var e = exception;
1575
+ var suppress = false;
1576
+ if (e && typeof e == "object") {
1577
+ var msg = e.message;
1578
+ suppress = !!msg && msg.includes("Unexpected end");
1579
+ }
1580
+ if (!suppress) {
1581
+ console.error(e);
1582
+ }
1575
1583
  }
1576
1584
  }
1577
1585
  return value;
@@ -2669,6 +2677,34 @@ var EntityRelation;
2669
2677
  return Api.ECacheKey.Relation + Api.ECacheKey.RelationType + Api.ECacheKey.Id + params.typeId + Api.ECacheKey.Id + params.oneWayOnly + Api.ECacheKey.Id + params.loadEntityData;
2670
2678
  }
2671
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;
2672
2708
  function Update(api, data) {
2673
2709
  return __awaiter(this, void 0, void 0, function () {
2674
2710
  var url;