@7365admin1/module-hygiene 4.15.0 → 4.16.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 +6 -0
- package/dist/index.d.ts +20 -18
- package/dist/index.js +34 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -24
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1183,11 +1183,13 @@ function useUnitRepository() {
|
|
|
1183
1183
|
}) {
|
|
1184
1184
|
page = page > 0 ? page - 1 : 0;
|
|
1185
1185
|
const query = {
|
|
1186
|
-
status: { $ne: "deleted" }
|
|
1186
|
+
status: { $ne: "deleted" },
|
|
1187
|
+
serviceType
|
|
1187
1188
|
};
|
|
1188
1189
|
const cacheOptions = {
|
|
1189
1190
|
page,
|
|
1190
|
-
limit
|
|
1191
|
+
limit,
|
|
1192
|
+
serviceType
|
|
1191
1193
|
};
|
|
1192
1194
|
try {
|
|
1193
1195
|
site = new ObjectId5(site);
|
|
@@ -1196,10 +1198,6 @@ function useUnitRepository() {
|
|
|
1196
1198
|
} catch (error) {
|
|
1197
1199
|
throw new BadRequestError6("Invalid site ID format.");
|
|
1198
1200
|
}
|
|
1199
|
-
if (serviceType) {
|
|
1200
|
-
query.serviceType = serviceType;
|
|
1201
|
-
cacheOptions.serviceType = serviceType;
|
|
1202
|
-
}
|
|
1203
1201
|
if (search) {
|
|
1204
1202
|
query.$or = [{ name: { $regex: search, $options: "i" } }];
|
|
1205
1203
|
cacheOptions.search = search;
|
|
@@ -2634,6 +2632,7 @@ function useParentChecklistRepo() {
|
|
|
2634
2632
|
getAllParentChecklist,
|
|
2635
2633
|
getParentChecklistById,
|
|
2636
2634
|
updateParentChecklistStatuses,
|
|
2635
|
+
getHygieneSiteIds,
|
|
2637
2636
|
closeExpiredParentChecklists,
|
|
2638
2637
|
getTodayParentChecklists,
|
|
2639
2638
|
getTodayParentChecklistsForAreaGen
|
|
@@ -2650,7 +2649,12 @@ function useParentChecklistController() {
|
|
|
2650
2649
|
} = useParentChecklistRepo();
|
|
2651
2650
|
async function createParentChecklist(req, res, next) {
|
|
2652
2651
|
const payload = req.body;
|
|
2653
|
-
const
|
|
2652
|
+
const validation = Joi7.object({
|
|
2653
|
+
createdAt: Joi7.alternatives().try(Joi7.date(), Joi7.string()).optional().allow("", null),
|
|
2654
|
+
site: Joi7.string().hex().required(),
|
|
2655
|
+
serviceType: Joi7.string().valid(...Object.values(ServiceType)).optional().allow("", null)
|
|
2656
|
+
});
|
|
2657
|
+
const { error } = validation.validate(payload);
|
|
2654
2658
|
if (error) {
|
|
2655
2659
|
logger15.log({ level: "error", message: error.message });
|
|
2656
2660
|
next(new BadRequestError13(error.message));
|
|
@@ -2724,7 +2728,7 @@ import { BadRequestError as BadRequestError14, logger as logger16 } from "@7365a
|
|
|
2724
2728
|
var allowedChecklistStatus = ["open", "completed", "closed"];
|
|
2725
2729
|
var areaChecklistSchema = Joi8.object({
|
|
2726
2730
|
schedule: Joi8.string().hex().required(),
|
|
2727
|
-
serviceType: Joi8.string().valid(...Object.values(ServiceType)).
|
|
2731
|
+
serviceType: Joi8.string().valid(...Object.values(ServiceType)).required(),
|
|
2728
2732
|
area: Joi8.string().hex().required(),
|
|
2729
2733
|
name: Joi8.string().required(),
|
|
2730
2734
|
type: Joi8.string().valid(...allowedTypes).required(),
|
|
@@ -2917,10 +2921,11 @@ function useAreaChecklistRepo() {
|
|
|
2917
2921
|
serviceType
|
|
2918
2922
|
}, session) {
|
|
2919
2923
|
page = page > 0 ? page - 1 : 0;
|
|
2920
|
-
const query = {};
|
|
2924
|
+
const query = { serviceType };
|
|
2921
2925
|
const cacheOptions = {
|
|
2922
2926
|
page,
|
|
2923
|
-
limit
|
|
2927
|
+
limit,
|
|
2928
|
+
serviceType
|
|
2924
2929
|
};
|
|
2925
2930
|
try {
|
|
2926
2931
|
query.schedule = new ObjectId9(schedule);
|
|
@@ -2928,10 +2933,6 @@ function useAreaChecklistRepo() {
|
|
|
2928
2933
|
} catch (error) {
|
|
2929
2934
|
throw new BadRequestError15("Invalid parent checklist ID format.");
|
|
2930
2935
|
}
|
|
2931
|
-
if (serviceType) {
|
|
2932
|
-
query.serviceType = serviceType;
|
|
2933
|
-
cacheOptions.serviceType = serviceType;
|
|
2934
|
-
}
|
|
2935
2936
|
if (type && type !== "all") {
|
|
2936
2937
|
query.type = type;
|
|
2937
2938
|
cacheOptions.type = type;
|
|
@@ -3331,10 +3332,11 @@ function useAreaChecklistRepo() {
|
|
|
3331
3332
|
_id
|
|
3332
3333
|
}, session) {
|
|
3333
3334
|
page = page > 0 ? page - 1 : 0;
|
|
3334
|
-
const query = {};
|
|
3335
|
+
const query = { serviceType };
|
|
3335
3336
|
const cacheOptions = {
|
|
3336
3337
|
page,
|
|
3337
|
-
limit
|
|
3338
|
+
limit,
|
|
3339
|
+
serviceType
|
|
3338
3340
|
};
|
|
3339
3341
|
try {
|
|
3340
3342
|
query._id = new ObjectId9(_id);
|
|
@@ -3342,10 +3344,6 @@ function useAreaChecklistRepo() {
|
|
|
3342
3344
|
} catch (error) {
|
|
3343
3345
|
throw new BadRequestError15("Invalid area checklist ID format.");
|
|
3344
3346
|
}
|
|
3345
|
-
if (serviceType) {
|
|
3346
|
-
query.serviceType = serviceType;
|
|
3347
|
-
cacheOptions.serviceType = serviceType;
|
|
3348
|
-
}
|
|
3349
3347
|
if (search) {
|
|
3350
3348
|
query.$text = { $search: search };
|
|
3351
3349
|
cacheOptions.search = search;
|
|
@@ -3559,7 +3557,16 @@ function useAreaChecklistRepo() {
|
|
|
3559
3557
|
try {
|
|
3560
3558
|
const area = await collection.findOne(
|
|
3561
3559
|
{ _id },
|
|
3562
|
-
{
|
|
3560
|
+
{
|
|
3561
|
+
projection: {
|
|
3562
|
+
schedule: 1,
|
|
3563
|
+
serviceType: 1,
|
|
3564
|
+
name: 1,
|
|
3565
|
+
type: 1,
|
|
3566
|
+
status: 1
|
|
3567
|
+
},
|
|
3568
|
+
session
|
|
3569
|
+
}
|
|
3563
3570
|
);
|
|
3564
3571
|
if (!area) {
|
|
3565
3572
|
throw new BadRequestError15("Area checklist not found.");
|
|
@@ -4118,10 +4125,14 @@ function useAreaChecklistService() {
|
|
|
4118
4125
|
);
|
|
4119
4126
|
}
|
|
4120
4127
|
await _updateAreaChecklistUnits(_id, set, unitId, value, session);
|
|
4128
|
+
const currentArea = await getAreaChecklistById(_id, session);
|
|
4129
|
+
const scheduleId = currentArea.schedule;
|
|
4130
|
+
const serviceType = currentArea.serviceType;
|
|
4121
4131
|
const allUnitsResult = await getAreaChecklistUnits(
|
|
4122
4132
|
{
|
|
4123
4133
|
page: 1,
|
|
4124
4134
|
limit: 1e3,
|
|
4135
|
+
serviceType,
|
|
4125
4136
|
_id: _id.toString()
|
|
4126
4137
|
},
|
|
4127
4138
|
session
|
|
@@ -4146,14 +4157,13 @@ function useAreaChecklistService() {
|
|
|
4146
4157
|
}
|
|
4147
4158
|
}
|
|
4148
4159
|
await updateAreaChecklistStatus(_id, areaStatus, session);
|
|
4149
|
-
const currentArea = await getAreaChecklistById(_id, session);
|
|
4150
|
-
const scheduleId = currentArea.schedule;
|
|
4151
4160
|
if (scheduleId) {
|
|
4152
4161
|
const allAreasResult = await getAllAreaChecklist(
|
|
4153
4162
|
{
|
|
4154
4163
|
page: 1,
|
|
4155
4164
|
limit: 1e3,
|
|
4156
|
-
schedule: scheduleId.toString()
|
|
4165
|
+
schedule: scheduleId.toString(),
|
|
4166
|
+
serviceType
|
|
4157
4167
|
},
|
|
4158
4168
|
session
|
|
4159
4169
|
);
|