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.
@@ -858,6 +858,80 @@ var IdmApi = /** @class */ (function (_super) {
858
858
  return IdmApi;
859
859
  }(AbstractApi));
860
860
 
861
+ /**
862
+ * This is the request handler for Global Api,
863
+ * it should be passed to any method that wants to communicate with this particular api.
864
+ */
865
+ var GlobalApi = /** @class */ (function (_super) {
866
+ __extends(GlobalApi, _super);
867
+ function GlobalApi(env) {
868
+ var _this = _super.call(this, "SSID") || this;
869
+ _this.baseUrl = "";
870
+ _this.env = env !== null && env !== void 0 ? env : Api.EEnv.PROD;
871
+ _this.setBaseUrl();
872
+ return _this;
873
+ }
874
+ GlobalApi.prototype.setBaseUrl = function () {
875
+ var url;
876
+ var env = this.env.toUpperCase();
877
+ switch (env) {
878
+ case Api.EEnv.DEV:
879
+ url = "https://bruceglobal.nextspace-dev.net/";
880
+ break;
881
+ case Api.EEnv.STG:
882
+ url = "https://bruceglobal.nextspace-stg.net/";
883
+ break;
884
+ case Api.EEnv.UAT:
885
+ url = "https://bruceglobal.api.nextspace-uat.net/";
886
+ break;
887
+ case Api.EEnv.PROD:
888
+ url = "https://bruceglobal.api.nextspace.host/";
889
+ break;
890
+ default:
891
+ throw ("Specified Environment is not valid. SuppliedEnv=" + env);
892
+ }
893
+ this.baseUrl = url;
894
+ };
895
+ GlobalApi.prototype.GetBaseUrl = function () {
896
+ return this.baseUrl;
897
+ };
898
+ GlobalApi.prototype.SetBaseUrl = function (url) {
899
+ this.baseUrl = url;
900
+ if (!this.baseUrl.endsWith("/")) {
901
+ this.baseUrl += "/";
902
+ }
903
+ };
904
+ GlobalApi.prototype.GET = function (url, params) {
905
+ return __awaiter(this, void 0, void 0, function () {
906
+ return __generator(this, function (_a) {
907
+ return [2 /*return*/, this.get(this.baseUrl + url, params)];
908
+ });
909
+ });
910
+ };
911
+ GlobalApi.prototype.DELETE = function (url, params) {
912
+ return __awaiter(this, void 0, void 0, function () {
913
+ return __generator(this, function (_a) {
914
+ return [2 /*return*/, this.delete(this.baseUrl + url, params)];
915
+ });
916
+ });
917
+ };
918
+ GlobalApi.prototype.POST = function (url, data, params) {
919
+ return __awaiter(this, void 0, void 0, function () {
920
+ return __generator(this, function (_a) {
921
+ return [2 /*return*/, this.post(this.baseUrl + url, data, params)];
922
+ });
923
+ });
924
+ };
925
+ GlobalApi.prototype.UPLOAD = function (url, blob, params) {
926
+ return __awaiter(this, void 0, void 0, function () {
927
+ return __generator(this, function (_a) {
928
+ return [2 /*return*/, this.upload(this.baseUrl + url, blob, params)];
929
+ });
930
+ });
931
+ };
932
+ return GlobalApi;
933
+ }(AbstractApi));
934
+
861
935
  var Color;
862
936
  (function (Color) {
863
937
  var EBlendMode;
@@ -5507,194 +5581,32 @@ var User;
5507
5581
  })(AccessToken = User.AccessToken || (User.AccessToken = {}));
5508
5582
  })(User || (User = {}));
5509
5583
 
5510
- var EncryptUtils;
5511
- (function (EncryptUtils) {
5512
- // https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript
5513
- function Cyrb53Hash(str, seed) {
5514
- if (seed === void 0) { seed = 0; }
5515
- var h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;
5516
- for (var i = 0, ch = void 0; i < str.length; i++) {
5517
- ch = str.charCodeAt(i);
5518
- h1 = Math.imul(h1 ^ ch, 2654435761);
5519
- h2 = Math.imul(h2 ^ ch, 1597334677);
5520
- }
5521
- h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909);
5522
- h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909);
5523
- return (4294967296 * (2097151 & h2) + (h1 >>> 0));
5524
- }
5525
- EncryptUtils.Cyrb53Hash = Cyrb53Hash;
5526
- })(EncryptUtils || (EncryptUtils = {}));
5527
-
5528
- var MathUtils;
5529
- (function (MathUtils) {
5530
- /**
5531
- * Rounds a number to a given number of decimal places.
5532
- * @param num
5533
- * @param decimals
5534
- * @returns
5535
- */
5536
- function Round(num, decimals) {
5537
- if (decimals === void 0) { decimals = 0; }
5538
- if (decimals <= 0) {
5539
- return Math.round(num);
5540
- }
5541
- var tmp = "1";
5542
- for (var i = 0; i < decimals; i++) {
5543
- tmp += "0";
5544
- }
5545
- var d = parseFloat(tmp);
5546
- return Math.round((num + Number.EPSILON) * d) / d;
5547
- }
5548
- MathUtils.Round = Round;
5549
- /**
5550
- * Returns a random integer between min (inclusive) and max (inclusive).
5551
- * @param min
5552
- * @param max
5553
- * @returns
5554
- */
5555
- function RandInt(min, max) {
5556
- if (min == max) {
5557
- return min;
5558
- }
5559
- else if (min > max) {
5560
- throw ("Min is greater than max.");
5561
- }
5562
- return Math.floor(Math.random() * (max - min + 1)) + min;
5563
- }
5564
- MathUtils.RandInt = RandInt;
5565
- })(MathUtils || (MathUtils = {}));
5566
-
5567
- /**
5568
- * Utility to help with url manipulation.
5569
- */
5570
- var UrlUtils;
5571
- (function (UrlUtils) {
5572
- function GetQueryString(doc) {
5573
- var qs = {};
5574
- var p0 = doc.location.href.indexOf("?");
5575
- if (p0 >= 0) {
5576
- var str = doc.location.href.substring(p0 + 1);
5577
- var tokens = str.split("&");
5578
- tokens.forEach(function (token) {
5579
- var p = token.split("=");
5580
- if (p.length == 2) {
5581
- qs[p[0]] = p[1];
5582
- }
5583
- });
5584
- }
5585
- return qs;
5586
- }
5587
- UrlUtils.GetQueryString = GetQueryString;
5588
- /**
5589
- * Helper to get and set url params for a given window.
5590
- */
5591
- var Handler = /** @class */ (function () {
5592
- function Handler(window, allowedKeys) {
5593
- this._allowedKeys = null;
5594
- this._window = window;
5595
- this._allowedKeys = allowedKeys;
5596
- }
5597
- Object.defineProperty(Handler.prototype, "window", {
5598
- get: function () {
5599
- return this._window;
5600
- },
5601
- enumerable: false,
5602
- configurable: true
5603
- });
5604
- Object.defineProperty(Handler.prototype, "document", {
5605
- get: function () {
5606
- var _a;
5607
- return (_a = this.window) === null || _a === void 0 ? void 0 : _a.document;
5608
- },
5609
- enumerable: false,
5610
- configurable: true
5611
- });
5612
- Object.defineProperty(Handler.prototype, "allowedKeys", {
5613
- get: function () {
5614
- return this._allowedKeys;
5615
- },
5616
- enumerable: false,
5617
- configurable: true
5618
- });
5619
- Handler.prototype.UpdateAllowedKeys = function (allowedKeys) {
5620
- this._allowedKeys = allowedKeys;
5621
- var params = this.GetParams();
5622
- this.refresh(params);
5623
- };
5624
- Handler.prototype.UpdateParam = function (key, value) {
5625
- var params = this.GetParams();
5626
- params[key + ""] = value + "";
5627
- this.refresh(params);
5628
- };
5629
- Handler.prototype.RemoveParam = function (key) {
5630
- var params = this.GetParams();
5631
- params[key + ""] = null;
5632
- this.refresh(params);
5633
- };
5634
- Handler.prototype.GetParamKeys = function () {
5635
- var params = GetQueryString(this.document);
5636
- return Object.keys(params);
5637
- };
5638
- Handler.prototype.GetParams = function () {
5639
- return GetQueryString(this.document);
5640
- };
5641
- Handler.prototype.GetParam = function (key) {
5642
- var params = this.GetParams();
5643
- return params[key + ""];
5644
- };
5645
- Handler.prototype.Clear = function () {
5646
- this.refresh({});
5647
- };
5648
- Handler.prototype.refresh = function (data) {
5649
- var params = [];
5650
- var keys = Object.keys(data);
5651
- for (var i = 0; i < keys.length; i++) {
5652
- var key = keys[i];
5653
- if (this._allowedKeys == null || this._allowedKeys.includes(key)) {
5654
- var val = data[key];
5655
- if (!!val || val == 0) {
5656
- params.push(key + "=" + val);
5657
- }
5658
- }
5659
- }
5660
- if (params.length > 0) {
5661
- this.window.history.replaceState({}, null, "?" + params.join("&"));
5662
- }
5663
- else {
5664
- this.window.history.replaceState({}, null, "");
5665
- }
5666
- };
5667
- return Handler;
5668
- }());
5669
- UrlUtils.Handler = Handler;
5670
- })(UrlUtils || (UrlUtils = {}));
5671
-
5672
5584
  var ACCOUNT_EXCLUSIONS = ["hyperportal", "hypeportal", "bviewer"];
5673
5585
  /**
5674
5586
  * Describes the "Client Account" concept within Bruce.
5675
5587
  * A client account is a database instance that holds one or many users.
5676
5588
  */
5677
5589
  var Account;
5678
- (function (Account$$1) {
5590
+ (function (Account) {
5679
5591
  function GetCacheKey(accountId, appSettingsId) {
5680
5592
  if (appSettingsId) {
5681
5593
  return Api.ECacheKey.Account + Api.ECacheKey.Id + accountId + Api.ECacheKey + appSettingsId;
5682
5594
  }
5683
5595
  return Api.ECacheKey.Account + Api.ECacheKey.Id + accountId;
5684
5596
  }
5685
- Account$$1.GetCacheKey = GetCacheKey;
5597
+ Account.GetCacheKey = GetCacheKey;
5686
5598
  function GetListCacheKey(ssid) {
5687
5599
  return Api.ECacheKey.Account + Api.ECacheKey.Session + Api.ECacheKey.Id + ssid;
5688
5600
  }
5689
- Account$$1.GetListCacheKey = GetListCacheKey;
5601
+ Account.GetListCacheKey = GetListCacheKey;
5690
5602
  var EDbRegion;
5691
5603
  (function (EDbRegion) {
5692
5604
  EDbRegion["USA"] = "US";
5693
5605
  EDbRegion["Paris"] = "EU";
5694
5606
  EDbRegion["Singapore"] = "SE";
5695
5607
  EDbRegion["Australia"] = "AU";
5696
- })(EDbRegion = Account$$1.EDbRegion || (Account$$1.EDbRegion = {}));
5697
- Account$$1.DbRegions = [
5608
+ })(EDbRegion = Account.EDbRegion || (Account.EDbRegion = {}));
5609
+ Account.DbRegions = [
5698
5610
  {
5699
5611
  name: "North California, USA",
5700
5612
  value: EDbRegion.USA
@@ -5731,7 +5643,7 @@ var Account;
5731
5643
  });
5732
5644
  });
5733
5645
  }
5734
- Account$$1.Get = Get;
5646
+ Account.Get = Get;
5735
5647
  function GetRelatedList(api) {
5736
5648
  return __awaiter(this, void 0, void 0, function () {
5737
5649
  var cacheData, req, prom;
@@ -5767,7 +5679,7 @@ var Account;
5767
5679
  });
5768
5680
  });
5769
5681
  }
5770
- Account$$1.GetRelatedList = GetRelatedList;
5682
+ Account.GetRelatedList = GetRelatedList;
5771
5683
  function GetAppSettings(api, id, appId) {
5772
5684
  return __awaiter(this, void 0, void 0, function () {
5773
5685
  var cacheData, req, prom;
@@ -5809,7 +5721,7 @@ var Account;
5809
5721
  });
5810
5722
  });
5811
5723
  }
5812
- Account$$1.GetAppSettings = GetAppSettings;
5724
+ Account.GetAppSettings = GetAppSettings;
5813
5725
  /**
5814
5726
  * WARNING: Do not update API settings without knowing what you're doing.
5815
5727
  * @param api
@@ -5831,7 +5743,7 @@ var Account;
5831
5743
  });
5832
5744
  });
5833
5745
  }
5834
- Account$$1.UpdateAppSettings = UpdateAppSettings;
5746
+ Account.UpdateAppSettings = UpdateAppSettings;
5835
5747
  /**
5836
5748
  * Creates a new Bruce account using given details.
5837
5749
  * @param api
@@ -5857,8 +5769,221 @@ var Account;
5857
5769
  });
5858
5770
  });
5859
5771
  }
5860
- Account$$1.Create = Create;
5772
+ Account.Create = Create;
5861
5773
  })(Account || (Account = {}));
5862
5774
 
5863
- export { AnnDocument, CustomForm, AbstractApi, Api, BruceApi, CamApi, IdmApi, Calculator, BruceEvent, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, Geometry, UTC, EntityAttachmentType, EntityAttachment, EntityComment, EntityLink, EntityLod, EntityRelationType, EntityRelation, EntitySource, EntityTag, EntityType, Entity, EntityGlobe, EntityFilterGetter, BatchedDataGetter, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, PendingAction, Style, TilesetEntitiesMapTiles, TilesetExtMapTiles, Tileset, Ucs, Permission, Session, UserGroup, User, Account, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils };
5775
+ var EncryptUtils;
5776
+ (function (EncryptUtils) {
5777
+ // https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript
5778
+ function Cyrb53Hash(str, seed) {
5779
+ if (seed === void 0) { seed = 0; }
5780
+ var h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;
5781
+ for (var i = 0, ch = void 0; i < str.length; i++) {
5782
+ ch = str.charCodeAt(i);
5783
+ h1 = Math.imul(h1 ^ ch, 2654435761);
5784
+ h2 = Math.imul(h2 ^ ch, 1597334677);
5785
+ }
5786
+ h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909);
5787
+ h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909);
5788
+ return (4294967296 * (2097151 & h2) + (h1 >>> 0));
5789
+ }
5790
+ EncryptUtils.Cyrb53Hash = Cyrb53Hash;
5791
+ })(EncryptUtils || (EncryptUtils = {}));
5792
+
5793
+ var MathUtils;
5794
+ (function (MathUtils) {
5795
+ /**
5796
+ * Rounds a number to a given number of decimal places.
5797
+ * @param num
5798
+ * @param decimals
5799
+ * @returns
5800
+ */
5801
+ function Round(num, decimals) {
5802
+ if (decimals === void 0) { decimals = 0; }
5803
+ if (decimals <= 0) {
5804
+ return Math.round(num);
5805
+ }
5806
+ var tmp = "1";
5807
+ for (var i = 0; i < decimals; i++) {
5808
+ tmp += "0";
5809
+ }
5810
+ var d = parseFloat(tmp);
5811
+ return Math.round((num + Number.EPSILON) * d) / d;
5812
+ }
5813
+ MathUtils.Round = Round;
5814
+ /**
5815
+ * Returns a random integer between min (inclusive) and max (inclusive).
5816
+ * @param min
5817
+ * @param max
5818
+ * @returns
5819
+ */
5820
+ function RandInt(min, max) {
5821
+ if (min == max) {
5822
+ return min;
5823
+ }
5824
+ else if (min > max) {
5825
+ throw ("Min is greater than max.");
5826
+ }
5827
+ return Math.floor(Math.random() * (max - min + 1)) + min;
5828
+ }
5829
+ MathUtils.RandInt = RandInt;
5830
+ })(MathUtils || (MathUtils = {}));
5831
+
5832
+ /**
5833
+ * Utility to help with url manipulation.
5834
+ */
5835
+ var UrlUtils;
5836
+ (function (UrlUtils) {
5837
+ function GetQueryString(doc) {
5838
+ var qs = {};
5839
+ var p0 = doc.location.href.indexOf("?");
5840
+ if (p0 >= 0) {
5841
+ var str = doc.location.href.substring(p0 + 1);
5842
+ var tokens = str.split("&");
5843
+ tokens.forEach(function (token) {
5844
+ var p = token.split("=");
5845
+ if (p.length == 2) {
5846
+ qs[p[0]] = p[1];
5847
+ }
5848
+ });
5849
+ }
5850
+ return qs;
5851
+ }
5852
+ UrlUtils.GetQueryString = GetQueryString;
5853
+ /**
5854
+ * Helper to get and set url params for a given window.
5855
+ */
5856
+ var Handler = /** @class */ (function () {
5857
+ function Handler(window, allowedKeys) {
5858
+ this._allowedKeys = null;
5859
+ this._window = window;
5860
+ this._allowedKeys = allowedKeys;
5861
+ }
5862
+ Object.defineProperty(Handler.prototype, "window", {
5863
+ get: function () {
5864
+ return this._window;
5865
+ },
5866
+ enumerable: false,
5867
+ configurable: true
5868
+ });
5869
+ Object.defineProperty(Handler.prototype, "document", {
5870
+ get: function () {
5871
+ var _a;
5872
+ return (_a = this.window) === null || _a === void 0 ? void 0 : _a.document;
5873
+ },
5874
+ enumerable: false,
5875
+ configurable: true
5876
+ });
5877
+ Object.defineProperty(Handler.prototype, "allowedKeys", {
5878
+ get: function () {
5879
+ return this._allowedKeys;
5880
+ },
5881
+ enumerable: false,
5882
+ configurable: true
5883
+ });
5884
+ Handler.prototype.UpdateAllowedKeys = function (allowedKeys) {
5885
+ this._allowedKeys = allowedKeys;
5886
+ var params = this.GetParams();
5887
+ this.refresh(params);
5888
+ };
5889
+ Handler.prototype.UpdateParam = function (key, value) {
5890
+ var params = this.GetParams();
5891
+ params[key + ""] = value + "";
5892
+ this.refresh(params);
5893
+ };
5894
+ Handler.prototype.RemoveParam = function (key) {
5895
+ var params = this.GetParams();
5896
+ params[key + ""] = null;
5897
+ this.refresh(params);
5898
+ };
5899
+ Handler.prototype.GetParamKeys = function () {
5900
+ var params = GetQueryString(this.document);
5901
+ return Object.keys(params);
5902
+ };
5903
+ Handler.prototype.GetParams = function () {
5904
+ return GetQueryString(this.document);
5905
+ };
5906
+ Handler.prototype.GetParam = function (key) {
5907
+ var params = this.GetParams();
5908
+ return params[key + ""];
5909
+ };
5910
+ Handler.prototype.Clear = function () {
5911
+ this.refresh({});
5912
+ };
5913
+ Handler.prototype.refresh = function (data) {
5914
+ var params = [];
5915
+ var keys = Object.keys(data);
5916
+ for (var i = 0; i < keys.length; i++) {
5917
+ var key = keys[i];
5918
+ if (this._allowedKeys == null || this._allowedKeys.includes(key)) {
5919
+ var val = data[key];
5920
+ if (!!val || val == 0) {
5921
+ params.push(key + "=" + val);
5922
+ }
5923
+ }
5924
+ }
5925
+ if (params.length > 0) {
5926
+ this.window.history.replaceState({}, null, "?" + params.join("&"));
5927
+ }
5928
+ else {
5929
+ this.window.history.replaceState({}, null, "");
5930
+ }
5931
+ };
5932
+ return Handler;
5933
+ }());
5934
+ UrlUtils.Handler = Handler;
5935
+ })(UrlUtils || (UrlUtils = {}));
5936
+
5937
+ var DataLab;
5938
+ (function (DataLab) {
5939
+ var EReqKey;
5940
+ (function (EReqKey) {
5941
+ EReqKey["Primary"] = "PrimarySelection";
5942
+ EReqKey["Secondary"] = "SecondarySelection";
5943
+ })(EReqKey = DataLab.EReqKey || (DataLab.EReqKey = {}));
5944
+ var Entity;
5945
+ (function (Entity) {
5946
+ function GetList(api, query, key, skip, load) {
5947
+ return __awaiter(this, void 0, void 0, function () {
5948
+ var req, prom;
5949
+ var _this = this;
5950
+ return __generator(this, function (_a) {
5951
+ if (!key) {
5952
+ key = EReqKey.Primary;
5953
+ }
5954
+ if (!skip) {
5955
+ skip = 0;
5956
+ }
5957
+ if (!load) {
5958
+ load = 50;
5959
+ }
5960
+ req = api.POST("entities/datalab/getMatchingEntities/" + key + "?skip=" + skip + "&load=" + load, query, Api.PrepReqParams());
5961
+ prom = new Promise(function (res, rej) { return __awaiter(_this, void 0, void 0, function () {
5962
+ var data, e_1;
5963
+ return __generator(this, function (_a) {
5964
+ switch (_a.label) {
5965
+ case 0:
5966
+ _a.trys.push([0, 2, , 3]);
5967
+ return [4 /*yield*/, req];
5968
+ case 1:
5969
+ data = _a.sent();
5970
+ res(data.Items);
5971
+ return [3 /*break*/, 3];
5972
+ case 2:
5973
+ e_1 = _a.sent();
5974
+ rej(e_1);
5975
+ return [3 /*break*/, 3];
5976
+ case 3: return [2 /*return*/];
5977
+ }
5978
+ });
5979
+ }); });
5980
+ return [2 /*return*/, prom];
5981
+ });
5982
+ });
5983
+ }
5984
+ Entity.GetList = GetList;
5985
+ })(Entity = DataLab.Entity || (DataLab.Entity = {}));
5986
+ })(DataLab || (DataLab = {}));
5987
+
5988
+ export { AnnDocument, CustomForm, AbstractApi, Api, BruceApi, CamApi, IdmApi, GlobalApi, Calculator, BruceEvent, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, Geometry, UTC, EntityAttachmentType, EntityAttachment, EntityComment, EntityLink, EntityLod, EntityRelationType, EntityRelation, EntitySource, EntityTag, EntityType, Entity, EntityGlobe, EntityFilterGetter, BatchedDataGetter, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, PendingAction, Style, TilesetEntitiesMapTiles, TilesetExtMapTiles, Tileset, Ucs, Permission, Session, UserGroup, User, Account, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, DataLab };
5864
5989
  //# sourceMappingURL=bruce-models.es5.js.map