bruce-models 0.3.2 → 0.3.3

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.
@@ -5507,194 +5507,32 @@ var User;
5507
5507
  })(AccessToken = User.AccessToken || (User.AccessToken = {}));
5508
5508
  })(User || (User = {}));
5509
5509
 
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
5510
  var ACCOUNT_EXCLUSIONS = ["hyperportal", "hypeportal", "bviewer"];
5673
5511
  /**
5674
5512
  * Describes the "Client Account" concept within Bruce.
5675
5513
  * A client account is a database instance that holds one or many users.
5676
5514
  */
5677
5515
  var Account;
5678
- (function (Account$$1) {
5516
+ (function (Account) {
5679
5517
  function GetCacheKey(accountId, appSettingsId) {
5680
5518
  if (appSettingsId) {
5681
5519
  return Api.ECacheKey.Account + Api.ECacheKey.Id + accountId + Api.ECacheKey + appSettingsId;
5682
5520
  }
5683
5521
  return Api.ECacheKey.Account + Api.ECacheKey.Id + accountId;
5684
5522
  }
5685
- Account$$1.GetCacheKey = GetCacheKey;
5523
+ Account.GetCacheKey = GetCacheKey;
5686
5524
  function GetListCacheKey(ssid) {
5687
5525
  return Api.ECacheKey.Account + Api.ECacheKey.Session + Api.ECacheKey.Id + ssid;
5688
5526
  }
5689
- Account$$1.GetListCacheKey = GetListCacheKey;
5527
+ Account.GetListCacheKey = GetListCacheKey;
5690
5528
  var EDbRegion;
5691
5529
  (function (EDbRegion) {
5692
5530
  EDbRegion["USA"] = "US";
5693
5531
  EDbRegion["Paris"] = "EU";
5694
5532
  EDbRegion["Singapore"] = "SE";
5695
5533
  EDbRegion["Australia"] = "AU";
5696
- })(EDbRegion = Account$$1.EDbRegion || (Account$$1.EDbRegion = {}));
5697
- Account$$1.DbRegions = [
5534
+ })(EDbRegion = Account.EDbRegion || (Account.EDbRegion = {}));
5535
+ Account.DbRegions = [
5698
5536
  {
5699
5537
  name: "North California, USA",
5700
5538
  value: EDbRegion.USA
@@ -5731,7 +5569,7 @@ var Account;
5731
5569
  });
5732
5570
  });
5733
5571
  }
5734
- Account$$1.Get = Get;
5572
+ Account.Get = Get;
5735
5573
  function GetRelatedList(api) {
5736
5574
  return __awaiter(this, void 0, void 0, function () {
5737
5575
  var cacheData, req, prom;
@@ -5767,7 +5605,7 @@ var Account;
5767
5605
  });
5768
5606
  });
5769
5607
  }
5770
- Account$$1.GetRelatedList = GetRelatedList;
5608
+ Account.GetRelatedList = GetRelatedList;
5771
5609
  function GetAppSettings(api, id, appId) {
5772
5610
  return __awaiter(this, void 0, void 0, function () {
5773
5611
  var cacheData, req, prom;
@@ -5809,7 +5647,7 @@ var Account;
5809
5647
  });
5810
5648
  });
5811
5649
  }
5812
- Account$$1.GetAppSettings = GetAppSettings;
5650
+ Account.GetAppSettings = GetAppSettings;
5813
5651
  /**
5814
5652
  * WARNING: Do not update API settings without knowing what you're doing.
5815
5653
  * @param api
@@ -5831,7 +5669,7 @@ var Account;
5831
5669
  });
5832
5670
  });
5833
5671
  }
5834
- Account$$1.UpdateAppSettings = UpdateAppSettings;
5672
+ Account.UpdateAppSettings = UpdateAppSettings;
5835
5673
  /**
5836
5674
  * Creates a new Bruce account using given details.
5837
5675
  * @param api
@@ -5857,8 +5695,221 @@ var Account;
5857
5695
  });
5858
5696
  });
5859
5697
  }
5860
- Account$$1.Create = Create;
5698
+ Account.Create = Create;
5861
5699
  })(Account || (Account = {}));
5862
5700
 
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 };
5701
+ var EncryptUtils;
5702
+ (function (EncryptUtils) {
5703
+ // https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript
5704
+ function Cyrb53Hash(str, seed) {
5705
+ if (seed === void 0) { seed = 0; }
5706
+ var h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;
5707
+ for (var i = 0, ch = void 0; i < str.length; i++) {
5708
+ ch = str.charCodeAt(i);
5709
+ h1 = Math.imul(h1 ^ ch, 2654435761);
5710
+ h2 = Math.imul(h2 ^ ch, 1597334677);
5711
+ }
5712
+ h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909);
5713
+ h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909);
5714
+ return (4294967296 * (2097151 & h2) + (h1 >>> 0));
5715
+ }
5716
+ EncryptUtils.Cyrb53Hash = Cyrb53Hash;
5717
+ })(EncryptUtils || (EncryptUtils = {}));
5718
+
5719
+ var MathUtils;
5720
+ (function (MathUtils) {
5721
+ /**
5722
+ * Rounds a number to a given number of decimal places.
5723
+ * @param num
5724
+ * @param decimals
5725
+ * @returns
5726
+ */
5727
+ function Round(num, decimals) {
5728
+ if (decimals === void 0) { decimals = 0; }
5729
+ if (decimals <= 0) {
5730
+ return Math.round(num);
5731
+ }
5732
+ var tmp = "1";
5733
+ for (var i = 0; i < decimals; i++) {
5734
+ tmp += "0";
5735
+ }
5736
+ var d = parseFloat(tmp);
5737
+ return Math.round((num + Number.EPSILON) * d) / d;
5738
+ }
5739
+ MathUtils.Round = Round;
5740
+ /**
5741
+ * Returns a random integer between min (inclusive) and max (inclusive).
5742
+ * @param min
5743
+ * @param max
5744
+ * @returns
5745
+ */
5746
+ function RandInt(min, max) {
5747
+ if (min == max) {
5748
+ return min;
5749
+ }
5750
+ else if (min > max) {
5751
+ throw ("Min is greater than max.");
5752
+ }
5753
+ return Math.floor(Math.random() * (max - min + 1)) + min;
5754
+ }
5755
+ MathUtils.RandInt = RandInt;
5756
+ })(MathUtils || (MathUtils = {}));
5757
+
5758
+ /**
5759
+ * Utility to help with url manipulation.
5760
+ */
5761
+ var UrlUtils;
5762
+ (function (UrlUtils) {
5763
+ function GetQueryString(doc) {
5764
+ var qs = {};
5765
+ var p0 = doc.location.href.indexOf("?");
5766
+ if (p0 >= 0) {
5767
+ var str = doc.location.href.substring(p0 + 1);
5768
+ var tokens = str.split("&");
5769
+ tokens.forEach(function (token) {
5770
+ var p = token.split("=");
5771
+ if (p.length == 2) {
5772
+ qs[p[0]] = p[1];
5773
+ }
5774
+ });
5775
+ }
5776
+ return qs;
5777
+ }
5778
+ UrlUtils.GetQueryString = GetQueryString;
5779
+ /**
5780
+ * Helper to get and set url params for a given window.
5781
+ */
5782
+ var Handler = /** @class */ (function () {
5783
+ function Handler(window, allowedKeys) {
5784
+ this._allowedKeys = null;
5785
+ this._window = window;
5786
+ this._allowedKeys = allowedKeys;
5787
+ }
5788
+ Object.defineProperty(Handler.prototype, "window", {
5789
+ get: function () {
5790
+ return this._window;
5791
+ },
5792
+ enumerable: false,
5793
+ configurable: true
5794
+ });
5795
+ Object.defineProperty(Handler.prototype, "document", {
5796
+ get: function () {
5797
+ var _a;
5798
+ return (_a = this.window) === null || _a === void 0 ? void 0 : _a.document;
5799
+ },
5800
+ enumerable: false,
5801
+ configurable: true
5802
+ });
5803
+ Object.defineProperty(Handler.prototype, "allowedKeys", {
5804
+ get: function () {
5805
+ return this._allowedKeys;
5806
+ },
5807
+ enumerable: false,
5808
+ configurable: true
5809
+ });
5810
+ Handler.prototype.UpdateAllowedKeys = function (allowedKeys) {
5811
+ this._allowedKeys = allowedKeys;
5812
+ var params = this.GetParams();
5813
+ this.refresh(params);
5814
+ };
5815
+ Handler.prototype.UpdateParam = function (key, value) {
5816
+ var params = this.GetParams();
5817
+ params[key + ""] = value + "";
5818
+ this.refresh(params);
5819
+ };
5820
+ Handler.prototype.RemoveParam = function (key) {
5821
+ var params = this.GetParams();
5822
+ params[key + ""] = null;
5823
+ this.refresh(params);
5824
+ };
5825
+ Handler.prototype.GetParamKeys = function () {
5826
+ var params = GetQueryString(this.document);
5827
+ return Object.keys(params);
5828
+ };
5829
+ Handler.prototype.GetParams = function () {
5830
+ return GetQueryString(this.document);
5831
+ };
5832
+ Handler.prototype.GetParam = function (key) {
5833
+ var params = this.GetParams();
5834
+ return params[key + ""];
5835
+ };
5836
+ Handler.prototype.Clear = function () {
5837
+ this.refresh({});
5838
+ };
5839
+ Handler.prototype.refresh = function (data) {
5840
+ var params = [];
5841
+ var keys = Object.keys(data);
5842
+ for (var i = 0; i < keys.length; i++) {
5843
+ var key = keys[i];
5844
+ if (this._allowedKeys == null || this._allowedKeys.includes(key)) {
5845
+ var val = data[key];
5846
+ if (!!val || val == 0) {
5847
+ params.push(key + "=" + val);
5848
+ }
5849
+ }
5850
+ }
5851
+ if (params.length > 0) {
5852
+ this.window.history.replaceState({}, null, "?" + params.join("&"));
5853
+ }
5854
+ else {
5855
+ this.window.history.replaceState({}, null, "");
5856
+ }
5857
+ };
5858
+ return Handler;
5859
+ }());
5860
+ UrlUtils.Handler = Handler;
5861
+ })(UrlUtils || (UrlUtils = {}));
5862
+
5863
+ var DataLab;
5864
+ (function (DataLab) {
5865
+ var EReqKey;
5866
+ (function (EReqKey) {
5867
+ EReqKey["Primary"] = "PrimarySelection";
5868
+ EReqKey["Secondary"] = "SecondarySelection";
5869
+ })(EReqKey = DataLab.EReqKey || (DataLab.EReqKey = {}));
5870
+ var Entity;
5871
+ (function (Entity) {
5872
+ function GetList(api, query, key, skip, load) {
5873
+ return __awaiter(this, void 0, void 0, function () {
5874
+ var req, prom;
5875
+ var _this = this;
5876
+ return __generator(this, function (_a) {
5877
+ if (!key) {
5878
+ key = EReqKey.Primary;
5879
+ }
5880
+ if (!skip) {
5881
+ skip = 0;
5882
+ }
5883
+ if (!load) {
5884
+ load = 50;
5885
+ }
5886
+ req = api.POST("entities/datalab/getMatchingEntities/" + key + "?skip=" + skip + "&load=" + load, query, Api.PrepReqParams());
5887
+ prom = new Promise(function (res, rej) { return __awaiter(_this, void 0, void 0, function () {
5888
+ var data, e_1;
5889
+ return __generator(this, function (_a) {
5890
+ switch (_a.label) {
5891
+ case 0:
5892
+ _a.trys.push([0, 2, , 3]);
5893
+ return [4 /*yield*/, req];
5894
+ case 1:
5895
+ data = _a.sent();
5896
+ res(data.Items);
5897
+ return [3 /*break*/, 3];
5898
+ case 2:
5899
+ e_1 = _a.sent();
5900
+ rej(e_1);
5901
+ return [3 /*break*/, 3];
5902
+ case 3: return [2 /*return*/];
5903
+ }
5904
+ });
5905
+ }); });
5906
+ return [2 /*return*/, prom];
5907
+ });
5908
+ });
5909
+ }
5910
+ Entity.GetList = GetList;
5911
+ })(Entity = DataLab.Entity || (DataLab.Entity = {}));
5912
+ })(DataLab || (DataLab = {}));
5913
+
5914
+ 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, DataLab };
5864
5915
  //# sourceMappingURL=bruce-models.es5.js.map