@iservice365/module-hygiene 1.5.0 → 1.6.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
@@ -3,9 +3,9 @@ var allowedTypes = ["common", "toilet"];
3
3
  var allowedStatus = ["ready", "ongoing", "completed"];
4
4
 
5
5
  // src/models/hygiene-area.model.ts
6
- import { BadRequestError, logger } from "@iservice365/node-server-utils";
7
6
  import Joi from "joi";
8
7
  import { ObjectId } from "mongodb";
8
+ import { BadRequestError, logger } from "@iservice365/node-server-utils";
9
9
  var areaSchema = Joi.object({
10
10
  site: Joi.string().hex().required(),
11
11
  name: Joi.string().required(),
@@ -147,6 +147,7 @@ function useAreaRepo() {
147
147
  page = 1,
148
148
  limit = 10,
149
149
  search = "",
150
+ type = "all",
150
151
  site
151
152
  }) {
152
153
  page = page > 0 ? page - 1 : 0;
@@ -164,6 +165,10 @@ function useAreaRepo() {
164
165
  } catch (error) {
165
166
  throw new BadRequestError2("Invalid site ID format.");
166
167
  }
168
+ if (type && type !== "all") {
169
+ query.type = type;
170
+ cacheOptions.type = type;
171
+ }
167
172
  if (search) {
168
173
  query.$or = [{ name: { $regex: search, $options: "i" } }];
169
174
  cacheOptions.search = search;
@@ -592,8 +597,8 @@ function useAreaService() {
592
597
  }
593
598
 
594
599
  // src/controllers/hygiene-area.controller.ts
595
- import { BadRequestError as BadRequestError4, logger as logger4 } from "@iservice365/node-server-utils";
596
600
  import Joi2 from "joi";
601
+ import { BadRequestError as BadRequestError4, logger as logger4 } from "@iservice365/node-server-utils";
597
602
 
598
603
  // src/utils/convert-excel.util.ts
599
604
  import { Readable } from "stream";
@@ -656,6 +661,7 @@ function useAreaController() {
656
661
  page: Joi2.number().min(1).optional().allow("", null),
657
662
  limit: Joi2.number().min(1).optional().allow("", null),
658
663
  search: Joi2.string().optional().allow("", null),
664
+ type: Joi2.string().valid("all", ...allowedTypes).optional().allow("", null),
659
665
  site: Joi2.string().hex().required()
660
666
  });
661
667
  const { error } = validation.validate(query);
@@ -667,12 +673,14 @@ function useAreaController() {
667
673
  const page = parseInt(req.query.page) ?? 1;
668
674
  const limit = parseInt(req.query.limit) ?? 10;
669
675
  const search = req.query.search ?? "";
676
+ const type = req.query.type ?? "all";
670
677
  const site = req.params.site ?? "";
671
678
  try {
672
679
  const data = await _getAreas({
673
680
  page,
674
681
  limit,
675
682
  search,
683
+ type,
676
684
  site
677
685
  });
678
686
  res.json(data);
@@ -788,9 +796,9 @@ function useAreaController() {
788
796
  }
789
797
 
790
798
  // src/models/hygiene-unit.model.ts
791
- import { BadRequestError as BadRequestError5, logger as logger5 } from "@iservice365/node-server-utils";
792
799
  import Joi3 from "joi";
793
800
  import { ObjectId as ObjectId3 } from "mongodb";
801
+ import { BadRequestError as BadRequestError5, logger as logger5 } from "@iservice365/node-server-utils";
794
802
  var unitSchema = Joi3.object({
795
803
  site: Joi3.string().hex().required(),
796
804
  name: Joi3.string().required()
@@ -1027,12 +1035,12 @@ function useUnitRepository() {
1027
1035
 
1028
1036
  // src/services/hygiene-unit.service.ts
1029
1037
  function useUnitService() {
1038
+ const { verifyAreaByUnitId, updateAreaChecklist } = useAreaRepo();
1030
1039
  const {
1031
1040
  createUnit: _createUnit,
1032
1041
  updateUnit: _updateUnit,
1033
1042
  deleteUnit: _deleteUnit
1034
1043
  } = useUnitRepository();
1035
- const { verifyAreaByUnitId, updateAreaChecklist } = useAreaRepo();
1036
1044
  async function importUnit({
1037
1045
  dataJson,
1038
1046
  site
@@ -1172,8 +1180,8 @@ function useUnitService() {
1172
1180
  }
1173
1181
 
1174
1182
  // src/controllers/hygiene-unit.controller.ts
1175
- import { BadRequestError as BadRequestError8, logger as logger8 } from "@iservice365/node-server-utils";
1176
1183
  import Joi4 from "joi";
1184
+ import { BadRequestError as BadRequestError8, logger as logger8 } from "@iservice365/node-server-utils";
1177
1185
  function useUnitController() {
1178
1186
  const { createUnit: _createUnit, getUnits: _getUnits } = useUnitRepository();
1179
1187
  const {
@@ -1310,9 +1318,9 @@ function useUnitController() {
1310
1318
  }
1311
1319
 
1312
1320
  // src/models/hygiene-parent-checklist.model.ts
1313
- import { BadRequestError as BadRequestError9, logger as logger9 } from "@iservice365/node-server-utils";
1314
1321
  import Joi5 from "joi";
1315
1322
  import { ObjectId as ObjectId5 } from "mongodb";
1323
+ import { BadRequestError as BadRequestError9, logger as logger9 } from "@iservice365/node-server-utils";
1316
1324
  var parentChecklistSchema = Joi5.object({
1317
1325
  createdAt: Joi5.alternatives().try(Joi5.date(), Joi5.string()).optional().allow("", null),
1318
1326
  site: Joi5.string().hex().required()
@@ -1433,7 +1441,8 @@ function useParentChecklistRepo() {
1433
1441
  search = "",
1434
1442
  site,
1435
1443
  startDate = "",
1436
- endDate = ""
1444
+ endDate = "",
1445
+ status = "all"
1437
1446
  }) {
1438
1447
  page = page > 0 ? page - 1 : 0;
1439
1448
  const query = {};
@@ -1466,6 +1475,10 @@ function useParentChecklistRepo() {
1466
1475
  query.createdAt = { $lte: new Date(endDate) };
1467
1476
  cacheOptions.endDate = new Date(endDate).toISOString().split("T")[0];
1468
1477
  }
1478
+ if (status && status !== "all") {
1479
+ query.status = status;
1480
+ cacheOptions.status = status;
1481
+ }
1469
1482
  const cacheKey = makeCacheKey3(namespace_collection, cacheOptions);
1470
1483
  const cachedData = await getCache(cacheKey);
1471
1484
  if (cachedData) {
@@ -1589,8 +1602,8 @@ function useParentChecklistRepo() {
1589
1602
  }
1590
1603
 
1591
1604
  // src/controllers/hygiene-parent-checklist.controller.ts
1592
- import { BadRequestError as BadRequestError11, logger as logger11 } from "@iservice365/node-server-utils";
1593
1605
  import Joi6 from "joi";
1606
+ import { BadRequestError as BadRequestError11, logger as logger11 } from "@iservice365/node-server-utils";
1594
1607
  function useParentChecklistController() {
1595
1608
  const {
1596
1609
  createParentChecklist: _createParentChecklist,
@@ -1622,7 +1635,8 @@ function useParentChecklistController() {
1622
1635
  search: Joi6.string().optional().allow("", null),
1623
1636
  site: Joi6.string().hex().required(),
1624
1637
  startDate: Joi6.alternatives().try(Joi6.date(), Joi6.string()).optional().allow("", null),
1625
- endDate: Joi6.alternatives().try(Joi6.date(), Joi6.string()).optional().allow("", null)
1638
+ endDate: Joi6.alternatives().try(Joi6.date(), Joi6.string()).optional().allow("", null),
1639
+ status: Joi6.string().valid(...allowedStatus, "all").optional().allow("", null)
1626
1640
  });
1627
1641
  const { error } = validation.validate(query);
1628
1642
  if (error) {
@@ -1636,6 +1650,7 @@ function useParentChecklistController() {
1636
1650
  const site = req.params.site ?? "";
1637
1651
  const startDate = req.query.startDate ?? "";
1638
1652
  const endDate = req.query.endDate ?? "";
1653
+ const status = req.query.status ?? "all";
1639
1654
  try {
1640
1655
  const data = await _getAllParentChecklist({
1641
1656
  page,
@@ -1643,7 +1658,8 @@ function useParentChecklistController() {
1643
1658
  search,
1644
1659
  site,
1645
1660
  startDate,
1646
- endDate
1661
+ endDate,
1662
+ status
1647
1663
  });
1648
1664
  res.json(data);
1649
1665
  return;
@@ -1660,9 +1676,9 @@ function useParentChecklistController() {
1660
1676
  }
1661
1677
 
1662
1678
  // src/models/hygiene-area-checklist.model.ts
1663
- import { BadRequestError as BadRequestError12, logger as logger12 } from "@iservice365/node-server-utils";
1664
1679
  import Joi7 from "joi";
1665
1680
  import { ObjectId as ObjectId7 } from "mongodb";
1681
+ import { BadRequestError as BadRequestError12, logger as logger12 } from "@iservice365/node-server-utils";
1666
1682
  var allowedChecklistStatus = ["ready", "completed"];
1667
1683
  var areaChecklistSchema = Joi7.object({
1668
1684
  schedule: Joi7.string().hex().required(),
@@ -1733,6 +1749,7 @@ function MAreaChecklist(value) {
1733
1749
  import { logger as logger14, useAtlas as useAtlas6 } from "@iservice365/node-server-utils";
1734
1750
 
1735
1751
  // src/repositories/hygiene-area-checklist.repository.ts
1752
+ import { ObjectId as ObjectId8 } from "mongodb";
1736
1753
  import {
1737
1754
  BadRequestError as BadRequestError13,
1738
1755
  InternalServerError as InternalServerError4,
@@ -1742,7 +1759,6 @@ import {
1742
1759
  useAtlas as useAtlas5,
1743
1760
  useCache as useCache4
1744
1761
  } from "@iservice365/node-server-utils";
1745
- import { ObjectId as ObjectId8 } from "mongodb";
1746
1762
  function useAreaChecklistRepo() {
1747
1763
  const db = useAtlas5.getDb();
1748
1764
  if (!db) {
@@ -1822,7 +1838,8 @@ function useAreaChecklistRepo() {
1822
1838
  page = 1,
1823
1839
  limit = 10,
1824
1840
  search = "",
1825
- type,
1841
+ type = "all",
1842
+ status = "all",
1826
1843
  schedule
1827
1844
  }, session) {
1828
1845
  page = page > 0 ? page - 1 : 0;
@@ -1837,10 +1854,14 @@ function useAreaChecklistRepo() {
1837
1854
  } catch (error) {
1838
1855
  throw new BadRequestError13("Invalid parent checklist ID format.");
1839
1856
  }
1840
- if (type) {
1857
+ if (type && type !== "all") {
1841
1858
  query.type = type;
1842
1859
  cacheOptions.type = type;
1843
1860
  }
1861
+ if (status && status !== "all") {
1862
+ query.status = status;
1863
+ cacheOptions.status = status;
1864
+ }
1844
1865
  if (search) {
1845
1866
  query.$text = { $search: search };
1846
1867
  cacheOptions.search = search;
@@ -2408,6 +2429,7 @@ function useAreaChecklistRepo() {
2408
2429
 
2409
2430
  // src/services/hygiene-area-checklist.service.ts
2410
2431
  function useAreaChecklistService() {
2432
+ const { getAreasForChecklist } = useAreaRepo();
2411
2433
  const {
2412
2434
  createAreaChecklist: _createAreaChecklist,
2413
2435
  getAllAreaChecklist,
@@ -2416,7 +2438,6 @@ function useAreaChecklistService() {
2416
2438
  completeAreaChecklistUnits: _completeAreaChecklistUnits,
2417
2439
  updateAreaChecklistStatus
2418
2440
  } = useAreaChecklistRepo();
2419
- const { getAreasForChecklist } = useAreaRepo();
2420
2441
  const { updateParentChecklistStatuses } = useParentChecklistRepo();
2421
2442
  async function createAreaChecklist(value) {
2422
2443
  const session = useAtlas6.getClient()?.startSession();
@@ -2563,8 +2584,8 @@ function useAreaChecklistService() {
2563
2584
  }
2564
2585
 
2565
2586
  // src/controllers/hygiene-area-checklist.controller.ts
2566
- import { BadRequestError as BadRequestError14, logger as logger15 } from "@iservice365/node-server-utils";
2567
2587
  import Joi8 from "joi";
2588
+ import { BadRequestError as BadRequestError14, logger as logger15 } from "@iservice365/node-server-utils";
2568
2589
  function useAreaChecklistController() {
2569
2590
  const {
2570
2591
  getAllAreaChecklist: _getAllAreaChecklist,
@@ -2607,7 +2628,8 @@ function useAreaChecklistController() {
2607
2628
  page: Joi8.number().min(1).optional().allow("", null),
2608
2629
  limit: Joi8.number().min(1).optional().allow("", null),
2609
2630
  search: Joi8.string().optional().allow("", null),
2610
- type: Joi8.string().optional().allow("", ...allowedTypes),
2631
+ type: Joi8.string().valid(...allowedTypes, "all").optional().allow("", null),
2632
+ status: Joi8.string().valid(...allowedStatus, "all").optional().allow("", null),
2611
2633
  schedule: Joi8.string().hex().required()
2612
2634
  });
2613
2635
  const { error } = validation.validate(query);
@@ -2619,7 +2641,8 @@ function useAreaChecklistController() {
2619
2641
  const page = parseInt(req.query.page) ?? 1;
2620
2642
  const limit = parseInt(req.query.limit) ?? 10;
2621
2643
  const search = req.query.search ?? "";
2622
- const type = req.query.type ?? "";
2644
+ const type = req.query.type ?? "all";
2645
+ const status = req.query.status ?? "all";
2623
2646
  const schedule = req.params.schedule ?? "";
2624
2647
  try {
2625
2648
  const data = await _getAllAreaChecklist({
@@ -2627,6 +2650,7 @@ function useAreaChecklistController() {
2627
2650
  limit,
2628
2651
  search,
2629
2652
  type,
2653
+ status,
2630
2654
  schedule
2631
2655
  });
2632
2656
  res.json(data);
@@ -2782,9 +2806,9 @@ function useAreaChecklistController() {
2782
2806
  }
2783
2807
 
2784
2808
  // src/models/hygiene-supply.model.ts
2785
- import { BadRequestError as BadRequestError15, logger as logger16 } from "@iservice365/node-server-utils";
2786
2809
  import Joi9 from "joi";
2787
2810
  import { ObjectId as ObjectId9 } from "mongodb";
2811
+ import { BadRequestError as BadRequestError15, logger as logger16 } from "@iservice365/node-server-utils";
2788
2812
  var supplySchema = Joi9.object({
2789
2813
  site: Joi9.string().hex().required(),
2790
2814
  name: Joi9.string().required(),
@@ -3068,8 +3092,8 @@ function useSupplyRepository() {
3068
3092
  }
3069
3093
 
3070
3094
  // src/controllers/hygiene-supply.controller.ts
3071
- import { BadRequestError as BadRequestError17, logger as logger18 } from "@iservice365/node-server-utils";
3072
3095
  import Joi10 from "joi";
3096
+ import { BadRequestError as BadRequestError17, logger as logger18 } from "@iservice365/node-server-utils";
3073
3097
  function useSupplyController() {
3074
3098
  const {
3075
3099
  createSupply: _createSupply,
@@ -3204,9 +3228,9 @@ function useSupplyController() {
3204
3228
  }
3205
3229
 
3206
3230
  // src/models/hygiene-stock.model.ts
3207
- import { BadRequestError as BadRequestError18, logger as logger19 } from "@iservice365/node-server-utils";
3208
3231
  import Joi11 from "joi";
3209
3232
  import { ObjectId as ObjectId11 } from "mongodb";
3233
+ import { BadRequestError as BadRequestError18, logger as logger19 } from "@iservice365/node-server-utils";
3210
3234
  var stockSchema = Joi11.object({
3211
3235
  site: Joi11.string().hex().required(),
3212
3236
  supply: Joi11.string().hex().required(),
@@ -3427,8 +3451,8 @@ function useStockService() {
3427
3451
  }
3428
3452
 
3429
3453
  // src/controllers/hygiene-stock.controller.ts
3430
- import { BadRequestError as BadRequestError21, logger as logger21 } from "@iservice365/node-server-utils";
3431
3454
  import Joi12 from "joi";
3455
+ import { BadRequestError as BadRequestError21, logger as logger21 } from "@iservice365/node-server-utils";
3432
3456
  function useStockController() {
3433
3457
  const { getStocksBySupplyId: _getStocksBySupplyId } = useStockRepository();
3434
3458
  const { createStock: _createStock } = useStockService();
@@ -3499,9 +3523,9 @@ function useStockController() {
3499
3523
  }
3500
3524
 
3501
3525
  // src/models/hygiene-request-item.model.ts
3502
- import { BadRequestError as BadRequestError22, logger as logger22 } from "@iservice365/node-server-utils";
3503
3526
  import Joi13 from "joi";
3504
3527
  import { ObjectId as ObjectId13 } from "mongodb";
3528
+ import { BadRequestError as BadRequestError22, logger as logger22 } from "@iservice365/node-server-utils";
3505
3529
  var allowedRequestItemStatus = [
3506
3530
  "pending",
3507
3531
  "approved",
@@ -3645,6 +3669,7 @@ function useRequestItemRepository() {
3645
3669
  { $match: query },
3646
3670
  {
3647
3671
  $project: {
3672
+ supplyName: 1,
3648
3673
  createdAt: 1,
3649
3674
  status: 1
3650
3675
  }
@@ -3803,8 +3828,8 @@ function useRequestItemRepository() {
3803
3828
  }
3804
3829
 
3805
3830
  // src/services/hygiene-request-item.service.ts
3806
- import { BadRequestError as BadRequestError24, useAtlas as useAtlas11 } from "@iservice365/node-server-utils";
3807
3831
  import { useUserRepo } from "@iservice365/core";
3832
+ import { BadRequestError as BadRequestError24, useAtlas as useAtlas11 } from "@iservice365/node-server-utils";
3808
3833
  function useRequestItemService() {
3809
3834
  const {
3810
3835
  createRequestItem: _createRequestItem,
@@ -3919,8 +3944,8 @@ function useRequestItemService() {
3919
3944
  }
3920
3945
 
3921
3946
  // src/controllers/hygiene-request-item.controller.ts
3922
- import { BadRequestError as BadRequestError25, logger as logger24 } from "@iservice365/node-server-utils";
3923
3947
  import Joi14 from "joi";
3948
+ import { BadRequestError as BadRequestError25, logger as logger24 } from "@iservice365/node-server-utils";
3924
3949
  function useRequestItemController() {
3925
3950
  const {
3926
3951
  getRequestItems: _getRequestItems,
@@ -4496,9 +4521,9 @@ function useScheduleTaskRepository() {
4496
4521
  // src/services/hygiene-schedule-task.service.ts
4497
4522
  import { logger as logger27 } from "@iservice365/node-server-utils";
4498
4523
  function useScheduleTaskService() {
4524
+ const { createParentChecklist } = useParentChecklistRepo();
4499
4525
  const { getAllScheduleTask } = useScheduleTaskRepository();
4500
4526
  const { createAreaChecklist } = useAreaChecklistService();
4501
- const { createParentChecklist } = useParentChecklistRepo();
4502
4527
  function checkScheduleConditions(schedule, currentDate = /* @__PURE__ */ new Date()) {
4503
4528
  try {
4504
4529
  const now = currentDate;
@@ -4686,8 +4711,8 @@ function useScheduleTaskService() {
4686
4711
  }
4687
4712
 
4688
4713
  // src/controllers/hygiene-schedule-task.controller.ts
4689
- import { BadRequestError as BadRequestError28, logger as logger28 } from "@iservice365/node-server-utils";
4690
4714
  import Joi16 from "joi";
4715
+ import { BadRequestError as BadRequestError28, logger as logger28 } from "@iservice365/node-server-utils";
4691
4716
  function useScheduleTaskController() {
4692
4717
  const {
4693
4718
  createScheduleTask: _createScheduleTask,