@7365admin1/module-hygiene 1.7.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +91 -65
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +91 -65
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -280,6 +280,7 @@ declare function useAreaChecklistRepo(): {
|
|
|
280
280
|
updateAreaChecklist: (_id: string | ObjectId, value: TAreaChecklistUpdate, session?: ClientSession) => Promise<number>;
|
|
281
281
|
updateAreaChecklistStatus: (_id: string | ObjectId, status: (typeof allowedStatus)[number], session?: ClientSession) => Promise<number>;
|
|
282
282
|
completeAreaChecklistUnits: (_id: string | ObjectId, set: number, unitId: string | ObjectId, value: TAreaChecklistUnitsUpdate, session?: ClientSession) => Promise<number>;
|
|
283
|
+
getMaxSetNumberForArea: (areaId: string | ObjectId, session?: ClientSession) => Promise<any>;
|
|
283
284
|
};
|
|
284
285
|
|
|
285
286
|
declare function useAreaChecklistController(): {
|
package/dist/index.js
CHANGED
|
@@ -90,7 +90,7 @@ var allowedPeriods = ["today", "thisWeek", "thisMonth"];
|
|
|
90
90
|
// src/repositories/hygiene-dashboard.repository.ts
|
|
91
91
|
var import_moment_timezone = __toESM(require("moment-timezone"));
|
|
92
92
|
var import_mongodb = require("mongodb");
|
|
93
|
-
var import_node_server_utils = require("@
|
|
93
|
+
var import_node_server_utils = require("@7365admin1/node-server-utils");
|
|
94
94
|
function useHygieneDashboardRepository() {
|
|
95
95
|
const db = import_node_server_utils.useAtlas.getDb();
|
|
96
96
|
if (!db) {
|
|
@@ -563,7 +563,7 @@ function useHygieneDashboardRepository() {
|
|
|
563
563
|
|
|
564
564
|
// src/controllers/hygiene-dashboard.controller.ts
|
|
565
565
|
var import_joi = __toESM(require("joi"));
|
|
566
|
-
var import_node_server_utils2 = require("@
|
|
566
|
+
var import_node_server_utils2 = require("@7365admin1/node-server-utils");
|
|
567
567
|
function useHygieneDashboardController() {
|
|
568
568
|
const { getHygieneDashboard: _getHygieneDashboard } = useHygieneDashboardRepository();
|
|
569
569
|
async function getHygieneDashboard(req, res, next) {
|
|
@@ -616,7 +616,7 @@ function useHygieneDashboardController() {
|
|
|
616
616
|
// src/models/hygiene-area.model.ts
|
|
617
617
|
var import_joi2 = __toESM(require("joi"));
|
|
618
618
|
var import_mongodb2 = require("mongodb");
|
|
619
|
-
var import_node_server_utils3 = require("@
|
|
619
|
+
var import_node_server_utils3 = require("@7365admin1/node-server-utils");
|
|
620
620
|
var areaSchema = import_joi2.default.object({
|
|
621
621
|
site: import_joi2.default.string().hex().required(),
|
|
622
622
|
name: import_joi2.default.string().required(),
|
|
@@ -671,7 +671,7 @@ function MArea(value) {
|
|
|
671
671
|
|
|
672
672
|
// src/repositories/hygiene-area.repository.ts
|
|
673
673
|
var import_mongodb3 = require("mongodb");
|
|
674
|
-
var import_node_server_utils4 = require("@
|
|
674
|
+
var import_node_server_utils4 = require("@7365admin1/node-server-utils");
|
|
675
675
|
|
|
676
676
|
// src/utils/capitalize-text.ts
|
|
677
677
|
function capitalizeText(text) {
|
|
@@ -1081,7 +1081,7 @@ function useAreaRepo() {
|
|
|
1081
1081
|
}
|
|
1082
1082
|
|
|
1083
1083
|
// src/services/hygiene-area.service.ts
|
|
1084
|
-
var import_node_server_utils5 = require("@
|
|
1084
|
+
var import_node_server_utils5 = require("@7365admin1/node-server-utils");
|
|
1085
1085
|
function useAreaService() {
|
|
1086
1086
|
const { createArea: _createArea } = useAreaRepo();
|
|
1087
1087
|
async function importArea({
|
|
@@ -1196,7 +1196,7 @@ function useAreaService() {
|
|
|
1196
1196
|
|
|
1197
1197
|
// src/controllers/hygiene-area.controller.ts
|
|
1198
1198
|
var import_joi3 = __toESM(require("joi"));
|
|
1199
|
-
var import_node_server_utils6 = require("@
|
|
1199
|
+
var import_node_server_utils6 = require("@7365admin1/node-server-utils");
|
|
1200
1200
|
|
|
1201
1201
|
// src/utils/convert-excel.util.ts
|
|
1202
1202
|
var import_stream = require("stream");
|
|
@@ -1291,14 +1291,14 @@ function useAreaController() {
|
|
|
1291
1291
|
async function getAreaById(req, res, next) {
|
|
1292
1292
|
const validation = import_joi3.default.string().hex().required();
|
|
1293
1293
|
const _id = req.params.id;
|
|
1294
|
-
const { error } = validation.validate(_id);
|
|
1294
|
+
const { error, value } = validation.validate(_id);
|
|
1295
1295
|
if (error) {
|
|
1296
1296
|
import_node_server_utils6.logger.log({ level: "error", message: error.message });
|
|
1297
1297
|
next(new import_node_server_utils6.BadRequestError(error.message));
|
|
1298
1298
|
return;
|
|
1299
1299
|
}
|
|
1300
1300
|
try {
|
|
1301
|
-
const data = await _getAreaById(
|
|
1301
|
+
const data = await _getAreaById(value);
|
|
1302
1302
|
res.json(data);
|
|
1303
1303
|
return;
|
|
1304
1304
|
} catch (error2) {
|
|
@@ -1343,14 +1343,14 @@ function useAreaController() {
|
|
|
1343
1343
|
async function deleteArea(req, res, next) {
|
|
1344
1344
|
const id = req.params.id;
|
|
1345
1345
|
const validation = import_joi3.default.string().hex().required();
|
|
1346
|
-
const { error } = validation.validate(id);
|
|
1346
|
+
const { error, value } = validation.validate(id);
|
|
1347
1347
|
if (error) {
|
|
1348
1348
|
import_node_server_utils6.logger.log({ level: "error", message: error.message });
|
|
1349
1349
|
next(new import_node_server_utils6.BadRequestError(error.message));
|
|
1350
1350
|
return;
|
|
1351
1351
|
}
|
|
1352
1352
|
try {
|
|
1353
|
-
await _deleteById(
|
|
1353
|
+
await _deleteById(value);
|
|
1354
1354
|
res.json({ message: "Area deleted successfully." });
|
|
1355
1355
|
return;
|
|
1356
1356
|
} catch (error2) {
|
|
@@ -1366,7 +1366,7 @@ function useAreaController() {
|
|
|
1366
1366
|
}
|
|
1367
1367
|
const { site } = req.params;
|
|
1368
1368
|
const schema = import_joi3.default.string().hex().required();
|
|
1369
|
-
const { error } = schema.validate(site);
|
|
1369
|
+
const { error, value } = schema.validate(site);
|
|
1370
1370
|
if (error) {
|
|
1371
1371
|
import_node_server_utils6.logger.log({ level: "error", message: error.message });
|
|
1372
1372
|
next(new import_node_server_utils6.BadRequestError(error.message));
|
|
@@ -1375,7 +1375,7 @@ function useAreaController() {
|
|
|
1375
1375
|
try {
|
|
1376
1376
|
const xlsData = await convertBufferFile(req.file.buffer);
|
|
1377
1377
|
const dataJson = JSON.stringify(xlsData);
|
|
1378
|
-
const result = await _importArea({ dataJson, site });
|
|
1378
|
+
const result = await _importArea({ dataJson, site: value });
|
|
1379
1379
|
return res.status(201).json(result);
|
|
1380
1380
|
} catch (error2) {
|
|
1381
1381
|
import_node_server_utils6.logger.log({ level: "error", message: error2.message });
|
|
@@ -1396,7 +1396,7 @@ function useAreaController() {
|
|
|
1396
1396
|
// src/models/hygiene-unit.model.ts
|
|
1397
1397
|
var import_joi4 = __toESM(require("joi"));
|
|
1398
1398
|
var import_mongodb4 = require("mongodb");
|
|
1399
|
-
var import_node_server_utils7 = require("@
|
|
1399
|
+
var import_node_server_utils7 = require("@7365admin1/node-server-utils");
|
|
1400
1400
|
var unitSchema = import_joi4.default.object({
|
|
1401
1401
|
site: import_joi4.default.string().hex().required(),
|
|
1402
1402
|
name: import_joi4.default.string().required()
|
|
@@ -1425,11 +1425,11 @@ function MUnit(value) {
|
|
|
1425
1425
|
}
|
|
1426
1426
|
|
|
1427
1427
|
// src/services/hygiene-unit.service.ts
|
|
1428
|
-
var import_node_server_utils9 = require("@
|
|
1428
|
+
var import_node_server_utils9 = require("@7365admin1/node-server-utils");
|
|
1429
1429
|
|
|
1430
1430
|
// src/repositories/hygiene-unit.repository.ts
|
|
1431
1431
|
var import_mongodb5 = require("mongodb");
|
|
1432
|
-
var import_node_server_utils8 = require("@
|
|
1432
|
+
var import_node_server_utils8 = require("@7365admin1/node-server-utils");
|
|
1433
1433
|
function useUnitRepository() {
|
|
1434
1434
|
const db = import_node_server_utils8.useAtlas.getDb();
|
|
1435
1435
|
if (!db) {
|
|
@@ -1766,7 +1766,7 @@ function useUnitService() {
|
|
|
1766
1766
|
|
|
1767
1767
|
// src/controllers/hygiene-unit.controller.ts
|
|
1768
1768
|
var import_joi5 = __toESM(require("joi"));
|
|
1769
|
-
var import_node_server_utils10 = require("@
|
|
1769
|
+
var import_node_server_utils10 = require("@7365admin1/node-server-utils");
|
|
1770
1770
|
function useUnitController() {
|
|
1771
1771
|
const { createUnit: _createUnit, getUnits: _getUnits } = useUnitRepository();
|
|
1772
1772
|
const {
|
|
@@ -1853,14 +1853,14 @@ function useUnitController() {
|
|
|
1853
1853
|
const validation = import_joi5.default.object({
|
|
1854
1854
|
id: import_joi5.default.string().hex().required()
|
|
1855
1855
|
});
|
|
1856
|
-
const { error } = validation.validate({ id });
|
|
1856
|
+
const { error, value } = validation.validate({ id });
|
|
1857
1857
|
if (error) {
|
|
1858
1858
|
import_node_server_utils10.logger.log({ level: "error", message: error.message });
|
|
1859
1859
|
next(new import_node_server_utils10.BadRequestError(error.message));
|
|
1860
1860
|
return;
|
|
1861
1861
|
}
|
|
1862
1862
|
try {
|
|
1863
|
-
await _deleteUnit(
|
|
1863
|
+
await _deleteUnit(value);
|
|
1864
1864
|
res.json({ message: "Unit deleted successfully." });
|
|
1865
1865
|
return;
|
|
1866
1866
|
} catch (error2) {
|
|
@@ -1876,7 +1876,7 @@ function useUnitController() {
|
|
|
1876
1876
|
}
|
|
1877
1877
|
const { site } = req.params;
|
|
1878
1878
|
const validation = import_joi5.default.string().hex().required();
|
|
1879
|
-
const { error } = validation.validate(site);
|
|
1879
|
+
const { error, value } = validation.validate(site);
|
|
1880
1880
|
if (error) {
|
|
1881
1881
|
import_node_server_utils10.logger.log({ level: "error", message: error.message });
|
|
1882
1882
|
next(new import_node_server_utils10.BadRequestError(error.message));
|
|
@@ -1885,7 +1885,7 @@ function useUnitController() {
|
|
|
1885
1885
|
try {
|
|
1886
1886
|
const xlsData = await convertBufferFile(req.file.buffer);
|
|
1887
1887
|
const dataJson = JSON.stringify(xlsData);
|
|
1888
|
-
const result = await _importUnit({ dataJson, site });
|
|
1888
|
+
const result = await _importUnit({ dataJson, site: value });
|
|
1889
1889
|
return res.status(201).json(result);
|
|
1890
1890
|
} catch (error2) {
|
|
1891
1891
|
import_node_server_utils10.logger.log({ level: "error", message: error2.message });
|
|
@@ -1905,7 +1905,7 @@ function useUnitController() {
|
|
|
1905
1905
|
// src/models/hygiene-parent-checklist.model.ts
|
|
1906
1906
|
var import_joi6 = __toESM(require("joi"));
|
|
1907
1907
|
var import_mongodb6 = require("mongodb");
|
|
1908
|
-
var import_node_server_utils11 = require("@
|
|
1908
|
+
var import_node_server_utils11 = require("@7365admin1/node-server-utils");
|
|
1909
1909
|
var parentChecklistSchema = import_joi6.default.object({
|
|
1910
1910
|
createdAt: import_joi6.default.alternatives().try(import_joi6.default.date(), import_joi6.default.string()).optional().allow("", null),
|
|
1911
1911
|
site: import_joi6.default.string().hex().required()
|
|
@@ -1933,7 +1933,7 @@ function MParentChecklist(value) {
|
|
|
1933
1933
|
|
|
1934
1934
|
// src/repositories/hygiene-parent-checklist.repository.ts
|
|
1935
1935
|
var import_mongodb7 = require("mongodb");
|
|
1936
|
-
var import_node_server_utils12 = require("@
|
|
1936
|
+
var import_node_server_utils12 = require("@7365admin1/node-server-utils");
|
|
1937
1937
|
function useParentChecklistRepo() {
|
|
1938
1938
|
const db = import_node_server_utils12.useAtlas.getDb();
|
|
1939
1939
|
if (!db) {
|
|
@@ -2224,7 +2224,7 @@ function useParentChecklistRepo() {
|
|
|
2224
2224
|
|
|
2225
2225
|
// src/controllers/hygiene-parent-checklist.controller.ts
|
|
2226
2226
|
var import_joi7 = __toESM(require("joi"));
|
|
2227
|
-
var import_node_server_utils13 = require("@
|
|
2227
|
+
var import_node_server_utils13 = require("@7365admin1/node-server-utils");
|
|
2228
2228
|
function useParentChecklistController() {
|
|
2229
2229
|
const {
|
|
2230
2230
|
createParentChecklist: _createParentChecklist,
|
|
@@ -2299,7 +2299,7 @@ function useParentChecklistController() {
|
|
|
2299
2299
|
// src/models/hygiene-area-checklist.model.ts
|
|
2300
2300
|
var import_joi8 = __toESM(require("joi"));
|
|
2301
2301
|
var import_mongodb8 = require("mongodb");
|
|
2302
|
-
var import_node_server_utils14 = require("@
|
|
2302
|
+
var import_node_server_utils14 = require("@7365admin1/node-server-utils");
|
|
2303
2303
|
var allowedChecklistStatus = ["ready", "completed"];
|
|
2304
2304
|
var areaChecklistSchema = import_joi8.default.object({
|
|
2305
2305
|
schedule: import_joi8.default.string().hex().required(),
|
|
@@ -2367,11 +2367,11 @@ function MAreaChecklist(value) {
|
|
|
2367
2367
|
}
|
|
2368
2368
|
|
|
2369
2369
|
// src/services/hygiene-area-checklist.service.ts
|
|
2370
|
-
var import_node_server_utils16 = require("@
|
|
2370
|
+
var import_node_server_utils16 = require("@7365admin1/node-server-utils");
|
|
2371
2371
|
|
|
2372
2372
|
// src/repositories/hygiene-area-checklist.repository.ts
|
|
2373
2373
|
var import_mongodb9 = require("mongodb");
|
|
2374
|
-
var import_node_server_utils15 = require("@
|
|
2374
|
+
var import_node_server_utils15 = require("@7365admin1/node-server-utils");
|
|
2375
2375
|
function useAreaChecklistRepo() {
|
|
2376
2376
|
const db = import_node_server_utils15.useAtlas.getDb();
|
|
2377
2377
|
if (!db) {
|
|
@@ -3014,6 +3014,7 @@ function useAreaChecklistRepo() {
|
|
|
3014
3014
|
}
|
|
3015
3015
|
try {
|
|
3016
3016
|
const updateValue = {
|
|
3017
|
+
...value,
|
|
3017
3018
|
updatedAt: /* @__PURE__ */ new Date()
|
|
3018
3019
|
};
|
|
3019
3020
|
const res = await collection.updateOne(
|
|
@@ -3022,9 +3023,7 @@ function useAreaChecklistRepo() {
|
|
|
3022
3023
|
{ session }
|
|
3023
3024
|
);
|
|
3024
3025
|
if (res.modifiedCount === 0) {
|
|
3025
|
-
throw new import_node_server_utils15.InternalServerError(
|
|
3026
|
-
"Unable to update area checklist status."
|
|
3027
|
-
);
|
|
3026
|
+
throw new import_node_server_utils15.InternalServerError("Unable to update area checklist.");
|
|
3028
3027
|
}
|
|
3029
3028
|
delNamespace().then(() => {
|
|
3030
3029
|
import_node_server_utils15.logger.info(`Cache cleared for namespace: ${namespace_collection}`);
|
|
@@ -3076,6 +3075,23 @@ function useAreaChecklistRepo() {
|
|
|
3076
3075
|
throw error;
|
|
3077
3076
|
}
|
|
3078
3077
|
}
|
|
3078
|
+
async function getMaxSetNumberForArea(areaId, session) {
|
|
3079
|
+
try {
|
|
3080
|
+
const _id = new import_mongodb9.ObjectId(areaId);
|
|
3081
|
+
const result = await collection.aggregate(
|
|
3082
|
+
[
|
|
3083
|
+
{ $match: { area: _id.toString() } },
|
|
3084
|
+
{ $unwind: "$checklist" },
|
|
3085
|
+
{ $group: { _id: null, maxSet: { $max: "$checklist.set" } } }
|
|
3086
|
+
],
|
|
3087
|
+
{ session }
|
|
3088
|
+
).toArray();
|
|
3089
|
+
return result.length > 0 && result[0].maxSet ? result[0].maxSet : 0;
|
|
3090
|
+
} catch (error) {
|
|
3091
|
+
import_node_server_utils15.logger.error(`Error getting max set number for area ${areaId}:`, error);
|
|
3092
|
+
return 0;
|
|
3093
|
+
}
|
|
3094
|
+
}
|
|
3079
3095
|
return {
|
|
3080
3096
|
createIndex,
|
|
3081
3097
|
createTextIndex,
|
|
@@ -3088,7 +3104,8 @@ function useAreaChecklistRepo() {
|
|
|
3088
3104
|
getAreaChecklistByAreaAndSchedule,
|
|
3089
3105
|
updateAreaChecklist,
|
|
3090
3106
|
updateAreaChecklistStatus,
|
|
3091
|
-
completeAreaChecklistUnits
|
|
3107
|
+
completeAreaChecklistUnits,
|
|
3108
|
+
getMaxSetNumberForArea
|
|
3092
3109
|
};
|
|
3093
3110
|
}
|
|
3094
3111
|
|
|
@@ -3101,7 +3118,8 @@ function useAreaChecklistService() {
|
|
|
3101
3118
|
getAreaChecklistUnits,
|
|
3102
3119
|
getAreaChecklistById,
|
|
3103
3120
|
completeAreaChecklistUnits: _completeAreaChecklistUnits,
|
|
3104
|
-
updateAreaChecklistStatus
|
|
3121
|
+
updateAreaChecklistStatus,
|
|
3122
|
+
getMaxSetNumberForArea
|
|
3105
3123
|
} = useAreaChecklistRepo();
|
|
3106
3124
|
const { updateParentChecklistStatuses } = useParentChecklistRepo();
|
|
3107
3125
|
async function createAreaChecklist(value) {
|
|
@@ -3117,18 +3135,26 @@ function useAreaChecklistService() {
|
|
|
3117
3135
|
for (let i = 0; i < areas.length; i += BATCH_SIZE) {
|
|
3118
3136
|
const batch = areas.slice(i, i + BATCH_SIZE);
|
|
3119
3137
|
const batchPromises = batch.map(async (area) => {
|
|
3138
|
+
if (!area.units || area.units.length === 0) {
|
|
3139
|
+
import_node_server_utils16.logger.warn(
|
|
3140
|
+
`Skipping area ${area.name} (${area._id}): No units defined`
|
|
3141
|
+
);
|
|
3142
|
+
return null;
|
|
3143
|
+
}
|
|
3144
|
+
const maxSet = await getMaxSetNumberForArea(area._id, session);
|
|
3145
|
+
const setCount = area.set || 1;
|
|
3120
3146
|
const checklistData = {
|
|
3121
3147
|
schedule: value.schedule,
|
|
3122
3148
|
area: area._id.toString(),
|
|
3123
3149
|
name: area.name,
|
|
3124
3150
|
type: area.type,
|
|
3125
|
-
checklist:
|
|
3126
|
-
set: index + 1,
|
|
3151
|
+
checklist: Array.from({ length: setCount }, (_, index) => ({
|
|
3152
|
+
set: maxSet + index + 1,
|
|
3127
3153
|
units: area.units.map((unit) => ({
|
|
3128
3154
|
unit: unit.unit.toString(),
|
|
3129
3155
|
name: unit.name
|
|
3130
3156
|
}))
|
|
3131
|
-
}))
|
|
3157
|
+
}))
|
|
3132
3158
|
};
|
|
3133
3159
|
const insertedId = await _createAreaChecklist(
|
|
3134
3160
|
checklistData,
|
|
@@ -3138,10 +3164,10 @@ function useAreaChecklistService() {
|
|
|
3138
3164
|
return insertedId;
|
|
3139
3165
|
});
|
|
3140
3166
|
const batchResults = await Promise.all(batchPromises);
|
|
3141
|
-
results.push(...batchResults);
|
|
3167
|
+
results.push(...batchResults.filter((id) => id !== null));
|
|
3142
3168
|
}
|
|
3143
3169
|
import_node_server_utils16.logger.info(
|
|
3144
|
-
`Created ${areas.length}
|
|
3170
|
+
`Created ${totalChecklistsCreated} area checklists out of ${areas.length} areas for site: ${value.site}`
|
|
3145
3171
|
);
|
|
3146
3172
|
} else {
|
|
3147
3173
|
import_node_server_utils16.logger.warn(`No common areas found for site: ${value.site}`);
|
|
@@ -3250,7 +3276,7 @@ function useAreaChecklistService() {
|
|
|
3250
3276
|
|
|
3251
3277
|
// src/controllers/hygiene-area-checklist.controller.ts
|
|
3252
3278
|
var import_joi9 = __toESM(require("joi"));
|
|
3253
|
-
var import_node_server_utils17 = require("@
|
|
3279
|
+
var import_node_server_utils17 = require("@7365admin1/node-server-utils");
|
|
3254
3280
|
function useAreaChecklistController() {
|
|
3255
3281
|
const {
|
|
3256
3282
|
getAllAreaChecklist: _getAllAreaChecklist,
|
|
@@ -3271,14 +3297,14 @@ function useAreaChecklistController() {
|
|
|
3271
3297
|
site: import_joi9.default.string().hex().required(),
|
|
3272
3298
|
schedule: import_joi9.default.string().hex().required()
|
|
3273
3299
|
});
|
|
3274
|
-
const { error } = validation.validate(payload);
|
|
3300
|
+
const { error, value } = validation.validate(payload);
|
|
3275
3301
|
if (error) {
|
|
3276
3302
|
import_node_server_utils17.logger.log({ level: "error", message: error.message });
|
|
3277
3303
|
next(new import_node_server_utils17.BadRequestError(error.message));
|
|
3278
3304
|
return;
|
|
3279
3305
|
}
|
|
3280
3306
|
try {
|
|
3281
|
-
await _createAreaChecklist(
|
|
3307
|
+
await _createAreaChecklist(value);
|
|
3282
3308
|
res.status(201).json({ message: "Area checklist generated successfully." });
|
|
3283
3309
|
return;
|
|
3284
3310
|
} catch (error2) {
|
|
@@ -3371,14 +3397,14 @@ function useAreaChecklistController() {
|
|
|
3371
3397
|
async function getAreaChecklistHistoryDetails(req, res, next) {
|
|
3372
3398
|
const validation = import_joi9.default.string().hex().required();
|
|
3373
3399
|
const _id = req.params.id;
|
|
3374
|
-
const { error } = validation.validate(_id);
|
|
3400
|
+
const { error, value } = validation.validate(_id);
|
|
3375
3401
|
if (error) {
|
|
3376
3402
|
import_node_server_utils17.logger.log({ level: "error", message: error.message });
|
|
3377
3403
|
next(new import_node_server_utils17.BadRequestError(error.message));
|
|
3378
3404
|
return;
|
|
3379
3405
|
}
|
|
3380
3406
|
try {
|
|
3381
|
-
const data = await _getAreaChecklistHistoryDetails(
|
|
3407
|
+
const data = await _getAreaChecklistHistoryDetails(value);
|
|
3382
3408
|
res.json(data);
|
|
3383
3409
|
return;
|
|
3384
3410
|
} catch (error2) {
|
|
@@ -3473,7 +3499,7 @@ function useAreaChecklistController() {
|
|
|
3473
3499
|
// src/models/hygiene-supply.model.ts
|
|
3474
3500
|
var import_joi10 = __toESM(require("joi"));
|
|
3475
3501
|
var import_mongodb10 = require("mongodb");
|
|
3476
|
-
var import_node_server_utils18 = require("@
|
|
3502
|
+
var import_node_server_utils18 = require("@7365admin1/node-server-utils");
|
|
3477
3503
|
var supplySchema = import_joi10.default.object({
|
|
3478
3504
|
site: import_joi10.default.string().hex().required(),
|
|
3479
3505
|
name: import_joi10.default.string().required(),
|
|
@@ -3506,7 +3532,7 @@ function MSupply(value) {
|
|
|
3506
3532
|
|
|
3507
3533
|
// src/repositories/hygiene-supply.repository.ts
|
|
3508
3534
|
var import_mongodb11 = require("mongodb");
|
|
3509
|
-
var import_node_server_utils19 = require("@
|
|
3535
|
+
var import_node_server_utils19 = require("@7365admin1/node-server-utils");
|
|
3510
3536
|
function useSupplyRepository() {
|
|
3511
3537
|
const db = import_node_server_utils19.useAtlas.getDb();
|
|
3512
3538
|
if (!db) {
|
|
@@ -3749,7 +3775,7 @@ function useSupplyRepository() {
|
|
|
3749
3775
|
|
|
3750
3776
|
// src/controllers/hygiene-supply.controller.ts
|
|
3751
3777
|
var import_joi11 = __toESM(require("joi"));
|
|
3752
|
-
var import_node_server_utils20 = require("@
|
|
3778
|
+
var import_node_server_utils20 = require("@7365admin1/node-server-utils");
|
|
3753
3779
|
function useSupplyController() {
|
|
3754
3780
|
const {
|
|
3755
3781
|
createSupply: _createSupply,
|
|
@@ -3812,14 +3838,14 @@ function useSupplyController() {
|
|
|
3812
3838
|
async function getSupplyById(req, res, next) {
|
|
3813
3839
|
const validation = import_joi11.default.string().hex().required();
|
|
3814
3840
|
const _id = req.params.id;
|
|
3815
|
-
const { error } = validation.validate(_id);
|
|
3841
|
+
const { error, value } = validation.validate(_id);
|
|
3816
3842
|
if (error) {
|
|
3817
3843
|
import_node_server_utils20.logger.log({ level: "error", message: error.message });
|
|
3818
3844
|
next(new import_node_server_utils20.BadRequestError(error.message));
|
|
3819
3845
|
return;
|
|
3820
3846
|
}
|
|
3821
3847
|
try {
|
|
3822
|
-
const data = await _getSupplyById(
|
|
3848
|
+
const data = await _getSupplyById(value);
|
|
3823
3849
|
res.json(data);
|
|
3824
3850
|
return;
|
|
3825
3851
|
} catch (error2) {
|
|
@@ -3858,14 +3884,14 @@ function useSupplyController() {
|
|
|
3858
3884
|
const validation = import_joi11.default.object({
|
|
3859
3885
|
id: import_joi11.default.string().hex().required()
|
|
3860
3886
|
});
|
|
3861
|
-
const { error } = validation.validate({ id });
|
|
3887
|
+
const { error, value } = validation.validate({ id });
|
|
3862
3888
|
if (error) {
|
|
3863
3889
|
import_node_server_utils20.logger.log({ level: "error", message: error.message });
|
|
3864
3890
|
next(new import_node_server_utils20.BadRequestError(error.message));
|
|
3865
3891
|
return;
|
|
3866
3892
|
}
|
|
3867
3893
|
try {
|
|
3868
|
-
await _deleteSupply(
|
|
3894
|
+
await _deleteSupply(value);
|
|
3869
3895
|
res.json({ message: "Supply deleted successfully." });
|
|
3870
3896
|
return;
|
|
3871
3897
|
} catch (error2) {
|
|
@@ -3886,7 +3912,7 @@ function useSupplyController() {
|
|
|
3886
3912
|
// src/models/hygiene-stock.model.ts
|
|
3887
3913
|
var import_joi12 = __toESM(require("joi"));
|
|
3888
3914
|
var import_mongodb12 = require("mongodb");
|
|
3889
|
-
var import_node_server_utils21 = require("@
|
|
3915
|
+
var import_node_server_utils21 = require("@7365admin1/node-server-utils");
|
|
3890
3916
|
var stockSchema = import_joi12.default.object({
|
|
3891
3917
|
site: import_joi12.default.string().hex().required(),
|
|
3892
3918
|
supply: import_joi12.default.string().hex().required(),
|
|
@@ -3931,7 +3957,7 @@ function MStock(value) {
|
|
|
3931
3957
|
|
|
3932
3958
|
// src/repositories/hygiene-stock.repository.ts
|
|
3933
3959
|
var import_mongodb13 = require("mongodb");
|
|
3934
|
-
var import_node_server_utils22 = require("@
|
|
3960
|
+
var import_node_server_utils22 = require("@7365admin1/node-server-utils");
|
|
3935
3961
|
function useStockRepository() {
|
|
3936
3962
|
const db = import_node_server_utils22.useAtlas.getDb();
|
|
3937
3963
|
if (!db) {
|
|
@@ -4053,7 +4079,7 @@ function useStockRepository() {
|
|
|
4053
4079
|
}
|
|
4054
4080
|
|
|
4055
4081
|
// src/services/hygiene-stock.service.ts
|
|
4056
|
-
var import_node_server_utils23 = require("@
|
|
4082
|
+
var import_node_server_utils23 = require("@7365admin1/node-server-utils");
|
|
4057
4083
|
function useStockService() {
|
|
4058
4084
|
const { createStock: _createStock } = useStockRepository();
|
|
4059
4085
|
const { getSupplyById, updateSupply } = useSupplyRepository();
|
|
@@ -4096,7 +4122,7 @@ function useStockService() {
|
|
|
4096
4122
|
|
|
4097
4123
|
// src/controllers/hygiene-stock.controller.ts
|
|
4098
4124
|
var import_joi13 = __toESM(require("joi"));
|
|
4099
|
-
var import_node_server_utils24 = require("@
|
|
4125
|
+
var import_node_server_utils24 = require("@7365admin1/node-server-utils");
|
|
4100
4126
|
function useStockController() {
|
|
4101
4127
|
const { getStocksBySupplyId: _getStocksBySupplyId } = useStockRepository();
|
|
4102
4128
|
const { createStock: _createStock } = useStockService();
|
|
@@ -4169,7 +4195,7 @@ function useStockController() {
|
|
|
4169
4195
|
// src/models/hygiene-request-item.model.ts
|
|
4170
4196
|
var import_joi14 = __toESM(require("joi"));
|
|
4171
4197
|
var import_mongodb14 = require("mongodb");
|
|
4172
|
-
var import_node_server_utils25 = require("@
|
|
4198
|
+
var import_node_server_utils25 = require("@7365admin1/node-server-utils");
|
|
4173
4199
|
var allowedRequestItemStatus = [
|
|
4174
4200
|
"pending",
|
|
4175
4201
|
"approved",
|
|
@@ -4220,7 +4246,7 @@ function MRequestItem(value) {
|
|
|
4220
4246
|
|
|
4221
4247
|
// src/repositories/hygiene-request-item.repository.ts
|
|
4222
4248
|
var import_mongodb15 = require("mongodb");
|
|
4223
|
-
var import_node_server_utils26 = require("@
|
|
4249
|
+
var import_node_server_utils26 = require("@7365admin1/node-server-utils");
|
|
4224
4250
|
function useRequestItemRepository() {
|
|
4225
4251
|
const db = import_node_server_utils26.useAtlas.getDb();
|
|
4226
4252
|
if (!db) {
|
|
@@ -4463,8 +4489,8 @@ function useRequestItemRepository() {
|
|
|
4463
4489
|
}
|
|
4464
4490
|
|
|
4465
4491
|
// src/services/hygiene-request-item.service.ts
|
|
4466
|
-
var import_core = require("@
|
|
4467
|
-
var import_node_server_utils27 = require("@
|
|
4492
|
+
var import_core = require("@7365admin1/core");
|
|
4493
|
+
var import_node_server_utils27 = require("@7365admin1/node-server-utils");
|
|
4468
4494
|
function useRequestItemService() {
|
|
4469
4495
|
const {
|
|
4470
4496
|
createRequestItem: _createRequestItem,
|
|
@@ -4580,7 +4606,7 @@ function useRequestItemService() {
|
|
|
4580
4606
|
|
|
4581
4607
|
// src/controllers/hygiene-request-item.controller.ts
|
|
4582
4608
|
var import_joi15 = __toESM(require("joi"));
|
|
4583
|
-
var import_node_server_utils28 = require("@
|
|
4609
|
+
var import_node_server_utils28 = require("@7365admin1/node-server-utils");
|
|
4584
4610
|
function useRequestItemController() {
|
|
4585
4611
|
const {
|
|
4586
4612
|
getRequestItems: _getRequestItems,
|
|
@@ -4698,14 +4724,14 @@ function useRequestItemController() {
|
|
|
4698
4724
|
async function getRequestItemById(req, res, next) {
|
|
4699
4725
|
const validation = import_joi15.default.string().hex().required();
|
|
4700
4726
|
const _id = req.params.id;
|
|
4701
|
-
const { error } = validation.validate(_id);
|
|
4727
|
+
const { error, value } = validation.validate(_id);
|
|
4702
4728
|
if (error) {
|
|
4703
4729
|
import_node_server_utils28.logger.log({ level: "error", message: error.message });
|
|
4704
4730
|
next(new import_node_server_utils28.BadRequestError(error.message));
|
|
4705
4731
|
return;
|
|
4706
4732
|
}
|
|
4707
4733
|
try {
|
|
4708
|
-
const data = await _getRequestItemById(
|
|
4734
|
+
const data = await _getRequestItemById(value);
|
|
4709
4735
|
res.json(data);
|
|
4710
4736
|
return;
|
|
4711
4737
|
} catch (error2) {
|
|
@@ -4769,7 +4795,7 @@ function useRequestItemController() {
|
|
|
4769
4795
|
}
|
|
4770
4796
|
|
|
4771
4797
|
// src/models/hygiene-schedule-task.model.ts
|
|
4772
|
-
var import_node_server_utils29 = require("@
|
|
4798
|
+
var import_node_server_utils29 = require("@7365admin1/node-server-utils");
|
|
4773
4799
|
var import_joi16 = __toESM(require("joi"));
|
|
4774
4800
|
var import_mongodb16 = require("mongodb");
|
|
4775
4801
|
var allowedFrequency = [
|
|
@@ -4864,7 +4890,7 @@ function MScheduleTask(value) {
|
|
|
4864
4890
|
|
|
4865
4891
|
// src/repositories/hygiene-schedule-task.repository.ts
|
|
4866
4892
|
var import_mongodb17 = require("mongodb");
|
|
4867
|
-
var import_node_server_utils30 = require("@
|
|
4893
|
+
var import_node_server_utils30 = require("@7365admin1/node-server-utils");
|
|
4868
4894
|
function useScheduleTaskRepository() {
|
|
4869
4895
|
const db = import_node_server_utils30.useAtlas.getDb();
|
|
4870
4896
|
if (!db) {
|
|
@@ -5145,7 +5171,7 @@ function useScheduleTaskRepository() {
|
|
|
5145
5171
|
}
|
|
5146
5172
|
|
|
5147
5173
|
// src/services/hygiene-schedule-task.service.ts
|
|
5148
|
-
var import_node_server_utils31 = require("@
|
|
5174
|
+
var import_node_server_utils31 = require("@7365admin1/node-server-utils");
|
|
5149
5175
|
function useScheduleTaskService() {
|
|
5150
5176
|
const { createParentChecklist } = useParentChecklistRepo();
|
|
5151
5177
|
const { getAllScheduleTask, getScheduleTaskById } = useScheduleTaskRepository();
|
|
@@ -5492,7 +5518,7 @@ function useScheduleTaskService() {
|
|
|
5492
5518
|
|
|
5493
5519
|
// src/controllers/hygiene-schedule-task.controller.ts
|
|
5494
5520
|
var import_joi17 = __toESM(require("joi"));
|
|
5495
|
-
var import_node_server_utils32 = require("@
|
|
5521
|
+
var import_node_server_utils32 = require("@7365admin1/node-server-utils");
|
|
5496
5522
|
function useScheduleTaskController() {
|
|
5497
5523
|
const {
|
|
5498
5524
|
createScheduleTask: _createScheduleTask,
|
|
@@ -5588,14 +5614,14 @@ function useScheduleTaskController() {
|
|
|
5588
5614
|
async function getScheduleTaskById(req, res, next) {
|
|
5589
5615
|
const validation = import_joi17.default.string().hex().required();
|
|
5590
5616
|
const _id = req.params.id;
|
|
5591
|
-
const { error } = validation.validate(_id);
|
|
5617
|
+
const { error, value } = validation.validate(_id);
|
|
5592
5618
|
if (error) {
|
|
5593
5619
|
import_node_server_utils32.logger.log({ level: "error", message: error.message });
|
|
5594
5620
|
next(new import_node_server_utils32.BadRequestError(error.message));
|
|
5595
5621
|
return;
|
|
5596
5622
|
}
|
|
5597
5623
|
try {
|
|
5598
|
-
const data = await _getScheduleTaskById(
|
|
5624
|
+
const data = await _getScheduleTaskById(value);
|
|
5599
5625
|
res.json(data);
|
|
5600
5626
|
return;
|
|
5601
5627
|
} catch (error2) {
|