bruce-models 1.3.0 → 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 +83 -18
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +83 -18
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/account/account.js +24 -18
- package/dist/lib/account/account.js.map +1 -1
- package/dist/lib/api/api.js +2 -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/account/account.d.ts +8 -5
- package/dist/types/api/api.d.ts +2 -0
- package/dist/types/user/user.d.ts +25 -1
- package/package.json +1 -1
package/dist/bruce-models.umd.js
CHANGED
|
@@ -59,10 +59,12 @@
|
|
|
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";
|
|
65
66
|
ECacheKey["Account"] = "account";
|
|
67
|
+
ECacheKey["DatabaseRegion"] = "databaseregion";
|
|
66
68
|
ECacheKey["CustomForm"] = "customform";
|
|
67
69
|
ECacheKey["ImportedFile"] = "importedfile";
|
|
68
70
|
})(ECacheKey = Api.ECacheKey || (Api.ECacheKey = {}));
|
|
@@ -626,6 +628,10 @@
|
|
|
626
628
|
return exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Session + exports.Api.ECacheKey.Id + ssid;
|
|
627
629
|
}
|
|
628
630
|
Account.GetListCacheKey = GetListCacheKey;
|
|
631
|
+
function GetDbRegionListCacheKey() {
|
|
632
|
+
return exports.Api.ECacheKey.DatabaseRegion;
|
|
633
|
+
}
|
|
634
|
+
Account.GetDbRegionListCacheKey = GetDbRegionListCacheKey;
|
|
629
635
|
let EDbRegion;
|
|
630
636
|
(function (EDbRegion) {
|
|
631
637
|
EDbRegion["USA"] = "US";
|
|
@@ -642,24 +648,6 @@
|
|
|
642
648
|
EStarterContent["Default"] = "default";
|
|
643
649
|
EStarterContent["None"] = "none";
|
|
644
650
|
})(EStarterContent = Account.EStarterContent || (Account.EStarterContent = {}));
|
|
645
|
-
Account.DbRegions = [
|
|
646
|
-
{
|
|
647
|
-
name: "North California, USA",
|
|
648
|
-
value: EDbRegion.USA
|
|
649
|
-
},
|
|
650
|
-
{
|
|
651
|
-
name: "Paris, France",
|
|
652
|
-
value: EDbRegion.Paris
|
|
653
|
-
},
|
|
654
|
-
{
|
|
655
|
-
name: "Singapore",
|
|
656
|
-
value: EDbRegion.Singapore
|
|
657
|
-
},
|
|
658
|
-
{
|
|
659
|
-
name: "Sydney, Australia",
|
|
660
|
-
value: EDbRegion.Australia
|
|
661
|
-
}
|
|
662
|
-
];
|
|
663
651
|
function Get(api, id, reqParams) {
|
|
664
652
|
return __awaiter(this, void 0, void 0, function* () {
|
|
665
653
|
const cacheData = api.GetCacheItem(GetCacheKey(id), reqParams);
|
|
@@ -763,6 +751,26 @@
|
|
|
763
751
|
});
|
|
764
752
|
}
|
|
765
753
|
Account.Create = Create;
|
|
754
|
+
function GetDbRegions(api, reqParams) {
|
|
755
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
756
|
+
const cacheData = api.GetCacheItem(GetDbRegionListCacheKey(), reqParams);
|
|
757
|
+
if (cacheData) {
|
|
758
|
+
return cacheData;
|
|
759
|
+
}
|
|
760
|
+
const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
761
|
+
try {
|
|
762
|
+
const data = yield api.GET("config/regions", exports.Api.PrepReqParams(reqParams));
|
|
763
|
+
res(data.regions);
|
|
764
|
+
}
|
|
765
|
+
catch (e) {
|
|
766
|
+
rej(e);
|
|
767
|
+
}
|
|
768
|
+
}));
|
|
769
|
+
api.Cache.Set(GetDbRegionListCacheKey(), prom, exports.Api.DEFAULT_CACHE_DURATION);
|
|
770
|
+
return prom;
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
Account.GetDbRegions = GetDbRegions;
|
|
766
774
|
})(exports.Account || (exports.Account = {}));
|
|
767
775
|
|
|
768
776
|
(function (MessageBroker) {
|
|
@@ -5368,6 +5376,10 @@
|
|
|
5368
5376
|
return exports.Api.ECacheKey.User + exports.Api.ECacheKey.UserEmail + email + exports.Api.ECacheKey.Id + accountId;
|
|
5369
5377
|
}
|
|
5370
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;
|
|
5371
5383
|
let EType;
|
|
5372
5384
|
(function (EType) {
|
|
5373
5385
|
EType["User"] = "LOGIN_USER";
|
|
@@ -5405,6 +5417,59 @@
|
|
|
5405
5417
|
});
|
|
5406
5418
|
}
|
|
5407
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;
|
|
5408
5473
|
function GetUsernameAvailable(api, username, reqParams) {
|
|
5409
5474
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5410
5475
|
if (!username) {
|