bruce-models 0.2.9 → 0.3.1

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.
@@ -536,6 +536,37 @@ var AbstractApi = /** @class */ (function () {
536
536
  });
537
537
  });
538
538
  };
539
+ AbstractApi.prototype.put = function (url, data, params) {
540
+ var _a;
541
+ return __awaiter(this, void 0, void 0, function () {
542
+ var res;
543
+ var _b;
544
+ return __generator(this, function (_c) {
545
+ switch (_c.label) {
546
+ case 0:
547
+ if (!params) {
548
+ params = {};
549
+ }
550
+ params.headers = params.headers || {};
551
+ params.headers = __assign((_b = { "Content-Type": "application/json;" }, _b[this.ssidHeader] = this.ssid, _b), params.headers);
552
+ if (!data) {
553
+ data = {};
554
+ }
555
+ if (typeof data != "string") {
556
+ data = JSON.stringify(data);
557
+ }
558
+ return [4 /*yield*/, fetch(url, {
559
+ headers: params.headers,
560
+ method: "PUT",
561
+ body: data
562
+ })];
563
+ case 1:
564
+ res = _c.sent();
565
+ return [2 /*return*/, parseResult(res, (_a = params.response) === null || _a === void 0 ? void 0 : _a.encoding)];
566
+ }
567
+ });
568
+ });
569
+ };
539
570
  AbstractApi.prototype.upload = function (url, blob, params) {
540
571
  return __awaiter(this, void 0, void 0, function () {
541
572
  var _this = this;
@@ -660,6 +691,13 @@ var BruceApi = /** @class */ (function (_super) {
660
691
  });
661
692
  });
662
693
  };
694
+ BruceApi.prototype.PUT = function (url, data, params) {
695
+ return __awaiter(this, void 0, void 0, function () {
696
+ return __generator(this, function (_a) {
697
+ return [2 /*return*/, this.put(this.baseUrl + url, data, params)];
698
+ });
699
+ });
700
+ };
663
701
  BruceApi.prototype.UPLOAD = function (url, blob, params) {
664
702
  return __awaiter(this, void 0, void 0, function () {
665
703
  return __generator(this, function (_a) {
@@ -1868,7 +1906,7 @@ var EntityAttachmentType;
1868
1906
  if (!(data === null || data === void 0 ? void 0 : data.ID)) {
1869
1907
  throw ("Type ID is required.");
1870
1908
  }
1871
- return [4 /*yield*/, api.post("entityAttachmentType/" + data.ID, data, Api.PrepReqParams())];
1909
+ return [4 /*yield*/, api.POST("entityAttachmentType/" + data.ID, data, Api.PrepReqParams())];
1872
1910
  case 1:
1873
1911
  data = _a.sent();
1874
1912
  api.Cache.Remove(GetCacheKey(data.ID));
@@ -2454,7 +2492,7 @@ var EntityRelationType;
2454
2492
  if (!data.ID) {
2455
2493
  data.ID = ObjectUtils.UId();
2456
2494
  }
2457
- return [4 /*yield*/, api.post("entityRelationType/" + data.ID, data, Api.PrepReqParams())];
2495
+ return [4 /*yield*/, api.POST("entityRelationType/" + data.ID, data, Api.PrepReqParams())];
2458
2496
  case 1:
2459
2497
  data = _a.sent();
2460
2498
  api.Cache.Remove(GetCacheKey(data.ID));
@@ -2496,7 +2534,7 @@ var EntityRelation;
2496
2534
  throw ("Principal Entity ID, Related Entity ID, and Relation Type ID are required.");
2497
2535
  }
2498
2536
  url = "entity/" + data["Principal.Entity.ID"] + "/otherEntityID/" + data["Related.Entity.ID"] + "/relation/" + data["Relation.Type.ID"] + "/update";
2499
- return [4 /*yield*/, api.post(url, data, Api.PrepReqParams())];
2537
+ return [4 /*yield*/, api.POST(url, data, Api.PrepReqParams())];
2500
2538
  case 1:
2501
2539
  data = _a.sent();
2502
2540
  api.Cache.RemoveByStartsWith(Api.ECacheKey.Relation + Api.ECacheKey.Id + data["Principal.Entity.ID"]);
@@ -2888,7 +2926,7 @@ var EntityTag;
2888
2926
  throw ("Tag ID is required.");
2889
2927
  }
2890
2928
  url = data.ID ? "layer/" + data.ID : "layer";
2891
- return [4 /*yield*/, api.post(url, data, Api.PrepReqParams())];
2929
+ return [4 /*yield*/, api.POST(url, data, Api.PrepReqParams())];
2892
2930
  case 1:
2893
2931
  data = _a.sent();
2894
2932
  api.Cache.Remove(GetCacheKey(data.ID));
@@ -3751,7 +3789,7 @@ var ProgramKey;
3751
3789
  if (!(data === null || data === void 0 ? void 0 : data.ProgramId)) {
3752
3790
  throw ("Program ID is required.");
3753
3791
  }
3754
- return [4 /*yield*/, api.post("programkey", data, Api.PrepReqParams())];
3792
+ return [4 /*yield*/, api.POST("programkey", data, Api.PrepReqParams())];
3755
3793
  case 1:
3756
3794
  data = _a.sent();
3757
3795
  api.Cache.Remove(GetCacheKey(data.ProgramId));
@@ -3905,7 +3943,7 @@ var Tileset;
3905
3943
  res = _a.sent();
3906
3944
  data = __assign(__assign({}, data), res);
3907
3945
  _a.label = 2;
3908
- case 2: return [4 /*yield*/, api.post("tileset", data)];
3946
+ case 2: return [4 /*yield*/, api.POST("tileset", data)];
3909
3947
  case 3:
3910
3948
  data = _a.sent();
3911
3949
  api.Cache.RemoveByStartsWith(Api.ECacheKey.Tileset + Api.ECacheKey.Id + data.id);
@@ -4338,7 +4376,7 @@ var ProjectViewBookmark;
4338
4376
  if (!(data === null || data === void 0 ? void 0 : data.Title)) {
4339
4377
  data.Title = data.ID;
4340
4378
  }
4341
- return [4 /*yield*/, api.post("ui.view/" + viewId + "/slide/" + data.ID, data, Api.PrepReqParams())];
4379
+ return [4 /*yield*/, api.POST("ui.view/" + viewId + "/slide/" + data.ID, data, Api.PrepReqParams())];
4342
4380
  case 1:
4343
4381
  data = _a.sent();
4344
4382
  api.Cache.Remove(GetCacheKey(viewId, data.ID));
@@ -4440,18 +4478,33 @@ var ProjectView;
4440
4478
  ProjectView.Delete = Delete;
4441
4479
  function Update(api, data) {
4442
4480
  return __awaiter(this, void 0, void 0, function () {
4481
+ var isNew;
4443
4482
  return __generator(this, function (_a) {
4444
4483
  switch (_a.label) {
4445
4484
  case 0:
4446
- if (!(data === null || data === void 0 ? void 0 : data.ID)) {
4485
+ if (!data) {
4486
+ data = {};
4487
+ }
4488
+ isNew = !data.ID;
4489
+ if (!data.ID) {
4447
4490
  data.ID = ObjectUtils.UId();
4448
4491
  }
4449
- if (!(data === null || data === void 0 ? void 0 : data.Name)) {
4492
+ if (!data.Name) {
4450
4493
  data.Name = data.ID;
4451
4494
  }
4452
- return [4 /*yield*/, api.post("ui.view", data, Api.PrepReqParams())];
4495
+ if (!data.CreatedByUIVersion) {
4496
+ data.CreatedByUIVersion = "-1";
4497
+ }
4498
+ if (!isNew) return [3 /*break*/, 2];
4499
+ return [4 /*yield*/, api.POST("ui.view/" + data.ID, data, Api.PrepReqParams())];
4453
4500
  case 1:
4454
4501
  data = _a.sent();
4502
+ return [3 /*break*/, 4];
4503
+ case 2: return [4 /*yield*/, api.PUT("ui.view/" + data.ID, data, Api.PrepReqParams())];
4504
+ case 3:
4505
+ data = _a.sent();
4506
+ _a.label = 4;
4507
+ case 4:
4455
4508
  api.Cache.Remove(GetCacheKey(data.ID));
4456
4509
  api.Cache.Remove(GetListCacheKey());
4457
4510
  return [2 /*return*/, data];
@@ -4756,7 +4809,7 @@ var Ucs;
4756
4809
  if (!(data === null || data === void 0 ? void 0 : data.name)) {
4757
4810
  throw ("UCS name is required.");
4758
4811
  }
4759
- return [4 /*yield*/, api.post("ucs" + (!data.id ? "" : "/" + data.id), data)];
4812
+ return [4 /*yield*/, api.POST("ucs" + (!data.id ? "" : "/" + data.id), data)];
4760
4813
  case 1:
4761
4814
  data = _a.sent();
4762
4815
  api.Cache.RemoveByStartsWith(Api.ECacheKey.Ucs + Api.ECacheKey.Id + data.id);