bruce-models 0.3.1 → 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.
@@ -2320,6 +2320,10 @@ var EntityLod;
2320
2320
  return Api.ECacheKey.Lod + Api.ECacheKey.Id + url;
2321
2321
  }
2322
2322
  EntityLod.GetCacheKey = GetCacheKey;
2323
+ function GetTypeListKey(typeId, group) {
2324
+ return Api.ECacheKey.Lod + Api.ECacheKey.EntityType + typeId + Api.ECacheKey.Id + group;
2325
+ }
2326
+ EntityLod.GetTypeListKey = GetTypeListKey;
2323
2327
  function GetUrl(api, entityId, categoryId, level, strict) {
2324
2328
  if (!entityId) {
2325
2329
  throw ("Entity ID is required.");
@@ -2393,6 +2397,51 @@ var EntityLod;
2393
2397
  });
2394
2398
  }
2395
2399
  EntityLod.GetLods = GetLods;
2400
+ /**
2401
+ * Returns lods for a specified entity type.
2402
+ * @param api
2403
+ * @param typeId
2404
+ * @param group default is "DEFAULT".
2405
+ */
2406
+ function GetTypeLods(api, typeId, group) {
2407
+ return __awaiter(this, void 0, void 0, function () {
2408
+ var cacheData, url, req, prom;
2409
+ var _this = this;
2410
+ return __generator(this, function (_a) {
2411
+ if (!group) {
2412
+ group = "DEFAULT";
2413
+ }
2414
+ cacheData = api.Cache.Get(GetTypeListKey(typeId, group));
2415
+ if (cacheData) {
2416
+ return [2 /*return*/, cacheData];
2417
+ }
2418
+ url = "entityType/" + typeId + "/lods?includeClientFiles=yes" + (group ? "&group=" + group : "");
2419
+ req = api.GET(url, Api.PrepReqParams());
2420
+ prom = new Promise(function (res, rej) { return __awaiter(_this, void 0, void 0, function () {
2421
+ var data, e_2;
2422
+ return __generator(this, function (_a) {
2423
+ switch (_a.label) {
2424
+ case 0:
2425
+ _a.trys.push([0, 2, , 3]);
2426
+ return [4 /*yield*/, req];
2427
+ case 1:
2428
+ data = _a.sent();
2429
+ res(data.Items);
2430
+ return [3 /*break*/, 3];
2431
+ case 2:
2432
+ e_2 = _a.sent();
2433
+ rej(e_2);
2434
+ return [3 /*break*/, 3];
2435
+ case 3: return [2 /*return*/];
2436
+ }
2437
+ });
2438
+ }); });
2439
+ api.Cache.Set(GetTypeListKey(typeId, group), prom, Api.DEFAULT_CACHE_DURATION);
2440
+ return [2 /*return*/, prom];
2441
+ });
2442
+ });
2443
+ }
2444
+ EntityLod.GetTypeLods = GetTypeLods;
2396
2445
  })(EntityLod || (EntityLod = {}));
2397
2446
 
2398
2447
  /**
@@ -5458,194 +5507,32 @@ var User;
5458
5507
  })(AccessToken = User.AccessToken || (User.AccessToken = {}));
5459
5508
  })(User || (User = {}));
5460
5509
 
5461
- var EncryptUtils;
5462
- (function (EncryptUtils) {
5463
- // https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript
5464
- function Cyrb53Hash(str, seed) {
5465
- if (seed === void 0) { seed = 0; }
5466
- var h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;
5467
- for (var i = 0, ch = void 0; i < str.length; i++) {
5468
- ch = str.charCodeAt(i);
5469
- h1 = Math.imul(h1 ^ ch, 2654435761);
5470
- h2 = Math.imul(h2 ^ ch, 1597334677);
5471
- }
5472
- h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909);
5473
- h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909);
5474
- return (4294967296 * (2097151 & h2) + (h1 >>> 0));
5475
- }
5476
- EncryptUtils.Cyrb53Hash = Cyrb53Hash;
5477
- })(EncryptUtils || (EncryptUtils = {}));
5478
-
5479
- var MathUtils;
5480
- (function (MathUtils) {
5481
- /**
5482
- * Rounds a number to a given number of decimal places.
5483
- * @param num
5484
- * @param decimals
5485
- * @returns
5486
- */
5487
- function Round(num, decimals) {
5488
- if (decimals === void 0) { decimals = 0; }
5489
- if (decimals <= 0) {
5490
- return Math.round(num);
5491
- }
5492
- var tmp = "1";
5493
- for (var i = 0; i < decimals; i++) {
5494
- tmp += "0";
5495
- }
5496
- var d = parseFloat(tmp);
5497
- return Math.round((num + Number.EPSILON) * d) / d;
5498
- }
5499
- MathUtils.Round = Round;
5500
- /**
5501
- * Returns a random integer between min (inclusive) and max (inclusive).
5502
- * @param min
5503
- * @param max
5504
- * @returns
5505
- */
5506
- function RandInt(min, max) {
5507
- if (min == max) {
5508
- return min;
5509
- }
5510
- else if (min > max) {
5511
- throw ("Min is greater than max.");
5512
- }
5513
- return Math.floor(Math.random() * (max - min + 1)) + min;
5514
- }
5515
- MathUtils.RandInt = RandInt;
5516
- })(MathUtils || (MathUtils = {}));
5517
-
5518
- /**
5519
- * Utility to help with url manipulation.
5520
- */
5521
- var UrlUtils;
5522
- (function (UrlUtils) {
5523
- function GetQueryString(doc) {
5524
- var qs = {};
5525
- var p0 = doc.location.href.indexOf("?");
5526
- if (p0 >= 0) {
5527
- var str = doc.location.href.substring(p0 + 1);
5528
- var tokens = str.split("&");
5529
- tokens.forEach(function (token) {
5530
- var p = token.split("=");
5531
- if (p.length == 2) {
5532
- qs[p[0]] = p[1];
5533
- }
5534
- });
5535
- }
5536
- return qs;
5537
- }
5538
- UrlUtils.GetQueryString = GetQueryString;
5539
- /**
5540
- * Helper to get and set url params for a given window.
5541
- */
5542
- var Handler = /** @class */ (function () {
5543
- function Handler(window, allowedKeys) {
5544
- this._allowedKeys = null;
5545
- this._window = window;
5546
- this._allowedKeys = allowedKeys;
5547
- }
5548
- Object.defineProperty(Handler.prototype, "window", {
5549
- get: function () {
5550
- return this._window;
5551
- },
5552
- enumerable: false,
5553
- configurable: true
5554
- });
5555
- Object.defineProperty(Handler.prototype, "document", {
5556
- get: function () {
5557
- var _a;
5558
- return (_a = this.window) === null || _a === void 0 ? void 0 : _a.document;
5559
- },
5560
- enumerable: false,
5561
- configurable: true
5562
- });
5563
- Object.defineProperty(Handler.prototype, "allowedKeys", {
5564
- get: function () {
5565
- return this._allowedKeys;
5566
- },
5567
- enumerable: false,
5568
- configurable: true
5569
- });
5570
- Handler.prototype.UpdateAllowedKeys = function (allowedKeys) {
5571
- this._allowedKeys = allowedKeys;
5572
- var params = this.GetParams();
5573
- this.refresh(params);
5574
- };
5575
- Handler.prototype.UpdateParam = function (key, value) {
5576
- var params = this.GetParams();
5577
- params[key + ""] = value + "";
5578
- this.refresh(params);
5579
- };
5580
- Handler.prototype.RemoveParam = function (key) {
5581
- var params = this.GetParams();
5582
- params[key + ""] = null;
5583
- this.refresh(params);
5584
- };
5585
- Handler.prototype.GetParamKeys = function () {
5586
- var params = GetQueryString(this.document);
5587
- return Object.keys(params);
5588
- };
5589
- Handler.prototype.GetParams = function () {
5590
- return GetQueryString(this.document);
5591
- };
5592
- Handler.prototype.GetParam = function (key) {
5593
- var params = this.GetParams();
5594
- return params[key + ""];
5595
- };
5596
- Handler.prototype.Clear = function () {
5597
- this.refresh({});
5598
- };
5599
- Handler.prototype.refresh = function (data) {
5600
- var params = [];
5601
- var keys = Object.keys(data);
5602
- for (var i = 0; i < keys.length; i++) {
5603
- var key = keys[i];
5604
- if (this._allowedKeys == null || this._allowedKeys.includes(key)) {
5605
- var val = data[key];
5606
- if (!!val || val == 0) {
5607
- params.push(key + "=" + val);
5608
- }
5609
- }
5610
- }
5611
- if (params.length > 0) {
5612
- this.window.history.replaceState({}, null, "?" + params.join("&"));
5613
- }
5614
- else {
5615
- this.window.history.replaceState({}, null, "");
5616
- }
5617
- };
5618
- return Handler;
5619
- }());
5620
- UrlUtils.Handler = Handler;
5621
- })(UrlUtils || (UrlUtils = {}));
5622
-
5623
5510
  var ACCOUNT_EXCLUSIONS = ["hyperportal", "hypeportal", "bviewer"];
5624
5511
  /**
5625
5512
  * Describes the "Client Account" concept within Bruce.
5626
5513
  * A client account is a database instance that holds one or many users.
5627
5514
  */
5628
5515
  var Account;
5629
- (function (Account$$1) {
5516
+ (function (Account) {
5630
5517
  function GetCacheKey(accountId, appSettingsId) {
5631
5518
  if (appSettingsId) {
5632
5519
  return Api.ECacheKey.Account + Api.ECacheKey.Id + accountId + Api.ECacheKey + appSettingsId;
5633
5520
  }
5634
5521
  return Api.ECacheKey.Account + Api.ECacheKey.Id + accountId;
5635
5522
  }
5636
- Account$$1.GetCacheKey = GetCacheKey;
5523
+ Account.GetCacheKey = GetCacheKey;
5637
5524
  function GetListCacheKey(ssid) {
5638
5525
  return Api.ECacheKey.Account + Api.ECacheKey.Session + Api.ECacheKey.Id + ssid;
5639
5526
  }
5640
- Account$$1.GetListCacheKey = GetListCacheKey;
5527
+ Account.GetListCacheKey = GetListCacheKey;
5641
5528
  var EDbRegion;
5642
5529
  (function (EDbRegion) {
5643
5530
  EDbRegion["USA"] = "US";
5644
5531
  EDbRegion["Paris"] = "EU";
5645
5532
  EDbRegion["Singapore"] = "SE";
5646
5533
  EDbRegion["Australia"] = "AU";
5647
- })(EDbRegion = Account$$1.EDbRegion || (Account$$1.EDbRegion = {}));
5648
- Account$$1.DbRegions = [
5534
+ })(EDbRegion = Account.EDbRegion || (Account.EDbRegion = {}));
5535
+ Account.DbRegions = [
5649
5536
  {
5650
5537
  name: "North California, USA",
5651
5538
  value: EDbRegion.USA
@@ -5682,7 +5569,7 @@ var Account;
5682
5569
  });
5683
5570
  });
5684
5571
  }
5685
- Account$$1.Get = Get;
5572
+ Account.Get = Get;
5686
5573
  function GetRelatedList(api) {
5687
5574
  return __awaiter(this, void 0, void 0, function () {
5688
5575
  var cacheData, req, prom;
@@ -5718,7 +5605,7 @@ var Account;
5718
5605
  });
5719
5606
  });
5720
5607
  }
5721
- Account$$1.GetRelatedList = GetRelatedList;
5608
+ Account.GetRelatedList = GetRelatedList;
5722
5609
  function GetAppSettings(api, id, appId) {
5723
5610
  return __awaiter(this, void 0, void 0, function () {
5724
5611
  var cacheData, req, prom;
@@ -5760,7 +5647,7 @@ var Account;
5760
5647
  });
5761
5648
  });
5762
5649
  }
5763
- Account$$1.GetAppSettings = GetAppSettings;
5650
+ Account.GetAppSettings = GetAppSettings;
5764
5651
  /**
5765
5652
  * WARNING: Do not update API settings without knowing what you're doing.
5766
5653
  * @param api
@@ -5782,7 +5669,7 @@ var Account;
5782
5669
  });
5783
5670
  });
5784
5671
  }
5785
- Account$$1.UpdateAppSettings = UpdateAppSettings;
5672
+ Account.UpdateAppSettings = UpdateAppSettings;
5786
5673
  /**
5787
5674
  * Creates a new Bruce account using given details.
5788
5675
  * @param api
@@ -5808,8 +5695,221 @@ var Account;
5808
5695
  });
5809
5696
  });
5810
5697
  }
5811
- Account$$1.Create = Create;
5698
+ Account.Create = Create;
5812
5699
  })(Account || (Account = {}));
5813
5700
 
5814
- 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 };
5815
5915
  //# sourceMappingURL=bruce-models.es5.js.map