@7365admin1/core 3.139.0 → 3.140.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 +12 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +19 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/test/e2e/service-provider-invite-email-new-company.e2e.test.mjs +25 -0
- package/test/member-entitled-list.test.mjs +60 -0
- package/test/member-lookup-honours-org.test.mjs +3 -3
- package/test/member-lookup-site.test.mjs +1 -0
package/dist/index.mjs
CHANGED
|
@@ -3203,7 +3203,10 @@ function sameAppType(a, b) {
|
|
|
3203
3203
|
// src/utils/member-lookup.util.ts
|
|
3204
3204
|
var idOf = (v) => v == null ? "" : String(v?._id ?? v).toLowerCase();
|
|
3205
3205
|
function isLiveMembership(m) {
|
|
3206
|
-
return m
|
|
3206
|
+
return !TAKEN_AWAY_MEMBER_STATUSES.includes(String(m?.status ?? "")) && !m?.deletedAt;
|
|
3207
|
+
}
|
|
3208
|
+
function entitledMemberships(rows) {
|
|
3209
|
+
return (Array.isArray(rows) ? rows : []).filter(isLiveMembership);
|
|
3207
3210
|
}
|
|
3208
3211
|
function pickSiteMembership(rows, type, site, org = "") {
|
|
3209
3212
|
site = site.toLowerCase();
|
|
@@ -3231,6 +3234,7 @@ function pickLookupMembership(rows, type, site = "", org = "") {
|
|
|
3231
3234
|
return preferWorkingMembership(list.filter((m) => sameAppType(m.type, type)));
|
|
3232
3235
|
}
|
|
3233
3236
|
var WORKING = /* @__PURE__ */ new Set(["active", "approved"]);
|
|
3237
|
+
var TAKEN_AWAY_MEMBER_STATUSES = ["deleted", "inactive"];
|
|
3234
3238
|
function preferWorkingMembership(rows, defaultOrg = "") {
|
|
3235
3239
|
const list = Array.isArray(rows) ? rows : [];
|
|
3236
3240
|
const working = list.filter((m) => WORKING.has(String(m.status ?? "")) && !m.deletedAt);
|
|
@@ -4094,7 +4098,7 @@ function useMemberRepo() {
|
|
|
4094
4098
|
// sets it inactive, removal deletes it) must not keep the organisation
|
|
4095
4099
|
// on the person's list: latitude.sec@ still saw JLL Singapore beside its
|
|
4096
4100
|
// own company after the repair (owner report 2026-09-30).
|
|
4097
|
-
status: { $nin:
|
|
4101
|
+
status: { $nin: TAKEN_AWAY_MEMBER_STATUSES }
|
|
4098
4102
|
};
|
|
4099
4103
|
const cacheOptions = {
|
|
4100
4104
|
page: page2,
|
|
@@ -8803,7 +8807,7 @@ async function resolveInviteActor(userId) {
|
|
|
8803
8807
|
const db2 = useAtlas17.getDb();
|
|
8804
8808
|
if (!db2)
|
|
8805
8809
|
return { ...EMPTY, id };
|
|
8806
|
-
const members = await db2.collection("members").find({ user: new ObjectId26(id), status: { $
|
|
8810
|
+
const members = await db2.collection("members").find({ user: new ObjectId26(id), status: { $nin: TAKEN_AWAY_MEMBER_STATUSES } }).toArray();
|
|
8807
8811
|
const adminMember = members.find((m) => m.type === "admin");
|
|
8808
8812
|
let isSuperAdmin2 = false;
|
|
8809
8813
|
let staffPermissions;
|
|
@@ -9110,7 +9114,7 @@ async function holdsRole(userId, roleId, orgId) {
|
|
|
9110
9114
|
const member = await db2.collection("members").findOne({
|
|
9111
9115
|
user: new ObjectId26(id),
|
|
9112
9116
|
role: new ObjectId26(role),
|
|
9113
|
-
status: { $
|
|
9117
|
+
status: { $nin: TAKEN_AWAY_MEMBER_STATUSES },
|
|
9114
9118
|
// both shapes, as `hasOrgInvitation` does for `metadata.org`
|
|
9115
9119
|
...org ? { org: { $in: [new ObjectId26(org), org] } } : {}
|
|
9116
9120
|
});
|
|
@@ -22152,7 +22156,8 @@ async function getUserPermissions(params) {
|
|
|
22152
22156
|
if (!roleId || !ObjectId51.isValid(roleId)) {
|
|
22153
22157
|
const memberQuery = {
|
|
22154
22158
|
user: new ObjectId51(user),
|
|
22155
|
-
|
|
22159
|
+
// A taken-away (inactive) row grants no permissions either.
|
|
22160
|
+
status: { $nin: TAKEN_AWAY_MEMBER_STATUSES }
|
|
22156
22161
|
};
|
|
22157
22162
|
if (org && ObjectId51.isValid(org)) {
|
|
22158
22163
|
memberQuery.org = new ObjectId51(org);
|
|
@@ -22242,7 +22247,7 @@ function useCameraViewService() {
|
|
|
22242
22247
|
}
|
|
22243
22248
|
}
|
|
22244
22249
|
async function resolveSiteAccess(params) {
|
|
22245
|
-
const memberships = await params.db.collection("members").find({ user: new ObjectId52(params.userId), status: { $
|
|
22250
|
+
const memberships = await params.db.collection("members").find({ user: new ObjectId52(params.userId), status: { $nin: TAKEN_AWAY_MEMBER_STATUSES } }).project({ siteId: 1, org: 1, role: 1, type: 1 }).toArray();
|
|
22246
22251
|
const memberOrgIds = [
|
|
22247
22252
|
...new Map(
|
|
22248
22253
|
memberships.filter((membership) => membership.org).map((membership) => [String(membership.org), membership.org])
|
|
@@ -28480,9 +28485,10 @@ function useMemberService() {
|
|
|
28480
28485
|
throw error;
|
|
28481
28486
|
}
|
|
28482
28487
|
}
|
|
28483
|
-
async function getAllByUser(user) {
|
|
28488
|
+
async function getAllByUser(user, { includeRemoved = false } = {}) {
|
|
28484
28489
|
try {
|
|
28485
|
-
const
|
|
28490
|
+
const all = await _getAllByUserId(user);
|
|
28491
|
+
const members = includeRemoved ? all : entitledMemberships(all);
|
|
28486
28492
|
return {
|
|
28487
28493
|
items: members,
|
|
28488
28494
|
total: members.length
|
|
@@ -29043,7 +29049,9 @@ function useMemberController() {
|
|
|
29043
29049
|
return;
|
|
29044
29050
|
}
|
|
29045
29051
|
try {
|
|
29046
|
-
const data = await _getAllByUser(userId
|
|
29052
|
+
const data = await _getAllByUser(userId, {
|
|
29053
|
+
includeRemoved: req.query.include === "removed"
|
|
29054
|
+
});
|
|
29047
29055
|
const whole = await requireSelfOrPlatformStaff(req, userId, {
|
|
29048
29056
|
resource: "members",
|
|
29049
29057
|
action: "view-members"
|
|
@@ -29084,7 +29092,7 @@ function useMemberController() {
|
|
|
29084
29092
|
org
|
|
29085
29093
|
) : null;
|
|
29086
29094
|
const inOrg = org && !atSite ? await _getByUserIdTypeOrg(user, type, org).catch(() => null) : null;
|
|
29087
|
-
const liveInOrg = inOrg && inOrg
|
|
29095
|
+
const liveInOrg = inOrg && isLiveMembership(inOrg) ? inOrg : null;
|
|
29088
29096
|
const data = atSite ?? liveInOrg ?? await _getByUserIdType(user, type);
|
|
29089
29097
|
res.json(data);
|
|
29090
29098
|
return;
|
|
@@ -107852,7 +107860,7 @@ function useNotificationPreferenceService() {
|
|
|
107852
107860
|
const db2 = useAtlas163.getDb();
|
|
107853
107861
|
if (!db2)
|
|
107854
107862
|
return [];
|
|
107855
|
-
const members = await db2.collection("members").find({ user: new ObjectId200(userId), status: { $
|
|
107863
|
+
const members = await db2.collection("members").find({ user: new ObjectId200(userId), status: { $nin: TAKEN_AWAY_MEMBER_STATUSES } }).toArray();
|
|
107856
107864
|
if (!members.length)
|
|
107857
107865
|
return [];
|
|
107858
107866
|
const isResident = members.some((m) => m.type === "resident");
|