bruce-models 1.3.1 → 1.3.2
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 +58 -0
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +58 -0
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/api/api.js +1 -0
- package/dist/lib/api/api.js.map +1 -1
- package/dist/lib/user/user.js +57 -0
- package/dist/lib/user/user.js.map +1 -1
- package/dist/types/api/api.d.ts +1 -0
- package/dist/types/user/user.d.ts +25 -1
- package/package.json +1 -1
package/dist/bruce-models.umd.js
CHANGED
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
ECacheKey["Style"] = "style";
|
|
60
60
|
ECacheKey["PublishTileset"] = "publishtileset";
|
|
61
61
|
ECacheKey["User"] = "user";
|
|
62
|
+
ECacheKey["UserSettings"] = "usersettings";
|
|
62
63
|
ECacheKey["UserEmail"] = "useremail";
|
|
63
64
|
ECacheKey["AccessToken"] = "accesstoken";
|
|
64
65
|
ECacheKey["UserGroup"] = "usergroup";
|
|
@@ -5375,6 +5376,10 @@
|
|
|
5375
5376
|
return exports.Api.ECacheKey.User + exports.Api.ECacheKey.UserEmail + email + exports.Api.ECacheKey.Id + accountId;
|
|
5376
5377
|
}
|
|
5377
5378
|
User.GetEmailCacheKey = GetEmailCacheKey;
|
|
5379
|
+
function GetSettingsCacheKey(userId, appId) {
|
|
5380
|
+
return exports.Api.ECacheKey.User + exports.Api.ECacheKey.UserSettings + userId + exports.Api.ECacheKey.Id + appId;
|
|
5381
|
+
}
|
|
5382
|
+
User.GetSettingsCacheKey = GetSettingsCacheKey;
|
|
5378
5383
|
let EType;
|
|
5379
5384
|
(function (EType) {
|
|
5380
5385
|
EType["User"] = "LOGIN_USER";
|
|
@@ -5412,6 +5417,59 @@
|
|
|
5412
5417
|
});
|
|
5413
5418
|
}
|
|
5414
5419
|
User.Update = Update;
|
|
5420
|
+
/**
|
|
5421
|
+
* Loads settings for a given user + app.
|
|
5422
|
+
* The session's account id is used to separate settings between accounts.
|
|
5423
|
+
* @param params
|
|
5424
|
+
*/
|
|
5425
|
+
function GetSettings(params) {
|
|
5426
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5427
|
+
const { api, userId, appId, req } = params;
|
|
5428
|
+
if (!userId || !appId) {
|
|
5429
|
+
throw ("UserId and appId are required.");
|
|
5430
|
+
}
|
|
5431
|
+
const cacheData = api.GetCacheItem(GetSettingsCacheKey(userId, appId), req);
|
|
5432
|
+
if (cacheData) {
|
|
5433
|
+
return cacheData;
|
|
5434
|
+
}
|
|
5435
|
+
const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
5436
|
+
try {
|
|
5437
|
+
const data = yield api.GET(`user/${userId}/application/${appId}/settings`);
|
|
5438
|
+
const settings = (data === null || data === void 0 ? void 0 : data.Settings) ? data.Settings : {};
|
|
5439
|
+
res(settings);
|
|
5440
|
+
}
|
|
5441
|
+
catch (e) {
|
|
5442
|
+
rej(e);
|
|
5443
|
+
}
|
|
5444
|
+
}));
|
|
5445
|
+
api.Cache.Set(GetSettingsCacheKey(userId, appId), prom, exports.Api.DEFAULT_CACHE_DURATION);
|
|
5446
|
+
return prom;
|
|
5447
|
+
});
|
|
5448
|
+
}
|
|
5449
|
+
User.GetSettings = GetSettings;
|
|
5450
|
+
/**
|
|
5451
|
+
* Updates settings for a given accId + user + app.
|
|
5452
|
+
* The settings update will replace the existing record, please ensure to merge with existing settings.
|
|
5453
|
+
* @param params
|
|
5454
|
+
*/
|
|
5455
|
+
function UpdateSettings(params) {
|
|
5456
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5457
|
+
const { api, accId, userId, appId, settings, req } = params;
|
|
5458
|
+
if (!accId || !userId || !appId) {
|
|
5459
|
+
throw ("accId, userId and appId are required.");
|
|
5460
|
+
}
|
|
5461
|
+
const postBody = {
|
|
5462
|
+
Settings: settings == null ? {} : settings,
|
|
5463
|
+
Application: appId,
|
|
5464
|
+
ClientAccountID: accId,
|
|
5465
|
+
UserID: userId
|
|
5466
|
+
};
|
|
5467
|
+
const prom = api.POST(`user/${userId}/application/${appId}/settings`, postBody, req);
|
|
5468
|
+
api.Cache.Remove(GetSettingsCacheKey(userId, appId));
|
|
5469
|
+
return prom;
|
|
5470
|
+
});
|
|
5471
|
+
}
|
|
5472
|
+
User.UpdateSettings = UpdateSettings;
|
|
5415
5473
|
function GetUsernameAvailable(api, username, reqParams) {
|
|
5416
5474
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5417
5475
|
if (!username) {
|