@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/dist/index.mjs CHANGED
@@ -3166,6 +3166,16 @@ import {
3166
3166
  } from "@7365admin1/node-server-utils";
3167
3167
  import { v4 as uuidv4 } from "uuid";
3168
3168
 
3169
+ // src/utils/service-app-type.util.ts
3170
+ var APP_TYPE_ALIASES = Object.freeze({
3171
+ real_estate_developer: "property_management_agency"
3172
+ });
3173
+ function serviceAppType(type) {
3174
+ if (typeof type !== "string")
3175
+ return type;
3176
+ return APP_TYPE_ALIASES[type] ?? type;
3177
+ }
3178
+
3169
3179
  // src/repositories/member.repo.ts
3170
3180
  import {
3171
3181
  AppError as AppError2,
@@ -3328,7 +3338,7 @@ function useMemberRepo() {
3328
3338
  }
3329
3339
  async function add(value, session) {
3330
3340
  try {
3331
- value = MMember(value);
3341
+ value = MMember({ ...value, type: serviceAppType(value.type) });
3332
3342
  await collection.insertOne(value, { session });
3333
3343
  delNamespace().then(() => {
3334
3344
  logger7.info(`Cache cleared for namespace: ${namespace_collection3}`);
@@ -3456,6 +3466,7 @@ function useMemberRepo() {
3456
3466
  }
3457
3467
  }
3458
3468
  async function getByUserIdType(user, type) {
3469
+ type = serviceAppType(type);
3459
3470
  try {
3460
3471
  user = new ObjectId13(user);
3461
3472
  } catch (error) {
@@ -3615,7 +3626,7 @@ function useMemberRepo() {
3615
3626
  search = search || "";
3616
3627
  page = page > 0 ? page - 1 : 0;
3617
3628
  const query2 = {
3618
- type,
3629
+ type: serviceAppType(type),
3619
3630
  status
3620
3631
  };
3621
3632
  const cacheOptions = {
@@ -4137,6 +4148,7 @@ function useMemberRepo() {
4137
4148
  }
4138
4149
  }
4139
4150
  async function getByUserIdTypeOrg(user, type, org) {
4151
+ type = serviceAppType(type);
4140
4152
  try {
4141
4153
  user = new ObjectId13(user);
4142
4154
  } catch {
@@ -11751,7 +11763,7 @@ function useRoleRepo() {
11751
11763
  const { delNamespace, setCache, getCache } = useCache14(namespace_collection3);
11752
11764
  const { delNamespace: _delDashboardNameSpace } = useCache14("dashboard");
11753
11765
  async function addRole(value, session) {
11754
- value = new MRole(value);
11766
+ value = new MRole({ ...value, type: serviceAppType(value.type) });
11755
11767
  try {
11756
11768
  const res = await collection.insertOne(value, { session });
11757
11769
  delNamespace().then(() => {
@@ -11854,6 +11866,7 @@ function useRoleRepo() {
11854
11866
  if (!name) {
11855
11867
  throw new BadRequestError33("Role name is required.");
11856
11868
  }
11869
+ type = serviceAppType(type);
11857
11870
  const query2 = type ? { name, type } : { name };
11858
11871
  try {
11859
11872
  const cacheKey = makeCacheKey11(namespace_collection3, query2);
@@ -11910,8 +11923,8 @@ function useRoleRepo() {
11910
11923
  cacheOptions.search = search;
11911
11924
  }
11912
11925
  if (type) {
11913
- query2.type = type;
11914
- cacheOptions.type = type;
11926
+ query2.type = serviceAppType(type);
11927
+ cacheOptions.type = query2.type;
11915
11928
  }
11916
11929
  const cacheKey = makeCacheKey11(namespace_collection3, cacheOptions);
11917
11930
  const cachedData = await getCache(cacheKey);
@@ -14552,13 +14565,14 @@ function defaultOwnerRoles(org, nature, appOwnerPermissions) {
14552
14565
  { ...owner, type: "organization" },
14553
14566
  { ...administrator, type: "organization" }
14554
14567
  ];
14555
- if (nature && APP_SERVICE_TYPES.has(nature)) {
14568
+ const appType = serviceAppType(nature);
14569
+ if (appType && APP_SERVICE_TYPES.has(appType)) {
14556
14570
  roles.push({
14557
14571
  ...owner,
14558
- type: nature,
14572
+ type: appType,
14559
14573
  ...appOwnerPermissions?.length && { permissions: [...appOwnerPermissions] }
14560
14574
  });
14561
- roles.push({ ...administrator, type: nature });
14575
+ roles.push({ ...administrator, type: appType });
14562
14576
  }
14563
14577
  return roles;
14564
14578
  }
@@ -14643,15 +14657,17 @@ async function moduleCeiling(org, site) {
14643
14657
  }
14644
14658
  async function ownerGrantCeiling(org, type) {
14645
14659
  const orgId = org?.toString() ?? "";
14660
+ type = serviceAppType(type);
14646
14661
  if (!orgId || !type)
14647
14662
  return null;
14648
14663
  try {
14649
14664
  const orgDoc = await useOrgRepo().getById(orgId).catch(() => null);
14650
- if (!orgDoc?.invitedRole || orgDoc.nature !== type)
14665
+ const appType = serviceAppType(orgDoc?.nature);
14666
+ if (!orgDoc?.invitedRole || appType !== type)
14651
14667
  return null;
14652
14668
  const role = await useRoleRepo().getRoleById(String(orgDoc.invitedRole)).catch(() => null);
14653
14669
  const permissions = role?.permissions;
14654
- const chosen = role && String(role.org ?? "") === orgId && role.default === true && role.type === orgDoc.nature && Array.isArray(permissions) && permissions.length > 0 && !permissions.includes("*");
14670
+ const chosen = role && String(role.org ?? "") === orgId && role.default === true && role.type === appType && Array.isArray(permissions) && permissions.length > 0 && !permissions.includes("*");
14655
14671
  return chosen ? permissions.map(String) : null;
14656
14672
  } catch {
14657
14673
  return null;
@@ -25657,7 +25673,7 @@ function useOrgController() {
25657
25673
  invitedModules?.permissions
25658
25674
  );
25659
25675
  const appOwnerRole = invitedModules?.permissions.length ? seededRoles.find(
25660
- (role) => role.type === body.nature && role.name === "owner"
25676
+ (role) => role.type === serviceAppType(body.nature) && role.name === "owner"
25661
25677
  ) : void 0;
25662
25678
  if (appOwnerRole) {
25663
25679
  try {