bruce-models 0.7.4 → 0.7.6

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.
Files changed (33) hide show
  1. package/dist/bruce-models.es5.js +187 -13
  2. package/dist/bruce-models.es5.js.map +1 -1
  3. package/dist/bruce-models.umd.js +184 -11
  4. package/dist/bruce-models.umd.js.map +1 -1
  5. package/dist/lib/api/bruce-api.js +30 -4
  6. package/dist/lib/api/bruce-api.js.map +1 -1
  7. package/dist/lib/api/cam-api.js.map +1 -1
  8. package/dist/lib/api/global-api.js.map +1 -1
  9. package/dist/lib/api/idm-api.js.map +1 -1
  10. package/dist/lib/bruce-models.js +2 -1
  11. package/dist/lib/bruce-models.js.map +1 -1
  12. package/dist/lib/entity/entity.js +11 -2
  13. package/dist/lib/entity/entity.js.map +1 -1
  14. package/dist/lib/project/project-view-bookmark.js +11 -0
  15. package/dist/lib/project/project-view-bookmark.js.map +1 -1
  16. package/dist/lib/project/{project-view-tile-source.js → project-view-legacy-tile.js} +8 -8
  17. package/dist/lib/project/project-view-legacy-tile.js.map +1 -0
  18. package/dist/lib/project/project-view-tile.js +120 -0
  19. package/dist/lib/project/project-view-tile.js.map +1 -0
  20. package/dist/lib/project/project-view.js +11 -0
  21. package/dist/lib/project/project-view.js.map +1 -1
  22. package/dist/types/api/bruce-api.d.ts +22 -2
  23. package/dist/types/api/cam-api.d.ts +1 -1
  24. package/dist/types/api/global-api.d.ts +1 -1
  25. package/dist/types/api/idm-api.d.ts +1 -1
  26. package/dist/types/bruce-models.d.ts +2 -1
  27. package/dist/types/entity/entity.d.ts +10 -1
  28. package/dist/types/project/project-view-bookmark.d.ts +85 -36
  29. package/dist/types/project/{project-view-tile-source.d.ts → project-view-legacy-tile.d.ts} +1 -1
  30. package/dist/types/project/project-view-tile.d.ts +68 -0
  31. package/dist/types/project/project-view.d.ts +64 -39
  32. package/package.json +1 -1
  33. package/dist/lib/project/project-view-tile-source.js.map +0 -1
@@ -907,22 +907,30 @@
907
907
  */
908
908
  var Api$$1 = /** @class */ (function (_super) {
909
909
  __extends(Api$$1, _super);
910
- function Api$$1(accountId, env) {
910
+ /**
911
+ * @param accountId
912
+ * @param env (Optional) environment to use, this will default to PROD.
913
+ * @param cam (Optional) cam instance to use for loading the regional base url.
914
+ */
915
+ function Api$$1(accountId, env, cam) {
911
916
  var _this = _super.call(this, "x-sessionid") || this;
912
917
  _this.baseUrl = "";
918
+ _this.loadCancelled = false;
913
919
  _this.accountId = accountId;
914
920
  _this.env = env !== null && env !== void 0 ? env : exports.Api.EEnv.PROD;
915
- _this.loadProm = _this.setBaseUrl();
921
+ _this.loadProm = _this.setBaseUrl(cam);
916
922
  return _this;
917
923
  }
918
924
  Object.defineProperty(Api$$1.prototype, "Loading", {
925
+ // Indicates if the init process has finished loading.
926
+ // This means the regional base url has been set.
919
927
  get: function () {
920
928
  return this.loadProm;
921
929
  },
922
930
  enumerable: false,
923
931
  configurable: true
924
932
  });
925
- Api$$1.prototype.setBaseUrl = function () {
933
+ Api$$1.prototype.setBaseUrl = function (cam) {
926
934
  var _a;
927
935
  return __awaiter(this, void 0, void 0, function () {
928
936
  var prefix, url, env, camApi, settings, endpoint, e_1;
@@ -951,10 +959,14 @@
951
959
  _b.label = 1;
952
960
  case 1:
953
961
  _b.trys.push([1, 3, , 4]);
954
- camApi = new exports.CamApi.Api(env);
962
+ camApi = cam ? cam : new exports.CamApi.Api(env);
955
963
  return [4 /*yield*/, exports.Account.GetAppSettings(camApi, this.accountId, exports.Account.EAppId.BruceApi)];
956
964
  case 2:
957
965
  settings = _b.sent();
966
+ if (this.loadCancelled) {
967
+ console.warn("BruceApi: Loading was cancelled due to SetBaseUrl being called, not setting regional base url.");
968
+ return [2 /*return*/];
969
+ }
958
970
  endpoint = (_a = settings.BruceAPIURL) === null || _a === void 0 ? void 0 : _a[env];
959
971
  if (typeof endpoint == "string") {
960
972
  if (!endpoint.endsWith("/")) {
@@ -972,14 +984,28 @@
972
984
  });
973
985
  });
974
986
  };
987
+ /**
988
+ * Warning: This method does not wait for init to finish loading.
989
+ * This means the url could be changed once fully initialized.
990
+ * The url will be valid either way, but the loaded one may be faster as it is region specific.
991
+ * Await the "Loading" promise if you care about this.
992
+ * @returns
993
+ */
975
994
  Api$$1.prototype.GetBaseUrl = function () {
976
995
  return this.baseUrl;
977
996
  };
997
+ /**
998
+ * Warning: This will cancel the init process.
999
+ * The init process loads a region specific endpoint.
1000
+ * Setting a base url will stop that process from completing.
1001
+ * @param url
1002
+ */
978
1003
  Api$$1.prototype.SetBaseUrl = function (url) {
979
1004
  this.baseUrl = url;
980
1005
  if (!this.baseUrl.endsWith("/")) {
981
1006
  this.baseUrl += "/";
982
1007
  }
1008
+ this.loadCancelled = true;
983
1009
  };
984
1010
  Api$$1.prototype.GET = function (url, params) {
985
1011
  return __awaiter(this, void 0, void 0, function () {
@@ -1566,7 +1592,16 @@
1566
1592
  return null;
1567
1593
  }
1568
1594
  Entity.GetValue = GetValue;
1569
- function CalculateName(entity, type) {
1595
+ /**
1596
+ * Calculates an entity's name based on attribute priority set in the type.
1597
+ * @param entity
1598
+ * @param type
1599
+ * @param defaultToId
1600
+ * If true, will return the entity ID if no name can be calculated.
1601
+ * Otherwise it returns null.
1602
+ * @returns
1603
+ */
1604
+ function CalculateName(entity, type, defaultToId) {
1570
1605
  var attrStr = type.DisplayNameAttributePath;
1571
1606
  if (attrStr) {
1572
1607
  var attrPaths = attrStr.split(",");
@@ -1579,7 +1614,7 @@
1579
1614
  }
1580
1615
  }
1581
1616
  }
1582
- return entity.Bruce.ID;
1617
+ return defaultToId ? entity.Bruce.ID : null;
1583
1618
  }
1584
1619
  Entity.CalculateName = CalculateName;
1585
1620
  var Filter;
@@ -4861,6 +4896,17 @@
4861
4896
  return "" + exports.Api.ECacheKey.ProjectViewBookmark + exports.Api.ECacheKey.Id + viewId;
4862
4897
  }
4863
4898
  ProjectViewBookmark.GetListCacheKey = GetListCacheKey;
4899
+ // This is the expected default version for the DataVersion value.
4900
+ // This value should NOT be changed without looking at our API and seeing what the default value is.
4901
+ ProjectViewBookmark.DEFAULT_DATA_VERSION = 1;
4902
+ var V1;
4903
+ (function (V1) {
4904
+ V1.DATA_VERSION = 1;
4905
+ })(V1 = ProjectViewBookmark.V1 || (ProjectViewBookmark.V1 = {}));
4906
+ var V2;
4907
+ (function (V2) {
4908
+ V2.DATA_VERSION = 2;
4909
+ })(V2 = ProjectViewBookmark.V2 || (ProjectViewBookmark.V2 = {}));
4864
4910
  function Get(api, viewId, bookmarkId) {
4865
4911
  return __awaiter(this, void 0, void 0, function () {
4866
4912
  var key, cacheData, req;
@@ -4986,6 +5032,17 @@
4986
5032
  return exports.Api.ECacheKey.ProjectView;
4987
5033
  }
4988
5034
  ProjectView.GetListCacheKey = GetListCacheKey;
5035
+ // This is the expected default version for the DataVersion value.
5036
+ // This value should NOT be changed without looking at our API and seeing what the default value is.
5037
+ ProjectView.DEFAULT_DATA_VERSION = 1;
5038
+ var V1;
5039
+ (function (V1) {
5040
+ V1.DATA_VERSION = 1;
5041
+ })(V1 = ProjectView.V1 || (ProjectView.V1 = {}));
5042
+ var V2;
5043
+ (function (V2) {
5044
+ V2.DATA_VERSION = 2;
5045
+ })(V2 = ProjectView.V2 || (ProjectView.V2 = {}));
4989
5046
  function Get(api, viewId) {
4990
5047
  return __awaiter(this, void 0, void 0, function () {
4991
5048
  var key, cacheData, req;
@@ -5103,7 +5160,7 @@
5103
5160
  var view;
5104
5161
  return __generator(this, function (_b) {
5105
5162
  switch (_b.label) {
5106
- case 0: return [4 /*yield*/, exports.ProjectView.Get(apiGetter.getApi(exports.Api.TEMPLATE_ACCOUNT_ID, apiGetter.env), "default")];
5163
+ case 0: return [4 /*yield*/, exports.ProjectView.Get(apiGetter.getApi(exports.Api.TEMPLATE_ACCOUNT_ID), "default")];
5107
5164
  case 1:
5108
5165
  view = _b.sent();
5109
5166
  return [2 /*return*/, (_a = view.Settings) !== null && _a !== void 0 ? _a : {}];
@@ -5123,7 +5180,7 @@
5123
5180
  items.push(templateItem);
5124
5181
  }
5125
5182
  }
5126
- (function (ProjectViewTileSource) {
5183
+ (function (ProjectViewLegacyTile) {
5127
5184
  function MergeMapTemplateData(getter, items, addIfMissing) {
5128
5185
  var _a;
5129
5186
  return __awaiter(this, void 0, void 0, function () {
@@ -5143,7 +5200,7 @@
5143
5200
  });
5144
5201
  });
5145
5202
  }
5146
- ProjectViewTileSource.MergeMapTemplateData = MergeMapTemplateData;
5203
+ ProjectViewLegacyTile.MergeMapTemplateData = MergeMapTemplateData;
5147
5204
  function MergeTerrainTemplateData(getter, items, addIfMissing) {
5148
5205
  var _a;
5149
5206
  return __awaiter(this, void 0, void 0, function () {
@@ -5163,8 +5220,124 @@
5163
5220
  });
5164
5221
  });
5165
5222
  }
5166
- ProjectViewTileSource.MergeTerrainTemplateData = MergeTerrainTemplateData;
5167
- })(exports.ProjectViewTileSource || (exports.ProjectViewTileSource = {}));
5223
+ ProjectViewLegacyTile.MergeTerrainTemplateData = MergeTerrainTemplateData;
5224
+ })(exports.ProjectViewLegacyTile || (exports.ProjectViewLegacyTile = {}));
5225
+
5226
+ (function (ProjectViewTile) {
5227
+ var EDefaultImagery;
5228
+ (function (EDefaultImagery) {
5229
+ EDefaultImagery["BingMapsAerial"] = "bingmapsaerial";
5230
+ EDefaultImagery["BingMapsAerialWithLabels"] = "bingmapsaerialwithlabels";
5231
+ EDefaultImagery["BingMapsRoads"] = "bingmapsroads";
5232
+ EDefaultImagery["MapboxSatellite"] = "mapboxsatellite";
5233
+ EDefaultImagery["MapBoxStreets"] = "mapboxstreets";
5234
+ EDefaultImagery["MapBoxStreetsClassic"] = "mapboxstreetsclassic";
5235
+ EDefaultImagery["EsriWorldImagery"] = "esriworldimagery";
5236
+ EDefaultImagery["EsriWorldStreetMap"] = "esriworldstreetmap";
5237
+ EDefaultImagery["EsriNationalGeographic"] = "esrinationalgeographic";
5238
+ EDefaultImagery["OpenStreetMap"] = "openstreetmap";
5239
+ EDefaultImagery["StamenWaterColor"] = "stamenwatercolor";
5240
+ EDefaultImagery["StamenToner"] = "stamentoner";
5241
+ EDefaultImagery["Grid"] = "grid";
5242
+ })(EDefaultImagery = ProjectViewTile.EDefaultImagery || (ProjectViewTile.EDefaultImagery = {}));
5243
+ /**
5244
+ * Prepared array for UI.
5245
+ * TODO: Im not happy with icon urls sitting in the code. I'd prefer we ship these icons in the library as files.
5246
+ */
5247
+ ProjectViewTile.DefaultImagery = [
5248
+ {
5249
+ id: EDefaultImagery.BingMapsAerial,
5250
+ name: "Bing Maps Aerial",
5251
+ iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/bingAerial.png"
5252
+ },
5253
+ {
5254
+ id: EDefaultImagery.BingMapsAerialWithLabels,
5255
+ name: "Bing Maps Aerial with Labels",
5256
+ iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/bingAerialLabels.png"
5257
+ },
5258
+ {
5259
+ id: EDefaultImagery.BingMapsRoads,
5260
+ name: "Bing Maps Roads",
5261
+ iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/bingRoads.png"
5262
+ },
5263
+ {
5264
+ id: EDefaultImagery.MapboxSatellite,
5265
+ name: "Mapbox Satellite",
5266
+ iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/mapboxSatellite.png"
5267
+ },
5268
+ {
5269
+ id: EDefaultImagery.MapBoxStreets,
5270
+ name: "Mapbox Streets",
5271
+ iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/mapboxTerrain.png"
5272
+ },
5273
+ {
5274
+ id: EDefaultImagery.MapBoxStreetsClassic,
5275
+ name: "Mapbox Streets Classic",
5276
+ iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/mapboxStreets.png"
5277
+ },
5278
+ {
5279
+ id: EDefaultImagery.EsriWorldImagery,
5280
+ name: "Esri World Imagery",
5281
+ iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/esriWorldImagery.png"
5282
+ },
5283
+ {
5284
+ id: EDefaultImagery.EsriWorldStreetMap,
5285
+ name: "Esri World Street Map",
5286
+ iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/esriWorldStreetMap.png"
5287
+ },
5288
+ {
5289
+ id: EDefaultImagery.EsriNationalGeographic,
5290
+ name: "Esri National Geographic",
5291
+ iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/esriNationalGeographic.png"
5292
+ },
5293
+ {
5294
+ id: EDefaultImagery.OpenStreetMap,
5295
+ name: "Open Street Map",
5296
+ iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/openStreetMap.png"
5297
+ },
5298
+ {
5299
+ id: EDefaultImagery.StamenWaterColor,
5300
+ name: "Stamen Water Color",
5301
+ iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/stamenWatercolor.png"
5302
+ },
5303
+ {
5304
+ id: EDefaultImagery.StamenToner,
5305
+ name: "Stamen Toner",
5306
+ iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/stamenToner.png"
5307
+ },
5308
+ {
5309
+ id: EDefaultImagery.Grid,
5310
+ name: "Grid",
5311
+ iconUrl: "https://template.api.nextspace-uat.net/file/2885d8df-028b-4f5c-80b3-2634f7e7cf69.png"
5312
+ }
5313
+ ];
5314
+ var EDefaultTerrain;
5315
+ (function (EDefaultTerrain) {
5316
+ EDefaultTerrain["CesiumWorldTerrain"] = "cesiumworldterrain";
5317
+ EDefaultTerrain["FlatTerrain"] = "flatterrain";
5318
+ EDefaultTerrain["LINZ"] = "linz";
5319
+ })(EDefaultTerrain = ProjectViewTile.EDefaultTerrain || (ProjectViewTile.EDefaultTerrain = {}));
5320
+ /**
5321
+ * Prepared array for UI.
5322
+ * TODO: Im not happy with icon urls sitting in the code. I'd prefer we ship these icons in the library as files.
5323
+ */
5324
+ ProjectViewTile.DefaultTerrains = [
5325
+ {
5326
+ id: EDefaultTerrain.CesiumWorldTerrain,
5327
+ name: "Cesium World Terrain",
5328
+ iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/TerrainProviders/CesiumWorldTerrain.png"
5329
+ },
5330
+ {
5331
+ id: EDefaultTerrain.LINZ,
5332
+ name: "LINZ",
5333
+ iconUrl: "https://template.ui.nextspace.host/media/linz.jpg"
5334
+ },
5335
+ {
5336
+ id: EDefaultTerrain.FlatTerrain,
5337
+ name: "Flat Terrain",
5338
+ }
5339
+ ];
5340
+ })(exports.ProjectViewTile || (exports.ProjectViewTile = {}));
5168
5341
 
5169
5342
  (function (PendingAction) {
5170
5343
  var EStatus;