@7365admin1/core 2.25.0 → 2.27.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 +138 -51
- package/dist/index.js +500 -104
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +543 -139
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -38,6 +38,7 @@ __export(src_exports, {
|
|
|
38
38
|
BulletinStatus: () => BulletinStatus,
|
|
39
39
|
CameraType: () => CameraType,
|
|
40
40
|
DEVICE_STATUS: () => DEVICE_STATUS,
|
|
41
|
+
DOBStatus: () => DOBStatus,
|
|
41
42
|
DayOfWeek: () => DayOfWeek,
|
|
42
43
|
EAccessCardTypes: () => EAccessCardTypes,
|
|
43
44
|
EAccessCardUserTypes: () => EAccessCardUserTypes,
|
|
@@ -104,6 +105,7 @@ __export(src_exports, {
|
|
|
104
105
|
MVehicle: () => MVehicle,
|
|
105
106
|
MVehicleTransaction: () => MVehicleTransaction,
|
|
106
107
|
MVerification: () => MVerification,
|
|
108
|
+
MVerificationV2: () => MVerificationV2,
|
|
107
109
|
MVisitorTransaction: () => MVisitorTransaction,
|
|
108
110
|
MWorkOrder: () => MWorkOrder,
|
|
109
111
|
OrgNature: () => OrgNature,
|
|
@@ -112,6 +114,7 @@ __export(src_exports, {
|
|
|
112
114
|
PERSON_TYPES: () => PERSON_TYPES,
|
|
113
115
|
PMDashboardCollection: () => PMDashboardCollection,
|
|
114
116
|
Period: () => Period,
|
|
117
|
+
PersonStatus: () => PersonStatus,
|
|
115
118
|
PersonTypes: () => PersonTypes,
|
|
116
119
|
SiteCategories: () => SiteCategories,
|
|
117
120
|
SiteStatus: () => SiteStatus,
|
|
@@ -124,6 +127,7 @@ __export(src_exports, {
|
|
|
124
127
|
VehicleSort: () => VehicleSort,
|
|
125
128
|
VehicleStatus: () => VehicleStatus,
|
|
126
129
|
VehicleType: () => VehicleType,
|
|
130
|
+
VerificationType: () => VerificationType,
|
|
127
131
|
VisitorSort: () => VisitorSort,
|
|
128
132
|
VisitorStatus: () => VisitorStatus,
|
|
129
133
|
addressSchema: () => addressSchema,
|
|
@@ -248,6 +252,7 @@ __export(src_exports, {
|
|
|
248
252
|
useAttendanceSettingsRepository: () => useAttendanceSettingsRepository,
|
|
249
253
|
useAttendanceSettingsService: () => useAttendanceSettingsService,
|
|
250
254
|
useAuthController: () => useAuthController,
|
|
255
|
+
useAuthControllerV2: () => useAuthControllerV2,
|
|
251
256
|
useAuthService: () => useAuthService,
|
|
252
257
|
useBuildingController: () => useBuildingController,
|
|
253
258
|
useBuildingRepo: () => useBuildingRepo,
|
|
@@ -401,7 +406,9 @@ __export(src_exports, {
|
|
|
401
406
|
useVehicleService: () => useVehicleService,
|
|
402
407
|
useVerificationController: () => useVerificationController,
|
|
403
408
|
useVerificationRepo: () => useVerificationRepo,
|
|
409
|
+
useVerificationRepoV2: () => useVerificationRepoV2,
|
|
404
410
|
useVerificationService: () => useVerificationService,
|
|
411
|
+
useVerificationServiceV2: () => useVerificationServiceV2,
|
|
405
412
|
useVisitorTransactionController: () => useVisitorTransactionController,
|
|
406
413
|
useVisitorTransactionRepo: () => useVisitorTransactionRepo,
|
|
407
414
|
useVisitorTransactionService: () => useVisitorTransactionService,
|
|
@@ -4518,7 +4525,9 @@ var siteSchema = import_joi9.default.object({
|
|
|
4518
4525
|
category: import_joi9.default.string().valid(...Object.values(SiteCategories)).default("commercial" /* COMMERCIAL */),
|
|
4519
4526
|
deliveryCompanyList: import_joi9.default.array().items(import_joi9.default.string()).optional().allow(null),
|
|
4520
4527
|
isOpenGate: import_joi9.default.boolean().optional().default(false),
|
|
4521
|
-
dahuaTimeExpiration: import_joi9.default.number().optional().allow(null)
|
|
4528
|
+
dahuaTimeExpiration: import_joi9.default.number().optional().allow(null),
|
|
4529
|
+
siteDocs: import_joi9.default.array().items(import_joi9.default.string().hex().length(24).allow(null, "")),
|
|
4530
|
+
unitDocs: import_joi9.default.array().items(import_joi9.default.string().hex().length(24).allow(null, ""))
|
|
4522
4531
|
});
|
|
4523
4532
|
var updateSiteSchema = import_joi9.default.object({
|
|
4524
4533
|
_id: import_joi9.default.string().hex().length(24).required(),
|
|
@@ -4526,7 +4535,9 @@ var updateSiteSchema = import_joi9.default.object({
|
|
|
4526
4535
|
metadata: metadataSchema3.optional(),
|
|
4527
4536
|
deliveryCompanyList: import_joi9.default.array().items(import_joi9.default.string().trim()).optional().allow(null),
|
|
4528
4537
|
isOpenGate: import_joi9.default.boolean().optional().allow(null),
|
|
4529
|
-
dahuaTimeExpiration: import_joi9.default.number().optional().allow(null)
|
|
4538
|
+
dahuaTimeExpiration: import_joi9.default.number().optional().allow(null),
|
|
4539
|
+
siteDocs: import_joi9.default.array().items(import_joi9.default.string().hex().length(24).allow(null, "")),
|
|
4540
|
+
unitDocs: import_joi9.default.array().items(import_joi9.default.string().hex().length(24).allow(null, ""))
|
|
4530
4541
|
});
|
|
4531
4542
|
function MSite(value) {
|
|
4532
4543
|
const { error } = siteSchema.validate(value);
|
|
@@ -4553,6 +4564,8 @@ function MSite(value) {
|
|
|
4553
4564
|
deliveryCompanyList: value.deliveryCompanyList ?? [],
|
|
4554
4565
|
isOpenGate: value.isOpenGate,
|
|
4555
4566
|
dahuaTimeExpiration: value.dahuaTimeExpiration,
|
|
4567
|
+
siteDocs: value.siteDocs ?? [],
|
|
4568
|
+
unitDocs: value.unitDocs ?? [],
|
|
4556
4569
|
updatedAt: value.updatedAt ?? "",
|
|
4557
4570
|
deletedAt: value.deletedAt ?? ""
|
|
4558
4571
|
};
|
|
@@ -8743,7 +8756,7 @@ var import_node_server_utils41 = require("@7365admin1/node-server-utils");
|
|
|
8743
8756
|
var import_zod = require("zod");
|
|
8744
8757
|
var import_mongodb25 = require("mongodb");
|
|
8745
8758
|
var import_node_server_utils40 = require("@7365admin1/node-server-utils");
|
|
8746
|
-
function
|
|
8759
|
+
function toObjectId3(value) {
|
|
8747
8760
|
if (typeof value === "string") {
|
|
8748
8761
|
if (!/^[a-fA-F0-9]{24}$/.test(value)) {
|
|
8749
8762
|
throw new import_node_server_utils40.BadRequestError(`Invalid ObjectId format: ${value}`);
|
|
@@ -8795,7 +8808,7 @@ var TInvoice = import_zod.z.object({
|
|
|
8795
8808
|
message: "Invalid ObjectId: Must be a 24-character hex string."
|
|
8796
8809
|
}),
|
|
8797
8810
|
import_zod.z.instanceof(import_mongodb25.ObjectId, { message: "Invalid ObjectId instance." })
|
|
8798
|
-
]).optional().transform((val) => val ?
|
|
8811
|
+
]).optional().transform((val) => val ? toObjectId3(val) : void 0),
|
|
8799
8812
|
invoiceNumber: import_zod.z.string({ required_error: "Invoice number is required." }),
|
|
8800
8813
|
type: TInvoiceType.default("other"),
|
|
8801
8814
|
amount: import_zod.z.number().min(0, { message: "Invoice amount must be at least 0." }),
|
|
@@ -12953,17 +12966,22 @@ var import_mongodb38 = require("mongodb");
|
|
|
12953
12966
|
var import_node_server_utils66 = require("@7365admin1/node-server-utils");
|
|
12954
12967
|
var import_joi35 = __toESM(require("joi"));
|
|
12955
12968
|
var import_mongodb37 = require("mongodb");
|
|
12956
|
-
var PersonTypes = /* @__PURE__ */ ((
|
|
12957
|
-
|
|
12958
|
-
|
|
12959
|
-
|
|
12960
|
-
|
|
12961
|
-
|
|
12962
|
-
|
|
12963
|
-
|
|
12964
|
-
|
|
12965
|
-
return
|
|
12969
|
+
var PersonTypes = /* @__PURE__ */ ((PersonTypes3) => {
|
|
12970
|
+
PersonTypes3["WALK_IN"] = "walk-in";
|
|
12971
|
+
PersonTypes3["DROP_OFF"] = "drop-off";
|
|
12972
|
+
PersonTypes3["CONTRACTOR"] = "contractor";
|
|
12973
|
+
PersonTypes3["DELIVERY"] = "delivery";
|
|
12974
|
+
PersonTypes3["PICK_UP"] = "pick-up";
|
|
12975
|
+
PersonTypes3["GUEST"] = "guest";
|
|
12976
|
+
PersonTypes3["TENANT"] = "tenant";
|
|
12977
|
+
PersonTypes3["RESIDENT"] = "resident";
|
|
12978
|
+
return PersonTypes3;
|
|
12966
12979
|
})(PersonTypes || {});
|
|
12980
|
+
var PersonStatus = /* @__PURE__ */ ((PersonStatus2) => {
|
|
12981
|
+
PersonStatus2["ACTIVE"] = "active";
|
|
12982
|
+
PersonStatus2["DELETED"] = "deleted";
|
|
12983
|
+
return PersonStatus2;
|
|
12984
|
+
})(PersonStatus || {});
|
|
12967
12985
|
var PERSON_TYPES = [
|
|
12968
12986
|
"walk-in",
|
|
12969
12987
|
"drop-off",
|
|
@@ -13644,6 +13662,7 @@ var VehicleSort = /* @__PURE__ */ ((VehicleSort2) => {
|
|
|
13644
13662
|
VehicleSort2["NAME"] = "name";
|
|
13645
13663
|
VehicleSort2["START"] = "start";
|
|
13646
13664
|
VehicleSort2["END"] = "end";
|
|
13665
|
+
VehicleSort2["UPDATED_AT"] = "updatedAt";
|
|
13647
13666
|
return VehicleSort2;
|
|
13648
13667
|
})(VehicleSort || {});
|
|
13649
13668
|
var OrgNature = /* @__PURE__ */ ((OrgNature2) => {
|
|
@@ -13682,7 +13701,8 @@ var vehicleSchema = import_joi37.default.object({
|
|
|
13682
13701
|
start: import_joi37.default.date().optional().allow("", null),
|
|
13683
13702
|
end: import_joi37.default.date().optional().allow("", null),
|
|
13684
13703
|
unitName: import_joi37.default.string().optional().allow("", null),
|
|
13685
|
-
status: import_joi37.default.string().optional().valid(...Object.values(VehicleStatus)).allow("")
|
|
13704
|
+
status: import_joi37.default.string().optional().valid(...Object.values(VehicleStatus)).allow(""),
|
|
13705
|
+
peopleId: import_joi37.default.string().hex().length(24).optional().allow(null, "")
|
|
13686
13706
|
});
|
|
13687
13707
|
function MVehicle(value) {
|
|
13688
13708
|
const { error } = vehicleSchema.validate(value);
|
|
@@ -13711,6 +13731,13 @@ function MVehicle(value) {
|
|
|
13711
13731
|
throw new import_node_server_utils68.BadRequestError("Invalid building unit ID format.");
|
|
13712
13732
|
}
|
|
13713
13733
|
}
|
|
13734
|
+
if (value.peopleId) {
|
|
13735
|
+
try {
|
|
13736
|
+
value.peopleId = new import_mongodb40.ObjectId(value.peopleId);
|
|
13737
|
+
} catch (error2) {
|
|
13738
|
+
throw new import_node_server_utils68.BadRequestError("Invalid building unit ID format.");
|
|
13739
|
+
}
|
|
13740
|
+
}
|
|
13714
13741
|
const createdAtDate = value.createdAt ? new Date(value.createdAt) : /* @__PURE__ */ new Date();
|
|
13715
13742
|
const expiredDate = new Date(createdAtDate);
|
|
13716
13743
|
expiredDate.setFullYear(expiredDate.getFullYear() + 10);
|
|
@@ -13735,8 +13762,9 @@ function MVehicle(value) {
|
|
|
13735
13762
|
end: value.end ?? expiredAt,
|
|
13736
13763
|
status: value.status ?? "active" /* ACTIVE */,
|
|
13737
13764
|
unitName: value.unitName ?? "",
|
|
13765
|
+
peopleId: value.peopleId ?? "",
|
|
13738
13766
|
createdAt,
|
|
13739
|
-
updatedAt: value.updatedAt ??
|
|
13767
|
+
updatedAt: value.updatedAt ?? createdAt,
|
|
13740
13768
|
deletedAt: value.deletedAt ?? ""
|
|
13741
13769
|
};
|
|
13742
13770
|
}
|
|
@@ -13875,7 +13903,6 @@ function useVehicleRepo() {
|
|
|
13875
13903
|
...category && { category }
|
|
13876
13904
|
};
|
|
13877
13905
|
let query = { ...baseQuery };
|
|
13878
|
-
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
13879
13906
|
const cacheOptions = {
|
|
13880
13907
|
...status && { status },
|
|
13881
13908
|
...type && { type },
|
|
@@ -13921,7 +13948,9 @@ function useVehicleRepo() {
|
|
|
13921
13948
|
unitName: "$unit.name",
|
|
13922
13949
|
recNo: 1,
|
|
13923
13950
|
nric: 1,
|
|
13924
|
-
plateNumber: 1
|
|
13951
|
+
plateNumber: 1,
|
|
13952
|
+
createdAt: 1,
|
|
13953
|
+
updatedAt: 1
|
|
13925
13954
|
}
|
|
13926
13955
|
},
|
|
13927
13956
|
{
|
|
@@ -13949,6 +13978,8 @@ function useVehicleRepo() {
|
|
|
13949
13978
|
unit: { $first: "$unit" },
|
|
13950
13979
|
unitName: { $first: "$unitName" },
|
|
13951
13980
|
nric: { $first: "$nric" },
|
|
13981
|
+
createdAt: { $min: "$createdAt" },
|
|
13982
|
+
updatedAt: { $max: "$updatedAt" },
|
|
13952
13983
|
plates: {
|
|
13953
13984
|
$addToSet: {
|
|
13954
13985
|
_id: "$_id",
|
|
@@ -13984,10 +14015,19 @@ function useVehicleRepo() {
|
|
|
13984
14015
|
]
|
|
13985
14016
|
}
|
|
13986
14017
|
}
|
|
14018
|
+
},
|
|
14019
|
+
createdAt: 1,
|
|
14020
|
+
updatedAt: 1
|
|
14021
|
+
}
|
|
14022
|
+
},
|
|
14023
|
+
{
|
|
14024
|
+
$addFields: {
|
|
14025
|
+
sortDate: {
|
|
14026
|
+
$ifNull: ["$updatedAt", "$createdAt"]
|
|
13987
14027
|
}
|
|
13988
14028
|
}
|
|
13989
14029
|
},
|
|
13990
|
-
{ $sort:
|
|
14030
|
+
{ $sort: { sortDate: -1 } },
|
|
13991
14031
|
{ $skip: page * limit },
|
|
13992
14032
|
{ $limit: limit }
|
|
13993
14033
|
];
|
|
@@ -14886,7 +14926,7 @@ function usePersonRepo() {
|
|
|
14886
14926
|
}
|
|
14887
14927
|
async function getPeopleByUnit({
|
|
14888
14928
|
status = "active",
|
|
14889
|
-
type,
|
|
14929
|
+
type = [],
|
|
14890
14930
|
unit
|
|
14891
14931
|
}, session) {
|
|
14892
14932
|
const cacheKey = (0, import_node_server_utils70.makeCacheKey)(site_people_namespace_collection, {
|
|
@@ -14895,13 +14935,20 @@ function usePersonRepo() {
|
|
|
14895
14935
|
type,
|
|
14896
14936
|
key: "get-residents-by-unit"
|
|
14897
14937
|
});
|
|
14938
|
+
const cacheData = await getCache(cacheKey);
|
|
14939
|
+
if (cacheData) {
|
|
14940
|
+
import_node_server_utils70.logger.info(`Cache hit for key: ${cacheKey}`);
|
|
14941
|
+
return cacheData;
|
|
14942
|
+
}
|
|
14898
14943
|
try {
|
|
14899
|
-
const
|
|
14900
|
-
|
|
14901
|
-
|
|
14902
|
-
|
|
14903
|
-
|
|
14904
|
-
|
|
14944
|
+
const query = {
|
|
14945
|
+
unit,
|
|
14946
|
+
status,
|
|
14947
|
+
...Array.isArray(type) && type.length > 0 && {
|
|
14948
|
+
type: { $in: type }
|
|
14949
|
+
}
|
|
14950
|
+
};
|
|
14951
|
+
const data = await collection.find(query).sort({ _id: -1 }).toArray();
|
|
14905
14952
|
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
14906
14953
|
import_node_server_utils70.logger.info(`Cache set for key: ${cacheKey}`);
|
|
14907
14954
|
}).catch((err) => {
|
|
@@ -15043,13 +15090,14 @@ function usePersonRepo() {
|
|
|
15043
15090
|
throw new import_node_server_utils70.InternalServerError("Failed to retrieve person by NRIC.");
|
|
15044
15091
|
}
|
|
15045
15092
|
}
|
|
15046
|
-
async function
|
|
15093
|
+
async function pushVehicleById(id, plate, session) {
|
|
15047
15094
|
const { plateNumber, recNo } = plate;
|
|
15048
15095
|
const updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
15096
|
+
const _id = (0, import_node_server_utils70.toObjectId)(id);
|
|
15049
15097
|
try {
|
|
15050
15098
|
const updateExisting = await collection.updateOne(
|
|
15051
15099
|
{
|
|
15052
|
-
|
|
15100
|
+
_id,
|
|
15053
15101
|
"plates.plateNumber": plateNumber
|
|
15054
15102
|
},
|
|
15055
15103
|
{
|
|
@@ -15062,7 +15110,7 @@ function usePersonRepo() {
|
|
|
15062
15110
|
);
|
|
15063
15111
|
if (updateExisting.matchedCount === 0) {
|
|
15064
15112
|
await collection.updateOne(
|
|
15065
|
-
{
|
|
15113
|
+
{ _id },
|
|
15066
15114
|
{
|
|
15067
15115
|
$push: {
|
|
15068
15116
|
plates: {
|
|
@@ -15154,7 +15202,7 @@ function usePersonRepo() {
|
|
|
15154
15202
|
getCompany,
|
|
15155
15203
|
getPeopleByPlateNumber,
|
|
15156
15204
|
getPeopleByNRIC,
|
|
15157
|
-
|
|
15205
|
+
pushVehicleById,
|
|
15158
15206
|
pullVehicleByRecNo,
|
|
15159
15207
|
getByUserId
|
|
15160
15208
|
};
|
|
@@ -15185,7 +15233,7 @@ function useVehicleService() {
|
|
|
15185
15233
|
} = useDahuaService();
|
|
15186
15234
|
const { getAllCameraWithPassword: _getAllSiteCameras } = useSiteCameraRepo();
|
|
15187
15235
|
const { getById: _getById } = useOrgRepo();
|
|
15188
|
-
const {
|
|
15236
|
+
const { pushVehicleById: _pushVehicleById } = usePersonRepo();
|
|
15189
15237
|
const { pullVehicleByRecNo: _pullVehicleByRecNo } = usePersonRepo();
|
|
15190
15238
|
async function add(value) {
|
|
15191
15239
|
const session = import_node_server_utils71.useAtlas.getClient()?.startSession();
|
|
@@ -15292,9 +15340,9 @@ function useVehicleService() {
|
|
|
15292
15340
|
}
|
|
15293
15341
|
const responseData = dahuaResponse?.data?.toString("utf-8") ?? "";
|
|
15294
15342
|
vehicleValue.recNo = responseData.split("=")[1]?.trim();
|
|
15295
|
-
if (value.
|
|
15296
|
-
await
|
|
15297
|
-
value.
|
|
15343
|
+
if (value.peopleId && vehicleValue.recNo) {
|
|
15344
|
+
await _pushVehicleById(
|
|
15345
|
+
value.peopleId,
|
|
15298
15346
|
{
|
|
15299
15347
|
plateNumber,
|
|
15300
15348
|
recNo: vehicleValue.recNo
|
|
@@ -15454,9 +15502,9 @@ function useVehicleService() {
|
|
|
15454
15502
|
value.recNo = responseData.split("=")[1]?.trim();
|
|
15455
15503
|
}
|
|
15456
15504
|
value.status = "active" /* ACTIVE */;
|
|
15457
|
-
if (vehicle.
|
|
15458
|
-
await
|
|
15459
|
-
vehicle.
|
|
15505
|
+
if (vehicle.peopleId && value.recNo) {
|
|
15506
|
+
await _pushVehicleById(
|
|
15507
|
+
vehicle.peopleId,
|
|
15460
15508
|
{
|
|
15461
15509
|
plateNumber: _plateNumber,
|
|
15462
15510
|
recNo: value.recNo
|
|
@@ -15571,9 +15619,9 @@ function useVehicleService() {
|
|
|
15571
15619
|
value.recNo = responseData.split("=")[1]?.trim();
|
|
15572
15620
|
}
|
|
15573
15621
|
value.status = "active" /* ACTIVE */;
|
|
15574
|
-
if (vehicle.
|
|
15575
|
-
await
|
|
15576
|
-
vehicle.
|
|
15622
|
+
if (vehicle.peopleId && value.recNo) {
|
|
15623
|
+
await _pushVehicleById(
|
|
15624
|
+
vehicle.peopleId,
|
|
15577
15625
|
{
|
|
15578
15626
|
plateNumber: _plateNumber,
|
|
15579
15627
|
recNo: value.recNo
|
|
@@ -15610,7 +15658,7 @@ function useVehicleService() {
|
|
|
15610
15658
|
const _start = vehicle.start;
|
|
15611
15659
|
const _end = vehicle.end;
|
|
15612
15660
|
const _recNo = plate.recNo;
|
|
15613
|
-
const _type = plate.type;
|
|
15661
|
+
const _type = value.type ? value.type : plate.type;
|
|
15614
15662
|
const { name, plateNumber, start, end, recNo, type, unit, site, ...rest } = value;
|
|
15615
15663
|
const startDahua = value.start ? formatDahuaDate(new Date(value.start)) : formatDahuaDate(new Date(_start));
|
|
15616
15664
|
const endDahua = value.end ? formatDahuaDate(new Date(value.end)) : formatDahuaDate(new Date(_end));
|
|
@@ -15638,20 +15686,60 @@ function useVehicleService() {
|
|
|
15638
15686
|
}
|
|
15639
15687
|
for (const camera of siteCameras) {
|
|
15640
15688
|
const { host, username, password } = camera;
|
|
15641
|
-
|
|
15642
|
-
|
|
15643
|
-
|
|
15644
|
-
|
|
15645
|
-
|
|
15646
|
-
|
|
15647
|
-
|
|
15648
|
-
|
|
15649
|
-
|
|
15650
|
-
|
|
15651
|
-
|
|
15652
|
-
|
|
15653
|
-
|
|
15654
|
-
|
|
15689
|
+
if (value.type) {
|
|
15690
|
+
const removePlateNumber = {
|
|
15691
|
+
host,
|
|
15692
|
+
username,
|
|
15693
|
+
password,
|
|
15694
|
+
mode: plate.type === "blocklist" /* BLOCKLIST */ ? "TrafficBlackList" /* TRAFFIC_BLACKLIST */ : "TrafficRedList" /* TRAFFIC_REDLIST */,
|
|
15695
|
+
//whitelist or blocklist
|
|
15696
|
+
recno: _recNo
|
|
15697
|
+
};
|
|
15698
|
+
const responseForDeletion = await _removePlateNumber(
|
|
15699
|
+
removePlateNumber
|
|
15700
|
+
);
|
|
15701
|
+
if (responseForDeletion?.statusCode !== 200) {
|
|
15702
|
+
throw new import_node_server_utils71.BadRequestError(
|
|
15703
|
+
"Failed to delete plate number to ANPR"
|
|
15704
|
+
);
|
|
15705
|
+
}
|
|
15706
|
+
const dahuaPayload = {
|
|
15707
|
+
host,
|
|
15708
|
+
username,
|
|
15709
|
+
password,
|
|
15710
|
+
plateNumber: _plateNumber,
|
|
15711
|
+
mode: value.type === "blocklist" /* BLOCKLIST */ ? "TrafficBlackList" /* TRAFFIC_BLACKLIST */ : "TrafficRedList" /* TRAFFIC_REDLIST */,
|
|
15712
|
+
//whitelist or blocklist
|
|
15713
|
+
owner: _name,
|
|
15714
|
+
...startDahua ? { start: startDahua } : {},
|
|
15715
|
+
...endDahua ? { end: endDahua } : {}
|
|
15716
|
+
};
|
|
15717
|
+
const dahuaResponse = await _addPlateNumber(dahuaPayload);
|
|
15718
|
+
if (dahuaResponse?.statusCode !== 200) {
|
|
15719
|
+
throw new import_node_server_utils71.BadRequestError(
|
|
15720
|
+
"Failed to update plate number to ANPR"
|
|
15721
|
+
);
|
|
15722
|
+
}
|
|
15723
|
+
const responseData = dahuaResponse?.data?.toString("utf-8") ?? "";
|
|
15724
|
+
value.recNo = responseData.split("=")[1]?.trim();
|
|
15725
|
+
} else {
|
|
15726
|
+
const dahuaPayload = {
|
|
15727
|
+
host,
|
|
15728
|
+
username,
|
|
15729
|
+
password,
|
|
15730
|
+
plateNumber: plateNumber ? plateNumber : _plateNumber,
|
|
15731
|
+
recno: _recNo,
|
|
15732
|
+
mode: _type === "blocklist" /* BLOCKLIST */ ? "TrafficBlackList" /* TRAFFIC_BLACKLIST */ : "TrafficRedList" /* TRAFFIC_REDLIST */,
|
|
15733
|
+
start: startDahua,
|
|
15734
|
+
end: endDahua,
|
|
15735
|
+
owner: name ? name : _name
|
|
15736
|
+
};
|
|
15737
|
+
const dahuaResponse = await _updatePlateNumber(dahuaPayload);
|
|
15738
|
+
if (dahuaResponse?.statusCode !== 200) {
|
|
15739
|
+
throw new import_node_server_utils71.BadRequestError(
|
|
15740
|
+
"Failed to update plate number to ANPR"
|
|
15741
|
+
);
|
|
15742
|
+
}
|
|
15655
15743
|
}
|
|
15656
15744
|
}
|
|
15657
15745
|
}
|
|
@@ -15663,7 +15751,9 @@ function useVehicleService() {
|
|
|
15663
15751
|
...end && { end },
|
|
15664
15752
|
...unit && {
|
|
15665
15753
|
unit: typeof unit === "string" ? new import_mongodb43.ObjectId(unit) : unit
|
|
15666
|
-
}
|
|
15754
|
+
},
|
|
15755
|
+
...value.recNo && { recNo: value.recNo },
|
|
15756
|
+
...type && { type: value.type }
|
|
15667
15757
|
};
|
|
15668
15758
|
await _updateVehicleById(_id, formattedValue, session);
|
|
15669
15759
|
await session.commitTransaction();
|
|
@@ -18321,7 +18411,7 @@ function useVehicleController() {
|
|
|
18321
18411
|
search: import_joi46.default.string().optional().allow("", null),
|
|
18322
18412
|
page: import_joi46.default.number().integer().min(1).optional().default(1),
|
|
18323
18413
|
limit: import_joi46.default.number().integer().min(1).max(100).optional().default(10),
|
|
18324
|
-
sort: import_joi46.default.string().optional().valid(...Object.values(VehicleSort)),
|
|
18414
|
+
sort: import_joi46.default.string().optional().valid(...Object.values(VehicleSort)).default("updatedAt" /* UPDATED_AT */),
|
|
18325
18415
|
order: import_joi46.default.string().optional().valid(...Object.values(SortOrder)),
|
|
18326
18416
|
type: import_joi46.default.string().optional().valid(...Object.values(VehicleType)).allow(null, ""),
|
|
18327
18417
|
category: import_joi46.default.string().optional().valid(...Object.values(VehicleCategory)).allow(null, ""),
|
|
@@ -18337,15 +18427,20 @@ function useVehicleController() {
|
|
|
18337
18427
|
return;
|
|
18338
18428
|
}
|
|
18339
18429
|
const { search, page, limit, type, category, status, sort, order } = value;
|
|
18340
|
-
|
|
18341
|
-
|
|
18342
|
-
|
|
18430
|
+
let sortObj;
|
|
18431
|
+
if (sort === "updatedAt" /* UPDATED_AT */) {
|
|
18432
|
+
sortObj = order === "asc" /* ASC */ ? { updatedAt: 1, createdAt: 1, _id: 1 } : { updatedAt: -1, createdAt: -1, _id: -1 };
|
|
18433
|
+
} else {
|
|
18434
|
+
sortObj = {
|
|
18435
|
+
[sort]: order === "asc" /* ASC */ ? 1 : -1
|
|
18436
|
+
};
|
|
18437
|
+
}
|
|
18343
18438
|
try {
|
|
18344
18439
|
const data = await _getVehicles({
|
|
18345
18440
|
search,
|
|
18346
18441
|
page,
|
|
18347
18442
|
limit,
|
|
18348
|
-
sort: sortObj,
|
|
18443
|
+
// sort: sortObj,
|
|
18349
18444
|
type,
|
|
18350
18445
|
category,
|
|
18351
18446
|
status
|
|
@@ -19367,8 +19462,24 @@ function useCustomerSiteController() {
|
|
|
19367
19462
|
var import_node_server_utils91 = require("@7365admin1/node-server-utils");
|
|
19368
19463
|
var import_joi51 = __toESM(require("joi"));
|
|
19369
19464
|
var import_mongodb50 = require("mongodb");
|
|
19465
|
+
|
|
19466
|
+
// src/models/base.model.ts
|
|
19467
|
+
var AppServiceType = /* @__PURE__ */ ((AppServiceType2) => {
|
|
19468
|
+
AppServiceType2["REAL_ESTATE_DEVELOPER"] = "real_estate_developer";
|
|
19469
|
+
AppServiceType2["PROPERTY_MANAGEMENT_AGENCY"] = "property_management_agency";
|
|
19470
|
+
AppServiceType2["SECURITY_AGENCY"] = "security_agency";
|
|
19471
|
+
AppServiceType2["CLEANING_SERVICES"] = "cleaning_services";
|
|
19472
|
+
AppServiceType2["MECHANICAL_ELECTRICAL_SERVICES"] = "mechanical_electrical_services";
|
|
19473
|
+
AppServiceType2["LANDSCAPING_SERVICES"] = "landscaping_services";
|
|
19474
|
+
AppServiceType2["PEST_CONTROL_SERVICES"] = "pest_control_services";
|
|
19475
|
+
AppServiceType2["POOL_MAINTENANCE_SERVICES"] = "pool_maintenance_services";
|
|
19476
|
+
return AppServiceType2;
|
|
19477
|
+
})(AppServiceType || {});
|
|
19478
|
+
|
|
19479
|
+
// src/models/attendance-settings.model.ts
|
|
19370
19480
|
var attendanceSettingsSchema = import_joi51.default.object({
|
|
19371
19481
|
site: import_joi51.default.string().hex().required(),
|
|
19482
|
+
serviceType: import_joi51.default.string().valid(...Object.values(AppServiceType)).required(),
|
|
19372
19483
|
isLocationEnabled: import_joi51.default.boolean().required(),
|
|
19373
19484
|
location: import_joi51.default.when("isLocationEnabled", {
|
|
19374
19485
|
is: true,
|
|
@@ -19411,6 +19522,7 @@ function MAttendanceSettings(value) {
|
|
|
19411
19522
|
}
|
|
19412
19523
|
return {
|
|
19413
19524
|
site: value.site,
|
|
19525
|
+
serviceType: value.serviceType,
|
|
19414
19526
|
isLocationEnabled: value.isLocationEnabled,
|
|
19415
19527
|
location: value.isLocationEnabled && value.location ? value.location : void 0,
|
|
19416
19528
|
isGeofencingEnabled: value.isLocationEnabled ? value.isGeofencingEnabled ?? false : void 0,
|
|
@@ -19435,7 +19547,10 @@ function useAttendanceSettingsRepository() {
|
|
|
19435
19547
|
const { delNamespace, setCache, getCache } = (0, import_node_server_utils92.useCache)(namespace_collection);
|
|
19436
19548
|
async function createIndex() {
|
|
19437
19549
|
try {
|
|
19438
|
-
await collection.createIndexes([
|
|
19550
|
+
await collection.createIndexes([
|
|
19551
|
+
{ key: { site: 1 } },
|
|
19552
|
+
{ key: { serviceType: 1 } }
|
|
19553
|
+
]);
|
|
19439
19554
|
} catch (error) {
|
|
19440
19555
|
throw new import_node_server_utils92.InternalServerError(
|
|
19441
19556
|
"Failed to create index on attendance settings."
|
|
@@ -19459,15 +19574,16 @@ function useAttendanceSettingsRepository() {
|
|
|
19459
19574
|
throw error;
|
|
19460
19575
|
}
|
|
19461
19576
|
}
|
|
19462
|
-
async function getAttendanceSettingsBySite(site, session) {
|
|
19577
|
+
async function getAttendanceSettingsBySite(site, serviceType, session) {
|
|
19463
19578
|
try {
|
|
19464
19579
|
site = new import_mongodb51.ObjectId(site);
|
|
19465
19580
|
} catch (error) {
|
|
19466
19581
|
throw new import_node_server_utils92.BadRequestError("Invalid attendance settings site ID format.");
|
|
19467
19582
|
}
|
|
19468
|
-
const query = { site };
|
|
19583
|
+
const query = { site, serviceType };
|
|
19469
19584
|
const cacheKey = (0, import_node_server_utils92.makeCacheKey)(namespace_collection, {
|
|
19470
|
-
site: site.toString()
|
|
19585
|
+
site: site.toString(),
|
|
19586
|
+
serviceType
|
|
19471
19587
|
});
|
|
19472
19588
|
if (!session) {
|
|
19473
19589
|
const cachedData = await getCache(cacheKey);
|
|
@@ -19539,8 +19655,8 @@ function useAttendanceSettingsRepository() {
|
|
|
19539
19655
|
return {
|
|
19540
19656
|
createIndex,
|
|
19541
19657
|
createAttendanceSettings,
|
|
19542
|
-
|
|
19543
|
-
|
|
19658
|
+
getAttendanceSettingsBySite,
|
|
19659
|
+
updateAttendanceSettings
|
|
19544
19660
|
};
|
|
19545
19661
|
}
|
|
19546
19662
|
|
|
@@ -19551,9 +19667,9 @@ function useAttendanceSettingsService() {
|
|
|
19551
19667
|
createAttendanceSettings,
|
|
19552
19668
|
getAttendanceSettingsBySite: _getAttendanceSettingsBySite
|
|
19553
19669
|
} = useAttendanceSettingsRepository();
|
|
19554
|
-
async function getAttendanceSettingsBySite(site) {
|
|
19670
|
+
async function getAttendanceSettingsBySite(site, serviceType) {
|
|
19555
19671
|
try {
|
|
19556
|
-
let settings = await _getAttendanceSettingsBySite(site);
|
|
19672
|
+
let settings = await _getAttendanceSettingsBySite(site, serviceType);
|
|
19557
19673
|
if (!settings) {
|
|
19558
19674
|
import_node_server_utils93.logger.info(
|
|
19559
19675
|
`No attendance settings found for site ${site}, creating default settings`
|
|
@@ -19564,12 +19680,13 @@ function useAttendanceSettingsService() {
|
|
|
19564
19680
|
await createAttendanceSettings(
|
|
19565
19681
|
{
|
|
19566
19682
|
site,
|
|
19683
|
+
serviceType,
|
|
19567
19684
|
isLocationEnabled: false
|
|
19568
19685
|
},
|
|
19569
19686
|
session
|
|
19570
19687
|
);
|
|
19571
19688
|
await session?.commitTransaction();
|
|
19572
|
-
settings = await _getAttendanceSettingsBySite(site);
|
|
19689
|
+
settings = await _getAttendanceSettingsBySite(site, serviceType);
|
|
19573
19690
|
} catch (error) {
|
|
19574
19691
|
await session?.abortTransaction();
|
|
19575
19692
|
throw error;
|
|
@@ -19593,16 +19710,21 @@ function useAttendanceSettingsController() {
|
|
|
19593
19710
|
const { getAttendanceSettingsBySite: _getAttendanceSettingsBySite } = useAttendanceSettingsService();
|
|
19594
19711
|
const { updateAttendanceSettings: _updateAttendanceSettings } = useAttendanceSettingsRepository();
|
|
19595
19712
|
async function getAttendanceSettingsBySite(req, res, next) {
|
|
19596
|
-
const
|
|
19597
|
-
const
|
|
19598
|
-
|
|
19713
|
+
const query = { ...req.query, ...req.params };
|
|
19714
|
+
const validation = import_joi52.default.object({
|
|
19715
|
+
site: import_joi52.default.string().hex().required(),
|
|
19716
|
+
serviceType: import_joi52.default.string().valid(...Object.values(AppServiceType)).required()
|
|
19717
|
+
});
|
|
19718
|
+
const { error } = validation.validate(query);
|
|
19599
19719
|
if (error) {
|
|
19600
19720
|
import_node_server_utils94.logger.log({ level: "error", message: error.message });
|
|
19601
19721
|
next(new import_node_server_utils94.BadRequestError(error.message));
|
|
19602
19722
|
return;
|
|
19603
19723
|
}
|
|
19724
|
+
const site = req.params.site ?? "";
|
|
19725
|
+
const serviceType = req.query.serviceType ?? "";
|
|
19604
19726
|
try {
|
|
19605
|
-
const data = await _getAttendanceSettingsBySite(site);
|
|
19727
|
+
const data = await _getAttendanceSettingsBySite(site, serviceType);
|
|
19606
19728
|
res.json(data);
|
|
19607
19729
|
return;
|
|
19608
19730
|
} catch (error2) {
|
|
@@ -19641,6 +19763,7 @@ var import_joi53 = __toESM(require("joi"));
|
|
|
19641
19763
|
var import_mongodb52 = require("mongodb");
|
|
19642
19764
|
var attendanceSchema = import_joi53.default.object({
|
|
19643
19765
|
site: import_joi53.default.string().hex().required(),
|
|
19766
|
+
serviceType: import_joi53.default.string().valid(...Object.values(AppServiceType)).required(),
|
|
19644
19767
|
checkIn: import_joi53.default.object({
|
|
19645
19768
|
timestamp: import_joi53.default.date().required(),
|
|
19646
19769
|
location: import_joi53.default.object({
|
|
@@ -19673,6 +19796,7 @@ function MAttendance(value) {
|
|
|
19673
19796
|
}
|
|
19674
19797
|
return {
|
|
19675
19798
|
site: value.site,
|
|
19799
|
+
serviceType: value.serviceType,
|
|
19676
19800
|
checkIn: value.checkIn,
|
|
19677
19801
|
checkOut: null,
|
|
19678
19802
|
user: value.user,
|
|
@@ -19697,6 +19821,7 @@ function useAttendanceRepository() {
|
|
|
19697
19821
|
try {
|
|
19698
19822
|
await collection.createIndexes([
|
|
19699
19823
|
{ key: { site: 1 } },
|
|
19824
|
+
{ key: { serviceType: 1 } },
|
|
19700
19825
|
{ key: { user: 1 } }
|
|
19701
19826
|
]);
|
|
19702
19827
|
} catch (error) {
|
|
@@ -19724,13 +19849,15 @@ function useAttendanceRepository() {
|
|
|
19724
19849
|
page = 1,
|
|
19725
19850
|
limit = 10,
|
|
19726
19851
|
search = "",
|
|
19727
|
-
site
|
|
19852
|
+
site,
|
|
19853
|
+
serviceType
|
|
19728
19854
|
}) {
|
|
19729
19855
|
page = page > 0 ? page - 1 : 0;
|
|
19730
|
-
const query = {};
|
|
19856
|
+
const query = { serviceType };
|
|
19731
19857
|
const cacheOptions = {
|
|
19732
19858
|
page,
|
|
19733
|
-
limit
|
|
19859
|
+
limit,
|
|
19860
|
+
serviceType
|
|
19734
19861
|
};
|
|
19735
19862
|
try {
|
|
19736
19863
|
site = new import_mongodb53.ObjectId(site);
|
|
@@ -19819,13 +19946,15 @@ function useAttendanceRepository() {
|
|
|
19819
19946
|
limit = 10,
|
|
19820
19947
|
search = "",
|
|
19821
19948
|
site,
|
|
19949
|
+
serviceType,
|
|
19822
19950
|
user
|
|
19823
19951
|
}) {
|
|
19824
19952
|
page = page > 0 ? page - 1 : 0;
|
|
19825
|
-
const query = {};
|
|
19953
|
+
const query = { serviceType };
|
|
19826
19954
|
const cacheOptions = {
|
|
19827
19955
|
page,
|
|
19828
|
-
limit
|
|
19956
|
+
limit,
|
|
19957
|
+
serviceType
|
|
19829
19958
|
};
|
|
19830
19959
|
try {
|
|
19831
19960
|
site = new import_mongodb53.ObjectId(site);
|
|
@@ -20103,7 +20232,11 @@ function useAttendanceService() {
|
|
|
20103
20232
|
const session = import_node_server_utils97.useAtlas.getClient()?.startSession();
|
|
20104
20233
|
try {
|
|
20105
20234
|
session?.startTransaction();
|
|
20106
|
-
const setting = await getAttendanceSettingsBySite(
|
|
20235
|
+
const setting = await getAttendanceSettingsBySite(
|
|
20236
|
+
value.site,
|
|
20237
|
+
value.serviceType,
|
|
20238
|
+
session
|
|
20239
|
+
);
|
|
20107
20240
|
if (setting?.isLocationEnabled && setting?.isGeofencingEnabled) {
|
|
20108
20241
|
if (!setting.location || !value.checkIn.location) {
|
|
20109
20242
|
throw new import_node_server_utils97.BadRequestError("Location data is required for check-in.");
|
|
@@ -20150,6 +20283,7 @@ function useAttendanceService() {
|
|
|
20150
20283
|
const attendance = await getRawAttendanceById(_id, session);
|
|
20151
20284
|
const setting = await getAttendanceSettingsBySite(
|
|
20152
20285
|
attendance.site,
|
|
20286
|
+
attendance.serviceType,
|
|
20153
20287
|
session
|
|
20154
20288
|
);
|
|
20155
20289
|
if (setting?.isLocationEnabled && setting?.isGeofencingEnabled) {
|
|
@@ -20235,7 +20369,8 @@ function useAttendanceController() {
|
|
|
20235
20369
|
page: import_joi54.default.number().min(1).optional().allow("", null),
|
|
20236
20370
|
limit: import_joi54.default.number().min(1).optional().allow("", null),
|
|
20237
20371
|
search: import_joi54.default.string().optional().allow("", null),
|
|
20238
|
-
site: import_joi54.default.string().hex().required()
|
|
20372
|
+
site: import_joi54.default.string().hex().required(),
|
|
20373
|
+
serviceType: import_joi54.default.string().valid(...Object.values(AppServiceType)).required()
|
|
20239
20374
|
});
|
|
20240
20375
|
const { error } = validation.validate(query);
|
|
20241
20376
|
if (error) {
|
|
@@ -20247,12 +20382,14 @@ function useAttendanceController() {
|
|
|
20247
20382
|
const limit = parseInt(req.query.limit) ?? 10;
|
|
20248
20383
|
const search = req.query.search ?? "";
|
|
20249
20384
|
const site = req.params.site ?? "";
|
|
20385
|
+
const serviceType = req.query.serviceType ?? "";
|
|
20250
20386
|
try {
|
|
20251
20387
|
const data = await _getAllAttendances({
|
|
20252
20388
|
page,
|
|
20253
20389
|
limit,
|
|
20254
20390
|
search,
|
|
20255
|
-
site
|
|
20391
|
+
site,
|
|
20392
|
+
serviceType
|
|
20256
20393
|
});
|
|
20257
20394
|
res.json(data);
|
|
20258
20395
|
return;
|
|
@@ -20274,6 +20411,7 @@ function useAttendanceController() {
|
|
|
20274
20411
|
limit: import_joi54.default.number().min(1).optional().allow("", null),
|
|
20275
20412
|
search: import_joi54.default.string().optional().allow("", null),
|
|
20276
20413
|
site: import_joi54.default.string().hex().required(),
|
|
20414
|
+
serviceType: import_joi54.default.string().valid(...Object.values(AppServiceType)).required(),
|
|
20277
20415
|
user: import_joi54.default.string().hex().required()
|
|
20278
20416
|
});
|
|
20279
20417
|
const { error } = validation.validate(query);
|
|
@@ -20286,12 +20424,14 @@ function useAttendanceController() {
|
|
|
20286
20424
|
const limit = parseInt(req.query.limit) ?? 10;
|
|
20287
20425
|
const search = req.query.search ?? "";
|
|
20288
20426
|
const site = req.params.site ?? "";
|
|
20427
|
+
const serviceType = req.query.serviceType ?? "";
|
|
20289
20428
|
try {
|
|
20290
20429
|
const data = await _getAttendanceByUser({
|
|
20291
20430
|
page,
|
|
20292
20431
|
limit,
|
|
20293
20432
|
search,
|
|
20294
20433
|
site,
|
|
20434
|
+
serviceType,
|
|
20295
20435
|
user
|
|
20296
20436
|
});
|
|
20297
20437
|
res.json(data);
|
|
@@ -21669,20 +21809,37 @@ function usePersonController() {
|
|
|
21669
21809
|
}
|
|
21670
21810
|
}
|
|
21671
21811
|
async function getPeopleByUnit(req, res, next) {
|
|
21672
|
-
const
|
|
21673
|
-
|
|
21674
|
-
|
|
21675
|
-
|
|
21676
|
-
|
|
21677
|
-
|
|
21678
|
-
|
|
21679
|
-
|
|
21680
|
-
|
|
21681
|
-
|
|
21682
|
-
|
|
21683
|
-
|
|
21684
|
-
|
|
21685
|
-
|
|
21812
|
+
const PERSON_TYPES3 = Object.values(PersonTypes);
|
|
21813
|
+
console.log(req.query);
|
|
21814
|
+
try {
|
|
21815
|
+
const schema2 = import_joi58.default.object({
|
|
21816
|
+
unit: import_joi58.default.string().required(),
|
|
21817
|
+
type: import_joi58.default.string().optional().allow("", null).custom((value2, helpers) => {
|
|
21818
|
+
if (!value2)
|
|
21819
|
+
return ["resident" /* RESIDENT */];
|
|
21820
|
+
const parsed = value2.split(",").map((v) => v.trim()).filter(Boolean);
|
|
21821
|
+
for (const t of parsed) {
|
|
21822
|
+
if (!PERSON_TYPES3.includes(t)) {
|
|
21823
|
+
return helpers.error("any.only");
|
|
21824
|
+
}
|
|
21825
|
+
}
|
|
21826
|
+
return parsed;
|
|
21827
|
+
}).messages({
|
|
21828
|
+
"any.only": `Type must be one of: ${PERSON_TYPES3.join(", ")}`
|
|
21829
|
+
}),
|
|
21830
|
+
status: import_joi58.default.string().valid(...Object.values(PersonStatus)).optional().default("active" /* ACTIVE */)
|
|
21831
|
+
});
|
|
21832
|
+
const { error, value } = schema2.validate(
|
|
21833
|
+
{ unit: req.params.unit, ...req.query },
|
|
21834
|
+
{ abortEarly: false }
|
|
21835
|
+
);
|
|
21836
|
+
if (error) {
|
|
21837
|
+
const messages = error.details.map((d) => d.message).join(", ");
|
|
21838
|
+
import_node_server_utils105.logger.log({ level: "error", message: messages });
|
|
21839
|
+
next(new import_node_server_utils105.BadRequestError(messages));
|
|
21840
|
+
return;
|
|
21841
|
+
}
|
|
21842
|
+
const { unit, type, status } = value;
|
|
21686
21843
|
const data = await _getPeopleByUnit({
|
|
21687
21844
|
status,
|
|
21688
21845
|
type,
|
|
@@ -21690,9 +21847,9 @@ function usePersonController() {
|
|
|
21690
21847
|
});
|
|
21691
21848
|
res.json(data);
|
|
21692
21849
|
return;
|
|
21693
|
-
} catch (
|
|
21694
|
-
import_node_server_utils105.logger.log({ level: "error", message:
|
|
21695
|
-
next(
|
|
21850
|
+
} catch (error) {
|
|
21851
|
+
import_node_server_utils105.logger.log({ level: "error", message: error.message });
|
|
21852
|
+
next(error);
|
|
21696
21853
|
return;
|
|
21697
21854
|
}
|
|
21698
21855
|
}
|
|
@@ -28151,7 +28308,7 @@ function useSiteBillingConfigurationController() {
|
|
|
28151
28308
|
(acc, [key, value2]) => ({ ...acc, [key]: value2 }),
|
|
28152
28309
|
{}
|
|
28153
28310
|
);
|
|
28154
|
-
req.body.createdBy = cookies?.["user"].toString()
|
|
28311
|
+
req.body.createdBy = cookies?.["user"] ? cookies["user"].toString() : req.body.createdBy;
|
|
28155
28312
|
const data = { ...req.body };
|
|
28156
28313
|
const { error, value } = schemaBillingConfiguration.validate(data);
|
|
28157
28314
|
if (error) {
|
|
@@ -33557,6 +33714,11 @@ function useNfcPatrolTagController() {
|
|
|
33557
33714
|
// src/models/occurrence-book.model.ts
|
|
33558
33715
|
var import_mongodb87 = require("mongodb");
|
|
33559
33716
|
var import_joi88 = __toESM(require("joi"));
|
|
33717
|
+
var DOBStatus = /* @__PURE__ */ ((DOBStatus3) => {
|
|
33718
|
+
DOBStatus3["OPEN"] = "open";
|
|
33719
|
+
DOBStatus3["CLOSE"] = "close";
|
|
33720
|
+
return DOBStatus3;
|
|
33721
|
+
})(DOBStatus || {});
|
|
33560
33722
|
var schemaOccurrenceBook = import_joi88.default.object({
|
|
33561
33723
|
_id: import_joi88.default.string().optional().allow(null, ""),
|
|
33562
33724
|
site: import_joi88.default.string().hex().required(),
|
|
@@ -33614,7 +33776,12 @@ function useOccurrenceBookRepo() {
|
|
|
33614
33776
|
async function createIndexes() {
|
|
33615
33777
|
try {
|
|
33616
33778
|
await collection.createIndexes([
|
|
33617
|
-
{ key: { site: 1, status: 1, date: 1, closedAt: 1 } }
|
|
33779
|
+
{ key: { site: 1, status: 1, date: 1, closedAt: 1 } },
|
|
33780
|
+
{
|
|
33781
|
+
key: { site: 1, date: 1 },
|
|
33782
|
+
unique: true,
|
|
33783
|
+
name: "unique_site_date"
|
|
33784
|
+
}
|
|
33618
33785
|
]);
|
|
33619
33786
|
} catch (error) {
|
|
33620
33787
|
throw new import_node_server_utils155.InternalServerError(
|
|
@@ -34012,7 +34179,9 @@ function useOccurrenceBookService() {
|
|
|
34012
34179
|
site: site._id,
|
|
34013
34180
|
date: baseDate.toISOString(),
|
|
34014
34181
|
closedAt: closedAt.toISOString(),
|
|
34015
|
-
entryCounter
|
|
34182
|
+
entryCounter,
|
|
34183
|
+
totalInput: 0,
|
|
34184
|
+
status: "open" /* OPEN */
|
|
34016
34185
|
}));
|
|
34017
34186
|
await _bulkCreate(payloads, session);
|
|
34018
34187
|
await session?.commitTransaction();
|
|
@@ -35216,7 +35385,7 @@ function useStatementOfAccountController() {
|
|
|
35216
35385
|
(acc, [key, value]) => ({ ...acc, [key]: value }),
|
|
35217
35386
|
{}
|
|
35218
35387
|
);
|
|
35219
|
-
req.body.createdBy = cookies?.["user"].toString()
|
|
35388
|
+
req.body.createdBy = cookies?.["user"] ? cookies["user"].toString() : req.body.createdBy;
|
|
35220
35389
|
const data = { ...req.body };
|
|
35221
35390
|
const validation = import_joi93.default.object({
|
|
35222
35391
|
dateFrom: import_joi93.default.string().required(),
|
|
@@ -44004,7 +44173,6 @@ var import_node_server_utils213 = require("@7365admin1/node-server-utils");
|
|
|
44004
44173
|
var import_mongodb116 = require("mongodb");
|
|
44005
44174
|
var import_moment_timezone5 = __toESM(require("moment-timezone"));
|
|
44006
44175
|
async function manpowerEvents(io) {
|
|
44007
|
-
console.log("Manpower events initialized");
|
|
44008
44176
|
let intervalId = null;
|
|
44009
44177
|
let activeConnections = 0;
|
|
44010
44178
|
const { getAttendanceDataCount: _getAttendanceDataCount } = useHrmLabsAttendanceSrvc();
|
|
@@ -44822,6 +44990,227 @@ function useRedDotPaymentController() {
|
|
|
44822
44990
|
getMerchantDetailsById
|
|
44823
44991
|
};
|
|
44824
44992
|
}
|
|
44993
|
+
|
|
44994
|
+
// src/models/verification-v2.model.ts
|
|
44995
|
+
var import_node_server_utils216 = require("@7365admin1/node-server-utils");
|
|
44996
|
+
var import_mongodb121 = require("mongodb");
|
|
44997
|
+
var VerificationType = /* @__PURE__ */ ((VerificationType2) => {
|
|
44998
|
+
VerificationType2["USER_SIGN_UP"] = "user-sign-up";
|
|
44999
|
+
VerificationType2["FORGET_PASSWORD"] = "forget-password";
|
|
45000
|
+
VerificationType2["USER_INVITE"] = "user-invite";
|
|
45001
|
+
VerificationType2["MEMBER_INVITE"] = "member-invite";
|
|
45002
|
+
return VerificationType2;
|
|
45003
|
+
})(VerificationType || {});
|
|
45004
|
+
var MVerificationV2 = class {
|
|
45005
|
+
constructor(value) {
|
|
45006
|
+
this._id = value._id ?? new import_mongodb121.ObjectId();
|
|
45007
|
+
this.type = value.type ?? "";
|
|
45008
|
+
this.email = value.email ?? "";
|
|
45009
|
+
if (value.metadata?.role) {
|
|
45010
|
+
try {
|
|
45011
|
+
value.metadata.role = new import_mongodb121.ObjectId(value.metadata.role);
|
|
45012
|
+
} catch (error) {
|
|
45013
|
+
throw new import_node_server_utils216.BadRequestError("Invalid role ID format.");
|
|
45014
|
+
}
|
|
45015
|
+
}
|
|
45016
|
+
if (value.metadata?.org) {
|
|
45017
|
+
try {
|
|
45018
|
+
value.metadata.org = new import_mongodb121.ObjectId(value.metadata.org);
|
|
45019
|
+
} catch (error) {
|
|
45020
|
+
throw new import_node_server_utils216.BadRequestError("Invalid org ID format.");
|
|
45021
|
+
}
|
|
45022
|
+
}
|
|
45023
|
+
if (value.metadata?.siteId) {
|
|
45024
|
+
try {
|
|
45025
|
+
value.metadata.siteId = new import_mongodb121.ObjectId(value.metadata.siteId);
|
|
45026
|
+
} catch (error) {
|
|
45027
|
+
throw new import_node_server_utils216.BadRequestError("Invalid site ID format.");
|
|
45028
|
+
}
|
|
45029
|
+
}
|
|
45030
|
+
if (value.metadata?.serviceProviderOrgId) {
|
|
45031
|
+
try {
|
|
45032
|
+
value.metadata.serviceProviderOrgId = new import_mongodb121.ObjectId(
|
|
45033
|
+
value.metadata.serviceProviderOrgId
|
|
45034
|
+
);
|
|
45035
|
+
} catch (error) {
|
|
45036
|
+
throw new import_node_server_utils216.BadRequestError("Invalid service provider ID format.");
|
|
45037
|
+
}
|
|
45038
|
+
}
|
|
45039
|
+
this.metadata = { ...value.metadata };
|
|
45040
|
+
this.status = value.status ?? "pending";
|
|
45041
|
+
this.createdAt = value.createdAt ?? /* @__PURE__ */ new Date();
|
|
45042
|
+
this.updatedAt = value.updatedAt ?? null;
|
|
45043
|
+
this.expireAt = value.expireAt ?? new Date(Date.now() + 3600 * 1e3);
|
|
45044
|
+
}
|
|
45045
|
+
};
|
|
45046
|
+
|
|
45047
|
+
// src/repositories/verification-v2.repo.ts
|
|
45048
|
+
var import_node_server_utils217 = require("@7365admin1/node-server-utils");
|
|
45049
|
+
function useVerificationRepoV2() {
|
|
45050
|
+
const db = import_node_server_utils217.useAtlas.getDb();
|
|
45051
|
+
if (!db) {
|
|
45052
|
+
throw new import_node_server_utils217.InternalServerError("Unable to connect to server.");
|
|
45053
|
+
}
|
|
45054
|
+
const namespace_collection = "verifications";
|
|
45055
|
+
const collection = db.collection(namespace_collection);
|
|
45056
|
+
async function createIndex() {
|
|
45057
|
+
try {
|
|
45058
|
+
await collection.createIndex([
|
|
45059
|
+
{ email: 1 },
|
|
45060
|
+
{ type: 1 },
|
|
45061
|
+
{ status: 1 },
|
|
45062
|
+
{ "metadata.org": 1 }
|
|
45063
|
+
]);
|
|
45064
|
+
} catch (error) {
|
|
45065
|
+
throw new import_node_server_utils217.InternalServerError("Failed to create index.");
|
|
45066
|
+
}
|
|
45067
|
+
}
|
|
45068
|
+
async function createTextIndex() {
|
|
45069
|
+
try {
|
|
45070
|
+
await collection.createIndex({
|
|
45071
|
+
email: "text"
|
|
45072
|
+
});
|
|
45073
|
+
} catch (error) {
|
|
45074
|
+
throw new import_node_server_utils217.InternalServerError("Failed to create text index on email.");
|
|
45075
|
+
}
|
|
45076
|
+
}
|
|
45077
|
+
const { delNamespace, setCache, getCache, delCache } = (0, import_node_server_utils217.useCache)(namespace_collection);
|
|
45078
|
+
async function add(value, session) {
|
|
45079
|
+
value = new MVerificationV2(value);
|
|
45080
|
+
try {
|
|
45081
|
+
const res = await collection.insertOne(value, { session });
|
|
45082
|
+
delNamespace().then(() => {
|
|
45083
|
+
import_node_server_utils217.logger.info(`Cache cleared for namespace: ${namespace_collection}`);
|
|
45084
|
+
}).catch((err) => {
|
|
45085
|
+
import_node_server_utils217.logger.error(
|
|
45086
|
+
`Failed to clear cache for namespace: ${namespace_collection}`,
|
|
45087
|
+
err
|
|
45088
|
+
);
|
|
45089
|
+
});
|
|
45090
|
+
return res.insertedId;
|
|
45091
|
+
} catch (error) {
|
|
45092
|
+
import_node_server_utils217.logger.log({
|
|
45093
|
+
level: "info",
|
|
45094
|
+
message: String(error)
|
|
45095
|
+
});
|
|
45096
|
+
throw new import_node_server_utils217.InternalServerError("Server internal error.");
|
|
45097
|
+
}
|
|
45098
|
+
}
|
|
45099
|
+
return {
|
|
45100
|
+
createIndex,
|
|
45101
|
+
createTextIndex,
|
|
45102
|
+
add
|
|
45103
|
+
};
|
|
45104
|
+
}
|
|
45105
|
+
|
|
45106
|
+
// src/services/verification-v2.service.ts
|
|
45107
|
+
var import_node_server_utils218 = require("@7365admin1/node-server-utils");
|
|
45108
|
+
function useVerificationServiceV2() {
|
|
45109
|
+
const MailerConfig = {
|
|
45110
|
+
host: MAILER_TRANSPORT_HOST,
|
|
45111
|
+
port: MAILER_TRANSPORT_PORT,
|
|
45112
|
+
secure: MAILER_TRANSPORT_SECURE,
|
|
45113
|
+
email: MAILER_EMAIL,
|
|
45114
|
+
password: MAILER_PASSWORD
|
|
45115
|
+
};
|
|
45116
|
+
const mailer = new import_node_server_utils218.useMailer(MailerConfig);
|
|
45117
|
+
const { add } = useVerificationRepoV2();
|
|
45118
|
+
const { getUserByEmail } = useUserRepo();
|
|
45119
|
+
async function signUp({
|
|
45120
|
+
email,
|
|
45121
|
+
metadata
|
|
45122
|
+
}) {
|
|
45123
|
+
try {
|
|
45124
|
+
const user = await getUserByEmail(email);
|
|
45125
|
+
if (user) {
|
|
45126
|
+
throw new import_node_server_utils218.BadRequestError(
|
|
45127
|
+
`Email ${email} is already registered, please login to continue.`
|
|
45128
|
+
);
|
|
45129
|
+
}
|
|
45130
|
+
metadata.password = await (0, import_node_server_utils218.hashPassword)(metadata.password);
|
|
45131
|
+
const value = {
|
|
45132
|
+
type: "user-sign-up" /* USER_SIGN_UP */,
|
|
45133
|
+
email,
|
|
45134
|
+
metadata,
|
|
45135
|
+
expireAt: new Date((/* @__PURE__ */ new Date()).getTime() + 5 * 60 * 1e3).toISOString(),
|
|
45136
|
+
// 5mins from now
|
|
45137
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
45138
|
+
};
|
|
45139
|
+
const res = await add(value);
|
|
45140
|
+
const dir = __dirname;
|
|
45141
|
+
const filePath = (0, import_node_server_utils218.getDirectory)(dir, "./public/handlebars/sign-up");
|
|
45142
|
+
const emailContent = (0, import_node_server_utils218.compileHandlebar)({
|
|
45143
|
+
context: {
|
|
45144
|
+
email,
|
|
45145
|
+
validity: "5 minutes",
|
|
45146
|
+
link: `${APP_MAIN}/sign-up/${res}`
|
|
45147
|
+
},
|
|
45148
|
+
filePath
|
|
45149
|
+
});
|
|
45150
|
+
mailer.sendMail({
|
|
45151
|
+
to: email,
|
|
45152
|
+
subject: "Sign Up Verification",
|
|
45153
|
+
html: emailContent,
|
|
45154
|
+
sender: "iService365"
|
|
45155
|
+
}).catch((error) => {
|
|
45156
|
+
import_node_server_utils218.logger.log({
|
|
45157
|
+
level: "error",
|
|
45158
|
+
message: `Error sending user invite email: ${error}`
|
|
45159
|
+
});
|
|
45160
|
+
});
|
|
45161
|
+
return res;
|
|
45162
|
+
} catch (error) {
|
|
45163
|
+
throw error;
|
|
45164
|
+
}
|
|
45165
|
+
}
|
|
45166
|
+
return {
|
|
45167
|
+
signUp
|
|
45168
|
+
};
|
|
45169
|
+
}
|
|
45170
|
+
|
|
45171
|
+
// src/controllers/auth-v2.controller.ts
|
|
45172
|
+
var import_joi125 = __toESM(require("joi"));
|
|
45173
|
+
var import_node_server_utils219 = require("@7365admin1/node-server-utils");
|
|
45174
|
+
function useAuthControllerV2() {
|
|
45175
|
+
const { signUp: _signUp } = useVerificationServiceV2();
|
|
45176
|
+
async function signUp(req, res, next) {
|
|
45177
|
+
const validation = import_joi125.default.object({
|
|
45178
|
+
email: import_joi125.default.string().email().lowercase().trim().required(),
|
|
45179
|
+
password: import_joi125.default.string().trim().required(),
|
|
45180
|
+
country: import_joi125.default.string().min(3).required(),
|
|
45181
|
+
orgName: import_joi125.default.string().min(1).required()
|
|
45182
|
+
});
|
|
45183
|
+
const { error, value } = validation.validate(req.body, {
|
|
45184
|
+
abortEarly: false
|
|
45185
|
+
});
|
|
45186
|
+
if (error) {
|
|
45187
|
+
const messages = error.details.map((d) => d.message);
|
|
45188
|
+
import_node_server_utils219.logger.log({ level: "error", message: messages.join(", ") });
|
|
45189
|
+
next(new import_node_server_utils219.BadRequestError(messages.join(", ")));
|
|
45190
|
+
return;
|
|
45191
|
+
}
|
|
45192
|
+
const { email, password, country, orgName } = value;
|
|
45193
|
+
try {
|
|
45194
|
+
const message = await _signUp({
|
|
45195
|
+
email,
|
|
45196
|
+
metadata: {
|
|
45197
|
+
password,
|
|
45198
|
+
country,
|
|
45199
|
+
orgName
|
|
45200
|
+
}
|
|
45201
|
+
});
|
|
45202
|
+
res.json({ message });
|
|
45203
|
+
return;
|
|
45204
|
+
} catch (error2) {
|
|
45205
|
+
import_node_server_utils219.logger.log({ level: "error", message: error2.message });
|
|
45206
|
+
next(error2);
|
|
45207
|
+
return;
|
|
45208
|
+
}
|
|
45209
|
+
}
|
|
45210
|
+
return {
|
|
45211
|
+
signUp
|
|
45212
|
+
};
|
|
45213
|
+
}
|
|
44825
45214
|
// Annotate the CommonJS export names for ESM import in node:
|
|
44826
45215
|
0 && (module.exports = {
|
|
44827
45216
|
ANPRMode,
|
|
@@ -44832,6 +45221,7 @@ function useRedDotPaymentController() {
|
|
|
44832
45221
|
BulletinStatus,
|
|
44833
45222
|
CameraType,
|
|
44834
45223
|
DEVICE_STATUS,
|
|
45224
|
+
DOBStatus,
|
|
44835
45225
|
DayOfWeek,
|
|
44836
45226
|
EAccessCardTypes,
|
|
44837
45227
|
EAccessCardUserTypes,
|
|
@@ -44898,6 +45288,7 @@ function useRedDotPaymentController() {
|
|
|
44898
45288
|
MVehicle,
|
|
44899
45289
|
MVehicleTransaction,
|
|
44900
45290
|
MVerification,
|
|
45291
|
+
MVerificationV2,
|
|
44901
45292
|
MVisitorTransaction,
|
|
44902
45293
|
MWorkOrder,
|
|
44903
45294
|
OrgNature,
|
|
@@ -44906,6 +45297,7 @@ function useRedDotPaymentController() {
|
|
|
44906
45297
|
PERSON_TYPES,
|
|
44907
45298
|
PMDashboardCollection,
|
|
44908
45299
|
Period,
|
|
45300
|
+
PersonStatus,
|
|
44909
45301
|
PersonTypes,
|
|
44910
45302
|
SiteCategories,
|
|
44911
45303
|
SiteStatus,
|
|
@@ -44918,6 +45310,7 @@ function useRedDotPaymentController() {
|
|
|
44918
45310
|
VehicleSort,
|
|
44919
45311
|
VehicleStatus,
|
|
44920
45312
|
VehicleType,
|
|
45313
|
+
VerificationType,
|
|
44921
45314
|
VisitorSort,
|
|
44922
45315
|
VisitorStatus,
|
|
44923
45316
|
addressSchema,
|
|
@@ -45042,6 +45435,7 @@ function useRedDotPaymentController() {
|
|
|
45042
45435
|
useAttendanceSettingsRepository,
|
|
45043
45436
|
useAttendanceSettingsService,
|
|
45044
45437
|
useAuthController,
|
|
45438
|
+
useAuthControllerV2,
|
|
45045
45439
|
useAuthService,
|
|
45046
45440
|
useBuildingController,
|
|
45047
45441
|
useBuildingRepo,
|
|
@@ -45195,7 +45589,9 @@ function useRedDotPaymentController() {
|
|
|
45195
45589
|
useVehicleService,
|
|
45196
45590
|
useVerificationController,
|
|
45197
45591
|
useVerificationRepo,
|
|
45592
|
+
useVerificationRepoV2,
|
|
45198
45593
|
useVerificationService,
|
|
45594
|
+
useVerificationServiceV2,
|
|
45199
45595
|
useVisitorTransactionController,
|
|
45200
45596
|
useVisitorTransactionRepo,
|
|
45201
45597
|
useVisitorTransactionService,
|