@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/CHANGELOG.md +12 -0
- package/dist/index.d.ts +30 -27
- package/dist/index.js +52 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +52 -27
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -23,12 +23,13 @@ type TArea = {
|
|
|
23
23
|
updatedAt?: Date | string;
|
|
24
24
|
deletedAt?: Date | string;
|
|
25
25
|
};
|
|
26
|
+
type TAreaCreate = Pick<TArea, "site" | "name" | "type" | "set" | "units">;
|
|
26
27
|
type TAreaGetQuery = {
|
|
27
28
|
page?: number;
|
|
28
29
|
limit?: number;
|
|
29
30
|
search?: string;
|
|
31
|
+
type?: (typeof allowedTypes)[number] | "all";
|
|
30
32
|
} & Pick<TArea, "site">;
|
|
31
|
-
type TAreaCreate = Pick<TArea, "site" | "name" | "type" | "set" | "units">;
|
|
32
33
|
type TAreaUpdate = Partial<Pick<TArea, "name" | "type" | "set" | "units">>;
|
|
33
34
|
type TAreaUpdateChecklist = {
|
|
34
35
|
units: TAreaUnits[];
|
|
@@ -51,7 +52,7 @@ declare function useAreaRepo(): {
|
|
|
51
52
|
createTextIndex: () => Promise<void>;
|
|
52
53
|
createUniqueIndex: () => Promise<void>;
|
|
53
54
|
createArea: (value: TAreaCreate, session?: ClientSession) => Promise<ObjectId>;
|
|
54
|
-
getAreas: ({ page, limit, search, site, }: TAreaGetQuery) => Promise<{}>;
|
|
55
|
+
getAreas: ({ page, limit, search, type, site, }: TAreaGetQuery) => Promise<{}>;
|
|
55
56
|
getAreasForChecklist: (site: string | ObjectId) => Promise<{}>;
|
|
56
57
|
getAreaById: (_id: string | ObjectId) => Promise<{}>;
|
|
57
58
|
getAreaByMultipleId: (_id: string[] | ObjectId[]) => Promise<bson.Document[]>;
|
|
@@ -150,6 +151,14 @@ type TParentChecklist = {
|
|
|
150
151
|
createdAt?: Date | string;
|
|
151
152
|
updatedAt?: Date | string;
|
|
152
153
|
};
|
|
154
|
+
type TParentChecklistGetQuery = {
|
|
155
|
+
page?: number;
|
|
156
|
+
limit?: number;
|
|
157
|
+
search?: string;
|
|
158
|
+
site: string | ObjectId;
|
|
159
|
+
startDate?: string | Date;
|
|
160
|
+
endDate?: string | Date;
|
|
161
|
+
} & Pick<TParentChecklist, "status">;
|
|
153
162
|
declare const parentChecklistSchema: Joi.ObjectSchema<any>;
|
|
154
163
|
declare function MParentChecklist(value: TParentChecklist): {
|
|
155
164
|
site: string | ObjectId | undefined;
|
|
@@ -161,14 +170,7 @@ declare function MParentChecklist(value: TParentChecklist): {
|
|
|
161
170
|
declare function useParentChecklistRepo(): {
|
|
162
171
|
createIndex: () => Promise<void>;
|
|
163
172
|
createParentChecklist: (value: TParentChecklist, session?: ClientSession) => Promise<ObjectId | ObjectId[]>;
|
|
164
|
-
getAllParentChecklist: ({ page, limit, search, site, startDate, endDate, }: {
|
|
165
|
-
page?: number | undefined;
|
|
166
|
-
limit?: number | undefined;
|
|
167
|
-
search?: string | undefined;
|
|
168
|
-
site: ObjectId | string;
|
|
169
|
-
startDate?: string | Date | undefined;
|
|
170
|
-
endDate?: string | Date | undefined;
|
|
171
|
-
}) => Promise<{}>;
|
|
173
|
+
getAllParentChecklist: ({ page, limit, search, site, startDate, endDate, status, }: TParentChecklistGetQuery) => Promise<{}>;
|
|
172
174
|
updateParentChecklistStatuses: (_id: string | ObjectId, status: (typeof allowedStatus)[number], session?: ClientSession) => Promise<number>;
|
|
173
175
|
};
|
|
174
176
|
|
|
@@ -205,6 +207,13 @@ type TAreaChecklistUnits = {
|
|
|
205
207
|
type TAreaChecklistCreate = Pick<TCleaningScheduleArea, "schedule"> & {
|
|
206
208
|
site: string | ObjectId;
|
|
207
209
|
};
|
|
210
|
+
type TCleaningScheduleAreaGetQuery = {
|
|
211
|
+
page?: number;
|
|
212
|
+
limit?: number;
|
|
213
|
+
search?: string;
|
|
214
|
+
type?: (typeof allowedTypes)[number] | "all";
|
|
215
|
+
status?: (typeof allowedStatus)[number] | "all";
|
|
216
|
+
} & Pick<TCleaningScheduleArea, "schedule">;
|
|
208
217
|
type TAreaChecklistUnitsUpdate = Pick<TAreaChecklistUnits, "remarks" | "completedBy">;
|
|
209
218
|
declare const areaChecklistSchema: Joi.ObjectSchema<any>;
|
|
210
219
|
declare function MAreaChecklist(value: TCleaningScheduleArea): {
|
|
@@ -228,13 +237,7 @@ declare function useAreaChecklistRepo(): {
|
|
|
228
237
|
createIndex: () => Promise<void>;
|
|
229
238
|
createTextIndex: () => Promise<void>;
|
|
230
239
|
createAreaChecklist: (value: TCleaningScheduleArea, session?: ClientSession) => Promise<ObjectId>;
|
|
231
|
-
getAllAreaChecklist: ({ page, limit, search, type, schedule, }: {
|
|
232
|
-
page?: number | undefined;
|
|
233
|
-
limit?: number | undefined;
|
|
234
|
-
search?: string | undefined;
|
|
235
|
-
type?: string | undefined;
|
|
236
|
-
schedule: string | ObjectId;
|
|
237
|
-
}, session?: ClientSession) => Promise<{}>;
|
|
240
|
+
getAllAreaChecklist: ({ page, limit, search, type, status, schedule, }: TCleaningScheduleAreaGetQuery, session?: ClientSession) => Promise<{}>;
|
|
238
241
|
getAreaChecklistHistory: ({ page, limit, search, type, schedule, status, createdAt, }: {
|
|
239
242
|
page?: number | undefined;
|
|
240
243
|
limit?: number | undefined;
|
|
@@ -386,12 +389,12 @@ type TRequestItemCreateService = Pick<TRequestItem, "site" | "supply" | "qty" |
|
|
|
386
389
|
type TRequestItemCreateByBatchService = Pick<TRequestItem, "site" | "createdBy"> & {
|
|
387
390
|
items: Pick<TRequestItem, "supply" | "qty">[];
|
|
388
391
|
};
|
|
389
|
-
type
|
|
392
|
+
type TRequestItemGetQuery = {
|
|
390
393
|
page?: number;
|
|
391
394
|
limit?: number;
|
|
392
395
|
search?: string;
|
|
393
396
|
} & Pick<TRequestItem, "site">;
|
|
394
|
-
type
|
|
397
|
+
type TRequestItemGetById = Pick<TRequestItem, "_id" | "site" | "supply" | "supplyName" | "qty" | "status"> & {
|
|
395
398
|
unitOfMeasurement?: string;
|
|
396
399
|
};
|
|
397
400
|
declare const requestItemSchema: Joi.ObjectSchema<any>;
|
|
@@ -413,8 +416,8 @@ declare function useRequestItemRepository(): {
|
|
|
413
416
|
createIndex: () => Promise<void>;
|
|
414
417
|
createTextIndex: () => Promise<void>;
|
|
415
418
|
createRequestItem: (value: TRequestItemCreate, session?: ClientSession) => Promise<ObjectId>;
|
|
416
|
-
getRequestItems: ({ page, limit, search, site, }:
|
|
417
|
-
getRequestItemById: (_id: string | ObjectId, session?: ClientSession) => Promise<
|
|
419
|
+
getRequestItems: ({ page, limit, search, site, }: TRequestItemGetQuery) => Promise<{}>;
|
|
420
|
+
getRequestItemById: (_id: string | ObjectId, session?: ClientSession) => Promise<TRequestItemGetById>;
|
|
418
421
|
approveRequestItem: (_id: string | ObjectId, remarks?: string, session?: ClientSession) => Promise<number>;
|
|
419
422
|
disapproveRequestItem: (_id: string | ObjectId, remarks?: string, session?: ClientSession) => Promise<number>;
|
|
420
423
|
};
|
|
@@ -460,13 +463,13 @@ type TScheduleTask = {
|
|
|
460
463
|
deletedAt?: string | Date;
|
|
461
464
|
};
|
|
462
465
|
type TScheduleTaskCreate = Pick<TScheduleTask, "site" | "title" | "frequency" | "time" | "day" | "weekOfMonth" | "month" | "date" | "description" | "areas">;
|
|
463
|
-
type
|
|
464
|
-
type TScheduleTaskGetById = Pick<TScheduleTask, "title" | "frequency" | "time" | "day" | "weekOfMonth" | "month" | "date" | "description" | "areas" | "status" | "createdAt">;
|
|
465
|
-
type TGetScheduleTasksQuery = {
|
|
466
|
+
type TScheduleTaskGetQuery = {
|
|
466
467
|
page?: number;
|
|
467
468
|
limit?: number;
|
|
468
469
|
search?: string;
|
|
469
470
|
} & Pick<TScheduleTask, "site">;
|
|
471
|
+
type TScheduleTaskGetById = Pick<TScheduleTask, "title" | "frequency" | "time" | "day" | "weekOfMonth" | "month" | "date" | "description" | "areas" | "status" | "createdAt">;
|
|
472
|
+
type TScheduleTaskUpdate = Partial<Pick<TScheduleTask, "title" | "frequency" | "time" | "day" | "weekOfMonth" | "month" | "date" | "description" | "areas">>;
|
|
470
473
|
declare const scheduleTaskSchema: Joi.ObjectSchema<any>;
|
|
471
474
|
declare function MScheduleTask(value: TScheduleTaskCreate): {
|
|
472
475
|
site: string | ObjectId;
|
|
@@ -492,9 +495,9 @@ declare function useScheduleTaskRepository(): {
|
|
|
492
495
|
createIndex: () => Promise<void>;
|
|
493
496
|
createTextIndex: () => Promise<void>;
|
|
494
497
|
createScheduleTask: (value: TScheduleTaskCreate, session?: ClientSession) => Promise<ObjectId>;
|
|
495
|
-
getScheduleTasks: ({ page, limit, search, site, }:
|
|
498
|
+
getScheduleTasks: ({ page, limit, search, site, }: TScheduleTaskGetQuery) => Promise<{}>;
|
|
496
499
|
getAllScheduleTask: () => Promise<TScheduleTask[]>;
|
|
497
|
-
getTasksForScheduleTask: ({ page, limit, search, site, }:
|
|
500
|
+
getTasksForScheduleTask: ({ page, limit, search, site, }: TScheduleTaskGetQuery) => Promise<{}>;
|
|
498
501
|
getScheduleTaskById: (_id: string | ObjectId, session?: ClientSession) => Promise<TScheduleTaskGetById>;
|
|
499
502
|
updateScheduleTask: (_id: string | ObjectId, value: TScheduleTaskUpdate, session?: ClientSession) => Promise<number>;
|
|
500
503
|
};
|
|
@@ -520,4 +523,4 @@ declare function useScheduleTaskController(): {
|
|
|
520
523
|
updateScheduleTask: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
521
524
|
};
|
|
522
525
|
|
|
523
|
-
export { MArea, MAreaChecklist, MParentChecklist, MRequestItem, MScheduleTask, MStock, MSupply, MUnit, TArea, TAreaChecklist, TAreaChecklistCreate, TAreaChecklistUnits, TAreaChecklistUnitsUpdate, TAreaCreate, TAreaGetQuery, TAreaUnits, TAreaUpdate, TAreaUpdateChecklist, TCleaningScheduleArea,
|
|
526
|
+
export { MArea, MAreaChecklist, MParentChecklist, MRequestItem, MScheduleTask, MStock, MSupply, MUnit, TArea, TAreaChecklist, TAreaChecklistCreate, TAreaChecklistUnits, TAreaChecklistUnitsUpdate, TAreaCreate, TAreaGetQuery, TAreaUnits, TAreaUpdate, TAreaUpdateChecklist, TCleaningScheduleArea, TCleaningScheduleAreaGetQuery, TGetStocksQuery, TGetSupplysQuery, TGetUnitsQuery, TParentChecklist, TParentChecklistGetQuery, TRequestItem, TRequestItemCreate, TRequestItemCreateByBatchService, TRequestItemCreateService, TRequestItemGetById, TRequestItemGetQuery, TScheduleTask, TScheduleTaskCreate, TScheduleTaskGetById, TScheduleTaskGetQuery, TScheduleTaskUpdate, TStock, TStockCreate, TStockCreateService, TSupply, TSupplyCreate, TSupplyGetById, TSupplyUpdate, TUnit, TUnitCreate, TUnitUpdate, allowedChecklistStatus, allowedDays, allowedFrequency, allowedMonths, allowedRequestItemStatus, allowedStatus, allowedTypes, allowedWeekOfMonth, areaChecklistSchema, areaSchema, parentChecklistSchema, requestItemSchema, scheduleTaskSchema, stockSchema, supplySchema, unitSchema, useAreaChecklistController, useAreaChecklistRepo, useAreaChecklistService, useAreaController, useAreaRepo, useAreaService, useParentChecklistController, useParentChecklistRepo, useRequestItemController, useRequestItemRepository, useRequestItemService, useScheduleTaskController, useScheduleTaskRepository, useScheduleTaskService, useStockController, useStockRepository, useStockService, useSupplyController, useSupplyRepository, useUnitController, useUnitRepository, useUnitService };
|
package/dist/index.js
CHANGED
|
@@ -84,9 +84,9 @@ var allowedTypes = ["common", "toilet"];
|
|
|
84
84
|
var allowedStatus = ["ready", "ongoing", "completed"];
|
|
85
85
|
|
|
86
86
|
// src/models/hygiene-area.model.ts
|
|
87
|
-
var import_node_server_utils = require("@iservice365/node-server-utils");
|
|
88
87
|
var import_joi = __toESM(require("joi"));
|
|
89
88
|
var import_mongodb = require("mongodb");
|
|
89
|
+
var import_node_server_utils = require("@iservice365/node-server-utils");
|
|
90
90
|
var areaSchema = import_joi.default.object({
|
|
91
91
|
site: import_joi.default.string().hex().required(),
|
|
92
92
|
name: import_joi.default.string().required(),
|
|
@@ -219,6 +219,7 @@ function useAreaRepo() {
|
|
|
219
219
|
page = 1,
|
|
220
220
|
limit = 10,
|
|
221
221
|
search = "",
|
|
222
|
+
type = "all",
|
|
222
223
|
site
|
|
223
224
|
}) {
|
|
224
225
|
page = page > 0 ? page - 1 : 0;
|
|
@@ -236,6 +237,10 @@ function useAreaRepo() {
|
|
|
236
237
|
} catch (error) {
|
|
237
238
|
throw new import_node_server_utils2.BadRequestError("Invalid site ID format.");
|
|
238
239
|
}
|
|
240
|
+
if (type && type !== "all") {
|
|
241
|
+
query.type = type;
|
|
242
|
+
cacheOptions.type = type;
|
|
243
|
+
}
|
|
239
244
|
if (search) {
|
|
240
245
|
query.$or = [{ name: { $regex: search, $options: "i" } }];
|
|
241
246
|
cacheOptions.search = search;
|
|
@@ -660,8 +665,8 @@ function useAreaService() {
|
|
|
660
665
|
}
|
|
661
666
|
|
|
662
667
|
// src/controllers/hygiene-area.controller.ts
|
|
663
|
-
var import_node_server_utils4 = require("@iservice365/node-server-utils");
|
|
664
668
|
var import_joi2 = __toESM(require("joi"));
|
|
669
|
+
var import_node_server_utils4 = require("@iservice365/node-server-utils");
|
|
665
670
|
|
|
666
671
|
// src/utils/convert-excel.util.ts
|
|
667
672
|
var import_stream = require("stream");
|
|
@@ -724,6 +729,7 @@ function useAreaController() {
|
|
|
724
729
|
page: import_joi2.default.number().min(1).optional().allow("", null),
|
|
725
730
|
limit: import_joi2.default.number().min(1).optional().allow("", null),
|
|
726
731
|
search: import_joi2.default.string().optional().allow("", null),
|
|
732
|
+
type: import_joi2.default.string().valid("all", ...allowedTypes).optional().allow("", null),
|
|
727
733
|
site: import_joi2.default.string().hex().required()
|
|
728
734
|
});
|
|
729
735
|
const { error } = validation.validate(query);
|
|
@@ -735,12 +741,14 @@ function useAreaController() {
|
|
|
735
741
|
const page = parseInt(req.query.page) ?? 1;
|
|
736
742
|
const limit = parseInt(req.query.limit) ?? 10;
|
|
737
743
|
const search = req.query.search ?? "";
|
|
744
|
+
const type = req.query.type ?? "all";
|
|
738
745
|
const site = req.params.site ?? "";
|
|
739
746
|
try {
|
|
740
747
|
const data = await _getAreas({
|
|
741
748
|
page,
|
|
742
749
|
limit,
|
|
743
750
|
search,
|
|
751
|
+
type,
|
|
744
752
|
site
|
|
745
753
|
});
|
|
746
754
|
res.json(data);
|
|
@@ -856,9 +864,9 @@ function useAreaController() {
|
|
|
856
864
|
}
|
|
857
865
|
|
|
858
866
|
// src/models/hygiene-unit.model.ts
|
|
859
|
-
var import_node_server_utils5 = require("@iservice365/node-server-utils");
|
|
860
867
|
var import_joi3 = __toESM(require("joi"));
|
|
861
868
|
var import_mongodb3 = require("mongodb");
|
|
869
|
+
var import_node_server_utils5 = require("@iservice365/node-server-utils");
|
|
862
870
|
var unitSchema = import_joi3.default.object({
|
|
863
871
|
site: import_joi3.default.string().hex().required(),
|
|
864
872
|
name: import_joi3.default.string().required()
|
|
@@ -1082,12 +1090,12 @@ function useUnitRepository() {
|
|
|
1082
1090
|
|
|
1083
1091
|
// src/services/hygiene-unit.service.ts
|
|
1084
1092
|
function useUnitService() {
|
|
1093
|
+
const { verifyAreaByUnitId, updateAreaChecklist } = useAreaRepo();
|
|
1085
1094
|
const {
|
|
1086
1095
|
createUnit: _createUnit,
|
|
1087
1096
|
updateUnit: _updateUnit,
|
|
1088
1097
|
deleteUnit: _deleteUnit
|
|
1089
1098
|
} = useUnitRepository();
|
|
1090
|
-
const { verifyAreaByUnitId, updateAreaChecklist } = useAreaRepo();
|
|
1091
1099
|
async function importUnit({
|
|
1092
1100
|
dataJson,
|
|
1093
1101
|
site
|
|
@@ -1227,8 +1235,8 @@ function useUnitService() {
|
|
|
1227
1235
|
}
|
|
1228
1236
|
|
|
1229
1237
|
// src/controllers/hygiene-unit.controller.ts
|
|
1230
|
-
var import_node_server_utils8 = require("@iservice365/node-server-utils");
|
|
1231
1238
|
var import_joi4 = __toESM(require("joi"));
|
|
1239
|
+
var import_node_server_utils8 = require("@iservice365/node-server-utils");
|
|
1232
1240
|
function useUnitController() {
|
|
1233
1241
|
const { createUnit: _createUnit, getUnits: _getUnits } = useUnitRepository();
|
|
1234
1242
|
const {
|
|
@@ -1365,9 +1373,9 @@ function useUnitController() {
|
|
|
1365
1373
|
}
|
|
1366
1374
|
|
|
1367
1375
|
// src/models/hygiene-parent-checklist.model.ts
|
|
1368
|
-
var import_node_server_utils9 = require("@iservice365/node-server-utils");
|
|
1369
1376
|
var import_joi5 = __toESM(require("joi"));
|
|
1370
1377
|
var import_mongodb5 = require("mongodb");
|
|
1378
|
+
var import_node_server_utils9 = require("@iservice365/node-server-utils");
|
|
1371
1379
|
var parentChecklistSchema = import_joi5.default.object({
|
|
1372
1380
|
createdAt: import_joi5.default.alternatives().try(import_joi5.default.date(), import_joi5.default.string()).optional().allow("", null),
|
|
1373
1381
|
site: import_joi5.default.string().hex().required()
|
|
@@ -1480,7 +1488,8 @@ function useParentChecklistRepo() {
|
|
|
1480
1488
|
search = "",
|
|
1481
1489
|
site,
|
|
1482
1490
|
startDate = "",
|
|
1483
|
-
endDate = ""
|
|
1491
|
+
endDate = "",
|
|
1492
|
+
status = "all"
|
|
1484
1493
|
}) {
|
|
1485
1494
|
page = page > 0 ? page - 1 : 0;
|
|
1486
1495
|
const query = {};
|
|
@@ -1513,6 +1522,10 @@ function useParentChecklistRepo() {
|
|
|
1513
1522
|
query.createdAt = { $lte: new Date(endDate) };
|
|
1514
1523
|
cacheOptions.endDate = new Date(endDate).toISOString().split("T")[0];
|
|
1515
1524
|
}
|
|
1525
|
+
if (status && status !== "all") {
|
|
1526
|
+
query.status = status;
|
|
1527
|
+
cacheOptions.status = status;
|
|
1528
|
+
}
|
|
1516
1529
|
const cacheKey = (0, import_node_server_utils10.makeCacheKey)(namespace_collection, cacheOptions);
|
|
1517
1530
|
const cachedData = await getCache(cacheKey);
|
|
1518
1531
|
if (cachedData) {
|
|
@@ -1636,8 +1649,8 @@ function useParentChecklistRepo() {
|
|
|
1636
1649
|
}
|
|
1637
1650
|
|
|
1638
1651
|
// src/controllers/hygiene-parent-checklist.controller.ts
|
|
1639
|
-
var import_node_server_utils11 = require("@iservice365/node-server-utils");
|
|
1640
1652
|
var import_joi6 = __toESM(require("joi"));
|
|
1653
|
+
var import_node_server_utils11 = require("@iservice365/node-server-utils");
|
|
1641
1654
|
function useParentChecklistController() {
|
|
1642
1655
|
const {
|
|
1643
1656
|
createParentChecklist: _createParentChecklist,
|
|
@@ -1669,7 +1682,8 @@ function useParentChecklistController() {
|
|
|
1669
1682
|
search: import_joi6.default.string().optional().allow("", null),
|
|
1670
1683
|
site: import_joi6.default.string().hex().required(),
|
|
1671
1684
|
startDate: import_joi6.default.alternatives().try(import_joi6.default.date(), import_joi6.default.string()).optional().allow("", null),
|
|
1672
|
-
endDate: import_joi6.default.alternatives().try(import_joi6.default.date(), import_joi6.default.string()).optional().allow("", null)
|
|
1685
|
+
endDate: import_joi6.default.alternatives().try(import_joi6.default.date(), import_joi6.default.string()).optional().allow("", null),
|
|
1686
|
+
status: import_joi6.default.string().valid(...allowedStatus, "all").optional().allow("", null)
|
|
1673
1687
|
});
|
|
1674
1688
|
const { error } = validation.validate(query);
|
|
1675
1689
|
if (error) {
|
|
@@ -1683,6 +1697,7 @@ function useParentChecklistController() {
|
|
|
1683
1697
|
const site = req.params.site ?? "";
|
|
1684
1698
|
const startDate = req.query.startDate ?? "";
|
|
1685
1699
|
const endDate = req.query.endDate ?? "";
|
|
1700
|
+
const status = req.query.status ?? "all";
|
|
1686
1701
|
try {
|
|
1687
1702
|
const data = await _getAllParentChecklist({
|
|
1688
1703
|
page,
|
|
@@ -1690,7 +1705,8 @@ function useParentChecklistController() {
|
|
|
1690
1705
|
search,
|
|
1691
1706
|
site,
|
|
1692
1707
|
startDate,
|
|
1693
|
-
endDate
|
|
1708
|
+
endDate,
|
|
1709
|
+
status
|
|
1694
1710
|
});
|
|
1695
1711
|
res.json(data);
|
|
1696
1712
|
return;
|
|
@@ -1707,9 +1723,9 @@ function useParentChecklistController() {
|
|
|
1707
1723
|
}
|
|
1708
1724
|
|
|
1709
1725
|
// src/models/hygiene-area-checklist.model.ts
|
|
1710
|
-
var import_node_server_utils12 = require("@iservice365/node-server-utils");
|
|
1711
1726
|
var import_joi7 = __toESM(require("joi"));
|
|
1712
1727
|
var import_mongodb7 = require("mongodb");
|
|
1728
|
+
var import_node_server_utils12 = require("@iservice365/node-server-utils");
|
|
1713
1729
|
var allowedChecklistStatus = ["ready", "completed"];
|
|
1714
1730
|
var areaChecklistSchema = import_joi7.default.object({
|
|
1715
1731
|
schedule: import_joi7.default.string().hex().required(),
|
|
@@ -1780,8 +1796,8 @@ function MAreaChecklist(value) {
|
|
|
1780
1796
|
var import_node_server_utils14 = require("@iservice365/node-server-utils");
|
|
1781
1797
|
|
|
1782
1798
|
// src/repositories/hygiene-area-checklist.repository.ts
|
|
1783
|
-
var import_node_server_utils13 = require("@iservice365/node-server-utils");
|
|
1784
1799
|
var import_mongodb8 = require("mongodb");
|
|
1800
|
+
var import_node_server_utils13 = require("@iservice365/node-server-utils");
|
|
1785
1801
|
function useAreaChecklistRepo() {
|
|
1786
1802
|
const db = import_node_server_utils13.useAtlas.getDb();
|
|
1787
1803
|
if (!db) {
|
|
@@ -1861,7 +1877,8 @@ function useAreaChecklistRepo() {
|
|
|
1861
1877
|
page = 1,
|
|
1862
1878
|
limit = 10,
|
|
1863
1879
|
search = "",
|
|
1864
|
-
type,
|
|
1880
|
+
type = "all",
|
|
1881
|
+
status = "all",
|
|
1865
1882
|
schedule
|
|
1866
1883
|
}, session) {
|
|
1867
1884
|
page = page > 0 ? page - 1 : 0;
|
|
@@ -1876,10 +1893,14 @@ function useAreaChecklistRepo() {
|
|
|
1876
1893
|
} catch (error) {
|
|
1877
1894
|
throw new import_node_server_utils13.BadRequestError("Invalid parent checklist ID format.");
|
|
1878
1895
|
}
|
|
1879
|
-
if (type) {
|
|
1896
|
+
if (type && type !== "all") {
|
|
1880
1897
|
query.type = type;
|
|
1881
1898
|
cacheOptions.type = type;
|
|
1882
1899
|
}
|
|
1900
|
+
if (status && status !== "all") {
|
|
1901
|
+
query.status = status;
|
|
1902
|
+
cacheOptions.status = status;
|
|
1903
|
+
}
|
|
1883
1904
|
if (search) {
|
|
1884
1905
|
query.$text = { $search: search };
|
|
1885
1906
|
cacheOptions.search = search;
|
|
@@ -2447,6 +2468,7 @@ function useAreaChecklistRepo() {
|
|
|
2447
2468
|
|
|
2448
2469
|
// src/services/hygiene-area-checklist.service.ts
|
|
2449
2470
|
function useAreaChecklistService() {
|
|
2471
|
+
const { getAreasForChecklist } = useAreaRepo();
|
|
2450
2472
|
const {
|
|
2451
2473
|
createAreaChecklist: _createAreaChecklist,
|
|
2452
2474
|
getAllAreaChecklist,
|
|
@@ -2455,7 +2477,6 @@ function useAreaChecklistService() {
|
|
|
2455
2477
|
completeAreaChecklistUnits: _completeAreaChecklistUnits,
|
|
2456
2478
|
updateAreaChecklistStatus
|
|
2457
2479
|
} = useAreaChecklistRepo();
|
|
2458
|
-
const { getAreasForChecklist } = useAreaRepo();
|
|
2459
2480
|
const { updateParentChecklistStatuses } = useParentChecklistRepo();
|
|
2460
2481
|
async function createAreaChecklist(value) {
|
|
2461
2482
|
const session = import_node_server_utils14.useAtlas.getClient()?.startSession();
|
|
@@ -2602,8 +2623,8 @@ function useAreaChecklistService() {
|
|
|
2602
2623
|
}
|
|
2603
2624
|
|
|
2604
2625
|
// src/controllers/hygiene-area-checklist.controller.ts
|
|
2605
|
-
var import_node_server_utils15 = require("@iservice365/node-server-utils");
|
|
2606
2626
|
var import_joi8 = __toESM(require("joi"));
|
|
2627
|
+
var import_node_server_utils15 = require("@iservice365/node-server-utils");
|
|
2607
2628
|
function useAreaChecklistController() {
|
|
2608
2629
|
const {
|
|
2609
2630
|
getAllAreaChecklist: _getAllAreaChecklist,
|
|
@@ -2646,7 +2667,8 @@ function useAreaChecklistController() {
|
|
|
2646
2667
|
page: import_joi8.default.number().min(1).optional().allow("", null),
|
|
2647
2668
|
limit: import_joi8.default.number().min(1).optional().allow("", null),
|
|
2648
2669
|
search: import_joi8.default.string().optional().allow("", null),
|
|
2649
|
-
type: import_joi8.default.string().optional().allow("",
|
|
2670
|
+
type: import_joi8.default.string().valid(...allowedTypes, "all").optional().allow("", null),
|
|
2671
|
+
status: import_joi8.default.string().valid(...allowedStatus, "all").optional().allow("", null),
|
|
2650
2672
|
schedule: import_joi8.default.string().hex().required()
|
|
2651
2673
|
});
|
|
2652
2674
|
const { error } = validation.validate(query);
|
|
@@ -2658,7 +2680,8 @@ function useAreaChecklistController() {
|
|
|
2658
2680
|
const page = parseInt(req.query.page) ?? 1;
|
|
2659
2681
|
const limit = parseInt(req.query.limit) ?? 10;
|
|
2660
2682
|
const search = req.query.search ?? "";
|
|
2661
|
-
const type = req.query.type ?? "";
|
|
2683
|
+
const type = req.query.type ?? "all";
|
|
2684
|
+
const status = req.query.status ?? "all";
|
|
2662
2685
|
const schedule = req.params.schedule ?? "";
|
|
2663
2686
|
try {
|
|
2664
2687
|
const data = await _getAllAreaChecklist({
|
|
@@ -2666,6 +2689,7 @@ function useAreaChecklistController() {
|
|
|
2666
2689
|
limit,
|
|
2667
2690
|
search,
|
|
2668
2691
|
type,
|
|
2692
|
+
status,
|
|
2669
2693
|
schedule
|
|
2670
2694
|
});
|
|
2671
2695
|
res.json(data);
|
|
@@ -2821,9 +2845,9 @@ function useAreaChecklistController() {
|
|
|
2821
2845
|
}
|
|
2822
2846
|
|
|
2823
2847
|
// src/models/hygiene-supply.model.ts
|
|
2824
|
-
var import_node_server_utils16 = require("@iservice365/node-server-utils");
|
|
2825
2848
|
var import_joi9 = __toESM(require("joi"));
|
|
2826
2849
|
var import_mongodb9 = require("mongodb");
|
|
2850
|
+
var import_node_server_utils16 = require("@iservice365/node-server-utils");
|
|
2827
2851
|
var supplySchema = import_joi9.default.object({
|
|
2828
2852
|
site: import_joi9.default.string().hex().required(),
|
|
2829
2853
|
name: import_joi9.default.string().required(),
|
|
@@ -3098,8 +3122,8 @@ function useSupplyRepository() {
|
|
|
3098
3122
|
}
|
|
3099
3123
|
|
|
3100
3124
|
// src/controllers/hygiene-supply.controller.ts
|
|
3101
|
-
var import_node_server_utils18 = require("@iservice365/node-server-utils");
|
|
3102
3125
|
var import_joi10 = __toESM(require("joi"));
|
|
3126
|
+
var import_node_server_utils18 = require("@iservice365/node-server-utils");
|
|
3103
3127
|
function useSupplyController() {
|
|
3104
3128
|
const {
|
|
3105
3129
|
createSupply: _createSupply,
|
|
@@ -3234,9 +3258,9 @@ function useSupplyController() {
|
|
|
3234
3258
|
}
|
|
3235
3259
|
|
|
3236
3260
|
// src/models/hygiene-stock.model.ts
|
|
3237
|
-
var import_node_server_utils19 = require("@iservice365/node-server-utils");
|
|
3238
3261
|
var import_joi11 = __toESM(require("joi"));
|
|
3239
3262
|
var import_mongodb11 = require("mongodb");
|
|
3263
|
+
var import_node_server_utils19 = require("@iservice365/node-server-utils");
|
|
3240
3264
|
var stockSchema = import_joi11.default.object({
|
|
3241
3265
|
site: import_joi11.default.string().hex().required(),
|
|
3242
3266
|
supply: import_joi11.default.string().hex().required(),
|
|
@@ -3445,8 +3469,8 @@ function useStockService() {
|
|
|
3445
3469
|
}
|
|
3446
3470
|
|
|
3447
3471
|
// src/controllers/hygiene-stock.controller.ts
|
|
3448
|
-
var import_node_server_utils22 = require("@iservice365/node-server-utils");
|
|
3449
3472
|
var import_joi12 = __toESM(require("joi"));
|
|
3473
|
+
var import_node_server_utils22 = require("@iservice365/node-server-utils");
|
|
3450
3474
|
function useStockController() {
|
|
3451
3475
|
const { getStocksBySupplyId: _getStocksBySupplyId } = useStockRepository();
|
|
3452
3476
|
const { createStock: _createStock } = useStockService();
|
|
@@ -3517,9 +3541,9 @@ function useStockController() {
|
|
|
3517
3541
|
}
|
|
3518
3542
|
|
|
3519
3543
|
// src/models/hygiene-request-item.model.ts
|
|
3520
|
-
var import_node_server_utils23 = require("@iservice365/node-server-utils");
|
|
3521
3544
|
var import_joi13 = __toESM(require("joi"));
|
|
3522
3545
|
var import_mongodb13 = require("mongodb");
|
|
3546
|
+
var import_node_server_utils23 = require("@iservice365/node-server-utils");
|
|
3523
3547
|
var allowedRequestItemStatus = [
|
|
3524
3548
|
"pending",
|
|
3525
3549
|
"approved",
|
|
@@ -3654,6 +3678,7 @@ function useRequestItemRepository() {
|
|
|
3654
3678
|
{ $match: query },
|
|
3655
3679
|
{
|
|
3656
3680
|
$project: {
|
|
3681
|
+
supplyName: 1,
|
|
3657
3682
|
createdAt: 1,
|
|
3658
3683
|
status: 1
|
|
3659
3684
|
}
|
|
@@ -3812,8 +3837,8 @@ function useRequestItemRepository() {
|
|
|
3812
3837
|
}
|
|
3813
3838
|
|
|
3814
3839
|
// src/services/hygiene-request-item.service.ts
|
|
3815
|
-
var import_node_server_utils25 = require("@iservice365/node-server-utils");
|
|
3816
3840
|
var import_core = require("@iservice365/core");
|
|
3841
|
+
var import_node_server_utils25 = require("@iservice365/node-server-utils");
|
|
3817
3842
|
function useRequestItemService() {
|
|
3818
3843
|
const {
|
|
3819
3844
|
createRequestItem: _createRequestItem,
|
|
@@ -3928,8 +3953,8 @@ function useRequestItemService() {
|
|
|
3928
3953
|
}
|
|
3929
3954
|
|
|
3930
3955
|
// src/controllers/hygiene-request-item.controller.ts
|
|
3931
|
-
var import_node_server_utils26 = require("@iservice365/node-server-utils");
|
|
3932
3956
|
var import_joi14 = __toESM(require("joi"));
|
|
3957
|
+
var import_node_server_utils26 = require("@iservice365/node-server-utils");
|
|
3933
3958
|
function useRequestItemController() {
|
|
3934
3959
|
const {
|
|
3935
3960
|
getRequestItems: _getRequestItems,
|
|
@@ -4496,9 +4521,9 @@ function useScheduleTaskRepository() {
|
|
|
4496
4521
|
// src/services/hygiene-schedule-task.service.ts
|
|
4497
4522
|
var import_node_server_utils29 = require("@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
|
-
var import_node_server_utils30 = require("@iservice365/node-server-utils");
|
|
4690
4714
|
var import_joi16 = __toESM(require("joi"));
|
|
4715
|
+
var import_node_server_utils30 = require("@iservice365/node-server-utils");
|
|
4691
4716
|
function useScheduleTaskController() {
|
|
4692
4717
|
const {
|
|
4693
4718
|
createScheduleTask: _createScheduleTask,
|