bruce-models 4.1.5 → 4.1.7
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 +1522 -349
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +1510 -344
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/account/account-features.js +8 -6
- package/dist/lib/account/account-features.js.map +1 -1
- package/dist/lib/account/account-limits.js +617 -0
- package/dist/lib/account/account-limits.js.map +1 -0
- package/dist/lib/api/api.js +1 -0
- package/dist/lib/api/api.js.map +1 -1
- package/dist/lib/bruce-models.js +3 -1
- package/dist/lib/bruce-models.js.map +1 -1
- package/dist/lib/common/cache.js.map +1 -1
- package/dist/lib/common/utc.js +109 -8
- package/dist/lib/common/utc.js.map +1 -1
- package/dist/lib/entity/entity-attribute.js +4 -1
- package/dist/lib/entity/entity-attribute.js.map +1 -1
- package/dist/lib/entity-type-model/comment.js +478 -0
- package/dist/lib/entity-type-model/comment.js.map +1 -0
- package/dist/lib/environment.js +0 -3
- package/dist/lib/environment.js.map +1 -1
- package/dist/lib/util/path-utils.js +7 -1
- package/dist/lib/util/path-utils.js.map +1 -1
- package/dist/types/account/account-features.d.ts +1 -3
- package/dist/types/account/account-limits.d.ts +186 -0
- package/dist/types/api/api.d.ts +2 -1
- package/dist/types/bruce-models.d.ts +3 -1
- package/dist/types/common/utc.d.ts +26 -1
- package/dist/types/entity-type-model/comment.d.ts +71 -0
- package/package.json +1 -1
package/dist/bruce-models.es5.js
CHANGED
|
@@ -79,6 +79,7 @@ var Api;
|
|
|
79
79
|
ECacheKey["EntityHistoricData"] = "entityhistoricdata";
|
|
80
80
|
ECacheKey["EntityHistoricDataRec"] = "entityhistoricdatarec";
|
|
81
81
|
ECacheKey["EntityHistoricDataStats"] = "entityhistoricdatastats";
|
|
82
|
+
ECacheKey["AccountLimits"] = "accountlimits";
|
|
82
83
|
})(ECacheKey = Api.ECacheKey || (Api.ECacheKey = {}));
|
|
83
84
|
// 1 minute.
|
|
84
85
|
Api.DEFAULT_CACHE_DURATION = 60 * 1000;
|
|
@@ -2020,9 +2021,6 @@ var ENVIRONMENT;
|
|
|
2020
2021
|
if (ENVIRONMENT.IS_SELF_MANAGED) {
|
|
2021
2022
|
throw ("Self managed mode ON. You are getting this error because you didn't pass an Api instance to a function.");
|
|
2022
2023
|
}
|
|
2023
|
-
if (!ENVIRONMENT.PARAMS.accountId) {
|
|
2024
|
-
console.warn("No accountId set. This is required for the getters to work properly.");
|
|
2025
|
-
}
|
|
2026
2024
|
if (!_getters) {
|
|
2027
2025
|
_getters = new ApiGetters({
|
|
2028
2026
|
accountId: ENVIRONMENT.PARAMS.accountId,
|
|
@@ -2987,7 +2985,7 @@ var PathUtils;
|
|
|
2987
2985
|
* @returns
|
|
2988
2986
|
*/
|
|
2989
2987
|
function Parse(str) {
|
|
2990
|
-
if (!str) {
|
|
2988
|
+
if (!(str === null || str === void 0 ? void 0 : str.length)) {
|
|
2991
2989
|
return [];
|
|
2992
2990
|
}
|
|
2993
2991
|
const broken = str.split("\"/\"");
|
|
@@ -3017,6 +3015,9 @@ var PathUtils;
|
|
|
3017
3015
|
* @returns
|
|
3018
3016
|
*/
|
|
3019
3017
|
function Wrap(path) {
|
|
3018
|
+
if (!(path === null || path === void 0 ? void 0 : path.length)) {
|
|
3019
|
+
return "";
|
|
3020
|
+
}
|
|
3020
3021
|
let tmp = "\"";
|
|
3021
3022
|
for (let i = 0; i < path.length; i++) {
|
|
3022
3023
|
let section = path[i];
|
|
@@ -3035,6 +3036,9 @@ var PathUtils;
|
|
|
3035
3036
|
* @returns
|
|
3036
3037
|
*/
|
|
3037
3038
|
function ParseLegacy(str) {
|
|
3039
|
+
if (!(str === null || str === void 0 ? void 0 : str.length)) {
|
|
3040
|
+
return [];
|
|
3041
|
+
}
|
|
3038
3042
|
const broken = str.split(".");
|
|
3039
3043
|
for (let i = 0; i < broken.length; i++) {
|
|
3040
3044
|
let piece = broken[0];
|
|
@@ -4931,22 +4935,123 @@ var UTC;
|
|
|
4931
4935
|
EMonth[EMonth["November"] = 11] = "November";
|
|
4932
4936
|
EMonth[EMonth["December"] = 12] = "December";
|
|
4933
4937
|
})(EMonth = UTC.EMonth || (UTC.EMonth = {}));
|
|
4938
|
+
/**
|
|
4939
|
+
* Returns an ISO 8601 string representation of the provided date.
|
|
4940
|
+
* @param utc
|
|
4941
|
+
*/
|
|
4942
|
+
function ToString(utc) {
|
|
4943
|
+
return ToDate(utc).toISOString();
|
|
4944
|
+
}
|
|
4945
|
+
UTC.ToString = ToString;
|
|
4934
4946
|
function ToDate(utc) {
|
|
4935
|
-
return new Date(utc.y, utc.m - 1, utc.d, utc.hh, utc.mm, utc.ss, 0);
|
|
4947
|
+
return new Date(Date.UTC(utc.y, utc.m - 1, utc.d, utc.hh, utc.mm, utc.ss, 0));
|
|
4936
4948
|
}
|
|
4937
4949
|
UTC.ToDate = ToDate;
|
|
4938
|
-
function FromDate(
|
|
4950
|
+
function FromDate(utc) {
|
|
4939
4951
|
return {
|
|
4940
|
-
y:
|
|
4941
|
-
m:
|
|
4942
|
-
d:
|
|
4943
|
-
hh:
|
|
4944
|
-
mm:
|
|
4945
|
-
ss:
|
|
4952
|
+
y: utc.getUTCFullYear(),
|
|
4953
|
+
m: utc.getUTCMonth() + 1,
|
|
4954
|
+
d: utc.getUTCDate(),
|
|
4955
|
+
hh: utc.getUTCHours(),
|
|
4956
|
+
mm: utc.getUTCMinutes(),
|
|
4957
|
+
ss: utc.getUTCSeconds()
|
|
4946
4958
|
};
|
|
4947
4959
|
}
|
|
4948
4960
|
UTC.FromDate = FromDate;
|
|
4961
|
+
/**
|
|
4962
|
+
* Returns how many seconds have passed between two dates.
|
|
4963
|
+
* If the second date is not provided, it will be the current date.
|
|
4964
|
+
* @param from
|
|
4965
|
+
* @param to
|
|
4966
|
+
* @returns
|
|
4967
|
+
*/
|
|
4968
|
+
function GetPassedSeconds(from, to) {
|
|
4969
|
+
if (!to) {
|
|
4970
|
+
to = FromDate(new Date());
|
|
4971
|
+
}
|
|
4972
|
+
const fromTime = ToDate(from).getTime();
|
|
4973
|
+
const toTime = ToDate(to).getTime();
|
|
4974
|
+
return Math.floor((toTime - fromTime) / 1000);
|
|
4975
|
+
}
|
|
4976
|
+
UTC.GetPassedSeconds = GetPassedSeconds;
|
|
4977
|
+
/**
|
|
4978
|
+
* Returns a human-readable string that describes how much time has passed since the provided date.
|
|
4979
|
+
* @param utc
|
|
4980
|
+
*/
|
|
4981
|
+
function GetPassedTime(utc) {
|
|
4982
|
+
const passedSeconds = GetPassedSeconds(utc);
|
|
4983
|
+
if (passedSeconds < 60) {
|
|
4984
|
+
return `${passedSeconds} second${passedSeconds > 1 ? "s" : ""} ago`;
|
|
4985
|
+
}
|
|
4986
|
+
const passedMinutes = Math.floor(passedSeconds / 60);
|
|
4987
|
+
if (passedMinutes < 60) {
|
|
4988
|
+
return `${passedMinutes} minute${passedMinutes > 1 ? "s" : ""} ago`;
|
|
4989
|
+
}
|
|
4990
|
+
const passedHours = Math.floor(passedMinutes / 60);
|
|
4991
|
+
if (passedHours < 24) {
|
|
4992
|
+
return `${passedHours} hour${passedHours > 1 ? "s" : ""} ago`;
|
|
4993
|
+
}
|
|
4994
|
+
const passedDays = Math.floor(passedHours / 24);
|
|
4995
|
+
if (passedDays < 30) {
|
|
4996
|
+
return `${passedDays} day${passedDays > 1 ? "s" : ""} ago`;
|
|
4997
|
+
}
|
|
4998
|
+
const passedMonths = Math.floor(passedDays / 30);
|
|
4999
|
+
if (passedMonths < 12) {
|
|
5000
|
+
return `${passedMonths} month${passedMonths > 1 ? "s" : ""} ago`;
|
|
5001
|
+
}
|
|
5002
|
+
const passedYears = Math.floor(passedMonths / 12);
|
|
5003
|
+
return `${passedYears} year${passedYears > 1 ? "s" : ""} ago`;
|
|
5004
|
+
}
|
|
5005
|
+
UTC.GetPassedTime = GetPassedTime;
|
|
5006
|
+
/**
|
|
5007
|
+
* Returns a human-readable string that describes the provided date.
|
|
5008
|
+
* If a timezone is not provided then it will use the locale timezone.
|
|
5009
|
+
* @param utc
|
|
5010
|
+
* @param timezone
|
|
5011
|
+
*/
|
|
5012
|
+
function GetDateTime(utc, timezone) {
|
|
5013
|
+
const date = ToDate(utc);
|
|
5014
|
+
// Possibly could just pass the timezone and it might get ignored if missing.
|
|
5015
|
+
if (timezone) {
|
|
5016
|
+
return date.toLocaleString("en-US", {
|
|
5017
|
+
timeZone: timezone,
|
|
5018
|
+
hour12: true,
|
|
5019
|
+
hour: "numeric",
|
|
5020
|
+
minute: "numeric",
|
|
5021
|
+
year: "2-digit",
|
|
5022
|
+
month: "2-digit",
|
|
5023
|
+
day: "2-digit"
|
|
5024
|
+
}) + " " + getTimezoneName(timezone);
|
|
5025
|
+
}
|
|
5026
|
+
return date.toLocaleString(undefined, {
|
|
5027
|
+
hour12: true,
|
|
5028
|
+
hour: "numeric",
|
|
5029
|
+
minute: "numeric",
|
|
5030
|
+
year: "2-digit",
|
|
5031
|
+
month: "2-digit",
|
|
5032
|
+
day: "2-digit"
|
|
5033
|
+
});
|
|
5034
|
+
}
|
|
5035
|
+
UTC.GetDateTime = GetDateTime;
|
|
4949
5036
|
})(UTC || (UTC = {}));
|
|
5037
|
+
// Found here https://stackoverflow.com/questions/9772955/how-can-i-get-the-timezone-name-in-javascript
|
|
5038
|
+
// Formats a given timezone into a human readable format.
|
|
5039
|
+
function getTimezoneName(timezone) {
|
|
5040
|
+
const today = new Date();
|
|
5041
|
+
const short = today.toLocaleDateString(undefined, { timeZone: timezone });
|
|
5042
|
+
const full = today.toLocaleDateString(undefined, { timeZoneName: "long", timeZone: timezone });
|
|
5043
|
+
// Trying to remove date from the string in a locale-agnostic way
|
|
5044
|
+
const shortIndex = full.indexOf(short);
|
|
5045
|
+
if (shortIndex >= 0) {
|
|
5046
|
+
const trimmed = full.substring(0, shortIndex) + full.substring(shortIndex + short.length);
|
|
5047
|
+
// by this time `trimmed` should be the timezone's name with some punctuation -
|
|
5048
|
+
// trim it from both sides
|
|
5049
|
+
return trimmed.replace(/^[\s,.\-:;]+|[\s,.\-:;]+$/g, "");
|
|
5050
|
+
}
|
|
5051
|
+
// in some magic case when short representation of date is not present in the long one,
|
|
5052
|
+
// just return the long one as a fallback, since it should contain the timezone's name
|
|
5053
|
+
return full;
|
|
5054
|
+
}
|
|
4950
5055
|
|
|
4951
5056
|
/**
|
|
4952
5057
|
* A simple LRU cache implementation.
|
|
@@ -7032,7 +7137,7 @@ var EntityAttribute;
|
|
|
7032
7137
|
* @param path
|
|
7033
7138
|
*/
|
|
7034
7139
|
function RemoveAttribute(items, path) {
|
|
7035
|
-
if (!items || !path ||
|
|
7140
|
+
if (!items || !(path === null || path === void 0 ? void 0 : path.length)) {
|
|
7036
7141
|
return;
|
|
7037
7142
|
}
|
|
7038
7143
|
const key = path[0];
|
|
@@ -7061,6 +7166,9 @@ var EntityAttribute;
|
|
|
7061
7166
|
* @param attribute
|
|
7062
7167
|
*/
|
|
7063
7168
|
function AddAttribute(items, path, attribute) {
|
|
7169
|
+
if (!items || !(path === null || path === void 0 ? void 0 : path.length)) {
|
|
7170
|
+
return;
|
|
7171
|
+
}
|
|
7064
7172
|
const key = path[0];
|
|
7065
7173
|
if (path.length === 1) {
|
|
7066
7174
|
// If we're at the last key in the path, add the attribute to the items array.
|
|
@@ -7090,158 +7198,94 @@ var EntityAttribute;
|
|
|
7090
7198
|
})(EntityAttribute || (EntityAttribute = {}));
|
|
7091
7199
|
|
|
7092
7200
|
/**
|
|
7093
|
-
*
|
|
7201
|
+
* Describes the "Style" concept within Nextspace.
|
|
7202
|
+
* A legacy way of referring to styles is "entity display settings".
|
|
7203
|
+
*
|
|
7204
|
+
* A style is a collection of settings (which can be calculations to perform on entity data) that
|
|
7205
|
+
* describe how an entity should be displayed.
|
|
7094
7206
|
*/
|
|
7095
|
-
var
|
|
7096
|
-
(function (
|
|
7097
|
-
Uploader.MIN_LARGE_FILE_SIZE = 100000000; // 100MB.
|
|
7207
|
+
var Style;
|
|
7208
|
+
(function (Style) {
|
|
7098
7209
|
/**
|
|
7099
|
-
*
|
|
7210
|
+
* Types of styles available.
|
|
7211
|
+
* The type will dictate what settings are available.
|
|
7212
|
+
*/
|
|
7213
|
+
let EType;
|
|
7214
|
+
(function (EType) {
|
|
7215
|
+
EType["Entity"] = "ENTITY";
|
|
7216
|
+
EType["EntityRelationship"] = "ENTITY_RELATIONSHIP";
|
|
7217
|
+
})(EType = Style.EType || (Style.EType = {}));
|
|
7218
|
+
/**
|
|
7219
|
+
* Available types of points.
|
|
7220
|
+
* Default is POINT.
|
|
7221
|
+
*/
|
|
7222
|
+
let EPointType;
|
|
7223
|
+
(function (EPointType) {
|
|
7224
|
+
// Render a sphere with a fixed pixel size.
|
|
7225
|
+
EPointType["Point"] = "POINT";
|
|
7226
|
+
// Render an icon.
|
|
7227
|
+
EPointType["Icon"] = "ICON";
|
|
7228
|
+
// Render a cylinder with a fixed meter size.
|
|
7229
|
+
EPointType["Cylinder"] = "CYLINDER";
|
|
7230
|
+
})(EPointType = Style.EPointType || (Style.EPointType = {}));
|
|
7231
|
+
/**
|
|
7232
|
+
* Returns a list of styles.
|
|
7100
7233
|
* @param params
|
|
7101
7234
|
* @returns
|
|
7102
7235
|
*/
|
|
7103
|
-
function
|
|
7236
|
+
function GetList(params) {
|
|
7104
7237
|
return __awaiter(this, void 0, void 0, function* () {
|
|
7105
|
-
let {
|
|
7238
|
+
let { api, req: reqParams } = params;
|
|
7106
7239
|
if (!api) {
|
|
7107
7240
|
api = ENVIRONMENT.Api().GetBruceApi();
|
|
7108
7241
|
}
|
|
7109
|
-
const
|
|
7110
|
-
|
|
7111
|
-
|
|
7112
|
-
let filePartsCount = fileSize / FILE_PORTION_SIZE;
|
|
7113
|
-
let t = Math.trunc(filePartsCount);
|
|
7114
|
-
filePartsCount = filePartsCount > t ? t + 1 : t;
|
|
7115
|
-
let filePartIndex = 1;
|
|
7116
|
-
let uploadToken = ObjectUtils.UId();
|
|
7117
|
-
let data;
|
|
7118
|
-
while (fileOffset < fileSize) {
|
|
7119
|
-
let partSize = Math.min(FILE_PORTION_SIZE, fileSize - fileOffset);
|
|
7120
|
-
let retryCount = 5;
|
|
7121
|
-
let retryWait = 1000;
|
|
7122
|
-
while (retryCount > 0) {
|
|
7123
|
-
try {
|
|
7124
|
-
const blob = file.slice(fileOffset, fileOffset + partSize);
|
|
7125
|
-
const partialFile = new File([blob], file.name, { type: file.type });
|
|
7126
|
-
const formData = new FormData();
|
|
7127
|
-
formData.append("originalFileName", file.name);
|
|
7128
|
-
formData.append("token", uploadToken);
|
|
7129
|
-
formData.append("count", "" + filePartsCount);
|
|
7130
|
-
formData.append("part", "" + filePartIndex);
|
|
7131
|
-
formData.append("file", partialFile);
|
|
7132
|
-
const reqParams = Api.PrepReqParams(req);
|
|
7133
|
-
reqParams.formData = formData;
|
|
7134
|
-
reqParams.onProgress = (progress) => {
|
|
7135
|
-
const sofar = fileOffset + progress.loaded;
|
|
7136
|
-
const percent = Math.round((sofar / file.size) * 100);
|
|
7137
|
-
onProgress === null || onProgress === void 0 ? void 0 : onProgress({
|
|
7138
|
-
percent: percent,
|
|
7139
|
-
uploaded: false
|
|
7140
|
-
});
|
|
7141
|
-
};
|
|
7142
|
-
data = yield api.UPLOAD(url, partialFile, reqParams);
|
|
7143
|
-
retryCount = 0;
|
|
7144
|
-
}
|
|
7145
|
-
catch (up) {
|
|
7146
|
-
retryCount -= 1;
|
|
7147
|
-
if (retryCount <= 0) {
|
|
7148
|
-
throw up;
|
|
7149
|
-
}
|
|
7150
|
-
yield new Promise((res) => setTimeout(res, retryWait));
|
|
7151
|
-
retryWait = retryWait * 2;
|
|
7152
|
-
}
|
|
7153
|
-
}
|
|
7154
|
-
fileOffset += partSize;
|
|
7155
|
-
filePartIndex++;
|
|
7242
|
+
const cache = yield api.GetCacheItem(GetListCacheKey(), reqParams);
|
|
7243
|
+
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
7244
|
+
return cache.data;
|
|
7156
7245
|
}
|
|
7157
|
-
|
|
7158
|
-
|
|
7159
|
-
|
|
7246
|
+
const res = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
7247
|
+
try {
|
|
7248
|
+
const data = yield api.GET("ui.entityDisplaySettings", Api.PrepReqParams(reqParams));
|
|
7249
|
+
res({
|
|
7250
|
+
styles: data.Items
|
|
7251
|
+
});
|
|
7252
|
+
}
|
|
7253
|
+
catch (e) {
|
|
7254
|
+
rej(e);
|
|
7255
|
+
}
|
|
7256
|
+
}));
|
|
7257
|
+
yield api.SetCacheItem({
|
|
7258
|
+
key: GetListCacheKey(),
|
|
7259
|
+
value: res,
|
|
7260
|
+
req: reqParams
|
|
7160
7261
|
});
|
|
7161
|
-
return
|
|
7262
|
+
return res;
|
|
7162
7263
|
});
|
|
7163
7264
|
}
|
|
7164
|
-
|
|
7165
|
-
})(Uploader || (Uploader = {}));
|
|
7166
|
-
|
|
7167
|
-
/**
|
|
7168
|
-
* Describes the "Client File" concept within Nextspace.
|
|
7169
|
-
* A client file is a record of a file uploaded to Bruce.
|
|
7170
|
-
*/
|
|
7171
|
-
var ClientFile;
|
|
7172
|
-
(function (ClientFile$$1) {
|
|
7173
|
-
let EPurpose;
|
|
7174
|
-
(function (EPurpose) {
|
|
7175
|
-
// Use this purpose for uploading bookmark thumbnail images.
|
|
7176
|
-
// This will allow lower level privileges to upload (small) bookmark thumbnails.
|
|
7177
|
-
EPurpose["BookmarkThumbnail"] = "Bookmark Thumbnail";
|
|
7178
|
-
})(EPurpose = ClientFile$$1.EPurpose || (ClientFile$$1.EPurpose = {}));
|
|
7179
|
-
/**
|
|
7180
|
-
* Returns the URL for a client file.
|
|
7181
|
-
* @param params
|
|
7182
|
-
* @returns
|
|
7183
|
-
*/
|
|
7184
|
-
function GetUrl(params) {
|
|
7185
|
-
let { api, fileId, viaCdn } = params;
|
|
7186
|
-
if (!api) {
|
|
7187
|
-
api = ENVIRONMENT.Api().GetBruceApi();
|
|
7188
|
-
}
|
|
7189
|
-
const urlSuffix = `file/${fileId}`;
|
|
7190
|
-
const cdnUrl = viaCdn ? api.ConstructCdnUrl(urlSuffix) : null;
|
|
7191
|
-
if (cdnUrl) {
|
|
7192
|
-
return cdnUrl;
|
|
7193
|
-
}
|
|
7194
|
-
let url = `${api.GetBaseUrl()}${urlSuffix}`;
|
|
7195
|
-
// Invalidating cache manually because we have a wave of invalid headers now cached across devices.
|
|
7196
|
-
url = UrlUtils.AddQueryParam(url, "cc", "1");
|
|
7197
|
-
return url;
|
|
7198
|
-
}
|
|
7199
|
-
ClientFile$$1.GetUrl = GetUrl;
|
|
7200
|
-
/**
|
|
7201
|
-
* Returns the URL for a client file with the extension.
|
|
7202
|
-
* @param params
|
|
7203
|
-
* @returns
|
|
7204
|
-
*/
|
|
7205
|
-
function GetUrlWithExt(params) {
|
|
7206
|
-
let { api, file, viaCdn } = params;
|
|
7207
|
-
if (!api) {
|
|
7208
|
-
api = ENVIRONMENT.Api().GetBruceApi();
|
|
7209
|
-
}
|
|
7210
|
-
const urlSuffix = file.FileExt ? `file/${file.ID}${file.FileExt}` : `file/${file.ID}`;
|
|
7211
|
-
const cdnUrl = viaCdn ? api.ConstructCdnUrl(urlSuffix) : null;
|
|
7212
|
-
if (cdnUrl) {
|
|
7213
|
-
return cdnUrl;
|
|
7214
|
-
}
|
|
7215
|
-
let url = `${api.GetBaseUrl()}${urlSuffix}`;
|
|
7216
|
-
// Invalidating cache manually because we have a wave of invalid headers now cached across devices.
|
|
7217
|
-
url = UrlUtils.AddQueryParam(url, "cc", "1");
|
|
7218
|
-
return url;
|
|
7219
|
-
}
|
|
7220
|
-
ClientFile$$1.GetUrlWithExt = GetUrlWithExt;
|
|
7265
|
+
Style.GetList = GetList;
|
|
7221
7266
|
/**
|
|
7222
|
-
* Returns a
|
|
7267
|
+
* Returns a style.
|
|
7223
7268
|
* @param params
|
|
7224
7269
|
* @returns
|
|
7225
7270
|
*/
|
|
7226
7271
|
function Get(params) {
|
|
7227
7272
|
return __awaiter(this, void 0, void 0, function* () {
|
|
7228
|
-
let { api,
|
|
7273
|
+
let { api, styleId: id, req: reqParams } = params;
|
|
7274
|
+
if (!id) {
|
|
7275
|
+
throw ("Style ID is required.");
|
|
7276
|
+
}
|
|
7229
7277
|
if (!api) {
|
|
7230
7278
|
api = ENVIRONMENT.Api().GetBruceApi();
|
|
7231
7279
|
}
|
|
7232
|
-
|
|
7233
|
-
throw ("File ID is required.");
|
|
7234
|
-
}
|
|
7235
|
-
const key = GetCacheKey(fileId);
|
|
7236
|
-
const cache = yield api.GetCacheItem(key, reqParams);
|
|
7280
|
+
const cache = yield api.GetCacheItem(GetCacheKey(id), reqParams);
|
|
7237
7281
|
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
7238
7282
|
return cache.data;
|
|
7239
7283
|
}
|
|
7240
7284
|
const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
7241
7285
|
try {
|
|
7242
|
-
const data = yield api.GET(`
|
|
7286
|
+
const data = yield api.GET(`ui.entityDisplaySetting/${id}`, Api.PrepReqParams(reqParams));
|
|
7243
7287
|
res({
|
|
7244
|
-
|
|
7288
|
+
style: data
|
|
7245
7289
|
});
|
|
7246
7290
|
}
|
|
7247
7291
|
catch (e) {
|
|
@@ -7249,52 +7293,753 @@ var ClientFile;
|
|
|
7249
7293
|
}
|
|
7250
7294
|
}));
|
|
7251
7295
|
yield api.SetCacheItem({
|
|
7252
|
-
key,
|
|
7296
|
+
key: GetCacheKey(id),
|
|
7253
7297
|
value: prom,
|
|
7254
7298
|
req: reqParams
|
|
7255
7299
|
});
|
|
7256
7300
|
return prom;
|
|
7257
7301
|
});
|
|
7258
7302
|
}
|
|
7259
|
-
|
|
7303
|
+
Style.Get = Get;
|
|
7260
7304
|
/**
|
|
7261
|
-
*
|
|
7305
|
+
* Creates or updates a style.
|
|
7262
7306
|
* @param params
|
|
7307
|
+
* @returns
|
|
7263
7308
|
*/
|
|
7264
|
-
function
|
|
7309
|
+
function Update(params) {
|
|
7265
7310
|
return __awaiter(this, void 0, void 0, function* () {
|
|
7266
|
-
let { api,
|
|
7267
|
-
if (!
|
|
7268
|
-
|
|
7311
|
+
let { api, style: data, req: reqParams } = params;
|
|
7312
|
+
if (!(data === null || data === void 0 ? void 0 : data.Name)) {
|
|
7313
|
+
throw ("Style name is required.");
|
|
7269
7314
|
}
|
|
7270
7315
|
if (!api) {
|
|
7271
7316
|
api = ENVIRONMENT.Api().GetBruceApi();
|
|
7272
7317
|
}
|
|
7273
|
-
|
|
7274
|
-
|
|
7275
|
-
};
|
|
7276
|
-
yield api.POST("deleteFiles", data, Api.PrepReqParams(reqParams));
|
|
7277
|
-
for (let i = 0; i < fileIds.length; i++) {
|
|
7278
|
-
const key = GetCacheKey(fileIds[i]);
|
|
7279
|
-
api.Cache.Remove(key);
|
|
7318
|
+
if (!data.ID) {
|
|
7319
|
+
data.ID = 0;
|
|
7280
7320
|
}
|
|
7321
|
+
const res = yield api.POST(`ui.entityDisplaySetting/${data.ID}`, data, Api.PrepReqParams(reqParams));
|
|
7322
|
+
api.Cache.Remove(GetCacheKey(data.ID));
|
|
7323
|
+
api.Cache.Remove(GetListCacheKey());
|
|
7324
|
+
return {
|
|
7325
|
+
style: res
|
|
7326
|
+
};
|
|
7281
7327
|
});
|
|
7282
7328
|
}
|
|
7283
|
-
|
|
7329
|
+
Style.Update = Update;
|
|
7284
7330
|
/**
|
|
7285
|
-
*
|
|
7331
|
+
* Deletes a style.
|
|
7286
7332
|
* @param params
|
|
7287
|
-
* @returns
|
|
7288
7333
|
*/
|
|
7289
|
-
function
|
|
7334
|
+
function Delete(params) {
|
|
7290
7335
|
return __awaiter(this, void 0, void 0, function* () {
|
|
7291
|
-
let { api,
|
|
7336
|
+
let { api, styleId: id, req: reqParams } = params;
|
|
7292
7337
|
if (!api) {
|
|
7293
7338
|
api = ENVIRONMENT.Api().GetBruceApi();
|
|
7294
7339
|
}
|
|
7295
|
-
if (!
|
|
7296
|
-
throw ("
|
|
7297
|
-
}
|
|
7340
|
+
if (!id) {
|
|
7341
|
+
throw ("Style ID is required.");
|
|
7342
|
+
}
|
|
7343
|
+
yield api.DELETE(`ui.entityDisplaySetting/${id}`, Api.PrepReqParams(reqParams));
|
|
7344
|
+
api.Cache.Remove(GetCacheKey(id));
|
|
7345
|
+
api.Cache.Remove(GetListCacheKey());
|
|
7346
|
+
});
|
|
7347
|
+
}
|
|
7348
|
+
Style.Delete = Delete;
|
|
7349
|
+
/**
|
|
7350
|
+
* Returns cache identifier for a style.
|
|
7351
|
+
* Example: {
|
|
7352
|
+
* const api: BruceApi.Api = ...;
|
|
7353
|
+
* const key = GetCacheKey(1);
|
|
7354
|
+
* api.Cache.Remove(key);
|
|
7355
|
+
* }
|
|
7356
|
+
* @param id
|
|
7357
|
+
* @returns
|
|
7358
|
+
*/
|
|
7359
|
+
function GetCacheKey(id) {
|
|
7360
|
+
return Api.ECacheKey.Style + Api.ECacheKey.Id + id;
|
|
7361
|
+
}
|
|
7362
|
+
Style.GetCacheKey = GetCacheKey;
|
|
7363
|
+
/**
|
|
7364
|
+
* Returns cache identifier for a list of styles.
|
|
7365
|
+
* Example: {
|
|
7366
|
+
* const api: BruceApi.Api = ...;
|
|
7367
|
+
* const key = GetListCacheKey();
|
|
7368
|
+
* api.Cache.Remove(key);
|
|
7369
|
+
* }
|
|
7370
|
+
* @returns
|
|
7371
|
+
*/
|
|
7372
|
+
function GetListCacheKey() {
|
|
7373
|
+
return Api.ECacheKey.Style;
|
|
7374
|
+
}
|
|
7375
|
+
Style.GetListCacheKey = GetListCacheKey;
|
|
7376
|
+
})(Style || (Style = {}));
|
|
7377
|
+
|
|
7378
|
+
/**
|
|
7379
|
+
* Generic comment record and related functions.
|
|
7380
|
+
* This uses Entity records with a specific Entity Type.
|
|
7381
|
+
* This replaced the original comment system and allows for comments to be placed on any Entity, or by themselves.
|
|
7382
|
+
*/
|
|
7383
|
+
var Comment;
|
|
7384
|
+
(function (Comment) {
|
|
7385
|
+
// Entity Type used for storing comment records.
|
|
7386
|
+
Comment.ENTITY_TYPE_ID = "COMMENTS";
|
|
7387
|
+
// Relationship Type ID for linking relies to comments.
|
|
7388
|
+
Comment.REPLY_RELATIONSHIP_TYPE_ID = "COMMENTS_REPLY";
|
|
7389
|
+
// Possible kinds of comments.
|
|
7390
|
+
let EType;
|
|
7391
|
+
(function (EType) {
|
|
7392
|
+
EType["Comment"] = "COMMENT";
|
|
7393
|
+
EType["Reply"] = "REPLY";
|
|
7394
|
+
})(EType = Comment.EType || (Comment.EType = {}));
|
|
7395
|
+
/**
|
|
7396
|
+
* Returns a list of comments based on the provided filter.
|
|
7397
|
+
* @param params
|
|
7398
|
+
* @returns
|
|
7399
|
+
*/
|
|
7400
|
+
function GetList(params) {
|
|
7401
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
7402
|
+
let { api, req, filter } = params;
|
|
7403
|
+
if (!api) {
|
|
7404
|
+
api = ENVIRONMENT.Api().GetBruceApi();
|
|
7405
|
+
}
|
|
7406
|
+
req = Api.PrepReqParams(req);
|
|
7407
|
+
if (!(yield getEntityTypeExists(api, req))) {
|
|
7408
|
+
return {
|
|
7409
|
+
comments: []
|
|
7410
|
+
};
|
|
7411
|
+
}
|
|
7412
|
+
const reqFilter = {};
|
|
7413
|
+
if (filter.viewId) {
|
|
7414
|
+
reqFilter["viewId"] = {
|
|
7415
|
+
"equals": filter.viewId
|
|
7416
|
+
};
|
|
7417
|
+
}
|
|
7418
|
+
if (filter.userId) {
|
|
7419
|
+
reqFilter["CreatedBy.User.ID"] = {
|
|
7420
|
+
"equals": filter.userId
|
|
7421
|
+
};
|
|
7422
|
+
}
|
|
7423
|
+
if (filter.text) {
|
|
7424
|
+
reqFilter["text"] = {
|
|
7425
|
+
"contains": filter.text
|
|
7426
|
+
};
|
|
7427
|
+
}
|
|
7428
|
+
if (filter.entityId) {
|
|
7429
|
+
reqFilter["entityId"] = {
|
|
7430
|
+
"equals": filter.entityId
|
|
7431
|
+
};
|
|
7432
|
+
}
|
|
7433
|
+
const records = (yield Entity.GetList({
|
|
7434
|
+
api,
|
|
7435
|
+
req,
|
|
7436
|
+
filter: {
|
|
7437
|
+
entityTypeId: Comment.ENTITY_TYPE_ID,
|
|
7438
|
+
pageSize: filter.amount == null ? 20 : filter.amount,
|
|
7439
|
+
pageIndex: filter.index == null ? 0 : filter.index,
|
|
7440
|
+
entityTypeConditions: reqFilter,
|
|
7441
|
+
orderBy: "lastUpdateTime"
|
|
7442
|
+
}
|
|
7443
|
+
})).entities;
|
|
7444
|
+
return {
|
|
7445
|
+
comments: records
|
|
7446
|
+
};
|
|
7447
|
+
});
|
|
7448
|
+
}
|
|
7449
|
+
Comment.GetList = GetList;
|
|
7450
|
+
/**
|
|
7451
|
+
* Ensure the Entity Type exists.
|
|
7452
|
+
* If it does not exist, it will be created.
|
|
7453
|
+
* @param params
|
|
7454
|
+
*/
|
|
7455
|
+
function AssertEntityType(params) {
|
|
7456
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
7457
|
+
let { api, req } = params;
|
|
7458
|
+
if (!api) {
|
|
7459
|
+
api = ENVIRONMENT.Api().GetBruceApi();
|
|
7460
|
+
}
|
|
7461
|
+
req = Api.PrepReqParams(req);
|
|
7462
|
+
// If the Entity Type does not exist, create it.
|
|
7463
|
+
if (!(yield getEntityTypeExists(api, req))) {
|
|
7464
|
+
// Create Style and set it to the Entity Type.
|
|
7465
|
+
const styleId = yield ensureStyleExists(api);
|
|
7466
|
+
const template = JSON.parse(JSON.stringify(ENTITY_TYPE_TEMPLATE));
|
|
7467
|
+
template["DisplaySetting.ID"] = styleId;
|
|
7468
|
+
yield EntityType.Update({
|
|
7469
|
+
api,
|
|
7470
|
+
entityType: template
|
|
7471
|
+
});
|
|
7472
|
+
}
|
|
7473
|
+
});
|
|
7474
|
+
}
|
|
7475
|
+
Comment.AssertEntityType = AssertEntityType;
|
|
7476
|
+
/**
|
|
7477
|
+
* Ensure the Relation Type exists.
|
|
7478
|
+
* If it does not exist, it will be created.
|
|
7479
|
+
* @param params
|
|
7480
|
+
*/
|
|
7481
|
+
function AssertRelationType(params) {
|
|
7482
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
7483
|
+
let { api, req } = params;
|
|
7484
|
+
if (!api) {
|
|
7485
|
+
api = ENVIRONMENT.Api().GetBruceApi();
|
|
7486
|
+
}
|
|
7487
|
+
req = Api.PrepReqParams(req);
|
|
7488
|
+
yield ensureRelationExists(api, req);
|
|
7489
|
+
});
|
|
7490
|
+
}
|
|
7491
|
+
Comment.AssertRelationType = AssertRelationType;
|
|
7492
|
+
})(Comment || (Comment = {}));
|
|
7493
|
+
function getEntityTypeExists(api, req) {
|
|
7494
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
7495
|
+
try {
|
|
7496
|
+
const { entityType: data } = yield EntityType.Get({
|
|
7497
|
+
api,
|
|
7498
|
+
req: req,
|
|
7499
|
+
entityTypeId: Comment.ENTITY_TYPE_ID
|
|
7500
|
+
});
|
|
7501
|
+
return !!data;
|
|
7502
|
+
}
|
|
7503
|
+
catch (e) {
|
|
7504
|
+
// TODO: suppress if the error is related to not being found.
|
|
7505
|
+
console.error(e);
|
|
7506
|
+
}
|
|
7507
|
+
return false;
|
|
7508
|
+
});
|
|
7509
|
+
}
|
|
7510
|
+
function ensureStyleExists(api, req) {
|
|
7511
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
7512
|
+
try {
|
|
7513
|
+
const template = JSON.parse(JSON.stringify(STYLE_SETTINGS_TEMPLATE));
|
|
7514
|
+
const { style } = yield Style.Update({
|
|
7515
|
+
api,
|
|
7516
|
+
req: req,
|
|
7517
|
+
style: {
|
|
7518
|
+
Name: "Comment Style",
|
|
7519
|
+
Settings: template,
|
|
7520
|
+
Type: Style.EType.Entity,
|
|
7521
|
+
ID: 0
|
|
7522
|
+
}
|
|
7523
|
+
});
|
|
7524
|
+
return style.ID;
|
|
7525
|
+
}
|
|
7526
|
+
catch (e) {
|
|
7527
|
+
console.error(e);
|
|
7528
|
+
}
|
|
7529
|
+
return 0;
|
|
7530
|
+
});
|
|
7531
|
+
}
|
|
7532
|
+
function ensureRelationExists(api, req) {
|
|
7533
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
7534
|
+
try {
|
|
7535
|
+
const { relationType: data } = yield EntityRelationType.Get({
|
|
7536
|
+
api,
|
|
7537
|
+
req: req,
|
|
7538
|
+
relationTypeId: Comment.REPLY_RELATIONSHIP_TYPE_ID
|
|
7539
|
+
});
|
|
7540
|
+
if (!data) {
|
|
7541
|
+
throw ("Relation Type not found");
|
|
7542
|
+
}
|
|
7543
|
+
}
|
|
7544
|
+
catch (e) {
|
|
7545
|
+
yield EntityRelationType.Update({
|
|
7546
|
+
api,
|
|
7547
|
+
req: req,
|
|
7548
|
+
relationType: {
|
|
7549
|
+
ID: Comment.REPLY_RELATIONSHIP_TYPE_ID,
|
|
7550
|
+
ForwardName: "Parent of",
|
|
7551
|
+
ReverseName: "Reply to",
|
|
7552
|
+
Name: "Comment Reply"
|
|
7553
|
+
}
|
|
7554
|
+
});
|
|
7555
|
+
}
|
|
7556
|
+
});
|
|
7557
|
+
}
|
|
7558
|
+
const STYLE_SETTINGS_TEMPLATE = {
|
|
7559
|
+
pointStyle: {
|
|
7560
|
+
"color": [
|
|
7561
|
+
{
|
|
7562
|
+
"type": 0,
|
|
7563
|
+
"value": "rgba(33,150,243,0.8)"
|
|
7564
|
+
}
|
|
7565
|
+
],
|
|
7566
|
+
"CylinderBorderEnabled": false,
|
|
7567
|
+
"CylinderBorderWidth": [
|
|
7568
|
+
{
|
|
7569
|
+
"type": 1,
|
|
7570
|
+
"value": "15"
|
|
7571
|
+
}
|
|
7572
|
+
],
|
|
7573
|
+
"CylinderFillExtrusion": [
|
|
7574
|
+
{
|
|
7575
|
+
"type": 1,
|
|
7576
|
+
"value": "40"
|
|
7577
|
+
}
|
|
7578
|
+
],
|
|
7579
|
+
"Type": Style.EPointType.Icon,
|
|
7580
|
+
"iconId": null,
|
|
7581
|
+
"altitudeOption": {
|
|
7582
|
+
"name": "Absolute position",
|
|
7583
|
+
"id": 1
|
|
7584
|
+
},
|
|
7585
|
+
"size": [
|
|
7586
|
+
{
|
|
7587
|
+
"type": 1,
|
|
7588
|
+
"value": "20"
|
|
7589
|
+
}
|
|
7590
|
+
],
|
|
7591
|
+
"CylinderFillColor": [
|
|
7592
|
+
{
|
|
7593
|
+
"type": 1,
|
|
7594
|
+
"value": "rgba(33,150,243,0.8)"
|
|
7595
|
+
}
|
|
7596
|
+
],
|
|
7597
|
+
"CylinderBorderExtrusion": [
|
|
7598
|
+
{
|
|
7599
|
+
"type": 1,
|
|
7600
|
+
"value": "35"
|
|
7601
|
+
}
|
|
7602
|
+
],
|
|
7603
|
+
"CylinderRadius": [
|
|
7604
|
+
{
|
|
7605
|
+
"type": 1,
|
|
7606
|
+
"value": "20"
|
|
7607
|
+
}
|
|
7608
|
+
],
|
|
7609
|
+
"iconUrl": [
|
|
7610
|
+
{
|
|
7611
|
+
"type": 1,
|
|
7612
|
+
"value": "https://template.api.nextspace-uat.net/file/faf2194d-3a95-40cc-a6b3-6a7aa223f766.png"
|
|
7613
|
+
}
|
|
7614
|
+
],
|
|
7615
|
+
"ClusterNearbyEntities": false,
|
|
7616
|
+
"CylinderBorderColor": [
|
|
7617
|
+
{
|
|
7618
|
+
"type": 1,
|
|
7619
|
+
"value": "rgba(33,150,243,0.8)"
|
|
7620
|
+
}
|
|
7621
|
+
],
|
|
7622
|
+
"iconScale": [
|
|
7623
|
+
{
|
|
7624
|
+
"type": 1,
|
|
7625
|
+
"value": 1
|
|
7626
|
+
}
|
|
7627
|
+
],
|
|
7628
|
+
"MinimumEntitiesCountForClustering": [
|
|
7629
|
+
{
|
|
7630
|
+
"type": 1,
|
|
7631
|
+
"value": "2"
|
|
7632
|
+
}
|
|
7633
|
+
]
|
|
7634
|
+
}
|
|
7635
|
+
};
|
|
7636
|
+
const ENTITY_TYPE_TEMPLATE = {
|
|
7637
|
+
ID: Comment.ENTITY_TYPE_ID,
|
|
7638
|
+
Name: "Comments",
|
|
7639
|
+
DataSchema: {
|
|
7640
|
+
"Key": "root",
|
|
7641
|
+
"Name": "Root",
|
|
7642
|
+
"Type": EntityAttribute.EType.Structure,
|
|
7643
|
+
Structure: [
|
|
7644
|
+
{
|
|
7645
|
+
"IsIndexed": true,
|
|
7646
|
+
"IsImportant": false,
|
|
7647
|
+
"Type": EntityAttribute.EType.String,
|
|
7648
|
+
"IsArray": false,
|
|
7649
|
+
"Size": 40,
|
|
7650
|
+
"Key": "ID",
|
|
7651
|
+
"Name": "Identity",
|
|
7652
|
+
"IsFamilyAttribute": false,
|
|
7653
|
+
"IsFamilyAttributeDefault": false
|
|
7654
|
+
},
|
|
7655
|
+
{
|
|
7656
|
+
"IsIndexed": false,
|
|
7657
|
+
"IsImportant": false,
|
|
7658
|
+
"Type": EntityAttribute.EType.Geometry,
|
|
7659
|
+
"IsArray": false,
|
|
7660
|
+
"Size": 0,
|
|
7661
|
+
"Key": "geometry",
|
|
7662
|
+
"Name": "Geometry",
|
|
7663
|
+
"IsFamilyAttribute": false,
|
|
7664
|
+
"IsFamilyAttributeDefault": false
|
|
7665
|
+
},
|
|
7666
|
+
{
|
|
7667
|
+
"IsImportant": false,
|
|
7668
|
+
"Type": EntityAttribute.EType.Structure,
|
|
7669
|
+
"IsArray": false,
|
|
7670
|
+
"Structure": [
|
|
7671
|
+
{
|
|
7672
|
+
"IsIndexed": true,
|
|
7673
|
+
"IsImportant": false,
|
|
7674
|
+
"Type": EntityAttribute.EType.Double,
|
|
7675
|
+
"IsArray": false,
|
|
7676
|
+
"Key": "minLongitude",
|
|
7677
|
+
"Name": "Min Longitude",
|
|
7678
|
+
"IsFamilyAttribute": false,
|
|
7679
|
+
"IsFamilyAttributeDefault": false
|
|
7680
|
+
},
|
|
7681
|
+
{
|
|
7682
|
+
"IsIndexed": true,
|
|
7683
|
+
"IsImportant": false,
|
|
7684
|
+
"Type": EntityAttribute.EType.Double,
|
|
7685
|
+
"IsArray": false,
|
|
7686
|
+
"Key": "minLatitude",
|
|
7687
|
+
"Name": "Min Latitude",
|
|
7688
|
+
"IsFamilyAttribute": false,
|
|
7689
|
+
"IsFamilyAttributeDefault": false
|
|
7690
|
+
},
|
|
7691
|
+
{
|
|
7692
|
+
"IsIndexed": true,
|
|
7693
|
+
"IsImportant": false,
|
|
7694
|
+
"Type": EntityAttribute.EType.Double,
|
|
7695
|
+
"IsArray": false,
|
|
7696
|
+
"Size": 0,
|
|
7697
|
+
"Key": "minAltitude",
|
|
7698
|
+
"Name": "Min Altitude",
|
|
7699
|
+
"IsFamilyAttribute": false,
|
|
7700
|
+
"IsFamilyAttributeDefault": false
|
|
7701
|
+
},
|
|
7702
|
+
{
|
|
7703
|
+
"IsIndexed": true,
|
|
7704
|
+
"IsImportant": false,
|
|
7705
|
+
"Type": EntityAttribute.EType.Double,
|
|
7706
|
+
"IsArray": false,
|
|
7707
|
+
"Key": "maxLongitude",
|
|
7708
|
+
"Name": "Max Longitude",
|
|
7709
|
+
"IsFamilyAttribute": false,
|
|
7710
|
+
"IsFamilyAttributeDefault": false
|
|
7711
|
+
},
|
|
7712
|
+
{
|
|
7713
|
+
"IsIndexed": true,
|
|
7714
|
+
"IsImportant": false,
|
|
7715
|
+
"Type": EntityAttribute.EType.Double,
|
|
7716
|
+
"IsArray": false,
|
|
7717
|
+
"Key": "maxLatitude",
|
|
7718
|
+
"Name": "Max Latitude",
|
|
7719
|
+
"IsFamilyAttribute": false,
|
|
7720
|
+
"IsFamilyAttributeDefault": false
|
|
7721
|
+
},
|
|
7722
|
+
{
|
|
7723
|
+
"IsIndexed": true,
|
|
7724
|
+
"IsImportant": false,
|
|
7725
|
+
"Type": EntityAttribute.EType.Double,
|
|
7726
|
+
"IsArray": false,
|
|
7727
|
+
"Size": 0,
|
|
7728
|
+
"Key": "maxAltitude",
|
|
7729
|
+
"Name": "Max Altitude",
|
|
7730
|
+
"IsFamilyAttribute": false,
|
|
7731
|
+
"IsFamilyAttributeDefault": false
|
|
7732
|
+
}
|
|
7733
|
+
],
|
|
7734
|
+
"Key": "boundaries",
|
|
7735
|
+
"Name": "Boundaries",
|
|
7736
|
+
"IsFamilyAttribute": false,
|
|
7737
|
+
"IsFamilyAttributeDefault": false
|
|
7738
|
+
},
|
|
7739
|
+
{
|
|
7740
|
+
"IsImportant": false,
|
|
7741
|
+
"Type": EntityAttribute.EType.Structure,
|
|
7742
|
+
"IsArray": false,
|
|
7743
|
+
"Structure": [
|
|
7744
|
+
{
|
|
7745
|
+
"IsIndexed": true,
|
|
7746
|
+
"IsImportant": false,
|
|
7747
|
+
"Type": EntityAttribute.EType.Double,
|
|
7748
|
+
"IsArray": false,
|
|
7749
|
+
"Key": "latitude",
|
|
7750
|
+
"Name": "Latitude",
|
|
7751
|
+
"IsFamilyAttribute": false,
|
|
7752
|
+
"IsFamilyAttributeDefault": false
|
|
7753
|
+
},
|
|
7754
|
+
{
|
|
7755
|
+
"IsIndexed": true,
|
|
7756
|
+
"IsImportant": false,
|
|
7757
|
+
"Type": EntityAttribute.EType.Double,
|
|
7758
|
+
"IsArray": false,
|
|
7759
|
+
"Key": "longitude",
|
|
7760
|
+
"Name": "Longitude",
|
|
7761
|
+
"IsFamilyAttribute": false,
|
|
7762
|
+
"IsFamilyAttributeDefault": false
|
|
7763
|
+
},
|
|
7764
|
+
{
|
|
7765
|
+
"IsIndexed": true,
|
|
7766
|
+
"IsImportant": false,
|
|
7767
|
+
"Type": EntityAttribute.EType.Double,
|
|
7768
|
+
"IsArray": false,
|
|
7769
|
+
"Key": "altitude",
|
|
7770
|
+
"Name": "Altitude",
|
|
7771
|
+
"IsFamilyAttribute": false,
|
|
7772
|
+
"IsFamilyAttributeDefault": false
|
|
7773
|
+
}
|
|
7774
|
+
],
|
|
7775
|
+
"Key": "location",
|
|
7776
|
+
"Name": "Location",
|
|
7777
|
+
"IsFamilyAttribute": false,
|
|
7778
|
+
"IsFamilyAttributeDefault": false
|
|
7779
|
+
},
|
|
7780
|
+
{
|
|
7781
|
+
"IsIndexed": true,
|
|
7782
|
+
"IsImportant": true,
|
|
7783
|
+
"Type": EntityAttribute.EType.String,
|
|
7784
|
+
"IsArray": false,
|
|
7785
|
+
"Size": 60,
|
|
7786
|
+
"Key": "viewId",
|
|
7787
|
+
"Name": "View Id",
|
|
7788
|
+
"IsFamilyAttribute": false,
|
|
7789
|
+
"IsFamilyAttributeDefault": false
|
|
7790
|
+
},
|
|
7791
|
+
{
|
|
7792
|
+
"IsIndexed": true,
|
|
7793
|
+
"IsImportant": true,
|
|
7794
|
+
"Type": EntityAttribute.EType.String,
|
|
7795
|
+
"IsArray": false,
|
|
7796
|
+
"Size": 60,
|
|
7797
|
+
"Key": "bookmarkId",
|
|
7798
|
+
"Name": "Bookmark Id",
|
|
7799
|
+
"IsFamilyAttribute": false,
|
|
7800
|
+
"IsFamilyAttributeDefault": false
|
|
7801
|
+
},
|
|
7802
|
+
{
|
|
7803
|
+
"IsIndexed": true,
|
|
7804
|
+
"IsImportant": true,
|
|
7805
|
+
"Type": EntityAttribute.EType.String,
|
|
7806
|
+
"IsArray": false,
|
|
7807
|
+
"Key": "text",
|
|
7808
|
+
"Name": "Comment",
|
|
7809
|
+
"IsFamilyAttribute": false,
|
|
7810
|
+
"IsFamilyAttributeDefault": false
|
|
7811
|
+
},
|
|
7812
|
+
{
|
|
7813
|
+
"IsIndexed": true,
|
|
7814
|
+
"IsImportant": true,
|
|
7815
|
+
"Type": EntityAttribute.EType.Datetime,
|
|
7816
|
+
"IsArray": false,
|
|
7817
|
+
"Key": "lastUpdateTime",
|
|
7818
|
+
"Name": "Last Update Time",
|
|
7819
|
+
"IsFamilyAttribute": false,
|
|
7820
|
+
"IsFamilyAttributeDefault": false
|
|
7821
|
+
},
|
|
7822
|
+
{
|
|
7823
|
+
"IsIndexed": true,
|
|
7824
|
+
"IsImportant": true,
|
|
7825
|
+
"Type": EntityAttribute.EType.String,
|
|
7826
|
+
"IsArray": false,
|
|
7827
|
+
"Key": "entityId",
|
|
7828
|
+
"Name": "Related Entity ID",
|
|
7829
|
+
"IsFamilyAttribute": false,
|
|
7830
|
+
"IsFamilyAttributeDefault": false
|
|
7831
|
+
}
|
|
7832
|
+
]
|
|
7833
|
+
},
|
|
7834
|
+
"DisplaySetting.ID": 0
|
|
7835
|
+
};
|
|
7836
|
+
|
|
7837
|
+
/**
|
|
7838
|
+
* Utility for uploading files.
|
|
7839
|
+
*/
|
|
7840
|
+
var Uploader;
|
|
7841
|
+
(function (Uploader) {
|
|
7842
|
+
Uploader.MIN_LARGE_FILE_SIZE = 100000000; // 100MB.
|
|
7843
|
+
/**
|
|
7844
|
+
* Uploads a file to the server.
|
|
7845
|
+
* @param params
|
|
7846
|
+
* @returns
|
|
7847
|
+
*/
|
|
7848
|
+
function DoMultiPartUpload(params) {
|
|
7849
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
7850
|
+
let { file, api, urlSuffix: url, req, onProgress } = params;
|
|
7851
|
+
if (!api) {
|
|
7852
|
+
api = ENVIRONMENT.Api().GetBruceApi();
|
|
7853
|
+
}
|
|
7854
|
+
const FILE_PORTION_SIZE = 100000000; // 100MB.
|
|
7855
|
+
let fileSize = file.size;
|
|
7856
|
+
let fileOffset = 0;
|
|
7857
|
+
let filePartsCount = fileSize / FILE_PORTION_SIZE;
|
|
7858
|
+
let t = Math.trunc(filePartsCount);
|
|
7859
|
+
filePartsCount = filePartsCount > t ? t + 1 : t;
|
|
7860
|
+
let filePartIndex = 1;
|
|
7861
|
+
let uploadToken = ObjectUtils.UId();
|
|
7862
|
+
let data;
|
|
7863
|
+
while (fileOffset < fileSize) {
|
|
7864
|
+
let partSize = Math.min(FILE_PORTION_SIZE, fileSize - fileOffset);
|
|
7865
|
+
let retryCount = 5;
|
|
7866
|
+
let retryWait = 1000;
|
|
7867
|
+
while (retryCount > 0) {
|
|
7868
|
+
try {
|
|
7869
|
+
const blob = file.slice(fileOffset, fileOffset + partSize);
|
|
7870
|
+
const partialFile = new File([blob], file.name, { type: file.type });
|
|
7871
|
+
const formData = new FormData();
|
|
7872
|
+
formData.append("originalFileName", file.name);
|
|
7873
|
+
formData.append("token", uploadToken);
|
|
7874
|
+
formData.append("count", "" + filePartsCount);
|
|
7875
|
+
formData.append("part", "" + filePartIndex);
|
|
7876
|
+
formData.append("file", partialFile);
|
|
7877
|
+
const reqParams = Api.PrepReqParams(req);
|
|
7878
|
+
reqParams.formData = formData;
|
|
7879
|
+
reqParams.onProgress = (progress) => {
|
|
7880
|
+
const sofar = fileOffset + progress.loaded;
|
|
7881
|
+
const percent = Math.round((sofar / file.size) * 100);
|
|
7882
|
+
onProgress === null || onProgress === void 0 ? void 0 : onProgress({
|
|
7883
|
+
percent: percent,
|
|
7884
|
+
uploaded: false
|
|
7885
|
+
});
|
|
7886
|
+
};
|
|
7887
|
+
data = yield api.UPLOAD(url, partialFile, reqParams);
|
|
7888
|
+
retryCount = 0;
|
|
7889
|
+
}
|
|
7890
|
+
catch (up) {
|
|
7891
|
+
retryCount -= 1;
|
|
7892
|
+
if (retryCount <= 0) {
|
|
7893
|
+
throw up;
|
|
7894
|
+
}
|
|
7895
|
+
yield new Promise((res) => setTimeout(res, retryWait));
|
|
7896
|
+
retryWait = retryWait * 2;
|
|
7897
|
+
}
|
|
7898
|
+
}
|
|
7899
|
+
fileOffset += partSize;
|
|
7900
|
+
filePartIndex++;
|
|
7901
|
+
}
|
|
7902
|
+
onProgress === null || onProgress === void 0 ? void 0 : onProgress({
|
|
7903
|
+
percent: 100,
|
|
7904
|
+
uploaded: true
|
|
7905
|
+
});
|
|
7906
|
+
return data;
|
|
7907
|
+
});
|
|
7908
|
+
}
|
|
7909
|
+
Uploader.DoMultiPartUpload = DoMultiPartUpload;
|
|
7910
|
+
})(Uploader || (Uploader = {}));
|
|
7911
|
+
|
|
7912
|
+
/**
|
|
7913
|
+
* Describes the "Client File" concept within Nextspace.
|
|
7914
|
+
* A client file is a record of a file uploaded to Bruce.
|
|
7915
|
+
*/
|
|
7916
|
+
var ClientFile;
|
|
7917
|
+
(function (ClientFile$$1) {
|
|
7918
|
+
let EPurpose;
|
|
7919
|
+
(function (EPurpose) {
|
|
7920
|
+
// Use this purpose for uploading bookmark thumbnail images.
|
|
7921
|
+
// This will allow lower level privileges to upload (small) bookmark thumbnails.
|
|
7922
|
+
EPurpose["BookmarkThumbnail"] = "Bookmark Thumbnail";
|
|
7923
|
+
})(EPurpose = ClientFile$$1.EPurpose || (ClientFile$$1.EPurpose = {}));
|
|
7924
|
+
/**
|
|
7925
|
+
* Returns the URL for a client file.
|
|
7926
|
+
* @param params
|
|
7927
|
+
* @returns
|
|
7928
|
+
*/
|
|
7929
|
+
function GetUrl(params) {
|
|
7930
|
+
let { api, fileId, viaCdn } = params;
|
|
7931
|
+
if (!api) {
|
|
7932
|
+
api = ENVIRONMENT.Api().GetBruceApi();
|
|
7933
|
+
}
|
|
7934
|
+
const urlSuffix = `file/${fileId}`;
|
|
7935
|
+
const cdnUrl = viaCdn ? api.ConstructCdnUrl(urlSuffix) : null;
|
|
7936
|
+
if (cdnUrl) {
|
|
7937
|
+
return cdnUrl;
|
|
7938
|
+
}
|
|
7939
|
+
let url = `${api.GetBaseUrl()}${urlSuffix}`;
|
|
7940
|
+
// Invalidating cache manually because we have a wave of invalid headers now cached across devices.
|
|
7941
|
+
url = UrlUtils.AddQueryParam(url, "cc", "1");
|
|
7942
|
+
return url;
|
|
7943
|
+
}
|
|
7944
|
+
ClientFile$$1.GetUrl = GetUrl;
|
|
7945
|
+
/**
|
|
7946
|
+
* Returns the URL for a client file with the extension.
|
|
7947
|
+
* @param params
|
|
7948
|
+
* @returns
|
|
7949
|
+
*/
|
|
7950
|
+
function GetUrlWithExt(params) {
|
|
7951
|
+
let { api, file, viaCdn } = params;
|
|
7952
|
+
if (!api) {
|
|
7953
|
+
api = ENVIRONMENT.Api().GetBruceApi();
|
|
7954
|
+
}
|
|
7955
|
+
const urlSuffix = file.FileExt ? `file/${file.ID}${file.FileExt}` : `file/${file.ID}`;
|
|
7956
|
+
const cdnUrl = viaCdn ? api.ConstructCdnUrl(urlSuffix) : null;
|
|
7957
|
+
if (cdnUrl) {
|
|
7958
|
+
return cdnUrl;
|
|
7959
|
+
}
|
|
7960
|
+
let url = `${api.GetBaseUrl()}${urlSuffix}`;
|
|
7961
|
+
// Invalidating cache manually because we have a wave of invalid headers now cached across devices.
|
|
7962
|
+
url = UrlUtils.AddQueryParam(url, "cc", "1");
|
|
7963
|
+
return url;
|
|
7964
|
+
}
|
|
7965
|
+
ClientFile$$1.GetUrlWithExt = GetUrlWithExt;
|
|
7966
|
+
/**
|
|
7967
|
+
* Returns a client file record by ID.
|
|
7968
|
+
* @param params
|
|
7969
|
+
* @returns
|
|
7970
|
+
*/
|
|
7971
|
+
function Get(params) {
|
|
7972
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
7973
|
+
let { api, fileId, req: reqParams } = params;
|
|
7974
|
+
if (!api) {
|
|
7975
|
+
api = ENVIRONMENT.Api().GetBruceApi();
|
|
7976
|
+
}
|
|
7977
|
+
if (!fileId) {
|
|
7978
|
+
throw ("File ID is required.");
|
|
7979
|
+
}
|
|
7980
|
+
const key = GetCacheKey(fileId);
|
|
7981
|
+
const cache = yield api.GetCacheItem(key, reqParams);
|
|
7982
|
+
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
7983
|
+
return cache.data;
|
|
7984
|
+
}
|
|
7985
|
+
const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
7986
|
+
try {
|
|
7987
|
+
const data = yield api.GET(`file/${fileId}/details`, Api.PrepReqParams(reqParams));
|
|
7988
|
+
res({
|
|
7989
|
+
clientFile: data
|
|
7990
|
+
});
|
|
7991
|
+
}
|
|
7992
|
+
catch (e) {
|
|
7993
|
+
rej(e);
|
|
7994
|
+
}
|
|
7995
|
+
}));
|
|
7996
|
+
yield api.SetCacheItem({
|
|
7997
|
+
key,
|
|
7998
|
+
value: prom,
|
|
7999
|
+
req: reqParams
|
|
8000
|
+
});
|
|
8001
|
+
return prom;
|
|
8002
|
+
});
|
|
8003
|
+
}
|
|
8004
|
+
ClientFile$$1.Get = Get;
|
|
8005
|
+
/**
|
|
8006
|
+
* Deletes one or many client file records by IDs.
|
|
8007
|
+
* @param params
|
|
8008
|
+
*/
|
|
8009
|
+
function Delete(params) {
|
|
8010
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
8011
|
+
let { api, fileIds, req: reqParams } = params;
|
|
8012
|
+
if (!fileIds.length) {
|
|
8013
|
+
return Promise.resolve();
|
|
8014
|
+
}
|
|
8015
|
+
if (!api) {
|
|
8016
|
+
api = ENVIRONMENT.Api().GetBruceApi();
|
|
8017
|
+
}
|
|
8018
|
+
const data = {
|
|
8019
|
+
Items: fileIds
|
|
8020
|
+
};
|
|
8021
|
+
yield api.POST("deleteFiles", data, Api.PrepReqParams(reqParams));
|
|
8022
|
+
for (let i = 0; i < fileIds.length; i++) {
|
|
8023
|
+
const key = GetCacheKey(fileIds[i]);
|
|
8024
|
+
api.Cache.Remove(key);
|
|
8025
|
+
}
|
|
8026
|
+
});
|
|
8027
|
+
}
|
|
8028
|
+
ClientFile$$1.Delete = Delete;
|
|
8029
|
+
/**
|
|
8030
|
+
* Uploads a file and creates a new client file record.
|
|
8031
|
+
* @param params
|
|
8032
|
+
* @returns
|
|
8033
|
+
*/
|
|
8034
|
+
function Upload(params) {
|
|
8035
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
8036
|
+
let { api, file, purpose, req, onProgress } = params;
|
|
8037
|
+
if (!api) {
|
|
8038
|
+
api = ENVIRONMENT.Api().GetBruceApi();
|
|
8039
|
+
}
|
|
8040
|
+
if (!file) {
|
|
8041
|
+
throw ("File is required.");
|
|
8042
|
+
}
|
|
7298
8043
|
const size = file === null || file === void 0 ? void 0 : file.size;
|
|
7299
8044
|
if (!size) {
|
|
7300
8045
|
throw ("You cannot upload a 0byte sized file.");
|
|
@@ -9530,189 +10275,11 @@ var PendingAction;
|
|
|
9530
10275
|
if (!api) {
|
|
9531
10276
|
api = ENVIRONMENT.Api().GetBruceApi();
|
|
9532
10277
|
}
|
|
9533
|
-
yield api.DELETE(`pendingAction/${actionId}`, Api.PrepReqParams(reqParams));
|
|
9534
|
-
});
|
|
9535
|
-
}
|
|
9536
|
-
PendingAction.Cancel = Cancel;
|
|
9537
|
-
})(PendingAction || (PendingAction = {}));
|
|
9538
|
-
|
|
9539
|
-
/**
|
|
9540
|
-
* Describes the "Style" concept within Nextspace.
|
|
9541
|
-
* A legacy way of referring to styles is "entity display settings".
|
|
9542
|
-
*
|
|
9543
|
-
* A style is a collection of settings (which can be calculations to perform on entity data) that
|
|
9544
|
-
* describe how an entity should be displayed.
|
|
9545
|
-
*/
|
|
9546
|
-
var Style;
|
|
9547
|
-
(function (Style) {
|
|
9548
|
-
/**
|
|
9549
|
-
* Types of styles available.
|
|
9550
|
-
* The type will dictate what settings are available.
|
|
9551
|
-
*/
|
|
9552
|
-
let EType;
|
|
9553
|
-
(function (EType) {
|
|
9554
|
-
EType["Entity"] = "ENTITY";
|
|
9555
|
-
EType["EntityRelationship"] = "ENTITY_RELATIONSHIP";
|
|
9556
|
-
})(EType = Style.EType || (Style.EType = {}));
|
|
9557
|
-
/**
|
|
9558
|
-
* Available types of points.
|
|
9559
|
-
* Default is POINT.
|
|
9560
|
-
*/
|
|
9561
|
-
let EPointType;
|
|
9562
|
-
(function (EPointType) {
|
|
9563
|
-
// Render a sphere with a fixed pixel size.
|
|
9564
|
-
EPointType["Point"] = "POINT";
|
|
9565
|
-
// Render an icon.
|
|
9566
|
-
EPointType["Icon"] = "ICON";
|
|
9567
|
-
// Render a cylinder with a fixed meter size.
|
|
9568
|
-
EPointType["Cylinder"] = "CYLINDER";
|
|
9569
|
-
})(EPointType = Style.EPointType || (Style.EPointType = {}));
|
|
9570
|
-
/**
|
|
9571
|
-
* Returns a list of styles.
|
|
9572
|
-
* @param params
|
|
9573
|
-
* @returns
|
|
9574
|
-
*/
|
|
9575
|
-
function GetList(params) {
|
|
9576
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
9577
|
-
let { api, req: reqParams } = params;
|
|
9578
|
-
if (!api) {
|
|
9579
|
-
api = ENVIRONMENT.Api().GetBruceApi();
|
|
9580
|
-
}
|
|
9581
|
-
const cache = yield api.GetCacheItem(GetListCacheKey(), reqParams);
|
|
9582
|
-
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
9583
|
-
return cache.data;
|
|
9584
|
-
}
|
|
9585
|
-
const res = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
9586
|
-
try {
|
|
9587
|
-
const data = yield api.GET("ui.entityDisplaySettings", Api.PrepReqParams(reqParams));
|
|
9588
|
-
res({
|
|
9589
|
-
styles: data.Items
|
|
9590
|
-
});
|
|
9591
|
-
}
|
|
9592
|
-
catch (e) {
|
|
9593
|
-
rej(e);
|
|
9594
|
-
}
|
|
9595
|
-
}));
|
|
9596
|
-
yield api.SetCacheItem({
|
|
9597
|
-
key: GetListCacheKey(),
|
|
9598
|
-
value: res,
|
|
9599
|
-
req: reqParams
|
|
9600
|
-
});
|
|
9601
|
-
return res;
|
|
9602
|
-
});
|
|
9603
|
-
}
|
|
9604
|
-
Style.GetList = GetList;
|
|
9605
|
-
/**
|
|
9606
|
-
* Returns a style.
|
|
9607
|
-
* @param params
|
|
9608
|
-
* @returns
|
|
9609
|
-
*/
|
|
9610
|
-
function Get(params) {
|
|
9611
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
9612
|
-
let { api, styleId: id, req: reqParams } = params;
|
|
9613
|
-
if (!id) {
|
|
9614
|
-
throw ("Style ID is required.");
|
|
9615
|
-
}
|
|
9616
|
-
if (!api) {
|
|
9617
|
-
api = ENVIRONMENT.Api().GetBruceApi();
|
|
9618
|
-
}
|
|
9619
|
-
const cache = yield api.GetCacheItem(GetCacheKey(id), reqParams);
|
|
9620
|
-
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
9621
|
-
return cache.data;
|
|
9622
|
-
}
|
|
9623
|
-
const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
9624
|
-
try {
|
|
9625
|
-
const data = yield api.GET(`ui.entityDisplaySetting/${id}`, Api.PrepReqParams(reqParams));
|
|
9626
|
-
res({
|
|
9627
|
-
style: data
|
|
9628
|
-
});
|
|
9629
|
-
}
|
|
9630
|
-
catch (e) {
|
|
9631
|
-
rej(e);
|
|
9632
|
-
}
|
|
9633
|
-
}));
|
|
9634
|
-
yield api.SetCacheItem({
|
|
9635
|
-
key: GetCacheKey(id),
|
|
9636
|
-
value: prom,
|
|
9637
|
-
req: reqParams
|
|
9638
|
-
});
|
|
9639
|
-
return prom;
|
|
9640
|
-
});
|
|
9641
|
-
}
|
|
9642
|
-
Style.Get = Get;
|
|
9643
|
-
/**
|
|
9644
|
-
* Creates or updates a style.
|
|
9645
|
-
* @param params
|
|
9646
|
-
* @returns
|
|
9647
|
-
*/
|
|
9648
|
-
function Update(params) {
|
|
9649
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
9650
|
-
let { api, style: data, req: reqParams } = params;
|
|
9651
|
-
if (!(data === null || data === void 0 ? void 0 : data.Name)) {
|
|
9652
|
-
throw ("Style name is required.");
|
|
9653
|
-
}
|
|
9654
|
-
if (!api) {
|
|
9655
|
-
api = ENVIRONMENT.Api().GetBruceApi();
|
|
9656
|
-
}
|
|
9657
|
-
if (!data.ID) {
|
|
9658
|
-
data.ID = 0;
|
|
9659
|
-
}
|
|
9660
|
-
const res = yield api.POST(`ui.entityDisplaySetting/${data.ID}`, data, Api.PrepReqParams(reqParams));
|
|
9661
|
-
api.Cache.Remove(GetCacheKey(data.ID));
|
|
9662
|
-
api.Cache.Remove(GetListCacheKey());
|
|
9663
|
-
return {
|
|
9664
|
-
style: res
|
|
9665
|
-
};
|
|
9666
|
-
});
|
|
9667
|
-
}
|
|
9668
|
-
Style.Update = Update;
|
|
9669
|
-
/**
|
|
9670
|
-
* Deletes a style.
|
|
9671
|
-
* @param params
|
|
9672
|
-
*/
|
|
9673
|
-
function Delete(params) {
|
|
9674
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
9675
|
-
let { api, styleId: id, req: reqParams } = params;
|
|
9676
|
-
if (!api) {
|
|
9677
|
-
api = ENVIRONMENT.Api().GetBruceApi();
|
|
9678
|
-
}
|
|
9679
|
-
if (!id) {
|
|
9680
|
-
throw ("Style ID is required.");
|
|
9681
|
-
}
|
|
9682
|
-
yield api.DELETE(`ui.entityDisplaySetting/${id}`, Api.PrepReqParams(reqParams));
|
|
9683
|
-
api.Cache.Remove(GetCacheKey(id));
|
|
9684
|
-
api.Cache.Remove(GetListCacheKey());
|
|
9685
|
-
});
|
|
9686
|
-
}
|
|
9687
|
-
Style.Delete = Delete;
|
|
9688
|
-
/**
|
|
9689
|
-
* Returns cache identifier for a style.
|
|
9690
|
-
* Example: {
|
|
9691
|
-
* const api: BruceApi.Api = ...;
|
|
9692
|
-
* const key = GetCacheKey(1);
|
|
9693
|
-
* api.Cache.Remove(key);
|
|
9694
|
-
* }
|
|
9695
|
-
* @param id
|
|
9696
|
-
* @returns
|
|
9697
|
-
*/
|
|
9698
|
-
function GetCacheKey(id) {
|
|
9699
|
-
return Api.ECacheKey.Style + Api.ECacheKey.Id + id;
|
|
9700
|
-
}
|
|
9701
|
-
Style.GetCacheKey = GetCacheKey;
|
|
9702
|
-
/**
|
|
9703
|
-
* Returns cache identifier for a list of styles.
|
|
9704
|
-
* Example: {
|
|
9705
|
-
* const api: BruceApi.Api = ...;
|
|
9706
|
-
* const key = GetListCacheKey();
|
|
9707
|
-
* api.Cache.Remove(key);
|
|
9708
|
-
* }
|
|
9709
|
-
* @returns
|
|
9710
|
-
*/
|
|
9711
|
-
function GetListCacheKey() {
|
|
9712
|
-
return Api.ECacheKey.Style;
|
|
10278
|
+
yield api.DELETE(`pendingAction/${actionId}`, Api.PrepReqParams(reqParams));
|
|
10279
|
+
});
|
|
9713
10280
|
}
|
|
9714
|
-
|
|
9715
|
-
})(
|
|
10281
|
+
PendingAction.Cancel = Cancel;
|
|
10282
|
+
})(PendingAction || (PendingAction = {}));
|
|
9716
10283
|
|
|
9717
10284
|
/**
|
|
9718
10285
|
* Permissions in Nextspace are arbitrary strings with meaning in specific contexts.
|
|
@@ -10831,17 +11398,18 @@ var AccountFeatures;
|
|
|
10831
11398
|
EFeature["EntityLexicalSearch"] = "Feature_Entity_Lexical_Search";
|
|
10832
11399
|
})(EFeature = AccountFeatures.EFeature || (AccountFeatures.EFeature = {}));
|
|
10833
11400
|
/**
|
|
10834
|
-
* Gets account features corresponding to
|
|
11401
|
+
* Gets account features corresponding to the API instance's account.
|
|
10835
11402
|
* @param params
|
|
10836
11403
|
* @returns
|
|
10837
11404
|
*/
|
|
10838
11405
|
function Get(params) {
|
|
10839
11406
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10840
|
-
let { api,
|
|
11407
|
+
let { api, req: reqParams } = params;
|
|
10841
11408
|
if (!api) {
|
|
10842
11409
|
api = ENVIRONMENT.Api().GetBruceApi();
|
|
10843
11410
|
}
|
|
10844
|
-
const
|
|
11411
|
+
const accountId = api.AccountId;
|
|
11412
|
+
const cache = yield api.GetCacheItem(GetCacheKey(accountId), reqParams);
|
|
10845
11413
|
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
10846
11414
|
return cache.data;
|
|
10847
11415
|
}
|
|
@@ -10858,7 +11426,7 @@ var AccountFeatures;
|
|
|
10858
11426
|
}
|
|
10859
11427
|
}));
|
|
10860
11428
|
api.SetCacheItem({
|
|
10861
|
-
key: GetCacheKey(
|
|
11429
|
+
key: GetCacheKey(accountId),
|
|
10862
11430
|
value: prom,
|
|
10863
11431
|
req: reqParams
|
|
10864
11432
|
});
|
|
@@ -10868,10 +11436,11 @@ var AccountFeatures;
|
|
|
10868
11436
|
AccountFeatures.Get = Get;
|
|
10869
11437
|
function Update(params) {
|
|
10870
11438
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10871
|
-
let { api,
|
|
11439
|
+
let { api, features, req: reqParams } = params;
|
|
10872
11440
|
if (!api) {
|
|
10873
11441
|
api = ENVIRONMENT.Api().GetBruceApi();
|
|
10874
11442
|
}
|
|
11443
|
+
const accountId = api.AccountId;
|
|
10875
11444
|
const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
10876
11445
|
try {
|
|
10877
11446
|
const data = yield api.POST("features", {
|
|
@@ -10886,7 +11455,7 @@ var AccountFeatures;
|
|
|
10886
11455
|
rej(e);
|
|
10887
11456
|
}
|
|
10888
11457
|
}));
|
|
10889
|
-
api.Cache.Remove(GetCacheKey(
|
|
11458
|
+
api.Cache.Remove(GetCacheKey(accountId));
|
|
10890
11459
|
return prom;
|
|
10891
11460
|
});
|
|
10892
11461
|
}
|
|
@@ -10907,6 +11476,610 @@ var AccountFeatures;
|
|
|
10907
11476
|
AccountFeatures.GetCacheKey = GetCacheKey;
|
|
10908
11477
|
})(AccountFeatures || (AccountFeatures = {}));
|
|
10909
11478
|
|
|
11479
|
+
var AccountLimits;
|
|
11480
|
+
(function (AccountLimits$$1) {
|
|
11481
|
+
let ELimit;
|
|
11482
|
+
(function (ELimit) {
|
|
11483
|
+
ELimit["MaxProjectViewCount"] = "MaxProjectViewCount";
|
|
11484
|
+
ELimit["MaxStorageUseGigabytes"] = "MaxStorageUseGigabytes";
|
|
11485
|
+
ELimit["MaxEntitiesCount"] = "MaxEntitiesCount";
|
|
11486
|
+
ELimit["MaxFileImportSizeGigabytes"] = "MaxFileImportSizeGigabytes";
|
|
11487
|
+
ELimit["OperatorAccessAllowed"] = "OperatorAccessAllowed";
|
|
11488
|
+
ELimit["DenyPublicAccess"] = "DenyPublicAccess";
|
|
11489
|
+
ELimit["EnableSSOLogin"] = "EnableSSOLogin";
|
|
11490
|
+
ELimit["EnableSSOLoginAutoRedirect"] = "EnableSSOLoginAutoRedirect";
|
|
11491
|
+
})(ELimit = AccountLimits$$1.ELimit || (AccountLimits$$1.ELimit = {}));
|
|
11492
|
+
/**
|
|
11493
|
+
* Returns a dictionary of limits for the given account.
|
|
11494
|
+
* @param params
|
|
11495
|
+
* @returns
|
|
11496
|
+
*/
|
|
11497
|
+
function GetLimits(params) {
|
|
11498
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11499
|
+
let { accountId, api, req } = params;
|
|
11500
|
+
if (!api) {
|
|
11501
|
+
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
11502
|
+
}
|
|
11503
|
+
req = Api.PrepReqParams(req);
|
|
11504
|
+
const cacheData = api.GetCacheItem(GetLimitsCacheKey(accountId));
|
|
11505
|
+
if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.found) {
|
|
11506
|
+
return cacheData.data;
|
|
11507
|
+
}
|
|
11508
|
+
const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
11509
|
+
try {
|
|
11510
|
+
const data = yield api.GET(`account/${accountId}?WithLimits=true`);
|
|
11511
|
+
const limits = data.Limits ? data.Limits : {};
|
|
11512
|
+
res({
|
|
11513
|
+
limits: limits
|
|
11514
|
+
});
|
|
11515
|
+
}
|
|
11516
|
+
catch (e) {
|
|
11517
|
+
rej(e);
|
|
11518
|
+
}
|
|
11519
|
+
}));
|
|
11520
|
+
api.SetCacheItem({
|
|
11521
|
+
key: GetLimitsCacheKey(accountId),
|
|
11522
|
+
value: prom,
|
|
11523
|
+
req: req
|
|
11524
|
+
});
|
|
11525
|
+
return prom;
|
|
11526
|
+
});
|
|
11527
|
+
}
|
|
11528
|
+
AccountLimits$$1.GetLimits = GetLimits;
|
|
11529
|
+
/**
|
|
11530
|
+
* Returns a numeric limit for the given account.
|
|
11531
|
+
* @param params
|
|
11532
|
+
*/
|
|
11533
|
+
function GetNumericLimit(params) {
|
|
11534
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11535
|
+
const { key, api, req, onErrorValue, onEmptyValue, accountId } = params;
|
|
11536
|
+
try {
|
|
11537
|
+
const { limits } = yield GetLimits({
|
|
11538
|
+
accountId: accountId,
|
|
11539
|
+
api: api,
|
|
11540
|
+
req: req
|
|
11541
|
+
});
|
|
11542
|
+
const limit = limits[key];
|
|
11543
|
+
if (limit == null || limit.Numeric == null) {
|
|
11544
|
+
return onEmptyValue;
|
|
11545
|
+
}
|
|
11546
|
+
return Number(limit.Numeric);
|
|
11547
|
+
}
|
|
11548
|
+
catch (e) {
|
|
11549
|
+
return onErrorValue;
|
|
11550
|
+
}
|
|
11551
|
+
});
|
|
11552
|
+
}
|
|
11553
|
+
AccountLimits$$1.GetNumericLimit = GetNumericLimit;
|
|
11554
|
+
/**
|
|
11555
|
+
* Returns a boolean limit for the given account.
|
|
11556
|
+
* @param params
|
|
11557
|
+
*/
|
|
11558
|
+
function GetBooleanLimit(params) {
|
|
11559
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11560
|
+
const { key, api, req, onErrorValue, onEmptyValue, accountId } = params;
|
|
11561
|
+
try {
|
|
11562
|
+
const { limits } = yield GetLimits({
|
|
11563
|
+
accountId: accountId,
|
|
11564
|
+
api: api,
|
|
11565
|
+
req: req
|
|
11566
|
+
});
|
|
11567
|
+
const limit = limits[key];
|
|
11568
|
+
if (limit == null || limit.Boolean == null) {
|
|
11569
|
+
return onEmptyValue;
|
|
11570
|
+
}
|
|
11571
|
+
return Boolean(limit.Boolean);
|
|
11572
|
+
}
|
|
11573
|
+
catch (e) {
|
|
11574
|
+
return onErrorValue;
|
|
11575
|
+
}
|
|
11576
|
+
});
|
|
11577
|
+
}
|
|
11578
|
+
AccountLimits$$1.GetBooleanLimit = GetBooleanLimit;
|
|
11579
|
+
/**
|
|
11580
|
+
* Returns a string limit for the given account.
|
|
11581
|
+
* @param params
|
|
11582
|
+
*/
|
|
11583
|
+
function GetStringLimit(params) {
|
|
11584
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11585
|
+
const { key, api, req, onErrorValue, onEmptyValue, accountId } = params;
|
|
11586
|
+
try {
|
|
11587
|
+
const { limits } = yield GetLimits({
|
|
11588
|
+
accountId: accountId,
|
|
11589
|
+
api: api,
|
|
11590
|
+
req: req
|
|
11591
|
+
});
|
|
11592
|
+
const limit = limits[key];
|
|
11593
|
+
if (limit == null || limit.String == null) {
|
|
11594
|
+
return onEmptyValue;
|
|
11595
|
+
}
|
|
11596
|
+
return limit.String;
|
|
11597
|
+
}
|
|
11598
|
+
catch (e) {
|
|
11599
|
+
return onErrorValue;
|
|
11600
|
+
}
|
|
11601
|
+
});
|
|
11602
|
+
}
|
|
11603
|
+
AccountLimits$$1.GetStringLimit = GetStringLimit;
|
|
11604
|
+
/**
|
|
11605
|
+
* Functions for validating if a user can do things sit here.
|
|
11606
|
+
*/
|
|
11607
|
+
let Assert;
|
|
11608
|
+
(function (Assert) {
|
|
11609
|
+
/**
|
|
11610
|
+
* Returns if project view creation is allowed for the account.
|
|
11611
|
+
*/
|
|
11612
|
+
function GetCanCreateProjectView(params) {
|
|
11613
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11614
|
+
if (!params.getters) {
|
|
11615
|
+
params.getters = ENVIRONMENT.Api();
|
|
11616
|
+
}
|
|
11617
|
+
if (!params.accountId) {
|
|
11618
|
+
params.accountId = params.getters.GetAccountId();
|
|
11619
|
+
}
|
|
11620
|
+
let current = -1;
|
|
11621
|
+
let max = yield GetNumericLimit({
|
|
11622
|
+
accountId: params.accountId,
|
|
11623
|
+
key: ELimit.MaxProjectViewCount,
|
|
11624
|
+
onEmptyValue: 0,
|
|
11625
|
+
onErrorValue: null,
|
|
11626
|
+
api: params.getters.GetGuardianApi()
|
|
11627
|
+
});
|
|
11628
|
+
if (max != null) {
|
|
11629
|
+
// Should use proper statistic API as this will exclude project views the user cannot access.
|
|
11630
|
+
try {
|
|
11631
|
+
const { views } = yield ProjectView.GetList({
|
|
11632
|
+
api: params.getters.GetBruceApi({
|
|
11633
|
+
accountId: params.accountId
|
|
11634
|
+
})
|
|
11635
|
+
});
|
|
11636
|
+
current = views.length;
|
|
11637
|
+
}
|
|
11638
|
+
catch (e) {
|
|
11639
|
+
console.error(e);
|
|
11640
|
+
max = null;
|
|
11641
|
+
}
|
|
11642
|
+
}
|
|
11643
|
+
if (max == null) {
|
|
11644
|
+
return {
|
|
11645
|
+
allowed: false,
|
|
11646
|
+
errorText: "We apologize but Project View creation is currently unavailable."
|
|
11647
|
+
};
|
|
11648
|
+
}
|
|
11649
|
+
else if (max == -1) {
|
|
11650
|
+
return {
|
|
11651
|
+
allowed: true
|
|
11652
|
+
};
|
|
11653
|
+
}
|
|
11654
|
+
else if (current == -1) {
|
|
11655
|
+
return {
|
|
11656
|
+
allowed: false,
|
|
11657
|
+
errorText: "We apologize but Project View creation is currently unavailable."
|
|
11658
|
+
};
|
|
11659
|
+
}
|
|
11660
|
+
else if (current >= max) {
|
|
11661
|
+
return {
|
|
11662
|
+
allowed: false,
|
|
11663
|
+
errorText: `You have reached the maximum number of Project Views allowed for your account. Your limit is ${max} Project ${max == 1 ? "View" : "Views"} and you have ${current}.`
|
|
11664
|
+
};
|
|
11665
|
+
}
|
|
11666
|
+
return {
|
|
11667
|
+
allowed: true
|
|
11668
|
+
};
|
|
11669
|
+
});
|
|
11670
|
+
}
|
|
11671
|
+
Assert.GetCanCreateProjectView = GetCanCreateProjectView;
|
|
11672
|
+
/**
|
|
11673
|
+
* Returns the project view limit for an account.
|
|
11674
|
+
* If -1 is returned then it is unlimited.
|
|
11675
|
+
* @param params
|
|
11676
|
+
* @returns
|
|
11677
|
+
*/
|
|
11678
|
+
function GetProjectViewLimit(params) {
|
|
11679
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11680
|
+
if (!params.api) {
|
|
11681
|
+
params.api = ENVIRONMENT.Api().GetGuardianApi();
|
|
11682
|
+
}
|
|
11683
|
+
if (!params.accountId) {
|
|
11684
|
+
params.accountId = ENVIRONMENT.Api().GetAccountId();
|
|
11685
|
+
}
|
|
11686
|
+
const max = yield GetNumericLimit({
|
|
11687
|
+
accountId: params.accountId,
|
|
11688
|
+
key: ELimit.MaxProjectViewCount,
|
|
11689
|
+
onEmptyValue: 0,
|
|
11690
|
+
onErrorValue: null,
|
|
11691
|
+
api: params.api
|
|
11692
|
+
});
|
|
11693
|
+
// Our error so we'll just allow unlimited for the time being.
|
|
11694
|
+
if (max == null) {
|
|
11695
|
+
return -1;
|
|
11696
|
+
}
|
|
11697
|
+
return max;
|
|
11698
|
+
});
|
|
11699
|
+
}
|
|
11700
|
+
Assert.GetProjectViewLimit = GetProjectViewLimit;
|
|
11701
|
+
/**
|
|
11702
|
+
* Returns if file uploads are allowed for the account.
|
|
11703
|
+
*/
|
|
11704
|
+
function GetCanUploadFile(params) {
|
|
11705
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11706
|
+
if (!params.getters) {
|
|
11707
|
+
params.getters = ENVIRONMENT.Api();
|
|
11708
|
+
}
|
|
11709
|
+
if (!params.accountId) {
|
|
11710
|
+
params.accountId = params.getters.GetAccountId();
|
|
11711
|
+
}
|
|
11712
|
+
let current = -1;
|
|
11713
|
+
let max = yield GetNumericLimit({
|
|
11714
|
+
accountId: params.accountId,
|
|
11715
|
+
key: ELimit.MaxStorageUseGigabytes,
|
|
11716
|
+
onEmptyValue: 0,
|
|
11717
|
+
onErrorValue: null,
|
|
11718
|
+
api: params.getters.GetGuardianApi()
|
|
11719
|
+
});
|
|
11720
|
+
if (max != null && max > 0) {
|
|
11721
|
+
try {
|
|
11722
|
+
const api = params.getters.GetBruceApi({
|
|
11723
|
+
accountId: params.accountId
|
|
11724
|
+
});
|
|
11725
|
+
const stats = yield api.GET("account/summary-stats");
|
|
11726
|
+
if (stats === null || stats === void 0 ? void 0 : stats.ID) {
|
|
11727
|
+
const result = stats === null || stats === void 0 ? void 0 : stats.Result;
|
|
11728
|
+
try {
|
|
11729
|
+
const resJson = JSON.parse(result);
|
|
11730
|
+
const fileBytes = resJson.TotalStorageUseBytes;
|
|
11731
|
+
const fileGB = fileBytes != null && !isNaN(fileBytes) && fileBytes != -1 ? MathUtils.Round(fileBytes / 1024 / 1024 / 1024, 2) : null;
|
|
11732
|
+
// Still counting so we'll give unlimited for the time being.
|
|
11733
|
+
// This count can take ages so we won't make the user wait.
|
|
11734
|
+
if (fileGB == null || isNaN(fileGB)) {
|
|
11735
|
+
max = -1;
|
|
11736
|
+
}
|
|
11737
|
+
else {
|
|
11738
|
+
current = fileGB;
|
|
11739
|
+
}
|
|
11740
|
+
}
|
|
11741
|
+
// We won't count this as a fatal error because who knows how stable this is.
|
|
11742
|
+
catch (e) {
|
|
11743
|
+
console.error(e);
|
|
11744
|
+
}
|
|
11745
|
+
}
|
|
11746
|
+
// Unknown so we'll just give unlimited for the time being.
|
|
11747
|
+
else {
|
|
11748
|
+
max = -1;
|
|
11749
|
+
}
|
|
11750
|
+
}
|
|
11751
|
+
catch (e) {
|
|
11752
|
+
console.error(e);
|
|
11753
|
+
max = null;
|
|
11754
|
+
}
|
|
11755
|
+
}
|
|
11756
|
+
// Optional param for a file size to add to the current storage amount.
|
|
11757
|
+
// Eg: user is uploading a 3gb file, is that allowed right now?
|
|
11758
|
+
if (current != -1 && !isNaN(params.fileSize) && params.fileSize) {
|
|
11759
|
+
current += MathUtils.Round(params.fileSize / 1024 / 1024 / 1024, 3);
|
|
11760
|
+
}
|
|
11761
|
+
if (max == null) {
|
|
11762
|
+
return {
|
|
11763
|
+
allowed: false,
|
|
11764
|
+
errorText: "We apologize but file uploads are currently unavailable."
|
|
11765
|
+
};
|
|
11766
|
+
}
|
|
11767
|
+
else if (max == -1) {
|
|
11768
|
+
return {
|
|
11769
|
+
allowed: true
|
|
11770
|
+
};
|
|
11771
|
+
}
|
|
11772
|
+
else if (current == -1) {
|
|
11773
|
+
return {
|
|
11774
|
+
allowed: false,
|
|
11775
|
+
errorText: "We apologize but file uploads are currently unavailable."
|
|
11776
|
+
};
|
|
11777
|
+
}
|
|
11778
|
+
else if (current >= max) {
|
|
11779
|
+
return {
|
|
11780
|
+
allowed: false,
|
|
11781
|
+
errorText: `You have reached the maximum amount of storage allowed for your account. You are limited to ${max.toLocaleString()} ${max == 1 ? "GB" : "GBs"} of storage.`
|
|
11782
|
+
};
|
|
11783
|
+
}
|
|
11784
|
+
return {
|
|
11785
|
+
allowed: true
|
|
11786
|
+
};
|
|
11787
|
+
});
|
|
11788
|
+
}
|
|
11789
|
+
Assert.GetCanUploadFile = GetCanUploadFile;
|
|
11790
|
+
/**
|
|
11791
|
+
* Returns the file limit for an account.
|
|
11792
|
+
* If -1 is returned then it is unlimited.
|
|
11793
|
+
* @param params
|
|
11794
|
+
* @returns
|
|
11795
|
+
*/
|
|
11796
|
+
function GetFileGBLimit(params) {
|
|
11797
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11798
|
+
if (!params.api) {
|
|
11799
|
+
params.api = ENVIRONMENT.Api().GetGuardianApi();
|
|
11800
|
+
}
|
|
11801
|
+
if (!params.accountId) {
|
|
11802
|
+
params.accountId = ENVIRONMENT.Api().GetAccountId();
|
|
11803
|
+
}
|
|
11804
|
+
const max = yield GetNumericLimit({
|
|
11805
|
+
accountId: params.accountId,
|
|
11806
|
+
key: ELimit.MaxStorageUseGigabytes,
|
|
11807
|
+
onEmptyValue: 0,
|
|
11808
|
+
onErrorValue: null,
|
|
11809
|
+
api: params.api
|
|
11810
|
+
});
|
|
11811
|
+
// Our error so we'll just allow unlimited for the time being.
|
|
11812
|
+
if (max == null) {
|
|
11813
|
+
return -1;
|
|
11814
|
+
}
|
|
11815
|
+
return max;
|
|
11816
|
+
});
|
|
11817
|
+
}
|
|
11818
|
+
Assert.GetFileGBLimit = GetFileGBLimit;
|
|
11819
|
+
/**
|
|
11820
|
+
* Returns the maximum file import size for an account.
|
|
11821
|
+
* If -1 is returned then it is unlimited.
|
|
11822
|
+
* @param params
|
|
11823
|
+
* @returns
|
|
11824
|
+
*/
|
|
11825
|
+
function GetMaxImportSizeGB(params) {
|
|
11826
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11827
|
+
if (!params.api) {
|
|
11828
|
+
params.api = ENVIRONMENT.Api().GetGuardianApi();
|
|
11829
|
+
}
|
|
11830
|
+
if (!params.accountId) {
|
|
11831
|
+
params.accountId = ENVIRONMENT.Api().GetAccountId();
|
|
11832
|
+
}
|
|
11833
|
+
const max = yield GetNumericLimit({
|
|
11834
|
+
accountId: params.accountId,
|
|
11835
|
+
key: ELimit.MaxFileImportSizeGigabytes,
|
|
11836
|
+
onEmptyValue: 0,
|
|
11837
|
+
onErrorValue: null,
|
|
11838
|
+
api: params.api
|
|
11839
|
+
});
|
|
11840
|
+
// Our error so we'll just allow unlimited for the time being.
|
|
11841
|
+
if (max == null) {
|
|
11842
|
+
return -1;
|
|
11843
|
+
}
|
|
11844
|
+
return max;
|
|
11845
|
+
});
|
|
11846
|
+
}
|
|
11847
|
+
Assert.GetMaxImportSizeGB = GetMaxImportSizeGB;
|
|
11848
|
+
/**
|
|
11849
|
+
* Returns if entity creation is allowed for the account.
|
|
11850
|
+
*/
|
|
11851
|
+
function GetCanCreateEntity(params) {
|
|
11852
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11853
|
+
if (!params.getters) {
|
|
11854
|
+
params.getters = ENVIRONMENT.Api();
|
|
11855
|
+
}
|
|
11856
|
+
if (!params.accountId) {
|
|
11857
|
+
params.accountId = params.getters.GetAccountId();
|
|
11858
|
+
}
|
|
11859
|
+
let current = -1;
|
|
11860
|
+
let max = yield GetNumericLimit({
|
|
11861
|
+
accountId: params.accountId,
|
|
11862
|
+
key: ELimit.MaxEntitiesCount,
|
|
11863
|
+
onEmptyValue: 0,
|
|
11864
|
+
onErrorValue: null,
|
|
11865
|
+
api: params.getters.GetGuardianApi()
|
|
11866
|
+
});
|
|
11867
|
+
if (max != null && max > 0) {
|
|
11868
|
+
try {
|
|
11869
|
+
const api = params.getters.GetBruceApi({
|
|
11870
|
+
accountId: params.accountId
|
|
11871
|
+
});
|
|
11872
|
+
const stats = yield api.GET("account/summary-stats");
|
|
11873
|
+
if (stats === null || stats === void 0 ? void 0 : stats.ID) {
|
|
11874
|
+
const result = stats === null || stats === void 0 ? void 0 : stats.Result;
|
|
11875
|
+
try {
|
|
11876
|
+
const resJson = JSON.parse(result);
|
|
11877
|
+
const eCount = resJson.EntitiesCount;
|
|
11878
|
+
// Still counting so we'll give unlimited for the time being.
|
|
11879
|
+
// This count can take ages so we won't make the user wait.
|
|
11880
|
+
if (eCount == null || isNaN(eCount)) {
|
|
11881
|
+
max = -1;
|
|
11882
|
+
}
|
|
11883
|
+
else {
|
|
11884
|
+
current = eCount;
|
|
11885
|
+
}
|
|
11886
|
+
}
|
|
11887
|
+
// We won't count this as a fatal error because who knows how stable this is.
|
|
11888
|
+
catch (e) {
|
|
11889
|
+
console.error(e);
|
|
11890
|
+
}
|
|
11891
|
+
}
|
|
11892
|
+
// Unknown so we'll just give unlimited for the time being.
|
|
11893
|
+
else {
|
|
11894
|
+
max = -1;
|
|
11895
|
+
}
|
|
11896
|
+
}
|
|
11897
|
+
catch (e) {
|
|
11898
|
+
console.error(e);
|
|
11899
|
+
max = null;
|
|
11900
|
+
}
|
|
11901
|
+
}
|
|
11902
|
+
// Optional param for an entity count to add to the current entity amount.
|
|
11903
|
+
// Eg: user is creating 3 entities, is that allowed right now?
|
|
11904
|
+
if (current != -1 && !isNaN(params.count) && params.count) {
|
|
11905
|
+
current += params.count;
|
|
11906
|
+
// Remove one since we do an inclusive check later in the code.
|
|
11907
|
+
current -= 1;
|
|
11908
|
+
}
|
|
11909
|
+
if (max == null) {
|
|
11910
|
+
return {
|
|
11911
|
+
allowed: false,
|
|
11912
|
+
errorText: "We apologize but Entity creation is currently unavailable."
|
|
11913
|
+
};
|
|
11914
|
+
}
|
|
11915
|
+
else if (max == -1) {
|
|
11916
|
+
return {
|
|
11917
|
+
allowed: true
|
|
11918
|
+
};
|
|
11919
|
+
}
|
|
11920
|
+
else if (current == -1) {
|
|
11921
|
+
return {
|
|
11922
|
+
allowed: false,
|
|
11923
|
+
errorText: "We apologize but Entity creation is currently unavailable."
|
|
11924
|
+
};
|
|
11925
|
+
}
|
|
11926
|
+
else if (current >= max) {
|
|
11927
|
+
return {
|
|
11928
|
+
allowed: false,
|
|
11929
|
+
errorText: `You have reached the maximum number of Entities allowed for your account. You are limited to ${max.toLocaleString()} ${max == 1 ? "Entity" : "Entities"}.`
|
|
11930
|
+
};
|
|
11931
|
+
}
|
|
11932
|
+
return {
|
|
11933
|
+
allowed: true
|
|
11934
|
+
};
|
|
11935
|
+
});
|
|
11936
|
+
}
|
|
11937
|
+
Assert.GetCanCreateEntity = GetCanCreateEntity;
|
|
11938
|
+
/**
|
|
11939
|
+
* Returns the entity limit for an account.
|
|
11940
|
+
* If -1 is returned then it is unlimited.
|
|
11941
|
+
*/
|
|
11942
|
+
function GetEntityLimit(params) {
|
|
11943
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11944
|
+
if (!params.api) {
|
|
11945
|
+
params.api = ENVIRONMENT.Api().GetGuardianApi();
|
|
11946
|
+
}
|
|
11947
|
+
if (!params.accountId) {
|
|
11948
|
+
params.accountId = ENVIRONMENT.Api().GetAccountId();
|
|
11949
|
+
}
|
|
11950
|
+
const max = yield GetNumericLimit({
|
|
11951
|
+
accountId: params.accountId,
|
|
11952
|
+
key: ELimit.MaxEntitiesCount,
|
|
11953
|
+
onEmptyValue: 0,
|
|
11954
|
+
onErrorValue: null,
|
|
11955
|
+
api: params.api
|
|
11956
|
+
});
|
|
11957
|
+
// Our error so we'll just allow unlimited for the time being.
|
|
11958
|
+
if (max == null) {
|
|
11959
|
+
return -1;
|
|
11960
|
+
}
|
|
11961
|
+
return max;
|
|
11962
|
+
});
|
|
11963
|
+
}
|
|
11964
|
+
Assert.GetEntityLimit = GetEntityLimit;
|
|
11965
|
+
/**
|
|
11966
|
+
* Returns if Operator access is allowed for the account.
|
|
11967
|
+
* @param params
|
|
11968
|
+
* @returns
|
|
11969
|
+
*/
|
|
11970
|
+
function GetCanOpenOperator(params) {
|
|
11971
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11972
|
+
if (!params.api) {
|
|
11973
|
+
params.api = ENVIRONMENT.Api().GetGuardianApi();
|
|
11974
|
+
}
|
|
11975
|
+
if (!params.accountId) {
|
|
11976
|
+
params.accountId = ENVIRONMENT.Api().GetAccountId();
|
|
11977
|
+
}
|
|
11978
|
+
const allowed = yield GetBooleanLimit({
|
|
11979
|
+
accountId: params.accountId,
|
|
11980
|
+
key: ELimit.OperatorAccessAllowed,
|
|
11981
|
+
onEmptyValue: false,
|
|
11982
|
+
onErrorValue: null,
|
|
11983
|
+
api: params.api
|
|
11984
|
+
});
|
|
11985
|
+
if (allowed == null) {
|
|
11986
|
+
return {
|
|
11987
|
+
allowed: false,
|
|
11988
|
+
errorText: "We apologize but Operator access is currently unavailable."
|
|
11989
|
+
};
|
|
11990
|
+
}
|
|
11991
|
+
else if (allowed) {
|
|
11992
|
+
return {
|
|
11993
|
+
allowed: true
|
|
11994
|
+
};
|
|
11995
|
+
}
|
|
11996
|
+
else {
|
|
11997
|
+
return {
|
|
11998
|
+
allowed: false,
|
|
11999
|
+
errorText: "You do not have access to Operator."
|
|
12000
|
+
};
|
|
12001
|
+
}
|
|
12002
|
+
});
|
|
12003
|
+
}
|
|
12004
|
+
Assert.GetCanOpenOperator = GetCanOpenOperator;
|
|
12005
|
+
/**
|
|
12006
|
+
* Returns SSO login settings for the account.
|
|
12007
|
+
* @param params
|
|
12008
|
+
* @returns
|
|
12009
|
+
*/
|
|
12010
|
+
function GetSSOLoginSettings(params) {
|
|
12011
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
12012
|
+
if (!params.api) {
|
|
12013
|
+
params.api = ENVIRONMENT.Api().GetGuardianApi();
|
|
12014
|
+
}
|
|
12015
|
+
if (!params.accountId) {
|
|
12016
|
+
params.accountId = ENVIRONMENT.Api().GetAccountId();
|
|
12017
|
+
}
|
|
12018
|
+
const enabled = yield GetBooleanLimit({
|
|
12019
|
+
accountId: params.accountId,
|
|
12020
|
+
key: ELimit.EnableSSOLogin,
|
|
12021
|
+
onEmptyValue: false,
|
|
12022
|
+
onErrorValue: null,
|
|
12023
|
+
api: params.api
|
|
12024
|
+
});
|
|
12025
|
+
const autoRedirect = yield GetBooleanLimit({
|
|
12026
|
+
accountId: params.accountId,
|
|
12027
|
+
key: ELimit.EnableSSOLoginAutoRedirect,
|
|
12028
|
+
onEmptyValue: false,
|
|
12029
|
+
onErrorValue: null,
|
|
12030
|
+
api: params.api
|
|
12031
|
+
});
|
|
12032
|
+
if (enabled == null || autoRedirect == null) {
|
|
12033
|
+
return {
|
|
12034
|
+
enabled: false,
|
|
12035
|
+
autoRedirect: false,
|
|
12036
|
+
errorText: "We apologize but SSO login is currently unavailable."
|
|
12037
|
+
};
|
|
12038
|
+
}
|
|
12039
|
+
return {
|
|
12040
|
+
enabled: enabled,
|
|
12041
|
+
autoRedirect: autoRedirect
|
|
12042
|
+
};
|
|
12043
|
+
});
|
|
12044
|
+
}
|
|
12045
|
+
Assert.GetSSOLoginSettings = GetSSOLoginSettings;
|
|
12046
|
+
/**
|
|
12047
|
+
* Returns if public access is denied to this account.
|
|
12048
|
+
* @param params
|
|
12049
|
+
* @returns
|
|
12050
|
+
*/
|
|
12051
|
+
function GetDenyPublicAccess(params) {
|
|
12052
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
12053
|
+
if (!params.api) {
|
|
12054
|
+
params.api = ENVIRONMENT.Api().GetGuardianApi();
|
|
12055
|
+
}
|
|
12056
|
+
if (!params.accountId) {
|
|
12057
|
+
params.accountId = ENVIRONMENT.Api().GetAccountId();
|
|
12058
|
+
}
|
|
12059
|
+
const enabled = yield GetBooleanLimit({
|
|
12060
|
+
accountId: params.accountId,
|
|
12061
|
+
key: ELimit.DenyPublicAccess,
|
|
12062
|
+
// If empty then we'll assume we are not denying public access.
|
|
12063
|
+
onEmptyValue: false,
|
|
12064
|
+
// If we crash we are denying public access.
|
|
12065
|
+
onErrorValue: true,
|
|
12066
|
+
api: params.api
|
|
12067
|
+
});
|
|
12068
|
+
return enabled;
|
|
12069
|
+
});
|
|
12070
|
+
}
|
|
12071
|
+
Assert.GetDenyPublicAccess = GetDenyPublicAccess;
|
|
12072
|
+
})(Assert = AccountLimits$$1.Assert || (AccountLimits$$1.Assert = {}));
|
|
12073
|
+
/**
|
|
12074
|
+
* Cache key for requesting account limits for a specific account.
|
|
12075
|
+
* @param accountId
|
|
12076
|
+
*/
|
|
12077
|
+
function GetLimitsCacheKey(accountId) {
|
|
12078
|
+
return Api.ECacheKey.AccountLimits + Api.ECacheKey.Id + accountId;
|
|
12079
|
+
}
|
|
12080
|
+
AccountLimits$$1.GetLimitsCacheKey = GetLimitsCacheKey;
|
|
12081
|
+
})(AccountLimits || (AccountLimits = {}));
|
|
12082
|
+
|
|
10910
12083
|
var EncryptUtils;
|
|
10911
12084
|
(function (EncryptUtils) {
|
|
10912
12085
|
// https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript
|
|
@@ -11943,7 +13116,7 @@ var DataSource;
|
|
|
11943
13116
|
})(DataSource || (DataSource = {}));
|
|
11944
13117
|
|
|
11945
13118
|
// This is updated with the package.json version on build.
|
|
11946
|
-
const VERSION = "4.1.
|
|
13119
|
+
const VERSION = "4.1.7";
|
|
11947
13120
|
|
|
11948
|
-
export { VERSION, AnnDocument, CustomForm, AbstractApi, Api, BruceApi, GlobalApi, GuardianApi, ApiGetters, Calculator, Bounds, BruceEvent, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, Geometry, UTC, BruceVariable, LRUCache, EntityAttachmentType, EntityAttachment, EntityComment, EntityLink, EntityLod, EntityLodCategory, EntityRelationType, EntityRelation, EntitySource, EntityTag, EntityType, Entity, EntityCoords, EntityTypeVisualSettings, EntityAttribute, EntityHistoricData, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, ProjectViewLegacyTile, ProjectViewTile, ProjectViewLegacy, ProjectViewLegacyBookmark, PendingAction, MessageBroker, HostingLocation, Style, Tileset, Permission, Session, UserGroup, User, Account, AccountInvite, AccountFeatures, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, DataLab, ImportCad, ImportCsv, ImportJson, ImportKml, ImportedFile, Markup, Uploader, Plugin, ENVIRONMENT, DataSource };
|
|
13121
|
+
export { VERSION, AnnDocument, CustomForm, AbstractApi, Api, BruceApi, GlobalApi, GuardianApi, ApiGetters, Calculator, Bounds, BruceEvent, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, Geometry, UTC, BruceVariable, LRUCache, EntityAttachmentType, EntityAttachment, EntityComment, EntityLink, EntityLod, EntityLodCategory, EntityRelationType, EntityRelation, EntitySource, EntityTag, EntityType, Entity, EntityCoords, EntityTypeVisualSettings, EntityAttribute, EntityHistoricData, Comment, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, ProjectViewLegacyTile, ProjectViewTile, ProjectViewLegacy, ProjectViewLegacyBookmark, PendingAction, MessageBroker, HostingLocation, Style, Tileset, Permission, Session, UserGroup, User, Account, AccountInvite, AccountFeatures, AccountLimits, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, DataLab, ImportCad, ImportCsv, ImportJson, ImportKml, ImportedFile, Markup, Uploader, Plugin, ENVIRONMENT, DataSource };
|
|
11949
13122
|
//# sourceMappingURL=bruce-models.es5.js.map
|