bruce-models 5.4.5 → 5.4.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.
@@ -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
- let full = wsProtocol + "://" + currentUrl.host + currentUrl.pathname + "websocket";
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) {
@@ -11035,6 +11037,7 @@ var Account;
11035
11037
  EAppId["BruceApi"] = "BruceAPI";
11036
11038
  EAppId["Navigator"] = "Navigator";
11037
11039
  EAppId["Operator"] = "BruceClientAdmin";
11040
+ EAppId["UI"] = "UI";
11038
11041
  })(EAppId = Account.EAppId || (Account.EAppId = {}));
11039
11042
  /**
11040
11043
  * Possible starter content options.
@@ -11138,15 +11141,15 @@ var Account;
11138
11141
  */
11139
11142
  function GetRelatedList(params) {
11140
11143
  return __awaiter(this, void 0, void 0, function* () {
11141
- let { api, req: reqParams } = params;
11144
+ let { api, req: reqParams, owned } = params;
11142
11145
  if (!api) {
11143
11146
  api = ENVIRONMENT.Api().GetGuardianApi();
11144
11147
  }
11145
- const cache = api.GetCacheItem(GetListCacheKey(api.GetSessionId()), reqParams);
11148
+ const cache = api.GetCacheItem(GetListCacheKey(api.GetSessionId(), owned), reqParams);
11146
11149
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
11147
11150
  return cache.data;
11148
11151
  }
11149
- const req = api.GET("user/relatedClientAccounts", reqParams);
11152
+ const req = api.GET(owned ? "user/ownedClientAccounts" : "user/relatedClientAccounts", reqParams);
11150
11153
  const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
11151
11154
  try {
11152
11155
  const data = yield req;
@@ -11160,7 +11163,7 @@ var Account;
11160
11163
  }
11161
11164
  }));
11162
11165
  api.SetCacheItem({
11163
- key: GetListCacheKey(api.GetSessionId()),
11166
+ key: GetListCacheKey(api.GetSessionId(), owned),
11164
11167
  value: prom,
11165
11168
  req: reqParams
11166
11169
  });
@@ -11252,7 +11255,7 @@ var Account;
11252
11255
  const resData = {
11253
11256
  account: res
11254
11257
  };
11255
- api.Cache.Remove(GetListCacheKey(api.GetSessionId()));
11258
+ api.Cache.RemoveByStartsWith(GetListCacheKey(api.GetSessionId()));
11256
11259
  return resData;
11257
11260
  });
11258
11261
  }
@@ -11306,8 +11309,11 @@ var Account;
11306
11309
  * @param ssid
11307
11310
  * @returns
11308
11311
  */
11309
- function GetListCacheKey(ssid) {
11310
- return Api.ECacheKey.Account + Api.ECacheKey.Session + Api.ECacheKey.Id + ssid;
11312
+ function GetListCacheKey(ssid, owned) {
11313
+ if (!owned) {
11314
+ owned = false;
11315
+ }
11316
+ return Api.ECacheKey.Account + Api.ECacheKey.Session + Api.ECacheKey.Id + ssid + Api.ECacheKey.Id + (owned ? "owned" : "related");
11311
11317
  }
11312
11318
  Account.GetListCacheKey = GetListCacheKey;
11313
11319
  /**
@@ -11822,158 +11828,6 @@ var Session;
11822
11828
  }
11823
11829
  })(Session || (Session = {}));
11824
11830
 
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
11831
  /**
11978
11832
  * Describes the "User" concept within Nextspace.
11979
11833
  * A user is either a login-user or an access-token.
@@ -11982,7 +11836,7 @@ var UserGroup;
11982
11836
  * treated the same way in terms of permissions and user groups.
11983
11837
  */
11984
11838
  var User;
11985
- (function (User) {
11839
+ (function (User$$1) {
11986
11840
  /**
11987
11841
  * Available user types.
11988
11842
  */
@@ -11992,7 +11846,7 @@ var User;
11992
11846
  EType["User"] = "LOGIN_USER";
11993
11847
  // Access token. Used to gain access to related permissions.
11994
11848
  EType["AccessToken"] = "ACCESS_TOKEN";
11995
- })(EType = User.EType || (User.EType = {}));
11849
+ })(EType = User$$1.EType || (User$$1.EType = {}));
11996
11850
  /**
11997
11851
  * Gets a user record.
11998
11852
  * @param params
@@ -12039,7 +11893,7 @@ var User;
12039
11893
  return prom;
12040
11894
  });
12041
11895
  }
12042
- User.Get = Get;
11896
+ User$$1.Get = Get;
12043
11897
  /**
12044
11898
  * Updates a user record.
12045
11899
  * @param params
@@ -12081,7 +11935,37 @@ var User;
12081
11935
  };
12082
11936
  });
12083
11937
  }
12084
- User.Update = Update;
11938
+ User$$1.Update = Update;
11939
+ /**
11940
+ * Creates a user record.
11941
+ * This is not a user invitation, this creates a new user which you can then manage or invite yourself.
11942
+ * TODO: The user should be tied to the client account's client and not the global list.
11943
+ * @param params
11944
+ */
11945
+ function Create(params) {
11946
+ return __awaiter(this, void 0, void 0, function* () {
11947
+ let { api, user: data, req: reqParams } = params;
11948
+ if (!api) {
11949
+ api = ENVIRONMENT.Api().GetGuardianApi();
11950
+ }
11951
+ if (data.Type == EType.AccessToken) {
11952
+ throw ("Access tokens cannot be created this way.");
11953
+ }
11954
+ if (!data.Type) {
11955
+ data.Type = EType.User;
11956
+ }
11957
+ if (!data.ID) {
11958
+ data.ID = ObjectUtils.UId();
11959
+ }
11960
+ const res = yield api.POST("user", data, reqParams);
11961
+ api.Cache.RemoveByContains(Api.ECacheKey.User + Api.ECacheKey.Id + data.ID);
11962
+ api.Cache.RemoveByStartsWith(Api.ECacheKey.User + Api.ECacheKey.Account);
11963
+ return {
11964
+ user: res
11965
+ };
11966
+ });
11967
+ }
11968
+ User$$1.Create = Create;
12085
11969
  /**
12086
11970
  * Loads settings for a given user + app.
12087
11971
  * The session's account id is used to separate settings between accounts.
@@ -12130,7 +12014,7 @@ var User;
12130
12014
  return prom;
12131
12015
  });
12132
12016
  }
12133
- User.GetSettings = GetSettings;
12017
+ User$$1.GetSettings = GetSettings;
12134
12018
  /**
12135
12019
  * Updates settings for a given accId + user + app.
12136
12020
  * The settings update will replace the existing record, please ensure to merge with existing settings.
@@ -12157,7 +12041,7 @@ var User;
12157
12041
  return prom;
12158
12042
  });
12159
12043
  }
12160
- User.UpdateSettings = UpdateSettings;
12044
+ User$$1.UpdateSettings = UpdateSettings;
12161
12045
  /**
12162
12046
  * Returns if a username is available.
12163
12047
  * @param params
@@ -12187,7 +12071,7 @@ var User;
12187
12071
  return prom;
12188
12072
  });
12189
12073
  }
12190
- User.GetUsernameAvailable = GetUsernameAvailable;
12074
+ User$$1.GetUsernameAvailable = GetUsernameAvailable;
12191
12075
  let LoginUser;
12192
12076
  (function (LoginUser) {
12193
12077
  /**
@@ -12198,10 +12082,18 @@ var User;
12198
12082
  * api.Cache.Remove(key);
12199
12083
  * }
12200
12084
  * @param accountId
12085
+ * @param exclusive
12086
+ * @param search
12201
12087
  * @returns
12202
12088
  */
12203
- function GetListCacheKey(accountId) {
12204
- return Api.ECacheKey.User + Api.ECacheKey.Account + Api.ECacheKey.Id + accountId;
12089
+ function GetListCacheKey(accountId, exclusive, search) {
12090
+ if (!exclusive) {
12091
+ exclusive = false;
12092
+ }
12093
+ if (!search) {
12094
+ search = "";
12095
+ }
12096
+ return Api.ECacheKey.User + Api.ECacheKey.Account + Api.ECacheKey.Id + accountId + Api.ECacheKey.Id + exclusive + Api.ECacheKey.Id + search;
12205
12097
  }
12206
12098
  LoginUser.GetListCacheKey = GetListCacheKey;
12207
12099
  /**
@@ -12249,23 +12141,31 @@ var User;
12249
12141
  */
12250
12142
  function GetList(params) {
12251
12143
  return __awaiter(this, void 0, void 0, function* () {
12252
- let { api, accountId, exclusive, req: reqParams } = params;
12253
- if (!accountId) {
12254
- throw ("Client account ID is required.");
12255
- }
12144
+ let { api, accountId, exclusive, req: reqParams, search } = params;
12256
12145
  if (!api) {
12257
12146
  api = ENVIRONMENT.Api().GetGuardianApi();
12258
12147
  }
12259
12148
  if (!exclusive) {
12260
12149
  exclusive = false;
12261
12150
  }
12262
- const cache = exclusive ? null : api.GetCacheItem(GetListCacheKey(accountId), reqParams);
12151
+ const cacheKey = GetListCacheKey(accountId, exclusive, search);
12152
+ const cache = exclusive ? null : api.GetCacheItem(cacheKey, reqParams);
12263
12153
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
12264
12154
  return cache.data;
12265
12155
  }
12266
12156
  const req = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
12267
12157
  try {
12268
- const data = yield api.GET(`users?clientAccountID=${accountId}${exclusive ? "&allExcludingClientAccount=true" : ""}`, reqParams);
12158
+ const urlParams = new URLSearchParams();
12159
+ if (accountId) {
12160
+ urlParams.append("clientAccountID", accountId);
12161
+ }
12162
+ if (search) {
12163
+ urlParams.append("search", search);
12164
+ }
12165
+ if (exclusive) {
12166
+ urlParams.append("allExcludingClientAccount", "true");
12167
+ }
12168
+ const data = yield api.GET(`users?${urlParams.toString()}`, reqParams);
12269
12169
  res({
12270
12170
  users: data.Items
12271
12171
  });
@@ -12288,7 +12188,7 @@ var User;
12288
12188
  }));
12289
12189
  if (!exclusive) {
12290
12190
  api.SetCacheItem({
12291
- key: GetListCacheKey(accountId),
12191
+ key: cacheKey,
12292
12192
  value: req,
12293
12193
  req: reqParams
12294
12194
  });
@@ -12426,7 +12326,7 @@ var User;
12426
12326
  });
12427
12327
  }
12428
12328
  LoginUser.ForgotPasswordComplete = ForgotPasswordComplete;
12429
- })(LoginUser = User.LoginUser || (User.LoginUser = {}));
12329
+ })(LoginUser = User$$1.LoginUser || (User$$1.LoginUser = {}));
12430
12330
  let AccessToken;
12431
12331
  (function (AccessToken) {
12432
12332
  /**
@@ -12522,7 +12422,27 @@ var User;
12522
12422
  });
12523
12423
  }
12524
12424
  AccessToken.Create = Create;
12525
- })(AccessToken = User.AccessToken || (User.AccessToken = {}));
12425
+ })(AccessToken = User$$1.AccessToken || (User$$1.AccessToken = {}));
12426
+ /**
12427
+ * Updates the password for a user by supplying the existing and new password.
12428
+ * @param params
12429
+ */
12430
+ function UpdatePassword(params) {
12431
+ return __awaiter(this, void 0, void 0, function* () {
12432
+ let { userId, passwordCurrent, passwordNew, api, req } = params;
12433
+ if (!userId || !passwordCurrent || !passwordNew) {
12434
+ throw ("UserId, current password, and new password are required.");
12435
+ }
12436
+ if (!api) {
12437
+ api = ENVIRONMENT.Api().GetGuardianApi();
12438
+ }
12439
+ return api.POST(`user/${userId}/setPassword`, {
12440
+ CurrentPassword: passwordCurrent,
12441
+ NewPassword: passwordNew
12442
+ }, req);
12443
+ });
12444
+ }
12445
+ User$$1.UpdatePassword = UpdatePassword;
12526
12446
  /**
12527
12447
  * Returns cache identifier for a user.
12528
12448
  * Example: {
@@ -12540,7 +12460,7 @@ var User;
12540
12460
  }
12541
12461
  return Api.ECacheKey.User + Api.ECacheKey.Id + userId + Api.ECacheKey.Id + accountId;
12542
12462
  }
12543
- User.GetCacheKey = GetCacheKey;
12463
+ User$$1.GetCacheKey = GetCacheKey;
12544
12464
  /**
12545
12465
  * Returns cache identifier for a user.
12546
12466
  * Example: {
@@ -12558,7 +12478,7 @@ var User;
12558
12478
  }
12559
12479
  return Api.ECacheKey.User + Api.ECacheKey.UserEmail + email + Api.ECacheKey.Id + accountId;
12560
12480
  }
12561
- User.GetEmailCacheKey = GetEmailCacheKey;
12481
+ User$$1.GetEmailCacheKey = GetEmailCacheKey;
12562
12482
  /**
12563
12483
  * Returns cache identifier for a user's settings.
12564
12484
  * Example: {
@@ -12573,9 +12493,214 @@ var User;
12573
12493
  function GetSettingsCacheKey(userId, appId) {
12574
12494
  return Api.ECacheKey.User + Api.ECacheKey.UserSettings + userId + Api.ECacheKey.Id + appId;
12575
12495
  }
12576
- User.GetSettingsCacheKey = GetSettingsCacheKey;
12496
+ User$$1.GetSettingsCacheKey = GetSettingsCacheKey;
12577
12497
  })(User || (User = {}));
12578
12498
 
12499
+ /**
12500
+ * Describes the "User Group" concept within Nextspace.
12501
+ * A user group is a collection of permissions ("Features") and what users should be in the group.
12502
+ */
12503
+ var UserGroup;
12504
+ (function (UserGroup) {
12505
+ /**
12506
+ * Returns a user group by its name.
12507
+ * @param params
12508
+ * @returns
12509
+ */
12510
+ function GetByName(params) {
12511
+ return __awaiter(this, void 0, void 0, function* () {
12512
+ let { api, accountId, name, req: reqParams } = params;
12513
+ if (!name) {
12514
+ throw ("Name is required.");
12515
+ }
12516
+ if (!api) {
12517
+ api = ENVIRONMENT.Api().GetGuardianApi();
12518
+ }
12519
+ // Default groups.
12520
+ if (!accountId) {
12521
+ accountId = "";
12522
+ }
12523
+ const data = yield api.GET(`account/${accountId}/userGroupByName/${name}`, reqParams);
12524
+ return {
12525
+ group: data
12526
+ };
12527
+ });
12528
+ }
12529
+ UserGroup.GetByName = GetByName;
12530
+ /**
12531
+ * Returns all users in a user group.
12532
+ * @param params
12533
+ * @returns
12534
+ */
12535
+ function GetUsers(params) {
12536
+ return __awaiter(this, void 0, void 0, function* () {
12537
+ let { api, accountId, groupId: id, req: reqParams } = params;
12538
+ if (!id) {
12539
+ throw ("ID is required.");
12540
+ }
12541
+ if (!api) {
12542
+ api = ENVIRONMENT.Api().GetGuardianApi();
12543
+ }
12544
+ // Default groups.
12545
+ if (!accountId) {
12546
+ accountId = "";
12547
+ }
12548
+ const data = yield api.GET(`userGroup/${accountId}/${id}/users`, reqParams);
12549
+ return {
12550
+ users: data.Items
12551
+ };
12552
+ });
12553
+ }
12554
+ UserGroup.GetUsers = GetUsers;
12555
+ /**
12556
+ * Returns list of user groups that have a specific permission enabled.
12557
+ * @param params
12558
+ * @returns
12559
+ */
12560
+ function GetListByPerm(params) {
12561
+ return __awaiter(this, void 0, void 0, function* () {
12562
+ let { api, accountId, perm, req: reqParams } = params;
12563
+ if (!perm) {
12564
+ throw ("Perm is required.");
12565
+ }
12566
+ if (!api) {
12567
+ api = ENVIRONMENT.Api().GetGuardianApi();
12568
+ }
12569
+ // Default groups.
12570
+ if (!accountId) {
12571
+ accountId = "";
12572
+ }
12573
+ const data = yield api.GET(`userGroupsByFeature/${accountId}/${perm}`, reqParams);
12574
+ return {
12575
+ groups: data.Items
12576
+ };
12577
+ });
12578
+ }
12579
+ UserGroup.GetListByPerm = GetListByPerm;
12580
+ /**
12581
+ * Returns all user groups for an account.
12582
+ * @param params
12583
+ * @returns
12584
+ */
12585
+ function GetList(params) {
12586
+ return __awaiter(this, void 0, void 0, function* () {
12587
+ let { api, accountId, req: reqParams } = params;
12588
+ if (!api) {
12589
+ api = ENVIRONMENT.Api().GetGuardianApi();
12590
+ }
12591
+ // Default groups.
12592
+ if (!accountId) {
12593
+ accountId = "";
12594
+ }
12595
+ const data = yield api.GET(`userGroups/${accountId}`, reqParams);
12596
+ return {
12597
+ groups: data.Items
12598
+ };
12599
+ });
12600
+ }
12601
+ UserGroup.GetList = GetList;
12602
+ /**
12603
+ * Deletes a user group.
12604
+ * @param params
12605
+ * @returns
12606
+ */
12607
+ function Delete(params) {
12608
+ return __awaiter(this, void 0, void 0, function* () {
12609
+ let { api, accountId, groupId: id, req: reqParams } = params;
12610
+ if (!id) {
12611
+ throw ("ID is required.");
12612
+ }
12613
+ if (!api) {
12614
+ api = ENVIRONMENT.Api().GetGuardianApi();
12615
+ }
12616
+ // Default groups.
12617
+ if (!accountId) {
12618
+ accountId = "";
12619
+ }
12620
+ return api.DELETE(`account/${accountId}/userGroupID/${id}`, reqParams);
12621
+ });
12622
+ }
12623
+ UserGroup.Delete = Delete;
12624
+ /**
12625
+ * Creates or updates a user group.
12626
+ * @param params
12627
+ * @returns
12628
+ */
12629
+ function Update(params) {
12630
+ return __awaiter(this, void 0, void 0, function* () {
12631
+ let { api, group: data, reqParams } = params;
12632
+ if (!data.Name) {
12633
+ throw ("User group name is required.");
12634
+ }
12635
+ // Default groups.
12636
+ if (!data["ClientAccount.ID"]) {
12637
+ data["ClientAccount.ID"] = "";
12638
+ }
12639
+ if (!api) {
12640
+ api = ENVIRONMENT.Api().GetGuardianApi();
12641
+ }
12642
+ const res = yield api.POST(`userGroup${data.ID ? ("/" + data.ID) : ""}`, data, reqParams);
12643
+ return {
12644
+ group: res
12645
+ };
12646
+ });
12647
+ }
12648
+ UserGroup.Update = Update;
12649
+ /**
12650
+ * Adds a user to specified groups.
12651
+ * @param params
12652
+ * @returns
12653
+ */
12654
+ function AddUser(params) {
12655
+ return __awaiter(this, void 0, void 0, function* () {
12656
+ let { api, userId, groupIds, accountId, req: reqParams } = params;
12657
+ if (!userId) {
12658
+ throw ("User ID is required.");
12659
+ }
12660
+ if (!(groupIds === null || groupIds === void 0 ? void 0 : groupIds.length)) {
12661
+ throw ("At least one group ID is required.");
12662
+ }
12663
+ if (!accountId) {
12664
+ accountId = "";
12665
+ }
12666
+ if (!api) {
12667
+ api = ENVIRONMENT.Api().GetGuardianApi();
12668
+ }
12669
+ yield api.POST(`user/${userId}/account/${accountId}/addToGroups`, {
12670
+ UserGroups: groupIds
12671
+ }, reqParams);
12672
+ api.Cache.RemoveByContains(User.GetCacheKey(userId, accountId));
12673
+ });
12674
+ }
12675
+ UserGroup.AddUser = AddUser;
12676
+ /**
12677
+ * Removes a user from specified groups.
12678
+ * @param params
12679
+ */
12680
+ function RemoveUser(params) {
12681
+ return __awaiter(this, void 0, void 0, function* () {
12682
+ let { api, userId, groupIds, accountId, req: reqParams } = params;
12683
+ if (!userId) {
12684
+ throw ("User ID is required.");
12685
+ }
12686
+ if (!(groupIds === null || groupIds === void 0 ? void 0 : groupIds.length)) {
12687
+ throw ("At least one group ID is required.");
12688
+ }
12689
+ if (!accountId) {
12690
+ accountId = "";
12691
+ }
12692
+ if (!api) {
12693
+ api = ENVIRONMENT.Api().GetGuardianApi();
12694
+ }
12695
+ yield api.POST(`user/${userId}/account/${accountId}/removeFromGroups`, {
12696
+ UserGroups: groupIds
12697
+ }, reqParams);
12698
+ api.Cache.RemoveByContains(User.GetCacheKey(userId, accountId));
12699
+ });
12700
+ }
12701
+ UserGroup.RemoveUser = RemoveUser;
12702
+ })(UserGroup || (UserGroup = {}));
12703
+
12579
12704
  /**
12580
12705
  * An account-invite is an invitation to a user to join a client account.
12581
12706
  * New users to Nextspace will setup their user account within the invitation process.
@@ -13400,6 +13525,115 @@ var AccountLimits;
13400
13525
  AccountLimits$$1.GetLimitsCacheKey = GetLimitsCacheKey;
13401
13526
  })(AccountLimits || (AccountLimits = {}));
13402
13527
 
13528
+ /**
13529
+ * Account templates are templates for sending emails to users.
13530
+ * In the future it might also be tied to other communication, eg: SMS.
13531
+ * When a template is not found then our hypeportal ones will be used as a fallback.
13532
+ */
13533
+ var AccountTemplate;
13534
+ (function (AccountTemplate) {
13535
+ /**
13536
+ * Known keywords that will be substituted in the template.
13537
+ * A keyword must be surrounded by ${blah} in the template.
13538
+ */
13539
+ let EKeyword;
13540
+ (function (EKeyword) {
13541
+ EKeyword["AccountName"] = "ClientAccount.Name";
13542
+ EKeyword["InvitedByUserName"] = "InvitedBy.User.FullName";
13543
+ EKeyword["InvitedUserName"] = "Invited.User.FullName";
13544
+ EKeyword["URL"] = "URL";
13545
+ EKeyword["ActivationCode"] = "ActivationCode";
13546
+ })(EKeyword = AccountTemplate.EKeyword || (AccountTemplate.EKeyword = {}));
13547
+ function GetList(params) {
13548
+ return __awaiter(this, void 0, void 0, function* () {
13549
+ let { accountId, api, req } = params;
13550
+ if (!accountId) {
13551
+ throw new Error("accountId is required");
13552
+ }
13553
+ if (!api) {
13554
+ api = ENVIRONMENT.Api().GetGuardianApi();
13555
+ }
13556
+ const data = yield api.GET(`templates/${accountId}`, Api.PrepReqParams(req));
13557
+ return {
13558
+ templates: data.Items
13559
+ };
13560
+ });
13561
+ }
13562
+ AccountTemplate.GetList = GetList;
13563
+ function Get(params) {
13564
+ return __awaiter(this, void 0, void 0, function* () {
13565
+ let { key, accountId, api, req } = params;
13566
+ if (!accountId) {
13567
+ throw new Error("accountId is required");
13568
+ }
13569
+ if (!api) {
13570
+ api = ENVIRONMENT.Api().GetGuardianApi();
13571
+ }
13572
+ const data = yield api.GET(`template/${accountId}/${key}`, Api.PrepReqParams(req));
13573
+ return {
13574
+ template: data
13575
+ };
13576
+ });
13577
+ }
13578
+ AccountTemplate.Get = Get;
13579
+ function Update(params) {
13580
+ return __awaiter(this, void 0, void 0, function* () {
13581
+ let { template, api, req } = params;
13582
+ if (!(template === null || template === void 0 ? void 0 : template["ClientAccount.ID"])) {
13583
+ throw new Error("ClientAccount.ID is required");
13584
+ }
13585
+ if (!(template === null || template === void 0 ? void 0 : template.Key)) {
13586
+ throw new Error("Key is required");
13587
+ }
13588
+ if (!api) {
13589
+ api = ENVIRONMENT.Api().GetGuardianApi();
13590
+ }
13591
+ const data = yield api.POST(`template/${template["ClientAccount.ID"]}/${template.Key}`, template, Api.PrepReqParams(req));
13592
+ return {
13593
+ template: data
13594
+ };
13595
+ });
13596
+ }
13597
+ AccountTemplate.Update = Update;
13598
+ function Delete(params) {
13599
+ return __awaiter(this, void 0, void 0, function* () {
13600
+ let { key, accountId, api, req } = params;
13601
+ if (!accountId) {
13602
+ throw new Error("accountId is required");
13603
+ }
13604
+ if (!key) {
13605
+ throw new Error("key is required");
13606
+ }
13607
+ if (!api) {
13608
+ api = ENVIRONMENT.Api().GetGuardianApi();
13609
+ }
13610
+ yield api.DELETE(`template/${accountId}/${key}`, Api.PrepReqParams(req));
13611
+ });
13612
+ }
13613
+ AccountTemplate.Delete = Delete;
13614
+ })(AccountTemplate || (AccountTemplate = {}));
13615
+
13616
+ /**
13617
+ * An account type dictates limitations and available features.
13618
+ * Eg: how many Entities an account can have.
13619
+ */
13620
+ var AccountType;
13621
+ (function (AccountType) {
13622
+ function GetList(params) {
13623
+ return __awaiter(this, void 0, void 0, function* () {
13624
+ let { api, req } = params;
13625
+ if (!api) {
13626
+ api = ENVIRONMENT.Api().GetGuardianApi();
13627
+ }
13628
+ const data = yield api.GET("accountTypes", Api.PrepReqParams(req));
13629
+ return {
13630
+ types: data.Items
13631
+ };
13632
+ });
13633
+ }
13634
+ AccountType.GetList = GetList;
13635
+ })(AccountType || (AccountType = {}));
13636
+
13403
13637
  var EncryptUtils;
13404
13638
  (function (EncryptUtils) {
13405
13639
  // https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript
@@ -14758,7 +14992,7 @@ var DataSource;
14758
14992
  })(DataSource || (DataSource = {}));
14759
14993
 
14760
14994
  // This is updated with the package.json version on build.
14761
- const VERSION = "5.4.5";
14995
+ const VERSION = "5.4.7";
14762
14996
 
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 };
14997
+ 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
14998
  //# sourceMappingURL=bruce-models.es5.js.map