@7365admin1/module-hygiene 4.29.1-staging.13 → 4.29.1-staging.15
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/search-input-bounds.md +5 -0
- package/dist/index.js +281 -270
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +281 -270
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/test/area-import-unit-id.test.mjs +18 -0
- package/test/escape-regex.util.test.mjs +26 -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
|
})
|
|
@@ -921,6 +930,11 @@ function capitalizeText(text) {
|
|
|
921
930
|
return text.toLowerCase().split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
922
931
|
}
|
|
923
932
|
|
|
933
|
+
// src/utils/escape-regex.util.ts
|
|
934
|
+
function escapeRegex(value) {
|
|
935
|
+
return String(value ?? "").replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
936
|
+
}
|
|
937
|
+
|
|
924
938
|
// src/repositories/hygiene-area.repository.ts
|
|
925
939
|
function useAreaRepo() {
|
|
926
940
|
const db = useAtlas2.getDb();
|
|
@@ -1017,7 +1031,7 @@ function useAreaRepo() {
|
|
|
1017
1031
|
cacheOptions.type = type;
|
|
1018
1032
|
}
|
|
1019
1033
|
if (search) {
|
|
1020
|
-
query.$or = [{ name: { $regex: search, $options: "i" } }];
|
|
1034
|
+
query.$or = [{ name: { $regex: escapeRegex(search), $options: "i" } }];
|
|
1021
1035
|
cacheOptions.search = search;
|
|
1022
1036
|
}
|
|
1023
1037
|
const cacheKey = makeCacheKey2(namespace_collection, cacheOptions);
|
|
@@ -1371,14 +1385,14 @@ import {
|
|
|
1371
1385
|
} from "@7365admin1/node-server-utils";
|
|
1372
1386
|
|
|
1373
1387
|
// src/models/hygiene-unit.model.ts
|
|
1374
|
-
import
|
|
1388
|
+
import Joi4 from "joi";
|
|
1375
1389
|
import { ObjectId as ObjectId4 } from "mongodb";
|
|
1376
1390
|
import { BadRequestError as BadRequestError5, logger as logger6 } from "@7365admin1/node-server-utils";
|
|
1377
1391
|
import { AppServiceType as AppServiceType3 } from "@7365admin1/core";
|
|
1378
|
-
var unitSchema =
|
|
1379
|
-
site:
|
|
1380
|
-
serviceType:
|
|
1381
|
-
name:
|
|
1392
|
+
var unitSchema = Joi4.object({
|
|
1393
|
+
site: Joi4.string().hex().required(),
|
|
1394
|
+
serviceType: Joi4.string().valid(...Object.values(AppServiceType3)).required(),
|
|
1395
|
+
name: Joi4.string().required()
|
|
1382
1396
|
});
|
|
1383
1397
|
function MUnit(value) {
|
|
1384
1398
|
const { error } = unitSchema.validate(value);
|
|
@@ -1491,7 +1505,7 @@ function useUnitRepository() {
|
|
|
1491
1505
|
throw new BadRequestError6("Invalid site ID format.");
|
|
1492
1506
|
}
|
|
1493
1507
|
if (search) {
|
|
1494
|
-
query.$or = [{ name: { $regex: search, $options: "i" } }];
|
|
1508
|
+
query.$or = [{ name: { $regex: escapeRegex(search), $options: "i" } }];
|
|
1495
1509
|
cacheOptions.search = search;
|
|
1496
1510
|
}
|
|
1497
1511
|
const cacheKey = makeCacheKey3(namespace_collection, cacheOptions);
|
|
@@ -1713,10 +1727,7 @@ function useAreaService() {
|
|
|
1713
1727
|
}
|
|
1714
1728
|
}
|
|
1715
1729
|
if (foundUnit) {
|
|
1716
|
-
areaUnits.push(
|
|
1717
|
-
unit: foundUnit._id,
|
|
1718
|
-
name: foundUnit.name
|
|
1719
|
-
});
|
|
1730
|
+
areaUnits.push(toAreaUnit(foundUnit));
|
|
1720
1731
|
}
|
|
1721
1732
|
}
|
|
1722
1733
|
if (areaUnits.length > 0) {
|
|
@@ -1813,7 +1824,7 @@ function useAreaService() {
|
|
|
1813
1824
|
}
|
|
1814
1825
|
|
|
1815
1826
|
// src/controllers/hygiene-area.controller.ts
|
|
1816
|
-
import
|
|
1827
|
+
import Joi5 from "joi";
|
|
1817
1828
|
import { BadRequestError as BadRequestError8, logger as logger9 } from "@7365admin1/node-server-utils";
|
|
1818
1829
|
import { AppServiceType as AppServiceType4 } from "@7365admin1/core";
|
|
1819
1830
|
|
|
@@ -1874,13 +1885,13 @@ function useAreaController() {
|
|
|
1874
1885
|
}
|
|
1875
1886
|
async function getAreas(req, res, next) {
|
|
1876
1887
|
const query = { ...req.query, ...req.params };
|
|
1877
|
-
const validation =
|
|
1878
|
-
page:
|
|
1879
|
-
limit:
|
|
1880
|
-
search:
|
|
1881
|
-
type:
|
|
1882
|
-
site:
|
|
1883
|
-
serviceType:
|
|
1888
|
+
const validation = Joi5.object({
|
|
1889
|
+
page: Joi5.number().min(1).optional().allow("", null),
|
|
1890
|
+
limit: Joi5.number().min(1).optional().allow("", null),
|
|
1891
|
+
search: Joi5.string().optional().allow("", null),
|
|
1892
|
+
type: Joi5.string().valid("all", ...allowedTypes).optional().allow("", null),
|
|
1893
|
+
site: Joi5.string().hex().required(),
|
|
1894
|
+
serviceType: Joi5.string().valid(...Object.values(AppServiceType4)).required()
|
|
1884
1895
|
});
|
|
1885
1896
|
const { error } = validation.validate(query);
|
|
1886
1897
|
if (error) {
|
|
@@ -1911,7 +1922,7 @@ function useAreaController() {
|
|
|
1911
1922
|
}
|
|
1912
1923
|
}
|
|
1913
1924
|
async function getAreaById(req, res, next) {
|
|
1914
|
-
const validation =
|
|
1925
|
+
const validation = Joi5.string().hex().required();
|
|
1915
1926
|
const _id = req.params.id;
|
|
1916
1927
|
const { error, value } = validation.validate(_id);
|
|
1917
1928
|
if (error) {
|
|
@@ -1931,15 +1942,15 @@ function useAreaController() {
|
|
|
1931
1942
|
}
|
|
1932
1943
|
async function updateArea(req, res, next) {
|
|
1933
1944
|
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:
|
|
1945
|
+
const schema = Joi5.object({
|
|
1946
|
+
id: Joi5.string().hex().required(),
|
|
1947
|
+
name: Joi5.string().optional().allow("", null),
|
|
1948
|
+
type: Joi5.string().optional().allow("", null, ...allowedTypes),
|
|
1949
|
+
set: Joi5.number().min(0).optional(),
|
|
1950
|
+
units: Joi5.array().items(
|
|
1951
|
+
Joi5.object({
|
|
1952
|
+
unit: Joi5.string().hex().required(),
|
|
1953
|
+
name: Joi5.string().required()
|
|
1943
1954
|
}).required()
|
|
1944
1955
|
).min(1).unique("unit", { ignoreUndefined: true }).optional().messages({
|
|
1945
1956
|
"array.unique": "Duplicate area units are not allowed"
|
|
@@ -1964,7 +1975,7 @@ function useAreaController() {
|
|
|
1964
1975
|
}
|
|
1965
1976
|
async function deleteArea(req, res, next) {
|
|
1966
1977
|
const id = req.params.id;
|
|
1967
|
-
const validation =
|
|
1978
|
+
const validation = Joi5.string().hex().required();
|
|
1968
1979
|
const { error, value } = validation.validate(id);
|
|
1969
1980
|
if (error) {
|
|
1970
1981
|
logger9.log({ level: "error", message: error.message });
|
|
@@ -1987,9 +1998,9 @@ function useAreaController() {
|
|
|
1987
1998
|
return;
|
|
1988
1999
|
}
|
|
1989
2000
|
const query = { ...req.query, ...req.params };
|
|
1990
|
-
const validation =
|
|
1991
|
-
site:
|
|
1992
|
-
serviceType:
|
|
2001
|
+
const validation = Joi5.object({
|
|
2002
|
+
site: Joi5.string().hex().required(),
|
|
2003
|
+
serviceType: Joi5.string().valid(...Object.values(AppServiceType4)).required()
|
|
1993
2004
|
});
|
|
1994
2005
|
const { error, value } = validation.validate(query);
|
|
1995
2006
|
if (error) {
|
|
@@ -2010,9 +2021,9 @@ function useAreaController() {
|
|
|
2010
2021
|
}
|
|
2011
2022
|
async function exportAreas(req, res, next) {
|
|
2012
2023
|
const query = { ...req.query, ...req.params };
|
|
2013
|
-
const validation =
|
|
2014
|
-
site:
|
|
2015
|
-
serviceType:
|
|
2024
|
+
const validation = Joi5.object({
|
|
2025
|
+
site: Joi5.string().hex().required(),
|
|
2026
|
+
serviceType: Joi5.string().valid(...Object.values(AppServiceType4)).required()
|
|
2016
2027
|
});
|
|
2017
2028
|
const { error, value } = validation.validate(query);
|
|
2018
2029
|
if (error) {
|
|
@@ -2299,7 +2310,7 @@ function useUnitService() {
|
|
|
2299
2310
|
}
|
|
2300
2311
|
|
|
2301
2312
|
// src/controllers/hygiene-unit.controller.ts
|
|
2302
|
-
import
|
|
2313
|
+
import Joi6 from "joi";
|
|
2303
2314
|
import { BadRequestError as BadRequestError10, logger as logger12 } from "@7365admin1/node-server-utils";
|
|
2304
2315
|
import { AppServiceType as AppServiceType5 } from "@7365admin1/core";
|
|
2305
2316
|
function useUnitController() {
|
|
@@ -2330,12 +2341,12 @@ function useUnitController() {
|
|
|
2330
2341
|
}
|
|
2331
2342
|
async function getUnits(req, res, next) {
|
|
2332
2343
|
const query = { ...req.query, ...req.params };
|
|
2333
|
-
const validation =
|
|
2334
|
-
page:
|
|
2335
|
-
limit:
|
|
2336
|
-
search:
|
|
2337
|
-
site:
|
|
2338
|
-
serviceType:
|
|
2344
|
+
const validation = Joi6.object({
|
|
2345
|
+
page: Joi6.number().min(1).optional().allow("", null),
|
|
2346
|
+
limit: Joi6.number().min(1).optional().allow("", null),
|
|
2347
|
+
search: Joi6.string().optional().allow("", null),
|
|
2348
|
+
site: Joi6.string().hex().required(),
|
|
2349
|
+
serviceType: Joi6.string().valid(...Object.values(AppServiceType5)).required()
|
|
2339
2350
|
});
|
|
2340
2351
|
const { error } = validation.validate(query);
|
|
2341
2352
|
if (error) {
|
|
@@ -2366,9 +2377,9 @@ function useUnitController() {
|
|
|
2366
2377
|
}
|
|
2367
2378
|
async function updateUnit(req, res, next) {
|
|
2368
2379
|
const payload = { id: req.params.id, ...req.body };
|
|
2369
|
-
const validation =
|
|
2370
|
-
id:
|
|
2371
|
-
name:
|
|
2380
|
+
const validation = Joi6.object({
|
|
2381
|
+
id: Joi6.string().hex().required(),
|
|
2382
|
+
name: Joi6.string().required()
|
|
2372
2383
|
});
|
|
2373
2384
|
const { error } = validation.validate(payload);
|
|
2374
2385
|
if (error) {
|
|
@@ -2389,8 +2400,8 @@ function useUnitController() {
|
|
|
2389
2400
|
}
|
|
2390
2401
|
async function deleteUnit(req, res, next) {
|
|
2391
2402
|
const id = req.params.id;
|
|
2392
|
-
const validation =
|
|
2393
|
-
id:
|
|
2403
|
+
const validation = Joi6.object({
|
|
2404
|
+
id: Joi6.string().hex().required()
|
|
2394
2405
|
});
|
|
2395
2406
|
const { error, value } = validation.validate({ id });
|
|
2396
2407
|
if (error) {
|
|
@@ -2414,9 +2425,9 @@ function useUnitController() {
|
|
|
2414
2425
|
return;
|
|
2415
2426
|
}
|
|
2416
2427
|
const query = { ...req.query, ...req.params };
|
|
2417
|
-
const validation =
|
|
2418
|
-
site:
|
|
2419
|
-
serviceType:
|
|
2428
|
+
const validation = Joi6.object({
|
|
2429
|
+
site: Joi6.string().hex().required(),
|
|
2430
|
+
serviceType: Joi6.string().valid(...Object.values(AppServiceType5)).required()
|
|
2420
2431
|
});
|
|
2421
2432
|
const { error, value } = validation.validate(query);
|
|
2422
2433
|
if (error) {
|
|
@@ -2437,9 +2448,9 @@ function useUnitController() {
|
|
|
2437
2448
|
}
|
|
2438
2449
|
async function exportUnits(req, res, next) {
|
|
2439
2450
|
const query = { ...req.query, ...req.params };
|
|
2440
|
-
const validation =
|
|
2441
|
-
site:
|
|
2442
|
-
serviceType:
|
|
2451
|
+
const validation = Joi6.object({
|
|
2452
|
+
site: Joi6.string().hex().required(),
|
|
2453
|
+
serviceType: Joi6.string().valid(...Object.values(AppServiceType5)).required()
|
|
2443
2454
|
});
|
|
2444
2455
|
const { error, value } = validation.validate(query);
|
|
2445
2456
|
if (error) {
|
|
@@ -2482,15 +2493,15 @@ function useUnitController() {
|
|
|
2482
2493
|
}
|
|
2483
2494
|
|
|
2484
2495
|
// src/models/hygiene-parent-checklist.model.ts
|
|
2485
|
-
import
|
|
2496
|
+
import Joi7 from "joi";
|
|
2486
2497
|
import { ObjectId as ObjectId6 } from "mongodb";
|
|
2487
2498
|
import { BadRequestError as BadRequestError11, logger as logger13 } from "@7365admin1/node-server-utils";
|
|
2488
2499
|
import { AppServiceType as AppServiceType6 } from "@7365admin1/core";
|
|
2489
|
-
var parentChecklistSchema =
|
|
2490
|
-
createdAt:
|
|
2491
|
-
site:
|
|
2492
|
-
serviceType:
|
|
2493
|
-
dateStr:
|
|
2500
|
+
var parentChecklistSchema = Joi7.object({
|
|
2501
|
+
createdAt: Joi7.alternatives().try(Joi7.date(), Joi7.string()).optional().allow("", null),
|
|
2502
|
+
site: Joi7.string().hex().required(),
|
|
2503
|
+
serviceType: Joi7.string().valid(...Object.values(AppServiceType6)).required(),
|
|
2504
|
+
dateStr: Joi7.string().optional().allow("", null)
|
|
2494
2505
|
});
|
|
2495
2506
|
function MParentChecklist(value) {
|
|
2496
2507
|
const { error } = parentChecklistSchema.validate(value);
|
|
@@ -3071,7 +3082,7 @@ function useParentChecklistRepo() {
|
|
|
3071
3082
|
}
|
|
3072
3083
|
|
|
3073
3084
|
// src/controllers/hygiene-parent-checklist.controller.ts
|
|
3074
|
-
import
|
|
3085
|
+
import Joi8 from "joi";
|
|
3075
3086
|
import { BadRequestError as BadRequestError13, logger as logger15 } from "@7365admin1/node-server-utils";
|
|
3076
3087
|
import { AppServiceType as AppServiceType8 } from "@7365admin1/core";
|
|
3077
3088
|
function useParentChecklistController() {
|
|
@@ -3081,10 +3092,10 @@ function useParentChecklistController() {
|
|
|
3081
3092
|
} = useParentChecklistRepo();
|
|
3082
3093
|
async function createParentChecklist(req, res, next) {
|
|
3083
3094
|
const payload = req.body;
|
|
3084
|
-
const validation =
|
|
3085
|
-
createdAt:
|
|
3086
|
-
site:
|
|
3087
|
-
serviceType:
|
|
3095
|
+
const validation = Joi8.object({
|
|
3096
|
+
createdAt: Joi8.alternatives().try(Joi8.date(), Joi8.string()).optional().allow("", null),
|
|
3097
|
+
site: Joi8.string().hex().required(),
|
|
3098
|
+
serviceType: Joi8.string().valid(...Object.values(AppServiceType8)).optional().allow("", null)
|
|
3088
3099
|
});
|
|
3089
3100
|
const { error } = validation.validate(payload);
|
|
3090
3101
|
if (error) {
|
|
@@ -3104,15 +3115,15 @@ function useParentChecklistController() {
|
|
|
3104
3115
|
}
|
|
3105
3116
|
async function getAllParentChecklist(req, res, next) {
|
|
3106
3117
|
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:
|
|
3118
|
+
const validation = Joi8.object({
|
|
3119
|
+
page: Joi8.number().min(1).optional().allow("", null),
|
|
3120
|
+
limit: Joi8.number().min(1).optional().allow("", null),
|
|
3121
|
+
search: Joi8.string().optional().allow("", null),
|
|
3122
|
+
site: Joi8.string().hex().required(),
|
|
3123
|
+
serviceType: Joi8.string().valid(...Object.values(AppServiceType8)).required(),
|
|
3124
|
+
startDate: Joi8.alternatives().try(Joi8.date(), Joi8.string()).optional().allow("", null),
|
|
3125
|
+
endDate: Joi8.alternatives().try(Joi8.date(), Joi8.string()).optional().allow("", null),
|
|
3126
|
+
status: Joi8.string().valid(...allowedStatus, "all").optional().allow("", null)
|
|
3116
3127
|
});
|
|
3117
3128
|
const { error } = validation.validate(query);
|
|
3118
3129
|
if (error) {
|
|
@@ -3154,28 +3165,28 @@ function useParentChecklistController() {
|
|
|
3154
3165
|
}
|
|
3155
3166
|
|
|
3156
3167
|
// src/models/hygiene-area-checklist.model.ts
|
|
3157
|
-
import
|
|
3168
|
+
import Joi9 from "joi";
|
|
3158
3169
|
import { ObjectId as ObjectId8 } from "mongodb";
|
|
3159
3170
|
import { BadRequestError as BadRequestError14, logger as logger16 } from "@7365admin1/node-server-utils";
|
|
3160
3171
|
import { AppServiceType as AppServiceType9 } from "@7365admin1/core";
|
|
3161
3172
|
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:
|
|
3173
|
+
var areaChecklistSchema = Joi9.object({
|
|
3174
|
+
schedule: Joi9.string().hex().required(),
|
|
3175
|
+
serviceType: Joi9.string().valid(...Object.values(AppServiceType9)).required(),
|
|
3176
|
+
area: Joi9.string().hex().required(),
|
|
3177
|
+
name: Joi9.string().required(),
|
|
3178
|
+
type: Joi9.string().valid(...allowedTypes).required(),
|
|
3179
|
+
checklist: Joi9.array().items(
|
|
3180
|
+
Joi9.object({
|
|
3181
|
+
set: Joi9.number().min(0).required(),
|
|
3182
|
+
units: Joi9.array().items(
|
|
3183
|
+
Joi9.object({
|
|
3184
|
+
unit: Joi9.string().hex().required(),
|
|
3185
|
+
name: Joi9.string().required()
|
|
3175
3186
|
}).required()
|
|
3176
3187
|
).min(1).required(),
|
|
3177
|
-
isScheduleTask:
|
|
3178
|
-
scheduleTaskId:
|
|
3188
|
+
isScheduleTask: Joi9.boolean().optional().default(false),
|
|
3189
|
+
scheduleTaskId: Joi9.string().hex().optional().allow(null)
|
|
3179
3190
|
}).required()
|
|
3180
3191
|
).optional().default([])
|
|
3181
3192
|
});
|
|
@@ -4664,7 +4675,7 @@ function useAreaChecklistService() {
|
|
|
4664
4675
|
}
|
|
4665
4676
|
|
|
4666
4677
|
// src/controllers/hygiene-area-checklist.controller.ts
|
|
4667
|
-
import
|
|
4678
|
+
import Joi10 from "joi";
|
|
4668
4679
|
import {
|
|
4669
4680
|
BadRequestError as BadRequestError16,
|
|
4670
4681
|
InternalServerError as InternalServerError7,
|
|
@@ -4909,9 +4920,9 @@ function useAreaChecklistController() {
|
|
|
4909
4920
|
site: req.params.site,
|
|
4910
4921
|
schedule: req.params.schedule
|
|
4911
4922
|
};
|
|
4912
|
-
const validation =
|
|
4913
|
-
site:
|
|
4914
|
-
schedule:
|
|
4923
|
+
const validation = Joi10.object({
|
|
4924
|
+
site: Joi10.string().hex().required(),
|
|
4925
|
+
schedule: Joi10.string().hex().required()
|
|
4915
4926
|
});
|
|
4916
4927
|
const { error, value } = validation.validate(payload);
|
|
4917
4928
|
if (error) {
|
|
@@ -4931,14 +4942,14 @@ function useAreaChecklistController() {
|
|
|
4931
4942
|
}
|
|
4932
4943
|
async function getAllAreaChecklist(req, res, next) {
|
|
4933
4944
|
const query = { ...req.query, ...req.params };
|
|
4934
|
-
const validation =
|
|
4935
|
-
page:
|
|
4936
|
-
limit:
|
|
4937
|
-
search:
|
|
4938
|
-
type:
|
|
4939
|
-
status:
|
|
4940
|
-
schedule:
|
|
4941
|
-
serviceType:
|
|
4945
|
+
const validation = Joi10.object({
|
|
4946
|
+
page: Joi10.number().min(1).optional().allow("", null),
|
|
4947
|
+
limit: Joi10.number().min(1).optional().allow("", null),
|
|
4948
|
+
search: Joi10.string().optional().allow("", null),
|
|
4949
|
+
type: Joi10.string().valid(...allowedTypes, "all").optional().allow("", null),
|
|
4950
|
+
status: Joi10.string().valid(...allowedStatus, "all").optional().allow("", null),
|
|
4951
|
+
schedule: Joi10.string().hex().required(),
|
|
4952
|
+
serviceType: Joi10.string().valid(...Object.values(AppServiceType10)).required()
|
|
4942
4953
|
});
|
|
4943
4954
|
const { error } = validation.validate(query);
|
|
4944
4955
|
if (error) {
|
|
@@ -4973,14 +4984,14 @@ function useAreaChecklistController() {
|
|
|
4973
4984
|
}
|
|
4974
4985
|
async function getAreaChecklistHistory(req, res, next) {
|
|
4975
4986
|
const query = { ...req.query, ...req.params };
|
|
4976
|
-
const validation =
|
|
4977
|
-
page:
|
|
4978
|
-
limit:
|
|
4979
|
-
search:
|
|
4980
|
-
type:
|
|
4981
|
-
schedule:
|
|
4982
|
-
status:
|
|
4983
|
-
createdAt:
|
|
4987
|
+
const validation = Joi10.object({
|
|
4988
|
+
page: Joi10.number().min(1).optional().allow("", null),
|
|
4989
|
+
limit: Joi10.number().min(1).optional().allow("", null),
|
|
4990
|
+
search: Joi10.string().optional().allow("", null),
|
|
4991
|
+
type: Joi10.string().optional().allow("", ...allowedTypes),
|
|
4992
|
+
schedule: Joi10.string().hex().required(),
|
|
4993
|
+
status: Joi10.string().allow("", null, ...allowedStatus),
|
|
4994
|
+
createdAt: Joi10.alternatives().try(Joi10.date(), Joi10.string()).optional().allow("", null)
|
|
4984
4995
|
});
|
|
4985
4996
|
const { error } = validation.validate(query);
|
|
4986
4997
|
if (error) {
|
|
@@ -5014,7 +5025,7 @@ function useAreaChecklistController() {
|
|
|
5014
5025
|
}
|
|
5015
5026
|
}
|
|
5016
5027
|
async function getAreaChecklistHistoryDetails(req, res, next) {
|
|
5017
|
-
const validation =
|
|
5028
|
+
const validation = Joi10.string().hex().required();
|
|
5018
5029
|
const _id = req.params.id;
|
|
5019
5030
|
const { error, value } = validation.validate(_id);
|
|
5020
5031
|
if (error) {
|
|
@@ -5034,12 +5045,12 @@ function useAreaChecklistController() {
|
|
|
5034
5045
|
}
|
|
5035
5046
|
async function getAreaChecklistUnits(req, res, next) {
|
|
5036
5047
|
const query = { ...req.query, ...req.params };
|
|
5037
|
-
const validation =
|
|
5038
|
-
page:
|
|
5039
|
-
limit:
|
|
5040
|
-
search:
|
|
5041
|
-
serviceType:
|
|
5042
|
-
id:
|
|
5048
|
+
const validation = Joi10.object({
|
|
5049
|
+
page: Joi10.number().min(1).optional().allow("", null),
|
|
5050
|
+
limit: Joi10.number().min(1).optional().allow("", null),
|
|
5051
|
+
search: Joi10.string().optional().allow("", null),
|
|
5052
|
+
serviceType: Joi10.string().valid(...Object.values(AppServiceType10)).required(),
|
|
5053
|
+
id: Joi10.string().hex().required()
|
|
5043
5054
|
});
|
|
5044
5055
|
const { error } = validation.validate(query);
|
|
5045
5056
|
if (error) {
|
|
@@ -5089,21 +5100,21 @@ function useAreaChecklistController() {
|
|
|
5089
5100
|
...decisionValues,
|
|
5090
5101
|
completedBy
|
|
5091
5102
|
};
|
|
5092
|
-
const validation =
|
|
5093
|
-
id:
|
|
5094
|
-
set:
|
|
5095
|
-
unit:
|
|
5096
|
-
decision:
|
|
5097
|
-
approve:
|
|
5098
|
-
reject:
|
|
5099
|
-
remarks:
|
|
5103
|
+
const validation = Joi10.object({
|
|
5104
|
+
id: Joi10.string().hex().required(),
|
|
5105
|
+
set: Joi10.number().integer().min(1).required(),
|
|
5106
|
+
unit: Joi10.string().hex().required(),
|
|
5107
|
+
decision: Joi10.string().valid("approve", "reject").required(),
|
|
5108
|
+
approve: Joi10.boolean().optional(),
|
|
5109
|
+
reject: Joi10.boolean().optional(),
|
|
5110
|
+
remarks: Joi10.string().optional().allow("", null),
|
|
5100
5111
|
/*
|
|
5101
5112
|
* Shape only. WHETHER a photo is required depends on the set's current
|
|
5102
5113
|
* state in the database, which Joi cannot see — see the check below.
|
|
5103
5114
|
* Each entry must still be a real id: a blank string carries no evidence.
|
|
5104
5115
|
*/
|
|
5105
|
-
attachment:
|
|
5106
|
-
completedBy:
|
|
5116
|
+
attachment: Joi10.array().items(Joi10.string().trim().min(1)).optional(),
|
|
5117
|
+
completedBy: Joi10.string().hex().required()
|
|
5107
5118
|
});
|
|
5108
5119
|
const { error } = validation.validate(payload);
|
|
5109
5120
|
if (error) {
|
|
@@ -5140,7 +5151,7 @@ function useAreaChecklistController() {
|
|
|
5140
5151
|
}
|
|
5141
5152
|
}
|
|
5142
5153
|
async function downloadChecklistPdf(req, res, next) {
|
|
5143
|
-
const validation =
|
|
5154
|
+
const validation = Joi10.string().hex().required();
|
|
5144
5155
|
const schedule = req.params.schedule;
|
|
5145
5156
|
const { error, value } = validation.validate(schedule);
|
|
5146
5157
|
if (error) {
|
|
@@ -5186,16 +5197,16 @@ function useAreaChecklistController() {
|
|
|
5186
5197
|
}
|
|
5187
5198
|
|
|
5188
5199
|
// src/models/hygiene-supply.model.ts
|
|
5189
|
-
import
|
|
5200
|
+
import Joi11 from "joi";
|
|
5190
5201
|
import { ObjectId as ObjectId12 } from "mongodb";
|
|
5191
5202
|
import { BadRequestError as BadRequestError17, logger as logger21 } from "@7365admin1/node-server-utils";
|
|
5192
5203
|
import { AppServiceType as AppServiceType11 } from "@7365admin1/core";
|
|
5193
|
-
var supplySchema =
|
|
5194
|
-
site:
|
|
5195
|
-
serviceType:
|
|
5196
|
-
name:
|
|
5197
|
-
unitOfMeasurement:
|
|
5198
|
-
attachment:
|
|
5204
|
+
var supplySchema = Joi11.object({
|
|
5205
|
+
site: Joi11.string().hex().required(),
|
|
5206
|
+
serviceType: Joi11.string().valid(...Object.values(AppServiceType11)).required(),
|
|
5207
|
+
name: Joi11.string().required(),
|
|
5208
|
+
unitOfMeasurement: Joi11.string().required(),
|
|
5209
|
+
attachment: Joi11.string().allow(null, "").optional()
|
|
5199
5210
|
});
|
|
5200
5211
|
function MSupply(value) {
|
|
5201
5212
|
const { error } = supplySchema.validate(value);
|
|
@@ -5332,7 +5343,7 @@ function useSupplyRepository() {
|
|
|
5332
5343
|
throw new BadRequestError18("Invalid site ID format.");
|
|
5333
5344
|
}
|
|
5334
5345
|
if (search) {
|
|
5335
|
-
query.name = { $regex: search, $options: "i" };
|
|
5346
|
+
query.name = { $regex: escapeRegex(search), $options: "i" };
|
|
5336
5347
|
cacheOptions.search = search;
|
|
5337
5348
|
}
|
|
5338
5349
|
const cacheKey = makeCacheKey6(namespace_collection, cacheOptions);
|
|
@@ -5494,7 +5505,7 @@ function useSupplyRepository() {
|
|
|
5494
5505
|
}
|
|
5495
5506
|
|
|
5496
5507
|
// src/controllers/hygiene-supply.controller.ts
|
|
5497
|
-
import
|
|
5508
|
+
import Joi12 from "joi";
|
|
5498
5509
|
import { BadRequestError as BadRequestError19, logger as logger23 } from "@7365admin1/node-server-utils";
|
|
5499
5510
|
import { AppServiceType as AppServiceType12 } from "@7365admin1/core";
|
|
5500
5511
|
function useSupplyController() {
|
|
@@ -5525,12 +5536,12 @@ function useSupplyController() {
|
|
|
5525
5536
|
}
|
|
5526
5537
|
async function getSupplies(req, res, next) {
|
|
5527
5538
|
const query = { ...req.query, ...req.params };
|
|
5528
|
-
const validation =
|
|
5529
|
-
page:
|
|
5530
|
-
limit:
|
|
5531
|
-
search:
|
|
5532
|
-
site:
|
|
5533
|
-
serviceType:
|
|
5539
|
+
const validation = Joi12.object({
|
|
5540
|
+
page: Joi12.number().min(1).optional().allow("", null),
|
|
5541
|
+
limit: Joi12.number().min(1).optional().allow("", null),
|
|
5542
|
+
search: Joi12.string().optional().allow("", null),
|
|
5543
|
+
site: Joi12.string().hex().required(),
|
|
5544
|
+
serviceType: Joi12.string().valid(...Object.values(AppServiceType12)).required()
|
|
5534
5545
|
});
|
|
5535
5546
|
const { error } = validation.validate(query);
|
|
5536
5547
|
if (error) {
|
|
@@ -5560,7 +5571,7 @@ function useSupplyController() {
|
|
|
5560
5571
|
}
|
|
5561
5572
|
}
|
|
5562
5573
|
async function getSupplyById(req, res, next) {
|
|
5563
|
-
const validation =
|
|
5574
|
+
const validation = Joi12.string().hex().required();
|
|
5564
5575
|
const _id = req.params.id;
|
|
5565
5576
|
const { error, value } = validation.validate(_id);
|
|
5566
5577
|
if (error) {
|
|
@@ -5580,12 +5591,12 @@ function useSupplyController() {
|
|
|
5580
5591
|
}
|
|
5581
5592
|
async function updateSupply(req, res, next) {
|
|
5582
5593
|
const payload = { id: req.params.id, ...req.body };
|
|
5583
|
-
const validation =
|
|
5584
|
-
id:
|
|
5585
|
-
name:
|
|
5586
|
-
unitOfMeasurement:
|
|
5587
|
-
qty:
|
|
5588
|
-
attachment:
|
|
5594
|
+
const validation = Joi12.object({
|
|
5595
|
+
id: Joi12.string().hex().required(),
|
|
5596
|
+
name: Joi12.string().optional().allow("", null),
|
|
5597
|
+
unitOfMeasurement: Joi12.string().optional().allow("", null),
|
|
5598
|
+
qty: Joi12.number().min(0).optional().allow("", null),
|
|
5599
|
+
attachment: Joi12.string().optional().allow("", null)
|
|
5589
5600
|
});
|
|
5590
5601
|
const { error } = validation.validate(payload);
|
|
5591
5602
|
if (error) {
|
|
@@ -5606,7 +5617,7 @@ function useSupplyController() {
|
|
|
5606
5617
|
}
|
|
5607
5618
|
async function deleteSupply(req, res, next) {
|
|
5608
5619
|
const id = req.params.id;
|
|
5609
|
-
const validation =
|
|
5620
|
+
const validation = Joi12.string().hex().required();
|
|
5610
5621
|
const { error, value } = validation.validate(id);
|
|
5611
5622
|
if (error) {
|
|
5612
5623
|
logger23.log({ level: "error", message: error.message });
|
|
@@ -5633,18 +5644,18 @@ function useSupplyController() {
|
|
|
5633
5644
|
}
|
|
5634
5645
|
|
|
5635
5646
|
// src/models/hygiene-stock.model.ts
|
|
5636
|
-
import
|
|
5647
|
+
import Joi13 from "joi";
|
|
5637
5648
|
import { ObjectId as ObjectId14 } from "mongodb";
|
|
5638
5649
|
import { BadRequestError as BadRequestError20, logger as logger24 } from "@7365admin1/node-server-utils";
|
|
5639
5650
|
import { AppServiceType as AppServiceType13 } from "@7365admin1/core";
|
|
5640
|
-
var stockSchema =
|
|
5641
|
-
site:
|
|
5642
|
-
serviceType:
|
|
5643
|
-
supply:
|
|
5644
|
-
in:
|
|
5645
|
-
out:
|
|
5646
|
-
balance:
|
|
5647
|
-
remarks:
|
|
5651
|
+
var stockSchema = Joi13.object({
|
|
5652
|
+
site: Joi13.string().hex().required(),
|
|
5653
|
+
serviceType: Joi13.string().valid(...Object.values(AppServiceType13)).required(),
|
|
5654
|
+
supply: Joi13.string().hex().required(),
|
|
5655
|
+
in: Joi13.number().min(0).optional(),
|
|
5656
|
+
out: Joi13.number().min(0).optional(),
|
|
5657
|
+
balance: Joi13.number().min(0).required(),
|
|
5658
|
+
remarks: Joi13.string().optional().allow("", null)
|
|
5648
5659
|
});
|
|
5649
5660
|
function MStock(value) {
|
|
5650
5661
|
const { error } = stockSchema.validate(value);
|
|
@@ -5871,7 +5882,7 @@ function useStockService() {
|
|
|
5871
5882
|
}
|
|
5872
5883
|
|
|
5873
5884
|
// src/controllers/hygiene-stock.controller.ts
|
|
5874
|
-
import
|
|
5885
|
+
import Joi14 from "joi";
|
|
5875
5886
|
import { BadRequestError as BadRequestError23, logger as logger26 } from "@7365admin1/node-server-utils";
|
|
5876
5887
|
import { AppServiceType as AppServiceType14 } from "@7365admin1/core";
|
|
5877
5888
|
function useStockController() {
|
|
@@ -5879,12 +5890,12 @@ function useStockController() {
|
|
|
5879
5890
|
const { createStock: _createStock } = useStockService();
|
|
5880
5891
|
async function createStock(req, res, next) {
|
|
5881
5892
|
const payload = { ...req.body, ...req.params };
|
|
5882
|
-
const validation =
|
|
5883
|
-
site:
|
|
5884
|
-
serviceType:
|
|
5885
|
-
supply:
|
|
5886
|
-
qty:
|
|
5887
|
-
remarks:
|
|
5893
|
+
const validation = Joi14.object({
|
|
5894
|
+
site: Joi14.string().hex().required(),
|
|
5895
|
+
serviceType: Joi14.string().valid(...Object.values(AppServiceType14)).required(),
|
|
5896
|
+
supply: Joi14.string().hex().required(),
|
|
5897
|
+
qty: Joi14.number().min(0).required(),
|
|
5898
|
+
remarks: Joi14.string().optional().allow("", null)
|
|
5888
5899
|
});
|
|
5889
5900
|
const { error } = validation.validate(payload);
|
|
5890
5901
|
if (error) {
|
|
@@ -5904,13 +5915,13 @@ function useStockController() {
|
|
|
5904
5915
|
}
|
|
5905
5916
|
async function getStocksBySupplyId(req, res, next) {
|
|
5906
5917
|
const query = { ...req.query, ...req.params };
|
|
5907
|
-
const validation =
|
|
5908
|
-
page:
|
|
5909
|
-
limit:
|
|
5910
|
-
search:
|
|
5911
|
-
site:
|
|
5912
|
-
serviceType:
|
|
5913
|
-
supply:
|
|
5918
|
+
const validation = Joi14.object({
|
|
5919
|
+
page: Joi14.number().min(1).optional().allow("", null),
|
|
5920
|
+
limit: Joi14.number().min(1).optional().allow("", null),
|
|
5921
|
+
search: Joi14.string().optional().allow("", null),
|
|
5922
|
+
site: Joi14.string().hex().required(),
|
|
5923
|
+
serviceType: Joi14.string().valid(...Object.values(AppServiceType14)).required(),
|
|
5924
|
+
supply: Joi14.string().hex().required()
|
|
5914
5925
|
});
|
|
5915
5926
|
const { error } = validation.validate(query);
|
|
5916
5927
|
if (error) {
|
|
@@ -5972,21 +5983,21 @@ async function applyCheckOutDecision(decision, decide, returnStock) {
|
|
|
5972
5983
|
}
|
|
5973
5984
|
|
|
5974
5985
|
// src/models/hygiene-checkout-item.model.ts
|
|
5975
|
-
import
|
|
5986
|
+
import Joi15 from "joi";
|
|
5976
5987
|
import { ObjectId as ObjectId16 } from "mongodb";
|
|
5977
5988
|
import { BadRequestError as BadRequestError24, logger as logger27 } from "@7365admin1/node-server-utils";
|
|
5978
5989
|
import { AppServiceType as AppServiceType15 } from "@7365admin1/core";
|
|
5979
5990
|
var allowedCheckOutItemStatus = ["pending", "completed"];
|
|
5980
|
-
var checkOutItemSchema =
|
|
5981
|
-
site:
|
|
5982
|
-
serviceType:
|
|
5983
|
-
supply:
|
|
5984
|
-
supplyName:
|
|
5985
|
-
supplyQty:
|
|
5986
|
-
qty:
|
|
5987
|
-
attachment:
|
|
5988
|
-
createdBy:
|
|
5989
|
-
createdByName:
|
|
5991
|
+
var checkOutItemSchema = Joi15.object({
|
|
5992
|
+
site: Joi15.string().hex().required(),
|
|
5993
|
+
serviceType: Joi15.string().valid(...Object.values(AppServiceType15)).required(),
|
|
5994
|
+
supply: Joi15.string().hex().required(),
|
|
5995
|
+
supplyName: Joi15.string().required(),
|
|
5996
|
+
supplyQty: Joi15.number().min(0).required(),
|
|
5997
|
+
qty: Joi15.number().min(0).required(),
|
|
5998
|
+
attachment: Joi15.array().items(Joi15.string()).optional().allow(null),
|
|
5999
|
+
createdBy: Joi15.string().hex().required(),
|
|
6000
|
+
createdByName: Joi15.string().required()
|
|
5990
6001
|
});
|
|
5991
6002
|
function MCheckOutItem(value) {
|
|
5992
6003
|
const { error } = checkOutItemSchema.validate(value);
|
|
@@ -6119,7 +6130,7 @@ function useCheckOutItemRepository() {
|
|
|
6119
6130
|
throw new BadRequestError25("Invalid site ID format.");
|
|
6120
6131
|
}
|
|
6121
6132
|
if (search) {
|
|
6122
|
-
query.supplyName = { $regex: search, $options: "i" };
|
|
6133
|
+
query.supplyName = { $regex: escapeRegex(search), $options: "i" };
|
|
6123
6134
|
cacheOptions.search = search;
|
|
6124
6135
|
}
|
|
6125
6136
|
const cacheKey = makeCacheKey8(namespace_collection, cacheOptions);
|
|
@@ -6475,7 +6486,7 @@ function useCheckOutItemService() {
|
|
|
6475
6486
|
}
|
|
6476
6487
|
|
|
6477
6488
|
// src/controllers/hygiene-checkout-item.controller.ts
|
|
6478
|
-
import
|
|
6489
|
+
import Joi16 from "joi";
|
|
6479
6490
|
import { BadRequestError as BadRequestError27, logger as logger29 } from "@7365admin1/node-server-utils";
|
|
6480
6491
|
import { AppServiceType as AppServiceType16 } from "@7365admin1/core";
|
|
6481
6492
|
function useCheckOutItemController() {
|
|
@@ -6499,13 +6510,13 @@ function useCheckOutItemController() {
|
|
|
6499
6510
|
...req.params,
|
|
6500
6511
|
createdBy
|
|
6501
6512
|
};
|
|
6502
|
-
const validation =
|
|
6503
|
-
site:
|
|
6504
|
-
serviceType:
|
|
6505
|
-
supply:
|
|
6506
|
-
qty:
|
|
6507
|
-
attachment:
|
|
6508
|
-
createdBy:
|
|
6513
|
+
const validation = Joi16.object({
|
|
6514
|
+
site: Joi16.string().hex().required(),
|
|
6515
|
+
serviceType: Joi16.string().valid(...Object.values(AppServiceType16)).required(),
|
|
6516
|
+
supply: Joi16.string().hex().required(),
|
|
6517
|
+
qty: Joi16.number().min(0).required(),
|
|
6518
|
+
attachment: Joi16.array().items(Joi16.string()).optional().allow(null),
|
|
6519
|
+
createdBy: Joi16.string().hex().required()
|
|
6509
6520
|
});
|
|
6510
6521
|
const { error } = validation.validate(payload);
|
|
6511
6522
|
if (error) {
|
|
@@ -6534,15 +6545,15 @@ function useCheckOutItemController() {
|
|
|
6534
6545
|
...req.params,
|
|
6535
6546
|
createdBy
|
|
6536
6547
|
};
|
|
6537
|
-
const validation =
|
|
6538
|
-
site:
|
|
6539
|
-
serviceType:
|
|
6540
|
-
createdBy:
|
|
6541
|
-
items:
|
|
6542
|
-
|
|
6543
|
-
supply:
|
|
6544
|
-
qty:
|
|
6545
|
-
attachment:
|
|
6548
|
+
const validation = Joi16.object({
|
|
6549
|
+
site: Joi16.string().hex().required(),
|
|
6550
|
+
serviceType: Joi16.string().valid(...Object.values(AppServiceType16)).required(),
|
|
6551
|
+
createdBy: Joi16.string().hex().required(),
|
|
6552
|
+
items: Joi16.array().items(
|
|
6553
|
+
Joi16.object({
|
|
6554
|
+
supply: Joi16.string().hex().required(),
|
|
6555
|
+
qty: Joi16.number().min(0).required(),
|
|
6556
|
+
attachment: Joi16.array().items(Joi16.string()).optional().allow(null)
|
|
6546
6557
|
})
|
|
6547
6558
|
).min(1).required()
|
|
6548
6559
|
});
|
|
@@ -6564,12 +6575,12 @@ function useCheckOutItemController() {
|
|
|
6564
6575
|
}
|
|
6565
6576
|
async function getCheckOutItems(req, res, next) {
|
|
6566
6577
|
const query = { ...req.query, ...req.params };
|
|
6567
|
-
const validation =
|
|
6568
|
-
page:
|
|
6569
|
-
limit:
|
|
6570
|
-
search:
|
|
6571
|
-
site:
|
|
6572
|
-
serviceType:
|
|
6578
|
+
const validation = Joi16.object({
|
|
6579
|
+
page: Joi16.number().min(1).optional().allow("", null),
|
|
6580
|
+
limit: Joi16.number().min(1).optional().allow("", null),
|
|
6581
|
+
search: Joi16.string().optional().allow("", null),
|
|
6582
|
+
site: Joi16.string().hex().required(),
|
|
6583
|
+
serviceType: Joi16.string().valid(...Object.values(AppServiceType16)).required()
|
|
6573
6584
|
});
|
|
6574
6585
|
const { error } = validation.validate(query);
|
|
6575
6586
|
if (error) {
|
|
@@ -6599,7 +6610,7 @@ function useCheckOutItemController() {
|
|
|
6599
6610
|
}
|
|
6600
6611
|
}
|
|
6601
6612
|
async function getCheckOutItemById(req, res, next) {
|
|
6602
|
-
const validation =
|
|
6613
|
+
const validation = Joi16.string().hex().required();
|
|
6603
6614
|
const _id = req.params.id;
|
|
6604
6615
|
const { error, value } = validation.validate(_id);
|
|
6605
6616
|
if (error) {
|
|
@@ -6638,13 +6649,13 @@ function useCheckOutItemController() {
|
|
|
6638
6649
|
...decisionValues,
|
|
6639
6650
|
completedBy
|
|
6640
6651
|
};
|
|
6641
|
-
const validation =
|
|
6642
|
-
id:
|
|
6643
|
-
decision:
|
|
6644
|
-
approve:
|
|
6645
|
-
reject:
|
|
6646
|
-
remarks:
|
|
6647
|
-
completedBy:
|
|
6652
|
+
const validation = Joi16.object({
|
|
6653
|
+
id: Joi16.string().hex().required(),
|
|
6654
|
+
decision: Joi16.string().valid("approve", "disapprove").required(),
|
|
6655
|
+
approve: Joi16.boolean().required(),
|
|
6656
|
+
reject: Joi16.boolean().required(),
|
|
6657
|
+
remarks: Joi16.string().optional().allow("", null),
|
|
6658
|
+
completedBy: Joi16.string().hex().required()
|
|
6648
6659
|
});
|
|
6649
6660
|
const { error } = validation.validate(payload);
|
|
6650
6661
|
if (error) {
|
|
@@ -6677,21 +6688,21 @@ function useCheckOutItemController() {
|
|
|
6677
6688
|
// src/models/hygiene-schedule-task.model.ts
|
|
6678
6689
|
import { BadRequestError as BadRequestError28, logger as logger30 } from "@7365admin1/node-server-utils";
|
|
6679
6690
|
import { AppServiceType as AppServiceType17 } from "@7365admin1/core";
|
|
6680
|
-
import
|
|
6691
|
+
import Joi17 from "joi";
|
|
6681
6692
|
import { ObjectId as ObjectId18 } from "mongodb";
|
|
6682
|
-
var scheduleTaskSchema =
|
|
6683
|
-
site:
|
|
6684
|
-
serviceType:
|
|
6685
|
-
title:
|
|
6686
|
-
time:
|
|
6687
|
-
dates:
|
|
6688
|
-
|
|
6693
|
+
var scheduleTaskSchema = Joi17.object({
|
|
6694
|
+
site: Joi17.string().hex().required(),
|
|
6695
|
+
serviceType: Joi17.string().valid(...Object.values(AppServiceType17)).required(),
|
|
6696
|
+
title: Joi17.string().required(),
|
|
6697
|
+
time: Joi17.string().pattern(/^([0-1]\d|2[0-3]):([0-5]\d)$/).required(),
|
|
6698
|
+
dates: Joi17.array().min(1).items(
|
|
6699
|
+
Joi17.string().pattern(/^\d{4}-\d{2}-\d{2}$/).required()
|
|
6689
6700
|
).required(),
|
|
6690
|
-
description:
|
|
6691
|
-
areas:
|
|
6692
|
-
|
|
6693
|
-
name:
|
|
6694
|
-
value:
|
|
6701
|
+
description: Joi17.string().optional().allow("", null),
|
|
6702
|
+
areas: Joi17.array().min(1).items(
|
|
6703
|
+
Joi17.object({
|
|
6704
|
+
name: Joi17.string().required(),
|
|
6705
|
+
value: Joi17.any().required()
|
|
6695
6706
|
})
|
|
6696
6707
|
).required()
|
|
6697
6708
|
});
|
|
@@ -6819,7 +6830,7 @@ function useScheduleTaskRepository() {
|
|
|
6819
6830
|
throw new BadRequestError29("Invalid site ID format.");
|
|
6820
6831
|
}
|
|
6821
6832
|
if (search) {
|
|
6822
|
-
query.$or = [{ title: { $regex: search, $options: "i" } }];
|
|
6833
|
+
query.$or = [{ title: { $regex: escapeRegex(search), $options: "i" } }];
|
|
6823
6834
|
cacheOptions.search = search;
|
|
6824
6835
|
}
|
|
6825
6836
|
const cacheKey = makeCacheKey9(namespace_collection, cacheOptions);
|
|
@@ -7295,7 +7306,7 @@ function useScheduleTaskService() {
|
|
|
7295
7306
|
}
|
|
7296
7307
|
|
|
7297
7308
|
// src/controllers/hygiene-schedule-task.controller.ts
|
|
7298
|
-
import
|
|
7309
|
+
import Joi18 from "joi";
|
|
7299
7310
|
import { BadRequestError as BadRequestError30, logger as logger33 } from "@7365admin1/node-server-utils";
|
|
7300
7311
|
import { AppServiceType as AppServiceType18 } from "@7365admin1/core";
|
|
7301
7312
|
function useScheduleTaskController() {
|
|
@@ -7326,12 +7337,12 @@ function useScheduleTaskController() {
|
|
|
7326
7337
|
}
|
|
7327
7338
|
async function getScheduleTasks(req, res, next) {
|
|
7328
7339
|
const query = { ...req.query, ...req.params };
|
|
7329
|
-
const validation =
|
|
7330
|
-
page:
|
|
7331
|
-
limit:
|
|
7332
|
-
search:
|
|
7333
|
-
site:
|
|
7334
|
-
serviceType:
|
|
7340
|
+
const validation = Joi18.object({
|
|
7341
|
+
page: Joi18.number().min(1).optional().allow("", null),
|
|
7342
|
+
limit: Joi18.number().min(1).optional().allow("", null),
|
|
7343
|
+
search: Joi18.string().optional().allow("", null),
|
|
7344
|
+
site: Joi18.string().hex().required(),
|
|
7345
|
+
serviceType: Joi18.string().valid(...Object.values(AppServiceType18)).required()
|
|
7335
7346
|
});
|
|
7336
7347
|
const { error } = validation.validate(query);
|
|
7337
7348
|
if (error) {
|
|
@@ -7361,7 +7372,7 @@ function useScheduleTaskController() {
|
|
|
7361
7372
|
}
|
|
7362
7373
|
}
|
|
7363
7374
|
async function getScheduleTaskById(req, res, next) {
|
|
7364
|
-
const validation =
|
|
7375
|
+
const validation = Joi18.string().hex().required();
|
|
7365
7376
|
const _id = req.params.id;
|
|
7366
7377
|
const { error, value } = validation.validate(_id);
|
|
7367
7378
|
if (error) {
|
|
@@ -7381,18 +7392,18 @@ function useScheduleTaskController() {
|
|
|
7381
7392
|
}
|
|
7382
7393
|
async function updateScheduleTask(req, res, next) {
|
|
7383
7394
|
const payload = { id: req.params.id, ...req.body };
|
|
7384
|
-
const validation =
|
|
7385
|
-
id:
|
|
7386
|
-
title:
|
|
7387
|
-
time:
|
|
7388
|
-
dates:
|
|
7389
|
-
|
|
7395
|
+
const validation = Joi18.object({
|
|
7396
|
+
id: Joi18.string().hex().required(),
|
|
7397
|
+
title: Joi18.string().optional().allow("", null),
|
|
7398
|
+
time: Joi18.string().pattern(/^([0-1]\d|2[0-3]):([0-5]\d)$/).optional().allow("", null),
|
|
7399
|
+
dates: Joi18.array().min(1).items(
|
|
7400
|
+
Joi18.string().pattern(/^\d{4}-\d{2}-\d{2}$/).required()
|
|
7390
7401
|
).optional(),
|
|
7391
|
-
description:
|
|
7392
|
-
areas:
|
|
7393
|
-
|
|
7394
|
-
name:
|
|
7395
|
-
value:
|
|
7402
|
+
description: Joi18.string().optional().allow("", null),
|
|
7403
|
+
areas: Joi18.array().min(1).items(
|
|
7404
|
+
Joi18.object({
|
|
7405
|
+
name: Joi18.string().required(),
|
|
7406
|
+
value: Joi18.any().required()
|
|
7396
7407
|
})
|
|
7397
7408
|
).optional()
|
|
7398
7409
|
});
|
|
@@ -7414,7 +7425,7 @@ function useScheduleTaskController() {
|
|
|
7414
7425
|
}
|
|
7415
7426
|
}
|
|
7416
7427
|
async function deleteScheduleTask(req, res, next) {
|
|
7417
|
-
const validation =
|
|
7428
|
+
const validation = Joi18.string().hex().required();
|
|
7418
7429
|
const _id = req.params.id;
|
|
7419
7430
|
const { error, value } = validation.validate(_id);
|
|
7420
7431
|
if (error) {
|
|
@@ -7658,17 +7669,17 @@ function useQRService() {
|
|
|
7658
7669
|
}
|
|
7659
7670
|
|
|
7660
7671
|
// src/controllers/hygiene-qr.controller.ts
|
|
7661
|
-
import
|
|
7672
|
+
import Joi19 from "joi";
|
|
7662
7673
|
import { BadRequestError as BadRequestError31, logger as logger35 } from "@7365admin1/node-server-utils";
|
|
7663
7674
|
function useQRController() {
|
|
7664
7675
|
const { generateQRImage: _generateQRImage, generateQRPDF: _generateQRPDF } = useQRService();
|
|
7665
7676
|
async function generateQR(req, res, next) {
|
|
7666
|
-
const validation =
|
|
7667
|
-
url:
|
|
7668
|
-
filename:
|
|
7669
|
-
title:
|
|
7670
|
-
subtitle:
|
|
7671
|
-
download:
|
|
7677
|
+
const validation = Joi19.object({
|
|
7678
|
+
url: Joi19.string().uri().required(),
|
|
7679
|
+
filename: Joi19.string().optional().allow("", null),
|
|
7680
|
+
title: Joi19.string().optional().allow("", null),
|
|
7681
|
+
subtitle: Joi19.string().optional().allow("", null),
|
|
7682
|
+
download: Joi19.boolean().optional().default(false)
|
|
7672
7683
|
});
|
|
7673
7684
|
const query = { ...req.query };
|
|
7674
7685
|
const { error, value } = validation.validate(query);
|