@7365admin1/core 3.34.4-staging.17 → 3.34.4-staging.19
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 +5 -5
- package/dist/index.js +71 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +71 -33
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2625,7 +2625,7 @@ type TGetAttendancesQuery = {
|
|
|
2625
2625
|
startDate?: string | Date;
|
|
2626
2626
|
endDate?: string | Date;
|
|
2627
2627
|
} & Pick<TAttendance, "site" | "serviceType">;
|
|
2628
|
-
type TGetAttendancesByUserQuery = Pick<TGetAttendancesQuery, "page" | "limit" | "search" | "site" | "serviceType"> & Pick<TAttendance, "user">;
|
|
2628
|
+
type TGetAttendancesByUserQuery = Pick<TGetAttendancesQuery, "page" | "limit" | "search" | "site" | "serviceType" | "startDate" | "endDate"> & Pick<TAttendance, "user">;
|
|
2629
2629
|
declare const attendanceSchema: Joi.ObjectSchema<any>;
|
|
2630
2630
|
declare function MAttendance(value: TAttendance): {
|
|
2631
2631
|
site: string | ObjectId;
|
|
@@ -2685,7 +2685,7 @@ declare function useAttendanceRepository(): {
|
|
|
2685
2685
|
createIndex: () => Promise<void>;
|
|
2686
2686
|
checkInAttendance: (value: TAttendanceCheckIn, session?: ClientSession) => Promise<ObjectId>;
|
|
2687
2687
|
getAllAttendances: ({ page, limit, search, site, startDate, endDate, serviceType, }: TGetAttendancesQuery) => Promise<{}>;
|
|
2688
|
-
getAttendanceByUser: ({ page, limit, search, site, serviceType, user, }: TGetAttendancesByUserQuery) => Promise<{}>;
|
|
2688
|
+
getAttendanceByUser: ({ page, limit, search, site, startDate, endDate, serviceType, user, }: TGetAttendancesByUserQuery) => Promise<{}>;
|
|
2689
2689
|
getAttendanceById: (_id: string | ObjectId, session?: ClientSession) => Promise<{}>;
|
|
2690
2690
|
getRawAttendanceById: (_id: string | ObjectId, session?: ClientSession) => Promise<TAttendance>;
|
|
2691
2691
|
checkOutAttendance: (_id: string | ObjectId, value: TAttendanceCheckOut, session?: ClientSession) => Promise<number>;
|
|
@@ -6104,8 +6104,8 @@ declare function useNfcPatrolLogRepo(): {
|
|
|
6104
6104
|
date?: string | undefined;
|
|
6105
6105
|
type?: "month" | undefined;
|
|
6106
6106
|
route?: {
|
|
6107
|
-
_id
|
|
6108
|
-
startTime
|
|
6107
|
+
_id?: string | ObjectId | undefined;
|
|
6108
|
+
startTime?: string | undefined;
|
|
6109
6109
|
} | undefined;
|
|
6110
6110
|
}, session?: ClientSession) => Promise<{
|
|
6111
6111
|
items: any[];
|
|
@@ -6136,7 +6136,7 @@ declare function useNfcPatrolLogService(): {
|
|
|
6136
6136
|
|
|
6137
6137
|
declare function useNfcPatrolLogController(): {
|
|
6138
6138
|
add: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
6139
|
-
getAllBySite: (req: Request, res: Response, next: NextFunction) => Promise<void
|
|
6139
|
+
getAllBySite: (req: Request, res: Response, next: NextFunction) => Promise<void | Response<any, Record<string, any>>>;
|
|
6140
6140
|
completeCheckpoint: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
6141
6141
|
getLog: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
6142
6142
|
sign: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -33211,6 +33211,8 @@ function useAttendanceRepository() {
|
|
|
33211
33211
|
limit = 10,
|
|
33212
33212
|
search = "",
|
|
33213
33213
|
site,
|
|
33214
|
+
startDate = "",
|
|
33215
|
+
endDate = "",
|
|
33214
33216
|
serviceType,
|
|
33215
33217
|
user
|
|
33216
33218
|
}) {
|
|
@@ -33238,6 +33240,37 @@ function useAttendanceRepository() {
|
|
|
33238
33240
|
if (search) {
|
|
33239
33241
|
cacheOptions.search = search;
|
|
33240
33242
|
}
|
|
33243
|
+
const singaporeTz = "Asia/Singapore";
|
|
33244
|
+
const normalizedStartDate = typeof startDate === "string" ? startDate : (0, import_moment.default)(startDate).tz(singaporeTz).format("YYYY-MM-DD");
|
|
33245
|
+
const normalizedEndDate = typeof endDate === "string" ? endDate : (0, import_moment.default)(endDate).tz(singaporeTz).format("YYYY-MM-DD");
|
|
33246
|
+
if (startDate && endDate) {
|
|
33247
|
+
const startOfDay = import_moment.default.tz(normalizedStartDate, "YYYY-MM-DD", singaporeTz).startOf("day").toDate();
|
|
33248
|
+
const endOfDay = import_moment.default.tz(normalizedEndDate, "YYYY-MM-DD", singaporeTz).endOf("day").toDate();
|
|
33249
|
+
query.$expr = {
|
|
33250
|
+
$and: [
|
|
33251
|
+
{ $gte: [{ $toDate: "$checkIn.timestamp" }, startOfDay] },
|
|
33252
|
+
{ $lte: [{ $toDate: "$checkIn.timestamp" }, endOfDay] }
|
|
33253
|
+
]
|
|
33254
|
+
};
|
|
33255
|
+
cacheOptions.startDate = normalizedStartDate;
|
|
33256
|
+
cacheOptions.endDate = normalizedEndDate;
|
|
33257
|
+
} else if (startDate) {
|
|
33258
|
+
query.$expr = {
|
|
33259
|
+
$gte: [
|
|
33260
|
+
{ $toDate: "$checkIn.timestamp" },
|
|
33261
|
+
import_moment.default.tz(normalizedStartDate, "YYYY-MM-DD", singaporeTz).startOf("day").toDate()
|
|
33262
|
+
]
|
|
33263
|
+
};
|
|
33264
|
+
cacheOptions.startDate = normalizedStartDate;
|
|
33265
|
+
} else if (endDate) {
|
|
33266
|
+
query.$expr = {
|
|
33267
|
+
$lte: [
|
|
33268
|
+
{ $toDate: "$checkIn.timestamp" },
|
|
33269
|
+
import_moment.default.tz(normalizedEndDate, "YYYY-MM-DD", singaporeTz).endOf("day").toDate()
|
|
33270
|
+
]
|
|
33271
|
+
};
|
|
33272
|
+
cacheOptions.endDate = normalizedEndDate;
|
|
33273
|
+
}
|
|
33241
33274
|
const cacheKey = (0, import_node_server_utils103.makeCacheKey)(namespace_collection, cacheOptions);
|
|
33242
33275
|
const cachedData = await getCache(cacheKey);
|
|
33243
33276
|
if (cachedData) {
|
|
@@ -33683,6 +33716,8 @@ function useAttendanceController() {
|
|
|
33683
33716
|
search: import_joi56.default.string().optional().allow("", null),
|
|
33684
33717
|
site: import_joi56.default.string().hex().required(),
|
|
33685
33718
|
serviceType: import_joi56.default.string().valid(...Object.values(AppServiceType)).required(),
|
|
33719
|
+
dateFrom: import_joi56.default.alternatives().try(import_joi56.default.date(), import_joi56.default.string()).optional().allow("", null),
|
|
33720
|
+
dateTo: import_joi56.default.alternatives().try(import_joi56.default.date(), import_joi56.default.string()).optional().allow("", null),
|
|
33686
33721
|
user: import_joi56.default.string().hex().required()
|
|
33687
33722
|
});
|
|
33688
33723
|
const { error } = validation.validate(query);
|
|
@@ -33696,6 +33731,8 @@ function useAttendanceController() {
|
|
|
33696
33731
|
const search = req.query.search ?? "";
|
|
33697
33732
|
const site = req.params.site ?? "";
|
|
33698
33733
|
const serviceType = req.query.serviceType ?? "";
|
|
33734
|
+
const startDate = req.query.dateFrom ?? "";
|
|
33735
|
+
const endDate = req.query.dateTo ?? "";
|
|
33699
33736
|
try {
|
|
33700
33737
|
const data = await _getAttendanceByUser({
|
|
33701
33738
|
page,
|
|
@@ -33703,7 +33740,9 @@ function useAttendanceController() {
|
|
|
33703
33740
|
search,
|
|
33704
33741
|
site,
|
|
33705
33742
|
serviceType,
|
|
33706
|
-
user
|
|
33743
|
+
user,
|
|
33744
|
+
startDate,
|
|
33745
|
+
endDate
|
|
33707
33746
|
});
|
|
33708
33747
|
res.json(data);
|
|
33709
33748
|
return;
|
|
@@ -58589,13 +58628,9 @@ function useNfcPatrolLogRepo() {
|
|
|
58589
58628
|
};
|
|
58590
58629
|
if (date) {
|
|
58591
58630
|
if (type === "month") {
|
|
58592
|
-
const [year, month] = date.split("-").map(Number);
|
|
58593
|
-
const endDay = new Date(year, month, 0).getDate();
|
|
58594
58631
|
query.date = {
|
|
58595
|
-
$gte: `${
|
|
58596
|
-
$lte: `${
|
|
58597
|
-
endDay
|
|
58598
|
-
).padStart(2, "0")}`
|
|
58632
|
+
$gte: `${date}-01-01`,
|
|
58633
|
+
$lte: `${date}-12-31`
|
|
58599
58634
|
};
|
|
58600
58635
|
} else {
|
|
58601
58636
|
query.date = date;
|
|
@@ -58916,49 +58951,52 @@ function useNfcPatrolLogController() {
|
|
|
58916
58951
|
page: import_joi111.default.number().integer().min(1).default(1),
|
|
58917
58952
|
limit: import_joi111.default.number().integer().min(1).max(100).default(10),
|
|
58918
58953
|
site: import_joi111.default.string().length(24).hex().required(),
|
|
58919
|
-
date: import_joi111.default.string().pattern(/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])
|
|
58920
|
-
"string.pattern.base": "Date must be
|
|
58954
|
+
date: import_joi111.default.string().pattern(/^\d{4}(-(0[1-9]|1[0-2])(-(0[1-9]|[12][0-9]|3[01]))?)?$/).optional().messages({
|
|
58955
|
+
"string.pattern.base": "Date must be YYYY or YYYY-MM or YYYY-MM-DD"
|
|
58921
58956
|
}),
|
|
58922
58957
|
type: import_joi111.default.string().valid("month").optional(),
|
|
58923
58958
|
route: import_joi111.default.object({
|
|
58924
|
-
_id: import_joi111.default.string().length(24).hex().
|
|
58925
|
-
startTime: import_joi111.default.string().pattern(/^([01]\d|2[0-3]):([0-5]\d)$/).
|
|
58926
|
-
|
|
58959
|
+
_id: import_joi111.default.string().length(24).hex().optional(),
|
|
58960
|
+
startTime: import_joi111.default.string().pattern(/^([01]\d|2[0-3]):([0-5]\d)$/).optional().messages({
|
|
58961
|
+
"string.pattern.base": "startTime must be in HH:mm 24-hour format"
|
|
58962
|
+
})
|
|
58963
|
+
}).min(1).optional()
|
|
58927
58964
|
});
|
|
58928
58965
|
const query = {
|
|
58966
|
+
page: req.query.page,
|
|
58967
|
+
limit: req.query.limit,
|
|
58929
58968
|
site: req.query.site,
|
|
58930
58969
|
date: req.query.date,
|
|
58931
58970
|
type: req.query.type,
|
|
58932
|
-
route: {
|
|
58933
|
-
_id: req.query["route._id"],
|
|
58934
|
-
startTime: req.query["route.startTime"]
|
|
58935
|
-
}
|
|
58971
|
+
route: req.query["route._id"] || req.query["route.startTime"] ? {
|
|
58972
|
+
...req.query["route._id"] ? { _id: req.query["route._id"] } : {},
|
|
58973
|
+
...req.query["route.startTime"] ? { startTime: req.query["route.startTime"] } : {}
|
|
58974
|
+
} : void 0
|
|
58936
58975
|
};
|
|
58937
58976
|
const { error, value } = validation.validate(query, {
|
|
58938
|
-
abortEarly: false
|
|
58977
|
+
abortEarly: false,
|
|
58978
|
+
allowUnknown: true,
|
|
58979
|
+
stripUnknown: true
|
|
58939
58980
|
});
|
|
58940
58981
|
if (error) {
|
|
58941
|
-
|
|
58942
|
-
|
|
58943
|
-
|
|
58944
|
-
|
|
58982
|
+
return next(
|
|
58983
|
+
new import_node_server_utils200.BadRequestError(
|
|
58984
|
+
error.details.map((d) => d.message).join(", ")
|
|
58985
|
+
)
|
|
58986
|
+
);
|
|
58945
58987
|
}
|
|
58946
|
-
const { page, limit, site, date, type, route } = value;
|
|
58947
58988
|
try {
|
|
58948
58989
|
const data = await _getAllBySite({
|
|
58949
|
-
page,
|
|
58950
|
-
limit,
|
|
58951
|
-
site,
|
|
58952
|
-
date,
|
|
58953
|
-
type,
|
|
58954
|
-
route
|
|
58990
|
+
page: value.page,
|
|
58991
|
+
limit: value.limit,
|
|
58992
|
+
site: value.site,
|
|
58993
|
+
date: value.date,
|
|
58994
|
+
type: value.type,
|
|
58995
|
+
route: value.route
|
|
58955
58996
|
});
|
|
58956
|
-
res.status(200).json(data);
|
|
58957
|
-
return;
|
|
58997
|
+
return res.status(200).json(data);
|
|
58958
58998
|
} catch (error2) {
|
|
58959
|
-
|
|
58960
|
-
next(error2);
|
|
58961
|
-
return;
|
|
58999
|
+
return next(error2);
|
|
58962
59000
|
}
|
|
58963
59001
|
}
|
|
58964
59002
|
async function completeCheckpoint(req, res, next) {
|