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.umd.js
CHANGED
|
@@ -84,6 +84,7 @@
|
|
|
84
84
|
ECacheKey["EntityHistoricData"] = "entityhistoricdata";
|
|
85
85
|
ECacheKey["EntityHistoricDataRec"] = "entityhistoricdatarec";
|
|
86
86
|
ECacheKey["EntityHistoricDataStats"] = "entityhistoricdatastats";
|
|
87
|
+
ECacheKey["AccountLimits"] = "accountlimits";
|
|
87
88
|
})(ECacheKey = Api.ECacheKey || (Api.ECacheKey = {}));
|
|
88
89
|
// 1 minute.
|
|
89
90
|
Api.DEFAULT_CACHE_DURATION = 60 * 1000;
|
|
@@ -1994,9 +1995,6 @@
|
|
|
1994
1995
|
if (ENVIRONMENT.IS_SELF_MANAGED) {
|
|
1995
1996
|
throw ("Self managed mode ON. You are getting this error because you didn't pass an Api instance to a function.");
|
|
1996
1997
|
}
|
|
1997
|
-
if (!ENVIRONMENT.PARAMS.accountId) {
|
|
1998
|
-
console.warn("No accountId set. This is required for the getters to work properly.");
|
|
1999
|
-
}
|
|
2000
1998
|
if (!_getters) {
|
|
2001
1999
|
_getters = new ApiGetters({
|
|
2002
2000
|
accountId: ENVIRONMENT.PARAMS.accountId,
|
|
@@ -2941,7 +2939,7 @@
|
|
|
2941
2939
|
* @returns
|
|
2942
2940
|
*/
|
|
2943
2941
|
function Parse(str) {
|
|
2944
|
-
if (!str) {
|
|
2942
|
+
if (!(str === null || str === void 0 ? void 0 : str.length)) {
|
|
2945
2943
|
return [];
|
|
2946
2944
|
}
|
|
2947
2945
|
const broken = str.split("\"/\"");
|
|
@@ -2971,6 +2969,9 @@
|
|
|
2971
2969
|
* @returns
|
|
2972
2970
|
*/
|
|
2973
2971
|
function Wrap(path) {
|
|
2972
|
+
if (!(path === null || path === void 0 ? void 0 : path.length)) {
|
|
2973
|
+
return "";
|
|
2974
|
+
}
|
|
2974
2975
|
let tmp = "\"";
|
|
2975
2976
|
for (let i = 0; i < path.length; i++) {
|
|
2976
2977
|
let section = path[i];
|
|
@@ -2989,6 +2990,9 @@
|
|
|
2989
2990
|
* @returns
|
|
2990
2991
|
*/
|
|
2991
2992
|
function ParseLegacy(str) {
|
|
2993
|
+
if (!(str === null || str === void 0 ? void 0 : str.length)) {
|
|
2994
|
+
return [];
|
|
2995
|
+
}
|
|
2992
2996
|
const broken = str.split(".");
|
|
2993
2997
|
for (let i = 0; i < broken.length; i++) {
|
|
2994
2998
|
let piece = broken[0];
|
|
@@ -4860,22 +4864,123 @@
|
|
|
4860
4864
|
EMonth[EMonth["November"] = 11] = "November";
|
|
4861
4865
|
EMonth[EMonth["December"] = 12] = "December";
|
|
4862
4866
|
})(EMonth = UTC.EMonth || (UTC.EMonth = {}));
|
|
4867
|
+
/**
|
|
4868
|
+
* Returns an ISO 8601 string representation of the provided date.
|
|
4869
|
+
* @param utc
|
|
4870
|
+
*/
|
|
4871
|
+
function ToString(utc) {
|
|
4872
|
+
return ToDate(utc).toISOString();
|
|
4873
|
+
}
|
|
4874
|
+
UTC.ToString = ToString;
|
|
4863
4875
|
function ToDate(utc) {
|
|
4864
|
-
return new Date(utc.y, utc.m - 1, utc.d, utc.hh, utc.mm, utc.ss, 0);
|
|
4876
|
+
return new Date(Date.UTC(utc.y, utc.m - 1, utc.d, utc.hh, utc.mm, utc.ss, 0));
|
|
4865
4877
|
}
|
|
4866
4878
|
UTC.ToDate = ToDate;
|
|
4867
|
-
function FromDate(
|
|
4879
|
+
function FromDate(utc) {
|
|
4868
4880
|
return {
|
|
4869
|
-
y:
|
|
4870
|
-
m:
|
|
4871
|
-
d:
|
|
4872
|
-
hh:
|
|
4873
|
-
mm:
|
|
4874
|
-
ss:
|
|
4881
|
+
y: utc.getUTCFullYear(),
|
|
4882
|
+
m: utc.getUTCMonth() + 1,
|
|
4883
|
+
d: utc.getUTCDate(),
|
|
4884
|
+
hh: utc.getUTCHours(),
|
|
4885
|
+
mm: utc.getUTCMinutes(),
|
|
4886
|
+
ss: utc.getUTCSeconds()
|
|
4875
4887
|
};
|
|
4876
4888
|
}
|
|
4877
4889
|
UTC.FromDate = FromDate;
|
|
4890
|
+
/**
|
|
4891
|
+
* Returns how many seconds have passed between two dates.
|
|
4892
|
+
* If the second date is not provided, it will be the current date.
|
|
4893
|
+
* @param from
|
|
4894
|
+
* @param to
|
|
4895
|
+
* @returns
|
|
4896
|
+
*/
|
|
4897
|
+
function GetPassedSeconds(from, to) {
|
|
4898
|
+
if (!to) {
|
|
4899
|
+
to = FromDate(new Date());
|
|
4900
|
+
}
|
|
4901
|
+
const fromTime = ToDate(from).getTime();
|
|
4902
|
+
const toTime = ToDate(to).getTime();
|
|
4903
|
+
return Math.floor((toTime - fromTime) / 1000);
|
|
4904
|
+
}
|
|
4905
|
+
UTC.GetPassedSeconds = GetPassedSeconds;
|
|
4906
|
+
/**
|
|
4907
|
+
* Returns a human-readable string that describes how much time has passed since the provided date.
|
|
4908
|
+
* @param utc
|
|
4909
|
+
*/
|
|
4910
|
+
function GetPassedTime(utc) {
|
|
4911
|
+
const passedSeconds = GetPassedSeconds(utc);
|
|
4912
|
+
if (passedSeconds < 60) {
|
|
4913
|
+
return `${passedSeconds} second${passedSeconds > 1 ? "s" : ""} ago`;
|
|
4914
|
+
}
|
|
4915
|
+
const passedMinutes = Math.floor(passedSeconds / 60);
|
|
4916
|
+
if (passedMinutes < 60) {
|
|
4917
|
+
return `${passedMinutes} minute${passedMinutes > 1 ? "s" : ""} ago`;
|
|
4918
|
+
}
|
|
4919
|
+
const passedHours = Math.floor(passedMinutes / 60);
|
|
4920
|
+
if (passedHours < 24) {
|
|
4921
|
+
return `${passedHours} hour${passedHours > 1 ? "s" : ""} ago`;
|
|
4922
|
+
}
|
|
4923
|
+
const passedDays = Math.floor(passedHours / 24);
|
|
4924
|
+
if (passedDays < 30) {
|
|
4925
|
+
return `${passedDays} day${passedDays > 1 ? "s" : ""} ago`;
|
|
4926
|
+
}
|
|
4927
|
+
const passedMonths = Math.floor(passedDays / 30);
|
|
4928
|
+
if (passedMonths < 12) {
|
|
4929
|
+
return `${passedMonths} month${passedMonths > 1 ? "s" : ""} ago`;
|
|
4930
|
+
}
|
|
4931
|
+
const passedYears = Math.floor(passedMonths / 12);
|
|
4932
|
+
return `${passedYears} year${passedYears > 1 ? "s" : ""} ago`;
|
|
4933
|
+
}
|
|
4934
|
+
UTC.GetPassedTime = GetPassedTime;
|
|
4935
|
+
/**
|
|
4936
|
+
* Returns a human-readable string that describes the provided date.
|
|
4937
|
+
* If a timezone is not provided then it will use the locale timezone.
|
|
4938
|
+
* @param utc
|
|
4939
|
+
* @param timezone
|
|
4940
|
+
*/
|
|
4941
|
+
function GetDateTime(utc, timezone) {
|
|
4942
|
+
const date = ToDate(utc);
|
|
4943
|
+
// Possibly could just pass the timezone and it might get ignored if missing.
|
|
4944
|
+
if (timezone) {
|
|
4945
|
+
return date.toLocaleString("en-US", {
|
|
4946
|
+
timeZone: timezone,
|
|
4947
|
+
hour12: true,
|
|
4948
|
+
hour: "numeric",
|
|
4949
|
+
minute: "numeric",
|
|
4950
|
+
year: "2-digit",
|
|
4951
|
+
month: "2-digit",
|
|
4952
|
+
day: "2-digit"
|
|
4953
|
+
}) + " " + getTimezoneName(timezone);
|
|
4954
|
+
}
|
|
4955
|
+
return date.toLocaleString(undefined, {
|
|
4956
|
+
hour12: true,
|
|
4957
|
+
hour: "numeric",
|
|
4958
|
+
minute: "numeric",
|
|
4959
|
+
year: "2-digit",
|
|
4960
|
+
month: "2-digit",
|
|
4961
|
+
day: "2-digit"
|
|
4962
|
+
});
|
|
4963
|
+
}
|
|
4964
|
+
UTC.GetDateTime = GetDateTime;
|
|
4878
4965
|
})(exports.UTC || (exports.UTC = {}));
|
|
4966
|
+
// Found here https://stackoverflow.com/questions/9772955/how-can-i-get-the-timezone-name-in-javascript
|
|
4967
|
+
// Formats a given timezone into a human readable format.
|
|
4968
|
+
function getTimezoneName(timezone) {
|
|
4969
|
+
const today = new Date();
|
|
4970
|
+
const short = today.toLocaleDateString(undefined, { timeZone: timezone });
|
|
4971
|
+
const full = today.toLocaleDateString(undefined, { timeZoneName: "long", timeZone: timezone });
|
|
4972
|
+
// Trying to remove date from the string in a locale-agnostic way
|
|
4973
|
+
const shortIndex = full.indexOf(short);
|
|
4974
|
+
if (shortIndex >= 0) {
|
|
4975
|
+
const trimmed = full.substring(0, shortIndex) + full.substring(shortIndex + short.length);
|
|
4976
|
+
// by this time `trimmed` should be the timezone's name with some punctuation -
|
|
4977
|
+
// trim it from both sides
|
|
4978
|
+
return trimmed.replace(/^[\s,.\-:;]+|[\s,.\-:;]+$/g, "");
|
|
4979
|
+
}
|
|
4980
|
+
// in some magic case when short representation of date is not present in the long one,
|
|
4981
|
+
// just return the long one as a fallback, since it should contain the timezone's name
|
|
4982
|
+
return full;
|
|
4983
|
+
}
|
|
4879
4984
|
|
|
4880
4985
|
/**
|
|
4881
4986
|
* A simple LRU cache implementation.
|
|
@@ -6894,7 +6999,7 @@
|
|
|
6894
6999
|
* @param path
|
|
6895
7000
|
*/
|
|
6896
7001
|
function RemoveAttribute(items, path) {
|
|
6897
|
-
if (!items || !path ||
|
|
7002
|
+
if (!items || !(path === null || path === void 0 ? void 0 : path.length)) {
|
|
6898
7003
|
return;
|
|
6899
7004
|
}
|
|
6900
7005
|
const key = path[0];
|
|
@@ -6923,6 +7028,9 @@
|
|
|
6923
7028
|
* @param attribute
|
|
6924
7029
|
*/
|
|
6925
7030
|
function AddAttribute(items, path, attribute) {
|
|
7031
|
+
if (!items || !(path === null || path === void 0 ? void 0 : path.length)) {
|
|
7032
|
+
return;
|
|
7033
|
+
}
|
|
6926
7034
|
const key = path[0];
|
|
6927
7035
|
if (path.length === 1) {
|
|
6928
7036
|
// If we're at the last key in the path, add the attribute to the items array.
|
|
@@ -6951,150 +7059,87 @@
|
|
|
6951
7059
|
EntityAttribute.AddAttribute = AddAttribute;
|
|
6952
7060
|
})(exports.EntityAttribute || (exports.EntityAttribute = {}));
|
|
6953
7061
|
|
|
6954
|
-
(function (
|
|
6955
|
-
Uploader.MIN_LARGE_FILE_SIZE = 100000000; // 100MB.
|
|
7062
|
+
(function (Style) {
|
|
6956
7063
|
/**
|
|
6957
|
-
*
|
|
7064
|
+
* Types of styles available.
|
|
7065
|
+
* The type will dictate what settings are available.
|
|
7066
|
+
*/
|
|
7067
|
+
let EType;
|
|
7068
|
+
(function (EType) {
|
|
7069
|
+
EType["Entity"] = "ENTITY";
|
|
7070
|
+
EType["EntityRelationship"] = "ENTITY_RELATIONSHIP";
|
|
7071
|
+
})(EType = Style.EType || (Style.EType = {}));
|
|
7072
|
+
/**
|
|
7073
|
+
* Available types of points.
|
|
7074
|
+
* Default is POINT.
|
|
7075
|
+
*/
|
|
7076
|
+
let EPointType;
|
|
7077
|
+
(function (EPointType) {
|
|
7078
|
+
// Render a sphere with a fixed pixel size.
|
|
7079
|
+
EPointType["Point"] = "POINT";
|
|
7080
|
+
// Render an icon.
|
|
7081
|
+
EPointType["Icon"] = "ICON";
|
|
7082
|
+
// Render a cylinder with a fixed meter size.
|
|
7083
|
+
EPointType["Cylinder"] = "CYLINDER";
|
|
7084
|
+
})(EPointType = Style.EPointType || (Style.EPointType = {}));
|
|
7085
|
+
/**
|
|
7086
|
+
* Returns a list of styles.
|
|
6958
7087
|
* @param params
|
|
6959
7088
|
* @returns
|
|
6960
7089
|
*/
|
|
6961
|
-
function
|
|
7090
|
+
function GetList(params) {
|
|
6962
7091
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6963
|
-
let {
|
|
7092
|
+
let { api, req: reqParams } = params;
|
|
6964
7093
|
if (!api) {
|
|
6965
7094
|
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
6966
7095
|
}
|
|
6967
|
-
const
|
|
6968
|
-
|
|
6969
|
-
|
|
6970
|
-
let filePartsCount = fileSize / FILE_PORTION_SIZE;
|
|
6971
|
-
let t = Math.trunc(filePartsCount);
|
|
6972
|
-
filePartsCount = filePartsCount > t ? t + 1 : t;
|
|
6973
|
-
let filePartIndex = 1;
|
|
6974
|
-
let uploadToken = exports.ObjectUtils.UId();
|
|
6975
|
-
let data;
|
|
6976
|
-
while (fileOffset < fileSize) {
|
|
6977
|
-
let partSize = Math.min(FILE_PORTION_SIZE, fileSize - fileOffset);
|
|
6978
|
-
let retryCount = 5;
|
|
6979
|
-
let retryWait = 1000;
|
|
6980
|
-
while (retryCount > 0) {
|
|
6981
|
-
try {
|
|
6982
|
-
const blob = file.slice(fileOffset, fileOffset + partSize);
|
|
6983
|
-
const partialFile = new File([blob], file.name, { type: file.type });
|
|
6984
|
-
const formData = new FormData();
|
|
6985
|
-
formData.append("originalFileName", file.name);
|
|
6986
|
-
formData.append("token", uploadToken);
|
|
6987
|
-
formData.append("count", "" + filePartsCount);
|
|
6988
|
-
formData.append("part", "" + filePartIndex);
|
|
6989
|
-
formData.append("file", partialFile);
|
|
6990
|
-
const reqParams = exports.Api.PrepReqParams(req);
|
|
6991
|
-
reqParams.formData = formData;
|
|
6992
|
-
reqParams.onProgress = (progress) => {
|
|
6993
|
-
const sofar = fileOffset + progress.loaded;
|
|
6994
|
-
const percent = Math.round((sofar / file.size) * 100);
|
|
6995
|
-
onProgress === null || onProgress === void 0 ? void 0 : onProgress({
|
|
6996
|
-
percent: percent,
|
|
6997
|
-
uploaded: false
|
|
6998
|
-
});
|
|
6999
|
-
};
|
|
7000
|
-
data = yield api.UPLOAD(url, partialFile, reqParams);
|
|
7001
|
-
retryCount = 0;
|
|
7002
|
-
}
|
|
7003
|
-
catch (up) {
|
|
7004
|
-
retryCount -= 1;
|
|
7005
|
-
if (retryCount <= 0) {
|
|
7006
|
-
throw up;
|
|
7007
|
-
}
|
|
7008
|
-
yield new Promise((res) => setTimeout(res, retryWait));
|
|
7009
|
-
retryWait = retryWait * 2;
|
|
7010
|
-
}
|
|
7011
|
-
}
|
|
7012
|
-
fileOffset += partSize;
|
|
7013
|
-
filePartIndex++;
|
|
7096
|
+
const cache = yield api.GetCacheItem(GetListCacheKey(), reqParams);
|
|
7097
|
+
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
7098
|
+
return cache.data;
|
|
7014
7099
|
}
|
|
7015
|
-
|
|
7016
|
-
|
|
7017
|
-
|
|
7100
|
+
const res = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
7101
|
+
try {
|
|
7102
|
+
const data = yield api.GET("ui.entityDisplaySettings", exports.Api.PrepReqParams(reqParams));
|
|
7103
|
+
res({
|
|
7104
|
+
styles: data.Items
|
|
7105
|
+
});
|
|
7106
|
+
}
|
|
7107
|
+
catch (e) {
|
|
7108
|
+
rej(e);
|
|
7109
|
+
}
|
|
7110
|
+
}));
|
|
7111
|
+
yield api.SetCacheItem({
|
|
7112
|
+
key: GetListCacheKey(),
|
|
7113
|
+
value: res,
|
|
7114
|
+
req: reqParams
|
|
7018
7115
|
});
|
|
7019
|
-
return
|
|
7116
|
+
return res;
|
|
7020
7117
|
});
|
|
7021
7118
|
}
|
|
7022
|
-
|
|
7023
|
-
})(exports.Uploader || (exports.Uploader = {}));
|
|
7024
|
-
|
|
7025
|
-
(function (ClientFile) {
|
|
7026
|
-
let EPurpose;
|
|
7027
|
-
(function (EPurpose) {
|
|
7028
|
-
// Use this purpose for uploading bookmark thumbnail images.
|
|
7029
|
-
// This will allow lower level privileges to upload (small) bookmark thumbnails.
|
|
7030
|
-
EPurpose["BookmarkThumbnail"] = "Bookmark Thumbnail";
|
|
7031
|
-
})(EPurpose = ClientFile.EPurpose || (ClientFile.EPurpose = {}));
|
|
7032
|
-
/**
|
|
7033
|
-
* Returns the URL for a client file.
|
|
7034
|
-
* @param params
|
|
7035
|
-
* @returns
|
|
7036
|
-
*/
|
|
7037
|
-
function GetUrl(params) {
|
|
7038
|
-
let { api, fileId, viaCdn } = params;
|
|
7039
|
-
if (!api) {
|
|
7040
|
-
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
7041
|
-
}
|
|
7042
|
-
const urlSuffix = `file/${fileId}`;
|
|
7043
|
-
const cdnUrl = viaCdn ? api.ConstructCdnUrl(urlSuffix) : null;
|
|
7044
|
-
if (cdnUrl) {
|
|
7045
|
-
return cdnUrl;
|
|
7046
|
-
}
|
|
7047
|
-
let url = `${api.GetBaseUrl()}${urlSuffix}`;
|
|
7048
|
-
// Invalidating cache manually because we have a wave of invalid headers now cached across devices.
|
|
7049
|
-
url = exports.UrlUtils.AddQueryParam(url, "cc", "1");
|
|
7050
|
-
return url;
|
|
7051
|
-
}
|
|
7052
|
-
ClientFile.GetUrl = GetUrl;
|
|
7053
|
-
/**
|
|
7054
|
-
* Returns the URL for a client file with the extension.
|
|
7055
|
-
* @param params
|
|
7056
|
-
* @returns
|
|
7057
|
-
*/
|
|
7058
|
-
function GetUrlWithExt(params) {
|
|
7059
|
-
let { api, file, viaCdn } = params;
|
|
7060
|
-
if (!api) {
|
|
7061
|
-
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
7062
|
-
}
|
|
7063
|
-
const urlSuffix = file.FileExt ? `file/${file.ID}${file.FileExt}` : `file/${file.ID}`;
|
|
7064
|
-
const cdnUrl = viaCdn ? api.ConstructCdnUrl(urlSuffix) : null;
|
|
7065
|
-
if (cdnUrl) {
|
|
7066
|
-
return cdnUrl;
|
|
7067
|
-
}
|
|
7068
|
-
let url = `${api.GetBaseUrl()}${urlSuffix}`;
|
|
7069
|
-
// Invalidating cache manually because we have a wave of invalid headers now cached across devices.
|
|
7070
|
-
url = exports.UrlUtils.AddQueryParam(url, "cc", "1");
|
|
7071
|
-
return url;
|
|
7072
|
-
}
|
|
7073
|
-
ClientFile.GetUrlWithExt = GetUrlWithExt;
|
|
7119
|
+
Style.GetList = GetList;
|
|
7074
7120
|
/**
|
|
7075
|
-
* Returns a
|
|
7121
|
+
* Returns a style.
|
|
7076
7122
|
* @param params
|
|
7077
7123
|
* @returns
|
|
7078
7124
|
*/
|
|
7079
7125
|
function Get(params) {
|
|
7080
7126
|
return __awaiter(this, void 0, void 0, function* () {
|
|
7081
|
-
let { api,
|
|
7127
|
+
let { api, styleId: id, req: reqParams } = params;
|
|
7128
|
+
if (!id) {
|
|
7129
|
+
throw ("Style ID is required.");
|
|
7130
|
+
}
|
|
7082
7131
|
if (!api) {
|
|
7083
7132
|
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
7084
7133
|
}
|
|
7085
|
-
|
|
7086
|
-
throw ("File ID is required.");
|
|
7087
|
-
}
|
|
7088
|
-
const key = GetCacheKey(fileId);
|
|
7089
|
-
const cache = yield api.GetCacheItem(key, reqParams);
|
|
7134
|
+
const cache = yield api.GetCacheItem(GetCacheKey(id), reqParams);
|
|
7090
7135
|
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
7091
7136
|
return cache.data;
|
|
7092
7137
|
}
|
|
7093
7138
|
const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
7094
7139
|
try {
|
|
7095
|
-
const data = yield api.GET(`
|
|
7140
|
+
const data = yield api.GET(`ui.entityDisplaySetting/${id}`, exports.Api.PrepReqParams(reqParams));
|
|
7096
7141
|
res({
|
|
7097
|
-
|
|
7142
|
+
style: data
|
|
7098
7143
|
});
|
|
7099
7144
|
}
|
|
7100
7145
|
catch (e) {
|
|
@@ -7102,64 +7147,750 @@
|
|
|
7102
7147
|
}
|
|
7103
7148
|
}));
|
|
7104
7149
|
yield api.SetCacheItem({
|
|
7105
|
-
key,
|
|
7150
|
+
key: GetCacheKey(id),
|
|
7106
7151
|
value: prom,
|
|
7107
7152
|
req: reqParams
|
|
7108
7153
|
});
|
|
7109
7154
|
return prom;
|
|
7110
7155
|
});
|
|
7111
7156
|
}
|
|
7112
|
-
|
|
7157
|
+
Style.Get = Get;
|
|
7113
7158
|
/**
|
|
7114
|
-
*
|
|
7159
|
+
* Creates or updates a style.
|
|
7115
7160
|
* @param params
|
|
7161
|
+
* @returns
|
|
7116
7162
|
*/
|
|
7117
|
-
function
|
|
7163
|
+
function Update(params) {
|
|
7118
7164
|
return __awaiter(this, void 0, void 0, function* () {
|
|
7119
|
-
let { api,
|
|
7120
|
-
if (!
|
|
7121
|
-
|
|
7165
|
+
let { api, style: data, req: reqParams } = params;
|
|
7166
|
+
if (!(data === null || data === void 0 ? void 0 : data.Name)) {
|
|
7167
|
+
throw ("Style name is required.");
|
|
7122
7168
|
}
|
|
7123
7169
|
if (!api) {
|
|
7124
7170
|
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
7125
7171
|
}
|
|
7126
|
-
|
|
7127
|
-
|
|
7128
|
-
};
|
|
7129
|
-
yield api.POST("deleteFiles", data, exports.Api.PrepReqParams(reqParams));
|
|
7130
|
-
for (let i = 0; i < fileIds.length; i++) {
|
|
7131
|
-
const key = GetCacheKey(fileIds[i]);
|
|
7132
|
-
api.Cache.Remove(key);
|
|
7172
|
+
if (!data.ID) {
|
|
7173
|
+
data.ID = 0;
|
|
7133
7174
|
}
|
|
7175
|
+
const res = yield api.POST(`ui.entityDisplaySetting/${data.ID}`, data, exports.Api.PrepReqParams(reqParams));
|
|
7176
|
+
api.Cache.Remove(GetCacheKey(data.ID));
|
|
7177
|
+
api.Cache.Remove(GetListCacheKey());
|
|
7178
|
+
return {
|
|
7179
|
+
style: res
|
|
7180
|
+
};
|
|
7134
7181
|
});
|
|
7135
7182
|
}
|
|
7136
|
-
|
|
7183
|
+
Style.Update = Update;
|
|
7137
7184
|
/**
|
|
7138
|
-
*
|
|
7185
|
+
* Deletes a style.
|
|
7139
7186
|
* @param params
|
|
7140
|
-
* @returns
|
|
7141
7187
|
*/
|
|
7142
|
-
function
|
|
7188
|
+
function Delete(params) {
|
|
7143
7189
|
return __awaiter(this, void 0, void 0, function* () {
|
|
7144
|
-
let { api,
|
|
7190
|
+
let { api, styleId: id, req: reqParams } = params;
|
|
7145
7191
|
if (!api) {
|
|
7146
7192
|
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
7147
7193
|
}
|
|
7148
|
-
if (!
|
|
7149
|
-
throw ("
|
|
7150
|
-
}
|
|
7151
|
-
const size = file === null || file === void 0 ? void 0 : file.size;
|
|
7152
|
-
if (!size) {
|
|
7153
|
-
throw ("You cannot upload a 0byte sized file.");
|
|
7194
|
+
if (!id) {
|
|
7195
|
+
throw ("Style ID is required.");
|
|
7154
7196
|
}
|
|
7155
|
-
|
|
7156
|
-
|
|
7157
|
-
|
|
7158
|
-
|
|
7159
|
-
|
|
7160
|
-
|
|
7161
|
-
|
|
7162
|
-
|
|
7197
|
+
yield api.DELETE(`ui.entityDisplaySetting/${id}`, exports.Api.PrepReqParams(reqParams));
|
|
7198
|
+
api.Cache.Remove(GetCacheKey(id));
|
|
7199
|
+
api.Cache.Remove(GetListCacheKey());
|
|
7200
|
+
});
|
|
7201
|
+
}
|
|
7202
|
+
Style.Delete = Delete;
|
|
7203
|
+
/**
|
|
7204
|
+
* Returns cache identifier for a style.
|
|
7205
|
+
* Example: {
|
|
7206
|
+
* const api: BruceApi.Api = ...;
|
|
7207
|
+
* const key = GetCacheKey(1);
|
|
7208
|
+
* api.Cache.Remove(key);
|
|
7209
|
+
* }
|
|
7210
|
+
* @param id
|
|
7211
|
+
* @returns
|
|
7212
|
+
*/
|
|
7213
|
+
function GetCacheKey(id) {
|
|
7214
|
+
return exports.Api.ECacheKey.Style + exports.Api.ECacheKey.Id + id;
|
|
7215
|
+
}
|
|
7216
|
+
Style.GetCacheKey = GetCacheKey;
|
|
7217
|
+
/**
|
|
7218
|
+
* Returns cache identifier for a list of styles.
|
|
7219
|
+
* Example: {
|
|
7220
|
+
* const api: BruceApi.Api = ...;
|
|
7221
|
+
* const key = GetListCacheKey();
|
|
7222
|
+
* api.Cache.Remove(key);
|
|
7223
|
+
* }
|
|
7224
|
+
* @returns
|
|
7225
|
+
*/
|
|
7226
|
+
function GetListCacheKey() {
|
|
7227
|
+
return exports.Api.ECacheKey.Style;
|
|
7228
|
+
}
|
|
7229
|
+
Style.GetListCacheKey = GetListCacheKey;
|
|
7230
|
+
})(exports.Style || (exports.Style = {}));
|
|
7231
|
+
|
|
7232
|
+
(function (Comment) {
|
|
7233
|
+
// Entity Type used for storing comment records.
|
|
7234
|
+
Comment.ENTITY_TYPE_ID = "COMMENTS";
|
|
7235
|
+
// Relationship Type ID for linking relies to comments.
|
|
7236
|
+
Comment.REPLY_RELATIONSHIP_TYPE_ID = "COMMENTS_REPLY";
|
|
7237
|
+
// Possible kinds of comments.
|
|
7238
|
+
let EType;
|
|
7239
|
+
(function (EType) {
|
|
7240
|
+
EType["Comment"] = "COMMENT";
|
|
7241
|
+
EType["Reply"] = "REPLY";
|
|
7242
|
+
})(EType = Comment.EType || (Comment.EType = {}));
|
|
7243
|
+
/**
|
|
7244
|
+
* Returns a list of comments based on the provided filter.
|
|
7245
|
+
* @param params
|
|
7246
|
+
* @returns
|
|
7247
|
+
*/
|
|
7248
|
+
function GetList(params) {
|
|
7249
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
7250
|
+
let { api, req, filter } = params;
|
|
7251
|
+
if (!api) {
|
|
7252
|
+
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
7253
|
+
}
|
|
7254
|
+
req = exports.Api.PrepReqParams(req);
|
|
7255
|
+
if (!(yield getEntityTypeExists(api, req))) {
|
|
7256
|
+
return {
|
|
7257
|
+
comments: []
|
|
7258
|
+
};
|
|
7259
|
+
}
|
|
7260
|
+
const reqFilter = {};
|
|
7261
|
+
if (filter.viewId) {
|
|
7262
|
+
reqFilter["viewId"] = {
|
|
7263
|
+
"equals": filter.viewId
|
|
7264
|
+
};
|
|
7265
|
+
}
|
|
7266
|
+
if (filter.userId) {
|
|
7267
|
+
reqFilter["CreatedBy.User.ID"] = {
|
|
7268
|
+
"equals": filter.userId
|
|
7269
|
+
};
|
|
7270
|
+
}
|
|
7271
|
+
if (filter.text) {
|
|
7272
|
+
reqFilter["text"] = {
|
|
7273
|
+
"contains": filter.text
|
|
7274
|
+
};
|
|
7275
|
+
}
|
|
7276
|
+
if (filter.entityId) {
|
|
7277
|
+
reqFilter["entityId"] = {
|
|
7278
|
+
"equals": filter.entityId
|
|
7279
|
+
};
|
|
7280
|
+
}
|
|
7281
|
+
const records = (yield exports.Entity.GetList({
|
|
7282
|
+
api,
|
|
7283
|
+
req,
|
|
7284
|
+
filter: {
|
|
7285
|
+
entityTypeId: Comment.ENTITY_TYPE_ID,
|
|
7286
|
+
pageSize: filter.amount == null ? 20 : filter.amount,
|
|
7287
|
+
pageIndex: filter.index == null ? 0 : filter.index,
|
|
7288
|
+
entityTypeConditions: reqFilter,
|
|
7289
|
+
orderBy: "lastUpdateTime"
|
|
7290
|
+
}
|
|
7291
|
+
})).entities;
|
|
7292
|
+
return {
|
|
7293
|
+
comments: records
|
|
7294
|
+
};
|
|
7295
|
+
});
|
|
7296
|
+
}
|
|
7297
|
+
Comment.GetList = GetList;
|
|
7298
|
+
/**
|
|
7299
|
+
* Ensure the Entity Type exists.
|
|
7300
|
+
* If it does not exist, it will be created.
|
|
7301
|
+
* @param params
|
|
7302
|
+
*/
|
|
7303
|
+
function AssertEntityType(params) {
|
|
7304
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
7305
|
+
let { api, req } = params;
|
|
7306
|
+
if (!api) {
|
|
7307
|
+
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
7308
|
+
}
|
|
7309
|
+
req = exports.Api.PrepReqParams(req);
|
|
7310
|
+
// If the Entity Type does not exist, create it.
|
|
7311
|
+
if (!(yield getEntityTypeExists(api, req))) {
|
|
7312
|
+
// Create Style and set it to the Entity Type.
|
|
7313
|
+
const styleId = yield ensureStyleExists(api);
|
|
7314
|
+
const template = JSON.parse(JSON.stringify(ENTITY_TYPE_TEMPLATE));
|
|
7315
|
+
template["DisplaySetting.ID"] = styleId;
|
|
7316
|
+
yield exports.EntityType.Update({
|
|
7317
|
+
api,
|
|
7318
|
+
entityType: template
|
|
7319
|
+
});
|
|
7320
|
+
}
|
|
7321
|
+
});
|
|
7322
|
+
}
|
|
7323
|
+
Comment.AssertEntityType = AssertEntityType;
|
|
7324
|
+
/**
|
|
7325
|
+
* Ensure the Relation Type exists.
|
|
7326
|
+
* If it does not exist, it will be created.
|
|
7327
|
+
* @param params
|
|
7328
|
+
*/
|
|
7329
|
+
function AssertRelationType(params) {
|
|
7330
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
7331
|
+
let { api, req } = params;
|
|
7332
|
+
if (!api) {
|
|
7333
|
+
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
7334
|
+
}
|
|
7335
|
+
req = exports.Api.PrepReqParams(req);
|
|
7336
|
+
yield ensureRelationExists(api, req);
|
|
7337
|
+
});
|
|
7338
|
+
}
|
|
7339
|
+
Comment.AssertRelationType = AssertRelationType;
|
|
7340
|
+
})(exports.Comment || (exports.Comment = {}));
|
|
7341
|
+
function getEntityTypeExists(api, req) {
|
|
7342
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
7343
|
+
try {
|
|
7344
|
+
const { entityType: data } = yield exports.EntityType.Get({
|
|
7345
|
+
api,
|
|
7346
|
+
req: req,
|
|
7347
|
+
entityTypeId: exports.Comment.ENTITY_TYPE_ID
|
|
7348
|
+
});
|
|
7349
|
+
return !!data;
|
|
7350
|
+
}
|
|
7351
|
+
catch (e) {
|
|
7352
|
+
// TODO: suppress if the error is related to not being found.
|
|
7353
|
+
console.error(e);
|
|
7354
|
+
}
|
|
7355
|
+
return false;
|
|
7356
|
+
});
|
|
7357
|
+
}
|
|
7358
|
+
function ensureStyleExists(api, req) {
|
|
7359
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
7360
|
+
try {
|
|
7361
|
+
const template = JSON.parse(JSON.stringify(STYLE_SETTINGS_TEMPLATE));
|
|
7362
|
+
const { style } = yield exports.Style.Update({
|
|
7363
|
+
api,
|
|
7364
|
+
req: req,
|
|
7365
|
+
style: {
|
|
7366
|
+
Name: "Comment Style",
|
|
7367
|
+
Settings: template,
|
|
7368
|
+
Type: exports.Style.EType.Entity,
|
|
7369
|
+
ID: 0
|
|
7370
|
+
}
|
|
7371
|
+
});
|
|
7372
|
+
return style.ID;
|
|
7373
|
+
}
|
|
7374
|
+
catch (e) {
|
|
7375
|
+
console.error(e);
|
|
7376
|
+
}
|
|
7377
|
+
return 0;
|
|
7378
|
+
});
|
|
7379
|
+
}
|
|
7380
|
+
function ensureRelationExists(api, req) {
|
|
7381
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
7382
|
+
try {
|
|
7383
|
+
const { relationType: data } = yield exports.EntityRelationType.Get({
|
|
7384
|
+
api,
|
|
7385
|
+
req: req,
|
|
7386
|
+
relationTypeId: exports.Comment.REPLY_RELATIONSHIP_TYPE_ID
|
|
7387
|
+
});
|
|
7388
|
+
if (!data) {
|
|
7389
|
+
throw ("Relation Type not found");
|
|
7390
|
+
}
|
|
7391
|
+
}
|
|
7392
|
+
catch (e) {
|
|
7393
|
+
yield exports.EntityRelationType.Update({
|
|
7394
|
+
api,
|
|
7395
|
+
req: req,
|
|
7396
|
+
relationType: {
|
|
7397
|
+
ID: exports.Comment.REPLY_RELATIONSHIP_TYPE_ID,
|
|
7398
|
+
ForwardName: "Parent of",
|
|
7399
|
+
ReverseName: "Reply to",
|
|
7400
|
+
Name: "Comment Reply"
|
|
7401
|
+
}
|
|
7402
|
+
});
|
|
7403
|
+
}
|
|
7404
|
+
});
|
|
7405
|
+
}
|
|
7406
|
+
const STYLE_SETTINGS_TEMPLATE = {
|
|
7407
|
+
pointStyle: {
|
|
7408
|
+
"color": [
|
|
7409
|
+
{
|
|
7410
|
+
"type": 0,
|
|
7411
|
+
"value": "rgba(33,150,243,0.8)"
|
|
7412
|
+
}
|
|
7413
|
+
],
|
|
7414
|
+
"CylinderBorderEnabled": false,
|
|
7415
|
+
"CylinderBorderWidth": [
|
|
7416
|
+
{
|
|
7417
|
+
"type": 1,
|
|
7418
|
+
"value": "15"
|
|
7419
|
+
}
|
|
7420
|
+
],
|
|
7421
|
+
"CylinderFillExtrusion": [
|
|
7422
|
+
{
|
|
7423
|
+
"type": 1,
|
|
7424
|
+
"value": "40"
|
|
7425
|
+
}
|
|
7426
|
+
],
|
|
7427
|
+
"Type": exports.Style.EPointType.Icon,
|
|
7428
|
+
"iconId": null,
|
|
7429
|
+
"altitudeOption": {
|
|
7430
|
+
"name": "Absolute position",
|
|
7431
|
+
"id": 1
|
|
7432
|
+
},
|
|
7433
|
+
"size": [
|
|
7434
|
+
{
|
|
7435
|
+
"type": 1,
|
|
7436
|
+
"value": "20"
|
|
7437
|
+
}
|
|
7438
|
+
],
|
|
7439
|
+
"CylinderFillColor": [
|
|
7440
|
+
{
|
|
7441
|
+
"type": 1,
|
|
7442
|
+
"value": "rgba(33,150,243,0.8)"
|
|
7443
|
+
}
|
|
7444
|
+
],
|
|
7445
|
+
"CylinderBorderExtrusion": [
|
|
7446
|
+
{
|
|
7447
|
+
"type": 1,
|
|
7448
|
+
"value": "35"
|
|
7449
|
+
}
|
|
7450
|
+
],
|
|
7451
|
+
"CylinderRadius": [
|
|
7452
|
+
{
|
|
7453
|
+
"type": 1,
|
|
7454
|
+
"value": "20"
|
|
7455
|
+
}
|
|
7456
|
+
],
|
|
7457
|
+
"iconUrl": [
|
|
7458
|
+
{
|
|
7459
|
+
"type": 1,
|
|
7460
|
+
"value": "https://template.api.nextspace-uat.net/file/faf2194d-3a95-40cc-a6b3-6a7aa223f766.png"
|
|
7461
|
+
}
|
|
7462
|
+
],
|
|
7463
|
+
"ClusterNearbyEntities": false,
|
|
7464
|
+
"CylinderBorderColor": [
|
|
7465
|
+
{
|
|
7466
|
+
"type": 1,
|
|
7467
|
+
"value": "rgba(33,150,243,0.8)"
|
|
7468
|
+
}
|
|
7469
|
+
],
|
|
7470
|
+
"iconScale": [
|
|
7471
|
+
{
|
|
7472
|
+
"type": 1,
|
|
7473
|
+
"value": 1
|
|
7474
|
+
}
|
|
7475
|
+
],
|
|
7476
|
+
"MinimumEntitiesCountForClustering": [
|
|
7477
|
+
{
|
|
7478
|
+
"type": 1,
|
|
7479
|
+
"value": "2"
|
|
7480
|
+
}
|
|
7481
|
+
]
|
|
7482
|
+
}
|
|
7483
|
+
};
|
|
7484
|
+
const ENTITY_TYPE_TEMPLATE = {
|
|
7485
|
+
ID: exports.Comment.ENTITY_TYPE_ID,
|
|
7486
|
+
Name: "Comments",
|
|
7487
|
+
DataSchema: {
|
|
7488
|
+
"Key": "root",
|
|
7489
|
+
"Name": "Root",
|
|
7490
|
+
"Type": exports.EntityAttribute.EType.Structure,
|
|
7491
|
+
Structure: [
|
|
7492
|
+
{
|
|
7493
|
+
"IsIndexed": true,
|
|
7494
|
+
"IsImportant": false,
|
|
7495
|
+
"Type": exports.EntityAttribute.EType.String,
|
|
7496
|
+
"IsArray": false,
|
|
7497
|
+
"Size": 40,
|
|
7498
|
+
"Key": "ID",
|
|
7499
|
+
"Name": "Identity",
|
|
7500
|
+
"IsFamilyAttribute": false,
|
|
7501
|
+
"IsFamilyAttributeDefault": false
|
|
7502
|
+
},
|
|
7503
|
+
{
|
|
7504
|
+
"IsIndexed": false,
|
|
7505
|
+
"IsImportant": false,
|
|
7506
|
+
"Type": exports.EntityAttribute.EType.Geometry,
|
|
7507
|
+
"IsArray": false,
|
|
7508
|
+
"Size": 0,
|
|
7509
|
+
"Key": "geometry",
|
|
7510
|
+
"Name": "Geometry",
|
|
7511
|
+
"IsFamilyAttribute": false,
|
|
7512
|
+
"IsFamilyAttributeDefault": false
|
|
7513
|
+
},
|
|
7514
|
+
{
|
|
7515
|
+
"IsImportant": false,
|
|
7516
|
+
"Type": exports.EntityAttribute.EType.Structure,
|
|
7517
|
+
"IsArray": false,
|
|
7518
|
+
"Structure": [
|
|
7519
|
+
{
|
|
7520
|
+
"IsIndexed": true,
|
|
7521
|
+
"IsImportant": false,
|
|
7522
|
+
"Type": exports.EntityAttribute.EType.Double,
|
|
7523
|
+
"IsArray": false,
|
|
7524
|
+
"Key": "minLongitude",
|
|
7525
|
+
"Name": "Min Longitude",
|
|
7526
|
+
"IsFamilyAttribute": false,
|
|
7527
|
+
"IsFamilyAttributeDefault": false
|
|
7528
|
+
},
|
|
7529
|
+
{
|
|
7530
|
+
"IsIndexed": true,
|
|
7531
|
+
"IsImportant": false,
|
|
7532
|
+
"Type": exports.EntityAttribute.EType.Double,
|
|
7533
|
+
"IsArray": false,
|
|
7534
|
+
"Key": "minLatitude",
|
|
7535
|
+
"Name": "Min Latitude",
|
|
7536
|
+
"IsFamilyAttribute": false,
|
|
7537
|
+
"IsFamilyAttributeDefault": false
|
|
7538
|
+
},
|
|
7539
|
+
{
|
|
7540
|
+
"IsIndexed": true,
|
|
7541
|
+
"IsImportant": false,
|
|
7542
|
+
"Type": exports.EntityAttribute.EType.Double,
|
|
7543
|
+
"IsArray": false,
|
|
7544
|
+
"Size": 0,
|
|
7545
|
+
"Key": "minAltitude",
|
|
7546
|
+
"Name": "Min Altitude",
|
|
7547
|
+
"IsFamilyAttribute": false,
|
|
7548
|
+
"IsFamilyAttributeDefault": false
|
|
7549
|
+
},
|
|
7550
|
+
{
|
|
7551
|
+
"IsIndexed": true,
|
|
7552
|
+
"IsImportant": false,
|
|
7553
|
+
"Type": exports.EntityAttribute.EType.Double,
|
|
7554
|
+
"IsArray": false,
|
|
7555
|
+
"Key": "maxLongitude",
|
|
7556
|
+
"Name": "Max Longitude",
|
|
7557
|
+
"IsFamilyAttribute": false,
|
|
7558
|
+
"IsFamilyAttributeDefault": false
|
|
7559
|
+
},
|
|
7560
|
+
{
|
|
7561
|
+
"IsIndexed": true,
|
|
7562
|
+
"IsImportant": false,
|
|
7563
|
+
"Type": exports.EntityAttribute.EType.Double,
|
|
7564
|
+
"IsArray": false,
|
|
7565
|
+
"Key": "maxLatitude",
|
|
7566
|
+
"Name": "Max Latitude",
|
|
7567
|
+
"IsFamilyAttribute": false,
|
|
7568
|
+
"IsFamilyAttributeDefault": false
|
|
7569
|
+
},
|
|
7570
|
+
{
|
|
7571
|
+
"IsIndexed": true,
|
|
7572
|
+
"IsImportant": false,
|
|
7573
|
+
"Type": exports.EntityAttribute.EType.Double,
|
|
7574
|
+
"IsArray": false,
|
|
7575
|
+
"Size": 0,
|
|
7576
|
+
"Key": "maxAltitude",
|
|
7577
|
+
"Name": "Max Altitude",
|
|
7578
|
+
"IsFamilyAttribute": false,
|
|
7579
|
+
"IsFamilyAttributeDefault": false
|
|
7580
|
+
}
|
|
7581
|
+
],
|
|
7582
|
+
"Key": "boundaries",
|
|
7583
|
+
"Name": "Boundaries",
|
|
7584
|
+
"IsFamilyAttribute": false,
|
|
7585
|
+
"IsFamilyAttributeDefault": false
|
|
7586
|
+
},
|
|
7587
|
+
{
|
|
7588
|
+
"IsImportant": false,
|
|
7589
|
+
"Type": exports.EntityAttribute.EType.Structure,
|
|
7590
|
+
"IsArray": false,
|
|
7591
|
+
"Structure": [
|
|
7592
|
+
{
|
|
7593
|
+
"IsIndexed": true,
|
|
7594
|
+
"IsImportant": false,
|
|
7595
|
+
"Type": exports.EntityAttribute.EType.Double,
|
|
7596
|
+
"IsArray": false,
|
|
7597
|
+
"Key": "latitude",
|
|
7598
|
+
"Name": "Latitude",
|
|
7599
|
+
"IsFamilyAttribute": false,
|
|
7600
|
+
"IsFamilyAttributeDefault": false
|
|
7601
|
+
},
|
|
7602
|
+
{
|
|
7603
|
+
"IsIndexed": true,
|
|
7604
|
+
"IsImportant": false,
|
|
7605
|
+
"Type": exports.EntityAttribute.EType.Double,
|
|
7606
|
+
"IsArray": false,
|
|
7607
|
+
"Key": "longitude",
|
|
7608
|
+
"Name": "Longitude",
|
|
7609
|
+
"IsFamilyAttribute": false,
|
|
7610
|
+
"IsFamilyAttributeDefault": false
|
|
7611
|
+
},
|
|
7612
|
+
{
|
|
7613
|
+
"IsIndexed": true,
|
|
7614
|
+
"IsImportant": false,
|
|
7615
|
+
"Type": exports.EntityAttribute.EType.Double,
|
|
7616
|
+
"IsArray": false,
|
|
7617
|
+
"Key": "altitude",
|
|
7618
|
+
"Name": "Altitude",
|
|
7619
|
+
"IsFamilyAttribute": false,
|
|
7620
|
+
"IsFamilyAttributeDefault": false
|
|
7621
|
+
}
|
|
7622
|
+
],
|
|
7623
|
+
"Key": "location",
|
|
7624
|
+
"Name": "Location",
|
|
7625
|
+
"IsFamilyAttribute": false,
|
|
7626
|
+
"IsFamilyAttributeDefault": false
|
|
7627
|
+
},
|
|
7628
|
+
{
|
|
7629
|
+
"IsIndexed": true,
|
|
7630
|
+
"IsImportant": true,
|
|
7631
|
+
"Type": exports.EntityAttribute.EType.String,
|
|
7632
|
+
"IsArray": false,
|
|
7633
|
+
"Size": 60,
|
|
7634
|
+
"Key": "viewId",
|
|
7635
|
+
"Name": "View Id",
|
|
7636
|
+
"IsFamilyAttribute": false,
|
|
7637
|
+
"IsFamilyAttributeDefault": false
|
|
7638
|
+
},
|
|
7639
|
+
{
|
|
7640
|
+
"IsIndexed": true,
|
|
7641
|
+
"IsImportant": true,
|
|
7642
|
+
"Type": exports.EntityAttribute.EType.String,
|
|
7643
|
+
"IsArray": false,
|
|
7644
|
+
"Size": 60,
|
|
7645
|
+
"Key": "bookmarkId",
|
|
7646
|
+
"Name": "Bookmark Id",
|
|
7647
|
+
"IsFamilyAttribute": false,
|
|
7648
|
+
"IsFamilyAttributeDefault": false
|
|
7649
|
+
},
|
|
7650
|
+
{
|
|
7651
|
+
"IsIndexed": true,
|
|
7652
|
+
"IsImportant": true,
|
|
7653
|
+
"Type": exports.EntityAttribute.EType.String,
|
|
7654
|
+
"IsArray": false,
|
|
7655
|
+
"Key": "text",
|
|
7656
|
+
"Name": "Comment",
|
|
7657
|
+
"IsFamilyAttribute": false,
|
|
7658
|
+
"IsFamilyAttributeDefault": false
|
|
7659
|
+
},
|
|
7660
|
+
{
|
|
7661
|
+
"IsIndexed": true,
|
|
7662
|
+
"IsImportant": true,
|
|
7663
|
+
"Type": exports.EntityAttribute.EType.Datetime,
|
|
7664
|
+
"IsArray": false,
|
|
7665
|
+
"Key": "lastUpdateTime",
|
|
7666
|
+
"Name": "Last Update Time",
|
|
7667
|
+
"IsFamilyAttribute": false,
|
|
7668
|
+
"IsFamilyAttributeDefault": false
|
|
7669
|
+
},
|
|
7670
|
+
{
|
|
7671
|
+
"IsIndexed": true,
|
|
7672
|
+
"IsImportant": true,
|
|
7673
|
+
"Type": exports.EntityAttribute.EType.String,
|
|
7674
|
+
"IsArray": false,
|
|
7675
|
+
"Key": "entityId",
|
|
7676
|
+
"Name": "Related Entity ID",
|
|
7677
|
+
"IsFamilyAttribute": false,
|
|
7678
|
+
"IsFamilyAttributeDefault": false
|
|
7679
|
+
}
|
|
7680
|
+
]
|
|
7681
|
+
},
|
|
7682
|
+
"DisplaySetting.ID": 0
|
|
7683
|
+
};
|
|
7684
|
+
|
|
7685
|
+
(function (Uploader) {
|
|
7686
|
+
Uploader.MIN_LARGE_FILE_SIZE = 100000000; // 100MB.
|
|
7687
|
+
/**
|
|
7688
|
+
* Uploads a file to the server.
|
|
7689
|
+
* @param params
|
|
7690
|
+
* @returns
|
|
7691
|
+
*/
|
|
7692
|
+
function DoMultiPartUpload(params) {
|
|
7693
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
7694
|
+
let { file, api, urlSuffix: url, req, onProgress } = params;
|
|
7695
|
+
if (!api) {
|
|
7696
|
+
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
7697
|
+
}
|
|
7698
|
+
const FILE_PORTION_SIZE = 100000000; // 100MB.
|
|
7699
|
+
let fileSize = file.size;
|
|
7700
|
+
let fileOffset = 0;
|
|
7701
|
+
let filePartsCount = fileSize / FILE_PORTION_SIZE;
|
|
7702
|
+
let t = Math.trunc(filePartsCount);
|
|
7703
|
+
filePartsCount = filePartsCount > t ? t + 1 : t;
|
|
7704
|
+
let filePartIndex = 1;
|
|
7705
|
+
let uploadToken = exports.ObjectUtils.UId();
|
|
7706
|
+
let data;
|
|
7707
|
+
while (fileOffset < fileSize) {
|
|
7708
|
+
let partSize = Math.min(FILE_PORTION_SIZE, fileSize - fileOffset);
|
|
7709
|
+
let retryCount = 5;
|
|
7710
|
+
let retryWait = 1000;
|
|
7711
|
+
while (retryCount > 0) {
|
|
7712
|
+
try {
|
|
7713
|
+
const blob = file.slice(fileOffset, fileOffset + partSize);
|
|
7714
|
+
const partialFile = new File([blob], file.name, { type: file.type });
|
|
7715
|
+
const formData = new FormData();
|
|
7716
|
+
formData.append("originalFileName", file.name);
|
|
7717
|
+
formData.append("token", uploadToken);
|
|
7718
|
+
formData.append("count", "" + filePartsCount);
|
|
7719
|
+
formData.append("part", "" + filePartIndex);
|
|
7720
|
+
formData.append("file", partialFile);
|
|
7721
|
+
const reqParams = exports.Api.PrepReqParams(req);
|
|
7722
|
+
reqParams.formData = formData;
|
|
7723
|
+
reqParams.onProgress = (progress) => {
|
|
7724
|
+
const sofar = fileOffset + progress.loaded;
|
|
7725
|
+
const percent = Math.round((sofar / file.size) * 100);
|
|
7726
|
+
onProgress === null || onProgress === void 0 ? void 0 : onProgress({
|
|
7727
|
+
percent: percent,
|
|
7728
|
+
uploaded: false
|
|
7729
|
+
});
|
|
7730
|
+
};
|
|
7731
|
+
data = yield api.UPLOAD(url, partialFile, reqParams);
|
|
7732
|
+
retryCount = 0;
|
|
7733
|
+
}
|
|
7734
|
+
catch (up) {
|
|
7735
|
+
retryCount -= 1;
|
|
7736
|
+
if (retryCount <= 0) {
|
|
7737
|
+
throw up;
|
|
7738
|
+
}
|
|
7739
|
+
yield new Promise((res) => setTimeout(res, retryWait));
|
|
7740
|
+
retryWait = retryWait * 2;
|
|
7741
|
+
}
|
|
7742
|
+
}
|
|
7743
|
+
fileOffset += partSize;
|
|
7744
|
+
filePartIndex++;
|
|
7745
|
+
}
|
|
7746
|
+
onProgress === null || onProgress === void 0 ? void 0 : onProgress({
|
|
7747
|
+
percent: 100,
|
|
7748
|
+
uploaded: true
|
|
7749
|
+
});
|
|
7750
|
+
return data;
|
|
7751
|
+
});
|
|
7752
|
+
}
|
|
7753
|
+
Uploader.DoMultiPartUpload = DoMultiPartUpload;
|
|
7754
|
+
})(exports.Uploader || (exports.Uploader = {}));
|
|
7755
|
+
|
|
7756
|
+
(function (ClientFile) {
|
|
7757
|
+
let EPurpose;
|
|
7758
|
+
(function (EPurpose) {
|
|
7759
|
+
// Use this purpose for uploading bookmark thumbnail images.
|
|
7760
|
+
// This will allow lower level privileges to upload (small) bookmark thumbnails.
|
|
7761
|
+
EPurpose["BookmarkThumbnail"] = "Bookmark Thumbnail";
|
|
7762
|
+
})(EPurpose = ClientFile.EPurpose || (ClientFile.EPurpose = {}));
|
|
7763
|
+
/**
|
|
7764
|
+
* Returns the URL for a client file.
|
|
7765
|
+
* @param params
|
|
7766
|
+
* @returns
|
|
7767
|
+
*/
|
|
7768
|
+
function GetUrl(params) {
|
|
7769
|
+
let { api, fileId, viaCdn } = params;
|
|
7770
|
+
if (!api) {
|
|
7771
|
+
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
7772
|
+
}
|
|
7773
|
+
const urlSuffix = `file/${fileId}`;
|
|
7774
|
+
const cdnUrl = viaCdn ? api.ConstructCdnUrl(urlSuffix) : null;
|
|
7775
|
+
if (cdnUrl) {
|
|
7776
|
+
return cdnUrl;
|
|
7777
|
+
}
|
|
7778
|
+
let url = `${api.GetBaseUrl()}${urlSuffix}`;
|
|
7779
|
+
// Invalidating cache manually because we have a wave of invalid headers now cached across devices.
|
|
7780
|
+
url = exports.UrlUtils.AddQueryParam(url, "cc", "1");
|
|
7781
|
+
return url;
|
|
7782
|
+
}
|
|
7783
|
+
ClientFile.GetUrl = GetUrl;
|
|
7784
|
+
/**
|
|
7785
|
+
* Returns the URL for a client file with the extension.
|
|
7786
|
+
* @param params
|
|
7787
|
+
* @returns
|
|
7788
|
+
*/
|
|
7789
|
+
function GetUrlWithExt(params) {
|
|
7790
|
+
let { api, file, viaCdn } = params;
|
|
7791
|
+
if (!api) {
|
|
7792
|
+
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
7793
|
+
}
|
|
7794
|
+
const urlSuffix = file.FileExt ? `file/${file.ID}${file.FileExt}` : `file/${file.ID}`;
|
|
7795
|
+
const cdnUrl = viaCdn ? api.ConstructCdnUrl(urlSuffix) : null;
|
|
7796
|
+
if (cdnUrl) {
|
|
7797
|
+
return cdnUrl;
|
|
7798
|
+
}
|
|
7799
|
+
let url = `${api.GetBaseUrl()}${urlSuffix}`;
|
|
7800
|
+
// Invalidating cache manually because we have a wave of invalid headers now cached across devices.
|
|
7801
|
+
url = exports.UrlUtils.AddQueryParam(url, "cc", "1");
|
|
7802
|
+
return url;
|
|
7803
|
+
}
|
|
7804
|
+
ClientFile.GetUrlWithExt = GetUrlWithExt;
|
|
7805
|
+
/**
|
|
7806
|
+
* Returns a client file record by ID.
|
|
7807
|
+
* @param params
|
|
7808
|
+
* @returns
|
|
7809
|
+
*/
|
|
7810
|
+
function Get(params) {
|
|
7811
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
7812
|
+
let { api, fileId, req: reqParams } = params;
|
|
7813
|
+
if (!api) {
|
|
7814
|
+
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
7815
|
+
}
|
|
7816
|
+
if (!fileId) {
|
|
7817
|
+
throw ("File ID is required.");
|
|
7818
|
+
}
|
|
7819
|
+
const key = GetCacheKey(fileId);
|
|
7820
|
+
const cache = yield api.GetCacheItem(key, reqParams);
|
|
7821
|
+
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
7822
|
+
return cache.data;
|
|
7823
|
+
}
|
|
7824
|
+
const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
7825
|
+
try {
|
|
7826
|
+
const data = yield api.GET(`file/${fileId}/details`, exports.Api.PrepReqParams(reqParams));
|
|
7827
|
+
res({
|
|
7828
|
+
clientFile: data
|
|
7829
|
+
});
|
|
7830
|
+
}
|
|
7831
|
+
catch (e) {
|
|
7832
|
+
rej(e);
|
|
7833
|
+
}
|
|
7834
|
+
}));
|
|
7835
|
+
yield api.SetCacheItem({
|
|
7836
|
+
key,
|
|
7837
|
+
value: prom,
|
|
7838
|
+
req: reqParams
|
|
7839
|
+
});
|
|
7840
|
+
return prom;
|
|
7841
|
+
});
|
|
7842
|
+
}
|
|
7843
|
+
ClientFile.Get = Get;
|
|
7844
|
+
/**
|
|
7845
|
+
* Deletes one or many client file records by IDs.
|
|
7846
|
+
* @param params
|
|
7847
|
+
*/
|
|
7848
|
+
function Delete(params) {
|
|
7849
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
7850
|
+
let { api, fileIds, req: reqParams } = params;
|
|
7851
|
+
if (!fileIds.length) {
|
|
7852
|
+
return Promise.resolve();
|
|
7853
|
+
}
|
|
7854
|
+
if (!api) {
|
|
7855
|
+
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
7856
|
+
}
|
|
7857
|
+
const data = {
|
|
7858
|
+
Items: fileIds
|
|
7859
|
+
};
|
|
7860
|
+
yield api.POST("deleteFiles", data, exports.Api.PrepReqParams(reqParams));
|
|
7861
|
+
for (let i = 0; i < fileIds.length; i++) {
|
|
7862
|
+
const key = GetCacheKey(fileIds[i]);
|
|
7863
|
+
api.Cache.Remove(key);
|
|
7864
|
+
}
|
|
7865
|
+
});
|
|
7866
|
+
}
|
|
7867
|
+
ClientFile.Delete = Delete;
|
|
7868
|
+
/**
|
|
7869
|
+
* Uploads a file and creates a new client file record.
|
|
7870
|
+
* @param params
|
|
7871
|
+
* @returns
|
|
7872
|
+
*/
|
|
7873
|
+
function Upload(params) {
|
|
7874
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
7875
|
+
let { api, file, purpose, req, onProgress } = params;
|
|
7876
|
+
if (!api) {
|
|
7877
|
+
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
7878
|
+
}
|
|
7879
|
+
if (!file) {
|
|
7880
|
+
throw ("File is required.");
|
|
7881
|
+
}
|
|
7882
|
+
const size = file === null || file === void 0 ? void 0 : file.size;
|
|
7883
|
+
if (!size) {
|
|
7884
|
+
throw ("You cannot upload a 0byte sized file.");
|
|
7885
|
+
}
|
|
7886
|
+
req = exports.Api.PrepReqParams(req);
|
|
7887
|
+
let clientFile;
|
|
7888
|
+
if (size > exports.Uploader.MIN_LARGE_FILE_SIZE) {
|
|
7889
|
+
clientFile = yield exports.Uploader.DoMultiPartUpload({
|
|
7890
|
+
api,
|
|
7891
|
+
file,
|
|
7892
|
+
urlSuffix: "fileUpload",
|
|
7893
|
+
req,
|
|
7163
7894
|
onProgress
|
|
7164
7895
|
});
|
|
7165
7896
|
// TODO: Check if we can add it to the request like the small file upload.
|
|
@@ -9333,181 +10064,11 @@
|
|
|
9333
10064
|
if (!api) {
|
|
9334
10065
|
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
9335
10066
|
}
|
|
9336
|
-
yield api.DELETE(`pendingAction/${actionId}`, exports.Api.PrepReqParams(reqParams));
|
|
9337
|
-
});
|
|
9338
|
-
}
|
|
9339
|
-
PendingAction.Cancel = Cancel;
|
|
9340
|
-
})(exports.PendingAction || (exports.PendingAction = {}));
|
|
9341
|
-
|
|
9342
|
-
(function (Style) {
|
|
9343
|
-
/**
|
|
9344
|
-
* Types of styles available.
|
|
9345
|
-
* The type will dictate what settings are available.
|
|
9346
|
-
*/
|
|
9347
|
-
let EType;
|
|
9348
|
-
(function (EType) {
|
|
9349
|
-
EType["Entity"] = "ENTITY";
|
|
9350
|
-
EType["EntityRelationship"] = "ENTITY_RELATIONSHIP";
|
|
9351
|
-
})(EType = Style.EType || (Style.EType = {}));
|
|
9352
|
-
/**
|
|
9353
|
-
* Available types of points.
|
|
9354
|
-
* Default is POINT.
|
|
9355
|
-
*/
|
|
9356
|
-
let EPointType;
|
|
9357
|
-
(function (EPointType) {
|
|
9358
|
-
// Render a sphere with a fixed pixel size.
|
|
9359
|
-
EPointType["Point"] = "POINT";
|
|
9360
|
-
// Render an icon.
|
|
9361
|
-
EPointType["Icon"] = "ICON";
|
|
9362
|
-
// Render a cylinder with a fixed meter size.
|
|
9363
|
-
EPointType["Cylinder"] = "CYLINDER";
|
|
9364
|
-
})(EPointType = Style.EPointType || (Style.EPointType = {}));
|
|
9365
|
-
/**
|
|
9366
|
-
* Returns a list of styles.
|
|
9367
|
-
* @param params
|
|
9368
|
-
* @returns
|
|
9369
|
-
*/
|
|
9370
|
-
function GetList(params) {
|
|
9371
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
9372
|
-
let { api, req: reqParams } = params;
|
|
9373
|
-
if (!api) {
|
|
9374
|
-
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
9375
|
-
}
|
|
9376
|
-
const cache = yield api.GetCacheItem(GetListCacheKey(), reqParams);
|
|
9377
|
-
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
9378
|
-
return cache.data;
|
|
9379
|
-
}
|
|
9380
|
-
const res = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
9381
|
-
try {
|
|
9382
|
-
const data = yield api.GET("ui.entityDisplaySettings", exports.Api.PrepReqParams(reqParams));
|
|
9383
|
-
res({
|
|
9384
|
-
styles: data.Items
|
|
9385
|
-
});
|
|
9386
|
-
}
|
|
9387
|
-
catch (e) {
|
|
9388
|
-
rej(e);
|
|
9389
|
-
}
|
|
9390
|
-
}));
|
|
9391
|
-
yield api.SetCacheItem({
|
|
9392
|
-
key: GetListCacheKey(),
|
|
9393
|
-
value: res,
|
|
9394
|
-
req: reqParams
|
|
9395
|
-
});
|
|
9396
|
-
return res;
|
|
9397
|
-
});
|
|
9398
|
-
}
|
|
9399
|
-
Style.GetList = GetList;
|
|
9400
|
-
/**
|
|
9401
|
-
* Returns a style.
|
|
9402
|
-
* @param params
|
|
9403
|
-
* @returns
|
|
9404
|
-
*/
|
|
9405
|
-
function Get(params) {
|
|
9406
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
9407
|
-
let { api, styleId: id, req: reqParams } = params;
|
|
9408
|
-
if (!id) {
|
|
9409
|
-
throw ("Style ID is required.");
|
|
9410
|
-
}
|
|
9411
|
-
if (!api) {
|
|
9412
|
-
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
9413
|
-
}
|
|
9414
|
-
const cache = yield api.GetCacheItem(GetCacheKey(id), reqParams);
|
|
9415
|
-
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
9416
|
-
return cache.data;
|
|
9417
|
-
}
|
|
9418
|
-
const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
9419
|
-
try {
|
|
9420
|
-
const data = yield api.GET(`ui.entityDisplaySetting/${id}`, exports.Api.PrepReqParams(reqParams));
|
|
9421
|
-
res({
|
|
9422
|
-
style: data
|
|
9423
|
-
});
|
|
9424
|
-
}
|
|
9425
|
-
catch (e) {
|
|
9426
|
-
rej(e);
|
|
9427
|
-
}
|
|
9428
|
-
}));
|
|
9429
|
-
yield api.SetCacheItem({
|
|
9430
|
-
key: GetCacheKey(id),
|
|
9431
|
-
value: prom,
|
|
9432
|
-
req: reqParams
|
|
9433
|
-
});
|
|
9434
|
-
return prom;
|
|
9435
|
-
});
|
|
9436
|
-
}
|
|
9437
|
-
Style.Get = Get;
|
|
9438
|
-
/**
|
|
9439
|
-
* Creates or updates a style.
|
|
9440
|
-
* @param params
|
|
9441
|
-
* @returns
|
|
9442
|
-
*/
|
|
9443
|
-
function Update(params) {
|
|
9444
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
9445
|
-
let { api, style: data, req: reqParams } = params;
|
|
9446
|
-
if (!(data === null || data === void 0 ? void 0 : data.Name)) {
|
|
9447
|
-
throw ("Style name is required.");
|
|
9448
|
-
}
|
|
9449
|
-
if (!api) {
|
|
9450
|
-
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
9451
|
-
}
|
|
9452
|
-
if (!data.ID) {
|
|
9453
|
-
data.ID = 0;
|
|
9454
|
-
}
|
|
9455
|
-
const res = yield api.POST(`ui.entityDisplaySetting/${data.ID}`, data, exports.Api.PrepReqParams(reqParams));
|
|
9456
|
-
api.Cache.Remove(GetCacheKey(data.ID));
|
|
9457
|
-
api.Cache.Remove(GetListCacheKey());
|
|
9458
|
-
return {
|
|
9459
|
-
style: res
|
|
9460
|
-
};
|
|
9461
|
-
});
|
|
9462
|
-
}
|
|
9463
|
-
Style.Update = Update;
|
|
9464
|
-
/**
|
|
9465
|
-
* Deletes a style.
|
|
9466
|
-
* @param params
|
|
9467
|
-
*/
|
|
9468
|
-
function Delete(params) {
|
|
9469
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
9470
|
-
let { api, styleId: id, req: reqParams } = params;
|
|
9471
|
-
if (!api) {
|
|
9472
|
-
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
9473
|
-
}
|
|
9474
|
-
if (!id) {
|
|
9475
|
-
throw ("Style ID is required.");
|
|
9476
|
-
}
|
|
9477
|
-
yield api.DELETE(`ui.entityDisplaySetting/${id}`, exports.Api.PrepReqParams(reqParams));
|
|
9478
|
-
api.Cache.Remove(GetCacheKey(id));
|
|
9479
|
-
api.Cache.Remove(GetListCacheKey());
|
|
9480
|
-
});
|
|
9481
|
-
}
|
|
9482
|
-
Style.Delete = Delete;
|
|
9483
|
-
/**
|
|
9484
|
-
* Returns cache identifier for a style.
|
|
9485
|
-
* Example: {
|
|
9486
|
-
* const api: BruceApi.Api = ...;
|
|
9487
|
-
* const key = GetCacheKey(1);
|
|
9488
|
-
* api.Cache.Remove(key);
|
|
9489
|
-
* }
|
|
9490
|
-
* @param id
|
|
9491
|
-
* @returns
|
|
9492
|
-
*/
|
|
9493
|
-
function GetCacheKey(id) {
|
|
9494
|
-
return exports.Api.ECacheKey.Style + exports.Api.ECacheKey.Id + id;
|
|
9495
|
-
}
|
|
9496
|
-
Style.GetCacheKey = GetCacheKey;
|
|
9497
|
-
/**
|
|
9498
|
-
* Returns cache identifier for a list of styles.
|
|
9499
|
-
* Example: {
|
|
9500
|
-
* const api: BruceApi.Api = ...;
|
|
9501
|
-
* const key = GetListCacheKey();
|
|
9502
|
-
* api.Cache.Remove(key);
|
|
9503
|
-
* }
|
|
9504
|
-
* @returns
|
|
9505
|
-
*/
|
|
9506
|
-
function GetListCacheKey() {
|
|
9507
|
-
return exports.Api.ECacheKey.Style;
|
|
10067
|
+
yield api.DELETE(`pendingAction/${actionId}`, exports.Api.PrepReqParams(reqParams));
|
|
10068
|
+
});
|
|
9508
10069
|
}
|
|
9509
|
-
|
|
9510
|
-
})(exports.
|
|
10070
|
+
PendingAction.Cancel = Cancel;
|
|
10071
|
+
})(exports.PendingAction || (exports.PendingAction = {}));
|
|
9511
10072
|
|
|
9512
10073
|
/**
|
|
9513
10074
|
* Permissions in Nextspace are arbitrary strings with meaning in specific contexts.
|
|
@@ -10596,17 +11157,18 @@
|
|
|
10596
11157
|
EFeature["EntityLexicalSearch"] = "Feature_Entity_Lexical_Search";
|
|
10597
11158
|
})(EFeature = AccountFeatures.EFeature || (AccountFeatures.EFeature = {}));
|
|
10598
11159
|
/**
|
|
10599
|
-
* Gets account features corresponding to
|
|
11160
|
+
* Gets account features corresponding to the API instance's account.
|
|
10600
11161
|
* @param params
|
|
10601
11162
|
* @returns
|
|
10602
11163
|
*/
|
|
10603
11164
|
function Get(params) {
|
|
10604
11165
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10605
|
-
let { api,
|
|
11166
|
+
let { api, req: reqParams } = params;
|
|
10606
11167
|
if (!api) {
|
|
10607
11168
|
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
10608
11169
|
}
|
|
10609
|
-
const
|
|
11170
|
+
const accountId = api.AccountId;
|
|
11171
|
+
const cache = yield api.GetCacheItem(GetCacheKey(accountId), reqParams);
|
|
10610
11172
|
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
10611
11173
|
return cache.data;
|
|
10612
11174
|
}
|
|
@@ -10623,7 +11185,7 @@
|
|
|
10623
11185
|
}
|
|
10624
11186
|
}));
|
|
10625
11187
|
api.SetCacheItem({
|
|
10626
|
-
key: GetCacheKey(
|
|
11188
|
+
key: GetCacheKey(accountId),
|
|
10627
11189
|
value: prom,
|
|
10628
11190
|
req: reqParams
|
|
10629
11191
|
});
|
|
@@ -10633,10 +11195,11 @@
|
|
|
10633
11195
|
AccountFeatures.Get = Get;
|
|
10634
11196
|
function Update(params) {
|
|
10635
11197
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10636
|
-
let { api,
|
|
11198
|
+
let { api, features, req: reqParams } = params;
|
|
10637
11199
|
if (!api) {
|
|
10638
11200
|
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
10639
11201
|
}
|
|
11202
|
+
const accountId = api.AccountId;
|
|
10640
11203
|
const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
10641
11204
|
try {
|
|
10642
11205
|
const data = yield api.POST("features", {
|
|
@@ -10651,7 +11214,7 @@
|
|
|
10651
11214
|
rej(e);
|
|
10652
11215
|
}
|
|
10653
11216
|
}));
|
|
10654
|
-
api.Cache.Remove(GetCacheKey(
|
|
11217
|
+
api.Cache.Remove(GetCacheKey(accountId));
|
|
10655
11218
|
return prom;
|
|
10656
11219
|
});
|
|
10657
11220
|
}
|
|
@@ -10672,6 +11235,609 @@
|
|
|
10672
11235
|
AccountFeatures.GetCacheKey = GetCacheKey;
|
|
10673
11236
|
})(exports.AccountFeatures || (exports.AccountFeatures = {}));
|
|
10674
11237
|
|
|
11238
|
+
(function (AccountLimits) {
|
|
11239
|
+
let ELimit;
|
|
11240
|
+
(function (ELimit) {
|
|
11241
|
+
ELimit["MaxProjectViewCount"] = "MaxProjectViewCount";
|
|
11242
|
+
ELimit["MaxStorageUseGigabytes"] = "MaxStorageUseGigabytes";
|
|
11243
|
+
ELimit["MaxEntitiesCount"] = "MaxEntitiesCount";
|
|
11244
|
+
ELimit["MaxFileImportSizeGigabytes"] = "MaxFileImportSizeGigabytes";
|
|
11245
|
+
ELimit["OperatorAccessAllowed"] = "OperatorAccessAllowed";
|
|
11246
|
+
ELimit["DenyPublicAccess"] = "DenyPublicAccess";
|
|
11247
|
+
ELimit["EnableSSOLogin"] = "EnableSSOLogin";
|
|
11248
|
+
ELimit["EnableSSOLoginAutoRedirect"] = "EnableSSOLoginAutoRedirect";
|
|
11249
|
+
})(ELimit = AccountLimits.ELimit || (AccountLimits.ELimit = {}));
|
|
11250
|
+
/**
|
|
11251
|
+
* Returns a dictionary of limits for the given account.
|
|
11252
|
+
* @param params
|
|
11253
|
+
* @returns
|
|
11254
|
+
*/
|
|
11255
|
+
function GetLimits(params) {
|
|
11256
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11257
|
+
let { accountId, api, req } = params;
|
|
11258
|
+
if (!api) {
|
|
11259
|
+
api = exports.ENVIRONMENT.Api().GetGuardianApi();
|
|
11260
|
+
}
|
|
11261
|
+
req = exports.Api.PrepReqParams(req);
|
|
11262
|
+
const cacheData = api.GetCacheItem(GetLimitsCacheKey(accountId));
|
|
11263
|
+
if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.found) {
|
|
11264
|
+
return cacheData.data;
|
|
11265
|
+
}
|
|
11266
|
+
const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
11267
|
+
try {
|
|
11268
|
+
const data = yield api.GET(`account/${accountId}?WithLimits=true`);
|
|
11269
|
+
const limits = data.Limits ? data.Limits : {};
|
|
11270
|
+
res({
|
|
11271
|
+
limits: limits
|
|
11272
|
+
});
|
|
11273
|
+
}
|
|
11274
|
+
catch (e) {
|
|
11275
|
+
rej(e);
|
|
11276
|
+
}
|
|
11277
|
+
}));
|
|
11278
|
+
api.SetCacheItem({
|
|
11279
|
+
key: GetLimitsCacheKey(accountId),
|
|
11280
|
+
value: prom,
|
|
11281
|
+
req: req
|
|
11282
|
+
});
|
|
11283
|
+
return prom;
|
|
11284
|
+
});
|
|
11285
|
+
}
|
|
11286
|
+
AccountLimits.GetLimits = GetLimits;
|
|
11287
|
+
/**
|
|
11288
|
+
* Returns a numeric limit for the given account.
|
|
11289
|
+
* @param params
|
|
11290
|
+
*/
|
|
11291
|
+
function GetNumericLimit(params) {
|
|
11292
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11293
|
+
const { key, api, req, onErrorValue, onEmptyValue, accountId } = params;
|
|
11294
|
+
try {
|
|
11295
|
+
const { limits } = yield GetLimits({
|
|
11296
|
+
accountId: accountId,
|
|
11297
|
+
api: api,
|
|
11298
|
+
req: req
|
|
11299
|
+
});
|
|
11300
|
+
const limit = limits[key];
|
|
11301
|
+
if (limit == null || limit.Numeric == null) {
|
|
11302
|
+
return onEmptyValue;
|
|
11303
|
+
}
|
|
11304
|
+
return Number(limit.Numeric);
|
|
11305
|
+
}
|
|
11306
|
+
catch (e) {
|
|
11307
|
+
return onErrorValue;
|
|
11308
|
+
}
|
|
11309
|
+
});
|
|
11310
|
+
}
|
|
11311
|
+
AccountLimits.GetNumericLimit = GetNumericLimit;
|
|
11312
|
+
/**
|
|
11313
|
+
* Returns a boolean limit for the given account.
|
|
11314
|
+
* @param params
|
|
11315
|
+
*/
|
|
11316
|
+
function GetBooleanLimit(params) {
|
|
11317
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11318
|
+
const { key, api, req, onErrorValue, onEmptyValue, accountId } = params;
|
|
11319
|
+
try {
|
|
11320
|
+
const { limits } = yield GetLimits({
|
|
11321
|
+
accountId: accountId,
|
|
11322
|
+
api: api,
|
|
11323
|
+
req: req
|
|
11324
|
+
});
|
|
11325
|
+
const limit = limits[key];
|
|
11326
|
+
if (limit == null || limit.Boolean == null) {
|
|
11327
|
+
return onEmptyValue;
|
|
11328
|
+
}
|
|
11329
|
+
return Boolean(limit.Boolean);
|
|
11330
|
+
}
|
|
11331
|
+
catch (e) {
|
|
11332
|
+
return onErrorValue;
|
|
11333
|
+
}
|
|
11334
|
+
});
|
|
11335
|
+
}
|
|
11336
|
+
AccountLimits.GetBooleanLimit = GetBooleanLimit;
|
|
11337
|
+
/**
|
|
11338
|
+
* Returns a string limit for the given account.
|
|
11339
|
+
* @param params
|
|
11340
|
+
*/
|
|
11341
|
+
function GetStringLimit(params) {
|
|
11342
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11343
|
+
const { key, api, req, onErrorValue, onEmptyValue, accountId } = params;
|
|
11344
|
+
try {
|
|
11345
|
+
const { limits } = yield GetLimits({
|
|
11346
|
+
accountId: accountId,
|
|
11347
|
+
api: api,
|
|
11348
|
+
req: req
|
|
11349
|
+
});
|
|
11350
|
+
const limit = limits[key];
|
|
11351
|
+
if (limit == null || limit.String == null) {
|
|
11352
|
+
return onEmptyValue;
|
|
11353
|
+
}
|
|
11354
|
+
return limit.String;
|
|
11355
|
+
}
|
|
11356
|
+
catch (e) {
|
|
11357
|
+
return onErrorValue;
|
|
11358
|
+
}
|
|
11359
|
+
});
|
|
11360
|
+
}
|
|
11361
|
+
AccountLimits.GetStringLimit = GetStringLimit;
|
|
11362
|
+
/**
|
|
11363
|
+
* Functions for validating if a user can do things sit here.
|
|
11364
|
+
*/
|
|
11365
|
+
let Assert;
|
|
11366
|
+
(function (Assert) {
|
|
11367
|
+
/**
|
|
11368
|
+
* Returns if project view creation is allowed for the account.
|
|
11369
|
+
*/
|
|
11370
|
+
function GetCanCreateProjectView(params) {
|
|
11371
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11372
|
+
if (!params.getters) {
|
|
11373
|
+
params.getters = exports.ENVIRONMENT.Api();
|
|
11374
|
+
}
|
|
11375
|
+
if (!params.accountId) {
|
|
11376
|
+
params.accountId = params.getters.GetAccountId();
|
|
11377
|
+
}
|
|
11378
|
+
let current = -1;
|
|
11379
|
+
let max = yield GetNumericLimit({
|
|
11380
|
+
accountId: params.accountId,
|
|
11381
|
+
key: ELimit.MaxProjectViewCount,
|
|
11382
|
+
onEmptyValue: 0,
|
|
11383
|
+
onErrorValue: null,
|
|
11384
|
+
api: params.getters.GetGuardianApi()
|
|
11385
|
+
});
|
|
11386
|
+
if (max != null) {
|
|
11387
|
+
// Should use proper statistic API as this will exclude project views the user cannot access.
|
|
11388
|
+
try {
|
|
11389
|
+
const { views } = yield exports.ProjectView.GetList({
|
|
11390
|
+
api: params.getters.GetBruceApi({
|
|
11391
|
+
accountId: params.accountId
|
|
11392
|
+
})
|
|
11393
|
+
});
|
|
11394
|
+
current = views.length;
|
|
11395
|
+
}
|
|
11396
|
+
catch (e) {
|
|
11397
|
+
console.error(e);
|
|
11398
|
+
max = null;
|
|
11399
|
+
}
|
|
11400
|
+
}
|
|
11401
|
+
if (max == null) {
|
|
11402
|
+
return {
|
|
11403
|
+
allowed: false,
|
|
11404
|
+
errorText: "We apologize but Project View creation is currently unavailable."
|
|
11405
|
+
};
|
|
11406
|
+
}
|
|
11407
|
+
else if (max == -1) {
|
|
11408
|
+
return {
|
|
11409
|
+
allowed: true
|
|
11410
|
+
};
|
|
11411
|
+
}
|
|
11412
|
+
else if (current == -1) {
|
|
11413
|
+
return {
|
|
11414
|
+
allowed: false,
|
|
11415
|
+
errorText: "We apologize but Project View creation is currently unavailable."
|
|
11416
|
+
};
|
|
11417
|
+
}
|
|
11418
|
+
else if (current >= max) {
|
|
11419
|
+
return {
|
|
11420
|
+
allowed: false,
|
|
11421
|
+
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}.`
|
|
11422
|
+
};
|
|
11423
|
+
}
|
|
11424
|
+
return {
|
|
11425
|
+
allowed: true
|
|
11426
|
+
};
|
|
11427
|
+
});
|
|
11428
|
+
}
|
|
11429
|
+
Assert.GetCanCreateProjectView = GetCanCreateProjectView;
|
|
11430
|
+
/**
|
|
11431
|
+
* Returns the project view limit for an account.
|
|
11432
|
+
* If -1 is returned then it is unlimited.
|
|
11433
|
+
* @param params
|
|
11434
|
+
* @returns
|
|
11435
|
+
*/
|
|
11436
|
+
function GetProjectViewLimit(params) {
|
|
11437
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11438
|
+
if (!params.api) {
|
|
11439
|
+
params.api = exports.ENVIRONMENT.Api().GetGuardianApi();
|
|
11440
|
+
}
|
|
11441
|
+
if (!params.accountId) {
|
|
11442
|
+
params.accountId = exports.ENVIRONMENT.Api().GetAccountId();
|
|
11443
|
+
}
|
|
11444
|
+
const max = yield GetNumericLimit({
|
|
11445
|
+
accountId: params.accountId,
|
|
11446
|
+
key: ELimit.MaxProjectViewCount,
|
|
11447
|
+
onEmptyValue: 0,
|
|
11448
|
+
onErrorValue: null,
|
|
11449
|
+
api: params.api
|
|
11450
|
+
});
|
|
11451
|
+
// Our error so we'll just allow unlimited for the time being.
|
|
11452
|
+
if (max == null) {
|
|
11453
|
+
return -1;
|
|
11454
|
+
}
|
|
11455
|
+
return max;
|
|
11456
|
+
});
|
|
11457
|
+
}
|
|
11458
|
+
Assert.GetProjectViewLimit = GetProjectViewLimit;
|
|
11459
|
+
/**
|
|
11460
|
+
* Returns if file uploads are allowed for the account.
|
|
11461
|
+
*/
|
|
11462
|
+
function GetCanUploadFile(params) {
|
|
11463
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11464
|
+
if (!params.getters) {
|
|
11465
|
+
params.getters = exports.ENVIRONMENT.Api();
|
|
11466
|
+
}
|
|
11467
|
+
if (!params.accountId) {
|
|
11468
|
+
params.accountId = params.getters.GetAccountId();
|
|
11469
|
+
}
|
|
11470
|
+
let current = -1;
|
|
11471
|
+
let max = yield GetNumericLimit({
|
|
11472
|
+
accountId: params.accountId,
|
|
11473
|
+
key: ELimit.MaxStorageUseGigabytes,
|
|
11474
|
+
onEmptyValue: 0,
|
|
11475
|
+
onErrorValue: null,
|
|
11476
|
+
api: params.getters.GetGuardianApi()
|
|
11477
|
+
});
|
|
11478
|
+
if (max != null && max > 0) {
|
|
11479
|
+
try {
|
|
11480
|
+
const api = params.getters.GetBruceApi({
|
|
11481
|
+
accountId: params.accountId
|
|
11482
|
+
});
|
|
11483
|
+
const stats = yield api.GET("account/summary-stats");
|
|
11484
|
+
if (stats === null || stats === void 0 ? void 0 : stats.ID) {
|
|
11485
|
+
const result = stats === null || stats === void 0 ? void 0 : stats.Result;
|
|
11486
|
+
try {
|
|
11487
|
+
const resJson = JSON.parse(result);
|
|
11488
|
+
const fileBytes = resJson.TotalStorageUseBytes;
|
|
11489
|
+
const fileGB = fileBytes != null && !isNaN(fileBytes) && fileBytes != -1 ? exports.MathUtils.Round(fileBytes / 1024 / 1024 / 1024, 2) : null;
|
|
11490
|
+
// Still counting so we'll give unlimited for the time being.
|
|
11491
|
+
// This count can take ages so we won't make the user wait.
|
|
11492
|
+
if (fileGB == null || isNaN(fileGB)) {
|
|
11493
|
+
max = -1;
|
|
11494
|
+
}
|
|
11495
|
+
else {
|
|
11496
|
+
current = fileGB;
|
|
11497
|
+
}
|
|
11498
|
+
}
|
|
11499
|
+
// We won't count this as a fatal error because who knows how stable this is.
|
|
11500
|
+
catch (e) {
|
|
11501
|
+
console.error(e);
|
|
11502
|
+
}
|
|
11503
|
+
}
|
|
11504
|
+
// Unknown so we'll just give unlimited for the time being.
|
|
11505
|
+
else {
|
|
11506
|
+
max = -1;
|
|
11507
|
+
}
|
|
11508
|
+
}
|
|
11509
|
+
catch (e) {
|
|
11510
|
+
console.error(e);
|
|
11511
|
+
max = null;
|
|
11512
|
+
}
|
|
11513
|
+
}
|
|
11514
|
+
// Optional param for a file size to add to the current storage amount.
|
|
11515
|
+
// Eg: user is uploading a 3gb file, is that allowed right now?
|
|
11516
|
+
if (current != -1 && !isNaN(params.fileSize) && params.fileSize) {
|
|
11517
|
+
current += exports.MathUtils.Round(params.fileSize / 1024 / 1024 / 1024, 3);
|
|
11518
|
+
}
|
|
11519
|
+
if (max == null) {
|
|
11520
|
+
return {
|
|
11521
|
+
allowed: false,
|
|
11522
|
+
errorText: "We apologize but file uploads are currently unavailable."
|
|
11523
|
+
};
|
|
11524
|
+
}
|
|
11525
|
+
else if (max == -1) {
|
|
11526
|
+
return {
|
|
11527
|
+
allowed: true
|
|
11528
|
+
};
|
|
11529
|
+
}
|
|
11530
|
+
else if (current == -1) {
|
|
11531
|
+
return {
|
|
11532
|
+
allowed: false,
|
|
11533
|
+
errorText: "We apologize but file uploads are currently unavailable."
|
|
11534
|
+
};
|
|
11535
|
+
}
|
|
11536
|
+
else if (current >= max) {
|
|
11537
|
+
return {
|
|
11538
|
+
allowed: false,
|
|
11539
|
+
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.`
|
|
11540
|
+
};
|
|
11541
|
+
}
|
|
11542
|
+
return {
|
|
11543
|
+
allowed: true
|
|
11544
|
+
};
|
|
11545
|
+
});
|
|
11546
|
+
}
|
|
11547
|
+
Assert.GetCanUploadFile = GetCanUploadFile;
|
|
11548
|
+
/**
|
|
11549
|
+
* Returns the file limit for an account.
|
|
11550
|
+
* If -1 is returned then it is unlimited.
|
|
11551
|
+
* @param params
|
|
11552
|
+
* @returns
|
|
11553
|
+
*/
|
|
11554
|
+
function GetFileGBLimit(params) {
|
|
11555
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11556
|
+
if (!params.api) {
|
|
11557
|
+
params.api = exports.ENVIRONMENT.Api().GetGuardianApi();
|
|
11558
|
+
}
|
|
11559
|
+
if (!params.accountId) {
|
|
11560
|
+
params.accountId = exports.ENVIRONMENT.Api().GetAccountId();
|
|
11561
|
+
}
|
|
11562
|
+
const max = yield GetNumericLimit({
|
|
11563
|
+
accountId: params.accountId,
|
|
11564
|
+
key: ELimit.MaxStorageUseGigabytes,
|
|
11565
|
+
onEmptyValue: 0,
|
|
11566
|
+
onErrorValue: null,
|
|
11567
|
+
api: params.api
|
|
11568
|
+
});
|
|
11569
|
+
// Our error so we'll just allow unlimited for the time being.
|
|
11570
|
+
if (max == null) {
|
|
11571
|
+
return -1;
|
|
11572
|
+
}
|
|
11573
|
+
return max;
|
|
11574
|
+
});
|
|
11575
|
+
}
|
|
11576
|
+
Assert.GetFileGBLimit = GetFileGBLimit;
|
|
11577
|
+
/**
|
|
11578
|
+
* Returns the maximum file import size for an account.
|
|
11579
|
+
* If -1 is returned then it is unlimited.
|
|
11580
|
+
* @param params
|
|
11581
|
+
* @returns
|
|
11582
|
+
*/
|
|
11583
|
+
function GetMaxImportSizeGB(params) {
|
|
11584
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11585
|
+
if (!params.api) {
|
|
11586
|
+
params.api = exports.ENVIRONMENT.Api().GetGuardianApi();
|
|
11587
|
+
}
|
|
11588
|
+
if (!params.accountId) {
|
|
11589
|
+
params.accountId = exports.ENVIRONMENT.Api().GetAccountId();
|
|
11590
|
+
}
|
|
11591
|
+
const max = yield GetNumericLimit({
|
|
11592
|
+
accountId: params.accountId,
|
|
11593
|
+
key: ELimit.MaxFileImportSizeGigabytes,
|
|
11594
|
+
onEmptyValue: 0,
|
|
11595
|
+
onErrorValue: null,
|
|
11596
|
+
api: params.api
|
|
11597
|
+
});
|
|
11598
|
+
// Our error so we'll just allow unlimited for the time being.
|
|
11599
|
+
if (max == null) {
|
|
11600
|
+
return -1;
|
|
11601
|
+
}
|
|
11602
|
+
return max;
|
|
11603
|
+
});
|
|
11604
|
+
}
|
|
11605
|
+
Assert.GetMaxImportSizeGB = GetMaxImportSizeGB;
|
|
11606
|
+
/**
|
|
11607
|
+
* Returns if entity creation is allowed for the account.
|
|
11608
|
+
*/
|
|
11609
|
+
function GetCanCreateEntity(params) {
|
|
11610
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11611
|
+
if (!params.getters) {
|
|
11612
|
+
params.getters = exports.ENVIRONMENT.Api();
|
|
11613
|
+
}
|
|
11614
|
+
if (!params.accountId) {
|
|
11615
|
+
params.accountId = params.getters.GetAccountId();
|
|
11616
|
+
}
|
|
11617
|
+
let current = -1;
|
|
11618
|
+
let max = yield GetNumericLimit({
|
|
11619
|
+
accountId: params.accountId,
|
|
11620
|
+
key: ELimit.MaxEntitiesCount,
|
|
11621
|
+
onEmptyValue: 0,
|
|
11622
|
+
onErrorValue: null,
|
|
11623
|
+
api: params.getters.GetGuardianApi()
|
|
11624
|
+
});
|
|
11625
|
+
if (max != null && max > 0) {
|
|
11626
|
+
try {
|
|
11627
|
+
const api = params.getters.GetBruceApi({
|
|
11628
|
+
accountId: params.accountId
|
|
11629
|
+
});
|
|
11630
|
+
const stats = yield api.GET("account/summary-stats");
|
|
11631
|
+
if (stats === null || stats === void 0 ? void 0 : stats.ID) {
|
|
11632
|
+
const result = stats === null || stats === void 0 ? void 0 : stats.Result;
|
|
11633
|
+
try {
|
|
11634
|
+
const resJson = JSON.parse(result);
|
|
11635
|
+
const eCount = resJson.EntitiesCount;
|
|
11636
|
+
// Still counting so we'll give unlimited for the time being.
|
|
11637
|
+
// This count can take ages so we won't make the user wait.
|
|
11638
|
+
if (eCount == null || isNaN(eCount)) {
|
|
11639
|
+
max = -1;
|
|
11640
|
+
}
|
|
11641
|
+
else {
|
|
11642
|
+
current = eCount;
|
|
11643
|
+
}
|
|
11644
|
+
}
|
|
11645
|
+
// We won't count this as a fatal error because who knows how stable this is.
|
|
11646
|
+
catch (e) {
|
|
11647
|
+
console.error(e);
|
|
11648
|
+
}
|
|
11649
|
+
}
|
|
11650
|
+
// Unknown so we'll just give unlimited for the time being.
|
|
11651
|
+
else {
|
|
11652
|
+
max = -1;
|
|
11653
|
+
}
|
|
11654
|
+
}
|
|
11655
|
+
catch (e) {
|
|
11656
|
+
console.error(e);
|
|
11657
|
+
max = null;
|
|
11658
|
+
}
|
|
11659
|
+
}
|
|
11660
|
+
// Optional param for an entity count to add to the current entity amount.
|
|
11661
|
+
// Eg: user is creating 3 entities, is that allowed right now?
|
|
11662
|
+
if (current != -1 && !isNaN(params.count) && params.count) {
|
|
11663
|
+
current += params.count;
|
|
11664
|
+
// Remove one since we do an inclusive check later in the code.
|
|
11665
|
+
current -= 1;
|
|
11666
|
+
}
|
|
11667
|
+
if (max == null) {
|
|
11668
|
+
return {
|
|
11669
|
+
allowed: false,
|
|
11670
|
+
errorText: "We apologize but Entity creation is currently unavailable."
|
|
11671
|
+
};
|
|
11672
|
+
}
|
|
11673
|
+
else if (max == -1) {
|
|
11674
|
+
return {
|
|
11675
|
+
allowed: true
|
|
11676
|
+
};
|
|
11677
|
+
}
|
|
11678
|
+
else if (current == -1) {
|
|
11679
|
+
return {
|
|
11680
|
+
allowed: false,
|
|
11681
|
+
errorText: "We apologize but Entity creation is currently unavailable."
|
|
11682
|
+
};
|
|
11683
|
+
}
|
|
11684
|
+
else if (current >= max) {
|
|
11685
|
+
return {
|
|
11686
|
+
allowed: false,
|
|
11687
|
+
errorText: `You have reached the maximum number of Entities allowed for your account. You are limited to ${max.toLocaleString()} ${max == 1 ? "Entity" : "Entities"}.`
|
|
11688
|
+
};
|
|
11689
|
+
}
|
|
11690
|
+
return {
|
|
11691
|
+
allowed: true
|
|
11692
|
+
};
|
|
11693
|
+
});
|
|
11694
|
+
}
|
|
11695
|
+
Assert.GetCanCreateEntity = GetCanCreateEntity;
|
|
11696
|
+
/**
|
|
11697
|
+
* Returns the entity limit for an account.
|
|
11698
|
+
* If -1 is returned then it is unlimited.
|
|
11699
|
+
*/
|
|
11700
|
+
function GetEntityLimit(params) {
|
|
11701
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11702
|
+
if (!params.api) {
|
|
11703
|
+
params.api = exports.ENVIRONMENT.Api().GetGuardianApi();
|
|
11704
|
+
}
|
|
11705
|
+
if (!params.accountId) {
|
|
11706
|
+
params.accountId = exports.ENVIRONMENT.Api().GetAccountId();
|
|
11707
|
+
}
|
|
11708
|
+
const max = yield GetNumericLimit({
|
|
11709
|
+
accountId: params.accountId,
|
|
11710
|
+
key: ELimit.MaxEntitiesCount,
|
|
11711
|
+
onEmptyValue: 0,
|
|
11712
|
+
onErrorValue: null,
|
|
11713
|
+
api: params.api
|
|
11714
|
+
});
|
|
11715
|
+
// Our error so we'll just allow unlimited for the time being.
|
|
11716
|
+
if (max == null) {
|
|
11717
|
+
return -1;
|
|
11718
|
+
}
|
|
11719
|
+
return max;
|
|
11720
|
+
});
|
|
11721
|
+
}
|
|
11722
|
+
Assert.GetEntityLimit = GetEntityLimit;
|
|
11723
|
+
/**
|
|
11724
|
+
* Returns if Operator access is allowed for the account.
|
|
11725
|
+
* @param params
|
|
11726
|
+
* @returns
|
|
11727
|
+
*/
|
|
11728
|
+
function GetCanOpenOperator(params) {
|
|
11729
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11730
|
+
if (!params.api) {
|
|
11731
|
+
params.api = exports.ENVIRONMENT.Api().GetGuardianApi();
|
|
11732
|
+
}
|
|
11733
|
+
if (!params.accountId) {
|
|
11734
|
+
params.accountId = exports.ENVIRONMENT.Api().GetAccountId();
|
|
11735
|
+
}
|
|
11736
|
+
const allowed = yield GetBooleanLimit({
|
|
11737
|
+
accountId: params.accountId,
|
|
11738
|
+
key: ELimit.OperatorAccessAllowed,
|
|
11739
|
+
onEmptyValue: false,
|
|
11740
|
+
onErrorValue: null,
|
|
11741
|
+
api: params.api
|
|
11742
|
+
});
|
|
11743
|
+
if (allowed == null) {
|
|
11744
|
+
return {
|
|
11745
|
+
allowed: false,
|
|
11746
|
+
errorText: "We apologize but Operator access is currently unavailable."
|
|
11747
|
+
};
|
|
11748
|
+
}
|
|
11749
|
+
else if (allowed) {
|
|
11750
|
+
return {
|
|
11751
|
+
allowed: true
|
|
11752
|
+
};
|
|
11753
|
+
}
|
|
11754
|
+
else {
|
|
11755
|
+
return {
|
|
11756
|
+
allowed: false,
|
|
11757
|
+
errorText: "You do not have access to Operator."
|
|
11758
|
+
};
|
|
11759
|
+
}
|
|
11760
|
+
});
|
|
11761
|
+
}
|
|
11762
|
+
Assert.GetCanOpenOperator = GetCanOpenOperator;
|
|
11763
|
+
/**
|
|
11764
|
+
* Returns SSO login settings for the account.
|
|
11765
|
+
* @param params
|
|
11766
|
+
* @returns
|
|
11767
|
+
*/
|
|
11768
|
+
function GetSSOLoginSettings(params) {
|
|
11769
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11770
|
+
if (!params.api) {
|
|
11771
|
+
params.api = exports.ENVIRONMENT.Api().GetGuardianApi();
|
|
11772
|
+
}
|
|
11773
|
+
if (!params.accountId) {
|
|
11774
|
+
params.accountId = exports.ENVIRONMENT.Api().GetAccountId();
|
|
11775
|
+
}
|
|
11776
|
+
const enabled = yield GetBooleanLimit({
|
|
11777
|
+
accountId: params.accountId,
|
|
11778
|
+
key: ELimit.EnableSSOLogin,
|
|
11779
|
+
onEmptyValue: false,
|
|
11780
|
+
onErrorValue: null,
|
|
11781
|
+
api: params.api
|
|
11782
|
+
});
|
|
11783
|
+
const autoRedirect = yield GetBooleanLimit({
|
|
11784
|
+
accountId: params.accountId,
|
|
11785
|
+
key: ELimit.EnableSSOLoginAutoRedirect,
|
|
11786
|
+
onEmptyValue: false,
|
|
11787
|
+
onErrorValue: null,
|
|
11788
|
+
api: params.api
|
|
11789
|
+
});
|
|
11790
|
+
if (enabled == null || autoRedirect == null) {
|
|
11791
|
+
return {
|
|
11792
|
+
enabled: false,
|
|
11793
|
+
autoRedirect: false,
|
|
11794
|
+
errorText: "We apologize but SSO login is currently unavailable."
|
|
11795
|
+
};
|
|
11796
|
+
}
|
|
11797
|
+
return {
|
|
11798
|
+
enabled: enabled,
|
|
11799
|
+
autoRedirect: autoRedirect
|
|
11800
|
+
};
|
|
11801
|
+
});
|
|
11802
|
+
}
|
|
11803
|
+
Assert.GetSSOLoginSettings = GetSSOLoginSettings;
|
|
11804
|
+
/**
|
|
11805
|
+
* Returns if public access is denied to this account.
|
|
11806
|
+
* @param params
|
|
11807
|
+
* @returns
|
|
11808
|
+
*/
|
|
11809
|
+
function GetDenyPublicAccess(params) {
|
|
11810
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11811
|
+
if (!params.api) {
|
|
11812
|
+
params.api = exports.ENVIRONMENT.Api().GetGuardianApi();
|
|
11813
|
+
}
|
|
11814
|
+
if (!params.accountId) {
|
|
11815
|
+
params.accountId = exports.ENVIRONMENT.Api().GetAccountId();
|
|
11816
|
+
}
|
|
11817
|
+
const enabled = yield GetBooleanLimit({
|
|
11818
|
+
accountId: params.accountId,
|
|
11819
|
+
key: ELimit.DenyPublicAccess,
|
|
11820
|
+
// If empty then we'll assume we are not denying public access.
|
|
11821
|
+
onEmptyValue: false,
|
|
11822
|
+
// If we crash we are denying public access.
|
|
11823
|
+
onErrorValue: true,
|
|
11824
|
+
api: params.api
|
|
11825
|
+
});
|
|
11826
|
+
return enabled;
|
|
11827
|
+
});
|
|
11828
|
+
}
|
|
11829
|
+
Assert.GetDenyPublicAccess = GetDenyPublicAccess;
|
|
11830
|
+
})(Assert = AccountLimits.Assert || (AccountLimits.Assert = {}));
|
|
11831
|
+
/**
|
|
11832
|
+
* Cache key for requesting account limits for a specific account.
|
|
11833
|
+
* @param accountId
|
|
11834
|
+
*/
|
|
11835
|
+
function GetLimitsCacheKey(accountId) {
|
|
11836
|
+
return exports.Api.ECacheKey.AccountLimits + exports.Api.ECacheKey.Id + accountId;
|
|
11837
|
+
}
|
|
11838
|
+
AccountLimits.GetLimitsCacheKey = GetLimitsCacheKey;
|
|
11839
|
+
})(exports.AccountLimits || (exports.AccountLimits = {}));
|
|
11840
|
+
|
|
10675
11841
|
(function (EncryptUtils) {
|
|
10676
11842
|
// https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript
|
|
10677
11843
|
function Cyrb53Hash(str, seed = 0) {
|
|
@@ -11684,7 +12850,7 @@
|
|
|
11684
12850
|
})(exports.DataSource || (exports.DataSource = {}));
|
|
11685
12851
|
|
|
11686
12852
|
// This is updated with the package.json version on build.
|
|
11687
|
-
const VERSION = "4.1.
|
|
12853
|
+
const VERSION = "4.1.7";
|
|
11688
12854
|
|
|
11689
12855
|
exports.VERSION = VERSION;
|
|
11690
12856
|
exports.AbstractApi = AbstractApi;
|