bruce-models 5.4.4 → 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.
@@ -625,9 +625,11 @@
625
625
  }
626
626
  }
627
627
  formatApiUri(uri) {
628
- const wsProtocol = window.document.location.protocol === "https:" ? "wss" : "ws";
629
628
  const currentUrl = new URL(uri);
630
- let full = wsProtocol + "://" + currentUrl.host + currentUrl.pathname + "websocket";
629
+ // Protocol matching the Bruce API one.
630
+ // In almost all cases it will be wss, in a localhost BruceAPI then it might be ws.
631
+ const protocol = currentUrl.protocol === "http:" ? "ws:" : "wss:";
632
+ let full = protocol + "://" + currentUrl.host + currentUrl.pathname + "websocket";
631
633
  // Check if we have a queryParam for accountId.
632
634
  const accountId = currentUrl.searchParams.get("accountId");
633
635
  if (accountId) {
@@ -3216,11 +3218,23 @@
3216
3218
  if (!api) {
3217
3219
  api = exports.ENVIRONMENT.Api().GetBruceApi();
3218
3220
  }
3221
+ const cacheKeyData = {
3222
+ expandLocation,
3223
+ expandRelations,
3224
+ expandImports,
3225
+ expandSources,
3226
+ entityTypeId: null,
3227
+ historicFrom: historicFrom,
3228
+ historicKey: historicKey,
3229
+ historicTo: historicTo,
3230
+ historicPoint: historicPoint,
3231
+ schemaId: schemaId
3232
+ };
3219
3233
  const crashRiskReqs = [];
3220
3234
  const reqIds = [];
3221
3235
  for (let i = 0; i < entityIds.length; i++) {
3222
3236
  const entityId = entityIds[i];
3223
- const key = GetCacheKey({ entityId, expandRelations, expandLocation });
3237
+ const key = GetCacheKey(Object.assign(Object.assign({}, cacheKeyData), { entityId }));
3224
3238
  const cache = api.GetCacheItem(key, reqParams);
3225
3239
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
3226
3240
  crashRiskReqs.push(cache.data);
@@ -3285,19 +3299,7 @@
3285
3299
  const req = api.POST(url, reqData, exports.Api.PrepReqParams(reqParams));
3286
3300
  for (let i = 0; i < reqIds.length; i++) {
3287
3301
  const entityId = reqIds[i];
3288
- const key = GetCacheKey({
3289
- entityId,
3290
- expandLocation,
3291
- expandRelations,
3292
- expandImports,
3293
- expandSources,
3294
- entityTypeId: null,
3295
- historicFrom: historicFrom,
3296
- historicKey: historicKey,
3297
- historicTo: historicTo,
3298
- historicPoint: historicPoint,
3299
- schemaId: schemaId
3300
- });
3302
+ const key = GetCacheKey(Object.assign(Object.assign({}, cacheKeyData), { entityId }));
3301
3303
  const prom = new Promise((res) => __awaiter(this, void 0, void 0, function* () {
3302
3304
  try {
3303
3305
  const data = yield req;
@@ -10923,15 +10925,15 @@
10923
10925
  */
10924
10926
  function GetRelatedList(params) {
10925
10927
  return __awaiter(this, void 0, void 0, function* () {
10926
- let { api, req: reqParams } = params;
10928
+ let { api, req: reqParams, owned } = params;
10927
10929
  if (!api) {
10928
10930
  api = exports.ENVIRONMENT.Api().GetGuardianApi();
10929
10931
  }
10930
- const cache = api.GetCacheItem(GetListCacheKey(api.GetSessionId()), reqParams);
10932
+ const cache = api.GetCacheItem(GetListCacheKey(api.GetSessionId(), owned), reqParams);
10931
10933
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
10932
10934
  return cache.data;
10933
10935
  }
10934
- const req = api.GET("user/relatedClientAccounts", reqParams);
10936
+ const req = api.GET(owned ? "user/ownedClientAccounts" : "user/relatedClientAccounts", reqParams);
10935
10937
  const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
10936
10938
  try {
10937
10939
  const data = yield req;
@@ -10945,7 +10947,7 @@
10945
10947
  }
10946
10948
  }));
10947
10949
  api.SetCacheItem({
10948
- key: GetListCacheKey(api.GetSessionId()),
10950
+ key: GetListCacheKey(api.GetSessionId(), owned),
10949
10951
  value: prom,
10950
10952
  req: reqParams
10951
10953
  });
@@ -11037,7 +11039,7 @@
11037
11039
  const resData = {
11038
11040
  account: res
11039
11041
  };
11040
- api.Cache.Remove(GetListCacheKey(api.GetSessionId()));
11042
+ api.Cache.RemoveByStartsWith(GetListCacheKey(api.GetSessionId()));
11041
11043
  return resData;
11042
11044
  });
11043
11045
  }
@@ -11091,8 +11093,11 @@
11091
11093
  * @param ssid
11092
11094
  * @returns
11093
11095
  */
11094
- function GetListCacheKey(ssid) {
11095
- return exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Session + exports.Api.ECacheKey.Id + ssid;
11096
+ function GetListCacheKey(ssid, owned) {
11097
+ if (!owned) {
11098
+ owned = false;
11099
+ }
11100
+ return exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Session + exports.Api.ECacheKey.Id + ssid + exports.Api.ECacheKey.Id + (owned ? "owned" : "related");
11096
11101
  }
11097
11102
  Account.GetListCacheKey = GetListCacheKey;
11098
11103
  /**
@@ -11595,153 +11600,6 @@
11595
11600
  }
11596
11601
  })(exports.Session || (exports.Session = {}));
11597
11602
 
11598
- (function (UserGroup) {
11599
- /**
11600
- * Returns a user group by its name.
11601
- * @param params
11602
- * @returns
11603
- */
11604
- function GetByName(params) {
11605
- return __awaiter(this, void 0, void 0, function* () {
11606
- let { api, accountId, name, req: reqParams } = params;
11607
- if (!name) {
11608
- throw ("Name is required.");
11609
- }
11610
- if (!api) {
11611
- api = exports.ENVIRONMENT.Api().GetGuardianApi();
11612
- }
11613
- // Default groups.
11614
- if (!accountId) {
11615
- accountId = "";
11616
- }
11617
- const data = yield api.GET(`account/${accountId}/userGroupByName/${name}`, reqParams);
11618
- return {
11619
- group: data
11620
- };
11621
- });
11622
- }
11623
- UserGroup.GetByName = GetByName;
11624
- /**
11625
- * Returns all users in a user group.
11626
- * @param params
11627
- * @returns
11628
- */
11629
- function GetUsers(params) {
11630
- return __awaiter(this, void 0, void 0, function* () {
11631
- let { api, accountId, groupId: id, req: reqParams } = params;
11632
- if (!id) {
11633
- throw ("ID is required.");
11634
- }
11635
- if (!api) {
11636
- api = exports.ENVIRONMENT.Api().GetGuardianApi();
11637
- }
11638
- // Default groups.
11639
- if (!accountId) {
11640
- accountId = "";
11641
- }
11642
- const data = yield api.GET(`userGroup/${accountId}/${id}/users`, reqParams);
11643
- return {
11644
- users: data.Items
11645
- };
11646
- });
11647
- }
11648
- UserGroup.GetUsers = GetUsers;
11649
- /**
11650
- * Returns list of user groups that have a specific permission enabled.
11651
- * @param params
11652
- * @returns
11653
- */
11654
- function GetListByPerm(params) {
11655
- return __awaiter(this, void 0, void 0, function* () {
11656
- let { api, accountId, perm, req: reqParams } = params;
11657
- if (!perm) {
11658
- throw ("Perm is required.");
11659
- }
11660
- if (!api) {
11661
- api = exports.ENVIRONMENT.Api().GetGuardianApi();
11662
- }
11663
- // Default groups.
11664
- if (!accountId) {
11665
- accountId = "";
11666
- }
11667
- const data = yield api.GET(`userGroupsByFeature/${accountId}/${perm}`, reqParams);
11668
- return {
11669
- groups: data.Items
11670
- };
11671
- });
11672
- }
11673
- UserGroup.GetListByPerm = GetListByPerm;
11674
- /**
11675
- * Returns all user groups for an account.
11676
- * @param params
11677
- * @returns
11678
- */
11679
- function GetList(params) {
11680
- return __awaiter(this, void 0, void 0, function* () {
11681
- let { api, accountId, req: reqParams } = params;
11682
- if (!api) {
11683
- api = exports.ENVIRONMENT.Api().GetGuardianApi();
11684
- }
11685
- // Default groups.
11686
- if (!accountId) {
11687
- accountId = "";
11688
- }
11689
- const data = yield api.GET(`userGroups/${accountId}`, reqParams);
11690
- return {
11691
- groups: data.Items
11692
- };
11693
- });
11694
- }
11695
- UserGroup.GetList = GetList;
11696
- /**
11697
- * Deletes a user group.
11698
- * @param params
11699
- * @returns
11700
- */
11701
- function Delete(params) {
11702
- return __awaiter(this, void 0, void 0, function* () {
11703
- let { api, accountId, groupId: id, req: reqParams } = params;
11704
- if (!id) {
11705
- throw ("ID is required.");
11706
- }
11707
- if (!api) {
11708
- api = exports.ENVIRONMENT.Api().GetGuardianApi();
11709
- }
11710
- // Default groups.
11711
- if (!accountId) {
11712
- accountId = "";
11713
- }
11714
- return api.DELETE(`account/${accountId}/userGroupID/${id}`, reqParams);
11715
- });
11716
- }
11717
- UserGroup.Delete = Delete;
11718
- /**
11719
- * Creates or updates a user group.
11720
- * @param params
11721
- * @returns
11722
- */
11723
- function Update(params) {
11724
- return __awaiter(this, void 0, void 0, function* () {
11725
- let { api, group: data, reqParams } = params;
11726
- if (!data.Name) {
11727
- throw ("User group name is required.");
11728
- }
11729
- // Default groups.
11730
- if (!data["ClientAccount.ID"]) {
11731
- data["ClientAccount.ID"] = "";
11732
- }
11733
- if (!api) {
11734
- api = exports.ENVIRONMENT.Api().GetGuardianApi();
11735
- }
11736
- const res = yield api.POST(`userGroup${data.ID ? ("/" + data.ID) : ""}`, data, reqParams);
11737
- return {
11738
- group: res
11739
- };
11740
- });
11741
- }
11742
- UserGroup.Update = Update;
11743
- })(exports.UserGroup || (exports.UserGroup = {}));
11744
-
11745
11603
  (function (User) {
11746
11604
  /**
11747
11605
  * Available user types.
@@ -11842,6 +11700,36 @@
11842
11700
  });
11843
11701
  }
11844
11702
  User.Update = Update;
11703
+ /**
11704
+ * Creates a user record.
11705
+ * This is not a user invitation, this creates a new user which you can then manage or invite yourself.
11706
+ * TODO: The user should be tied to the client account's client and not the global list.
11707
+ * @param params
11708
+ */
11709
+ function Create(params) {
11710
+ return __awaiter(this, void 0, void 0, function* () {
11711
+ let { api, user: data, req: reqParams } = params;
11712
+ if (!api) {
11713
+ api = exports.ENVIRONMENT.Api().GetGuardianApi();
11714
+ }
11715
+ if (data.Type == EType.AccessToken) {
11716
+ throw ("Access tokens cannot be created this way.");
11717
+ }
11718
+ if (!data.Type) {
11719
+ data.Type = EType.User;
11720
+ }
11721
+ if (!data.ID) {
11722
+ data.ID = exports.ObjectUtils.UId();
11723
+ }
11724
+ const res = yield api.POST("user", data, reqParams);
11725
+ api.Cache.RemoveByContains(exports.Api.ECacheKey.User + exports.Api.ECacheKey.Id + data.ID);
11726
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.User + exports.Api.ECacheKey.Account);
11727
+ return {
11728
+ user: res
11729
+ };
11730
+ });
11731
+ }
11732
+ User.Create = Create;
11845
11733
  /**
11846
11734
  * Loads settings for a given user + app.
11847
11735
  * The session's account id is used to separate settings between accounts.
@@ -11958,10 +11846,18 @@
11958
11846
  * api.Cache.Remove(key);
11959
11847
  * }
11960
11848
  * @param accountId
11849
+ * @param exclusive
11850
+ * @param search
11961
11851
  * @returns
11962
11852
  */
11963
- function GetListCacheKey(accountId) {
11964
- return exports.Api.ECacheKey.User + exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + accountId;
11853
+ function GetListCacheKey(accountId, exclusive, search) {
11854
+ if (!exclusive) {
11855
+ exclusive = false;
11856
+ }
11857
+ if (!search) {
11858
+ search = "";
11859
+ }
11860
+ return exports.Api.ECacheKey.User + exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + accountId + exports.Api.ECacheKey.Id + exclusive + exports.Api.ECacheKey.Id + search;
11965
11861
  }
11966
11862
  LoginUser.GetListCacheKey = GetListCacheKey;
11967
11863
  /**
@@ -12009,7 +11905,7 @@
12009
11905
  */
12010
11906
  function GetList(params) {
12011
11907
  return __awaiter(this, void 0, void 0, function* () {
12012
- let { api, accountId, exclusive, req: reqParams } = params;
11908
+ let { api, accountId, exclusive, req: reqParams, search } = params;
12013
11909
  if (!accountId) {
12014
11910
  throw ("Client account ID is required.");
12015
11911
  }
@@ -12019,13 +11915,24 @@
12019
11915
  if (!exclusive) {
12020
11916
  exclusive = false;
12021
11917
  }
12022
- const cache = exclusive ? null : api.GetCacheItem(GetListCacheKey(accountId), reqParams);
11918
+ const cacheKey = GetListCacheKey(accountId, exclusive, search);
11919
+ const cache = exclusive ? null : api.GetCacheItem(cacheKey, reqParams);
12023
11920
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
12024
11921
  return cache.data;
12025
11922
  }
12026
11923
  const req = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
12027
11924
  try {
12028
- const data = yield api.GET(`users?clientAccountID=${accountId}${exclusive ? "&allExcludingClientAccount=true" : ""}`, reqParams);
11925
+ const urlParams = new URLSearchParams();
11926
+ if (accountId) {
11927
+ urlParams.append("clientAccountID", accountId);
11928
+ }
11929
+ if (search) {
11930
+ urlParams.append("search", search);
11931
+ }
11932
+ if (exclusive) {
11933
+ urlParams.append("allExcludingClientAccount", "true");
11934
+ }
11935
+ const data = yield api.GET(`users?${urlParams.toString()}`, reqParams);
12029
11936
  res({
12030
11937
  users: data.Items
12031
11938
  });
@@ -12048,7 +11955,7 @@
12048
11955
  }));
12049
11956
  if (!exclusive) {
12050
11957
  api.SetCacheItem({
12051
- key: GetListCacheKey(accountId),
11958
+ key: cacheKey,
12052
11959
  value: req,
12053
11960
  req: reqParams
12054
11961
  });
@@ -12283,6 +12190,26 @@
12283
12190
  }
12284
12191
  AccessToken.Create = Create;
12285
12192
  })(AccessToken = User.AccessToken || (User.AccessToken = {}));
12193
+ /**
12194
+ * Updates the password for a user by supplying the existing and new password.
12195
+ * @param params
12196
+ */
12197
+ function UpdatePassword(params) {
12198
+ return __awaiter(this, void 0, void 0, function* () {
12199
+ let { userId, passwordCurrent, passwordNew, api, req } = params;
12200
+ if (!userId || !passwordCurrent || !passwordNew) {
12201
+ throw ("UserId, current password, and new password are required.");
12202
+ }
12203
+ if (!api) {
12204
+ api = exports.ENVIRONMENT.Api().GetGuardianApi();
12205
+ }
12206
+ return api.POST(`user/${userId}/setPassword`, {
12207
+ CurrentPassword: passwordCurrent,
12208
+ NewPassword: passwordNew
12209
+ }, req);
12210
+ });
12211
+ }
12212
+ User.UpdatePassword = UpdatePassword;
12286
12213
  /**
12287
12214
  * Returns cache identifier for a user.
12288
12215
  * Example: {
@@ -12336,6 +12263,206 @@
12336
12263
  User.GetSettingsCacheKey = GetSettingsCacheKey;
12337
12264
  })(exports.User || (exports.User = {}));
12338
12265
 
12266
+ (function (UserGroup) {
12267
+ /**
12268
+ * Returns a user group by its name.
12269
+ * @param params
12270
+ * @returns
12271
+ */
12272
+ function GetByName(params) {
12273
+ return __awaiter(this, void 0, void 0, function* () {
12274
+ let { api, accountId, name, req: reqParams } = params;
12275
+ if (!name) {
12276
+ throw ("Name is required.");
12277
+ }
12278
+ if (!api) {
12279
+ api = exports.ENVIRONMENT.Api().GetGuardianApi();
12280
+ }
12281
+ // Default groups.
12282
+ if (!accountId) {
12283
+ accountId = "";
12284
+ }
12285
+ const data = yield api.GET(`account/${accountId}/userGroupByName/${name}`, reqParams);
12286
+ return {
12287
+ group: data
12288
+ };
12289
+ });
12290
+ }
12291
+ UserGroup.GetByName = GetByName;
12292
+ /**
12293
+ * Returns all users in a user group.
12294
+ * @param params
12295
+ * @returns
12296
+ */
12297
+ function GetUsers(params) {
12298
+ return __awaiter(this, void 0, void 0, function* () {
12299
+ let { api, accountId, groupId: id, req: reqParams } = params;
12300
+ if (!id) {
12301
+ throw ("ID is required.");
12302
+ }
12303
+ if (!api) {
12304
+ api = exports.ENVIRONMENT.Api().GetGuardianApi();
12305
+ }
12306
+ // Default groups.
12307
+ if (!accountId) {
12308
+ accountId = "";
12309
+ }
12310
+ const data = yield api.GET(`userGroup/${accountId}/${id}/users`, reqParams);
12311
+ return {
12312
+ users: data.Items
12313
+ };
12314
+ });
12315
+ }
12316
+ UserGroup.GetUsers = GetUsers;
12317
+ /**
12318
+ * Returns list of user groups that have a specific permission enabled.
12319
+ * @param params
12320
+ * @returns
12321
+ */
12322
+ function GetListByPerm(params) {
12323
+ return __awaiter(this, void 0, void 0, function* () {
12324
+ let { api, accountId, perm, req: reqParams } = params;
12325
+ if (!perm) {
12326
+ throw ("Perm is required.");
12327
+ }
12328
+ if (!api) {
12329
+ api = exports.ENVIRONMENT.Api().GetGuardianApi();
12330
+ }
12331
+ // Default groups.
12332
+ if (!accountId) {
12333
+ accountId = "";
12334
+ }
12335
+ const data = yield api.GET(`userGroupsByFeature/${accountId}/${perm}`, reqParams);
12336
+ return {
12337
+ groups: data.Items
12338
+ };
12339
+ });
12340
+ }
12341
+ UserGroup.GetListByPerm = GetListByPerm;
12342
+ /**
12343
+ * Returns all user groups for an account.
12344
+ * @param params
12345
+ * @returns
12346
+ */
12347
+ function GetList(params) {
12348
+ return __awaiter(this, void 0, void 0, function* () {
12349
+ let { api, accountId, req: reqParams } = params;
12350
+ if (!api) {
12351
+ api = exports.ENVIRONMENT.Api().GetGuardianApi();
12352
+ }
12353
+ // Default groups.
12354
+ if (!accountId) {
12355
+ accountId = "";
12356
+ }
12357
+ const data = yield api.GET(`userGroups/${accountId}`, reqParams);
12358
+ return {
12359
+ groups: data.Items
12360
+ };
12361
+ });
12362
+ }
12363
+ UserGroup.GetList = GetList;
12364
+ /**
12365
+ * Deletes a user group.
12366
+ * @param params
12367
+ * @returns
12368
+ */
12369
+ function Delete(params) {
12370
+ return __awaiter(this, void 0, void 0, function* () {
12371
+ let { api, accountId, groupId: id, req: reqParams } = params;
12372
+ if (!id) {
12373
+ throw ("ID is required.");
12374
+ }
12375
+ if (!api) {
12376
+ api = exports.ENVIRONMENT.Api().GetGuardianApi();
12377
+ }
12378
+ // Default groups.
12379
+ if (!accountId) {
12380
+ accountId = "";
12381
+ }
12382
+ return api.DELETE(`account/${accountId}/userGroupID/${id}`, reqParams);
12383
+ });
12384
+ }
12385
+ UserGroup.Delete = Delete;
12386
+ /**
12387
+ * Creates or updates a user group.
12388
+ * @param params
12389
+ * @returns
12390
+ */
12391
+ function Update(params) {
12392
+ return __awaiter(this, void 0, void 0, function* () {
12393
+ let { api, group: data, reqParams } = params;
12394
+ if (!data.Name) {
12395
+ throw ("User group name is required.");
12396
+ }
12397
+ // Default groups.
12398
+ if (!data["ClientAccount.ID"]) {
12399
+ data["ClientAccount.ID"] = "";
12400
+ }
12401
+ if (!api) {
12402
+ api = exports.ENVIRONMENT.Api().GetGuardianApi();
12403
+ }
12404
+ const res = yield api.POST(`userGroup${data.ID ? ("/" + data.ID) : ""}`, data, reqParams);
12405
+ return {
12406
+ group: res
12407
+ };
12408
+ });
12409
+ }
12410
+ UserGroup.Update = Update;
12411
+ /**
12412
+ * Adds a user to specified groups.
12413
+ * @param params
12414
+ * @returns
12415
+ */
12416
+ function AddUser(params) {
12417
+ return __awaiter(this, void 0, void 0, function* () {
12418
+ let { api, userId, groupIds, accountId, req: reqParams } = params;
12419
+ if (!userId) {
12420
+ throw ("User ID is required.");
12421
+ }
12422
+ if (!(groupIds === null || groupIds === void 0 ? void 0 : groupIds.length)) {
12423
+ throw ("At least one group ID is required.");
12424
+ }
12425
+ if (!accountId) {
12426
+ accountId = "";
12427
+ }
12428
+ if (!api) {
12429
+ api = exports.ENVIRONMENT.Api().GetGuardianApi();
12430
+ }
12431
+ yield api.POST(`user/${userId}/account/${accountId}/addToGroups`, {
12432
+ UserGroups: groupIds
12433
+ }, reqParams);
12434
+ api.Cache.RemoveByContains(exports.User.GetCacheKey(userId, accountId));
12435
+ });
12436
+ }
12437
+ UserGroup.AddUser = AddUser;
12438
+ /**
12439
+ * Removes a user from specified groups.
12440
+ * @param params
12441
+ */
12442
+ function RemoveUser(params) {
12443
+ return __awaiter(this, void 0, void 0, function* () {
12444
+ let { api, userId, groupIds, accountId, req: reqParams } = params;
12445
+ if (!userId) {
12446
+ throw ("User ID is required.");
12447
+ }
12448
+ if (!(groupIds === null || groupIds === void 0 ? void 0 : groupIds.length)) {
12449
+ throw ("At least one group ID is required.");
12450
+ }
12451
+ if (!accountId) {
12452
+ accountId = "";
12453
+ }
12454
+ if (!api) {
12455
+ api = exports.ENVIRONMENT.Api().GetGuardianApi();
12456
+ }
12457
+ yield api.POST(`user/${userId}/account/${accountId}/removeFromGroups`, {
12458
+ UserGroups: groupIds
12459
+ }, reqParams);
12460
+ api.Cache.RemoveByContains(exports.User.GetCacheKey(userId, accountId));
12461
+ });
12462
+ }
12463
+ UserGroup.RemoveUser = RemoveUser;
12464
+ })(exports.UserGroup || (exports.UserGroup = {}));
12465
+
12339
12466
  (function (AccountInvite) {
12340
12467
  /**
12341
12468
  * Possible invite statuses.
@@ -13149,6 +13276,104 @@
13149
13276
  AccountLimits.GetLimitsCacheKey = GetLimitsCacheKey;
13150
13277
  })(exports.AccountLimits || (exports.AccountLimits = {}));
13151
13278
 
13279
+ (function (AccountTemplate) {
13280
+ /**
13281
+ * Known keywords that will be substituted in the template.
13282
+ * A keyword must be surrounded by ${blah} in the template.
13283
+ */
13284
+ let EKeyword;
13285
+ (function (EKeyword) {
13286
+ EKeyword["AccountName"] = "ClientAccount.Name";
13287
+ EKeyword["InvitedByUserName"] = "InvitedBy.User.FullName";
13288
+ EKeyword["InvitedUserName"] = "Invited.User.FullName";
13289
+ EKeyword["URL"] = "URL";
13290
+ EKeyword["ActivationCode"] = "ActivationCode";
13291
+ })(EKeyword = AccountTemplate.EKeyword || (AccountTemplate.EKeyword = {}));
13292
+ function GetList(params) {
13293
+ return __awaiter(this, void 0, void 0, function* () {
13294
+ let { accountId, api, req } = params;
13295
+ if (!accountId) {
13296
+ throw new Error("accountId is required");
13297
+ }
13298
+ if (!api) {
13299
+ api = exports.ENVIRONMENT.Api().GetGuardianApi();
13300
+ }
13301
+ const data = yield api.GET(`templates/${accountId}`, exports.Api.PrepReqParams(req));
13302
+ return {
13303
+ templates: data.Items
13304
+ };
13305
+ });
13306
+ }
13307
+ AccountTemplate.GetList = GetList;
13308
+ function Get(params) {
13309
+ return __awaiter(this, void 0, void 0, function* () {
13310
+ let { key, accountId, api, req } = params;
13311
+ if (!accountId) {
13312
+ throw new Error("accountId is required");
13313
+ }
13314
+ if (!api) {
13315
+ api = exports.ENVIRONMENT.Api().GetGuardianApi();
13316
+ }
13317
+ const data = yield api.GET(`template/${accountId}/${key}`, exports.Api.PrepReqParams(req));
13318
+ return {
13319
+ template: data
13320
+ };
13321
+ });
13322
+ }
13323
+ AccountTemplate.Get = Get;
13324
+ function Update(params) {
13325
+ return __awaiter(this, void 0, void 0, function* () {
13326
+ let { template, api, req } = params;
13327
+ if (!(template === null || template === void 0 ? void 0 : template["ClientAccount.ID"])) {
13328
+ throw new Error("ClientAccount.ID is required");
13329
+ }
13330
+ if (!(template === null || template === void 0 ? void 0 : template.Key)) {
13331
+ throw new Error("Key is required");
13332
+ }
13333
+ if (!api) {
13334
+ api = exports.ENVIRONMENT.Api().GetGuardianApi();
13335
+ }
13336
+ const data = yield api.POST(`template/${template["ClientAccount.ID"]}/${template.Key}`, template, exports.Api.PrepReqParams(req));
13337
+ return {
13338
+ template: data
13339
+ };
13340
+ });
13341
+ }
13342
+ AccountTemplate.Update = Update;
13343
+ function Delete(params) {
13344
+ return __awaiter(this, void 0, void 0, function* () {
13345
+ let { key, accountId, api, req } = params;
13346
+ if (!accountId) {
13347
+ throw new Error("accountId is required");
13348
+ }
13349
+ if (!key) {
13350
+ throw new Error("key is required");
13351
+ }
13352
+ if (!api) {
13353
+ api = exports.ENVIRONMENT.Api().GetGuardianApi();
13354
+ }
13355
+ yield api.DELETE(`template/${accountId}/${key}`, exports.Api.PrepReqParams(req));
13356
+ });
13357
+ }
13358
+ AccountTemplate.Delete = Delete;
13359
+ })(exports.AccountTemplate || (exports.AccountTemplate = {}));
13360
+
13361
+ (function (AccountType) {
13362
+ function GetList(params) {
13363
+ return __awaiter(this, void 0, void 0, function* () {
13364
+ let { api, req } = params;
13365
+ if (!api) {
13366
+ api = exports.ENVIRONMENT.Api().GetGuardianApi();
13367
+ }
13368
+ const data = yield api.GET("accountTypes", exports.Api.PrepReqParams(req));
13369
+ return {
13370
+ types: data.Items
13371
+ };
13372
+ });
13373
+ }
13374
+ AccountType.GetList = GetList;
13375
+ })(exports.AccountType || (exports.AccountType = {}));
13376
+
13152
13377
  (function (EncryptUtils) {
13153
13378
  // https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript
13154
13379
  function Cyrb53Hash(str, seed = 0) {
@@ -14477,7 +14702,7 @@
14477
14702
  })(exports.DataSource || (exports.DataSource = {}));
14478
14703
 
14479
14704
  // This is updated with the package.json version on build.
14480
- const VERSION = "5.4.4";
14705
+ const VERSION = "5.4.6";
14481
14706
 
14482
14707
  exports.VERSION = VERSION;
14483
14708
  exports.AbstractApi = AbstractApi;