bruce-models 3.3.1 → 3.3.3
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 +75 -15
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +75 -15
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/account/account.js +64 -6
- package/dist/lib/account/account.js.map +1 -1
- package/dist/lib/bruce-models.js +1 -1
- package/dist/lib/entity/entity.js +10 -8
- package/dist/lib/entity/entity.js.map +1 -1
- package/dist/types/account/account.d.ts +12 -0
- package/dist/types/bruce-models.d.ts +1 -1
- package/dist/types/entity/entity.d.ts +1 -0
- package/package.json +1 -1
package/dist/bruce-models.umd.js
CHANGED
|
@@ -874,19 +874,77 @@
|
|
|
874
874
|
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
875
875
|
return cache.data;
|
|
876
876
|
}
|
|
877
|
-
const
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
877
|
+
const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
878
|
+
try {
|
|
879
|
+
const data = yield api.GET(`accountbyid/${id}`, reqParams);
|
|
880
|
+
// Update the cache by subdomain as well in case it's different to the ID.
|
|
881
|
+
if ((data === null || data === void 0 ? void 0 : data.ID) && (reqParams === null || reqParams === void 0 ? void 0 : reqParams.noCache) != false) {
|
|
882
|
+
yield api.SetCacheItem({
|
|
883
|
+
key: data.Subdomain,
|
|
884
|
+
value: prom,
|
|
885
|
+
req: reqParams
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
res({
|
|
889
|
+
account: data
|
|
890
|
+
});
|
|
891
|
+
}
|
|
892
|
+
catch (e) {
|
|
893
|
+
rej(e);
|
|
894
|
+
}
|
|
895
|
+
}));
|
|
881
896
|
yield api.SetCacheItem({
|
|
882
897
|
key: GetCacheKey(id),
|
|
883
|
-
value:
|
|
898
|
+
value: prom,
|
|
884
899
|
req: reqParams
|
|
885
900
|
});
|
|
886
|
-
return
|
|
901
|
+
return prom;
|
|
887
902
|
});
|
|
888
903
|
}
|
|
889
904
|
Account.Get = Get;
|
|
905
|
+
/**
|
|
906
|
+
* Returns a client account record by subdomain or ID.
|
|
907
|
+
* @param params
|
|
908
|
+
* @returns
|
|
909
|
+
*/
|
|
910
|
+
function GetBySubdomain(params) {
|
|
911
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
912
|
+
let { api, subdomain, req: reqParams } = params;
|
|
913
|
+
if (!api) {
|
|
914
|
+
api = exports.ENVIRONMENT.Api().GetGuardianApi();
|
|
915
|
+
}
|
|
916
|
+
const cache = yield api.GetCacheItem(GetCacheKey(subdomain), reqParams);
|
|
917
|
+
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
918
|
+
return cache.data;
|
|
919
|
+
}
|
|
920
|
+
const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
921
|
+
try {
|
|
922
|
+
const data = yield api.GET(`account/${subdomain}`, reqParams);
|
|
923
|
+
// Update the cache by ID as well in case it's different to the subdomain.
|
|
924
|
+
if ((data === null || data === void 0 ? void 0 : data.ID) && (reqParams === null || reqParams === void 0 ? void 0 : reqParams.noCache) != false) {
|
|
925
|
+
yield api.SetCacheItem({
|
|
926
|
+
key: data.ID,
|
|
927
|
+
value: prom,
|
|
928
|
+
req: reqParams
|
|
929
|
+
});
|
|
930
|
+
}
|
|
931
|
+
res({
|
|
932
|
+
account: data
|
|
933
|
+
});
|
|
934
|
+
}
|
|
935
|
+
catch (e) {
|
|
936
|
+
rej(e);
|
|
937
|
+
}
|
|
938
|
+
}));
|
|
939
|
+
yield api.SetCacheItem({
|
|
940
|
+
key: GetCacheKey(subdomain),
|
|
941
|
+
value: prom,
|
|
942
|
+
req: reqParams
|
|
943
|
+
});
|
|
944
|
+
return prom;
|
|
945
|
+
});
|
|
946
|
+
}
|
|
947
|
+
Account.GetBySubdomain = GetBySubdomain;
|
|
890
948
|
/**
|
|
891
949
|
* Gets a list of client accounts related to the current session user.
|
|
892
950
|
* @param params
|
|
@@ -2719,7 +2777,7 @@
|
|
|
2719
2777
|
*/
|
|
2720
2778
|
function GetListByIds(params) {
|
|
2721
2779
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2722
|
-
let { api, entityIds, req: reqParams, expandRelations } = params;
|
|
2780
|
+
let { api, entityIds, req: reqParams, expandRelations, expandLocation } = params;
|
|
2723
2781
|
if (!entityIds.length) {
|
|
2724
2782
|
throw ("Entity IDs are required.");
|
|
2725
2783
|
}
|
|
@@ -2730,7 +2788,7 @@
|
|
|
2730
2788
|
const reqIds = [];
|
|
2731
2789
|
for (let i = 0; i < entityIds.length; i++) {
|
|
2732
2790
|
const entityId = entityIds[i];
|
|
2733
|
-
const key = GetCacheKey({ entityId, expandRelations });
|
|
2791
|
+
const key = GetCacheKey({ entityId, expandRelations, expandLocation });
|
|
2734
2792
|
const cache = api.GetCacheItem(key, reqParams);
|
|
2735
2793
|
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
2736
2794
|
reqs.push(cache.data);
|
|
@@ -2747,15 +2805,17 @@
|
|
|
2747
2805
|
},
|
|
2748
2806
|
PageSize: reqIds.length
|
|
2749
2807
|
};
|
|
2808
|
+
if (expandRelations) {
|
|
2809
|
+
reqData["Expand"] = "relation";
|
|
2810
|
+
}
|
|
2811
|
+
else if (expandLocation) {
|
|
2812
|
+
reqData["Expand"] = "location";
|
|
2813
|
+
}
|
|
2750
2814
|
if (reqIds.length > 0) {
|
|
2751
|
-
const
|
|
2752
|
-
if (expandRelations) {
|
|
2753
|
-
urlParams.append("$expand", "relation");
|
|
2754
|
-
}
|
|
2755
|
-
const req = api.POST("entities?" + urlParams.toString(), reqData, exports.Api.PrepReqParams(reqParams));
|
|
2815
|
+
const req = api.POST("entities", reqData, exports.Api.PrepReqParams(reqParams));
|
|
2756
2816
|
for (let i = 0; i < reqIds.length; i++) {
|
|
2757
2817
|
const entityId = reqIds[i];
|
|
2758
|
-
const key = GetCacheKey({ entityId });
|
|
2818
|
+
const key = GetCacheKey({ entityId, expandLocation, expandRelations });
|
|
2759
2819
|
const prom = new Promise((res) => __awaiter(this, void 0, void 0, function* () {
|
|
2760
2820
|
try {
|
|
2761
2821
|
const data = yield req;
|
|
@@ -10369,7 +10429,7 @@
|
|
|
10369
10429
|
DataSource.GetList = GetList;
|
|
10370
10430
|
})(exports.DataSource || (exports.DataSource = {}));
|
|
10371
10431
|
|
|
10372
|
-
const VERSION = "3.3.
|
|
10432
|
+
const VERSION = "3.3.3";
|
|
10373
10433
|
|
|
10374
10434
|
exports.VERSION = VERSION;
|
|
10375
10435
|
exports.AbstractApi = AbstractApi;
|