@7365admin1/module-hygiene 4.30.3 → 4.31.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 +10 -0
- package/dist/index.d.ts +40 -10
- package/dist/index.js +647 -270
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +647 -270
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/test/escape-regex.util.test.mjs +26 -0
- package/test/schedule-task-rules.test.mjs +185 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @7365admin1/module-hygiene
|
|
2
2
|
|
|
3
|
+
## 4.31.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 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).
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 1c84370: Search boxes match the typed text literally instead of running it as a regular expression.
|
|
12
|
+
|
|
3
13
|
## 4.30.3
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -641,6 +641,17 @@ declare function useCheckOutItemController(): {
|
|
|
641
641
|
decideCheckOutItem: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
642
642
|
};
|
|
643
643
|
|
|
644
|
+
/**
|
|
645
|
+
* Schedule task rules: repeat, end date, paused, "when does it run next".
|
|
646
|
+
* Pure (no database, no core import) so every rule is unit-testable.
|
|
647
|
+
*
|
|
648
|
+
* A task with none of `repeat` / `startDate` / `endDate` / `paused` behaves
|
|
649
|
+
* exactly as before: it runs on the dates listed in `dates`, at `time`.
|
|
650
|
+
* All times are Singapore time (UTC+8, no daylight saving).
|
|
651
|
+
*/
|
|
652
|
+
declare const REPEATS: readonly ["none", "daily", "weekdays", "weekly", "monthly"];
|
|
653
|
+
type TRepeat = (typeof REPEATS)[number];
|
|
654
|
+
|
|
644
655
|
type TScheduleTask = {
|
|
645
656
|
_id?: ObjectId;
|
|
646
657
|
site: string | ObjectId;
|
|
@@ -653,21 +664,32 @@ type TScheduleTask = {
|
|
|
653
664
|
name: string;
|
|
654
665
|
value: ObjectId;
|
|
655
666
|
}[];
|
|
667
|
+
repeat?: TRepeat;
|
|
668
|
+
daysOfWeek?: number[];
|
|
669
|
+
dayOfMonth?: number;
|
|
670
|
+
startDate?: string;
|
|
671
|
+
endDate?: string;
|
|
672
|
+
paused?: boolean;
|
|
673
|
+
lastRunDate?: string;
|
|
656
674
|
status?: "active" | "deleted";
|
|
657
675
|
createdAt?: string | Date;
|
|
658
676
|
updatedAt?: string | Date;
|
|
659
677
|
deletedAt?: string | Date;
|
|
660
678
|
};
|
|
661
|
-
type TScheduleTaskCreate = Pick<TScheduleTask, "site" | "serviceType" | "title" | "time" | "dates" | "description" | "areas">;
|
|
679
|
+
type TScheduleTaskCreate = Pick<TScheduleTask, "site" | "serviceType" | "title" | "time" | "dates" | "description" | "areas" | "repeat" | "daysOfWeek" | "dayOfMonth" | "startDate" | "endDate" | "paused">;
|
|
662
680
|
type TScheduleTaskGetQuery = {
|
|
663
681
|
page?: number;
|
|
664
682
|
limit?: number;
|
|
665
683
|
search?: string;
|
|
666
684
|
} & 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">>;
|
|
685
|
+
type TScheduleTaskGetById = Pick<TScheduleTask, "title" | "time" | "dates" | "description" | "areas" | "status" | "createdAt" | "repeat" | "daysOfWeek" | "dayOfMonth" | "startDate" | "endDate" | "paused" | "lastRunDate">;
|
|
686
|
+
type TScheduleTaskUpdate = Partial<Pick<TScheduleTask, "title" | "time" | "dates" | "description" | "areas" | "repeat" | "daysOfWeek" | "dayOfMonth" | "startDate" | "endDate" | "paused">>;
|
|
669
687
|
declare const scheduleTaskSchema: Joi.ObjectSchema<any>;
|
|
670
688
|
declare function MScheduleTask(value: TScheduleTaskCreate): {
|
|
689
|
+
status: string;
|
|
690
|
+
createdAt: Date;
|
|
691
|
+
updatedAt: string;
|
|
692
|
+
deletedAt: string;
|
|
671
693
|
site: string | ObjectId;
|
|
672
694
|
serviceType: AppServiceType;
|
|
673
695
|
title: string;
|
|
@@ -678,33 +700,41 @@ declare function MScheduleTask(value: TScheduleTaskCreate): {
|
|
|
678
700
|
name: string;
|
|
679
701
|
value: ObjectId;
|
|
680
702
|
}[];
|
|
681
|
-
status: string;
|
|
682
|
-
createdAt: Date;
|
|
683
|
-
updatedAt: string;
|
|
684
|
-
deletedAt: string;
|
|
685
703
|
};
|
|
686
704
|
|
|
687
705
|
declare function useScheduleTaskRepository(): {
|
|
688
706
|
createIndex: () => Promise<void>;
|
|
689
707
|
createTextIndex: () => Promise<void>;
|
|
690
708
|
createScheduleTask: (value: TScheduleTaskCreate, session?: ClientSession) => Promise<ObjectId>;
|
|
691
|
-
getScheduleTasks: ({ page, limit, search, site, serviceType, }: TScheduleTaskGetQuery) => Promise<
|
|
692
|
-
getAllScheduleTask: () => Promise<TScheduleTask[]>;
|
|
709
|
+
getScheduleTasks: ({ page, limit, search, site, serviceType, }: TScheduleTaskGetQuery) => Promise<any>;
|
|
710
|
+
getAllScheduleTask: (today?: string) => Promise<TScheduleTask[]>;
|
|
711
|
+
markScheduleTaskRan: (_id: string | ObjectId, date: string) => Promise<void>;
|
|
693
712
|
getScheduleTaskById: (_id: string | ObjectId, session?: ClientSession) => Promise<TScheduleTaskGetById>;
|
|
694
713
|
updateScheduleTask: (_id: string | ObjectId, value: TScheduleTaskUpdate, session?: ClientSession) => Promise<number>;
|
|
695
714
|
deleteScheduleTask: (_id: string | ObjectId, session?: ClientSession) => Promise<number>;
|
|
696
715
|
};
|
|
697
716
|
|
|
717
|
+
/** An extra visit that was just added to today's list (for the caller to notify staff). */
|
|
718
|
+
type TFiredScheduleTask = {
|
|
719
|
+
_id: ObjectId;
|
|
720
|
+
site: string | ObjectId;
|
|
721
|
+
serviceType: TAppServiceType;
|
|
722
|
+
title: string;
|
|
723
|
+
time: string;
|
|
724
|
+
areas: string[];
|
|
725
|
+
};
|
|
698
726
|
declare function useScheduleTaskService(): {
|
|
699
727
|
checkScheduleConditions: (schedule: any, serviceType: TAppServiceType, currentDate?: Date) => boolean;
|
|
700
728
|
processScheduledTasks: (currentDate?: Date) => Promise<{
|
|
701
729
|
processed: number;
|
|
702
730
|
validated: number;
|
|
731
|
+
fired: TFiredScheduleTask[];
|
|
703
732
|
tasks?: undefined;
|
|
704
733
|
} | {
|
|
705
734
|
processed: number;
|
|
706
735
|
validated: number;
|
|
707
736
|
tasks: TScheduleTask[];
|
|
737
|
+
fired: TFiredScheduleTask[];
|
|
708
738
|
}>;
|
|
709
739
|
};
|
|
710
740
|
|
|
@@ -725,4 +755,4 @@ declare function useQRController(): {
|
|
|
725
755
|
generateQR: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
726
756
|
};
|
|
727
757
|
|
|
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 };
|
|
758
|
+
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 };
|