bruce-models 1.5.0 → 1.5.2

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.
@@ -501,10 +501,20 @@ function parseResult(data) {
501
501
  * This is a base class for communication with an arbitrary Bruce Api.
502
502
  */
503
503
  class AbstractApi {
504
- constructor(ssidHeader) {
504
+ constructor(params) {
505
505
  this.ssid = "";
506
+ this.baseUrl = "";
506
507
  this.Cache = new CacheControl();
507
- this.ssidHeader = ssidHeader;
508
+ this.ssidHeader = params === null || params === void 0 ? void 0 : params.ssidHeader;
509
+ }
510
+ GetBaseUrl() {
511
+ return this.baseUrl;
512
+ }
513
+ SetBaseUrl(url) {
514
+ this.baseUrl = url;
515
+ if (!this.baseUrl.endsWith("/")) {
516
+ this.baseUrl += "/";
517
+ }
508
518
  }
509
519
  GetCacheItem(key, reqParams) {
510
520
  let noCache = reqParams === null || reqParams === void 0 ? void 0 : reqParams.noCache;
@@ -978,17 +988,17 @@ var BruceApi;
978
988
  */
979
989
  class Api$$1 extends AbstractApi {
980
990
  /**
981
- * @param accountId
982
- * @param env (Optional) environment to use, this will default to PROD.
983
- * @param cam (Optional) cam instance to use for loading the regional base url.
991
+ * @param params
984
992
  */
985
- constructor(accountId, env, cam) {
986
- super("x-sessionid");
987
- this.baseUrl = "";
993
+ constructor(params) {
994
+ super({
995
+ ssidHeader: "x-sessionid"
996
+ });
988
997
  this.loadCancelled = false;
998
+ const { accountId, env, cam, loadRegionalBaseUrl } = params;
989
999
  this.accountId = accountId;
990
1000
  this.env = env !== null && env !== void 0 ? env : Api.EEnv.PROD;
991
- this.loadProm = this.init(cam);
1001
+ this.loadProm = this.init(cam, loadRegionalBaseUrl);
992
1002
  }
993
1003
  get MessageBroker() {
994
1004
  return this.messageBroker;
@@ -1001,11 +1011,15 @@ var BruceApi;
1001
1011
  /**
1002
1012
  * Loads regional base url and sets up message broker.
1003
1013
  * @param cam Required for loading regional base url.
1014
+ * @param loadRegionalUrl
1004
1015
  * @returns
1005
1016
  */
1006
- init(cam) {
1017
+ init(cam, loadRegionalUrl) {
1007
1018
  var _a;
1008
1019
  return __awaiter(this, void 0, void 0, function* () {
1020
+ if (!this.accountId) {
1021
+ throw ("accountId is required.");
1022
+ }
1009
1023
  // Set using a stable default.
1010
1024
  const prefix = `https://${this.accountId}.api.nextspace`;
1011
1025
  let url;
@@ -1027,7 +1041,7 @@ var BruceApi;
1027
1041
  throw ("Specified Environment is not valid. SuppliedEnv=" + env);
1028
1042
  }
1029
1043
  this.baseUrl = url;
1030
- if (cam) {
1044
+ if (cam && loadRegionalUrl) {
1031
1045
  // Attempt to load an account specific base url.
1032
1046
  // This could be one with a region specific endpoint.
1033
1047
  try {
@@ -1139,10 +1153,11 @@ var BruceApi;
1139
1153
  var CamApi;
1140
1154
  (function (CamApi) {
1141
1155
  class Api$$1 extends AbstractApi {
1142
- constructor(env) {
1143
- super("SSID");
1144
- this.baseUrl = "";
1145
- this.env = env !== null && env !== void 0 ? env : Api.EEnv.PROD;
1156
+ constructor(params) {
1157
+ super({
1158
+ ssidHeader: "SSID"
1159
+ });
1160
+ this.env = (params === null || params === void 0 ? void 0 : params.env) ? params.env : Api.EEnv.PROD;
1146
1161
  this.setBaseUrl();
1147
1162
  }
1148
1163
  setBaseUrl() {
@@ -1207,10 +1222,11 @@ var IdmApi;
1207
1222
  * it should be passed to any method that wants to communicate with this particular api.
1208
1223
  */
1209
1224
  class Api$$1 extends AbstractApi {
1210
- constructor(env) {
1211
- super("SSID");
1212
- this.baseUrl = "";
1213
- this.env = env !== null && env !== void 0 ? env : Api.EEnv.PROD;
1225
+ constructor(params) {
1226
+ super({
1227
+ ssidHeader: "SSID"
1228
+ });
1229
+ this.env = (params === null || params === void 0 ? void 0 : params.env) ? params.env : Api.EEnv.PROD;
1214
1230
  this.setBaseUrl();
1215
1231
  }
1216
1232
  setBaseUrl() {
@@ -1275,10 +1291,11 @@ var GlobalApi;
1275
1291
  * it should be passed to any method that wants to communicate with this particular api.
1276
1292
  */
1277
1293
  class Api$$1 extends AbstractApi {
1278
- constructor(env) {
1279
- super("x-sessionid");
1280
- this.baseUrl = "";
1281
- this.env = env !== null && env !== void 0 ? env : Api.EEnv.PROD;
1294
+ constructor(params) {
1295
+ super({
1296
+ ssidHeader: "x-sessionid"
1297
+ });
1298
+ this.env = (params === null || params === void 0 ? void 0 : params.env) ? params.env : Api.EEnv.PROD;
1282
1299
  this.setBaseUrl();
1283
1300
  }
1284
1301
  setBaseUrl() {
@@ -1335,6 +1352,132 @@ var GlobalApi;
1335
1352
  GlobalApi.Api = Api$$1;
1336
1353
  })(GlobalApi || (GlobalApi = {}));
1337
1354
 
1355
+ class ApiGetters {
1356
+ constructor(params) {
1357
+ this.bruce = {};
1358
+ this.idm = {};
1359
+ this.cam = {};
1360
+ this.global = {};
1361
+ this.accountId = params === null || params === void 0 ? void 0 : params.accountId;
1362
+ this.env = (params === null || params === void 0 ? void 0 : params.env) ? params.env : Api.EEnv.PROD;
1363
+ this.sessionId = params === null || params === void 0 ? void 0 : params.sessionId;
1364
+ }
1365
+ SetAccountId(accountId) {
1366
+ this.accountId = accountId;
1367
+ }
1368
+ GetAccountId() {
1369
+ return this.accountId;
1370
+ }
1371
+ SetEnv(env) {
1372
+ this.env = env;
1373
+ }
1374
+ GetEnv() {
1375
+ return this.env;
1376
+ }
1377
+ SetSessionId(sessionId) {
1378
+ this.sessionId = sessionId;
1379
+ for (const key in this.bruce) {
1380
+ this.bruce[key].SetSessionId(sessionId);
1381
+ }
1382
+ for (const key in this.idm) {
1383
+ this.idm[key].SetSessionId(sessionId);
1384
+ }
1385
+ for (const key in this.cam) {
1386
+ this.cam[key].SetSessionId(sessionId);
1387
+ }
1388
+ for (const key in this.global) {
1389
+ this.global[key].SetSessionId(sessionId);
1390
+ }
1391
+ }
1392
+ GetSessionId() {
1393
+ return this.sessionId;
1394
+ }
1395
+ GetBruceApi(params) {
1396
+ let { accountId, env } = params;
1397
+ accountId = accountId ? accountId : this.accountId;
1398
+ env = env ? env : this.env;
1399
+ const key = `${accountId}-${env}`;
1400
+ if (!this.bruce[key]) {
1401
+ this.bruce[key] = new BruceApi.Api({
1402
+ accountId,
1403
+ env,
1404
+ loadRegionalBaseUrl: true
1405
+ });
1406
+ this.bruce[key].SetSessionId(this.sessionId);
1407
+ }
1408
+ return this.bruce[key];
1409
+ }
1410
+ GetBruceGetter() {
1411
+ return {
1412
+ accountId: this.accountId,
1413
+ env: this.env,
1414
+ getApi: (accountId, env) => {
1415
+ return this.GetBruceApi({ accountId, env });
1416
+ }
1417
+ };
1418
+ }
1419
+ GetIdmApi(params) {
1420
+ let { env } = params;
1421
+ env = env ? env : this.env;
1422
+ const key = `${env}`;
1423
+ if (!this.idm[key]) {
1424
+ this.idm[key] = new IdmApi.Api({
1425
+ env
1426
+ });
1427
+ this.idm[key].SetSessionId(this.sessionId);
1428
+ }
1429
+ return this.idm[key];
1430
+ }
1431
+ GetIdmGetter() {
1432
+ return {
1433
+ env: this.env,
1434
+ getApi: (env) => {
1435
+ return this.GetIdmApi({ env });
1436
+ }
1437
+ };
1438
+ }
1439
+ GetCamApi(params) {
1440
+ let { env } = params;
1441
+ env = env ? env : this.env;
1442
+ const key = `${env}`;
1443
+ if (!this.cam[key]) {
1444
+ this.cam[key] = new CamApi.Api({
1445
+ env
1446
+ });
1447
+ this.cam[key].SetSessionId(this.sessionId);
1448
+ }
1449
+ return this.cam[key];
1450
+ }
1451
+ GetCamGetter() {
1452
+ return {
1453
+ env: this.env,
1454
+ getApi: (env) => {
1455
+ return this.GetCamApi({ env });
1456
+ }
1457
+ };
1458
+ }
1459
+ GetGlobalApi(params) {
1460
+ let { env } = params;
1461
+ env = env ? env : this.env;
1462
+ const key = `${env}`;
1463
+ if (!this.global[key]) {
1464
+ this.global[key] = new GlobalApi.Api({
1465
+ env
1466
+ });
1467
+ this.global[key].SetSessionId(this.sessionId);
1468
+ }
1469
+ return this.global[key];
1470
+ }
1471
+ GetGlobalGetter() {
1472
+ return {
1473
+ env: this.env,
1474
+ getApi: (env) => {
1475
+ return this.GetGlobalApi({ env });
1476
+ }
1477
+ };
1478
+ }
1479
+ }
1480
+
1338
1481
  var Color;
1339
1482
  (function (Color) {
1340
1483
  let EBlendMode;
@@ -6952,5 +7095,5 @@ var Markup;
6952
7095
  })(Circle = Markup.Circle || (Markup.Circle = {}));
6953
7096
  })(Markup || (Markup = {}));
6954
7097
 
6955
- export { AnnDocument, CustomForm, CustomFormContent, AbstractApi, Api, BruceApi, CamApi, IdmApi, GlobalApi, Calculator, Bounds, BruceEvent, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, Geometry, UTC, BruceVariable, EntityAttachmentType, EntityAttachment, EntityComment, EntityLink, EntityLod, EntityLodCategory, EntityRelationType, EntityRelation, EntitySource, EntityTag, EntityType, Entity, EntityGlobe, EntityFilterGetter, BatchedDataGetter, EntityCoords, EntityTypeVisualSettings, EntityAttribute, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, ProjectViewLegacyTile, ProjectViewTile, PendingAction, MessageBroker, Style, Tileset, Permission, Session, UserGroup, User, Account, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, DataLab, ImportCad, ImportCsv, ImportJson, ImportKml, ImportedFile, Markup };
7098
+ export { AnnDocument, CustomForm, CustomFormContent, AbstractApi, Api, BruceApi, CamApi, IdmApi, GlobalApi, ApiGetters, Calculator, Bounds, BruceEvent, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, Geometry, UTC, BruceVariable, EntityAttachmentType, EntityAttachment, EntityComment, EntityLink, EntityLod, EntityLodCategory, EntityRelationType, EntityRelation, EntitySource, EntityTag, EntityType, Entity, EntityGlobe, EntityFilterGetter, BatchedDataGetter, EntityCoords, EntityTypeVisualSettings, EntityAttribute, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, ProjectViewLegacyTile, ProjectViewTile, PendingAction, MessageBroker, Style, Tileset, Permission, Session, UserGroup, User, Account, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, DataLab, ImportCad, ImportCsv, ImportJson, ImportKml, ImportedFile, Markup };
6956
7099
  //# sourceMappingURL=bruce-models.es5.js.map