@7365admin1/core 3.79.1-staging.351 → 3.79.1-staging.352
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.d.ts +8 -2
- package/dist/index.js +84 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +84 -24
- package/dist/index.mjs.map +1 -1
- package/logs/.6b77785a74c362881f6fb7e95a7530280abbf9ed-audit.json +5 -0
- package/logs/.ca6dad43b7d35307d69543a741eb24d3ce997028-audit.json +5 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -10951,11 +10951,17 @@ declare function UseAccessManagementRepo(): {
|
|
|
10951
10951
|
}>;
|
|
10952
10952
|
assignedAccessCardsByUnitRepo: (params: {
|
|
10953
10953
|
site: string;
|
|
10954
|
-
unitId
|
|
10954
|
+
unitId?: string;
|
|
10955
10955
|
userType: string;
|
|
10956
10956
|
type: string;
|
|
10957
10957
|
search: string;
|
|
10958
|
-
|
|
10958
|
+
page?: number;
|
|
10959
|
+
limit?: number;
|
|
10960
|
+
}) => Promise<{
|
|
10961
|
+
items: any[];
|
|
10962
|
+
pages: number;
|
|
10963
|
+
pageRange: string;
|
|
10964
|
+
}>;
|
|
10959
10965
|
acknowlegdeCardRepo: (params: {
|
|
10960
10966
|
userId: string[];
|
|
10961
10967
|
cardId: string[];
|
package/dist/index.js
CHANGED
|
@@ -55827,26 +55827,50 @@ function UseAccessManagementRepo() {
|
|
|
55827
55827
|
async function assignedAccessCardsByUnitRepo(params) {
|
|
55828
55828
|
try {
|
|
55829
55829
|
const site = new import_mongodb97.ObjectId(params.site);
|
|
55830
|
-
const unitId = new import_mongodb97.ObjectId(params.unitId);
|
|
55830
|
+
const unitId = params.unitId ? new import_mongodb97.ObjectId(params.unitId) : null;
|
|
55831
55831
|
const userType = params.userType;
|
|
55832
55832
|
const type = params.type;
|
|
55833
|
-
const search = params.search;
|
|
55833
|
+
const search = params.search ? params.search.trim() : "";
|
|
55834
|
+
const page = params.page ? Number(params.page) - 1 : 0;
|
|
55835
|
+
const limit = Number(params.limit) || 10;
|
|
55834
55836
|
const typeFilter = type.toLowerCase() === "all" ? [] : [{ $eq: ["$type", type] }];
|
|
55837
|
+
const matchesSearch = (field) => ({
|
|
55838
|
+
$regexMatch: {
|
|
55839
|
+
input: {
|
|
55840
|
+
$cond: [{ $eq: [{ $type: field }, "string"] }, field, ""]
|
|
55841
|
+
},
|
|
55842
|
+
regex: search,
|
|
55843
|
+
options: "i"
|
|
55844
|
+
}
|
|
55845
|
+
});
|
|
55846
|
+
const unitNameMatch = matchesSearch("$$unitName");
|
|
55835
55847
|
const searchFilter = search ? [
|
|
55836
55848
|
{
|
|
55837
55849
|
$or: [
|
|
55838
|
-
|
|
55839
|
-
|
|
55840
|
-
|
|
55841
|
-
|
|
55850
|
+
unitNameMatch,
|
|
55851
|
+
matchesSearch("$cardNo"),
|
|
55852
|
+
matchesSearch("$accessLevel"),
|
|
55853
|
+
matchesSearch("$doorName"),
|
|
55854
|
+
matchesSearch("$liftName")
|
|
55842
55855
|
]
|
|
55843
55856
|
}
|
|
55844
55857
|
] : [];
|
|
55858
|
+
const unitFilters = [
|
|
55859
|
+
...unitId ? [] : [{ $gt: [{ $size: "$accessCards" }, 0] }],
|
|
55860
|
+
...search ? [
|
|
55861
|
+
{
|
|
55862
|
+
$or: [
|
|
55863
|
+
matchesSearch("$name"),
|
|
55864
|
+
{ $gt: [{ $size: "$accessCards" }, 0] }
|
|
55865
|
+
]
|
|
55866
|
+
}
|
|
55867
|
+
] : []
|
|
55868
|
+
];
|
|
55845
55869
|
const result = await collectionName("building-units").aggregate(
|
|
55846
55870
|
[
|
|
55847
55871
|
{
|
|
55848
55872
|
$match: {
|
|
55849
|
-
_id: unitId,
|
|
55873
|
+
...unitId ? { _id: unitId } : {},
|
|
55850
55874
|
site,
|
|
55851
55875
|
status: { $ne: "deleted" }
|
|
55852
55876
|
}
|
|
@@ -55884,7 +55908,7 @@ function UseAccessManagementRepo() {
|
|
|
55884
55908
|
{
|
|
55885
55909
|
$lookup: {
|
|
55886
55910
|
from: "access-cards",
|
|
55887
|
-
let: { unit: "$_id" },
|
|
55911
|
+
let: { unit: "$_id", unitName: "$name" },
|
|
55888
55912
|
pipeline: [
|
|
55889
55913
|
{
|
|
55890
55914
|
$match: {
|
|
@@ -55908,10 +55932,10 @@ function UseAccessManagementRepo() {
|
|
|
55908
55932
|
...typeFilter,
|
|
55909
55933
|
// Cards actually held by a user only - a card sitting
|
|
55910
55934
|
// unassigned on the unit (`userId: null`) is left out.
|
|
55911
|
-
{ $ne: ["$userId", null] }
|
|
55935
|
+
{ $ne: ["$userId", null] },
|
|
55936
|
+
...searchFilter
|
|
55912
55937
|
]
|
|
55913
|
-
}
|
|
55914
|
-
...searchFilter[0]
|
|
55938
|
+
}
|
|
55915
55939
|
}
|
|
55916
55940
|
},
|
|
55917
55941
|
{ $sort: { _id: -1 } },
|
|
@@ -55941,20 +55965,48 @@ function UseAccessManagementRepo() {
|
|
|
55941
55965
|
as: "accessCards"
|
|
55942
55966
|
}
|
|
55943
55967
|
},
|
|
55968
|
+
// Listing mode hides units with nothing assigned, the same rule
|
|
55969
|
+
// assignedAccessCardsRepo applies. A directly requested unitId is
|
|
55970
|
+
// exempt, so the single-unit call still returns the unit with an
|
|
55971
|
+
// empty `accessCards` list.
|
|
55972
|
+
// The search keeps a unit whose own name matches even when none of
|
|
55973
|
+
// its cards do.
|
|
55974
|
+
...unitFilters.length ? [{ $match: { $expr: { $and: unitFilters } } }] : [],
|
|
55944
55975
|
{
|
|
55945
|
-
$
|
|
55946
|
-
|
|
55947
|
-
|
|
55948
|
-
|
|
55949
|
-
|
|
55950
|
-
|
|
55951
|
-
|
|
55976
|
+
$sort: {
|
|
55977
|
+
"buildingInfo.name": 1,
|
|
55978
|
+
"levelInfo.name": 1,
|
|
55979
|
+
name: 1
|
|
55980
|
+
}
|
|
55981
|
+
},
|
|
55982
|
+
{
|
|
55983
|
+
$facet: {
|
|
55984
|
+
totalCount: [{ $count: "count" }],
|
|
55985
|
+
items: [
|
|
55986
|
+
{ $skip: page * limit },
|
|
55987
|
+
{ $limit: limit },
|
|
55988
|
+
{
|
|
55989
|
+
$project: {
|
|
55990
|
+
_id: 0,
|
|
55991
|
+
unitId: "$_id",
|
|
55992
|
+
block: {
|
|
55993
|
+
$ifNull: ["$buildingInfo.name", "$buildingName"]
|
|
55994
|
+
},
|
|
55995
|
+
level: "$levelInfo.name",
|
|
55996
|
+
unit: "$name",
|
|
55997
|
+
accessCards: 1
|
|
55998
|
+
}
|
|
55999
|
+
}
|
|
56000
|
+
]
|
|
55952
56001
|
}
|
|
55953
56002
|
}
|
|
55954
56003
|
],
|
|
55955
56004
|
{ allowDiskUse: true }
|
|
55956
56005
|
).toArray();
|
|
55957
|
-
|
|
56006
|
+
const totalCount = result[0]?.totalCount?.[0]?.count ?? 0;
|
|
56007
|
+
const items = result[0]?.items ?? [];
|
|
56008
|
+
const paginatedResult = (0, import_node_server_utils145.paginate)(items, page, limit, totalCount);
|
|
56009
|
+
return paginatedResult;
|
|
55958
56010
|
} catch (error) {
|
|
55959
56011
|
throw new Error(error.message);
|
|
55960
56012
|
}
|
|
@@ -74394,21 +74446,27 @@ function useAccessManagementController() {
|
|
|
74394
74446
|
unitId,
|
|
74395
74447
|
userType,
|
|
74396
74448
|
type,
|
|
74397
|
-
search = ""
|
|
74449
|
+
search = "",
|
|
74450
|
+
page,
|
|
74451
|
+
limit
|
|
74398
74452
|
} = req.query;
|
|
74399
74453
|
const schema2 = import_joi106.default.object({
|
|
74400
74454
|
site: import_joi106.default.string().hex().required(),
|
|
74401
|
-
unitId: import_joi106.default.string().hex().
|
|
74455
|
+
unitId: import_joi106.default.string().hex().optional().allow("", null),
|
|
74402
74456
|
userType: import_joi106.default.string().required(),
|
|
74403
74457
|
type: import_joi106.default.string().valid("all", ...Object.values(EAccessCardTypes)).required(),
|
|
74404
|
-
search: import_joi106.default.string().optional().allow("", null)
|
|
74458
|
+
search: import_joi106.default.string().optional().allow("", null),
|
|
74459
|
+
page: import_joi106.default.number().optional().default(1),
|
|
74460
|
+
limit: import_joi106.default.number().optional().default(10)
|
|
74405
74461
|
});
|
|
74406
74462
|
const { error } = schema2.validate({
|
|
74407
74463
|
site,
|
|
74408
74464
|
unitId,
|
|
74409
74465
|
userType,
|
|
74410
74466
|
type,
|
|
74411
|
-
search
|
|
74467
|
+
search,
|
|
74468
|
+
page,
|
|
74469
|
+
limit
|
|
74412
74470
|
});
|
|
74413
74471
|
if (error) {
|
|
74414
74472
|
return res.status(400).json({ message: error.message });
|
|
@@ -74420,7 +74478,9 @@ function useAccessManagementController() {
|
|
|
74420
74478
|
unitId,
|
|
74421
74479
|
userType,
|
|
74422
74480
|
type,
|
|
74423
|
-
search
|
|
74481
|
+
search,
|
|
74482
|
+
page,
|
|
74483
|
+
limit
|
|
74424
74484
|
});
|
|
74425
74485
|
return res.status(200).json({ message: "Success", data: result });
|
|
74426
74486
|
} catch (error) {
|