bruce-models 0.6.9 → 0.7.2

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.
@@ -626,6 +626,206 @@
626
626
  return AbstractApi;
627
627
  }());
628
628
 
629
+ var ACCOUNT_EXCLUSIONS = ["hyperportal", "hypeportal", "bviewer"];
630
+ (function (Account) {
631
+ function GetCacheKey(accountId, appSettingsId) {
632
+ if (appSettingsId) {
633
+ return exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + accountId + exports.Api.ECacheKey + appSettingsId;
634
+ }
635
+ return exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + accountId;
636
+ }
637
+ Account.GetCacheKey = GetCacheKey;
638
+ function GetListCacheKey(ssid) {
639
+ return exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Session + exports.Api.ECacheKey.Id + ssid;
640
+ }
641
+ Account.GetListCacheKey = GetListCacheKey;
642
+ var EDbRegion;
643
+ (function (EDbRegion) {
644
+ EDbRegion["USA"] = "US";
645
+ EDbRegion["Paris"] = "EU";
646
+ EDbRegion["Singapore"] = "SE";
647
+ EDbRegion["Australia"] = "AU";
648
+ })(EDbRegion = Account.EDbRegion || (Account.EDbRegion = {}));
649
+ var EAppId;
650
+ (function (EAppId) {
651
+ EAppId["BruceApi"] = "BruceAPI";
652
+ })(EAppId = Account.EAppId || (Account.EAppId = {}));
653
+ var EStarterContent;
654
+ (function (EStarterContent) {
655
+ EStarterContent["Default"] = "default";
656
+ EStarterContent["None"] = "none";
657
+ })(EStarterContent = Account.EStarterContent || (Account.EStarterContent = {}));
658
+ Account.DbRegions = [
659
+ {
660
+ name: "North California, USA",
661
+ value: EDbRegion.USA
662
+ },
663
+ {
664
+ name: "Paris, France",
665
+ value: EDbRegion.Paris
666
+ },
667
+ {
668
+ name: "Singapore",
669
+ value: EDbRegion.Singapore
670
+ },
671
+ {
672
+ name: "Sydney, Australia",
673
+ value: EDbRegion.Australia
674
+ }
675
+ ];
676
+ function Get(api, id) {
677
+ return __awaiter(this, void 0, void 0, function () {
678
+ var cacheData, req;
679
+ return __generator(this, function (_a) {
680
+ switch (_a.label) {
681
+ case 0:
682
+ cacheData = api.Cache.Get(GetCacheKey(id));
683
+ if (cacheData) {
684
+ return [2 /*return*/, cacheData];
685
+ }
686
+ return [4 /*yield*/, api.GET("account/" + id)];
687
+ case 1:
688
+ req = _a.sent();
689
+ api.Cache.Set(GetCacheKey(id), req, exports.Api.DEFAULT_CACHE_DURATION);
690
+ return [2 /*return*/, req];
691
+ }
692
+ });
693
+ });
694
+ }
695
+ Account.Get = Get;
696
+ function GetRelatedList(api) {
697
+ return __awaiter(this, void 0, void 0, function () {
698
+ var cacheData, req, prom;
699
+ var _this = this;
700
+ return __generator(this, function (_a) {
701
+ cacheData = api.Cache.Get(GetListCacheKey(api.GetSessionId()));
702
+ if (cacheData) {
703
+ return [2 /*return*/, cacheData];
704
+ }
705
+ req = api.GET("user/relatedClientAccounts");
706
+ prom = new Promise(function (res, rej) { return __awaiter(_this, void 0, void 0, function () {
707
+ var data, items, e_1;
708
+ return __generator(this, function (_a) {
709
+ switch (_a.label) {
710
+ case 0:
711
+ _a.trys.push([0, 2, , 3]);
712
+ return [4 /*yield*/, req];
713
+ case 1:
714
+ data = _a.sent();
715
+ items = data.Items.filter(function (x) { return !ACCOUNT_EXCLUSIONS.includes(x.ID); });
716
+ res(items);
717
+ return [3 /*break*/, 3];
718
+ case 2:
719
+ e_1 = _a.sent();
720
+ rej(e_1);
721
+ return [3 /*break*/, 3];
722
+ case 3: return [2 /*return*/];
723
+ }
724
+ });
725
+ }); });
726
+ api.Cache.Set(GetListCacheKey(api.GetSessionId()), prom, exports.Api.DEFAULT_CACHE_DURATION);
727
+ return [2 /*return*/, prom];
728
+ });
729
+ });
730
+ }
731
+ Account.GetRelatedList = GetRelatedList;
732
+ function GetAppSettings(api, id, appId) {
733
+ return __awaiter(this, void 0, void 0, function () {
734
+ var cacheData, req, prom;
735
+ var _this = this;
736
+ return __generator(this, function (_a) {
737
+ switch (_a.label) {
738
+ case 0:
739
+ cacheData = api.Cache.Get(GetCacheKey(id, appId));
740
+ if (cacheData) {
741
+ return [2 /*return*/, cacheData];
742
+ }
743
+ return [4 /*yield*/, api.GET("account/" + id + "?ApplicationID=" + appId)];
744
+ case 1:
745
+ req = _a.sent();
746
+ prom = new Promise(function (res, rej) { return __awaiter(_this, void 0, void 0, function () {
747
+ var data, settings, e_2;
748
+ var _a;
749
+ return __generator(this, function (_b) {
750
+ switch (_b.label) {
751
+ case 0:
752
+ _b.trys.push([0, 2, , 3]);
753
+ return [4 /*yield*/, req];
754
+ case 1:
755
+ data = _b.sent();
756
+ settings = (_a = data === null || data === void 0 ? void 0 : data["Application.Settings"]) !== null && _a !== void 0 ? _a : {};
757
+ res(settings);
758
+ return [3 /*break*/, 3];
759
+ case 2:
760
+ e_2 = _b.sent();
761
+ rej(e_2);
762
+ return [3 /*break*/, 3];
763
+ case 3: return [2 /*return*/];
764
+ }
765
+ });
766
+ }); });
767
+ api.Cache.Set(GetCacheKey(id, appId), prom, exports.Api.DEFAULT_CACHE_DURATION);
768
+ return [2 /*return*/, prom];
769
+ }
770
+ });
771
+ });
772
+ }
773
+ Account.GetAppSettings = GetAppSettings;
774
+ /**
775
+ * WARNING: Do not update API settings without knowing what you're doing.
776
+ * @param api
777
+ * @param id
778
+ * @param appId
779
+ * @param data
780
+ * @returns
781
+ */
782
+ function UpdateAppSettings(api, id, appId, data) {
783
+ return __awaiter(this, void 0, void 0, function () {
784
+ return __generator(this, function (_a) {
785
+ switch (_a.label) {
786
+ case 0: return [4 /*yield*/, api.POST("account/" + id + "/applicationSettings/" + appId, data)];
787
+ case 1:
788
+ data = _a.sent();
789
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + id);
790
+ return [2 /*return*/, data];
791
+ }
792
+ });
793
+ });
794
+ }
795
+ Account.UpdateAppSettings = UpdateAppSettings;
796
+ /**
797
+ * Creates a new Bruce account using given details.
798
+ * @param api
799
+ * @param id
800
+ * @param name
801
+ * @param region
802
+ * @param starterContent
803
+ * @returns
804
+ */
805
+ function Create(api, id, name, region, starterContent) {
806
+ return __awaiter(this, void 0, void 0, function () {
807
+ var reqData, res;
808
+ return __generator(this, function (_a) {
809
+ if (!id || !name || !region) {
810
+ throw new Error("Id, Name and Region are required.");
811
+ }
812
+ if (!starterContent) {
813
+ starterContent = EStarterContent.None;
814
+ }
815
+ reqData = {
816
+ "Name": name,
817
+ "DBLocation": region,
818
+ "StarterContent": starterContent
819
+ };
820
+ res = api.POST("clientAccount/" + id, reqData, exports.Api.PrepReqParams());
821
+ api.Cache.Remove(GetListCacheKey(api.GetSessionId()));
822
+ return [2 /*return*/, res];
823
+ });
824
+ });
825
+ }
826
+ Account.Create = Create;
827
+ })(exports.Account || (exports.Account = {}));
828
+
629
829
  (function (CamApi) {
630
830
  var Api$$1 = /** @class */ (function (_super) {
631
831
  __extends(Api$$1, _super);
@@ -3898,7 +4098,7 @@
3898
4098
  clientFileId: clientFileId,
3899
4099
  destinationFormat: ext,
3900
4100
  operations: []
3901
- }, exports.Api.PrepReqParams())];
4101
+ })];
3902
4102
  });
3903
4103
  });
3904
4104
  }
@@ -5704,206 +5904,6 @@
5704
5904
  })(AccessToken = User.AccessToken || (User.AccessToken = {}));
5705
5905
  })(exports.User || (exports.User = {}));
5706
5906
 
5707
- var ACCOUNT_EXCLUSIONS = ["hyperportal", "hypeportal", "bviewer"];
5708
- (function (Account) {
5709
- function GetCacheKey(accountId, appSettingsId) {
5710
- if (appSettingsId) {
5711
- return exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + accountId + exports.Api.ECacheKey + appSettingsId;
5712
- }
5713
- return exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + accountId;
5714
- }
5715
- Account.GetCacheKey = GetCacheKey;
5716
- function GetListCacheKey(ssid) {
5717
- return exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Session + exports.Api.ECacheKey.Id + ssid;
5718
- }
5719
- Account.GetListCacheKey = GetListCacheKey;
5720
- var EDbRegion;
5721
- (function (EDbRegion) {
5722
- EDbRegion["USA"] = "US";
5723
- EDbRegion["Paris"] = "EU";
5724
- EDbRegion["Singapore"] = "SE";
5725
- EDbRegion["Australia"] = "AU";
5726
- })(EDbRegion = Account.EDbRegion || (Account.EDbRegion = {}));
5727
- var EAppId;
5728
- (function (EAppId) {
5729
- EAppId["BruceApi"] = "BruceAPI";
5730
- })(EAppId = Account.EAppId || (Account.EAppId = {}));
5731
- var EStarterContent;
5732
- (function (EStarterContent) {
5733
- EStarterContent["Default"] = "default";
5734
- EStarterContent["None"] = "none";
5735
- })(EStarterContent = Account.EStarterContent || (Account.EStarterContent = {}));
5736
- Account.DbRegions = [
5737
- {
5738
- name: "North California, USA",
5739
- value: EDbRegion.USA
5740
- },
5741
- {
5742
- name: "Paris, France",
5743
- value: EDbRegion.Paris
5744
- },
5745
- {
5746
- name: "Singapore",
5747
- value: EDbRegion.Singapore
5748
- },
5749
- {
5750
- name: "Sydney, Australia",
5751
- value: EDbRegion.Australia
5752
- }
5753
- ];
5754
- function Get(api, id) {
5755
- return __awaiter(this, void 0, void 0, function () {
5756
- var cacheData, req;
5757
- return __generator(this, function (_a) {
5758
- switch (_a.label) {
5759
- case 0:
5760
- cacheData = api.Cache.Get(GetCacheKey(id));
5761
- if (cacheData) {
5762
- return [2 /*return*/, cacheData];
5763
- }
5764
- return [4 /*yield*/, api.GET("account/" + id)];
5765
- case 1:
5766
- req = _a.sent();
5767
- api.Cache.Set(GetCacheKey(id), req, exports.Api.DEFAULT_CACHE_DURATION);
5768
- return [2 /*return*/, req];
5769
- }
5770
- });
5771
- });
5772
- }
5773
- Account.Get = Get;
5774
- function GetRelatedList(api) {
5775
- return __awaiter(this, void 0, void 0, function () {
5776
- var cacheData, req, prom;
5777
- var _this = this;
5778
- return __generator(this, function (_a) {
5779
- cacheData = api.Cache.Get(GetListCacheKey(api.GetSessionId()));
5780
- if (cacheData) {
5781
- return [2 /*return*/, cacheData];
5782
- }
5783
- req = api.GET("user/relatedClientAccounts");
5784
- prom = new Promise(function (res, rej) { return __awaiter(_this, void 0, void 0, function () {
5785
- var data, items, e_1;
5786
- return __generator(this, function (_a) {
5787
- switch (_a.label) {
5788
- case 0:
5789
- _a.trys.push([0, 2, , 3]);
5790
- return [4 /*yield*/, req];
5791
- case 1:
5792
- data = _a.sent();
5793
- items = data.Items.filter(function (x) { return !ACCOUNT_EXCLUSIONS.includes(x.ID); });
5794
- res(items);
5795
- return [3 /*break*/, 3];
5796
- case 2:
5797
- e_1 = _a.sent();
5798
- rej(e_1);
5799
- return [3 /*break*/, 3];
5800
- case 3: return [2 /*return*/];
5801
- }
5802
- });
5803
- }); });
5804
- api.Cache.Set(GetListCacheKey(api.GetSessionId()), prom, exports.Api.DEFAULT_CACHE_DURATION);
5805
- return [2 /*return*/, prom];
5806
- });
5807
- });
5808
- }
5809
- Account.GetRelatedList = GetRelatedList;
5810
- function GetAppSettings(api, id, appId) {
5811
- return __awaiter(this, void 0, void 0, function () {
5812
- var cacheData, req, prom;
5813
- var _this = this;
5814
- return __generator(this, function (_a) {
5815
- switch (_a.label) {
5816
- case 0:
5817
- cacheData = api.Cache.Get(GetCacheKey(id, appId));
5818
- if (cacheData) {
5819
- return [2 /*return*/, cacheData];
5820
- }
5821
- return [4 /*yield*/, api.GET("account/" + id + "?ApplicationID=" + appId)];
5822
- case 1:
5823
- req = _a.sent();
5824
- prom = new Promise(function (res, rej) { return __awaiter(_this, void 0, void 0, function () {
5825
- var data, settings, e_2;
5826
- var _a;
5827
- return __generator(this, function (_b) {
5828
- switch (_b.label) {
5829
- case 0:
5830
- _b.trys.push([0, 2, , 3]);
5831
- return [4 /*yield*/, req];
5832
- case 1:
5833
- data = _b.sent();
5834
- settings = (_a = data === null || data === void 0 ? void 0 : data["Application.Settings"]) !== null && _a !== void 0 ? _a : {};
5835
- res(settings);
5836
- return [3 /*break*/, 3];
5837
- case 2:
5838
- e_2 = _b.sent();
5839
- rej(e_2);
5840
- return [3 /*break*/, 3];
5841
- case 3: return [2 /*return*/];
5842
- }
5843
- });
5844
- }); });
5845
- api.Cache.Set(GetCacheKey(id, appId), prom, exports.Api.DEFAULT_CACHE_DURATION);
5846
- return [2 /*return*/, prom];
5847
- }
5848
- });
5849
- });
5850
- }
5851
- Account.GetAppSettings = GetAppSettings;
5852
- /**
5853
- * WARNING: Do not update API settings without knowing what you're doing.
5854
- * @param api
5855
- * @param id
5856
- * @param appId
5857
- * @param data
5858
- * @returns
5859
- */
5860
- function UpdateAppSettings(api, id, appId, data) {
5861
- return __awaiter(this, void 0, void 0, function () {
5862
- return __generator(this, function (_a) {
5863
- switch (_a.label) {
5864
- case 0: return [4 /*yield*/, api.POST("account/" + id + "/applicationSettings/" + appId, data)];
5865
- case 1:
5866
- data = _a.sent();
5867
- api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + id);
5868
- return [2 /*return*/, data];
5869
- }
5870
- });
5871
- });
5872
- }
5873
- Account.UpdateAppSettings = UpdateAppSettings;
5874
- /**
5875
- * Creates a new Bruce account using given details.
5876
- * @param api
5877
- * @param id
5878
- * @param name
5879
- * @param region
5880
- * @param starterContent
5881
- * @returns
5882
- */
5883
- function Create(api, id, name, region, starterContent) {
5884
- return __awaiter(this, void 0, void 0, function () {
5885
- var reqData, res;
5886
- return __generator(this, function (_a) {
5887
- if (!id || !name || !region) {
5888
- throw new Error("Id, Name and Region are required.");
5889
- }
5890
- if (!starterContent) {
5891
- starterContent = EStarterContent.None;
5892
- }
5893
- reqData = {
5894
- "Name": name,
5895
- "DBLocation": region,
5896
- "StarterContent": starterContent
5897
- };
5898
- res = api.POST("clientAccount/" + id, reqData, exports.Api.PrepReqParams());
5899
- api.Cache.Remove(GetListCacheKey(api.GetSessionId()));
5900
- return [2 /*return*/, res];
5901
- });
5902
- });
5903
- }
5904
- Account.Create = Create;
5905
- })(exports.Account || (exports.Account = {}));
5906
-
5907
5907
  (function (EncryptUtils) {
5908
5908
  // https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript
5909
5909
  function Cyrb53Hash(str, seed) {