@7365admin1/core 3.72.1-staging.321 → 3.72.1-staging.323
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/.changeset/real-estate-developer-app-type.md +5 -0
- package/dist/index.js +27 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/test/backfill-org-owner-roles.test.mjs +6 -1
- package/test/e2e/client-invite-service365.e2e.test.mjs +50 -1
- package/test/org-default-roles.test.mjs +11 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
---
|
|
2
|
+
"@7365admin1/core": minor
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Real Estate Developer clients use the Property Management application: membership and role types `real_estate_developer` are stored and looked up as `property_management_agency`, so a developer's owner can open the Property Management app and the owner grant caps their roles.
|
package/dist/index.js
CHANGED
|
@@ -3987,6 +3987,16 @@ function useUserRepo() {
|
|
|
3987
3987
|
var import_node_server_utils17 = require("@7365admin1/node-server-utils");
|
|
3988
3988
|
var import_uuid = require("uuid");
|
|
3989
3989
|
|
|
3990
|
+
// src/utils/service-app-type.util.ts
|
|
3991
|
+
var APP_TYPE_ALIASES = Object.freeze({
|
|
3992
|
+
real_estate_developer: "property_management_agency"
|
|
3993
|
+
});
|
|
3994
|
+
function serviceAppType(type) {
|
|
3995
|
+
if (typeof type !== "string")
|
|
3996
|
+
return type;
|
|
3997
|
+
return APP_TYPE_ALIASES[type] ?? type;
|
|
3998
|
+
}
|
|
3999
|
+
|
|
3990
4000
|
// src/repositories/member.repo.ts
|
|
3991
4001
|
var import_node_server_utils14 = require("@7365admin1/node-server-utils");
|
|
3992
4002
|
|
|
@@ -4139,7 +4149,7 @@ function useMemberRepo() {
|
|
|
4139
4149
|
}
|
|
4140
4150
|
async function add(value, session) {
|
|
4141
4151
|
try {
|
|
4142
|
-
value = MMember(value);
|
|
4152
|
+
value = MMember({ ...value, type: serviceAppType(value.type) });
|
|
4143
4153
|
await collection.insertOne(value, { session });
|
|
4144
4154
|
delNamespace().then(() => {
|
|
4145
4155
|
import_node_server_utils14.logger.info(`Cache cleared for namespace: ${namespace_collection3}`);
|
|
@@ -4267,6 +4277,7 @@ function useMemberRepo() {
|
|
|
4267
4277
|
}
|
|
4268
4278
|
}
|
|
4269
4279
|
async function getByUserIdType(user, type) {
|
|
4280
|
+
type = serviceAppType(type);
|
|
4270
4281
|
try {
|
|
4271
4282
|
user = new import_mongodb13.ObjectId(user);
|
|
4272
4283
|
} catch (error) {
|
|
@@ -4426,7 +4437,7 @@ function useMemberRepo() {
|
|
|
4426
4437
|
search = search || "";
|
|
4427
4438
|
page = page > 0 ? page - 1 : 0;
|
|
4428
4439
|
const query2 = {
|
|
4429
|
-
type,
|
|
4440
|
+
type: serviceAppType(type),
|
|
4430
4441
|
status
|
|
4431
4442
|
};
|
|
4432
4443
|
const cacheOptions = {
|
|
@@ -4948,6 +4959,7 @@ function useMemberRepo() {
|
|
|
4948
4959
|
}
|
|
4949
4960
|
}
|
|
4950
4961
|
async function getByUserIdTypeOrg(user, type, org) {
|
|
4962
|
+
type = serviceAppType(type);
|
|
4951
4963
|
try {
|
|
4952
4964
|
user = new import_mongodb13.ObjectId(user);
|
|
4953
4965
|
} catch {
|
|
@@ -12515,7 +12527,7 @@ function useRoleRepo() {
|
|
|
12515
12527
|
const { delNamespace, setCache, getCache } = (0, import_node_server_utils42.useCache)(namespace_collection3);
|
|
12516
12528
|
const { delNamespace: _delDashboardNameSpace } = (0, import_node_server_utils42.useCache)("dashboard");
|
|
12517
12529
|
async function addRole(value, session) {
|
|
12518
|
-
value = new MRole(value);
|
|
12530
|
+
value = new MRole({ ...value, type: serviceAppType(value.type) });
|
|
12519
12531
|
try {
|
|
12520
12532
|
const res = await collection.insertOne(value, { session });
|
|
12521
12533
|
delNamespace().then(() => {
|
|
@@ -12618,6 +12630,7 @@ function useRoleRepo() {
|
|
|
12618
12630
|
if (!name) {
|
|
12619
12631
|
throw new import_node_server_utils42.BadRequestError("Role name is required.");
|
|
12620
12632
|
}
|
|
12633
|
+
type = serviceAppType(type);
|
|
12621
12634
|
const query2 = type ? { name, type } : { name };
|
|
12622
12635
|
try {
|
|
12623
12636
|
const cacheKey = (0, import_node_server_utils42.makeCacheKey)(namespace_collection3, query2);
|
|
@@ -12674,8 +12687,8 @@ function useRoleRepo() {
|
|
|
12674
12687
|
cacheOptions.search = search;
|
|
12675
12688
|
}
|
|
12676
12689
|
if (type) {
|
|
12677
|
-
query2.type = type;
|
|
12678
|
-
cacheOptions.type = type;
|
|
12690
|
+
query2.type = serviceAppType(type);
|
|
12691
|
+
cacheOptions.type = query2.type;
|
|
12679
12692
|
}
|
|
12680
12693
|
const cacheKey = (0, import_node_server_utils42.makeCacheKey)(namespace_collection3, cacheOptions);
|
|
12681
12694
|
const cachedData = await getCache(cacheKey);
|
|
@@ -15470,13 +15483,14 @@ function defaultOwnerRoles(org, nature, appOwnerPermissions) {
|
|
|
15470
15483
|
{ ...owner, type: "organization" },
|
|
15471
15484
|
{ ...administrator, type: "organization" }
|
|
15472
15485
|
];
|
|
15473
|
-
|
|
15486
|
+
const appType = serviceAppType(nature);
|
|
15487
|
+
if (appType && APP_SERVICE_TYPES.has(appType)) {
|
|
15474
15488
|
roles.push({
|
|
15475
15489
|
...owner,
|
|
15476
|
-
type:
|
|
15490
|
+
type: appType,
|
|
15477
15491
|
...appOwnerPermissions?.length && { permissions: [...appOwnerPermissions] }
|
|
15478
15492
|
});
|
|
15479
|
-
roles.push({ ...administrator, type:
|
|
15493
|
+
roles.push({ ...administrator, type: appType });
|
|
15480
15494
|
}
|
|
15481
15495
|
return roles;
|
|
15482
15496
|
}
|
|
@@ -15561,15 +15575,17 @@ async function moduleCeiling(org, site) {
|
|
|
15561
15575
|
}
|
|
15562
15576
|
async function ownerGrantCeiling(org, type) {
|
|
15563
15577
|
const orgId = org?.toString() ?? "";
|
|
15578
|
+
type = serviceAppType(type);
|
|
15564
15579
|
if (!orgId || !type)
|
|
15565
15580
|
return null;
|
|
15566
15581
|
try {
|
|
15567
15582
|
const orgDoc = await useOrgRepo().getById(orgId).catch(() => null);
|
|
15568
|
-
|
|
15583
|
+
const appType = serviceAppType(orgDoc?.nature);
|
|
15584
|
+
if (!orgDoc?.invitedRole || appType !== type)
|
|
15569
15585
|
return null;
|
|
15570
15586
|
const role = await useRoleRepo().getRoleById(String(orgDoc.invitedRole)).catch(() => null);
|
|
15571
15587
|
const permissions = role?.permissions;
|
|
15572
|
-
const chosen = role && String(role.org ?? "") === orgId && role.default === true && role.type ===
|
|
15588
|
+
const chosen = role && String(role.org ?? "") === orgId && role.default === true && role.type === appType && Array.isArray(permissions) && permissions.length > 0 && !permissions.includes("*");
|
|
15573
15589
|
return chosen ? permissions.map(String) : null;
|
|
15574
15590
|
} catch {
|
|
15575
15591
|
return null;
|
|
@@ -26521,7 +26537,7 @@ function useOrgController() {
|
|
|
26521
26537
|
invitedModules?.permissions
|
|
26522
26538
|
);
|
|
26523
26539
|
const appOwnerRole = invitedModules?.permissions.length ? seededRoles.find(
|
|
26524
|
-
(role) => role.type === body.nature && role.name === "owner"
|
|
26540
|
+
(role) => role.type === serviceAppType(body.nature) && role.name === "owner"
|
|
26525
26541
|
) : void 0;
|
|
26526
26542
|
if (appOwnerRole) {
|
|
26527
26543
|
try {
|