bruce-models 0.2.5 → 0.2.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.
@@ -111,6 +111,7 @@
111
111
  ECacheKey["Style"] = "style";
112
112
  ECacheKey["PublishTileset"] = "publishtileset";
113
113
  ECacheKey["User"] = "user";
114
+ ECacheKey["UserEmail"] = "useremail";
114
115
  ECacheKey["AccessToken"] = "accesstoken";
115
116
  ECacheKey["UserGroup"] = "usergroup";
116
117
  ECacheKey["Account"] = "account";
@@ -4830,6 +4831,10 @@
4830
4831
  return exports.Api.ECacheKey.User + exports.Api.ECacheKey.Id + userId + exports.Api.ECacheKey.Id + accountId;
4831
4832
  }
4832
4833
  User.GetCacheKey = GetCacheKey;
4834
+ function GetEmailCacheKey(email, accountId) {
4835
+ return exports.Api.ECacheKey.User + exports.Api.ECacheKey.UserEmail + email + exports.Api.ECacheKey.Id + accountId;
4836
+ }
4837
+ User.GetEmailCacheKey = GetEmailCacheKey;
4833
4838
  var EType;
4834
4839
  (function (EType) {
4835
4840
  EType["User"] = "LOGIN_USER";
@@ -4921,6 +4926,29 @@
4921
4926
  return exports.Api.ECacheKey.User + exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + accountId;
4922
4927
  }
4923
4928
  LoginUser.GetListCacheKey = GetListCacheKey;
4929
+ function GetByEmail(api, email, accountId) {
4930
+ return __awaiter(this, void 0, void 0, function () {
4931
+ var cacheData, req;
4932
+ return __generator(this, function (_a) {
4933
+ switch (_a.label) {
4934
+ case 0:
4935
+ if (!email) {
4936
+ throw ("Email is required.");
4937
+ }
4938
+ cacheData = api.Cache.Get(GetEmailCacheKey(email, accountId));
4939
+ if (cacheData) {
4940
+ return [2 /*return*/, cacheData];
4941
+ }
4942
+ return [4 /*yield*/, api.GET("userByEmail/" + email + (accountId ? "?clientAccountID=" + accountId : ""))];
4943
+ case 1:
4944
+ req = _a.sent();
4945
+ api.Cache.Set(GetEmailCacheKey(email, accountId), req, exports.Api.DEFAULT_CACHE_DURATION);
4946
+ return [2 /*return*/, req];
4947
+ }
4948
+ });
4949
+ });
4950
+ }
4951
+ LoginUser.GetByEmail = GetByEmail;
4924
4952
  function GetList(api, accountId, exclusive) {
4925
4953
  return __awaiter(this, void 0, void 0, function () {
4926
4954
  var cacheData, req;
@@ -5007,12 +5035,12 @@
5007
5035
  /**
5008
5036
  * Completes signup using user data and a signup code.
5009
5037
  * @param api
5010
- * @param accountId
5011
5038
  * @param code
5012
5039
  * @param data
5040
+ * @param accountId
5013
5041
  * @returns
5014
5042
  */
5015
- function SignupComplete(api, accountId, code, data) {
5043
+ function SignupComplete(api, code, data, accountId) {
5016
5044
  return __awaiter(this, void 0, void 0, function () {
5017
5045
  var res;
5018
5046
  return __generator(this, function (_a) {
@@ -5025,7 +5053,7 @@
5025
5053
  data.IsActivated = true;
5026
5054
  data.IsDisabled = false;
5027
5055
  data.key = code;
5028
- return [4 /*yield*/, api.POST("UserActivate/" + accountId, data)];
5056
+ return [4 /*yield*/, api.POST("UserActivate/" + (accountId ? accountId : ""), data)];
5029
5057
  case 1:
5030
5058
  res = _a.sent();
5031
5059
  api.Cache.RemoveByContains(exports.Api.ECacheKey.User + exports.Api.ECacheKey.Id + res.ID);