bruce-models 5.4.5 → 5.4.6
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 +417 -181
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +388 -163
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/account/account-template.js +102 -0
- package/dist/lib/account/account-template.js.map +1 -0
- package/dist/lib/account/account-type.js +35 -0
- package/dist/lib/account/account-type.js.map +1 -0
- package/dist/lib/account/account.js +10 -7
- package/dist/lib/account/account.js.map +1 -1
- package/dist/lib/bruce-models.js +3 -1
- package/dist/lib/bruce-models.js.map +1 -1
- package/dist/lib/server/message-broker.js +4 -2
- package/dist/lib/server/message-broker.js.map +1 -1
- package/dist/lib/user/user-group.js +54 -0
- package/dist/lib/user/user-group.js.map +1 -1
- package/dist/lib/user/user.js +76 -6
- package/dist/lib/user/user.js.map +1 -1
- package/dist/types/account/account-template.d.ts +55 -0
- package/dist/types/account/account-type.d.ts +18 -0
- package/dist/types/account/account.d.ts +2 -1
- package/dist/types/bruce-models.d.ts +3 -1
- package/dist/types/user/user-group.d.ts +23 -0
- package/dist/types/user/user.d.ts +28 -1
- package/package.json +1 -1
package/dist/bruce-models.es5.js
CHANGED
|
@@ -624,9 +624,11 @@ var MessageBroker;
|
|
|
624
624
|
}
|
|
625
625
|
}
|
|
626
626
|
formatApiUri(uri) {
|
|
627
|
-
const wsProtocol = window.document.location.protocol === "https:" ? "wss" : "ws";
|
|
628
627
|
const currentUrl = new URL(uri);
|
|
629
|
-
|
|
628
|
+
// Protocol matching the Bruce API one.
|
|
629
|
+
// In almost all cases it will be wss, in a localhost BruceAPI then it might be ws.
|
|
630
|
+
const protocol = currentUrl.protocol === "http:" ? "ws:" : "wss:";
|
|
631
|
+
let full = protocol + "://" + currentUrl.host + currentUrl.pathname + "websocket";
|
|
630
632
|
// Check if we have a queryParam for accountId.
|
|
631
633
|
const accountId = currentUrl.searchParams.get("accountId");
|
|
632
634
|
if (accountId) {
|
|
@@ -11138,15 +11140,15 @@ var Account;
|
|
|
11138
11140
|
*/
|
|
11139
11141
|
function GetRelatedList(params) {
|
|
11140
11142
|
return __awaiter(this, void 0, void 0, function* () {
|
|
11141
|
-
let { api, req: reqParams } = params;
|
|
11143
|
+
let { api, req: reqParams, owned } = params;
|
|
11142
11144
|
if (!api) {
|
|
11143
11145
|
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
11144
11146
|
}
|
|
11145
|
-
const cache = api.GetCacheItem(GetListCacheKey(api.GetSessionId()), reqParams);
|
|
11147
|
+
const cache = api.GetCacheItem(GetListCacheKey(api.GetSessionId(), owned), reqParams);
|
|
11146
11148
|
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
11147
11149
|
return cache.data;
|
|
11148
11150
|
}
|
|
11149
|
-
const req = api.GET("user/relatedClientAccounts", reqParams);
|
|
11151
|
+
const req = api.GET(owned ? "user/ownedClientAccounts" : "user/relatedClientAccounts", reqParams);
|
|
11150
11152
|
const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
11151
11153
|
try {
|
|
11152
11154
|
const data = yield req;
|
|
@@ -11160,7 +11162,7 @@ var Account;
|
|
|
11160
11162
|
}
|
|
11161
11163
|
}));
|
|
11162
11164
|
api.SetCacheItem({
|
|
11163
|
-
key: GetListCacheKey(api.GetSessionId()),
|
|
11165
|
+
key: GetListCacheKey(api.GetSessionId(), owned),
|
|
11164
11166
|
value: prom,
|
|
11165
11167
|
req: reqParams
|
|
11166
11168
|
});
|
|
@@ -11252,7 +11254,7 @@ var Account;
|
|
|
11252
11254
|
const resData = {
|
|
11253
11255
|
account: res
|
|
11254
11256
|
};
|
|
11255
|
-
api.Cache.
|
|
11257
|
+
api.Cache.RemoveByStartsWith(GetListCacheKey(api.GetSessionId()));
|
|
11256
11258
|
return resData;
|
|
11257
11259
|
});
|
|
11258
11260
|
}
|
|
@@ -11306,8 +11308,11 @@ var Account;
|
|
|
11306
11308
|
* @param ssid
|
|
11307
11309
|
* @returns
|
|
11308
11310
|
*/
|
|
11309
|
-
function GetListCacheKey(ssid) {
|
|
11310
|
-
|
|
11311
|
+
function GetListCacheKey(ssid, owned) {
|
|
11312
|
+
if (!owned) {
|
|
11313
|
+
owned = false;
|
|
11314
|
+
}
|
|
11315
|
+
return Api.ECacheKey.Account + Api.ECacheKey.Session + Api.ECacheKey.Id + ssid + Api.ECacheKey.Id + (owned ? "owned" : "related");
|
|
11311
11316
|
}
|
|
11312
11317
|
Account.GetListCacheKey = GetListCacheKey;
|
|
11313
11318
|
/**
|
|
@@ -11822,158 +11827,6 @@ var Session;
|
|
|
11822
11827
|
}
|
|
11823
11828
|
})(Session || (Session = {}));
|
|
11824
11829
|
|
|
11825
|
-
/**
|
|
11826
|
-
* Describes the "User Group" concept within Nextspace.
|
|
11827
|
-
* A user group is a collection of permissions ("Features") and what users should be in the group.
|
|
11828
|
-
*/
|
|
11829
|
-
var UserGroup;
|
|
11830
|
-
(function (UserGroup) {
|
|
11831
|
-
/**
|
|
11832
|
-
* Returns a user group by its name.
|
|
11833
|
-
* @param params
|
|
11834
|
-
* @returns
|
|
11835
|
-
*/
|
|
11836
|
-
function GetByName(params) {
|
|
11837
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
11838
|
-
let { api, accountId, name, req: reqParams } = params;
|
|
11839
|
-
if (!name) {
|
|
11840
|
-
throw ("Name is required.");
|
|
11841
|
-
}
|
|
11842
|
-
if (!api) {
|
|
11843
|
-
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
11844
|
-
}
|
|
11845
|
-
// Default groups.
|
|
11846
|
-
if (!accountId) {
|
|
11847
|
-
accountId = "";
|
|
11848
|
-
}
|
|
11849
|
-
const data = yield api.GET(`account/${accountId}/userGroupByName/${name}`, reqParams);
|
|
11850
|
-
return {
|
|
11851
|
-
group: data
|
|
11852
|
-
};
|
|
11853
|
-
});
|
|
11854
|
-
}
|
|
11855
|
-
UserGroup.GetByName = GetByName;
|
|
11856
|
-
/**
|
|
11857
|
-
* Returns all users in a user group.
|
|
11858
|
-
* @param params
|
|
11859
|
-
* @returns
|
|
11860
|
-
*/
|
|
11861
|
-
function GetUsers(params) {
|
|
11862
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
11863
|
-
let { api, accountId, groupId: id, req: reqParams } = params;
|
|
11864
|
-
if (!id) {
|
|
11865
|
-
throw ("ID is required.");
|
|
11866
|
-
}
|
|
11867
|
-
if (!api) {
|
|
11868
|
-
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
11869
|
-
}
|
|
11870
|
-
// Default groups.
|
|
11871
|
-
if (!accountId) {
|
|
11872
|
-
accountId = "";
|
|
11873
|
-
}
|
|
11874
|
-
const data = yield api.GET(`userGroup/${accountId}/${id}/users`, reqParams);
|
|
11875
|
-
return {
|
|
11876
|
-
users: data.Items
|
|
11877
|
-
};
|
|
11878
|
-
});
|
|
11879
|
-
}
|
|
11880
|
-
UserGroup.GetUsers = GetUsers;
|
|
11881
|
-
/**
|
|
11882
|
-
* Returns list of user groups that have a specific permission enabled.
|
|
11883
|
-
* @param params
|
|
11884
|
-
* @returns
|
|
11885
|
-
*/
|
|
11886
|
-
function GetListByPerm(params) {
|
|
11887
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
11888
|
-
let { api, accountId, perm, req: reqParams } = params;
|
|
11889
|
-
if (!perm) {
|
|
11890
|
-
throw ("Perm is required.");
|
|
11891
|
-
}
|
|
11892
|
-
if (!api) {
|
|
11893
|
-
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
11894
|
-
}
|
|
11895
|
-
// Default groups.
|
|
11896
|
-
if (!accountId) {
|
|
11897
|
-
accountId = "";
|
|
11898
|
-
}
|
|
11899
|
-
const data = yield api.GET(`userGroupsByFeature/${accountId}/${perm}`, reqParams);
|
|
11900
|
-
return {
|
|
11901
|
-
groups: data.Items
|
|
11902
|
-
};
|
|
11903
|
-
});
|
|
11904
|
-
}
|
|
11905
|
-
UserGroup.GetListByPerm = GetListByPerm;
|
|
11906
|
-
/**
|
|
11907
|
-
* Returns all user groups for an account.
|
|
11908
|
-
* @param params
|
|
11909
|
-
* @returns
|
|
11910
|
-
*/
|
|
11911
|
-
function GetList(params) {
|
|
11912
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
11913
|
-
let { api, accountId, req: reqParams } = params;
|
|
11914
|
-
if (!api) {
|
|
11915
|
-
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
11916
|
-
}
|
|
11917
|
-
// Default groups.
|
|
11918
|
-
if (!accountId) {
|
|
11919
|
-
accountId = "";
|
|
11920
|
-
}
|
|
11921
|
-
const data = yield api.GET(`userGroups/${accountId}`, reqParams);
|
|
11922
|
-
return {
|
|
11923
|
-
groups: data.Items
|
|
11924
|
-
};
|
|
11925
|
-
});
|
|
11926
|
-
}
|
|
11927
|
-
UserGroup.GetList = GetList;
|
|
11928
|
-
/**
|
|
11929
|
-
* Deletes a user group.
|
|
11930
|
-
* @param params
|
|
11931
|
-
* @returns
|
|
11932
|
-
*/
|
|
11933
|
-
function Delete(params) {
|
|
11934
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
11935
|
-
let { api, accountId, groupId: id, req: reqParams } = params;
|
|
11936
|
-
if (!id) {
|
|
11937
|
-
throw ("ID is required.");
|
|
11938
|
-
}
|
|
11939
|
-
if (!api) {
|
|
11940
|
-
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
11941
|
-
}
|
|
11942
|
-
// Default groups.
|
|
11943
|
-
if (!accountId) {
|
|
11944
|
-
accountId = "";
|
|
11945
|
-
}
|
|
11946
|
-
return api.DELETE(`account/${accountId}/userGroupID/${id}`, reqParams);
|
|
11947
|
-
});
|
|
11948
|
-
}
|
|
11949
|
-
UserGroup.Delete = Delete;
|
|
11950
|
-
/**
|
|
11951
|
-
* Creates or updates a user group.
|
|
11952
|
-
* @param params
|
|
11953
|
-
* @returns
|
|
11954
|
-
*/
|
|
11955
|
-
function Update(params) {
|
|
11956
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
11957
|
-
let { api, group: data, reqParams } = params;
|
|
11958
|
-
if (!data.Name) {
|
|
11959
|
-
throw ("User group name is required.");
|
|
11960
|
-
}
|
|
11961
|
-
// Default groups.
|
|
11962
|
-
if (!data["ClientAccount.ID"]) {
|
|
11963
|
-
data["ClientAccount.ID"] = "";
|
|
11964
|
-
}
|
|
11965
|
-
if (!api) {
|
|
11966
|
-
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
11967
|
-
}
|
|
11968
|
-
const res = yield api.POST(`userGroup${data.ID ? ("/" + data.ID) : ""}`, data, reqParams);
|
|
11969
|
-
return {
|
|
11970
|
-
group: res
|
|
11971
|
-
};
|
|
11972
|
-
});
|
|
11973
|
-
}
|
|
11974
|
-
UserGroup.Update = Update;
|
|
11975
|
-
})(UserGroup || (UserGroup = {}));
|
|
11976
|
-
|
|
11977
11830
|
/**
|
|
11978
11831
|
* Describes the "User" concept within Nextspace.
|
|
11979
11832
|
* A user is either a login-user or an access-token.
|
|
@@ -11982,7 +11835,7 @@ var UserGroup;
|
|
|
11982
11835
|
* treated the same way in terms of permissions and user groups.
|
|
11983
11836
|
*/
|
|
11984
11837
|
var User;
|
|
11985
|
-
(function (User) {
|
|
11838
|
+
(function (User$$1) {
|
|
11986
11839
|
/**
|
|
11987
11840
|
* Available user types.
|
|
11988
11841
|
*/
|
|
@@ -11992,7 +11845,7 @@ var User;
|
|
|
11992
11845
|
EType["User"] = "LOGIN_USER";
|
|
11993
11846
|
// Access token. Used to gain access to related permissions.
|
|
11994
11847
|
EType["AccessToken"] = "ACCESS_TOKEN";
|
|
11995
|
-
})(EType = User.EType || (User.EType = {}));
|
|
11848
|
+
})(EType = User$$1.EType || (User$$1.EType = {}));
|
|
11996
11849
|
/**
|
|
11997
11850
|
* Gets a user record.
|
|
11998
11851
|
* @param params
|
|
@@ -12039,7 +11892,7 @@ var User;
|
|
|
12039
11892
|
return prom;
|
|
12040
11893
|
});
|
|
12041
11894
|
}
|
|
12042
|
-
User.Get = Get;
|
|
11895
|
+
User$$1.Get = Get;
|
|
12043
11896
|
/**
|
|
12044
11897
|
* Updates a user record.
|
|
12045
11898
|
* @param params
|
|
@@ -12081,7 +11934,37 @@ var User;
|
|
|
12081
11934
|
};
|
|
12082
11935
|
});
|
|
12083
11936
|
}
|
|
12084
|
-
User.Update = Update;
|
|
11937
|
+
User$$1.Update = Update;
|
|
11938
|
+
/**
|
|
11939
|
+
* Creates a user record.
|
|
11940
|
+
* This is not a user invitation, this creates a new user which you can then manage or invite yourself.
|
|
11941
|
+
* TODO: The user should be tied to the client account's client and not the global list.
|
|
11942
|
+
* @param params
|
|
11943
|
+
*/
|
|
11944
|
+
function Create(params) {
|
|
11945
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11946
|
+
let { api, user: data, req: reqParams } = params;
|
|
11947
|
+
if (!api) {
|
|
11948
|
+
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
11949
|
+
}
|
|
11950
|
+
if (data.Type == EType.AccessToken) {
|
|
11951
|
+
throw ("Access tokens cannot be created this way.");
|
|
11952
|
+
}
|
|
11953
|
+
if (!data.Type) {
|
|
11954
|
+
data.Type = EType.User;
|
|
11955
|
+
}
|
|
11956
|
+
if (!data.ID) {
|
|
11957
|
+
data.ID = ObjectUtils.UId();
|
|
11958
|
+
}
|
|
11959
|
+
const res = yield api.POST("user", data, reqParams);
|
|
11960
|
+
api.Cache.RemoveByContains(Api.ECacheKey.User + Api.ECacheKey.Id + data.ID);
|
|
11961
|
+
api.Cache.RemoveByStartsWith(Api.ECacheKey.User + Api.ECacheKey.Account);
|
|
11962
|
+
return {
|
|
11963
|
+
user: res
|
|
11964
|
+
};
|
|
11965
|
+
});
|
|
11966
|
+
}
|
|
11967
|
+
User$$1.Create = Create;
|
|
12085
11968
|
/**
|
|
12086
11969
|
* Loads settings for a given user + app.
|
|
12087
11970
|
* The session's account id is used to separate settings between accounts.
|
|
@@ -12130,7 +12013,7 @@ var User;
|
|
|
12130
12013
|
return prom;
|
|
12131
12014
|
});
|
|
12132
12015
|
}
|
|
12133
|
-
User.GetSettings = GetSettings;
|
|
12016
|
+
User$$1.GetSettings = GetSettings;
|
|
12134
12017
|
/**
|
|
12135
12018
|
* Updates settings for a given accId + user + app.
|
|
12136
12019
|
* The settings update will replace the existing record, please ensure to merge with existing settings.
|
|
@@ -12157,7 +12040,7 @@ var User;
|
|
|
12157
12040
|
return prom;
|
|
12158
12041
|
});
|
|
12159
12042
|
}
|
|
12160
|
-
User.UpdateSettings = UpdateSettings;
|
|
12043
|
+
User$$1.UpdateSettings = UpdateSettings;
|
|
12161
12044
|
/**
|
|
12162
12045
|
* Returns if a username is available.
|
|
12163
12046
|
* @param params
|
|
@@ -12187,7 +12070,7 @@ var User;
|
|
|
12187
12070
|
return prom;
|
|
12188
12071
|
});
|
|
12189
12072
|
}
|
|
12190
|
-
User.GetUsernameAvailable = GetUsernameAvailable;
|
|
12073
|
+
User$$1.GetUsernameAvailable = GetUsernameAvailable;
|
|
12191
12074
|
let LoginUser;
|
|
12192
12075
|
(function (LoginUser) {
|
|
12193
12076
|
/**
|
|
@@ -12198,10 +12081,18 @@ var User;
|
|
|
12198
12081
|
* api.Cache.Remove(key);
|
|
12199
12082
|
* }
|
|
12200
12083
|
* @param accountId
|
|
12084
|
+
* @param exclusive
|
|
12085
|
+
* @param search
|
|
12201
12086
|
* @returns
|
|
12202
12087
|
*/
|
|
12203
|
-
function GetListCacheKey(accountId) {
|
|
12204
|
-
|
|
12088
|
+
function GetListCacheKey(accountId, exclusive, search) {
|
|
12089
|
+
if (!exclusive) {
|
|
12090
|
+
exclusive = false;
|
|
12091
|
+
}
|
|
12092
|
+
if (!search) {
|
|
12093
|
+
search = "";
|
|
12094
|
+
}
|
|
12095
|
+
return Api.ECacheKey.User + Api.ECacheKey.Account + Api.ECacheKey.Id + accountId + Api.ECacheKey.Id + exclusive + Api.ECacheKey.Id + search;
|
|
12205
12096
|
}
|
|
12206
12097
|
LoginUser.GetListCacheKey = GetListCacheKey;
|
|
12207
12098
|
/**
|
|
@@ -12249,7 +12140,7 @@ var User;
|
|
|
12249
12140
|
*/
|
|
12250
12141
|
function GetList(params) {
|
|
12251
12142
|
return __awaiter(this, void 0, void 0, function* () {
|
|
12252
|
-
let { api, accountId, exclusive, req: reqParams } = params;
|
|
12143
|
+
let { api, accountId, exclusive, req: reqParams, search } = params;
|
|
12253
12144
|
if (!accountId) {
|
|
12254
12145
|
throw ("Client account ID is required.");
|
|
12255
12146
|
}
|
|
@@ -12259,13 +12150,24 @@ var User;
|
|
|
12259
12150
|
if (!exclusive) {
|
|
12260
12151
|
exclusive = false;
|
|
12261
12152
|
}
|
|
12262
|
-
const
|
|
12153
|
+
const cacheKey = GetListCacheKey(accountId, exclusive, search);
|
|
12154
|
+
const cache = exclusive ? null : api.GetCacheItem(cacheKey, reqParams);
|
|
12263
12155
|
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
12264
12156
|
return cache.data;
|
|
12265
12157
|
}
|
|
12266
12158
|
const req = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
12267
12159
|
try {
|
|
12268
|
-
const
|
|
12160
|
+
const urlParams = new URLSearchParams();
|
|
12161
|
+
if (accountId) {
|
|
12162
|
+
urlParams.append("clientAccountID", accountId);
|
|
12163
|
+
}
|
|
12164
|
+
if (search) {
|
|
12165
|
+
urlParams.append("search", search);
|
|
12166
|
+
}
|
|
12167
|
+
if (exclusive) {
|
|
12168
|
+
urlParams.append("allExcludingClientAccount", "true");
|
|
12169
|
+
}
|
|
12170
|
+
const data = yield api.GET(`users?${urlParams.toString()}`, reqParams);
|
|
12269
12171
|
res({
|
|
12270
12172
|
users: data.Items
|
|
12271
12173
|
});
|
|
@@ -12288,7 +12190,7 @@ var User;
|
|
|
12288
12190
|
}));
|
|
12289
12191
|
if (!exclusive) {
|
|
12290
12192
|
api.SetCacheItem({
|
|
12291
|
-
key:
|
|
12193
|
+
key: cacheKey,
|
|
12292
12194
|
value: req,
|
|
12293
12195
|
req: reqParams
|
|
12294
12196
|
});
|
|
@@ -12426,7 +12328,7 @@ var User;
|
|
|
12426
12328
|
});
|
|
12427
12329
|
}
|
|
12428
12330
|
LoginUser.ForgotPasswordComplete = ForgotPasswordComplete;
|
|
12429
|
-
})(LoginUser = User.LoginUser || (User.LoginUser = {}));
|
|
12331
|
+
})(LoginUser = User$$1.LoginUser || (User$$1.LoginUser = {}));
|
|
12430
12332
|
let AccessToken;
|
|
12431
12333
|
(function (AccessToken) {
|
|
12432
12334
|
/**
|
|
@@ -12522,7 +12424,27 @@ var User;
|
|
|
12522
12424
|
});
|
|
12523
12425
|
}
|
|
12524
12426
|
AccessToken.Create = Create;
|
|
12525
|
-
})(AccessToken = User.AccessToken || (User.AccessToken = {}));
|
|
12427
|
+
})(AccessToken = User$$1.AccessToken || (User$$1.AccessToken = {}));
|
|
12428
|
+
/**
|
|
12429
|
+
* Updates the password for a user by supplying the existing and new password.
|
|
12430
|
+
* @param params
|
|
12431
|
+
*/
|
|
12432
|
+
function UpdatePassword(params) {
|
|
12433
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
12434
|
+
let { userId, passwordCurrent, passwordNew, api, req } = params;
|
|
12435
|
+
if (!userId || !passwordCurrent || !passwordNew) {
|
|
12436
|
+
throw ("UserId, current password, and new password are required.");
|
|
12437
|
+
}
|
|
12438
|
+
if (!api) {
|
|
12439
|
+
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
12440
|
+
}
|
|
12441
|
+
return api.POST(`user/${userId}/setPassword`, {
|
|
12442
|
+
CurrentPassword: passwordCurrent,
|
|
12443
|
+
NewPassword: passwordNew
|
|
12444
|
+
}, req);
|
|
12445
|
+
});
|
|
12446
|
+
}
|
|
12447
|
+
User$$1.UpdatePassword = UpdatePassword;
|
|
12526
12448
|
/**
|
|
12527
12449
|
* Returns cache identifier for a user.
|
|
12528
12450
|
* Example: {
|
|
@@ -12540,7 +12462,7 @@ var User;
|
|
|
12540
12462
|
}
|
|
12541
12463
|
return Api.ECacheKey.User + Api.ECacheKey.Id + userId + Api.ECacheKey.Id + accountId;
|
|
12542
12464
|
}
|
|
12543
|
-
User.GetCacheKey = GetCacheKey;
|
|
12465
|
+
User$$1.GetCacheKey = GetCacheKey;
|
|
12544
12466
|
/**
|
|
12545
12467
|
* Returns cache identifier for a user.
|
|
12546
12468
|
* Example: {
|
|
@@ -12558,7 +12480,7 @@ var User;
|
|
|
12558
12480
|
}
|
|
12559
12481
|
return Api.ECacheKey.User + Api.ECacheKey.UserEmail + email + Api.ECacheKey.Id + accountId;
|
|
12560
12482
|
}
|
|
12561
|
-
User.GetEmailCacheKey = GetEmailCacheKey;
|
|
12483
|
+
User$$1.GetEmailCacheKey = GetEmailCacheKey;
|
|
12562
12484
|
/**
|
|
12563
12485
|
* Returns cache identifier for a user's settings.
|
|
12564
12486
|
* Example: {
|
|
@@ -12573,9 +12495,214 @@ var User;
|
|
|
12573
12495
|
function GetSettingsCacheKey(userId, appId) {
|
|
12574
12496
|
return Api.ECacheKey.User + Api.ECacheKey.UserSettings + userId + Api.ECacheKey.Id + appId;
|
|
12575
12497
|
}
|
|
12576
|
-
User.GetSettingsCacheKey = GetSettingsCacheKey;
|
|
12498
|
+
User$$1.GetSettingsCacheKey = GetSettingsCacheKey;
|
|
12577
12499
|
})(User || (User = {}));
|
|
12578
12500
|
|
|
12501
|
+
/**
|
|
12502
|
+
* Describes the "User Group" concept within Nextspace.
|
|
12503
|
+
* A user group is a collection of permissions ("Features") and what users should be in the group.
|
|
12504
|
+
*/
|
|
12505
|
+
var UserGroup;
|
|
12506
|
+
(function (UserGroup) {
|
|
12507
|
+
/**
|
|
12508
|
+
* Returns a user group by its name.
|
|
12509
|
+
* @param params
|
|
12510
|
+
* @returns
|
|
12511
|
+
*/
|
|
12512
|
+
function GetByName(params) {
|
|
12513
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
12514
|
+
let { api, accountId, name, req: reqParams } = params;
|
|
12515
|
+
if (!name) {
|
|
12516
|
+
throw ("Name is required.");
|
|
12517
|
+
}
|
|
12518
|
+
if (!api) {
|
|
12519
|
+
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
12520
|
+
}
|
|
12521
|
+
// Default groups.
|
|
12522
|
+
if (!accountId) {
|
|
12523
|
+
accountId = "";
|
|
12524
|
+
}
|
|
12525
|
+
const data = yield api.GET(`account/${accountId}/userGroupByName/${name}`, reqParams);
|
|
12526
|
+
return {
|
|
12527
|
+
group: data
|
|
12528
|
+
};
|
|
12529
|
+
});
|
|
12530
|
+
}
|
|
12531
|
+
UserGroup.GetByName = GetByName;
|
|
12532
|
+
/**
|
|
12533
|
+
* Returns all users in a user group.
|
|
12534
|
+
* @param params
|
|
12535
|
+
* @returns
|
|
12536
|
+
*/
|
|
12537
|
+
function GetUsers(params) {
|
|
12538
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
12539
|
+
let { api, accountId, groupId: id, req: reqParams } = params;
|
|
12540
|
+
if (!id) {
|
|
12541
|
+
throw ("ID is required.");
|
|
12542
|
+
}
|
|
12543
|
+
if (!api) {
|
|
12544
|
+
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
12545
|
+
}
|
|
12546
|
+
// Default groups.
|
|
12547
|
+
if (!accountId) {
|
|
12548
|
+
accountId = "";
|
|
12549
|
+
}
|
|
12550
|
+
const data = yield api.GET(`userGroup/${accountId}/${id}/users`, reqParams);
|
|
12551
|
+
return {
|
|
12552
|
+
users: data.Items
|
|
12553
|
+
};
|
|
12554
|
+
});
|
|
12555
|
+
}
|
|
12556
|
+
UserGroup.GetUsers = GetUsers;
|
|
12557
|
+
/**
|
|
12558
|
+
* Returns list of user groups that have a specific permission enabled.
|
|
12559
|
+
* @param params
|
|
12560
|
+
* @returns
|
|
12561
|
+
*/
|
|
12562
|
+
function GetListByPerm(params) {
|
|
12563
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
12564
|
+
let { api, accountId, perm, req: reqParams } = params;
|
|
12565
|
+
if (!perm) {
|
|
12566
|
+
throw ("Perm is required.");
|
|
12567
|
+
}
|
|
12568
|
+
if (!api) {
|
|
12569
|
+
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
12570
|
+
}
|
|
12571
|
+
// Default groups.
|
|
12572
|
+
if (!accountId) {
|
|
12573
|
+
accountId = "";
|
|
12574
|
+
}
|
|
12575
|
+
const data = yield api.GET(`userGroupsByFeature/${accountId}/${perm}`, reqParams);
|
|
12576
|
+
return {
|
|
12577
|
+
groups: data.Items
|
|
12578
|
+
};
|
|
12579
|
+
});
|
|
12580
|
+
}
|
|
12581
|
+
UserGroup.GetListByPerm = GetListByPerm;
|
|
12582
|
+
/**
|
|
12583
|
+
* Returns all user groups for an account.
|
|
12584
|
+
* @param params
|
|
12585
|
+
* @returns
|
|
12586
|
+
*/
|
|
12587
|
+
function GetList(params) {
|
|
12588
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
12589
|
+
let { api, accountId, req: reqParams } = params;
|
|
12590
|
+
if (!api) {
|
|
12591
|
+
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
12592
|
+
}
|
|
12593
|
+
// Default groups.
|
|
12594
|
+
if (!accountId) {
|
|
12595
|
+
accountId = "";
|
|
12596
|
+
}
|
|
12597
|
+
const data = yield api.GET(`userGroups/${accountId}`, reqParams);
|
|
12598
|
+
return {
|
|
12599
|
+
groups: data.Items
|
|
12600
|
+
};
|
|
12601
|
+
});
|
|
12602
|
+
}
|
|
12603
|
+
UserGroup.GetList = GetList;
|
|
12604
|
+
/**
|
|
12605
|
+
* Deletes a user group.
|
|
12606
|
+
* @param params
|
|
12607
|
+
* @returns
|
|
12608
|
+
*/
|
|
12609
|
+
function Delete(params) {
|
|
12610
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
12611
|
+
let { api, accountId, groupId: id, req: reqParams } = params;
|
|
12612
|
+
if (!id) {
|
|
12613
|
+
throw ("ID is required.");
|
|
12614
|
+
}
|
|
12615
|
+
if (!api) {
|
|
12616
|
+
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
12617
|
+
}
|
|
12618
|
+
// Default groups.
|
|
12619
|
+
if (!accountId) {
|
|
12620
|
+
accountId = "";
|
|
12621
|
+
}
|
|
12622
|
+
return api.DELETE(`account/${accountId}/userGroupID/${id}`, reqParams);
|
|
12623
|
+
});
|
|
12624
|
+
}
|
|
12625
|
+
UserGroup.Delete = Delete;
|
|
12626
|
+
/**
|
|
12627
|
+
* Creates or updates a user group.
|
|
12628
|
+
* @param params
|
|
12629
|
+
* @returns
|
|
12630
|
+
*/
|
|
12631
|
+
function Update(params) {
|
|
12632
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
12633
|
+
let { api, group: data, reqParams } = params;
|
|
12634
|
+
if (!data.Name) {
|
|
12635
|
+
throw ("User group name is required.");
|
|
12636
|
+
}
|
|
12637
|
+
// Default groups.
|
|
12638
|
+
if (!data["ClientAccount.ID"]) {
|
|
12639
|
+
data["ClientAccount.ID"] = "";
|
|
12640
|
+
}
|
|
12641
|
+
if (!api) {
|
|
12642
|
+
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
12643
|
+
}
|
|
12644
|
+
const res = yield api.POST(`userGroup${data.ID ? ("/" + data.ID) : ""}`, data, reqParams);
|
|
12645
|
+
return {
|
|
12646
|
+
group: res
|
|
12647
|
+
};
|
|
12648
|
+
});
|
|
12649
|
+
}
|
|
12650
|
+
UserGroup.Update = Update;
|
|
12651
|
+
/**
|
|
12652
|
+
* Adds a user to specified groups.
|
|
12653
|
+
* @param params
|
|
12654
|
+
* @returns
|
|
12655
|
+
*/
|
|
12656
|
+
function AddUser(params) {
|
|
12657
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
12658
|
+
let { api, userId, groupIds, accountId, req: reqParams } = params;
|
|
12659
|
+
if (!userId) {
|
|
12660
|
+
throw ("User ID is required.");
|
|
12661
|
+
}
|
|
12662
|
+
if (!(groupIds === null || groupIds === void 0 ? void 0 : groupIds.length)) {
|
|
12663
|
+
throw ("At least one group ID is required.");
|
|
12664
|
+
}
|
|
12665
|
+
if (!accountId) {
|
|
12666
|
+
accountId = "";
|
|
12667
|
+
}
|
|
12668
|
+
if (!api) {
|
|
12669
|
+
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
12670
|
+
}
|
|
12671
|
+
yield api.POST(`user/${userId}/account/${accountId}/addToGroups`, {
|
|
12672
|
+
UserGroups: groupIds
|
|
12673
|
+
}, reqParams);
|
|
12674
|
+
api.Cache.RemoveByContains(User.GetCacheKey(userId, accountId));
|
|
12675
|
+
});
|
|
12676
|
+
}
|
|
12677
|
+
UserGroup.AddUser = AddUser;
|
|
12678
|
+
/**
|
|
12679
|
+
* Removes a user from specified groups.
|
|
12680
|
+
* @param params
|
|
12681
|
+
*/
|
|
12682
|
+
function RemoveUser(params) {
|
|
12683
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
12684
|
+
let { api, userId, groupIds, accountId, req: reqParams } = params;
|
|
12685
|
+
if (!userId) {
|
|
12686
|
+
throw ("User ID is required.");
|
|
12687
|
+
}
|
|
12688
|
+
if (!(groupIds === null || groupIds === void 0 ? void 0 : groupIds.length)) {
|
|
12689
|
+
throw ("At least one group ID is required.");
|
|
12690
|
+
}
|
|
12691
|
+
if (!accountId) {
|
|
12692
|
+
accountId = "";
|
|
12693
|
+
}
|
|
12694
|
+
if (!api) {
|
|
12695
|
+
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
12696
|
+
}
|
|
12697
|
+
yield api.POST(`user/${userId}/account/${accountId}/removeFromGroups`, {
|
|
12698
|
+
UserGroups: groupIds
|
|
12699
|
+
}, reqParams);
|
|
12700
|
+
api.Cache.RemoveByContains(User.GetCacheKey(userId, accountId));
|
|
12701
|
+
});
|
|
12702
|
+
}
|
|
12703
|
+
UserGroup.RemoveUser = RemoveUser;
|
|
12704
|
+
})(UserGroup || (UserGroup = {}));
|
|
12705
|
+
|
|
12579
12706
|
/**
|
|
12580
12707
|
* An account-invite is an invitation to a user to join a client account.
|
|
12581
12708
|
* New users to Nextspace will setup their user account within the invitation process.
|
|
@@ -13400,6 +13527,115 @@ var AccountLimits;
|
|
|
13400
13527
|
AccountLimits$$1.GetLimitsCacheKey = GetLimitsCacheKey;
|
|
13401
13528
|
})(AccountLimits || (AccountLimits = {}));
|
|
13402
13529
|
|
|
13530
|
+
/**
|
|
13531
|
+
* Account templates are templates for sending emails to users.
|
|
13532
|
+
* In the future it might also be tied to other communication, eg: SMS.
|
|
13533
|
+
* When a template is not found then our hypeportal ones will be used as a fallback.
|
|
13534
|
+
*/
|
|
13535
|
+
var AccountTemplate;
|
|
13536
|
+
(function (AccountTemplate) {
|
|
13537
|
+
/**
|
|
13538
|
+
* Known keywords that will be substituted in the template.
|
|
13539
|
+
* A keyword must be surrounded by ${blah} in the template.
|
|
13540
|
+
*/
|
|
13541
|
+
let EKeyword;
|
|
13542
|
+
(function (EKeyword) {
|
|
13543
|
+
EKeyword["AccountName"] = "ClientAccount.Name";
|
|
13544
|
+
EKeyword["InvitedByUserName"] = "InvitedBy.User.FullName";
|
|
13545
|
+
EKeyword["InvitedUserName"] = "Invited.User.FullName";
|
|
13546
|
+
EKeyword["URL"] = "URL";
|
|
13547
|
+
EKeyword["ActivationCode"] = "ActivationCode";
|
|
13548
|
+
})(EKeyword = AccountTemplate.EKeyword || (AccountTemplate.EKeyword = {}));
|
|
13549
|
+
function GetList(params) {
|
|
13550
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
13551
|
+
let { accountId, api, req } = params;
|
|
13552
|
+
if (!accountId) {
|
|
13553
|
+
throw new Error("accountId is required");
|
|
13554
|
+
}
|
|
13555
|
+
if (!api) {
|
|
13556
|
+
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
13557
|
+
}
|
|
13558
|
+
const data = yield api.GET(`templates/${accountId}`, Api.PrepReqParams(req));
|
|
13559
|
+
return {
|
|
13560
|
+
templates: data.Items
|
|
13561
|
+
};
|
|
13562
|
+
});
|
|
13563
|
+
}
|
|
13564
|
+
AccountTemplate.GetList = GetList;
|
|
13565
|
+
function Get(params) {
|
|
13566
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
13567
|
+
let { key, accountId, api, req } = params;
|
|
13568
|
+
if (!accountId) {
|
|
13569
|
+
throw new Error("accountId is required");
|
|
13570
|
+
}
|
|
13571
|
+
if (!api) {
|
|
13572
|
+
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
13573
|
+
}
|
|
13574
|
+
const data = yield api.GET(`template/${accountId}/${key}`, Api.PrepReqParams(req));
|
|
13575
|
+
return {
|
|
13576
|
+
template: data
|
|
13577
|
+
};
|
|
13578
|
+
});
|
|
13579
|
+
}
|
|
13580
|
+
AccountTemplate.Get = Get;
|
|
13581
|
+
function Update(params) {
|
|
13582
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
13583
|
+
let { template, api, req } = params;
|
|
13584
|
+
if (!(template === null || template === void 0 ? void 0 : template["ClientAccount.ID"])) {
|
|
13585
|
+
throw new Error("ClientAccount.ID is required");
|
|
13586
|
+
}
|
|
13587
|
+
if (!(template === null || template === void 0 ? void 0 : template.Key)) {
|
|
13588
|
+
throw new Error("Key is required");
|
|
13589
|
+
}
|
|
13590
|
+
if (!api) {
|
|
13591
|
+
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
13592
|
+
}
|
|
13593
|
+
const data = yield api.POST(`template/${template["ClientAccount.ID"]}/${template.Key}`, template, Api.PrepReqParams(req));
|
|
13594
|
+
return {
|
|
13595
|
+
template: data
|
|
13596
|
+
};
|
|
13597
|
+
});
|
|
13598
|
+
}
|
|
13599
|
+
AccountTemplate.Update = Update;
|
|
13600
|
+
function Delete(params) {
|
|
13601
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
13602
|
+
let { key, accountId, api, req } = params;
|
|
13603
|
+
if (!accountId) {
|
|
13604
|
+
throw new Error("accountId is required");
|
|
13605
|
+
}
|
|
13606
|
+
if (!key) {
|
|
13607
|
+
throw new Error("key is required");
|
|
13608
|
+
}
|
|
13609
|
+
if (!api) {
|
|
13610
|
+
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
13611
|
+
}
|
|
13612
|
+
yield api.DELETE(`template/${accountId}/${key}`, Api.PrepReqParams(req));
|
|
13613
|
+
});
|
|
13614
|
+
}
|
|
13615
|
+
AccountTemplate.Delete = Delete;
|
|
13616
|
+
})(AccountTemplate || (AccountTemplate = {}));
|
|
13617
|
+
|
|
13618
|
+
/**
|
|
13619
|
+
* An account type dictates limitations and available features.
|
|
13620
|
+
* Eg: how many Entities an account can have.
|
|
13621
|
+
*/
|
|
13622
|
+
var AccountType;
|
|
13623
|
+
(function (AccountType) {
|
|
13624
|
+
function GetList(params) {
|
|
13625
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
13626
|
+
let { api, req } = params;
|
|
13627
|
+
if (!api) {
|
|
13628
|
+
api = ENVIRONMENT.Api().GetGuardianApi();
|
|
13629
|
+
}
|
|
13630
|
+
const data = yield api.GET("accountTypes", Api.PrepReqParams(req));
|
|
13631
|
+
return {
|
|
13632
|
+
types: data.Items
|
|
13633
|
+
};
|
|
13634
|
+
});
|
|
13635
|
+
}
|
|
13636
|
+
AccountType.GetList = GetList;
|
|
13637
|
+
})(AccountType || (AccountType = {}));
|
|
13638
|
+
|
|
13403
13639
|
var EncryptUtils;
|
|
13404
13640
|
(function (EncryptUtils) {
|
|
13405
13641
|
// https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript
|
|
@@ -14758,7 +14994,7 @@ var DataSource;
|
|
|
14758
14994
|
})(DataSource || (DataSource = {}));
|
|
14759
14995
|
|
|
14760
14996
|
// This is updated with the package.json version on build.
|
|
14761
|
-
const VERSION = "5.4.
|
|
14997
|
+
const VERSION = "5.4.6";
|
|
14762
14998
|
|
|
14763
|
-
export { VERSION, AnnDocument, CustomForm, AbstractApi, Api, BruceApi, GlobalApi, GuardianApi, ApiGetters, Calculator, Bounds, BruceEvent, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, Geometry, UTC, BruceVariable, LRUCache, GeoJson, EntityAttachmentType, EntityAttachment, EntityComment, EntityLink, EntityLod, EntityLodCategory, EntityRelationType, EntityRelation, EntitySource, EntityTag, EntityType, Entity, EntityCoords, EntityTypeVisualSettings, EntityAttribute, EntityHistoricData, EntityTableView, Comment, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, ProjectViewLegacyTile, ProjectViewTile, ProjectViewLegacy, ProjectViewLegacyBookmark, PendingAction, MessageBroker, HostingLocation, Style, Tileset, Permission, Session, UserGroup, User, Account, AccountInvite, AccountFeatures, AccountLimits, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, DataLab, DataLabGroup, ImportAssembly, ImportCad, ImportCsv, ImportJson, ImportGeoJson, ImportKml, ImportedFile, ExportBrz, ExportUsd, Markup, Uploader, Plugin, ENVIRONMENT, DataSource };
|
|
14999
|
+
export { VERSION, AnnDocument, CustomForm, AbstractApi, Api, BruceApi, GlobalApi, GuardianApi, ApiGetters, Calculator, Bounds, BruceEvent, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, Geometry, UTC, BruceVariable, LRUCache, GeoJson, EntityAttachmentType, EntityAttachment, EntityComment, EntityLink, EntityLod, EntityLodCategory, EntityRelationType, EntityRelation, EntitySource, EntityTag, EntityType, Entity, EntityCoords, EntityTypeVisualSettings, EntityAttribute, EntityHistoricData, EntityTableView, Comment, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, ProjectViewLegacyTile, ProjectViewTile, ProjectViewLegacy, ProjectViewLegacyBookmark, PendingAction, MessageBroker, HostingLocation, Style, Tileset, Permission, Session, UserGroup, User, Account, AccountInvite, AccountFeatures, AccountLimits, AccountTemplate, AccountType, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, DataLab, DataLabGroup, ImportAssembly, ImportCad, ImportCsv, ImportJson, ImportGeoJson, ImportKml, ImportedFile, ExportBrz, ExportUsd, Markup, Uploader, Plugin, ENVIRONMENT, DataSource };
|
|
14764
15000
|
//# sourceMappingURL=bruce-models.es5.js.map
|