@7365admin1/module-hygiene 4.30.3 → 4.32.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 +16 -0
- package/dist/index.d.ts +42 -10
- package/dist/index.js +692 -291
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +692 -291
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/test/escape-regex.util.test.mjs +26 -0
- package/test/schedule-followups.test.mjs +24 -0
- package/test/schedule-task-rules.test.mjs +185 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @7365admin1/module-hygiene
|
|
2
2
|
|
|
3
|
+
## 4.32.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 8b89acd: Extra-visit sets now store `scheduleTaskId`, `scheduleTaskTitle` and `scheduleTaskTime`, returned by the area-checklist unit/set responses (null on older sets). The history PDF marks not-done items "Missed".
|
|
8
|
+
|
|
9
|
+
## 4.31.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- e4374ee: Schedule tasks can repeat (daily, weekdays, weekly on chosen days, monthly), have an end date and be paused. Older tasks (picked dates only) behave exactly as before. List and detail rows add nextRun, lastRun, lastRunStatus and scheduleStatus plus the stored time, dates and repeat fields. A visit whose minute was missed by a restart still runs later the same day, once (run marker lastRunDate). The runner returns the visits it added (`fired`) so the API can notify staff. An extra visit added before the daily list exists no longer cancels the area's regular visits. Create and update check the form in plain English (required fields, time format, start before end, no schedule that can never run).
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 1c84370: Search boxes match the typed text literally instead of running it as a regular expression.
|
|
18
|
+
|
|
3
19
|
## 4.30.3
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -281,6 +281,8 @@ type TAreaChecklist = {
|
|
|
281
281
|
attachment?: string[];
|
|
282
282
|
isScheduleTask?: boolean;
|
|
283
283
|
scheduleTaskId?: string | ObjectId;
|
|
284
|
+
scheduleTaskTitle?: string;
|
|
285
|
+
scheduleTaskTime?: string;
|
|
284
286
|
};
|
|
285
287
|
type TAreaChecklistUnits = {
|
|
286
288
|
unit: string | ObjectId;
|
|
@@ -641,6 +643,17 @@ declare function useCheckOutItemController(): {
|
|
|
641
643
|
decideCheckOutItem: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
642
644
|
};
|
|
643
645
|
|
|
646
|
+
/**
|
|
647
|
+
* Schedule task rules: repeat, end date, paused, "when does it run next".
|
|
648
|
+
* Pure (no database, no core import) so every rule is unit-testable.
|
|
649
|
+
*
|
|
650
|
+
* A task with none of `repeat` / `startDate` / `endDate` / `paused` behaves
|
|
651
|
+
* exactly as before: it runs on the dates listed in `dates`, at `time`.
|
|
652
|
+
* All times are Singapore time (UTC+8, no daylight saving).
|
|
653
|
+
*/
|
|
654
|
+
declare const REPEATS: readonly ["none", "daily", "weekdays", "weekly", "monthly"];
|
|
655
|
+
type TRepeat = (typeof REPEATS)[number];
|
|
656
|
+
|
|
644
657
|
type TScheduleTask = {
|
|
645
658
|
_id?: ObjectId;
|
|
646
659
|
site: string | ObjectId;
|
|
@@ -653,21 +666,32 @@ type TScheduleTask = {
|
|
|
653
666
|
name: string;
|
|
654
667
|
value: ObjectId;
|
|
655
668
|
}[];
|
|
669
|
+
repeat?: TRepeat;
|
|
670
|
+
daysOfWeek?: number[];
|
|
671
|
+
dayOfMonth?: number;
|
|
672
|
+
startDate?: string;
|
|
673
|
+
endDate?: string;
|
|
674
|
+
paused?: boolean;
|
|
675
|
+
lastRunDate?: string;
|
|
656
676
|
status?: "active" | "deleted";
|
|
657
677
|
createdAt?: string | Date;
|
|
658
678
|
updatedAt?: string | Date;
|
|
659
679
|
deletedAt?: string | Date;
|
|
660
680
|
};
|
|
661
|
-
type TScheduleTaskCreate = Pick<TScheduleTask, "site" | "serviceType" | "title" | "time" | "dates" | "description" | "areas">;
|
|
681
|
+
type TScheduleTaskCreate = Pick<TScheduleTask, "site" | "serviceType" | "title" | "time" | "dates" | "description" | "areas" | "repeat" | "daysOfWeek" | "dayOfMonth" | "startDate" | "endDate" | "paused">;
|
|
662
682
|
type TScheduleTaskGetQuery = {
|
|
663
683
|
page?: number;
|
|
664
684
|
limit?: number;
|
|
665
685
|
search?: string;
|
|
666
686
|
} & Pick<TScheduleTask, "site" | "serviceType">;
|
|
667
|
-
type TScheduleTaskGetById = Pick<TScheduleTask, "title" | "time" | "dates" | "description" | "areas" | "status" | "createdAt">;
|
|
668
|
-
type TScheduleTaskUpdate = Partial<Pick<TScheduleTask, "title" | "time" | "dates" | "description" | "areas">>;
|
|
687
|
+
type TScheduleTaskGetById = Pick<TScheduleTask, "title" | "time" | "dates" | "description" | "areas" | "status" | "createdAt" | "repeat" | "daysOfWeek" | "dayOfMonth" | "startDate" | "endDate" | "paused" | "lastRunDate">;
|
|
688
|
+
type TScheduleTaskUpdate = Partial<Pick<TScheduleTask, "title" | "time" | "dates" | "description" | "areas" | "repeat" | "daysOfWeek" | "dayOfMonth" | "startDate" | "endDate" | "paused">>;
|
|
669
689
|
declare const scheduleTaskSchema: Joi.ObjectSchema<any>;
|
|
670
690
|
declare function MScheduleTask(value: TScheduleTaskCreate): {
|
|
691
|
+
status: string;
|
|
692
|
+
createdAt: Date;
|
|
693
|
+
updatedAt: string;
|
|
694
|
+
deletedAt: string;
|
|
671
695
|
site: string | ObjectId;
|
|
672
696
|
serviceType: AppServiceType;
|
|
673
697
|
title: string;
|
|
@@ -678,33 +702,41 @@ declare function MScheduleTask(value: TScheduleTaskCreate): {
|
|
|
678
702
|
name: string;
|
|
679
703
|
value: ObjectId;
|
|
680
704
|
}[];
|
|
681
|
-
status: string;
|
|
682
|
-
createdAt: Date;
|
|
683
|
-
updatedAt: string;
|
|
684
|
-
deletedAt: string;
|
|
685
705
|
};
|
|
686
706
|
|
|
687
707
|
declare function useScheduleTaskRepository(): {
|
|
688
708
|
createIndex: () => Promise<void>;
|
|
689
709
|
createTextIndex: () => Promise<void>;
|
|
690
710
|
createScheduleTask: (value: TScheduleTaskCreate, session?: ClientSession) => Promise<ObjectId>;
|
|
691
|
-
getScheduleTasks: ({ page, limit, search, site, serviceType, }: TScheduleTaskGetQuery) => Promise<
|
|
692
|
-
getAllScheduleTask: () => Promise<TScheduleTask[]>;
|
|
711
|
+
getScheduleTasks: ({ page, limit, search, site, serviceType, }: TScheduleTaskGetQuery) => Promise<any>;
|
|
712
|
+
getAllScheduleTask: (today?: string) => Promise<TScheduleTask[]>;
|
|
713
|
+
markScheduleTaskRan: (_id: string | ObjectId, date: string) => Promise<void>;
|
|
693
714
|
getScheduleTaskById: (_id: string | ObjectId, session?: ClientSession) => Promise<TScheduleTaskGetById>;
|
|
694
715
|
updateScheduleTask: (_id: string | ObjectId, value: TScheduleTaskUpdate, session?: ClientSession) => Promise<number>;
|
|
695
716
|
deleteScheduleTask: (_id: string | ObjectId, session?: ClientSession) => Promise<number>;
|
|
696
717
|
};
|
|
697
718
|
|
|
719
|
+
/** An extra visit that was just added to today's list (for the caller to notify staff). */
|
|
720
|
+
type TFiredScheduleTask = {
|
|
721
|
+
_id: ObjectId;
|
|
722
|
+
site: string | ObjectId;
|
|
723
|
+
serviceType: TAppServiceType;
|
|
724
|
+
title: string;
|
|
725
|
+
time: string;
|
|
726
|
+
areas: string[];
|
|
727
|
+
};
|
|
698
728
|
declare function useScheduleTaskService(): {
|
|
699
729
|
checkScheduleConditions: (schedule: any, serviceType: TAppServiceType, currentDate?: Date) => boolean;
|
|
700
730
|
processScheduledTasks: (currentDate?: Date) => Promise<{
|
|
701
731
|
processed: number;
|
|
702
732
|
validated: number;
|
|
733
|
+
fired: TFiredScheduleTask[];
|
|
703
734
|
tasks?: undefined;
|
|
704
735
|
} | {
|
|
705
736
|
processed: number;
|
|
706
737
|
validated: number;
|
|
707
738
|
tasks: TScheduleTask[];
|
|
739
|
+
fired: TFiredScheduleTask[];
|
|
708
740
|
}>;
|
|
709
741
|
};
|
|
710
742
|
|
|
@@ -725,4 +757,4 @@ declare function useQRController(): {
|
|
|
725
757
|
generateQR: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
726
758
|
};
|
|
727
759
|
|
|
728
|
-
export { CHECKOUT_DECIDABLE_STATUS, CHECKOUT_DECISIONS, MArea, MAreaChecklist, MCheckOutItem, MParentChecklist, MScheduleTask, MStock, MSupply, MUnit, TArea, TAreaChecklist, TAreaChecklistBatchCreate, TAreaChecklistCreate, TAreaChecklistUnits, TAreaChecklistUnitsUpdate, TAreaChecklistUpdate, TAreaCreate, TAreaGetQuery, TAreaUnits, TAreaUpdate, TAreaUpdateChecklist, TCheckOutDecision, TCheckOutItem, TCheckOutItemCreate, TCheckOutItemCreateByBatchService, TCheckOutItemCreateService, TCheckOutItemDecision, TCheckOutItemGetById, TCheckOutItemGetQuery, TCleaningScheduleArea, TCleaningScheduleAreaGetQuery, TGetStocksQuery, TParentChecklist, TParentChecklistCreate, TParentChecklistGetQuery, TScheduleTask, TScheduleTaskCreate, TScheduleTaskGetById, TScheduleTaskGetQuery, TScheduleTaskUpdate, TStock, TStockCreate, TStockCreateService, TSupply, TSupplyCreate, TSupplyGetById, TSupplyGetQuery, TSupplyUpdate, TUnit, TUnitCreate, TUnitGetQuery, TUnitUpdate, allowedCheckOutItemStatus, allowedChecklistStatus, allowedPeriods, allowedStatus, allowedTypes, applyCheckOutDecision, areaChecklistSchema, areaSchema, buildCheckOutDecision, checkOutItemSchema, isCheckOutDecision, parentChecklistSchema, scheduleTaskSchema, stockSchema, supplySchema, unitSchema, useAreaChecklistController, useAreaChecklistRepo, useAreaChecklistService, useAreaController, useAreaExportService, useAreaRepo, useAreaService, useCheckOutItemController, useCheckOutItemRepository, useCheckOutItemService, useHygieneDashboardController, useHygieneDashboardRepository, useParentChecklistController, useParentChecklistRepo, useQRController, useQRService, useScheduleTaskController, useScheduleTaskRepository, useScheduleTaskService, useStockController, useStockRepository, useStockService, useSupplyController, useSupplyRepository, useUnitController, useUnitExportService, useUnitRepository, useUnitService };
|
|
760
|
+
export { CHECKOUT_DECIDABLE_STATUS, CHECKOUT_DECISIONS, MArea, MAreaChecklist, MCheckOutItem, MParentChecklist, MScheduleTask, MStock, MSupply, MUnit, TArea, TAreaChecklist, TAreaChecklistBatchCreate, TAreaChecklistCreate, TAreaChecklistUnits, TAreaChecklistUnitsUpdate, TAreaChecklistUpdate, TAreaCreate, TAreaGetQuery, TAreaUnits, TAreaUpdate, TAreaUpdateChecklist, TCheckOutDecision, TCheckOutItem, TCheckOutItemCreate, TCheckOutItemCreateByBatchService, TCheckOutItemCreateService, TCheckOutItemDecision, TCheckOutItemGetById, TCheckOutItemGetQuery, TCleaningScheduleArea, TCleaningScheduleAreaGetQuery, TFiredScheduleTask, TGetStocksQuery, TParentChecklist, TParentChecklistCreate, TParentChecklistGetQuery, TScheduleTask, TScheduleTaskCreate, TScheduleTaskGetById, TScheduleTaskGetQuery, TScheduleTaskUpdate, TStock, TStockCreate, TStockCreateService, TSupply, TSupplyCreate, TSupplyGetById, TSupplyGetQuery, TSupplyUpdate, TUnit, TUnitCreate, TUnitGetQuery, TUnitUpdate, allowedCheckOutItemStatus, allowedChecklistStatus, allowedPeriods, allowedStatus, allowedTypes, applyCheckOutDecision, areaChecklistSchema, areaSchema, buildCheckOutDecision, checkOutItemSchema, isCheckOutDecision, parentChecklistSchema, scheduleTaskSchema, stockSchema, supplySchema, unitSchema, useAreaChecklistController, useAreaChecklistRepo, useAreaChecklistService, useAreaController, useAreaExportService, useAreaRepo, useAreaService, useCheckOutItemController, useCheckOutItemRepository, useCheckOutItemService, useHygieneDashboardController, useHygieneDashboardRepository, useParentChecklistController, useParentChecklistRepo, useQRController, useQRService, useScheduleTaskController, useScheduleTaskRepository, useScheduleTaskService, useStockController, useStockRepository, useStockService, useSupplyController, useSupplyRepository, useUnitController, useUnitExportService, useUnitRepository, useUnitService };
|