@7365admin1/core 3.64.3 → 3.64.4
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 +21 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +53 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/test/module-gate.test.mjs +237 -0
- package/test/org-modules.test.mjs +78 -0
- package/test/site-modules.test.mjs +84 -0
package/dist/index.mjs
CHANGED
|
@@ -10981,13 +10981,42 @@ function normaliseModules(modules) {
|
|
|
10981
10981
|
}
|
|
10982
10982
|
return out;
|
|
10983
10983
|
}
|
|
10984
|
+
var ALWAYS_ALLOWED = Object.freeze([
|
|
10985
|
+
"sites",
|
|
10986
|
+
"subscriptions",
|
|
10987
|
+
"customers",
|
|
10988
|
+
"payment-methods",
|
|
10989
|
+
"members",
|
|
10990
|
+
"invitations",
|
|
10991
|
+
"roles",
|
|
10992
|
+
"roles-and-permissions",
|
|
10993
|
+
"site-settings"
|
|
10994
|
+
]);
|
|
10995
|
+
var SPELLING_GROUPS = Object.freeze(
|
|
10996
|
+
[
|
|
10997
|
+
["work_orders", "workOrder", "work_order", "work-orders"],
|
|
10998
|
+
["visitor-mgmt", "visitorManagement"],
|
|
10999
|
+
["bulletin-board", "bulletin-board-mgmt"],
|
|
11000
|
+
["facility-booking-mgmt", "facility-booking"],
|
|
11001
|
+
["feedbacks", "feedback"],
|
|
11002
|
+
["building-mgmt", "buildingManagement"],
|
|
11003
|
+
["roles", "roles-and-permissions"],
|
|
11004
|
+
["service-provider-mgmt", "service-provider"],
|
|
11005
|
+
["online-form-configuration", "online-forms"]
|
|
11006
|
+
].map((group) => Object.freeze(group))
|
|
11007
|
+
);
|
|
11008
|
+
function moduleSpellings(key) {
|
|
11009
|
+
return SPELLING_GROUPS.find((group) => group.includes(key)) ?? [key];
|
|
11010
|
+
}
|
|
10984
11011
|
function orgAllowsModule(modules, resource) {
|
|
10985
11012
|
if (!Array.isArray(modules) || modules.length === 0)
|
|
10986
11013
|
return true;
|
|
10987
11014
|
const key = typeof resource === "string" ? resource.trim() : "";
|
|
10988
11015
|
if (!key)
|
|
10989
11016
|
return true;
|
|
10990
|
-
|
|
11017
|
+
if (ALWAYS_ALLOWED.includes(key))
|
|
11018
|
+
return true;
|
|
11019
|
+
return moduleSpellings(key).some((spelling) => modules.includes(spelling));
|
|
10991
11020
|
}
|
|
10992
11021
|
|
|
10993
11022
|
// src/models/site.model.ts
|
|
@@ -11017,7 +11046,15 @@ function rejectedSiteModules(orgModules, requested) {
|
|
|
11017
11046
|
if (!narrows(orgModules))
|
|
11018
11047
|
return [];
|
|
11019
11048
|
const org = normaliseModules(orgModules);
|
|
11020
|
-
return normaliseModules(requested).filter((key) => !org
|
|
11049
|
+
return normaliseModules(requested).filter((key) => !orgAllowsModule(org, key));
|
|
11050
|
+
}
|
|
11051
|
+
function keepStoredSiteModules(metadata, stored) {
|
|
11052
|
+
if (!metadata || typeof metadata !== "object" || Array.isArray(metadata)) {
|
|
11053
|
+
return metadata;
|
|
11054
|
+
}
|
|
11055
|
+
const { modules: _sent, ...rest } = metadata;
|
|
11056
|
+
const kept = stored && typeof stored === "object" && !Array.isArray(stored) ? stored.modules : void 0;
|
|
11057
|
+
return kept === void 0 ? rest : { ...rest, modules: kept };
|
|
11021
11058
|
}
|
|
11022
11059
|
function rejectedSiteModulesMessage(rejected) {
|
|
11023
11060
|
return `This organisation has not been given ${rejected.join(", ")}, so a site cannot offer it. Ask Seven365 to add it to the organisation first.`;
|
|
@@ -38111,8 +38148,8 @@ function useSiteController() {
|
|
|
38111
38148
|
}
|
|
38112
38149
|
const { _id, ...rest } = value;
|
|
38113
38150
|
await requireSiteWrite(req, _id);
|
|
38151
|
+
const existing = rest?.metadata ? await _getSiteById(_id) : null;
|
|
38114
38152
|
if (rest?.metadata?.residentAppModules) {
|
|
38115
|
-
const existing = await _getSiteById(_id);
|
|
38116
38153
|
const org = existing?.orgId ? await _getOrgById(existing.orgId.toString()).catch(
|
|
38117
38154
|
() => null
|
|
38118
38155
|
) : null;
|
|
@@ -38127,6 +38164,12 @@ function useSiteController() {
|
|
|
38127
38164
|
return;
|
|
38128
38165
|
}
|
|
38129
38166
|
}
|
|
38167
|
+
if (rest?.metadata) {
|
|
38168
|
+
rest.metadata = keepStoredSiteModules(
|
|
38169
|
+
rest.metadata,
|
|
38170
|
+
existing?.metadata
|
|
38171
|
+
);
|
|
38172
|
+
}
|
|
38130
38173
|
await _updateById(_id, rest);
|
|
38131
38174
|
res.json({ message: "Successfully updated site." });
|
|
38132
38175
|
return;
|
|
@@ -55185,7 +55228,6 @@ function UseAccessManagementRepo() {
|
|
|
55185
55228
|
const type = params.type;
|
|
55186
55229
|
const search = params.search;
|
|
55187
55230
|
const typeFilter = type.toLowerCase() === "all" ? [] : [{ $eq: ["$type", type] }];
|
|
55188
|
-
const userIdFilter = params.userId ? [{ $eq: ["$userId", new ObjectId90(params.userId)] }] : [];
|
|
55189
55231
|
const searchFilter = search ? [
|
|
55190
55232
|
{
|
|
55191
55233
|
$or: [
|
|
@@ -55260,7 +55302,9 @@ function UseAccessManagementRepo() {
|
|
|
55260
55302
|
{ $eq: ["$isActivated", true] },
|
|
55261
55303
|
{ $eq: ["$userType", userType] },
|
|
55262
55304
|
...typeFilter,
|
|
55263
|
-
|
|
55305
|
+
// Cards actually held by a user only - a card sitting
|
|
55306
|
+
// unassigned on the unit (`userId: null`) is left out.
|
|
55307
|
+
{ $ne: ["$userId", null] }
|
|
55264
55308
|
]
|
|
55265
55309
|
},
|
|
55266
55310
|
...searchFilter[0]
|
|
@@ -70449,24 +70493,21 @@ function useAccessManagementController() {
|
|
|
70449
70493
|
unitId,
|
|
70450
70494
|
userType,
|
|
70451
70495
|
type,
|
|
70452
|
-
search = ""
|
|
70453
|
-
userId = ""
|
|
70496
|
+
search = ""
|
|
70454
70497
|
} = req.query;
|
|
70455
70498
|
const schema2 = Joi101.object({
|
|
70456
70499
|
site: Joi101.string().hex().required(),
|
|
70457
70500
|
unitId: Joi101.string().hex().required(),
|
|
70458
70501
|
userType: Joi101.string().required(),
|
|
70459
70502
|
type: Joi101.string().valid("all", ...Object.values(EAccessCardTypes)).required(),
|
|
70460
|
-
search: Joi101.string().optional().allow("", null)
|
|
70461
|
-
userId: Joi101.string().hex().optional().allow("", null)
|
|
70503
|
+
search: Joi101.string().optional().allow("", null)
|
|
70462
70504
|
});
|
|
70463
70505
|
const { error } = schema2.validate({
|
|
70464
70506
|
site,
|
|
70465
70507
|
unitId,
|
|
70466
70508
|
userType,
|
|
70467
70509
|
type,
|
|
70468
|
-
search
|
|
70469
|
-
userId
|
|
70510
|
+
search
|
|
70470
70511
|
});
|
|
70471
70512
|
if (error) {
|
|
70472
70513
|
return res.status(400).json({ message: error.message });
|
|
@@ -70478,8 +70519,7 @@ function useAccessManagementController() {
|
|
|
70478
70519
|
unitId,
|
|
70479
70520
|
userType,
|
|
70480
70521
|
type,
|
|
70481
|
-
search
|
|
70482
|
-
userId
|
|
70522
|
+
search
|
|
70483
70523
|
});
|
|
70484
70524
|
return res.status(200).json({ message: "Success", data: result });
|
|
70485
70525
|
} catch (error) {
|