@iservice365/module-hygiene 1.5.1 → 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 +6 -0
- package/dist/index.d.ts +30 -27
- package/dist/index.js +31 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -7
- 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
|
@@ -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;
|
|
@@ -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);
|
|
@@ -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) {
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -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);
|