@7365admin1/core 3.75.0 → 3.75.1
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/CHANGELOG.md +6 -0
- package/dist/index.js +28 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/test/default-staff-role.test.mjs +1 -1
- package/test/e2e/client-invite-service365.e2e.test.mjs +57 -0
- package/test/service-app-type.test.mjs +35 -0
package/dist/index.mjs
CHANGED
|
@@ -3175,6 +3175,20 @@ function serviceAppType(type) {
|
|
|
3175
3175
|
return type;
|
|
3176
3176
|
return APP_TYPE_ALIASES[type] ?? type;
|
|
3177
3177
|
}
|
|
3178
|
+
function storedAppTypes(type) {
|
|
3179
|
+
const app = serviceAppType(type);
|
|
3180
|
+
return [
|
|
3181
|
+
app,
|
|
3182
|
+
...Object.keys(APP_TYPE_ALIASES).filter((alias) => APP_TYPE_ALIASES[alias] === app)
|
|
3183
|
+
];
|
|
3184
|
+
}
|
|
3185
|
+
function appTypeQuery(type) {
|
|
3186
|
+
const types = storedAppTypes(type);
|
|
3187
|
+
return types.length === 1 ? types[0] : { $in: types };
|
|
3188
|
+
}
|
|
3189
|
+
function sameAppType(a, b) {
|
|
3190
|
+
return !!a && !!b && serviceAppType(a) === serviceAppType(b);
|
|
3191
|
+
}
|
|
3178
3192
|
|
|
3179
3193
|
// src/repositories/member.repo.ts
|
|
3180
3194
|
import {
|
|
@@ -3482,7 +3496,7 @@ function useMemberRepo() {
|
|
|
3482
3496
|
return cachedData;
|
|
3483
3497
|
}
|
|
3484
3498
|
try {
|
|
3485
|
-
const data = await collection.findOne({ user, type });
|
|
3499
|
+
const data = await collection.findOne({ user, type: appTypeQuery(type) });
|
|
3486
3500
|
if (!data) {
|
|
3487
3501
|
throw new NotFoundError5("Member not found.");
|
|
3488
3502
|
}
|
|
@@ -3626,7 +3640,7 @@ function useMemberRepo() {
|
|
|
3626
3640
|
search = search || "";
|
|
3627
3641
|
page = page > 0 ? page - 1 : 0;
|
|
3628
3642
|
const query2 = {
|
|
3629
|
-
type:
|
|
3643
|
+
type: type ? appTypeQuery(type) : type,
|
|
3630
3644
|
status
|
|
3631
3645
|
};
|
|
3632
3646
|
const cacheOptions = {
|
|
@@ -3755,7 +3769,7 @@ function useMemberRepo() {
|
|
|
3755
3769
|
const query2 = {
|
|
3756
3770
|
user,
|
|
3757
3771
|
org: { $nin: [null, ""] },
|
|
3758
|
-
type
|
|
3772
|
+
type: appTypeQuery(type)
|
|
3759
3773
|
};
|
|
3760
3774
|
const cacheOptions = {
|
|
3761
3775
|
page,
|
|
@@ -4172,7 +4186,7 @@ function useMemberRepo() {
|
|
|
4172
4186
|
try {
|
|
4173
4187
|
const data = await collection.findOne({
|
|
4174
4188
|
user,
|
|
4175
|
-
type,
|
|
4189
|
+
type: appTypeQuery(type),
|
|
4176
4190
|
org
|
|
4177
4191
|
});
|
|
4178
4192
|
if (!data) {
|
|
@@ -9836,7 +9850,7 @@ function pickSiteMembership(rows, type, site, org = "") {
|
|
|
9836
9850
|
if (!site)
|
|
9837
9851
|
return null;
|
|
9838
9852
|
const live = rows.filter(
|
|
9839
|
-
(m) => m.type
|
|
9853
|
+
(m) => sameAppType(m.type, type) && isLiveMembership(m) && (!org || idOf2(m.org) === org)
|
|
9840
9854
|
);
|
|
9841
9855
|
const atSite = live.find((m) => idOf2(m.siteId) === site);
|
|
9842
9856
|
if (atSite)
|
|
@@ -9850,10 +9864,10 @@ function pickLookupMembership(rows, type, site = "", org = "") {
|
|
|
9850
9864
|
const atSite = site ? pickSiteMembership(list, type, site, org) : null;
|
|
9851
9865
|
if (atSite)
|
|
9852
9866
|
return atSite;
|
|
9853
|
-
const inOrg = org ? list.find((m) => m.type
|
|
9867
|
+
const inOrg = org ? list.find((m) => sameAppType(m.type, type) && idOf2(m.org) === org.toLowerCase()) : void 0;
|
|
9854
9868
|
if (inOrg && isLiveMembership(inOrg))
|
|
9855
9869
|
return inOrg;
|
|
9856
|
-
return list.find((m) => m.type
|
|
9870
|
+
return list.find((m) => sameAppType(m.type, type)) ?? null;
|
|
9857
9871
|
}
|
|
9858
9872
|
function memberListSiteScope(memberships, org) {
|
|
9859
9873
|
const inOrg = (memberships ?? []).filter((m) => idOf2(m.org) === idOf2(org));
|
|
@@ -11827,7 +11841,7 @@ function useRoleRepo() {
|
|
|
11827
11841
|
return cachedData;
|
|
11828
11842
|
}
|
|
11829
11843
|
try {
|
|
11830
|
-
const data = await collection.find({ org, permissions: "*", type, status: "active" }).toArray();
|
|
11844
|
+
const data = await collection.find({ org, permissions: "*", type: appTypeQuery(type), status: "active" }).toArray();
|
|
11831
11845
|
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
11832
11846
|
logger22.info(`Cache set for key: ${cacheKey}`);
|
|
11833
11847
|
}).catch((err) => {
|
|
@@ -11867,7 +11881,7 @@ function useRoleRepo() {
|
|
|
11867
11881
|
throw new BadRequestError33("Role name is required.");
|
|
11868
11882
|
}
|
|
11869
11883
|
type = serviceAppType(type);
|
|
11870
|
-
const query2 = type ? { name, type } : { name };
|
|
11884
|
+
const query2 = type ? { name, type: appTypeQuery(type) } : { name };
|
|
11871
11885
|
try {
|
|
11872
11886
|
const cacheKey = makeCacheKey11(namespace_collection3, query2);
|
|
11873
11887
|
const cachedData = await getCache(cacheKey);
|
|
@@ -11923,8 +11937,8 @@ function useRoleRepo() {
|
|
|
11923
11937
|
cacheOptions.search = search;
|
|
11924
11938
|
}
|
|
11925
11939
|
if (type) {
|
|
11926
|
-
query2.type =
|
|
11927
|
-
cacheOptions.type =
|
|
11940
|
+
query2.type = appTypeQuery(type);
|
|
11941
|
+
cacheOptions.type = serviceAppType(type);
|
|
11928
11942
|
}
|
|
11929
11943
|
const cacheKey = makeCacheKey11(namespace_collection3, cacheOptions);
|
|
11930
11944
|
const cachedData = await getCache(cacheKey);
|
|
@@ -14662,12 +14676,11 @@ async function ownerGrantCeiling(org, type) {
|
|
|
14662
14676
|
return null;
|
|
14663
14677
|
try {
|
|
14664
14678
|
const orgDoc = await useOrgRepo().getById(orgId).catch(() => null);
|
|
14665
|
-
|
|
14666
|
-
if (!orgDoc?.invitedRole || appType !== type)
|
|
14679
|
+
if (!orgDoc?.invitedRole || !sameAppType(orgDoc?.nature, type))
|
|
14667
14680
|
return null;
|
|
14668
14681
|
const role = await useRoleRepo().getRoleById(String(orgDoc.invitedRole)).catch(() => null);
|
|
14669
14682
|
const permissions = role?.permissions;
|
|
14670
|
-
const chosen = role && String(role.org ?? "") === orgId && role.default === true && role.type
|
|
14683
|
+
const chosen = role && String(role.org ?? "") === orgId && role.default === true && sameAppType(role.type, type) && Array.isArray(permissions) && permissions.length > 0 && !permissions.includes("*");
|
|
14671
14684
|
return chosen ? permissions.map(String) : null;
|
|
14672
14685
|
} catch {
|
|
14673
14686
|
return null;
|
|
@@ -25673,7 +25686,7 @@ function useOrgController() {
|
|
|
25673
25686
|
invitedModules?.permissions
|
|
25674
25687
|
);
|
|
25675
25688
|
const appOwnerRole = invitedModules?.permissions.length ? seededRoles.find(
|
|
25676
|
-
(role) => role.type
|
|
25689
|
+
(role) => sameAppType(role.type, body.nature) && role.name === "owner"
|
|
25677
25690
|
) : void 0;
|
|
25678
25691
|
if (appOwnerRole) {
|
|
25679
25692
|
try {
|