@7365admin1/module-hygiene 4.30.1 → 4.30.3
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.js +305 -295
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +305 -295
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/test/area-import-unit-id.test.mjs +18 -0
- package/test/require-photo-on-completion.test.mjs +63 -0
package/dist/index.mjs
CHANGED
|
@@ -843,21 +843,30 @@ function useHygieneDashboardController() {
|
|
|
843
843
|
}
|
|
844
844
|
|
|
845
845
|
// src/models/hygiene-area.model.ts
|
|
846
|
-
import
|
|
846
|
+
import Joi3 from "joi";
|
|
847
847
|
import { ObjectId as ObjectId2 } from "mongodb";
|
|
848
848
|
import { BadRequestError as BadRequestError3, logger as logger3 } from "@7365admin1/node-server-utils";
|
|
849
849
|
import { AppServiceType as AppServiceType2 } from "@7365admin1/core";
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
850
|
+
|
|
851
|
+
// src/utils/area-unit.util.ts
|
|
852
|
+
import Joi2 from "joi";
|
|
853
|
+
var areaUnitSchema = Joi2.object({
|
|
854
|
+
unit: Joi2.string().hex().required(),
|
|
855
|
+
name: Joi2.string().required()
|
|
856
|
+
});
|
|
857
|
+
function toAreaUnit(unit) {
|
|
858
|
+
return { unit: String(unit._id), name: unit.name };
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
// src/models/hygiene-area.model.ts
|
|
862
|
+
var areaSchema = Joi3.object({
|
|
863
|
+
site: Joi3.string().hex().required(),
|
|
864
|
+
serviceType: Joi3.string().valid(...Object.values(AppServiceType2)).required(),
|
|
865
|
+
name: Joi3.string().required(),
|
|
866
|
+
type: Joi3.string().valid(...allowedTypes).required(),
|
|
867
|
+
set: Joi3.number().min(0).optional(),
|
|
868
|
+
units: Joi3.array().items(
|
|
869
|
+
areaUnitSchema.optional()
|
|
861
870
|
).min(1).unique("unit", { ignoreUndefined: true }).messages({
|
|
862
871
|
"array.unique": "Duplicate area units are not allowed"
|
|
863
872
|
})
|
|
@@ -1371,14 +1380,14 @@ import {
|
|
|
1371
1380
|
} from "@7365admin1/node-server-utils";
|
|
1372
1381
|
|
|
1373
1382
|
// src/models/hygiene-unit.model.ts
|
|
1374
|
-
import
|
|
1383
|
+
import Joi4 from "joi";
|
|
1375
1384
|
import { ObjectId as ObjectId4 } from "mongodb";
|
|
1376
1385
|
import { BadRequestError as BadRequestError5, logger as logger6 } from "@7365admin1/node-server-utils";
|
|
1377
1386
|
import { AppServiceType as AppServiceType3 } from "@7365admin1/core";
|
|
1378
|
-
var unitSchema =
|
|
1379
|
-
site:
|
|
1380
|
-
serviceType:
|
|
1381
|
-
name:
|
|
1387
|
+
var unitSchema = Joi4.object({
|
|
1388
|
+
site: Joi4.string().hex().required(),
|
|
1389
|
+
serviceType: Joi4.string().valid(...Object.values(AppServiceType3)).required(),
|
|
1390
|
+
name: Joi4.string().required()
|
|
1382
1391
|
});
|
|
1383
1392
|
function MUnit(value) {
|
|
1384
1393
|
const { error } = unitSchema.validate(value);
|
|
@@ -1713,10 +1722,7 @@ function useAreaService() {
|
|
|
1713
1722
|
}
|
|
1714
1723
|
}
|
|
1715
1724
|
if (foundUnit) {
|
|
1716
|
-
areaUnits.push(
|
|
1717
|
-
unit: foundUnit._id,
|
|
1718
|
-
name: foundUnit.name
|
|
1719
|
-
});
|
|
1725
|
+
areaUnits.push(toAreaUnit(foundUnit));
|
|
1720
1726
|
}
|
|
1721
1727
|
}
|
|
1722
1728
|
if (areaUnits.length > 0) {
|
|
@@ -1813,7 +1819,7 @@ function useAreaService() {
|
|
|
1813
1819
|
}
|
|
1814
1820
|
|
|
1815
1821
|
// src/controllers/hygiene-area.controller.ts
|
|
1816
|
-
import
|
|
1822
|
+
import Joi5 from "joi";
|
|
1817
1823
|
import { BadRequestError as BadRequestError8, logger as logger9 } from "@7365admin1/node-server-utils";
|
|
1818
1824
|
import { AppServiceType as AppServiceType4 } from "@7365admin1/core";
|
|
1819
1825
|
|
|
@@ -1874,13 +1880,13 @@ function useAreaController() {
|
|
|
1874
1880
|
}
|
|
1875
1881
|
async function getAreas(req, res, next) {
|
|
1876
1882
|
const query = { ...req.query, ...req.params };
|
|
1877
|
-
const validation =
|
|
1878
|
-
page:
|
|
1879
|
-
limit:
|
|
1880
|
-
search:
|
|
1881
|
-
type:
|
|
1882
|
-
site:
|
|
1883
|
-
serviceType:
|
|
1883
|
+
const validation = Joi5.object({
|
|
1884
|
+
page: Joi5.number().min(1).optional().allow("", null),
|
|
1885
|
+
limit: Joi5.number().min(1).optional().allow("", null),
|
|
1886
|
+
search: Joi5.string().optional().allow("", null),
|
|
1887
|
+
type: Joi5.string().valid("all", ...allowedTypes).optional().allow("", null),
|
|
1888
|
+
site: Joi5.string().hex().required(),
|
|
1889
|
+
serviceType: Joi5.string().valid(...Object.values(AppServiceType4)).required()
|
|
1884
1890
|
});
|
|
1885
1891
|
const { error } = validation.validate(query);
|
|
1886
1892
|
if (error) {
|
|
@@ -1911,7 +1917,7 @@ function useAreaController() {
|
|
|
1911
1917
|
}
|
|
1912
1918
|
}
|
|
1913
1919
|
async function getAreaById(req, res, next) {
|
|
1914
|
-
const validation =
|
|
1920
|
+
const validation = Joi5.string().hex().required();
|
|
1915
1921
|
const _id = req.params.id;
|
|
1916
1922
|
const { error, value } = validation.validate(_id);
|
|
1917
1923
|
if (error) {
|
|
@@ -1931,15 +1937,15 @@ function useAreaController() {
|
|
|
1931
1937
|
}
|
|
1932
1938
|
async function updateArea(req, res, next) {
|
|
1933
1939
|
const payload = { id: req.params.id, ...req.body };
|
|
1934
|
-
const schema =
|
|
1935
|
-
id:
|
|
1936
|
-
name:
|
|
1937
|
-
type:
|
|
1938
|
-
set:
|
|
1939
|
-
units:
|
|
1940
|
-
|
|
1941
|
-
unit:
|
|
1942
|
-
name:
|
|
1940
|
+
const schema = Joi5.object({
|
|
1941
|
+
id: Joi5.string().hex().required(),
|
|
1942
|
+
name: Joi5.string().optional().allow("", null),
|
|
1943
|
+
type: Joi5.string().optional().allow("", null, ...allowedTypes),
|
|
1944
|
+
set: Joi5.number().min(0).optional(),
|
|
1945
|
+
units: Joi5.array().items(
|
|
1946
|
+
Joi5.object({
|
|
1947
|
+
unit: Joi5.string().hex().required(),
|
|
1948
|
+
name: Joi5.string().required()
|
|
1943
1949
|
}).required()
|
|
1944
1950
|
).min(1).unique("unit", { ignoreUndefined: true }).optional().messages({
|
|
1945
1951
|
"array.unique": "Duplicate area units are not allowed"
|
|
@@ -1964,7 +1970,7 @@ function useAreaController() {
|
|
|
1964
1970
|
}
|
|
1965
1971
|
async function deleteArea(req, res, next) {
|
|
1966
1972
|
const id = req.params.id;
|
|
1967
|
-
const validation =
|
|
1973
|
+
const validation = Joi5.string().hex().required();
|
|
1968
1974
|
const { error, value } = validation.validate(id);
|
|
1969
1975
|
if (error) {
|
|
1970
1976
|
logger9.log({ level: "error", message: error.message });
|
|
@@ -1987,9 +1993,9 @@ function useAreaController() {
|
|
|
1987
1993
|
return;
|
|
1988
1994
|
}
|
|
1989
1995
|
const query = { ...req.query, ...req.params };
|
|
1990
|
-
const validation =
|
|
1991
|
-
site:
|
|
1992
|
-
serviceType:
|
|
1996
|
+
const validation = Joi5.object({
|
|
1997
|
+
site: Joi5.string().hex().required(),
|
|
1998
|
+
serviceType: Joi5.string().valid(...Object.values(AppServiceType4)).required()
|
|
1993
1999
|
});
|
|
1994
2000
|
const { error, value } = validation.validate(query);
|
|
1995
2001
|
if (error) {
|
|
@@ -2010,9 +2016,9 @@ function useAreaController() {
|
|
|
2010
2016
|
}
|
|
2011
2017
|
async function exportAreas(req, res, next) {
|
|
2012
2018
|
const query = { ...req.query, ...req.params };
|
|
2013
|
-
const validation =
|
|
2014
|
-
site:
|
|
2015
|
-
serviceType:
|
|
2019
|
+
const validation = Joi5.object({
|
|
2020
|
+
site: Joi5.string().hex().required(),
|
|
2021
|
+
serviceType: Joi5.string().valid(...Object.values(AppServiceType4)).required()
|
|
2016
2022
|
});
|
|
2017
2023
|
const { error, value } = validation.validate(query);
|
|
2018
2024
|
if (error) {
|
|
@@ -2299,7 +2305,7 @@ function useUnitService() {
|
|
|
2299
2305
|
}
|
|
2300
2306
|
|
|
2301
2307
|
// src/controllers/hygiene-unit.controller.ts
|
|
2302
|
-
import
|
|
2308
|
+
import Joi6 from "joi";
|
|
2303
2309
|
import { BadRequestError as BadRequestError10, logger as logger12 } from "@7365admin1/node-server-utils";
|
|
2304
2310
|
import { AppServiceType as AppServiceType5 } from "@7365admin1/core";
|
|
2305
2311
|
function useUnitController() {
|
|
@@ -2330,12 +2336,12 @@ function useUnitController() {
|
|
|
2330
2336
|
}
|
|
2331
2337
|
async function getUnits(req, res, next) {
|
|
2332
2338
|
const query = { ...req.query, ...req.params };
|
|
2333
|
-
const validation =
|
|
2334
|
-
page:
|
|
2335
|
-
limit:
|
|
2336
|
-
search:
|
|
2337
|
-
site:
|
|
2338
|
-
serviceType:
|
|
2339
|
+
const validation = Joi6.object({
|
|
2340
|
+
page: Joi6.number().min(1).optional().allow("", null),
|
|
2341
|
+
limit: Joi6.number().min(1).optional().allow("", null),
|
|
2342
|
+
search: Joi6.string().optional().allow("", null),
|
|
2343
|
+
site: Joi6.string().hex().required(),
|
|
2344
|
+
serviceType: Joi6.string().valid(...Object.values(AppServiceType5)).required()
|
|
2339
2345
|
});
|
|
2340
2346
|
const { error } = validation.validate(query);
|
|
2341
2347
|
if (error) {
|
|
@@ -2366,9 +2372,9 @@ function useUnitController() {
|
|
|
2366
2372
|
}
|
|
2367
2373
|
async function updateUnit(req, res, next) {
|
|
2368
2374
|
const payload = { id: req.params.id, ...req.body };
|
|
2369
|
-
const validation =
|
|
2370
|
-
id:
|
|
2371
|
-
name:
|
|
2375
|
+
const validation = Joi6.object({
|
|
2376
|
+
id: Joi6.string().hex().required(),
|
|
2377
|
+
name: Joi6.string().required()
|
|
2372
2378
|
});
|
|
2373
2379
|
const { error } = validation.validate(payload);
|
|
2374
2380
|
if (error) {
|
|
@@ -2389,8 +2395,8 @@ function useUnitController() {
|
|
|
2389
2395
|
}
|
|
2390
2396
|
async function deleteUnit(req, res, next) {
|
|
2391
2397
|
const id = req.params.id;
|
|
2392
|
-
const validation =
|
|
2393
|
-
id:
|
|
2398
|
+
const validation = Joi6.object({
|
|
2399
|
+
id: Joi6.string().hex().required()
|
|
2394
2400
|
});
|
|
2395
2401
|
const { error, value } = validation.validate({ id });
|
|
2396
2402
|
if (error) {
|
|
@@ -2414,9 +2420,9 @@ function useUnitController() {
|
|
|
2414
2420
|
return;
|
|
2415
2421
|
}
|
|
2416
2422
|
const query = { ...req.query, ...req.params };
|
|
2417
|
-
const validation =
|
|
2418
|
-
site:
|
|
2419
|
-
serviceType:
|
|
2423
|
+
const validation = Joi6.object({
|
|
2424
|
+
site: Joi6.string().hex().required(),
|
|
2425
|
+
serviceType: Joi6.string().valid(...Object.values(AppServiceType5)).required()
|
|
2420
2426
|
});
|
|
2421
2427
|
const { error, value } = validation.validate(query);
|
|
2422
2428
|
if (error) {
|
|
@@ -2437,9 +2443,9 @@ function useUnitController() {
|
|
|
2437
2443
|
}
|
|
2438
2444
|
async function exportUnits(req, res, next) {
|
|
2439
2445
|
const query = { ...req.query, ...req.params };
|
|
2440
|
-
const validation =
|
|
2441
|
-
site:
|
|
2442
|
-
serviceType:
|
|
2446
|
+
const validation = Joi6.object({
|
|
2447
|
+
site: Joi6.string().hex().required(),
|
|
2448
|
+
serviceType: Joi6.string().valid(...Object.values(AppServiceType5)).required()
|
|
2443
2449
|
});
|
|
2444
2450
|
const { error, value } = validation.validate(query);
|
|
2445
2451
|
if (error) {
|
|
@@ -2482,15 +2488,15 @@ function useUnitController() {
|
|
|
2482
2488
|
}
|
|
2483
2489
|
|
|
2484
2490
|
// src/models/hygiene-parent-checklist.model.ts
|
|
2485
|
-
import
|
|
2491
|
+
import Joi7 from "joi";
|
|
2486
2492
|
import { ObjectId as ObjectId6 } from "mongodb";
|
|
2487
2493
|
import { BadRequestError as BadRequestError11, logger as logger13 } from "@7365admin1/node-server-utils";
|
|
2488
2494
|
import { AppServiceType as AppServiceType6 } from "@7365admin1/core";
|
|
2489
|
-
var parentChecklistSchema =
|
|
2490
|
-
createdAt:
|
|
2491
|
-
site:
|
|
2492
|
-
serviceType:
|
|
2493
|
-
dateStr:
|
|
2495
|
+
var parentChecklistSchema = Joi7.object({
|
|
2496
|
+
createdAt: Joi7.alternatives().try(Joi7.date(), Joi7.string()).optional().allow("", null),
|
|
2497
|
+
site: Joi7.string().hex().required(),
|
|
2498
|
+
serviceType: Joi7.string().valid(...Object.values(AppServiceType6)).required(),
|
|
2499
|
+
dateStr: Joi7.string().optional().allow("", null)
|
|
2494
2500
|
});
|
|
2495
2501
|
function MParentChecklist(value) {
|
|
2496
2502
|
const { error } = parentChecklistSchema.validate(value);
|
|
@@ -3071,7 +3077,7 @@ function useParentChecklistRepo() {
|
|
|
3071
3077
|
}
|
|
3072
3078
|
|
|
3073
3079
|
// src/controllers/hygiene-parent-checklist.controller.ts
|
|
3074
|
-
import
|
|
3080
|
+
import Joi8 from "joi";
|
|
3075
3081
|
import { BadRequestError as BadRequestError13, logger as logger15 } from "@7365admin1/node-server-utils";
|
|
3076
3082
|
import { AppServiceType as AppServiceType8 } from "@7365admin1/core";
|
|
3077
3083
|
function useParentChecklistController() {
|
|
@@ -3081,10 +3087,10 @@ function useParentChecklistController() {
|
|
|
3081
3087
|
} = useParentChecklistRepo();
|
|
3082
3088
|
async function createParentChecklist(req, res, next) {
|
|
3083
3089
|
const payload = req.body;
|
|
3084
|
-
const validation =
|
|
3085
|
-
createdAt:
|
|
3086
|
-
site:
|
|
3087
|
-
serviceType:
|
|
3090
|
+
const validation = Joi8.object({
|
|
3091
|
+
createdAt: Joi8.alternatives().try(Joi8.date(), Joi8.string()).optional().allow("", null),
|
|
3092
|
+
site: Joi8.string().hex().required(),
|
|
3093
|
+
serviceType: Joi8.string().valid(...Object.values(AppServiceType8)).optional().allow("", null)
|
|
3088
3094
|
});
|
|
3089
3095
|
const { error } = validation.validate(payload);
|
|
3090
3096
|
if (error) {
|
|
@@ -3104,15 +3110,15 @@ function useParentChecklistController() {
|
|
|
3104
3110
|
}
|
|
3105
3111
|
async function getAllParentChecklist(req, res, next) {
|
|
3106
3112
|
const query = { ...req.query, ...req.params };
|
|
3107
|
-
const validation =
|
|
3108
|
-
page:
|
|
3109
|
-
limit:
|
|
3110
|
-
search:
|
|
3111
|
-
site:
|
|
3112
|
-
serviceType:
|
|
3113
|
-
startDate:
|
|
3114
|
-
endDate:
|
|
3115
|
-
status:
|
|
3113
|
+
const validation = Joi8.object({
|
|
3114
|
+
page: Joi8.number().min(1).optional().allow("", null),
|
|
3115
|
+
limit: Joi8.number().min(1).optional().allow("", null),
|
|
3116
|
+
search: Joi8.string().optional().allow("", null),
|
|
3117
|
+
site: Joi8.string().hex().required(),
|
|
3118
|
+
serviceType: Joi8.string().valid(...Object.values(AppServiceType8)).required(),
|
|
3119
|
+
startDate: Joi8.alternatives().try(Joi8.date(), Joi8.string()).optional().allow("", null),
|
|
3120
|
+
endDate: Joi8.alternatives().try(Joi8.date(), Joi8.string()).optional().allow("", null),
|
|
3121
|
+
status: Joi8.string().valid(...allowedStatus, "all").optional().allow("", null)
|
|
3116
3122
|
});
|
|
3117
3123
|
const { error } = validation.validate(query);
|
|
3118
3124
|
if (error) {
|
|
@@ -3154,28 +3160,28 @@ function useParentChecklistController() {
|
|
|
3154
3160
|
}
|
|
3155
3161
|
|
|
3156
3162
|
// src/models/hygiene-area-checklist.model.ts
|
|
3157
|
-
import
|
|
3163
|
+
import Joi9 from "joi";
|
|
3158
3164
|
import { ObjectId as ObjectId8 } from "mongodb";
|
|
3159
3165
|
import { BadRequestError as BadRequestError14, logger as logger16 } from "@7365admin1/node-server-utils";
|
|
3160
3166
|
import { AppServiceType as AppServiceType9 } from "@7365admin1/core";
|
|
3161
3167
|
var allowedChecklistStatus = ["open", "completed", "closed"];
|
|
3162
|
-
var areaChecklistSchema =
|
|
3163
|
-
schedule:
|
|
3164
|
-
serviceType:
|
|
3165
|
-
area:
|
|
3166
|
-
name:
|
|
3167
|
-
type:
|
|
3168
|
-
checklist:
|
|
3169
|
-
|
|
3170
|
-
set:
|
|
3171
|
-
units:
|
|
3172
|
-
|
|
3173
|
-
unit:
|
|
3174
|
-
name:
|
|
3168
|
+
var areaChecklistSchema = Joi9.object({
|
|
3169
|
+
schedule: Joi9.string().hex().required(),
|
|
3170
|
+
serviceType: Joi9.string().valid(...Object.values(AppServiceType9)).required(),
|
|
3171
|
+
area: Joi9.string().hex().required(),
|
|
3172
|
+
name: Joi9.string().required(),
|
|
3173
|
+
type: Joi9.string().valid(...allowedTypes).required(),
|
|
3174
|
+
checklist: Joi9.array().items(
|
|
3175
|
+
Joi9.object({
|
|
3176
|
+
set: Joi9.number().min(0).required(),
|
|
3177
|
+
units: Joi9.array().items(
|
|
3178
|
+
Joi9.object({
|
|
3179
|
+
unit: Joi9.string().hex().required(),
|
|
3180
|
+
name: Joi9.string().required()
|
|
3175
3181
|
}).required()
|
|
3176
3182
|
).min(1).required(),
|
|
3177
|
-
isScheduleTask:
|
|
3178
|
-
scheduleTaskId:
|
|
3183
|
+
isScheduleTask: Joi9.boolean().optional().default(false),
|
|
3184
|
+
scheduleTaskId: Joi9.string().hex().optional().allow(null)
|
|
3179
3185
|
}).required()
|
|
3180
3186
|
).optional().default([])
|
|
3181
3187
|
});
|
|
@@ -3253,6 +3259,39 @@ import {
|
|
|
3253
3259
|
useAtlas as useAtlas6,
|
|
3254
3260
|
useCache as useCache5
|
|
3255
3261
|
} from "@7365admin1/node-server-utils";
|
|
3262
|
+
|
|
3263
|
+
// src/utils/completion-photo.util.ts
|
|
3264
|
+
var COMPLETION_PHOTO_MESSAGE = "A photo is required to complete this task. Take or upload at least one photo before marking it complete.";
|
|
3265
|
+
function readCompletion(units, unitId) {
|
|
3266
|
+
if (units.length === 0)
|
|
3267
|
+
return { completesSet: false, hasEvidence: false };
|
|
3268
|
+
const others = units.filter((unit) => String(unit.unit) !== String(unitId));
|
|
3269
|
+
return {
|
|
3270
|
+
completesSet: others.every(
|
|
3271
|
+
(unit) => unit.approve === true || unit.reject === true
|
|
3272
|
+
),
|
|
3273
|
+
hasEvidence: others.some(
|
|
3274
|
+
(unit) => Array.isArray(unit.attachment) && unit.attachment.length > 0
|
|
3275
|
+
)
|
|
3276
|
+
};
|
|
3277
|
+
}
|
|
3278
|
+
function requiresCompletionPhoto({
|
|
3279
|
+
decision,
|
|
3280
|
+
attachment,
|
|
3281
|
+
completesSet,
|
|
3282
|
+
hasEvidence
|
|
3283
|
+
}) {
|
|
3284
|
+
if (decision !== "approve")
|
|
3285
|
+
return false;
|
|
3286
|
+
if (!completesSet)
|
|
3287
|
+
return false;
|
|
3288
|
+
if (hasEvidence)
|
|
3289
|
+
return false;
|
|
3290
|
+
const carriesEvidence = Array.isArray(attachment) && attachment.some((id) => typeof id === "string" && id.trim().length > 0);
|
|
3291
|
+
return !carriesEvidence;
|
|
3292
|
+
}
|
|
3293
|
+
|
|
3294
|
+
// src/repositories/hygiene-area-checklist.repository.ts
|
|
3256
3295
|
function useAreaChecklistRepo() {
|
|
3257
3296
|
const db = useAtlas6.getDb();
|
|
3258
3297
|
if (!db) {
|
|
@@ -4097,18 +4136,7 @@ function useAreaChecklistRepo() {
|
|
|
4097
4136
|
const group = (doc?.checklist ?? []).find(
|
|
4098
4137
|
(entry) => entry.set === set
|
|
4099
4138
|
);
|
|
4100
|
-
|
|
4101
|
-
if (units.length === 0)
|
|
4102
|
-
return { completesSet: false, hasEvidence: false };
|
|
4103
|
-
const others = units.filter(
|
|
4104
|
-
(unit) => String(unit.unit) !== String(unitId)
|
|
4105
|
-
);
|
|
4106
|
-
return {
|
|
4107
|
-
completesSet: others.every((unit) => unit.status === "completed"),
|
|
4108
|
-
hasEvidence: others.some(
|
|
4109
|
-
(unit) => Array.isArray(unit.attachment) && unit.attachment.length > 0
|
|
4110
|
-
)
|
|
4111
|
-
};
|
|
4139
|
+
return readCompletion(group?.units ?? [], unitId);
|
|
4112
4140
|
}
|
|
4113
4141
|
async function updateAreaChecklist(_id, value, session) {
|
|
4114
4142
|
try {
|
|
@@ -4642,7 +4670,7 @@ function useAreaChecklistService() {
|
|
|
4642
4670
|
}
|
|
4643
4671
|
|
|
4644
4672
|
// src/controllers/hygiene-area-checklist.controller.ts
|
|
4645
|
-
import
|
|
4673
|
+
import Joi10 from "joi";
|
|
4646
4674
|
import {
|
|
4647
4675
|
BadRequestError as BadRequestError16,
|
|
4648
4676
|
InternalServerError as InternalServerError7,
|
|
@@ -4650,24 +4678,6 @@ import {
|
|
|
4650
4678
|
} from "@7365admin1/node-server-utils";
|
|
4651
4679
|
import { AppServiceType as AppServiceType10 } from "@7365admin1/core";
|
|
4652
4680
|
|
|
4653
|
-
// src/utils/completion-photo.util.ts
|
|
4654
|
-
var COMPLETION_PHOTO_MESSAGE = "A photo is required to complete this task. Take or upload at least one photo before marking it complete.";
|
|
4655
|
-
function requiresCompletionPhoto({
|
|
4656
|
-
decision,
|
|
4657
|
-
attachment,
|
|
4658
|
-
completesSet,
|
|
4659
|
-
hasEvidence
|
|
4660
|
-
}) {
|
|
4661
|
-
if (decision !== "approve")
|
|
4662
|
-
return false;
|
|
4663
|
-
if (!completesSet)
|
|
4664
|
-
return false;
|
|
4665
|
-
if (hasEvidence)
|
|
4666
|
-
return false;
|
|
4667
|
-
const carriesEvidence = Array.isArray(attachment) && attachment.some((id) => typeof id === "string" && id.trim().length > 0);
|
|
4668
|
-
return !carriesEvidence;
|
|
4669
|
-
}
|
|
4670
|
-
|
|
4671
4681
|
// src/services/hygiene-checklist-pdf.service.ts
|
|
4672
4682
|
import { launch } from "puppeteer";
|
|
4673
4683
|
import { InternalServerError as InternalServerError6, useAtlas as useAtlas8 } from "@7365admin1/node-server-utils";
|
|
@@ -4905,9 +4915,9 @@ function useAreaChecklistController() {
|
|
|
4905
4915
|
site: req.params.site,
|
|
4906
4916
|
schedule: req.params.schedule
|
|
4907
4917
|
};
|
|
4908
|
-
const validation =
|
|
4909
|
-
site:
|
|
4910
|
-
schedule:
|
|
4918
|
+
const validation = Joi10.object({
|
|
4919
|
+
site: Joi10.string().hex().required(),
|
|
4920
|
+
schedule: Joi10.string().hex().required()
|
|
4911
4921
|
});
|
|
4912
4922
|
const { error, value } = validation.validate(payload);
|
|
4913
4923
|
if (error) {
|
|
@@ -4927,14 +4937,14 @@ function useAreaChecklistController() {
|
|
|
4927
4937
|
}
|
|
4928
4938
|
async function getAllAreaChecklist(req, res, next) {
|
|
4929
4939
|
const query = { ...req.query, ...req.params };
|
|
4930
|
-
const validation =
|
|
4931
|
-
page:
|
|
4932
|
-
limit:
|
|
4933
|
-
search:
|
|
4934
|
-
type:
|
|
4935
|
-
status:
|
|
4936
|
-
schedule:
|
|
4937
|
-
serviceType:
|
|
4940
|
+
const validation = Joi10.object({
|
|
4941
|
+
page: Joi10.number().min(1).optional().allow("", null),
|
|
4942
|
+
limit: Joi10.number().min(1).optional().allow("", null),
|
|
4943
|
+
search: Joi10.string().optional().allow("", null),
|
|
4944
|
+
type: Joi10.string().valid(...allowedTypes, "all").optional().allow("", null),
|
|
4945
|
+
status: Joi10.string().valid(...allowedStatus, "all").optional().allow("", null),
|
|
4946
|
+
schedule: Joi10.string().hex().required(),
|
|
4947
|
+
serviceType: Joi10.string().valid(...Object.values(AppServiceType10)).required()
|
|
4938
4948
|
});
|
|
4939
4949
|
const { error } = validation.validate(query);
|
|
4940
4950
|
if (error) {
|
|
@@ -4969,14 +4979,14 @@ function useAreaChecklistController() {
|
|
|
4969
4979
|
}
|
|
4970
4980
|
async function getAreaChecklistHistory(req, res, next) {
|
|
4971
4981
|
const query = { ...req.query, ...req.params };
|
|
4972
|
-
const validation =
|
|
4973
|
-
page:
|
|
4974
|
-
limit:
|
|
4975
|
-
search:
|
|
4976
|
-
type:
|
|
4977
|
-
schedule:
|
|
4978
|
-
status:
|
|
4979
|
-
createdAt:
|
|
4982
|
+
const validation = Joi10.object({
|
|
4983
|
+
page: Joi10.number().min(1).optional().allow("", null),
|
|
4984
|
+
limit: Joi10.number().min(1).optional().allow("", null),
|
|
4985
|
+
search: Joi10.string().optional().allow("", null),
|
|
4986
|
+
type: Joi10.string().optional().allow("", ...allowedTypes),
|
|
4987
|
+
schedule: Joi10.string().hex().required(),
|
|
4988
|
+
status: Joi10.string().allow("", null, ...allowedStatus),
|
|
4989
|
+
createdAt: Joi10.alternatives().try(Joi10.date(), Joi10.string()).optional().allow("", null)
|
|
4980
4990
|
});
|
|
4981
4991
|
const { error } = validation.validate(query);
|
|
4982
4992
|
if (error) {
|
|
@@ -5010,7 +5020,7 @@ function useAreaChecklistController() {
|
|
|
5010
5020
|
}
|
|
5011
5021
|
}
|
|
5012
5022
|
async function getAreaChecklistHistoryDetails(req, res, next) {
|
|
5013
|
-
const validation =
|
|
5023
|
+
const validation = Joi10.string().hex().required();
|
|
5014
5024
|
const _id = req.params.id;
|
|
5015
5025
|
const { error, value } = validation.validate(_id);
|
|
5016
5026
|
if (error) {
|
|
@@ -5030,12 +5040,12 @@ function useAreaChecklistController() {
|
|
|
5030
5040
|
}
|
|
5031
5041
|
async function getAreaChecklistUnits(req, res, next) {
|
|
5032
5042
|
const query = { ...req.query, ...req.params };
|
|
5033
|
-
const validation =
|
|
5034
|
-
page:
|
|
5035
|
-
limit:
|
|
5036
|
-
search:
|
|
5037
|
-
serviceType:
|
|
5038
|
-
id:
|
|
5043
|
+
const validation = Joi10.object({
|
|
5044
|
+
page: Joi10.number().min(1).optional().allow("", null),
|
|
5045
|
+
limit: Joi10.number().min(1).optional().allow("", null),
|
|
5046
|
+
search: Joi10.string().optional().allow("", null),
|
|
5047
|
+
serviceType: Joi10.string().valid(...Object.values(AppServiceType10)).required(),
|
|
5048
|
+
id: Joi10.string().hex().required()
|
|
5039
5049
|
});
|
|
5040
5050
|
const { error } = validation.validate(query);
|
|
5041
5051
|
if (error) {
|
|
@@ -5085,21 +5095,21 @@ function useAreaChecklistController() {
|
|
|
5085
5095
|
...decisionValues,
|
|
5086
5096
|
completedBy
|
|
5087
5097
|
};
|
|
5088
|
-
const validation =
|
|
5089
|
-
id:
|
|
5090
|
-
set:
|
|
5091
|
-
unit:
|
|
5092
|
-
decision:
|
|
5093
|
-
approve:
|
|
5094
|
-
reject:
|
|
5095
|
-
remarks:
|
|
5098
|
+
const validation = Joi10.object({
|
|
5099
|
+
id: Joi10.string().hex().required(),
|
|
5100
|
+
set: Joi10.number().integer().min(1).required(),
|
|
5101
|
+
unit: Joi10.string().hex().required(),
|
|
5102
|
+
decision: Joi10.string().valid("approve", "reject").required(),
|
|
5103
|
+
approve: Joi10.boolean().optional(),
|
|
5104
|
+
reject: Joi10.boolean().optional(),
|
|
5105
|
+
remarks: Joi10.string().optional().allow("", null),
|
|
5096
5106
|
/*
|
|
5097
5107
|
* Shape only. WHETHER a photo is required depends on the set's current
|
|
5098
5108
|
* state in the database, which Joi cannot see — see the check below.
|
|
5099
5109
|
* Each entry must still be a real id: a blank string carries no evidence.
|
|
5100
5110
|
*/
|
|
5101
|
-
attachment:
|
|
5102
|
-
completedBy:
|
|
5111
|
+
attachment: Joi10.array().items(Joi10.string().trim().min(1)).optional(),
|
|
5112
|
+
completedBy: Joi10.string().hex().required()
|
|
5103
5113
|
});
|
|
5104
5114
|
const { error } = validation.validate(payload);
|
|
5105
5115
|
if (error) {
|
|
@@ -5136,7 +5146,7 @@ function useAreaChecklistController() {
|
|
|
5136
5146
|
}
|
|
5137
5147
|
}
|
|
5138
5148
|
async function downloadChecklistPdf(req, res, next) {
|
|
5139
|
-
const validation =
|
|
5149
|
+
const validation = Joi10.string().hex().required();
|
|
5140
5150
|
const schedule = req.params.schedule;
|
|
5141
5151
|
const { error, value } = validation.validate(schedule);
|
|
5142
5152
|
if (error) {
|
|
@@ -5182,16 +5192,16 @@ function useAreaChecklistController() {
|
|
|
5182
5192
|
}
|
|
5183
5193
|
|
|
5184
5194
|
// src/models/hygiene-supply.model.ts
|
|
5185
|
-
import
|
|
5195
|
+
import Joi11 from "joi";
|
|
5186
5196
|
import { ObjectId as ObjectId12 } from "mongodb";
|
|
5187
5197
|
import { BadRequestError as BadRequestError17, logger as logger21 } from "@7365admin1/node-server-utils";
|
|
5188
5198
|
import { AppServiceType as AppServiceType11 } from "@7365admin1/core";
|
|
5189
|
-
var supplySchema =
|
|
5190
|
-
site:
|
|
5191
|
-
serviceType:
|
|
5192
|
-
name:
|
|
5193
|
-
unitOfMeasurement:
|
|
5194
|
-
attachment:
|
|
5199
|
+
var supplySchema = Joi11.object({
|
|
5200
|
+
site: Joi11.string().hex().required(),
|
|
5201
|
+
serviceType: Joi11.string().valid(...Object.values(AppServiceType11)).required(),
|
|
5202
|
+
name: Joi11.string().required(),
|
|
5203
|
+
unitOfMeasurement: Joi11.string().required(),
|
|
5204
|
+
attachment: Joi11.string().allow(null, "").optional()
|
|
5195
5205
|
});
|
|
5196
5206
|
function MSupply(value) {
|
|
5197
5207
|
const { error } = supplySchema.validate(value);
|
|
@@ -5490,7 +5500,7 @@ function useSupplyRepository() {
|
|
|
5490
5500
|
}
|
|
5491
5501
|
|
|
5492
5502
|
// src/controllers/hygiene-supply.controller.ts
|
|
5493
|
-
import
|
|
5503
|
+
import Joi12 from "joi";
|
|
5494
5504
|
import { BadRequestError as BadRequestError19, logger as logger23 } from "@7365admin1/node-server-utils";
|
|
5495
5505
|
import { AppServiceType as AppServiceType12 } from "@7365admin1/core";
|
|
5496
5506
|
function useSupplyController() {
|
|
@@ -5521,12 +5531,12 @@ function useSupplyController() {
|
|
|
5521
5531
|
}
|
|
5522
5532
|
async function getSupplies(req, res, next) {
|
|
5523
5533
|
const query = { ...req.query, ...req.params };
|
|
5524
|
-
const validation =
|
|
5525
|
-
page:
|
|
5526
|
-
limit:
|
|
5527
|
-
search:
|
|
5528
|
-
site:
|
|
5529
|
-
serviceType:
|
|
5534
|
+
const validation = Joi12.object({
|
|
5535
|
+
page: Joi12.number().min(1).optional().allow("", null),
|
|
5536
|
+
limit: Joi12.number().min(1).optional().allow("", null),
|
|
5537
|
+
search: Joi12.string().optional().allow("", null),
|
|
5538
|
+
site: Joi12.string().hex().required(),
|
|
5539
|
+
serviceType: Joi12.string().valid(...Object.values(AppServiceType12)).required()
|
|
5530
5540
|
});
|
|
5531
5541
|
const { error } = validation.validate(query);
|
|
5532
5542
|
if (error) {
|
|
@@ -5556,7 +5566,7 @@ function useSupplyController() {
|
|
|
5556
5566
|
}
|
|
5557
5567
|
}
|
|
5558
5568
|
async function getSupplyById(req, res, next) {
|
|
5559
|
-
const validation =
|
|
5569
|
+
const validation = Joi12.string().hex().required();
|
|
5560
5570
|
const _id = req.params.id;
|
|
5561
5571
|
const { error, value } = validation.validate(_id);
|
|
5562
5572
|
if (error) {
|
|
@@ -5576,12 +5586,12 @@ function useSupplyController() {
|
|
|
5576
5586
|
}
|
|
5577
5587
|
async function updateSupply(req, res, next) {
|
|
5578
5588
|
const payload = { id: req.params.id, ...req.body };
|
|
5579
|
-
const validation =
|
|
5580
|
-
id:
|
|
5581
|
-
name:
|
|
5582
|
-
unitOfMeasurement:
|
|
5583
|
-
qty:
|
|
5584
|
-
attachment:
|
|
5589
|
+
const validation = Joi12.object({
|
|
5590
|
+
id: Joi12.string().hex().required(),
|
|
5591
|
+
name: Joi12.string().optional().allow("", null),
|
|
5592
|
+
unitOfMeasurement: Joi12.string().optional().allow("", null),
|
|
5593
|
+
qty: Joi12.number().min(0).optional().allow("", null),
|
|
5594
|
+
attachment: Joi12.string().optional().allow("", null)
|
|
5585
5595
|
});
|
|
5586
5596
|
const { error } = validation.validate(payload);
|
|
5587
5597
|
if (error) {
|
|
@@ -5602,7 +5612,7 @@ function useSupplyController() {
|
|
|
5602
5612
|
}
|
|
5603
5613
|
async function deleteSupply(req, res, next) {
|
|
5604
5614
|
const id = req.params.id;
|
|
5605
|
-
const validation =
|
|
5615
|
+
const validation = Joi12.string().hex().required();
|
|
5606
5616
|
const { error, value } = validation.validate(id);
|
|
5607
5617
|
if (error) {
|
|
5608
5618
|
logger23.log({ level: "error", message: error.message });
|
|
@@ -5629,18 +5639,18 @@ function useSupplyController() {
|
|
|
5629
5639
|
}
|
|
5630
5640
|
|
|
5631
5641
|
// src/models/hygiene-stock.model.ts
|
|
5632
|
-
import
|
|
5642
|
+
import Joi13 from "joi";
|
|
5633
5643
|
import { ObjectId as ObjectId14 } from "mongodb";
|
|
5634
5644
|
import { BadRequestError as BadRequestError20, logger as logger24 } from "@7365admin1/node-server-utils";
|
|
5635
5645
|
import { AppServiceType as AppServiceType13 } from "@7365admin1/core";
|
|
5636
|
-
var stockSchema =
|
|
5637
|
-
site:
|
|
5638
|
-
serviceType:
|
|
5639
|
-
supply:
|
|
5640
|
-
in:
|
|
5641
|
-
out:
|
|
5642
|
-
balance:
|
|
5643
|
-
remarks:
|
|
5646
|
+
var stockSchema = Joi13.object({
|
|
5647
|
+
site: Joi13.string().hex().required(),
|
|
5648
|
+
serviceType: Joi13.string().valid(...Object.values(AppServiceType13)).required(),
|
|
5649
|
+
supply: Joi13.string().hex().required(),
|
|
5650
|
+
in: Joi13.number().min(0).optional(),
|
|
5651
|
+
out: Joi13.number().min(0).optional(),
|
|
5652
|
+
balance: Joi13.number().min(0).required(),
|
|
5653
|
+
remarks: Joi13.string().optional().allow("", null)
|
|
5644
5654
|
});
|
|
5645
5655
|
function MStock(value) {
|
|
5646
5656
|
const { error } = stockSchema.validate(value);
|
|
@@ -5867,7 +5877,7 @@ function useStockService() {
|
|
|
5867
5877
|
}
|
|
5868
5878
|
|
|
5869
5879
|
// src/controllers/hygiene-stock.controller.ts
|
|
5870
|
-
import
|
|
5880
|
+
import Joi14 from "joi";
|
|
5871
5881
|
import { BadRequestError as BadRequestError23, logger as logger26 } from "@7365admin1/node-server-utils";
|
|
5872
5882
|
import { AppServiceType as AppServiceType14 } from "@7365admin1/core";
|
|
5873
5883
|
function useStockController() {
|
|
@@ -5875,12 +5885,12 @@ function useStockController() {
|
|
|
5875
5885
|
const { createStock: _createStock } = useStockService();
|
|
5876
5886
|
async function createStock(req, res, next) {
|
|
5877
5887
|
const payload = { ...req.body, ...req.params };
|
|
5878
|
-
const validation =
|
|
5879
|
-
site:
|
|
5880
|
-
serviceType:
|
|
5881
|
-
supply:
|
|
5882
|
-
qty:
|
|
5883
|
-
remarks:
|
|
5888
|
+
const validation = Joi14.object({
|
|
5889
|
+
site: Joi14.string().hex().required(),
|
|
5890
|
+
serviceType: Joi14.string().valid(...Object.values(AppServiceType14)).required(),
|
|
5891
|
+
supply: Joi14.string().hex().required(),
|
|
5892
|
+
qty: Joi14.number().min(0).required(),
|
|
5893
|
+
remarks: Joi14.string().optional().allow("", null)
|
|
5884
5894
|
});
|
|
5885
5895
|
const { error } = validation.validate(payload);
|
|
5886
5896
|
if (error) {
|
|
@@ -5900,13 +5910,13 @@ function useStockController() {
|
|
|
5900
5910
|
}
|
|
5901
5911
|
async function getStocksBySupplyId(req, res, next) {
|
|
5902
5912
|
const query = { ...req.query, ...req.params };
|
|
5903
|
-
const validation =
|
|
5904
|
-
page:
|
|
5905
|
-
limit:
|
|
5906
|
-
search:
|
|
5907
|
-
site:
|
|
5908
|
-
serviceType:
|
|
5909
|
-
supply:
|
|
5913
|
+
const validation = Joi14.object({
|
|
5914
|
+
page: Joi14.number().min(1).optional().allow("", null),
|
|
5915
|
+
limit: Joi14.number().min(1).optional().allow("", null),
|
|
5916
|
+
search: Joi14.string().optional().allow("", null),
|
|
5917
|
+
site: Joi14.string().hex().required(),
|
|
5918
|
+
serviceType: Joi14.string().valid(...Object.values(AppServiceType14)).required(),
|
|
5919
|
+
supply: Joi14.string().hex().required()
|
|
5910
5920
|
});
|
|
5911
5921
|
const { error } = validation.validate(query);
|
|
5912
5922
|
if (error) {
|
|
@@ -5968,21 +5978,21 @@ async function applyCheckOutDecision(decision, decide, returnStock) {
|
|
|
5968
5978
|
}
|
|
5969
5979
|
|
|
5970
5980
|
// src/models/hygiene-checkout-item.model.ts
|
|
5971
|
-
import
|
|
5981
|
+
import Joi15 from "joi";
|
|
5972
5982
|
import { ObjectId as ObjectId16 } from "mongodb";
|
|
5973
5983
|
import { BadRequestError as BadRequestError24, logger as logger27 } from "@7365admin1/node-server-utils";
|
|
5974
5984
|
import { AppServiceType as AppServiceType15 } from "@7365admin1/core";
|
|
5975
5985
|
var allowedCheckOutItemStatus = ["pending", "completed"];
|
|
5976
|
-
var checkOutItemSchema =
|
|
5977
|
-
site:
|
|
5978
|
-
serviceType:
|
|
5979
|
-
supply:
|
|
5980
|
-
supplyName:
|
|
5981
|
-
supplyQty:
|
|
5982
|
-
qty:
|
|
5983
|
-
attachment:
|
|
5984
|
-
createdBy:
|
|
5985
|
-
createdByName:
|
|
5986
|
+
var checkOutItemSchema = Joi15.object({
|
|
5987
|
+
site: Joi15.string().hex().required(),
|
|
5988
|
+
serviceType: Joi15.string().valid(...Object.values(AppServiceType15)).required(),
|
|
5989
|
+
supply: Joi15.string().hex().required(),
|
|
5990
|
+
supplyName: Joi15.string().required(),
|
|
5991
|
+
supplyQty: Joi15.number().min(0).required(),
|
|
5992
|
+
qty: Joi15.number().min(0).required(),
|
|
5993
|
+
attachment: Joi15.array().items(Joi15.string()).optional().allow(null),
|
|
5994
|
+
createdBy: Joi15.string().hex().required(),
|
|
5995
|
+
createdByName: Joi15.string().required()
|
|
5986
5996
|
});
|
|
5987
5997
|
function MCheckOutItem(value) {
|
|
5988
5998
|
const { error } = checkOutItemSchema.validate(value);
|
|
@@ -6471,7 +6481,7 @@ function useCheckOutItemService() {
|
|
|
6471
6481
|
}
|
|
6472
6482
|
|
|
6473
6483
|
// src/controllers/hygiene-checkout-item.controller.ts
|
|
6474
|
-
import
|
|
6484
|
+
import Joi16 from "joi";
|
|
6475
6485
|
import { BadRequestError as BadRequestError27, logger as logger29 } from "@7365admin1/node-server-utils";
|
|
6476
6486
|
import { AppServiceType as AppServiceType16 } from "@7365admin1/core";
|
|
6477
6487
|
function useCheckOutItemController() {
|
|
@@ -6495,13 +6505,13 @@ function useCheckOutItemController() {
|
|
|
6495
6505
|
...req.params,
|
|
6496
6506
|
createdBy
|
|
6497
6507
|
};
|
|
6498
|
-
const validation =
|
|
6499
|
-
site:
|
|
6500
|
-
serviceType:
|
|
6501
|
-
supply:
|
|
6502
|
-
qty:
|
|
6503
|
-
attachment:
|
|
6504
|
-
createdBy:
|
|
6508
|
+
const validation = Joi16.object({
|
|
6509
|
+
site: Joi16.string().hex().required(),
|
|
6510
|
+
serviceType: Joi16.string().valid(...Object.values(AppServiceType16)).required(),
|
|
6511
|
+
supply: Joi16.string().hex().required(),
|
|
6512
|
+
qty: Joi16.number().min(0).required(),
|
|
6513
|
+
attachment: Joi16.array().items(Joi16.string()).optional().allow(null),
|
|
6514
|
+
createdBy: Joi16.string().hex().required()
|
|
6505
6515
|
});
|
|
6506
6516
|
const { error } = validation.validate(payload);
|
|
6507
6517
|
if (error) {
|
|
@@ -6530,15 +6540,15 @@ function useCheckOutItemController() {
|
|
|
6530
6540
|
...req.params,
|
|
6531
6541
|
createdBy
|
|
6532
6542
|
};
|
|
6533
|
-
const validation =
|
|
6534
|
-
site:
|
|
6535
|
-
serviceType:
|
|
6536
|
-
createdBy:
|
|
6537
|
-
items:
|
|
6538
|
-
|
|
6539
|
-
supply:
|
|
6540
|
-
qty:
|
|
6541
|
-
attachment:
|
|
6543
|
+
const validation = Joi16.object({
|
|
6544
|
+
site: Joi16.string().hex().required(),
|
|
6545
|
+
serviceType: Joi16.string().valid(...Object.values(AppServiceType16)).required(),
|
|
6546
|
+
createdBy: Joi16.string().hex().required(),
|
|
6547
|
+
items: Joi16.array().items(
|
|
6548
|
+
Joi16.object({
|
|
6549
|
+
supply: Joi16.string().hex().required(),
|
|
6550
|
+
qty: Joi16.number().min(0).required(),
|
|
6551
|
+
attachment: Joi16.array().items(Joi16.string()).optional().allow(null)
|
|
6542
6552
|
})
|
|
6543
6553
|
).min(1).required()
|
|
6544
6554
|
});
|
|
@@ -6560,12 +6570,12 @@ function useCheckOutItemController() {
|
|
|
6560
6570
|
}
|
|
6561
6571
|
async function getCheckOutItems(req, res, next) {
|
|
6562
6572
|
const query = { ...req.query, ...req.params };
|
|
6563
|
-
const validation =
|
|
6564
|
-
page:
|
|
6565
|
-
limit:
|
|
6566
|
-
search:
|
|
6567
|
-
site:
|
|
6568
|
-
serviceType:
|
|
6573
|
+
const validation = Joi16.object({
|
|
6574
|
+
page: Joi16.number().min(1).optional().allow("", null),
|
|
6575
|
+
limit: Joi16.number().min(1).optional().allow("", null),
|
|
6576
|
+
search: Joi16.string().optional().allow("", null),
|
|
6577
|
+
site: Joi16.string().hex().required(),
|
|
6578
|
+
serviceType: Joi16.string().valid(...Object.values(AppServiceType16)).required()
|
|
6569
6579
|
});
|
|
6570
6580
|
const { error } = validation.validate(query);
|
|
6571
6581
|
if (error) {
|
|
@@ -6595,7 +6605,7 @@ function useCheckOutItemController() {
|
|
|
6595
6605
|
}
|
|
6596
6606
|
}
|
|
6597
6607
|
async function getCheckOutItemById(req, res, next) {
|
|
6598
|
-
const validation =
|
|
6608
|
+
const validation = Joi16.string().hex().required();
|
|
6599
6609
|
const _id = req.params.id;
|
|
6600
6610
|
const { error, value } = validation.validate(_id);
|
|
6601
6611
|
if (error) {
|
|
@@ -6634,13 +6644,13 @@ function useCheckOutItemController() {
|
|
|
6634
6644
|
...decisionValues,
|
|
6635
6645
|
completedBy
|
|
6636
6646
|
};
|
|
6637
|
-
const validation =
|
|
6638
|
-
id:
|
|
6639
|
-
decision:
|
|
6640
|
-
approve:
|
|
6641
|
-
reject:
|
|
6642
|
-
remarks:
|
|
6643
|
-
completedBy:
|
|
6647
|
+
const validation = Joi16.object({
|
|
6648
|
+
id: Joi16.string().hex().required(),
|
|
6649
|
+
decision: Joi16.string().valid("approve", "disapprove").required(),
|
|
6650
|
+
approve: Joi16.boolean().required(),
|
|
6651
|
+
reject: Joi16.boolean().required(),
|
|
6652
|
+
remarks: Joi16.string().optional().allow("", null),
|
|
6653
|
+
completedBy: Joi16.string().hex().required()
|
|
6644
6654
|
});
|
|
6645
6655
|
const { error } = validation.validate(payload);
|
|
6646
6656
|
if (error) {
|
|
@@ -6673,21 +6683,21 @@ function useCheckOutItemController() {
|
|
|
6673
6683
|
// src/models/hygiene-schedule-task.model.ts
|
|
6674
6684
|
import { BadRequestError as BadRequestError28, logger as logger30 } from "@7365admin1/node-server-utils";
|
|
6675
6685
|
import { AppServiceType as AppServiceType17 } from "@7365admin1/core";
|
|
6676
|
-
import
|
|
6686
|
+
import Joi17 from "joi";
|
|
6677
6687
|
import { ObjectId as ObjectId18 } from "mongodb";
|
|
6678
|
-
var scheduleTaskSchema =
|
|
6679
|
-
site:
|
|
6680
|
-
serviceType:
|
|
6681
|
-
title:
|
|
6682
|
-
time:
|
|
6683
|
-
dates:
|
|
6684
|
-
|
|
6688
|
+
var scheduleTaskSchema = Joi17.object({
|
|
6689
|
+
site: Joi17.string().hex().required(),
|
|
6690
|
+
serviceType: Joi17.string().valid(...Object.values(AppServiceType17)).required(),
|
|
6691
|
+
title: Joi17.string().required(),
|
|
6692
|
+
time: Joi17.string().pattern(/^([0-1]\d|2[0-3]):([0-5]\d)$/).required(),
|
|
6693
|
+
dates: Joi17.array().min(1).items(
|
|
6694
|
+
Joi17.string().pattern(/^\d{4}-\d{2}-\d{2}$/).required()
|
|
6685
6695
|
).required(),
|
|
6686
|
-
description:
|
|
6687
|
-
areas:
|
|
6688
|
-
|
|
6689
|
-
name:
|
|
6690
|
-
value:
|
|
6696
|
+
description: Joi17.string().optional().allow("", null),
|
|
6697
|
+
areas: Joi17.array().min(1).items(
|
|
6698
|
+
Joi17.object({
|
|
6699
|
+
name: Joi17.string().required(),
|
|
6700
|
+
value: Joi17.any().required()
|
|
6691
6701
|
})
|
|
6692
6702
|
).required()
|
|
6693
6703
|
});
|
|
@@ -7291,7 +7301,7 @@ function useScheduleTaskService() {
|
|
|
7291
7301
|
}
|
|
7292
7302
|
|
|
7293
7303
|
// src/controllers/hygiene-schedule-task.controller.ts
|
|
7294
|
-
import
|
|
7304
|
+
import Joi18 from "joi";
|
|
7295
7305
|
import { BadRequestError as BadRequestError30, logger as logger33 } from "@7365admin1/node-server-utils";
|
|
7296
7306
|
import { AppServiceType as AppServiceType18 } from "@7365admin1/core";
|
|
7297
7307
|
function useScheduleTaskController() {
|
|
@@ -7322,12 +7332,12 @@ function useScheduleTaskController() {
|
|
|
7322
7332
|
}
|
|
7323
7333
|
async function getScheduleTasks(req, res, next) {
|
|
7324
7334
|
const query = { ...req.query, ...req.params };
|
|
7325
|
-
const validation =
|
|
7326
|
-
page:
|
|
7327
|
-
limit:
|
|
7328
|
-
search:
|
|
7329
|
-
site:
|
|
7330
|
-
serviceType:
|
|
7335
|
+
const validation = Joi18.object({
|
|
7336
|
+
page: Joi18.number().min(1).optional().allow("", null),
|
|
7337
|
+
limit: Joi18.number().min(1).optional().allow("", null),
|
|
7338
|
+
search: Joi18.string().optional().allow("", null),
|
|
7339
|
+
site: Joi18.string().hex().required(),
|
|
7340
|
+
serviceType: Joi18.string().valid(...Object.values(AppServiceType18)).required()
|
|
7331
7341
|
});
|
|
7332
7342
|
const { error } = validation.validate(query);
|
|
7333
7343
|
if (error) {
|
|
@@ -7357,7 +7367,7 @@ function useScheduleTaskController() {
|
|
|
7357
7367
|
}
|
|
7358
7368
|
}
|
|
7359
7369
|
async function getScheduleTaskById(req, res, next) {
|
|
7360
|
-
const validation =
|
|
7370
|
+
const validation = Joi18.string().hex().required();
|
|
7361
7371
|
const _id = req.params.id;
|
|
7362
7372
|
const { error, value } = validation.validate(_id);
|
|
7363
7373
|
if (error) {
|
|
@@ -7377,18 +7387,18 @@ function useScheduleTaskController() {
|
|
|
7377
7387
|
}
|
|
7378
7388
|
async function updateScheduleTask(req, res, next) {
|
|
7379
7389
|
const payload = { id: req.params.id, ...req.body };
|
|
7380
|
-
const validation =
|
|
7381
|
-
id:
|
|
7382
|
-
title:
|
|
7383
|
-
time:
|
|
7384
|
-
dates:
|
|
7385
|
-
|
|
7390
|
+
const validation = Joi18.object({
|
|
7391
|
+
id: Joi18.string().hex().required(),
|
|
7392
|
+
title: Joi18.string().optional().allow("", null),
|
|
7393
|
+
time: Joi18.string().pattern(/^([0-1]\d|2[0-3]):([0-5]\d)$/).optional().allow("", null),
|
|
7394
|
+
dates: Joi18.array().min(1).items(
|
|
7395
|
+
Joi18.string().pattern(/^\d{4}-\d{2}-\d{2}$/).required()
|
|
7386
7396
|
).optional(),
|
|
7387
|
-
description:
|
|
7388
|
-
areas:
|
|
7389
|
-
|
|
7390
|
-
name:
|
|
7391
|
-
value:
|
|
7397
|
+
description: Joi18.string().optional().allow("", null),
|
|
7398
|
+
areas: Joi18.array().min(1).items(
|
|
7399
|
+
Joi18.object({
|
|
7400
|
+
name: Joi18.string().required(),
|
|
7401
|
+
value: Joi18.any().required()
|
|
7392
7402
|
})
|
|
7393
7403
|
).optional()
|
|
7394
7404
|
});
|
|
@@ -7410,7 +7420,7 @@ function useScheduleTaskController() {
|
|
|
7410
7420
|
}
|
|
7411
7421
|
}
|
|
7412
7422
|
async function deleteScheduleTask(req, res, next) {
|
|
7413
|
-
const validation =
|
|
7423
|
+
const validation = Joi18.string().hex().required();
|
|
7414
7424
|
const _id = req.params.id;
|
|
7415
7425
|
const { error, value } = validation.validate(_id);
|
|
7416
7426
|
if (error) {
|
|
@@ -7654,17 +7664,17 @@ function useQRService() {
|
|
|
7654
7664
|
}
|
|
7655
7665
|
|
|
7656
7666
|
// src/controllers/hygiene-qr.controller.ts
|
|
7657
|
-
import
|
|
7667
|
+
import Joi19 from "joi";
|
|
7658
7668
|
import { BadRequestError as BadRequestError31, logger as logger35 } from "@7365admin1/node-server-utils";
|
|
7659
7669
|
function useQRController() {
|
|
7660
7670
|
const { generateQRImage: _generateQRImage, generateQRPDF: _generateQRPDF } = useQRService();
|
|
7661
7671
|
async function generateQR(req, res, next) {
|
|
7662
|
-
const validation =
|
|
7663
|
-
url:
|
|
7664
|
-
filename:
|
|
7665
|
-
title:
|
|
7666
|
-
subtitle:
|
|
7667
|
-
download:
|
|
7672
|
+
const validation = Joi19.object({
|
|
7673
|
+
url: Joi19.string().uri().required(),
|
|
7674
|
+
filename: Joi19.string().optional().allow("", null),
|
|
7675
|
+
title: Joi19.string().optional().allow("", null),
|
|
7676
|
+
subtitle: Joi19.string().optional().allow("", null),
|
|
7677
|
+
download: Joi19.boolean().optional().default(false)
|
|
7668
7678
|
});
|
|
7669
7679
|
const query = { ...req.query };
|
|
7670
7680
|
const { error, value } = validation.validate(query);
|