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.
@@ -106,6 +106,7 @@ var Api;
106
106
  ECacheKey["Style"] = "style";
107
107
  ECacheKey["PublishTileset"] = "publishtileset";
108
108
  ECacheKey["User"] = "user";
109
+ ECacheKey["UserEmail"] = "useremail";
109
110
  ECacheKey["AccessToken"] = "accesstoken";
110
111
  ECacheKey["UserGroup"] = "usergroup";
111
112
  ECacheKey["Account"] = "account";
@@ -5011,6 +5012,10 @@ var User;
5011
5012
  return Api.ECacheKey.User + Api.ECacheKey.Id + userId + Api.ECacheKey.Id + accountId;
5012
5013
  }
5013
5014
  User.GetCacheKey = GetCacheKey;
5015
+ function GetEmailCacheKey(email, accountId) {
5016
+ return Api.ECacheKey.User + Api.ECacheKey.UserEmail + email + Api.ECacheKey.Id + accountId;
5017
+ }
5018
+ User.GetEmailCacheKey = GetEmailCacheKey;
5014
5019
  var EType;
5015
5020
  (function (EType) {
5016
5021
  EType["User"] = "LOGIN_USER";
@@ -5102,6 +5107,29 @@ var User;
5102
5107
  return Api.ECacheKey.User + Api.ECacheKey.Account + Api.ECacheKey.Id + accountId;
5103
5108
  }
5104
5109
  LoginUser.GetListCacheKey = GetListCacheKey;
5110
+ function GetByEmail(api, email, accountId) {
5111
+ return __awaiter(this, void 0, void 0, function () {
5112
+ var cacheData, req;
5113
+ return __generator(this, function (_a) {
5114
+ switch (_a.label) {
5115
+ case 0:
5116
+ if (!email) {
5117
+ throw ("Email is required.");
5118
+ }
5119
+ cacheData = api.Cache.Get(GetEmailCacheKey(email, accountId));
5120
+ if (cacheData) {
5121
+ return [2 /*return*/, cacheData];
5122
+ }
5123
+ return [4 /*yield*/, api.GET("userByEmail/" + email + (accountId ? "?clientAccountID=" + accountId : ""))];
5124
+ case 1:
5125
+ req = _a.sent();
5126
+ api.Cache.Set(GetEmailCacheKey(email, accountId), req, Api.DEFAULT_CACHE_DURATION);
5127
+ return [2 /*return*/, req];
5128
+ }
5129
+ });
5130
+ });
5131
+ }
5132
+ LoginUser.GetByEmail = GetByEmail;
5105
5133
  function GetList(api, accountId, exclusive) {
5106
5134
  return __awaiter(this, void 0, void 0, function () {
5107
5135
  var cacheData, req;
@@ -5188,12 +5216,12 @@ var User;
5188
5216
  /**
5189
5217
  * Completes signup using user data and a signup code.
5190
5218
  * @param api
5191
- * @param accountId
5192
5219
  * @param code
5193
5220
  * @param data
5221
+ * @param accountId
5194
5222
  * @returns
5195
5223
  */
5196
- function SignupComplete(api, accountId, code, data) {
5224
+ function SignupComplete(api, code, data, accountId) {
5197
5225
  return __awaiter(this, void 0, void 0, function () {
5198
5226
  var res;
5199
5227
  return __generator(this, function (_a) {
@@ -5206,7 +5234,7 @@ var User;
5206
5234
  data.IsActivated = true;
5207
5235
  data.IsDisabled = false;
5208
5236
  data.key = code;
5209
- return [4 /*yield*/, api.POST("UserActivate/" + accountId, data)];
5237
+ return [4 /*yield*/, api.POST("UserActivate/" + (accountId ? accountId : ""), data)];
5210
5238
  case 1:
5211
5239
  res = _a.sent();
5212
5240
  api.Cache.RemoveByContains(Api.ECacheKey.User + Api.ECacheKey.Id + res.ID);