@7365admin1/module-hygiene 4.15.0 → 4.17.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 +12 -0
- package/dist/index.d.ts +23 -25
- package/dist/index.js +42 -87
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -87
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -135,19 +135,19 @@ type TUnit = {
|
|
|
135
135
|
status?: "active" | "deleted";
|
|
136
136
|
};
|
|
137
137
|
type TUnitCreate = {
|
|
138
|
-
serviceType
|
|
138
|
+
serviceType: TServiceType;
|
|
139
139
|
} & Pick<TUnit, "site" | "name">;
|
|
140
140
|
type TUnitGetQuery = {
|
|
141
141
|
page?: number;
|
|
142
142
|
limit?: number;
|
|
143
143
|
search?: string;
|
|
144
|
-
serviceType
|
|
144
|
+
serviceType: TServiceType;
|
|
145
145
|
} & Pick<TUnit, "site">;
|
|
146
146
|
type TUnitUpdate = Pick<TUnit, "name">;
|
|
147
147
|
declare const unitSchema: Joi.ObjectSchema<any>;
|
|
148
148
|
declare function MUnit(value: TUnitCreate): {
|
|
149
149
|
site: string | ObjectId;
|
|
150
|
-
serviceType: ServiceType
|
|
150
|
+
serviceType: ServiceType;
|
|
151
151
|
name: string;
|
|
152
152
|
status: string;
|
|
153
153
|
createdAt: Date;
|
|
@@ -159,7 +159,7 @@ declare function useUnitService(): {
|
|
|
159
159
|
importUnit: ({ dataJson, site, serviceType, }: {
|
|
160
160
|
dataJson: string;
|
|
161
161
|
site: string | ObjectId;
|
|
162
|
-
serviceType
|
|
162
|
+
serviceType: TServiceType;
|
|
163
163
|
}) => Promise<{
|
|
164
164
|
message: string;
|
|
165
165
|
}>;
|
|
@@ -167,7 +167,7 @@ declare function useUnitService(): {
|
|
|
167
167
|
deleteUnit: (_id: string | ObjectId) => Promise<number>;
|
|
168
168
|
exportUnits: ({ site, serviceType, }: {
|
|
169
169
|
site: string | ObjectId;
|
|
170
|
-
serviceType
|
|
170
|
+
serviceType: TServiceType;
|
|
171
171
|
}) => Promise<Buffer>;
|
|
172
172
|
};
|
|
173
173
|
|
|
@@ -192,12 +192,16 @@ declare function useUnitController(): {
|
|
|
192
192
|
|
|
193
193
|
type TParentChecklist = {
|
|
194
194
|
_id?: ObjectId;
|
|
195
|
-
site
|
|
196
|
-
serviceType
|
|
195
|
+
site: string | ObjectId;
|
|
196
|
+
serviceType: TServiceType;
|
|
197
197
|
status?: (typeof allowedStatus)[number];
|
|
198
198
|
createdAt?: Date | string;
|
|
199
199
|
updatedAt?: Date | string;
|
|
200
200
|
};
|
|
201
|
+
type TParentChecklistCreate = {
|
|
202
|
+
site?: string | ObjectId;
|
|
203
|
+
serviceType?: TServiceType;
|
|
204
|
+
} & Pick<TParentChecklist, "createdAt">;
|
|
201
205
|
type TParentChecklistGetQuery = {
|
|
202
206
|
site: string | ObjectId;
|
|
203
207
|
serviceType: TServiceType;
|
|
@@ -209,8 +213,8 @@ type TParentChecklistGetQuery = {
|
|
|
209
213
|
} & Pick<TParentChecklist, "status">;
|
|
210
214
|
declare const parentChecklistSchema: Joi.ObjectSchema<any>;
|
|
211
215
|
declare function MParentChecklist(value: TParentChecklist): {
|
|
212
|
-
site: string | ObjectId
|
|
213
|
-
serviceType: ServiceType
|
|
216
|
+
site: string | ObjectId;
|
|
217
|
+
serviceType: ServiceType;
|
|
214
218
|
status: string;
|
|
215
219
|
createdAt: string | Date;
|
|
216
220
|
updatedAt: string | Date;
|
|
@@ -218,12 +222,13 @@ declare function MParentChecklist(value: TParentChecklist): {
|
|
|
218
222
|
|
|
219
223
|
declare function useParentChecklistRepo(): {
|
|
220
224
|
createIndex: () => Promise<void>;
|
|
221
|
-
createParentChecklist: (value:
|
|
225
|
+
createParentChecklist: (value: TParentChecklistCreate, session?: ClientSession) => Promise<ObjectId | ObjectId[]>;
|
|
222
226
|
getAllParentChecklist: ({ page, limit, search, site, startDate, endDate, status, serviceType, }: TParentChecklistGetQuery) => Promise<{}>;
|
|
223
227
|
getParentChecklistById: (_id: string | ObjectId) => Promise<TParentChecklist & {
|
|
224
228
|
_id: ObjectId;
|
|
225
229
|
}>;
|
|
226
230
|
updateParentChecklistStatuses: (_id: string | ObjectId, status: (typeof allowedStatus)[number], session?: ClientSession) => Promise<number>;
|
|
231
|
+
getHygieneSiteIds: () => Promise<any[]>;
|
|
227
232
|
closeExpiredParentChecklists: () => Promise<number>;
|
|
228
233
|
getTodayParentChecklists: () => Promise<{
|
|
229
234
|
_id: ObjectId;
|
|
@@ -251,7 +256,6 @@ type TCleaningScheduleArea = {
|
|
|
251
256
|
type: (typeof allowedTypes)[number];
|
|
252
257
|
checklist: TAreaChecklist[];
|
|
253
258
|
status?: (typeof allowedStatus)[number];
|
|
254
|
-
createdBy?: string | ObjectId;
|
|
255
259
|
createdAt?: Date | string;
|
|
256
260
|
completedAt?: Date | string;
|
|
257
261
|
updatedAt?: Date | string;
|
|
@@ -274,20 +278,17 @@ type TAreaChecklistUnits = {
|
|
|
274
278
|
completedBy?: string | ObjectId;
|
|
275
279
|
timestamp?: Date | string;
|
|
276
280
|
};
|
|
277
|
-
type TAreaChecklistCreate = Pick<TCleaningScheduleArea, "schedule" | "
|
|
278
|
-
|
|
279
|
-
};
|
|
280
|
-
type TAreaChecklistBatchCreate = Pick<TCleaningScheduleArea, "schedule" | "createdBy"> & {
|
|
281
|
+
type TAreaChecklistCreate = Pick<TCleaningScheduleArea, "schedule" | "serviceType" | "area" | "name" | "type" | "checklist">;
|
|
282
|
+
type TAreaChecklistBatchCreate = Pick<TCleaningScheduleArea, "schedule"> & {
|
|
281
283
|
site: string | ObjectId;
|
|
282
284
|
};
|
|
283
285
|
type TCleaningScheduleAreaGetQuery = {
|
|
284
286
|
page?: number;
|
|
285
287
|
limit?: number;
|
|
286
288
|
search?: string;
|
|
287
|
-
serviceType?: TServiceType;
|
|
288
289
|
type?: (typeof allowedTypes)[number] | "all";
|
|
289
290
|
status?: (typeof allowedStatus)[number] | "all";
|
|
290
|
-
} & Pick<TCleaningScheduleArea, "schedule">;
|
|
291
|
+
} & Pick<TCleaningScheduleArea, "schedule" | "serviceType">;
|
|
291
292
|
type TAreaChecklistUpdate = Pick<TCleaningScheduleArea, "checklist">;
|
|
292
293
|
type TAreaChecklistUnitsUpdate = Pick<TAreaChecklistUnits, "approve" | "reject" | "remarks" | "completedBy"> & Pick<TAreaChecklist, "attachment">;
|
|
293
294
|
declare const areaChecklistSchema: Joi.ObjectSchema<any>;
|
|
@@ -299,7 +300,6 @@ declare function MAreaChecklist(value: TAreaChecklistCreate): {
|
|
|
299
300
|
type: string;
|
|
300
301
|
checklist: TAreaChecklist[];
|
|
301
302
|
status: string;
|
|
302
|
-
createdBy: string | ObjectId | undefined;
|
|
303
303
|
createdAt: Date;
|
|
304
304
|
completedAt: string;
|
|
305
305
|
updatedAt: string;
|
|
@@ -359,13 +359,13 @@ declare function useAreaChecklistRepo(): {
|
|
|
359
359
|
page?: number | undefined;
|
|
360
360
|
limit?: number | undefined;
|
|
361
361
|
search?: string | undefined;
|
|
362
|
-
serviceType
|
|
362
|
+
serviceType: TServiceType;
|
|
363
363
|
_id: string | ObjectId;
|
|
364
364
|
}, session?: ClientSession) => Promise<{}>;
|
|
365
365
|
getAreaChecklistById: (_id: string | ObjectId, session?: ClientSession) => Promise<mongodb.WithId<bson.Document>>;
|
|
366
366
|
getAreaChecklistByAreaAndSchedule: ({ schedule, serviceType, area, session, }: {
|
|
367
367
|
schedule: string | ObjectId;
|
|
368
|
-
serviceType
|
|
368
|
+
serviceType: TServiceType;
|
|
369
369
|
area: string | ObjectId;
|
|
370
370
|
session?: ClientSession | undefined;
|
|
371
371
|
}) => Promise<mongodb.WithId<bson.Document>>;
|
|
@@ -574,18 +574,17 @@ type TScheduleTask = {
|
|
|
574
574
|
value: ObjectId;
|
|
575
575
|
}[];
|
|
576
576
|
status?: "active" | "deleted";
|
|
577
|
-
createdBy: string | ObjectId;
|
|
578
577
|
createdAt?: string | Date;
|
|
579
578
|
updatedAt?: string | Date;
|
|
580
579
|
deletedAt?: string | Date;
|
|
581
580
|
};
|
|
582
|
-
type TScheduleTaskCreate = Pick<TScheduleTask, "site" | "serviceType" | "title" | "time" | "dates" | "description" | "areas"
|
|
581
|
+
type TScheduleTaskCreate = Pick<TScheduleTask, "site" | "serviceType" | "title" | "time" | "dates" | "description" | "areas">;
|
|
583
582
|
type TScheduleTaskGetQuery = {
|
|
584
583
|
page?: number;
|
|
585
584
|
limit?: number;
|
|
586
585
|
search?: string;
|
|
587
586
|
} & Pick<TScheduleTask, "site" | "serviceType">;
|
|
588
|
-
type TScheduleTaskGetById = Pick<TScheduleTask, "title" | "time" | "dates" | "description" | "areas" | "status" | "
|
|
587
|
+
type TScheduleTaskGetById = Pick<TScheduleTask, "title" | "time" | "dates" | "description" | "areas" | "status" | "createdAt">;
|
|
589
588
|
type TScheduleTaskUpdate = Partial<Pick<TScheduleTask, "title" | "time" | "dates" | "description" | "areas">>;
|
|
590
589
|
declare const scheduleTaskSchema: Joi.ObjectSchema<any>;
|
|
591
590
|
declare function MScheduleTask(value: TScheduleTaskCreate): {
|
|
@@ -600,7 +599,6 @@ declare function MScheduleTask(value: TScheduleTaskCreate): {
|
|
|
600
599
|
value: ObjectId;
|
|
601
600
|
}[];
|
|
602
601
|
status: string;
|
|
603
|
-
createdBy: string | ObjectId;
|
|
604
602
|
createdAt: Date;
|
|
605
603
|
updatedAt: string;
|
|
606
604
|
deletedAt: string;
|
|
@@ -647,4 +645,4 @@ declare function useQRController(): {
|
|
|
647
645
|
generateQR: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
648
646
|
};
|
|
649
647
|
|
|
650
|
-
export { MArea, MAreaChecklist, MCheckOutItem, MParentChecklist, MScheduleTask, MStock, MSupply, MUnit, ServiceType, TArea, TAreaChecklist, TAreaChecklistBatchCreate, TAreaChecklistCreate, TAreaChecklistUnits, TAreaChecklistUnitsUpdate, TAreaChecklistUpdate, TAreaCreate, TAreaGetQuery, TAreaUnits, TAreaUpdate, TAreaUpdateChecklist, TCheckOutItem, TCheckOutItemCreate, TCheckOutItemCreateByBatchService, TCheckOutItemCreateService, TCheckOutItemGetById, TCheckOutItemGetQuery, TCleaningScheduleArea, TCleaningScheduleAreaGetQuery, TGetStocksQuery, TParentChecklist, TParentChecklistGetQuery, TScheduleTask, TScheduleTaskCreate, TScheduleTaskGetById, TScheduleTaskGetQuery, TScheduleTaskUpdate, TServiceType, TStock, TStockCreate, TStockCreateService, TSupply, TSupplyCreate, TSupplyGetById, TSupplyGetQuery, TSupplyUpdate, TUnit, TUnitCreate, TUnitGetQuery, TUnitUpdate, allowedCheckOutItemStatus, allowedChecklistStatus, allowedPeriods, allowedStatus, allowedTypes, areaChecklistSchema, areaSchema, checkOutItemSchema, parentChecklistSchema, scheduleTaskSchema, stockSchema, supplySchema, unitSchema, useAreaChecklistController, useAreaChecklistRepo, useAreaChecklistService, useAreaController, useAreaExportService, useAreaRepo, useAreaService, useCheckOutItemController, useCheckOutItemRepository, useCheckOutItemService, useHygieneDashboardController, useHygieneDashboardRepository, useParentChecklistController, useParentChecklistRepo, useQRController, useQRService, useScheduleTaskController, useScheduleTaskRepository, useScheduleTaskService, useStockController, useStockRepository, useStockService, useSupplyController, useSupplyRepository, useUnitController, useUnitExportService, useUnitRepository, useUnitService };
|
|
648
|
+
export { MArea, MAreaChecklist, MCheckOutItem, MParentChecklist, MScheduleTask, MStock, MSupply, MUnit, ServiceType, TArea, TAreaChecklist, TAreaChecklistBatchCreate, TAreaChecklistCreate, TAreaChecklistUnits, TAreaChecklistUnitsUpdate, TAreaChecklistUpdate, TAreaCreate, TAreaGetQuery, TAreaUnits, TAreaUpdate, TAreaUpdateChecklist, TCheckOutItem, TCheckOutItemCreate, TCheckOutItemCreateByBatchService, TCheckOutItemCreateService, TCheckOutItemGetById, TCheckOutItemGetQuery, TCleaningScheduleArea, TCleaningScheduleAreaGetQuery, TGetStocksQuery, TParentChecklist, TParentChecklistCreate, TParentChecklistGetQuery, TScheduleTask, TScheduleTaskCreate, TScheduleTaskGetById, TScheduleTaskGetQuery, TScheduleTaskUpdate, TServiceType, TStock, TStockCreate, TStockCreateService, TSupply, TSupplyCreate, TSupplyGetById, TSupplyGetQuery, TSupplyUpdate, TUnit, TUnitCreate, TUnitGetQuery, TUnitUpdate, allowedCheckOutItemStatus, allowedChecklistStatus, allowedPeriods, allowedStatus, allowedTypes, areaChecklistSchema, areaSchema, checkOutItemSchema, parentChecklistSchema, scheduleTaskSchema, stockSchema, supplySchema, unitSchema, useAreaChecklistController, useAreaChecklistRepo, useAreaChecklistService, useAreaController, useAreaExportService, useAreaRepo, useAreaService, useCheckOutItemController, useCheckOutItemRepository, useCheckOutItemService, useHygieneDashboardController, useHygieneDashboardRepository, useParentChecklistController, useParentChecklistRepo, useQRController, useQRService, useScheduleTaskController, useScheduleTaskRepository, useScheduleTaskService, useStockController, useStockRepository, useStockService, useSupplyController, useSupplyRepository, useUnitController, useUnitExportService, useUnitRepository, useUnitService };
|
package/dist/index.js
CHANGED
|
@@ -1240,11 +1240,13 @@ function useUnitRepository() {
|
|
|
1240
1240
|
}) {
|
|
1241
1241
|
page = page > 0 ? page - 1 : 0;
|
|
1242
1242
|
const query = {
|
|
1243
|
-
status: { $ne: "deleted" }
|
|
1243
|
+
status: { $ne: "deleted" },
|
|
1244
|
+
serviceType
|
|
1244
1245
|
};
|
|
1245
1246
|
const cacheOptions = {
|
|
1246
1247
|
page,
|
|
1247
|
-
limit
|
|
1248
|
+
limit,
|
|
1249
|
+
serviceType
|
|
1248
1250
|
};
|
|
1249
1251
|
try {
|
|
1250
1252
|
site = new import_mongodb5.ObjectId(site);
|
|
@@ -1253,10 +1255,6 @@ function useUnitRepository() {
|
|
|
1253
1255
|
} catch (error) {
|
|
1254
1256
|
throw new import_node_server_utils7.BadRequestError("Invalid site ID format.");
|
|
1255
1257
|
}
|
|
1256
|
-
if (serviceType) {
|
|
1257
|
-
query.serviceType = serviceType;
|
|
1258
|
-
cacheOptions.serviceType = serviceType;
|
|
1259
|
-
}
|
|
1260
1258
|
if (search) {
|
|
1261
1259
|
query.$or = [{ name: { $regex: search, $options: "i" } }];
|
|
1262
1260
|
cacheOptions.search = search;
|
|
@@ -2678,6 +2676,7 @@ function useParentChecklistRepo() {
|
|
|
2678
2676
|
getAllParentChecklist,
|
|
2679
2677
|
getParentChecklistById,
|
|
2680
2678
|
updateParentChecklistStatuses,
|
|
2679
|
+
getHygieneSiteIds,
|
|
2681
2680
|
closeExpiredParentChecklists,
|
|
2682
2681
|
getTodayParentChecklists,
|
|
2683
2682
|
getTodayParentChecklistsForAreaGen
|
|
@@ -2694,7 +2693,12 @@ function useParentChecklistController() {
|
|
|
2694
2693
|
} = useParentChecklistRepo();
|
|
2695
2694
|
async function createParentChecklist(req, res, next) {
|
|
2696
2695
|
const payload = req.body;
|
|
2697
|
-
const
|
|
2696
|
+
const validation = import_joi7.default.object({
|
|
2697
|
+
createdAt: import_joi7.default.alternatives().try(import_joi7.default.date(), import_joi7.default.string()).optional().allow("", null),
|
|
2698
|
+
site: import_joi7.default.string().hex().required(),
|
|
2699
|
+
serviceType: import_joi7.default.string().valid(...Object.values(ServiceType)).optional().allow("", null)
|
|
2700
|
+
});
|
|
2701
|
+
const { error } = validation.validate(payload);
|
|
2698
2702
|
if (error) {
|
|
2699
2703
|
import_node_server_utils15.logger.log({ level: "error", message: error.message });
|
|
2700
2704
|
next(new import_node_server_utils15.BadRequestError(error.message));
|
|
@@ -2768,7 +2772,7 @@ var import_node_server_utils16 = require("@7365admin1/node-server-utils");
|
|
|
2768
2772
|
var allowedChecklistStatus = ["open", "completed", "closed"];
|
|
2769
2773
|
var areaChecklistSchema = import_joi8.default.object({
|
|
2770
2774
|
schedule: import_joi8.default.string().hex().required(),
|
|
2771
|
-
serviceType: import_joi8.default.string().valid(...Object.values(ServiceType)).
|
|
2775
|
+
serviceType: import_joi8.default.string().valid(...Object.values(ServiceType)).required(),
|
|
2772
2776
|
area: import_joi8.default.string().hex().required(),
|
|
2773
2777
|
name: import_joi8.default.string().required(),
|
|
2774
2778
|
type: import_joi8.default.string().valid(...allowedTypes).required(),
|
|
@@ -2784,8 +2788,7 @@ var areaChecklistSchema = import_joi8.default.object({
|
|
|
2784
2788
|
isScheduleTask: import_joi8.default.boolean().optional().default(false),
|
|
2785
2789
|
scheduleTaskId: import_joi8.default.string().hex().optional().allow(null)
|
|
2786
2790
|
}).required()
|
|
2787
|
-
).optional().default([])
|
|
2788
|
-
createdBy: import_joi8.default.string().hex().required()
|
|
2791
|
+
).optional().default([])
|
|
2789
2792
|
});
|
|
2790
2793
|
function MAreaChecklist(value) {
|
|
2791
2794
|
const { error } = areaChecklistSchema.validate(value);
|
|
@@ -2826,13 +2829,6 @@ function MAreaChecklist(value) {
|
|
|
2826
2829
|
};
|
|
2827
2830
|
});
|
|
2828
2831
|
}
|
|
2829
|
-
if (value.createdBy) {
|
|
2830
|
-
try {
|
|
2831
|
-
value.createdBy = new import_mongodb8.ObjectId(value.createdBy);
|
|
2832
|
-
} catch (error2) {
|
|
2833
|
-
throw new import_node_server_utils16.BadRequestError("Invalid createdBy ID format.");
|
|
2834
|
-
}
|
|
2835
|
-
}
|
|
2836
2832
|
return {
|
|
2837
2833
|
schedule: value.schedule,
|
|
2838
2834
|
serviceType: value.serviceType,
|
|
@@ -2841,7 +2837,6 @@ function MAreaChecklist(value) {
|
|
|
2841
2837
|
type: value.type,
|
|
2842
2838
|
checklist: value.checklist || [],
|
|
2843
2839
|
status: "open",
|
|
2844
|
-
createdBy: value.createdBy,
|
|
2845
2840
|
createdAt: /* @__PURE__ */ new Date(),
|
|
2846
2841
|
completedAt: "",
|
|
2847
2842
|
updatedAt: ""
|
|
@@ -2949,10 +2944,11 @@ function useAreaChecklistRepo() {
|
|
|
2949
2944
|
serviceType
|
|
2950
2945
|
}, session) {
|
|
2951
2946
|
page = page > 0 ? page - 1 : 0;
|
|
2952
|
-
const query = {};
|
|
2947
|
+
const query = { serviceType };
|
|
2953
2948
|
const cacheOptions = {
|
|
2954
2949
|
page,
|
|
2955
|
-
limit
|
|
2950
|
+
limit,
|
|
2951
|
+
serviceType
|
|
2956
2952
|
};
|
|
2957
2953
|
try {
|
|
2958
2954
|
query.schedule = new import_mongodb9.ObjectId(schedule);
|
|
@@ -2960,10 +2956,6 @@ function useAreaChecklistRepo() {
|
|
|
2960
2956
|
} catch (error) {
|
|
2961
2957
|
throw new import_node_server_utils17.BadRequestError("Invalid parent checklist ID format.");
|
|
2962
2958
|
}
|
|
2963
|
-
if (serviceType) {
|
|
2964
|
-
query.serviceType = serviceType;
|
|
2965
|
-
cacheOptions.serviceType = serviceType;
|
|
2966
|
-
}
|
|
2967
2959
|
if (type && type !== "all") {
|
|
2968
2960
|
query.type = type;
|
|
2969
2961
|
cacheOptions.type = type;
|
|
@@ -2987,32 +2979,6 @@ function useAreaChecklistRepo() {
|
|
|
2987
2979
|
try {
|
|
2988
2980
|
const pipeline = [
|
|
2989
2981
|
{ $match: query },
|
|
2990
|
-
{
|
|
2991
|
-
$lookup: {
|
|
2992
|
-
from: "users",
|
|
2993
|
-
let: { createdById: "$createdBy" },
|
|
2994
|
-
pipeline: [
|
|
2995
|
-
{
|
|
2996
|
-
$match: {
|
|
2997
|
-
$expr: {
|
|
2998
|
-
$and: [
|
|
2999
|
-
{ $ne: ["$$createdById", ""] },
|
|
3000
|
-
{ $eq: ["$_id", "$$createdById"] }
|
|
3001
|
-
]
|
|
3002
|
-
}
|
|
3003
|
-
}
|
|
3004
|
-
},
|
|
3005
|
-
{ $project: { name: 1 } }
|
|
3006
|
-
],
|
|
3007
|
-
as: "createdByDoc"
|
|
3008
|
-
}
|
|
3009
|
-
},
|
|
3010
|
-
{
|
|
3011
|
-
$unwind: {
|
|
3012
|
-
path: "$createdByDoc",
|
|
3013
|
-
preserveNullAndEmptyArrays: true
|
|
3014
|
-
}
|
|
3015
|
-
},
|
|
3016
2982
|
{
|
|
3017
2983
|
$addFields: {
|
|
3018
2984
|
statusOrder: {
|
|
@@ -3064,8 +3030,7 @@ function useAreaChecklistRepo() {
|
|
|
3064
3030
|
},
|
|
3065
3031
|
else: 0
|
|
3066
3032
|
}
|
|
3067
|
-
}
|
|
3068
|
-
createdByName: "$createdByDoc.name"
|
|
3033
|
+
}
|
|
3069
3034
|
}
|
|
3070
3035
|
},
|
|
3071
3036
|
{ $skip: page * limit },
|
|
@@ -3363,10 +3328,11 @@ function useAreaChecklistRepo() {
|
|
|
3363
3328
|
_id
|
|
3364
3329
|
}, session) {
|
|
3365
3330
|
page = page > 0 ? page - 1 : 0;
|
|
3366
|
-
const query = {};
|
|
3331
|
+
const query = { serviceType };
|
|
3367
3332
|
const cacheOptions = {
|
|
3368
3333
|
page,
|
|
3369
|
-
limit
|
|
3334
|
+
limit,
|
|
3335
|
+
serviceType
|
|
3370
3336
|
};
|
|
3371
3337
|
try {
|
|
3372
3338
|
query._id = new import_mongodb9.ObjectId(_id);
|
|
@@ -3374,10 +3340,6 @@ function useAreaChecklistRepo() {
|
|
|
3374
3340
|
} catch (error) {
|
|
3375
3341
|
throw new import_node_server_utils17.BadRequestError("Invalid area checklist ID format.");
|
|
3376
3342
|
}
|
|
3377
|
-
if (serviceType) {
|
|
3378
|
-
query.serviceType = serviceType;
|
|
3379
|
-
cacheOptions.serviceType = serviceType;
|
|
3380
|
-
}
|
|
3381
3343
|
if (search) {
|
|
3382
3344
|
query.$text = { $search: search };
|
|
3383
3345
|
cacheOptions.search = search;
|
|
@@ -3591,7 +3553,16 @@ function useAreaChecklistRepo() {
|
|
|
3591
3553
|
try {
|
|
3592
3554
|
const area = await collection.findOne(
|
|
3593
3555
|
{ _id },
|
|
3594
|
-
{
|
|
3556
|
+
{
|
|
3557
|
+
projection: {
|
|
3558
|
+
schedule: 1,
|
|
3559
|
+
serviceType: 1,
|
|
3560
|
+
name: 1,
|
|
3561
|
+
type: 1,
|
|
3562
|
+
status: 1
|
|
3563
|
+
},
|
|
3564
|
+
session
|
|
3565
|
+
}
|
|
3595
3566
|
);
|
|
3596
3567
|
if (!area) {
|
|
3597
3568
|
throw new import_node_server_utils17.BadRequestError("Area checklist not found.");
|
|
@@ -4113,8 +4084,7 @@ function useAreaChecklistService() {
|
|
|
4113
4084
|
unit: unit.unit.toString(),
|
|
4114
4085
|
name: unit.name
|
|
4115
4086
|
}))
|
|
4116
|
-
}))
|
|
4117
|
-
createdBy: value.createdBy
|
|
4087
|
+
}))
|
|
4118
4088
|
};
|
|
4119
4089
|
const insertedId = await _createAreaChecklist(checklistData);
|
|
4120
4090
|
totalChecklistsCreated++;
|
|
@@ -4150,10 +4120,14 @@ function useAreaChecklistService() {
|
|
|
4150
4120
|
);
|
|
4151
4121
|
}
|
|
4152
4122
|
await _updateAreaChecklistUnits(_id, set, unitId, value, session);
|
|
4123
|
+
const currentArea = await getAreaChecklistById(_id, session);
|
|
4124
|
+
const scheduleId = currentArea.schedule;
|
|
4125
|
+
const serviceType = currentArea.serviceType;
|
|
4153
4126
|
const allUnitsResult = await getAreaChecklistUnits(
|
|
4154
4127
|
{
|
|
4155
4128
|
page: 1,
|
|
4156
4129
|
limit: 1e3,
|
|
4130
|
+
serviceType,
|
|
4157
4131
|
_id: _id.toString()
|
|
4158
4132
|
},
|
|
4159
4133
|
session
|
|
@@ -4178,14 +4152,13 @@ function useAreaChecklistService() {
|
|
|
4178
4152
|
}
|
|
4179
4153
|
}
|
|
4180
4154
|
await updateAreaChecklistStatus(_id, areaStatus, session);
|
|
4181
|
-
const currentArea = await getAreaChecklistById(_id, session);
|
|
4182
|
-
const scheduleId = currentArea.schedule;
|
|
4183
4155
|
if (scheduleId) {
|
|
4184
4156
|
const allAreasResult = await getAllAreaChecklist(
|
|
4185
4157
|
{
|
|
4186
4158
|
page: 1,
|
|
4187
4159
|
limit: 1e3,
|
|
4188
|
-
schedule: scheduleId.toString()
|
|
4160
|
+
schedule: scheduleId.toString(),
|
|
4161
|
+
serviceType
|
|
4189
4162
|
},
|
|
4190
4163
|
session
|
|
4191
4164
|
);
|
|
@@ -4468,16 +4441,13 @@ function useAreaChecklistController() {
|
|
|
4468
4441
|
(acc, [key, value2]) => ({ ...acc, [key]: value2 }),
|
|
4469
4442
|
{}
|
|
4470
4443
|
) : {};
|
|
4471
|
-
const createdBy = cookies["user"] || "";
|
|
4472
4444
|
const payload = {
|
|
4473
4445
|
site: req.params.site,
|
|
4474
|
-
schedule: req.params.schedule
|
|
4475
|
-
createdBy
|
|
4446
|
+
schedule: req.params.schedule
|
|
4476
4447
|
};
|
|
4477
4448
|
const validation = import_joi9.default.object({
|
|
4478
4449
|
site: import_joi9.default.string().hex().required(),
|
|
4479
|
-
schedule: import_joi9.default.string().hex().required()
|
|
4480
|
-
createdBy: import_joi9.default.string().hex().required()
|
|
4450
|
+
schedule: import_joi9.default.string().hex().required()
|
|
4481
4451
|
});
|
|
4482
4452
|
const { error, value } = validation.validate(payload);
|
|
4483
4453
|
if (error) {
|
|
@@ -6019,8 +5989,7 @@ var scheduleTaskSchema = import_joi16.default.object({
|
|
|
6019
5989
|
name: import_joi16.default.string().required(),
|
|
6020
5990
|
value: import_joi16.default.any().required()
|
|
6021
5991
|
})
|
|
6022
|
-
).required()
|
|
6023
|
-
createdBy: import_joi16.default.string().hex().required()
|
|
5992
|
+
).required()
|
|
6024
5993
|
});
|
|
6025
5994
|
function MScheduleTask(value) {
|
|
6026
5995
|
const { error } = scheduleTaskSchema.validate(value);
|
|
@@ -6047,13 +6016,6 @@ function MScheduleTask(value) {
|
|
|
6047
6016
|
}
|
|
6048
6017
|
});
|
|
6049
6018
|
}
|
|
6050
|
-
if (value.createdBy) {
|
|
6051
|
-
try {
|
|
6052
|
-
value.createdBy = new import_mongodb18.ObjectId(value.createdBy);
|
|
6053
|
-
} catch (error2) {
|
|
6054
|
-
throw new import_node_server_utils32.BadRequestError("Invalid createdBy ID format.");
|
|
6055
|
-
}
|
|
6056
|
-
}
|
|
6057
6019
|
return {
|
|
6058
6020
|
site: value.site,
|
|
6059
6021
|
serviceType: value.serviceType,
|
|
@@ -6063,7 +6025,6 @@ function MScheduleTask(value) {
|
|
|
6063
6025
|
description: value.description,
|
|
6064
6026
|
areas: value.areas,
|
|
6065
6027
|
status: "active",
|
|
6066
|
-
createdBy: value.createdBy,
|
|
6067
6028
|
createdAt: /* @__PURE__ */ new Date(),
|
|
6068
6029
|
updatedAt: "",
|
|
6069
6030
|
deletedAt: ""
|
|
@@ -6576,8 +6537,7 @@ function useScheduleTaskService() {
|
|
|
6576
6537
|
area: areaId,
|
|
6577
6538
|
name: area.name,
|
|
6578
6539
|
type: areaDetails.type || "common",
|
|
6579
|
-
checklist: schedTaskSets
|
|
6580
|
-
createdBy: scheduleTask.createdBy
|
|
6540
|
+
checklist: schedTaskSets
|
|
6581
6541
|
};
|
|
6582
6542
|
import_node_server_utils34.logger.info(
|
|
6583
6543
|
`Area ${area.name} (${areaId}): Creating new area checklist with schedule-task sets only`
|
|
@@ -6632,12 +6592,7 @@ function useScheduleTaskController() {
|
|
|
6632
6592
|
deleteScheduleTask: _deleteScheduleTask
|
|
6633
6593
|
} = useScheduleTaskRepository();
|
|
6634
6594
|
async function createScheduleTask(req, res, next) {
|
|
6635
|
-
const
|
|
6636
|
-
(acc, [key, value]) => ({ ...acc, [key]: value }),
|
|
6637
|
-
{}
|
|
6638
|
-
) : {};
|
|
6639
|
-
const createdBy = cookies["user"] || "";
|
|
6640
|
-
const payload = { ...req.body, ...req.params, createdBy };
|
|
6595
|
+
const payload = { ...req.body, ...req.params };
|
|
6641
6596
|
const { error } = scheduleTaskSchema.validate(payload);
|
|
6642
6597
|
if (error) {
|
|
6643
6598
|
import_node_server_utils35.logger.log({ level: "error", message: error.message });
|