bruce-models 0.1.7 → 0.1.8
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 +353 -7
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +347 -6
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/account/account.js +213 -0
- package/dist/lib/account/account.js.map +1 -0
- package/dist/lib/bruce-models.js +1 -0
- package/dist/lib/bruce-models.js.map +1 -1
- package/dist/lib/user/user.js +179 -6
- package/dist/lib/user/user.js.map +1 -1
- package/dist/types/account/account.d.ts +46 -0
- package/dist/types/bruce-models.d.ts +1 -0
- package/dist/types/user/user.d.ts +41 -0
- package/package.json +1 -1
package/dist/bruce-models.umd.js
CHANGED
|
@@ -4875,6 +4875,39 @@
|
|
|
4875
4875
|
});
|
|
4876
4876
|
}
|
|
4877
4877
|
User.Update = Update;
|
|
4878
|
+
function GetUsernameAvailable(api, username) {
|
|
4879
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4880
|
+
var req, prom;
|
|
4881
|
+
var _this = this;
|
|
4882
|
+
return __generator(this, function (_a) {
|
|
4883
|
+
if (!username) {
|
|
4884
|
+
throw ("Username is required.");
|
|
4885
|
+
}
|
|
4886
|
+
req = api.GET("user/loginavailable/" + username);
|
|
4887
|
+
prom = new Promise(function (rej, res) { return __awaiter(_this, void 0, void 0, function () {
|
|
4888
|
+
var data, e_1;
|
|
4889
|
+
return __generator(this, function (_a) {
|
|
4890
|
+
switch (_a.label) {
|
|
4891
|
+
case 0:
|
|
4892
|
+
_a.trys.push([0, 2, , 3]);
|
|
4893
|
+
return [4 /*yield*/, req];
|
|
4894
|
+
case 1:
|
|
4895
|
+
data = _a.sent();
|
|
4896
|
+
res(data.IsAvailable);
|
|
4897
|
+
return [3 /*break*/, 3];
|
|
4898
|
+
case 2:
|
|
4899
|
+
e_1 = _a.sent();
|
|
4900
|
+
rej(e_1);
|
|
4901
|
+
return [3 /*break*/, 3];
|
|
4902
|
+
case 3: return [2 /*return*/];
|
|
4903
|
+
}
|
|
4904
|
+
});
|
|
4905
|
+
}); });
|
|
4906
|
+
return [2 /*return*/, prom];
|
|
4907
|
+
});
|
|
4908
|
+
});
|
|
4909
|
+
}
|
|
4910
|
+
User.GetUsernameAvailable = GetUsernameAvailable;
|
|
4878
4911
|
var LoginUser;
|
|
4879
4912
|
(function (LoginUser) {
|
|
4880
4913
|
function GetListCacheKey(accountId) {
|
|
@@ -4897,7 +4930,7 @@
|
|
|
4897
4930
|
return [2 /*return*/, cacheData];
|
|
4898
4931
|
}
|
|
4899
4932
|
req = new Promise(function (res, rej) { return __awaiter(_this, void 0, void 0, function () {
|
|
4900
|
-
var data,
|
|
4933
|
+
var data, e_2;
|
|
4901
4934
|
return __generator(this, function (_a) {
|
|
4902
4935
|
switch (_a.label) {
|
|
4903
4936
|
case 0:
|
|
@@ -4908,8 +4941,8 @@
|
|
|
4908
4941
|
res(data.Items);
|
|
4909
4942
|
return [3 /*break*/, 3];
|
|
4910
4943
|
case 2:
|
|
4911
|
-
|
|
4912
|
-
rej(
|
|
4944
|
+
e_2 = _a.sent();
|
|
4945
|
+
rej(e_2);
|
|
4913
4946
|
return [3 /*break*/, 3];
|
|
4914
4947
|
case 3: return [2 /*return*/];
|
|
4915
4948
|
}
|
|
@@ -4928,6 +4961,146 @@
|
|
|
4928
4961
|
});
|
|
4929
4962
|
}
|
|
4930
4963
|
LoginUser.GetList = GetList;
|
|
4964
|
+
/**
|
|
4965
|
+
* Sends a signup email to the specified email address.
|
|
4966
|
+
* @param api
|
|
4967
|
+
* @param email
|
|
4968
|
+
* @returns
|
|
4969
|
+
*/
|
|
4970
|
+
function Signup(api, email) {
|
|
4971
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4972
|
+
return __generator(this, function (_a) {
|
|
4973
|
+
if (!email) {
|
|
4974
|
+
throw ("Email is required.");
|
|
4975
|
+
}
|
|
4976
|
+
return [2 /*return*/, api.POST("clientaccount/signup", {
|
|
4977
|
+
Email: email
|
|
4978
|
+
})];
|
|
4979
|
+
});
|
|
4980
|
+
});
|
|
4981
|
+
}
|
|
4982
|
+
LoginUser.Signup = Signup;
|
|
4983
|
+
/**
|
|
4984
|
+
* Sends a new signup email using a previous one's expired code.
|
|
4985
|
+
* @param api
|
|
4986
|
+
* @param expiredCode
|
|
4987
|
+
* @returns
|
|
4988
|
+
*/
|
|
4989
|
+
function SignupResend(api, expiredCode) {
|
|
4990
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4991
|
+
return __generator(this, function (_a) {
|
|
4992
|
+
if (!expiredCode) {
|
|
4993
|
+
throw ("Expired activation code is required.");
|
|
4994
|
+
}
|
|
4995
|
+
return [2 /*return*/, api.POST("clientaccount/signup/resend?activationKey=" + exports.Api.Encode(expiredCode), null)];
|
|
4996
|
+
});
|
|
4997
|
+
});
|
|
4998
|
+
}
|
|
4999
|
+
LoginUser.SignupResend = SignupResend;
|
|
5000
|
+
/**
|
|
5001
|
+
* Completes signup using user data and a signup code.
|
|
5002
|
+
* @param api
|
|
5003
|
+
* @param accountId
|
|
5004
|
+
* @param code
|
|
5005
|
+
* @param data
|
|
5006
|
+
* @returns
|
|
5007
|
+
*/
|
|
5008
|
+
function SignupComplete(api, accountId, code, data) {
|
|
5009
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
5010
|
+
var res;
|
|
5011
|
+
return __generator(this, function (_a) {
|
|
5012
|
+
switch (_a.label) {
|
|
5013
|
+
case 0:
|
|
5014
|
+
if (!code || !accountId) {
|
|
5015
|
+
throw ("Activation code and account ID are required.");
|
|
5016
|
+
}
|
|
5017
|
+
if (!(data === null || data === void 0 ? void 0 : data.Login) || !(data === null || data === void 0 ? void 0 : data.Password)) {
|
|
5018
|
+
throw ("Login and password are required.");
|
|
5019
|
+
}
|
|
5020
|
+
data = JSON.parse(JSON.stringify(data));
|
|
5021
|
+
data.IsActivated = true;
|
|
5022
|
+
data.IsDisabled = false;
|
|
5023
|
+
data.key = code;
|
|
5024
|
+
return [4 /*yield*/, api.POST("UserActivate/" + accountId, data)];
|
|
5025
|
+
case 1:
|
|
5026
|
+
res = _a.sent();
|
|
5027
|
+
api.Cache.RemoveByContains(exports.Api.ECacheKey.User + exports.Api.ECacheKey.Id + res.ID);
|
|
5028
|
+
return [2 /*return*/, res];
|
|
5029
|
+
}
|
|
5030
|
+
});
|
|
5031
|
+
});
|
|
5032
|
+
}
|
|
5033
|
+
LoginUser.SignupComplete = SignupComplete;
|
|
5034
|
+
/**
|
|
5035
|
+
* Sends a password reset email to the specified email address.
|
|
5036
|
+
* @param api
|
|
5037
|
+
* @param accountId
|
|
5038
|
+
* @param email
|
|
5039
|
+
* @returns user id associated with provided email.
|
|
5040
|
+
*/
|
|
5041
|
+
function ForgotPassword(api, accountId, email) {
|
|
5042
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
5043
|
+
var req, prom;
|
|
5044
|
+
var _this = this;
|
|
5045
|
+
return __generator(this, function (_a) {
|
|
5046
|
+
if (!accountId || !email) {
|
|
5047
|
+
throw ("Account ID and email are required.");
|
|
5048
|
+
}
|
|
5049
|
+
req = api.POST("UserForgotPassword/" + accountId, {
|
|
5050
|
+
Email: email
|
|
5051
|
+
});
|
|
5052
|
+
prom = new Promise(function (res, rej) { return __awaiter(_this, void 0, void 0, function () {
|
|
5053
|
+
var data, e_3;
|
|
5054
|
+
return __generator(this, function (_a) {
|
|
5055
|
+
switch (_a.label) {
|
|
5056
|
+
case 0:
|
|
5057
|
+
_a.trys.push([0, 2, , 3]);
|
|
5058
|
+
return [4 /*yield*/, req];
|
|
5059
|
+
case 1:
|
|
5060
|
+
data = _a.sent();
|
|
5061
|
+
res(data.ID);
|
|
5062
|
+
return [3 /*break*/, 3];
|
|
5063
|
+
case 2:
|
|
5064
|
+
e_3 = _a.sent();
|
|
5065
|
+
rej(e_3);
|
|
5066
|
+
return [3 /*break*/, 3];
|
|
5067
|
+
case 3: return [2 /*return*/];
|
|
5068
|
+
}
|
|
5069
|
+
});
|
|
5070
|
+
}); });
|
|
5071
|
+
return [2 /*return*/, prom];
|
|
5072
|
+
});
|
|
5073
|
+
});
|
|
5074
|
+
}
|
|
5075
|
+
LoginUser.ForgotPassword = ForgotPassword;
|
|
5076
|
+
/**
|
|
5077
|
+
* Completes password reset using a password reset code and new password.
|
|
5078
|
+
* @param api
|
|
5079
|
+
* @param code
|
|
5080
|
+
* @param userId
|
|
5081
|
+
* @param password
|
|
5082
|
+
* @returns
|
|
5083
|
+
*/
|
|
5084
|
+
function ForgotPasswordComplete(api, code, userId, password) {
|
|
5085
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
5086
|
+
var user;
|
|
5087
|
+
return __generator(this, function (_a) {
|
|
5088
|
+
switch (_a.label) {
|
|
5089
|
+
case 0: return [4 /*yield*/, Get(api, userId, "")];
|
|
5090
|
+
case 1:
|
|
5091
|
+
user = _a.sent();
|
|
5092
|
+
return [2 /*return*/, api.POST("UserSetNameAndPassword", {
|
|
5093
|
+
ID: userId,
|
|
5094
|
+
Email: user.Email,
|
|
5095
|
+
ActivationCode: code,
|
|
5096
|
+
Password: password,
|
|
5097
|
+
FullName: user.FullName
|
|
5098
|
+
})];
|
|
5099
|
+
}
|
|
5100
|
+
});
|
|
5101
|
+
});
|
|
5102
|
+
}
|
|
5103
|
+
LoginUser.ForgotPasswordComplete = ForgotPasswordComplete;
|
|
4931
5104
|
})(LoginUser = User.LoginUser || (User.LoginUser = {}));
|
|
4932
5105
|
var AccessToken;
|
|
4933
5106
|
(function (AccessToken) {
|
|
@@ -4945,7 +5118,7 @@
|
|
|
4945
5118
|
return [2 /*return*/, cacheData];
|
|
4946
5119
|
}
|
|
4947
5120
|
req = new Promise(function (res, rej) { return __awaiter(_this, void 0, void 0, function () {
|
|
4948
|
-
var data,
|
|
5121
|
+
var data, e_4;
|
|
4949
5122
|
return __generator(this, function (_a) {
|
|
4950
5123
|
switch (_a.label) {
|
|
4951
5124
|
case 0:
|
|
@@ -4956,8 +5129,8 @@
|
|
|
4956
5129
|
res(data.Items);
|
|
4957
5130
|
return [3 /*break*/, 3];
|
|
4958
5131
|
case 2:
|
|
4959
|
-
|
|
4960
|
-
rej(
|
|
5132
|
+
e_4 = _a.sent();
|
|
5133
|
+
rej(e_4);
|
|
4961
5134
|
return [3 /*break*/, 3];
|
|
4962
5135
|
case 3: return [2 /*return*/];
|
|
4963
5136
|
}
|
|
@@ -5175,6 +5348,174 @@
|
|
|
5175
5348
|
UrlUtils.Handler = Handler;
|
|
5176
5349
|
})(exports.UrlUtils || (exports.UrlUtils = {}));
|
|
5177
5350
|
|
|
5351
|
+
var ACCOUNT_EXCLUSIONS = ["hyperportal", "hypeportal", "bviewer"];
|
|
5352
|
+
(function (Account) {
|
|
5353
|
+
function GetCacheKey(accountId, appSettingsId) {
|
|
5354
|
+
if (appSettingsId) {
|
|
5355
|
+
return exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + accountId + exports.Api.ECacheKey + appSettingsId;
|
|
5356
|
+
}
|
|
5357
|
+
return exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + accountId;
|
|
5358
|
+
}
|
|
5359
|
+
Account.GetCacheKey = GetCacheKey;
|
|
5360
|
+
function GetListCacheKey(ssid) {
|
|
5361
|
+
return exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Session + exports.Api.ECacheKey.Id + ssid;
|
|
5362
|
+
}
|
|
5363
|
+
Account.GetListCacheKey = GetListCacheKey;
|
|
5364
|
+
var EDbRegion;
|
|
5365
|
+
(function (EDbRegion) {
|
|
5366
|
+
EDbRegion["USA"] = "US";
|
|
5367
|
+
EDbRegion["Paris"] = "EU";
|
|
5368
|
+
EDbRegion["Singapore"] = "SE";
|
|
5369
|
+
EDbRegion["Australia"] = "AU";
|
|
5370
|
+
})(EDbRegion || (EDbRegion = {}));
|
|
5371
|
+
function Get(api, id) {
|
|
5372
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
5373
|
+
var cacheData, req;
|
|
5374
|
+
return __generator(this, function (_a) {
|
|
5375
|
+
switch (_a.label) {
|
|
5376
|
+
case 0:
|
|
5377
|
+
cacheData = api.Cache.Get(GetCacheKey(id));
|
|
5378
|
+
if (cacheData) {
|
|
5379
|
+
return [2 /*return*/, cacheData];
|
|
5380
|
+
}
|
|
5381
|
+
return [4 /*yield*/, api.GET("account/" + id)];
|
|
5382
|
+
case 1:
|
|
5383
|
+
req = _a.sent();
|
|
5384
|
+
api.Cache.Set(GetCacheKey(id), req, exports.Api.DEFAULT_CACHE_DURATION);
|
|
5385
|
+
return [2 /*return*/, req];
|
|
5386
|
+
}
|
|
5387
|
+
});
|
|
5388
|
+
});
|
|
5389
|
+
}
|
|
5390
|
+
Account.Get = Get;
|
|
5391
|
+
function GetRelatedList(api) {
|
|
5392
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
5393
|
+
var cacheData, req, prom;
|
|
5394
|
+
var _this = this;
|
|
5395
|
+
return __generator(this, function (_a) {
|
|
5396
|
+
cacheData = api.Cache.Get(GetListCacheKey(api.GetSessionId()));
|
|
5397
|
+
if (cacheData) {
|
|
5398
|
+
return [2 /*return*/, cacheData];
|
|
5399
|
+
}
|
|
5400
|
+
req = api.GET("user/relatedClientAccounts");
|
|
5401
|
+
prom = new Promise(function (res, rej) { return __awaiter(_this, void 0, void 0, function () {
|
|
5402
|
+
var data, items, e_1;
|
|
5403
|
+
return __generator(this, function (_a) {
|
|
5404
|
+
switch (_a.label) {
|
|
5405
|
+
case 0:
|
|
5406
|
+
_a.trys.push([0, 2, , 3]);
|
|
5407
|
+
return [4 /*yield*/, req];
|
|
5408
|
+
case 1:
|
|
5409
|
+
data = _a.sent();
|
|
5410
|
+
items = data.Items.filter(function (x) { return !ACCOUNT_EXCLUSIONS.includes(x.ID); });
|
|
5411
|
+
res(items);
|
|
5412
|
+
return [3 /*break*/, 3];
|
|
5413
|
+
case 2:
|
|
5414
|
+
e_1 = _a.sent();
|
|
5415
|
+
rej(e_1);
|
|
5416
|
+
return [3 /*break*/, 3];
|
|
5417
|
+
case 3: return [2 /*return*/];
|
|
5418
|
+
}
|
|
5419
|
+
});
|
|
5420
|
+
}); });
|
|
5421
|
+
api.Cache.Set(GetListCacheKey(api.GetSessionId()), prom, exports.Api.DEFAULT_CACHE_DURATION);
|
|
5422
|
+
return [2 /*return*/, prom];
|
|
5423
|
+
});
|
|
5424
|
+
});
|
|
5425
|
+
}
|
|
5426
|
+
Account.GetRelatedList = GetRelatedList;
|
|
5427
|
+
function GetAppSettings(api, id, appId) {
|
|
5428
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
5429
|
+
var cacheData, req, prom;
|
|
5430
|
+
var _this = this;
|
|
5431
|
+
return __generator(this, function (_a) {
|
|
5432
|
+
switch (_a.label) {
|
|
5433
|
+
case 0:
|
|
5434
|
+
cacheData = api.Cache.Get(GetCacheKey(id, appId));
|
|
5435
|
+
if (cacheData) {
|
|
5436
|
+
return [2 /*return*/, cacheData];
|
|
5437
|
+
}
|
|
5438
|
+
return [4 /*yield*/, api.GET("account/" + id + "?ApplicationID=" + appId)];
|
|
5439
|
+
case 1:
|
|
5440
|
+
req = _a.sent();
|
|
5441
|
+
prom = new Promise(function (res, rej) { return __awaiter(_this, void 0, void 0, function () {
|
|
5442
|
+
var data, settings, e_2;
|
|
5443
|
+
var _a;
|
|
5444
|
+
return __generator(this, function (_b) {
|
|
5445
|
+
switch (_b.label) {
|
|
5446
|
+
case 0:
|
|
5447
|
+
_b.trys.push([0, 2, , 3]);
|
|
5448
|
+
return [4 /*yield*/, req];
|
|
5449
|
+
case 1:
|
|
5450
|
+
data = _b.sent();
|
|
5451
|
+
settings = (_a = data === null || data === void 0 ? void 0 : data["Application.Settings"]) !== null && _a !== void 0 ? _a : {};
|
|
5452
|
+
res(settings);
|
|
5453
|
+
return [3 /*break*/, 3];
|
|
5454
|
+
case 2:
|
|
5455
|
+
e_2 = _b.sent();
|
|
5456
|
+
rej(e_2);
|
|
5457
|
+
return [3 /*break*/, 3];
|
|
5458
|
+
case 3: return [2 /*return*/];
|
|
5459
|
+
}
|
|
5460
|
+
});
|
|
5461
|
+
}); });
|
|
5462
|
+
api.Cache.Set(GetCacheKey(id, appId), prom, exports.Api.DEFAULT_CACHE_DURATION);
|
|
5463
|
+
return [2 /*return*/, prom];
|
|
5464
|
+
}
|
|
5465
|
+
});
|
|
5466
|
+
});
|
|
5467
|
+
}
|
|
5468
|
+
Account.GetAppSettings = GetAppSettings;
|
|
5469
|
+
/**
|
|
5470
|
+
* WARNING: Do not update API settings without knowing what you're doing.
|
|
5471
|
+
* @param api
|
|
5472
|
+
* @param id
|
|
5473
|
+
* @param appId
|
|
5474
|
+
* @param data
|
|
5475
|
+
* @returns
|
|
5476
|
+
*/
|
|
5477
|
+
function UpdateAppSettings(api, id, appId, data) {
|
|
5478
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
5479
|
+
return __generator(this, function (_a) {
|
|
5480
|
+
switch (_a.label) {
|
|
5481
|
+
case 0: return [4 /*yield*/, api.POST("account/" + id + "/applicationSettings/" + appId, data)];
|
|
5482
|
+
case 1:
|
|
5483
|
+
data = _a.sent();
|
|
5484
|
+
api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + id);
|
|
5485
|
+
return [2 /*return*/, data];
|
|
5486
|
+
}
|
|
5487
|
+
});
|
|
5488
|
+
});
|
|
5489
|
+
}
|
|
5490
|
+
Account.UpdateAppSettings = UpdateAppSettings;
|
|
5491
|
+
/**
|
|
5492
|
+
* Creates a new Bruce account using given details.
|
|
5493
|
+
* @param api
|
|
5494
|
+
* @param id
|
|
5495
|
+
* @param name
|
|
5496
|
+
* @param region
|
|
5497
|
+
* @returns
|
|
5498
|
+
*/
|
|
5499
|
+
function Create(api, id, name, region) {
|
|
5500
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
5501
|
+
var reqData, res;
|
|
5502
|
+
return __generator(this, function (_a) {
|
|
5503
|
+
if (!id || !name || !region) {
|
|
5504
|
+
throw new Error("Id, Name and Region are required.");
|
|
5505
|
+
}
|
|
5506
|
+
reqData = {
|
|
5507
|
+
"Name": name,
|
|
5508
|
+
"DBLocation": region
|
|
5509
|
+
};
|
|
5510
|
+
res = api.POST("clientAccount/" + id, reqData);
|
|
5511
|
+
api.Cache.Remove(GetListCacheKey(api.GetSessionId()));
|
|
5512
|
+
return [2 /*return*/, res];
|
|
5513
|
+
});
|
|
5514
|
+
});
|
|
5515
|
+
}
|
|
5516
|
+
Account.Create = Create;
|
|
5517
|
+
})(exports.Account || (exports.Account = {}));
|
|
5518
|
+
|
|
5178
5519
|
exports.AbstractApi = AbstractApi;
|
|
5179
5520
|
exports.BruceApi = BruceApi;
|
|
5180
5521
|
exports.CamApi = CamApi;
|