@7365admin1/core 3.32.2-staging.39 → 3.32.2-staging.40
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 +7 -1
- package/dist/index.js +39 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -4791,7 +4791,13 @@ declare function UseAccessManagementRepo(): {
|
|
|
4791
4791
|
userType: string;
|
|
4792
4792
|
type: string;
|
|
4793
4793
|
search: string;
|
|
4794
|
-
|
|
4794
|
+
page: number;
|
|
4795
|
+
limit: number;
|
|
4796
|
+
}) => Promise<{
|
|
4797
|
+
items: any[];
|
|
4798
|
+
pages: number;
|
|
4799
|
+
pageRange: string;
|
|
4800
|
+
}>;
|
|
4795
4801
|
assignedAccessCardsByUnitRepo: (params: {
|
|
4796
4802
|
site: string;
|
|
4797
4803
|
unitId: string;
|
package/dist/index.js
CHANGED
|
@@ -47787,6 +47787,8 @@ function UseAccessManagementRepo() {
|
|
|
47787
47787
|
const userType = params.userType;
|
|
47788
47788
|
const type = params.type;
|
|
47789
47789
|
const search = params.search;
|
|
47790
|
+
const page = params.page ? Number(params.page) - 1 : 0;
|
|
47791
|
+
const limit = Number(params.limit) || 10;
|
|
47790
47792
|
const typeFilter = type.toLowerCase() === "all" ? [] : [{ $eq: ["$type", type] }];
|
|
47791
47793
|
const query = {
|
|
47792
47794
|
site: { $in: [site] }
|
|
@@ -47953,18 +47955,31 @@ function UseAccessManagementRepo() {
|
|
|
47953
47955
|
}
|
|
47954
47956
|
},
|
|
47955
47957
|
{
|
|
47956
|
-
$
|
|
47957
|
-
|
|
47958
|
-
|
|
47959
|
-
|
|
47960
|
-
|
|
47961
|
-
|
|
47958
|
+
$facet: {
|
|
47959
|
+
totalCount: [{ $count: "count" }],
|
|
47960
|
+
items: [
|
|
47961
|
+
// ✅ Sort BEFORE skip/limit for correct pagination
|
|
47962
|
+
{ $skip: page * limit },
|
|
47963
|
+
{ $limit: limit },
|
|
47964
|
+
{
|
|
47965
|
+
$project: {
|
|
47966
|
+
_id: 0,
|
|
47967
|
+
unitId: "$level.units._id",
|
|
47968
|
+
block: "$name",
|
|
47969
|
+
level: "$level.level",
|
|
47970
|
+
unit: "$level.units.name"
|
|
47971
|
+
}
|
|
47972
|
+
}
|
|
47973
|
+
]
|
|
47962
47974
|
}
|
|
47963
47975
|
}
|
|
47964
47976
|
],
|
|
47965
47977
|
{ allowDiskUse: true }
|
|
47966
47978
|
).toArray();
|
|
47967
|
-
|
|
47979
|
+
const totalCount = result[0]?.totalCount?.[0]?.count ?? 0;
|
|
47980
|
+
const items = result[0]?.items ?? [];
|
|
47981
|
+
const paginatedResult = (0, import_node_server_utils158.paginate)(items, page, limit, totalCount);
|
|
47982
|
+
return paginatedResult;
|
|
47968
47983
|
} catch (error) {
|
|
47969
47984
|
throw new Error(error.message);
|
|
47970
47985
|
}
|
|
@@ -50772,15 +50787,26 @@ function useAccessManagementController() {
|
|
|
50772
50787
|
site,
|
|
50773
50788
|
userType,
|
|
50774
50789
|
type,
|
|
50775
|
-
search = ""
|
|
50790
|
+
search = "",
|
|
50791
|
+
page,
|
|
50792
|
+
limit
|
|
50776
50793
|
} = req.query;
|
|
50777
50794
|
const schema2 = import_joi87.default.object({
|
|
50778
50795
|
site: import_joi87.default.string().hex().required(),
|
|
50779
50796
|
userType: import_joi87.default.string().required(),
|
|
50780
50797
|
type: import_joi87.default.string().required(),
|
|
50781
|
-
search: import_joi87.default.string().optional().allow("", null)
|
|
50798
|
+
search: import_joi87.default.string().optional().allow("", null),
|
|
50799
|
+
page: import_joi87.default.number().required(),
|
|
50800
|
+
limit: import_joi87.default.number().optional().default(10)
|
|
50801
|
+
});
|
|
50802
|
+
const { error } = schema2.validate({
|
|
50803
|
+
site,
|
|
50804
|
+
userType,
|
|
50805
|
+
type,
|
|
50806
|
+
search,
|
|
50807
|
+
page,
|
|
50808
|
+
limit
|
|
50782
50809
|
});
|
|
50783
|
-
const { error } = schema2.validate({ site, userType, type, search });
|
|
50784
50810
|
if (error) {
|
|
50785
50811
|
return res.status(400).json({ message: error.message });
|
|
50786
50812
|
}
|
|
@@ -50788,7 +50814,9 @@ function useAccessManagementController() {
|
|
|
50788
50814
|
site,
|
|
50789
50815
|
userType,
|
|
50790
50816
|
type,
|
|
50791
|
-
search
|
|
50817
|
+
search,
|
|
50818
|
+
page,
|
|
50819
|
+
limit
|
|
50792
50820
|
});
|
|
50793
50821
|
return res.status(200).json({ message: "Success", data: result });
|
|
50794
50822
|
} catch (error) {
|