bruce-models 0.3.0 → 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) {
@@ -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];