@7365admin1/module-hygiene 4.16.0 → 4.18.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 +12 -0
- package/dist/index.d.ts +36 -50
- package/dist/index.js +55 -106
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +51 -101
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
// src/models/hygiene-base.model.ts
|
|
2
|
-
var ServiceType = /* @__PURE__ */ ((ServiceType2) => {
|
|
3
|
-
ServiceType2["REAL_ESTATE_DEVELOPER"] = "real_estate_developer";
|
|
4
|
-
ServiceType2["PROPERTY_MANAGEMENT_AGENCY"] = "property_management_agency";
|
|
5
|
-
ServiceType2["SECURITY_AGENCY"] = "security_agency";
|
|
6
|
-
ServiceType2["CLEANING_SERVICES"] = "cleaning_services";
|
|
7
|
-
ServiceType2["MECHANICAL_ELECTRICAL_SERVICES"] = "mechanical_electrical_services";
|
|
8
|
-
ServiceType2["LANDSCAPING_SERVICES"] = "landscaping_services";
|
|
9
|
-
ServiceType2["PEST_CONTROL_SERVICES"] = "pest_control_services";
|
|
10
|
-
ServiceType2["POOL_MAINTENANCE_SERVICES"] = "pool_maintenance_services";
|
|
11
|
-
return ServiceType2;
|
|
12
|
-
})(ServiceType || {});
|
|
13
2
|
var allowedTypes = ["common", "toilet"];
|
|
14
3
|
var allowedStatus = [
|
|
15
4
|
"open",
|
|
@@ -556,9 +545,10 @@ function useHygieneDashboardController() {
|
|
|
556
545
|
import Joi2 from "joi";
|
|
557
546
|
import { ObjectId as ObjectId2 } from "mongodb";
|
|
558
547
|
import { BadRequestError as BadRequestError3, logger as logger3 } from "@7365admin1/node-server-utils";
|
|
548
|
+
import { AppServiceType } from "@7365admin1/core";
|
|
559
549
|
var areaSchema = Joi2.object({
|
|
560
550
|
site: Joi2.string().hex().required(),
|
|
561
|
-
serviceType: Joi2.string().valid(...Object.values(
|
|
551
|
+
serviceType: Joi2.string().valid(...Object.values(AppServiceType)).required(),
|
|
562
552
|
name: Joi2.string().required(),
|
|
563
553
|
type: Joi2.string().valid(...allowedTypes).required(),
|
|
564
554
|
set: Joi2.number().min(0).optional(),
|
|
@@ -1083,9 +1073,10 @@ import {
|
|
|
1083
1073
|
import Joi3 from "joi";
|
|
1084
1074
|
import { ObjectId as ObjectId4 } from "mongodb";
|
|
1085
1075
|
import { BadRequestError as BadRequestError5, logger as logger6 } from "@7365admin1/node-server-utils";
|
|
1076
|
+
import { AppServiceType as AppServiceType2 } from "@7365admin1/core";
|
|
1086
1077
|
var unitSchema = Joi3.object({
|
|
1087
1078
|
site: Joi3.string().hex().required(),
|
|
1088
|
-
serviceType: Joi3.string().valid(...Object.values(
|
|
1079
|
+
serviceType: Joi3.string().valid(...Object.values(AppServiceType2)).required(),
|
|
1089
1080
|
name: Joi3.string().required()
|
|
1090
1081
|
});
|
|
1091
1082
|
function MUnit(value) {
|
|
@@ -1506,6 +1497,7 @@ function useAreaService() {
|
|
|
1506
1497
|
// src/controllers/hygiene-area.controller.ts
|
|
1507
1498
|
import Joi4 from "joi";
|
|
1508
1499
|
import { BadRequestError as BadRequestError8, logger as logger9 } from "@7365admin1/node-server-utils";
|
|
1500
|
+
import { AppServiceType as AppServiceType3 } from "@7365admin1/core";
|
|
1509
1501
|
|
|
1510
1502
|
// src/utils/convert-excel.util.ts
|
|
1511
1503
|
import { Readable } from "stream";
|
|
@@ -1570,7 +1562,7 @@ function useAreaController() {
|
|
|
1570
1562
|
search: Joi4.string().optional().allow("", null),
|
|
1571
1563
|
type: Joi4.string().valid("all", ...allowedTypes).optional().allow("", null),
|
|
1572
1564
|
site: Joi4.string().hex().required(),
|
|
1573
|
-
serviceType: Joi4.string().valid(...Object.values(
|
|
1565
|
+
serviceType: Joi4.string().valid(...Object.values(AppServiceType3)).required()
|
|
1574
1566
|
});
|
|
1575
1567
|
const { error } = validation.validate(query);
|
|
1576
1568
|
if (error) {
|
|
@@ -1679,7 +1671,7 @@ function useAreaController() {
|
|
|
1679
1671
|
const query = { ...req.query, ...req.params };
|
|
1680
1672
|
const validation = Joi4.object({
|
|
1681
1673
|
site: Joi4.string().hex().required(),
|
|
1682
|
-
serviceType: Joi4.string().valid(...Object.values(
|
|
1674
|
+
serviceType: Joi4.string().valid(...Object.values(AppServiceType3)).required()
|
|
1683
1675
|
});
|
|
1684
1676
|
const { error, value } = validation.validate(query);
|
|
1685
1677
|
if (error) {
|
|
@@ -1702,7 +1694,7 @@ function useAreaController() {
|
|
|
1702
1694
|
const query = { ...req.query, ...req.params };
|
|
1703
1695
|
const validation = Joi4.object({
|
|
1704
1696
|
site: Joi4.string().hex().required(),
|
|
1705
|
-
serviceType: Joi4.string().valid(...Object.values(
|
|
1697
|
+
serviceType: Joi4.string().valid(...Object.values(AppServiceType3)).required()
|
|
1706
1698
|
});
|
|
1707
1699
|
const { error, value } = validation.validate(query);
|
|
1708
1700
|
if (error) {
|
|
@@ -1985,6 +1977,7 @@ function useUnitService() {
|
|
|
1985
1977
|
// src/controllers/hygiene-unit.controller.ts
|
|
1986
1978
|
import Joi5 from "joi";
|
|
1987
1979
|
import { BadRequestError as BadRequestError10, logger as logger12 } from "@7365admin1/node-server-utils";
|
|
1980
|
+
import { AppServiceType as AppServiceType4 } from "@7365admin1/core";
|
|
1988
1981
|
function useUnitController() {
|
|
1989
1982
|
const { createUnit: _createUnit, getUnits: _getUnits } = useUnitRepository();
|
|
1990
1983
|
const {
|
|
@@ -2018,7 +2011,7 @@ function useUnitController() {
|
|
|
2018
2011
|
limit: Joi5.number().min(1).optional().allow("", null),
|
|
2019
2012
|
search: Joi5.string().optional().allow("", null),
|
|
2020
2013
|
site: Joi5.string().hex().required(),
|
|
2021
|
-
serviceType: Joi5.string().valid(...Object.values(
|
|
2014
|
+
serviceType: Joi5.string().valid(...Object.values(AppServiceType4)).required()
|
|
2022
2015
|
});
|
|
2023
2016
|
const { error } = validation.validate(query);
|
|
2024
2017
|
if (error) {
|
|
@@ -2099,7 +2092,7 @@ function useUnitController() {
|
|
|
2099
2092
|
const query = { ...req.query, ...req.params };
|
|
2100
2093
|
const validation = Joi5.object({
|
|
2101
2094
|
site: Joi5.string().hex().required(),
|
|
2102
|
-
serviceType: Joi5.string().valid(...Object.values(
|
|
2095
|
+
serviceType: Joi5.string().valid(...Object.values(AppServiceType4)).required()
|
|
2103
2096
|
});
|
|
2104
2097
|
const { error, value } = validation.validate(query);
|
|
2105
2098
|
if (error) {
|
|
@@ -2122,7 +2115,7 @@ function useUnitController() {
|
|
|
2122
2115
|
const query = { ...req.query, ...req.params };
|
|
2123
2116
|
const validation = Joi5.object({
|
|
2124
2117
|
site: Joi5.string().hex().required(),
|
|
2125
|
-
serviceType: Joi5.string().valid(...Object.values(
|
|
2118
|
+
serviceType: Joi5.string().valid(...Object.values(AppServiceType4)).required()
|
|
2126
2119
|
});
|
|
2127
2120
|
const { error, value } = validation.validate(query);
|
|
2128
2121
|
if (error) {
|
|
@@ -2168,10 +2161,11 @@ function useUnitController() {
|
|
|
2168
2161
|
import Joi6 from "joi";
|
|
2169
2162
|
import { ObjectId as ObjectId6 } from "mongodb";
|
|
2170
2163
|
import { BadRequestError as BadRequestError11, logger as logger13 } from "@7365admin1/node-server-utils";
|
|
2164
|
+
import { AppServiceType as AppServiceType5 } from "@7365admin1/core";
|
|
2171
2165
|
var parentChecklistSchema = Joi6.object({
|
|
2172
2166
|
createdAt: Joi6.alternatives().try(Joi6.date(), Joi6.string()).optional().allow("", null),
|
|
2173
2167
|
site: Joi6.string().hex().required(),
|
|
2174
|
-
serviceType: Joi6.string().valid(...Object.values(
|
|
2168
|
+
serviceType: Joi6.string().valid(...Object.values(AppServiceType5)).required()
|
|
2175
2169
|
});
|
|
2176
2170
|
function MParentChecklist(value) {
|
|
2177
2171
|
const { error } = parentChecklistSchema.validate(value);
|
|
@@ -2206,6 +2200,7 @@ import {
|
|
|
2206
2200
|
makeCacheKey as makeCacheKey4,
|
|
2207
2201
|
BadRequestError as BadRequestError12
|
|
2208
2202
|
} from "@7365admin1/node-server-utils";
|
|
2203
|
+
import { AppServiceType as AppServiceType6 } from "@7365admin1/core";
|
|
2209
2204
|
function useParentChecklistRepo() {
|
|
2210
2205
|
const db = useAtlas5.getDb();
|
|
2211
2206
|
if (!db) {
|
|
@@ -2237,7 +2232,7 @@ function useParentChecklistRepo() {
|
|
|
2237
2232
|
startOfDay.setUTCHours(0, 0, 0, 0);
|
|
2238
2233
|
const endOfDay = new Date(currentDate);
|
|
2239
2234
|
endOfDay.setUTCHours(23, 59, 59, 999);
|
|
2240
|
-
const allServiceTypes = Object.values(
|
|
2235
|
+
const allServiceTypes = Object.values(AppServiceType6);
|
|
2241
2236
|
const dateStr = currentDate.toISOString().split("T")[0];
|
|
2242
2237
|
if (value.site) {
|
|
2243
2238
|
let siteObjectId;
|
|
@@ -2642,6 +2637,7 @@ function useParentChecklistRepo() {
|
|
|
2642
2637
|
// src/controllers/hygiene-parent-checklist.controller.ts
|
|
2643
2638
|
import Joi7 from "joi";
|
|
2644
2639
|
import { BadRequestError as BadRequestError13, logger as logger15 } from "@7365admin1/node-server-utils";
|
|
2640
|
+
import { AppServiceType as AppServiceType7 } from "@7365admin1/core";
|
|
2645
2641
|
function useParentChecklistController() {
|
|
2646
2642
|
const {
|
|
2647
2643
|
createParentChecklist: _createParentChecklist,
|
|
@@ -2652,7 +2648,7 @@ function useParentChecklistController() {
|
|
|
2652
2648
|
const validation = Joi7.object({
|
|
2653
2649
|
createdAt: Joi7.alternatives().try(Joi7.date(), Joi7.string()).optional().allow("", null),
|
|
2654
2650
|
site: Joi7.string().hex().required(),
|
|
2655
|
-
serviceType: Joi7.string().valid(...Object.values(
|
|
2651
|
+
serviceType: Joi7.string().valid(...Object.values(AppServiceType7)).optional().allow("", null)
|
|
2656
2652
|
});
|
|
2657
2653
|
const { error } = validation.validate(payload);
|
|
2658
2654
|
if (error) {
|
|
@@ -2677,7 +2673,7 @@ function useParentChecklistController() {
|
|
|
2677
2673
|
limit: Joi7.number().min(1).optional().allow("", null),
|
|
2678
2674
|
search: Joi7.string().optional().allow("", null),
|
|
2679
2675
|
site: Joi7.string().hex().required(),
|
|
2680
|
-
serviceType: Joi7.string().valid(...Object.values(
|
|
2676
|
+
serviceType: Joi7.string().valid(...Object.values(AppServiceType7)).required(),
|
|
2681
2677
|
startDate: Joi7.alternatives().try(Joi7.date(), Joi7.string()).optional().allow("", null),
|
|
2682
2678
|
endDate: Joi7.alternatives().try(Joi7.date(), Joi7.string()).optional().allow("", null),
|
|
2683
2679
|
status: Joi7.string().valid(...allowedStatus, "all").optional().allow("", null)
|
|
@@ -2725,10 +2721,11 @@ function useParentChecklistController() {
|
|
|
2725
2721
|
import Joi8 from "joi";
|
|
2726
2722
|
import { ObjectId as ObjectId8 } from "mongodb";
|
|
2727
2723
|
import { BadRequestError as BadRequestError14, logger as logger16 } from "@7365admin1/node-server-utils";
|
|
2724
|
+
import { AppServiceType as AppServiceType8 } from "@7365admin1/core";
|
|
2728
2725
|
var allowedChecklistStatus = ["open", "completed", "closed"];
|
|
2729
2726
|
var areaChecklistSchema = Joi8.object({
|
|
2730
2727
|
schedule: Joi8.string().hex().required(),
|
|
2731
|
-
serviceType: Joi8.string().valid(...Object.values(
|
|
2728
|
+
serviceType: Joi8.string().valid(...Object.values(AppServiceType8)).required(),
|
|
2732
2729
|
area: Joi8.string().hex().required(),
|
|
2733
2730
|
name: Joi8.string().required(),
|
|
2734
2731
|
type: Joi8.string().valid(...allowedTypes).required(),
|
|
@@ -2744,8 +2741,7 @@ var areaChecklistSchema = Joi8.object({
|
|
|
2744
2741
|
isScheduleTask: Joi8.boolean().optional().default(false),
|
|
2745
2742
|
scheduleTaskId: Joi8.string().hex().optional().allow(null)
|
|
2746
2743
|
}).required()
|
|
2747
|
-
).optional().default([])
|
|
2748
|
-
createdBy: Joi8.string().hex().required()
|
|
2744
|
+
).optional().default([])
|
|
2749
2745
|
});
|
|
2750
2746
|
function MAreaChecklist(value) {
|
|
2751
2747
|
const { error } = areaChecklistSchema.validate(value);
|
|
@@ -2786,13 +2782,6 @@ function MAreaChecklist(value) {
|
|
|
2786
2782
|
};
|
|
2787
2783
|
});
|
|
2788
2784
|
}
|
|
2789
|
-
if (value.createdBy) {
|
|
2790
|
-
try {
|
|
2791
|
-
value.createdBy = new ObjectId8(value.createdBy);
|
|
2792
|
-
} catch (error2) {
|
|
2793
|
-
throw new BadRequestError14("Invalid createdBy ID format.");
|
|
2794
|
-
}
|
|
2795
|
-
}
|
|
2796
2785
|
return {
|
|
2797
2786
|
schedule: value.schedule,
|
|
2798
2787
|
serviceType: value.serviceType,
|
|
@@ -2801,7 +2790,6 @@ function MAreaChecklist(value) {
|
|
|
2801
2790
|
type: value.type,
|
|
2802
2791
|
checklist: value.checklist || [],
|
|
2803
2792
|
status: "open",
|
|
2804
|
-
createdBy: value.createdBy,
|
|
2805
2793
|
createdAt: /* @__PURE__ */ new Date(),
|
|
2806
2794
|
completedAt: "",
|
|
2807
2795
|
updatedAt: ""
|
|
@@ -2956,32 +2944,6 @@ function useAreaChecklistRepo() {
|
|
|
2956
2944
|
try {
|
|
2957
2945
|
const pipeline = [
|
|
2958
2946
|
{ $match: query },
|
|
2959
|
-
{
|
|
2960
|
-
$lookup: {
|
|
2961
|
-
from: "users",
|
|
2962
|
-
let: { createdById: "$createdBy" },
|
|
2963
|
-
pipeline: [
|
|
2964
|
-
{
|
|
2965
|
-
$match: {
|
|
2966
|
-
$expr: {
|
|
2967
|
-
$and: [
|
|
2968
|
-
{ $ne: ["$$createdById", ""] },
|
|
2969
|
-
{ $eq: ["$_id", "$$createdById"] }
|
|
2970
|
-
]
|
|
2971
|
-
}
|
|
2972
|
-
}
|
|
2973
|
-
},
|
|
2974
|
-
{ $project: { name: 1 } }
|
|
2975
|
-
],
|
|
2976
|
-
as: "createdByDoc"
|
|
2977
|
-
}
|
|
2978
|
-
},
|
|
2979
|
-
{
|
|
2980
|
-
$unwind: {
|
|
2981
|
-
path: "$createdByDoc",
|
|
2982
|
-
preserveNullAndEmptyArrays: true
|
|
2983
|
-
}
|
|
2984
|
-
},
|
|
2985
2947
|
{
|
|
2986
2948
|
$addFields: {
|
|
2987
2949
|
statusOrder: {
|
|
@@ -3033,8 +2995,7 @@ function useAreaChecklistRepo() {
|
|
|
3033
2995
|
},
|
|
3034
2996
|
else: 0
|
|
3035
2997
|
}
|
|
3036
|
-
}
|
|
3037
|
-
createdByName: "$createdByDoc.name"
|
|
2998
|
+
}
|
|
3038
2999
|
}
|
|
3039
3000
|
},
|
|
3040
3001
|
{ $skip: page * limit },
|
|
@@ -4088,8 +4049,7 @@ function useAreaChecklistService() {
|
|
|
4088
4049
|
unit: unit.unit.toString(),
|
|
4089
4050
|
name: unit.name
|
|
4090
4051
|
}))
|
|
4091
|
-
}))
|
|
4092
|
-
createdBy: value.createdBy
|
|
4052
|
+
}))
|
|
4093
4053
|
};
|
|
4094
4054
|
const insertedId = await _createAreaChecklist(checklistData);
|
|
4095
4055
|
totalChecklistsCreated++;
|
|
@@ -4217,6 +4177,7 @@ import {
|
|
|
4217
4177
|
InternalServerError as InternalServerError7,
|
|
4218
4178
|
logger as logger20
|
|
4219
4179
|
} from "@7365admin1/node-server-utils";
|
|
4180
|
+
import { AppServiceType as AppServiceType9 } from "@7365admin1/core";
|
|
4220
4181
|
|
|
4221
4182
|
// src/services/hygiene-checklist-pdf.service.ts
|
|
4222
4183
|
import { launch } from "puppeteer";
|
|
@@ -4450,16 +4411,13 @@ function useAreaChecklistController() {
|
|
|
4450
4411
|
(acc, [key, value2]) => ({ ...acc, [key]: value2 }),
|
|
4451
4412
|
{}
|
|
4452
4413
|
) : {};
|
|
4453
|
-
const createdBy = cookies["user"] || "";
|
|
4454
4414
|
const payload = {
|
|
4455
4415
|
site: req.params.site,
|
|
4456
|
-
schedule: req.params.schedule
|
|
4457
|
-
createdBy
|
|
4416
|
+
schedule: req.params.schedule
|
|
4458
4417
|
};
|
|
4459
4418
|
const validation = Joi9.object({
|
|
4460
4419
|
site: Joi9.string().hex().required(),
|
|
4461
|
-
schedule: Joi9.string().hex().required()
|
|
4462
|
-
createdBy: Joi9.string().hex().required()
|
|
4420
|
+
schedule: Joi9.string().hex().required()
|
|
4463
4421
|
});
|
|
4464
4422
|
const { error, value } = validation.validate(payload);
|
|
4465
4423
|
if (error) {
|
|
@@ -4486,7 +4444,7 @@ function useAreaChecklistController() {
|
|
|
4486
4444
|
type: Joi9.string().valid(...allowedTypes, "all").optional().allow("", null),
|
|
4487
4445
|
status: Joi9.string().valid(...allowedStatus, "all").optional().allow("", null),
|
|
4488
4446
|
schedule: Joi9.string().hex().required(),
|
|
4489
|
-
serviceType: Joi9.string().valid(...Object.values(
|
|
4447
|
+
serviceType: Joi9.string().valid(...Object.values(AppServiceType9)).required()
|
|
4490
4448
|
});
|
|
4491
4449
|
const { error } = validation.validate(query);
|
|
4492
4450
|
if (error) {
|
|
@@ -4586,7 +4544,7 @@ function useAreaChecklistController() {
|
|
|
4586
4544
|
page: Joi9.number().min(1).optional().allow("", null),
|
|
4587
4545
|
limit: Joi9.number().min(1).optional().allow("", null),
|
|
4588
4546
|
search: Joi9.string().optional().allow("", null),
|
|
4589
|
-
serviceType: Joi9.string().valid(...Object.values(
|
|
4547
|
+
serviceType: Joi9.string().valid(...Object.values(AppServiceType9)).required(),
|
|
4590
4548
|
id: Joi9.string().hex().required()
|
|
4591
4549
|
});
|
|
4592
4550
|
const { error } = validation.validate(query);
|
|
@@ -4715,9 +4673,10 @@ function useAreaChecklistController() {
|
|
|
4715
4673
|
import Joi10 from "joi";
|
|
4716
4674
|
import { ObjectId as ObjectId12 } from "mongodb";
|
|
4717
4675
|
import { BadRequestError as BadRequestError17, logger as logger21 } from "@7365admin1/node-server-utils";
|
|
4676
|
+
import { AppServiceType as AppServiceType10 } from "@7365admin1/core";
|
|
4718
4677
|
var supplySchema = Joi10.object({
|
|
4719
4678
|
site: Joi10.string().hex().required(),
|
|
4720
|
-
serviceType: Joi10.string().valid(...Object.values(
|
|
4679
|
+
serviceType: Joi10.string().valid(...Object.values(AppServiceType10)).required(),
|
|
4721
4680
|
name: Joi10.string().required(),
|
|
4722
4681
|
unitOfMeasurement: Joi10.string().required()
|
|
4723
4682
|
});
|
|
@@ -5008,6 +4967,7 @@ function useSupplyRepository() {
|
|
|
5008
4967
|
// src/controllers/hygiene-supply.controller.ts
|
|
5009
4968
|
import Joi11 from "joi";
|
|
5010
4969
|
import { BadRequestError as BadRequestError19, logger as logger23 } from "@7365admin1/node-server-utils";
|
|
4970
|
+
import { AppServiceType as AppServiceType11 } from "@7365admin1/core";
|
|
5011
4971
|
function useSupplyController() {
|
|
5012
4972
|
const {
|
|
5013
4973
|
createSupply: _createSupply,
|
|
@@ -5041,7 +5001,7 @@ function useSupplyController() {
|
|
|
5041
5001
|
limit: Joi11.number().min(1).optional().allow("", null),
|
|
5042
5002
|
search: Joi11.string().optional().allow("", null),
|
|
5043
5003
|
site: Joi11.string().hex().required(),
|
|
5044
|
-
serviceType: Joi11.string().valid(...Object.values(
|
|
5004
|
+
serviceType: Joi11.string().valid(...Object.values(AppServiceType11)).required()
|
|
5045
5005
|
});
|
|
5046
5006
|
const { error } = validation.validate(query);
|
|
5047
5007
|
if (error) {
|
|
@@ -5146,9 +5106,10 @@ function useSupplyController() {
|
|
|
5146
5106
|
import Joi12 from "joi";
|
|
5147
5107
|
import { ObjectId as ObjectId14 } from "mongodb";
|
|
5148
5108
|
import { BadRequestError as BadRequestError20, logger as logger24 } from "@7365admin1/node-server-utils";
|
|
5109
|
+
import { AppServiceType as AppServiceType12 } from "@7365admin1/core";
|
|
5149
5110
|
var stockSchema = Joi12.object({
|
|
5150
5111
|
site: Joi12.string().hex().required(),
|
|
5151
|
-
serviceType: Joi12.string().valid(...Object.values(
|
|
5112
|
+
serviceType: Joi12.string().valid(...Object.values(AppServiceType12)).required(),
|
|
5152
5113
|
supply: Joi12.string().hex().required(),
|
|
5153
5114
|
in: Joi12.number().min(0).optional(),
|
|
5154
5115
|
out: Joi12.number().min(0).optional(),
|
|
@@ -5382,6 +5343,7 @@ function useStockService() {
|
|
|
5382
5343
|
// src/controllers/hygiene-stock.controller.ts
|
|
5383
5344
|
import Joi13 from "joi";
|
|
5384
5345
|
import { BadRequestError as BadRequestError23, logger as logger26 } from "@7365admin1/node-server-utils";
|
|
5346
|
+
import { AppServiceType as AppServiceType13 } from "@7365admin1/core";
|
|
5385
5347
|
function useStockController() {
|
|
5386
5348
|
const { getStocksBySupplyId: _getStocksBySupplyId } = useStockRepository();
|
|
5387
5349
|
const { createStock: _createStock } = useStockService();
|
|
@@ -5389,7 +5351,7 @@ function useStockController() {
|
|
|
5389
5351
|
const payload = { ...req.body, ...req.params };
|
|
5390
5352
|
const validation = Joi13.object({
|
|
5391
5353
|
site: Joi13.string().hex().required(),
|
|
5392
|
-
serviceType: Joi13.string().valid(...Object.values(
|
|
5354
|
+
serviceType: Joi13.string().valid(...Object.values(AppServiceType13)).required(),
|
|
5393
5355
|
supply: Joi13.string().hex().required(),
|
|
5394
5356
|
qty: Joi13.number().min(0).required(),
|
|
5395
5357
|
remarks: Joi13.string().optional().allow("", null)
|
|
@@ -5417,7 +5379,7 @@ function useStockController() {
|
|
|
5417
5379
|
limit: Joi13.number().min(1).optional().allow("", null),
|
|
5418
5380
|
search: Joi13.string().optional().allow("", null),
|
|
5419
5381
|
site: Joi13.string().hex().required(),
|
|
5420
|
-
serviceType: Joi13.string().valid(...Object.values(
|
|
5382
|
+
serviceType: Joi13.string().valid(...Object.values(AppServiceType13)).required(),
|
|
5421
5383
|
supply: Joi13.string().hex().required()
|
|
5422
5384
|
});
|
|
5423
5385
|
const { error } = validation.validate(query);
|
|
@@ -5459,10 +5421,11 @@ function useStockController() {
|
|
|
5459
5421
|
import Joi14 from "joi";
|
|
5460
5422
|
import { ObjectId as ObjectId16 } from "mongodb";
|
|
5461
5423
|
import { BadRequestError as BadRequestError24, logger as logger27 } from "@7365admin1/node-server-utils";
|
|
5424
|
+
import { AppServiceType as AppServiceType14 } from "@7365admin1/core";
|
|
5462
5425
|
var allowedCheckOutItemStatus = ["pending", "completed"];
|
|
5463
5426
|
var checkOutItemSchema = Joi14.object({
|
|
5464
5427
|
site: Joi14.string().hex().required(),
|
|
5465
|
-
serviceType: Joi14.string().valid(...Object.values(
|
|
5428
|
+
serviceType: Joi14.string().valid(...Object.values(AppServiceType14)).required(),
|
|
5466
5429
|
supply: Joi14.string().hex().required(),
|
|
5467
5430
|
supplyName: Joi14.string().required(),
|
|
5468
5431
|
qty: Joi14.number().min(0).required(),
|
|
@@ -5867,6 +5830,7 @@ function useCheckOutItemService() {
|
|
|
5867
5830
|
// src/controllers/hygiene-checkout-item.controller.ts
|
|
5868
5831
|
import Joi15 from "joi";
|
|
5869
5832
|
import { BadRequestError as BadRequestError27, logger as logger29 } from "@7365admin1/node-server-utils";
|
|
5833
|
+
import { AppServiceType as AppServiceType15 } from "@7365admin1/core";
|
|
5870
5834
|
function useCheckOutItemController() {
|
|
5871
5835
|
const {
|
|
5872
5836
|
getCheckOutItems: _getCheckOutItems,
|
|
@@ -5889,7 +5853,7 @@ function useCheckOutItemController() {
|
|
|
5889
5853
|
};
|
|
5890
5854
|
const validation = Joi15.object({
|
|
5891
5855
|
site: Joi15.string().hex().required(),
|
|
5892
|
-
serviceType: Joi15.string().valid(...Object.values(
|
|
5856
|
+
serviceType: Joi15.string().valid(...Object.values(AppServiceType15)).required(),
|
|
5893
5857
|
supply: Joi15.string().hex().required(),
|
|
5894
5858
|
qty: Joi15.number().min(0).required(),
|
|
5895
5859
|
attachment: Joi15.array().items(Joi15.string()).optional().allow(null),
|
|
@@ -5924,7 +5888,7 @@ function useCheckOutItemController() {
|
|
|
5924
5888
|
};
|
|
5925
5889
|
const validation = Joi15.object({
|
|
5926
5890
|
site: Joi15.string().hex().required(),
|
|
5927
|
-
serviceType: Joi15.string().valid(...Object.values(
|
|
5891
|
+
serviceType: Joi15.string().valid(...Object.values(AppServiceType15)).required(),
|
|
5928
5892
|
createdBy: Joi15.string().hex().required(),
|
|
5929
5893
|
items: Joi15.array().items(
|
|
5930
5894
|
Joi15.object({
|
|
@@ -5957,7 +5921,7 @@ function useCheckOutItemController() {
|
|
|
5957
5921
|
limit: Joi15.number().min(1).optional().allow("", null),
|
|
5958
5922
|
search: Joi15.string().optional().allow("", null),
|
|
5959
5923
|
site: Joi15.string().hex().required(),
|
|
5960
|
-
serviceType: Joi15.string().valid(...Object.values(
|
|
5924
|
+
serviceType: Joi15.string().valid(...Object.values(AppServiceType15)).required()
|
|
5961
5925
|
});
|
|
5962
5926
|
const { error } = validation.validate(query);
|
|
5963
5927
|
if (error) {
|
|
@@ -6015,11 +5979,12 @@ function useCheckOutItemController() {
|
|
|
6015
5979
|
|
|
6016
5980
|
// src/models/hygiene-schedule-task.model.ts
|
|
6017
5981
|
import { BadRequestError as BadRequestError28, logger as logger30 } from "@7365admin1/node-server-utils";
|
|
5982
|
+
import { AppServiceType as AppServiceType16 } from "@7365admin1/core";
|
|
6018
5983
|
import Joi16 from "joi";
|
|
6019
5984
|
import { ObjectId as ObjectId18 } from "mongodb";
|
|
6020
5985
|
var scheduleTaskSchema = Joi16.object({
|
|
6021
5986
|
site: Joi16.string().hex().required(),
|
|
6022
|
-
serviceType: Joi16.string().valid(...Object.values(
|
|
5987
|
+
serviceType: Joi16.string().valid(...Object.values(AppServiceType16)).required(),
|
|
6023
5988
|
title: Joi16.string().required(),
|
|
6024
5989
|
time: Joi16.string().pattern(/^([0-1]\d|2[0-3]):([0-5]\d)$/).required(),
|
|
6025
5990
|
dates: Joi16.array().min(1).items(
|
|
@@ -6031,8 +5996,7 @@ var scheduleTaskSchema = Joi16.object({
|
|
|
6031
5996
|
name: Joi16.string().required(),
|
|
6032
5997
|
value: Joi16.any().required()
|
|
6033
5998
|
})
|
|
6034
|
-
).required()
|
|
6035
|
-
createdBy: Joi16.string().hex().required()
|
|
5999
|
+
).required()
|
|
6036
6000
|
});
|
|
6037
6001
|
function MScheduleTask(value) {
|
|
6038
6002
|
const { error } = scheduleTaskSchema.validate(value);
|
|
@@ -6059,13 +6023,6 @@ function MScheduleTask(value) {
|
|
|
6059
6023
|
}
|
|
6060
6024
|
});
|
|
6061
6025
|
}
|
|
6062
|
-
if (value.createdBy) {
|
|
6063
|
-
try {
|
|
6064
|
-
value.createdBy = new ObjectId18(value.createdBy);
|
|
6065
|
-
} catch (error2) {
|
|
6066
|
-
throw new BadRequestError28("Invalid createdBy ID format.");
|
|
6067
|
-
}
|
|
6068
|
-
}
|
|
6069
6026
|
return {
|
|
6070
6027
|
site: value.site,
|
|
6071
6028
|
serviceType: value.serviceType,
|
|
@@ -6075,7 +6032,6 @@ function MScheduleTask(value) {
|
|
|
6075
6032
|
description: value.description,
|
|
6076
6033
|
areas: value.areas,
|
|
6077
6034
|
status: "active",
|
|
6078
|
-
createdBy: value.createdBy,
|
|
6079
6035
|
createdAt: /* @__PURE__ */ new Date(),
|
|
6080
6036
|
updatedAt: "",
|
|
6081
6037
|
deletedAt: ""
|
|
@@ -6597,8 +6553,7 @@ function useScheduleTaskService() {
|
|
|
6597
6553
|
area: areaId,
|
|
6598
6554
|
name: area.name,
|
|
6599
6555
|
type: areaDetails.type || "common",
|
|
6600
|
-
checklist: schedTaskSets
|
|
6601
|
-
createdBy: scheduleTask.createdBy
|
|
6556
|
+
checklist: schedTaskSets
|
|
6602
6557
|
};
|
|
6603
6558
|
logger32.info(
|
|
6604
6559
|
`Area ${area.name} (${areaId}): Creating new area checklist with schedule-task sets only`
|
|
@@ -6644,6 +6599,7 @@ function useScheduleTaskService() {
|
|
|
6644
6599
|
// src/controllers/hygiene-schedule-task.controller.ts
|
|
6645
6600
|
import Joi17 from "joi";
|
|
6646
6601
|
import { BadRequestError as BadRequestError30, logger as logger33 } from "@7365admin1/node-server-utils";
|
|
6602
|
+
import { AppServiceType as AppServiceType17 } from "@7365admin1/core";
|
|
6647
6603
|
function useScheduleTaskController() {
|
|
6648
6604
|
const {
|
|
6649
6605
|
createScheduleTask: _createScheduleTask,
|
|
@@ -6653,12 +6609,7 @@ function useScheduleTaskController() {
|
|
|
6653
6609
|
deleteScheduleTask: _deleteScheduleTask
|
|
6654
6610
|
} = useScheduleTaskRepository();
|
|
6655
6611
|
async function createScheduleTask(req, res, next) {
|
|
6656
|
-
const
|
|
6657
|
-
(acc, [key, value]) => ({ ...acc, [key]: value }),
|
|
6658
|
-
{}
|
|
6659
|
-
) : {};
|
|
6660
|
-
const createdBy = cookies["user"] || "";
|
|
6661
|
-
const payload = { ...req.body, ...req.params, createdBy };
|
|
6612
|
+
const payload = { ...req.body, ...req.params };
|
|
6662
6613
|
const { error } = scheduleTaskSchema.validate(payload);
|
|
6663
6614
|
if (error) {
|
|
6664
6615
|
logger33.log({ level: "error", message: error.message });
|
|
@@ -6682,7 +6633,7 @@ function useScheduleTaskController() {
|
|
|
6682
6633
|
limit: Joi17.number().min(1).optional().allow("", null),
|
|
6683
6634
|
search: Joi17.string().optional().allow("", null),
|
|
6684
6635
|
site: Joi17.string().hex().required(),
|
|
6685
|
-
serviceType: Joi17.string().valid(...Object.values(
|
|
6636
|
+
serviceType: Joi17.string().valid(...Object.values(AppServiceType17)).required()
|
|
6686
6637
|
});
|
|
6687
6638
|
const { error } = validation.validate(query);
|
|
6688
6639
|
if (error) {
|
|
@@ -7078,7 +7029,6 @@ export {
|
|
|
7078
7029
|
MStock,
|
|
7079
7030
|
MSupply,
|
|
7080
7031
|
MUnit,
|
|
7081
|
-
ServiceType,
|
|
7082
7032
|
allowedCheckOutItemStatus,
|
|
7083
7033
|
allowedChecklistStatus,
|
|
7084
7034
|
allowedPeriods,
|