@7365admin1/module-hygiene 4.29.1-staging.12 → 4.29.1-staging.14
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/.changeset/area-import-unit-ids.md +5 -0
- package/.changeset/checklist-photo-set-finish-approve-reject.md +9 -0
- package/.changeset/photo-required-only-on-completion.md +9 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +348 -296
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +348 -296
- 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 +161 -117
package/dist/index.js
CHANGED
|
@@ -924,21 +924,30 @@ function useHygieneDashboardController() {
|
|
|
924
924
|
}
|
|
925
925
|
|
|
926
926
|
// src/models/hygiene-area.model.ts
|
|
927
|
-
var
|
|
927
|
+
var import_joi3 = __toESM(require("joi"));
|
|
928
928
|
var import_mongodb2 = require("mongodb");
|
|
929
929
|
var import_node_server_utils3 = require("@7365admin1/node-server-utils");
|
|
930
930
|
var import_core2 = require("@7365admin1/core");
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
931
|
+
|
|
932
|
+
// src/utils/area-unit.util.ts
|
|
933
|
+
var import_joi2 = __toESM(require("joi"));
|
|
934
|
+
var areaUnitSchema = import_joi2.default.object({
|
|
935
|
+
unit: import_joi2.default.string().hex().required(),
|
|
936
|
+
name: import_joi2.default.string().required()
|
|
937
|
+
});
|
|
938
|
+
function toAreaUnit(unit) {
|
|
939
|
+
return { unit: String(unit._id), name: unit.name };
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
// src/models/hygiene-area.model.ts
|
|
943
|
+
var areaSchema = import_joi3.default.object({
|
|
944
|
+
site: import_joi3.default.string().hex().required(),
|
|
945
|
+
serviceType: import_joi3.default.string().valid(...Object.values(import_core2.AppServiceType)).required(),
|
|
946
|
+
name: import_joi3.default.string().required(),
|
|
947
|
+
type: import_joi3.default.string().valid(...allowedTypes).required(),
|
|
948
|
+
set: import_joi3.default.number().min(0).optional(),
|
|
949
|
+
units: import_joi3.default.array().items(
|
|
950
|
+
areaUnitSchema.optional()
|
|
942
951
|
).min(1).unique("unit", { ignoreUndefined: true }).messages({
|
|
943
952
|
"array.unique": "Duplicate area units are not allowed"
|
|
944
953
|
})
|
|
@@ -1431,14 +1440,14 @@ var import_mongodb5 = require("mongodb");
|
|
|
1431
1440
|
var import_node_server_utils7 = require("@7365admin1/node-server-utils");
|
|
1432
1441
|
|
|
1433
1442
|
// src/models/hygiene-unit.model.ts
|
|
1434
|
-
var
|
|
1443
|
+
var import_joi4 = __toESM(require("joi"));
|
|
1435
1444
|
var import_mongodb4 = require("mongodb");
|
|
1436
1445
|
var import_node_server_utils6 = require("@7365admin1/node-server-utils");
|
|
1437
1446
|
var import_core3 = require("@7365admin1/core");
|
|
1438
|
-
var unitSchema =
|
|
1439
|
-
site:
|
|
1440
|
-
serviceType:
|
|
1441
|
-
name:
|
|
1447
|
+
var unitSchema = import_joi4.default.object({
|
|
1448
|
+
site: import_joi4.default.string().hex().required(),
|
|
1449
|
+
serviceType: import_joi4.default.string().valid(...Object.values(import_core3.AppServiceType)).required(),
|
|
1450
|
+
name: import_joi4.default.string().required()
|
|
1442
1451
|
});
|
|
1443
1452
|
function MUnit(value) {
|
|
1444
1453
|
const { error } = unitSchema.validate(value);
|
|
@@ -1773,10 +1782,7 @@ function useAreaService() {
|
|
|
1773
1782
|
}
|
|
1774
1783
|
}
|
|
1775
1784
|
if (foundUnit) {
|
|
1776
|
-
areaUnits.push(
|
|
1777
|
-
unit: foundUnit._id,
|
|
1778
|
-
name: foundUnit.name
|
|
1779
|
-
});
|
|
1785
|
+
areaUnits.push(toAreaUnit(foundUnit));
|
|
1780
1786
|
}
|
|
1781
1787
|
}
|
|
1782
1788
|
if (areaUnits.length > 0) {
|
|
@@ -1873,7 +1879,7 @@ function useAreaService() {
|
|
|
1873
1879
|
}
|
|
1874
1880
|
|
|
1875
1881
|
// src/controllers/hygiene-area.controller.ts
|
|
1876
|
-
var
|
|
1882
|
+
var import_joi5 = __toESM(require("joi"));
|
|
1877
1883
|
var import_node_server_utils9 = require("@7365admin1/node-server-utils");
|
|
1878
1884
|
var import_core4 = require("@7365admin1/core");
|
|
1879
1885
|
|
|
@@ -1934,13 +1940,13 @@ function useAreaController() {
|
|
|
1934
1940
|
}
|
|
1935
1941
|
async function getAreas(req, res, next) {
|
|
1936
1942
|
const query = { ...req.query, ...req.params };
|
|
1937
|
-
const validation =
|
|
1938
|
-
page:
|
|
1939
|
-
limit:
|
|
1940
|
-
search:
|
|
1941
|
-
type:
|
|
1942
|
-
site:
|
|
1943
|
-
serviceType:
|
|
1943
|
+
const validation = import_joi5.default.object({
|
|
1944
|
+
page: import_joi5.default.number().min(1).optional().allow("", null),
|
|
1945
|
+
limit: import_joi5.default.number().min(1).optional().allow("", null),
|
|
1946
|
+
search: import_joi5.default.string().optional().allow("", null),
|
|
1947
|
+
type: import_joi5.default.string().valid("all", ...allowedTypes).optional().allow("", null),
|
|
1948
|
+
site: import_joi5.default.string().hex().required(),
|
|
1949
|
+
serviceType: import_joi5.default.string().valid(...Object.values(import_core4.AppServiceType)).required()
|
|
1944
1950
|
});
|
|
1945
1951
|
const { error } = validation.validate(query);
|
|
1946
1952
|
if (error) {
|
|
@@ -1971,7 +1977,7 @@ function useAreaController() {
|
|
|
1971
1977
|
}
|
|
1972
1978
|
}
|
|
1973
1979
|
async function getAreaById(req, res, next) {
|
|
1974
|
-
const validation =
|
|
1980
|
+
const validation = import_joi5.default.string().hex().required();
|
|
1975
1981
|
const _id = req.params.id;
|
|
1976
1982
|
const { error, value } = validation.validate(_id);
|
|
1977
1983
|
if (error) {
|
|
@@ -1991,15 +1997,15 @@ function useAreaController() {
|
|
|
1991
1997
|
}
|
|
1992
1998
|
async function updateArea(req, res, next) {
|
|
1993
1999
|
const payload = { id: req.params.id, ...req.body };
|
|
1994
|
-
const schema =
|
|
1995
|
-
id:
|
|
1996
|
-
name:
|
|
1997
|
-
type:
|
|
1998
|
-
set:
|
|
1999
|
-
units:
|
|
2000
|
-
|
|
2001
|
-
unit:
|
|
2002
|
-
name:
|
|
2000
|
+
const schema = import_joi5.default.object({
|
|
2001
|
+
id: import_joi5.default.string().hex().required(),
|
|
2002
|
+
name: import_joi5.default.string().optional().allow("", null),
|
|
2003
|
+
type: import_joi5.default.string().optional().allow("", null, ...allowedTypes),
|
|
2004
|
+
set: import_joi5.default.number().min(0).optional(),
|
|
2005
|
+
units: import_joi5.default.array().items(
|
|
2006
|
+
import_joi5.default.object({
|
|
2007
|
+
unit: import_joi5.default.string().hex().required(),
|
|
2008
|
+
name: import_joi5.default.string().required()
|
|
2003
2009
|
}).required()
|
|
2004
2010
|
).min(1).unique("unit", { ignoreUndefined: true }).optional().messages({
|
|
2005
2011
|
"array.unique": "Duplicate area units are not allowed"
|
|
@@ -2024,7 +2030,7 @@ function useAreaController() {
|
|
|
2024
2030
|
}
|
|
2025
2031
|
async function deleteArea(req, res, next) {
|
|
2026
2032
|
const id = req.params.id;
|
|
2027
|
-
const validation =
|
|
2033
|
+
const validation = import_joi5.default.string().hex().required();
|
|
2028
2034
|
const { error, value } = validation.validate(id);
|
|
2029
2035
|
if (error) {
|
|
2030
2036
|
import_node_server_utils9.logger.log({ level: "error", message: error.message });
|
|
@@ -2047,9 +2053,9 @@ function useAreaController() {
|
|
|
2047
2053
|
return;
|
|
2048
2054
|
}
|
|
2049
2055
|
const query = { ...req.query, ...req.params };
|
|
2050
|
-
const validation =
|
|
2051
|
-
site:
|
|
2052
|
-
serviceType:
|
|
2056
|
+
const validation = import_joi5.default.object({
|
|
2057
|
+
site: import_joi5.default.string().hex().required(),
|
|
2058
|
+
serviceType: import_joi5.default.string().valid(...Object.values(import_core4.AppServiceType)).required()
|
|
2053
2059
|
});
|
|
2054
2060
|
const { error, value } = validation.validate(query);
|
|
2055
2061
|
if (error) {
|
|
@@ -2070,9 +2076,9 @@ function useAreaController() {
|
|
|
2070
2076
|
}
|
|
2071
2077
|
async function exportAreas(req, res, next) {
|
|
2072
2078
|
const query = { ...req.query, ...req.params };
|
|
2073
|
-
const validation =
|
|
2074
|
-
site:
|
|
2075
|
-
serviceType:
|
|
2079
|
+
const validation = import_joi5.default.object({
|
|
2080
|
+
site: import_joi5.default.string().hex().required(),
|
|
2081
|
+
serviceType: import_joi5.default.string().valid(...Object.values(import_core4.AppServiceType)).required()
|
|
2076
2082
|
});
|
|
2077
2083
|
const { error, value } = validation.validate(query);
|
|
2078
2084
|
if (error) {
|
|
@@ -2354,7 +2360,7 @@ function useUnitService() {
|
|
|
2354
2360
|
}
|
|
2355
2361
|
|
|
2356
2362
|
// src/controllers/hygiene-unit.controller.ts
|
|
2357
|
-
var
|
|
2363
|
+
var import_joi6 = __toESM(require("joi"));
|
|
2358
2364
|
var import_node_server_utils12 = require("@7365admin1/node-server-utils");
|
|
2359
2365
|
var import_core5 = require("@7365admin1/core");
|
|
2360
2366
|
function useUnitController() {
|
|
@@ -2385,12 +2391,12 @@ function useUnitController() {
|
|
|
2385
2391
|
}
|
|
2386
2392
|
async function getUnits(req, res, next) {
|
|
2387
2393
|
const query = { ...req.query, ...req.params };
|
|
2388
|
-
const validation =
|
|
2389
|
-
page:
|
|
2390
|
-
limit:
|
|
2391
|
-
search:
|
|
2392
|
-
site:
|
|
2393
|
-
serviceType:
|
|
2394
|
+
const validation = import_joi6.default.object({
|
|
2395
|
+
page: import_joi6.default.number().min(1).optional().allow("", null),
|
|
2396
|
+
limit: import_joi6.default.number().min(1).optional().allow("", null),
|
|
2397
|
+
search: import_joi6.default.string().optional().allow("", null),
|
|
2398
|
+
site: import_joi6.default.string().hex().required(),
|
|
2399
|
+
serviceType: import_joi6.default.string().valid(...Object.values(import_core5.AppServiceType)).required()
|
|
2394
2400
|
});
|
|
2395
2401
|
const { error } = validation.validate(query);
|
|
2396
2402
|
if (error) {
|
|
@@ -2421,9 +2427,9 @@ function useUnitController() {
|
|
|
2421
2427
|
}
|
|
2422
2428
|
async function updateUnit(req, res, next) {
|
|
2423
2429
|
const payload = { id: req.params.id, ...req.body };
|
|
2424
|
-
const validation =
|
|
2425
|
-
id:
|
|
2426
|
-
name:
|
|
2430
|
+
const validation = import_joi6.default.object({
|
|
2431
|
+
id: import_joi6.default.string().hex().required(),
|
|
2432
|
+
name: import_joi6.default.string().required()
|
|
2427
2433
|
});
|
|
2428
2434
|
const { error } = validation.validate(payload);
|
|
2429
2435
|
if (error) {
|
|
@@ -2444,8 +2450,8 @@ function useUnitController() {
|
|
|
2444
2450
|
}
|
|
2445
2451
|
async function deleteUnit(req, res, next) {
|
|
2446
2452
|
const id = req.params.id;
|
|
2447
|
-
const validation =
|
|
2448
|
-
id:
|
|
2453
|
+
const validation = import_joi6.default.object({
|
|
2454
|
+
id: import_joi6.default.string().hex().required()
|
|
2449
2455
|
});
|
|
2450
2456
|
const { error, value } = validation.validate({ id });
|
|
2451
2457
|
if (error) {
|
|
@@ -2469,9 +2475,9 @@ function useUnitController() {
|
|
|
2469
2475
|
return;
|
|
2470
2476
|
}
|
|
2471
2477
|
const query = { ...req.query, ...req.params };
|
|
2472
|
-
const validation =
|
|
2473
|
-
site:
|
|
2474
|
-
serviceType:
|
|
2478
|
+
const validation = import_joi6.default.object({
|
|
2479
|
+
site: import_joi6.default.string().hex().required(),
|
|
2480
|
+
serviceType: import_joi6.default.string().valid(...Object.values(import_core5.AppServiceType)).required()
|
|
2475
2481
|
});
|
|
2476
2482
|
const { error, value } = validation.validate(query);
|
|
2477
2483
|
if (error) {
|
|
@@ -2492,9 +2498,9 @@ function useUnitController() {
|
|
|
2492
2498
|
}
|
|
2493
2499
|
async function exportUnits(req, res, next) {
|
|
2494
2500
|
const query = { ...req.query, ...req.params };
|
|
2495
|
-
const validation =
|
|
2496
|
-
site:
|
|
2497
|
-
serviceType:
|
|
2501
|
+
const validation = import_joi6.default.object({
|
|
2502
|
+
site: import_joi6.default.string().hex().required(),
|
|
2503
|
+
serviceType: import_joi6.default.string().valid(...Object.values(import_core5.AppServiceType)).required()
|
|
2498
2504
|
});
|
|
2499
2505
|
const { error, value } = validation.validate(query);
|
|
2500
2506
|
if (error) {
|
|
@@ -2537,15 +2543,15 @@ function useUnitController() {
|
|
|
2537
2543
|
}
|
|
2538
2544
|
|
|
2539
2545
|
// src/models/hygiene-parent-checklist.model.ts
|
|
2540
|
-
var
|
|
2546
|
+
var import_joi7 = __toESM(require("joi"));
|
|
2541
2547
|
var import_mongodb6 = require("mongodb");
|
|
2542
2548
|
var import_node_server_utils13 = require("@7365admin1/node-server-utils");
|
|
2543
2549
|
var import_core6 = require("@7365admin1/core");
|
|
2544
|
-
var parentChecklistSchema =
|
|
2545
|
-
createdAt:
|
|
2546
|
-
site:
|
|
2547
|
-
serviceType:
|
|
2548
|
-
dateStr:
|
|
2550
|
+
var parentChecklistSchema = import_joi7.default.object({
|
|
2551
|
+
createdAt: import_joi7.default.alternatives().try(import_joi7.default.date(), import_joi7.default.string()).optional().allow("", null),
|
|
2552
|
+
site: import_joi7.default.string().hex().required(),
|
|
2553
|
+
serviceType: import_joi7.default.string().valid(...Object.values(import_core6.AppServiceType)).required(),
|
|
2554
|
+
dateStr: import_joi7.default.string().optional().allow("", null)
|
|
2549
2555
|
});
|
|
2550
2556
|
function MParentChecklist(value) {
|
|
2551
2557
|
const { error } = parentChecklistSchema.validate(value);
|
|
@@ -3118,7 +3124,7 @@ function useParentChecklistRepo() {
|
|
|
3118
3124
|
}
|
|
3119
3125
|
|
|
3120
3126
|
// src/controllers/hygiene-parent-checklist.controller.ts
|
|
3121
|
-
var
|
|
3127
|
+
var import_joi8 = __toESM(require("joi"));
|
|
3122
3128
|
var import_node_server_utils15 = require("@7365admin1/node-server-utils");
|
|
3123
3129
|
var import_core8 = require("@7365admin1/core");
|
|
3124
3130
|
function useParentChecklistController() {
|
|
@@ -3128,10 +3134,10 @@ function useParentChecklistController() {
|
|
|
3128
3134
|
} = useParentChecklistRepo();
|
|
3129
3135
|
async function createParentChecklist(req, res, next) {
|
|
3130
3136
|
const payload = req.body;
|
|
3131
|
-
const validation =
|
|
3132
|
-
createdAt:
|
|
3133
|
-
site:
|
|
3134
|
-
serviceType:
|
|
3137
|
+
const validation = import_joi8.default.object({
|
|
3138
|
+
createdAt: import_joi8.default.alternatives().try(import_joi8.default.date(), import_joi8.default.string()).optional().allow("", null),
|
|
3139
|
+
site: import_joi8.default.string().hex().required(),
|
|
3140
|
+
serviceType: import_joi8.default.string().valid(...Object.values(import_core8.AppServiceType)).optional().allow("", null)
|
|
3135
3141
|
});
|
|
3136
3142
|
const { error } = validation.validate(payload);
|
|
3137
3143
|
if (error) {
|
|
@@ -3151,15 +3157,15 @@ function useParentChecklistController() {
|
|
|
3151
3157
|
}
|
|
3152
3158
|
async function getAllParentChecklist(req, res, next) {
|
|
3153
3159
|
const query = { ...req.query, ...req.params };
|
|
3154
|
-
const validation =
|
|
3155
|
-
page:
|
|
3156
|
-
limit:
|
|
3157
|
-
search:
|
|
3158
|
-
site:
|
|
3159
|
-
serviceType:
|
|
3160
|
-
startDate:
|
|
3161
|
-
endDate:
|
|
3162
|
-
status:
|
|
3160
|
+
const validation = import_joi8.default.object({
|
|
3161
|
+
page: import_joi8.default.number().min(1).optional().allow("", null),
|
|
3162
|
+
limit: import_joi8.default.number().min(1).optional().allow("", null),
|
|
3163
|
+
search: import_joi8.default.string().optional().allow("", null),
|
|
3164
|
+
site: import_joi8.default.string().hex().required(),
|
|
3165
|
+
serviceType: import_joi8.default.string().valid(...Object.values(import_core8.AppServiceType)).required(),
|
|
3166
|
+
startDate: import_joi8.default.alternatives().try(import_joi8.default.date(), import_joi8.default.string()).optional().allow("", null),
|
|
3167
|
+
endDate: import_joi8.default.alternatives().try(import_joi8.default.date(), import_joi8.default.string()).optional().allow("", null),
|
|
3168
|
+
status: import_joi8.default.string().valid(...allowedStatus, "all").optional().allow("", null)
|
|
3163
3169
|
});
|
|
3164
3170
|
const { error } = validation.validate(query);
|
|
3165
3171
|
if (error) {
|
|
@@ -3201,28 +3207,28 @@ function useParentChecklistController() {
|
|
|
3201
3207
|
}
|
|
3202
3208
|
|
|
3203
3209
|
// src/models/hygiene-area-checklist.model.ts
|
|
3204
|
-
var
|
|
3210
|
+
var import_joi9 = __toESM(require("joi"));
|
|
3205
3211
|
var import_mongodb8 = require("mongodb");
|
|
3206
3212
|
var import_node_server_utils16 = require("@7365admin1/node-server-utils");
|
|
3207
3213
|
var import_core9 = require("@7365admin1/core");
|
|
3208
3214
|
var allowedChecklistStatus = ["open", "completed", "closed"];
|
|
3209
|
-
var areaChecklistSchema =
|
|
3210
|
-
schedule:
|
|
3211
|
-
serviceType:
|
|
3212
|
-
area:
|
|
3213
|
-
name:
|
|
3214
|
-
type:
|
|
3215
|
-
checklist:
|
|
3216
|
-
|
|
3217
|
-
set:
|
|
3218
|
-
units:
|
|
3219
|
-
|
|
3220
|
-
unit:
|
|
3221
|
-
name:
|
|
3215
|
+
var areaChecklistSchema = import_joi9.default.object({
|
|
3216
|
+
schedule: import_joi9.default.string().hex().required(),
|
|
3217
|
+
serviceType: import_joi9.default.string().valid(...Object.values(import_core9.AppServiceType)).required(),
|
|
3218
|
+
area: import_joi9.default.string().hex().required(),
|
|
3219
|
+
name: import_joi9.default.string().required(),
|
|
3220
|
+
type: import_joi9.default.string().valid(...allowedTypes).required(),
|
|
3221
|
+
checklist: import_joi9.default.array().items(
|
|
3222
|
+
import_joi9.default.object({
|
|
3223
|
+
set: import_joi9.default.number().min(0).required(),
|
|
3224
|
+
units: import_joi9.default.array().items(
|
|
3225
|
+
import_joi9.default.object({
|
|
3226
|
+
unit: import_joi9.default.string().hex().required(),
|
|
3227
|
+
name: import_joi9.default.string().required()
|
|
3222
3228
|
}).required()
|
|
3223
3229
|
).min(1).required(),
|
|
3224
|
-
isScheduleTask:
|
|
3225
|
-
scheduleTaskId:
|
|
3230
|
+
isScheduleTask: import_joi9.default.boolean().optional().default(false),
|
|
3231
|
+
scheduleTaskId: import_joi9.default.string().hex().optional().allow(null)
|
|
3226
3232
|
}).required()
|
|
3227
3233
|
).optional().default([])
|
|
3228
3234
|
});
|
|
@@ -3288,6 +3294,39 @@ var import_core10 = require("@7365admin1/core");
|
|
|
3288
3294
|
// src/repositories/hygiene-area-checklist.repository.ts
|
|
3289
3295
|
var import_mongodb9 = require("mongodb");
|
|
3290
3296
|
var import_node_server_utils17 = require("@7365admin1/node-server-utils");
|
|
3297
|
+
|
|
3298
|
+
// src/utils/completion-photo.util.ts
|
|
3299
|
+
var COMPLETION_PHOTO_MESSAGE = "A photo is required to complete this task. Take or upload at least one photo before marking it complete.";
|
|
3300
|
+
function readCompletion(units, unitId) {
|
|
3301
|
+
if (units.length === 0)
|
|
3302
|
+
return { completesSet: false, hasEvidence: false };
|
|
3303
|
+
const others = units.filter((unit) => String(unit.unit) !== String(unitId));
|
|
3304
|
+
return {
|
|
3305
|
+
completesSet: others.every(
|
|
3306
|
+
(unit) => unit.approve === true || unit.reject === true
|
|
3307
|
+
),
|
|
3308
|
+
hasEvidence: others.some(
|
|
3309
|
+
(unit) => Array.isArray(unit.attachment) && unit.attachment.length > 0
|
|
3310
|
+
)
|
|
3311
|
+
};
|
|
3312
|
+
}
|
|
3313
|
+
function requiresCompletionPhoto({
|
|
3314
|
+
decision,
|
|
3315
|
+
attachment,
|
|
3316
|
+
completesSet,
|
|
3317
|
+
hasEvidence
|
|
3318
|
+
}) {
|
|
3319
|
+
if (decision !== "approve")
|
|
3320
|
+
return false;
|
|
3321
|
+
if (!completesSet)
|
|
3322
|
+
return false;
|
|
3323
|
+
if (hasEvidence)
|
|
3324
|
+
return false;
|
|
3325
|
+
const carriesEvidence = Array.isArray(attachment) && attachment.some((id) => typeof id === "string" && id.trim().length > 0);
|
|
3326
|
+
return !carriesEvidence;
|
|
3327
|
+
}
|
|
3328
|
+
|
|
3329
|
+
// src/repositories/hygiene-area-checklist.repository.ts
|
|
3291
3330
|
function useAreaChecklistRepo() {
|
|
3292
3331
|
const db = import_node_server_utils17.useAtlas.getDb();
|
|
3293
3332
|
if (!db) {
|
|
@@ -3359,7 +3398,11 @@ function useAreaChecklistRepo() {
|
|
|
3359
3398
|
const parentChecklistId = new import_mongodb9.ObjectId(value.schedule);
|
|
3360
3399
|
const areaId = new import_mongodb9.ObjectId(value.area);
|
|
3361
3400
|
const existingChecklist = await collection.findOne(
|
|
3362
|
-
{
|
|
3401
|
+
{
|
|
3402
|
+
schedule: parentChecklistId,
|
|
3403
|
+
area: areaId,
|
|
3404
|
+
serviceType: value.serviceType
|
|
3405
|
+
},
|
|
3363
3406
|
{ session }
|
|
3364
3407
|
);
|
|
3365
3408
|
if (existingChecklist) {
|
|
@@ -4115,6 +4158,21 @@ function useAreaChecklistRepo() {
|
|
|
4115
4158
|
throw error;
|
|
4116
4159
|
}
|
|
4117
4160
|
}
|
|
4161
|
+
async function readSetCompletionState(_id, set, unitId) {
|
|
4162
|
+
try {
|
|
4163
|
+
_id = new import_mongodb9.ObjectId(_id);
|
|
4164
|
+
} catch (error) {
|
|
4165
|
+
throw new import_node_server_utils17.BadRequestError("Invalid area checklist ID format.");
|
|
4166
|
+
}
|
|
4167
|
+
const doc = await collection.findOne(
|
|
4168
|
+
{ _id, "checklist.set": set },
|
|
4169
|
+
{ projection: { checklist: 1 } }
|
|
4170
|
+
);
|
|
4171
|
+
const group = (doc?.checklist ?? []).find(
|
|
4172
|
+
(entry) => entry.set === set
|
|
4173
|
+
);
|
|
4174
|
+
return readCompletion(group?.units ?? [], unitId);
|
|
4175
|
+
}
|
|
4118
4176
|
async function updateAreaChecklist(_id, value, session) {
|
|
4119
4177
|
try {
|
|
4120
4178
|
_id = new import_mongodb9.ObjectId(_id);
|
|
@@ -4399,6 +4457,7 @@ function useAreaChecklistRepo() {
|
|
|
4399
4457
|
updateAreaChecklist,
|
|
4400
4458
|
updateAreaChecklistStatus,
|
|
4401
4459
|
updateAreaChecklistUnits,
|
|
4460
|
+
readSetCompletionState,
|
|
4402
4461
|
getMaxSetNumberForArea,
|
|
4403
4462
|
closeExpiredAreaChecklists,
|
|
4404
4463
|
pushScheduleTaskSets,
|
|
@@ -4646,7 +4705,7 @@ function useAreaChecklistService() {
|
|
|
4646
4705
|
}
|
|
4647
4706
|
|
|
4648
4707
|
// src/controllers/hygiene-area-checklist.controller.ts
|
|
4649
|
-
var
|
|
4708
|
+
var import_joi10 = __toESM(require("joi"));
|
|
4650
4709
|
var import_node_server_utils20 = require("@7365admin1/node-server-utils");
|
|
4651
4710
|
var import_core11 = require("@7365admin1/core");
|
|
4652
4711
|
|
|
@@ -4870,7 +4929,8 @@ function useAreaChecklistController() {
|
|
|
4870
4929
|
getAllAreaChecklist: _getAllAreaChecklist,
|
|
4871
4930
|
getAreaChecklistHistory: _getAreaChecklistHistory,
|
|
4872
4931
|
getAreaChecklistHistoryDetails: _getAreaChecklistHistoryDetails,
|
|
4873
|
-
getAreaChecklistUnits: _getAreaChecklistUnits
|
|
4932
|
+
getAreaChecklistUnits: _getAreaChecklistUnits,
|
|
4933
|
+
readSetCompletionState: _readSetCompletionState
|
|
4874
4934
|
} = useAreaChecklistRepo();
|
|
4875
4935
|
const {
|
|
4876
4936
|
createAreaChecklist: _createAreaChecklist,
|
|
@@ -4886,9 +4946,9 @@ function useAreaChecklistController() {
|
|
|
4886
4946
|
site: req.params.site,
|
|
4887
4947
|
schedule: req.params.schedule
|
|
4888
4948
|
};
|
|
4889
|
-
const validation =
|
|
4890
|
-
site:
|
|
4891
|
-
schedule:
|
|
4949
|
+
const validation = import_joi10.default.object({
|
|
4950
|
+
site: import_joi10.default.string().hex().required(),
|
|
4951
|
+
schedule: import_joi10.default.string().hex().required()
|
|
4892
4952
|
});
|
|
4893
4953
|
const { error, value } = validation.validate(payload);
|
|
4894
4954
|
if (error) {
|
|
@@ -4908,14 +4968,14 @@ function useAreaChecklistController() {
|
|
|
4908
4968
|
}
|
|
4909
4969
|
async function getAllAreaChecklist(req, res, next) {
|
|
4910
4970
|
const query = { ...req.query, ...req.params };
|
|
4911
|
-
const validation =
|
|
4912
|
-
page:
|
|
4913
|
-
limit:
|
|
4914
|
-
search:
|
|
4915
|
-
type:
|
|
4916
|
-
status:
|
|
4917
|
-
schedule:
|
|
4918
|
-
serviceType:
|
|
4971
|
+
const validation = import_joi10.default.object({
|
|
4972
|
+
page: import_joi10.default.number().min(1).optional().allow("", null),
|
|
4973
|
+
limit: import_joi10.default.number().min(1).optional().allow("", null),
|
|
4974
|
+
search: import_joi10.default.string().optional().allow("", null),
|
|
4975
|
+
type: import_joi10.default.string().valid(...allowedTypes, "all").optional().allow("", null),
|
|
4976
|
+
status: import_joi10.default.string().valid(...allowedStatus, "all").optional().allow("", null),
|
|
4977
|
+
schedule: import_joi10.default.string().hex().required(),
|
|
4978
|
+
serviceType: import_joi10.default.string().valid(...Object.values(import_core11.AppServiceType)).required()
|
|
4919
4979
|
});
|
|
4920
4980
|
const { error } = validation.validate(query);
|
|
4921
4981
|
if (error) {
|
|
@@ -4950,14 +5010,14 @@ function useAreaChecklistController() {
|
|
|
4950
5010
|
}
|
|
4951
5011
|
async function getAreaChecklistHistory(req, res, next) {
|
|
4952
5012
|
const query = { ...req.query, ...req.params };
|
|
4953
|
-
const validation =
|
|
4954
|
-
page:
|
|
4955
|
-
limit:
|
|
4956
|
-
search:
|
|
4957
|
-
type:
|
|
4958
|
-
schedule:
|
|
4959
|
-
status:
|
|
4960
|
-
createdAt:
|
|
5013
|
+
const validation = import_joi10.default.object({
|
|
5014
|
+
page: import_joi10.default.number().min(1).optional().allow("", null),
|
|
5015
|
+
limit: import_joi10.default.number().min(1).optional().allow("", null),
|
|
5016
|
+
search: import_joi10.default.string().optional().allow("", null),
|
|
5017
|
+
type: import_joi10.default.string().optional().allow("", ...allowedTypes),
|
|
5018
|
+
schedule: import_joi10.default.string().hex().required(),
|
|
5019
|
+
status: import_joi10.default.string().allow("", null, ...allowedStatus),
|
|
5020
|
+
createdAt: import_joi10.default.alternatives().try(import_joi10.default.date(), import_joi10.default.string()).optional().allow("", null)
|
|
4961
5021
|
});
|
|
4962
5022
|
const { error } = validation.validate(query);
|
|
4963
5023
|
if (error) {
|
|
@@ -4991,7 +5051,7 @@ function useAreaChecklistController() {
|
|
|
4991
5051
|
}
|
|
4992
5052
|
}
|
|
4993
5053
|
async function getAreaChecklistHistoryDetails(req, res, next) {
|
|
4994
|
-
const validation =
|
|
5054
|
+
const validation = import_joi10.default.string().hex().required();
|
|
4995
5055
|
const _id = req.params.id;
|
|
4996
5056
|
const { error, value } = validation.validate(_id);
|
|
4997
5057
|
if (error) {
|
|
@@ -5011,12 +5071,12 @@ function useAreaChecklistController() {
|
|
|
5011
5071
|
}
|
|
5012
5072
|
async function getAreaChecklistUnits(req, res, next) {
|
|
5013
5073
|
const query = { ...req.query, ...req.params };
|
|
5014
|
-
const validation =
|
|
5015
|
-
page:
|
|
5016
|
-
limit:
|
|
5017
|
-
search:
|
|
5018
|
-
serviceType:
|
|
5019
|
-
id:
|
|
5074
|
+
const validation = import_joi10.default.object({
|
|
5075
|
+
page: import_joi10.default.number().min(1).optional().allow("", null),
|
|
5076
|
+
limit: import_joi10.default.number().min(1).optional().allow("", null),
|
|
5077
|
+
search: import_joi10.default.string().optional().allow("", null),
|
|
5078
|
+
serviceType: import_joi10.default.string().valid(...Object.values(import_core11.AppServiceType)).required(),
|
|
5079
|
+
id: import_joi10.default.string().hex().required()
|
|
5020
5080
|
});
|
|
5021
5081
|
const { error } = validation.validate(query);
|
|
5022
5082
|
if (error) {
|
|
@@ -5066,46 +5126,21 @@ function useAreaChecklistController() {
|
|
|
5066
5126
|
...decisionValues,
|
|
5067
5127
|
completedBy
|
|
5068
5128
|
};
|
|
5069
|
-
const validation =
|
|
5070
|
-
id:
|
|
5071
|
-
set:
|
|
5072
|
-
unit:
|
|
5073
|
-
decision:
|
|
5074
|
-
approve:
|
|
5075
|
-
reject:
|
|
5076
|
-
remarks:
|
|
5129
|
+
const validation = import_joi10.default.object({
|
|
5130
|
+
id: import_joi10.default.string().hex().required(),
|
|
5131
|
+
set: import_joi10.default.number().integer().min(1).required(),
|
|
5132
|
+
unit: import_joi10.default.string().hex().required(),
|
|
5133
|
+
decision: import_joi10.default.string().valid("approve", "reject").required(),
|
|
5134
|
+
approve: import_joi10.default.boolean().optional(),
|
|
5135
|
+
reject: import_joi10.default.boolean().optional(),
|
|
5136
|
+
remarks: import_joi10.default.string().optional().allow("", null),
|
|
5077
5137
|
/*
|
|
5078
|
-
*
|
|
5079
|
-
*
|
|
5080
|
-
*
|
|
5081
|
-
* to take photo before completing the task ... all the services that has
|
|
5082
|
-
* this module must be the same process."*
|
|
5083
|
-
*
|
|
5084
|
-
* This endpoint is the one place every service and every client meets:
|
|
5085
|
-
* the five field apps (M&E, Cleaning, Landscape, Pest, Pool) all PATCH
|
|
5086
|
-
* `/api/hygiene-area-checklist/...` with a `serviceType`, and the web
|
|
5087
|
-
* checklist (`layer-common ManageChecklistMain`) posts here too. Requiring
|
|
5088
|
-
* it here is what makes "the same process" true rather than five client
|
|
5089
|
-
* guards that can drift apart — and a client guard alone is a suggestion.
|
|
5090
|
-
*
|
|
5091
|
-
* ONLY ON APPROVE. Completing a unit is the act the evidence is for.
|
|
5092
|
-
* A REJECT is the technician reporting a problem, and demanding a
|
|
5093
|
-
* photograph before somebody can report one would stop them reporting it.
|
|
5094
|
-
* `decision` carries which is which.
|
|
5095
|
-
*
|
|
5096
|
-
* At least one entry, and each must be a real id — an empty array or a
|
|
5097
|
-
* blank string would satisfy `.optional()` while carrying no evidence at
|
|
5098
|
-
* all, which is the shape a client sends when its uploader failed.
|
|
5138
|
+
* Shape only. WHETHER a photo is required depends on the set's current
|
|
5139
|
+
* state in the database, which Joi cannot see — see the check below.
|
|
5140
|
+
* Each entry must still be a real id: a blank string carries no evidence.
|
|
5099
5141
|
*/
|
|
5100
|
-
attachment:
|
|
5101
|
-
|
|
5102
|
-
then: import_joi9.default.array().min(1).required().messages({
|
|
5103
|
-
"array.min": "A photo is required to complete this task. Take or upload at least one photo before marking it complete.",
|
|
5104
|
-
"any.required": "A photo is required to complete this task. Take or upload at least one photo before marking it complete."
|
|
5105
|
-
}),
|
|
5106
|
-
otherwise: import_joi9.default.array().optional()
|
|
5107
|
-
}),
|
|
5108
|
-
completedBy: import_joi9.default.string().hex().required()
|
|
5142
|
+
attachment: import_joi10.default.array().items(import_joi10.default.string().trim().min(1)).optional(),
|
|
5143
|
+
completedBy: import_joi10.default.string().hex().required()
|
|
5109
5144
|
});
|
|
5110
5145
|
const { error } = validation.validate(payload);
|
|
5111
5146
|
if (error) {
|
|
@@ -5115,7 +5150,24 @@ function useAreaChecklistController() {
|
|
|
5115
5150
|
}
|
|
5116
5151
|
try {
|
|
5117
5152
|
const { id, set, unit, decision: decision2, ...value } = payload;
|
|
5118
|
-
|
|
5153
|
+
const setNumber = parseInt(set);
|
|
5154
|
+
if (decision2 === "approve") {
|
|
5155
|
+
const { completesSet, hasEvidence } = await _readSetCompletionState(
|
|
5156
|
+
id,
|
|
5157
|
+
setNumber,
|
|
5158
|
+
unit
|
|
5159
|
+
);
|
|
5160
|
+
if (requiresCompletionPhoto({
|
|
5161
|
+
decision: decision2,
|
|
5162
|
+
attachment: value.attachment,
|
|
5163
|
+
completesSet,
|
|
5164
|
+
hasEvidence
|
|
5165
|
+
})) {
|
|
5166
|
+
next(new import_node_server_utils20.BadRequestError(COMPLETION_PHOTO_MESSAGE));
|
|
5167
|
+
return;
|
|
5168
|
+
}
|
|
5169
|
+
}
|
|
5170
|
+
await _updateAreaChecklistUnits(id, setNumber, unit, value);
|
|
5119
5171
|
res.json({ message: "Area checklist updated successfully." });
|
|
5120
5172
|
return;
|
|
5121
5173
|
} catch (error2) {
|
|
@@ -5125,7 +5177,7 @@ function useAreaChecklistController() {
|
|
|
5125
5177
|
}
|
|
5126
5178
|
}
|
|
5127
5179
|
async function downloadChecklistPdf(req, res, next) {
|
|
5128
|
-
const validation =
|
|
5180
|
+
const validation = import_joi10.default.string().hex().required();
|
|
5129
5181
|
const schedule = req.params.schedule;
|
|
5130
5182
|
const { error, value } = validation.validate(schedule);
|
|
5131
5183
|
if (error) {
|
|
@@ -5171,16 +5223,16 @@ function useAreaChecklistController() {
|
|
|
5171
5223
|
}
|
|
5172
5224
|
|
|
5173
5225
|
// src/models/hygiene-supply.model.ts
|
|
5174
|
-
var
|
|
5226
|
+
var import_joi11 = __toESM(require("joi"));
|
|
5175
5227
|
var import_mongodb12 = require("mongodb");
|
|
5176
5228
|
var import_node_server_utils21 = require("@7365admin1/node-server-utils");
|
|
5177
5229
|
var import_core12 = require("@7365admin1/core");
|
|
5178
|
-
var supplySchema =
|
|
5179
|
-
site:
|
|
5180
|
-
serviceType:
|
|
5181
|
-
name:
|
|
5182
|
-
unitOfMeasurement:
|
|
5183
|
-
attachment:
|
|
5230
|
+
var supplySchema = import_joi11.default.object({
|
|
5231
|
+
site: import_joi11.default.string().hex().required(),
|
|
5232
|
+
serviceType: import_joi11.default.string().valid(...Object.values(import_core12.AppServiceType)).required(),
|
|
5233
|
+
name: import_joi11.default.string().required(),
|
|
5234
|
+
unitOfMeasurement: import_joi11.default.string().required(),
|
|
5235
|
+
attachment: import_joi11.default.string().allow(null, "").optional()
|
|
5184
5236
|
});
|
|
5185
5237
|
function MSupply(value) {
|
|
5186
5238
|
const { error } = supplySchema.validate(value);
|
|
@@ -5470,7 +5522,7 @@ function useSupplyRepository() {
|
|
|
5470
5522
|
}
|
|
5471
5523
|
|
|
5472
5524
|
// src/controllers/hygiene-supply.controller.ts
|
|
5473
|
-
var
|
|
5525
|
+
var import_joi12 = __toESM(require("joi"));
|
|
5474
5526
|
var import_node_server_utils23 = require("@7365admin1/node-server-utils");
|
|
5475
5527
|
var import_core13 = require("@7365admin1/core");
|
|
5476
5528
|
function useSupplyController() {
|
|
@@ -5501,12 +5553,12 @@ function useSupplyController() {
|
|
|
5501
5553
|
}
|
|
5502
5554
|
async function getSupplies(req, res, next) {
|
|
5503
5555
|
const query = { ...req.query, ...req.params };
|
|
5504
|
-
const validation =
|
|
5505
|
-
page:
|
|
5506
|
-
limit:
|
|
5507
|
-
search:
|
|
5508
|
-
site:
|
|
5509
|
-
serviceType:
|
|
5556
|
+
const validation = import_joi12.default.object({
|
|
5557
|
+
page: import_joi12.default.number().min(1).optional().allow("", null),
|
|
5558
|
+
limit: import_joi12.default.number().min(1).optional().allow("", null),
|
|
5559
|
+
search: import_joi12.default.string().optional().allow("", null),
|
|
5560
|
+
site: import_joi12.default.string().hex().required(),
|
|
5561
|
+
serviceType: import_joi12.default.string().valid(...Object.values(import_core13.AppServiceType)).required()
|
|
5510
5562
|
});
|
|
5511
5563
|
const { error } = validation.validate(query);
|
|
5512
5564
|
if (error) {
|
|
@@ -5536,7 +5588,7 @@ function useSupplyController() {
|
|
|
5536
5588
|
}
|
|
5537
5589
|
}
|
|
5538
5590
|
async function getSupplyById(req, res, next) {
|
|
5539
|
-
const validation =
|
|
5591
|
+
const validation = import_joi12.default.string().hex().required();
|
|
5540
5592
|
const _id = req.params.id;
|
|
5541
5593
|
const { error, value } = validation.validate(_id);
|
|
5542
5594
|
if (error) {
|
|
@@ -5556,12 +5608,12 @@ function useSupplyController() {
|
|
|
5556
5608
|
}
|
|
5557
5609
|
async function updateSupply(req, res, next) {
|
|
5558
5610
|
const payload = { id: req.params.id, ...req.body };
|
|
5559
|
-
const validation =
|
|
5560
|
-
id:
|
|
5561
|
-
name:
|
|
5562
|
-
unitOfMeasurement:
|
|
5563
|
-
qty:
|
|
5564
|
-
attachment:
|
|
5611
|
+
const validation = import_joi12.default.object({
|
|
5612
|
+
id: import_joi12.default.string().hex().required(),
|
|
5613
|
+
name: import_joi12.default.string().optional().allow("", null),
|
|
5614
|
+
unitOfMeasurement: import_joi12.default.string().optional().allow("", null),
|
|
5615
|
+
qty: import_joi12.default.number().min(0).optional().allow("", null),
|
|
5616
|
+
attachment: import_joi12.default.string().optional().allow("", null)
|
|
5565
5617
|
});
|
|
5566
5618
|
const { error } = validation.validate(payload);
|
|
5567
5619
|
if (error) {
|
|
@@ -5582,7 +5634,7 @@ function useSupplyController() {
|
|
|
5582
5634
|
}
|
|
5583
5635
|
async function deleteSupply(req, res, next) {
|
|
5584
5636
|
const id = req.params.id;
|
|
5585
|
-
const validation =
|
|
5637
|
+
const validation = import_joi12.default.string().hex().required();
|
|
5586
5638
|
const { error, value } = validation.validate(id);
|
|
5587
5639
|
if (error) {
|
|
5588
5640
|
import_node_server_utils23.logger.log({ level: "error", message: error.message });
|
|
@@ -5609,18 +5661,18 @@ function useSupplyController() {
|
|
|
5609
5661
|
}
|
|
5610
5662
|
|
|
5611
5663
|
// src/models/hygiene-stock.model.ts
|
|
5612
|
-
var
|
|
5664
|
+
var import_joi13 = __toESM(require("joi"));
|
|
5613
5665
|
var import_mongodb14 = require("mongodb");
|
|
5614
5666
|
var import_node_server_utils24 = require("@7365admin1/node-server-utils");
|
|
5615
5667
|
var import_core14 = require("@7365admin1/core");
|
|
5616
|
-
var stockSchema =
|
|
5617
|
-
site:
|
|
5618
|
-
serviceType:
|
|
5619
|
-
supply:
|
|
5620
|
-
in:
|
|
5621
|
-
out:
|
|
5622
|
-
balance:
|
|
5623
|
-
remarks:
|
|
5668
|
+
var stockSchema = import_joi13.default.object({
|
|
5669
|
+
site: import_joi13.default.string().hex().required(),
|
|
5670
|
+
serviceType: import_joi13.default.string().valid(...Object.values(import_core14.AppServiceType)).required(),
|
|
5671
|
+
supply: import_joi13.default.string().hex().required(),
|
|
5672
|
+
in: import_joi13.default.number().min(0).optional(),
|
|
5673
|
+
out: import_joi13.default.number().min(0).optional(),
|
|
5674
|
+
balance: import_joi13.default.number().min(0).required(),
|
|
5675
|
+
remarks: import_joi13.default.string().optional().allow("", null)
|
|
5624
5676
|
});
|
|
5625
5677
|
function MStock(value) {
|
|
5626
5678
|
const { error } = stockSchema.validate(value);
|
|
@@ -5835,7 +5887,7 @@ function useStockService() {
|
|
|
5835
5887
|
}
|
|
5836
5888
|
|
|
5837
5889
|
// src/controllers/hygiene-stock.controller.ts
|
|
5838
|
-
var
|
|
5890
|
+
var import_joi14 = __toESM(require("joi"));
|
|
5839
5891
|
var import_node_server_utils27 = require("@7365admin1/node-server-utils");
|
|
5840
5892
|
var import_core15 = require("@7365admin1/core");
|
|
5841
5893
|
function useStockController() {
|
|
@@ -5843,12 +5895,12 @@ function useStockController() {
|
|
|
5843
5895
|
const { createStock: _createStock } = useStockService();
|
|
5844
5896
|
async function createStock(req, res, next) {
|
|
5845
5897
|
const payload = { ...req.body, ...req.params };
|
|
5846
|
-
const validation =
|
|
5847
|
-
site:
|
|
5848
|
-
serviceType:
|
|
5849
|
-
supply:
|
|
5850
|
-
qty:
|
|
5851
|
-
remarks:
|
|
5898
|
+
const validation = import_joi14.default.object({
|
|
5899
|
+
site: import_joi14.default.string().hex().required(),
|
|
5900
|
+
serviceType: import_joi14.default.string().valid(...Object.values(import_core15.AppServiceType)).required(),
|
|
5901
|
+
supply: import_joi14.default.string().hex().required(),
|
|
5902
|
+
qty: import_joi14.default.number().min(0).required(),
|
|
5903
|
+
remarks: import_joi14.default.string().optional().allow("", null)
|
|
5852
5904
|
});
|
|
5853
5905
|
const { error } = validation.validate(payload);
|
|
5854
5906
|
if (error) {
|
|
@@ -5868,13 +5920,13 @@ function useStockController() {
|
|
|
5868
5920
|
}
|
|
5869
5921
|
async function getStocksBySupplyId(req, res, next) {
|
|
5870
5922
|
const query = { ...req.query, ...req.params };
|
|
5871
|
-
const validation =
|
|
5872
|
-
page:
|
|
5873
|
-
limit:
|
|
5874
|
-
search:
|
|
5875
|
-
site:
|
|
5876
|
-
serviceType:
|
|
5877
|
-
supply:
|
|
5923
|
+
const validation = import_joi14.default.object({
|
|
5924
|
+
page: import_joi14.default.number().min(1).optional().allow("", null),
|
|
5925
|
+
limit: import_joi14.default.number().min(1).optional().allow("", null),
|
|
5926
|
+
search: import_joi14.default.string().optional().allow("", null),
|
|
5927
|
+
site: import_joi14.default.string().hex().required(),
|
|
5928
|
+
serviceType: import_joi14.default.string().valid(...Object.values(import_core15.AppServiceType)).required(),
|
|
5929
|
+
supply: import_joi14.default.string().hex().required()
|
|
5878
5930
|
});
|
|
5879
5931
|
const { error } = validation.validate(query);
|
|
5880
5932
|
if (error) {
|
|
@@ -5936,21 +5988,21 @@ async function applyCheckOutDecision(decision, decide, returnStock) {
|
|
|
5936
5988
|
}
|
|
5937
5989
|
|
|
5938
5990
|
// src/models/hygiene-checkout-item.model.ts
|
|
5939
|
-
var
|
|
5991
|
+
var import_joi15 = __toESM(require("joi"));
|
|
5940
5992
|
var import_mongodb16 = require("mongodb");
|
|
5941
5993
|
var import_node_server_utils28 = require("@7365admin1/node-server-utils");
|
|
5942
5994
|
var import_core16 = require("@7365admin1/core");
|
|
5943
5995
|
var allowedCheckOutItemStatus = ["pending", "completed"];
|
|
5944
|
-
var checkOutItemSchema =
|
|
5945
|
-
site:
|
|
5946
|
-
serviceType:
|
|
5947
|
-
supply:
|
|
5948
|
-
supplyName:
|
|
5949
|
-
supplyQty:
|
|
5950
|
-
qty:
|
|
5951
|
-
attachment:
|
|
5952
|
-
createdBy:
|
|
5953
|
-
createdByName:
|
|
5996
|
+
var checkOutItemSchema = import_joi15.default.object({
|
|
5997
|
+
site: import_joi15.default.string().hex().required(),
|
|
5998
|
+
serviceType: import_joi15.default.string().valid(...Object.values(import_core16.AppServiceType)).required(),
|
|
5999
|
+
supply: import_joi15.default.string().hex().required(),
|
|
6000
|
+
supplyName: import_joi15.default.string().required(),
|
|
6001
|
+
supplyQty: import_joi15.default.number().min(0).required(),
|
|
6002
|
+
qty: import_joi15.default.number().min(0).required(),
|
|
6003
|
+
attachment: import_joi15.default.array().items(import_joi15.default.string()).optional().allow(null),
|
|
6004
|
+
createdBy: import_joi15.default.string().hex().required(),
|
|
6005
|
+
createdByName: import_joi15.default.string().required()
|
|
5954
6006
|
});
|
|
5955
6007
|
function MCheckOutItem(value) {
|
|
5956
6008
|
const { error } = checkOutItemSchema.validate(value);
|
|
@@ -6430,7 +6482,7 @@ function useCheckOutItemService() {
|
|
|
6430
6482
|
}
|
|
6431
6483
|
|
|
6432
6484
|
// src/controllers/hygiene-checkout-item.controller.ts
|
|
6433
|
-
var
|
|
6485
|
+
var import_joi16 = __toESM(require("joi"));
|
|
6434
6486
|
var import_node_server_utils31 = require("@7365admin1/node-server-utils");
|
|
6435
6487
|
var import_core18 = require("@7365admin1/core");
|
|
6436
6488
|
function useCheckOutItemController() {
|
|
@@ -6454,13 +6506,13 @@ function useCheckOutItemController() {
|
|
|
6454
6506
|
...req.params,
|
|
6455
6507
|
createdBy
|
|
6456
6508
|
};
|
|
6457
|
-
const validation =
|
|
6458
|
-
site:
|
|
6459
|
-
serviceType:
|
|
6460
|
-
supply:
|
|
6461
|
-
qty:
|
|
6462
|
-
attachment:
|
|
6463
|
-
createdBy:
|
|
6509
|
+
const validation = import_joi16.default.object({
|
|
6510
|
+
site: import_joi16.default.string().hex().required(),
|
|
6511
|
+
serviceType: import_joi16.default.string().valid(...Object.values(import_core18.AppServiceType)).required(),
|
|
6512
|
+
supply: import_joi16.default.string().hex().required(),
|
|
6513
|
+
qty: import_joi16.default.number().min(0).required(),
|
|
6514
|
+
attachment: import_joi16.default.array().items(import_joi16.default.string()).optional().allow(null),
|
|
6515
|
+
createdBy: import_joi16.default.string().hex().required()
|
|
6464
6516
|
});
|
|
6465
6517
|
const { error } = validation.validate(payload);
|
|
6466
6518
|
if (error) {
|
|
@@ -6489,15 +6541,15 @@ function useCheckOutItemController() {
|
|
|
6489
6541
|
...req.params,
|
|
6490
6542
|
createdBy
|
|
6491
6543
|
};
|
|
6492
|
-
const validation =
|
|
6493
|
-
site:
|
|
6494
|
-
serviceType:
|
|
6495
|
-
createdBy:
|
|
6496
|
-
items:
|
|
6497
|
-
|
|
6498
|
-
supply:
|
|
6499
|
-
qty:
|
|
6500
|
-
attachment:
|
|
6544
|
+
const validation = import_joi16.default.object({
|
|
6545
|
+
site: import_joi16.default.string().hex().required(),
|
|
6546
|
+
serviceType: import_joi16.default.string().valid(...Object.values(import_core18.AppServiceType)).required(),
|
|
6547
|
+
createdBy: import_joi16.default.string().hex().required(),
|
|
6548
|
+
items: import_joi16.default.array().items(
|
|
6549
|
+
import_joi16.default.object({
|
|
6550
|
+
supply: import_joi16.default.string().hex().required(),
|
|
6551
|
+
qty: import_joi16.default.number().min(0).required(),
|
|
6552
|
+
attachment: import_joi16.default.array().items(import_joi16.default.string()).optional().allow(null)
|
|
6501
6553
|
})
|
|
6502
6554
|
).min(1).required()
|
|
6503
6555
|
});
|
|
@@ -6519,12 +6571,12 @@ function useCheckOutItemController() {
|
|
|
6519
6571
|
}
|
|
6520
6572
|
async function getCheckOutItems(req, res, next) {
|
|
6521
6573
|
const query = { ...req.query, ...req.params };
|
|
6522
|
-
const validation =
|
|
6523
|
-
page:
|
|
6524
|
-
limit:
|
|
6525
|
-
search:
|
|
6526
|
-
site:
|
|
6527
|
-
serviceType:
|
|
6574
|
+
const validation = import_joi16.default.object({
|
|
6575
|
+
page: import_joi16.default.number().min(1).optional().allow("", null),
|
|
6576
|
+
limit: import_joi16.default.number().min(1).optional().allow("", null),
|
|
6577
|
+
search: import_joi16.default.string().optional().allow("", null),
|
|
6578
|
+
site: import_joi16.default.string().hex().required(),
|
|
6579
|
+
serviceType: import_joi16.default.string().valid(...Object.values(import_core18.AppServiceType)).required()
|
|
6528
6580
|
});
|
|
6529
6581
|
const { error } = validation.validate(query);
|
|
6530
6582
|
if (error) {
|
|
@@ -6554,7 +6606,7 @@ function useCheckOutItemController() {
|
|
|
6554
6606
|
}
|
|
6555
6607
|
}
|
|
6556
6608
|
async function getCheckOutItemById(req, res, next) {
|
|
6557
|
-
const validation =
|
|
6609
|
+
const validation = import_joi16.default.string().hex().required();
|
|
6558
6610
|
const _id = req.params.id;
|
|
6559
6611
|
const { error, value } = validation.validate(_id);
|
|
6560
6612
|
if (error) {
|
|
@@ -6593,13 +6645,13 @@ function useCheckOutItemController() {
|
|
|
6593
6645
|
...decisionValues,
|
|
6594
6646
|
completedBy
|
|
6595
6647
|
};
|
|
6596
|
-
const validation =
|
|
6597
|
-
id:
|
|
6598
|
-
decision:
|
|
6599
|
-
approve:
|
|
6600
|
-
reject:
|
|
6601
|
-
remarks:
|
|
6602
|
-
completedBy:
|
|
6648
|
+
const validation = import_joi16.default.object({
|
|
6649
|
+
id: import_joi16.default.string().hex().required(),
|
|
6650
|
+
decision: import_joi16.default.string().valid("approve", "disapprove").required(),
|
|
6651
|
+
approve: import_joi16.default.boolean().required(),
|
|
6652
|
+
reject: import_joi16.default.boolean().required(),
|
|
6653
|
+
remarks: import_joi16.default.string().optional().allow("", null),
|
|
6654
|
+
completedBy: import_joi16.default.string().hex().required()
|
|
6603
6655
|
});
|
|
6604
6656
|
const { error } = validation.validate(payload);
|
|
6605
6657
|
if (error) {
|
|
@@ -6632,21 +6684,21 @@ function useCheckOutItemController() {
|
|
|
6632
6684
|
// src/models/hygiene-schedule-task.model.ts
|
|
6633
6685
|
var import_node_server_utils32 = require("@7365admin1/node-server-utils");
|
|
6634
6686
|
var import_core19 = require("@7365admin1/core");
|
|
6635
|
-
var
|
|
6687
|
+
var import_joi17 = __toESM(require("joi"));
|
|
6636
6688
|
var import_mongodb18 = require("mongodb");
|
|
6637
|
-
var scheduleTaskSchema =
|
|
6638
|
-
site:
|
|
6639
|
-
serviceType:
|
|
6640
|
-
title:
|
|
6641
|
-
time:
|
|
6642
|
-
dates:
|
|
6643
|
-
|
|
6689
|
+
var scheduleTaskSchema = import_joi17.default.object({
|
|
6690
|
+
site: import_joi17.default.string().hex().required(),
|
|
6691
|
+
serviceType: import_joi17.default.string().valid(...Object.values(import_core19.AppServiceType)).required(),
|
|
6692
|
+
title: import_joi17.default.string().required(),
|
|
6693
|
+
time: import_joi17.default.string().pattern(/^([0-1]\d|2[0-3]):([0-5]\d)$/).required(),
|
|
6694
|
+
dates: import_joi17.default.array().min(1).items(
|
|
6695
|
+
import_joi17.default.string().pattern(/^\d{4}-\d{2}-\d{2}$/).required()
|
|
6644
6696
|
).required(),
|
|
6645
|
-
description:
|
|
6646
|
-
areas:
|
|
6647
|
-
|
|
6648
|
-
name:
|
|
6649
|
-
value:
|
|
6697
|
+
description: import_joi17.default.string().optional().allow("", null),
|
|
6698
|
+
areas: import_joi17.default.array().min(1).items(
|
|
6699
|
+
import_joi17.default.object({
|
|
6700
|
+
name: import_joi17.default.string().required(),
|
|
6701
|
+
value: import_joi17.default.any().required()
|
|
6650
6702
|
})
|
|
6651
6703
|
).required()
|
|
6652
6704
|
});
|
|
@@ -7241,7 +7293,7 @@ function useScheduleTaskService() {
|
|
|
7241
7293
|
}
|
|
7242
7294
|
|
|
7243
7295
|
// src/controllers/hygiene-schedule-task.controller.ts
|
|
7244
|
-
var
|
|
7296
|
+
var import_joi18 = __toESM(require("joi"));
|
|
7245
7297
|
var import_node_server_utils35 = require("@7365admin1/node-server-utils");
|
|
7246
7298
|
var import_core20 = require("@7365admin1/core");
|
|
7247
7299
|
function useScheduleTaskController() {
|
|
@@ -7272,12 +7324,12 @@ function useScheduleTaskController() {
|
|
|
7272
7324
|
}
|
|
7273
7325
|
async function getScheduleTasks(req, res, next) {
|
|
7274
7326
|
const query = { ...req.query, ...req.params };
|
|
7275
|
-
const validation =
|
|
7276
|
-
page:
|
|
7277
|
-
limit:
|
|
7278
|
-
search:
|
|
7279
|
-
site:
|
|
7280
|
-
serviceType:
|
|
7327
|
+
const validation = import_joi18.default.object({
|
|
7328
|
+
page: import_joi18.default.number().min(1).optional().allow("", null),
|
|
7329
|
+
limit: import_joi18.default.number().min(1).optional().allow("", null),
|
|
7330
|
+
search: import_joi18.default.string().optional().allow("", null),
|
|
7331
|
+
site: import_joi18.default.string().hex().required(),
|
|
7332
|
+
serviceType: import_joi18.default.string().valid(...Object.values(import_core20.AppServiceType)).required()
|
|
7281
7333
|
});
|
|
7282
7334
|
const { error } = validation.validate(query);
|
|
7283
7335
|
if (error) {
|
|
@@ -7307,7 +7359,7 @@ function useScheduleTaskController() {
|
|
|
7307
7359
|
}
|
|
7308
7360
|
}
|
|
7309
7361
|
async function getScheduleTaskById(req, res, next) {
|
|
7310
|
-
const validation =
|
|
7362
|
+
const validation = import_joi18.default.string().hex().required();
|
|
7311
7363
|
const _id = req.params.id;
|
|
7312
7364
|
const { error, value } = validation.validate(_id);
|
|
7313
7365
|
if (error) {
|
|
@@ -7327,18 +7379,18 @@ function useScheduleTaskController() {
|
|
|
7327
7379
|
}
|
|
7328
7380
|
async function updateScheduleTask(req, res, next) {
|
|
7329
7381
|
const payload = { id: req.params.id, ...req.body };
|
|
7330
|
-
const validation =
|
|
7331
|
-
id:
|
|
7332
|
-
title:
|
|
7333
|
-
time:
|
|
7334
|
-
dates:
|
|
7335
|
-
|
|
7382
|
+
const validation = import_joi18.default.object({
|
|
7383
|
+
id: import_joi18.default.string().hex().required(),
|
|
7384
|
+
title: import_joi18.default.string().optional().allow("", null),
|
|
7385
|
+
time: import_joi18.default.string().pattern(/^([0-1]\d|2[0-3]):([0-5]\d)$/).optional().allow("", null),
|
|
7386
|
+
dates: import_joi18.default.array().min(1).items(
|
|
7387
|
+
import_joi18.default.string().pattern(/^\d{4}-\d{2}-\d{2}$/).required()
|
|
7336
7388
|
).optional(),
|
|
7337
|
-
description:
|
|
7338
|
-
areas:
|
|
7339
|
-
|
|
7340
|
-
name:
|
|
7341
|
-
value:
|
|
7389
|
+
description: import_joi18.default.string().optional().allow("", null),
|
|
7390
|
+
areas: import_joi18.default.array().min(1).items(
|
|
7391
|
+
import_joi18.default.object({
|
|
7392
|
+
name: import_joi18.default.string().required(),
|
|
7393
|
+
value: import_joi18.default.any().required()
|
|
7342
7394
|
})
|
|
7343
7395
|
).optional()
|
|
7344
7396
|
});
|
|
@@ -7360,7 +7412,7 @@ function useScheduleTaskController() {
|
|
|
7360
7412
|
}
|
|
7361
7413
|
}
|
|
7362
7414
|
async function deleteScheduleTask(req, res, next) {
|
|
7363
|
-
const validation =
|
|
7415
|
+
const validation = import_joi18.default.string().hex().required();
|
|
7364
7416
|
const _id = req.params.id;
|
|
7365
7417
|
const { error, value } = validation.validate(_id);
|
|
7366
7418
|
if (error) {
|
|
@@ -7604,17 +7656,17 @@ function useQRService() {
|
|
|
7604
7656
|
}
|
|
7605
7657
|
|
|
7606
7658
|
// src/controllers/hygiene-qr.controller.ts
|
|
7607
|
-
var
|
|
7659
|
+
var import_joi19 = __toESM(require("joi"));
|
|
7608
7660
|
var import_node_server_utils37 = require("@7365admin1/node-server-utils");
|
|
7609
7661
|
function useQRController() {
|
|
7610
7662
|
const { generateQRImage: _generateQRImage, generateQRPDF: _generateQRPDF } = useQRService();
|
|
7611
7663
|
async function generateQR(req, res, next) {
|
|
7612
|
-
const validation =
|
|
7613
|
-
url:
|
|
7614
|
-
filename:
|
|
7615
|
-
title:
|
|
7616
|
-
subtitle:
|
|
7617
|
-
download:
|
|
7664
|
+
const validation = import_joi19.default.object({
|
|
7665
|
+
url: import_joi19.default.string().uri().required(),
|
|
7666
|
+
filename: import_joi19.default.string().optional().allow("", null),
|
|
7667
|
+
title: import_joi19.default.string().optional().allow("", null),
|
|
7668
|
+
subtitle: import_joi19.default.string().optional().allow("", null),
|
|
7669
|
+
download: import_joi19.default.boolean().optional().default(false)
|
|
7618
7670
|
});
|
|
7619
7671
|
const query = { ...req.query };
|
|
7620
7672
|
const { error, value } = validation.validate(query);
|