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.es5.js
CHANGED
|
@@ -841,782 +841,482 @@ var GuardianApi;
|
|
|
841
841
|
GuardianApi.Api = Api$$1;
|
|
842
842
|
})(GuardianApi || (GuardianApi = {}));
|
|
843
843
|
|
|
844
|
-
// Some dead accounts that we don't want to show in the UI.
|
|
845
|
-
// Some accounts may not be "dead" but instead purposely don't have a NextspaceAPI database so we'll avoid them too.
|
|
846
|
-
const ACCOUNT_EXCLUSIONS = ["hyperportal", "hypeportal", "bviewer"];
|
|
847
844
|
/**
|
|
848
|
-
*
|
|
849
|
-
*
|
|
845
|
+
* The primary API for communication with Nextspace.
|
|
846
|
+
* This API is used to manage your data.
|
|
850
847
|
*/
|
|
851
|
-
var
|
|
852
|
-
(function (
|
|
853
|
-
/**
|
|
854
|
-
* Known Nextspace applications we store settings for.
|
|
855
|
-
*/
|
|
856
|
-
let EAppId;
|
|
857
|
-
(function (EAppId) {
|
|
858
|
-
EAppId["BruceApi"] = "BruceAPI";
|
|
859
|
-
EAppId["Navigator"] = "Navigator";
|
|
860
|
-
EAppId["Operator"] = "BruceClientAdmin";
|
|
861
|
-
})(EAppId = Account.EAppId || (Account.EAppId = {}));
|
|
862
|
-
/**
|
|
863
|
-
* Possible starter content options.
|
|
864
|
-
* When creating a new account you can populate it with certain default data.
|
|
865
|
-
*/
|
|
866
|
-
let EStarterContent;
|
|
867
|
-
(function (EStarterContent) {
|
|
868
|
-
EStarterContent["Default"] = "default";
|
|
869
|
-
EStarterContent["None"] = "none";
|
|
870
|
-
})(EStarterContent = Account.EStarterContent || (Account.EStarterContent = {}));
|
|
848
|
+
var BruceApi;
|
|
849
|
+
(function (BruceApi$$1) {
|
|
871
850
|
/**
|
|
872
|
-
*
|
|
873
|
-
*
|
|
874
|
-
* @returns
|
|
851
|
+
* This is the request handler for Bruce Api,
|
|
852
|
+
* it should be passed to any method that wants to communicate with this particular api.
|
|
875
853
|
*/
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
854
|
+
class Api$$1 extends AbstractApi {
|
|
855
|
+
get AccountId() {
|
|
856
|
+
return this.accountId;
|
|
857
|
+
}
|
|
858
|
+
get MessageBroker() {
|
|
859
|
+
return this.messageBroker;
|
|
860
|
+
}
|
|
861
|
+
get ConfigLoadAttempted() {
|
|
862
|
+
return this.configLoadAttempted;
|
|
863
|
+
}
|
|
864
|
+
get Version() {
|
|
865
|
+
return this.version;
|
|
866
|
+
}
|
|
867
|
+
get Loading() {
|
|
868
|
+
return this.loadProm;
|
|
869
|
+
}
|
|
870
|
+
constructor(params) {
|
|
871
|
+
super({
|
|
872
|
+
ssidHeader: "x-sessionid",
|
|
873
|
+
cacheId: `BRUCE_API_${params === null || params === void 0 ? void 0 : params.env}_${params === null || params === void 0 ? void 0 : params.accountId}_`
|
|
874
|
+
});
|
|
875
|
+
// Load cancelled indicates the user set a custom base url.
|
|
876
|
+
// This will stop the regional url from being set if it's still loading.
|
|
877
|
+
this.loadCancelled = false;
|
|
878
|
+
// Indicates if loading the regional configuration was already called.
|
|
879
|
+
this.configLoadAttempted = false;
|
|
880
|
+
let { accountId, env, guardian, loadRegionalBaseUrl, loadConfig, loadWebSocket, dummy } = params;
|
|
881
|
+
this.accountId = accountId;
|
|
882
|
+
this.env = env !== null && env !== void 0 ? env : Api.EEnv.PROD;
|
|
883
|
+
if (!dummy) {
|
|
884
|
+
// Backwards compatibility.
|
|
885
|
+
if (loadRegionalBaseUrl) {
|
|
886
|
+
loadConfig = true;
|
|
887
|
+
}
|
|
888
|
+
if (loadConfig) {
|
|
889
|
+
// Mark it as attempted right away because we don't want any external calls while it gets to that async point.
|
|
890
|
+
this.configLoadAttempted = true;
|
|
891
|
+
}
|
|
892
|
+
this.loadProm = this.init(guardian, loadConfig, loadWebSocket);
|
|
885
893
|
}
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
894
|
+
}
|
|
895
|
+
/**
|
|
896
|
+
* Loads regional base url and sets up message broker.
|
|
897
|
+
* @param guardian Required for loading regional base url.
|
|
898
|
+
* @param loadConfig
|
|
899
|
+
* @returns
|
|
900
|
+
*/
|
|
901
|
+
init(guardian, loadConfig, loadWebSocket) {
|
|
902
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
903
|
+
if (!this.accountId) {
|
|
904
|
+
throw ("accountId is required.");
|
|
905
|
+
}
|
|
906
|
+
// Set using a stable default.
|
|
907
|
+
const domain = this.getDomain();
|
|
908
|
+
this.baseUrl = `https://${this.accountId}.api.${domain}/`;
|
|
909
|
+
// Attempt to load regional configuration.
|
|
910
|
+
if (loadConfig) {
|
|
911
|
+
yield this.LoadConfig({
|
|
912
|
+
guardian: guardian,
|
|
913
|
+
// We marked it as attempted to load outside this method to fight any external calls.
|
|
914
|
+
// So we'll force load it now.
|
|
915
|
+
forceLoad: true
|
|
899
916
|
});
|
|
900
917
|
}
|
|
901
|
-
|
|
902
|
-
|
|
918
|
+
// Get the version.
|
|
919
|
+
if (this.baseUrl) {
|
|
920
|
+
const full = this.ConstructUrl({
|
|
921
|
+
url: "version"
|
|
922
|
+
});
|
|
923
|
+
const data = yield this.get(full);
|
|
924
|
+
if (data === null || data === void 0 ? void 0 : data["Bruce-API"]) {
|
|
925
|
+
this.version = data["Bruce-API"];
|
|
926
|
+
}
|
|
927
|
+
else {
|
|
928
|
+
this.version = "UNKNOWN";
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
// Start web socket connection.
|
|
932
|
+
if (loadWebSocket == true) {
|
|
933
|
+
try {
|
|
934
|
+
const full = this.ConstructUrl();
|
|
935
|
+
this.messageBroker = new MessageBroker.WebSocketBroker(full, this.env);
|
|
936
|
+
}
|
|
937
|
+
catch (e) {
|
|
938
|
+
console.warn("BruceApi: Failed to create message broker.", e);
|
|
939
|
+
}
|
|
903
940
|
}
|
|
904
|
-
}));
|
|
905
|
-
yield api.SetCacheItem({
|
|
906
|
-
key: GetCacheKey(id),
|
|
907
|
-
value: prom,
|
|
908
|
-
req: reqParams
|
|
909
941
|
});
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
942
|
+
}
|
|
943
|
+
getDomain() {
|
|
944
|
+
const env = this.env.toUpperCase();
|
|
945
|
+
let domain = "nextspace.host";
|
|
946
|
+
switch (env) {
|
|
947
|
+
case Api.EEnv.DEV:
|
|
948
|
+
domain = "nextspace-dev.net";
|
|
949
|
+
break;
|
|
950
|
+
case Api.EEnv.STG:
|
|
951
|
+
domain = "nextspace-stg.net";
|
|
952
|
+
break;
|
|
953
|
+
case Api.EEnv.UAT:
|
|
954
|
+
domain = "nextspace-uat.net";
|
|
955
|
+
break;
|
|
956
|
+
case Api.EEnv.PROD:
|
|
957
|
+
domain = "nextspace.host";
|
|
958
|
+
break;
|
|
959
|
+
default:
|
|
960
|
+
console.error("Specified Environment is not valid. SuppliedEnv=" + env);
|
|
928
961
|
}
|
|
929
|
-
|
|
962
|
+
return domain;
|
|
963
|
+
}
|
|
964
|
+
/**
|
|
965
|
+
* Loads the regional configuration for the account.
|
|
966
|
+
* If the config is already loaded then this will do nothing.
|
|
967
|
+
*/
|
|
968
|
+
LoadConfig(params) {
|
|
969
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
970
|
+
let { guardian, forceLoad } = (params !== null && params !== void 0 ? params : {});
|
|
971
|
+
if (this.configLoadAttempted && forceLoad != true) {
|
|
972
|
+
return;
|
|
973
|
+
}
|
|
974
|
+
this.configLoadAttempted = true;
|
|
930
975
|
try {
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
yield api.SetCacheItem({
|
|
935
|
-
key: data.ID,
|
|
936
|
-
value: prom,
|
|
937
|
-
req: reqParams
|
|
976
|
+
if (!guardian) {
|
|
977
|
+
guardian = new GuardianApi.Api({
|
|
978
|
+
env: this.env
|
|
938
979
|
});
|
|
939
980
|
}
|
|
940
|
-
|
|
941
|
-
|
|
981
|
+
const { account } = yield Account.GetBySubdomain({
|
|
982
|
+
subdomain: this.accountId,
|
|
983
|
+
api: guardian
|
|
942
984
|
});
|
|
985
|
+
if (!this.loadCancelled) {
|
|
986
|
+
// Set the calculated base url.
|
|
987
|
+
// If this is not available then this is considered a critical failure.
|
|
988
|
+
// However I am not crashing here because I want to monitor this in production.
|
|
989
|
+
if (account.URL) {
|
|
990
|
+
const urls = account.URL;
|
|
991
|
+
if (urls === null || urls === void 0 ? void 0 : urls.Base) {
|
|
992
|
+
this.baseUrl = urls.Base;
|
|
993
|
+
}
|
|
994
|
+
if (urls === null || urls === void 0 ? void 0 : urls.CDNEntities) {
|
|
995
|
+
this.EntityCdnUrl = urls.CDNEntities;
|
|
996
|
+
}
|
|
997
|
+
if (urls === null || urls === void 0 ? void 0 : urls.CDNTileset) {
|
|
998
|
+
this.TilesetCdnUrl = urls.CDNTileset;
|
|
999
|
+
}
|
|
1000
|
+
if (urls === null || urls === void 0 ? void 0 : urls.CDNLegacyTileset) {
|
|
1001
|
+
this.LegacyTilesetCdnUrl = urls.CDNLegacyTileset;
|
|
1002
|
+
}
|
|
1003
|
+
if (urls === null || urls === void 0 ? void 0 : urls.CDNBase) {
|
|
1004
|
+
this.cdnBaseUrl = urls.CDNBase;
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
else {
|
|
1008
|
+
console.error("BruceApi: Failed to load regional configuration for account.", this.accountId);
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
943
1011
|
}
|
|
944
1012
|
catch (e) {
|
|
945
|
-
|
|
1013
|
+
console.error(e);
|
|
946
1014
|
}
|
|
947
|
-
}));
|
|
948
|
-
yield api.SetCacheItem({
|
|
949
|
-
key: GetCacheKey(subdomain),
|
|
950
|
-
value: prom,
|
|
951
|
-
req: reqParams
|
|
952
1015
|
});
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
1016
|
+
}
|
|
1017
|
+
/**
|
|
1018
|
+
* Creates a message broker instance and returns it.
|
|
1019
|
+
* If an instance is already created, it will return that one.
|
|
1020
|
+
* @warning This will await the loading promise to avoid using data that isn't ready.
|
|
1021
|
+
*/
|
|
1022
|
+
ConnectWebsocket() {
|
|
1023
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1024
|
+
yield this.loadProm;
|
|
1025
|
+
if (this.messageBroker) {
|
|
1026
|
+
return this.messageBroker;
|
|
1027
|
+
}
|
|
1028
|
+
const full = this.ConstructUrl();
|
|
1029
|
+
this.messageBroker = new MessageBroker.WebSocketBroker(full, this.env);
|
|
1030
|
+
return this.messageBroker;
|
|
1031
|
+
});
|
|
1032
|
+
}
|
|
1033
|
+
/**
|
|
1034
|
+
* Warning: This method does not wait for init to finish loading.
|
|
1035
|
+
* This means the url could be changed once fully initialized.
|
|
1036
|
+
* The url will be valid either way, but the loaded one may be faster as it is region specific.
|
|
1037
|
+
* Await the "Loading" promise if you care about this.
|
|
1038
|
+
* @warning use ConstructUrl instead as the baseUrl may have a query param for the account.
|
|
1039
|
+
* @returns
|
|
1040
|
+
*/
|
|
1041
|
+
GetBaseUrl() {
|
|
1042
|
+
return this.baseUrl;
|
|
1043
|
+
}
|
|
1044
|
+
/**
|
|
1045
|
+
* Warning: Wait the "Loading" promise before using this url.
|
|
1046
|
+
* @warning use ConstructUrl instead as the baseUrl may have a query param for the account.
|
|
1047
|
+
* @returns
|
|
1048
|
+
*/
|
|
1049
|
+
GetCdnBaseUrl() {
|
|
1050
|
+
return this.cdnBaseUrl;
|
|
1051
|
+
}
|
|
1052
|
+
/**
|
|
1053
|
+
* Returns a url with the provided url appended to the loaded base url.
|
|
1054
|
+
* If the base url is not loaded yet, this will return null.
|
|
1055
|
+
* @param params
|
|
1056
|
+
*/
|
|
1057
|
+
ConstructUrl(params) {
|
|
1058
|
+
if ((params === null || params === void 0 ? void 0 : params.cdn) && this.cdnBaseUrl) {
|
|
1059
|
+
return this.ConstructCdnUrl(params.url, params.urlParams);
|
|
1060
|
+
}
|
|
1061
|
+
const tmp = new URL(this.baseUrl);
|
|
1062
|
+
if (params === null || params === void 0 ? void 0 : params.urlParams) {
|
|
1063
|
+
if (params.urlParams instanceof URLSearchParams) {
|
|
1064
|
+
params.urlParams.forEach((value, key) => {
|
|
1065
|
+
tmp.searchParams.append(key, value);
|
|
979
1066
|
});
|
|
980
1067
|
}
|
|
981
|
-
|
|
982
|
-
|
|
1068
|
+
else {
|
|
1069
|
+
for (const key in params.urlParams) {
|
|
1070
|
+
tmp.searchParams.append(key, params.urlParams[key]);
|
|
1071
|
+
}
|
|
983
1072
|
}
|
|
984
|
-
}));
|
|
985
|
-
yield api.SetCacheItem({
|
|
986
|
-
key: GetListCacheKey(api.GetSessionId()),
|
|
987
|
-
value: prom,
|
|
988
|
-
req: reqParams
|
|
989
|
-
});
|
|
990
|
-
return prom;
|
|
991
|
-
});
|
|
992
|
-
}
|
|
993
|
-
Account.GetRelatedList = GetRelatedList;
|
|
994
|
-
/**
|
|
995
|
-
* Gets application settings for a specific client account.
|
|
996
|
-
* @param params
|
|
997
|
-
* @returns
|
|
998
|
-
*/
|
|
999
|
-
function GetAppSettings(params) {
|
|
1000
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1001
|
-
let { api, accountId: id, appId, req: reqParams } = params;
|
|
1002
|
-
if (!api) {
|
|
1003
|
-
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
1004
1073
|
}
|
|
1005
|
-
|
|
1006
|
-
if (
|
|
1007
|
-
|
|
1074
|
+
// Ensure the url ends with a slash.
|
|
1075
|
+
if (!tmp.pathname.endsWith("/")) {
|
|
1076
|
+
tmp.pathname += "/";
|
|
1077
|
+
}
|
|
1078
|
+
if (params === null || params === void 0 ? void 0 : params.url) {
|
|
1079
|
+
// Ensure we're only adding the path.
|
|
1080
|
+
// The baseUrl could have included query params so have this extra logic.
|
|
1081
|
+
const split = params.url.split("?");
|
|
1082
|
+
// Ensure the url does not start with a slash.
|
|
1083
|
+
// This is because the base url already has a slash at the end.
|
|
1084
|
+
let path = split[0];
|
|
1085
|
+
if (path.startsWith("/")) {
|
|
1086
|
+
path = path.substring(1);
|
|
1087
|
+
}
|
|
1088
|
+
tmp.pathname += path;
|
|
1089
|
+
// Append the query string if any exist.
|
|
1090
|
+
if (split.length > 1) {
|
|
1091
|
+
const query = split[1].split("&");
|
|
1092
|
+
for (let q of query) {
|
|
1093
|
+
const parts = q.split("=");
|
|
1094
|
+
tmp.searchParams.append(parts[0], parts[1]);
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1008
1097
|
}
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1098
|
+
return tmp.toString();
|
|
1099
|
+
}
|
|
1100
|
+
/**
|
|
1101
|
+
* Returns a url routed through the API's CDN.
|
|
1102
|
+
* If the CDN is not enabled for the account, this will return null.
|
|
1103
|
+
* @param url suffix to append to the base url.
|
|
1104
|
+
* @param urlParams
|
|
1105
|
+
* @returns
|
|
1106
|
+
*/
|
|
1107
|
+
ConstructCdnUrl(url, urlParams) {
|
|
1108
|
+
if (!this.cdnBaseUrl) {
|
|
1109
|
+
return null;
|
|
1110
|
+
}
|
|
1111
|
+
const tmp = new URL(this.cdnBaseUrl);
|
|
1112
|
+
if (urlParams) {
|
|
1113
|
+
if (urlParams instanceof URLSearchParams) {
|
|
1114
|
+
urlParams.forEach((value, key) => {
|
|
1115
|
+
tmp.searchParams.append(key, value);
|
|
1017
1116
|
});
|
|
1018
1117
|
}
|
|
1019
|
-
|
|
1020
|
-
|
|
1118
|
+
else {
|
|
1119
|
+
for (const key in urlParams) {
|
|
1120
|
+
tmp.searchParams.append(key, urlParams[key]);
|
|
1121
|
+
}
|
|
1021
1122
|
}
|
|
1022
|
-
}));
|
|
1023
|
-
yield api.SetCacheItem({
|
|
1024
|
-
key: GetCacheKey(id, appId),
|
|
1025
|
-
value: prom,
|
|
1026
|
-
req: reqParams
|
|
1027
|
-
});
|
|
1028
|
-
return prom;
|
|
1029
|
-
});
|
|
1030
|
-
}
|
|
1031
|
-
Account.GetAppSettings = GetAppSettings;
|
|
1032
|
-
/**
|
|
1033
|
-
* Updates application settings for a specific client account + application.
|
|
1034
|
-
* WARNING: Do not update API settings without knowing what you're doing.
|
|
1035
|
-
* @param params
|
|
1036
|
-
* @returns
|
|
1037
|
-
*/
|
|
1038
|
-
function UpdateAppSettings(params) {
|
|
1039
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1040
|
-
let { api, accountId: id, appId, settings: data, req: reqParams } = params;
|
|
1041
|
-
if (!api) {
|
|
1042
|
-
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
1043
|
-
}
|
|
1044
|
-
const res = yield api.POST(`account/${id}/applicationSettings/${appId}`, data, reqParams);
|
|
1045
|
-
yield api.Cache.RemoveByStartsWith(Api.ECacheKey.Account + Api.ECacheKey.Id + id);
|
|
1046
|
-
return {
|
|
1047
|
-
settings: res
|
|
1048
|
-
};
|
|
1049
|
-
});
|
|
1050
|
-
}
|
|
1051
|
-
Account.UpdateAppSettings = UpdateAppSettings;
|
|
1052
|
-
/**
|
|
1053
|
-
* Creates a new Nextspace account using given details.
|
|
1054
|
-
* @param params
|
|
1055
|
-
* @returns
|
|
1056
|
-
*/
|
|
1057
|
-
function Create(params) {
|
|
1058
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1059
|
-
let { api, accountId: id, name, hostingLocationKey, starterContent, req: reqParams } = params;
|
|
1060
|
-
if (!id || !name || !hostingLocationKey) {
|
|
1061
|
-
throw new Error("Id, Name and hostingLocationKey are required.");
|
|
1062
1123
|
}
|
|
1063
|
-
|
|
1064
|
-
|
|
1124
|
+
// Ensure the url ends with a slash.
|
|
1125
|
+
if (!tmp.pathname.endsWith("/")) {
|
|
1126
|
+
tmp.pathname += "/";
|
|
1065
1127
|
}
|
|
1066
|
-
if (
|
|
1067
|
-
|
|
1128
|
+
if (url) {
|
|
1129
|
+
// Ensure we're only adding the path.
|
|
1130
|
+
// The baseUrl could have included query params so have this extra logic.
|
|
1131
|
+
let split = url.split("?");
|
|
1132
|
+
// Ensure the url does not start with a slash.
|
|
1133
|
+
// This is because the base url already has a slash at the end.
|
|
1134
|
+
let path = split[0];
|
|
1135
|
+
if (path.startsWith("/")) {
|
|
1136
|
+
path = url.substring(1);
|
|
1137
|
+
}
|
|
1138
|
+
tmp.pathname += path;
|
|
1139
|
+
// Append the query string if any exist.
|
|
1140
|
+
if (split.length > 1) {
|
|
1141
|
+
const query = split[1].split("&");
|
|
1142
|
+
for (let q of query) {
|
|
1143
|
+
const parts = q.split("=");
|
|
1144
|
+
tmp.searchParams.append(parts[0], parts[1]);
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1068
1147
|
}
|
|
1069
|
-
|
|
1070
|
-
"Name": name,
|
|
1071
|
-
"HostingLocation.Key": hostingLocationKey,
|
|
1072
|
-
"StarterContent": starterContent
|
|
1073
|
-
};
|
|
1074
|
-
const res = yield api.POST(`clientAccount/${id}`, reqData, Api.PrepReqParams(reqParams));
|
|
1075
|
-
const resData = {
|
|
1076
|
-
account: res
|
|
1077
|
-
};
|
|
1078
|
-
api.Cache.Remove(GetListCacheKey(api.GetSessionId()));
|
|
1079
|
-
return resData;
|
|
1080
|
-
});
|
|
1081
|
-
}
|
|
1082
|
-
Account.Create = Create;
|
|
1083
|
-
/**
|
|
1084
|
-
* Returns cache identifier for an account by ID.
|
|
1085
|
-
* Example: {
|
|
1086
|
-
* const api: BruceApi.Api = ...;
|
|
1087
|
-
* const key = GetCacheKey(1);
|
|
1088
|
-
* api.Cache.Remove(key);
|
|
1089
|
-
* }
|
|
1090
|
-
* @param accountId
|
|
1091
|
-
* @param appSettingsId
|
|
1092
|
-
* @returns
|
|
1093
|
-
*/
|
|
1094
|
-
function GetCacheKey(accountId, appSettingsId) {
|
|
1095
|
-
if (appSettingsId) {
|
|
1096
|
-
return Api.ECacheKey.Account + Api.ECacheKey.Id + accountId + Api.ECacheKey + appSettingsId;
|
|
1148
|
+
return tmp.toString();
|
|
1097
1149
|
}
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
Account.GetListCacheKey = GetListCacheKey;
|
|
1115
|
-
/**
|
|
1116
|
-
* Returns cache identifier for a list of database regions.
|
|
1117
|
-
* Example: {
|
|
1118
|
-
* const api: BruceApi.Api = ...;
|
|
1119
|
-
* const key = GetDbRegionListCacheKey();
|
|
1120
|
-
* api.Cache.Remove(key);
|
|
1121
|
-
* }
|
|
1122
|
-
* @returns
|
|
1123
|
-
*/
|
|
1124
|
-
function GetDbRegionListCacheKey() {
|
|
1125
|
-
return Api.ECacheKey.DatabaseRegion;
|
|
1126
|
-
}
|
|
1127
|
-
Account.GetDbRegionListCacheKey = GetDbRegionListCacheKey;
|
|
1128
|
-
})(Account || (Account = {}));
|
|
1129
|
-
|
|
1130
|
-
/**
|
|
1131
|
-
* A hosting location is a record for a possible bruce-api server configuration.
|
|
1132
|
-
* A hosting location will have one or many database servers as well, this is an additional setting.
|
|
1133
|
-
*/
|
|
1134
|
-
var HostingLocation;
|
|
1135
|
-
(function (HostingLocation) {
|
|
1136
|
-
/**
|
|
1137
|
-
* Returns a list of hosting locations.
|
|
1138
|
-
* @Warning: This will not return the Settings property.
|
|
1139
|
-
* @param params
|
|
1140
|
-
* @returns
|
|
1141
|
-
*/
|
|
1142
|
-
function GetList(params) {
|
|
1143
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1144
|
-
let { api, req } = params;
|
|
1145
|
-
if (!api) {
|
|
1146
|
-
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
1147
|
-
}
|
|
1148
|
-
const res = yield api.GET("hostinglocations", Api.PrepReqParams(req));
|
|
1149
|
-
return {
|
|
1150
|
-
locations: res.Items
|
|
1151
|
-
};
|
|
1152
|
-
});
|
|
1153
|
-
}
|
|
1154
|
-
HostingLocation.GetList = GetList;
|
|
1155
|
-
/**
|
|
1156
|
-
* Returns a hosting location record by ID.
|
|
1157
|
-
* @param params
|
|
1158
|
-
* @returns
|
|
1159
|
-
*/
|
|
1160
|
-
function GetById(params) {
|
|
1161
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1162
|
-
let { id, api, req } = params;
|
|
1163
|
-
if (!id) {
|
|
1164
|
-
throw ("Invalid id");
|
|
1165
|
-
}
|
|
1166
|
-
if (!api) {
|
|
1167
|
-
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
1150
|
+
/**
|
|
1151
|
+
* Warning: This will cancel the init process.
|
|
1152
|
+
* The init process loads a region specific endpoint.
|
|
1153
|
+
* Setting a base url will stop that process from completing.
|
|
1154
|
+
* @param url
|
|
1155
|
+
*/
|
|
1156
|
+
SetBaseUrl(url) {
|
|
1157
|
+
this.baseUrl = url;
|
|
1158
|
+
// If we're setting a valid URL then we'll ensure it ends with a slash.
|
|
1159
|
+
if (this.baseUrl && (this.baseUrl.startsWith("http://") || this.baseUrl.startsWith("https://"))) {
|
|
1160
|
+
// Parsing into URL object to avoid adding a "/" after query params.
|
|
1161
|
+
const full = new URL(this.baseUrl);
|
|
1162
|
+
if (!full.pathname.endsWith("/")) {
|
|
1163
|
+
full.pathname += "/";
|
|
1164
|
+
}
|
|
1165
|
+
this.baseUrl = full.toString();
|
|
1168
1166
|
}
|
|
1169
|
-
|
|
1170
|
-
return {
|
|
1171
|
-
location: res
|
|
1172
|
-
};
|
|
1173
|
-
});
|
|
1174
|
-
}
|
|
1175
|
-
HostingLocation.GetById = GetById;
|
|
1176
|
-
/**
|
|
1177
|
-
* Returns a hosting location record by key.
|
|
1178
|
-
* @param params
|
|
1179
|
-
* @returns
|
|
1180
|
-
*/
|
|
1181
|
-
function GetByKey(params) {
|
|
1182
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1183
|
-
let { key, api, req } = params;
|
|
1184
|
-
if (!key) {
|
|
1185
|
-
throw ("Invalid key");
|
|
1186
|
-
}
|
|
1187
|
-
if (!api) {
|
|
1188
|
-
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
1189
|
-
}
|
|
1190
|
-
const res = yield api.GET(`hostinglocation/key/${key}`, Api.PrepReqParams(req));
|
|
1191
|
-
return {
|
|
1192
|
-
location: res
|
|
1193
|
-
};
|
|
1194
|
-
});
|
|
1195
|
-
}
|
|
1196
|
-
HostingLocation.GetByKey = GetByKey;
|
|
1197
|
-
/**
|
|
1198
|
-
* Returns hostingLocationKey from given db url.
|
|
1199
|
-
* Some older accounts don't have this set, so we need to guess it.
|
|
1200
|
-
* @param params
|
|
1201
|
-
* @returns
|
|
1202
|
-
*/
|
|
1203
|
-
function GuessKey(params) {
|
|
1204
|
-
const { DBServer: databaseUrl } = params;
|
|
1205
|
-
if (databaseUrl.includes("hyperfarm-prod-instance-1")) {
|
|
1206
|
-
return "HYPERFARM";
|
|
1207
|
-
}
|
|
1208
|
-
if (databaseUrl.includes("prod-syd1.nextspace.host")) {
|
|
1209
|
-
return "AU-VULTR-FIRST";
|
|
1210
|
-
}
|
|
1211
|
-
else if (databaseUrl.includes("prod-nyc1.nextspace.host")) {
|
|
1212
|
-
return "US-VULTR-FIRST";
|
|
1213
|
-
}
|
|
1214
|
-
else if (databaseUrl.includes("prod-ams1.nextspace.host")) {
|
|
1215
|
-
return "EU-VULTR-FIRST";
|
|
1216
|
-
}
|
|
1217
|
-
else if (databaseUrl.includes("prod-sing1.nextspace.host")) {
|
|
1218
|
-
return "SE-VULTR-FIRST";
|
|
1219
|
-
}
|
|
1220
|
-
else if (databaseUrl.includes("dev-first")) {
|
|
1221
|
-
return "DEV-FIRST";
|
|
1222
|
-
}
|
|
1223
|
-
else if (databaseUrl.includes(".ap-southeast-1.")) {
|
|
1224
|
-
return "SE";
|
|
1225
|
-
}
|
|
1226
|
-
else if (databaseUrl.includes(".us-west-1.")) {
|
|
1227
|
-
return "US";
|
|
1167
|
+
this.loadCancelled = true;
|
|
1228
1168
|
}
|
|
1229
|
-
|
|
1230
|
-
|
|
1169
|
+
/**
|
|
1170
|
+
* Performs an HTTP GET request.
|
|
1171
|
+
* This will prepend the base url to the url.
|
|
1172
|
+
* @param url
|
|
1173
|
+
* @param params
|
|
1174
|
+
* @returns
|
|
1175
|
+
*/
|
|
1176
|
+
GET(url, params) {
|
|
1177
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1178
|
+
return new Promise((res, rej) => {
|
|
1179
|
+
this.loadProm.then(() => {
|
|
1180
|
+
const full = this.ConstructUrl({
|
|
1181
|
+
url: url
|
|
1182
|
+
});
|
|
1183
|
+
this.get(full, params).then(res).catch(rej);
|
|
1184
|
+
}).catch(rej);
|
|
1185
|
+
});
|
|
1186
|
+
});
|
|
1231
1187
|
}
|
|
1232
|
-
|
|
1233
|
-
|
|
1188
|
+
/**
|
|
1189
|
+
* Performs an HTTP DELETE request.
|
|
1190
|
+
* This will prepend the base url to the url.
|
|
1191
|
+
* @param url
|
|
1192
|
+
* @param params
|
|
1193
|
+
* @returns
|
|
1194
|
+
*/
|
|
1195
|
+
DELETE(url, params) {
|
|
1196
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1197
|
+
return new Promise((res, rej) => {
|
|
1198
|
+
this.loadProm.then(() => {
|
|
1199
|
+
const full = this.ConstructUrl({
|
|
1200
|
+
url: url
|
|
1201
|
+
});
|
|
1202
|
+
this.delete(full, params).then(res).catch(rej);
|
|
1203
|
+
}).catch(rej);
|
|
1204
|
+
});
|
|
1205
|
+
});
|
|
1234
1206
|
}
|
|
1235
|
-
|
|
1236
|
-
|
|
1207
|
+
/**
|
|
1208
|
+
* Performs an HTTP POST request.
|
|
1209
|
+
* This will prepend the base url to the url.
|
|
1210
|
+
* @param url
|
|
1211
|
+
* @param data
|
|
1212
|
+
* @param params
|
|
1213
|
+
* @returns
|
|
1214
|
+
*/
|
|
1215
|
+
POST(url, data, params) {
|
|
1216
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1217
|
+
return new Promise((res, rej) => {
|
|
1218
|
+
this.loadProm.then(() => {
|
|
1219
|
+
const full = this.ConstructUrl({
|
|
1220
|
+
url: url
|
|
1221
|
+
});
|
|
1222
|
+
this.post(full, data, params).then(res).catch(rej);
|
|
1223
|
+
}).catch(rej);
|
|
1224
|
+
});
|
|
1225
|
+
});
|
|
1237
1226
|
}
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
// We'll prioritize account record if provided.
|
|
1256
|
-
if (accountId && !account) {
|
|
1257
|
-
account = (yield Account.Get({
|
|
1258
|
-
accountId,
|
|
1259
|
-
api,
|
|
1260
|
-
req
|
|
1261
|
-
})).account;
|
|
1262
|
-
}
|
|
1263
|
-
if (account === null || account === void 0 ? void 0 : account["HostingLocation.Key"]) {
|
|
1264
|
-
return {
|
|
1265
|
-
key: account["HostingLocation.Key"],
|
|
1266
|
-
isLegacy: false
|
|
1267
|
-
};
|
|
1268
|
-
}
|
|
1269
|
-
// Fallback to settings JSON for older records.
|
|
1270
|
-
const settings = apiSettings ? apiSettings : (yield Account.GetAppSettings({
|
|
1271
|
-
api,
|
|
1272
|
-
accountId,
|
|
1273
|
-
appId: Account.EAppId.BruceApi
|
|
1274
|
-
})).settings;
|
|
1275
|
-
let hostingKey = settings["HostingLocation.Key"];
|
|
1276
|
-
let isLegacy = false;
|
|
1277
|
-
if (!hostingKey) {
|
|
1278
|
-
hostingKey = settings.DBLocation;
|
|
1279
|
-
isLegacy = true;
|
|
1280
|
-
}
|
|
1281
|
-
if (!hostingKey) {
|
|
1282
|
-
hostingKey = GuessKey({
|
|
1283
|
-
DBServer: settings.DBServer
|
|
1227
|
+
/**
|
|
1228
|
+
* Performs an HTTP PUT request.
|
|
1229
|
+
* This will prepend the base url to the url.
|
|
1230
|
+
* @param url
|
|
1231
|
+
* @param data
|
|
1232
|
+
* @param params
|
|
1233
|
+
* @returns
|
|
1234
|
+
*/
|
|
1235
|
+
PUT(url, data, params) {
|
|
1236
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1237
|
+
return new Promise((res, rej) => {
|
|
1238
|
+
this.loadProm.then(() => {
|
|
1239
|
+
const full = this.ConstructUrl({
|
|
1240
|
+
url: url
|
|
1241
|
+
});
|
|
1242
|
+
this.put(full, data, params).then(res).catch(rej);
|
|
1243
|
+
}).catch(rej);
|
|
1284
1244
|
});
|
|
1285
|
-
isLegacy = true;
|
|
1286
|
-
}
|
|
1287
|
-
return {
|
|
1288
|
-
key: hostingKey,
|
|
1289
|
-
isLegacy
|
|
1290
|
-
};
|
|
1291
|
-
});
|
|
1292
|
-
}
|
|
1293
|
-
HostingLocation.GetKeyByAccountId = GetKeyByAccountId;
|
|
1294
|
-
/**
|
|
1295
|
-
* Returns a hosting location record by account ID.
|
|
1296
|
-
* @param params
|
|
1297
|
-
* @returns
|
|
1298
|
-
*/
|
|
1299
|
-
function GetByAccountId(params) {
|
|
1300
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1301
|
-
let { accountId, apiSettings, api, req, account } = params;
|
|
1302
|
-
if (!api) {
|
|
1303
|
-
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
1304
|
-
}
|
|
1305
|
-
const data = yield GetKeyByAccountId({
|
|
1306
|
-
accountId,
|
|
1307
|
-
account,
|
|
1308
|
-
apiSettings,
|
|
1309
|
-
api,
|
|
1310
|
-
req
|
|
1311
1245
|
});
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1246
|
+
}
|
|
1247
|
+
/**
|
|
1248
|
+
* Performs a file upload request (HTTP POST).
|
|
1249
|
+
* This will prepend the base url to the url.
|
|
1250
|
+
* @param url
|
|
1251
|
+
* @param blob
|
|
1252
|
+
* @param params
|
|
1253
|
+
* @returns
|
|
1254
|
+
*/
|
|
1255
|
+
UPLOAD(url, blob, params) {
|
|
1256
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1257
|
+
return new Promise((res, rej) => {
|
|
1258
|
+
this.loadProm.then(() => {
|
|
1259
|
+
const full = this.ConstructUrl({
|
|
1260
|
+
url: url
|
|
1261
|
+
});
|
|
1262
|
+
this.upload(full, blob, params).then(res).catch(rej);
|
|
1263
|
+
}).catch(rej);
|
|
1264
|
+
});
|
|
1319
1265
|
});
|
|
1320
|
-
|
|
1321
|
-
});
|
|
1266
|
+
}
|
|
1322
1267
|
}
|
|
1323
|
-
|
|
1324
|
-
})(
|
|
1268
|
+
BruceApi$$1.Api = Api$$1;
|
|
1269
|
+
})(BruceApi || (BruceApi = {}));
|
|
1325
1270
|
|
|
1326
1271
|
/**
|
|
1327
|
-
*
|
|
1328
|
-
*
|
|
1272
|
+
* This is the request handler for Global Api,
|
|
1273
|
+
* The global api is used to store information that is higher level than client accounts.
|
|
1274
|
+
* For example it will store usage records, client account group settings, data sharing settings, etc.
|
|
1329
1275
|
*/
|
|
1330
|
-
var
|
|
1331
|
-
(function (
|
|
1332
|
-
/**
|
|
1333
|
-
* This is the request handler for Bruce Api,
|
|
1334
|
-
* it should be passed to any method that wants to communicate with this particular api.
|
|
1335
|
-
*/
|
|
1276
|
+
var GlobalApi;
|
|
1277
|
+
(function (GlobalApi) {
|
|
1336
1278
|
class Api$$1 extends AbstractApi {
|
|
1337
|
-
get AccountId() {
|
|
1338
|
-
return this.accountId;
|
|
1339
|
-
}
|
|
1340
|
-
get MessageBroker() {
|
|
1341
|
-
return this.messageBroker;
|
|
1342
|
-
}
|
|
1343
|
-
get ConfigLoadAttempted() {
|
|
1344
|
-
return this.configLoadAttempted;
|
|
1345
|
-
}
|
|
1346
|
-
get Version() {
|
|
1347
|
-
return this.version;
|
|
1348
|
-
}
|
|
1349
|
-
get Loading() {
|
|
1350
|
-
return this.loadProm;
|
|
1351
|
-
}
|
|
1352
1279
|
constructor(params) {
|
|
1353
1280
|
super({
|
|
1354
1281
|
ssidHeader: "x-sessionid",
|
|
1355
|
-
cacheId: `
|
|
1282
|
+
cacheId: `GLOBAL_API_${params === null || params === void 0 ? void 0 : params.env}_`
|
|
1356
1283
|
});
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
this.loadCancelled = false;
|
|
1360
|
-
// Indicates if loading the regional configuration was already called.
|
|
1361
|
-
this.configLoadAttempted = false;
|
|
1362
|
-
let { accountId, env, guardian, loadRegionalBaseUrl, loadConfig, loadWebSocket, dummy } = params;
|
|
1363
|
-
this.accountId = accountId;
|
|
1364
|
-
this.env = env !== null && env !== void 0 ? env : Api.EEnv.PROD;
|
|
1365
|
-
if (!dummy) {
|
|
1366
|
-
// Backwards compatibility.
|
|
1367
|
-
if (loadRegionalBaseUrl) {
|
|
1368
|
-
loadConfig = true;
|
|
1369
|
-
}
|
|
1370
|
-
if (loadConfig) {
|
|
1371
|
-
// Mark it as attempted right away because we don't want any external calls while it gets to that async point.
|
|
1372
|
-
this.configLoadAttempted = true;
|
|
1373
|
-
}
|
|
1374
|
-
this.loadProm = this.init(guardian, loadConfig, loadWebSocket);
|
|
1375
|
-
}
|
|
1284
|
+
this.env = (params === null || params === void 0 ? void 0 : params.env) ? params.env : Api.EEnv.PROD;
|
|
1285
|
+
this.setBaseUrl();
|
|
1376
1286
|
}
|
|
1377
1287
|
/**
|
|
1378
|
-
*
|
|
1379
|
-
* @param guardian Required for loading regional base url.
|
|
1380
|
-
* @param loadConfig
|
|
1381
|
-
* @returns
|
|
1288
|
+
* Sets the base url for this api.
|
|
1382
1289
|
*/
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
if (!this.accountId) {
|
|
1386
|
-
throw ("accountId is required.");
|
|
1387
|
-
}
|
|
1388
|
-
// Set using a stable default.
|
|
1389
|
-
const domain = this.getDomain();
|
|
1390
|
-
this.baseUrl = `https://${this.accountId}.api.${domain}/`;
|
|
1391
|
-
// Attempt to load regional configuration.
|
|
1392
|
-
if (loadConfig) {
|
|
1393
|
-
yield this.LoadConfig({
|
|
1394
|
-
guardian: guardian,
|
|
1395
|
-
// We marked it as attempted to load outside this method to fight any external calls.
|
|
1396
|
-
// So we'll force load it now.
|
|
1397
|
-
forceLoad: true
|
|
1398
|
-
});
|
|
1399
|
-
}
|
|
1400
|
-
// Get the version.
|
|
1401
|
-
if (this.baseUrl) {
|
|
1402
|
-
const data = yield this.get(this.baseUrl + "version");
|
|
1403
|
-
if (data === null || data === void 0 ? void 0 : data["Bruce-API"]) {
|
|
1404
|
-
this.version = data["Bruce-API"];
|
|
1405
|
-
}
|
|
1406
|
-
else {
|
|
1407
|
-
this.version = "UNKNOWN";
|
|
1408
|
-
}
|
|
1409
|
-
}
|
|
1410
|
-
// Start web socket connection.
|
|
1411
|
-
if (loadWebSocket == true) {
|
|
1412
|
-
try {
|
|
1413
|
-
this.messageBroker = new MessageBroker.WebSocketBroker(this.baseUrl, this.env);
|
|
1414
|
-
}
|
|
1415
|
-
catch (e) {
|
|
1416
|
-
console.warn("BruceApi: Failed to create message broker.", e);
|
|
1417
|
-
}
|
|
1418
|
-
}
|
|
1419
|
-
});
|
|
1420
|
-
}
|
|
1421
|
-
getDomain() {
|
|
1290
|
+
setBaseUrl() {
|
|
1291
|
+
let url;
|
|
1422
1292
|
const env = this.env.toUpperCase();
|
|
1423
|
-
let domain = "nextspace.host";
|
|
1424
1293
|
switch (env) {
|
|
1425
1294
|
case Api.EEnv.DEV:
|
|
1426
|
-
|
|
1295
|
+
url = "https://bruceglobal.nextspace-dev.net/";
|
|
1427
1296
|
break;
|
|
1428
1297
|
case Api.EEnv.STG:
|
|
1429
|
-
|
|
1298
|
+
url = "https://bruceglobal.nextspace-stg.net/";
|
|
1430
1299
|
break;
|
|
1431
1300
|
case Api.EEnv.UAT:
|
|
1432
|
-
|
|
1301
|
+
url = "https://bruceglobal.api.nextspace-uat.net/";
|
|
1433
1302
|
break;
|
|
1434
1303
|
case Api.EEnv.PROD:
|
|
1435
|
-
|
|
1304
|
+
url = "https://bruceglobal.api.nextspace.host/";
|
|
1436
1305
|
break;
|
|
1437
1306
|
default:
|
|
1438
|
-
|
|
1307
|
+
throw ("Specified Environment is not valid. SuppliedEnv=" + env);
|
|
1439
1308
|
}
|
|
1440
|
-
|
|
1441
|
-
}
|
|
1442
|
-
/**
|
|
1443
|
-
* Loads the regional configuration for the account.
|
|
1444
|
-
* If the config is already loaded then this will do nothing.
|
|
1445
|
-
*/
|
|
1446
|
-
LoadConfig(params) {
|
|
1447
|
-
var _a, _b, _c;
|
|
1448
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1449
|
-
let { guardian, forceLoad } = (params !== null && params !== void 0 ? params : {});
|
|
1450
|
-
if (this.configLoadAttempted && forceLoad != true) {
|
|
1451
|
-
return;
|
|
1452
|
-
}
|
|
1453
|
-
this.configLoadAttempted = true;
|
|
1454
|
-
try {
|
|
1455
|
-
if (!guardian) {
|
|
1456
|
-
guardian = new GuardianApi.Api({
|
|
1457
|
-
env: this.env
|
|
1458
|
-
});
|
|
1459
|
-
}
|
|
1460
|
-
const { account } = yield Account.GetBySubdomain({
|
|
1461
|
-
subdomain: this.accountId,
|
|
1462
|
-
api: guardian
|
|
1463
|
-
});
|
|
1464
|
-
// Precalculated URLs exist.
|
|
1465
|
-
// Soon this will be a stable requirement for any account record.
|
|
1466
|
-
if (account.URL) {
|
|
1467
|
-
if (!this.loadCancelled) {
|
|
1468
|
-
const urls = account.URL;
|
|
1469
|
-
if (urls === null || urls === void 0 ? void 0 : urls.Base) {
|
|
1470
|
-
this.baseUrl = urls.Base;
|
|
1471
|
-
}
|
|
1472
|
-
if (urls === null || urls === void 0 ? void 0 : urls.CDNEntities) {
|
|
1473
|
-
this.EntityCdnUrl = urls.CDNEntities;
|
|
1474
|
-
}
|
|
1475
|
-
if (urls === null || urls === void 0 ? void 0 : urls.CDNTileset) {
|
|
1476
|
-
this.TilesetCdnUrl = urls.CDNTileset;
|
|
1477
|
-
}
|
|
1478
|
-
if (urls === null || urls === void 0 ? void 0 : urls.CDNLegacyTileset) {
|
|
1479
|
-
this.LegacyTilesetCdnUrl = urls.CDNLegacyTileset;
|
|
1480
|
-
}
|
|
1481
|
-
if (urls === null || urls === void 0 ? void 0 : urls.CDNBase) {
|
|
1482
|
-
this.cdnBaseUrl = urls.CDNBase;
|
|
1483
|
-
}
|
|
1484
|
-
}
|
|
1485
|
-
}
|
|
1486
|
-
// Deprecated and will eventually stop working at all.
|
|
1487
|
-
else {
|
|
1488
|
-
const env = this.env.toUpperCase();
|
|
1489
|
-
const domain = this.getDomain();
|
|
1490
|
-
const host = yield HostingLocation.GetByAccountId({
|
|
1491
|
-
accountId: this.accountId,
|
|
1492
|
-
api: guardian
|
|
1493
|
-
});
|
|
1494
|
-
if (host === null || host === void 0 ? void 0 : host.location) {
|
|
1495
|
-
const settings = host.location.Settings;
|
|
1496
|
-
if (!this.loadCancelled) {
|
|
1497
|
-
// Attempt to load regional base url.
|
|
1498
|
-
// First try go through settings.
|
|
1499
|
-
let urlSet = false;
|
|
1500
|
-
if (settings === null || settings === void 0 ? void 0 : settings.BruceAPIURL) {
|
|
1501
|
-
let envUrl = settings.BruceAPIURL[env];
|
|
1502
|
-
if (envUrl) {
|
|
1503
|
-
envUrl = envUrl
|
|
1504
|
-
.replace("<ACCOUNTID>", this.accountId)
|
|
1505
|
-
.replace("<ACCOUNT>", this.accountId);
|
|
1506
|
-
if (envUrl && envUrl.length > 1) {
|
|
1507
|
-
this.baseUrl = envUrl;
|
|
1508
|
-
urlSet = true;
|
|
1509
|
-
}
|
|
1510
|
-
}
|
|
1511
|
-
}
|
|
1512
|
-
// Try go through host location's base url.
|
|
1513
|
-
// This may be wrong env which is why it's used as fallback right now.
|
|
1514
|
-
if (!urlSet && host.location.BruceAPIURL) {
|
|
1515
|
-
const regionalUrl = host.location.BruceAPIURL
|
|
1516
|
-
.replace("<ACCOUNTID>", this.accountId)
|
|
1517
|
-
.replace("<ACCOUNT>", this.accountId)
|
|
1518
|
-
.replace("<DOMAIN>", domain);
|
|
1519
|
-
if (regionalUrl && regionalUrl.length > 1) {
|
|
1520
|
-
this.baseUrl = regionalUrl;
|
|
1521
|
-
urlSet = true;
|
|
1522
|
-
}
|
|
1523
|
-
}
|
|
1524
|
-
}
|
|
1525
|
-
// Attempt to load CDN settings.
|
|
1526
|
-
if (settings === null || settings === void 0 ? void 0 : settings.CDN) {
|
|
1527
|
-
this.EntityCdnUrl = (_a = settings.CDN.entityURL) === null || _a === void 0 ? void 0 : _a[env];
|
|
1528
|
-
// We need to fix our configs.
|
|
1529
|
-
if (this.EntityCdnUrl) {
|
|
1530
|
-
if (this.EntityCdnUrl.includes("entitiesListForCDN")) {
|
|
1531
|
-
this.EntityCdnUrl = this.EntityCdnUrl.replace("<ACCOUNT>", this.accountId);
|
|
1532
|
-
}
|
|
1533
|
-
else {
|
|
1534
|
-
this.EntityCdnUrl = this.EntityCdnUrl.replace("<ACCOUNT>", "entitiesListForCDN/" + this.accountId);
|
|
1535
|
-
}
|
|
1536
|
-
}
|
|
1537
|
-
this.LegacyTilesetCdnUrl = (_b = settings.CDN.legacyTilesetURL) === null || _b === void 0 ? void 0 : _b[env];
|
|
1538
|
-
this.TilesetCdnUrl = (_c = settings.CDN.tilesetURL) === null || _c === void 0 ? void 0 : _c[env];
|
|
1539
|
-
if (this.TilesetCdnUrl) {
|
|
1540
|
-
this.TilesetCdnUrl = this.TilesetCdnUrl.replace("<ACCOUNT>", this.accountId);
|
|
1541
|
-
}
|
|
1542
|
-
// TilesetCdnUrl example: "https://blah.cloudfront.net/tilesets/<TILESETID>/files/<FILEPATH>?accountId=<ACCOUNT>".
|
|
1543
|
-
// Lazy at the moment to go around updating every region we have, I'll interpret the url from tilesetCdnUrl.
|
|
1544
|
-
if (this.TilesetCdnUrl) {
|
|
1545
|
-
try {
|
|
1546
|
-
const url = new URL(this.TilesetCdnUrl);
|
|
1547
|
-
this.cdnBaseUrl = `${url.protocol}//${url.hostname}/`;
|
|
1548
|
-
}
|
|
1549
|
-
catch (e) {
|
|
1550
|
-
console.error(e);
|
|
1551
|
-
}
|
|
1552
|
-
}
|
|
1553
|
-
}
|
|
1554
|
-
}
|
|
1555
|
-
}
|
|
1556
|
-
}
|
|
1557
|
-
catch (e) {
|
|
1558
|
-
console.error(e);
|
|
1559
|
-
}
|
|
1560
|
-
});
|
|
1561
|
-
}
|
|
1562
|
-
/**
|
|
1563
|
-
* Creates a message broker instance and returns it.
|
|
1564
|
-
* If an instance is already created, it will return that one.
|
|
1565
|
-
* @warning This will await the loading promise to avoid using data that isn't ready.
|
|
1566
|
-
*/
|
|
1567
|
-
ConnectWebsocket() {
|
|
1568
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1569
|
-
yield this.loadProm;
|
|
1570
|
-
if (this.messageBroker) {
|
|
1571
|
-
return this.messageBroker;
|
|
1572
|
-
}
|
|
1573
|
-
this.messageBroker = new MessageBroker.WebSocketBroker(this.baseUrl, this.env);
|
|
1574
|
-
return this.messageBroker;
|
|
1575
|
-
});
|
|
1309
|
+
this.baseUrl = url;
|
|
1576
1310
|
}
|
|
1577
1311
|
/**
|
|
1578
|
-
*
|
|
1579
|
-
* This means the url could be changed once fully initialized.
|
|
1580
|
-
* The url will be valid either way, but the loaded one may be faster as it is region specific.
|
|
1581
|
-
* Await the "Loading" promise if you care about this.
|
|
1312
|
+
* Gets the base url for this api.
|
|
1582
1313
|
* @returns
|
|
1583
1314
|
*/
|
|
1584
1315
|
GetBaseUrl() {
|
|
1585
1316
|
return this.baseUrl;
|
|
1586
1317
|
}
|
|
1587
1318
|
/**
|
|
1588
|
-
*
|
|
1589
|
-
* @returns
|
|
1590
|
-
*/
|
|
1591
|
-
GetCdnBaseUrl() {
|
|
1592
|
-
return this.cdnBaseUrl;
|
|
1593
|
-
}
|
|
1594
|
-
/**
|
|
1595
|
-
* Returns a url routed through the API's CDN.
|
|
1596
|
-
* If the CDN is not enabled for the account, this will return null.
|
|
1597
|
-
* @param url suffix to append to the base url.
|
|
1598
|
-
* @param urlParams
|
|
1599
|
-
* @returns
|
|
1600
|
-
*/
|
|
1601
|
-
ConstructCdnUrl(url, urlParams) {
|
|
1602
|
-
if (!this.cdnBaseUrl) {
|
|
1603
|
-
return null;
|
|
1604
|
-
}
|
|
1605
|
-
const tmp = new URL(this.cdnBaseUrl);
|
|
1606
|
-
if (urlParams && urlParams instanceof URLSearchParams) {
|
|
1607
|
-
urlParams.forEach((value, key) => {
|
|
1608
|
-
tmp.searchParams.append(key, value);
|
|
1609
|
-
});
|
|
1610
|
-
}
|
|
1611
|
-
if (url) {
|
|
1612
|
-
tmp.pathname += url;
|
|
1613
|
-
}
|
|
1614
|
-
return tmp.toString();
|
|
1615
|
-
}
|
|
1616
|
-
/**
|
|
1617
|
-
* Warning: This will cancel the init process.
|
|
1618
|
-
* The init process loads a region specific endpoint.
|
|
1619
|
-
* Setting a base url will stop that process from completing.
|
|
1319
|
+
* Sets the base url for this api.
|
|
1620
1320
|
* @param url
|
|
1621
1321
|
*/
|
|
1622
1322
|
SetBaseUrl(url) {
|
|
@@ -1624,7 +1324,6 @@ var BruceApi;
|
|
|
1624
1324
|
if (!this.baseUrl.endsWith("/")) {
|
|
1625
1325
|
this.baseUrl += "/";
|
|
1626
1326
|
}
|
|
1627
|
-
this.loadCancelled = true;
|
|
1628
1327
|
}
|
|
1629
1328
|
/**
|
|
1630
1329
|
* Performs an HTTP GET request.
|
|
@@ -1635,11 +1334,7 @@ var BruceApi;
|
|
|
1635
1334
|
*/
|
|
1636
1335
|
GET(url, params) {
|
|
1637
1336
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1638
|
-
return
|
|
1639
|
-
this.loadProm.then(() => {
|
|
1640
|
-
this.get(this.baseUrl + url, params).then(res).catch(rej);
|
|
1641
|
-
}).catch(rej);
|
|
1642
|
-
});
|
|
1337
|
+
return this.get(this.baseUrl + url, params);
|
|
1643
1338
|
});
|
|
1644
1339
|
}
|
|
1645
1340
|
/**
|
|
@@ -1651,11 +1346,7 @@ var BruceApi;
|
|
|
1651
1346
|
*/
|
|
1652
1347
|
DELETE(url, params) {
|
|
1653
1348
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1654
|
-
return
|
|
1655
|
-
this.loadProm.then(() => {
|
|
1656
|
-
this.delete(this.baseUrl + url, params).then(res).catch(rej);
|
|
1657
|
-
}).catch(rej);
|
|
1658
|
-
});
|
|
1349
|
+
return this.delete(this.baseUrl + url, params);
|
|
1659
1350
|
});
|
|
1660
1351
|
}
|
|
1661
1352
|
/**
|
|
@@ -1668,28 +1359,7 @@ var BruceApi;
|
|
|
1668
1359
|
*/
|
|
1669
1360
|
POST(url, data, params) {
|
|
1670
1361
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1671
|
-
return
|
|
1672
|
-
this.loadProm.then(() => {
|
|
1673
|
-
this.post(this.baseUrl + url, data, params).then(res).catch(rej);
|
|
1674
|
-
}).catch(rej);
|
|
1675
|
-
});
|
|
1676
|
-
});
|
|
1677
|
-
}
|
|
1678
|
-
/**
|
|
1679
|
-
* Performs an HTTP PUT request.
|
|
1680
|
-
* This will prepend the base url to the url.
|
|
1681
|
-
* @param url
|
|
1682
|
-
* @param data
|
|
1683
|
-
* @param params
|
|
1684
|
-
* @returns
|
|
1685
|
-
*/
|
|
1686
|
-
PUT(url, data, params) {
|
|
1687
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1688
|
-
return new Promise((res, rej) => {
|
|
1689
|
-
this.loadProm.then(() => {
|
|
1690
|
-
this.put(this.baseUrl + url, data, params).then(res).catch(rej);
|
|
1691
|
-
}).catch(rej);
|
|
1692
|
-
});
|
|
1362
|
+
return this.post(this.baseUrl + url, data, params);
|
|
1693
1363
|
});
|
|
1694
1364
|
}
|
|
1695
1365
|
/**
|
|
@@ -1702,146 +1372,31 @@ var BruceApi;
|
|
|
1702
1372
|
*/
|
|
1703
1373
|
UPLOAD(url, blob, params) {
|
|
1704
1374
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1705
|
-
return
|
|
1706
|
-
this.loadProm.then(() => {
|
|
1707
|
-
this.upload(this.baseUrl + url, blob, params).then(res).catch(rej);
|
|
1708
|
-
}).catch(rej);
|
|
1709
|
-
});
|
|
1375
|
+
return this.upload(this.baseUrl + url, blob, params);
|
|
1710
1376
|
});
|
|
1711
1377
|
}
|
|
1712
1378
|
}
|
|
1713
|
-
|
|
1714
|
-
})(
|
|
1379
|
+
GlobalApi.Api = Api$$1;
|
|
1380
|
+
})(GlobalApi || (GlobalApi = {}));
|
|
1715
1381
|
|
|
1716
1382
|
/**
|
|
1717
|
-
*
|
|
1718
|
-
*
|
|
1719
|
-
*
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
*/
|
|
1735
|
-
setBaseUrl() {
|
|
1736
|
-
let url;
|
|
1737
|
-
const env = this.env.toUpperCase();
|
|
1738
|
-
switch (env) {
|
|
1739
|
-
case Api.EEnv.DEV:
|
|
1740
|
-
url = "https://bruceglobal.nextspace-dev.net/";
|
|
1741
|
-
break;
|
|
1742
|
-
case Api.EEnv.STG:
|
|
1743
|
-
url = "https://bruceglobal.nextspace-stg.net/";
|
|
1744
|
-
break;
|
|
1745
|
-
case Api.EEnv.UAT:
|
|
1746
|
-
url = "https://bruceglobal.api.nextspace-uat.net/";
|
|
1747
|
-
break;
|
|
1748
|
-
case Api.EEnv.PROD:
|
|
1749
|
-
url = "https://bruceglobal.api.nextspace.host/";
|
|
1750
|
-
break;
|
|
1751
|
-
default:
|
|
1752
|
-
throw ("Specified Environment is not valid. SuppliedEnv=" + env);
|
|
1753
|
-
}
|
|
1754
|
-
this.baseUrl = url;
|
|
1755
|
-
}
|
|
1756
|
-
/**
|
|
1757
|
-
* Gets the base url for this api.
|
|
1758
|
-
* @returns
|
|
1759
|
-
*/
|
|
1760
|
-
GetBaseUrl() {
|
|
1761
|
-
return this.baseUrl;
|
|
1762
|
-
}
|
|
1763
|
-
/**
|
|
1764
|
-
* Sets the base url for this api.
|
|
1765
|
-
* @param url
|
|
1766
|
-
*/
|
|
1767
|
-
SetBaseUrl(url) {
|
|
1768
|
-
this.baseUrl = url;
|
|
1769
|
-
if (!this.baseUrl.endsWith("/")) {
|
|
1770
|
-
this.baseUrl += "/";
|
|
1771
|
-
}
|
|
1772
|
-
}
|
|
1773
|
-
/**
|
|
1774
|
-
* Performs an HTTP GET request.
|
|
1775
|
-
* This will prepend the base url to the url.
|
|
1776
|
-
* @param url
|
|
1777
|
-
* @param params
|
|
1778
|
-
* @returns
|
|
1779
|
-
*/
|
|
1780
|
-
GET(url, params) {
|
|
1781
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1782
|
-
return this.get(this.baseUrl + url, params);
|
|
1783
|
-
});
|
|
1784
|
-
}
|
|
1785
|
-
/**
|
|
1786
|
-
* Performs an HTTP DELETE request.
|
|
1787
|
-
* This will prepend the base url to the url.
|
|
1788
|
-
* @param url
|
|
1789
|
-
* @param params
|
|
1790
|
-
* @returns
|
|
1791
|
-
*/
|
|
1792
|
-
DELETE(url, params) {
|
|
1793
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1794
|
-
return this.delete(this.baseUrl + url, params);
|
|
1795
|
-
});
|
|
1796
|
-
}
|
|
1797
|
-
/**
|
|
1798
|
-
* Performs an HTTP POST request.
|
|
1799
|
-
* This will prepend the base url to the url.
|
|
1800
|
-
* @param url
|
|
1801
|
-
* @param data
|
|
1802
|
-
* @param params
|
|
1803
|
-
* @returns
|
|
1804
|
-
*/
|
|
1805
|
-
POST(url, data, params) {
|
|
1806
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1807
|
-
return this.post(this.baseUrl + url, data, params);
|
|
1808
|
-
});
|
|
1809
|
-
}
|
|
1810
|
-
/**
|
|
1811
|
-
* Performs a file upload request (HTTP POST).
|
|
1812
|
-
* This will prepend the base url to the url.
|
|
1813
|
-
* @param url
|
|
1814
|
-
* @param blob
|
|
1815
|
-
* @param params
|
|
1816
|
-
* @returns
|
|
1817
|
-
*/
|
|
1818
|
-
UPLOAD(url, blob, params) {
|
|
1819
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1820
|
-
return this.upload(this.baseUrl + url, blob, params);
|
|
1821
|
-
});
|
|
1822
|
-
}
|
|
1823
|
-
}
|
|
1824
|
-
GlobalApi.Api = Api$$1;
|
|
1825
|
-
})(GlobalApi || (GlobalApi = {}));
|
|
1826
|
-
|
|
1827
|
-
/**
|
|
1828
|
-
* Utility for managing multiple API instances.
|
|
1829
|
-
* Example: {
|
|
1830
|
-
* const api = new ApiGetters({
|
|
1831
|
-
* accountId: "123",
|
|
1832
|
-
* env: Api.EEnv.PROD
|
|
1833
|
-
* });
|
|
1834
|
-
*
|
|
1835
|
-
* // Returns default API instance specified in constructor.
|
|
1836
|
-
* const bruce1 = api.GetBruceApi();
|
|
1837
|
-
* // Returns API instance for account 456.
|
|
1838
|
-
* const bruce2 = api.GetBruceApi({
|
|
1839
|
-
* accountId: "456"
|
|
1840
|
-
* });
|
|
1841
|
-
*
|
|
1842
|
-
* const global = api.GetGlobalApi();
|
|
1843
|
-
* const guardian = api.GetGuardianApi();
|
|
1844
|
-
* }
|
|
1383
|
+
* Utility for managing multiple API instances.
|
|
1384
|
+
* Example: {
|
|
1385
|
+
* const api = new ApiGetters({
|
|
1386
|
+
* accountId: "123",
|
|
1387
|
+
* env: Api.EEnv.PROD
|
|
1388
|
+
* });
|
|
1389
|
+
*
|
|
1390
|
+
* // Returns default API instance specified in constructor.
|
|
1391
|
+
* const bruce1 = api.GetBruceApi();
|
|
1392
|
+
* // Returns API instance for account 456.
|
|
1393
|
+
* const bruce2 = api.GetBruceApi({
|
|
1394
|
+
* accountId: "456"
|
|
1395
|
+
* });
|
|
1396
|
+
*
|
|
1397
|
+
* const global = api.GetGlobalApi();
|
|
1398
|
+
* const guardian = api.GetGuardianApi();
|
|
1399
|
+
* }
|
|
1845
1400
|
*/
|
|
1846
1401
|
class ApiGetters {
|
|
1847
1402
|
constructor(params) {
|
|
@@ -4219,17 +3774,7 @@ var Entity;
|
|
|
4219
3774
|
let totalCount;
|
|
4220
3775
|
let entities = [];
|
|
4221
3776
|
if (analysis || expandRelations || (viaCdn && api.GetCdnBaseUrl())) {
|
|
4222
|
-
|
|
4223
|
-
if (analysis) {
|
|
4224
|
-
url = new URL(api.GetBaseUrl() + "entities/summary");
|
|
4225
|
-
}
|
|
4226
|
-
else if (viaCdn && api.GetCdnBaseUrl()) {
|
|
4227
|
-
url = new URL(api.ConstructCdnUrl("entities"));
|
|
4228
|
-
}
|
|
4229
|
-
else {
|
|
4230
|
-
url = new URL(api.GetBaseUrl() + "entities");
|
|
4231
|
-
}
|
|
4232
|
-
const urlParams = url.searchParams;
|
|
3777
|
+
const urlParams = new URLSearchParams();
|
|
4233
3778
|
urlParams.set("cacheToken", String(viaCdnCacheToken ? viaCdnCacheToken : 0));
|
|
4234
3779
|
if (body.SortOrder) {
|
|
4235
3780
|
urlParams.set("SortOrder", body.SortOrder);
|
|
@@ -4277,7 +3822,11 @@ var Entity;
|
|
|
4277
3822
|
urlParams.set("schema", schemaId);
|
|
4278
3823
|
}
|
|
4279
3824
|
urlParams.set("hasMigrated", String(Boolean(migrated)));
|
|
4280
|
-
const urlStr =
|
|
3825
|
+
const urlStr = api.ConstructUrl({
|
|
3826
|
+
cdn: !analysis && viaCdn,
|
|
3827
|
+
url: analysis ? "entities/summary" : "entities",
|
|
3828
|
+
urlParams: urlParams
|
|
3829
|
+
});
|
|
4281
3830
|
const data = yield api.get(urlStr, Api.PrepReqParams(reqParams));
|
|
4282
3831
|
if (!analysis) {
|
|
4283
3832
|
entities = data.Items;
|
|
@@ -4285,8 +3834,7 @@ var Entity;
|
|
|
4285
3834
|
totalCount = data.TotalCount;
|
|
4286
3835
|
}
|
|
4287
3836
|
else {
|
|
4288
|
-
const
|
|
4289
|
-
const urlParams = url.searchParams;
|
|
3837
|
+
const urlParams = new URLSearchParams();
|
|
4290
3838
|
if (expandRelations) {
|
|
4291
3839
|
urlParams.append("$expand", "relation");
|
|
4292
3840
|
}
|
|
@@ -4297,7 +3845,11 @@ var Entity;
|
|
|
4297
3845
|
urlParams.set("schema", schemaId);
|
|
4298
3846
|
}
|
|
4299
3847
|
urlParams.set("hasMigrated", String(Boolean(migrated)));
|
|
4300
|
-
const urlStr =
|
|
3848
|
+
const urlStr = api.ConstructUrl({
|
|
3849
|
+
cdn: false,
|
|
3850
|
+
url: analysis ? "entities/summary" : "entities",
|
|
3851
|
+
urlParams: urlParams
|
|
3852
|
+
});
|
|
4301
3853
|
const data = yield api.post(urlStr, body, Api.PrepReqParams(reqParams));
|
|
4302
3854
|
if (!analysis) {
|
|
4303
3855
|
entities = data.Items;
|
|
@@ -6215,12 +5767,13 @@ var EntityLod;
|
|
|
6215
5767
|
if (!level) {
|
|
6216
5768
|
level = 0;
|
|
6217
5769
|
}
|
|
6218
|
-
let url = api.GetBaseUrl() + `entity/${entityId}/lod/${categoryId}/${level}`;
|
|
6219
|
-
if (strict) {
|
|
6220
|
-
url = url + "?strict=true";
|
|
6221
|
-
}
|
|
6222
5770
|
return {
|
|
6223
|
-
url:
|
|
5771
|
+
url: api.ConstructUrl({
|
|
5772
|
+
url: `entity/${entityId}/lod/${categoryId}/${level}`,
|
|
5773
|
+
urlParams: {
|
|
5774
|
+
"strict": strict ? "true" : "false"
|
|
5775
|
+
}
|
|
5776
|
+
})
|
|
6224
5777
|
};
|
|
6225
5778
|
}
|
|
6226
5779
|
EntityLod.GetUrl = GetUrl;
|
|
@@ -8424,13 +7977,13 @@ var Uploader;
|
|
|
8424
7977
|
* A client file is a record of a file uploaded to Bruce.
|
|
8425
7978
|
*/
|
|
8426
7979
|
var ClientFile;
|
|
8427
|
-
(function (ClientFile
|
|
7980
|
+
(function (ClientFile) {
|
|
8428
7981
|
let EPurpose;
|
|
8429
7982
|
(function (EPurpose) {
|
|
8430
7983
|
// Use this purpose for uploading bookmark thumbnail images.
|
|
8431
7984
|
// This will allow lower level privileges to upload (small) bookmark thumbnails.
|
|
8432
7985
|
EPurpose["BookmarkThumbnail"] = "Bookmark Thumbnail";
|
|
8433
|
-
})(EPurpose = ClientFile
|
|
7986
|
+
})(EPurpose = ClientFile.EPurpose || (ClientFile.EPurpose = {}));
|
|
8434
7987
|
/**
|
|
8435
7988
|
* Returns the URL for a client file.
|
|
8436
7989
|
* @param params
|
|
@@ -8441,17 +7994,16 @@ var ClientFile;
|
|
|
8441
7994
|
if (!api) {
|
|
8442
7995
|
api = ENVIRONMENT.Api().GetBruceApi();
|
|
8443
7996
|
}
|
|
8444
|
-
|
|
8445
|
-
|
|
8446
|
-
|
|
8447
|
-
|
|
8448
|
-
|
|
8449
|
-
|
|
8450
|
-
|
|
8451
|
-
|
|
8452
|
-
return url;
|
|
7997
|
+
return api.ConstructUrl({
|
|
7998
|
+
cdn: viaCdn,
|
|
7999
|
+
url: `file/${fileId}`,
|
|
8000
|
+
urlParams: {
|
|
8001
|
+
// Invalidating cache manually because we have a wave of invalid headers now cached across devices.
|
|
8002
|
+
cc: "1"
|
|
8003
|
+
}
|
|
8004
|
+
});
|
|
8453
8005
|
}
|
|
8454
|
-
ClientFile
|
|
8006
|
+
ClientFile.GetUrl = GetUrl;
|
|
8455
8007
|
/**
|
|
8456
8008
|
* Returns the URL for a client file with the extension.
|
|
8457
8009
|
* @param params
|
|
@@ -8470,16 +8022,16 @@ var ClientFile;
|
|
|
8470
8022
|
ext = "." + ext;
|
|
8471
8023
|
}
|
|
8472
8024
|
const urlSuffix = ext ? `file/${file.ID}${ext}` : `file/${file.ID}`;
|
|
8473
|
-
|
|
8474
|
-
|
|
8475
|
-
|
|
8476
|
-
|
|
8477
|
-
|
|
8478
|
-
|
|
8479
|
-
|
|
8480
|
-
|
|
8025
|
+
return api.ConstructUrl({
|
|
8026
|
+
cdn: viaCdn,
|
|
8027
|
+
url: urlSuffix,
|
|
8028
|
+
urlParams: {
|
|
8029
|
+
// Invalidating cache manually because we have a wave of invalid headers now cached across devices.
|
|
8030
|
+
cc: "1"
|
|
8031
|
+
}
|
|
8032
|
+
});
|
|
8481
8033
|
}
|
|
8482
|
-
ClientFile
|
|
8034
|
+
ClientFile.GetUrlWithExt = GetUrlWithExt;
|
|
8483
8035
|
/**
|
|
8484
8036
|
* Returns a client file record by ID.
|
|
8485
8037
|
* @param params
|
|
@@ -8518,7 +8070,7 @@ var ClientFile;
|
|
|
8518
8070
|
return prom;
|
|
8519
8071
|
});
|
|
8520
8072
|
}
|
|
8521
|
-
ClientFile
|
|
8073
|
+
ClientFile.Get = Get;
|
|
8522
8074
|
/**
|
|
8523
8075
|
* Deletes one or many client file records by IDs.
|
|
8524
8076
|
* @param params
|
|
@@ -8542,7 +8094,7 @@ var ClientFile;
|
|
|
8542
8094
|
}
|
|
8543
8095
|
});
|
|
8544
8096
|
}
|
|
8545
|
-
ClientFile
|
|
8097
|
+
ClientFile.Delete = Delete;
|
|
8546
8098
|
/**
|
|
8547
8099
|
* Uploads a file and creates a new client file record.
|
|
8548
8100
|
* @param params
|
|
@@ -8605,7 +8157,7 @@ var ClientFile;
|
|
|
8605
8157
|
};
|
|
8606
8158
|
});
|
|
8607
8159
|
}
|
|
8608
|
-
ClientFile
|
|
8160
|
+
ClientFile.Upload = Upload;
|
|
8609
8161
|
/**
|
|
8610
8162
|
* Updates the purpose of a client file.
|
|
8611
8163
|
* @param params
|
|
@@ -8626,7 +8178,7 @@ var ClientFile;
|
|
|
8626
8178
|
api.Cache.RemoveByContains(cacheKey);
|
|
8627
8179
|
});
|
|
8628
8180
|
}
|
|
8629
|
-
ClientFile
|
|
8181
|
+
ClientFile.UpdatePurpose = UpdatePurpose;
|
|
8630
8182
|
/**
|
|
8631
8183
|
* Uploads a temp file.
|
|
8632
8184
|
* This will return a temp file ID.
|
|
@@ -8676,7 +8228,7 @@ var ClientFile;
|
|
|
8676
8228
|
};
|
|
8677
8229
|
});
|
|
8678
8230
|
}
|
|
8679
|
-
ClientFile
|
|
8231
|
+
ClientFile.UploadTemp = UploadTemp;
|
|
8680
8232
|
/**
|
|
8681
8233
|
* Returns a dictionary of purpose counts for client files.
|
|
8682
8234
|
* @param params
|
|
@@ -8715,7 +8267,7 @@ var ClientFile;
|
|
|
8715
8267
|
return prom;
|
|
8716
8268
|
});
|
|
8717
8269
|
}
|
|
8718
|
-
ClientFile
|
|
8270
|
+
ClientFile.GetCountsPurpose = GetCountsPurpose;
|
|
8719
8271
|
/**
|
|
8720
8272
|
* Returns a dictionary of MIME type counts for client files.
|
|
8721
8273
|
* @param params
|
|
@@ -8754,7 +8306,7 @@ var ClientFile;
|
|
|
8754
8306
|
return prom;
|
|
8755
8307
|
});
|
|
8756
8308
|
}
|
|
8757
|
-
ClientFile
|
|
8309
|
+
ClientFile.GetCountsExtension = GetCountsExtension;
|
|
8758
8310
|
/**
|
|
8759
8311
|
* Returns a dictionary of MIME type counts for client files.
|
|
8760
8312
|
* @param params
|
|
@@ -8793,7 +8345,7 @@ var ClientFile;
|
|
|
8793
8345
|
return prom;
|
|
8794
8346
|
});
|
|
8795
8347
|
}
|
|
8796
|
-
ClientFile
|
|
8348
|
+
ClientFile.GetCountsMIMEType = GetCountsMIMEType;
|
|
8797
8349
|
/**
|
|
8798
8350
|
* Returns a dictionary of user counts for client files.
|
|
8799
8351
|
* @param params
|
|
@@ -8832,7 +8384,7 @@ var ClientFile;
|
|
|
8832
8384
|
return prom;
|
|
8833
8385
|
});
|
|
8834
8386
|
}
|
|
8835
|
-
ClientFile
|
|
8387
|
+
ClientFile.GetCountsUser = GetCountsUser;
|
|
8836
8388
|
/**
|
|
8837
8389
|
* Filter definitions for requesting a list of client files.
|
|
8838
8390
|
*/
|
|
@@ -8858,7 +8410,7 @@ var ClientFile;
|
|
|
8858
8410
|
ERowOperator["AND"] = "AND";
|
|
8859
8411
|
ERowOperator["OR"] = "OR";
|
|
8860
8412
|
})(ERowOperator = Filter.ERowOperator || (Filter.ERowOperator = {}));
|
|
8861
|
-
})(Filter = ClientFile
|
|
8413
|
+
})(Filter = ClientFile.Filter || (ClientFile.Filter = {}));
|
|
8862
8414
|
/**
|
|
8863
8415
|
* Returns a list of client files matching the filter.
|
|
8864
8416
|
* @param params
|
|
@@ -8877,7 +8429,7 @@ var ClientFile;
|
|
|
8877
8429
|
};
|
|
8878
8430
|
});
|
|
8879
8431
|
}
|
|
8880
|
-
ClientFile
|
|
8432
|
+
ClientFile.GetList = GetList;
|
|
8881
8433
|
/**
|
|
8882
8434
|
* Deletes a list of client files matching the filter.
|
|
8883
8435
|
* @param params
|
|
@@ -8899,7 +8451,7 @@ var ClientFile;
|
|
|
8899
8451
|
};
|
|
8900
8452
|
});
|
|
8901
8453
|
}
|
|
8902
|
-
ClientFile
|
|
8454
|
+
ClientFile.DeleteList = DeleteList;
|
|
8903
8455
|
/**
|
|
8904
8456
|
* Utility for processing client files.
|
|
8905
8457
|
* Commonly used to convert a file to a different format. Eg: FBX to GLB.
|
|
@@ -8936,7 +8488,7 @@ var ClientFile;
|
|
|
8936
8488
|
});
|
|
8937
8489
|
}
|
|
8938
8490
|
Processor.ConvertFormat = ConvertFormat;
|
|
8939
|
-
})(Processor = ClientFile
|
|
8491
|
+
})(Processor = ClientFile.Processor || (ClientFile.Processor = {}));
|
|
8940
8492
|
/**
|
|
8941
8493
|
* Returns cache identifier for a client file by ID.
|
|
8942
8494
|
* Example: {
|
|
@@ -8950,23 +8502,23 @@ var ClientFile;
|
|
|
8950
8502
|
function GetCacheKey(fileId) {
|
|
8951
8503
|
return `${Api.ECacheKey.ClientFile}${Api.ECacheKey.Id}${fileId}`;
|
|
8952
8504
|
}
|
|
8953
|
-
ClientFile
|
|
8505
|
+
ClientFile.GetCacheKey = GetCacheKey;
|
|
8954
8506
|
function GetCountsPurposeCacheKey() {
|
|
8955
8507
|
return `${Api.ECacheKey.ClientFile}${Api.ECacheKey.ClientFileCountsPurpose}`;
|
|
8956
8508
|
}
|
|
8957
|
-
ClientFile
|
|
8509
|
+
ClientFile.GetCountsPurposeCacheKey = GetCountsPurposeCacheKey;
|
|
8958
8510
|
function GetCountsExtensionCacheKey() {
|
|
8959
8511
|
return `${Api.ECacheKey.ClientFile}${Api.ECacheKey.ClientFileCountsExtension}`;
|
|
8960
8512
|
}
|
|
8961
|
-
ClientFile
|
|
8513
|
+
ClientFile.GetCountsExtensionCacheKey = GetCountsExtensionCacheKey;
|
|
8962
8514
|
function GetCountsMIMETypeCacheKey() {
|
|
8963
8515
|
return `${Api.ECacheKey.ClientFile}${Api.ECacheKey.ClientFileCountsMIMEType}`;
|
|
8964
8516
|
}
|
|
8965
|
-
ClientFile
|
|
8517
|
+
ClientFile.GetCountsMIMETypeCacheKey = GetCountsMIMETypeCacheKey;
|
|
8966
8518
|
function GetCountsUserCacheKey() {
|
|
8967
8519
|
return `${Api.ECacheKey.ClientFile}${Api.ECacheKey.ClientFileCountsUser}`;
|
|
8968
8520
|
}
|
|
8969
|
-
ClientFile
|
|
8521
|
+
ClientFile.GetCountsUserCacheKey = GetCountsUserCacheKey;
|
|
8970
8522
|
})(ClientFile || (ClientFile = {}));
|
|
8971
8523
|
|
|
8972
8524
|
/**
|
|
@@ -9618,23 +9170,13 @@ var Tileset;
|
|
|
9618
9170
|
if (!file) {
|
|
9619
9171
|
file = "";
|
|
9620
9172
|
}
|
|
9621
|
-
|
|
9622
|
-
|
|
9623
|
-
|
|
9624
|
-
|
|
9625
|
-
|
|
9626
|
-
if (cacheToken != null) {
|
|
9627
|
-
urlParams.append("cacheToken", String(cacheToken));
|
|
9628
|
-
}
|
|
9629
|
-
url = api.ConstructCdnUrl(url, urlParams);
|
|
9630
|
-
}
|
|
9631
|
-
else {
|
|
9632
|
-
url = api.GetBaseUrl() + `v3/tilesets/${tilesetId}/files/${legacy ? "" : "files/"}${file}`;
|
|
9633
|
-
if (cacheToken != null) {
|
|
9634
|
-
url += `?cacheToken=${cacheToken}`;
|
|
9173
|
+
return api.ConstructUrl({
|
|
9174
|
+
cdn: viaCdn,
|
|
9175
|
+
url: `v3/tilesets/${tilesetId}/files/${legacy ? "" : "files/"}${file}`,
|
|
9176
|
+
urlParams: {
|
|
9177
|
+
"cacheToken": String(cacheToken ? cacheToken : 0)
|
|
9635
9178
|
}
|
|
9636
|
-
}
|
|
9637
|
-
return url;
|
|
9179
|
+
});
|
|
9638
9180
|
}
|
|
9639
9181
|
Tileset$$1.GetFileUrl = GetFileUrl;
|
|
9640
9182
|
/**
|
|
@@ -9653,7 +9195,9 @@ var Tileset;
|
|
|
9653
9195
|
if (!file) {
|
|
9654
9196
|
file = "";
|
|
9655
9197
|
}
|
|
9656
|
-
return api.
|
|
9198
|
+
return api.ConstructUrl({
|
|
9199
|
+
url: `tileset/getFile/${tilesetId}/src/${file}`
|
|
9200
|
+
});
|
|
9657
9201
|
}
|
|
9658
9202
|
Tileset$$1.GetSrcFileUrl = GetSrcFileUrl;
|
|
9659
9203
|
/**
|
|
@@ -9673,16 +9217,13 @@ var Tileset;
|
|
|
9673
9217
|
if (!file) {
|
|
9674
9218
|
file = "";
|
|
9675
9219
|
}
|
|
9676
|
-
|
|
9677
|
-
|
|
9678
|
-
|
|
9679
|
-
|
|
9220
|
+
return api.ConstructUrl({
|
|
9221
|
+
cdn: viaCdn,
|
|
9222
|
+
url: `tileset/file/${tilesetId}/${file}`,
|
|
9223
|
+
urlParams: {
|
|
9224
|
+
"cacheToken": String(viaCdnCacheToken ? viaCdnCacheToken : 0)
|
|
9680
9225
|
}
|
|
9681
|
-
|
|
9682
|
-
urlParams.append("cacheToken", String(viaCdnCacheToken));
|
|
9683
|
-
return api.ConstructCdnUrl(`tileset/file/${tilesetId}/${file}`, urlParams);
|
|
9684
|
-
}
|
|
9685
|
-
return api.GetBaseUrl() + `tileset/file/${tilesetId}/${file}`;
|
|
9226
|
+
});
|
|
9686
9227
|
}
|
|
9687
9228
|
Tileset$$1.GetPublicFileUrl = GetPublicFileUrl;
|
|
9688
9229
|
/**
|
|
@@ -10020,203 +9561,881 @@ var MenuItem;
|
|
|
10020
9561
|
}
|
|
10021
9562
|
MenuItem.CreateFromEntityId = CreateFromEntityId;
|
|
10022
9563
|
/**
|
|
10023
|
-
* Creates a menu item for an entity type.
|
|
10024
|
-
* @param typeId
|
|
10025
|
-
* @param styleId
|
|
10026
|
-
* @returns
|
|
9564
|
+
* Creates a menu item for an entity type.
|
|
9565
|
+
* @param typeId
|
|
9566
|
+
* @param styleId
|
|
9567
|
+
* @returns
|
|
9568
|
+
*/
|
|
9569
|
+
function CreateFromTypeId(typeId, styleId) {
|
|
9570
|
+
return {
|
|
9571
|
+
id: ObjectUtils.UId(),
|
|
9572
|
+
Type: EType.Entities,
|
|
9573
|
+
Caption: "Generated Entity Type Menu Item",
|
|
9574
|
+
BruceEntity: {
|
|
9575
|
+
"EntityType.ID": typeId
|
|
9576
|
+
},
|
|
9577
|
+
CameraZoomSettings: [
|
|
9578
|
+
{
|
|
9579
|
+
DisplayType: ZoomControl.EDisplayType.Model3D,
|
|
9580
|
+
MaxZoom: 100000,
|
|
9581
|
+
MinZoom: 0,
|
|
9582
|
+
StyleID: styleId
|
|
9583
|
+
}
|
|
9584
|
+
]
|
|
9585
|
+
};
|
|
9586
|
+
}
|
|
9587
|
+
MenuItem.CreateFromTypeId = CreateFromTypeId;
|
|
9588
|
+
/**
|
|
9589
|
+
* Creates a menu item for a tileset.
|
|
9590
|
+
* @param tilesetId
|
|
9591
|
+
* @param type
|
|
9592
|
+
* @returns
|
|
9593
|
+
*/
|
|
9594
|
+
function CreateFromTilesetId(tilesetId, type) {
|
|
9595
|
+
if (type === Tileset.EType.Cad) {
|
|
9596
|
+
return {
|
|
9597
|
+
id: ObjectUtils.UId(),
|
|
9598
|
+
Type: EType.CadTileset,
|
|
9599
|
+
Caption: "Generated CAD Menu Item",
|
|
9600
|
+
FlyTo: false,
|
|
9601
|
+
tileset: {
|
|
9602
|
+
TilesetID: tilesetId
|
|
9603
|
+
}
|
|
9604
|
+
};
|
|
9605
|
+
}
|
|
9606
|
+
else if (type == Tileset.EType.EntitiesSet) {
|
|
9607
|
+
return {
|
|
9608
|
+
id: ObjectUtils.UId(),
|
|
9609
|
+
Type: EType.EntityTileset,
|
|
9610
|
+
Caption: "Generated Entities Menu Item",
|
|
9611
|
+
FlyTo: false,
|
|
9612
|
+
tileset: {
|
|
9613
|
+
TilesetID: tilesetId
|
|
9614
|
+
}
|
|
9615
|
+
};
|
|
9616
|
+
}
|
|
9617
|
+
else if (type == Tileset.EType.PointCloud) {
|
|
9618
|
+
return {
|
|
9619
|
+
id: ObjectUtils.UId(),
|
|
9620
|
+
Type: EType.PointCloud,
|
|
9621
|
+
Caption: "Generated Point Cloud Menu Item",
|
|
9622
|
+
FlyTo: false,
|
|
9623
|
+
tileset: {
|
|
9624
|
+
TilesetID: tilesetId
|
|
9625
|
+
}
|
|
9626
|
+
};
|
|
9627
|
+
}
|
|
9628
|
+
else if (type == Tileset.EType.EntitiesMap) {
|
|
9629
|
+
return {
|
|
9630
|
+
id: ObjectUtils.UId(),
|
|
9631
|
+
Type: EType.EntityRaster,
|
|
9632
|
+
Caption: "Generated Entities Menu Item",
|
|
9633
|
+
tileset: {
|
|
9634
|
+
TilesetID: tilesetId
|
|
9635
|
+
}
|
|
9636
|
+
};
|
|
9637
|
+
}
|
|
9638
|
+
throw ("Tileset type not supported.");
|
|
9639
|
+
}
|
|
9640
|
+
MenuItem.CreateFromTilesetId = CreateFromTilesetId;
|
|
9641
|
+
})(MenuItem || (MenuItem = {}));
|
|
9642
|
+
|
|
9643
|
+
/**
|
|
9644
|
+
* Describe the "Project View Bookmark" concept within Nextspace.
|
|
9645
|
+
* This is referred to as "slides" in older code.
|
|
9646
|
+
*
|
|
9647
|
+
* A bookmark is a snapshot of what should be displayed and how in a particular project view.
|
|
9648
|
+
*/
|
|
9649
|
+
var ProjectViewBookmark;
|
|
9650
|
+
(function (ProjectViewBookmark) {
|
|
9651
|
+
// This is the expected default version for the DataVersion value.
|
|
9652
|
+
// This value should NOT be changed without looking at our API and seeing what the default value is.
|
|
9653
|
+
ProjectViewBookmark.DEFAULT_DATA_VERSION = 2;
|
|
9654
|
+
/**
|
|
9655
|
+
* Describes the content of a bookmark.
|
|
9656
|
+
* As part of a deal we've been commissioned to create an alternative bookmark type to embed content.
|
|
9657
|
+
*/
|
|
9658
|
+
let EContentType;
|
|
9659
|
+
(function (EContentType) {
|
|
9660
|
+
EContentType["WEB_3D"] = "WEB_3D";
|
|
9661
|
+
EContentType["IFRAME"] = "IFRAME";
|
|
9662
|
+
})(EContentType = ProjectViewBookmark.EContentType || (ProjectViewBookmark.EContentType = {}));
|
|
9663
|
+
/**
|
|
9664
|
+
* Gets a bookmark record.
|
|
9665
|
+
* @param params
|
|
9666
|
+
* @returns
|
|
9667
|
+
*/
|
|
9668
|
+
function Get(params) {
|
|
9669
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
9670
|
+
let { api, viewId, bookmarkId, req: reqParams } = params;
|
|
9671
|
+
if (!viewId || !bookmarkId) {
|
|
9672
|
+
throw ("View ID and Bookmark ID are required.");
|
|
9673
|
+
}
|
|
9674
|
+
if (!api) {
|
|
9675
|
+
api = ENVIRONMENT.Api().GetBruceApi();
|
|
9676
|
+
}
|
|
9677
|
+
const key = GetCacheKey(viewId, bookmarkId);
|
|
9678
|
+
const cache = yield api.GetCacheItem(key, reqParams);
|
|
9679
|
+
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
9680
|
+
return cache.data;
|
|
9681
|
+
}
|
|
9682
|
+
const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
9683
|
+
try {
|
|
9684
|
+
const data = yield api.GET(`ui.view/${viewId}/slide/${bookmarkId}`, Api.PrepReqParams(reqParams));
|
|
9685
|
+
res({
|
|
9686
|
+
bookmark: data
|
|
9687
|
+
});
|
|
9688
|
+
}
|
|
9689
|
+
catch (e) {
|
|
9690
|
+
rej(e);
|
|
9691
|
+
}
|
|
9692
|
+
}));
|
|
9693
|
+
yield api.SetCacheItem({
|
|
9694
|
+
key,
|
|
9695
|
+
value: prom,
|
|
9696
|
+
req: reqParams
|
|
9697
|
+
});
|
|
9698
|
+
return prom;
|
|
9699
|
+
});
|
|
9700
|
+
}
|
|
9701
|
+
ProjectViewBookmark.Get = Get;
|
|
9702
|
+
/**
|
|
9703
|
+
* Deletes a bookmark record.
|
|
9704
|
+
* @param params
|
|
9705
|
+
*/
|
|
9706
|
+
function Delete(params) {
|
|
9707
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
9708
|
+
let { api, viewId, bookmarkId, req: reqParams } = params;
|
|
9709
|
+
if (!viewId || !bookmarkId) {
|
|
9710
|
+
throw ("View ID and Bookmark ID are required.");
|
|
9711
|
+
}
|
|
9712
|
+
if (!api) {
|
|
9713
|
+
api = ENVIRONMENT.Api().GetBruceApi();
|
|
9714
|
+
}
|
|
9715
|
+
yield api.DELETE(`ui.view/${viewId}/slide/${bookmarkId}`, Api.PrepReqParams(reqParams));
|
|
9716
|
+
api.Cache.Remove(GetCacheKey(viewId, bookmarkId));
|
|
9717
|
+
api.Cache.Remove(GetListCacheKey(viewId));
|
|
9718
|
+
});
|
|
9719
|
+
}
|
|
9720
|
+
ProjectViewBookmark.Delete = Delete;
|
|
9721
|
+
/**
|
|
9722
|
+
* Gets a list of bookmark records.
|
|
9723
|
+
* @param params
|
|
9724
|
+
* @returns
|
|
9725
|
+
*/
|
|
9726
|
+
function GetList(params) {
|
|
9727
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
9728
|
+
let { api, viewId, req: reqParams } = params;
|
|
9729
|
+
if (!viewId) {
|
|
9730
|
+
throw ("View ID is required.");
|
|
9731
|
+
}
|
|
9732
|
+
if (!api) {
|
|
9733
|
+
api = ENVIRONMENT.Api().GetBruceApi();
|
|
9734
|
+
}
|
|
9735
|
+
const cache = yield api.GetCacheItem(GetListCacheKey(viewId), reqParams);
|
|
9736
|
+
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
9737
|
+
return cache.data;
|
|
9738
|
+
}
|
|
9739
|
+
const req = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
9740
|
+
try {
|
|
9741
|
+
const data = yield api.GET(`ui.view/${viewId}/slides`, Api.PrepReqParams(reqParams));
|
|
9742
|
+
const items = data.Items ? data.Items : [];
|
|
9743
|
+
// Cache individual items.
|
|
9744
|
+
// Maybe better to load list cache when getting 1 slide and seeing if it's in there.
|
|
9745
|
+
// WARNING: Right now the data matches, in the future the list may contain a shortened result.
|
|
9746
|
+
for (let i = 0; i < items.length; i++) {
|
|
9747
|
+
const item = items[i];
|
|
9748
|
+
const prom = new Promise((res) => {
|
|
9749
|
+
res({
|
|
9750
|
+
bookmark: item
|
|
9751
|
+
});
|
|
9752
|
+
});
|
|
9753
|
+
yield api.SetCacheItem({
|
|
9754
|
+
key: GetCacheKey(viewId, item.ID),
|
|
9755
|
+
value: prom,
|
|
9756
|
+
req: reqParams
|
|
9757
|
+
});
|
|
9758
|
+
}
|
|
9759
|
+
res({
|
|
9760
|
+
bookmarks: items
|
|
9761
|
+
});
|
|
9762
|
+
}
|
|
9763
|
+
catch (e) {
|
|
9764
|
+
rej(e);
|
|
9765
|
+
}
|
|
9766
|
+
}));
|
|
9767
|
+
yield api.SetCacheItem({
|
|
9768
|
+
key: GetListCacheKey(viewId),
|
|
9769
|
+
value: req,
|
|
9770
|
+
req: reqParams
|
|
9771
|
+
});
|
|
9772
|
+
return req;
|
|
9773
|
+
});
|
|
9774
|
+
}
|
|
9775
|
+
ProjectViewBookmark.GetList = GetList;
|
|
9776
|
+
/**
|
|
9777
|
+
* Creates or updates a bookmark record.
|
|
9778
|
+
* @param params
|
|
9779
|
+
* @returns
|
|
9780
|
+
*/
|
|
9781
|
+
function Update(params) {
|
|
9782
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
9783
|
+
let { api, viewId, bookmark: data, req: reqParams } = params;
|
|
9784
|
+
if (!api) {
|
|
9785
|
+
api = ENVIRONMENT.Api().GetBruceApi();
|
|
9786
|
+
}
|
|
9787
|
+
if (!(data === null || data === void 0 ? void 0 : data.Title)) {
|
|
9788
|
+
data.Title = data.ID;
|
|
9789
|
+
}
|
|
9790
|
+
const res = yield api.POST(`ui.view/${viewId}/slide/${data.ID ? data.ID : ""}`, data, Api.PrepReqParams(reqParams));
|
|
9791
|
+
api.Cache.Remove(GetCacheKey(viewId, data.ID));
|
|
9792
|
+
api.Cache.Remove(GetListCacheKey(viewId));
|
|
9793
|
+
return {
|
|
9794
|
+
bookmark: res
|
|
9795
|
+
};
|
|
9796
|
+
});
|
|
9797
|
+
}
|
|
9798
|
+
ProjectViewBookmark.Update = Update;
|
|
9799
|
+
/**
|
|
9800
|
+
* Sets the order of bookmarks within a project view.
|
|
9801
|
+
* @param params
|
|
9802
|
+
*/
|
|
9803
|
+
function SetOrder(params) {
|
|
9804
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
9805
|
+
let { api, viewId, bookmarkIds, req: reqParams } = params;
|
|
9806
|
+
if (!api) {
|
|
9807
|
+
api = ENVIRONMENT.Api().GetBruceApi();
|
|
9808
|
+
}
|
|
9809
|
+
const reqData = {
|
|
9810
|
+
"UISlide.ID": bookmarkIds,
|
|
9811
|
+
"DisplayOrder.Start": 0
|
|
9812
|
+
};
|
|
9813
|
+
yield api.POST(`ui.view/${viewId}/slides/setOrder`, reqData, Api.PrepReqParams(reqParams));
|
|
9814
|
+
yield api.Cache.RemoveByStartsWith(GetListCacheKey(viewId));
|
|
9815
|
+
});
|
|
9816
|
+
}
|
|
9817
|
+
ProjectViewBookmark.SetOrder = SetOrder;
|
|
9818
|
+
/**
|
|
9819
|
+
* Returns cache identifier for a bookmark.
|
|
9820
|
+
* Example: {
|
|
9821
|
+
* const api: BruceApi.Api = ...;
|
|
9822
|
+
* const key = GetCacheKey("abc", "def");
|
|
9823
|
+
* api.Cache.Remove(key);
|
|
9824
|
+
* }
|
|
9825
|
+
* @param viewId
|
|
9826
|
+
* @param bookmarkId
|
|
9827
|
+
* @returns
|
|
9828
|
+
*/
|
|
9829
|
+
function GetCacheKey(viewId, bookmarkId) {
|
|
9830
|
+
return `${Api.ECacheKey.ProjectViewBookmark}${Api.ECacheKey.Id}${viewId}${Api.ECacheKey.Id}${bookmarkId}`;
|
|
9831
|
+
}
|
|
9832
|
+
ProjectViewBookmark.GetCacheKey = GetCacheKey;
|
|
9833
|
+
/**
|
|
9834
|
+
* Returns cache identifier for a list of bookmarks.
|
|
9835
|
+
* Example: {
|
|
9836
|
+
* const api: BruceApi.Api = ...;
|
|
9837
|
+
* const key = GetListCacheKey("abc");
|
|
9838
|
+
* api.Cache.Remove(key);
|
|
9839
|
+
* }
|
|
9840
|
+
* @param viewId
|
|
9841
|
+
* @returns
|
|
9842
|
+
*/
|
|
9843
|
+
function GetListCacheKey(viewId) {
|
|
9844
|
+
return `${Api.ECacheKey.ProjectViewBookmark}${Api.ECacheKey.Id}${viewId}`;
|
|
9845
|
+
}
|
|
9846
|
+
ProjectViewBookmark.GetListCacheKey = GetListCacheKey;
|
|
9847
|
+
})(ProjectViewBookmark || (ProjectViewBookmark = {}));
|
|
9848
|
+
|
|
9849
|
+
/**
|
|
9850
|
+
* Describes the "Project View" concept within Nextspace.
|
|
9851
|
+
* A project view is a collection of settings for a visualization application we support.
|
|
9852
|
+
* It will describe what panels to show and how, it will also describe all possible ways data can be displayed.
|
|
9853
|
+
*/
|
|
9854
|
+
var ProjectView;
|
|
9855
|
+
(function (ProjectView) {
|
|
9856
|
+
// This is the expected default version for the DataVersion value.
|
|
9857
|
+
// This value should NOT be changed without looking at our API and seeing what the default value is.
|
|
9858
|
+
ProjectView.DEFAULT_DATA_VERSION = 2;
|
|
9859
|
+
// Our Cesium web navigator.
|
|
9860
|
+
ProjectView.TYPE_WEB_3D_NAVIGATOR = "WEB_3D_NAVIGATOR";
|
|
9861
|
+
// Our (currently WIP) 2D web navigator. Also known as our graph viewer.
|
|
9862
|
+
ProjectView.TYPE_WEB_2D_NAVIGATOR = "WEB_2D_NAVIGATOR";
|
|
9863
|
+
// Defaulting to 3D navigator for backwards compatibility.
|
|
9864
|
+
ProjectView.DEFAULT_TYPE = ProjectView.TYPE_WEB_3D_NAVIGATOR;
|
|
9865
|
+
/**
|
|
9866
|
+
* Gets a project view record.
|
|
9867
|
+
* @param params
|
|
9868
|
+
* @returns
|
|
9869
|
+
*/
|
|
9870
|
+
function Get(params) {
|
|
9871
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
9872
|
+
let { api, viewId, req: reqParams } = params;
|
|
9873
|
+
if (!viewId) {
|
|
9874
|
+
throw ("View ID is required.");
|
|
9875
|
+
}
|
|
9876
|
+
if (!api) {
|
|
9877
|
+
api = ENVIRONMENT.Api().GetBruceApi();
|
|
9878
|
+
}
|
|
9879
|
+
const key = GetCacheKey(viewId);
|
|
9880
|
+
const cache = yield api.GetCacheItem(key, reqParams);
|
|
9881
|
+
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
9882
|
+
return cache.data;
|
|
9883
|
+
}
|
|
9884
|
+
const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
9885
|
+
try {
|
|
9886
|
+
const data = yield api.GET(`ui.view/${viewId}`, Api.PrepReqParams(reqParams));
|
|
9887
|
+
res({
|
|
9888
|
+
view: data
|
|
9889
|
+
});
|
|
9890
|
+
}
|
|
9891
|
+
catch (e) {
|
|
9892
|
+
rej(e);
|
|
9893
|
+
}
|
|
9894
|
+
}));
|
|
9895
|
+
yield api.SetCacheItem({
|
|
9896
|
+
key,
|
|
9897
|
+
value: prom,
|
|
9898
|
+
req: reqParams
|
|
9899
|
+
});
|
|
9900
|
+
return prom;
|
|
9901
|
+
});
|
|
9902
|
+
}
|
|
9903
|
+
ProjectView.Get = Get;
|
|
9904
|
+
/**
|
|
9905
|
+
* Gets a list of project views.
|
|
9906
|
+
* @param params
|
|
9907
|
+
* @returns
|
|
9908
|
+
*/
|
|
9909
|
+
function GetList(params) {
|
|
9910
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
9911
|
+
let { api, req: reqParams, type } = params;
|
|
9912
|
+
if (!api) {
|
|
9913
|
+
api = ENVIRONMENT.Api().GetBruceApi();
|
|
9914
|
+
}
|
|
9915
|
+
const cache = yield api.GetCacheItem(GetListCacheKey(type), reqParams);
|
|
9916
|
+
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
9917
|
+
return cache.data;
|
|
9918
|
+
}
|
|
9919
|
+
const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
9920
|
+
try {
|
|
9921
|
+
const data = yield api.GET("ui.view/list", Api.PrepReqParams(reqParams));
|
|
9922
|
+
res({
|
|
9923
|
+
views: data.Items
|
|
9924
|
+
});
|
|
9925
|
+
}
|
|
9926
|
+
catch (e) {
|
|
9927
|
+
rej(e);
|
|
9928
|
+
}
|
|
9929
|
+
}));
|
|
9930
|
+
yield api.SetCacheItem({
|
|
9931
|
+
key: GetListCacheKey(type),
|
|
9932
|
+
value: prom,
|
|
9933
|
+
req: reqParams
|
|
9934
|
+
});
|
|
9935
|
+
return prom;
|
|
9936
|
+
});
|
|
9937
|
+
}
|
|
9938
|
+
ProjectView.GetList = GetList;
|
|
9939
|
+
/**
|
|
9940
|
+
* Deletes a project view.
|
|
9941
|
+
* @param params
|
|
9942
|
+
*/
|
|
9943
|
+
function Delete(params) {
|
|
9944
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
9945
|
+
let { api, viewId, req: reqParams } = params;
|
|
9946
|
+
if (!viewId) {
|
|
9947
|
+
throw ("View ID is required.");
|
|
9948
|
+
}
|
|
9949
|
+
if (!api) {
|
|
9950
|
+
api = ENVIRONMENT.Api().GetBruceApi();
|
|
9951
|
+
}
|
|
9952
|
+
yield api.DELETE(`ui.view/${viewId}`, Api.PrepReqParams(reqParams));
|
|
9953
|
+
api.Cache.Remove(GetCacheKey(viewId));
|
|
9954
|
+
api.Cache.RemoveByStartsWith(GetListCacheKey());
|
|
9955
|
+
});
|
|
9956
|
+
}
|
|
9957
|
+
ProjectView.Delete = Delete;
|
|
9958
|
+
/**
|
|
9959
|
+
* Creates or updates a project view.
|
|
9960
|
+
* @param params
|
|
9961
|
+
* @returns
|
|
9962
|
+
*/
|
|
9963
|
+
function Update(params) {
|
|
9964
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
9965
|
+
let { api, view: data, req: reqParams } = params;
|
|
9966
|
+
if (!api) {
|
|
9967
|
+
api = ENVIRONMENT.Api().GetBruceApi();
|
|
9968
|
+
}
|
|
9969
|
+
if (!data) {
|
|
9970
|
+
data = {};
|
|
9971
|
+
}
|
|
9972
|
+
const isNew = !data.ID;
|
|
9973
|
+
if (!data.ID) {
|
|
9974
|
+
// Short ID to keep the URL short.
|
|
9975
|
+
// 8 length = 4,294,967,296 combinations.
|
|
9976
|
+
data.ID = ObjectUtils.UId(8);
|
|
9977
|
+
}
|
|
9978
|
+
if (!data.Name) {
|
|
9979
|
+
data.Name = data.ID;
|
|
9980
|
+
}
|
|
9981
|
+
if (!data.CreatedByUIVersion) {
|
|
9982
|
+
data.CreatedByUIVersion = "-1";
|
|
9983
|
+
}
|
|
9984
|
+
if (isNew) {
|
|
9985
|
+
data = yield api.POST(`ui.view/${data.ID}`, data, Api.PrepReqParams(reqParams));
|
|
9986
|
+
}
|
|
9987
|
+
else {
|
|
9988
|
+
data = yield api.PUT(`ui.view/${data.ID}`, data, Api.PrepReqParams(reqParams));
|
|
9989
|
+
}
|
|
9990
|
+
api.Cache.Remove(GetCacheKey(data.ID));
|
|
9991
|
+
api.Cache.RemoveByStartsWith(GetListCacheKey());
|
|
9992
|
+
return {
|
|
9993
|
+
view: data
|
|
9994
|
+
};
|
|
9995
|
+
});
|
|
9996
|
+
}
|
|
9997
|
+
ProjectView.Update = Update;
|
|
9998
|
+
/**
|
|
9999
|
+
* Returns cache identifier for a project view.
|
|
10000
|
+
* Example: {
|
|
10001
|
+
* const api: BruceApi.Api = ...;
|
|
10002
|
+
* const key = GetCacheKey("abc");
|
|
10003
|
+
* api.Cache.Remove(key);
|
|
10004
|
+
* }
|
|
10005
|
+
* @param viewId
|
|
10006
|
+
* @returns
|
|
10007
|
+
*/
|
|
10008
|
+
function GetCacheKey(viewId) {
|
|
10009
|
+
return `${Api.ECacheKey.ProjectView}${Api.ECacheKey.Id}${viewId}`;
|
|
10010
|
+
}
|
|
10011
|
+
ProjectView.GetCacheKey = GetCacheKey;
|
|
10012
|
+
/**
|
|
10013
|
+
* Returns cache identifier for a list of project views.
|
|
10014
|
+
* Example: {
|
|
10015
|
+
* const api: BruceApi.Api = ...;
|
|
10016
|
+
* const key = GetListCacheKey();
|
|
10017
|
+
* api.Cache.Remove(key);
|
|
10018
|
+
* }
|
|
10019
|
+
* @param type optional filter for the type of project view.
|
|
10020
|
+
* @returns
|
|
10021
|
+
*/
|
|
10022
|
+
function GetListCacheKey(type) {
|
|
10023
|
+
if (type) {
|
|
10024
|
+
return `${Api.ECacheKey.ProjectView}${Api.ECacheKey.ListId}${type}`;
|
|
10025
|
+
}
|
|
10026
|
+
return `${Api.ECacheKey.ProjectView}${Api.ECacheKey.ListId}`;
|
|
10027
|
+
}
|
|
10028
|
+
ProjectView.GetListCacheKey = GetListCacheKey;
|
|
10029
|
+
})(ProjectView || (ProjectView = {}));
|
|
10030
|
+
|
|
10031
|
+
function getTemplateSettings(apiGetter, reqParams) {
|
|
10032
|
+
var _a;
|
|
10033
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
10034
|
+
const { view } = yield ProjectView.Get({
|
|
10035
|
+
api: apiGetter.getApi(Api.TEMPLATE_ACCOUNT_ID),
|
|
10036
|
+
viewId: "default",
|
|
10037
|
+
req: reqParams
|
|
10038
|
+
});
|
|
10039
|
+
return (_a = view.Settings) !== null && _a !== void 0 ? _a : {};
|
|
10040
|
+
});
|
|
10041
|
+
}
|
|
10042
|
+
function checkSourceToTemplate(items, templateItem, addIfMissing) {
|
|
10043
|
+
const index = items.findIndex(x => x.Name === templateItem.Name);
|
|
10044
|
+
if (index > -1) {
|
|
10045
|
+
templateItem.IsDefault = true;
|
|
10046
|
+
templateItem.IsEnabled = items[index].IsEnabled;
|
|
10047
|
+
items[index] = templateItem;
|
|
10048
|
+
}
|
|
10049
|
+
else if (addIfMissing) {
|
|
10050
|
+
templateItem.IsDefault = true;
|
|
10051
|
+
items.push(templateItem);
|
|
10052
|
+
}
|
|
10053
|
+
}
|
|
10054
|
+
/**
|
|
10055
|
+
* Describes a terrain or map source that are found in project view records.
|
|
10056
|
+
* This is a concept we want to trash as we're moving towards storing tileset ids instead.
|
|
10057
|
+
* This will help at least understand and manage this dying concept.
|
|
10058
|
+
*/
|
|
10059
|
+
var ProjectViewLegacyTile;
|
|
10060
|
+
(function (ProjectViewLegacyTile) {
|
|
10061
|
+
function MergeMapTemplateData(params) {
|
|
10062
|
+
var _a;
|
|
10063
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
10064
|
+
let { getter, sources: items, addIfMissing, req: reqParams } = params;
|
|
10065
|
+
if (!getter) {
|
|
10066
|
+
getter = ENVIRONMENT.Api().GetBruceGetter();
|
|
10067
|
+
}
|
|
10068
|
+
const settings = yield getTemplateSettings(getter, reqParams);
|
|
10069
|
+
const maps = (_a = settings.CesiumMapSources) !== null && _a !== void 0 ? _a : [];
|
|
10070
|
+
for (let i = 0; i < maps.length; i++) {
|
|
10071
|
+
const mapSource = maps[i];
|
|
10072
|
+
checkSourceToTemplate(items, mapSource, addIfMissing);
|
|
10073
|
+
}
|
|
10074
|
+
return {
|
|
10075
|
+
sources: items
|
|
10076
|
+
};
|
|
10077
|
+
});
|
|
10078
|
+
}
|
|
10079
|
+
ProjectViewLegacyTile.MergeMapTemplateData = MergeMapTemplateData;
|
|
10080
|
+
function MergeTerrainTemplateData(params) {
|
|
10081
|
+
var _a;
|
|
10082
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
10083
|
+
let { getter, sources: items, addIfMissing, req: reqParams } = params;
|
|
10084
|
+
if (!getter) {
|
|
10085
|
+
getter = ENVIRONMENT.Api().GetBruceGetter();
|
|
10086
|
+
}
|
|
10087
|
+
const settings = yield getTemplateSettings(getter, reqParams);
|
|
10088
|
+
const terrains = (_a = settings.CesiumTerrainSources) !== null && _a !== void 0 ? _a : [];
|
|
10089
|
+
for (let i = 0; i < terrains.length; i++) {
|
|
10090
|
+
const terrainSource = terrains[i];
|
|
10091
|
+
checkSourceToTemplate(items, terrainSource, addIfMissing);
|
|
10092
|
+
}
|
|
10093
|
+
return {
|
|
10094
|
+
sources: items
|
|
10095
|
+
};
|
|
10096
|
+
});
|
|
10097
|
+
}
|
|
10098
|
+
ProjectViewLegacyTile.MergeTerrainTemplateData = MergeTerrainTemplateData;
|
|
10099
|
+
})(ProjectViewLegacyTile || (ProjectViewLegacyTile = {}));
|
|
10100
|
+
|
|
10101
|
+
/**
|
|
10102
|
+
* A tile is an imagery or terrain tileset definition.
|
|
10103
|
+
*/
|
|
10104
|
+
var ProjectViewTile;
|
|
10105
|
+
(function (ProjectViewTile) {
|
|
10106
|
+
/**
|
|
10107
|
+
* Available imagery defaults.
|
|
10108
|
+
*/
|
|
10109
|
+
let EDefaultImagery;
|
|
10110
|
+
(function (EDefaultImagery) {
|
|
10111
|
+
EDefaultImagery["BingMapsAerial"] = "bingmapsaerial";
|
|
10112
|
+
EDefaultImagery["BingMapsAerialWithLabels"] = "bingmapsaerialwithlabels";
|
|
10113
|
+
EDefaultImagery["BingMapsRoads"] = "bingmapsroads";
|
|
10114
|
+
EDefaultImagery["MapboxSatellite"] = "mapboxsatellite";
|
|
10115
|
+
EDefaultImagery["MapBoxStreets"] = "mapboxstreets";
|
|
10116
|
+
EDefaultImagery["MapBoxStreetsClassic"] = "mapboxstreetsclassic";
|
|
10117
|
+
EDefaultImagery["EsriWorldImagery"] = "esriworldimagery";
|
|
10118
|
+
EDefaultImagery["EsriWorldStreetMap"] = "esriworldstreetmap";
|
|
10119
|
+
EDefaultImagery["EsriNationalGeographic"] = "esrinationalgeographic";
|
|
10120
|
+
EDefaultImagery["OpenStreetMap"] = "openstreetmap";
|
|
10121
|
+
EDefaultImagery["LINZ"] = "linz";
|
|
10122
|
+
EDefaultImagery["StamenWaterColor"] = "stamenwatercolor";
|
|
10123
|
+
EDefaultImagery["StamenToner"] = "stamentoner";
|
|
10124
|
+
EDefaultImagery["Grid"] = "grid";
|
|
10125
|
+
EDefaultImagery["ThunderforestCycle"] = "thunderforestcycle";
|
|
10126
|
+
EDefaultImagery["ThunderforestTransport"] = "thunderforesttransport";
|
|
10127
|
+
EDefaultImagery["ThunderforestLandscape"] = "thunderforestlandscape";
|
|
10128
|
+
})(EDefaultImagery = ProjectViewTile.EDefaultImagery || (ProjectViewTile.EDefaultImagery = {}));
|
|
10129
|
+
/**
|
|
10130
|
+
* Prepared array for UI.
|
|
10131
|
+
* TODO: Im not happy with icon urls sitting in the code. I'd prefer we ship these icons in the library as files.
|
|
10132
|
+
*/
|
|
10133
|
+
ProjectViewTile.DefaultImagery = [
|
|
10134
|
+
{
|
|
10135
|
+
id: EDefaultImagery.BingMapsAerial,
|
|
10136
|
+
name: "Bing Maps Aerial",
|
|
10137
|
+
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/bingAerial.png"
|
|
10138
|
+
},
|
|
10139
|
+
{
|
|
10140
|
+
id: EDefaultImagery.BingMapsAerialWithLabels,
|
|
10141
|
+
name: "Bing Maps Aerial with Labels",
|
|
10142
|
+
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/bingAerialLabels.png"
|
|
10143
|
+
},
|
|
10144
|
+
{
|
|
10145
|
+
id: EDefaultImagery.BingMapsRoads,
|
|
10146
|
+
name: "Bing Maps Roads",
|
|
10147
|
+
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/bingRoads.png"
|
|
10148
|
+
},
|
|
10149
|
+
{
|
|
10150
|
+
id: EDefaultImagery.MapboxSatellite,
|
|
10151
|
+
name: "Mapbox Satellite",
|
|
10152
|
+
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/mapboxSatellite.png"
|
|
10153
|
+
},
|
|
10154
|
+
{
|
|
10155
|
+
id: EDefaultImagery.MapBoxStreets,
|
|
10156
|
+
name: "Mapbox Streets",
|
|
10157
|
+
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/mapboxTerrain.png"
|
|
10158
|
+
},
|
|
10159
|
+
{
|
|
10160
|
+
id: EDefaultImagery.MapBoxStreetsClassic,
|
|
10161
|
+
name: "Mapbox Streets Classic",
|
|
10162
|
+
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/mapboxStreets.png"
|
|
10163
|
+
},
|
|
10164
|
+
{
|
|
10165
|
+
id: EDefaultImagery.EsriWorldImagery,
|
|
10166
|
+
name: "Esri World Imagery",
|
|
10167
|
+
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/esriWorldImagery.png"
|
|
10168
|
+
},
|
|
10169
|
+
{
|
|
10170
|
+
id: EDefaultImagery.EsriWorldStreetMap,
|
|
10171
|
+
name: "Esri World Street Map",
|
|
10172
|
+
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/esriWorldStreetMap.png"
|
|
10173
|
+
},
|
|
10174
|
+
{
|
|
10175
|
+
id: EDefaultImagery.EsriNationalGeographic,
|
|
10176
|
+
name: "Esri National Geographic",
|
|
10177
|
+
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/esriNationalGeographic.png"
|
|
10178
|
+
},
|
|
10179
|
+
{
|
|
10180
|
+
id: EDefaultImagery.OpenStreetMap,
|
|
10181
|
+
name: "Open Street Map",
|
|
10182
|
+
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/openStreetMap.png"
|
|
10183
|
+
},
|
|
10184
|
+
{
|
|
10185
|
+
id: EDefaultImagery.LINZ,
|
|
10186
|
+
name: "LINZ",
|
|
10187
|
+
iconUrl: "https://template.ui.nextspace.host/media/linz.jpg"
|
|
10188
|
+
},
|
|
10189
|
+
{
|
|
10190
|
+
id: EDefaultImagery.StamenWaterColor,
|
|
10191
|
+
name: "Stamen Water Color",
|
|
10192
|
+
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/stamenWatercolor.png"
|
|
10193
|
+
},
|
|
10194
|
+
{
|
|
10195
|
+
id: EDefaultImagery.StamenToner,
|
|
10196
|
+
name: "Stamen Toner",
|
|
10197
|
+
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/stamenToner.png"
|
|
10198
|
+
},
|
|
10199
|
+
{
|
|
10200
|
+
id: EDefaultImagery.ThunderforestCycle,
|
|
10201
|
+
name: "Thunderforest Cycle"
|
|
10202
|
+
},
|
|
10203
|
+
{
|
|
10204
|
+
id: EDefaultImagery.ThunderforestTransport,
|
|
10205
|
+
name: "Thunderforest Transport"
|
|
10206
|
+
},
|
|
10207
|
+
{
|
|
10208
|
+
id: EDefaultImagery.ThunderforestLandscape,
|
|
10209
|
+
name: "Thunderforest Landscape"
|
|
10210
|
+
},
|
|
10211
|
+
{
|
|
10212
|
+
id: EDefaultImagery.Grid,
|
|
10213
|
+
name: "Grid",
|
|
10214
|
+
iconUrl: "https://template.api.nextspace-uat.net/file/2885d8df-028b-4f5c-80b3-2634f7e7cf69.png"
|
|
10215
|
+
}
|
|
10216
|
+
];
|
|
10217
|
+
/**
|
|
10218
|
+
* Available terrain defaults.
|
|
10219
|
+
*/
|
|
10220
|
+
let EDefaultTerrain;
|
|
10221
|
+
(function (EDefaultTerrain) {
|
|
10222
|
+
EDefaultTerrain["CesiumWorldTerrain"] = "cesiumworldterrain";
|
|
10223
|
+
EDefaultTerrain["FlatTerrain"] = "flatterrain";
|
|
10224
|
+
EDefaultTerrain["LINZ"] = "linz";
|
|
10225
|
+
})(EDefaultTerrain = ProjectViewTile.EDefaultTerrain || (ProjectViewTile.EDefaultTerrain = {}));
|
|
10226
|
+
/**
|
|
10227
|
+
* Prepared array for UI.
|
|
10228
|
+
* TODO: Im not happy with icon urls sitting in the code. I'd prefer we ship these icons in the library as files.
|
|
10229
|
+
*/
|
|
10230
|
+
ProjectViewTile.DefaultTerrains = [
|
|
10231
|
+
{
|
|
10232
|
+
id: EDefaultTerrain.CesiumWorldTerrain,
|
|
10233
|
+
name: "Cesium World Terrain",
|
|
10234
|
+
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/TerrainProviders/CesiumWorldTerrain.png"
|
|
10235
|
+
},
|
|
10236
|
+
{
|
|
10237
|
+
id: EDefaultTerrain.LINZ,
|
|
10238
|
+
name: "LINZ",
|
|
10239
|
+
iconUrl: "https://template.ui.nextspace.host/media/linz.jpg"
|
|
10240
|
+
},
|
|
10241
|
+
{
|
|
10242
|
+
id: EDefaultTerrain.FlatTerrain,
|
|
10243
|
+
name: "Flat Terrain",
|
|
10244
|
+
}
|
|
10245
|
+
];
|
|
10246
|
+
})(ProjectViewTile || (ProjectViewTile = {}));
|
|
10247
|
+
|
|
10248
|
+
/**
|
|
10249
|
+
* Deprecated Project View record.
|
|
10250
|
+
* This was used in the legacy web Navigator.
|
|
10251
|
+
*/
|
|
10252
|
+
var ProjectViewLegacy;
|
|
10253
|
+
(function (ProjectViewLegacy) {
|
|
10254
|
+
ProjectViewLegacy.DATA_VERSION = 1;
|
|
10255
|
+
})(ProjectViewLegacy || (ProjectViewLegacy = {}));
|
|
10256
|
+
|
|
10257
|
+
/**
|
|
10258
|
+
* Deprecated Project View Bookmark record.
|
|
10259
|
+
* This was used in the legacy web Navigator.
|
|
10260
|
+
*/
|
|
10261
|
+
var ProjectViewLegacyBookmark;
|
|
10262
|
+
(function (ProjectViewLegacyBookmark) {
|
|
10263
|
+
ProjectViewLegacyBookmark.DATA_VERSION = 1;
|
|
10264
|
+
})(ProjectViewLegacyBookmark || (ProjectViewLegacyBookmark = {}));
|
|
10265
|
+
|
|
10266
|
+
/**
|
|
10267
|
+
* Describes the "Pending Action" concept within Nextspace.
|
|
10268
|
+
* A pending action is a record of a server-side background process.
|
|
10269
|
+
* This record is used to monitor its progress and completion state.
|
|
10270
|
+
*/
|
|
10271
|
+
var PendingAction;
|
|
10272
|
+
(function (PendingAction) {
|
|
10273
|
+
/**
|
|
10274
|
+
* Available pending action statuses.
|
|
10275
|
+
*/
|
|
10276
|
+
let EStatus;
|
|
10277
|
+
(function (EStatus) {
|
|
10278
|
+
EStatus["InProgress"] = "IN_PROGRESS";
|
|
10279
|
+
EStatus["Cancelled"] = "CANCELLED";
|
|
10280
|
+
EStatus["Complete"] = "COMPLETE";
|
|
10281
|
+
EStatus["Failed"] = "FAILED";
|
|
10282
|
+
})(EStatus = PendingAction.EStatus || (PendingAction.EStatus = {}));
|
|
10283
|
+
/**
|
|
10284
|
+
* Available message types.
|
|
10027
10285
|
*/
|
|
10028
|
-
|
|
10029
|
-
|
|
10030
|
-
|
|
10031
|
-
|
|
10032
|
-
|
|
10033
|
-
|
|
10034
|
-
|
|
10035
|
-
},
|
|
10036
|
-
CameraZoomSettings: [
|
|
10037
|
-
{
|
|
10038
|
-
DisplayType: ZoomControl.EDisplayType.Model3D,
|
|
10039
|
-
MaxZoom: 100000,
|
|
10040
|
-
MinZoom: 0,
|
|
10041
|
-
StyleID: styleId
|
|
10042
|
-
}
|
|
10043
|
-
]
|
|
10044
|
-
};
|
|
10045
|
-
}
|
|
10046
|
-
MenuItem.CreateFromTypeId = CreateFromTypeId;
|
|
10286
|
+
let EMessageType;
|
|
10287
|
+
(function (EMessageType) {
|
|
10288
|
+
EMessageType["Warn"] = "WARNING";
|
|
10289
|
+
EMessageType["Error"] = "ERROR";
|
|
10290
|
+
EMessageType["Status"] = "STATUS";
|
|
10291
|
+
EMessageType["Info"] = "INFO";
|
|
10292
|
+
})(EMessageType = PendingAction.EMessageType || (PendingAction.EMessageType = {}));
|
|
10047
10293
|
/**
|
|
10048
|
-
*
|
|
10049
|
-
* @param
|
|
10050
|
-
* @param type
|
|
10294
|
+
* Returns a pending action record.
|
|
10295
|
+
* @param params
|
|
10051
10296
|
* @returns
|
|
10052
10297
|
*/
|
|
10053
|
-
function
|
|
10054
|
-
|
|
10055
|
-
|
|
10056
|
-
|
|
10057
|
-
|
|
10058
|
-
|
|
10059
|
-
|
|
10060
|
-
|
|
10061
|
-
|
|
10062
|
-
|
|
10063
|
-
};
|
|
10064
|
-
}
|
|
10065
|
-
else if (type == Tileset.EType.EntitiesSet) {
|
|
10066
|
-
return {
|
|
10067
|
-
id: ObjectUtils.UId(),
|
|
10068
|
-
Type: EType.EntityTileset,
|
|
10069
|
-
Caption: "Generated Entities Menu Item",
|
|
10070
|
-
FlyTo: false,
|
|
10071
|
-
tileset: {
|
|
10072
|
-
TilesetID: tilesetId
|
|
10073
|
-
}
|
|
10074
|
-
};
|
|
10075
|
-
}
|
|
10076
|
-
else if (type == Tileset.EType.PointCloud) {
|
|
10077
|
-
return {
|
|
10078
|
-
id: ObjectUtils.UId(),
|
|
10079
|
-
Type: EType.PointCloud,
|
|
10080
|
-
Caption: "Generated Point Cloud Menu Item",
|
|
10081
|
-
FlyTo: false,
|
|
10082
|
-
tileset: {
|
|
10083
|
-
TilesetID: tilesetId
|
|
10084
|
-
}
|
|
10085
|
-
};
|
|
10086
|
-
}
|
|
10087
|
-
else if (type == Tileset.EType.EntitiesMap) {
|
|
10298
|
+
function Get(params) {
|
|
10299
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
10300
|
+
let { api, actionId, req: reqParams } = params;
|
|
10301
|
+
if (!actionId) {
|
|
10302
|
+
throw ("Action ID is required.");
|
|
10303
|
+
}
|
|
10304
|
+
if (!api) {
|
|
10305
|
+
api = ENVIRONMENT.Api().GetBruceApi();
|
|
10306
|
+
}
|
|
10307
|
+
const data = yield api.GET(`pendingAction/${actionId}`, Api.PrepReqParams(reqParams));
|
|
10088
10308
|
return {
|
|
10089
|
-
|
|
10090
|
-
Type: EType.EntityRaster,
|
|
10091
|
-
Caption: "Generated Entities Menu Item",
|
|
10092
|
-
tileset: {
|
|
10093
|
-
TilesetID: tilesetId
|
|
10094
|
-
}
|
|
10309
|
+
action: data
|
|
10095
10310
|
};
|
|
10096
|
-
}
|
|
10097
|
-
throw ("Tileset type not supported.");
|
|
10311
|
+
});
|
|
10098
10312
|
}
|
|
10099
|
-
|
|
10100
|
-
})(MenuItem || (MenuItem = {}));
|
|
10101
|
-
|
|
10102
|
-
/**
|
|
10103
|
-
* Describe the "Project View Bookmark" concept within Nextspace.
|
|
10104
|
-
* This is referred to as "slides" in older code.
|
|
10105
|
-
*
|
|
10106
|
-
* A bookmark is a snapshot of what should be displayed and how in a particular project view.
|
|
10107
|
-
*/
|
|
10108
|
-
var ProjectViewBookmark;
|
|
10109
|
-
(function (ProjectViewBookmark) {
|
|
10110
|
-
// This is the expected default version for the DataVersion value.
|
|
10111
|
-
// This value should NOT be changed without looking at our API and seeing what the default value is.
|
|
10112
|
-
ProjectViewBookmark.DEFAULT_DATA_VERSION = 2;
|
|
10313
|
+
PendingAction.Get = Get;
|
|
10113
10314
|
/**
|
|
10114
|
-
*
|
|
10115
|
-
*
|
|
10315
|
+
* Returns a list of pending action records.
|
|
10316
|
+
* @param params
|
|
10317
|
+
* @returns
|
|
10116
10318
|
*/
|
|
10117
|
-
|
|
10118
|
-
|
|
10119
|
-
|
|
10120
|
-
|
|
10121
|
-
|
|
10319
|
+
function GetRelevantList(params) {
|
|
10320
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
10321
|
+
let { api, stricter, reqParams } = params;
|
|
10322
|
+
if (!api) {
|
|
10323
|
+
api = ENVIRONMENT.Api().GetBruceApi();
|
|
10324
|
+
}
|
|
10325
|
+
const data = yield api.GET(`pendingActions/important?Update=${Boolean(stricter)}`, Api.PrepReqParams(reqParams));
|
|
10326
|
+
return {
|
|
10327
|
+
actions: data.Items
|
|
10328
|
+
};
|
|
10329
|
+
});
|
|
10330
|
+
}
|
|
10331
|
+
PendingAction.GetRelevantList = GetRelevantList;
|
|
10122
10332
|
/**
|
|
10123
|
-
*
|
|
10333
|
+
* Returns a list of pending action record messages.
|
|
10124
10334
|
* @param params
|
|
10125
10335
|
* @returns
|
|
10126
10336
|
*/
|
|
10127
|
-
function
|
|
10337
|
+
function GetMessages(params) {
|
|
10128
10338
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10129
|
-
let { api,
|
|
10130
|
-
if (!viewId || !bookmarkId) {
|
|
10131
|
-
throw ("View ID and Bookmark ID are required.");
|
|
10132
|
-
}
|
|
10339
|
+
let { api, actionId, order, startIndex, amount, req: reqParams, types } = params;
|
|
10133
10340
|
if (!api) {
|
|
10134
10341
|
api = ENVIRONMENT.Api().GetBruceApi();
|
|
10135
10342
|
}
|
|
10136
|
-
|
|
10137
|
-
|
|
10138
|
-
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
10139
|
-
return cache.data;
|
|
10343
|
+
if (amount == null) {
|
|
10344
|
+
amount = 500;
|
|
10140
10345
|
}
|
|
10141
|
-
|
|
10142
|
-
|
|
10143
|
-
|
|
10144
|
-
|
|
10145
|
-
|
|
10146
|
-
|
|
10147
|
-
|
|
10148
|
-
|
|
10149
|
-
|
|
10346
|
+
if (startIndex == null) {
|
|
10347
|
+
startIndex = 0;
|
|
10348
|
+
}
|
|
10349
|
+
if (order == null) {
|
|
10350
|
+
order = Api.ESortOrder.Asc;
|
|
10351
|
+
}
|
|
10352
|
+
let args = `?SortOrder=${order == Api.ESortOrder.Desc ? "DESC" : "ASC"}&PageSize=${amount}&PageIndex=${startIndex}`;
|
|
10353
|
+
if (types === null || types === void 0 ? void 0 : types.length) {
|
|
10354
|
+
for (let i = 0; i < types.length; i++) {
|
|
10355
|
+
args += `&Type=${types[i]}`;
|
|
10150
10356
|
}
|
|
10151
|
-
}
|
|
10152
|
-
yield api.
|
|
10153
|
-
|
|
10154
|
-
|
|
10155
|
-
|
|
10156
|
-
});
|
|
10157
|
-
return prom;
|
|
10357
|
+
}
|
|
10358
|
+
const data = yield api.GET(`pendingAction/${actionId}/progressMessages` + args, Api.PrepReqParams(reqParams));
|
|
10359
|
+
return {
|
|
10360
|
+
messages: data.Items
|
|
10361
|
+
};
|
|
10158
10362
|
});
|
|
10159
10363
|
}
|
|
10160
|
-
|
|
10364
|
+
PendingAction.GetMessages = GetMessages;
|
|
10161
10365
|
/**
|
|
10162
|
-
*
|
|
10366
|
+
* Requests to cancel a pending action.
|
|
10163
10367
|
* @param params
|
|
10164
10368
|
*/
|
|
10165
|
-
function
|
|
10369
|
+
function Cancel(params) {
|
|
10166
10370
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10167
|
-
let { api,
|
|
10168
|
-
if (!
|
|
10169
|
-
throw ("
|
|
10371
|
+
let { api, actionId, req: reqParams } = params;
|
|
10372
|
+
if (!actionId) {
|
|
10373
|
+
throw ("Action ID is required.");
|
|
10170
10374
|
}
|
|
10171
10375
|
if (!api) {
|
|
10172
10376
|
api = ENVIRONMENT.Api().GetBruceApi();
|
|
10173
10377
|
}
|
|
10174
|
-
yield api.DELETE(`
|
|
10175
|
-
api.Cache.Remove(GetCacheKey(viewId, bookmarkId));
|
|
10176
|
-
api.Cache.Remove(GetListCacheKey(viewId));
|
|
10378
|
+
yield api.DELETE(`pendingAction/${actionId}`, Api.PrepReqParams(reqParams));
|
|
10177
10379
|
});
|
|
10178
10380
|
}
|
|
10179
|
-
|
|
10381
|
+
PendingAction.Cancel = Cancel;
|
|
10382
|
+
})(PendingAction || (PendingAction = {}));
|
|
10383
|
+
|
|
10384
|
+
// Some dead accounts that we don't want to show in the UI.
|
|
10385
|
+
// Some accounts may not be "dead" but instead purposely don't have a NextspaceAPI database so we'll avoid them too.
|
|
10386
|
+
const ACCOUNT_EXCLUSIONS = ["hyperportal", "hypeportal", "bviewer"];
|
|
10387
|
+
/**
|
|
10388
|
+
* Describes the "Client Account" concept within Nextspace.
|
|
10389
|
+
* A client account is a database instance that holds one or many users.
|
|
10390
|
+
*/
|
|
10391
|
+
var Account;
|
|
10392
|
+
(function (Account) {
|
|
10180
10393
|
/**
|
|
10181
|
-
*
|
|
10394
|
+
* Known Nextspace applications we store settings for.
|
|
10395
|
+
*/
|
|
10396
|
+
let EAppId;
|
|
10397
|
+
(function (EAppId) {
|
|
10398
|
+
EAppId["BruceApi"] = "BruceAPI";
|
|
10399
|
+
EAppId["Navigator"] = "Navigator";
|
|
10400
|
+
EAppId["Operator"] = "BruceClientAdmin";
|
|
10401
|
+
})(EAppId = Account.EAppId || (Account.EAppId = {}));
|
|
10402
|
+
/**
|
|
10403
|
+
* Possible starter content options.
|
|
10404
|
+
* When creating a new account you can populate it with certain default data.
|
|
10405
|
+
*/
|
|
10406
|
+
let EStarterContent;
|
|
10407
|
+
(function (EStarterContent) {
|
|
10408
|
+
EStarterContent["Default"] = "default";
|
|
10409
|
+
EStarterContent["None"] = "none";
|
|
10410
|
+
})(EStarterContent = Account.EStarterContent || (Account.EStarterContent = {}));
|
|
10411
|
+
/**
|
|
10412
|
+
* Gets a client account record by ID.
|
|
10182
10413
|
* @param params
|
|
10183
10414
|
* @returns
|
|
10184
10415
|
*/
|
|
10185
|
-
function
|
|
10416
|
+
function Get(params) {
|
|
10186
10417
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10187
|
-
let { api,
|
|
10188
|
-
if (!viewId) {
|
|
10189
|
-
throw ("View ID is required.");
|
|
10190
|
-
}
|
|
10418
|
+
let { api, accountId: id, req: reqParams } = params;
|
|
10191
10419
|
if (!api) {
|
|
10192
|
-
api = ENVIRONMENT.Api().
|
|
10420
|
+
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
10193
10421
|
}
|
|
10194
|
-
const cache = yield api.GetCacheItem(
|
|
10422
|
+
const cache = yield api.GetCacheItem(GetCacheKey(id), reqParams);
|
|
10195
10423
|
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
10196
10424
|
return cache.data;
|
|
10197
10425
|
}
|
|
10198
|
-
const
|
|
10426
|
+
const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
10199
10427
|
try {
|
|
10200
|
-
const data = yield api.GET(`
|
|
10201
|
-
|
|
10202
|
-
|
|
10203
|
-
// Maybe better to load list cache when getting 1 slide and seeing if it's in there.
|
|
10204
|
-
// WARNING: Right now the data matches, in the future the list may contain a shortened result.
|
|
10205
|
-
for (let i = 0; i < items.length; i++) {
|
|
10206
|
-
const item = items[i];
|
|
10207
|
-
const prom = new Promise((res) => {
|
|
10208
|
-
res({
|
|
10209
|
-
bookmark: item
|
|
10210
|
-
});
|
|
10211
|
-
});
|
|
10428
|
+
const data = yield api.GET(`accountbyid/${id}`, reqParams);
|
|
10429
|
+
// Update the cache by subdomain as well in case it's different to the ID.
|
|
10430
|
+
if ((data === null || data === void 0 ? void 0 : data.ID) && (reqParams === null || reqParams === void 0 ? void 0 : reqParams.noCache) != false) {
|
|
10212
10431
|
yield api.SetCacheItem({
|
|
10213
|
-
key:
|
|
10432
|
+
key: data.Subdomain,
|
|
10214
10433
|
value: prom,
|
|
10215
10434
|
req: reqParams
|
|
10216
10435
|
});
|
|
10217
10436
|
}
|
|
10218
10437
|
res({
|
|
10219
|
-
|
|
10438
|
+
account: data
|
|
10220
10439
|
});
|
|
10221
10440
|
}
|
|
10222
10441
|
catch (e) {
|
|
@@ -10224,127 +10443,42 @@ var ProjectViewBookmark;
|
|
|
10224
10443
|
}
|
|
10225
10444
|
}));
|
|
10226
10445
|
yield api.SetCacheItem({
|
|
10227
|
-
key:
|
|
10228
|
-
value:
|
|
10446
|
+
key: GetCacheKey(id),
|
|
10447
|
+
value: prom,
|
|
10229
10448
|
req: reqParams
|
|
10230
10449
|
});
|
|
10231
|
-
return
|
|
10232
|
-
});
|
|
10233
|
-
}
|
|
10234
|
-
ProjectViewBookmark.GetList = GetList;
|
|
10235
|
-
/**
|
|
10236
|
-
* Creates or updates a bookmark record.
|
|
10237
|
-
* @param params
|
|
10238
|
-
* @returns
|
|
10239
|
-
*/
|
|
10240
|
-
function Update(params) {
|
|
10241
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
10242
|
-
let { api, viewId, bookmark: data, req: reqParams } = params;
|
|
10243
|
-
if (!api) {
|
|
10244
|
-
api = ENVIRONMENT.Api().GetBruceApi();
|
|
10245
|
-
}
|
|
10246
|
-
if (!(data === null || data === void 0 ? void 0 : data.Title)) {
|
|
10247
|
-
data.Title = data.ID;
|
|
10248
|
-
}
|
|
10249
|
-
const res = yield api.POST(`ui.view/${viewId}/slide/${data.ID ? data.ID : ""}`, data, Api.PrepReqParams(reqParams));
|
|
10250
|
-
api.Cache.Remove(GetCacheKey(viewId, data.ID));
|
|
10251
|
-
api.Cache.Remove(GetListCacheKey(viewId));
|
|
10252
|
-
return {
|
|
10253
|
-
bookmark: res
|
|
10254
|
-
};
|
|
10255
|
-
});
|
|
10256
|
-
}
|
|
10257
|
-
ProjectViewBookmark.Update = Update;
|
|
10258
|
-
/**
|
|
10259
|
-
* Sets the order of bookmarks within a project view.
|
|
10260
|
-
* @param params
|
|
10261
|
-
*/
|
|
10262
|
-
function SetOrder(params) {
|
|
10263
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
10264
|
-
let { api, viewId, bookmarkIds, req: reqParams } = params;
|
|
10265
|
-
if (!api) {
|
|
10266
|
-
api = ENVIRONMENT.Api().GetBruceApi();
|
|
10267
|
-
}
|
|
10268
|
-
const reqData = {
|
|
10269
|
-
"UISlide.ID": bookmarkIds,
|
|
10270
|
-
"DisplayOrder.Start": 0
|
|
10271
|
-
};
|
|
10272
|
-
yield api.POST(`ui.view/${viewId}/slides/setOrder`, reqData, Api.PrepReqParams(reqParams));
|
|
10273
|
-
yield api.Cache.RemoveByStartsWith(GetListCacheKey(viewId));
|
|
10450
|
+
return prom;
|
|
10274
10451
|
});
|
|
10275
10452
|
}
|
|
10276
|
-
|
|
10277
|
-
/**
|
|
10278
|
-
* Returns cache identifier for a bookmark.
|
|
10279
|
-
* Example: {
|
|
10280
|
-
* const api: BruceApi.Api = ...;
|
|
10281
|
-
* const key = GetCacheKey("abc", "def");
|
|
10282
|
-
* api.Cache.Remove(key);
|
|
10283
|
-
* }
|
|
10284
|
-
* @param viewId
|
|
10285
|
-
* @param bookmarkId
|
|
10286
|
-
* @returns
|
|
10287
|
-
*/
|
|
10288
|
-
function GetCacheKey(viewId, bookmarkId) {
|
|
10289
|
-
return `${Api.ECacheKey.ProjectViewBookmark}${Api.ECacheKey.Id}${viewId}${Api.ECacheKey.Id}${bookmarkId}`;
|
|
10290
|
-
}
|
|
10291
|
-
ProjectViewBookmark.GetCacheKey = GetCacheKey;
|
|
10292
|
-
/**
|
|
10293
|
-
* Returns cache identifier for a list of bookmarks.
|
|
10294
|
-
* Example: {
|
|
10295
|
-
* const api: BruceApi.Api = ...;
|
|
10296
|
-
* const key = GetListCacheKey("abc");
|
|
10297
|
-
* api.Cache.Remove(key);
|
|
10298
|
-
* }
|
|
10299
|
-
* @param viewId
|
|
10300
|
-
* @returns
|
|
10301
|
-
*/
|
|
10302
|
-
function GetListCacheKey(viewId) {
|
|
10303
|
-
return `${Api.ECacheKey.ProjectViewBookmark}${Api.ECacheKey.Id}${viewId}`;
|
|
10304
|
-
}
|
|
10305
|
-
ProjectViewBookmark.GetListCacheKey = GetListCacheKey;
|
|
10306
|
-
})(ProjectViewBookmark || (ProjectViewBookmark = {}));
|
|
10307
|
-
|
|
10308
|
-
/**
|
|
10309
|
-
* Describes the "Project View" concept within Nextspace.
|
|
10310
|
-
* A project view is a collection of settings for a visualization application we support.
|
|
10311
|
-
* It will describe what panels to show and how, it will also describe all possible ways data can be displayed.
|
|
10312
|
-
*/
|
|
10313
|
-
var ProjectView;
|
|
10314
|
-
(function (ProjectView) {
|
|
10315
|
-
// This is the expected default version for the DataVersion value.
|
|
10316
|
-
// This value should NOT be changed without looking at our API and seeing what the default value is.
|
|
10317
|
-
ProjectView.DEFAULT_DATA_VERSION = 2;
|
|
10318
|
-
// Our Cesium web navigator.
|
|
10319
|
-
ProjectView.TYPE_WEB_3D_NAVIGATOR = "WEB_3D_NAVIGATOR";
|
|
10320
|
-
// Our (currently WIP) 2D web navigator. Also known as our graph viewer.
|
|
10321
|
-
ProjectView.TYPE_WEB_2D_NAVIGATOR = "WEB_2D_NAVIGATOR";
|
|
10322
|
-
// Defaulting to 3D navigator for backwards compatibility.
|
|
10323
|
-
ProjectView.DEFAULT_TYPE = ProjectView.TYPE_WEB_3D_NAVIGATOR;
|
|
10453
|
+
Account.Get = Get;
|
|
10324
10454
|
/**
|
|
10325
|
-
*
|
|
10455
|
+
* Returns a client account record by subdomain or ID.
|
|
10326
10456
|
* @param params
|
|
10327
10457
|
* @returns
|
|
10328
10458
|
*/
|
|
10329
|
-
function
|
|
10459
|
+
function GetBySubdomain(params) {
|
|
10330
10460
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10331
|
-
let { api,
|
|
10332
|
-
if (!viewId) {
|
|
10333
|
-
throw ("View ID is required.");
|
|
10334
|
-
}
|
|
10461
|
+
let { api, subdomain, req: reqParams } = params;
|
|
10335
10462
|
if (!api) {
|
|
10336
|
-
api = ENVIRONMENT.Api().
|
|
10463
|
+
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
10337
10464
|
}
|
|
10338
|
-
const
|
|
10339
|
-
const cache = yield api.GetCacheItem(key, reqParams);
|
|
10465
|
+
const cache = yield api.GetCacheItem(GetCacheKey(subdomain), reqParams);
|
|
10340
10466
|
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
10341
10467
|
return cache.data;
|
|
10342
10468
|
}
|
|
10343
10469
|
const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
10344
10470
|
try {
|
|
10345
|
-
const data = yield api.GET(`
|
|
10471
|
+
const data = yield api.GET(`account/${subdomain}`, reqParams);
|
|
10472
|
+
// Update the cache by ID as well in case it's different to the subdomain.
|
|
10473
|
+
if ((data === null || data === void 0 ? void 0 : data.ID) && (reqParams === null || reqParams === void 0 ? void 0 : reqParams.noCache) != false) {
|
|
10474
|
+
yield api.SetCacheItem({
|
|
10475
|
+
key: data.ID,
|
|
10476
|
+
value: prom,
|
|
10477
|
+
req: reqParams
|
|
10478
|
+
});
|
|
10479
|
+
}
|
|
10346
10480
|
res({
|
|
10347
|
-
|
|
10481
|
+
account: data
|
|
10348
10482
|
});
|
|
10349
10483
|
}
|
|
10350
10484
|
catch (e) {
|
|
@@ -10352,34 +10486,36 @@ var ProjectView;
|
|
|
10352
10486
|
}
|
|
10353
10487
|
}));
|
|
10354
10488
|
yield api.SetCacheItem({
|
|
10355
|
-
key,
|
|
10489
|
+
key: GetCacheKey(subdomain),
|
|
10356
10490
|
value: prom,
|
|
10357
10491
|
req: reqParams
|
|
10358
10492
|
});
|
|
10359
10493
|
return prom;
|
|
10360
10494
|
});
|
|
10361
10495
|
}
|
|
10362
|
-
|
|
10496
|
+
Account.GetBySubdomain = GetBySubdomain;
|
|
10363
10497
|
/**
|
|
10364
|
-
* Gets a list of
|
|
10498
|
+
* Gets a list of client accounts related to the current session user.
|
|
10365
10499
|
* @param params
|
|
10366
10500
|
* @returns
|
|
10367
10501
|
*/
|
|
10368
|
-
function
|
|
10502
|
+
function GetRelatedList(params) {
|
|
10369
10503
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10370
|
-
let { api, req: reqParams
|
|
10504
|
+
let { api, req: reqParams } = params;
|
|
10371
10505
|
if (!api) {
|
|
10372
|
-
api = ENVIRONMENT.Api().
|
|
10506
|
+
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
10373
10507
|
}
|
|
10374
|
-
const cache = yield api.GetCacheItem(GetListCacheKey(
|
|
10508
|
+
const cache = yield api.GetCacheItem(GetListCacheKey(api.GetSessionId()), reqParams);
|
|
10375
10509
|
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
10376
10510
|
return cache.data;
|
|
10377
10511
|
}
|
|
10512
|
+
const req = api.GET("user/relatedClientAccounts", reqParams);
|
|
10378
10513
|
const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
10379
10514
|
try {
|
|
10380
|
-
const data = yield
|
|
10515
|
+
const data = yield req;
|
|
10516
|
+
const items = data.Items.filter((x) => !ACCOUNT_EXCLUSIONS.includes(x.ID));
|
|
10381
10517
|
res({
|
|
10382
|
-
|
|
10518
|
+
accounts: items
|
|
10383
10519
|
});
|
|
10384
10520
|
}
|
|
10385
10521
|
catch (e) {
|
|
@@ -10387,458 +10523,345 @@ var ProjectView;
|
|
|
10387
10523
|
}
|
|
10388
10524
|
}));
|
|
10389
10525
|
yield api.SetCacheItem({
|
|
10390
|
-
key: GetListCacheKey(
|
|
10526
|
+
key: GetListCacheKey(api.GetSessionId()),
|
|
10391
10527
|
value: prom,
|
|
10392
10528
|
req: reqParams
|
|
10393
10529
|
});
|
|
10394
10530
|
return prom;
|
|
10395
10531
|
});
|
|
10396
10532
|
}
|
|
10397
|
-
|
|
10398
|
-
/**
|
|
10399
|
-
* Deletes a project view.
|
|
10400
|
-
* @param params
|
|
10401
|
-
*/
|
|
10402
|
-
function Delete(params) {
|
|
10403
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
10404
|
-
let { api, viewId, req: reqParams } = params;
|
|
10405
|
-
if (!viewId) {
|
|
10406
|
-
throw ("View ID is required.");
|
|
10407
|
-
}
|
|
10408
|
-
if (!api) {
|
|
10409
|
-
api = ENVIRONMENT.Api().GetBruceApi();
|
|
10410
|
-
}
|
|
10411
|
-
yield api.DELETE(`ui.view/${viewId}`, Api.PrepReqParams(reqParams));
|
|
10412
|
-
api.Cache.Remove(GetCacheKey(viewId));
|
|
10413
|
-
api.Cache.RemoveByStartsWith(GetListCacheKey());
|
|
10414
|
-
});
|
|
10415
|
-
}
|
|
10416
|
-
ProjectView.Delete = Delete;
|
|
10533
|
+
Account.GetRelatedList = GetRelatedList;
|
|
10417
10534
|
/**
|
|
10418
|
-
*
|
|
10535
|
+
* Gets application settings for a specific client account.
|
|
10419
10536
|
* @param params
|
|
10420
10537
|
* @returns
|
|
10421
10538
|
*/
|
|
10422
|
-
function
|
|
10539
|
+
function GetAppSettings(params) {
|
|
10423
10540
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10424
|
-
let { api,
|
|
10541
|
+
let { api, accountId: id, appId, req: reqParams } = params;
|
|
10425
10542
|
if (!api) {
|
|
10426
|
-
api = ENVIRONMENT.Api().
|
|
10427
|
-
}
|
|
10428
|
-
if (!data) {
|
|
10429
|
-
data = {};
|
|
10430
|
-
}
|
|
10431
|
-
const isNew = !data.ID;
|
|
10432
|
-
if (!data.ID) {
|
|
10433
|
-
// Short ID to keep the URL short.
|
|
10434
|
-
// 8 length = 4,294,967,296 combinations.
|
|
10435
|
-
data.ID = ObjectUtils.UId(8);
|
|
10436
|
-
}
|
|
10437
|
-
if (!data.Name) {
|
|
10438
|
-
data.Name = data.ID;
|
|
10439
|
-
}
|
|
10440
|
-
if (!data.CreatedByUIVersion) {
|
|
10441
|
-
data.CreatedByUIVersion = "-1";
|
|
10442
|
-
}
|
|
10443
|
-
if (isNew) {
|
|
10444
|
-
data = yield api.POST(`ui.view/${data.ID}`, data, Api.PrepReqParams(reqParams));
|
|
10543
|
+
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
10445
10544
|
}
|
|
10446
|
-
|
|
10447
|
-
|
|
10545
|
+
const cache = yield api.GetCacheItem(GetCacheKey(id, appId), reqParams);
|
|
10546
|
+
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
10547
|
+
return cache.data;
|
|
10448
10548
|
}
|
|
10449
|
-
api.
|
|
10450
|
-
|
|
10451
|
-
|
|
10452
|
-
|
|
10453
|
-
|
|
10454
|
-
|
|
10455
|
-
|
|
10456
|
-
|
|
10457
|
-
|
|
10458
|
-
|
|
10459
|
-
|
|
10460
|
-
|
|
10461
|
-
|
|
10462
|
-
|
|
10463
|
-
|
|
10464
|
-
|
|
10465
|
-
|
|
10466
|
-
|
|
10467
|
-
|
|
10468
|
-
|
|
10469
|
-
}
|
|
10470
|
-
ProjectView.GetCacheKey = GetCacheKey;
|
|
10471
|
-
/**
|
|
10472
|
-
* Returns cache identifier for a list of project views.
|
|
10473
|
-
* Example: {
|
|
10474
|
-
* const api: BruceApi.Api = ...;
|
|
10475
|
-
* const key = GetListCacheKey();
|
|
10476
|
-
* api.Cache.Remove(key);
|
|
10477
|
-
* }
|
|
10478
|
-
* @param type optional filter for the type of project view.
|
|
10479
|
-
* @returns
|
|
10480
|
-
*/
|
|
10481
|
-
function GetListCacheKey(type) {
|
|
10482
|
-
if (type) {
|
|
10483
|
-
return `${Api.ECacheKey.ProjectView}${Api.ECacheKey.ListId}${type}`;
|
|
10484
|
-
}
|
|
10485
|
-
return `${Api.ECacheKey.ProjectView}${Api.ECacheKey.ListId}`;
|
|
10486
|
-
}
|
|
10487
|
-
ProjectView.GetListCacheKey = GetListCacheKey;
|
|
10488
|
-
})(ProjectView || (ProjectView = {}));
|
|
10489
|
-
|
|
10490
|
-
function getTemplateSettings(apiGetter, reqParams) {
|
|
10491
|
-
var _a;
|
|
10492
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
10493
|
-
const { view } = yield ProjectView.Get({
|
|
10494
|
-
api: apiGetter.getApi(Api.TEMPLATE_ACCOUNT_ID),
|
|
10495
|
-
viewId: "default",
|
|
10496
|
-
req: reqParams
|
|
10549
|
+
const req = yield api.GET(`account/${id}?ApplicationID=${appId}`, reqParams);
|
|
10550
|
+
const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
10551
|
+
var _a;
|
|
10552
|
+
try {
|
|
10553
|
+
const data = yield req;
|
|
10554
|
+
const settings = (_a = data === null || data === void 0 ? void 0 : data["Application.Settings"]) !== null && _a !== void 0 ? _a : {};
|
|
10555
|
+
res({
|
|
10556
|
+
settings: settings
|
|
10557
|
+
});
|
|
10558
|
+
}
|
|
10559
|
+
catch (e) {
|
|
10560
|
+
rej(e);
|
|
10561
|
+
}
|
|
10562
|
+
}));
|
|
10563
|
+
yield api.SetCacheItem({
|
|
10564
|
+
key: GetCacheKey(id, appId),
|
|
10565
|
+
value: prom,
|
|
10566
|
+
req: reqParams
|
|
10567
|
+
});
|
|
10568
|
+
return prom;
|
|
10497
10569
|
});
|
|
10498
|
-
return (_a = view.Settings) !== null && _a !== void 0 ? _a : {};
|
|
10499
|
-
});
|
|
10500
|
-
}
|
|
10501
|
-
function checkSourceToTemplate(items, templateItem, addIfMissing) {
|
|
10502
|
-
const index = items.findIndex(x => x.Name === templateItem.Name);
|
|
10503
|
-
if (index > -1) {
|
|
10504
|
-
templateItem.IsDefault = true;
|
|
10505
|
-
templateItem.IsEnabled = items[index].IsEnabled;
|
|
10506
|
-
items[index] = templateItem;
|
|
10507
|
-
}
|
|
10508
|
-
else if (addIfMissing) {
|
|
10509
|
-
templateItem.IsDefault = true;
|
|
10510
|
-
items.push(templateItem);
|
|
10511
10570
|
}
|
|
10512
|
-
|
|
10513
|
-
/**
|
|
10514
|
-
|
|
10515
|
-
|
|
10516
|
-
|
|
10517
|
-
|
|
10518
|
-
|
|
10519
|
-
|
|
10520
|
-
function MergeMapTemplateData(params) {
|
|
10521
|
-
var _a;
|
|
10571
|
+
Account.GetAppSettings = GetAppSettings;
|
|
10572
|
+
/**
|
|
10573
|
+
* Updates application settings for a specific client account + application.
|
|
10574
|
+
* WARNING: Do not update API settings without knowing what you're doing.
|
|
10575
|
+
* @param params
|
|
10576
|
+
* @returns
|
|
10577
|
+
*/
|
|
10578
|
+
function UpdateAppSettings(params) {
|
|
10522
10579
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10523
|
-
let {
|
|
10524
|
-
if (!
|
|
10525
|
-
|
|
10526
|
-
}
|
|
10527
|
-
const settings = yield getTemplateSettings(getter, reqParams);
|
|
10528
|
-
const maps = (_a = settings.CesiumMapSources) !== null && _a !== void 0 ? _a : [];
|
|
10529
|
-
for (let i = 0; i < maps.length; i++) {
|
|
10530
|
-
const mapSource = maps[i];
|
|
10531
|
-
checkSourceToTemplate(items, mapSource, addIfMissing);
|
|
10580
|
+
let { api, accountId: id, appId, settings: data, req: reqParams } = params;
|
|
10581
|
+
if (!api) {
|
|
10582
|
+
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
10532
10583
|
}
|
|
10584
|
+
const res = yield api.POST(`account/${id}/applicationSettings/${appId}`, data, reqParams);
|
|
10585
|
+
yield api.Cache.RemoveByStartsWith(Api.ECacheKey.Account + Api.ECacheKey.Id + id);
|
|
10533
10586
|
return {
|
|
10534
|
-
|
|
10587
|
+
settings: res
|
|
10535
10588
|
};
|
|
10536
10589
|
});
|
|
10537
10590
|
}
|
|
10538
|
-
|
|
10539
|
-
|
|
10540
|
-
|
|
10591
|
+
Account.UpdateAppSettings = UpdateAppSettings;
|
|
10592
|
+
/**
|
|
10593
|
+
* Creates a new Nextspace account using given details.
|
|
10594
|
+
* @param params
|
|
10595
|
+
* @returns
|
|
10596
|
+
*/
|
|
10597
|
+
function Create(params) {
|
|
10541
10598
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10542
|
-
let {
|
|
10543
|
-
if (!
|
|
10544
|
-
|
|
10599
|
+
let { api, accountId: id, name, hostingLocationKey, starterContent, req: reqParams } = params;
|
|
10600
|
+
if (!id || !name || !hostingLocationKey) {
|
|
10601
|
+
throw new Error("Id, Name and hostingLocationKey are required.");
|
|
10545
10602
|
}
|
|
10546
|
-
|
|
10547
|
-
|
|
10548
|
-
for (let i = 0; i < terrains.length; i++) {
|
|
10549
|
-
const terrainSource = terrains[i];
|
|
10550
|
-
checkSourceToTemplate(items, terrainSource, addIfMissing);
|
|
10603
|
+
if (!api) {
|
|
10604
|
+
api = ENVIRONMENT.Api().GetBruceApi();
|
|
10551
10605
|
}
|
|
10552
|
-
|
|
10553
|
-
|
|
10606
|
+
if (!starterContent) {
|
|
10607
|
+
starterContent = EStarterContent.None;
|
|
10608
|
+
}
|
|
10609
|
+
const reqData = {
|
|
10610
|
+
"Name": name,
|
|
10611
|
+
"HostingLocation.Key": hostingLocationKey,
|
|
10612
|
+
"StarterContent": starterContent
|
|
10613
|
+
};
|
|
10614
|
+
const res = yield api.POST(`clientAccount/${id}`, reqData, Api.PrepReqParams(reqParams));
|
|
10615
|
+
const resData = {
|
|
10616
|
+
account: res
|
|
10554
10617
|
};
|
|
10618
|
+
api.Cache.Remove(GetListCacheKey(api.GetSessionId()));
|
|
10619
|
+
return resData;
|
|
10555
10620
|
});
|
|
10556
10621
|
}
|
|
10557
|
-
|
|
10558
|
-
})(ProjectViewLegacyTile || (ProjectViewLegacyTile = {}));
|
|
10559
|
-
|
|
10560
|
-
/**
|
|
10561
|
-
* A tile is an imagery or terrain tileset definition.
|
|
10562
|
-
*/
|
|
10563
|
-
var ProjectViewTile;
|
|
10564
|
-
(function (ProjectViewTile) {
|
|
10565
|
-
/**
|
|
10566
|
-
* Available imagery defaults.
|
|
10567
|
-
*/
|
|
10568
|
-
let EDefaultImagery;
|
|
10569
|
-
(function (EDefaultImagery) {
|
|
10570
|
-
EDefaultImagery["BingMapsAerial"] = "bingmapsaerial";
|
|
10571
|
-
EDefaultImagery["BingMapsAerialWithLabels"] = "bingmapsaerialwithlabels";
|
|
10572
|
-
EDefaultImagery["BingMapsRoads"] = "bingmapsroads";
|
|
10573
|
-
EDefaultImagery["MapboxSatellite"] = "mapboxsatellite";
|
|
10574
|
-
EDefaultImagery["MapBoxStreets"] = "mapboxstreets";
|
|
10575
|
-
EDefaultImagery["MapBoxStreetsClassic"] = "mapboxstreetsclassic";
|
|
10576
|
-
EDefaultImagery["EsriWorldImagery"] = "esriworldimagery";
|
|
10577
|
-
EDefaultImagery["EsriWorldStreetMap"] = "esriworldstreetmap";
|
|
10578
|
-
EDefaultImagery["EsriNationalGeographic"] = "esrinationalgeographic";
|
|
10579
|
-
EDefaultImagery["OpenStreetMap"] = "openstreetmap";
|
|
10580
|
-
EDefaultImagery["LINZ"] = "linz";
|
|
10581
|
-
EDefaultImagery["StamenWaterColor"] = "stamenwatercolor";
|
|
10582
|
-
EDefaultImagery["StamenToner"] = "stamentoner";
|
|
10583
|
-
EDefaultImagery["Grid"] = "grid";
|
|
10584
|
-
EDefaultImagery["ThunderforestCycle"] = "thunderforestcycle";
|
|
10585
|
-
EDefaultImagery["ThunderforestTransport"] = "thunderforesttransport";
|
|
10586
|
-
EDefaultImagery["ThunderforestLandscape"] = "thunderforestlandscape";
|
|
10587
|
-
})(EDefaultImagery = ProjectViewTile.EDefaultImagery || (ProjectViewTile.EDefaultImagery = {}));
|
|
10622
|
+
Account.Create = Create;
|
|
10588
10623
|
/**
|
|
10589
|
-
*
|
|
10590
|
-
*
|
|
10624
|
+
* Returns cache identifier for an account by ID.
|
|
10625
|
+
* Example: {
|
|
10626
|
+
* const api: BruceApi.Api = ...;
|
|
10627
|
+
* const key = GetCacheKey(1);
|
|
10628
|
+
* api.Cache.Remove(key);
|
|
10629
|
+
* }
|
|
10630
|
+
* @param accountId
|
|
10631
|
+
* @param appSettingsId
|
|
10632
|
+
* @returns
|
|
10591
10633
|
*/
|
|
10592
|
-
|
|
10593
|
-
{
|
|
10594
|
-
|
|
10595
|
-
name: "Bing Maps Aerial",
|
|
10596
|
-
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/bingAerial.png"
|
|
10597
|
-
},
|
|
10598
|
-
{
|
|
10599
|
-
id: EDefaultImagery.BingMapsAerialWithLabels,
|
|
10600
|
-
name: "Bing Maps Aerial with Labels",
|
|
10601
|
-
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/bingAerialLabels.png"
|
|
10602
|
-
},
|
|
10603
|
-
{
|
|
10604
|
-
id: EDefaultImagery.BingMapsRoads,
|
|
10605
|
-
name: "Bing Maps Roads",
|
|
10606
|
-
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/bingRoads.png"
|
|
10607
|
-
},
|
|
10608
|
-
{
|
|
10609
|
-
id: EDefaultImagery.MapboxSatellite,
|
|
10610
|
-
name: "Mapbox Satellite",
|
|
10611
|
-
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/mapboxSatellite.png"
|
|
10612
|
-
},
|
|
10613
|
-
{
|
|
10614
|
-
id: EDefaultImagery.MapBoxStreets,
|
|
10615
|
-
name: "Mapbox Streets",
|
|
10616
|
-
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/mapboxTerrain.png"
|
|
10617
|
-
},
|
|
10618
|
-
{
|
|
10619
|
-
id: EDefaultImagery.MapBoxStreetsClassic,
|
|
10620
|
-
name: "Mapbox Streets Classic",
|
|
10621
|
-
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/mapboxStreets.png"
|
|
10622
|
-
},
|
|
10623
|
-
{
|
|
10624
|
-
id: EDefaultImagery.EsriWorldImagery,
|
|
10625
|
-
name: "Esri World Imagery",
|
|
10626
|
-
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/esriWorldImagery.png"
|
|
10627
|
-
},
|
|
10628
|
-
{
|
|
10629
|
-
id: EDefaultImagery.EsriWorldStreetMap,
|
|
10630
|
-
name: "Esri World Street Map",
|
|
10631
|
-
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/esriWorldStreetMap.png"
|
|
10632
|
-
},
|
|
10633
|
-
{
|
|
10634
|
-
id: EDefaultImagery.EsriNationalGeographic,
|
|
10635
|
-
name: "Esri National Geographic",
|
|
10636
|
-
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/esriNationalGeographic.png"
|
|
10637
|
-
},
|
|
10638
|
-
{
|
|
10639
|
-
id: EDefaultImagery.OpenStreetMap,
|
|
10640
|
-
name: "Open Street Map",
|
|
10641
|
-
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/openStreetMap.png"
|
|
10642
|
-
},
|
|
10643
|
-
{
|
|
10644
|
-
id: EDefaultImagery.LINZ,
|
|
10645
|
-
name: "LINZ",
|
|
10646
|
-
iconUrl: "https://template.ui.nextspace.host/media/linz.jpg"
|
|
10647
|
-
},
|
|
10648
|
-
{
|
|
10649
|
-
id: EDefaultImagery.StamenWaterColor,
|
|
10650
|
-
name: "Stamen Water Color",
|
|
10651
|
-
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/stamenWatercolor.png"
|
|
10652
|
-
},
|
|
10653
|
-
{
|
|
10654
|
-
id: EDefaultImagery.StamenToner,
|
|
10655
|
-
name: "Stamen Toner",
|
|
10656
|
-
iconUrl: "https://template.ui.nextspace.host/Default/media/Cesium/ImageryProviders/stamenToner.png"
|
|
10657
|
-
},
|
|
10658
|
-
{
|
|
10659
|
-
id: EDefaultImagery.ThunderforestCycle,
|
|
10660
|
-
name: "Thunderforest Cycle"
|
|
10661
|
-
},
|
|
10662
|
-
{
|
|
10663
|
-
id: EDefaultImagery.ThunderforestTransport,
|
|
10664
|
-
name: "Thunderforest Transport"
|
|
10665
|
-
},
|
|
10666
|
-
{
|
|
10667
|
-
id: EDefaultImagery.ThunderforestLandscape,
|
|
10668
|
-
name: "Thunderforest Landscape"
|
|
10669
|
-
},
|
|
10670
|
-
{
|
|
10671
|
-
id: EDefaultImagery.Grid,
|
|
10672
|
-
name: "Grid",
|
|
10673
|
-
iconUrl: "https://template.api.nextspace-uat.net/file/2885d8df-028b-4f5c-80b3-2634f7e7cf69.png"
|
|
10634
|
+
function GetCacheKey(accountId, appSettingsId) {
|
|
10635
|
+
if (appSettingsId) {
|
|
10636
|
+
return Api.ECacheKey.Account + Api.ECacheKey.Id + accountId + Api.ECacheKey + appSettingsId;
|
|
10674
10637
|
}
|
|
10675
|
-
|
|
10638
|
+
return Api.ECacheKey.Account + Api.ECacheKey.Id + accountId;
|
|
10639
|
+
}
|
|
10640
|
+
Account.GetCacheKey = GetCacheKey;
|
|
10676
10641
|
/**
|
|
10677
|
-
*
|
|
10642
|
+
* Returns cache identifier for a list of accounts by session ID.
|
|
10643
|
+
* Example: {
|
|
10644
|
+
* const api: BruceApi.Api = ...;
|
|
10645
|
+
* const key = GetListCacheKey(api.GetSessionId());
|
|
10646
|
+
* api.Cache.Remove(key);
|
|
10647
|
+
* }
|
|
10648
|
+
* @param ssid
|
|
10649
|
+
* @returns
|
|
10678
10650
|
*/
|
|
10679
|
-
|
|
10680
|
-
|
|
10681
|
-
|
|
10682
|
-
|
|
10683
|
-
EDefaultTerrain["LINZ"] = "linz";
|
|
10684
|
-
})(EDefaultTerrain = ProjectViewTile.EDefaultTerrain || (ProjectViewTile.EDefaultTerrain = {}));
|
|
10651
|
+
function GetListCacheKey(ssid) {
|
|
10652
|
+
return Api.ECacheKey.Account + Api.ECacheKey.Session + Api.ECacheKey.Id + ssid;
|
|
10653
|
+
}
|
|
10654
|
+
Account.GetListCacheKey = GetListCacheKey;
|
|
10685
10655
|
/**
|
|
10686
|
-
*
|
|
10687
|
-
*
|
|
10656
|
+
* Returns cache identifier for a list of database regions.
|
|
10657
|
+
* Example: {
|
|
10658
|
+
* const api: BruceApi.Api = ...;
|
|
10659
|
+
* const key = GetDbRegionListCacheKey();
|
|
10660
|
+
* api.Cache.Remove(key);
|
|
10661
|
+
* }
|
|
10662
|
+
* @returns
|
|
10688
10663
|
*/
|
|
10689
|
-
|
|
10690
|
-
|
|
10691
|
-
|
|
10692
|
-
|
|
10693
|
-
|
|
10694
|
-
},
|
|
10695
|
-
{
|
|
10696
|
-
id: EDefaultTerrain.LINZ,
|
|
10697
|
-
name: "LINZ",
|
|
10698
|
-
iconUrl: "https://template.ui.nextspace.host/media/linz.jpg"
|
|
10699
|
-
},
|
|
10700
|
-
{
|
|
10701
|
-
id: EDefaultTerrain.FlatTerrain,
|
|
10702
|
-
name: "Flat Terrain",
|
|
10703
|
-
}
|
|
10704
|
-
];
|
|
10705
|
-
})(ProjectViewTile || (ProjectViewTile = {}));
|
|
10706
|
-
|
|
10707
|
-
/**
|
|
10708
|
-
* Deprecated Project View record.
|
|
10709
|
-
* This was used in the legacy web Navigator.
|
|
10710
|
-
*/
|
|
10711
|
-
var ProjectViewLegacy;
|
|
10712
|
-
(function (ProjectViewLegacy) {
|
|
10713
|
-
ProjectViewLegacy.DATA_VERSION = 1;
|
|
10714
|
-
})(ProjectViewLegacy || (ProjectViewLegacy = {}));
|
|
10715
|
-
|
|
10716
|
-
/**
|
|
10717
|
-
* Deprecated Project View Bookmark record.
|
|
10718
|
-
* This was used in the legacy web Navigator.
|
|
10719
|
-
*/
|
|
10720
|
-
var ProjectViewLegacyBookmark;
|
|
10721
|
-
(function (ProjectViewLegacyBookmark) {
|
|
10722
|
-
ProjectViewLegacyBookmark.DATA_VERSION = 1;
|
|
10723
|
-
})(ProjectViewLegacyBookmark || (ProjectViewLegacyBookmark = {}));
|
|
10664
|
+
function GetDbRegionListCacheKey() {
|
|
10665
|
+
return Api.ECacheKey.DatabaseRegion;
|
|
10666
|
+
}
|
|
10667
|
+
Account.GetDbRegionListCacheKey = GetDbRegionListCacheKey;
|
|
10668
|
+
})(Account || (Account = {}));
|
|
10724
10669
|
|
|
10725
10670
|
/**
|
|
10726
|
-
*
|
|
10727
|
-
* A
|
|
10728
|
-
* This record is used to monitor its progress and completion state.
|
|
10671
|
+
* A hosting location is a record for a possible bruce-api server configuration.
|
|
10672
|
+
* A hosting location will have one or many database servers as well, this is an additional setting.
|
|
10729
10673
|
*/
|
|
10730
|
-
var
|
|
10731
|
-
(function (
|
|
10732
|
-
/**
|
|
10733
|
-
* Available pending action statuses.
|
|
10734
|
-
*/
|
|
10735
|
-
let EStatus;
|
|
10736
|
-
(function (EStatus) {
|
|
10737
|
-
EStatus["InProgress"] = "IN_PROGRESS";
|
|
10738
|
-
EStatus["Cancelled"] = "CANCELLED";
|
|
10739
|
-
EStatus["Complete"] = "COMPLETE";
|
|
10740
|
-
EStatus["Failed"] = "FAILED";
|
|
10741
|
-
})(EStatus = PendingAction.EStatus || (PendingAction.EStatus = {}));
|
|
10674
|
+
var HostingLocation;
|
|
10675
|
+
(function (HostingLocation) {
|
|
10742
10676
|
/**
|
|
10743
|
-
*
|
|
10677
|
+
* Returns a list of hosting locations.
|
|
10678
|
+
* @Warning: This will not return the Settings property.
|
|
10679
|
+
* @param params
|
|
10680
|
+
* @returns
|
|
10744
10681
|
*/
|
|
10745
|
-
|
|
10746
|
-
|
|
10747
|
-
|
|
10748
|
-
|
|
10749
|
-
|
|
10750
|
-
|
|
10751
|
-
|
|
10682
|
+
function GetList(params) {
|
|
10683
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
10684
|
+
let { api, req } = params;
|
|
10685
|
+
if (!api) {
|
|
10686
|
+
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
10687
|
+
}
|
|
10688
|
+
const res = yield api.GET("hostinglocations", Api.PrepReqParams(req));
|
|
10689
|
+
return {
|
|
10690
|
+
locations: res.Items
|
|
10691
|
+
};
|
|
10692
|
+
});
|
|
10693
|
+
}
|
|
10694
|
+
HostingLocation.GetList = GetList;
|
|
10752
10695
|
/**
|
|
10753
|
-
* Returns a
|
|
10696
|
+
* Returns a hosting location record by ID.
|
|
10754
10697
|
* @param params
|
|
10755
10698
|
* @returns
|
|
10756
10699
|
*/
|
|
10757
|
-
function
|
|
10700
|
+
function GetById(params) {
|
|
10758
10701
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10759
|
-
let {
|
|
10760
|
-
if (!
|
|
10761
|
-
throw ("
|
|
10702
|
+
let { id, api, req } = params;
|
|
10703
|
+
if (!id) {
|
|
10704
|
+
throw ("Invalid id");
|
|
10762
10705
|
}
|
|
10763
10706
|
if (!api) {
|
|
10764
|
-
api = ENVIRONMENT.Api().
|
|
10707
|
+
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
10765
10708
|
}
|
|
10766
|
-
const
|
|
10709
|
+
const res = yield api.GET(`hostinglocation/id/${id}`, Api.PrepReqParams(req));
|
|
10767
10710
|
return {
|
|
10768
|
-
|
|
10711
|
+
location: res
|
|
10769
10712
|
};
|
|
10770
10713
|
});
|
|
10771
10714
|
}
|
|
10772
|
-
|
|
10715
|
+
HostingLocation.GetById = GetById;
|
|
10773
10716
|
/**
|
|
10774
|
-
* Returns a
|
|
10717
|
+
* Returns a hosting location record by key.
|
|
10775
10718
|
* @param params
|
|
10776
10719
|
* @returns
|
|
10777
10720
|
*/
|
|
10778
|
-
function
|
|
10721
|
+
function GetByKey(params) {
|
|
10779
10722
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10780
|
-
let {
|
|
10723
|
+
let { key, api, req } = params;
|
|
10724
|
+
if (!key) {
|
|
10725
|
+
throw ("Invalid key");
|
|
10726
|
+
}
|
|
10781
10727
|
if (!api) {
|
|
10782
|
-
api = ENVIRONMENT.Api().
|
|
10728
|
+
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
10783
10729
|
}
|
|
10784
|
-
const
|
|
10730
|
+
const res = yield api.GET(`hostinglocation/key/${key}`, Api.PrepReqParams(req));
|
|
10785
10731
|
return {
|
|
10786
|
-
|
|
10732
|
+
location: res
|
|
10787
10733
|
};
|
|
10788
10734
|
});
|
|
10789
10735
|
}
|
|
10790
|
-
|
|
10736
|
+
HostingLocation.GetByKey = GetByKey;
|
|
10791
10737
|
/**
|
|
10792
|
-
* Returns
|
|
10738
|
+
* Returns hostingLocationKey from given db url.
|
|
10739
|
+
* Some older accounts don't have this set, so we need to guess it.
|
|
10793
10740
|
* @param params
|
|
10794
10741
|
* @returns
|
|
10795
10742
|
*/
|
|
10796
|
-
function
|
|
10743
|
+
function GuessKey(params) {
|
|
10744
|
+
const { DBServer: databaseUrl } = params;
|
|
10745
|
+
if (databaseUrl.includes("hyperfarm-prod-instance-1")) {
|
|
10746
|
+
return "HYPERFARM";
|
|
10747
|
+
}
|
|
10748
|
+
if (databaseUrl.includes("prod-syd1.nextspace.host")) {
|
|
10749
|
+
return "AU-VULTR-FIRST";
|
|
10750
|
+
}
|
|
10751
|
+
else if (databaseUrl.includes("prod-nyc1.nextspace.host")) {
|
|
10752
|
+
return "US-VULTR-FIRST";
|
|
10753
|
+
}
|
|
10754
|
+
else if (databaseUrl.includes("prod-ams1.nextspace.host")) {
|
|
10755
|
+
return "EU-VULTR-FIRST";
|
|
10756
|
+
}
|
|
10757
|
+
else if (databaseUrl.includes("prod-sing1.nextspace.host")) {
|
|
10758
|
+
return "SE-VULTR-FIRST";
|
|
10759
|
+
}
|
|
10760
|
+
else if (databaseUrl.includes("dev-first")) {
|
|
10761
|
+
return "DEV-FIRST";
|
|
10762
|
+
}
|
|
10763
|
+
else if (databaseUrl.includes(".ap-southeast-1.")) {
|
|
10764
|
+
return "SE";
|
|
10765
|
+
}
|
|
10766
|
+
else if (databaseUrl.includes(".us-west-1.")) {
|
|
10767
|
+
return "US";
|
|
10768
|
+
}
|
|
10769
|
+
else if (databaseUrl.includes(".eu-west-3.")) {
|
|
10770
|
+
return "EU";
|
|
10771
|
+
}
|
|
10772
|
+
else if (databaseUrl.includes("bruce-prod-au")) {
|
|
10773
|
+
return "AU";
|
|
10774
|
+
}
|
|
10775
|
+
else if (databaseUrl.includes("bruce-dev")) {
|
|
10776
|
+
return "DEV";
|
|
10777
|
+
}
|
|
10778
|
+
return null;
|
|
10779
|
+
}
|
|
10780
|
+
HostingLocation.GuessKey = GuessKey;
|
|
10781
|
+
/**
|
|
10782
|
+
* Returns a hosting location key by account ID.
|
|
10783
|
+
* @param params
|
|
10784
|
+
* @returns
|
|
10785
|
+
*/
|
|
10786
|
+
function GetKeyByAccountId(params) {
|
|
10797
10787
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10798
|
-
let {
|
|
10788
|
+
let { accountId, apiSettings, api, account, req } = params;
|
|
10789
|
+
if (!accountId && !apiSettings) {
|
|
10790
|
+
throw ("Invalid accountId or apiSettings");
|
|
10791
|
+
}
|
|
10799
10792
|
if (!api) {
|
|
10800
|
-
api = ENVIRONMENT.Api().
|
|
10793
|
+
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
10801
10794
|
}
|
|
10802
|
-
|
|
10803
|
-
|
|
10795
|
+
// We'll prioritize account record if provided.
|
|
10796
|
+
if (accountId && !account) {
|
|
10797
|
+
account = (yield Account.Get({
|
|
10798
|
+
accountId,
|
|
10799
|
+
api,
|
|
10800
|
+
req
|
|
10801
|
+
})).account;
|
|
10804
10802
|
}
|
|
10805
|
-
if (
|
|
10806
|
-
|
|
10803
|
+
if (account === null || account === void 0 ? void 0 : account["HostingLocation.Key"]) {
|
|
10804
|
+
return {
|
|
10805
|
+
key: account["HostingLocation.Key"],
|
|
10806
|
+
isLegacy: false
|
|
10807
|
+
};
|
|
10807
10808
|
}
|
|
10808
|
-
|
|
10809
|
-
|
|
10809
|
+
// Fallback to settings JSON for older records.
|
|
10810
|
+
const settings = apiSettings ? apiSettings : (yield Account.GetAppSettings({
|
|
10811
|
+
api,
|
|
10812
|
+
accountId,
|
|
10813
|
+
appId: Account.EAppId.BruceApi
|
|
10814
|
+
})).settings;
|
|
10815
|
+
let hostingKey = settings["HostingLocation.Key"];
|
|
10816
|
+
let isLegacy = false;
|
|
10817
|
+
if (!hostingKey) {
|
|
10818
|
+
hostingKey = settings.DBLocation;
|
|
10819
|
+
isLegacy = true;
|
|
10810
10820
|
}
|
|
10811
|
-
|
|
10812
|
-
|
|
10813
|
-
|
|
10814
|
-
|
|
10815
|
-
|
|
10821
|
+
if (!hostingKey) {
|
|
10822
|
+
hostingKey = GuessKey({
|
|
10823
|
+
DBServer: settings.DBServer
|
|
10824
|
+
});
|
|
10825
|
+
isLegacy = true;
|
|
10816
10826
|
}
|
|
10817
|
-
const data = yield api.GET(`pendingAction/${actionId}/progressMessages` + args, Api.PrepReqParams(reqParams));
|
|
10818
10827
|
return {
|
|
10819
|
-
|
|
10828
|
+
key: hostingKey,
|
|
10829
|
+
isLegacy
|
|
10820
10830
|
};
|
|
10821
10831
|
});
|
|
10822
10832
|
}
|
|
10823
|
-
|
|
10833
|
+
HostingLocation.GetKeyByAccountId = GetKeyByAccountId;
|
|
10824
10834
|
/**
|
|
10825
|
-
*
|
|
10835
|
+
* Returns a hosting location record by account ID.
|
|
10826
10836
|
* @param params
|
|
10837
|
+
* @returns
|
|
10827
10838
|
*/
|
|
10828
|
-
function
|
|
10839
|
+
function GetByAccountId(params) {
|
|
10829
10840
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10830
|
-
let {
|
|
10831
|
-
if (!actionId) {
|
|
10832
|
-
throw ("Action ID is required.");
|
|
10833
|
-
}
|
|
10841
|
+
let { accountId, apiSettings, api, req, account } = params;
|
|
10834
10842
|
if (!api) {
|
|
10835
|
-
api = ENVIRONMENT.Api().
|
|
10843
|
+
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
10836
10844
|
}
|
|
10837
|
-
yield
|
|
10845
|
+
const data = yield GetKeyByAccountId({
|
|
10846
|
+
accountId,
|
|
10847
|
+
account,
|
|
10848
|
+
apiSettings,
|
|
10849
|
+
api,
|
|
10850
|
+
req
|
|
10851
|
+
});
|
|
10852
|
+
if (!(data === null || data === void 0 ? void 0 : data.key)) {
|
|
10853
|
+
return null;
|
|
10854
|
+
}
|
|
10855
|
+
const key = yield GetByKey({
|
|
10856
|
+
key: data.key,
|
|
10857
|
+
api,
|
|
10858
|
+
req
|
|
10859
|
+
});
|
|
10860
|
+
return key;
|
|
10838
10861
|
});
|
|
10839
10862
|
}
|
|
10840
|
-
|
|
10841
|
-
})(
|
|
10863
|
+
HostingLocation.GetByAccountId = GetByAccountId;
|
|
10864
|
+
})(HostingLocation || (HostingLocation = {}));
|
|
10842
10865
|
|
|
10843
10866
|
/**
|
|
10844
10867
|
* Permissions in Nextspace are arbitrary strings with meaning in specific contexts.
|
|
@@ -13350,7 +13373,12 @@ var Plugin;
|
|
|
13350
13373
|
cacheKey = 0;
|
|
13351
13374
|
}
|
|
13352
13375
|
return {
|
|
13353
|
-
indexFileUrl:
|
|
13376
|
+
indexFileUrl: api.ConstructUrl({
|
|
13377
|
+
url: `ui.plugin/${pluginId}/file/index.jsc`,
|
|
13378
|
+
urlParams: {
|
|
13379
|
+
"version": String(cacheKey)
|
|
13380
|
+
}
|
|
13381
|
+
})
|
|
13354
13382
|
};
|
|
13355
13383
|
}
|
|
13356
13384
|
Plugin.GetLoadUrl = GetLoadUrl;
|
|
@@ -13733,7 +13761,7 @@ var DataSource;
|
|
|
13733
13761
|
})(DataSource || (DataSource = {}));
|
|
13734
13762
|
|
|
13735
13763
|
// This is updated with the package.json version on build.
|
|
13736
|
-
const VERSION = "4.
|
|
13764
|
+
const VERSION = "4.6.0";
|
|
13737
13765
|
|
|
13738
13766
|
export { VERSION, AnnDocument, CustomForm, AbstractApi, Api, BruceApi, GlobalApi, GuardianApi, ApiGetters, Calculator, Bounds, BruceEvent, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, Geometry, UTC, BruceVariable, LRUCache, EntityAttachmentType, EntityAttachment, EntityComment, EntityLink, EntityLod, EntityLodCategory, EntityRelationType, EntityRelation, EntitySource, EntityTag, EntityType, Entity, EntityCoords, EntityTypeVisualSettings, EntityAttribute, EntityHistoricData, EntityTableView, Comment, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, ProjectViewLegacyTile, ProjectViewTile, ProjectViewLegacy, ProjectViewLegacyBookmark, PendingAction, MessageBroker, HostingLocation, Style, Tileset, Permission, Session, UserGroup, User, Account, AccountInvite, AccountFeatures, AccountLimits, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, DataLab, ImportCad, ImportCsv, ImportJson, ImportKml, ImportedFile, Markup, Uploader, Plugin, ENVIRONMENT, DataSource };
|
|
13739
13767
|
//# sourceMappingURL=bruce-models.es5.js.map
|