bruce-models 0.3.2 → 0.3.4

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.
@@ -853,6 +853,80 @@
853
853
  return IdmApi;
854
854
  }(AbstractApi));
855
855
 
856
+ /**
857
+ * This is the request handler for Global Api,
858
+ * it should be passed to any method that wants to communicate with this particular api.
859
+ */
860
+ var GlobalApi = /** @class */ (function (_super) {
861
+ __extends(GlobalApi, _super);
862
+ function GlobalApi(env) {
863
+ var _this = _super.call(this, "SSID") || this;
864
+ _this.baseUrl = "";
865
+ _this.env = env !== null && env !== void 0 ? env : exports.Api.EEnv.PROD;
866
+ _this.setBaseUrl();
867
+ return _this;
868
+ }
869
+ GlobalApi.prototype.setBaseUrl = function () {
870
+ var url;
871
+ var env = this.env.toUpperCase();
872
+ switch (env) {
873
+ case exports.Api.EEnv.DEV:
874
+ url = "https://bruceglobal.nextspace-dev.net/";
875
+ break;
876
+ case exports.Api.EEnv.STG:
877
+ url = "https://bruceglobal.nextspace-stg.net/";
878
+ break;
879
+ case exports.Api.EEnv.UAT:
880
+ url = "https://bruceglobal.api.nextspace-uat.net/";
881
+ break;
882
+ case exports.Api.EEnv.PROD:
883
+ url = "https://bruceglobal.api.nextspace.host/";
884
+ break;
885
+ default:
886
+ throw ("Specified Environment is not valid. SuppliedEnv=" + env);
887
+ }
888
+ this.baseUrl = url;
889
+ };
890
+ GlobalApi.prototype.GetBaseUrl = function () {
891
+ return this.baseUrl;
892
+ };
893
+ GlobalApi.prototype.SetBaseUrl = function (url) {
894
+ this.baseUrl = url;
895
+ if (!this.baseUrl.endsWith("/")) {
896
+ this.baseUrl += "/";
897
+ }
898
+ };
899
+ GlobalApi.prototype.GET = function (url, params) {
900
+ return __awaiter(this, void 0, void 0, function () {
901
+ return __generator(this, function (_a) {
902
+ return [2 /*return*/, this.get(this.baseUrl + url, params)];
903
+ });
904
+ });
905
+ };
906
+ GlobalApi.prototype.DELETE = function (url, params) {
907
+ return __awaiter(this, void 0, void 0, function () {
908
+ return __generator(this, function (_a) {
909
+ return [2 /*return*/, this.delete(this.baseUrl + url, params)];
910
+ });
911
+ });
912
+ };
913
+ GlobalApi.prototype.POST = function (url, data, params) {
914
+ return __awaiter(this, void 0, void 0, function () {
915
+ return __generator(this, function (_a) {
916
+ return [2 /*return*/, this.post(this.baseUrl + url, data, params)];
917
+ });
918
+ });
919
+ };
920
+ GlobalApi.prototype.UPLOAD = function (url, blob, params) {
921
+ return __awaiter(this, void 0, void 0, function () {
922
+ return __generator(this, function (_a) {
923
+ return [2 /*return*/, this.upload(this.baseUrl + url, blob, params)];
924
+ });
925
+ });
926
+ };
927
+ return GlobalApi;
928
+ }(AbstractApi));
929
+
856
930
  (function (Color) {
857
931
  var EBlendMode;
858
932
  (function (EBlendMode) {
@@ -5326,165 +5400,6 @@
5326
5400
  })(AccessToken = User.AccessToken || (User.AccessToken = {}));
5327
5401
  })(exports.User || (exports.User = {}));
5328
5402
 
5329
- (function (EncryptUtils) {
5330
- // https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript
5331
- function Cyrb53Hash(str, seed) {
5332
- if (seed === void 0) { seed = 0; }
5333
- var h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;
5334
- for (var i = 0, ch = void 0; i < str.length; i++) {
5335
- ch = str.charCodeAt(i);
5336
- h1 = Math.imul(h1 ^ ch, 2654435761);
5337
- h2 = Math.imul(h2 ^ ch, 1597334677);
5338
- }
5339
- h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909);
5340
- h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909);
5341
- return (4294967296 * (2097151 & h2) + (h1 >>> 0));
5342
- }
5343
- EncryptUtils.Cyrb53Hash = Cyrb53Hash;
5344
- })(exports.EncryptUtils || (exports.EncryptUtils = {}));
5345
-
5346
- (function (MathUtils) {
5347
- /**
5348
- * Rounds a number to a given number of decimal places.
5349
- * @param num
5350
- * @param decimals
5351
- * @returns
5352
- */
5353
- function Round(num, decimals) {
5354
- if (decimals === void 0) { decimals = 0; }
5355
- if (decimals <= 0) {
5356
- return Math.round(num);
5357
- }
5358
- var tmp = "1";
5359
- for (var i = 0; i < decimals; i++) {
5360
- tmp += "0";
5361
- }
5362
- var d = parseFloat(tmp);
5363
- return Math.round((num + Number.EPSILON) * d) / d;
5364
- }
5365
- MathUtils.Round = Round;
5366
- /**
5367
- * Returns a random integer between min (inclusive) and max (inclusive).
5368
- * @param min
5369
- * @param max
5370
- * @returns
5371
- */
5372
- function RandInt(min, max) {
5373
- if (min == max) {
5374
- return min;
5375
- }
5376
- else if (min > max) {
5377
- throw ("Min is greater than max.");
5378
- }
5379
- return Math.floor(Math.random() * (max - min + 1)) + min;
5380
- }
5381
- MathUtils.RandInt = RandInt;
5382
- })(exports.MathUtils || (exports.MathUtils = {}));
5383
-
5384
- /**
5385
- * Utility to help with url manipulation.
5386
- */
5387
- (function (UrlUtils) {
5388
- function GetQueryString(doc) {
5389
- var qs = {};
5390
- var p0 = doc.location.href.indexOf("?");
5391
- if (p0 >= 0) {
5392
- var str = doc.location.href.substring(p0 + 1);
5393
- var tokens = str.split("&");
5394
- tokens.forEach(function (token) {
5395
- var p = token.split("=");
5396
- if (p.length == 2) {
5397
- qs[p[0]] = p[1];
5398
- }
5399
- });
5400
- }
5401
- return qs;
5402
- }
5403
- UrlUtils.GetQueryString = GetQueryString;
5404
- /**
5405
- * Helper to get and set url params for a given window.
5406
- */
5407
- var Handler = /** @class */ (function () {
5408
- function Handler(window, allowedKeys) {
5409
- this._allowedKeys = null;
5410
- this._window = window;
5411
- this._allowedKeys = allowedKeys;
5412
- }
5413
- Object.defineProperty(Handler.prototype, "window", {
5414
- get: function () {
5415
- return this._window;
5416
- },
5417
- enumerable: false,
5418
- configurable: true
5419
- });
5420
- Object.defineProperty(Handler.prototype, "document", {
5421
- get: function () {
5422
- var _a;
5423
- return (_a = this.window) === null || _a === void 0 ? void 0 : _a.document;
5424
- },
5425
- enumerable: false,
5426
- configurable: true
5427
- });
5428
- Object.defineProperty(Handler.prototype, "allowedKeys", {
5429
- get: function () {
5430
- return this._allowedKeys;
5431
- },
5432
- enumerable: false,
5433
- configurable: true
5434
- });
5435
- Handler.prototype.UpdateAllowedKeys = function (allowedKeys) {
5436
- this._allowedKeys = allowedKeys;
5437
- var params = this.GetParams();
5438
- this.refresh(params);
5439
- };
5440
- Handler.prototype.UpdateParam = function (key, value) {
5441
- var params = this.GetParams();
5442
- params[key + ""] = value + "";
5443
- this.refresh(params);
5444
- };
5445
- Handler.prototype.RemoveParam = function (key) {
5446
- var params = this.GetParams();
5447
- params[key + ""] = null;
5448
- this.refresh(params);
5449
- };
5450
- Handler.prototype.GetParamKeys = function () {
5451
- var params = GetQueryString(this.document);
5452
- return Object.keys(params);
5453
- };
5454
- Handler.prototype.GetParams = function () {
5455
- return GetQueryString(this.document);
5456
- };
5457
- Handler.prototype.GetParam = function (key) {
5458
- var params = this.GetParams();
5459
- return params[key + ""];
5460
- };
5461
- Handler.prototype.Clear = function () {
5462
- this.refresh({});
5463
- };
5464
- Handler.prototype.refresh = function (data) {
5465
- var params = [];
5466
- var keys = Object.keys(data);
5467
- for (var i = 0; i < keys.length; i++) {
5468
- var key = keys[i];
5469
- if (this._allowedKeys == null || this._allowedKeys.includes(key)) {
5470
- var val = data[key];
5471
- if (!!val || val == 0) {
5472
- params.push(key + "=" + val);
5473
- }
5474
- }
5475
- }
5476
- if (params.length > 0) {
5477
- this.window.history.replaceState({}, null, "?" + params.join("&"));
5478
- }
5479
- else {
5480
- this.window.history.replaceState({}, null, "");
5481
- }
5482
- };
5483
- return Handler;
5484
- }());
5485
- UrlUtils.Handler = Handler;
5486
- })(exports.UrlUtils || (exports.UrlUtils = {}));
5487
-
5488
5403
  var ACCOUNT_EXCLUSIONS = ["hyperportal", "hypeportal", "bviewer"];
5489
5404
  (function (Account) {
5490
5405
  function GetCacheKey(accountId, appSettingsId) {
@@ -5671,10 +5586,220 @@
5671
5586
  Account.Create = Create;
5672
5587
  })(exports.Account || (exports.Account = {}));
5673
5588
 
5589
+ (function (EncryptUtils) {
5590
+ // https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript
5591
+ function Cyrb53Hash(str, seed) {
5592
+ if (seed === void 0) { seed = 0; }
5593
+ var h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;
5594
+ for (var i = 0, ch = void 0; i < str.length; i++) {
5595
+ ch = str.charCodeAt(i);
5596
+ h1 = Math.imul(h1 ^ ch, 2654435761);
5597
+ h2 = Math.imul(h2 ^ ch, 1597334677);
5598
+ }
5599
+ h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909);
5600
+ h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909);
5601
+ return (4294967296 * (2097151 & h2) + (h1 >>> 0));
5602
+ }
5603
+ EncryptUtils.Cyrb53Hash = Cyrb53Hash;
5604
+ })(exports.EncryptUtils || (exports.EncryptUtils = {}));
5605
+
5606
+ (function (MathUtils) {
5607
+ /**
5608
+ * Rounds a number to a given number of decimal places.
5609
+ * @param num
5610
+ * @param decimals
5611
+ * @returns
5612
+ */
5613
+ function Round(num, decimals) {
5614
+ if (decimals === void 0) { decimals = 0; }
5615
+ if (decimals <= 0) {
5616
+ return Math.round(num);
5617
+ }
5618
+ var tmp = "1";
5619
+ for (var i = 0; i < decimals; i++) {
5620
+ tmp += "0";
5621
+ }
5622
+ var d = parseFloat(tmp);
5623
+ return Math.round((num + Number.EPSILON) * d) / d;
5624
+ }
5625
+ MathUtils.Round = Round;
5626
+ /**
5627
+ * Returns a random integer between min (inclusive) and max (inclusive).
5628
+ * @param min
5629
+ * @param max
5630
+ * @returns
5631
+ */
5632
+ function RandInt(min, max) {
5633
+ if (min == max) {
5634
+ return min;
5635
+ }
5636
+ else if (min > max) {
5637
+ throw ("Min is greater than max.");
5638
+ }
5639
+ return Math.floor(Math.random() * (max - min + 1)) + min;
5640
+ }
5641
+ MathUtils.RandInt = RandInt;
5642
+ })(exports.MathUtils || (exports.MathUtils = {}));
5643
+
5644
+ /**
5645
+ * Utility to help with url manipulation.
5646
+ */
5647
+ (function (UrlUtils) {
5648
+ function GetQueryString(doc) {
5649
+ var qs = {};
5650
+ var p0 = doc.location.href.indexOf("?");
5651
+ if (p0 >= 0) {
5652
+ var str = doc.location.href.substring(p0 + 1);
5653
+ var tokens = str.split("&");
5654
+ tokens.forEach(function (token) {
5655
+ var p = token.split("=");
5656
+ if (p.length == 2) {
5657
+ qs[p[0]] = p[1];
5658
+ }
5659
+ });
5660
+ }
5661
+ return qs;
5662
+ }
5663
+ UrlUtils.GetQueryString = GetQueryString;
5664
+ /**
5665
+ * Helper to get and set url params for a given window.
5666
+ */
5667
+ var Handler = /** @class */ (function () {
5668
+ function Handler(window, allowedKeys) {
5669
+ this._allowedKeys = null;
5670
+ this._window = window;
5671
+ this._allowedKeys = allowedKeys;
5672
+ }
5673
+ Object.defineProperty(Handler.prototype, "window", {
5674
+ get: function () {
5675
+ return this._window;
5676
+ },
5677
+ enumerable: false,
5678
+ configurable: true
5679
+ });
5680
+ Object.defineProperty(Handler.prototype, "document", {
5681
+ get: function () {
5682
+ var _a;
5683
+ return (_a = this.window) === null || _a === void 0 ? void 0 : _a.document;
5684
+ },
5685
+ enumerable: false,
5686
+ configurable: true
5687
+ });
5688
+ Object.defineProperty(Handler.prototype, "allowedKeys", {
5689
+ get: function () {
5690
+ return this._allowedKeys;
5691
+ },
5692
+ enumerable: false,
5693
+ configurable: true
5694
+ });
5695
+ Handler.prototype.UpdateAllowedKeys = function (allowedKeys) {
5696
+ this._allowedKeys = allowedKeys;
5697
+ var params = this.GetParams();
5698
+ this.refresh(params);
5699
+ };
5700
+ Handler.prototype.UpdateParam = function (key, value) {
5701
+ var params = this.GetParams();
5702
+ params[key + ""] = value + "";
5703
+ this.refresh(params);
5704
+ };
5705
+ Handler.prototype.RemoveParam = function (key) {
5706
+ var params = this.GetParams();
5707
+ params[key + ""] = null;
5708
+ this.refresh(params);
5709
+ };
5710
+ Handler.prototype.GetParamKeys = function () {
5711
+ var params = GetQueryString(this.document);
5712
+ return Object.keys(params);
5713
+ };
5714
+ Handler.prototype.GetParams = function () {
5715
+ return GetQueryString(this.document);
5716
+ };
5717
+ Handler.prototype.GetParam = function (key) {
5718
+ var params = this.GetParams();
5719
+ return params[key + ""];
5720
+ };
5721
+ Handler.prototype.Clear = function () {
5722
+ this.refresh({});
5723
+ };
5724
+ Handler.prototype.refresh = function (data) {
5725
+ var params = [];
5726
+ var keys = Object.keys(data);
5727
+ for (var i = 0; i < keys.length; i++) {
5728
+ var key = keys[i];
5729
+ if (this._allowedKeys == null || this._allowedKeys.includes(key)) {
5730
+ var val = data[key];
5731
+ if (!!val || val == 0) {
5732
+ params.push(key + "=" + val);
5733
+ }
5734
+ }
5735
+ }
5736
+ if (params.length > 0) {
5737
+ this.window.history.replaceState({}, null, "?" + params.join("&"));
5738
+ }
5739
+ else {
5740
+ this.window.history.replaceState({}, null, "");
5741
+ }
5742
+ };
5743
+ return Handler;
5744
+ }());
5745
+ UrlUtils.Handler = Handler;
5746
+ })(exports.UrlUtils || (exports.UrlUtils = {}));
5747
+
5748
+ (function (DataLab) {
5749
+ var EReqKey;
5750
+ (function (EReqKey) {
5751
+ EReqKey["Primary"] = "PrimarySelection";
5752
+ EReqKey["Secondary"] = "SecondarySelection";
5753
+ })(EReqKey = DataLab.EReqKey || (DataLab.EReqKey = {}));
5754
+ var Entity;
5755
+ (function (Entity) {
5756
+ function GetList(api, query, key, skip, load) {
5757
+ return __awaiter(this, void 0, void 0, function () {
5758
+ var req, prom;
5759
+ var _this = this;
5760
+ return __generator(this, function (_a) {
5761
+ if (!key) {
5762
+ key = EReqKey.Primary;
5763
+ }
5764
+ if (!skip) {
5765
+ skip = 0;
5766
+ }
5767
+ if (!load) {
5768
+ load = 50;
5769
+ }
5770
+ req = api.POST("entities/datalab/getMatchingEntities/" + key + "?skip=" + skip + "&load=" + load, query, exports.Api.PrepReqParams());
5771
+ prom = new Promise(function (res, rej) { return __awaiter(_this, void 0, void 0, function () {
5772
+ var data, e_1;
5773
+ return __generator(this, function (_a) {
5774
+ switch (_a.label) {
5775
+ case 0:
5776
+ _a.trys.push([0, 2, , 3]);
5777
+ return [4 /*yield*/, req];
5778
+ case 1:
5779
+ data = _a.sent();
5780
+ res(data.Items);
5781
+ return [3 /*break*/, 3];
5782
+ case 2:
5783
+ e_1 = _a.sent();
5784
+ rej(e_1);
5785
+ return [3 /*break*/, 3];
5786
+ case 3: return [2 /*return*/];
5787
+ }
5788
+ });
5789
+ }); });
5790
+ return [2 /*return*/, prom];
5791
+ });
5792
+ });
5793
+ }
5794
+ Entity.GetList = GetList;
5795
+ })(Entity = DataLab.Entity || (DataLab.Entity = {}));
5796
+ })(exports.DataLab || (exports.DataLab = {}));
5797
+
5674
5798
  exports.AbstractApi = AbstractApi;
5675
5799
  exports.BruceApi = BruceApi;
5676
5800
  exports.CamApi = CamApi;
5677
5801
  exports.IdmApi = IdmApi;
5802
+ exports.GlobalApi = GlobalApi;
5678
5803
  exports.BruceEvent = BruceEvent;
5679
5804
  exports.CacheControl = CacheControl;
5680
5805
  exports.DelayQueue = DelayQueue;