@7365admin1/module-hygiene 4.15.0 → 4.16.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 +20 -18
- package/dist/index.js +34 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -24
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -135,19 +135,19 @@ type TUnit = {
|
|
|
135
135
|
status?: "active" | "deleted";
|
|
136
136
|
};
|
|
137
137
|
type TUnitCreate = {
|
|
138
|
-
serviceType
|
|
138
|
+
serviceType: TServiceType;
|
|
139
139
|
} & Pick<TUnit, "site" | "name">;
|
|
140
140
|
type TUnitGetQuery = {
|
|
141
141
|
page?: number;
|
|
142
142
|
limit?: number;
|
|
143
143
|
search?: string;
|
|
144
|
-
serviceType
|
|
144
|
+
serviceType: TServiceType;
|
|
145
145
|
} & Pick<TUnit, "site">;
|
|
146
146
|
type TUnitUpdate = Pick<TUnit, "name">;
|
|
147
147
|
declare const unitSchema: Joi.ObjectSchema<any>;
|
|
148
148
|
declare function MUnit(value: TUnitCreate): {
|
|
149
149
|
site: string | ObjectId;
|
|
150
|
-
serviceType: ServiceType
|
|
150
|
+
serviceType: ServiceType;
|
|
151
151
|
name: string;
|
|
152
152
|
status: string;
|
|
153
153
|
createdAt: Date;
|
|
@@ -159,7 +159,7 @@ declare function useUnitService(): {
|
|
|
159
159
|
importUnit: ({ dataJson, site, serviceType, }: {
|
|
160
160
|
dataJson: string;
|
|
161
161
|
site: string | ObjectId;
|
|
162
|
-
serviceType
|
|
162
|
+
serviceType: TServiceType;
|
|
163
163
|
}) => Promise<{
|
|
164
164
|
message: string;
|
|
165
165
|
}>;
|
|
@@ -167,7 +167,7 @@ declare function useUnitService(): {
|
|
|
167
167
|
deleteUnit: (_id: string | ObjectId) => Promise<number>;
|
|
168
168
|
exportUnits: ({ site, serviceType, }: {
|
|
169
169
|
site: string | ObjectId;
|
|
170
|
-
serviceType
|
|
170
|
+
serviceType: TServiceType;
|
|
171
171
|
}) => Promise<Buffer>;
|
|
172
172
|
};
|
|
173
173
|
|
|
@@ -192,12 +192,16 @@ declare function useUnitController(): {
|
|
|
192
192
|
|
|
193
193
|
type TParentChecklist = {
|
|
194
194
|
_id?: ObjectId;
|
|
195
|
-
site
|
|
196
|
-
serviceType
|
|
195
|
+
site: string | ObjectId;
|
|
196
|
+
serviceType: TServiceType;
|
|
197
197
|
status?: (typeof allowedStatus)[number];
|
|
198
198
|
createdAt?: Date | string;
|
|
199
199
|
updatedAt?: Date | string;
|
|
200
200
|
};
|
|
201
|
+
type TParentChecklistCreate = {
|
|
202
|
+
site?: string | ObjectId;
|
|
203
|
+
serviceType?: TServiceType;
|
|
204
|
+
} & Pick<TParentChecklist, "createdAt">;
|
|
201
205
|
type TParentChecklistGetQuery = {
|
|
202
206
|
site: string | ObjectId;
|
|
203
207
|
serviceType: TServiceType;
|
|
@@ -209,8 +213,8 @@ type TParentChecklistGetQuery = {
|
|
|
209
213
|
} & Pick<TParentChecklist, "status">;
|
|
210
214
|
declare const parentChecklistSchema: Joi.ObjectSchema<any>;
|
|
211
215
|
declare function MParentChecklist(value: TParentChecklist): {
|
|
212
|
-
site: string | ObjectId
|
|
213
|
-
serviceType: ServiceType
|
|
216
|
+
site: string | ObjectId;
|
|
217
|
+
serviceType: ServiceType;
|
|
214
218
|
status: string;
|
|
215
219
|
createdAt: string | Date;
|
|
216
220
|
updatedAt: string | Date;
|
|
@@ -218,12 +222,13 @@ declare function MParentChecklist(value: TParentChecklist): {
|
|
|
218
222
|
|
|
219
223
|
declare function useParentChecklistRepo(): {
|
|
220
224
|
createIndex: () => Promise<void>;
|
|
221
|
-
createParentChecklist: (value:
|
|
225
|
+
createParentChecklist: (value: TParentChecklistCreate, session?: ClientSession) => Promise<ObjectId | ObjectId[]>;
|
|
222
226
|
getAllParentChecklist: ({ page, limit, search, site, startDate, endDate, status, serviceType, }: TParentChecklistGetQuery) => Promise<{}>;
|
|
223
227
|
getParentChecklistById: (_id: string | ObjectId) => Promise<TParentChecklist & {
|
|
224
228
|
_id: ObjectId;
|
|
225
229
|
}>;
|
|
226
230
|
updateParentChecklistStatuses: (_id: string | ObjectId, status: (typeof allowedStatus)[number], session?: ClientSession) => Promise<number>;
|
|
231
|
+
getHygieneSiteIds: () => Promise<any[]>;
|
|
227
232
|
closeExpiredParentChecklists: () => Promise<number>;
|
|
228
233
|
getTodayParentChecklists: () => Promise<{
|
|
229
234
|
_id: ObjectId;
|
|
@@ -274,9 +279,7 @@ type TAreaChecklistUnits = {
|
|
|
274
279
|
completedBy?: string | ObjectId;
|
|
275
280
|
timestamp?: Date | string;
|
|
276
281
|
};
|
|
277
|
-
type TAreaChecklistCreate = Pick<TCleaningScheduleArea, "schedule" | "area" | "name" | "type" | "checklist" | "createdBy"
|
|
278
|
-
serviceType: TServiceType;
|
|
279
|
-
};
|
|
282
|
+
type TAreaChecklistCreate = Pick<TCleaningScheduleArea, "schedule" | "serviceType" | "area" | "name" | "type" | "checklist" | "createdBy">;
|
|
280
283
|
type TAreaChecklistBatchCreate = Pick<TCleaningScheduleArea, "schedule" | "createdBy"> & {
|
|
281
284
|
site: string | ObjectId;
|
|
282
285
|
};
|
|
@@ -284,10 +287,9 @@ type TCleaningScheduleAreaGetQuery = {
|
|
|
284
287
|
page?: number;
|
|
285
288
|
limit?: number;
|
|
286
289
|
search?: string;
|
|
287
|
-
serviceType?: TServiceType;
|
|
288
290
|
type?: (typeof allowedTypes)[number] | "all";
|
|
289
291
|
status?: (typeof allowedStatus)[number] | "all";
|
|
290
|
-
} & Pick<TCleaningScheduleArea, "schedule">;
|
|
292
|
+
} & Pick<TCleaningScheduleArea, "schedule" | "serviceType">;
|
|
291
293
|
type TAreaChecklistUpdate = Pick<TCleaningScheduleArea, "checklist">;
|
|
292
294
|
type TAreaChecklistUnitsUpdate = Pick<TAreaChecklistUnits, "approve" | "reject" | "remarks" | "completedBy"> & Pick<TAreaChecklist, "attachment">;
|
|
293
295
|
declare const areaChecklistSchema: Joi.ObjectSchema<any>;
|
|
@@ -359,13 +361,13 @@ declare function useAreaChecklistRepo(): {
|
|
|
359
361
|
page?: number | undefined;
|
|
360
362
|
limit?: number | undefined;
|
|
361
363
|
search?: string | undefined;
|
|
362
|
-
serviceType
|
|
364
|
+
serviceType: TServiceType;
|
|
363
365
|
_id: string | ObjectId;
|
|
364
366
|
}, session?: ClientSession) => Promise<{}>;
|
|
365
367
|
getAreaChecklistById: (_id: string | ObjectId, session?: ClientSession) => Promise<mongodb.WithId<bson.Document>>;
|
|
366
368
|
getAreaChecklistByAreaAndSchedule: ({ schedule, serviceType, area, session, }: {
|
|
367
369
|
schedule: string | ObjectId;
|
|
368
|
-
serviceType
|
|
370
|
+
serviceType: TServiceType;
|
|
369
371
|
area: string | ObjectId;
|
|
370
372
|
session?: ClientSession | undefined;
|
|
371
373
|
}) => Promise<mongodb.WithId<bson.Document>>;
|
|
@@ -647,4 +649,4 @@ declare function useQRController(): {
|
|
|
647
649
|
generateQR: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
648
650
|
};
|
|
649
651
|
|
|
650
|
-
export { MArea, MAreaChecklist, MCheckOutItem, MParentChecklist, MScheduleTask, MStock, MSupply, MUnit, ServiceType, TArea, TAreaChecklist, TAreaChecklistBatchCreate, TAreaChecklistCreate, TAreaChecklistUnits, TAreaChecklistUnitsUpdate, TAreaChecklistUpdate, TAreaCreate, TAreaGetQuery, TAreaUnits, TAreaUpdate, TAreaUpdateChecklist, TCheckOutItem, TCheckOutItemCreate, TCheckOutItemCreateByBatchService, TCheckOutItemCreateService, TCheckOutItemGetById, TCheckOutItemGetQuery, TCleaningScheduleArea, TCleaningScheduleAreaGetQuery, TGetStocksQuery, TParentChecklist, TParentChecklistGetQuery, TScheduleTask, TScheduleTaskCreate, TScheduleTaskGetById, TScheduleTaskGetQuery, TScheduleTaskUpdate, TServiceType, TStock, TStockCreate, TStockCreateService, TSupply, TSupplyCreate, TSupplyGetById, TSupplyGetQuery, TSupplyUpdate, TUnit, TUnitCreate, TUnitGetQuery, TUnitUpdate, allowedCheckOutItemStatus, allowedChecklistStatus, allowedPeriods, allowedStatus, allowedTypes, areaChecklistSchema, areaSchema, checkOutItemSchema, 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 };
|
|
652
|
+
export { MArea, MAreaChecklist, MCheckOutItem, MParentChecklist, MScheduleTask, MStock, MSupply, MUnit, ServiceType, TArea, TAreaChecklist, TAreaChecklistBatchCreate, TAreaChecklistCreate, TAreaChecklistUnits, TAreaChecklistUnitsUpdate, TAreaChecklistUpdate, TAreaCreate, TAreaGetQuery, TAreaUnits, TAreaUpdate, TAreaUpdateChecklist, TCheckOutItem, TCheckOutItemCreate, TCheckOutItemCreateByBatchService, TCheckOutItemCreateService, TCheckOutItemGetById, TCheckOutItemGetQuery, TCleaningScheduleArea, TCleaningScheduleAreaGetQuery, TGetStocksQuery, TParentChecklist, TParentChecklistCreate, TParentChecklistGetQuery, TScheduleTask, TScheduleTaskCreate, TScheduleTaskGetById, TScheduleTaskGetQuery, TScheduleTaskUpdate, TServiceType, TStock, TStockCreate, TStockCreateService, TSupply, TSupplyCreate, TSupplyGetById, TSupplyGetQuery, TSupplyUpdate, TUnit, TUnitCreate, TUnitGetQuery, TUnitUpdate, allowedCheckOutItemStatus, allowedChecklistStatus, allowedPeriods, allowedStatus, allowedTypes, areaChecklistSchema, areaSchema, checkOutItemSchema, 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 };
|
package/dist/index.js
CHANGED
|
@@ -1240,11 +1240,13 @@ function useUnitRepository() {
|
|
|
1240
1240
|
}) {
|
|
1241
1241
|
page = page > 0 ? page - 1 : 0;
|
|
1242
1242
|
const query = {
|
|
1243
|
-
status: { $ne: "deleted" }
|
|
1243
|
+
status: { $ne: "deleted" },
|
|
1244
|
+
serviceType
|
|
1244
1245
|
};
|
|
1245
1246
|
const cacheOptions = {
|
|
1246
1247
|
page,
|
|
1247
|
-
limit
|
|
1248
|
+
limit,
|
|
1249
|
+
serviceType
|
|
1248
1250
|
};
|
|
1249
1251
|
try {
|
|
1250
1252
|
site = new import_mongodb5.ObjectId(site);
|
|
@@ -1253,10 +1255,6 @@ function useUnitRepository() {
|
|
|
1253
1255
|
} catch (error) {
|
|
1254
1256
|
throw new import_node_server_utils7.BadRequestError("Invalid site ID format.");
|
|
1255
1257
|
}
|
|
1256
|
-
if (serviceType) {
|
|
1257
|
-
query.serviceType = serviceType;
|
|
1258
|
-
cacheOptions.serviceType = serviceType;
|
|
1259
|
-
}
|
|
1260
1258
|
if (search) {
|
|
1261
1259
|
query.$or = [{ name: { $regex: search, $options: "i" } }];
|
|
1262
1260
|
cacheOptions.search = search;
|
|
@@ -2678,6 +2676,7 @@ function useParentChecklistRepo() {
|
|
|
2678
2676
|
getAllParentChecklist,
|
|
2679
2677
|
getParentChecklistById,
|
|
2680
2678
|
updateParentChecklistStatuses,
|
|
2679
|
+
getHygieneSiteIds,
|
|
2681
2680
|
closeExpiredParentChecklists,
|
|
2682
2681
|
getTodayParentChecklists,
|
|
2683
2682
|
getTodayParentChecklistsForAreaGen
|
|
@@ -2694,7 +2693,12 @@ function useParentChecklistController() {
|
|
|
2694
2693
|
} = useParentChecklistRepo();
|
|
2695
2694
|
async function createParentChecklist(req, res, next) {
|
|
2696
2695
|
const payload = req.body;
|
|
2697
|
-
const
|
|
2696
|
+
const validation = import_joi7.default.object({
|
|
2697
|
+
createdAt: import_joi7.default.alternatives().try(import_joi7.default.date(), import_joi7.default.string()).optional().allow("", null),
|
|
2698
|
+
site: import_joi7.default.string().hex().required(),
|
|
2699
|
+
serviceType: import_joi7.default.string().valid(...Object.values(ServiceType)).optional().allow("", null)
|
|
2700
|
+
});
|
|
2701
|
+
const { error } = validation.validate(payload);
|
|
2698
2702
|
if (error) {
|
|
2699
2703
|
import_node_server_utils15.logger.log({ level: "error", message: error.message });
|
|
2700
2704
|
next(new import_node_server_utils15.BadRequestError(error.message));
|
|
@@ -2768,7 +2772,7 @@ var import_node_server_utils16 = require("@7365admin1/node-server-utils");
|
|
|
2768
2772
|
var allowedChecklistStatus = ["open", "completed", "closed"];
|
|
2769
2773
|
var areaChecklistSchema = import_joi8.default.object({
|
|
2770
2774
|
schedule: import_joi8.default.string().hex().required(),
|
|
2771
|
-
serviceType: import_joi8.default.string().valid(...Object.values(ServiceType)).
|
|
2775
|
+
serviceType: import_joi8.default.string().valid(...Object.values(ServiceType)).required(),
|
|
2772
2776
|
area: import_joi8.default.string().hex().required(),
|
|
2773
2777
|
name: import_joi8.default.string().required(),
|
|
2774
2778
|
type: import_joi8.default.string().valid(...allowedTypes).required(),
|
|
@@ -2949,10 +2953,11 @@ function useAreaChecklistRepo() {
|
|
|
2949
2953
|
serviceType
|
|
2950
2954
|
}, session) {
|
|
2951
2955
|
page = page > 0 ? page - 1 : 0;
|
|
2952
|
-
const query = {};
|
|
2956
|
+
const query = { serviceType };
|
|
2953
2957
|
const cacheOptions = {
|
|
2954
2958
|
page,
|
|
2955
|
-
limit
|
|
2959
|
+
limit,
|
|
2960
|
+
serviceType
|
|
2956
2961
|
};
|
|
2957
2962
|
try {
|
|
2958
2963
|
query.schedule = new import_mongodb9.ObjectId(schedule);
|
|
@@ -2960,10 +2965,6 @@ function useAreaChecklistRepo() {
|
|
|
2960
2965
|
} catch (error) {
|
|
2961
2966
|
throw new import_node_server_utils17.BadRequestError("Invalid parent checklist ID format.");
|
|
2962
2967
|
}
|
|
2963
|
-
if (serviceType) {
|
|
2964
|
-
query.serviceType = serviceType;
|
|
2965
|
-
cacheOptions.serviceType = serviceType;
|
|
2966
|
-
}
|
|
2967
2968
|
if (type && type !== "all") {
|
|
2968
2969
|
query.type = type;
|
|
2969
2970
|
cacheOptions.type = type;
|
|
@@ -3363,10 +3364,11 @@ function useAreaChecklistRepo() {
|
|
|
3363
3364
|
_id
|
|
3364
3365
|
}, session) {
|
|
3365
3366
|
page = page > 0 ? page - 1 : 0;
|
|
3366
|
-
const query = {};
|
|
3367
|
+
const query = { serviceType };
|
|
3367
3368
|
const cacheOptions = {
|
|
3368
3369
|
page,
|
|
3369
|
-
limit
|
|
3370
|
+
limit,
|
|
3371
|
+
serviceType
|
|
3370
3372
|
};
|
|
3371
3373
|
try {
|
|
3372
3374
|
query._id = new import_mongodb9.ObjectId(_id);
|
|
@@ -3374,10 +3376,6 @@ function useAreaChecklistRepo() {
|
|
|
3374
3376
|
} catch (error) {
|
|
3375
3377
|
throw new import_node_server_utils17.BadRequestError("Invalid area checklist ID format.");
|
|
3376
3378
|
}
|
|
3377
|
-
if (serviceType) {
|
|
3378
|
-
query.serviceType = serviceType;
|
|
3379
|
-
cacheOptions.serviceType = serviceType;
|
|
3380
|
-
}
|
|
3381
3379
|
if (search) {
|
|
3382
3380
|
query.$text = { $search: search };
|
|
3383
3381
|
cacheOptions.search = search;
|
|
@@ -3591,7 +3589,16 @@ function useAreaChecklistRepo() {
|
|
|
3591
3589
|
try {
|
|
3592
3590
|
const area = await collection.findOne(
|
|
3593
3591
|
{ _id },
|
|
3594
|
-
{
|
|
3592
|
+
{
|
|
3593
|
+
projection: {
|
|
3594
|
+
schedule: 1,
|
|
3595
|
+
serviceType: 1,
|
|
3596
|
+
name: 1,
|
|
3597
|
+
type: 1,
|
|
3598
|
+
status: 1
|
|
3599
|
+
},
|
|
3600
|
+
session
|
|
3601
|
+
}
|
|
3595
3602
|
);
|
|
3596
3603
|
if (!area) {
|
|
3597
3604
|
throw new import_node_server_utils17.BadRequestError("Area checklist not found.");
|
|
@@ -4150,10 +4157,14 @@ function useAreaChecklistService() {
|
|
|
4150
4157
|
);
|
|
4151
4158
|
}
|
|
4152
4159
|
await _updateAreaChecklistUnits(_id, set, unitId, value, session);
|
|
4160
|
+
const currentArea = await getAreaChecklistById(_id, session);
|
|
4161
|
+
const scheduleId = currentArea.schedule;
|
|
4162
|
+
const serviceType = currentArea.serviceType;
|
|
4153
4163
|
const allUnitsResult = await getAreaChecklistUnits(
|
|
4154
4164
|
{
|
|
4155
4165
|
page: 1,
|
|
4156
4166
|
limit: 1e3,
|
|
4167
|
+
serviceType,
|
|
4157
4168
|
_id: _id.toString()
|
|
4158
4169
|
},
|
|
4159
4170
|
session
|
|
@@ -4178,14 +4189,13 @@ function useAreaChecklistService() {
|
|
|
4178
4189
|
}
|
|
4179
4190
|
}
|
|
4180
4191
|
await updateAreaChecklistStatus(_id, areaStatus, session);
|
|
4181
|
-
const currentArea = await getAreaChecklistById(_id, session);
|
|
4182
|
-
const scheduleId = currentArea.schedule;
|
|
4183
4192
|
if (scheduleId) {
|
|
4184
4193
|
const allAreasResult = await getAllAreaChecklist(
|
|
4185
4194
|
{
|
|
4186
4195
|
page: 1,
|
|
4187
4196
|
limit: 1e3,
|
|
4188
|
-
schedule: scheduleId.toString()
|
|
4197
|
+
schedule: scheduleId.toString(),
|
|
4198
|
+
serviceType
|
|
4189
4199
|
},
|
|
4190
4200
|
session
|
|
4191
4201
|
);
|