bruce-models 4.7.8 → 4.8.0

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.
@@ -1600,6 +1600,68 @@ class ApiGetters {
1600
1600
  }
1601
1601
  }
1602
1602
 
1603
+ /**
1604
+ * Simple event utility.
1605
+ * Instantiate the model, then subscribe and trigger events.
1606
+ */
1607
+ class BruceEvent {
1608
+ constructor() {
1609
+ // Counter to help differentiate subscriptions.
1610
+ this._counter = 0;
1611
+ // Record of all callback subscriptions for this event.
1612
+ this.callbacks = [];
1613
+ }
1614
+ /**
1615
+ * Subscribes to this event.
1616
+ * The provided callback will be called when the event is triggered.
1617
+ * @param callback
1618
+ * @returns A function that can be called to unsubscribe from this event.
1619
+ */
1620
+ Subscribe(callback) {
1621
+ let id = this._counter++;
1622
+ let newBruceEventCallback = {
1623
+ _id: id,
1624
+ removeCallback: () => {
1625
+ this.Unsubscribe(id);
1626
+ },
1627
+ callback: callback
1628
+ };
1629
+ this.callbacks.push(newBruceEventCallback);
1630
+ return newBruceEventCallback.removeCallback;
1631
+ }
1632
+ /**
1633
+ * Unsubscribes from this event.
1634
+ * @param id specific subscription entry to remove.
1635
+ * @warning please use the returned function from Subscribe() instead of this function.
1636
+ */
1637
+ Unsubscribe(id) {
1638
+ let index = this.callbacks.findIndex(x => x._id == id);
1639
+ if (index > -1) {
1640
+ this.callbacks.splice(index, 1);
1641
+ }
1642
+ }
1643
+ /**
1644
+ * Triggers this event with optional data.
1645
+ * This will call all subscribed callbacks.
1646
+ * @param data
1647
+ */
1648
+ Trigger(data) {
1649
+ let callbacks = this.callbacks;
1650
+ for (let i = 0; i < callbacks.length; i++) {
1651
+ let callback = callbacks[i];
1652
+ if (callback.callback) {
1653
+ callback.callback(data);
1654
+ }
1655
+ }
1656
+ }
1657
+ /**
1658
+ * Clears all subscriptions.
1659
+ */
1660
+ Clear() {
1661
+ this.callbacks = [];
1662
+ }
1663
+ }
1664
+
1603
1665
  // Global instance for smaller use-cases where you don't want to manage the getters yourself.
1604
1666
  let _getters;
1605
1667
  var ENVIRONMENT;
@@ -1615,6 +1677,9 @@ var ENVIRONMENT;
1615
1677
  // Default session ID.
1616
1678
  sessionId: ""
1617
1679
  };
1680
+ // Subscribe to get notified when someone calls Reset.
1681
+ // If you are manually updating params, call OnParamsChange.Trigger() to notify others.
1682
+ ENVIRONMENT.OnParamsChange = new BruceEvent();
1618
1683
  /**
1619
1684
  * Returns the ApiGetters instance.
1620
1685
  * This is used to communicate with any Nextspace API instance.
@@ -1639,6 +1704,7 @@ var ENVIRONMENT;
1639
1704
  * @param params
1640
1705
  */
1641
1706
  function Reset(params) {
1707
+ var _a;
1642
1708
  if (ENVIRONMENT.IS_SELF_MANAGED) {
1643
1709
  throw ("Self managed mode ON. You are getting this error because you didn't pass an Api instance to a function.");
1644
1710
  }
@@ -1655,6 +1721,7 @@ var ENVIRONMENT;
1655
1721
  }
1656
1722
  }
1657
1723
  ENVIRONMENT.PARAMS = Object.assign(Object.assign({}, ENVIRONMENT.PARAMS), params);
1724
+ (_a = ENVIRONMENT.OnParamsChange) === null || _a === void 0 ? void 0 : _a.Trigger();
1658
1725
  }
1659
1726
  ENVIRONMENT.Reset = Reset;
1660
1727
  })(ENVIRONMENT || (ENVIRONMENT = {}));
@@ -5009,68 +5076,6 @@ var Bounds;
5009
5076
  Bounds.FromEntity = FromEntity;
5010
5077
  })(Bounds || (Bounds = {}));
5011
5078
 
5012
- /**
5013
- * Simple event utility.
5014
- * Instantiate the model, then subscribe and trigger events.
5015
- */
5016
- class BruceEvent {
5017
- constructor() {
5018
- // Counter to help differentiate subscriptions.
5019
- this._counter = 0;
5020
- // Record of all callback subscriptions for this event.
5021
- this.callbacks = [];
5022
- }
5023
- /**
5024
- * Subscribes to this event.
5025
- * The provided callback will be called when the event is triggered.
5026
- * @param callback
5027
- * @returns A function that can be called to unsubscribe from this event.
5028
- */
5029
- Subscribe(callback) {
5030
- let id = this._counter++;
5031
- let newBruceEventCallback = {
5032
- _id: id,
5033
- removeCallback: () => {
5034
- this.Unsubscribe(id);
5035
- },
5036
- callback: callback
5037
- };
5038
- this.callbacks.push(newBruceEventCallback);
5039
- return newBruceEventCallback.removeCallback;
5040
- }
5041
- /**
5042
- * Unsubscribes from this event.
5043
- * @param id specific subscription entry to remove.
5044
- * @warning please use the returned function from Subscribe() instead of this function.
5045
- */
5046
- Unsubscribe(id) {
5047
- let index = this.callbacks.findIndex(x => x._id == id);
5048
- if (index > -1) {
5049
- this.callbacks.splice(index, 1);
5050
- }
5051
- }
5052
- /**
5053
- * Triggers this event with optional data.
5054
- * This will call all subscribed callbacks.
5055
- * @param data
5056
- */
5057
- Trigger(data) {
5058
- let callbacks = this.callbacks;
5059
- for (let i = 0; i < callbacks.length; i++) {
5060
- let callback = callbacks[i];
5061
- if (callback.callback) {
5062
- callback.callback(data);
5063
- }
5064
- }
5065
- }
5066
- /**
5067
- * Clears all subscriptions.
5068
- */
5069
- Clear() {
5070
- this.callbacks = [];
5071
- }
5072
- }
5073
-
5074
5079
  var Camera;
5075
5080
  (function (Camera) {
5076
5081
  let EFrustum;
@@ -13194,9 +13199,49 @@ var DataLab;
13194
13199
  DataLab.Run = Run;
13195
13200
  })(DataLab || (DataLab = {}));
13196
13201
 
13202
+ var ImportAssembly;
13203
+ (function (ImportAssembly) {
13204
+ function Analyze(params) {
13205
+ return __awaiter(this, void 0, void 0, function* () {
13206
+ let { api, fileAnalyze, req: reqParams } = params;
13207
+ if (!api) {
13208
+ api = ENVIRONMENT.Api().GetBruceApi();
13209
+ }
13210
+ return api.POST("import/analyze/assembly", fileAnalyze, Api.PrepReqParams(reqParams));
13211
+ });
13212
+ }
13213
+ ImportAssembly.Analyze = Analyze;
13214
+ function ImportEntities(params) {
13215
+ return __awaiter(this, void 0, void 0, function* () {
13216
+ let { api, fileImport, req: reqParams } = params;
13217
+ if (!api) {
13218
+ api = ENVIRONMENT.Api().GetBruceApi();
13219
+ }
13220
+ return api.POST("import/assembly", fileImport, Api.PrepReqParams(reqParams));
13221
+ });
13222
+ }
13223
+ ImportAssembly.ImportEntities = ImportEntities;
13224
+ /**
13225
+ * Parses the completed pending action result from running "ImportEntities".
13226
+ * This will return the root entity's id if any is present.
13227
+ * @param paResult
13228
+ */
13229
+ function ParseAnalysisResult(paResult) {
13230
+ try {
13231
+ return typeof paResult == "string" ? JSON.parse(paResult) : paResult;
13232
+ }
13233
+ catch (_a) {
13234
+ // Failed to parse json.
13235
+ }
13236
+ return null;
13237
+ }
13238
+ ImportAssembly.ParseAnalysisResult = ParseAnalysisResult;
13239
+ })(ImportAssembly || (ImportAssembly = {}));
13240
+
13197
13241
  /**
13198
13242
  * TODO: The analysis result is currently a mix of multiple layers of legacy.
13199
13243
  * We will first decide what we want it to do and then describe just the needed portions of the existing implementation.
13244
+ * @deprecated use import-assembly, this will be removed next update.
13200
13245
  */
13201
13246
  var ImportCad;
13202
13247
  (function (ImportCad) {
@@ -13249,7 +13294,7 @@ var ImportCsv;
13249
13294
  if (!api) {
13250
13295
  api = ENVIRONMENT.Api().GetBruceApi();
13251
13296
  }
13252
- return api.POST("entities/importCSVWithProgress2", fileImport, Api.PrepReqParams(reqParams));
13297
+ return api.POST("import/csv", fileImport, Api.PrepReqParams(reqParams));
13253
13298
  });
13254
13299
  }
13255
13300
  ImportCsv.ImportEntities = ImportEntities;
@@ -13263,12 +13308,26 @@ var ImportJson;
13263
13308
  if (!api) {
13264
13309
  api = ENVIRONMENT.Api().GetBruceApi();
13265
13310
  }
13266
- return api.POST("entities/importJsonWithProgress", fileImport, Api.PrepReqParams(reqParams));
13311
+ return api.POST("import/json", fileImport, Api.PrepReqParams(reqParams));
13267
13312
  });
13268
13313
  }
13269
13314
  ImportJson.ImportEntities = ImportEntities;
13270
13315
  })(ImportJson || (ImportJson = {}));
13271
13316
 
13317
+ var ImportGeoJson;
13318
+ (function (ImportGeoJson) {
13319
+ function ImportEntities(params) {
13320
+ return __awaiter(this, void 0, void 0, function* () {
13321
+ let { api, fileImport, req: reqParams } = params;
13322
+ if (!api) {
13323
+ api = ENVIRONMENT.Api().GetBruceApi();
13324
+ }
13325
+ return api.POST("import/geojson", fileImport, Api.PrepReqParams(reqParams));
13326
+ });
13327
+ }
13328
+ ImportGeoJson.ImportEntities = ImportEntities;
13329
+ })(ImportGeoJson || (ImportGeoJson = {}));
13330
+
13272
13331
  var ImportKml;
13273
13332
  (function (ImportKml) {
13274
13333
  function ImportEntities(params) {
@@ -13277,7 +13336,7 @@ var ImportKml;
13277
13336
  if (!api) {
13278
13337
  api = ENVIRONMENT.Api().GetBruceApi();
13279
13338
  }
13280
- return api.POST("entities/importKMLWithProgress2", fileImport, Api.PrepReqParams(reqParams));
13339
+ return api.POST("import/kml", fileImport, Api.PrepReqParams(reqParams));
13281
13340
  });
13282
13341
  }
13283
13342
  ImportKml.ImportEntities = ImportEntities;
@@ -14135,7 +14194,7 @@ var DataSource;
14135
14194
  })(DataSource || (DataSource = {}));
14136
14195
 
14137
14196
  // This is updated with the package.json version on build.
14138
- const VERSION = "4.7.8";
14197
+ const VERSION = "4.8.0";
14139
14198
 
14140
- export { VERSION, AnnDocument, CustomForm, AbstractApi, Api, BruceApi, GlobalApi, GuardianApi, ApiGetters, Calculator, Bounds, BruceEvent, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, Geometry, UTC, BruceVariable, LRUCache, GeoJson, EntityAttachmentType, EntityAttachment, EntityComment, EntityLink, EntityLod, EntityLodCategory, EntityRelationType, EntityRelation, EntitySource, EntityTag, EntityType, Entity, EntityCoords, EntityTypeVisualSettings, EntityAttribute, EntityHistoricData, EntityTableView, Comment, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, ProjectViewLegacyTile, ProjectViewTile, ProjectViewLegacy, ProjectViewLegacyBookmark, PendingAction, MessageBroker, HostingLocation, Style, Tileset, Permission, Session, UserGroup, User, Account, AccountInvite, AccountFeatures, AccountLimits, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, DataLab, ImportCad, ImportCsv, ImportJson, ImportKml, ImportedFile, Markup, Uploader, Plugin, ENVIRONMENT, DataSource };
14199
+ export { VERSION, AnnDocument, CustomForm, AbstractApi, Api, BruceApi, GlobalApi, GuardianApi, ApiGetters, Calculator, Bounds, BruceEvent, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, Geometry, UTC, BruceVariable, LRUCache, GeoJson, EntityAttachmentType, EntityAttachment, EntityComment, EntityLink, EntityLod, EntityLodCategory, EntityRelationType, EntityRelation, EntitySource, EntityTag, EntityType, Entity, EntityCoords, EntityTypeVisualSettings, EntityAttribute, EntityHistoricData, EntityTableView, Comment, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, ProjectViewLegacyTile, ProjectViewTile, ProjectViewLegacy, ProjectViewLegacyBookmark, PendingAction, MessageBroker, HostingLocation, Style, Tileset, Permission, Session, UserGroup, User, Account, AccountInvite, AccountFeatures, AccountLimits, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, DataLab, ImportAssembly, ImportCad, ImportCsv, ImportJson, ImportGeoJson, ImportKml, ImportedFile, Markup, Uploader, Plugin, ENVIRONMENT, DataSource };
14141
14200
  //# sourceMappingURL=bruce-models.es5.js.map