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.
@@ -531,6 +531,37 @@
531
531
  });
532
532
  });
533
533
  };
534
+ AbstractApi.prototype.put = function (url, data, params) {
535
+ var _a;
536
+ return __awaiter(this, void 0, void 0, function () {
537
+ var res;
538
+ var _b;
539
+ return __generator(this, function (_c) {
540
+ switch (_c.label) {
541
+ case 0:
542
+ if (!params) {
543
+ params = {};
544
+ }
545
+ params.headers = params.headers || {};
546
+ params.headers = __assign((_b = { "Content-Type": "application/json;" }, _b[this.ssidHeader] = this.ssid, _b), params.headers);
547
+ if (!data) {
548
+ data = {};
549
+ }
550
+ if (typeof data != "string") {
551
+ data = JSON.stringify(data);
552
+ }
553
+ return [4 /*yield*/, fetch(url, {
554
+ headers: params.headers,
555
+ method: "PUT",
556
+ body: data
557
+ })];
558
+ case 1:
559
+ res = _c.sent();
560
+ return [2 /*return*/, parseResult(res, (_a = params.response) === null || _a === void 0 ? void 0 : _a.encoding)];
561
+ }
562
+ });
563
+ });
564
+ };
534
565
  AbstractApi.prototype.upload = function (url, blob, params) {
535
566
  return __awaiter(this, void 0, void 0, function () {
536
567
  var _this = this;
@@ -655,6 +686,13 @@
655
686
  });
656
687
  });
657
688
  };
689
+ BruceApi.prototype.PUT = function (url, data, params) {
690
+ return __awaiter(this, void 0, void 0, function () {
691
+ return __generator(this, function (_a) {
692
+ return [2 /*return*/, this.put(this.baseUrl + url, data, params)];
693
+ });
694
+ });
695
+ };
658
696
  BruceApi.prototype.UPLOAD = function (url, blob, params) {
659
697
  return __awaiter(this, void 0, void 0, function () {
660
698
  return __generator(this, function (_a) {
@@ -1839,7 +1877,7 @@
1839
1877
  if (!(data === null || data === void 0 ? void 0 : data.ID)) {
1840
1878
  throw ("Type ID is required.");
1841
1879
  }
1842
- return [4 /*yield*/, api.post("entityAttachmentType/" + data.ID, data, exports.Api.PrepReqParams())];
1880
+ return [4 /*yield*/, api.POST("entityAttachmentType/" + data.ID, data, exports.Api.PrepReqParams())];
1843
1881
  case 1:
1844
1882
  data = _a.sent();
1845
1883
  api.Cache.Remove(GetCacheKey(data.ID));
@@ -2397,7 +2435,7 @@
2397
2435
  if (!data.ID) {
2398
2436
  data.ID = exports.ObjectUtils.UId();
2399
2437
  }
2400
- return [4 /*yield*/, api.post("entityRelationType/" + data.ID, data, exports.Api.PrepReqParams())];
2438
+ return [4 /*yield*/, api.POST("entityRelationType/" + data.ID, data, exports.Api.PrepReqParams())];
2401
2439
  case 1:
2402
2440
  data = _a.sent();
2403
2441
  api.Cache.Remove(GetCacheKey(data.ID));
@@ -2433,7 +2471,7 @@
2433
2471
  throw ("Principal Entity ID, Related Entity ID, and Relation Type ID are required.");
2434
2472
  }
2435
2473
  url = "entity/" + data["Principal.Entity.ID"] + "/otherEntityID/" + data["Related.Entity.ID"] + "/relation/" + data["Relation.Type.ID"] + "/update";
2436
- return [4 /*yield*/, api.post(url, data, exports.Api.PrepReqParams())];
2474
+ return [4 /*yield*/, api.POST(url, data, exports.Api.PrepReqParams())];
2437
2475
  case 1:
2438
2476
  data = _a.sent();
2439
2477
  api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Relation + exports.Api.ECacheKey.Id + data["Principal.Entity.ID"]);
@@ -2813,7 +2851,7 @@
2813
2851
  throw ("Tag ID is required.");
2814
2852
  }
2815
2853
  url = data.ID ? "layer/" + data.ID : "layer";
2816
- return [4 /*yield*/, api.post(url, data, exports.Api.PrepReqParams())];
2854
+ return [4 /*yield*/, api.POST(url, data, exports.Api.PrepReqParams())];
2817
2855
  case 1:
2818
2856
  data = _a.sent();
2819
2857
  api.Cache.Remove(GetCacheKey(data.ID));
@@ -3643,7 +3681,7 @@
3643
3681
  if (!(data === null || data === void 0 ? void 0 : data.ProgramId)) {
3644
3682
  throw ("Program ID is required.");
3645
3683
  }
3646
- return [4 /*yield*/, api.post("programkey", data, exports.Api.PrepReqParams())];
3684
+ return [4 /*yield*/, api.POST("programkey", data, exports.Api.PrepReqParams())];
3647
3685
  case 1:
3648
3686
  data = _a.sent();
3649
3687
  api.Cache.Remove(GetCacheKey(data.ProgramId));
@@ -3785,7 +3823,7 @@
3785
3823
  res = _a.sent();
3786
3824
  data = __assign(__assign({}, data), res);
3787
3825
  _a.label = 2;
3788
- case 2: return [4 /*yield*/, api.post("tileset", data)];
3826
+ case 2: return [4 /*yield*/, api.POST("tileset", data)];
3789
3827
  case 3:
3790
3828
  data = _a.sent();
3791
3829
  api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Tileset + exports.Api.ECacheKey.Id + data.id);
@@ -4205,7 +4243,7 @@
4205
4243
  if (!(data === null || data === void 0 ? void 0 : data.Title)) {
4206
4244
  data.Title = data.ID;
4207
4245
  }
4208
- return [4 /*yield*/, api.post("ui.view/" + viewId + "/slide/" + data.ID, data, exports.Api.PrepReqParams())];
4246
+ return [4 /*yield*/, api.POST("ui.view/" + viewId + "/slide/" + data.ID, data, exports.Api.PrepReqParams())];
4209
4247
  case 1:
4210
4248
  data = _a.sent();
4211
4249
  api.Cache.Remove(GetCacheKey(viewId, data.ID));
@@ -4301,18 +4339,33 @@
4301
4339
  ProjectView.Delete = Delete;
4302
4340
  function Update(api, data) {
4303
4341
  return __awaiter(this, void 0, void 0, function () {
4342
+ var isNew;
4304
4343
  return __generator(this, function (_a) {
4305
4344
  switch (_a.label) {
4306
4345
  case 0:
4307
- if (!(data === null || data === void 0 ? void 0 : data.ID)) {
4346
+ if (!data) {
4347
+ data = {};
4348
+ }
4349
+ isNew = !data.ID;
4350
+ if (!data.ID) {
4308
4351
  data.ID = exports.ObjectUtils.UId();
4309
4352
  }
4310
- if (!(data === null || data === void 0 ? void 0 : data.Name)) {
4353
+ if (!data.Name) {
4311
4354
  data.Name = data.ID;
4312
4355
  }
4313
- return [4 /*yield*/, api.post("ui.view", data, exports.Api.PrepReqParams())];
4356
+ if (!data.CreatedByUIVersion) {
4357
+ data.CreatedByUIVersion = "-1";
4358
+ }
4359
+ if (!isNew) return [3 /*break*/, 2];
4360
+ return [4 /*yield*/, api.POST("ui.view/" + data.ID, data, exports.Api.PrepReqParams())];
4314
4361
  case 1:
4315
4362
  data = _a.sent();
4363
+ return [3 /*break*/, 4];
4364
+ case 2: return [4 /*yield*/, api.PUT("ui.view/" + data.ID, data, exports.Api.PrepReqParams())];
4365
+ case 3:
4366
+ data = _a.sent();
4367
+ _a.label = 4;
4368
+ case 4:
4316
4369
  api.Cache.Remove(GetCacheKey(data.ID));
4317
4370
  api.Cache.Remove(GetListCacheKey());
4318
4371
  return [2 /*return*/, data];
@@ -4595,7 +4648,7 @@
4595
4648
  if (!(data === null || data === void 0 ? void 0 : data.name)) {
4596
4649
  throw ("UCS name is required.");
4597
4650
  }
4598
- return [4 /*yield*/, api.post("ucs" + (!data.id ? "" : "/" + data.id), data)];
4651
+ return [4 /*yield*/, api.POST("ucs" + (!data.id ? "" : "/" + data.id), data)];
4599
4652
  case 1:
4600
4653
  data = _a.sent();
4601
4654
  api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Ucs + exports.Api.ECacheKey.Id + data.id);