bruce-models 3.5.7 → 3.5.9
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.
- package/dist/bruce-models.es5.js +150 -94
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +150 -94
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/api/api-getters.js +17 -3
- package/dist/lib/api/api-getters.js.map +1 -1
- package/dist/lib/api/bruce-api.js +125 -88
- package/dist/lib/api/bruce-api.js.map +1 -1
- package/dist/lib/bruce-models.js +1 -1
- package/dist/lib/calculator/calculator.js +7 -2
- package/dist/lib/calculator/calculator.js.map +1 -1
- package/dist/types/api/bruce-api.d.ts +11 -1
- package/dist/types/bruce-models.d.ts +1 -1
- package/package.json +1 -1
package/dist/bruce-models.es5.js
CHANGED
|
@@ -1297,6 +1297,9 @@ var BruceApi;
|
|
|
1297
1297
|
get MessageBroker() {
|
|
1298
1298
|
return this.messageBroker;
|
|
1299
1299
|
}
|
|
1300
|
+
get ConfigLoadAttempted() {
|
|
1301
|
+
return this.configLoadAttempted;
|
|
1302
|
+
}
|
|
1300
1303
|
get Loading() {
|
|
1301
1304
|
return this.loadProm;
|
|
1302
1305
|
}
|
|
@@ -1308,16 +1311,18 @@ var BruceApi;
|
|
|
1308
1311
|
// Load cancelled indicates the user set a custom base url.
|
|
1309
1312
|
// This will stop the regional url from being set if it's still loading.
|
|
1310
1313
|
this.loadCancelled = false;
|
|
1314
|
+
// Indicates if loading the regional configuration was already called.
|
|
1315
|
+
this.configLoadAttempted = false;
|
|
1311
1316
|
let { accountId, env, guardian, loadRegionalBaseUrl, loadConfig, loadWebSocket } = params;
|
|
1312
1317
|
this.accountId = accountId;
|
|
1313
1318
|
this.env = env !== null && env !== void 0 ? env : Api.EEnv.PROD;
|
|
1319
|
+
// Backwards compatibility.
|
|
1314
1320
|
if (loadRegionalBaseUrl) {
|
|
1315
1321
|
loadConfig = true;
|
|
1316
1322
|
}
|
|
1317
|
-
if (
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
});
|
|
1323
|
+
if (loadConfig) {
|
|
1324
|
+
// Mark it as attempted right away because we don't want any external calls while it gets to that async point.
|
|
1325
|
+
this.configLoadAttempted = true;
|
|
1321
1326
|
}
|
|
1322
1327
|
this.loadProm = this.init(guardian, loadConfig, loadWebSocket);
|
|
1323
1328
|
}
|
|
@@ -1328,110 +1333,142 @@ var BruceApi;
|
|
|
1328
1333
|
* @returns
|
|
1329
1334
|
*/
|
|
1330
1335
|
init(guardian, loadConfig, loadWebSocket) {
|
|
1331
|
-
var _a, _b, _c;
|
|
1332
1336
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1333
1337
|
if (!this.accountId) {
|
|
1334
1338
|
throw ("accountId is required.");
|
|
1335
1339
|
}
|
|
1336
|
-
const env = this.env.toUpperCase();
|
|
1337
|
-
let domain = "nextspace.host";
|
|
1338
|
-
switch (env) {
|
|
1339
|
-
case Api.EEnv.DEV:
|
|
1340
|
-
domain = "nextspace-dev.net";
|
|
1341
|
-
break;
|
|
1342
|
-
case Api.EEnv.STG:
|
|
1343
|
-
domain = "nextspace-stg.net";
|
|
1344
|
-
break;
|
|
1345
|
-
case Api.EEnv.UAT:
|
|
1346
|
-
domain = "nextspace-uat.net";
|
|
1347
|
-
break;
|
|
1348
|
-
case Api.EEnv.PROD:
|
|
1349
|
-
domain = "nextspace.host";
|
|
1350
|
-
break;
|
|
1351
|
-
default:
|
|
1352
|
-
console.error("Specified Environment is not valid. SuppliedEnv=" + env);
|
|
1353
|
-
}
|
|
1354
1340
|
// Set using a stable default.
|
|
1341
|
+
const domain = this.getDomain();
|
|
1355
1342
|
this.baseUrl = `https://${this.accountId}.api.${domain}/`;
|
|
1356
|
-
|
|
1343
|
+
// Attempt to load regional configuration.
|
|
1344
|
+
if (loadConfig) {
|
|
1345
|
+
yield this.LoadConfig({
|
|
1346
|
+
guardian: guardian,
|
|
1347
|
+
// We marked it as attempted to load outside this method to fight any external calls.
|
|
1348
|
+
// So we'll force load it now.
|
|
1349
|
+
forceLoad: true
|
|
1350
|
+
});
|
|
1351
|
+
}
|
|
1352
|
+
// Start web socket connection.
|
|
1353
|
+
if (loadWebSocket != false) {
|
|
1357
1354
|
try {
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1355
|
+
this.messageBroker = new MessageBroker.WebSocketBroker(this.baseUrl, this.env);
|
|
1356
|
+
}
|
|
1357
|
+
catch (e) {
|
|
1358
|
+
console.warn("BruceApi: Failed to create message broker.", e);
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
});
|
|
1362
|
+
}
|
|
1363
|
+
getDomain() {
|
|
1364
|
+
const env = this.env.toUpperCase();
|
|
1365
|
+
let domain = "nextspace.host";
|
|
1366
|
+
switch (env) {
|
|
1367
|
+
case Api.EEnv.DEV:
|
|
1368
|
+
domain = "nextspace-dev.net";
|
|
1369
|
+
break;
|
|
1370
|
+
case Api.EEnv.STG:
|
|
1371
|
+
domain = "nextspace-stg.net";
|
|
1372
|
+
break;
|
|
1373
|
+
case Api.EEnv.UAT:
|
|
1374
|
+
domain = "nextspace-uat.net";
|
|
1375
|
+
break;
|
|
1376
|
+
case Api.EEnv.PROD:
|
|
1377
|
+
domain = "nextspace.host";
|
|
1378
|
+
break;
|
|
1379
|
+
default:
|
|
1380
|
+
console.error("Specified Environment is not valid. SuppliedEnv=" + env);
|
|
1381
|
+
}
|
|
1382
|
+
return domain;
|
|
1383
|
+
}
|
|
1384
|
+
/**
|
|
1385
|
+
* Loads the regional configuration for the account.
|
|
1386
|
+
* If the config is already loaded then this will do nothing.
|
|
1387
|
+
*/
|
|
1388
|
+
LoadConfig(params) {
|
|
1389
|
+
var _a, _b, _c;
|
|
1390
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1391
|
+
let { guardian, forceLoad } = (params !== null && params !== void 0 ? params : {});
|
|
1392
|
+
if (this.configLoadAttempted && forceLoad != true) {
|
|
1393
|
+
return;
|
|
1394
|
+
}
|
|
1395
|
+
this.configLoadAttempted = true;
|
|
1396
|
+
try {
|
|
1397
|
+
if (!guardian) {
|
|
1398
|
+
guardian = new GuardianApi.Api({
|
|
1399
|
+
env: this.env
|
|
1361
1400
|
});
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
}
|
|
1380
|
-
// Try go through host location's base url.
|
|
1381
|
-
// This may be wrong env which is why it's used as fallback right now.
|
|
1382
|
-
if (!urlSet && host.location.BruceAPIURL) {
|
|
1383
|
-
const regionalUrl = host.location.BruceAPIURL
|
|
1401
|
+
}
|
|
1402
|
+
const env = this.env.toUpperCase();
|
|
1403
|
+
const domain = this.getDomain();
|
|
1404
|
+
const host = yield HostingLocation.GetByAccountId({
|
|
1405
|
+
accountId: this.accountId,
|
|
1406
|
+
api: guardian
|
|
1407
|
+
});
|
|
1408
|
+
if (host === null || host === void 0 ? void 0 : host.location) {
|
|
1409
|
+
const settings = host.location.Settings;
|
|
1410
|
+
if (!this.loadCancelled) {
|
|
1411
|
+
// Attempt to load regional base url.
|
|
1412
|
+
// First try go through settings.
|
|
1413
|
+
let urlSet = false;
|
|
1414
|
+
if (settings === null || settings === void 0 ? void 0 : settings.BruceAPIURL) {
|
|
1415
|
+
let envUrl = settings.BruceAPIURL[env];
|
|
1416
|
+
if (envUrl) {
|
|
1417
|
+
envUrl = envUrl
|
|
1384
1418
|
.replace("<ACCOUNTID>", this.accountId)
|
|
1385
|
-
.replace("<ACCOUNT>", this.accountId)
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
this.baseUrl = regionalUrl;
|
|
1419
|
+
.replace("<ACCOUNT>", this.accountId);
|
|
1420
|
+
if (envUrl && envUrl.length > 1) {
|
|
1421
|
+
this.baseUrl = envUrl;
|
|
1389
1422
|
urlSet = true;
|
|
1390
1423
|
}
|
|
1391
1424
|
}
|
|
1392
1425
|
}
|
|
1393
|
-
//
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
}
|
|
1426
|
+
// Try go through host location's base url.
|
|
1427
|
+
// This may be wrong env which is why it's used as fallback right now.
|
|
1428
|
+
if (!urlSet && host.location.BruceAPIURL) {
|
|
1429
|
+
const regionalUrl = host.location.BruceAPIURL
|
|
1430
|
+
.replace("<ACCOUNTID>", this.accountId)
|
|
1431
|
+
.replace("<ACCOUNT>", this.accountId)
|
|
1432
|
+
.replace("<DOMAIN>", domain);
|
|
1433
|
+
if (regionalUrl && regionalUrl.length > 1) {
|
|
1434
|
+
this.baseUrl = regionalUrl;
|
|
1435
|
+
urlSet = true;
|
|
1404
1436
|
}
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1439
|
+
// Attempt to load CDN settings.
|
|
1440
|
+
if (settings === null || settings === void 0 ? void 0 : settings.CDN) {
|
|
1441
|
+
this.EntityCdnUrl = (_a = settings.CDN.entityURL) === null || _a === void 0 ? void 0 : _a[env];
|
|
1442
|
+
// We need to fix our configs.
|
|
1443
|
+
if (this.EntityCdnUrl) {
|
|
1444
|
+
if (this.EntityCdnUrl.includes("entitiesListForCDN")) {
|
|
1445
|
+
this.EntityCdnUrl = this.EntityCdnUrl.replace("<ACCOUNT>", this.accountId);
|
|
1409
1446
|
}
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1447
|
+
else {
|
|
1448
|
+
this.EntityCdnUrl = this.EntityCdnUrl.replace("<ACCOUNT>", "entitiesListForCDN/" + this.accountId);
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
this.LegacyTilesetCdnUrl = (_b = settings.CDN.legacyTilesetURL) === null || _b === void 0 ? void 0 : _b[env];
|
|
1452
|
+
this.TilesetCdnUrl = (_c = settings.CDN.tilesetURL) === null || _c === void 0 ? void 0 : _c[env];
|
|
1453
|
+
if (this.TilesetCdnUrl) {
|
|
1454
|
+
this.TilesetCdnUrl = this.TilesetCdnUrl.replace("<ACCOUNT>", this.accountId);
|
|
1455
|
+
}
|
|
1456
|
+
// TilesetCdnUrl example: "https://blah.cloudfront.net/tilesets/<TILESETID>/files/<FILEPATH>?accountId=<ACCOUNT>".
|
|
1457
|
+
// Lazy at the moment to go around updating every region we have, I'll interpret the url from tilesetCdnUrl.
|
|
1458
|
+
if (this.TilesetCdnUrl) {
|
|
1459
|
+
try {
|
|
1460
|
+
const url = new URL(this.TilesetCdnUrl);
|
|
1461
|
+
this.cdnBaseUrl = `${url.protocol}//${url.hostname}/`;
|
|
1462
|
+
}
|
|
1463
|
+
catch (e) {
|
|
1464
|
+
console.error(e);
|
|
1420
1465
|
}
|
|
1421
1466
|
}
|
|
1422
1467
|
}
|
|
1423
1468
|
}
|
|
1424
|
-
catch (e) {
|
|
1425
|
-
console.error(e);
|
|
1426
|
-
}
|
|
1427
1469
|
}
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
this.messageBroker = new MessageBroker.WebSocketBroker(this.baseUrl, this.env);
|
|
1431
|
-
}
|
|
1432
|
-
catch (e) {
|
|
1433
|
-
console.warn("BruceApi: Failed to create message broker.", e);
|
|
1434
|
-
}
|
|
1470
|
+
catch (e) {
|
|
1471
|
+
console.error(e);
|
|
1435
1472
|
}
|
|
1436
1473
|
});
|
|
1437
1474
|
}
|
|
@@ -1746,6 +1783,17 @@ class ApiGetters {
|
|
|
1746
1783
|
*/
|
|
1747
1784
|
SetAccountId(accountId) {
|
|
1748
1785
|
this.accountId = accountId;
|
|
1786
|
+
// Queue load of regional config in case an instance was made earlier without it.
|
|
1787
|
+
// We want the default account to always go through the fastest regional endpoint.
|
|
1788
|
+
const api = this.GetBruceApi({
|
|
1789
|
+
accountId: accountId,
|
|
1790
|
+
loadConfig: true
|
|
1791
|
+
});
|
|
1792
|
+
api.LoadConfig({
|
|
1793
|
+
guardian: this.GetGuardianApi({
|
|
1794
|
+
env: this.env
|
|
1795
|
+
})
|
|
1796
|
+
});
|
|
1749
1797
|
}
|
|
1750
1798
|
/**
|
|
1751
1799
|
* Returns the default account ID to use when one is unspecified.
|
|
@@ -1810,7 +1858,9 @@ class ApiGetters {
|
|
|
1810
1858
|
this.bruce[key] = new BruceApi.Api({
|
|
1811
1859
|
accountId,
|
|
1812
1860
|
env,
|
|
1813
|
-
|
|
1861
|
+
// We'll load regional config if the accountId matches the default accountId.
|
|
1862
|
+
// We'll also load if it no default is known.
|
|
1863
|
+
loadConfig: loadConfig != null ? loadConfig : (this.accountId == accountId || !this.accountId),
|
|
1814
1864
|
loadWebSocket: loadWebSocket,
|
|
1815
1865
|
guardian: this.GetGuardianApi({
|
|
1816
1866
|
env
|
|
@@ -1834,8 +1884,9 @@ class ApiGetters {
|
|
|
1834
1884
|
return this.GetBruceApi({
|
|
1835
1885
|
accountId,
|
|
1836
1886
|
env,
|
|
1837
|
-
|
|
1838
|
-
|
|
1887
|
+
// We'll load regional config if the accountId matches the default accountId.
|
|
1888
|
+
// We'll also load if it no default is known.
|
|
1889
|
+
loadConfig: this.accountId == accountId || !this.accountId
|
|
1839
1890
|
});
|
|
1840
1891
|
}
|
|
1841
1892
|
};
|
|
@@ -4028,9 +4079,14 @@ var Calculator;
|
|
|
4028
4079
|
str: value,
|
|
4029
4080
|
entity: entity
|
|
4030
4081
|
});
|
|
4031
|
-
|
|
4082
|
+
const isJsEval = value.startsWith("JS:");
|
|
4032
4083
|
const MATH_REGEX = /(\d+\.?\d*|\.\d+)([+\-*/])(\d+\.?\d*|\.\d+)/;
|
|
4033
|
-
|
|
4084
|
+
const isMathEval = isJsEval || MATH_REGEX.test(value);
|
|
4085
|
+
if (isJsEval || isMathEval) {
|
|
4086
|
+
if (isJsEval) {
|
|
4087
|
+
value = value.replace("JS:", "");
|
|
4088
|
+
value = value.trim();
|
|
4089
|
+
}
|
|
4034
4090
|
// https://rollupjs.org/guide/en/#avoiding-eval
|
|
4035
4091
|
// This stops eval warning.
|
|
4036
4092
|
const eval2 = eval;
|
|
@@ -10887,7 +10943,7 @@ var DataSource;
|
|
|
10887
10943
|
})(DataSource || (DataSource = {}));
|
|
10888
10944
|
|
|
10889
10945
|
// This is updated with the package.json version on build.
|
|
10890
|
-
const VERSION = "3.5.
|
|
10946
|
+
const VERSION = "3.5.9";
|
|
10891
10947
|
|
|
10892
10948
|
export { VERSION, AnnDocument, CustomForm, AbstractApi, Api, BruceApi, GlobalApi, GuardianApi, ApiGetters, Calculator, Bounds, BruceEvent, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, Geometry, UTC, BruceVariable, LRUCache, EntityAttachmentType, EntityAttachment, EntityComment, EntityLink, EntityLod, EntityLodCategory, EntityRelationType, EntityRelation, EntitySource, EntityTag, EntityType, Entity, EntityCoords, EntityTypeVisualSettings, EntityAttribute, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, ProjectViewLegacyTile, ProjectViewTile, ProjectViewLegacy, ProjectViewLegacyBookmark, PendingAction, MessageBroker, HostingLocation, Style, Tileset, Permission, Session, UserGroup, User, Account, AccountInvite, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, DataLab, ImportCad, ImportCsv, ImportJson, ImportKml, ImportedFile, Markup, Uploader, Plugin, ENVIRONMENT, DataSource };
|
|
10893
10949
|
//# sourceMappingURL=bruce-models.es5.js.map
|