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