@7365admin1/module-hygiene 4.13.0 → 4.15.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/dist/index.mjs CHANGED
@@ -763,13 +763,10 @@ function useAreaRepo() {
763
763
  }
764
764
  async function getAreasForChecklist(site, serviceType) {
765
765
  const query = {
766
- status: { $ne: "deleted" }
766
+ status: { $ne: "deleted" },
767
+ serviceType
767
768
  };
768
- const cacheOptions = {};
769
- if (serviceType) {
770
- query.serviceType = serviceType;
771
- cacheOptions.serviceType = serviceType;
772
- }
769
+ const cacheOptions = { serviceType };
773
770
  try {
774
771
  site = new ObjectId3(site);
775
772
  query.site = site;
@@ -2224,6 +2221,7 @@ function useParentChecklistRepo() {
2224
2221
  async function createIndex() {
2225
2222
  try {
2226
2223
  await collection.createIndexes([
2224
+ { key: { serviceType: 1 } },
2227
2225
  { key: { createdAt: 1 } },
2228
2226
  { key: { site: 1 } },
2229
2227
  { key: { status: 1 } }
@@ -2241,44 +2239,63 @@ function useParentChecklistRepo() {
2241
2239
  startOfDay.setUTCHours(0, 0, 0, 0);
2242
2240
  const endOfDay = new Date(currentDate);
2243
2241
  endOfDay.setUTCHours(23, 59, 59, 999);
2244
- const existingQuery = {
2245
- createdAt: {
2246
- $gte: startOfDay,
2247
- $lte: endOfDay
2248
- }
2249
- };
2242
+ const allServiceTypes = Object.values(ServiceType);
2243
+ const dateStr = currentDate.toISOString().split("T")[0];
2250
2244
  if (value.site) {
2245
+ let siteObjectId;
2251
2246
  try {
2252
- existingQuery.site = new ObjectId7(value.site);
2253
- logger14.info(
2254
- `createParentChecklist: Looking for existing checklist with query: ${JSON.stringify(
2255
- { ...existingQuery, site: value.site }
2256
- )}`
2257
- );
2247
+ siteObjectId = new ObjectId7(value.site);
2258
2248
  } catch (error) {
2259
2249
  throw new BadRequestError12("Invalid site ID format.");
2260
2250
  }
2261
- } else {
2262
- logger14.info(
2263
- `createParentChecklist: Looking for existing checklist with query (no site filter): ${JSON.stringify(
2264
- existingQuery
2265
- )}`
2266
- );
2267
- }
2268
- const existingChecklist = await collection.findOne(existingQuery);
2269
- if (existingChecklist) {
2270
- const dateStr2 = currentDate.toISOString().split("T")[0];
2271
- logger14.info(
2272
- `Parent checklist already exists for ${value.site ? `site ${value.site} on` : ""} today: ${dateStr2}. Found checklist: ${JSON.stringify({
2273
- _id: existingChecklist._id,
2274
- site: existingChecklist.site
2275
- })}`
2251
+ if (value.serviceType) {
2252
+ const existingChecklist = await collection.findOne({
2253
+ createdAt: { $gte: startOfDay, $lte: endOfDay },
2254
+ site: siteObjectId,
2255
+ serviceType: value.serviceType
2256
+ });
2257
+ if (existingChecklist) {
2258
+ logger14.info(
2259
+ `Parent checklist already exists for site ${value.site} / ${value.serviceType} on ${dateStr}. _id: ${existingChecklist._id}`
2260
+ );
2261
+ return existingChecklist._id;
2262
+ }
2263
+ const doc = MParentChecklist({
2264
+ site: value.site,
2265
+ createdAt: currentDate,
2266
+ serviceType: value.serviceType
2267
+ });
2268
+ const result3 = await collection.insertOne(doc, { session });
2269
+ delNamespace().catch((err) => {
2270
+ logger14.error(
2271
+ `Failed to clear cache for namespace: ${namespace_collection}`,
2272
+ err
2273
+ );
2274
+ });
2275
+ logger14.info(
2276
+ `Created parent checklist for site ${value.site} / ${value.serviceType} for today: ${dateStr}`
2277
+ );
2278
+ return result3.insertedId;
2279
+ }
2280
+ const existingServiceTypes = await collection.distinct("serviceType", {
2281
+ createdAt: { $gte: startOfDay, $lte: endOfDay },
2282
+ site: siteObjectId,
2283
+ serviceType: { $exists: true, $ne: null }
2284
+ });
2285
+ const missingServiceTypes = allServiceTypes.filter(
2286
+ (st) => !existingServiceTypes.includes(st)
2276
2287
  );
2277
- return existingChecklist._id;
2278
- }
2279
- const allServiceTypes = Object.values(ServiceType);
2280
- if (value.site) {
2281
- const checklistDocs2 = allServiceTypes.map(
2288
+ if (missingServiceTypes.length === 0) {
2289
+ logger14.info(
2290
+ `All serviceType checklists already exist for site ${value.site} on ${dateStr}`
2291
+ );
2292
+ const first = await collection.findOne({
2293
+ createdAt: { $gte: startOfDay, $lte: endOfDay },
2294
+ site: siteObjectId
2295
+ });
2296
+ return first._id;
2297
+ }
2298
+ const checklistDocs2 = missingServiceTypes.map(
2282
2299
  (serviceType) => MParentChecklist({
2283
2300
  site: value.site,
2284
2301
  createdAt: currentDate,
@@ -2286,17 +2303,14 @@ function useParentChecklistRepo() {
2286
2303
  })
2287
2304
  );
2288
2305
  const result2 = await collection.insertMany(checklistDocs2, { session });
2289
- delNamespace().then(() => {
2290
- logger14.info(`Cache cleared for namespace: ${namespace_collection}`);
2291
- }).catch((err) => {
2306
+ delNamespace().catch((err) => {
2292
2307
  logger14.error(
2293
2308
  `Failed to clear cache for namespace: ${namespace_collection}`,
2294
2309
  err
2295
2310
  );
2296
2311
  });
2297
- const dateStr2 = currentDate.toISOString().split("T")[0];
2298
2312
  logger14.info(
2299
- `Created ${checklistDocs2.length} parent checklists for site ${value.site} for today: ${dateStr2}`
2313
+ `Created ${checklistDocs2.length} parent checklists for site ${value.site} for today: ${dateStr}`
2300
2314
  );
2301
2315
  return Object.values(result2.insertedIds);
2302
2316
  }
@@ -2309,18 +2323,41 @@ function useParentChecklistRepo() {
2309
2323
  logger14.warn("No sites found for creating parent checklist");
2310
2324
  throw new BadRequestError12("No sites available for checklist creation");
2311
2325
  }
2326
+ const existingPairs = await collection.find(
2327
+ {
2328
+ createdAt: { $gte: startOfDay, $lte: endOfDay },
2329
+ serviceType: { $exists: true, $ne: null }
2330
+ },
2331
+ { projection: { site: 1, serviceType: 1 } }
2332
+ ).toArray();
2333
+ const existingSet = new Set(
2334
+ existingPairs.map(
2335
+ (doc) => `${doc.site?.toString()}|${doc.serviceType}`
2336
+ )
2337
+ );
2312
2338
  const checklistDocs = [];
2313
2339
  for (const site of siteIds) {
2314
2340
  for (const serviceType of allServiceTypes) {
2315
- checklistDocs.push(
2316
- MParentChecklist({
2317
- site,
2318
- createdAt: currentDate,
2319
- serviceType
2320
- })
2321
- );
2341
+ if (!existingSet.has(`${site}|${serviceType}`)) {
2342
+ checklistDocs.push(
2343
+ MParentChecklist({
2344
+ site,
2345
+ createdAt: currentDate,
2346
+ serviceType
2347
+ })
2348
+ );
2349
+ }
2322
2350
  }
2323
2351
  }
2352
+ if (checklistDocs.length === 0) {
2353
+ logger14.info(
2354
+ `All site+serviceType checklists already exist for today: ${dateStr}`
2355
+ );
2356
+ return [];
2357
+ }
2358
+ logger14.info(
2359
+ `createParentChecklist: Creating ${checklistDocs.length} missing site+serviceType checklist(s) for today: ${dateStr}`
2360
+ );
2324
2361
  const result = await collection.insertMany(checklistDocs, { session });
2325
2362
  delNamespace().then(() => {
2326
2363
  logger14.info(`Cache cleared for namespace: ${namespace_collection}`);
@@ -2330,7 +2367,6 @@ function useParentChecklistRepo() {
2330
2367
  err
2331
2368
  );
2332
2369
  });
2333
- const dateStr = currentDate.toISOString().split("T")[0];
2334
2370
  logger14.info(
2335
2371
  `Created ${Object.keys(result.insertedIds).length} parent checklists for today: ${dateStr}`
2336
2372
  );
@@ -2438,6 +2474,23 @@ function useParentChecklistRepo() {
2438
2474
  throw error;
2439
2475
  }
2440
2476
  }
2477
+ async function getParentChecklistById(_id) {
2478
+ try {
2479
+ _id = new ObjectId7(_id);
2480
+ } catch (error) {
2481
+ throw new BadRequestError12("Invalid parent checklist ID format.");
2482
+ }
2483
+ try {
2484
+ const data = await collection.findOne({ _id });
2485
+ if (!data) {
2486
+ throw new BadRequestError12("Parent checklist not found.");
2487
+ }
2488
+ return data;
2489
+ } catch (error) {
2490
+ logger14.error("Failed to get parent checklist by ID", error);
2491
+ throw error;
2492
+ }
2493
+ }
2441
2494
  async function updateParentChecklistStatuses(_id, status, session) {
2442
2495
  try {
2443
2496
  _id = new ObjectId7(_id);
@@ -2552,13 +2605,38 @@ function useParentChecklistRepo() {
2552
2605
  throw error;
2553
2606
  }
2554
2607
  }
2608
+ async function getTodayParentChecklistsForAreaGen() {
2609
+ const now = /* @__PURE__ */ new Date();
2610
+ const start = new Date(now);
2611
+ start.setUTCHours(0, 0, 0, 0);
2612
+ const end = new Date(now);
2613
+ end.setUTCHours(23, 59, 59, 999);
2614
+ try {
2615
+ const items = await collection.find(
2616
+ {
2617
+ createdAt: { $gte: start, $lte: end },
2618
+ serviceType: { $exists: true, $ne: null }
2619
+ },
2620
+ { projection: { _id: 1, site: 1, serviceType: 1 } }
2621
+ ).toArray();
2622
+ return items;
2623
+ } catch (error) {
2624
+ logger14.error(
2625
+ "Failed to get today's parent checklists for area generation",
2626
+ error
2627
+ );
2628
+ throw error;
2629
+ }
2630
+ }
2555
2631
  return {
2556
2632
  createIndex,
2557
2633
  createParentChecklist,
2558
2634
  getAllParentChecklist,
2635
+ getParentChecklistById,
2559
2636
  updateParentChecklistStatuses,
2560
2637
  closeExpiredParentChecklists,
2561
- getTodayParentChecklists
2638
+ getTodayParentChecklists,
2639
+ getTodayParentChecklistsForAreaGen
2562
2640
  };
2563
2641
  }
2564
2642
 
@@ -2646,6 +2724,7 @@ import { BadRequestError as BadRequestError14, logger as logger16 } from "@7365a
2646
2724
  var allowedChecklistStatus = ["open", "completed", "closed"];
2647
2725
  var areaChecklistSchema = Joi8.object({
2648
2726
  schedule: Joi8.string().hex().required(),
2727
+ serviceType: Joi8.string().valid(...Object.values(ServiceType)).optional(),
2649
2728
  area: Joi8.string().hex().required(),
2650
2729
  name: Joi8.string().required(),
2651
2730
  type: Joi8.string().valid(...allowedTypes).required(),
@@ -2712,6 +2791,7 @@ function MAreaChecklist(value) {
2712
2791
  }
2713
2792
  return {
2714
2793
  schedule: value.schedule,
2794
+ serviceType: value.serviceType,
2715
2795
  area: value.area,
2716
2796
  name: value.name,
2717
2797
  type: value.type,
@@ -2833,7 +2913,8 @@ function useAreaChecklistRepo() {
2833
2913
  search = "",
2834
2914
  type = "all",
2835
2915
  status = "all",
2836
- schedule
2916
+ schedule,
2917
+ serviceType
2837
2918
  }, session) {
2838
2919
  page = page > 0 ? page - 1 : 0;
2839
2920
  const query = {};
@@ -2847,6 +2928,10 @@ function useAreaChecklistRepo() {
2847
2928
  } catch (error) {
2848
2929
  throw new BadRequestError15("Invalid parent checklist ID format.");
2849
2930
  }
2931
+ if (serviceType) {
2932
+ query.serviceType = serviceType;
2933
+ cacheOptions.serviceType = serviceType;
2934
+ }
2850
2935
  if (type && type !== "all") {
2851
2936
  query.type = type;
2852
2937
  cacheOptions.type = type;
@@ -3242,6 +3327,7 @@ function useAreaChecklistRepo() {
3242
3327
  page = 1,
3243
3328
  limit = 10,
3244
3329
  search = "",
3330
+ serviceType,
3245
3331
  _id
3246
3332
  }, session) {
3247
3333
  page = page > 0 ? page - 1 : 0;
@@ -3256,6 +3342,10 @@ function useAreaChecklistRepo() {
3256
3342
  } catch (error) {
3257
3343
  throw new BadRequestError15("Invalid area checklist ID format.");
3258
3344
  }
3345
+ if (serviceType) {
3346
+ query.serviceType = serviceType;
3347
+ cacheOptions.serviceType = serviceType;
3348
+ }
3259
3349
  if (search) {
3260
3350
  query.$text = { $search: search };
3261
3351
  cacheOptions.search = search;
@@ -3479,7 +3569,12 @@ function useAreaChecklistRepo() {
3479
3569
  throw error;
3480
3570
  }
3481
3571
  }
3482
- async function getAreaChecklistByAreaAndSchedule(schedule, area, session) {
3572
+ async function getAreaChecklistByAreaAndSchedule({
3573
+ schedule,
3574
+ serviceType,
3575
+ area,
3576
+ session
3577
+ }) {
3483
3578
  try {
3484
3579
  schedule = new ObjectId9(schedule);
3485
3580
  area = new ObjectId9(area);
@@ -3487,7 +3582,10 @@ function useAreaChecklistRepo() {
3487
3582
  throw new BadRequestError15("Invalid area checklist ID format.");
3488
3583
  }
3489
3584
  try {
3490
- const data = await collection.findOne({ schedule, area }, { session });
3585
+ const data = await collection.findOne(
3586
+ { schedule, serviceType, area },
3587
+ { session }
3588
+ );
3491
3589
  if (!data) {
3492
3590
  throw new BadRequestError15("Area checklist not found.");
3493
3591
  }
@@ -3696,7 +3794,7 @@ function useAreaChecklistRepo() {
3696
3794
  throw error;
3697
3795
  }
3698
3796
  }
3699
- async function pushScheduleTaskSets(scheduleId, areaId, scheduleTaskId, newSets) {
3797
+ async function pushScheduleTaskSets(scheduleId, serviceType, areaId, scheduleTaskId, newSets) {
3700
3798
  try {
3701
3799
  const schedule = new ObjectId9(scheduleId);
3702
3800
  const area = new ObjectId9(areaId);
@@ -3704,6 +3802,7 @@ function useAreaChecklistRepo() {
3704
3802
  const result = await collection.updateOne(
3705
3803
  {
3706
3804
  schedule,
3805
+ serviceType,
3707
3806
  area,
3708
3807
  checklist: { $not: { $elemMatch: { scheduleTaskId: taskId } } }
3709
3808
  },
@@ -3726,13 +3825,14 @@ function useAreaChecklistRepo() {
3726
3825
  throw error;
3727
3826
  }
3728
3827
  }
3729
- async function insertAutoGenSets(scheduleId, areaId, newSets) {
3828
+ async function insertAutoGenSets(scheduleId, serviceType, areaId, newSets) {
3730
3829
  try {
3731
3830
  const schedule = new ObjectId9(scheduleId);
3732
3831
  const area = new ObjectId9(areaId);
3733
3832
  const result = await collection.updateOne(
3734
3833
  {
3735
3834
  schedule,
3835
+ serviceType,
3736
3836
  area,
3737
3837
  checklist: {
3738
3838
  $not: { $elemMatch: { isScheduleTask: { $ne: true } } }
@@ -3878,14 +3978,25 @@ function useAreaChecklistService() {
3878
3978
  updateAreaChecklistStatus,
3879
3979
  insertAutoGenSets
3880
3980
  } = useAreaChecklistRepo();
3881
- const { updateParentChecklistStatuses } = useParentChecklistRepo();
3981
+ const { updateParentChecklistStatuses, getParentChecklistById } = useParentChecklistRepo();
3882
3982
  const { getUserById } = useUserRepo();
3883
3983
  async function createAreaChecklist(value) {
3884
3984
  const results = [];
3885
3985
  let totalChecklistsCreated = 0;
3886
3986
  try {
3887
3987
  const BATCH_SIZE = 10;
3888
- const areasResult = await getAreasForChecklist(value.site);
3988
+ const schedule = await getParentChecklistById(value.schedule.toString());
3989
+ const serviceType = schedule.serviceType;
3990
+ if (!serviceType) {
3991
+ logger18.warn(
3992
+ `createAreaChecklist: Parent checklist ${value.schedule} has no serviceType, skipping area checklist generation`
3993
+ );
3994
+ return results;
3995
+ }
3996
+ const areasResult = await getAreasForChecklist(
3997
+ value.site,
3998
+ serviceType
3999
+ );
3889
4000
  const areas = areasResult || [];
3890
4001
  if (areas.length > 0) {
3891
4002
  for (let i = 0; i < areas.length; i += BATCH_SIZE) {
@@ -3899,10 +4010,11 @@ function useAreaChecklistService() {
3899
4010
  }
3900
4011
  let existing = null;
3901
4012
  try {
3902
- existing = await getAreaChecklistByAreaAndSchedule(
3903
- value.schedule.toString(),
3904
- area._id.toString()
3905
- );
4013
+ existing = await getAreaChecklistByAreaAndSchedule({
4014
+ schedule: value.schedule.toString(),
4015
+ serviceType,
4016
+ area: area._id.toString()
4017
+ });
3906
4018
  } catch (_) {
3907
4019
  }
3908
4020
  if (existing) {
@@ -3950,6 +4062,7 @@ function useAreaChecklistService() {
3950
4062
  );
3951
4063
  await insertAutoGenSets(
3952
4064
  value.schedule.toString(),
4065
+ serviceType,
3953
4066
  area._id.toString(),
3954
4067
  autoGenSets
3955
4068
  );
@@ -3958,6 +4071,7 @@ function useAreaChecklistService() {
3958
4071
  const setCount = Number(area.set) || 1;
3959
4072
  const checklistData = {
3960
4073
  schedule: value.schedule,
4074
+ serviceType,
3961
4075
  area: area._id.toString(),
3962
4076
  name: area.name,
3963
4077
  type: area.type,
@@ -4088,7 +4202,11 @@ function useAreaChecklistService() {
4088
4202
 
4089
4203
  // src/controllers/hygiene-area-checklist.controller.ts
4090
4204
  import Joi9 from "joi";
4091
- import { BadRequestError as BadRequestError16, InternalServerError as InternalServerError7, logger as logger20 } from "@7365admin1/node-server-utils";
4205
+ import {
4206
+ BadRequestError as BadRequestError16,
4207
+ InternalServerError as InternalServerError7,
4208
+ logger as logger20
4209
+ } from "@7365admin1/node-server-utils";
4092
4210
 
4093
4211
  // src/services/hygiene-checklist-pdf.service.ts
4094
4212
  import { launch } from "puppeteer";
@@ -4357,7 +4475,8 @@ function useAreaChecklistController() {
4357
4475
  search: Joi9.string().optional().allow("", null),
4358
4476
  type: Joi9.string().valid(...allowedTypes, "all").optional().allow("", null),
4359
4477
  status: Joi9.string().valid(...allowedStatus, "all").optional().allow("", null),
4360
- schedule: Joi9.string().hex().required()
4478
+ schedule: Joi9.string().hex().required(),
4479
+ serviceType: Joi9.string().valid(...Object.values(ServiceType)).required()
4361
4480
  });
4362
4481
  const { error } = validation.validate(query);
4363
4482
  if (error) {
@@ -4371,6 +4490,7 @@ function useAreaChecklistController() {
4371
4490
  const type = req.query.type ?? "all";
4372
4491
  const status = req.query.status ?? "all";
4373
4492
  const schedule = req.params.schedule ?? "";
4493
+ const serviceType = req.query.serviceType ?? "";
4374
4494
  try {
4375
4495
  const data = await _getAllAreaChecklist({
4376
4496
  page,
@@ -4378,7 +4498,8 @@ function useAreaChecklistController() {
4378
4498
  search,
4379
4499
  type,
4380
4500
  status,
4381
- schedule
4501
+ schedule,
4502
+ serviceType
4382
4503
  });
4383
4504
  res.json(data);
4384
4505
  return;
@@ -4455,6 +4576,7 @@ function useAreaChecklistController() {
4455
4576
  page: Joi9.number().min(1).optional().allow("", null),
4456
4577
  limit: Joi9.number().min(1).optional().allow("", null),
4457
4578
  search: Joi9.string().optional().allow("", null),
4579
+ serviceType: Joi9.string().valid(...Object.values(ServiceType)).required(),
4458
4580
  id: Joi9.string().hex().required()
4459
4581
  });
4460
4582
  const { error } = validation.validate(query);
@@ -4466,12 +4588,14 @@ function useAreaChecklistController() {
4466
4588
  const page = parseInt(req.query.page) ?? 1;
4467
4589
  const limit = parseInt(req.query.limit) ?? 10;
4468
4590
  const search = req.query.search ?? "";
4591
+ const serviceType = req.query.serviceType ?? "";
4469
4592
  const _id = req.params.id ?? "";
4470
4593
  try {
4471
4594
  const data = await _getAreaChecklistUnits({
4472
4595
  page,
4473
4596
  limit,
4474
4597
  search,
4598
+ serviceType,
4475
4599
  _id
4476
4600
  });
4477
4601
  res.json(data);
@@ -4543,12 +4667,15 @@ function useAreaChecklistController() {
4543
4667
  try {
4544
4668
  const pdfBuffer = await _generateChecklistPdf(value);
4545
4669
  if (!pdfBuffer || pdfBuffer.length === 0) {
4546
- throw new InternalServerError7("Generated checklist PDF is empty or invalid.");
4670
+ throw new InternalServerError7(
4671
+ "Generated checklist PDF is empty or invalid."
4672
+ );
4547
4673
  }
4548
4674
  const date = /* @__PURE__ */ new Date();
4549
- const formattedDate = `${String(date.getDate()).padStart(2, "0")}_${String(
4550
- date.getMonth() + 1
4551
- ).padStart(2, "0")}_${date.getFullYear()}`;
4675
+ const formattedDate = `${String(date.getDate()).padStart(
4676
+ 2,
4677
+ "0"
4678
+ )}_${String(date.getMonth() + 1).padStart(2, "0")}_${date.getFullYear()}`;
4552
4679
  res.setHeader("Content-Type", "application/pdf");
4553
4680
  res.setHeader(
4554
4681
  "Content-Disposition",
@@ -4580,6 +4707,7 @@ import { ObjectId as ObjectId12 } from "mongodb";
4580
4707
  import { BadRequestError as BadRequestError17, logger as logger21 } from "@7365admin1/node-server-utils";
4581
4708
  var supplySchema = Joi10.object({
4582
4709
  site: Joi10.string().hex().required(),
4710
+ serviceType: Joi10.string().valid(...Object.values(ServiceType)).required(),
4583
4711
  name: Joi10.string().required(),
4584
4712
  unitOfMeasurement: Joi10.string().required()
4585
4713
  });
@@ -4598,6 +4726,7 @@ function MSupply(value) {
4598
4726
  }
4599
4727
  return {
4600
4728
  site: value.site,
4729
+ serviceType: value.serviceType,
4601
4730
  name: value.name,
4602
4731
  unitOfMeasurement: value.unitOfMeasurement,
4603
4732
  qty: 0,
@@ -4630,7 +4759,10 @@ function useSupplyRepository() {
4630
4759
  const { delNamespace, setCache, getCache } = useCache6(namespace_collection);
4631
4760
  async function createIndex() {
4632
4761
  try {
4633
- await collection.createIndexes([{ key: { site: 1 } }]);
4762
+ await collection.createIndexes([
4763
+ { key: { site: 1 } },
4764
+ { key: { serviceType: 1 } }
4765
+ ]);
4634
4766
  } catch (error) {
4635
4767
  throw new InternalServerError8(
4636
4768
  "Failed to create index on hygiene supply."
@@ -4683,15 +4815,18 @@ function useSupplyRepository() {
4683
4815
  page = 1,
4684
4816
  limit = 10,
4685
4817
  search = "",
4686
- site
4818
+ site,
4819
+ serviceType
4687
4820
  }) {
4688
4821
  page = page > 0 ? page - 1 : 0;
4689
4822
  const query = {
4690
- status: { $ne: "deleted" }
4823
+ status: { $ne: "deleted" },
4824
+ serviceType
4691
4825
  };
4692
4826
  const cacheOptions = {
4693
4827
  page,
4694
- limit
4828
+ limit,
4829
+ serviceType
4695
4830
  };
4696
4831
  try {
4697
4832
  site = new ObjectId13(site);
@@ -4895,7 +5030,8 @@ function useSupplyController() {
4895
5030
  page: Joi11.number().min(1).optional().allow("", null),
4896
5031
  limit: Joi11.number().min(1).optional().allow("", null),
4897
5032
  search: Joi11.string().optional().allow("", null),
4898
- site: Joi11.string().hex().required()
5033
+ site: Joi11.string().hex().required(),
5034
+ serviceType: Joi11.string().valid(...Object.values(ServiceType)).required()
4899
5035
  });
4900
5036
  const { error } = validation.validate(query);
4901
5037
  if (error) {
@@ -4907,12 +5043,14 @@ function useSupplyController() {
4907
5043
  const limit = parseInt(req.query.limit) ?? 10;
4908
5044
  const search = req.query.search ?? "";
4909
5045
  const site = req.params.site ?? "";
5046
+ const serviceType = req.query.serviceType ?? "";
4910
5047
  try {
4911
5048
  const data = await _getSupplies({
4912
5049
  page,
4913
5050
  limit,
4914
5051
  search,
4915
- site
5052
+ site,
5053
+ serviceType
4916
5054
  });
4917
5055
  res.json(data);
4918
5056
  return;
@@ -4968,10 +5106,8 @@ function useSupplyController() {
4968
5106
  }
4969
5107
  async function deleteSupply(req, res, next) {
4970
5108
  const id = req.params.id;
4971
- const validation = Joi11.object({
4972
- id: Joi11.string().hex().required()
4973
- });
4974
- const { error, value } = validation.validate({ id });
5109
+ const validation = Joi11.string().hex().required();
5110
+ const { error, value } = validation.validate(id);
4975
5111
  if (error) {
4976
5112
  logger23.log({ level: "error", message: error.message });
4977
5113
  next(new BadRequestError19(error.message));
@@ -5002,6 +5138,7 @@ import { ObjectId as ObjectId14 } from "mongodb";
5002
5138
  import { BadRequestError as BadRequestError20, logger as logger24 } from "@7365admin1/node-server-utils";
5003
5139
  var stockSchema = Joi12.object({
5004
5140
  site: Joi12.string().hex().required(),
5141
+ serviceType: Joi12.string().valid(...Object.values(ServiceType)).required(),
5005
5142
  supply: Joi12.string().hex().required(),
5006
5143
  in: Joi12.number().min(0).optional(),
5007
5144
  out: Joi12.number().min(0).optional(),
@@ -5030,6 +5167,7 @@ function MStock(value) {
5030
5167
  }
5031
5168
  return {
5032
5169
  site: value.site,
5170
+ serviceType: value.serviceType,
5033
5171
  supply: value.supply,
5034
5172
  in: value.in ?? 0,
5035
5173
  out: value.out ?? 0,
@@ -5067,6 +5205,7 @@ function useStockRepository() {
5067
5205
  try {
5068
5206
  await collection.createIndexes([
5069
5207
  { key: { site: 1 } },
5208
+ { key: { serviceType: 1 } },
5070
5209
  { key: { supply: 1 } },
5071
5210
  { key: { balance: 1 } },
5072
5211
  { key: { status: 1 } }
@@ -5105,15 +5244,18 @@ function useStockRepository() {
5105
5244
  limit = 10,
5106
5245
  search = "",
5107
5246
  site,
5247
+ serviceType,
5108
5248
  supply
5109
5249
  }) {
5110
5250
  page = page > 0 ? page - 1 : 0;
5111
5251
  const query = {
5112
- status: { $ne: "deleted" }
5252
+ status: { $ne: "deleted" },
5253
+ serviceType
5113
5254
  };
5114
5255
  const cacheOptions = {
5115
5256
  page,
5116
- limit
5257
+ limit,
5258
+ serviceType
5117
5259
  };
5118
5260
  try {
5119
5261
  site = new ObjectId15(site);
@@ -5237,6 +5379,7 @@ function useStockController() {
5237
5379
  const payload = { ...req.body, ...req.params };
5238
5380
  const validation = Joi13.object({
5239
5381
  site: Joi13.string().hex().required(),
5382
+ serviceType: Joi13.string().valid(...Object.values(ServiceType)).required(),
5240
5383
  supply: Joi13.string().hex().required(),
5241
5384
  qty: Joi13.number().min(0).required(),
5242
5385
  remarks: Joi13.string().optional().allow("", null)
@@ -5264,6 +5407,7 @@ function useStockController() {
5264
5407
  limit: Joi13.number().min(1).optional().allow("", null),
5265
5408
  search: Joi13.string().optional().allow("", null),
5266
5409
  site: Joi13.string().hex().required(),
5410
+ serviceType: Joi13.string().valid(...Object.values(ServiceType)).required(),
5267
5411
  supply: Joi13.string().hex().required()
5268
5412
  });
5269
5413
  const { error } = validation.validate(query);
@@ -5276,6 +5420,7 @@ function useStockController() {
5276
5420
  const limit = parseInt(req.query.limit) ?? 10;
5277
5421
  const search = req.query.search ?? "";
5278
5422
  const site = req.params.site ?? "";
5423
+ const serviceType = req.query.serviceType ?? "";
5279
5424
  const supply = req.params.supply ?? "";
5280
5425
  try {
5281
5426
  const data = await _getStocksBySupplyId({
@@ -5283,6 +5428,7 @@ function useStockController() {
5283
5428
  limit,
5284
5429
  search,
5285
5430
  site,
5431
+ serviceType,
5286
5432
  supply
5287
5433
  });
5288
5434
  res.json(data);
@@ -5306,6 +5452,7 @@ import { BadRequestError as BadRequestError24, logger as logger27 } from "@7365a
5306
5452
  var allowedCheckOutItemStatus = ["pending", "completed"];
5307
5453
  var checkOutItemSchema = Joi14.object({
5308
5454
  site: Joi14.string().hex().required(),
5455
+ serviceType: Joi14.string().valid(...Object.values(ServiceType)).required(),
5309
5456
  supply: Joi14.string().hex().required(),
5310
5457
  supplyName: Joi14.string().required(),
5311
5458
  qty: Joi14.number().min(0).required(),
@@ -5335,6 +5482,7 @@ function MCheckOutItem(value) {
5335
5482
  }
5336
5483
  return {
5337
5484
  site: value.site,
5485
+ serviceType: value.serviceType,
5338
5486
  supply: value.supply,
5339
5487
  supplyName: value.supplyName,
5340
5488
  qty: value.qty,
@@ -5372,6 +5520,7 @@ function useCheckOutItemRepository() {
5372
5520
  try {
5373
5521
  await collection.createIndexes([
5374
5522
  { key: { site: 1 } },
5523
+ { key: { serviceType: 1 } },
5375
5524
  { key: { supply: 1 } },
5376
5525
  { key: { status: 1 } }
5377
5526
  ]);
@@ -5411,15 +5560,18 @@ function useCheckOutItemRepository() {
5411
5560
  page = 1,
5412
5561
  limit = 10,
5413
5562
  search = "",
5414
- site
5563
+ site,
5564
+ serviceType
5415
5565
  }) {
5416
5566
  page = page > 0 ? page - 1 : 0;
5417
5567
  const query = {
5418
- status: { $ne: "deleted" }
5568
+ status: { $ne: "deleted" },
5569
+ serviceType
5419
5570
  };
5420
5571
  const cacheOptions = {
5421
5572
  page,
5422
- limit
5573
+ limit,
5574
+ serviceType
5423
5575
  };
5424
5576
  try {
5425
5577
  site = new ObjectId17(site);
@@ -5533,6 +5685,7 @@ function useCheckOutItemRepository() {
5533
5685
  {
5534
5686
  $project: {
5535
5687
  site: 1,
5688
+ serviceType: 1,
5536
5689
  supply: 1,
5537
5690
  supplyName: 1,
5538
5691
  qty: 1,
@@ -5635,6 +5788,7 @@ function useCheckOutItemService() {
5635
5788
  const createdStocks = await createStock(
5636
5789
  {
5637
5790
  site: checkOutItem.site.toString(),
5791
+ serviceType: checkOutItem.serviceType,
5638
5792
  supply: checkOutItem.supply.toString(),
5639
5793
  qty: checkOutItem.qty
5640
5794
  },
@@ -5655,7 +5809,7 @@ function useCheckOutItemService() {
5655
5809
  const session = useAtlas13.getClient()?.startSession();
5656
5810
  try {
5657
5811
  session?.startTransaction();
5658
- const { site, createdBy, items } = value;
5812
+ const { site, serviceType, createdBy, items } = value;
5659
5813
  const createdByData = await getUserById(createdBy);
5660
5814
  const createdCheckOutItemIds = [];
5661
5815
  for (const item of items) {
@@ -5663,6 +5817,7 @@ function useCheckOutItemService() {
5663
5817
  const createdId = await _createCheckOutItem(
5664
5818
  {
5665
5819
  site,
5820
+ serviceType,
5666
5821
  supply: item.supply,
5667
5822
  supplyName: supplyData?.name || "",
5668
5823
  qty: item.qty,
@@ -5675,6 +5830,7 @@ function useCheckOutItemService() {
5675
5830
  await createStock(
5676
5831
  {
5677
5832
  site,
5833
+ serviceType,
5678
5834
  supply: item.supply,
5679
5835
  qty: item.qty
5680
5836
  },
@@ -5723,6 +5879,7 @@ function useCheckOutItemController() {
5723
5879
  };
5724
5880
  const validation = Joi15.object({
5725
5881
  site: Joi15.string().hex().required(),
5882
+ serviceType: Joi15.string().valid(...Object.values(ServiceType)).required(),
5726
5883
  supply: Joi15.string().hex().required(),
5727
5884
  qty: Joi15.number().min(0).required(),
5728
5885
  attachment: Joi15.array().items(Joi15.string()).optional().allow(null),
@@ -5757,6 +5914,7 @@ function useCheckOutItemController() {
5757
5914
  };
5758
5915
  const validation = Joi15.object({
5759
5916
  site: Joi15.string().hex().required(),
5917
+ serviceType: Joi15.string().valid(...Object.values(ServiceType)).required(),
5760
5918
  createdBy: Joi15.string().hex().required(),
5761
5919
  items: Joi15.array().items(
5762
5920
  Joi15.object({
@@ -5788,7 +5946,8 @@ function useCheckOutItemController() {
5788
5946
  page: Joi15.number().min(1).optional().allow("", null),
5789
5947
  limit: Joi15.number().min(1).optional().allow("", null),
5790
5948
  search: Joi15.string().optional().allow("", null),
5791
- site: Joi15.string().hex().required()
5949
+ site: Joi15.string().hex().required(),
5950
+ serviceType: Joi15.string().valid(...Object.values(ServiceType)).required()
5792
5951
  });
5793
5952
  const { error } = validation.validate(query);
5794
5953
  if (error) {
@@ -5800,12 +5959,14 @@ function useCheckOutItemController() {
5800
5959
  const limit = parseInt(req.query.limit) ?? 10;
5801
5960
  const search = req.query.search ?? "";
5802
5961
  const site = req.params.site ?? "";
5962
+ const serviceType = req.query.serviceType ?? "";
5803
5963
  try {
5804
5964
  const data = await _getCheckOutItems({
5805
5965
  page,
5806
5966
  limit,
5807
5967
  search,
5808
- site
5968
+ site,
5969
+ serviceType
5809
5970
  });
5810
5971
  res.json(data);
5811
5972
  return;
@@ -5848,6 +6009,7 @@ import Joi16 from "joi";
5848
6009
  import { ObjectId as ObjectId18 } from "mongodb";
5849
6010
  var scheduleTaskSchema = Joi16.object({
5850
6011
  site: Joi16.string().hex().required(),
6012
+ serviceType: Joi16.string().valid(...Object.values(ServiceType)).required(),
5851
6013
  title: Joi16.string().required(),
5852
6014
  time: Joi16.string().pattern(/^([0-1]\d|2[0-3]):([0-5]\d)$/).required(),
5853
6015
  dates: Joi16.array().min(1).items(
@@ -5896,6 +6058,7 @@ function MScheduleTask(value) {
5896
6058
  }
5897
6059
  return {
5898
6060
  site: value.site,
6061
+ serviceType: value.serviceType,
5899
6062
  title: value.title,
5900
6063
  time: value.time,
5901
6064
  dates: value.dates,
@@ -5933,6 +6096,7 @@ function useScheduleTaskRepository() {
5933
6096
  try {
5934
6097
  await collection.createIndexes([
5935
6098
  { key: { site: 1 } },
6099
+ { key: { serviceType: 1 } },
5936
6100
  { key: { status: 1 } }
5937
6101
  ]);
5938
6102
  } catch (error) {
@@ -5971,15 +6135,18 @@ function useScheduleTaskRepository() {
5971
6135
  page = 1,
5972
6136
  limit = 10,
5973
6137
  search = "",
5974
- site
6138
+ site,
6139
+ serviceType
5975
6140
  }) {
5976
6141
  page = page > 0 ? page - 1 : 0;
5977
6142
  const query = {
5978
- status: { $ne: "deleted" }
6143
+ status: { $ne: "deleted" },
6144
+ serviceType
5979
6145
  };
5980
6146
  const cacheOptions = {
5981
6147
  page,
5982
- limit
6148
+ limit,
6149
+ serviceType
5983
6150
  };
5984
6151
  try {
5985
6152
  site = new ObjectId19(site);
@@ -5989,7 +6156,7 @@ function useScheduleTaskRepository() {
5989
6156
  throw new BadRequestError29("Invalid site ID format.");
5990
6157
  }
5991
6158
  if (search) {
5992
- query.$or = [{ name: { $regex: search, $options: "i" } }];
6159
+ query.$or = [{ title: { $regex: search, $options: "i" } }];
5993
6160
  cacheOptions.search = search;
5994
6161
  }
5995
6162
  const cacheKey = makeCacheKey9(namespace_collection, cacheOptions);
@@ -6035,62 +6202,6 @@ function useScheduleTaskRepository() {
6035
6202
  throw error;
6036
6203
  }
6037
6204
  }
6038
- async function getTasksForScheduleTask({
6039
- page = 1,
6040
- limit = 10,
6041
- search = "",
6042
- site
6043
- }) {
6044
- page = page > 0 ? page - 1 : 0;
6045
- const query = {
6046
- status: { $ne: "deleted" }
6047
- };
6048
- const cacheOptions = {
6049
- page,
6050
- limit
6051
- };
6052
- try {
6053
- site = new ObjectId19(site);
6054
- query.site = site;
6055
- cacheOptions.site = site.toString();
6056
- } catch (error) {
6057
- throw new BadRequestError29("Invalid site ID format.");
6058
- }
6059
- if (search) {
6060
- query.$or = [{ name: { $regex: search, $options: "i" } }];
6061
- cacheOptions.search = search;
6062
- }
6063
- const cacheKey = makeCacheKey9(namespace_collection, cacheOptions);
6064
- const cachedData = await getCache(cacheKey);
6065
- if (cachedData) {
6066
- logger31.info(`Cache hit for key: ${cacheKey}`);
6067
- return cachedData;
6068
- }
6069
- try {
6070
- const items = await collection.aggregate([
6071
- { $match: query },
6072
- {
6073
- $project: {
6074
- createdAt: 1,
6075
- title: 1
6076
- }
6077
- },
6078
- { $sort: { _id: -1 } },
6079
- { $skip: page * limit },
6080
- { $limit: limit }
6081
- ]).toArray();
6082
- const length = await collection.countDocuments(query);
6083
- const data = paginate8(items, page, limit, length);
6084
- setCache(cacheKey, data, 15 * 60).then(() => {
6085
- logger31.info(`Cache set for key: ${cacheKey}`);
6086
- }).catch((err) => {
6087
- logger31.error(`Failed to set cache for key: ${cacheKey}`, err);
6088
- });
6089
- return data;
6090
- } catch (error) {
6091
- throw error;
6092
- }
6093
- }
6094
6205
  async function getScheduleTaskById(_id, session) {
6095
6206
  try {
6096
6207
  _id = new ObjectId19(_id);
@@ -6184,15 +6295,48 @@ function useScheduleTaskRepository() {
6184
6295
  throw error;
6185
6296
  }
6186
6297
  }
6298
+ async function deleteScheduleTask(_id, session) {
6299
+ try {
6300
+ _id = new ObjectId19(_id);
6301
+ } catch (error) {
6302
+ throw new BadRequestError29("Invalid schedule task ID format.");
6303
+ }
6304
+ try {
6305
+ const updateValue = {
6306
+ status: "deleted",
6307
+ updatedAt: /* @__PURE__ */ new Date(),
6308
+ deletedAt: /* @__PURE__ */ new Date()
6309
+ };
6310
+ const res = await collection.updateOne(
6311
+ { _id },
6312
+ { $set: updateValue },
6313
+ { session }
6314
+ );
6315
+ if (res.modifiedCount === 0) {
6316
+ throw new InternalServerError11("Unable to delete schedule task.");
6317
+ }
6318
+ delNamespace().then(() => {
6319
+ logger31.info(`Cache cleared for namespace: ${namespace_collection}`);
6320
+ }).catch((err) => {
6321
+ logger31.error(
6322
+ `Failed to clear cache for namespace: ${namespace_collection}`,
6323
+ err
6324
+ );
6325
+ });
6326
+ return res.modifiedCount;
6327
+ } catch (error) {
6328
+ throw error;
6329
+ }
6330
+ }
6187
6331
  return {
6188
6332
  createIndex,
6189
6333
  createTextIndex,
6190
6334
  createScheduleTask,
6191
6335
  getScheduleTasks,
6192
6336
  getAllScheduleTask,
6193
- getTasksForScheduleTask,
6194
6337
  getScheduleTaskById,
6195
- updateScheduleTask
6338
+ updateScheduleTask,
6339
+ deleteScheduleTask
6196
6340
  };
6197
6341
  }
6198
6342
 
@@ -6208,7 +6352,7 @@ function useScheduleTaskService() {
6208
6352
  pushScheduleTaskSets
6209
6353
  } = useAreaChecklistRepo();
6210
6354
  const { getAreaById } = useAreaRepo();
6211
- function checkScheduleConditions(schedule, currentDate = /* @__PURE__ */ new Date()) {
6355
+ function checkScheduleConditions(schedule, serviceType, currentDate = /* @__PURE__ */ new Date()) {
6212
6356
  try {
6213
6357
  const now = currentDate;
6214
6358
  const timeString = now.toLocaleTimeString("en-US", {
@@ -6299,12 +6443,17 @@ function useScheduleTaskService() {
6299
6443
  const validatedTasks = [];
6300
6444
  for (const scheduleTask of scheduleTasks) {
6301
6445
  try {
6446
+ const serviceType = scheduleTask.serviceType;
6302
6447
  logger32.info(
6303
6448
  `Checking schedule ${scheduleTask._id} - ${scheduleTask.title}: time=${scheduleTask.time}, dates=${JSON.stringify(
6304
6449
  scheduleTask.dates
6305
6450
  )}`
6306
6451
  );
6307
- const shouldRun = checkScheduleConditions(scheduleTask, currentDate);
6452
+ const shouldRun = checkScheduleConditions(
6453
+ scheduleTask,
6454
+ serviceType,
6455
+ currentDate
6456
+ );
6308
6457
  if (!shouldRun) {
6309
6458
  logger32.info(
6310
6459
  `Schedule ${scheduleTask._id} conditions not met, skipping`
@@ -6327,6 +6476,7 @@ function useScheduleTaskService() {
6327
6476
  );
6328
6477
  const parentChecklistIds = await createParentChecklist({
6329
6478
  site: scheduleTask.site.toString(),
6479
+ serviceType,
6330
6480
  createdAt: /* @__PURE__ */ new Date()
6331
6481
  });
6332
6482
  const parentChecklistId = Array.isArray(parentChecklistIds) ? parentChecklistIds[0] : parentChecklistIds;
@@ -6364,8 +6514,11 @@ function useScheduleTaskService() {
6364
6514
  let existingAreaChecklist;
6365
6515
  try {
6366
6516
  existingAreaChecklist = await getAreaChecklistByAreaAndSchedule(
6367
- parentChecklistId.toString(),
6368
- areaId
6517
+ {
6518
+ schedule: parentChecklistId.toString(),
6519
+ serviceType,
6520
+ area: areaId
6521
+ }
6369
6522
  );
6370
6523
  logger32.info(
6371
6524
  `Area ${area.name} (${areaId}): Existing area checklist found: ${existingAreaChecklist ? "Yes" : "No"}`
@@ -6402,6 +6555,7 @@ function useScheduleTaskService() {
6402
6555
  );
6403
6556
  const modified = await pushScheduleTaskSets(
6404
6557
  parentChecklistId.toString(),
6558
+ serviceType,
6405
6559
  areaId,
6406
6560
  scheduleTask._id.toString(),
6407
6561
  newSets
@@ -6429,6 +6583,7 @@ function useScheduleTaskService() {
6429
6583
  );
6430
6584
  const checklistData = {
6431
6585
  schedule: parentChecklistId.toString(),
6586
+ serviceType,
6432
6587
  area: areaId,
6433
6588
  name: area.name,
6434
6589
  type: areaDetails.type || "common",
@@ -6483,9 +6638,9 @@ function useScheduleTaskController() {
6483
6638
  const {
6484
6639
  createScheduleTask: _createScheduleTask,
6485
6640
  getScheduleTasks: _getScheduleTasks,
6486
- getTasksForScheduleTask: _getTasksForScheduleTask,
6487
6641
  getScheduleTaskById: _getScheduleTaskById,
6488
- updateScheduleTask: _updateScheduleTask
6642
+ updateScheduleTask: _updateScheduleTask,
6643
+ deleteScheduleTask: _deleteScheduleTask
6489
6644
  } = useScheduleTaskRepository();
6490
6645
  async function createScheduleTask(req, res, next) {
6491
6646
  const cookies = req.headers.cookie ? req.headers.cookie.split(";").map((cookie) => cookie.trim().split("=")).reduce(
@@ -6516,7 +6671,8 @@ function useScheduleTaskController() {
6516
6671
  page: Joi17.number().min(1).optional().allow("", null),
6517
6672
  limit: Joi17.number().min(1).optional().allow("", null),
6518
6673
  search: Joi17.string().optional().allow("", null),
6519
- site: Joi17.string().hex().required()
6674
+ site: Joi17.string().hex().required(),
6675
+ serviceType: Joi17.string().valid(...Object.values(ServiceType)).required()
6520
6676
  });
6521
6677
  const { error } = validation.validate(query);
6522
6678
  if (error) {
@@ -6528,45 +6684,14 @@ function useScheduleTaskController() {
6528
6684
  const limit = parseInt(req.query.limit) ?? 10;
6529
6685
  const search = req.query.search ?? "";
6530
6686
  const site = req.params.site ?? "";
6687
+ const serviceType = req.query.serviceType ?? "";
6531
6688
  try {
6532
6689
  const data = await _getScheduleTasks({
6533
6690
  page,
6534
6691
  limit,
6535
6692
  search,
6536
- site
6537
- });
6538
- res.json(data);
6539
- return;
6540
- } catch (error2) {
6541
- logger33.log({ level: "error", message: error2.message });
6542
- next(error2);
6543
- return;
6544
- }
6545
- }
6546
- async function getTasksForScheduleTask(req, res, next) {
6547
- const query = { ...req.query, ...req.params };
6548
- const validation = Joi17.object({
6549
- page: Joi17.number().min(1).optional().allow("", null),
6550
- limit: Joi17.number().min(1).optional().allow("", null),
6551
- search: Joi17.string().optional().allow("", null),
6552
- site: Joi17.string().hex().required()
6553
- });
6554
- const { error } = validation.validate(query);
6555
- if (error) {
6556
- logger33.log({ level: "error", message: error.message });
6557
- next(new BadRequestError30(error.message));
6558
- return;
6559
- }
6560
- const page = parseInt(req.query.page) ?? 1;
6561
- const limit = parseInt(req.query.limit) ?? 10;
6562
- const search = req.query.search ?? "";
6563
- const site = req.params.site ?? "";
6564
- try {
6565
- const data = await _getTasksForScheduleTask({
6566
- page,
6567
- limit,
6568
- search,
6569
- site
6693
+ site,
6694
+ serviceType
6570
6695
  });
6571
6696
  res.json(data);
6572
6697
  return;
@@ -6629,12 +6754,31 @@ function useScheduleTaskController() {
6629
6754
  return;
6630
6755
  }
6631
6756
  }
6757
+ async function deleteScheduleTask(req, res, next) {
6758
+ const validation = Joi17.string().hex().required();
6759
+ const _id = req.params.id;
6760
+ const { error, value } = validation.validate(_id);
6761
+ if (error) {
6762
+ logger33.log({ level: "error", message: error.message });
6763
+ next(new BadRequestError30(error.message));
6764
+ return;
6765
+ }
6766
+ try {
6767
+ const data = await _deleteScheduleTask(value);
6768
+ res.json(data);
6769
+ return;
6770
+ } catch (error2) {
6771
+ logger33.log({ level: "error", message: error2.message });
6772
+ next(error2);
6773
+ return;
6774
+ }
6775
+ }
6632
6776
  return {
6633
6777
  createScheduleTask,
6634
6778
  getScheduleTasks,
6635
- getTasksForScheduleTask,
6636
6779
  getScheduleTaskById,
6637
- updateScheduleTask
6780
+ updateScheduleTask,
6781
+ deleteScheduleTask
6638
6782
  };
6639
6783
  }
6640
6784