@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @iservice365/core
|
|
2
2
|
|
|
3
|
+
## 3.75.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- da435e7: Membership and role lookups by type match every stored spelling of an application: a Property Management lookup finds rows stored as `real_estate_developer` (written before 3.75.0) as well as `property_management_agency`, including the module deny list and the owner-grant cap.
|
|
8
|
+
|
|
3
9
|
## 3.75.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/dist/index.js
CHANGED
|
@@ -3983,6 +3983,20 @@ function serviceAppType(type) {
|
|
|
3983
3983
|
return type;
|
|
3984
3984
|
return APP_TYPE_ALIASES[type] ?? type;
|
|
3985
3985
|
}
|
|
3986
|
+
function storedAppTypes(type) {
|
|
3987
|
+
const app = serviceAppType(type);
|
|
3988
|
+
return [
|
|
3989
|
+
app,
|
|
3990
|
+
...Object.keys(APP_TYPE_ALIASES).filter((alias) => APP_TYPE_ALIASES[alias] === app)
|
|
3991
|
+
];
|
|
3992
|
+
}
|
|
3993
|
+
function appTypeQuery(type) {
|
|
3994
|
+
const types = storedAppTypes(type);
|
|
3995
|
+
return types.length === 1 ? types[0] : { $in: types };
|
|
3996
|
+
}
|
|
3997
|
+
function sameAppType(a, b) {
|
|
3998
|
+
return !!a && !!b && serviceAppType(a) === serviceAppType(b);
|
|
3999
|
+
}
|
|
3986
4000
|
|
|
3987
4001
|
// src/repositories/member.repo.ts
|
|
3988
4002
|
var import_node_server_utils14 = require("@7365admin1/node-server-utils");
|
|
@@ -4280,7 +4294,7 @@ function useMemberRepo() {
|
|
|
4280
4294
|
return cachedData;
|
|
4281
4295
|
}
|
|
4282
4296
|
try {
|
|
4283
|
-
const data = await collection.findOne({ user, type });
|
|
4297
|
+
const data = await collection.findOne({ user, type: appTypeQuery(type) });
|
|
4284
4298
|
if (!data) {
|
|
4285
4299
|
throw new import_node_server_utils14.NotFoundError("Member not found.");
|
|
4286
4300
|
}
|
|
@@ -4424,7 +4438,7 @@ function useMemberRepo() {
|
|
|
4424
4438
|
search = search || "";
|
|
4425
4439
|
page = page > 0 ? page - 1 : 0;
|
|
4426
4440
|
const query2 = {
|
|
4427
|
-
type:
|
|
4441
|
+
type: type ? appTypeQuery(type) : type,
|
|
4428
4442
|
status
|
|
4429
4443
|
};
|
|
4430
4444
|
const cacheOptions = {
|
|
@@ -4553,7 +4567,7 @@ function useMemberRepo() {
|
|
|
4553
4567
|
const query2 = {
|
|
4554
4568
|
user,
|
|
4555
4569
|
org: { $nin: [null, ""] },
|
|
4556
|
-
type
|
|
4570
|
+
type: appTypeQuery(type)
|
|
4557
4571
|
};
|
|
4558
4572
|
const cacheOptions = {
|
|
4559
4573
|
page,
|
|
@@ -4970,7 +4984,7 @@ function useMemberRepo() {
|
|
|
4970
4984
|
try {
|
|
4971
4985
|
const data = await collection.findOne({
|
|
4972
4986
|
user,
|
|
4973
|
-
type,
|
|
4987
|
+
type: appTypeQuery(type),
|
|
4974
4988
|
org
|
|
4975
4989
|
});
|
|
4976
4990
|
if (!data) {
|
|
@@ -10548,7 +10562,7 @@ function pickSiteMembership(rows, type, site, org = "") {
|
|
|
10548
10562
|
if (!site)
|
|
10549
10563
|
return null;
|
|
10550
10564
|
const live = rows.filter(
|
|
10551
|
-
(m) => m.type
|
|
10565
|
+
(m) => sameAppType(m.type, type) && isLiveMembership(m) && (!org || idOf2(m.org) === org)
|
|
10552
10566
|
);
|
|
10553
10567
|
const atSite = live.find((m) => idOf2(m.siteId) === site);
|
|
10554
10568
|
if (atSite)
|
|
@@ -10562,10 +10576,10 @@ function pickLookupMembership(rows, type, site = "", org = "") {
|
|
|
10562
10576
|
const atSite = site ? pickSiteMembership(list, type, site, org) : null;
|
|
10563
10577
|
if (atSite)
|
|
10564
10578
|
return atSite;
|
|
10565
|
-
const inOrg = org ? list.find((m) => m.type
|
|
10579
|
+
const inOrg = org ? list.find((m) => sameAppType(m.type, type) && idOf2(m.org) === org.toLowerCase()) : void 0;
|
|
10566
10580
|
if (inOrg && isLiveMembership(inOrg))
|
|
10567
10581
|
return inOrg;
|
|
10568
|
-
return list.find((m) => m.type
|
|
10582
|
+
return list.find((m) => sameAppType(m.type, type)) ?? null;
|
|
10569
10583
|
}
|
|
10570
10584
|
function memberListSiteScope(memberships, org) {
|
|
10571
10585
|
const inOrg = (memberships ?? []).filter((m) => idOf2(m.org) === idOf2(org));
|
|
@@ -12518,7 +12532,7 @@ function useRoleRepo() {
|
|
|
12518
12532
|
return cachedData;
|
|
12519
12533
|
}
|
|
12520
12534
|
try {
|
|
12521
|
-
const data = await collection.find({ org, permissions: "*", type, status: "active" }).toArray();
|
|
12535
|
+
const data = await collection.find({ org, permissions: "*", type: appTypeQuery(type), status: "active" }).toArray();
|
|
12522
12536
|
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
12523
12537
|
import_node_server_utils42.logger.info(`Cache set for key: ${cacheKey}`);
|
|
12524
12538
|
}).catch((err) => {
|
|
@@ -12558,7 +12572,7 @@ function useRoleRepo() {
|
|
|
12558
12572
|
throw new import_node_server_utils42.BadRequestError("Role name is required.");
|
|
12559
12573
|
}
|
|
12560
12574
|
type = serviceAppType(type);
|
|
12561
|
-
const query2 = type ? { name, type } : { name };
|
|
12575
|
+
const query2 = type ? { name, type: appTypeQuery(type) } : { name };
|
|
12562
12576
|
try {
|
|
12563
12577
|
const cacheKey = (0, import_node_server_utils42.makeCacheKey)(namespace_collection3, query2);
|
|
12564
12578
|
const cachedData = await getCache(cacheKey);
|
|
@@ -12614,8 +12628,8 @@ function useRoleRepo() {
|
|
|
12614
12628
|
cacheOptions.search = search;
|
|
12615
12629
|
}
|
|
12616
12630
|
if (type) {
|
|
12617
|
-
query2.type =
|
|
12618
|
-
cacheOptions.type =
|
|
12631
|
+
query2.type = appTypeQuery(type);
|
|
12632
|
+
cacheOptions.type = serviceAppType(type);
|
|
12619
12633
|
}
|
|
12620
12634
|
const cacheKey = (0, import_node_server_utils42.makeCacheKey)(namespace_collection3, cacheOptions);
|
|
12621
12635
|
const cachedData = await getCache(cacheKey);
|
|
@@ -15326,12 +15340,11 @@ async function ownerGrantCeiling(org, type) {
|
|
|
15326
15340
|
return null;
|
|
15327
15341
|
try {
|
|
15328
15342
|
const orgDoc = await useOrgRepo().getById(orgId).catch(() => null);
|
|
15329
|
-
|
|
15330
|
-
if (!orgDoc?.invitedRole || appType !== type)
|
|
15343
|
+
if (!orgDoc?.invitedRole || !sameAppType(orgDoc?.nature, type))
|
|
15331
15344
|
return null;
|
|
15332
15345
|
const role = await useRoleRepo().getRoleById(String(orgDoc.invitedRole)).catch(() => null);
|
|
15333
15346
|
const permissions = role?.permissions;
|
|
15334
|
-
const chosen = role && String(role.org ?? "") === orgId && role.default === true && role.type
|
|
15347
|
+
const chosen = role && String(role.org ?? "") === orgId && role.default === true && sameAppType(role.type, type) && Array.isArray(permissions) && permissions.length > 0 && !permissions.includes("*");
|
|
15335
15348
|
return chosen ? permissions.map(String) : null;
|
|
15336
15349
|
} catch {
|
|
15337
15350
|
return null;
|
|
@@ -26283,7 +26296,7 @@ function useOrgController() {
|
|
|
26283
26296
|
invitedModules?.permissions
|
|
26284
26297
|
);
|
|
26285
26298
|
const appOwnerRole = invitedModules?.permissions.length ? seededRoles.find(
|
|
26286
|
-
(role) => role.type
|
|
26299
|
+
(role) => sameAppType(role.type, body.nature) && role.name === "owner"
|
|
26287
26300
|
) : void 0;
|
|
26288
26301
|
if (appOwnerRole) {
|
|
26289
26302
|
try {
|