bruce-models 4.5.8 → 4.6.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.
- package/dist/bruce-models.es5.js +1617 -1589
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +1541 -1513
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/api/bruce-api.js +126 -90
- package/dist/lib/api/bruce-api.js.map +1 -1
- package/dist/lib/bruce-models.js +1 -1
- package/dist/lib/client-file/client-file.js +16 -18
- package/dist/lib/client-file/client-file.js.map +1 -1
- package/dist/lib/entity/entity-lod.js +6 -5
- package/dist/lib/entity/entity-lod.js.map +1 -1
- package/dist/lib/entity/entity.js +12 -15
- package/dist/lib/entity/entity.js.map +1 -1
- package/dist/lib/plugin/plugin.js +6 -1
- package/dist/lib/plugin/plugin.js.map +1 -1
- package/dist/lib/tileset/tileset.js +16 -27
- package/dist/lib/tileset/tileset.js.map +1 -1
- package/dist/types/api/bruce-api.d.ts +14 -1
- package/dist/types/bruce-models.d.ts +1 -1
- package/package.json +1 -1
package/dist/bruce-models.umd.js
CHANGED
|
@@ -837,767 +837,471 @@
|
|
|
837
837
|
GuardianApi.Api = Api$$1;
|
|
838
838
|
})(exports.GuardianApi || (exports.GuardianApi = {}));
|
|
839
839
|
|
|
840
|
-
|
|
841
|
-
// Some accounts may not be "dead" but instead purposely don't have a NextspaceAPI database so we'll avoid them too.
|
|
842
|
-
const ACCOUNT_EXCLUSIONS = ["hyperportal", "hypeportal", "bviewer"];
|
|
843
|
-
(function (Account) {
|
|
844
|
-
/**
|
|
845
|
-
* Known Nextspace applications we store settings for.
|
|
846
|
-
*/
|
|
847
|
-
let EAppId;
|
|
848
|
-
(function (EAppId) {
|
|
849
|
-
EAppId["BruceApi"] = "BruceAPI";
|
|
850
|
-
EAppId["Navigator"] = "Navigator";
|
|
851
|
-
EAppId["Operator"] = "BruceClientAdmin";
|
|
852
|
-
})(EAppId = Account.EAppId || (Account.EAppId = {}));
|
|
853
|
-
/**
|
|
854
|
-
* Possible starter content options.
|
|
855
|
-
* When creating a new account you can populate it with certain default data.
|
|
856
|
-
*/
|
|
857
|
-
let EStarterContent;
|
|
858
|
-
(function (EStarterContent) {
|
|
859
|
-
EStarterContent["Default"] = "default";
|
|
860
|
-
EStarterContent["None"] = "none";
|
|
861
|
-
})(EStarterContent = Account.EStarterContent || (Account.EStarterContent = {}));
|
|
840
|
+
(function (BruceApi) {
|
|
862
841
|
/**
|
|
863
|
-
*
|
|
864
|
-
*
|
|
865
|
-
* @returns
|
|
842
|
+
* This is the request handler for Bruce Api,
|
|
843
|
+
* it should be passed to any method that wants to communicate with this particular api.
|
|
866
844
|
*/
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
845
|
+
class Api$$1 extends AbstractApi {
|
|
846
|
+
get AccountId() {
|
|
847
|
+
return this.accountId;
|
|
848
|
+
}
|
|
849
|
+
get MessageBroker() {
|
|
850
|
+
return this.messageBroker;
|
|
851
|
+
}
|
|
852
|
+
get ConfigLoadAttempted() {
|
|
853
|
+
return this.configLoadAttempted;
|
|
854
|
+
}
|
|
855
|
+
get Version() {
|
|
856
|
+
return this.version;
|
|
857
|
+
}
|
|
858
|
+
get Loading() {
|
|
859
|
+
return this.loadProm;
|
|
860
|
+
}
|
|
861
|
+
constructor(params) {
|
|
862
|
+
super({
|
|
863
|
+
ssidHeader: "x-sessionid",
|
|
864
|
+
cacheId: `BRUCE_API_${params === null || params === void 0 ? void 0 : params.env}_${params === null || params === void 0 ? void 0 : params.accountId}_`
|
|
865
|
+
});
|
|
866
|
+
// Load cancelled indicates the user set a custom base url.
|
|
867
|
+
// This will stop the regional url from being set if it's still loading.
|
|
868
|
+
this.loadCancelled = false;
|
|
869
|
+
// Indicates if loading the regional configuration was already called.
|
|
870
|
+
this.configLoadAttempted = false;
|
|
871
|
+
let { accountId, env, guardian, loadRegionalBaseUrl, loadConfig, loadWebSocket, dummy } = params;
|
|
872
|
+
this.accountId = accountId;
|
|
873
|
+
this.env = env !== null && env !== void 0 ? env : exports.Api.EEnv.PROD;
|
|
874
|
+
if (!dummy) {
|
|
875
|
+
// Backwards compatibility.
|
|
876
|
+
if (loadRegionalBaseUrl) {
|
|
877
|
+
loadConfig = true;
|
|
878
|
+
}
|
|
879
|
+
if (loadConfig) {
|
|
880
|
+
// Mark it as attempted right away because we don't want any external calls while it gets to that async point.
|
|
881
|
+
this.configLoadAttempted = true;
|
|
882
|
+
}
|
|
883
|
+
this.loadProm = this.init(guardian, loadConfig, loadWebSocket);
|
|
876
884
|
}
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
885
|
+
}
|
|
886
|
+
/**
|
|
887
|
+
* Loads regional base url and sets up message broker.
|
|
888
|
+
* @param guardian Required for loading regional base url.
|
|
889
|
+
* @param loadConfig
|
|
890
|
+
* @returns
|
|
891
|
+
*/
|
|
892
|
+
init(guardian, loadConfig, loadWebSocket) {
|
|
893
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
894
|
+
if (!this.accountId) {
|
|
895
|
+
throw ("accountId is required.");
|
|
896
|
+
}
|
|
897
|
+
// Set using a stable default.
|
|
898
|
+
const domain = this.getDomain();
|
|
899
|
+
this.baseUrl = `https://${this.accountId}.api.${domain}/`;
|
|
900
|
+
// Attempt to load regional configuration.
|
|
901
|
+
if (loadConfig) {
|
|
902
|
+
yield this.LoadConfig({
|
|
903
|
+
guardian: guardian,
|
|
904
|
+
// We marked it as attempted to load outside this method to fight any external calls.
|
|
905
|
+
// So we'll force load it now.
|
|
906
|
+
forceLoad: true
|
|
890
907
|
});
|
|
891
908
|
}
|
|
892
|
-
|
|
893
|
-
|
|
909
|
+
// Get the version.
|
|
910
|
+
if (this.baseUrl) {
|
|
911
|
+
const full = this.ConstructUrl({
|
|
912
|
+
url: "version"
|
|
913
|
+
});
|
|
914
|
+
const data = yield this.get(full);
|
|
915
|
+
if (data === null || data === void 0 ? void 0 : data["Bruce-API"]) {
|
|
916
|
+
this.version = data["Bruce-API"];
|
|
917
|
+
}
|
|
918
|
+
else {
|
|
919
|
+
this.version = "UNKNOWN";
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
// Start web socket connection.
|
|
923
|
+
if (loadWebSocket == true) {
|
|
924
|
+
try {
|
|
925
|
+
const full = this.ConstructUrl();
|
|
926
|
+
this.messageBroker = new exports.MessageBroker.WebSocketBroker(full, this.env);
|
|
927
|
+
}
|
|
928
|
+
catch (e) {
|
|
929
|
+
console.warn("BruceApi: Failed to create message broker.", e);
|
|
930
|
+
}
|
|
894
931
|
}
|
|
895
|
-
}));
|
|
896
|
-
yield api.SetCacheItem({
|
|
897
|
-
key: GetCacheKey(id),
|
|
898
|
-
value: prom,
|
|
899
|
-
req: reqParams
|
|
900
932
|
});
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
933
|
+
}
|
|
934
|
+
getDomain() {
|
|
935
|
+
const env = this.env.toUpperCase();
|
|
936
|
+
let domain = "nextspace.host";
|
|
937
|
+
switch (env) {
|
|
938
|
+
case exports.Api.EEnv.DEV:
|
|
939
|
+
domain = "nextspace-dev.net";
|
|
940
|
+
break;
|
|
941
|
+
case exports.Api.EEnv.STG:
|
|
942
|
+
domain = "nextspace-stg.net";
|
|
943
|
+
break;
|
|
944
|
+
case exports.Api.EEnv.UAT:
|
|
945
|
+
domain = "nextspace-uat.net";
|
|
946
|
+
break;
|
|
947
|
+
case exports.Api.EEnv.PROD:
|
|
948
|
+
domain = "nextspace.host";
|
|
949
|
+
break;
|
|
950
|
+
default:
|
|
951
|
+
console.error("Specified Environment is not valid. SuppliedEnv=" + env);
|
|
919
952
|
}
|
|
920
|
-
|
|
953
|
+
return domain;
|
|
954
|
+
}
|
|
955
|
+
/**
|
|
956
|
+
* Loads the regional configuration for the account.
|
|
957
|
+
* If the config is already loaded then this will do nothing.
|
|
958
|
+
*/
|
|
959
|
+
LoadConfig(params) {
|
|
960
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
961
|
+
let { guardian, forceLoad } = (params !== null && params !== void 0 ? params : {});
|
|
962
|
+
if (this.configLoadAttempted && forceLoad != true) {
|
|
963
|
+
return;
|
|
964
|
+
}
|
|
965
|
+
this.configLoadAttempted = true;
|
|
921
966
|
try {
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
yield api.SetCacheItem({
|
|
926
|
-
key: data.ID,
|
|
927
|
-
value: prom,
|
|
928
|
-
req: reqParams
|
|
967
|
+
if (!guardian) {
|
|
968
|
+
guardian = new exports.GuardianApi.Api({
|
|
969
|
+
env: this.env
|
|
929
970
|
});
|
|
930
971
|
}
|
|
931
|
-
|
|
932
|
-
|
|
972
|
+
const { account } = yield exports.Account.GetBySubdomain({
|
|
973
|
+
subdomain: this.accountId,
|
|
974
|
+
api: guardian
|
|
933
975
|
});
|
|
976
|
+
if (!this.loadCancelled) {
|
|
977
|
+
// Set the calculated base url.
|
|
978
|
+
// If this is not available then this is considered a critical failure.
|
|
979
|
+
// However I am not crashing here because I want to monitor this in production.
|
|
980
|
+
if (account.URL) {
|
|
981
|
+
const urls = account.URL;
|
|
982
|
+
if (urls === null || urls === void 0 ? void 0 : urls.Base) {
|
|
983
|
+
this.baseUrl = urls.Base;
|
|
984
|
+
}
|
|
985
|
+
if (urls === null || urls === void 0 ? void 0 : urls.CDNEntities) {
|
|
986
|
+
this.EntityCdnUrl = urls.CDNEntities;
|
|
987
|
+
}
|
|
988
|
+
if (urls === null || urls === void 0 ? void 0 : urls.CDNTileset) {
|
|
989
|
+
this.TilesetCdnUrl = urls.CDNTileset;
|
|
990
|
+
}
|
|
991
|
+
if (urls === null || urls === void 0 ? void 0 : urls.CDNLegacyTileset) {
|
|
992
|
+
this.LegacyTilesetCdnUrl = urls.CDNLegacyTileset;
|
|
993
|
+
}
|
|
994
|
+
if (urls === null || urls === void 0 ? void 0 : urls.CDNBase) {
|
|
995
|
+
this.cdnBaseUrl = urls.CDNBase;
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
else {
|
|
999
|
+
console.error("BruceApi: Failed to load regional configuration for account.", this.accountId);
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
934
1002
|
}
|
|
935
1003
|
catch (e) {
|
|
936
|
-
|
|
1004
|
+
console.error(e);
|
|
937
1005
|
}
|
|
938
|
-
}));
|
|
939
|
-
yield api.SetCacheItem({
|
|
940
|
-
key: GetCacheKey(subdomain),
|
|
941
|
-
value: prom,
|
|
942
|
-
req: reqParams
|
|
943
1006
|
});
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
let { api, req: reqParams } = params;
|
|
956
|
-
if (!api) {
|
|
957
|
-
api = exports.ENVIRONMENT.Api().GetGuardianApi();
|
|
958
|
-
}
|
|
959
|
-
const cache = yield api.GetCacheItem(GetListCacheKey(api.GetSessionId()), reqParams);
|
|
960
|
-
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
961
|
-
return cache.data;
|
|
962
|
-
}
|
|
963
|
-
const req = api.GET("user/relatedClientAccounts", reqParams);
|
|
964
|
-
const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
965
|
-
try {
|
|
966
|
-
const data = yield req;
|
|
967
|
-
const items = data.Items.filter((x) => !ACCOUNT_EXCLUSIONS.includes(x.ID));
|
|
968
|
-
res({
|
|
969
|
-
accounts: items
|
|
970
|
-
});
|
|
971
|
-
}
|
|
972
|
-
catch (e) {
|
|
973
|
-
rej(e);
|
|
1007
|
+
}
|
|
1008
|
+
/**
|
|
1009
|
+
* Creates a message broker instance and returns it.
|
|
1010
|
+
* If an instance is already created, it will return that one.
|
|
1011
|
+
* @warning This will await the loading promise to avoid using data that isn't ready.
|
|
1012
|
+
*/
|
|
1013
|
+
ConnectWebsocket() {
|
|
1014
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1015
|
+
yield this.loadProm;
|
|
1016
|
+
if (this.messageBroker) {
|
|
1017
|
+
return this.messageBroker;
|
|
974
1018
|
}
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
value: prom,
|
|
979
|
-
req: reqParams
|
|
1019
|
+
const full = this.ConstructUrl();
|
|
1020
|
+
this.messageBroker = new exports.MessageBroker.WebSocketBroker(full, this.env);
|
|
1021
|
+
return this.messageBroker;
|
|
980
1022
|
});
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1023
|
+
}
|
|
1024
|
+
/**
|
|
1025
|
+
* Warning: This method does not wait for init to finish loading.
|
|
1026
|
+
* This means the url could be changed once fully initialized.
|
|
1027
|
+
* The url will be valid either way, but the loaded one may be faster as it is region specific.
|
|
1028
|
+
* Await the "Loading" promise if you care about this.
|
|
1029
|
+
* @warning use ConstructUrl instead as the baseUrl may have a query param for the account.
|
|
1030
|
+
* @returns
|
|
1031
|
+
*/
|
|
1032
|
+
GetBaseUrl() {
|
|
1033
|
+
return this.baseUrl;
|
|
1034
|
+
}
|
|
1035
|
+
/**
|
|
1036
|
+
* Warning: Wait the "Loading" promise before using this url.
|
|
1037
|
+
* @warning use ConstructUrl instead as the baseUrl may have a query param for the account.
|
|
1038
|
+
* @returns
|
|
1039
|
+
*/
|
|
1040
|
+
GetCdnBaseUrl() {
|
|
1041
|
+
return this.cdnBaseUrl;
|
|
1042
|
+
}
|
|
1043
|
+
/**
|
|
1044
|
+
* Returns a url with the provided url appended to the loaded base url.
|
|
1045
|
+
* If the base url is not loaded yet, this will return null.
|
|
1046
|
+
* @param params
|
|
1047
|
+
*/
|
|
1048
|
+
ConstructUrl(params) {
|
|
1049
|
+
if ((params === null || params === void 0 ? void 0 : params.cdn) && this.cdnBaseUrl) {
|
|
1050
|
+
return this.ConstructCdnUrl(params.url, params.urlParams);
|
|
1051
|
+
}
|
|
1052
|
+
const tmp = new URL(this.baseUrl);
|
|
1053
|
+
if (params === null || params === void 0 ? void 0 : params.urlParams) {
|
|
1054
|
+
if (params.urlParams instanceof URLSearchParams) {
|
|
1055
|
+
params.urlParams.forEach((value, key) => {
|
|
1056
|
+
tmp.searchParams.append(key, value);
|
|
1008
1057
|
});
|
|
1009
1058
|
}
|
|
1010
|
-
|
|
1011
|
-
|
|
1059
|
+
else {
|
|
1060
|
+
for (const key in params.urlParams) {
|
|
1061
|
+
tmp.searchParams.append(key, params.urlParams[key]);
|
|
1062
|
+
}
|
|
1012
1063
|
}
|
|
1013
|
-
}));
|
|
1014
|
-
yield api.SetCacheItem({
|
|
1015
|
-
key: GetCacheKey(id, appId),
|
|
1016
|
-
value: prom,
|
|
1017
|
-
req: reqParams
|
|
1018
|
-
});
|
|
1019
|
-
return prom;
|
|
1020
|
-
});
|
|
1021
|
-
}
|
|
1022
|
-
Account.GetAppSettings = GetAppSettings;
|
|
1023
|
-
/**
|
|
1024
|
-
* Updates application settings for a specific client account + application.
|
|
1025
|
-
* WARNING: Do not update API settings without knowing what you're doing.
|
|
1026
|
-
* @param params
|
|
1027
|
-
* @returns
|
|
1028
|
-
*/
|
|
1029
|
-
function UpdateAppSettings(params) {
|
|
1030
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1031
|
-
let { api, accountId: id, appId, settings: data, req: reqParams } = params;
|
|
1032
|
-
if (!api) {
|
|
1033
|
-
api = exports.ENVIRONMENT.Api().GetGuardianApi();
|
|
1034
|
-
}
|
|
1035
|
-
const res = yield api.POST(`account/${id}/applicationSettings/${appId}`, data, reqParams);
|
|
1036
|
-
yield api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + id);
|
|
1037
|
-
return {
|
|
1038
|
-
settings: res
|
|
1039
|
-
};
|
|
1040
|
-
});
|
|
1041
|
-
}
|
|
1042
|
-
Account.UpdateAppSettings = UpdateAppSettings;
|
|
1043
|
-
/**
|
|
1044
|
-
* Creates a new Nextspace account using given details.
|
|
1045
|
-
* @param params
|
|
1046
|
-
* @returns
|
|
1047
|
-
*/
|
|
1048
|
-
function Create(params) {
|
|
1049
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1050
|
-
let { api, accountId: id, name, hostingLocationKey, starterContent, req: reqParams } = params;
|
|
1051
|
-
if (!id || !name || !hostingLocationKey) {
|
|
1052
|
-
throw new Error("Id, Name and hostingLocationKey are required.");
|
|
1053
|
-
}
|
|
1054
|
-
if (!api) {
|
|
1055
|
-
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
1056
1064
|
}
|
|
1057
|
-
|
|
1058
|
-
|
|
1065
|
+
// Ensure the url ends with a slash.
|
|
1066
|
+
if (!tmp.pathname.endsWith("/")) {
|
|
1067
|
+
tmp.pathname += "/";
|
|
1068
|
+
}
|
|
1069
|
+
if (params === null || params === void 0 ? void 0 : params.url) {
|
|
1070
|
+
// Ensure we're only adding the path.
|
|
1071
|
+
// The baseUrl could have included query params so have this extra logic.
|
|
1072
|
+
const split = params.url.split("?");
|
|
1073
|
+
// Ensure the url does not start with a slash.
|
|
1074
|
+
// This is because the base url already has a slash at the end.
|
|
1075
|
+
let path = split[0];
|
|
1076
|
+
if (path.startsWith("/")) {
|
|
1077
|
+
path = path.substring(1);
|
|
1078
|
+
}
|
|
1079
|
+
tmp.pathname += path;
|
|
1080
|
+
// Append the query string if any exist.
|
|
1081
|
+
if (split.length > 1) {
|
|
1082
|
+
const query = split[1].split("&");
|
|
1083
|
+
for (let q of query) {
|
|
1084
|
+
const parts = q.split("=");
|
|
1085
|
+
tmp.searchParams.append(parts[0], parts[1]);
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1059
1088
|
}
|
|
1060
|
-
|
|
1061
|
-
"Name": name,
|
|
1062
|
-
"HostingLocation.Key": hostingLocationKey,
|
|
1063
|
-
"StarterContent": starterContent
|
|
1064
|
-
};
|
|
1065
|
-
const res = yield api.POST(`clientAccount/${id}`, reqData, exports.Api.PrepReqParams(reqParams));
|
|
1066
|
-
const resData = {
|
|
1067
|
-
account: res
|
|
1068
|
-
};
|
|
1069
|
-
api.Cache.Remove(GetListCacheKey(api.GetSessionId()));
|
|
1070
|
-
return resData;
|
|
1071
|
-
});
|
|
1072
|
-
}
|
|
1073
|
-
Account.Create = Create;
|
|
1074
|
-
/**
|
|
1075
|
-
* Returns cache identifier for an account by ID.
|
|
1076
|
-
* Example: {
|
|
1077
|
-
* const api: BruceApi.Api = ...;
|
|
1078
|
-
* const key = GetCacheKey(1);
|
|
1079
|
-
* api.Cache.Remove(key);
|
|
1080
|
-
* }
|
|
1081
|
-
* @param accountId
|
|
1082
|
-
* @param appSettingsId
|
|
1083
|
-
* @returns
|
|
1084
|
-
*/
|
|
1085
|
-
function GetCacheKey(accountId, appSettingsId) {
|
|
1086
|
-
if (appSettingsId) {
|
|
1087
|
-
return exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + accountId + exports.Api.ECacheKey + appSettingsId;
|
|
1089
|
+
return tmp.toString();
|
|
1088
1090
|
}
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
* @param ssid
|
|
1100
|
-
* @returns
|
|
1101
|
-
*/
|
|
1102
|
-
function GetListCacheKey(ssid) {
|
|
1103
|
-
return exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Session + exports.Api.ECacheKey.Id + ssid;
|
|
1104
|
-
}
|
|
1105
|
-
Account.GetListCacheKey = GetListCacheKey;
|
|
1106
|
-
/**
|
|
1107
|
-
* Returns cache identifier for a list of database regions.
|
|
1108
|
-
* Example: {
|
|
1109
|
-
* const api: BruceApi.Api = ...;
|
|
1110
|
-
* const key = GetDbRegionListCacheKey();
|
|
1111
|
-
* api.Cache.Remove(key);
|
|
1112
|
-
* }
|
|
1113
|
-
* @returns
|
|
1114
|
-
*/
|
|
1115
|
-
function GetDbRegionListCacheKey() {
|
|
1116
|
-
return exports.Api.ECacheKey.DatabaseRegion;
|
|
1117
|
-
}
|
|
1118
|
-
Account.GetDbRegionListCacheKey = GetDbRegionListCacheKey;
|
|
1119
|
-
})(exports.Account || (exports.Account = {}));
|
|
1120
|
-
|
|
1121
|
-
(function (HostingLocation) {
|
|
1122
|
-
/**
|
|
1123
|
-
* Returns a list of hosting locations.
|
|
1124
|
-
* @Warning: This will not return the Settings property.
|
|
1125
|
-
* @param params
|
|
1126
|
-
* @returns
|
|
1127
|
-
*/
|
|
1128
|
-
function GetList(params) {
|
|
1129
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1130
|
-
let { api, req } = params;
|
|
1131
|
-
if (!api) {
|
|
1132
|
-
api = exports.ENVIRONMENT.Api().GetGuardianApi();
|
|
1133
|
-
}
|
|
1134
|
-
const res = yield api.GET("hostinglocations", exports.Api.PrepReqParams(req));
|
|
1135
|
-
return {
|
|
1136
|
-
locations: res.Items
|
|
1137
|
-
};
|
|
1138
|
-
});
|
|
1139
|
-
}
|
|
1140
|
-
HostingLocation.GetList = GetList;
|
|
1141
|
-
/**
|
|
1142
|
-
* Returns a hosting location record by ID.
|
|
1143
|
-
* @param params
|
|
1144
|
-
* @returns
|
|
1145
|
-
*/
|
|
1146
|
-
function GetById(params) {
|
|
1147
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1148
|
-
let { id, api, req } = params;
|
|
1149
|
-
if (!id) {
|
|
1150
|
-
throw ("Invalid id");
|
|
1091
|
+
/**
|
|
1092
|
+
* Returns a url routed through the API's CDN.
|
|
1093
|
+
* If the CDN is not enabled for the account, this will return null.
|
|
1094
|
+
* @param url suffix to append to the base url.
|
|
1095
|
+
* @param urlParams
|
|
1096
|
+
* @returns
|
|
1097
|
+
*/
|
|
1098
|
+
ConstructCdnUrl(url, urlParams) {
|
|
1099
|
+
if (!this.cdnBaseUrl) {
|
|
1100
|
+
return null;
|
|
1151
1101
|
}
|
|
1152
|
-
|
|
1153
|
-
|
|
1102
|
+
const tmp = new URL(this.cdnBaseUrl);
|
|
1103
|
+
if (urlParams) {
|
|
1104
|
+
if (urlParams instanceof URLSearchParams) {
|
|
1105
|
+
urlParams.forEach((value, key) => {
|
|
1106
|
+
tmp.searchParams.append(key, value);
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1109
|
+
else {
|
|
1110
|
+
for (const key in urlParams) {
|
|
1111
|
+
tmp.searchParams.append(key, urlParams[key]);
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1154
1114
|
}
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
};
|
|
1159
|
-
});
|
|
1160
|
-
}
|
|
1161
|
-
HostingLocation.GetById = GetById;
|
|
1162
|
-
/**
|
|
1163
|
-
* Returns a hosting location record by key.
|
|
1164
|
-
* @param params
|
|
1165
|
-
* @returns
|
|
1166
|
-
*/
|
|
1167
|
-
function GetByKey(params) {
|
|
1168
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1169
|
-
let { key, api, req } = params;
|
|
1170
|
-
if (!key) {
|
|
1171
|
-
throw ("Invalid key");
|
|
1115
|
+
// Ensure the url ends with a slash.
|
|
1116
|
+
if (!tmp.pathname.endsWith("/")) {
|
|
1117
|
+
tmp.pathname += "/";
|
|
1172
1118
|
}
|
|
1173
|
-
if (
|
|
1174
|
-
|
|
1119
|
+
if (url) {
|
|
1120
|
+
// Ensure we're only adding the path.
|
|
1121
|
+
// The baseUrl could have included query params so have this extra logic.
|
|
1122
|
+
let split = url.split("?");
|
|
1123
|
+
// Ensure the url does not start with a slash.
|
|
1124
|
+
// This is because the base url already has a slash at the end.
|
|
1125
|
+
let path = split[0];
|
|
1126
|
+
if (path.startsWith("/")) {
|
|
1127
|
+
path = url.substring(1);
|
|
1128
|
+
}
|
|
1129
|
+
tmp.pathname += path;
|
|
1130
|
+
// Append the query string if any exist.
|
|
1131
|
+
if (split.length > 1) {
|
|
1132
|
+
const query = split[1].split("&");
|
|
1133
|
+
for (let q of query) {
|
|
1134
|
+
const parts = q.split("=");
|
|
1135
|
+
tmp.searchParams.append(parts[0], parts[1]);
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1175
1138
|
}
|
|
1176
|
-
|
|
1177
|
-
return {
|
|
1178
|
-
location: res
|
|
1179
|
-
};
|
|
1180
|
-
});
|
|
1181
|
-
}
|
|
1182
|
-
HostingLocation.GetByKey = GetByKey;
|
|
1183
|
-
/**
|
|
1184
|
-
* Returns hostingLocationKey from given db url.
|
|
1185
|
-
* Some older accounts don't have this set, so we need to guess it.
|
|
1186
|
-
* @param params
|
|
1187
|
-
* @returns
|
|
1188
|
-
*/
|
|
1189
|
-
function GuessKey(params) {
|
|
1190
|
-
const { DBServer: databaseUrl } = params;
|
|
1191
|
-
if (databaseUrl.includes("hyperfarm-prod-instance-1")) {
|
|
1192
|
-
return "HYPERFARM";
|
|
1193
|
-
}
|
|
1194
|
-
if (databaseUrl.includes("prod-syd1.nextspace.host")) {
|
|
1195
|
-
return "AU-VULTR-FIRST";
|
|
1196
|
-
}
|
|
1197
|
-
else if (databaseUrl.includes("prod-nyc1.nextspace.host")) {
|
|
1198
|
-
return "US-VULTR-FIRST";
|
|
1199
|
-
}
|
|
1200
|
-
else if (databaseUrl.includes("prod-ams1.nextspace.host")) {
|
|
1201
|
-
return "EU-VULTR-FIRST";
|
|
1202
|
-
}
|
|
1203
|
-
else if (databaseUrl.includes("prod-sing1.nextspace.host")) {
|
|
1204
|
-
return "SE-VULTR-FIRST";
|
|
1205
|
-
}
|
|
1206
|
-
else if (databaseUrl.includes("dev-first")) {
|
|
1207
|
-
return "DEV-FIRST";
|
|
1208
|
-
}
|
|
1209
|
-
else if (databaseUrl.includes(".ap-southeast-1.")) {
|
|
1210
|
-
return "SE";
|
|
1139
|
+
return tmp.toString();
|
|
1211
1140
|
}
|
|
1212
|
-
|
|
1213
|
-
|
|
1141
|
+
/**
|
|
1142
|
+
* Warning: This will cancel the init process.
|
|
1143
|
+
* The init process loads a region specific endpoint.
|
|
1144
|
+
* Setting a base url will stop that process from completing.
|
|
1145
|
+
* @param url
|
|
1146
|
+
*/
|
|
1147
|
+
SetBaseUrl(url) {
|
|
1148
|
+
this.baseUrl = url;
|
|
1149
|
+
// If we're setting a valid URL then we'll ensure it ends with a slash.
|
|
1150
|
+
if (this.baseUrl && (this.baseUrl.startsWith("http://") || this.baseUrl.startsWith("https://"))) {
|
|
1151
|
+
// Parsing into URL object to avoid adding a "/" after query params.
|
|
1152
|
+
const full = new URL(this.baseUrl);
|
|
1153
|
+
if (!full.pathname.endsWith("/")) {
|
|
1154
|
+
full.pathname += "/";
|
|
1155
|
+
}
|
|
1156
|
+
this.baseUrl = full.toString();
|
|
1157
|
+
}
|
|
1158
|
+
this.loadCancelled = true;
|
|
1214
1159
|
}
|
|
1215
|
-
|
|
1216
|
-
|
|
1160
|
+
/**
|
|
1161
|
+
* Performs an HTTP GET request.
|
|
1162
|
+
* This will prepend the base url to the url.
|
|
1163
|
+
* @param url
|
|
1164
|
+
* @param params
|
|
1165
|
+
* @returns
|
|
1166
|
+
*/
|
|
1167
|
+
GET(url, params) {
|
|
1168
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1169
|
+
return new Promise((res, rej) => {
|
|
1170
|
+
this.loadProm.then(() => {
|
|
1171
|
+
const full = this.ConstructUrl({
|
|
1172
|
+
url: url
|
|
1173
|
+
});
|
|
1174
|
+
this.get(full, params).then(res).catch(rej);
|
|
1175
|
+
}).catch(rej);
|
|
1176
|
+
});
|
|
1177
|
+
});
|
|
1217
1178
|
}
|
|
1218
|
-
|
|
1219
|
-
|
|
1179
|
+
/**
|
|
1180
|
+
* Performs an HTTP DELETE request.
|
|
1181
|
+
* This will prepend the base url to the url.
|
|
1182
|
+
* @param url
|
|
1183
|
+
* @param params
|
|
1184
|
+
* @returns
|
|
1185
|
+
*/
|
|
1186
|
+
DELETE(url, params) {
|
|
1187
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1188
|
+
return new Promise((res, rej) => {
|
|
1189
|
+
this.loadProm.then(() => {
|
|
1190
|
+
const full = this.ConstructUrl({
|
|
1191
|
+
url: url
|
|
1192
|
+
});
|
|
1193
|
+
this.delete(full, params).then(res).catch(rej);
|
|
1194
|
+
}).catch(rej);
|
|
1195
|
+
});
|
|
1196
|
+
});
|
|
1220
1197
|
}
|
|
1221
|
-
|
|
1222
|
-
|
|
1198
|
+
/**
|
|
1199
|
+
* Performs an HTTP POST request.
|
|
1200
|
+
* This will prepend the base url to the url.
|
|
1201
|
+
* @param url
|
|
1202
|
+
* @param data
|
|
1203
|
+
* @param params
|
|
1204
|
+
* @returns
|
|
1205
|
+
*/
|
|
1206
|
+
POST(url, data, params) {
|
|
1207
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1208
|
+
return new Promise((res, rej) => {
|
|
1209
|
+
this.loadProm.then(() => {
|
|
1210
|
+
const full = this.ConstructUrl({
|
|
1211
|
+
url: url
|
|
1212
|
+
});
|
|
1213
|
+
this.post(full, data, params).then(res).catch(rej);
|
|
1214
|
+
}).catch(rej);
|
|
1215
|
+
});
|
|
1216
|
+
});
|
|
1223
1217
|
}
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
// We'll prioritize account record if provided.
|
|
1242
|
-
if (accountId && !account) {
|
|
1243
|
-
account = (yield exports.Account.Get({
|
|
1244
|
-
accountId,
|
|
1245
|
-
api,
|
|
1246
|
-
req
|
|
1247
|
-
})).account;
|
|
1248
|
-
}
|
|
1249
|
-
if (account === null || account === void 0 ? void 0 : account["HostingLocation.Key"]) {
|
|
1250
|
-
return {
|
|
1251
|
-
key: account["HostingLocation.Key"],
|
|
1252
|
-
isLegacy: false
|
|
1253
|
-
};
|
|
1254
|
-
}
|
|
1255
|
-
// Fallback to settings JSON for older records.
|
|
1256
|
-
const settings = apiSettings ? apiSettings : (yield exports.Account.GetAppSettings({
|
|
1257
|
-
api,
|
|
1258
|
-
accountId,
|
|
1259
|
-
appId: exports.Account.EAppId.BruceApi
|
|
1260
|
-
})).settings;
|
|
1261
|
-
let hostingKey = settings["HostingLocation.Key"];
|
|
1262
|
-
let isLegacy = false;
|
|
1263
|
-
if (!hostingKey) {
|
|
1264
|
-
hostingKey = settings.DBLocation;
|
|
1265
|
-
isLegacy = true;
|
|
1266
|
-
}
|
|
1267
|
-
if (!hostingKey) {
|
|
1268
|
-
hostingKey = GuessKey({
|
|
1269
|
-
DBServer: settings.DBServer
|
|
1218
|
+
/**
|
|
1219
|
+
* Performs an HTTP PUT request.
|
|
1220
|
+
* This will prepend the base url to the url.
|
|
1221
|
+
* @param url
|
|
1222
|
+
* @param data
|
|
1223
|
+
* @param params
|
|
1224
|
+
* @returns
|
|
1225
|
+
*/
|
|
1226
|
+
PUT(url, data, params) {
|
|
1227
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1228
|
+
return new Promise((res, rej) => {
|
|
1229
|
+
this.loadProm.then(() => {
|
|
1230
|
+
const full = this.ConstructUrl({
|
|
1231
|
+
url: url
|
|
1232
|
+
});
|
|
1233
|
+
this.put(full, data, params).then(res).catch(rej);
|
|
1234
|
+
}).catch(rej);
|
|
1270
1235
|
});
|
|
1271
|
-
isLegacy = true;
|
|
1272
|
-
}
|
|
1273
|
-
return {
|
|
1274
|
-
key: hostingKey,
|
|
1275
|
-
isLegacy
|
|
1276
|
-
};
|
|
1277
|
-
});
|
|
1278
|
-
}
|
|
1279
|
-
HostingLocation.GetKeyByAccountId = GetKeyByAccountId;
|
|
1280
|
-
/**
|
|
1281
|
-
* Returns a hosting location record by account ID.
|
|
1282
|
-
* @param params
|
|
1283
|
-
* @returns
|
|
1284
|
-
*/
|
|
1285
|
-
function GetByAccountId(params) {
|
|
1286
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1287
|
-
let { accountId, apiSettings, api, req, account } = params;
|
|
1288
|
-
if (!api) {
|
|
1289
|
-
api = exports.ENVIRONMENT.Api().GetGuardianApi();
|
|
1290
|
-
}
|
|
1291
|
-
const data = yield GetKeyByAccountId({
|
|
1292
|
-
accountId,
|
|
1293
|
-
account,
|
|
1294
|
-
apiSettings,
|
|
1295
|
-
api,
|
|
1296
|
-
req
|
|
1297
1236
|
});
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1237
|
+
}
|
|
1238
|
+
/**
|
|
1239
|
+
* Performs a file upload request (HTTP POST).
|
|
1240
|
+
* This will prepend the base url to the url.
|
|
1241
|
+
* @param url
|
|
1242
|
+
* @param blob
|
|
1243
|
+
* @param params
|
|
1244
|
+
* @returns
|
|
1245
|
+
*/
|
|
1246
|
+
UPLOAD(url, blob, params) {
|
|
1247
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1248
|
+
return new Promise((res, rej) => {
|
|
1249
|
+
this.loadProm.then(() => {
|
|
1250
|
+
const full = this.ConstructUrl({
|
|
1251
|
+
url: url
|
|
1252
|
+
});
|
|
1253
|
+
this.upload(full, blob, params).then(res).catch(rej);
|
|
1254
|
+
}).catch(rej);
|
|
1255
|
+
});
|
|
1305
1256
|
});
|
|
1306
|
-
|
|
1307
|
-
});
|
|
1257
|
+
}
|
|
1308
1258
|
}
|
|
1309
|
-
|
|
1310
|
-
})(exports.
|
|
1259
|
+
BruceApi.Api = Api$$1;
|
|
1260
|
+
})(exports.BruceApi || (exports.BruceApi = {}));
|
|
1311
1261
|
|
|
1312
|
-
(function (
|
|
1313
|
-
/**
|
|
1314
|
-
* This is the request handler for Bruce Api,
|
|
1315
|
-
* it should be passed to any method that wants to communicate with this particular api.
|
|
1316
|
-
*/
|
|
1262
|
+
(function (GlobalApi) {
|
|
1317
1263
|
class Api$$1 extends AbstractApi {
|
|
1318
|
-
get AccountId() {
|
|
1319
|
-
return this.accountId;
|
|
1320
|
-
}
|
|
1321
|
-
get MessageBroker() {
|
|
1322
|
-
return this.messageBroker;
|
|
1323
|
-
}
|
|
1324
|
-
get ConfigLoadAttempted() {
|
|
1325
|
-
return this.configLoadAttempted;
|
|
1326
|
-
}
|
|
1327
|
-
get Version() {
|
|
1328
|
-
return this.version;
|
|
1329
|
-
}
|
|
1330
|
-
get Loading() {
|
|
1331
|
-
return this.loadProm;
|
|
1332
|
-
}
|
|
1333
1264
|
constructor(params) {
|
|
1334
1265
|
super({
|
|
1335
1266
|
ssidHeader: "x-sessionid",
|
|
1336
|
-
cacheId: `
|
|
1267
|
+
cacheId: `GLOBAL_API_${params === null || params === void 0 ? void 0 : params.env}_`
|
|
1337
1268
|
});
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
this.loadCancelled = false;
|
|
1341
|
-
// Indicates if loading the regional configuration was already called.
|
|
1342
|
-
this.configLoadAttempted = false;
|
|
1343
|
-
let { accountId, env, guardian, loadRegionalBaseUrl, loadConfig, loadWebSocket, dummy } = params;
|
|
1344
|
-
this.accountId = accountId;
|
|
1345
|
-
this.env = env !== null && env !== void 0 ? env : exports.Api.EEnv.PROD;
|
|
1346
|
-
if (!dummy) {
|
|
1347
|
-
// Backwards compatibility.
|
|
1348
|
-
if (loadRegionalBaseUrl) {
|
|
1349
|
-
loadConfig = true;
|
|
1350
|
-
}
|
|
1351
|
-
if (loadConfig) {
|
|
1352
|
-
// Mark it as attempted right away because we don't want any external calls while it gets to that async point.
|
|
1353
|
-
this.configLoadAttempted = true;
|
|
1354
|
-
}
|
|
1355
|
-
this.loadProm = this.init(guardian, loadConfig, loadWebSocket);
|
|
1356
|
-
}
|
|
1269
|
+
this.env = (params === null || params === void 0 ? void 0 : params.env) ? params.env : exports.Api.EEnv.PROD;
|
|
1270
|
+
this.setBaseUrl();
|
|
1357
1271
|
}
|
|
1358
1272
|
/**
|
|
1359
|
-
*
|
|
1360
|
-
* @param guardian Required for loading regional base url.
|
|
1361
|
-
* @param loadConfig
|
|
1362
|
-
* @returns
|
|
1273
|
+
* Sets the base url for this api.
|
|
1363
1274
|
*/
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
if (!this.accountId) {
|
|
1367
|
-
throw ("accountId is required.");
|
|
1368
|
-
}
|
|
1369
|
-
// Set using a stable default.
|
|
1370
|
-
const domain = this.getDomain();
|
|
1371
|
-
this.baseUrl = `https://${this.accountId}.api.${domain}/`;
|
|
1372
|
-
// Attempt to load regional configuration.
|
|
1373
|
-
if (loadConfig) {
|
|
1374
|
-
yield this.LoadConfig({
|
|
1375
|
-
guardian: guardian,
|
|
1376
|
-
// We marked it as attempted to load outside this method to fight any external calls.
|
|
1377
|
-
// So we'll force load it now.
|
|
1378
|
-
forceLoad: true
|
|
1379
|
-
});
|
|
1380
|
-
}
|
|
1381
|
-
// Get the version.
|
|
1382
|
-
if (this.baseUrl) {
|
|
1383
|
-
const data = yield this.get(this.baseUrl + "version");
|
|
1384
|
-
if (data === null || data === void 0 ? void 0 : data["Bruce-API"]) {
|
|
1385
|
-
this.version = data["Bruce-API"];
|
|
1386
|
-
}
|
|
1387
|
-
else {
|
|
1388
|
-
this.version = "UNKNOWN";
|
|
1389
|
-
}
|
|
1390
|
-
}
|
|
1391
|
-
// Start web socket connection.
|
|
1392
|
-
if (loadWebSocket == true) {
|
|
1393
|
-
try {
|
|
1394
|
-
this.messageBroker = new exports.MessageBroker.WebSocketBroker(this.baseUrl, this.env);
|
|
1395
|
-
}
|
|
1396
|
-
catch (e) {
|
|
1397
|
-
console.warn("BruceApi: Failed to create message broker.", e);
|
|
1398
|
-
}
|
|
1399
|
-
}
|
|
1400
|
-
});
|
|
1401
|
-
}
|
|
1402
|
-
getDomain() {
|
|
1275
|
+
setBaseUrl() {
|
|
1276
|
+
let url;
|
|
1403
1277
|
const env = this.env.toUpperCase();
|
|
1404
|
-
let domain = "nextspace.host";
|
|
1405
1278
|
switch (env) {
|
|
1406
1279
|
case exports.Api.EEnv.DEV:
|
|
1407
|
-
|
|
1280
|
+
url = "https://bruceglobal.nextspace-dev.net/";
|
|
1408
1281
|
break;
|
|
1409
1282
|
case exports.Api.EEnv.STG:
|
|
1410
|
-
|
|
1283
|
+
url = "https://bruceglobal.nextspace-stg.net/";
|
|
1411
1284
|
break;
|
|
1412
1285
|
case exports.Api.EEnv.UAT:
|
|
1413
|
-
|
|
1286
|
+
url = "https://bruceglobal.api.nextspace-uat.net/";
|
|
1414
1287
|
break;
|
|
1415
1288
|
case exports.Api.EEnv.PROD:
|
|
1416
|
-
|
|
1289
|
+
url = "https://bruceglobal.api.nextspace.host/";
|
|
1417
1290
|
break;
|
|
1418
1291
|
default:
|
|
1419
|
-
|
|
1292
|
+
throw ("Specified Environment is not valid. SuppliedEnv=" + env);
|
|
1420
1293
|
}
|
|
1421
|
-
|
|
1422
|
-
}
|
|
1423
|
-
/**
|
|
1424
|
-
* Loads the regional configuration for the account.
|
|
1425
|
-
* If the config is already loaded then this will do nothing.
|
|
1426
|
-
*/
|
|
1427
|
-
LoadConfig(params) {
|
|
1428
|
-
var _a, _b, _c;
|
|
1429
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1430
|
-
let { guardian, forceLoad } = (params !== null && params !== void 0 ? params : {});
|
|
1431
|
-
if (this.configLoadAttempted && forceLoad != true) {
|
|
1432
|
-
return;
|
|
1433
|
-
}
|
|
1434
|
-
this.configLoadAttempted = true;
|
|
1435
|
-
try {
|
|
1436
|
-
if (!guardian) {
|
|
1437
|
-
guardian = new exports.GuardianApi.Api({
|
|
1438
|
-
env: this.env
|
|
1439
|
-
});
|
|
1440
|
-
}
|
|
1441
|
-
const { account } = yield exports.Account.GetBySubdomain({
|
|
1442
|
-
subdomain: this.accountId,
|
|
1443
|
-
api: guardian
|
|
1444
|
-
});
|
|
1445
|
-
// Precalculated URLs exist.
|
|
1446
|
-
// Soon this will be a stable requirement for any account record.
|
|
1447
|
-
if (account.URL) {
|
|
1448
|
-
if (!this.loadCancelled) {
|
|
1449
|
-
const urls = account.URL;
|
|
1450
|
-
if (urls === null || urls === void 0 ? void 0 : urls.Base) {
|
|
1451
|
-
this.baseUrl = urls.Base;
|
|
1452
|
-
}
|
|
1453
|
-
if (urls === null || urls === void 0 ? void 0 : urls.CDNEntities) {
|
|
1454
|
-
this.EntityCdnUrl = urls.CDNEntities;
|
|
1455
|
-
}
|
|
1456
|
-
if (urls === null || urls === void 0 ? void 0 : urls.CDNTileset) {
|
|
1457
|
-
this.TilesetCdnUrl = urls.CDNTileset;
|
|
1458
|
-
}
|
|
1459
|
-
if (urls === null || urls === void 0 ? void 0 : urls.CDNLegacyTileset) {
|
|
1460
|
-
this.LegacyTilesetCdnUrl = urls.CDNLegacyTileset;
|
|
1461
|
-
}
|
|
1462
|
-
if (urls === null || urls === void 0 ? void 0 : urls.CDNBase) {
|
|
1463
|
-
this.cdnBaseUrl = urls.CDNBase;
|
|
1464
|
-
}
|
|
1465
|
-
}
|
|
1466
|
-
}
|
|
1467
|
-
// Deprecated and will eventually stop working at all.
|
|
1468
|
-
else {
|
|
1469
|
-
const env = this.env.toUpperCase();
|
|
1470
|
-
const domain = this.getDomain();
|
|
1471
|
-
const host = yield exports.HostingLocation.GetByAccountId({
|
|
1472
|
-
accountId: this.accountId,
|
|
1473
|
-
api: guardian
|
|
1474
|
-
});
|
|
1475
|
-
if (host === null || host === void 0 ? void 0 : host.location) {
|
|
1476
|
-
const settings = host.location.Settings;
|
|
1477
|
-
if (!this.loadCancelled) {
|
|
1478
|
-
// Attempt to load regional base url.
|
|
1479
|
-
// First try go through settings.
|
|
1480
|
-
let urlSet = false;
|
|
1481
|
-
if (settings === null || settings === void 0 ? void 0 : settings.BruceAPIURL) {
|
|
1482
|
-
let envUrl = settings.BruceAPIURL[env];
|
|
1483
|
-
if (envUrl) {
|
|
1484
|
-
envUrl = envUrl
|
|
1485
|
-
.replace("<ACCOUNTID>", this.accountId)
|
|
1486
|
-
.replace("<ACCOUNT>", this.accountId);
|
|
1487
|
-
if (envUrl && envUrl.length > 1) {
|
|
1488
|
-
this.baseUrl = envUrl;
|
|
1489
|
-
urlSet = true;
|
|
1490
|
-
}
|
|
1491
|
-
}
|
|
1492
|
-
}
|
|
1493
|
-
// Try go through host location's base url.
|
|
1494
|
-
// This may be wrong env which is why it's used as fallback right now.
|
|
1495
|
-
if (!urlSet && host.location.BruceAPIURL) {
|
|
1496
|
-
const regionalUrl = host.location.BruceAPIURL
|
|
1497
|
-
.replace("<ACCOUNTID>", this.accountId)
|
|
1498
|
-
.replace("<ACCOUNT>", this.accountId)
|
|
1499
|
-
.replace("<DOMAIN>", domain);
|
|
1500
|
-
if (regionalUrl && regionalUrl.length > 1) {
|
|
1501
|
-
this.baseUrl = regionalUrl;
|
|
1502
|
-
urlSet = true;
|
|
1503
|
-
}
|
|
1504
|
-
}
|
|
1505
|
-
}
|
|
1506
|
-
// Attempt to load CDN settings.
|
|
1507
|
-
if (settings === null || settings === void 0 ? void 0 : settings.CDN) {
|
|
1508
|
-
this.EntityCdnUrl = (_a = settings.CDN.entityURL) === null || _a === void 0 ? void 0 : _a[env];
|
|
1509
|
-
// We need to fix our configs.
|
|
1510
|
-
if (this.EntityCdnUrl) {
|
|
1511
|
-
if (this.EntityCdnUrl.includes("entitiesListForCDN")) {
|
|
1512
|
-
this.EntityCdnUrl = this.EntityCdnUrl.replace("<ACCOUNT>", this.accountId);
|
|
1513
|
-
}
|
|
1514
|
-
else {
|
|
1515
|
-
this.EntityCdnUrl = this.EntityCdnUrl.replace("<ACCOUNT>", "entitiesListForCDN/" + this.accountId);
|
|
1516
|
-
}
|
|
1517
|
-
}
|
|
1518
|
-
this.LegacyTilesetCdnUrl = (_b = settings.CDN.legacyTilesetURL) === null || _b === void 0 ? void 0 : _b[env];
|
|
1519
|
-
this.TilesetCdnUrl = (_c = settings.CDN.tilesetURL) === null || _c === void 0 ? void 0 : _c[env];
|
|
1520
|
-
if (this.TilesetCdnUrl) {
|
|
1521
|
-
this.TilesetCdnUrl = this.TilesetCdnUrl.replace("<ACCOUNT>", this.accountId);
|
|
1522
|
-
}
|
|
1523
|
-
// TilesetCdnUrl example: "https://blah.cloudfront.net/tilesets/<TILESETID>/files/<FILEPATH>?accountId=<ACCOUNT>".
|
|
1524
|
-
// Lazy at the moment to go around updating every region we have, I'll interpret the url from tilesetCdnUrl.
|
|
1525
|
-
if (this.TilesetCdnUrl) {
|
|
1526
|
-
try {
|
|
1527
|
-
const url = new URL(this.TilesetCdnUrl);
|
|
1528
|
-
this.cdnBaseUrl = `${url.protocol}//${url.hostname}/`;
|
|
1529
|
-
}
|
|
1530
|
-
catch (e) {
|
|
1531
|
-
console.error(e);
|
|
1532
|
-
}
|
|
1533
|
-
}
|
|
1534
|
-
}
|
|
1535
|
-
}
|
|
1536
|
-
}
|
|
1537
|
-
}
|
|
1538
|
-
catch (e) {
|
|
1539
|
-
console.error(e);
|
|
1540
|
-
}
|
|
1541
|
-
});
|
|
1542
|
-
}
|
|
1543
|
-
/**
|
|
1544
|
-
* Creates a message broker instance and returns it.
|
|
1545
|
-
* If an instance is already created, it will return that one.
|
|
1546
|
-
* @warning This will await the loading promise to avoid using data that isn't ready.
|
|
1547
|
-
*/
|
|
1548
|
-
ConnectWebsocket() {
|
|
1549
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1550
|
-
yield this.loadProm;
|
|
1551
|
-
if (this.messageBroker) {
|
|
1552
|
-
return this.messageBroker;
|
|
1553
|
-
}
|
|
1554
|
-
this.messageBroker = new exports.MessageBroker.WebSocketBroker(this.baseUrl, this.env);
|
|
1555
|
-
return this.messageBroker;
|
|
1556
|
-
});
|
|
1294
|
+
this.baseUrl = url;
|
|
1557
1295
|
}
|
|
1558
1296
|
/**
|
|
1559
|
-
*
|
|
1560
|
-
* This means the url could be changed once fully initialized.
|
|
1561
|
-
* The url will be valid either way, but the loaded one may be faster as it is region specific.
|
|
1562
|
-
* Await the "Loading" promise if you care about this.
|
|
1297
|
+
* Gets the base url for this api.
|
|
1563
1298
|
* @returns
|
|
1564
1299
|
*/
|
|
1565
1300
|
GetBaseUrl() {
|
|
1566
1301
|
return this.baseUrl;
|
|
1567
1302
|
}
|
|
1568
1303
|
/**
|
|
1569
|
-
*
|
|
1570
|
-
* @returns
|
|
1571
|
-
*/
|
|
1572
|
-
GetCdnBaseUrl() {
|
|
1573
|
-
return this.cdnBaseUrl;
|
|
1574
|
-
}
|
|
1575
|
-
/**
|
|
1576
|
-
* Returns a url routed through the API's CDN.
|
|
1577
|
-
* If the CDN is not enabled for the account, this will return null.
|
|
1578
|
-
* @param url suffix to append to the base url.
|
|
1579
|
-
* @param urlParams
|
|
1580
|
-
* @returns
|
|
1581
|
-
*/
|
|
1582
|
-
ConstructCdnUrl(url, urlParams) {
|
|
1583
|
-
if (!this.cdnBaseUrl) {
|
|
1584
|
-
return null;
|
|
1585
|
-
}
|
|
1586
|
-
const tmp = new URL(this.cdnBaseUrl);
|
|
1587
|
-
if (urlParams && urlParams instanceof URLSearchParams) {
|
|
1588
|
-
urlParams.forEach((value, key) => {
|
|
1589
|
-
tmp.searchParams.append(key, value);
|
|
1590
|
-
});
|
|
1591
|
-
}
|
|
1592
|
-
if (url) {
|
|
1593
|
-
tmp.pathname += url;
|
|
1594
|
-
}
|
|
1595
|
-
return tmp.toString();
|
|
1596
|
-
}
|
|
1597
|
-
/**
|
|
1598
|
-
* Warning: This will cancel the init process.
|
|
1599
|
-
* The init process loads a region specific endpoint.
|
|
1600
|
-
* Setting a base url will stop that process from completing.
|
|
1304
|
+
* Sets the base url for this api.
|
|
1601
1305
|
* @param url
|
|
1602
1306
|
*/
|
|
1603
1307
|
SetBaseUrl(url) {
|
|
@@ -1605,7 +1309,6 @@
|
|
|
1605
1309
|
if (!this.baseUrl.endsWith("/")) {
|
|
1606
1310
|
this.baseUrl += "/";
|
|
1607
1311
|
}
|
|
1608
|
-
this.loadCancelled = true;
|
|
1609
1312
|
}
|
|
1610
1313
|
/**
|
|
1611
1314
|
* Performs an HTTP GET request.
|
|
@@ -1616,11 +1319,7 @@
|
|
|
1616
1319
|
*/
|
|
1617
1320
|
GET(url, params) {
|
|
1618
1321
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1619
|
-
return
|
|
1620
|
-
this.loadProm.then(() => {
|
|
1621
|
-
this.get(this.baseUrl + url, params).then(res).catch(rej);
|
|
1622
|
-
}).catch(rej);
|
|
1623
|
-
});
|
|
1322
|
+
return this.get(this.baseUrl + url, params);
|
|
1624
1323
|
});
|
|
1625
1324
|
}
|
|
1626
1325
|
/**
|
|
@@ -1632,11 +1331,7 @@
|
|
|
1632
1331
|
*/
|
|
1633
1332
|
DELETE(url, params) {
|
|
1634
1333
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1635
|
-
return
|
|
1636
|
-
this.loadProm.then(() => {
|
|
1637
|
-
this.delete(this.baseUrl + url, params).then(res).catch(rej);
|
|
1638
|
-
}).catch(rej);
|
|
1639
|
-
});
|
|
1334
|
+
return this.delete(this.baseUrl + url, params);
|
|
1640
1335
|
});
|
|
1641
1336
|
}
|
|
1642
1337
|
/**
|
|
@@ -1649,28 +1344,7 @@
|
|
|
1649
1344
|
*/
|
|
1650
1345
|
POST(url, data, params) {
|
|
1651
1346
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1652
|
-
return
|
|
1653
|
-
this.loadProm.then(() => {
|
|
1654
|
-
this.post(this.baseUrl + url, data, params).then(res).catch(rej);
|
|
1655
|
-
}).catch(rej);
|
|
1656
|
-
});
|
|
1657
|
-
});
|
|
1658
|
-
}
|
|
1659
|
-
/**
|
|
1660
|
-
* Performs an HTTP PUT request.
|
|
1661
|
-
* This will prepend the base url to the url.
|
|
1662
|
-
* @param url
|
|
1663
|
-
* @param data
|
|
1664
|
-
* @param params
|
|
1665
|
-
* @returns
|
|
1666
|
-
*/
|
|
1667
|
-
PUT(url, data, params) {
|
|
1668
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1669
|
-
return new Promise((res, rej) => {
|
|
1670
|
-
this.loadProm.then(() => {
|
|
1671
|
-
this.put(this.baseUrl + url, data, params).then(res).catch(rej);
|
|
1672
|
-
}).catch(rej);
|
|
1673
|
-
});
|
|
1347
|
+
return this.post(this.baseUrl + url, data, params);
|
|
1674
1348
|
});
|
|
1675
1349
|
}
|
|
1676
1350
|
/**
|
|
@@ -1683,157 +1357,48 @@
|
|
|
1683
1357
|
*/
|
|
1684
1358
|
UPLOAD(url, blob, params) {
|
|
1685
1359
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1686
|
-
return
|
|
1687
|
-
this.loadProm.then(() => {
|
|
1688
|
-
this.upload(this.baseUrl + url, blob, params).then(res).catch(rej);
|
|
1689
|
-
}).catch(rej);
|
|
1690
|
-
});
|
|
1360
|
+
return this.upload(this.baseUrl + url, blob, params);
|
|
1691
1361
|
});
|
|
1692
1362
|
}
|
|
1693
1363
|
}
|
|
1694
|
-
|
|
1695
|
-
})(exports.
|
|
1364
|
+
GlobalApi.Api = Api$$1;
|
|
1365
|
+
})(exports.GlobalApi || (exports.GlobalApi = {}));
|
|
1696
1366
|
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
* Gets the base url for this api.
|
|
1733
|
-
* @returns
|
|
1734
|
-
*/
|
|
1735
|
-
GetBaseUrl() {
|
|
1736
|
-
return this.baseUrl;
|
|
1737
|
-
}
|
|
1738
|
-
/**
|
|
1739
|
-
* Sets the base url for this api.
|
|
1740
|
-
* @param url
|
|
1741
|
-
*/
|
|
1742
|
-
SetBaseUrl(url) {
|
|
1743
|
-
this.baseUrl = url;
|
|
1744
|
-
if (!this.baseUrl.endsWith("/")) {
|
|
1745
|
-
this.baseUrl += "/";
|
|
1746
|
-
}
|
|
1747
|
-
}
|
|
1748
|
-
/**
|
|
1749
|
-
* Performs an HTTP GET request.
|
|
1750
|
-
* This will prepend the base url to the url.
|
|
1751
|
-
* @param url
|
|
1752
|
-
* @param params
|
|
1753
|
-
* @returns
|
|
1754
|
-
*/
|
|
1755
|
-
GET(url, params) {
|
|
1756
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1757
|
-
return this.get(this.baseUrl + url, params);
|
|
1758
|
-
});
|
|
1759
|
-
}
|
|
1760
|
-
/**
|
|
1761
|
-
* Performs an HTTP DELETE request.
|
|
1762
|
-
* This will prepend the base url to the url.
|
|
1763
|
-
* @param url
|
|
1764
|
-
* @param params
|
|
1765
|
-
* @returns
|
|
1766
|
-
*/
|
|
1767
|
-
DELETE(url, params) {
|
|
1768
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1769
|
-
return this.delete(this.baseUrl + url, params);
|
|
1770
|
-
});
|
|
1771
|
-
}
|
|
1772
|
-
/**
|
|
1773
|
-
* Performs an HTTP POST request.
|
|
1774
|
-
* This will prepend the base url to the url.
|
|
1775
|
-
* @param url
|
|
1776
|
-
* @param data
|
|
1777
|
-
* @param params
|
|
1778
|
-
* @returns
|
|
1779
|
-
*/
|
|
1780
|
-
POST(url, data, params) {
|
|
1781
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1782
|
-
return this.post(this.baseUrl + url, data, params);
|
|
1783
|
-
});
|
|
1784
|
-
}
|
|
1785
|
-
/**
|
|
1786
|
-
* Performs a file upload request (HTTP POST).
|
|
1787
|
-
* This will prepend the base url to the url.
|
|
1788
|
-
* @param url
|
|
1789
|
-
* @param blob
|
|
1790
|
-
* @param params
|
|
1791
|
-
* @returns
|
|
1792
|
-
*/
|
|
1793
|
-
UPLOAD(url, blob, params) {
|
|
1794
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1795
|
-
return this.upload(this.baseUrl + url, blob, params);
|
|
1796
|
-
});
|
|
1797
|
-
}
|
|
1798
|
-
}
|
|
1799
|
-
GlobalApi.Api = Api$$1;
|
|
1800
|
-
})(exports.GlobalApi || (exports.GlobalApi = {}));
|
|
1801
|
-
|
|
1802
|
-
/**
|
|
1803
|
-
* Utility for managing multiple API instances.
|
|
1804
|
-
* Example: {
|
|
1805
|
-
* const api = new ApiGetters({
|
|
1806
|
-
* accountId: "123",
|
|
1807
|
-
* env: Api.EEnv.PROD
|
|
1808
|
-
* });
|
|
1809
|
-
*
|
|
1810
|
-
* // Returns default API instance specified in constructor.
|
|
1811
|
-
* const bruce1 = api.GetBruceApi();
|
|
1812
|
-
* // Returns API instance for account 456.
|
|
1813
|
-
* const bruce2 = api.GetBruceApi({
|
|
1814
|
-
* accountId: "456"
|
|
1815
|
-
* });
|
|
1816
|
-
*
|
|
1817
|
-
* const global = api.GetGlobalApi();
|
|
1818
|
-
* const guardian = api.GetGuardianApi();
|
|
1819
|
-
* }
|
|
1820
|
-
*/
|
|
1821
|
-
class ApiGetters {
|
|
1822
|
-
constructor(params) {
|
|
1823
|
-
this.bruce = {};
|
|
1824
|
-
this.guardian = {};
|
|
1825
|
-
this.global = {};
|
|
1826
|
-
this.accountId = params === null || params === void 0 ? void 0 : params.accountId;
|
|
1827
|
-
this.env = (params === null || params === void 0 ? void 0 : params.env) ? params.env : exports.Api.EEnv.PROD;
|
|
1828
|
-
this.sessionId = params === null || params === void 0 ? void 0 : params.sessionId;
|
|
1829
|
-
}
|
|
1830
|
-
/**
|
|
1831
|
-
* Clears all cache items in all API instances.
|
|
1832
|
-
*/
|
|
1833
|
-
ClearCache() {
|
|
1834
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1835
|
-
for (const key in this.bruce) {
|
|
1836
|
-
(_b = (_a = this.bruce[key]) === null || _a === void 0 ? void 0 : _a.Cache) === null || _b === void 0 ? void 0 : _b.Clear();
|
|
1367
|
+
/**
|
|
1368
|
+
* Utility for managing multiple API instances.
|
|
1369
|
+
* Example: {
|
|
1370
|
+
* const api = new ApiGetters({
|
|
1371
|
+
* accountId: "123",
|
|
1372
|
+
* env: Api.EEnv.PROD
|
|
1373
|
+
* });
|
|
1374
|
+
*
|
|
1375
|
+
* // Returns default API instance specified in constructor.
|
|
1376
|
+
* const bruce1 = api.GetBruceApi();
|
|
1377
|
+
* // Returns API instance for account 456.
|
|
1378
|
+
* const bruce2 = api.GetBruceApi({
|
|
1379
|
+
* accountId: "456"
|
|
1380
|
+
* });
|
|
1381
|
+
*
|
|
1382
|
+
* const global = api.GetGlobalApi();
|
|
1383
|
+
* const guardian = api.GetGuardianApi();
|
|
1384
|
+
* }
|
|
1385
|
+
*/
|
|
1386
|
+
class ApiGetters {
|
|
1387
|
+
constructor(params) {
|
|
1388
|
+
this.bruce = {};
|
|
1389
|
+
this.guardian = {};
|
|
1390
|
+
this.global = {};
|
|
1391
|
+
this.accountId = params === null || params === void 0 ? void 0 : params.accountId;
|
|
1392
|
+
this.env = (params === null || params === void 0 ? void 0 : params.env) ? params.env : exports.Api.EEnv.PROD;
|
|
1393
|
+
this.sessionId = params === null || params === void 0 ? void 0 : params.sessionId;
|
|
1394
|
+
}
|
|
1395
|
+
/**
|
|
1396
|
+
* Clears all cache items in all API instances.
|
|
1397
|
+
*/
|
|
1398
|
+
ClearCache() {
|
|
1399
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1400
|
+
for (const key in this.bruce) {
|
|
1401
|
+
(_b = (_a = this.bruce[key]) === null || _a === void 0 ? void 0 : _a.Cache) === null || _b === void 0 ? void 0 : _b.Clear();
|
|
1837
1402
|
}
|
|
1838
1403
|
for (const key in this.guardian) {
|
|
1839
1404
|
(_d = (_c = this.guardian[key]) === null || _c === void 0 ? void 0 : _c.Cache) === null || _d === void 0 ? void 0 : _d.Clear();
|
|
@@ -4164,17 +3729,7 @@
|
|
|
4164
3729
|
let totalCount;
|
|
4165
3730
|
let entities = [];
|
|
4166
3731
|
if (analysis || expandRelations || (viaCdn && api.GetCdnBaseUrl())) {
|
|
4167
|
-
|
|
4168
|
-
if (analysis) {
|
|
4169
|
-
url = new URL(api.GetBaseUrl() + "entities/summary");
|
|
4170
|
-
}
|
|
4171
|
-
else if (viaCdn && api.GetCdnBaseUrl()) {
|
|
4172
|
-
url = new URL(api.ConstructCdnUrl("entities"));
|
|
4173
|
-
}
|
|
4174
|
-
else {
|
|
4175
|
-
url = new URL(api.GetBaseUrl() + "entities");
|
|
4176
|
-
}
|
|
4177
|
-
const urlParams = url.searchParams;
|
|
3732
|
+
const urlParams = new URLSearchParams();
|
|
4178
3733
|
urlParams.set("cacheToken", String(viaCdnCacheToken ? viaCdnCacheToken : 0));
|
|
4179
3734
|
if (body.SortOrder) {
|
|
4180
3735
|
urlParams.set("SortOrder", body.SortOrder);
|
|
@@ -4222,7 +3777,11 @@
|
|
|
4222
3777
|
urlParams.set("schema", schemaId);
|
|
4223
3778
|
}
|
|
4224
3779
|
urlParams.set("hasMigrated", String(Boolean(migrated)));
|
|
4225
|
-
const urlStr =
|
|
3780
|
+
const urlStr = api.ConstructUrl({
|
|
3781
|
+
cdn: !analysis && viaCdn,
|
|
3782
|
+
url: analysis ? "entities/summary" : "entities",
|
|
3783
|
+
urlParams: urlParams
|
|
3784
|
+
});
|
|
4226
3785
|
const data = yield api.get(urlStr, exports.Api.PrepReqParams(reqParams));
|
|
4227
3786
|
if (!analysis) {
|
|
4228
3787
|
entities = data.Items;
|
|
@@ -4230,8 +3789,7 @@
|
|
|
4230
3789
|
totalCount = data.TotalCount;
|
|
4231
3790
|
}
|
|
4232
3791
|
else {
|
|
4233
|
-
const
|
|
4234
|
-
const urlParams = url.searchParams;
|
|
3792
|
+
const urlParams = new URLSearchParams();
|
|
4235
3793
|
if (expandRelations) {
|
|
4236
3794
|
urlParams.append("$expand", "relation");
|
|
4237
3795
|
}
|
|
@@ -4242,7 +3800,11 @@
|
|
|
4242
3800
|
urlParams.set("schema", schemaId);
|
|
4243
3801
|
}
|
|
4244
3802
|
urlParams.set("hasMigrated", String(Boolean(migrated)));
|
|
4245
|
-
const urlStr =
|
|
3803
|
+
const urlStr = api.ConstructUrl({
|
|
3804
|
+
cdn: false,
|
|
3805
|
+
url: analysis ? "entities/summary" : "entities",
|
|
3806
|
+
urlParams: urlParams
|
|
3807
|
+
});
|
|
4246
3808
|
const data = yield api.post(urlStr, body, exports.Api.PrepReqParams(reqParams));
|
|
4247
3809
|
if (!analysis) {
|
|
4248
3810
|
entities = data.Items;
|
|
@@ -6112,12 +5674,13 @@
|
|
|
6112
5674
|
if (!level) {
|
|
6113
5675
|
level = 0;
|
|
6114
5676
|
}
|
|
6115
|
-
let url = api.GetBaseUrl() + `entity/${entityId}/lod/${categoryId}/${level}`;
|
|
6116
|
-
if (strict) {
|
|
6117
|
-
url = url + "?strict=true";
|
|
6118
|
-
}
|
|
6119
5677
|
return {
|
|
6120
|
-
url:
|
|
5678
|
+
url: api.ConstructUrl({
|
|
5679
|
+
url: `entity/${entityId}/lod/${categoryId}/${level}`,
|
|
5680
|
+
urlParams: {
|
|
5681
|
+
"strict": strict ? "true" : "false"
|
|
5682
|
+
}
|
|
5683
|
+
})
|
|
6121
5684
|
};
|
|
6122
5685
|
}
|
|
6123
5686
|
EntityLod.GetUrl = GetUrl;
|
|
@@ -8275,15 +7838,14 @@
|
|
|
8275
7838
|
if (!api) {
|
|
8276
7839
|
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
8277
7840
|
}
|
|
8278
|
-
|
|
8279
|
-
|
|
8280
|
-
|
|
8281
|
-
|
|
8282
|
-
|
|
8283
|
-
|
|
8284
|
-
|
|
8285
|
-
|
|
8286
|
-
return url;
|
|
7841
|
+
return api.ConstructUrl({
|
|
7842
|
+
cdn: viaCdn,
|
|
7843
|
+
url: `file/${fileId}`,
|
|
7844
|
+
urlParams: {
|
|
7845
|
+
// Invalidating cache manually because we have a wave of invalid headers now cached across devices.
|
|
7846
|
+
cc: "1"
|
|
7847
|
+
}
|
|
7848
|
+
});
|
|
8287
7849
|
}
|
|
8288
7850
|
ClientFile.GetUrl = GetUrl;
|
|
8289
7851
|
/**
|
|
@@ -8304,14 +7866,14 @@
|
|
|
8304
7866
|
ext = "." + ext;
|
|
8305
7867
|
}
|
|
8306
7868
|
const urlSuffix = ext ? `file/${file.ID}${ext}` : `file/${file.ID}`;
|
|
8307
|
-
|
|
8308
|
-
|
|
8309
|
-
|
|
8310
|
-
|
|
8311
|
-
|
|
8312
|
-
|
|
8313
|
-
|
|
8314
|
-
|
|
7869
|
+
return api.ConstructUrl({
|
|
7870
|
+
cdn: viaCdn,
|
|
7871
|
+
url: urlSuffix,
|
|
7872
|
+
urlParams: {
|
|
7873
|
+
// Invalidating cache manually because we have a wave of invalid headers now cached across devices.
|
|
7874
|
+
cc: "1"
|
|
7875
|
+
}
|
|
7876
|
+
});
|
|
8315
7877
|
}
|
|
8316
7878
|
ClientFile.GetUrlWithExt = GetUrlWithExt;
|
|
8317
7879
|
/**
|
|
@@ -9436,23 +8998,13 @@
|
|
|
9436
8998
|
if (!file) {
|
|
9437
8999
|
file = "";
|
|
9438
9000
|
}
|
|
9439
|
-
|
|
9440
|
-
|
|
9441
|
-
|
|
9442
|
-
|
|
9443
|
-
|
|
9444
|
-
if (cacheToken != null) {
|
|
9445
|
-
urlParams.append("cacheToken", String(cacheToken));
|
|
9446
|
-
}
|
|
9447
|
-
url = api.ConstructCdnUrl(url, urlParams);
|
|
9448
|
-
}
|
|
9449
|
-
else {
|
|
9450
|
-
url = api.GetBaseUrl() + `v3/tilesets/${tilesetId}/files/${legacy ? "" : "files/"}${file}`;
|
|
9451
|
-
if (cacheToken != null) {
|
|
9452
|
-
url += `?cacheToken=${cacheToken}`;
|
|
9001
|
+
return api.ConstructUrl({
|
|
9002
|
+
cdn: viaCdn,
|
|
9003
|
+
url: `v3/tilesets/${tilesetId}/files/${legacy ? "" : "files/"}${file}`,
|
|
9004
|
+
urlParams: {
|
|
9005
|
+
"cacheToken": String(cacheToken ? cacheToken : 0)
|
|
9453
9006
|
}
|
|
9454
|
-
}
|
|
9455
|
-
return url;
|
|
9007
|
+
});
|
|
9456
9008
|
}
|
|
9457
9009
|
Tileset.GetFileUrl = GetFileUrl;
|
|
9458
9010
|
/**
|
|
@@ -9471,7 +9023,9 @@
|
|
|
9471
9023
|
if (!file) {
|
|
9472
9024
|
file = "";
|
|
9473
9025
|
}
|
|
9474
|
-
return api.
|
|
9026
|
+
return api.ConstructUrl({
|
|
9027
|
+
url: `tileset/getFile/${tilesetId}/src/${file}`
|
|
9028
|
+
});
|
|
9475
9029
|
}
|
|
9476
9030
|
Tileset.GetSrcFileUrl = GetSrcFileUrl;
|
|
9477
9031
|
/**
|
|
@@ -9491,16 +9045,13 @@
|
|
|
9491
9045
|
if (!file) {
|
|
9492
9046
|
file = "";
|
|
9493
9047
|
}
|
|
9494
|
-
|
|
9495
|
-
|
|
9496
|
-
|
|
9497
|
-
|
|
9048
|
+
return api.ConstructUrl({
|
|
9049
|
+
cdn: viaCdn,
|
|
9050
|
+
url: `tileset/file/${tilesetId}/${file}`,
|
|
9051
|
+
urlParams: {
|
|
9052
|
+
"cacheToken": String(viaCdnCacheToken ? viaCdnCacheToken : 0)
|
|
9498
9053
|
}
|
|
9499
|
-
|
|
9500
|
-
urlParams.append("cacheToken", String(viaCdnCacheToken));
|
|
9501
|
-
return api.ConstructCdnUrl(`tileset/file/${tilesetId}/${file}`, urlParams);
|
|
9502
|
-
}
|
|
9503
|
-
return api.GetBaseUrl() + `tileset/file/${tilesetId}/${file}`;
|
|
9054
|
+
});
|
|
9504
9055
|
}
|
|
9505
9056
|
Tileset.GetPublicFileUrl = GetPublicFileUrl;
|
|
9506
9057
|
/**
|
|
@@ -9857,293 +9408,823 @@
|
|
|
9857
9408
|
}
|
|
9858
9409
|
MenuItem.CreateFromTypeId = CreateFromTypeId;
|
|
9859
9410
|
/**
|
|
9860
|
-
* Creates a menu item for a tileset.
|
|
9861
|
-
* @param tilesetId
|
|
9862
|
-
* @param type
|
|
9863
|
-
* @returns
|
|
9411
|
+
* Creates a menu item for a tileset.
|
|
9412
|
+
* @param tilesetId
|
|
9413
|
+
* @param type
|
|
9414
|
+
* @returns
|
|
9415
|
+
*/
|
|
9416
|
+
function CreateFromTilesetId(tilesetId, type) {
|
|
9417
|
+
if (type === exports.Tileset.EType.Cad) {
|
|
9418
|
+
return {
|
|
9419
|
+
id: exports.ObjectUtils.UId(),
|
|
9420
|
+
Type: EType.CadTileset,
|
|
9421
|
+
Caption: "Generated CAD Menu Item",
|
|
9422
|
+
FlyTo: false,
|
|
9423
|
+
tileset: {
|
|
9424
|
+
TilesetID: tilesetId
|
|
9425
|
+
}
|
|
9426
|
+
};
|
|
9427
|
+
}
|
|
9428
|
+
else if (type == exports.Tileset.EType.EntitiesSet) {
|
|
9429
|
+
return {
|
|
9430
|
+
id: exports.ObjectUtils.UId(),
|
|
9431
|
+
Type: EType.EntityTileset,
|
|
9432
|
+
Caption: "Generated Entities Menu Item",
|
|
9433
|
+
FlyTo: false,
|
|
9434
|
+
tileset: {
|
|
9435
|
+
TilesetID: tilesetId
|
|
9436
|
+
}
|
|
9437
|
+
};
|
|
9438
|
+
}
|
|
9439
|
+
else if (type == exports.Tileset.EType.PointCloud) {
|
|
9440
|
+
return {
|
|
9441
|
+
id: exports.ObjectUtils.UId(),
|
|
9442
|
+
Type: EType.PointCloud,
|
|
9443
|
+
Caption: "Generated Point Cloud Menu Item",
|
|
9444
|
+
FlyTo: false,
|
|
9445
|
+
tileset: {
|
|
9446
|
+
TilesetID: tilesetId
|
|
9447
|
+
}
|
|
9448
|
+
};
|
|
9449
|
+
}
|
|
9450
|
+
else if (type == exports.Tileset.EType.EntitiesMap) {
|
|
9451
|
+
return {
|
|
9452
|
+
id: exports.ObjectUtils.UId(),
|
|
9453
|
+
Type: EType.EntityRaster,
|
|
9454
|
+
Caption: "Generated Entities Menu Item",
|
|
9455
|
+
tileset: {
|
|
9456
|
+
TilesetID: tilesetId
|
|
9457
|
+
}
|
|
9458
|
+
};
|
|
9459
|
+
}
|
|
9460
|
+
throw ("Tileset type not supported.");
|
|
9461
|
+
}
|
|
9462
|
+
MenuItem.CreateFromTilesetId = CreateFromTilesetId;
|
|
9463
|
+
})(exports.MenuItem || (exports.MenuItem = {}));
|
|
9464
|
+
|
|
9465
|
+
(function (ProjectViewBookmark) {
|
|
9466
|
+
// This is the expected default version for the DataVersion value.
|
|
9467
|
+
// This value should NOT be changed without looking at our API and seeing what the default value is.
|
|
9468
|
+
ProjectViewBookmark.DEFAULT_DATA_VERSION = 2;
|
|
9469
|
+
/**
|
|
9470
|
+
* Describes the content of a bookmark.
|
|
9471
|
+
* As part of a deal we've been commissioned to create an alternative bookmark type to embed content.
|
|
9472
|
+
*/
|
|
9473
|
+
let EContentType;
|
|
9474
|
+
(function (EContentType) {
|
|
9475
|
+
EContentType["WEB_3D"] = "WEB_3D";
|
|
9476
|
+
EContentType["IFRAME"] = "IFRAME";
|
|
9477
|
+
})(EContentType = ProjectViewBookmark.EContentType || (ProjectViewBookmark.EContentType = {}));
|
|
9478
|
+
/**
|
|
9479
|
+
* Gets a bookmark record.
|
|
9480
|
+
* @param params
|
|
9481
|
+
* @returns
|
|
9482
|
+
*/
|
|
9483
|
+
function Get(params) {
|
|
9484
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
9485
|
+
let { api, viewId, bookmarkId, req: reqParams } = params;
|
|
9486
|
+
if (!viewId || !bookmarkId) {
|
|
9487
|
+
throw ("View ID and Bookmark ID are required.");
|
|
9488
|
+
}
|
|
9489
|
+
if (!api) {
|
|
9490
|
+
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
9491
|
+
}
|
|
9492
|
+
const key = GetCacheKey(viewId, bookmarkId);
|
|
9493
|
+
const cache = yield api.GetCacheItem(key, reqParams);
|
|
9494
|
+
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
9495
|
+
return cache.data;
|
|
9496
|
+
}
|
|
9497
|
+
const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
9498
|
+
try {
|
|
9499
|
+
const data = yield api.GET(`ui.view/${viewId}/slide/${bookmarkId}`, exports.Api.PrepReqParams(reqParams));
|
|
9500
|
+
res({
|
|
9501
|
+
bookmark: data
|
|
9502
|
+
});
|
|
9503
|
+
}
|
|
9504
|
+
catch (e) {
|
|
9505
|
+
rej(e);
|
|
9506
|
+
}
|
|
9507
|
+
}));
|
|
9508
|
+
yield api.SetCacheItem({
|
|
9509
|
+
key,
|
|
9510
|
+
value: prom,
|
|
9511
|
+
req: reqParams
|
|
9512
|
+
});
|
|
9513
|
+
return prom;
|
|
9514
|
+
});
|
|
9515
|
+
}
|
|
9516
|
+
ProjectViewBookmark.Get = Get;
|
|
9517
|
+
/**
|
|
9518
|
+
* Deletes a bookmark record.
|
|
9519
|
+
* @param params
|
|
9520
|
+
*/
|
|
9521
|
+
function Delete(params) {
|
|
9522
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
9523
|
+
let { api, viewId, bookmarkId, req: reqParams } = params;
|
|
9524
|
+
if (!viewId || !bookmarkId) {
|
|
9525
|
+
throw ("View ID and Bookmark ID are required.");
|
|
9526
|
+
}
|
|
9527
|
+
if (!api) {
|
|
9528
|
+
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
9529
|
+
}
|
|
9530
|
+
yield api.DELETE(`ui.view/${viewId}/slide/${bookmarkId}`, exports.Api.PrepReqParams(reqParams));
|
|
9531
|
+
api.Cache.Remove(GetCacheKey(viewId, bookmarkId));
|
|
9532
|
+
api.Cache.Remove(GetListCacheKey(viewId));
|
|
9533
|
+
});
|
|
9534
|
+
}
|
|
9535
|
+
ProjectViewBookmark.Delete = Delete;
|
|
9536
|
+
/**
|
|
9537
|
+
* Gets a list of bookmark records.
|
|
9538
|
+
* @param params
|
|
9539
|
+
* @returns
|
|
9540
|
+
*/
|
|
9541
|
+
function GetList(params) {
|
|
9542
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
9543
|
+
let { api, viewId, req: reqParams } = params;
|
|
9544
|
+
if (!viewId) {
|
|
9545
|
+
throw ("View ID is required.");
|
|
9546
|
+
}
|
|
9547
|
+
if (!api) {
|
|
9548
|
+
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
9549
|
+
}
|
|
9550
|
+
const cache = yield api.GetCacheItem(GetListCacheKey(viewId), reqParams);
|
|
9551
|
+
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
9552
|
+
return cache.data;
|
|
9553
|
+
}
|
|
9554
|
+
const req = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
9555
|
+
try {
|
|
9556
|
+
const data = yield api.GET(`ui.view/${viewId}/slides`, exports.Api.PrepReqParams(reqParams));
|
|
9557
|
+
const items = data.Items ? data.Items : [];
|
|
9558
|
+
// Cache individual items.
|
|
9559
|
+
// Maybe better to load list cache when getting 1 slide and seeing if it's in there.
|
|
9560
|
+
// WARNING: Right now the data matches, in the future the list may contain a shortened result.
|
|
9561
|
+
for (let i = 0; i < items.length; i++) {
|
|
9562
|
+
const item = items[i];
|
|
9563
|
+
const prom = new Promise((res) => {
|
|
9564
|
+
res({
|
|
9565
|
+
bookmark: item
|
|
9566
|
+
});
|
|
9567
|
+
});
|
|
9568
|
+
yield api.SetCacheItem({
|
|
9569
|
+
key: GetCacheKey(viewId, item.ID),
|
|
9570
|
+
value: prom,
|
|
9571
|
+
req: reqParams
|
|
9572
|
+
});
|
|
9573
|
+
}
|
|
9574
|
+
res({
|
|
9575
|
+
bookmarks: items
|
|
9576
|
+
});
|
|
9577
|
+
}
|
|
9578
|
+
catch (e) {
|
|
9579
|
+
rej(e);
|
|
9580
|
+
}
|
|
9581
|
+
}));
|
|
9582
|
+
yield api.SetCacheItem({
|
|
9583
|
+
key: GetListCacheKey(viewId),
|
|
9584
|
+
value: req,
|
|
9585
|
+
req: reqParams
|
|
9586
|
+
});
|
|
9587
|
+
return req;
|
|
9588
|
+
});
|
|
9589
|
+
}
|
|
9590
|
+
ProjectViewBookmark.GetList = GetList;
|
|
9591
|
+
/**
|
|
9592
|
+
* Creates or updates a bookmark record.
|
|
9593
|
+
* @param params
|
|
9594
|
+
* @returns
|
|
9595
|
+
*/
|
|
9596
|
+
function Update(params) {
|
|
9597
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
9598
|
+
let { api, viewId, bookmark: data, req: reqParams } = params;
|
|
9599
|
+
if (!api) {
|
|
9600
|
+
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
9601
|
+
}
|
|
9602
|
+
if (!(data === null || data === void 0 ? void 0 : data.Title)) {
|
|
9603
|
+
data.Title = data.ID;
|
|
9604
|
+
}
|
|
9605
|
+
const res = yield api.POST(`ui.view/${viewId}/slide/${data.ID ? data.ID : ""}`, data, exports.Api.PrepReqParams(reqParams));
|
|
9606
|
+
api.Cache.Remove(GetCacheKey(viewId, data.ID));
|
|
9607
|
+
api.Cache.Remove(GetListCacheKey(viewId));
|
|
9608
|
+
return {
|
|
9609
|
+
bookmark: res
|
|
9610
|
+
};
|
|
9611
|
+
});
|
|
9612
|
+
}
|
|
9613
|
+
ProjectViewBookmark.Update = Update;
|
|
9614
|
+
/**
|
|
9615
|
+
* Sets the order of bookmarks within a project view.
|
|
9616
|
+
* @param params
|
|
9617
|
+
*/
|
|
9618
|
+
function SetOrder(params) {
|
|
9619
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
9620
|
+
let { api, viewId, bookmarkIds, req: reqParams } = params;
|
|
9621
|
+
if (!api) {
|
|
9622
|
+
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
9623
|
+
}
|
|
9624
|
+
const reqData = {
|
|
9625
|
+
"UISlide.ID": bookmarkIds,
|
|
9626
|
+
"DisplayOrder.Start": 0
|
|
9627
|
+
};
|
|
9628
|
+
yield api.POST(`ui.view/${viewId}/slides/setOrder`, reqData, exports.Api.PrepReqParams(reqParams));
|
|
9629
|
+
yield api.Cache.RemoveByStartsWith(GetListCacheKey(viewId));
|
|
9630
|
+
});
|
|
9631
|
+
}
|
|
9632
|
+
ProjectViewBookmark.SetOrder = SetOrder;
|
|
9633
|
+
/**
|
|
9634
|
+
* Returns cache identifier for a bookmark.
|
|
9635
|
+
* Example: {
|
|
9636
|
+
* const api: BruceApi.Api = ...;
|
|
9637
|
+
* const key = GetCacheKey("abc", "def");
|
|
9638
|
+
* api.Cache.Remove(key);
|
|
9639
|
+
* }
|
|
9640
|
+
* @param viewId
|
|
9641
|
+
* @param bookmarkId
|
|
9642
|
+
* @returns
|
|
9643
|
+
*/
|
|
9644
|
+
function GetCacheKey(viewId, bookmarkId) {
|
|
9645
|
+
return `${exports.Api.ECacheKey.ProjectViewBookmark}${exports.Api.ECacheKey.Id}${viewId}${exports.Api.ECacheKey.Id}${bookmarkId}`;
|
|
9646
|
+
}
|
|
9647
|
+
ProjectViewBookmark.GetCacheKey = GetCacheKey;
|
|
9648
|
+
/**
|
|
9649
|
+
* Returns cache identifier for a list of bookmarks.
|
|
9650
|
+
* Example: {
|
|
9651
|
+
* const api: BruceApi.Api = ...;
|
|
9652
|
+
* const key = GetListCacheKey("abc");
|
|
9653
|
+
* api.Cache.Remove(key);
|
|
9654
|
+
* }
|
|
9655
|
+
* @param viewId
|
|
9656
|
+
* @returns
|
|
9657
|
+
*/
|
|
9658
|
+
function GetListCacheKey(viewId) {
|
|
9659
|
+
return `${exports.Api.ECacheKey.ProjectViewBookmark}${exports.Api.ECacheKey.Id}${viewId}`;
|
|
9660
|
+
}
|
|
9661
|
+
ProjectViewBookmark.GetListCacheKey = GetListCacheKey;
|
|
9662
|
+
})(exports.ProjectViewBookmark || (exports.ProjectViewBookmark = {}));
|
|
9663
|
+
|
|
9664
|
+
(function (ProjectView) {
|
|
9665
|
+
// This is the expected default version for the DataVersion value.
|
|
9666
|
+
// This value should NOT be changed without looking at our API and seeing what the default value is.
|
|
9667
|
+
ProjectView.DEFAULT_DATA_VERSION = 2;
|
|
9668
|
+
// Our Cesium web navigator.
|
|
9669
|
+
ProjectView.TYPE_WEB_3D_NAVIGATOR = "WEB_3D_NAVIGATOR";
|
|
9670
|
+
// Our (currently WIP) 2D web navigator. Also known as our graph viewer.
|
|
9671
|
+
ProjectView.TYPE_WEB_2D_NAVIGATOR = "WEB_2D_NAVIGATOR";
|
|
9672
|
+
// Defaulting to 3D navigator for backwards compatibility.
|
|
9673
|
+
ProjectView.DEFAULT_TYPE = ProjectView.TYPE_WEB_3D_NAVIGATOR;
|
|
9674
|
+
/**
|
|
9675
|
+
* Gets a project view record.
|
|
9676
|
+
* @param params
|
|
9677
|
+
* @returns
|
|
9678
|
+
*/
|
|
9679
|
+
function Get(params) {
|
|
9680
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
9681
|
+
let { api, viewId, req: reqParams } = params;
|
|
9682
|
+
if (!viewId) {
|
|
9683
|
+
throw ("View ID is required.");
|
|
9684
|
+
}
|
|
9685
|
+
if (!api) {
|
|
9686
|
+
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
9687
|
+
}
|
|
9688
|
+
const key = GetCacheKey(viewId);
|
|
9689
|
+
const cache = yield api.GetCacheItem(key, reqParams);
|
|
9690
|
+
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
9691
|
+
return cache.data;
|
|
9692
|
+
}
|
|
9693
|
+
const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
9694
|
+
try {
|
|
9695
|
+
const data = yield api.GET(`ui.view/${viewId}`, exports.Api.PrepReqParams(reqParams));
|
|
9696
|
+
res({
|
|
9697
|
+
view: data
|
|
9698
|
+
});
|
|
9699
|
+
}
|
|
9700
|
+
catch (e) {
|
|
9701
|
+
rej(e);
|
|
9702
|
+
}
|
|
9703
|
+
}));
|
|
9704
|
+
yield api.SetCacheItem({
|
|
9705
|
+
key,
|
|
9706
|
+
value: prom,
|
|
9707
|
+
req: reqParams
|
|
9708
|
+
});
|
|
9709
|
+
return prom;
|
|
9710
|
+
});
|
|
9711
|
+
}
|
|
9712
|
+
ProjectView.Get = Get;
|
|
9713
|
+
/**
|
|
9714
|
+
* Gets a list of project views.
|
|
9715
|
+
* @param params
|
|
9716
|
+
* @returns
|
|
9717
|
+
*/
|
|
9718
|
+
function GetList(params) {
|
|
9719
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
9720
|
+
let { api, req: reqParams, type } = params;
|
|
9721
|
+
if (!api) {
|
|
9722
|
+
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
9723
|
+
}
|
|
9724
|
+
const cache = yield api.GetCacheItem(GetListCacheKey(type), reqParams);
|
|
9725
|
+
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
9726
|
+
return cache.data;
|
|
9727
|
+
}
|
|
9728
|
+
const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
9729
|
+
try {
|
|
9730
|
+
const data = yield api.GET("ui.view/list", exports.Api.PrepReqParams(reqParams));
|
|
9731
|
+
res({
|
|
9732
|
+
views: data.Items
|
|
9733
|
+
});
|
|
9734
|
+
}
|
|
9735
|
+
catch (e) {
|
|
9736
|
+
rej(e);
|
|
9737
|
+
}
|
|
9738
|
+
}));
|
|
9739
|
+
yield api.SetCacheItem({
|
|
9740
|
+
key: GetListCacheKey(type),
|
|
9741
|
+
value: prom,
|
|
9742
|
+
req: reqParams
|
|
9743
|
+
});
|
|
9744
|
+
return prom;
|
|
9745
|
+
});
|
|
9746
|
+
}
|
|
9747
|
+
ProjectView.GetList = GetList;
|
|
9748
|
+
/**
|
|
9749
|
+
* Deletes a project view.
|
|
9750
|
+
* @param params
|
|
9751
|
+
*/
|
|
9752
|
+
function Delete(params) {
|
|
9753
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
9754
|
+
let { api, viewId, req: reqParams } = params;
|
|
9755
|
+
if (!viewId) {
|
|
9756
|
+
throw ("View ID is required.");
|
|
9757
|
+
}
|
|
9758
|
+
if (!api) {
|
|
9759
|
+
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
9760
|
+
}
|
|
9761
|
+
yield api.DELETE(`ui.view/${viewId}`, exports.Api.PrepReqParams(reqParams));
|
|
9762
|
+
api.Cache.Remove(GetCacheKey(viewId));
|
|
9763
|
+
api.Cache.RemoveByStartsWith(GetListCacheKey());
|
|
9764
|
+
});
|
|
9765
|
+
}
|
|
9766
|
+
ProjectView.Delete = Delete;
|
|
9767
|
+
/**
|
|
9768
|
+
* Creates or updates a project view.
|
|
9769
|
+
* @param params
|
|
9770
|
+
* @returns
|
|
9771
|
+
*/
|
|
9772
|
+
function Update(params) {
|
|
9773
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
9774
|
+
let { api, view: data, req: reqParams } = params;
|
|
9775
|
+
if (!api) {
|
|
9776
|
+
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
9777
|
+
}
|
|
9778
|
+
if (!data) {
|
|
9779
|
+
data = {};
|
|
9780
|
+
}
|
|
9781
|
+
const isNew = !data.ID;
|
|
9782
|
+
if (!data.ID) {
|
|
9783
|
+
// Short ID to keep the URL short.
|
|
9784
|
+
// 8 length = 4,294,967,296 combinations.
|
|
9785
|
+
data.ID = exports.ObjectUtils.UId(8);
|
|
9786
|
+
}
|
|
9787
|
+
if (!data.Name) {
|
|
9788
|
+
data.Name = data.ID;
|
|
9789
|
+
}
|
|
9790
|
+
if (!data.CreatedByUIVersion) {
|
|
9791
|
+
data.CreatedByUIVersion = "-1";
|
|
9792
|
+
}
|
|
9793
|
+
if (isNew) {
|
|
9794
|
+
data = yield api.POST(`ui.view/${data.ID}`, data, exports.Api.PrepReqParams(reqParams));
|
|
9795
|
+
}
|
|
9796
|
+
else {
|
|
9797
|
+
data = yield api.PUT(`ui.view/${data.ID}`, data, exports.Api.PrepReqParams(reqParams));
|
|
9798
|
+
}
|
|
9799
|
+
api.Cache.Remove(GetCacheKey(data.ID));
|
|
9800
|
+
api.Cache.RemoveByStartsWith(GetListCacheKey());
|
|
9801
|
+
return {
|
|
9802
|
+
view: data
|
|
9803
|
+
};
|
|
9804
|
+
});
|
|
9805
|
+
}
|
|
9806
|
+
ProjectView.Update = Update;
|
|
9807
|
+
/**
|
|
9808
|
+
* Returns cache identifier for a project view.
|
|
9809
|
+
* Example: {
|
|
9810
|
+
* const api: BruceApi.Api = ...;
|
|
9811
|
+
* const key = GetCacheKey("abc");
|
|
9812
|
+
* api.Cache.Remove(key);
|
|
9813
|
+
* }
|
|
9814
|
+
* @param viewId
|
|
9815
|
+
* @returns
|
|
9816
|
+
*/
|
|
9817
|
+
function GetCacheKey(viewId) {
|
|
9818
|
+
return `${exports.Api.ECacheKey.ProjectView}${exports.Api.ECacheKey.Id}${viewId}`;
|
|
9819
|
+
}
|
|
9820
|
+
ProjectView.GetCacheKey = GetCacheKey;
|
|
9821
|
+
/**
|
|
9822
|
+
* Returns cache identifier for a list of project views.
|
|
9823
|
+
* Example: {
|
|
9824
|
+
* const api: BruceApi.Api = ...;
|
|
9825
|
+
* const key = GetListCacheKey();
|
|
9826
|
+
* api.Cache.Remove(key);
|
|
9827
|
+
* }
|
|
9828
|
+
* @param type optional filter for the type of project view.
|
|
9829
|
+
* @returns
|
|
9830
|
+
*/
|
|
9831
|
+
function GetListCacheKey(type) {
|
|
9832
|
+
if (type) {
|
|
9833
|
+
return `${exports.Api.ECacheKey.ProjectView}${exports.Api.ECacheKey.ListId}${type}`;
|
|
9834
|
+
}
|
|
9835
|
+
return `${exports.Api.ECacheKey.ProjectView}${exports.Api.ECacheKey.ListId}`;
|
|
9836
|
+
}
|
|
9837
|
+
ProjectView.GetListCacheKey = GetListCacheKey;
|
|
9838
|
+
})(exports.ProjectView || (exports.ProjectView = {}));
|
|
9839
|
+
|
|
9840
|
+
function getTemplateSettings(apiGetter, reqParams) {
|
|
9841
|
+
var _a;
|
|
9842
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
9843
|
+
const { view } = yield exports.ProjectView.Get({
|
|
9844
|
+
api: apiGetter.getApi(exports.Api.TEMPLATE_ACCOUNT_ID),
|
|
9845
|
+
viewId: "default",
|
|
9846
|
+
req: reqParams
|
|
9847
|
+
});
|
|
9848
|
+
return (_a = view.Settings) !== null && _a !== void 0 ? _a : {};
|
|
9849
|
+
});
|
|
9850
|
+
}
|
|
9851
|
+
function checkSourceToTemplate(items, templateItem, addIfMissing) {
|
|
9852
|
+
const index = items.findIndex(x => x.Name === templateItem.Name);
|
|
9853
|
+
if (index > -1) {
|
|
9854
|
+
templateItem.IsDefault = true;
|
|
9855
|
+
templateItem.IsEnabled = items[index].IsEnabled;
|
|
9856
|
+
items[index] = templateItem;
|
|
9857
|
+
}
|
|
9858
|
+
else if (addIfMissing) {
|
|
9859
|
+
templateItem.IsDefault = true;
|
|
9860
|
+
items.push(templateItem);
|
|
9861
|
+
}
|
|
9862
|
+
}
|
|
9863
|
+
(function (ProjectViewLegacyTile) {
|
|
9864
|
+
function MergeMapTemplateData(params) {
|
|
9865
|
+
var _a;
|
|
9866
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
9867
|
+
let { getter, sources: items, addIfMissing, req: reqParams } = params;
|
|
9868
|
+
if (!getter) {
|
|
9869
|
+
getter = exports.ENVIRONMENT.Api().GetBruceGetter();
|
|
9870
|
+
}
|
|
9871
|
+
const settings = yield getTemplateSettings(getter, reqParams);
|
|
9872
|
+
const maps = (_a = settings.CesiumMapSources) !== null && _a !== void 0 ? _a : [];
|
|
9873
|
+
for (let i = 0; i < maps.length; i++) {
|
|
9874
|
+
const mapSource = maps[i];
|
|
9875
|
+
checkSourceToTemplate(items, mapSource, addIfMissing);
|
|
9876
|
+
}
|
|
9877
|
+
return {
|
|
9878
|
+
sources: items
|
|
9879
|
+
};
|
|
9880
|
+
});
|
|
9881
|
+
}
|
|
9882
|
+
ProjectViewLegacyTile.MergeMapTemplateData = MergeMapTemplateData;
|
|
9883
|
+
function MergeTerrainTemplateData(params) {
|
|
9884
|
+
var _a;
|
|
9885
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
9886
|
+
let { getter, sources: items, addIfMissing, req: reqParams } = params;
|
|
9887
|
+
if (!getter) {
|
|
9888
|
+
getter = exports.ENVIRONMENT.Api().GetBruceGetter();
|
|
9889
|
+
}
|
|
9890
|
+
const settings = yield getTemplateSettings(getter, reqParams);
|
|
9891
|
+
const terrains = (_a = settings.CesiumTerrainSources) !== null && _a !== void 0 ? _a : [];
|
|
9892
|
+
for (let i = 0; i < terrains.length; i++) {
|
|
9893
|
+
const terrainSource = terrains[i];
|
|
9894
|
+
checkSourceToTemplate(items, terrainSource, addIfMissing);
|
|
9895
|
+
}
|
|
9896
|
+
return {
|
|
9897
|
+
sources: items
|
|
9898
|
+
};
|
|
9899
|
+
});
|
|
9900
|
+
}
|
|
9901
|
+
ProjectViewLegacyTile.MergeTerrainTemplateData = MergeTerrainTemplateData;
|
|
9902
|
+
})(exports.ProjectViewLegacyTile || (exports.ProjectViewLegacyTile = {}));
|
|
9903
|
+
|
|
9904
|
+
/**
|
|
9905
|
+
* A tile is an imagery or terrain tileset definition.
|
|
9906
|
+
*/
|
|
9907
|
+
(function (ProjectViewTile) {
|
|
9908
|
+
/**
|
|
9909
|
+
* Available imagery defaults.
|
|
9910
|
+
*/
|
|
9911
|
+
let EDefaultImagery;
|
|
9912
|
+
(function (EDefaultImagery) {
|
|
9913
|
+
EDefaultImagery["BingMapsAerial"] = "bingmapsaerial";
|
|
9914
|
+
EDefaultImagery["BingMapsAerialWithLabels"] = "bingmapsaerialwithlabels";
|
|
9915
|
+
EDefaultImagery["BingMapsRoads"] = "bingmapsroads";
|
|
9916
|
+
EDefaultImagery["MapboxSatellite"] = "mapboxsatellite";
|
|
9917
|
+
EDefaultImagery["MapBoxStreets"] = "mapboxstreets";
|
|
9918
|
+
EDefaultImagery["MapBoxStreetsClassic"] = "mapboxstreetsclassic";
|
|
9919
|
+
EDefaultImagery["EsriWorldImagery"] = "esriworldimagery";
|
|
9920
|
+
EDefaultImagery["EsriWorldStreetMap"] = "esriworldstreetmap";
|
|
9921
|
+
EDefaultImagery["EsriNationalGeographic"] = "esrinationalgeographic";
|
|
9922
|
+
EDefaultImagery["OpenStreetMap"] = "openstreetmap";
|
|
9923
|
+
EDefaultImagery["LINZ"] = "linz";
|
|
9924
|
+
EDefaultImagery["StamenWaterColor"] = "stamenwatercolor";
|
|
9925
|
+
EDefaultImagery["StamenToner"] = "stamentoner";
|
|
9926
|
+
EDefaultImagery["Grid"] = "grid";
|
|
9927
|
+
EDefaultImagery["ThunderforestCycle"] = "thunderforestcycle";
|
|
9928
|
+
EDefaultImagery["ThunderforestTransport"] = "thunderforesttransport";
|
|
9929
|
+
EDefaultImagery["ThunderforestLandscape"] = "thunderforestlandscape";
|
|
9930
|
+
})(EDefaultImagery = ProjectViewTile.EDefaultImagery || (ProjectViewTile.EDefaultImagery = {}));
|
|
9931
|
+
/**
|
|
9932
|
+
* Prepared array for UI.
|
|
9933
|
+
* TODO: Im not happy with icon urls sitting in the code. I'd prefer we ship these icons in the library as files.
|
|
9934
|
+
*/
|
|
9935
|
+
ProjectViewTile.DefaultImagery = [
|
|
9936
|
+
{
|
|
9937
|
+
id: EDefaultImagery.BingMapsAerial,
|
|
9938
|
+
name: "Bing Maps Aerial",
|
|
9939
|
+
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/bingAerial.png"
|
|
9940
|
+
},
|
|
9941
|
+
{
|
|
9942
|
+
id: EDefaultImagery.BingMapsAerialWithLabels,
|
|
9943
|
+
name: "Bing Maps Aerial with Labels",
|
|
9944
|
+
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/bingAerialLabels.png"
|
|
9945
|
+
},
|
|
9946
|
+
{
|
|
9947
|
+
id: EDefaultImagery.BingMapsRoads,
|
|
9948
|
+
name: "Bing Maps Roads",
|
|
9949
|
+
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/bingRoads.png"
|
|
9950
|
+
},
|
|
9951
|
+
{
|
|
9952
|
+
id: EDefaultImagery.MapboxSatellite,
|
|
9953
|
+
name: "Mapbox Satellite",
|
|
9954
|
+
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/mapboxSatellite.png"
|
|
9955
|
+
},
|
|
9956
|
+
{
|
|
9957
|
+
id: EDefaultImagery.MapBoxStreets,
|
|
9958
|
+
name: "Mapbox Streets",
|
|
9959
|
+
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/mapboxTerrain.png"
|
|
9960
|
+
},
|
|
9961
|
+
{
|
|
9962
|
+
id: EDefaultImagery.MapBoxStreetsClassic,
|
|
9963
|
+
name: "Mapbox Streets Classic",
|
|
9964
|
+
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/mapboxStreets.png"
|
|
9965
|
+
},
|
|
9966
|
+
{
|
|
9967
|
+
id: EDefaultImagery.EsriWorldImagery,
|
|
9968
|
+
name: "Esri World Imagery",
|
|
9969
|
+
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/esriWorldImagery.png"
|
|
9970
|
+
},
|
|
9971
|
+
{
|
|
9972
|
+
id: EDefaultImagery.EsriWorldStreetMap,
|
|
9973
|
+
name: "Esri World Street Map",
|
|
9974
|
+
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/esriWorldStreetMap.png"
|
|
9975
|
+
},
|
|
9976
|
+
{
|
|
9977
|
+
id: EDefaultImagery.EsriNationalGeographic,
|
|
9978
|
+
name: "Esri National Geographic",
|
|
9979
|
+
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/esriNationalGeographic.png"
|
|
9980
|
+
},
|
|
9981
|
+
{
|
|
9982
|
+
id: EDefaultImagery.OpenStreetMap,
|
|
9983
|
+
name: "Open Street Map",
|
|
9984
|
+
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/openStreetMap.png"
|
|
9985
|
+
},
|
|
9986
|
+
{
|
|
9987
|
+
id: EDefaultImagery.LINZ,
|
|
9988
|
+
name: "LINZ",
|
|
9989
|
+
iconUrl: "https://template.ui.nextspace.host/media/linz.jpg"
|
|
9990
|
+
},
|
|
9991
|
+
{
|
|
9992
|
+
id: EDefaultImagery.StamenWaterColor,
|
|
9993
|
+
name: "Stamen Water Color",
|
|
9994
|
+
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/stamenWatercolor.png"
|
|
9995
|
+
},
|
|
9996
|
+
{
|
|
9997
|
+
id: EDefaultImagery.StamenToner,
|
|
9998
|
+
name: "Stamen Toner",
|
|
9999
|
+
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/stamenToner.png"
|
|
10000
|
+
},
|
|
10001
|
+
{
|
|
10002
|
+
id: EDefaultImagery.ThunderforestCycle,
|
|
10003
|
+
name: "Thunderforest Cycle"
|
|
10004
|
+
},
|
|
10005
|
+
{
|
|
10006
|
+
id: EDefaultImagery.ThunderforestTransport,
|
|
10007
|
+
name: "Thunderforest Transport"
|
|
10008
|
+
},
|
|
10009
|
+
{
|
|
10010
|
+
id: EDefaultImagery.ThunderforestLandscape,
|
|
10011
|
+
name: "Thunderforest Landscape"
|
|
10012
|
+
},
|
|
10013
|
+
{
|
|
10014
|
+
id: EDefaultImagery.Grid,
|
|
10015
|
+
name: "Grid",
|
|
10016
|
+
iconUrl: "https://template.api.nextspace-uat.net/file/2885d8df-028b-4f5c-80b3-2634f7e7cf69.png"
|
|
10017
|
+
}
|
|
10018
|
+
];
|
|
10019
|
+
/**
|
|
10020
|
+
* Available terrain defaults.
|
|
9864
10021
|
*/
|
|
9865
|
-
|
|
9866
|
-
|
|
9867
|
-
|
|
9868
|
-
|
|
9869
|
-
|
|
9870
|
-
|
|
9871
|
-
|
|
9872
|
-
|
|
9873
|
-
|
|
9874
|
-
|
|
9875
|
-
|
|
9876
|
-
|
|
9877
|
-
|
|
9878
|
-
|
|
9879
|
-
|
|
9880
|
-
|
|
9881
|
-
|
|
9882
|
-
|
|
9883
|
-
|
|
9884
|
-
|
|
9885
|
-
|
|
9886
|
-
|
|
9887
|
-
|
|
9888
|
-
|
|
9889
|
-
return {
|
|
9890
|
-
id: exports.ObjectUtils.UId(),
|
|
9891
|
-
Type: EType.PointCloud,
|
|
9892
|
-
Caption: "Generated Point Cloud Menu Item",
|
|
9893
|
-
FlyTo: false,
|
|
9894
|
-
tileset: {
|
|
9895
|
-
TilesetID: tilesetId
|
|
9896
|
-
}
|
|
9897
|
-
};
|
|
9898
|
-
}
|
|
9899
|
-
else if (type == exports.Tileset.EType.EntitiesMap) {
|
|
9900
|
-
return {
|
|
9901
|
-
id: exports.ObjectUtils.UId(),
|
|
9902
|
-
Type: EType.EntityRaster,
|
|
9903
|
-
Caption: "Generated Entities Menu Item",
|
|
9904
|
-
tileset: {
|
|
9905
|
-
TilesetID: tilesetId
|
|
9906
|
-
}
|
|
9907
|
-
};
|
|
10022
|
+
let EDefaultTerrain;
|
|
10023
|
+
(function (EDefaultTerrain) {
|
|
10024
|
+
EDefaultTerrain["CesiumWorldTerrain"] = "cesiumworldterrain";
|
|
10025
|
+
EDefaultTerrain["FlatTerrain"] = "flatterrain";
|
|
10026
|
+
EDefaultTerrain["LINZ"] = "linz";
|
|
10027
|
+
})(EDefaultTerrain = ProjectViewTile.EDefaultTerrain || (ProjectViewTile.EDefaultTerrain = {}));
|
|
10028
|
+
/**
|
|
10029
|
+
* Prepared array for UI.
|
|
10030
|
+
* TODO: Im not happy with icon urls sitting in the code. I'd prefer we ship these icons in the library as files.
|
|
10031
|
+
*/
|
|
10032
|
+
ProjectViewTile.DefaultTerrains = [
|
|
10033
|
+
{
|
|
10034
|
+
id: EDefaultTerrain.CesiumWorldTerrain,
|
|
10035
|
+
name: "Cesium World Terrain",
|
|
10036
|
+
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/TerrainProviders/CesiumWorldTerrain.png"
|
|
10037
|
+
},
|
|
10038
|
+
{
|
|
10039
|
+
id: EDefaultTerrain.LINZ,
|
|
10040
|
+
name: "LINZ",
|
|
10041
|
+
iconUrl: "https://template.ui.nextspace.host/media/linz.jpg"
|
|
10042
|
+
},
|
|
10043
|
+
{
|
|
10044
|
+
id: EDefaultTerrain.FlatTerrain,
|
|
10045
|
+
name: "Flat Terrain",
|
|
9908
10046
|
}
|
|
9909
|
-
|
|
9910
|
-
|
|
9911
|
-
MenuItem.CreateFromTilesetId = CreateFromTilesetId;
|
|
9912
|
-
})(exports.MenuItem || (exports.MenuItem = {}));
|
|
10047
|
+
];
|
|
10048
|
+
})(exports.ProjectViewTile || (exports.ProjectViewTile = {}));
|
|
9913
10049
|
|
|
9914
|
-
|
|
9915
|
-
|
|
9916
|
-
|
|
9917
|
-
|
|
10050
|
+
/**
|
|
10051
|
+
* Deprecated Project View record.
|
|
10052
|
+
* This was used in the legacy web Navigator.
|
|
10053
|
+
*/
|
|
10054
|
+
(function (ProjectViewLegacy) {
|
|
10055
|
+
ProjectViewLegacy.DATA_VERSION = 1;
|
|
10056
|
+
})(exports.ProjectViewLegacy || (exports.ProjectViewLegacy = {}));
|
|
10057
|
+
|
|
10058
|
+
/**
|
|
10059
|
+
* Deprecated Project View Bookmark record.
|
|
10060
|
+
* This was used in the legacy web Navigator.
|
|
10061
|
+
*/
|
|
10062
|
+
(function (ProjectViewLegacyBookmark) {
|
|
10063
|
+
ProjectViewLegacyBookmark.DATA_VERSION = 1;
|
|
10064
|
+
})(exports.ProjectViewLegacyBookmark || (exports.ProjectViewLegacyBookmark = {}));
|
|
10065
|
+
|
|
10066
|
+
(function (PendingAction) {
|
|
9918
10067
|
/**
|
|
9919
|
-
*
|
|
9920
|
-
* As part of a deal we've been commissioned to create an alternative bookmark type to embed content.
|
|
10068
|
+
* Available pending action statuses.
|
|
9921
10069
|
*/
|
|
9922
|
-
let
|
|
9923
|
-
(function (
|
|
9924
|
-
|
|
9925
|
-
|
|
9926
|
-
|
|
10070
|
+
let EStatus;
|
|
10071
|
+
(function (EStatus) {
|
|
10072
|
+
EStatus["InProgress"] = "IN_PROGRESS";
|
|
10073
|
+
EStatus["Cancelled"] = "CANCELLED";
|
|
10074
|
+
EStatus["Complete"] = "COMPLETE";
|
|
10075
|
+
EStatus["Failed"] = "FAILED";
|
|
10076
|
+
})(EStatus = PendingAction.EStatus || (PendingAction.EStatus = {}));
|
|
9927
10077
|
/**
|
|
9928
|
-
*
|
|
10078
|
+
* Available message types.
|
|
10079
|
+
*/
|
|
10080
|
+
let EMessageType;
|
|
10081
|
+
(function (EMessageType) {
|
|
10082
|
+
EMessageType["Warn"] = "WARNING";
|
|
10083
|
+
EMessageType["Error"] = "ERROR";
|
|
10084
|
+
EMessageType["Status"] = "STATUS";
|
|
10085
|
+
EMessageType["Info"] = "INFO";
|
|
10086
|
+
})(EMessageType = PendingAction.EMessageType || (PendingAction.EMessageType = {}));
|
|
10087
|
+
/**
|
|
10088
|
+
* Returns a pending action record.
|
|
9929
10089
|
* @param params
|
|
9930
10090
|
* @returns
|
|
9931
10091
|
*/
|
|
9932
10092
|
function Get(params) {
|
|
9933
10093
|
return __awaiter(this, void 0, void 0, function* () {
|
|
9934
|
-
let { api,
|
|
9935
|
-
if (!
|
|
9936
|
-
throw ("
|
|
10094
|
+
let { api, actionId, req: reqParams } = params;
|
|
10095
|
+
if (!actionId) {
|
|
10096
|
+
throw ("Action ID is required.");
|
|
9937
10097
|
}
|
|
9938
10098
|
if (!api) {
|
|
9939
10099
|
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
9940
10100
|
}
|
|
9941
|
-
const
|
|
9942
|
-
|
|
9943
|
-
|
|
9944
|
-
|
|
9945
|
-
}
|
|
9946
|
-
const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
9947
|
-
try {
|
|
9948
|
-
const data = yield api.GET(`ui.view/${viewId}/slide/${bookmarkId}`, exports.Api.PrepReqParams(reqParams));
|
|
9949
|
-
res({
|
|
9950
|
-
bookmark: data
|
|
9951
|
-
});
|
|
9952
|
-
}
|
|
9953
|
-
catch (e) {
|
|
9954
|
-
rej(e);
|
|
9955
|
-
}
|
|
9956
|
-
}));
|
|
9957
|
-
yield api.SetCacheItem({
|
|
9958
|
-
key,
|
|
9959
|
-
value: prom,
|
|
9960
|
-
req: reqParams
|
|
9961
|
-
});
|
|
9962
|
-
return prom;
|
|
10101
|
+
const data = yield api.GET(`pendingAction/${actionId}`, exports.Api.PrepReqParams(reqParams));
|
|
10102
|
+
return {
|
|
10103
|
+
action: data
|
|
10104
|
+
};
|
|
9963
10105
|
});
|
|
9964
10106
|
}
|
|
9965
|
-
|
|
10107
|
+
PendingAction.Get = Get;
|
|
9966
10108
|
/**
|
|
9967
|
-
*
|
|
10109
|
+
* Returns a list of pending action records.
|
|
9968
10110
|
* @param params
|
|
10111
|
+
* @returns
|
|
9969
10112
|
*/
|
|
9970
|
-
function
|
|
10113
|
+
function GetRelevantList(params) {
|
|
9971
10114
|
return __awaiter(this, void 0, void 0, function* () {
|
|
9972
|
-
let { api,
|
|
9973
|
-
if (!viewId || !bookmarkId) {
|
|
9974
|
-
throw ("View ID and Bookmark ID are required.");
|
|
9975
|
-
}
|
|
10115
|
+
let { api, stricter, reqParams } = params;
|
|
9976
10116
|
if (!api) {
|
|
9977
10117
|
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
9978
10118
|
}
|
|
9979
|
-
yield api.
|
|
9980
|
-
|
|
9981
|
-
|
|
10119
|
+
const data = yield api.GET(`pendingActions/important?Update=${Boolean(stricter)}`, exports.Api.PrepReqParams(reqParams));
|
|
10120
|
+
return {
|
|
10121
|
+
actions: data.Items
|
|
10122
|
+
};
|
|
9982
10123
|
});
|
|
9983
10124
|
}
|
|
9984
|
-
|
|
10125
|
+
PendingAction.GetRelevantList = GetRelevantList;
|
|
9985
10126
|
/**
|
|
9986
|
-
*
|
|
10127
|
+
* Returns a list of pending action record messages.
|
|
9987
10128
|
* @param params
|
|
9988
10129
|
* @returns
|
|
9989
10130
|
*/
|
|
9990
|
-
function
|
|
10131
|
+
function GetMessages(params) {
|
|
9991
10132
|
return __awaiter(this, void 0, void 0, function* () {
|
|
9992
|
-
let { api,
|
|
9993
|
-
if (!viewId) {
|
|
9994
|
-
throw ("View ID is required.");
|
|
9995
|
-
}
|
|
10133
|
+
let { api, actionId, order, startIndex, amount, req: reqParams, types } = params;
|
|
9996
10134
|
if (!api) {
|
|
9997
10135
|
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
9998
10136
|
}
|
|
9999
|
-
|
|
10000
|
-
|
|
10001
|
-
return cache.data;
|
|
10137
|
+
if (amount == null) {
|
|
10138
|
+
amount = 500;
|
|
10002
10139
|
}
|
|
10003
|
-
|
|
10004
|
-
|
|
10005
|
-
|
|
10006
|
-
|
|
10007
|
-
|
|
10008
|
-
// Maybe better to load list cache when getting 1 slide and seeing if it's in there.
|
|
10009
|
-
// WARNING: Right now the data matches, in the future the list may contain a shortened result.
|
|
10010
|
-
for (let i = 0; i < items.length; i++) {
|
|
10011
|
-
const item = items[i];
|
|
10012
|
-
const prom = new Promise((res) => {
|
|
10013
|
-
res({
|
|
10014
|
-
bookmark: item
|
|
10015
|
-
});
|
|
10016
|
-
});
|
|
10017
|
-
yield api.SetCacheItem({
|
|
10018
|
-
key: GetCacheKey(viewId, item.ID),
|
|
10019
|
-
value: prom,
|
|
10020
|
-
req: reqParams
|
|
10021
|
-
});
|
|
10022
|
-
}
|
|
10023
|
-
res({
|
|
10024
|
-
bookmarks: items
|
|
10025
|
-
});
|
|
10026
|
-
}
|
|
10027
|
-
catch (e) {
|
|
10028
|
-
rej(e);
|
|
10029
|
-
}
|
|
10030
|
-
}));
|
|
10031
|
-
yield api.SetCacheItem({
|
|
10032
|
-
key: GetListCacheKey(viewId),
|
|
10033
|
-
value: req,
|
|
10034
|
-
req: reqParams
|
|
10035
|
-
});
|
|
10036
|
-
return req;
|
|
10037
|
-
});
|
|
10038
|
-
}
|
|
10039
|
-
ProjectViewBookmark.GetList = GetList;
|
|
10040
|
-
/**
|
|
10041
|
-
* Creates or updates a bookmark record.
|
|
10042
|
-
* @param params
|
|
10043
|
-
* @returns
|
|
10044
|
-
*/
|
|
10045
|
-
function Update(params) {
|
|
10046
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
10047
|
-
let { api, viewId, bookmark: data, req: reqParams } = params;
|
|
10048
|
-
if (!api) {
|
|
10049
|
-
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
10140
|
+
if (startIndex == null) {
|
|
10141
|
+
startIndex = 0;
|
|
10142
|
+
}
|
|
10143
|
+
if (order == null) {
|
|
10144
|
+
order = exports.Api.ESortOrder.Asc;
|
|
10050
10145
|
}
|
|
10051
|
-
|
|
10052
|
-
|
|
10146
|
+
let args = `?SortOrder=${order == exports.Api.ESortOrder.Desc ? "DESC" : "ASC"}&PageSize=${amount}&PageIndex=${startIndex}`;
|
|
10147
|
+
if (types === null || types === void 0 ? void 0 : types.length) {
|
|
10148
|
+
for (let i = 0; i < types.length; i++) {
|
|
10149
|
+
args += `&Type=${types[i]}`;
|
|
10150
|
+
}
|
|
10053
10151
|
}
|
|
10054
|
-
const
|
|
10055
|
-
api.Cache.Remove(GetCacheKey(viewId, data.ID));
|
|
10056
|
-
api.Cache.Remove(GetListCacheKey(viewId));
|
|
10152
|
+
const data = yield api.GET(`pendingAction/${actionId}/progressMessages` + args, exports.Api.PrepReqParams(reqParams));
|
|
10057
10153
|
return {
|
|
10058
|
-
|
|
10154
|
+
messages: data.Items
|
|
10059
10155
|
};
|
|
10060
10156
|
});
|
|
10061
10157
|
}
|
|
10062
|
-
|
|
10158
|
+
PendingAction.GetMessages = GetMessages;
|
|
10063
10159
|
/**
|
|
10064
|
-
*
|
|
10160
|
+
* Requests to cancel a pending action.
|
|
10065
10161
|
* @param params
|
|
10066
10162
|
*/
|
|
10067
|
-
function
|
|
10163
|
+
function Cancel(params) {
|
|
10068
10164
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10069
|
-
let { api,
|
|
10165
|
+
let { api, actionId, req: reqParams } = params;
|
|
10166
|
+
if (!actionId) {
|
|
10167
|
+
throw ("Action ID is required.");
|
|
10168
|
+
}
|
|
10070
10169
|
if (!api) {
|
|
10071
10170
|
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
10072
10171
|
}
|
|
10073
|
-
|
|
10074
|
-
"UISlide.ID": bookmarkIds,
|
|
10075
|
-
"DisplayOrder.Start": 0
|
|
10076
|
-
};
|
|
10077
|
-
yield api.POST(`ui.view/${viewId}/slides/setOrder`, reqData, exports.Api.PrepReqParams(reqParams));
|
|
10078
|
-
yield api.Cache.RemoveByStartsWith(GetListCacheKey(viewId));
|
|
10172
|
+
yield api.DELETE(`pendingAction/${actionId}`, exports.Api.PrepReqParams(reqParams));
|
|
10079
10173
|
});
|
|
10080
10174
|
}
|
|
10081
|
-
|
|
10175
|
+
PendingAction.Cancel = Cancel;
|
|
10176
|
+
})(exports.PendingAction || (exports.PendingAction = {}));
|
|
10177
|
+
|
|
10178
|
+
// Some dead accounts that we don't want to show in the UI.
|
|
10179
|
+
// Some accounts may not be "dead" but instead purposely don't have a NextspaceAPI database so we'll avoid them too.
|
|
10180
|
+
const ACCOUNT_EXCLUSIONS = ["hyperportal", "hypeportal", "bviewer"];
|
|
10181
|
+
(function (Account) {
|
|
10082
10182
|
/**
|
|
10083
|
-
*
|
|
10084
|
-
* Example: {
|
|
10085
|
-
* const api: BruceApi.Api = ...;
|
|
10086
|
-
* const key = GetCacheKey("abc", "def");
|
|
10087
|
-
* api.Cache.Remove(key);
|
|
10088
|
-
* }
|
|
10089
|
-
* @param viewId
|
|
10090
|
-
* @param bookmarkId
|
|
10091
|
-
* @returns
|
|
10183
|
+
* Known Nextspace applications we store settings for.
|
|
10092
10184
|
*/
|
|
10093
|
-
|
|
10094
|
-
|
|
10095
|
-
|
|
10096
|
-
|
|
10185
|
+
let EAppId;
|
|
10186
|
+
(function (EAppId) {
|
|
10187
|
+
EAppId["BruceApi"] = "BruceAPI";
|
|
10188
|
+
EAppId["Navigator"] = "Navigator";
|
|
10189
|
+
EAppId["Operator"] = "BruceClientAdmin";
|
|
10190
|
+
})(EAppId = Account.EAppId || (Account.EAppId = {}));
|
|
10097
10191
|
/**
|
|
10098
|
-
*
|
|
10099
|
-
*
|
|
10100
|
-
* const api: BruceApi.Api = ...;
|
|
10101
|
-
* const key = GetListCacheKey("abc");
|
|
10102
|
-
* api.Cache.Remove(key);
|
|
10103
|
-
* }
|
|
10104
|
-
* @param viewId
|
|
10105
|
-
* @returns
|
|
10192
|
+
* Possible starter content options.
|
|
10193
|
+
* When creating a new account you can populate it with certain default data.
|
|
10106
10194
|
*/
|
|
10107
|
-
|
|
10108
|
-
|
|
10109
|
-
|
|
10110
|
-
|
|
10111
|
-
|
|
10112
|
-
|
|
10113
|
-
(function (ProjectView) {
|
|
10114
|
-
// This is the expected default version for the DataVersion value.
|
|
10115
|
-
// This value should NOT be changed without looking at our API and seeing what the default value is.
|
|
10116
|
-
ProjectView.DEFAULT_DATA_VERSION = 2;
|
|
10117
|
-
// Our Cesium web navigator.
|
|
10118
|
-
ProjectView.TYPE_WEB_3D_NAVIGATOR = "WEB_3D_NAVIGATOR";
|
|
10119
|
-
// Our (currently WIP) 2D web navigator. Also known as our graph viewer.
|
|
10120
|
-
ProjectView.TYPE_WEB_2D_NAVIGATOR = "WEB_2D_NAVIGATOR";
|
|
10121
|
-
// Defaulting to 3D navigator for backwards compatibility.
|
|
10122
|
-
ProjectView.DEFAULT_TYPE = ProjectView.TYPE_WEB_3D_NAVIGATOR;
|
|
10195
|
+
let EStarterContent;
|
|
10196
|
+
(function (EStarterContent) {
|
|
10197
|
+
EStarterContent["Default"] = "default";
|
|
10198
|
+
EStarterContent["None"] = "none";
|
|
10199
|
+
})(EStarterContent = Account.EStarterContent || (Account.EStarterContent = {}));
|
|
10123
10200
|
/**
|
|
10124
|
-
* Gets a
|
|
10201
|
+
* Gets a client account record by ID.
|
|
10125
10202
|
* @param params
|
|
10126
10203
|
* @returns
|
|
10127
10204
|
*/
|
|
10128
10205
|
function Get(params) {
|
|
10129
10206
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10130
|
-
let { api,
|
|
10131
|
-
if (!viewId) {
|
|
10132
|
-
throw ("View ID is required.");
|
|
10133
|
-
}
|
|
10207
|
+
let { api, accountId: id, req: reqParams } = params;
|
|
10134
10208
|
if (!api) {
|
|
10135
|
-
api = exports.ENVIRONMENT.Api().
|
|
10209
|
+
api = exports.ENVIRONMENT.Api().GetGuardianApi();
|
|
10136
10210
|
}
|
|
10137
|
-
const
|
|
10138
|
-
const cache = yield api.GetCacheItem(key, reqParams);
|
|
10211
|
+
const cache = yield api.GetCacheItem(GetCacheKey(id), reqParams);
|
|
10139
10212
|
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
10140
10213
|
return cache.data;
|
|
10141
10214
|
}
|
|
10142
10215
|
const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
10143
10216
|
try {
|
|
10144
|
-
const data = yield api.GET(`
|
|
10217
|
+
const data = yield api.GET(`accountbyid/${id}`, reqParams);
|
|
10218
|
+
// Update the cache by subdomain as well in case it's different to the ID.
|
|
10219
|
+
if ((data === null || data === void 0 ? void 0 : data.ID) && (reqParams === null || reqParams === void 0 ? void 0 : reqParams.noCache) != false) {
|
|
10220
|
+
yield api.SetCacheItem({
|
|
10221
|
+
key: data.Subdomain,
|
|
10222
|
+
value: prom,
|
|
10223
|
+
req: reqParams
|
|
10224
|
+
});
|
|
10225
|
+
}
|
|
10145
10226
|
res({
|
|
10146
|
-
|
|
10227
|
+
account: data
|
|
10147
10228
|
});
|
|
10148
10229
|
}
|
|
10149
10230
|
catch (e) {
|
|
@@ -10151,34 +10232,42 @@
|
|
|
10151
10232
|
}
|
|
10152
10233
|
}));
|
|
10153
10234
|
yield api.SetCacheItem({
|
|
10154
|
-
key,
|
|
10235
|
+
key: GetCacheKey(id),
|
|
10155
10236
|
value: prom,
|
|
10156
10237
|
req: reqParams
|
|
10157
10238
|
});
|
|
10158
10239
|
return prom;
|
|
10159
10240
|
});
|
|
10160
10241
|
}
|
|
10161
|
-
|
|
10242
|
+
Account.Get = Get;
|
|
10162
10243
|
/**
|
|
10163
|
-
*
|
|
10244
|
+
* Returns a client account record by subdomain or ID.
|
|
10164
10245
|
* @param params
|
|
10165
10246
|
* @returns
|
|
10166
10247
|
*/
|
|
10167
|
-
function
|
|
10248
|
+
function GetBySubdomain(params) {
|
|
10168
10249
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10169
|
-
let { api, req: reqParams
|
|
10250
|
+
let { api, subdomain, req: reqParams } = params;
|
|
10170
10251
|
if (!api) {
|
|
10171
|
-
api = exports.ENVIRONMENT.Api().
|
|
10252
|
+
api = exports.ENVIRONMENT.Api().GetGuardianApi();
|
|
10172
10253
|
}
|
|
10173
|
-
const cache = yield api.GetCacheItem(
|
|
10254
|
+
const cache = yield api.GetCacheItem(GetCacheKey(subdomain), reqParams);
|
|
10174
10255
|
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
10175
10256
|
return cache.data;
|
|
10176
10257
|
}
|
|
10177
10258
|
const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
10178
10259
|
try {
|
|
10179
|
-
const data = yield api.GET(
|
|
10260
|
+
const data = yield api.GET(`account/${subdomain}`, reqParams);
|
|
10261
|
+
// Update the cache by ID as well in case it's different to the subdomain.
|
|
10262
|
+
if ((data === null || data === void 0 ? void 0 : data.ID) && (reqParams === null || reqParams === void 0 ? void 0 : reqParams.noCache) != false) {
|
|
10263
|
+
yield api.SetCacheItem({
|
|
10264
|
+
key: data.ID,
|
|
10265
|
+
value: prom,
|
|
10266
|
+
req: reqParams
|
|
10267
|
+
});
|
|
10268
|
+
}
|
|
10180
10269
|
res({
|
|
10181
|
-
|
|
10270
|
+
account: data
|
|
10182
10271
|
});
|
|
10183
10272
|
}
|
|
10184
10273
|
catch (e) {
|
|
@@ -10186,443 +10275,377 @@
|
|
|
10186
10275
|
}
|
|
10187
10276
|
}));
|
|
10188
10277
|
yield api.SetCacheItem({
|
|
10189
|
-
key:
|
|
10278
|
+
key: GetCacheKey(subdomain),
|
|
10190
10279
|
value: prom,
|
|
10191
10280
|
req: reqParams
|
|
10192
10281
|
});
|
|
10193
10282
|
return prom;
|
|
10194
10283
|
});
|
|
10195
10284
|
}
|
|
10196
|
-
|
|
10285
|
+
Account.GetBySubdomain = GetBySubdomain;
|
|
10197
10286
|
/**
|
|
10198
|
-
*
|
|
10287
|
+
* Gets a list of client accounts related to the current session user.
|
|
10199
10288
|
* @param params
|
|
10289
|
+
* @returns
|
|
10200
10290
|
*/
|
|
10201
|
-
function
|
|
10291
|
+
function GetRelatedList(params) {
|
|
10202
10292
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10203
|
-
let { api,
|
|
10204
|
-
if (!viewId) {
|
|
10205
|
-
throw ("View ID is required.");
|
|
10206
|
-
}
|
|
10293
|
+
let { api, req: reqParams } = params;
|
|
10207
10294
|
if (!api) {
|
|
10208
|
-
api = exports.ENVIRONMENT.Api().
|
|
10295
|
+
api = exports.ENVIRONMENT.Api().GetGuardianApi();
|
|
10209
10296
|
}
|
|
10210
|
-
yield api.
|
|
10211
|
-
|
|
10212
|
-
|
|
10297
|
+
const cache = yield api.GetCacheItem(GetListCacheKey(api.GetSessionId()), reqParams);
|
|
10298
|
+
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
10299
|
+
return cache.data;
|
|
10300
|
+
}
|
|
10301
|
+
const req = api.GET("user/relatedClientAccounts", reqParams);
|
|
10302
|
+
const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
10303
|
+
try {
|
|
10304
|
+
const data = yield req;
|
|
10305
|
+
const items = data.Items.filter((x) => !ACCOUNT_EXCLUSIONS.includes(x.ID));
|
|
10306
|
+
res({
|
|
10307
|
+
accounts: items
|
|
10308
|
+
});
|
|
10309
|
+
}
|
|
10310
|
+
catch (e) {
|
|
10311
|
+
rej(e);
|
|
10312
|
+
}
|
|
10313
|
+
}));
|
|
10314
|
+
yield api.SetCacheItem({
|
|
10315
|
+
key: GetListCacheKey(api.GetSessionId()),
|
|
10316
|
+
value: prom,
|
|
10317
|
+
req: reqParams
|
|
10318
|
+
});
|
|
10319
|
+
return prom;
|
|
10213
10320
|
});
|
|
10214
10321
|
}
|
|
10215
|
-
|
|
10322
|
+
Account.GetRelatedList = GetRelatedList;
|
|
10216
10323
|
/**
|
|
10217
|
-
*
|
|
10324
|
+
* Gets application settings for a specific client account.
|
|
10218
10325
|
* @param params
|
|
10219
10326
|
* @returns
|
|
10220
10327
|
*/
|
|
10221
|
-
function
|
|
10328
|
+
function GetAppSettings(params) {
|
|
10222
10329
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10223
|
-
let { api,
|
|
10330
|
+
let { api, accountId: id, appId, req: reqParams } = params;
|
|
10224
10331
|
if (!api) {
|
|
10225
|
-
api = exports.ENVIRONMENT.Api().
|
|
10226
|
-
}
|
|
10227
|
-
if (!data) {
|
|
10228
|
-
data = {};
|
|
10229
|
-
}
|
|
10230
|
-
const isNew = !data.ID;
|
|
10231
|
-
if (!data.ID) {
|
|
10232
|
-
// Short ID to keep the URL short.
|
|
10233
|
-
// 8 length = 4,294,967,296 combinations.
|
|
10234
|
-
data.ID = exports.ObjectUtils.UId(8);
|
|
10235
|
-
}
|
|
10236
|
-
if (!data.Name) {
|
|
10237
|
-
data.Name = data.ID;
|
|
10238
|
-
}
|
|
10239
|
-
if (!data.CreatedByUIVersion) {
|
|
10240
|
-
data.CreatedByUIVersion = "-1";
|
|
10241
|
-
}
|
|
10242
|
-
if (isNew) {
|
|
10243
|
-
data = yield api.POST(`ui.view/${data.ID}`, data, exports.Api.PrepReqParams(reqParams));
|
|
10332
|
+
api = exports.ENVIRONMENT.Api().GetGuardianApi();
|
|
10244
10333
|
}
|
|
10245
|
-
|
|
10246
|
-
|
|
10334
|
+
const cache = yield api.GetCacheItem(GetCacheKey(id, appId), reqParams);
|
|
10335
|
+
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
10336
|
+
return cache.data;
|
|
10247
10337
|
}
|
|
10248
|
-
api.
|
|
10249
|
-
|
|
10250
|
-
|
|
10251
|
-
|
|
10252
|
-
|
|
10338
|
+
const req = yield api.GET(`account/${id}?ApplicationID=${appId}`, reqParams);
|
|
10339
|
+
const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
10340
|
+
var _a;
|
|
10341
|
+
try {
|
|
10342
|
+
const data = yield req;
|
|
10343
|
+
const settings = (_a = data === null || data === void 0 ? void 0 : data["Application.Settings"]) !== null && _a !== void 0 ? _a : {};
|
|
10344
|
+
res({
|
|
10345
|
+
settings: settings
|
|
10346
|
+
});
|
|
10347
|
+
}
|
|
10348
|
+
catch (e) {
|
|
10349
|
+
rej(e);
|
|
10350
|
+
}
|
|
10351
|
+
}));
|
|
10352
|
+
yield api.SetCacheItem({
|
|
10353
|
+
key: GetCacheKey(id, appId),
|
|
10354
|
+
value: prom,
|
|
10355
|
+
req: reqParams
|
|
10356
|
+
});
|
|
10357
|
+
return prom;
|
|
10253
10358
|
});
|
|
10254
10359
|
}
|
|
10255
|
-
|
|
10256
|
-
/**
|
|
10257
|
-
* Returns cache identifier for a project view.
|
|
10258
|
-
* Example: {
|
|
10259
|
-
* const api: BruceApi.Api = ...;
|
|
10260
|
-
* const key = GetCacheKey("abc");
|
|
10261
|
-
* api.Cache.Remove(key);
|
|
10262
|
-
* }
|
|
10263
|
-
* @param viewId
|
|
10264
|
-
* @returns
|
|
10265
|
-
*/
|
|
10266
|
-
function GetCacheKey(viewId) {
|
|
10267
|
-
return `${exports.Api.ECacheKey.ProjectView}${exports.Api.ECacheKey.Id}${viewId}`;
|
|
10268
|
-
}
|
|
10269
|
-
ProjectView.GetCacheKey = GetCacheKey;
|
|
10360
|
+
Account.GetAppSettings = GetAppSettings;
|
|
10270
10361
|
/**
|
|
10271
|
-
*
|
|
10272
|
-
*
|
|
10273
|
-
*
|
|
10274
|
-
* const key = GetListCacheKey();
|
|
10275
|
-
* api.Cache.Remove(key);
|
|
10276
|
-
* }
|
|
10277
|
-
* @param type optional filter for the type of project view.
|
|
10362
|
+
* Updates application settings for a specific client account + application.
|
|
10363
|
+
* WARNING: Do not update API settings without knowing what you're doing.
|
|
10364
|
+
* @param params
|
|
10278
10365
|
* @returns
|
|
10279
10366
|
*/
|
|
10280
|
-
function
|
|
10281
|
-
if (type) {
|
|
10282
|
-
return `${exports.Api.ECacheKey.ProjectView}${exports.Api.ECacheKey.ListId}${type}`;
|
|
10283
|
-
}
|
|
10284
|
-
return `${exports.Api.ECacheKey.ProjectView}${exports.Api.ECacheKey.ListId}`;
|
|
10285
|
-
}
|
|
10286
|
-
ProjectView.GetListCacheKey = GetListCacheKey;
|
|
10287
|
-
})(exports.ProjectView || (exports.ProjectView = {}));
|
|
10288
|
-
|
|
10289
|
-
function getTemplateSettings(apiGetter, reqParams) {
|
|
10290
|
-
var _a;
|
|
10291
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
10292
|
-
const { view } = yield exports.ProjectView.Get({
|
|
10293
|
-
api: apiGetter.getApi(exports.Api.TEMPLATE_ACCOUNT_ID),
|
|
10294
|
-
viewId: "default",
|
|
10295
|
-
req: reqParams
|
|
10296
|
-
});
|
|
10297
|
-
return (_a = view.Settings) !== null && _a !== void 0 ? _a : {};
|
|
10298
|
-
});
|
|
10299
|
-
}
|
|
10300
|
-
function checkSourceToTemplate(items, templateItem, addIfMissing) {
|
|
10301
|
-
const index = items.findIndex(x => x.Name === templateItem.Name);
|
|
10302
|
-
if (index > -1) {
|
|
10303
|
-
templateItem.IsDefault = true;
|
|
10304
|
-
templateItem.IsEnabled = items[index].IsEnabled;
|
|
10305
|
-
items[index] = templateItem;
|
|
10306
|
-
}
|
|
10307
|
-
else if (addIfMissing) {
|
|
10308
|
-
templateItem.IsDefault = true;
|
|
10309
|
-
items.push(templateItem);
|
|
10310
|
-
}
|
|
10311
|
-
}
|
|
10312
|
-
(function (ProjectViewLegacyTile) {
|
|
10313
|
-
function MergeMapTemplateData(params) {
|
|
10314
|
-
var _a;
|
|
10367
|
+
function UpdateAppSettings(params) {
|
|
10315
10368
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10316
|
-
let {
|
|
10317
|
-
if (!
|
|
10318
|
-
|
|
10319
|
-
}
|
|
10320
|
-
const settings = yield getTemplateSettings(getter, reqParams);
|
|
10321
|
-
const maps = (_a = settings.CesiumMapSources) !== null && _a !== void 0 ? _a : [];
|
|
10322
|
-
for (let i = 0; i < maps.length; i++) {
|
|
10323
|
-
const mapSource = maps[i];
|
|
10324
|
-
checkSourceToTemplate(items, mapSource, addIfMissing);
|
|
10369
|
+
let { api, accountId: id, appId, settings: data, req: reqParams } = params;
|
|
10370
|
+
if (!api) {
|
|
10371
|
+
api = exports.ENVIRONMENT.Api().GetGuardianApi();
|
|
10325
10372
|
}
|
|
10373
|
+
const res = yield api.POST(`account/${id}/applicationSettings/${appId}`, data, reqParams);
|
|
10374
|
+
yield api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + id);
|
|
10326
10375
|
return {
|
|
10327
|
-
|
|
10376
|
+
settings: res
|
|
10328
10377
|
};
|
|
10329
10378
|
});
|
|
10330
10379
|
}
|
|
10331
|
-
|
|
10332
|
-
|
|
10333
|
-
|
|
10380
|
+
Account.UpdateAppSettings = UpdateAppSettings;
|
|
10381
|
+
/**
|
|
10382
|
+
* Creates a new Nextspace account using given details.
|
|
10383
|
+
* @param params
|
|
10384
|
+
* @returns
|
|
10385
|
+
*/
|
|
10386
|
+
function Create(params) {
|
|
10334
10387
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10335
|
-
let {
|
|
10336
|
-
if (!
|
|
10337
|
-
|
|
10388
|
+
let { api, accountId: id, name, hostingLocationKey, starterContent, req: reqParams } = params;
|
|
10389
|
+
if (!id || !name || !hostingLocationKey) {
|
|
10390
|
+
throw new Error("Id, Name and hostingLocationKey are required.");
|
|
10338
10391
|
}
|
|
10339
|
-
|
|
10340
|
-
|
|
10341
|
-
for (let i = 0; i < terrains.length; i++) {
|
|
10342
|
-
const terrainSource = terrains[i];
|
|
10343
|
-
checkSourceToTemplate(items, terrainSource, addIfMissing);
|
|
10392
|
+
if (!api) {
|
|
10393
|
+
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
10344
10394
|
}
|
|
10345
|
-
|
|
10346
|
-
|
|
10395
|
+
if (!starterContent) {
|
|
10396
|
+
starterContent = EStarterContent.None;
|
|
10397
|
+
}
|
|
10398
|
+
const reqData = {
|
|
10399
|
+
"Name": name,
|
|
10400
|
+
"HostingLocation.Key": hostingLocationKey,
|
|
10401
|
+
"StarterContent": starterContent
|
|
10347
10402
|
};
|
|
10403
|
+
const res = yield api.POST(`clientAccount/${id}`, reqData, exports.Api.PrepReqParams(reqParams));
|
|
10404
|
+
const resData = {
|
|
10405
|
+
account: res
|
|
10406
|
+
};
|
|
10407
|
+
api.Cache.Remove(GetListCacheKey(api.GetSessionId()));
|
|
10408
|
+
return resData;
|
|
10348
10409
|
});
|
|
10349
10410
|
}
|
|
10350
|
-
|
|
10351
|
-
})(exports.ProjectViewLegacyTile || (exports.ProjectViewLegacyTile = {}));
|
|
10352
|
-
|
|
10353
|
-
/**
|
|
10354
|
-
* A tile is an imagery or terrain tileset definition.
|
|
10355
|
-
*/
|
|
10356
|
-
(function (ProjectViewTile) {
|
|
10357
|
-
/**
|
|
10358
|
-
* Available imagery defaults.
|
|
10359
|
-
*/
|
|
10360
|
-
let EDefaultImagery;
|
|
10361
|
-
(function (EDefaultImagery) {
|
|
10362
|
-
EDefaultImagery["BingMapsAerial"] = "bingmapsaerial";
|
|
10363
|
-
EDefaultImagery["BingMapsAerialWithLabels"] = "bingmapsaerialwithlabels";
|
|
10364
|
-
EDefaultImagery["BingMapsRoads"] = "bingmapsroads";
|
|
10365
|
-
EDefaultImagery["MapboxSatellite"] = "mapboxsatellite";
|
|
10366
|
-
EDefaultImagery["MapBoxStreets"] = "mapboxstreets";
|
|
10367
|
-
EDefaultImagery["MapBoxStreetsClassic"] = "mapboxstreetsclassic";
|
|
10368
|
-
EDefaultImagery["EsriWorldImagery"] = "esriworldimagery";
|
|
10369
|
-
EDefaultImagery["EsriWorldStreetMap"] = "esriworldstreetmap";
|
|
10370
|
-
EDefaultImagery["EsriNationalGeographic"] = "esrinationalgeographic";
|
|
10371
|
-
EDefaultImagery["OpenStreetMap"] = "openstreetmap";
|
|
10372
|
-
EDefaultImagery["LINZ"] = "linz";
|
|
10373
|
-
EDefaultImagery["StamenWaterColor"] = "stamenwatercolor";
|
|
10374
|
-
EDefaultImagery["StamenToner"] = "stamentoner";
|
|
10375
|
-
EDefaultImagery["Grid"] = "grid";
|
|
10376
|
-
EDefaultImagery["ThunderforestCycle"] = "thunderforestcycle";
|
|
10377
|
-
EDefaultImagery["ThunderforestTransport"] = "thunderforesttransport";
|
|
10378
|
-
EDefaultImagery["ThunderforestLandscape"] = "thunderforestlandscape";
|
|
10379
|
-
})(EDefaultImagery = ProjectViewTile.EDefaultImagery || (ProjectViewTile.EDefaultImagery = {}));
|
|
10380
|
-
/**
|
|
10381
|
-
* Prepared array for UI.
|
|
10382
|
-
* TODO: Im not happy with icon urls sitting in the code. I'd prefer we ship these icons in the library as files.
|
|
10383
|
-
*/
|
|
10384
|
-
ProjectViewTile.DefaultImagery = [
|
|
10385
|
-
{
|
|
10386
|
-
id: EDefaultImagery.BingMapsAerial,
|
|
10387
|
-
name: "Bing Maps Aerial",
|
|
10388
|
-
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/bingAerial.png"
|
|
10389
|
-
},
|
|
10390
|
-
{
|
|
10391
|
-
id: EDefaultImagery.BingMapsAerialWithLabels,
|
|
10392
|
-
name: "Bing Maps Aerial with Labels",
|
|
10393
|
-
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/bingAerialLabels.png"
|
|
10394
|
-
},
|
|
10395
|
-
{
|
|
10396
|
-
id: EDefaultImagery.BingMapsRoads,
|
|
10397
|
-
name: "Bing Maps Roads",
|
|
10398
|
-
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/bingRoads.png"
|
|
10399
|
-
},
|
|
10400
|
-
{
|
|
10401
|
-
id: EDefaultImagery.MapboxSatellite,
|
|
10402
|
-
name: "Mapbox Satellite",
|
|
10403
|
-
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/mapboxSatellite.png"
|
|
10404
|
-
},
|
|
10405
|
-
{
|
|
10406
|
-
id: EDefaultImagery.MapBoxStreets,
|
|
10407
|
-
name: "Mapbox Streets",
|
|
10408
|
-
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/mapboxTerrain.png"
|
|
10409
|
-
},
|
|
10410
|
-
{
|
|
10411
|
-
id: EDefaultImagery.MapBoxStreetsClassic,
|
|
10412
|
-
name: "Mapbox Streets Classic",
|
|
10413
|
-
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/mapboxStreets.png"
|
|
10414
|
-
},
|
|
10415
|
-
{
|
|
10416
|
-
id: EDefaultImagery.EsriWorldImagery,
|
|
10417
|
-
name: "Esri World Imagery",
|
|
10418
|
-
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/esriWorldImagery.png"
|
|
10419
|
-
},
|
|
10420
|
-
{
|
|
10421
|
-
id: EDefaultImagery.EsriWorldStreetMap,
|
|
10422
|
-
name: "Esri World Street Map",
|
|
10423
|
-
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/esriWorldStreetMap.png"
|
|
10424
|
-
},
|
|
10425
|
-
{
|
|
10426
|
-
id: EDefaultImagery.EsriNationalGeographic,
|
|
10427
|
-
name: "Esri National Geographic",
|
|
10428
|
-
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/esriNationalGeographic.png"
|
|
10429
|
-
},
|
|
10430
|
-
{
|
|
10431
|
-
id: EDefaultImagery.OpenStreetMap,
|
|
10432
|
-
name: "Open Street Map",
|
|
10433
|
-
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/openStreetMap.png"
|
|
10434
|
-
},
|
|
10435
|
-
{
|
|
10436
|
-
id: EDefaultImagery.LINZ,
|
|
10437
|
-
name: "LINZ",
|
|
10438
|
-
iconUrl: "https://template.ui.nextspace.host/media/linz.jpg"
|
|
10439
|
-
},
|
|
10440
|
-
{
|
|
10441
|
-
id: EDefaultImagery.StamenWaterColor,
|
|
10442
|
-
name: "Stamen Water Color",
|
|
10443
|
-
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/stamenWatercolor.png"
|
|
10444
|
-
},
|
|
10445
|
-
{
|
|
10446
|
-
id: EDefaultImagery.StamenToner,
|
|
10447
|
-
name: "Stamen Toner",
|
|
10448
|
-
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/stamenToner.png"
|
|
10449
|
-
},
|
|
10450
|
-
{
|
|
10451
|
-
id: EDefaultImagery.ThunderforestCycle,
|
|
10452
|
-
name: "Thunderforest Cycle"
|
|
10453
|
-
},
|
|
10454
|
-
{
|
|
10455
|
-
id: EDefaultImagery.ThunderforestTransport,
|
|
10456
|
-
name: "Thunderforest Transport"
|
|
10457
|
-
},
|
|
10458
|
-
{
|
|
10459
|
-
id: EDefaultImagery.ThunderforestLandscape,
|
|
10460
|
-
name: "Thunderforest Landscape"
|
|
10461
|
-
},
|
|
10462
|
-
{
|
|
10463
|
-
id: EDefaultImagery.Grid,
|
|
10464
|
-
name: "Grid",
|
|
10465
|
-
iconUrl: "https://template.api.nextspace-uat.net/file/2885d8df-028b-4f5c-80b3-2634f7e7cf69.png"
|
|
10466
|
-
}
|
|
10467
|
-
];
|
|
10468
|
-
/**
|
|
10469
|
-
* Available terrain defaults.
|
|
10470
|
-
*/
|
|
10471
|
-
let EDefaultTerrain;
|
|
10472
|
-
(function (EDefaultTerrain) {
|
|
10473
|
-
EDefaultTerrain["CesiumWorldTerrain"] = "cesiumworldterrain";
|
|
10474
|
-
EDefaultTerrain["FlatTerrain"] = "flatterrain";
|
|
10475
|
-
EDefaultTerrain["LINZ"] = "linz";
|
|
10476
|
-
})(EDefaultTerrain = ProjectViewTile.EDefaultTerrain || (ProjectViewTile.EDefaultTerrain = {}));
|
|
10411
|
+
Account.Create = Create;
|
|
10477
10412
|
/**
|
|
10478
|
-
*
|
|
10479
|
-
*
|
|
10413
|
+
* Returns cache identifier for an account by ID.
|
|
10414
|
+
* Example: {
|
|
10415
|
+
* const api: BruceApi.Api = ...;
|
|
10416
|
+
* const key = GetCacheKey(1);
|
|
10417
|
+
* api.Cache.Remove(key);
|
|
10418
|
+
* }
|
|
10419
|
+
* @param accountId
|
|
10420
|
+
* @param appSettingsId
|
|
10421
|
+
* @returns
|
|
10480
10422
|
*/
|
|
10481
|
-
|
|
10482
|
-
{
|
|
10483
|
-
|
|
10484
|
-
name: "Cesium World Terrain",
|
|
10485
|
-
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/TerrainProviders/CesiumWorldTerrain.png"
|
|
10486
|
-
},
|
|
10487
|
-
{
|
|
10488
|
-
id: EDefaultTerrain.LINZ,
|
|
10489
|
-
name: "LINZ",
|
|
10490
|
-
iconUrl: "https://template.ui.nextspace.host/media/linz.jpg"
|
|
10491
|
-
},
|
|
10492
|
-
{
|
|
10493
|
-
id: EDefaultTerrain.FlatTerrain,
|
|
10494
|
-
name: "Flat Terrain",
|
|
10423
|
+
function GetCacheKey(accountId, appSettingsId) {
|
|
10424
|
+
if (appSettingsId) {
|
|
10425
|
+
return exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + accountId + exports.Api.ECacheKey + appSettingsId;
|
|
10495
10426
|
}
|
|
10496
|
-
|
|
10497
|
-
|
|
10498
|
-
|
|
10499
|
-
/**
|
|
10500
|
-
* Deprecated Project View record.
|
|
10501
|
-
* This was used in the legacy web Navigator.
|
|
10502
|
-
*/
|
|
10503
|
-
(function (ProjectViewLegacy) {
|
|
10504
|
-
ProjectViewLegacy.DATA_VERSION = 1;
|
|
10505
|
-
})(exports.ProjectViewLegacy || (exports.ProjectViewLegacy = {}));
|
|
10506
|
-
|
|
10507
|
-
/**
|
|
10508
|
-
* Deprecated Project View Bookmark record.
|
|
10509
|
-
* This was used in the legacy web Navigator.
|
|
10510
|
-
*/
|
|
10511
|
-
(function (ProjectViewLegacyBookmark) {
|
|
10512
|
-
ProjectViewLegacyBookmark.DATA_VERSION = 1;
|
|
10513
|
-
})(exports.ProjectViewLegacyBookmark || (exports.ProjectViewLegacyBookmark = {}));
|
|
10514
|
-
|
|
10515
|
-
(function (PendingAction) {
|
|
10427
|
+
return exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + accountId;
|
|
10428
|
+
}
|
|
10429
|
+
Account.GetCacheKey = GetCacheKey;
|
|
10516
10430
|
/**
|
|
10517
|
-
*
|
|
10431
|
+
* Returns cache identifier for a list of accounts by session ID.
|
|
10432
|
+
* Example: {
|
|
10433
|
+
* const api: BruceApi.Api = ...;
|
|
10434
|
+
* const key = GetListCacheKey(api.GetSessionId());
|
|
10435
|
+
* api.Cache.Remove(key);
|
|
10436
|
+
* }
|
|
10437
|
+
* @param ssid
|
|
10438
|
+
* @returns
|
|
10518
10439
|
*/
|
|
10519
|
-
|
|
10520
|
-
|
|
10521
|
-
|
|
10522
|
-
|
|
10523
|
-
EStatus["Complete"] = "COMPLETE";
|
|
10524
|
-
EStatus["Failed"] = "FAILED";
|
|
10525
|
-
})(EStatus = PendingAction.EStatus || (PendingAction.EStatus = {}));
|
|
10440
|
+
function GetListCacheKey(ssid) {
|
|
10441
|
+
return exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Session + exports.Api.ECacheKey.Id + ssid;
|
|
10442
|
+
}
|
|
10443
|
+
Account.GetListCacheKey = GetListCacheKey;
|
|
10526
10444
|
/**
|
|
10527
|
-
*
|
|
10445
|
+
* Returns cache identifier for a list of database regions.
|
|
10446
|
+
* Example: {
|
|
10447
|
+
* const api: BruceApi.Api = ...;
|
|
10448
|
+
* const key = GetDbRegionListCacheKey();
|
|
10449
|
+
* api.Cache.Remove(key);
|
|
10450
|
+
* }
|
|
10451
|
+
* @returns
|
|
10528
10452
|
*/
|
|
10529
|
-
|
|
10530
|
-
|
|
10531
|
-
|
|
10532
|
-
|
|
10533
|
-
|
|
10534
|
-
|
|
10535
|
-
|
|
10453
|
+
function GetDbRegionListCacheKey() {
|
|
10454
|
+
return exports.Api.ECacheKey.DatabaseRegion;
|
|
10455
|
+
}
|
|
10456
|
+
Account.GetDbRegionListCacheKey = GetDbRegionListCacheKey;
|
|
10457
|
+
})(exports.Account || (exports.Account = {}));
|
|
10458
|
+
|
|
10459
|
+
(function (HostingLocation) {
|
|
10536
10460
|
/**
|
|
10537
|
-
* Returns a
|
|
10461
|
+
* Returns a list of hosting locations.
|
|
10462
|
+
* @Warning: This will not return the Settings property.
|
|
10538
10463
|
* @param params
|
|
10539
10464
|
* @returns
|
|
10540
10465
|
*/
|
|
10541
|
-
function
|
|
10466
|
+
function GetList(params) {
|
|
10542
10467
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10543
|
-
let { api,
|
|
10544
|
-
if (!
|
|
10545
|
-
|
|
10468
|
+
let { api, req } = params;
|
|
10469
|
+
if (!api) {
|
|
10470
|
+
api = exports.ENVIRONMENT.Api().GetGuardianApi();
|
|
10471
|
+
}
|
|
10472
|
+
const res = yield api.GET("hostinglocations", exports.Api.PrepReqParams(req));
|
|
10473
|
+
return {
|
|
10474
|
+
locations: res.Items
|
|
10475
|
+
};
|
|
10476
|
+
});
|
|
10477
|
+
}
|
|
10478
|
+
HostingLocation.GetList = GetList;
|
|
10479
|
+
/**
|
|
10480
|
+
* Returns a hosting location record by ID.
|
|
10481
|
+
* @param params
|
|
10482
|
+
* @returns
|
|
10483
|
+
*/
|
|
10484
|
+
function GetById(params) {
|
|
10485
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
10486
|
+
let { id, api, req } = params;
|
|
10487
|
+
if (!id) {
|
|
10488
|
+
throw ("Invalid id");
|
|
10546
10489
|
}
|
|
10547
10490
|
if (!api) {
|
|
10548
|
-
api = exports.ENVIRONMENT.Api().
|
|
10491
|
+
api = exports.ENVIRONMENT.Api().GetGuardianApi();
|
|
10549
10492
|
}
|
|
10550
|
-
const
|
|
10493
|
+
const res = yield api.GET(`hostinglocation/id/${id}`, exports.Api.PrepReqParams(req));
|
|
10551
10494
|
return {
|
|
10552
|
-
|
|
10495
|
+
location: res
|
|
10553
10496
|
};
|
|
10554
10497
|
});
|
|
10555
10498
|
}
|
|
10556
|
-
|
|
10499
|
+
HostingLocation.GetById = GetById;
|
|
10557
10500
|
/**
|
|
10558
|
-
* Returns a
|
|
10501
|
+
* Returns a hosting location record by key.
|
|
10559
10502
|
* @param params
|
|
10560
10503
|
* @returns
|
|
10561
10504
|
*/
|
|
10562
|
-
function
|
|
10505
|
+
function GetByKey(params) {
|
|
10563
10506
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10564
|
-
let {
|
|
10507
|
+
let { key, api, req } = params;
|
|
10508
|
+
if (!key) {
|
|
10509
|
+
throw ("Invalid key");
|
|
10510
|
+
}
|
|
10565
10511
|
if (!api) {
|
|
10566
|
-
api = exports.ENVIRONMENT.Api().
|
|
10512
|
+
api = exports.ENVIRONMENT.Api().GetGuardianApi();
|
|
10567
10513
|
}
|
|
10568
|
-
const
|
|
10514
|
+
const res = yield api.GET(`hostinglocation/key/${key}`, exports.Api.PrepReqParams(req));
|
|
10569
10515
|
return {
|
|
10570
|
-
|
|
10516
|
+
location: res
|
|
10571
10517
|
};
|
|
10572
10518
|
});
|
|
10573
10519
|
}
|
|
10574
|
-
|
|
10520
|
+
HostingLocation.GetByKey = GetByKey;
|
|
10575
10521
|
/**
|
|
10576
|
-
* Returns
|
|
10522
|
+
* Returns hostingLocationKey from given db url.
|
|
10523
|
+
* Some older accounts don't have this set, so we need to guess it.
|
|
10577
10524
|
* @param params
|
|
10578
10525
|
* @returns
|
|
10579
10526
|
*/
|
|
10580
|
-
function
|
|
10527
|
+
function GuessKey(params) {
|
|
10528
|
+
const { DBServer: databaseUrl } = params;
|
|
10529
|
+
if (databaseUrl.includes("hyperfarm-prod-instance-1")) {
|
|
10530
|
+
return "HYPERFARM";
|
|
10531
|
+
}
|
|
10532
|
+
if (databaseUrl.includes("prod-syd1.nextspace.host")) {
|
|
10533
|
+
return "AU-VULTR-FIRST";
|
|
10534
|
+
}
|
|
10535
|
+
else if (databaseUrl.includes("prod-nyc1.nextspace.host")) {
|
|
10536
|
+
return "US-VULTR-FIRST";
|
|
10537
|
+
}
|
|
10538
|
+
else if (databaseUrl.includes("prod-ams1.nextspace.host")) {
|
|
10539
|
+
return "EU-VULTR-FIRST";
|
|
10540
|
+
}
|
|
10541
|
+
else if (databaseUrl.includes("prod-sing1.nextspace.host")) {
|
|
10542
|
+
return "SE-VULTR-FIRST";
|
|
10543
|
+
}
|
|
10544
|
+
else if (databaseUrl.includes("dev-first")) {
|
|
10545
|
+
return "DEV-FIRST";
|
|
10546
|
+
}
|
|
10547
|
+
else if (databaseUrl.includes(".ap-southeast-1.")) {
|
|
10548
|
+
return "SE";
|
|
10549
|
+
}
|
|
10550
|
+
else if (databaseUrl.includes(".us-west-1.")) {
|
|
10551
|
+
return "US";
|
|
10552
|
+
}
|
|
10553
|
+
else if (databaseUrl.includes(".eu-west-3.")) {
|
|
10554
|
+
return "EU";
|
|
10555
|
+
}
|
|
10556
|
+
else if (databaseUrl.includes("bruce-prod-au")) {
|
|
10557
|
+
return "AU";
|
|
10558
|
+
}
|
|
10559
|
+
else if (databaseUrl.includes("bruce-dev")) {
|
|
10560
|
+
return "DEV";
|
|
10561
|
+
}
|
|
10562
|
+
return null;
|
|
10563
|
+
}
|
|
10564
|
+
HostingLocation.GuessKey = GuessKey;
|
|
10565
|
+
/**
|
|
10566
|
+
* Returns a hosting location key by account ID.
|
|
10567
|
+
* @param params
|
|
10568
|
+
* @returns
|
|
10569
|
+
*/
|
|
10570
|
+
function GetKeyByAccountId(params) {
|
|
10581
10571
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10582
|
-
let {
|
|
10572
|
+
let { accountId, apiSettings, api, account, req } = params;
|
|
10573
|
+
if (!accountId && !apiSettings) {
|
|
10574
|
+
throw ("Invalid accountId or apiSettings");
|
|
10575
|
+
}
|
|
10583
10576
|
if (!api) {
|
|
10584
|
-
api = exports.ENVIRONMENT.Api().
|
|
10577
|
+
api = exports.ENVIRONMENT.Api().GetGuardianApi();
|
|
10585
10578
|
}
|
|
10586
|
-
|
|
10587
|
-
|
|
10579
|
+
// We'll prioritize account record if provided.
|
|
10580
|
+
if (accountId && !account) {
|
|
10581
|
+
account = (yield exports.Account.Get({
|
|
10582
|
+
accountId,
|
|
10583
|
+
api,
|
|
10584
|
+
req
|
|
10585
|
+
})).account;
|
|
10588
10586
|
}
|
|
10589
|
-
if (
|
|
10590
|
-
|
|
10587
|
+
if (account === null || account === void 0 ? void 0 : account["HostingLocation.Key"]) {
|
|
10588
|
+
return {
|
|
10589
|
+
key: account["HostingLocation.Key"],
|
|
10590
|
+
isLegacy: false
|
|
10591
|
+
};
|
|
10591
10592
|
}
|
|
10592
|
-
|
|
10593
|
-
|
|
10593
|
+
// Fallback to settings JSON for older records.
|
|
10594
|
+
const settings = apiSettings ? apiSettings : (yield exports.Account.GetAppSettings({
|
|
10595
|
+
api,
|
|
10596
|
+
accountId,
|
|
10597
|
+
appId: exports.Account.EAppId.BruceApi
|
|
10598
|
+
})).settings;
|
|
10599
|
+
let hostingKey = settings["HostingLocation.Key"];
|
|
10600
|
+
let isLegacy = false;
|
|
10601
|
+
if (!hostingKey) {
|
|
10602
|
+
hostingKey = settings.DBLocation;
|
|
10603
|
+
isLegacy = true;
|
|
10594
10604
|
}
|
|
10595
|
-
|
|
10596
|
-
|
|
10597
|
-
|
|
10598
|
-
|
|
10599
|
-
|
|
10605
|
+
if (!hostingKey) {
|
|
10606
|
+
hostingKey = GuessKey({
|
|
10607
|
+
DBServer: settings.DBServer
|
|
10608
|
+
});
|
|
10609
|
+
isLegacy = true;
|
|
10600
10610
|
}
|
|
10601
|
-
const data = yield api.GET(`pendingAction/${actionId}/progressMessages` + args, exports.Api.PrepReqParams(reqParams));
|
|
10602
10611
|
return {
|
|
10603
|
-
|
|
10612
|
+
key: hostingKey,
|
|
10613
|
+
isLegacy
|
|
10604
10614
|
};
|
|
10605
10615
|
});
|
|
10606
10616
|
}
|
|
10607
|
-
|
|
10617
|
+
HostingLocation.GetKeyByAccountId = GetKeyByAccountId;
|
|
10608
10618
|
/**
|
|
10609
|
-
*
|
|
10619
|
+
* Returns a hosting location record by account ID.
|
|
10610
10620
|
* @param params
|
|
10621
|
+
* @returns
|
|
10611
10622
|
*/
|
|
10612
|
-
function
|
|
10623
|
+
function GetByAccountId(params) {
|
|
10613
10624
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10614
|
-
let {
|
|
10615
|
-
if (!actionId) {
|
|
10616
|
-
throw ("Action ID is required.");
|
|
10617
|
-
}
|
|
10625
|
+
let { accountId, apiSettings, api, req, account } = params;
|
|
10618
10626
|
if (!api) {
|
|
10619
|
-
api = exports.ENVIRONMENT.Api().
|
|
10627
|
+
api = exports.ENVIRONMENT.Api().GetGuardianApi();
|
|
10620
10628
|
}
|
|
10621
|
-
yield
|
|
10629
|
+
const data = yield GetKeyByAccountId({
|
|
10630
|
+
accountId,
|
|
10631
|
+
account,
|
|
10632
|
+
apiSettings,
|
|
10633
|
+
api,
|
|
10634
|
+
req
|
|
10635
|
+
});
|
|
10636
|
+
if (!(data === null || data === void 0 ? void 0 : data.key)) {
|
|
10637
|
+
return null;
|
|
10638
|
+
}
|
|
10639
|
+
const key = yield GetByKey({
|
|
10640
|
+
key: data.key,
|
|
10641
|
+
api,
|
|
10642
|
+
req
|
|
10643
|
+
});
|
|
10644
|
+
return key;
|
|
10622
10645
|
});
|
|
10623
10646
|
}
|
|
10624
|
-
|
|
10625
|
-
})(exports.
|
|
10647
|
+
HostingLocation.GetByAccountId = GetByAccountId;
|
|
10648
|
+
})(exports.HostingLocation || (exports.HostingLocation = {}));
|
|
10626
10649
|
|
|
10627
10650
|
/**
|
|
10628
10651
|
* Permissions in Nextspace are arbitrary strings with meaning in specific contexts.
|
|
@@ -13080,7 +13103,12 @@
|
|
|
13080
13103
|
cacheKey = 0;
|
|
13081
13104
|
}
|
|
13082
13105
|
return {
|
|
13083
|
-
indexFileUrl:
|
|
13106
|
+
indexFileUrl: api.ConstructUrl({
|
|
13107
|
+
url: `ui.plugin/${pluginId}/file/index.jsc`,
|
|
13108
|
+
urlParams: {
|
|
13109
|
+
"version": String(cacheKey)
|
|
13110
|
+
}
|
|
13111
|
+
})
|
|
13084
13112
|
};
|
|
13085
13113
|
}
|
|
13086
13114
|
Plugin.GetLoadUrl = GetLoadUrl;
|
|
@@ -13462,7 +13490,7 @@
|
|
|
13462
13490
|
})(exports.DataSource || (exports.DataSource = {}));
|
|
13463
13491
|
|
|
13464
13492
|
// This is updated with the package.json version on build.
|
|
13465
|
-
const VERSION = "4.
|
|
13493
|
+
const VERSION = "4.6.0";
|
|
13466
13494
|
|
|
13467
13495
|
exports.VERSION = VERSION;
|
|
13468
13496
|
exports.AbstractApi = AbstractApi;
|