@7365admin1/core 3.74.0 → 3.75.0
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 +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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @iservice365/core
|
|
2
2
|
|
|
3
|
+
## 3.75.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 75fb139: 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.
|
|
8
|
+
|
|
3
9
|
## 3.74.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/dist/index.js
CHANGED
|
@@ -3974,6 +3974,16 @@ function useUserRepo() {
|
|
|
3974
3974
|
var import_node_server_utils17 = require("@7365admin1/node-server-utils");
|
|
3975
3975
|
var import_uuid = require("uuid");
|
|
3976
3976
|
|
|
3977
|
+
// src/utils/service-app-type.util.ts
|
|
3978
|
+
var APP_TYPE_ALIASES = Object.freeze({
|
|
3979
|
+
real_estate_developer: "property_management_agency"
|
|
3980
|
+
});
|
|
3981
|
+
function serviceAppType(type) {
|
|
3982
|
+
if (typeof type !== "string")
|
|
3983
|
+
return type;
|
|
3984
|
+
return APP_TYPE_ALIASES[type] ?? type;
|
|
3985
|
+
}
|
|
3986
|
+
|
|
3977
3987
|
// src/repositories/member.repo.ts
|
|
3978
3988
|
var import_node_server_utils14 = require("@7365admin1/node-server-utils");
|
|
3979
3989
|
|
|
@@ -4126,7 +4136,7 @@ function useMemberRepo() {
|
|
|
4126
4136
|
}
|
|
4127
4137
|
async function add(value, session) {
|
|
4128
4138
|
try {
|
|
4129
|
-
value = MMember(value);
|
|
4139
|
+
value = MMember({ ...value, type: serviceAppType(value.type) });
|
|
4130
4140
|
await collection.insertOne(value, { session });
|
|
4131
4141
|
delNamespace().then(() => {
|
|
4132
4142
|
import_node_server_utils14.logger.info(`Cache cleared for namespace: ${namespace_collection3}`);
|
|
@@ -4254,6 +4264,7 @@ function useMemberRepo() {
|
|
|
4254
4264
|
}
|
|
4255
4265
|
}
|
|
4256
4266
|
async function getByUserIdType(user, type) {
|
|
4267
|
+
type = serviceAppType(type);
|
|
4257
4268
|
try {
|
|
4258
4269
|
user = new import_mongodb13.ObjectId(user);
|
|
4259
4270
|
} catch (error) {
|
|
@@ -4413,7 +4424,7 @@ function useMemberRepo() {
|
|
|
4413
4424
|
search = search || "";
|
|
4414
4425
|
page = page > 0 ? page - 1 : 0;
|
|
4415
4426
|
const query2 = {
|
|
4416
|
-
type,
|
|
4427
|
+
type: serviceAppType(type),
|
|
4417
4428
|
status
|
|
4418
4429
|
};
|
|
4419
4430
|
const cacheOptions = {
|
|
@@ -4935,6 +4946,7 @@ function useMemberRepo() {
|
|
|
4935
4946
|
}
|
|
4936
4947
|
}
|
|
4937
4948
|
async function getByUserIdTypeOrg(user, type, org) {
|
|
4949
|
+
type = serviceAppType(type);
|
|
4938
4950
|
try {
|
|
4939
4951
|
user = new import_mongodb13.ObjectId(user);
|
|
4940
4952
|
} catch {
|
|
@@ -12442,7 +12454,7 @@ function useRoleRepo() {
|
|
|
12442
12454
|
const { delNamespace, setCache, getCache } = (0, import_node_server_utils42.useCache)(namespace_collection3);
|
|
12443
12455
|
const { delNamespace: _delDashboardNameSpace } = (0, import_node_server_utils42.useCache)("dashboard");
|
|
12444
12456
|
async function addRole(value, session) {
|
|
12445
|
-
value = new MRole(value);
|
|
12457
|
+
value = new MRole({ ...value, type: serviceAppType(value.type) });
|
|
12446
12458
|
try {
|
|
12447
12459
|
const res = await collection.insertOne(value, { session });
|
|
12448
12460
|
delNamespace().then(() => {
|
|
@@ -12545,6 +12557,7 @@ function useRoleRepo() {
|
|
|
12545
12557
|
if (!name) {
|
|
12546
12558
|
throw new import_node_server_utils42.BadRequestError("Role name is required.");
|
|
12547
12559
|
}
|
|
12560
|
+
type = serviceAppType(type);
|
|
12548
12561
|
const query2 = type ? { name, type } : { name };
|
|
12549
12562
|
try {
|
|
12550
12563
|
const cacheKey = (0, import_node_server_utils42.makeCacheKey)(namespace_collection3, query2);
|
|
@@ -12601,8 +12614,8 @@ function useRoleRepo() {
|
|
|
12601
12614
|
cacheOptions.search = search;
|
|
12602
12615
|
}
|
|
12603
12616
|
if (type) {
|
|
12604
|
-
query2.type = type;
|
|
12605
|
-
cacheOptions.type = type;
|
|
12617
|
+
query2.type = serviceAppType(type);
|
|
12618
|
+
cacheOptions.type = query2.type;
|
|
12606
12619
|
}
|
|
12607
12620
|
const cacheKey = (0, import_node_server_utils42.makeCacheKey)(namespace_collection3, cacheOptions);
|
|
12608
12621
|
const cachedData = await getCache(cacheKey);
|
|
@@ -15216,13 +15229,14 @@ function defaultOwnerRoles(org, nature, appOwnerPermissions) {
|
|
|
15216
15229
|
{ ...owner, type: "organization" },
|
|
15217
15230
|
{ ...administrator, type: "organization" }
|
|
15218
15231
|
];
|
|
15219
|
-
|
|
15232
|
+
const appType = serviceAppType(nature);
|
|
15233
|
+
if (appType && APP_SERVICE_TYPES.has(appType)) {
|
|
15220
15234
|
roles.push({
|
|
15221
15235
|
...owner,
|
|
15222
|
-
type:
|
|
15236
|
+
type: appType,
|
|
15223
15237
|
...appOwnerPermissions?.length && { permissions: [...appOwnerPermissions] }
|
|
15224
15238
|
});
|
|
15225
|
-
roles.push({ ...administrator, type:
|
|
15239
|
+
roles.push({ ...administrator, type: appType });
|
|
15226
15240
|
}
|
|
15227
15241
|
return roles;
|
|
15228
15242
|
}
|
|
@@ -15307,15 +15321,17 @@ async function moduleCeiling(org, site) {
|
|
|
15307
15321
|
}
|
|
15308
15322
|
async function ownerGrantCeiling(org, type) {
|
|
15309
15323
|
const orgId = org?.toString() ?? "";
|
|
15324
|
+
type = serviceAppType(type);
|
|
15310
15325
|
if (!orgId || !type)
|
|
15311
15326
|
return null;
|
|
15312
15327
|
try {
|
|
15313
15328
|
const orgDoc = await useOrgRepo().getById(orgId).catch(() => null);
|
|
15314
|
-
|
|
15329
|
+
const appType = serviceAppType(orgDoc?.nature);
|
|
15330
|
+
if (!orgDoc?.invitedRole || appType !== type)
|
|
15315
15331
|
return null;
|
|
15316
15332
|
const role = await useRoleRepo().getRoleById(String(orgDoc.invitedRole)).catch(() => null);
|
|
15317
15333
|
const permissions = role?.permissions;
|
|
15318
|
-
const chosen = role && String(role.org ?? "") === orgId && role.default === true && role.type ===
|
|
15334
|
+
const chosen = role && String(role.org ?? "") === orgId && role.default === true && role.type === appType && Array.isArray(permissions) && permissions.length > 0 && !permissions.includes("*");
|
|
15319
15335
|
return chosen ? permissions.map(String) : null;
|
|
15320
15336
|
} catch {
|
|
15321
15337
|
return null;
|
|
@@ -26267,7 +26283,7 @@ function useOrgController() {
|
|
|
26267
26283
|
invitedModules?.permissions
|
|
26268
26284
|
);
|
|
26269
26285
|
const appOwnerRole = invitedModules?.permissions.length ? seededRoles.find(
|
|
26270
|
-
(role) => role.type === body.nature && role.name === "owner"
|
|
26286
|
+
(role) => role.type === serviceAppType(body.nature) && role.name === "owner"
|
|
26271
26287
|
) : void 0;
|
|
26272
26288
|
if (appOwnerRole) {
|
|
26273
26289
|
try {
|