@7365admin1/core 2.31.0 → 2.31.2
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 +41 -1
- package/dist/index.js +455 -241
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +456 -241
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -7415,6 +7415,34 @@ function useOrgController() {
|
|
|
7415
7415
|
return;
|
|
7416
7416
|
}
|
|
7417
7417
|
}
|
|
7418
|
+
async function addOnboardingOrg(req, res, next) {
|
|
7419
|
+
const validation = Joi18.object({
|
|
7420
|
+
name: Joi18.string().required(),
|
|
7421
|
+
type: Joi18.string().required(),
|
|
7422
|
+
nature: Joi18.string().valid(...allowedNatures).required(),
|
|
7423
|
+
email: Joi18.string().email().optional().allow("", null),
|
|
7424
|
+
contact: Joi18.string().optional().allow("", null)
|
|
7425
|
+
});
|
|
7426
|
+
const { error } = validation.validate(req.body);
|
|
7427
|
+
if (error) {
|
|
7428
|
+
logger24.log({ level: "error", message: error.message });
|
|
7429
|
+
next(new BadRequestError32(error.message));
|
|
7430
|
+
return;
|
|
7431
|
+
}
|
|
7432
|
+
try {
|
|
7433
|
+
const _id = await _add(req.body);
|
|
7434
|
+
const data = await _getById(_id);
|
|
7435
|
+
res.status(201).json({
|
|
7436
|
+
message: "Successfully created organization.",
|
|
7437
|
+
data
|
|
7438
|
+
});
|
|
7439
|
+
return;
|
|
7440
|
+
} catch (error2) {
|
|
7441
|
+
logger24.log({ level: "error", message: error2.message });
|
|
7442
|
+
next(error2);
|
|
7443
|
+
return;
|
|
7444
|
+
}
|
|
7445
|
+
}
|
|
7418
7446
|
async function getOrgsByUserId(req, res, next) {
|
|
7419
7447
|
const validation = Joi18.object({
|
|
7420
7448
|
search: Joi18.string().optional().allow("", null),
|
|
@@ -7513,6 +7541,7 @@ function useOrgController() {
|
|
|
7513
7541
|
}
|
|
7514
7542
|
return {
|
|
7515
7543
|
add,
|
|
7544
|
+
addOnboardingOrg,
|
|
7516
7545
|
getAll,
|
|
7517
7546
|
getOrgsByUserId,
|
|
7518
7547
|
getByName,
|
|
@@ -13112,7 +13141,7 @@ var schemaVisitorTransaction = Joi36.object({
|
|
|
13112
13141
|
arrivalTime: Joi36.string().pattern(/^([01]\d|2[0-3]):([0-5]\d)$/).optional().allow(null, "").messages({
|
|
13113
13142
|
"string.pattern.base": "arrivalTime must be in HH:mm format (e.g. 09:30, 18:45)"
|
|
13114
13143
|
}),
|
|
13115
|
-
duration: Joi36.number().integer().optional().allow(null),
|
|
13144
|
+
duration: Joi36.number().integer().optional().allow(null, ""),
|
|
13116
13145
|
isOvernightParking: Joi36.boolean().optional().default(false),
|
|
13117
13146
|
email: Joi36.string().email().optional().allow(null, ""),
|
|
13118
13147
|
numberOfPassengers: Joi36.number().integer().optional().allow(null, ""),
|
|
@@ -13129,7 +13158,8 @@ var schemaVisitorTransaction = Joi36.object({
|
|
|
13129
13158
|
checkInRemarks: Joi36.string().optional().allow("", null),
|
|
13130
13159
|
checkOutRemarks: Joi36.string().optional().allow("", null),
|
|
13131
13160
|
expectedCheckIn: Joi36.string().isoDate().optional(),
|
|
13132
|
-
purpose: Joi36.string().optional().allow(null, "")
|
|
13161
|
+
purpose: Joi36.string().optional().allow(null, ""),
|
|
13162
|
+
invitedId: Joi36.any().optional().allow(null, "")
|
|
13133
13163
|
});
|
|
13134
13164
|
var schemaUpdateVisTrans = Joi36.object({
|
|
13135
13165
|
_id: Joi36.string().hex().length(24).required(),
|
|
@@ -13273,7 +13303,17 @@ function MVisitorTransaction(value) {
|
|
|
13273
13303
|
expiredAt: value.expiredAt ?? null,
|
|
13274
13304
|
createdAt: value.createdAt ?? newDate,
|
|
13275
13305
|
updatedAt: value.updatedAt ?? "",
|
|
13276
|
-
deletedAt: value.deletedAt ?? ""
|
|
13306
|
+
deletedAt: value.deletedAt ?? "",
|
|
13307
|
+
purpose: value.purpose,
|
|
13308
|
+
numberOfPassengers: value.numberOfPassengers ?? null,
|
|
13309
|
+
email: value.email,
|
|
13310
|
+
isOvernightParking: value.isOvernightParking ?? false,
|
|
13311
|
+
invitedId: new ObjectId39(String(value.invitedId)) ?? null,
|
|
13312
|
+
overnightParking: value.isOvernightParking == true ? {
|
|
13313
|
+
status: "pending approval",
|
|
13314
|
+
remarks: "",
|
|
13315
|
+
updatedBy: new ObjectId39(String(value.invitedId)) ?? null
|
|
13316
|
+
} : null
|
|
13277
13317
|
};
|
|
13278
13318
|
}
|
|
13279
13319
|
|
|
@@ -13405,16 +13445,40 @@ function useVisitorTransactionRepo() {
|
|
|
13405
13445
|
localField: "visitorPass.keyId",
|
|
13406
13446
|
foreignField: "_id",
|
|
13407
13447
|
pipeline: [
|
|
13448
|
+
{
|
|
13449
|
+
$lookup: {
|
|
13450
|
+
from: "qr-code-templates",
|
|
13451
|
+
localField: "template",
|
|
13452
|
+
foreignField: "_id",
|
|
13453
|
+
pipeline: [
|
|
13454
|
+
{
|
|
13455
|
+
$project: {
|
|
13456
|
+
_id: 1,
|
|
13457
|
+
prefixPass: 1,
|
|
13458
|
+
name: 1
|
|
13459
|
+
}
|
|
13460
|
+
}
|
|
13461
|
+
],
|
|
13462
|
+
as: "template"
|
|
13463
|
+
}
|
|
13464
|
+
},
|
|
13408
13465
|
{
|
|
13409
13466
|
$project: {
|
|
13410
13467
|
_id: 0,
|
|
13411
|
-
// remove original _id
|
|
13412
13468
|
keyId: "$_id",
|
|
13413
13469
|
status: 1,
|
|
13414
13470
|
description: 1,
|
|
13471
|
+
templatePrefixPass: {
|
|
13472
|
+
$arrayElemAt: ["$template.prefixPass", 0]
|
|
13473
|
+
},
|
|
13415
13474
|
prefixAndName: {
|
|
13416
13475
|
$concat: [
|
|
13417
|
-
{
|
|
13476
|
+
{
|
|
13477
|
+
$ifNull: [
|
|
13478
|
+
{ $arrayElemAt: ["$template.prefixPass", 0] },
|
|
13479
|
+
""
|
|
13480
|
+
]
|
|
13481
|
+
},
|
|
13418
13482
|
{ $ifNull: ["$name", ""] }
|
|
13419
13483
|
]
|
|
13420
13484
|
}
|
|
@@ -13427,145 +13491,50 @@ function useVisitorTransactionRepo() {
|
|
|
13427
13491
|
{
|
|
13428
13492
|
$lookup: {
|
|
13429
13493
|
from: "keys",
|
|
13430
|
-
localField: "
|
|
13494
|
+
localField: "passKeys.keyId",
|
|
13431
13495
|
foreignField: "_id",
|
|
13432
13496
|
pipeline: [
|
|
13433
13497
|
{
|
|
13434
|
-
$
|
|
13435
|
-
|
|
13436
|
-
|
|
13437
|
-
|
|
13438
|
-
|
|
13439
|
-
|
|
13440
|
-
|
|
13441
|
-
|
|
13442
|
-
|
|
13443
|
-
|
|
13444
|
-
as: "visitorPassDetails"
|
|
13445
|
-
}
|
|
13446
|
-
},
|
|
13447
|
-
{
|
|
13448
|
-
$addFields: {
|
|
13449
|
-
visitorPass: {
|
|
13450
|
-
$map: {
|
|
13451
|
-
input: "$visitorPass",
|
|
13452
|
-
as: "vp",
|
|
13453
|
-
in: {
|
|
13454
|
-
$let: {
|
|
13455
|
-
vars: {
|
|
13456
|
-
matchedKey: {
|
|
13457
|
-
$arrayElemAt: [
|
|
13458
|
-
{
|
|
13459
|
-
$filter: {
|
|
13460
|
-
input: "$visitorPassDetails",
|
|
13461
|
-
as: "kd",
|
|
13462
|
-
cond: { $eq: ["$$kd._id", "$$vp.keyId"] }
|
|
13463
|
-
}
|
|
13464
|
-
},
|
|
13465
|
-
0
|
|
13466
|
-
]
|
|
13467
|
-
}
|
|
13468
|
-
},
|
|
13469
|
-
in: {
|
|
13470
|
-
keyId: "$$vp.keyId",
|
|
13471
|
-
receivedDate: "$$vp.receivedDate",
|
|
13472
|
-
status: "$$vp.status",
|
|
13473
|
-
lastUpdate: {
|
|
13474
|
-
$max: [
|
|
13475
|
-
"$$matchedKey.createdAt",
|
|
13476
|
-
"$$matchedKey.updatedAt"
|
|
13477
|
-
]
|
|
13478
|
-
},
|
|
13479
|
-
remarks: "$$vp.remarks",
|
|
13480
|
-
description: "$$matchedKey.description",
|
|
13481
|
-
prefixAndName: {
|
|
13482
|
-
$concat: [
|
|
13483
|
-
{ $ifNull: ["$$matchedKey.prefix", ""] },
|
|
13484
|
-
{ $ifNull: ["$$matchedKey.name", ""] }
|
|
13485
|
-
]
|
|
13498
|
+
$lookup: {
|
|
13499
|
+
from: "qr-code-templates",
|
|
13500
|
+
localField: "template",
|
|
13501
|
+
foreignField: "_id",
|
|
13502
|
+
pipeline: [
|
|
13503
|
+
{
|
|
13504
|
+
$project: {
|
|
13505
|
+
_id: 1,
|
|
13506
|
+
prefixPass: 1,
|
|
13507
|
+
name: 1
|
|
13486
13508
|
}
|
|
13487
13509
|
}
|
|
13488
|
-
|
|
13510
|
+
],
|
|
13511
|
+
as: "template"
|
|
13489
13512
|
}
|
|
13490
|
-
}
|
|
13491
|
-
}
|
|
13492
|
-
}
|
|
13493
|
-
},
|
|
13494
|
-
{
|
|
13495
|
-
$project: {
|
|
13496
|
-
visitorPassDetails: 0
|
|
13497
|
-
}
|
|
13498
|
-
},
|
|
13499
|
-
{
|
|
13500
|
-
$lookup: {
|
|
13501
|
-
from: "keys",
|
|
13502
|
-
localField: "passKeys.keyId",
|
|
13503
|
-
foreignField: "_id",
|
|
13504
|
-
pipeline: [
|
|
13513
|
+
},
|
|
13505
13514
|
{
|
|
13506
13515
|
$project: {
|
|
13507
|
-
_id:
|
|
13508
|
-
|
|
13509
|
-
|
|
13516
|
+
_id: 0,
|
|
13517
|
+
keyId: "$_id",
|
|
13518
|
+
status: 1,
|
|
13510
13519
|
description: 1,
|
|
13511
|
-
|
|
13512
|
-
|
|
13513
|
-
|
|
13514
|
-
|
|
13515
|
-
|
|
13516
|
-
|
|
13517
|
-
|
|
13518
|
-
|
|
13519
|
-
|
|
13520
|
-
$addFields: {
|
|
13521
|
-
passKeys: {
|
|
13522
|
-
$map: {
|
|
13523
|
-
input: "$passKeys",
|
|
13524
|
-
as: "pk",
|
|
13525
|
-
in: {
|
|
13526
|
-
$let: {
|
|
13527
|
-
vars: {
|
|
13528
|
-
matchedKey: {
|
|
13529
|
-
$arrayElemAt: [
|
|
13530
|
-
{
|
|
13531
|
-
$filter: {
|
|
13532
|
-
input: "$passKeysDetails",
|
|
13533
|
-
as: "kd",
|
|
13534
|
-
cond: { $eq: ["$$kd._id", "$$pk.keyId"] }
|
|
13535
|
-
}
|
|
13536
|
-
},
|
|
13537
|
-
0
|
|
13538
|
-
]
|
|
13539
|
-
}
|
|
13540
|
-
},
|
|
13541
|
-
in: {
|
|
13542
|
-
keyId: "$$pk.keyId",
|
|
13543
|
-
receivedDate: "$$pk.receivedDate",
|
|
13544
|
-
status: "$$pk.status",
|
|
13545
|
-
lastUpdate: {
|
|
13546
|
-
$max: [
|
|
13547
|
-
"$$matchedKey.createdAt",
|
|
13548
|
-
"$$matchedKey.updatedAt"
|
|
13520
|
+
templatePrefixPass: {
|
|
13521
|
+
$arrayElemAt: ["$template.prefixPass", 0]
|
|
13522
|
+
},
|
|
13523
|
+
prefixAndName: {
|
|
13524
|
+
$concat: [
|
|
13525
|
+
{
|
|
13526
|
+
$ifNull: [
|
|
13527
|
+
{ $arrayElemAt: ["$template.prefixPass", 0] },
|
|
13528
|
+
""
|
|
13549
13529
|
]
|
|
13550
13530
|
},
|
|
13551
|
-
|
|
13552
|
-
|
|
13553
|
-
prefixAndName: {
|
|
13554
|
-
$concat: [
|
|
13555
|
-
{ $ifNull: ["$$matchedKey.prefix", ""] },
|
|
13556
|
-
{ $ifNull: ["$$matchedKey.name", ""] }
|
|
13557
|
-
]
|
|
13558
|
-
}
|
|
13559
|
-
}
|
|
13531
|
+
{ $ifNull: ["$name", ""] }
|
|
13532
|
+
]
|
|
13560
13533
|
}
|
|
13561
13534
|
}
|
|
13562
13535
|
}
|
|
13563
|
-
|
|
13564
|
-
|
|
13565
|
-
},
|
|
13566
|
-
{
|
|
13567
|
-
$project: {
|
|
13568
|
-
passKeysDetails: 0
|
|
13536
|
+
],
|
|
13537
|
+
as: "passKeys"
|
|
13569
13538
|
}
|
|
13570
13539
|
},
|
|
13571
13540
|
{ $sort: sort },
|
|
@@ -21674,6 +21643,7 @@ function useVisitorTransactionService() {
|
|
|
21674
21643
|
getExpiredCheckedOutTransactionsBySite: _getExpiredCheckedOutTransactionsBySite,
|
|
21675
21644
|
updateManyDahuaSyncStatus: _updateManyDahuaSyncStatus
|
|
21676
21645
|
} = useVisitorTransactionRepo();
|
|
21646
|
+
const { getById } = useBuildingUnitRepo();
|
|
21677
21647
|
const {
|
|
21678
21648
|
add: _addPerson,
|
|
21679
21649
|
getByNRIC,
|
|
@@ -22072,6 +22042,7 @@ function useVisitorTransactionService() {
|
|
|
22072
22042
|
try {
|
|
22073
22043
|
session.startTransaction();
|
|
22074
22044
|
const inviter = await _getByUserId(userId);
|
|
22045
|
+
const unit = await getById(inviter?.unit);
|
|
22075
22046
|
value.checkIn = null;
|
|
22076
22047
|
const dir = __dirname;
|
|
22077
22048
|
const filePath = getDirectory2(dir, "./public/handlebars/visitor-invite");
|
|
@@ -22080,9 +22051,11 @@ function useVisitorTransactionService() {
|
|
|
22080
22051
|
block: inviter?.block,
|
|
22081
22052
|
level: inviter?.level,
|
|
22082
22053
|
unit: inviter?.unit,
|
|
22054
|
+
unitName: unit?.name,
|
|
22083
22055
|
org: inviter?.org.toString(),
|
|
22084
22056
|
site: inviter?.site.toString(),
|
|
22085
|
-
status: "pending" /* PENDING
|
|
22057
|
+
status: "pending" /* PENDING */,
|
|
22058
|
+
invitedId: inviter?._id
|
|
22086
22059
|
};
|
|
22087
22060
|
const result = await _add(payload);
|
|
22088
22061
|
const emailContent = compileHandlebar2({
|
|
@@ -22305,7 +22278,7 @@ function useVisitorTransactionController() {
|
|
|
22305
22278
|
arrivalTime: Joi55.string().pattern(/^([01]\d|2[0-3]):([0-5]\d)$/).optional().allow(null, "").messages({
|
|
22306
22279
|
"string.pattern.base": "arrivalTime must be in HH:mm format (e.g. 09:30, 18:45)"
|
|
22307
22280
|
}),
|
|
22308
|
-
duration: Joi55.number().integer().optional().allow(null),
|
|
22281
|
+
duration: Joi55.number().integer().optional().allow(null, ""),
|
|
22309
22282
|
name: Joi55.string().required(),
|
|
22310
22283
|
contact: Joi55.string().required(),
|
|
22311
22284
|
email: Joi55.string().email().required(),
|
|
@@ -22328,8 +22301,8 @@ function useVisitorTransactionController() {
|
|
|
22328
22301
|
const { expectedCheckIn, arrivalTime, duration, name, contact, email, plateNumber, isOvernightParking, numberOfPassengers, purpose, inviterUserId } = value;
|
|
22329
22302
|
const rest = { expectedCheckIn, arrivalTime, duration, name, contact, email, plateNumber, isOvernightParking, numberOfPassengers, purpose };
|
|
22330
22303
|
try {
|
|
22331
|
-
await _inviteVisitor(rest, inviterUserId);
|
|
22332
|
-
res.status(200).json({
|
|
22304
|
+
const result = await _inviteVisitor(rest, inviterUserId);
|
|
22305
|
+
res.status(200).json({ insertedId: result });
|
|
22333
22306
|
return;
|
|
22334
22307
|
} catch (error2) {
|
|
22335
22308
|
logger78.log({ level: "error", message: error2.message });
|
|
@@ -36863,6 +36836,81 @@ function useStatementOfAccountRepo() {
|
|
|
36863
36836
|
throw new InternalServerError50("Failed to update soa request.");
|
|
36864
36837
|
}
|
|
36865
36838
|
}
|
|
36839
|
+
async function getResidentUserSoa({
|
|
36840
|
+
search = "",
|
|
36841
|
+
page = 1,
|
|
36842
|
+
limit = 10,
|
|
36843
|
+
sort = {},
|
|
36844
|
+
status = "pending",
|
|
36845
|
+
site = "",
|
|
36846
|
+
dateFrom,
|
|
36847
|
+
dateTo,
|
|
36848
|
+
unitId,
|
|
36849
|
+
category
|
|
36850
|
+
}, session) {
|
|
36851
|
+
page = page > 0 ? page - 1 : 0;
|
|
36852
|
+
let dateExpr = {};
|
|
36853
|
+
if (dateFrom && dateTo) {
|
|
36854
|
+
let startDate = new Date(dateFrom);
|
|
36855
|
+
startDate.setHours(0, 0, 0, 0);
|
|
36856
|
+
let endDate = new Date(dateTo);
|
|
36857
|
+
endDate.setHours(23, 59, 59, 999);
|
|
36858
|
+
dateExpr = {
|
|
36859
|
+
$expr: {
|
|
36860
|
+
$and: [
|
|
36861
|
+
{ $gte: ["$createdAt", startDate] },
|
|
36862
|
+
{ $lte: ["$createdAt", endDate] }
|
|
36863
|
+
]
|
|
36864
|
+
}
|
|
36865
|
+
};
|
|
36866
|
+
}
|
|
36867
|
+
const unitSearchRegex = search ? search.trim().replace(/\s+/g, "").replace(/\//g, "\\s*/\\s*") : null;
|
|
36868
|
+
const query = {
|
|
36869
|
+
...status && status !== "all" && { status },
|
|
36870
|
+
...search && {
|
|
36871
|
+
$or: [
|
|
36872
|
+
{ unitOwner: { $regex: search, $options: "i" } },
|
|
36873
|
+
{ unit: { $regex: unitSearchRegex, $options: "i" } },
|
|
36874
|
+
{ email: { $regex: search, $options: "i" } },
|
|
36875
|
+
{ category: { $regex: search, $options: "i" } }
|
|
36876
|
+
]
|
|
36877
|
+
},
|
|
36878
|
+
...ObjectId97.isValid(site) && { site: new ObjectId97(site) },
|
|
36879
|
+
...dateExpr,
|
|
36880
|
+
...ObjectId97.isValid(unitId) && { unitId: new ObjectId97(unitId) },
|
|
36881
|
+
...category && { category }
|
|
36882
|
+
};
|
|
36883
|
+
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
36884
|
+
try {
|
|
36885
|
+
const basePipeline = [
|
|
36886
|
+
{ $match: query },
|
|
36887
|
+
{
|
|
36888
|
+
$addFields: {
|
|
36889
|
+
sortPriority: {
|
|
36890
|
+
$cond: [{ $eq: ["$status", "pending"] }, 1, 2]
|
|
36891
|
+
}
|
|
36892
|
+
}
|
|
36893
|
+
},
|
|
36894
|
+
{
|
|
36895
|
+
$sort: {
|
|
36896
|
+
sortPriority: 1,
|
|
36897
|
+
...sort
|
|
36898
|
+
}
|
|
36899
|
+
},
|
|
36900
|
+
{ $skip: page * limit },
|
|
36901
|
+
{ $limit: limit }
|
|
36902
|
+
];
|
|
36903
|
+
const [items, countResult] = await Promise.all([
|
|
36904
|
+
collection.aggregate(basePipeline, { session }).toArray(),
|
|
36905
|
+
collection.aggregate([{ $match: query }, { $count: "total" }], { session }).toArray()
|
|
36906
|
+
]);
|
|
36907
|
+
const totalCount = countResult[0]?.total || 0;
|
|
36908
|
+
const data = paginate42(items, page, limit, totalCount);
|
|
36909
|
+
return data;
|
|
36910
|
+
} catch (error) {
|
|
36911
|
+
throw error;
|
|
36912
|
+
}
|
|
36913
|
+
}
|
|
36866
36914
|
function delCachedData() {
|
|
36867
36915
|
delNamespace().then(() => {
|
|
36868
36916
|
logger128.log({
|
|
@@ -36883,7 +36931,8 @@ function useStatementOfAccountRepo() {
|
|
|
36883
36931
|
getById,
|
|
36884
36932
|
updateById,
|
|
36885
36933
|
deleteById,
|
|
36886
|
-
updateStatusById
|
|
36934
|
+
updateStatusById,
|
|
36935
|
+
getResidentUserSoa
|
|
36887
36936
|
};
|
|
36888
36937
|
}
|
|
36889
36938
|
|
|
@@ -37040,7 +37089,8 @@ function useStatementOfAccountController() {
|
|
|
37040
37089
|
getById: _getById,
|
|
37041
37090
|
updateById: _updateById,
|
|
37042
37091
|
deleteById: _deleteById,
|
|
37043
|
-
updateStatusById: _updateStatusById
|
|
37092
|
+
updateStatusById: _updateStatusById,
|
|
37093
|
+
getResidentUserSoa: _getResidentUserSoa
|
|
37044
37094
|
} = useStatementOfAccountRepo();
|
|
37045
37095
|
const { add: _add, generatePDF: _generatePDF } = useStatementOfAccountService();
|
|
37046
37096
|
async function add(req, res, next) {
|
|
@@ -37291,6 +37341,57 @@ function useStatementOfAccountController() {
|
|
|
37291
37341
|
return;
|
|
37292
37342
|
}
|
|
37293
37343
|
}
|
|
37344
|
+
async function getResidentUserSoa(req, res, next) {
|
|
37345
|
+
const validation = Joi93.object({
|
|
37346
|
+
page: Joi93.number().integer().min(1).allow("", null).default(1),
|
|
37347
|
+
limit: Joi93.number().integer().min(1).max(100).allow("", null).default(10),
|
|
37348
|
+
status: Joi93.string().optional().allow(null, ""),
|
|
37349
|
+
search: Joi93.string().optional().allow(null, ""),
|
|
37350
|
+
site: Joi93.string().required(),
|
|
37351
|
+
dateFrom: Joi93.string().optional().allow(null, ""),
|
|
37352
|
+
dateTo: Joi93.string().optional().allow(null, ""),
|
|
37353
|
+
unitId: Joi93.string().required(),
|
|
37354
|
+
category: Joi93.string().optional().allow(null, "")
|
|
37355
|
+
});
|
|
37356
|
+
const query = { ...req.query };
|
|
37357
|
+
const { error } = validation.validate(query, {
|
|
37358
|
+
abortEarly: false
|
|
37359
|
+
});
|
|
37360
|
+
if (error) {
|
|
37361
|
+
const messages = error.details.map((d) => d.message).join(", ");
|
|
37362
|
+
logger130.log({ level: "error", message: messages });
|
|
37363
|
+
next(new BadRequestError153(messages));
|
|
37364
|
+
return;
|
|
37365
|
+
}
|
|
37366
|
+
const search = req.query.search ?? "";
|
|
37367
|
+
const page = parseInt(req.query.page ?? "1");
|
|
37368
|
+
const limit = parseInt(req.query.limit ?? "10");
|
|
37369
|
+
const status = req.query.status ?? "active";
|
|
37370
|
+
const site = req.query.site;
|
|
37371
|
+
const dateFrom = req.query.dateFrom ?? "";
|
|
37372
|
+
const dateTo = req.query.dateTo ?? "";
|
|
37373
|
+
const unitId = req.query.unitId;
|
|
37374
|
+
const category = req.query.category ?? "";
|
|
37375
|
+
try {
|
|
37376
|
+
const data = await _getResidentUserSoa({
|
|
37377
|
+
search,
|
|
37378
|
+
page,
|
|
37379
|
+
limit,
|
|
37380
|
+
status,
|
|
37381
|
+
site,
|
|
37382
|
+
dateFrom,
|
|
37383
|
+
dateTo,
|
|
37384
|
+
unitId,
|
|
37385
|
+
category
|
|
37386
|
+
});
|
|
37387
|
+
res.status(200).json(data);
|
|
37388
|
+
return;
|
|
37389
|
+
} catch (error2) {
|
|
37390
|
+
logger130.log({ level: "error", message: error2.message });
|
|
37391
|
+
next(error2);
|
|
37392
|
+
return;
|
|
37393
|
+
}
|
|
37394
|
+
}
|
|
37294
37395
|
return {
|
|
37295
37396
|
add,
|
|
37296
37397
|
getAll,
|
|
@@ -37298,7 +37399,8 @@ function useStatementOfAccountController() {
|
|
|
37298
37399
|
updateById,
|
|
37299
37400
|
deleteById,
|
|
37300
37401
|
generatePDF,
|
|
37301
|
-
updateStatusById
|
|
37402
|
+
updateStatusById,
|
|
37403
|
+
getResidentUserSoa
|
|
37302
37404
|
};
|
|
37303
37405
|
}
|
|
37304
37406
|
|
|
@@ -40071,6 +40173,7 @@ function useNfcPatrolSettingsController() {
|
|
|
40071
40173
|
|
|
40072
40174
|
// src/services/occurrence-entry.service.ts
|
|
40073
40175
|
import { useAtlas as useAtlas93 } from "@7365admin1/node-server-utils";
|
|
40176
|
+
import { ObjectId as ObjectId108 } from "mongodb";
|
|
40074
40177
|
|
|
40075
40178
|
// src/repositories/occurrence-subject.repo.ts
|
|
40076
40179
|
import {
|
|
@@ -40288,22 +40391,11 @@ function useOccurrenceSubjectRepo() {
|
|
|
40288
40391
|
} catch (error) {
|
|
40289
40392
|
throw new BadRequestError169("Invalid occurrence subject ID format.");
|
|
40290
40393
|
}
|
|
40291
|
-
const cacheKey = makeCacheKey54(namespace_collection, { _id });
|
|
40292
|
-
const cachedData = await getCache(cacheKey);
|
|
40293
|
-
if (cachedData) {
|
|
40294
|
-
logger146.info(`Cache hit for key: ${cacheKey}`);
|
|
40295
|
-
return cachedData;
|
|
40296
|
-
}
|
|
40297
40394
|
try {
|
|
40298
40395
|
const data = await collection.findOne({ _id }, { session });
|
|
40299
40396
|
if (!data) {
|
|
40300
40397
|
throw new NotFoundError46("Occurrence subject not found.");
|
|
40301
40398
|
}
|
|
40302
|
-
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
40303
|
-
logger146.info(`Cache set for key: ${cacheKey}`);
|
|
40304
|
-
}).catch((err) => {
|
|
40305
|
-
logger146.error(`Failed to set cache for key: ${cacheKey}`, err);
|
|
40306
|
-
});
|
|
40307
40399
|
return data;
|
|
40308
40400
|
} catch (error) {
|
|
40309
40401
|
throw error;
|
|
@@ -40444,11 +40536,22 @@ function useOccurrenceEntryService() {
|
|
|
40444
40536
|
const updatedSerialNumber = (entrySerialNumber + 0.1).toFixed(1);
|
|
40445
40537
|
const dobId = occurrenceEntry.dailyOccurrenceBookId;
|
|
40446
40538
|
const book = await _getOccurrenceBookById(dobId);
|
|
40447
|
-
const subject = await _getOccurrenceSubjectById(
|
|
40539
|
+
const subject = await _getOccurrenceSubjectById(
|
|
40540
|
+
occurrenceEntry.subject._id
|
|
40541
|
+
);
|
|
40542
|
+
value.subject = value.subject ? value.subject : occurrenceEntry.subject._id;
|
|
40543
|
+
value.subjectName = subject.subject;
|
|
40448
40544
|
value.serialNumber = updatedSerialNumber;
|
|
40449
40545
|
value.site = occurrenceEntry.site;
|
|
40450
40546
|
value.dailyOccurrenceBookId = occurrenceEntry.dailyOccurrenceBookId;
|
|
40451
|
-
value.
|
|
40547
|
+
value.bookEntryCount = value.bookEntryCount ? value.bookEntryCount : occurrenceEntry.bookEntryCount;
|
|
40548
|
+
value.occurrence = value.occurrence ? value.occurrence : occurrenceEntry.occurrence;
|
|
40549
|
+
value.signature = value.signature ? new ObjectId108(value.signature) : occurrenceEntry.signature._id;
|
|
40550
|
+
value.eSignature = value.eSignature ? new ObjectId108(value.eSignature) : occurrenceEntry.eSignature;
|
|
40551
|
+
value.createdAt = /* @__PURE__ */ new Date();
|
|
40552
|
+
value.date = value.date ? value.date : occurrenceEntry.date;
|
|
40553
|
+
value.userName = value.userName ? value.userName : occurrenceEntry.signature.name;
|
|
40554
|
+
value.createdByName = value.createdByName ? value.createdByName : occurrenceEntry.createdByName;
|
|
40452
40555
|
await _updateOccurrenceBookById(dobId, {
|
|
40453
40556
|
totalInput: book.totalInput + 1
|
|
40454
40557
|
});
|
|
@@ -40644,7 +40747,7 @@ function useOccurrenceEntryController() {
|
|
|
40644
40747
|
|
|
40645
40748
|
// src/models/online-form.model.ts
|
|
40646
40749
|
import Joi105 from "joi";
|
|
40647
|
-
import { ObjectId as
|
|
40750
|
+
import { ObjectId as ObjectId109 } from "mongodb";
|
|
40648
40751
|
var schemaOnlineForm = Joi105.object({
|
|
40649
40752
|
_id: Joi105.string().hex().optional().allow("", null),
|
|
40650
40753
|
name: Joi105.string().required(),
|
|
@@ -40692,21 +40795,21 @@ function MOnlineForm(value) {
|
|
|
40692
40795
|
}
|
|
40693
40796
|
if (value._id && typeof value._id === "string") {
|
|
40694
40797
|
try {
|
|
40695
|
-
value._id = new
|
|
40798
|
+
value._id = new ObjectId109(value._id);
|
|
40696
40799
|
} catch (error2) {
|
|
40697
40800
|
throw new Error("Invalid ID.");
|
|
40698
40801
|
}
|
|
40699
40802
|
}
|
|
40700
40803
|
if (value.org && typeof value.org === "string") {
|
|
40701
40804
|
try {
|
|
40702
|
-
value.org = new
|
|
40805
|
+
value.org = new ObjectId109(value.org);
|
|
40703
40806
|
} catch (error2) {
|
|
40704
40807
|
throw new Error("Invalid org ID.");
|
|
40705
40808
|
}
|
|
40706
40809
|
}
|
|
40707
40810
|
if (value.site && typeof value.site === "string") {
|
|
40708
40811
|
try {
|
|
40709
|
-
value.site = new
|
|
40812
|
+
value.site = new ObjectId109(value.site);
|
|
40710
40813
|
} catch (error2) {
|
|
40711
40814
|
throw new Error("Invalid site ID.");
|
|
40712
40815
|
}
|
|
@@ -40738,7 +40841,7 @@ import {
|
|
|
40738
40841
|
useAtlas as useAtlas94,
|
|
40739
40842
|
useCache as useCache57
|
|
40740
40843
|
} from "@7365admin1/node-server-utils";
|
|
40741
|
-
import { ObjectId as
|
|
40844
|
+
import { ObjectId as ObjectId110 } from "mongodb";
|
|
40742
40845
|
function useOnlineFormRepo() {
|
|
40743
40846
|
const db = useAtlas94.getDb();
|
|
40744
40847
|
if (!db) {
|
|
@@ -40790,7 +40893,7 @@ function useOnlineFormRepo() {
|
|
|
40790
40893
|
}) {
|
|
40791
40894
|
page = page > 0 ? page - 1 : 0;
|
|
40792
40895
|
try {
|
|
40793
|
-
site = new
|
|
40896
|
+
site = new ObjectId110(site);
|
|
40794
40897
|
} catch (error) {
|
|
40795
40898
|
throw new BadRequestError171("Invalid site ID format.");
|
|
40796
40899
|
}
|
|
@@ -40850,7 +40953,7 @@ function useOnlineFormRepo() {
|
|
|
40850
40953
|
}
|
|
40851
40954
|
async function getOnlineFormById(_id) {
|
|
40852
40955
|
try {
|
|
40853
|
-
_id = new
|
|
40956
|
+
_id = new ObjectId110(_id);
|
|
40854
40957
|
} catch (error) {
|
|
40855
40958
|
throw new BadRequestError171("Invalid online form ID format.");
|
|
40856
40959
|
}
|
|
@@ -40893,7 +40996,7 @@ function useOnlineFormRepo() {
|
|
|
40893
40996
|
}
|
|
40894
40997
|
async function updateOnlineFormById(_id, value) {
|
|
40895
40998
|
try {
|
|
40896
|
-
_id = new
|
|
40999
|
+
_id = new ObjectId110(_id);
|
|
40897
41000
|
} catch (error) {
|
|
40898
41001
|
throw new BadRequestError171("Invalid online form ID format.");
|
|
40899
41002
|
}
|
|
@@ -40921,7 +41024,7 @@ function useOnlineFormRepo() {
|
|
|
40921
41024
|
}
|
|
40922
41025
|
async function deleteOnlineFormById(_id, session) {
|
|
40923
41026
|
try {
|
|
40924
|
-
_id = new
|
|
41027
|
+
_id = new ObjectId110(_id);
|
|
40925
41028
|
} catch (error) {
|
|
40926
41029
|
throw new BadRequestError171("Invalid online form ID format.");
|
|
40927
41030
|
}
|
|
@@ -40954,7 +41057,7 @@ function useOnlineFormRepo() {
|
|
|
40954
41057
|
}
|
|
40955
41058
|
async function getOnlineFormsBySiteId(site, { search = "", page = 1, limit = 10, status = "active" }) {
|
|
40956
41059
|
try {
|
|
40957
|
-
site = new
|
|
41060
|
+
site = new ObjectId110(site);
|
|
40958
41061
|
} catch (error) {
|
|
40959
41062
|
throw new BadRequestError171(
|
|
40960
41063
|
"Invalid online form configuration site ID format."
|
|
@@ -41395,7 +41498,7 @@ function useOccurrenceSubjectController() {
|
|
|
41395
41498
|
}
|
|
41396
41499
|
|
|
41397
41500
|
// src/models/nfc-patrol-log.model.ts
|
|
41398
|
-
import { ObjectId as
|
|
41501
|
+
import { ObjectId as ObjectId111 } from "mongodb";
|
|
41399
41502
|
import Joi108 from "joi";
|
|
41400
41503
|
import { BadRequestError as BadRequestError174, logger as logger151 } from "@7365admin1/node-server-utils";
|
|
41401
41504
|
var schemaNfcPatrolLog = Joi108.object({
|
|
@@ -41447,32 +41550,32 @@ function MNfcPatrolLog(valueArg) {
|
|
|
41447
41550
|
}
|
|
41448
41551
|
if (value._id && typeof value._id === "string") {
|
|
41449
41552
|
try {
|
|
41450
|
-
value._id = new
|
|
41553
|
+
value._id = new ObjectId111(value._id);
|
|
41451
41554
|
} catch (error2) {
|
|
41452
41555
|
throw new BadRequestError174("Invalid _id format");
|
|
41453
41556
|
}
|
|
41454
41557
|
}
|
|
41455
41558
|
try {
|
|
41456
|
-
value.site = new
|
|
41559
|
+
value.site = new ObjectId111(value.site);
|
|
41457
41560
|
} catch (error2) {
|
|
41458
41561
|
throw new BadRequestError174("Invalid site format");
|
|
41459
41562
|
}
|
|
41460
41563
|
if (value?.createdBy) {
|
|
41461
41564
|
try {
|
|
41462
|
-
value.createdBy = new
|
|
41565
|
+
value.createdBy = new ObjectId111(value.createdBy);
|
|
41463
41566
|
} catch (error2) {
|
|
41464
41567
|
throw new BadRequestError174("Invalid createdBy format");
|
|
41465
41568
|
}
|
|
41466
41569
|
}
|
|
41467
41570
|
if (value?.route?._id) {
|
|
41468
41571
|
try {
|
|
41469
|
-
value.route._id = new
|
|
41572
|
+
value.route._id = new ObjectId111(value.route._id);
|
|
41470
41573
|
} catch (error2) {
|
|
41471
41574
|
throw new BadRequestError174("Invalid route _id format");
|
|
41472
41575
|
}
|
|
41473
41576
|
}
|
|
41474
41577
|
return {
|
|
41475
|
-
_id: value._id ?? new
|
|
41578
|
+
_id: value._id ?? new ObjectId111(),
|
|
41476
41579
|
site: value.site,
|
|
41477
41580
|
route: value.route,
|
|
41478
41581
|
date: value.date,
|
|
@@ -41494,7 +41597,7 @@ import {
|
|
|
41494
41597
|
useAtlas as useAtlas96,
|
|
41495
41598
|
useCache as useCache58
|
|
41496
41599
|
} from "@7365admin1/node-server-utils";
|
|
41497
|
-
import { ObjectId as
|
|
41600
|
+
import { ObjectId as ObjectId112 } from "mongodb";
|
|
41498
41601
|
function useNfcPatrolLogRepo() {
|
|
41499
41602
|
const db = useAtlas96.getDb();
|
|
41500
41603
|
if (!db) {
|
|
@@ -41547,7 +41650,7 @@ function useNfcPatrolLogRepo() {
|
|
|
41547
41650
|
const pageIndex = page > 0 ? page - 1 : 0;
|
|
41548
41651
|
let siteId;
|
|
41549
41652
|
try {
|
|
41550
|
-
siteId = typeof site === "string" ? new
|
|
41653
|
+
siteId = typeof site === "string" ? new ObjectId112(site) : site;
|
|
41551
41654
|
} catch {
|
|
41552
41655
|
throw new BadRequestError175("Invalid site ID format.");
|
|
41553
41656
|
}
|
|
@@ -41558,7 +41661,7 @@ function useNfcPatrolLogRepo() {
|
|
|
41558
41661
|
query.date = date;
|
|
41559
41662
|
}
|
|
41560
41663
|
if (route?._id) {
|
|
41561
|
-
query["route._id"] = typeof route._id === "string" ? new
|
|
41664
|
+
query["route._id"] = typeof route._id === "string" ? new ObjectId112(route._id) : route._id;
|
|
41562
41665
|
}
|
|
41563
41666
|
if (route?.startTime) {
|
|
41564
41667
|
query["route.startTime"] = route.startTime;
|
|
@@ -42430,7 +42533,7 @@ function useNewDashboardController() {
|
|
|
42430
42533
|
|
|
42431
42534
|
// src/models/manpower-monitoring.model.ts
|
|
42432
42535
|
import Joi111 from "joi";
|
|
42433
|
-
import { ObjectId as
|
|
42536
|
+
import { ObjectId as ObjectId113 } from "mongodb";
|
|
42434
42537
|
var shiftSchema = Joi111.object({
|
|
42435
42538
|
name: Joi111.string().required(),
|
|
42436
42539
|
checkIn: Joi111.string().optional().allow("", null),
|
|
@@ -42455,7 +42558,7 @@ var manpowerMonitoringSchema = Joi111.object({
|
|
|
42455
42558
|
});
|
|
42456
42559
|
var MManpowerMonitoring = class {
|
|
42457
42560
|
constructor(data) {
|
|
42458
|
-
this._id = new
|
|
42561
|
+
this._id = new ObjectId113();
|
|
42459
42562
|
this.serviceProviderId = data.serviceProviderId || "";
|
|
42460
42563
|
this.siteId = data.siteId || "";
|
|
42461
42564
|
this.siteName = data.siteName;
|
|
@@ -42925,7 +43028,7 @@ var hrmlabs_attendance_util_default = {
|
|
|
42925
43028
|
};
|
|
42926
43029
|
|
|
42927
43030
|
// src/repositories/manpower-monitoring.repo.ts
|
|
42928
|
-
import { ObjectId as
|
|
43031
|
+
import { ObjectId as ObjectId114 } from "mongodb";
|
|
42929
43032
|
var { hrmLabsAuthentication: hrmLabsAuthentication2, fetchSites: fetchSites2 } = hrmlabs_attendance_util_default;
|
|
42930
43033
|
function useManpowerMonitoringRepo() {
|
|
42931
43034
|
const db = useAtlas99.getDb();
|
|
@@ -42939,11 +43042,11 @@ function useManpowerMonitoringRepo() {
|
|
|
42939
43042
|
try {
|
|
42940
43043
|
value = new MManpowerMonitoring(value);
|
|
42941
43044
|
if (value.createdBy)
|
|
42942
|
-
value.createdBy = new
|
|
43045
|
+
value.createdBy = new ObjectId114(value.createdBy);
|
|
42943
43046
|
if (value.siteId)
|
|
42944
|
-
value.siteId = new
|
|
43047
|
+
value.siteId = new ObjectId114(value.siteId);
|
|
42945
43048
|
if (value.serviceProviderId)
|
|
42946
|
-
value.serviceProviderId = new
|
|
43049
|
+
value.serviceProviderId = new ObjectId114(value.serviceProviderId);
|
|
42947
43050
|
const result = await collection.insertOne(value, { session });
|
|
42948
43051
|
return result;
|
|
42949
43052
|
} catch (error) {
|
|
@@ -42984,8 +43087,8 @@ function useManpowerMonitoringRepo() {
|
|
|
42984
43087
|
}
|
|
42985
43088
|
async function getManpowerSettingsBySiteId(_id, serviceProviderId) {
|
|
42986
43089
|
try {
|
|
42987
|
-
_id = new
|
|
42988
|
-
serviceProviderId = new
|
|
43090
|
+
_id = new ObjectId114(_id);
|
|
43091
|
+
serviceProviderId = new ObjectId114(serviceProviderId);
|
|
42989
43092
|
} catch (error) {
|
|
42990
43093
|
throw new Error("Invalid Site ID format.");
|
|
42991
43094
|
}
|
|
@@ -43001,7 +43104,7 @@ function useManpowerMonitoringRepo() {
|
|
|
43001
43104
|
}
|
|
43002
43105
|
async function updateManpowerMonitoringSettings(_id, value) {
|
|
43003
43106
|
try {
|
|
43004
|
-
_id = new
|
|
43107
|
+
_id = new ObjectId114(_id);
|
|
43005
43108
|
} catch (error) {
|
|
43006
43109
|
throw new BadRequestError180("Invalid ID format.");
|
|
43007
43110
|
}
|
|
@@ -43028,7 +43131,7 @@ function useManpowerMonitoringRepo() {
|
|
|
43028
43131
|
for (let item of value) {
|
|
43029
43132
|
item = new MManpowerMonitoring(item);
|
|
43030
43133
|
const data = await collection.findOne({
|
|
43031
|
-
siteId: new
|
|
43134
|
+
siteId: new ObjectId114(item.siteId)
|
|
43032
43135
|
});
|
|
43033
43136
|
if (data) {
|
|
43034
43137
|
let updateValue;
|
|
@@ -43053,11 +43156,11 @@ function useManpowerMonitoringRepo() {
|
|
|
43053
43156
|
}
|
|
43054
43157
|
} else {
|
|
43055
43158
|
if (item.createdBy)
|
|
43056
|
-
item.createdBy = new
|
|
43159
|
+
item.createdBy = new ObjectId114(item.createdBy);
|
|
43057
43160
|
if (item.siteId)
|
|
43058
|
-
item.siteId = new
|
|
43161
|
+
item.siteId = new ObjectId114(item.siteId);
|
|
43059
43162
|
if (item.serviceProviderId)
|
|
43060
|
-
item.serviceProviderId = new
|
|
43163
|
+
item.serviceProviderId = new ObjectId114(item.serviceProviderId);
|
|
43061
43164
|
const result = await collection.insertOne(item);
|
|
43062
43165
|
if (result.insertedId) {
|
|
43063
43166
|
results.inserted++;
|
|
@@ -43081,7 +43184,7 @@ function useManpowerMonitoringRepo() {
|
|
|
43081
43184
|
const siteUrl = process.env.HRMLABS_SITE_URL;
|
|
43082
43185
|
try {
|
|
43083
43186
|
const serviceProvider = await serviceProviderCollection.findOne({
|
|
43084
|
-
_id: new
|
|
43187
|
+
_id: new ObjectId114(serviceProviderId)
|
|
43085
43188
|
});
|
|
43086
43189
|
if (!serviceProvider) {
|
|
43087
43190
|
throw new Error("Service Provider not found.");
|
|
@@ -43131,7 +43234,7 @@ import {
|
|
|
43131
43234
|
|
|
43132
43235
|
// src/models/manpower-remarks.model.ts
|
|
43133
43236
|
import Joi112 from "joi";
|
|
43134
|
-
import { ObjectId as
|
|
43237
|
+
import { ObjectId as ObjectId115 } from "mongodb";
|
|
43135
43238
|
var remarksSchema = Joi112.object({
|
|
43136
43239
|
name: Joi112.string().required(),
|
|
43137
43240
|
remark: Joi112.object({
|
|
@@ -43155,7 +43258,7 @@ var manpowerRemarksSchema = Joi112.object({
|
|
|
43155
43258
|
});
|
|
43156
43259
|
var MManpowerRemarks = class {
|
|
43157
43260
|
constructor(data) {
|
|
43158
|
-
this._id = new
|
|
43261
|
+
this._id = new ObjectId115();
|
|
43159
43262
|
this.serviceProviderId = data.serviceProviderId || "";
|
|
43160
43263
|
this.siteId = data.siteId || "";
|
|
43161
43264
|
this.siteName = data.siteName || "";
|
|
@@ -43173,7 +43276,7 @@ var MManpowerRemarks = class {
|
|
|
43173
43276
|
};
|
|
43174
43277
|
|
|
43175
43278
|
// src/repositories/manpower-remarks.repo.ts
|
|
43176
|
-
import { ObjectId as
|
|
43279
|
+
import { ObjectId as ObjectId116 } from "mongodb";
|
|
43177
43280
|
import moment2 from "moment-timezone";
|
|
43178
43281
|
function useManpowerRemarksRepo() {
|
|
43179
43282
|
const db = useAtlas100.getDb();
|
|
@@ -43186,9 +43289,9 @@ function useManpowerRemarksRepo() {
|
|
|
43186
43289
|
try {
|
|
43187
43290
|
value = new MManpowerRemarks(value);
|
|
43188
43291
|
if (value.siteId)
|
|
43189
|
-
value.siteId = new
|
|
43292
|
+
value.siteId = new ObjectId116(value.siteId);
|
|
43190
43293
|
if (value.serviceProviderId)
|
|
43191
|
-
value.serviceProviderId = new
|
|
43294
|
+
value.serviceProviderId = new ObjectId116(value.serviceProviderId);
|
|
43192
43295
|
const result = await collection.insertOne(value, { session });
|
|
43193
43296
|
return result;
|
|
43194
43297
|
} catch (error) {
|
|
@@ -43208,7 +43311,7 @@ function useManpowerRemarksRepo() {
|
|
|
43208
43311
|
limit = limit || 10;
|
|
43209
43312
|
const searchQuery = {};
|
|
43210
43313
|
const nowSGT = moment2().tz("Asia/Singapore");
|
|
43211
|
-
searchQuery.serviceProviderId = new
|
|
43314
|
+
searchQuery.serviceProviderId = new ObjectId116(serviceProviderId);
|
|
43212
43315
|
if (search != "") {
|
|
43213
43316
|
searchQuery.siteName = { $regex: search, $options: "i" };
|
|
43214
43317
|
}
|
|
@@ -43240,8 +43343,8 @@ function useManpowerRemarksRepo() {
|
|
|
43240
43343
|
}
|
|
43241
43344
|
async function getManpowerRemarksBySiteId(_id, date, serviceProviderId) {
|
|
43242
43345
|
try {
|
|
43243
|
-
_id = new
|
|
43244
|
-
serviceProviderId = new
|
|
43346
|
+
_id = new ObjectId116(_id);
|
|
43347
|
+
serviceProviderId = new ObjectId116(serviceProviderId);
|
|
43245
43348
|
} catch (error) {
|
|
43246
43349
|
throw new Error("Invalid Site ID format.");
|
|
43247
43350
|
}
|
|
@@ -43258,13 +43361,13 @@ function useManpowerRemarksRepo() {
|
|
|
43258
43361
|
}
|
|
43259
43362
|
async function updateManpowerRemarks(_id, value) {
|
|
43260
43363
|
try {
|
|
43261
|
-
_id = new
|
|
43364
|
+
_id = new ObjectId116(_id);
|
|
43262
43365
|
} catch (error) {
|
|
43263
43366
|
throw new BadRequestError181("Invalid ID format.");
|
|
43264
43367
|
}
|
|
43265
43368
|
try {
|
|
43266
43369
|
if (value.createdBy) {
|
|
43267
|
-
value.createdBy = new
|
|
43370
|
+
value.createdBy = new ObjectId116(value.createdBy);
|
|
43268
43371
|
}
|
|
43269
43372
|
const updateValue = {
|
|
43270
43373
|
...value,
|
|
@@ -43281,7 +43384,7 @@ function useManpowerRemarksRepo() {
|
|
|
43281
43384
|
}
|
|
43282
43385
|
async function updateRemarksStatus(_id, value) {
|
|
43283
43386
|
try {
|
|
43284
|
-
_id = new
|
|
43387
|
+
_id = new ObjectId116(_id);
|
|
43285
43388
|
} catch (error) {
|
|
43286
43389
|
throw new BadRequestError181("Invalid ID format.");
|
|
43287
43390
|
}
|
|
@@ -43553,7 +43656,7 @@ function useManpowerMonitoringCtrl() {
|
|
|
43553
43656
|
|
|
43554
43657
|
// src/models/manpower-designations.model.ts
|
|
43555
43658
|
import Joi114 from "joi";
|
|
43556
|
-
import { ObjectId as
|
|
43659
|
+
import { ObjectId as ObjectId117 } from "mongodb";
|
|
43557
43660
|
var designationsSchema = Joi114.object({
|
|
43558
43661
|
title: Joi114.string().required(),
|
|
43559
43662
|
shifts: Joi114.object({
|
|
@@ -43572,7 +43675,7 @@ var manpowerDesignationsSchema = Joi114.object({
|
|
|
43572
43675
|
});
|
|
43573
43676
|
var MManpowerDesignations = class {
|
|
43574
43677
|
constructor(data) {
|
|
43575
|
-
this._id = new
|
|
43678
|
+
this._id = new ObjectId117();
|
|
43576
43679
|
this.siteId = data.siteId || "";
|
|
43577
43680
|
this.siteName = data.siteName || "";
|
|
43578
43681
|
this.serviceProviderId = data.serviceProviderId || "";
|
|
@@ -43588,7 +43691,7 @@ var MManpowerDesignations = class {
|
|
|
43588
43691
|
import {
|
|
43589
43692
|
useAtlas as useAtlas102
|
|
43590
43693
|
} from "@7365admin1/node-server-utils";
|
|
43591
|
-
import { ObjectId as
|
|
43694
|
+
import { ObjectId as ObjectId118 } from "mongodb";
|
|
43592
43695
|
function useManpowerDesignationRepo() {
|
|
43593
43696
|
const db = useAtlas102.getDb();
|
|
43594
43697
|
if (!db) {
|
|
@@ -43600,11 +43703,11 @@ function useManpowerDesignationRepo() {
|
|
|
43600
43703
|
try {
|
|
43601
43704
|
value = new MManpowerDesignations(value);
|
|
43602
43705
|
if (value.createdBy)
|
|
43603
|
-
value.createdBy = new
|
|
43706
|
+
value.createdBy = new ObjectId118(value.createdBy);
|
|
43604
43707
|
if (value.siteId)
|
|
43605
|
-
value.siteId = new
|
|
43708
|
+
value.siteId = new ObjectId118(value.siteId);
|
|
43606
43709
|
if (value.serviceProviderId)
|
|
43607
|
-
value.serviceProviderId = new
|
|
43710
|
+
value.serviceProviderId = new ObjectId118(value.serviceProviderId);
|
|
43608
43711
|
const result = await collection.insertOne(value);
|
|
43609
43712
|
return result;
|
|
43610
43713
|
} catch (error) {
|
|
@@ -43613,8 +43716,8 @@ function useManpowerDesignationRepo() {
|
|
|
43613
43716
|
}
|
|
43614
43717
|
async function getManpowerDesignationsBySiteId(_id, serviceProviderId) {
|
|
43615
43718
|
try {
|
|
43616
|
-
_id = new
|
|
43617
|
-
serviceProviderId = new
|
|
43719
|
+
_id = new ObjectId118(_id);
|
|
43720
|
+
serviceProviderId = new ObjectId118(serviceProviderId);
|
|
43618
43721
|
} catch (error) {
|
|
43619
43722
|
throw new Error("Invalid Site ID format.");
|
|
43620
43723
|
}
|
|
@@ -43630,7 +43733,7 @@ function useManpowerDesignationRepo() {
|
|
|
43630
43733
|
}
|
|
43631
43734
|
async function updateManpowerDesignations(_id, value) {
|
|
43632
43735
|
try {
|
|
43633
|
-
_id = new
|
|
43736
|
+
_id = new ObjectId118(_id);
|
|
43634
43737
|
} catch (error) {
|
|
43635
43738
|
throw new Error("Invalid ID format.");
|
|
43636
43739
|
}
|
|
@@ -43733,7 +43836,7 @@ function useManpowerDesignationCtrl() {
|
|
|
43733
43836
|
|
|
43734
43837
|
// src/models/overnight-parking.model.ts
|
|
43735
43838
|
import Joi116 from "joi";
|
|
43736
|
-
import { ObjectId as
|
|
43839
|
+
import { ObjectId as ObjectId119 } from "mongodb";
|
|
43737
43840
|
var dayScheduleSchema = Joi116.object({
|
|
43738
43841
|
isEnabled: Joi116.boolean().required(),
|
|
43739
43842
|
startTime: Joi116.string().pattern(/^([01]\d|2[0-3]):([0-5]\d)$/).optional().allow(null, "").messages({
|
|
@@ -43775,7 +43878,7 @@ function MOvernightParkingApprovalHours(value) {
|
|
|
43775
43878
|
}
|
|
43776
43879
|
if (value.site && typeof value.site === "string") {
|
|
43777
43880
|
try {
|
|
43778
|
-
value.site = new
|
|
43881
|
+
value.site = new ObjectId119(value.site);
|
|
43779
43882
|
} catch {
|
|
43780
43883
|
throw new Error("Invalid site ID.");
|
|
43781
43884
|
}
|
|
@@ -45399,7 +45502,7 @@ function useManpowerRemarkCtrl() {
|
|
|
45399
45502
|
|
|
45400
45503
|
// src/models/manpower-sites.model.ts
|
|
45401
45504
|
import Joi122 from "joi";
|
|
45402
|
-
import { ObjectId as
|
|
45505
|
+
import { ObjectId as ObjectId120 } from "mongodb";
|
|
45403
45506
|
var manpowerSitesSchema = Joi122.object({
|
|
45404
45507
|
id: Joi122.string().hex().required(),
|
|
45405
45508
|
text: Joi122.string().hex().optional().allow("", null),
|
|
@@ -45410,7 +45513,7 @@ var manpowerSitesSchema = Joi122.object({
|
|
|
45410
45513
|
});
|
|
45411
45514
|
var MManpowerSites = class {
|
|
45412
45515
|
constructor(data) {
|
|
45413
|
-
this._id = new
|
|
45516
|
+
this._id = new ObjectId120();
|
|
45414
45517
|
this.id = data.id || "";
|
|
45415
45518
|
this.text = data.text || "";
|
|
45416
45519
|
this.contractID = data.contractID || "";
|
|
@@ -45632,7 +45735,7 @@ import {
|
|
|
45632
45735
|
getDirectory as getDirectory3,
|
|
45633
45736
|
logger as logger174
|
|
45634
45737
|
} from "@7365admin1/node-server-utils";
|
|
45635
|
-
import { ObjectId as
|
|
45738
|
+
import { ObjectId as ObjectId121 } from "mongodb";
|
|
45636
45739
|
import moment4 from "moment-timezone";
|
|
45637
45740
|
var createManpowerRemarksDaily = async () => {
|
|
45638
45741
|
const db = useAtlas108.getDb();
|
|
@@ -45792,7 +45895,7 @@ var updateRemarksisAcknowledged = async () => {
|
|
|
45792
45895
|
for (const id of updatedIds) {
|
|
45793
45896
|
const doc = await remarks.findOne({ _id: id });
|
|
45794
45897
|
const setting = await settings.findOne(
|
|
45795
|
-
{ siteId: new
|
|
45898
|
+
{ siteId: new ObjectId121(doc?.siteId) },
|
|
45796
45899
|
{ projection: { emails: 1 } }
|
|
45797
45900
|
);
|
|
45798
45901
|
const payload = {
|
|
@@ -45878,7 +45981,7 @@ var updateRemarksStatusEod = async () => {
|
|
|
45878
45981
|
for (const doc of docs) {
|
|
45879
45982
|
let shiftsToCheck = [];
|
|
45880
45983
|
const endShiftTime = await settings.findOne(
|
|
45881
|
-
{ siteId: new
|
|
45984
|
+
{ siteId: new ObjectId121(doc.siteId) },
|
|
45882
45985
|
{ projection: { shifts: 1, shiftType: 1 } }
|
|
45883
45986
|
);
|
|
45884
45987
|
if (doc.createdAtSGT === nowSGT) {
|
|
@@ -45984,7 +46087,7 @@ var isWithinHour = (alertTime, timeNow) => {
|
|
|
45984
46087
|
|
|
45985
46088
|
// src/events/manpower.event.ts
|
|
45986
46089
|
import { useAtlas as useAtlas109 } from "@7365admin1/node-server-utils";
|
|
45987
|
-
import { ObjectId as
|
|
46090
|
+
import { ObjectId as ObjectId122 } from "mongodb";
|
|
45988
46091
|
import moment5 from "moment-timezone";
|
|
45989
46092
|
async function manpowerEvents(io) {
|
|
45990
46093
|
let intervalId = null;
|
|
@@ -46010,7 +46113,7 @@ async function manpowerEvents(io) {
|
|
|
46010
46113
|
}).toArray();
|
|
46011
46114
|
for (const doc of docs) {
|
|
46012
46115
|
const siteSettings = await settings.findOne(
|
|
46013
|
-
{ siteId: new
|
|
46116
|
+
{ siteId: new ObjectId122(doc.siteId), enabled: true },
|
|
46014
46117
|
{ projection: { shifts: 1, shiftType: 1 } }
|
|
46015
46118
|
);
|
|
46016
46119
|
const shiftType = siteSettings?.shiftType || "2-shifts";
|
|
@@ -46129,7 +46232,7 @@ function genericSignature(params, secretKey) {
|
|
|
46129
46232
|
}
|
|
46130
46233
|
|
|
46131
46234
|
// src/repositories/reddot-payment.repository.ts
|
|
46132
|
-
import { ObjectId as
|
|
46235
|
+
import { ObjectId as ObjectId126 } from "mongodb";
|
|
46133
46236
|
|
|
46134
46237
|
// src/utils/date-format.util.ts
|
|
46135
46238
|
import moment6 from "moment-timezone";
|
|
@@ -46154,11 +46257,11 @@ function formatDateString(today, format, dateRange) {
|
|
|
46154
46257
|
}
|
|
46155
46258
|
|
|
46156
46259
|
// src/models/credit-card.model.ts
|
|
46157
|
-
import { ObjectId as
|
|
46260
|
+
import { ObjectId as ObjectId123 } from "mongodb";
|
|
46158
46261
|
var MCardInfo = class {
|
|
46159
46262
|
// this is coming from RDP transaction
|
|
46160
46263
|
constructor({
|
|
46161
|
-
_id = new
|
|
46264
|
+
_id = new ObjectId123(),
|
|
46162
46265
|
userId,
|
|
46163
46266
|
cardType,
|
|
46164
46267
|
cardNumber,
|
|
@@ -46193,11 +46296,11 @@ var MCardInfo = class {
|
|
|
46193
46296
|
};
|
|
46194
46297
|
|
|
46195
46298
|
// src/models/cart.model.ts
|
|
46196
|
-
import { ObjectId as
|
|
46299
|
+
import { ObjectId as ObjectId124 } from "mongodb";
|
|
46197
46300
|
var MUnitBillings = class {
|
|
46198
46301
|
// transaction response messages
|
|
46199
46302
|
constructor({
|
|
46200
|
-
_id = new
|
|
46303
|
+
_id = new ObjectId124(),
|
|
46201
46304
|
unit,
|
|
46202
46305
|
unitId,
|
|
46203
46306
|
unitBill,
|
|
@@ -46238,7 +46341,7 @@ var MUnitBillings = class {
|
|
|
46238
46341
|
};
|
|
46239
46342
|
|
|
46240
46343
|
// src/repositories/payment.repository.ts
|
|
46241
|
-
import { ObjectId as
|
|
46344
|
+
import { ObjectId as ObjectId125 } from "mongodb";
|
|
46242
46345
|
import {
|
|
46243
46346
|
InternalServerError as InternalServerError66,
|
|
46244
46347
|
useAtlas as useAtlas110
|
|
@@ -46275,7 +46378,7 @@ var PaymentBillRepo = () => {
|
|
|
46275
46378
|
if (unitBillInfo?.status === "Inactive" /* inactive */) {
|
|
46276
46379
|
throw new Error("This Bill is Inactive!");
|
|
46277
46380
|
}
|
|
46278
|
-
const billId = new
|
|
46381
|
+
const billId = new ObjectId125(unitBillInfo?.billId);
|
|
46279
46382
|
const billInfo = await billCollection().findOne({ _id: billId });
|
|
46280
46383
|
if (!billInfo) {
|
|
46281
46384
|
throw new Error("Bill info not found");
|
|
@@ -46314,13 +46417,13 @@ var PaymentBillRepo = () => {
|
|
|
46314
46417
|
const saveCreditCardInfo = async (payload) => {
|
|
46315
46418
|
try {
|
|
46316
46419
|
if (payload.userId)
|
|
46317
|
-
payload.userId = new
|
|
46420
|
+
payload.userId = new ObjectId125(payload.userId);
|
|
46318
46421
|
if (payload.site)
|
|
46319
|
-
payload.site = new
|
|
46422
|
+
payload.site = new ObjectId125(payload.site);
|
|
46320
46423
|
if (payload.organization)
|
|
46321
|
-
payload.organization = new
|
|
46424
|
+
payload.organization = new ObjectId125(payload.organization);
|
|
46322
46425
|
if (payload.createdBy)
|
|
46323
|
-
payload.createdBy = new
|
|
46426
|
+
payload.createdBy = new ObjectId125(payload.createdBy);
|
|
46324
46427
|
const createdAt = formatDateString(/* @__PURE__ */ new Date(), "mm-dd-yyyy");
|
|
46325
46428
|
payload.createdAt = createdAt;
|
|
46326
46429
|
const result = await creditCollection().insertOne(new MCardInfo(payload));
|
|
@@ -46332,19 +46435,19 @@ var PaymentBillRepo = () => {
|
|
|
46332
46435
|
const checkOutUnitBills = async (payload) => {
|
|
46333
46436
|
try {
|
|
46334
46437
|
if (payload.unitId)
|
|
46335
|
-
payload.unitId = new
|
|
46438
|
+
payload.unitId = new ObjectId125(payload.unitId);
|
|
46336
46439
|
if (payload.site)
|
|
46337
|
-
payload.site = new
|
|
46440
|
+
payload.site = new ObjectId125(payload.site);
|
|
46338
46441
|
if (payload.organization)
|
|
46339
|
-
payload.organization = new
|
|
46442
|
+
payload.organization = new ObjectId125(payload.organization);
|
|
46340
46443
|
payload.createdAt = await formatDateString(/* @__PURE__ */ new Date(), "mm-dd-yyyy");
|
|
46341
46444
|
const addToCart = await cartCollection().insertOne(new MUnitBillings(payload));
|
|
46342
46445
|
const unitId = payload.unitId;
|
|
46343
46446
|
const dateFormatted = formatDateString(/* @__PURE__ */ new Date(), "for-ref");
|
|
46344
46447
|
const unit = unitId?.toString().slice(-4);
|
|
46345
|
-
const newId = new
|
|
46448
|
+
const newId = new ObjectId125(addToCart?.insertedId).toString().slice(-4);
|
|
46346
46449
|
const referenceNumber = `CRT${unit}${newId}${dateFormatted}`;
|
|
46347
|
-
const result = await cartCollection().findOneAndUpdate({ _id: new
|
|
46450
|
+
const result = await cartCollection().findOneAndUpdate({ _id: new ObjectId125(addToCart.insertedId) }, { $set: { referenceNumber } }, { returnDocument: "after" });
|
|
46348
46451
|
return result;
|
|
46349
46452
|
} catch (error) {
|
|
46350
46453
|
throw new Error(error.message || error || "Server Internal Error");
|
|
@@ -46375,7 +46478,7 @@ var PaymentBillRepo = () => {
|
|
|
46375
46478
|
for (const ref of refNumber) {
|
|
46376
46479
|
const unitBillInfo = await collection().findOne({ referenceNumber: ref });
|
|
46377
46480
|
const billId = unitBillInfo?.billId;
|
|
46378
|
-
const billInfo = await billCollection().findOne({ _id: new
|
|
46481
|
+
const billInfo = await billCollection().findOne({ _id: new ObjectId125(billId) });
|
|
46379
46482
|
const billAmount = billInfo?.price;
|
|
46380
46483
|
payload.updatedAt = updatedAt;
|
|
46381
46484
|
payload.amountPaid = billAmount;
|
|
@@ -46529,7 +46632,7 @@ var useRedDotPaymentRepo = () => {
|
|
|
46529
46632
|
throw new Error("Failed to Add Merchant Details");
|
|
46530
46633
|
}
|
|
46531
46634
|
const merchantId = merchant?.insertedId;
|
|
46532
|
-
const orgId = new
|
|
46635
|
+
const orgId = new ObjectId126(_id);
|
|
46533
46636
|
const result = await orgCollection().findOneAndUpdate({ _id: orgId }, { $push: { merchant: merchantId } }, {
|
|
46534
46637
|
returnDocument: "after"
|
|
46535
46638
|
});
|
|
@@ -46558,7 +46661,7 @@ var useRedDotPaymentRepo = () => {
|
|
|
46558
46661
|
const getMerchantDetailsById = async (_id) => {
|
|
46559
46662
|
try {
|
|
46560
46663
|
if (_id)
|
|
46561
|
-
_id = new
|
|
46664
|
+
_id = new ObjectId126(_id);
|
|
46562
46665
|
const result = await redDotMerchantCollection().aggregate([
|
|
46563
46666
|
{
|
|
46564
46667
|
$match: {
|
|
@@ -46817,11 +46920,12 @@ import {
|
|
|
46817
46920
|
InternalServerError as InternalServerError68,
|
|
46818
46921
|
logger as logger175,
|
|
46819
46922
|
makeCacheKey as makeCacheKey64,
|
|
46923
|
+
paginate as paginate57,
|
|
46820
46924
|
toObjectId as toObjectId17,
|
|
46821
46925
|
useAtlas as useAtlas112,
|
|
46822
46926
|
useCache as useCache66
|
|
46823
46927
|
} from "@7365admin1/node-server-utils";
|
|
46824
|
-
import { ObjectId as
|
|
46928
|
+
import { ObjectId as ObjectId127 } from "mongodb";
|
|
46825
46929
|
function useVerificationRepoV2() {
|
|
46826
46930
|
const db = useAtlas112.getDb();
|
|
46827
46931
|
if (!db) {
|
|
@@ -46874,7 +46978,7 @@ function useVerificationRepoV2() {
|
|
|
46874
46978
|
}
|
|
46875
46979
|
async function updateVerificationStatusById(_id, status, session) {
|
|
46876
46980
|
try {
|
|
46877
|
-
_id = new
|
|
46981
|
+
_id = new ObjectId127(_id);
|
|
46878
46982
|
} catch (error) {
|
|
46879
46983
|
throw new BadRequestError195("Invalid verification ID format.");
|
|
46880
46984
|
}
|
|
@@ -46944,13 +47048,85 @@ function useVerificationRepoV2() {
|
|
|
46944
47048
|
);
|
|
46945
47049
|
}
|
|
46946
47050
|
}
|
|
47051
|
+
async function getVerifications({
|
|
47052
|
+
search = "",
|
|
47053
|
+
page = 1,
|
|
47054
|
+
limit = 10,
|
|
47055
|
+
sort = {},
|
|
47056
|
+
status = "active",
|
|
47057
|
+
app = "",
|
|
47058
|
+
type = {},
|
|
47059
|
+
email = ""
|
|
47060
|
+
}) {
|
|
47061
|
+
page = page > 0 ? page - 1 : 0;
|
|
47062
|
+
const query = { status };
|
|
47063
|
+
const cacheOptions = {
|
|
47064
|
+
page,
|
|
47065
|
+
limit,
|
|
47066
|
+
status
|
|
47067
|
+
};
|
|
47068
|
+
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
47069
|
+
cacheOptions.sort = JSON.stringify(sort);
|
|
47070
|
+
if (search) {
|
|
47071
|
+
query.$text = { $search: search };
|
|
47072
|
+
cacheOptions.search = search;
|
|
47073
|
+
}
|
|
47074
|
+
if (app) {
|
|
47075
|
+
query["metadata.app"] = app;
|
|
47076
|
+
cacheOptions["metadata.app"] = app;
|
|
47077
|
+
}
|
|
47078
|
+
if (type && Object.keys(type).length > 0) {
|
|
47079
|
+
query.type = { $in: Object.keys(type) };
|
|
47080
|
+
cacheOptions.type = JSON.stringify(type);
|
|
47081
|
+
}
|
|
47082
|
+
if (email) {
|
|
47083
|
+
query.email = email;
|
|
47084
|
+
cacheOptions.email = email;
|
|
47085
|
+
}
|
|
47086
|
+
const cacheKey = makeCacheKey64(namespace_collection, cacheOptions);
|
|
47087
|
+
const cachedData = await getCache(cacheKey);
|
|
47088
|
+
if (cachedData) {
|
|
47089
|
+
logger175.info(`Cache hit for key: ${cacheKey}`);
|
|
47090
|
+
return cachedData;
|
|
47091
|
+
}
|
|
47092
|
+
try {
|
|
47093
|
+
const items = await collection.aggregate([
|
|
47094
|
+
{ $match: query },
|
|
47095
|
+
{ $sort: sort },
|
|
47096
|
+
{ $skip: page * limit },
|
|
47097
|
+
{ $limit: limit },
|
|
47098
|
+
{
|
|
47099
|
+
$project: {
|
|
47100
|
+
_id: 1,
|
|
47101
|
+
createdAt: 1,
|
|
47102
|
+
email: 1,
|
|
47103
|
+
type: 1,
|
|
47104
|
+
metadata: 1,
|
|
47105
|
+
status: 1
|
|
47106
|
+
}
|
|
47107
|
+
}
|
|
47108
|
+
]).toArray();
|
|
47109
|
+
const length = await collection.countDocuments(query);
|
|
47110
|
+
const data = paginate57(items, page, limit, length);
|
|
47111
|
+
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
47112
|
+
logger175.info(`Cache set for key: ${cacheKey}`);
|
|
47113
|
+
}).catch((err) => {
|
|
47114
|
+
logger175.error(`Failed to set cache for key: ${cacheKey}`, err);
|
|
47115
|
+
});
|
|
47116
|
+
return data;
|
|
47117
|
+
} catch (error) {
|
|
47118
|
+
logger175.log({ level: "error", message: `${error}` });
|
|
47119
|
+
throw error;
|
|
47120
|
+
}
|
|
47121
|
+
}
|
|
46947
47122
|
return {
|
|
46948
47123
|
createIndex,
|
|
46949
47124
|
createTextIndex,
|
|
46950
47125
|
add,
|
|
46951
47126
|
updateVerificationStatusById,
|
|
46952
47127
|
getByVerificationCode,
|
|
46953
|
-
getVerificationById
|
|
47128
|
+
getVerificationById,
|
|
47129
|
+
getVerifications
|
|
46954
47130
|
};
|
|
46955
47131
|
}
|
|
46956
47132
|
|
|
@@ -47304,6 +47480,7 @@ function useVerificationControllerV2() {
|
|
|
47304
47480
|
createServiceProviderInvite: _createServiceProviderInvite,
|
|
47305
47481
|
createForgetPassword: _createForgetPassword
|
|
47306
47482
|
} = useVerificationServiceV2();
|
|
47483
|
+
const { getVerifications: _getVerifications } = useVerificationRepoV2();
|
|
47307
47484
|
async function verify(req, res, next) {
|
|
47308
47485
|
try {
|
|
47309
47486
|
const schema2 = Joi126.object({ verificationCode: Joi126.string().required() });
|
|
@@ -47419,11 +47596,49 @@ function useVerificationControllerV2() {
|
|
|
47419
47596
|
return;
|
|
47420
47597
|
}
|
|
47421
47598
|
}
|
|
47599
|
+
async function getVerifications(req, res, next) {
|
|
47600
|
+
const schema2 = Joi126.object({
|
|
47601
|
+
search: Joi126.string().optional().allow("", null),
|
|
47602
|
+
page: Joi126.number().integer().min(1).allow("", null).default(1),
|
|
47603
|
+
status: Joi126.string().required(),
|
|
47604
|
+
app: Joi126.string().optional().allow("", null),
|
|
47605
|
+
type: Joi126.alternatives().try(
|
|
47606
|
+
Joi126.array().items(Joi126.string()),
|
|
47607
|
+
Joi126.string().custom((value2) => value2.split(","))
|
|
47608
|
+
).optional().allow("", null),
|
|
47609
|
+
email: Joi126.string().optional().allow("", null)
|
|
47610
|
+
});
|
|
47611
|
+
const { error, value } = schema2.validate(req.query);
|
|
47612
|
+
if (error) {
|
|
47613
|
+
const messages = error.details.map((d) => d.message).join(", ");
|
|
47614
|
+
logger177.log({ level: "error", message: messages });
|
|
47615
|
+
next(new BadRequestError197(messages));
|
|
47616
|
+
return;
|
|
47617
|
+
}
|
|
47618
|
+
const { search, page, status, app, email, type } = value;
|
|
47619
|
+
try {
|
|
47620
|
+
const data = await _getVerifications({
|
|
47621
|
+
search,
|
|
47622
|
+
page,
|
|
47623
|
+
status,
|
|
47624
|
+
app,
|
|
47625
|
+
type,
|
|
47626
|
+
email
|
|
47627
|
+
});
|
|
47628
|
+
res.json(data);
|
|
47629
|
+
return;
|
|
47630
|
+
} catch (error2) {
|
|
47631
|
+
logger177.log({ level: "error", message: `${error2.message}` });
|
|
47632
|
+
next(error2);
|
|
47633
|
+
return;
|
|
47634
|
+
}
|
|
47635
|
+
}
|
|
47422
47636
|
return {
|
|
47423
47637
|
verify,
|
|
47424
47638
|
createUserInvite,
|
|
47425
47639
|
createServiceProviderInvite,
|
|
47426
|
-
createForgetPassword
|
|
47640
|
+
createForgetPassword,
|
|
47641
|
+
getVerifications
|
|
47427
47642
|
};
|
|
47428
47643
|
}
|
|
47429
47644
|
|
|
@@ -47442,7 +47657,7 @@ import {
|
|
|
47442
47657
|
import { v4 as uuidv42 } from "uuid";
|
|
47443
47658
|
|
|
47444
47659
|
// src/repositories/user-v2.repo.ts
|
|
47445
|
-
import { ObjectId as
|
|
47660
|
+
import { ObjectId as ObjectId128 } from "mongodb";
|
|
47446
47661
|
import {
|
|
47447
47662
|
useAtlas as useAtlas114,
|
|
47448
47663
|
InternalServerError as InternalServerError70,
|
|
@@ -47654,7 +47869,7 @@ function useUserRepoV2() {
|
|
|
47654
47869
|
}
|
|
47655
47870
|
if (organization) {
|
|
47656
47871
|
try {
|
|
47657
|
-
query.defaultOrg = new
|
|
47872
|
+
query.defaultOrg = new ObjectId128(organization);
|
|
47658
47873
|
cacheOptions.organization = organization.toString();
|
|
47659
47874
|
} catch (error) {
|
|
47660
47875
|
throw new BadRequestError198("Invalid organization ID format.");
|
|
@@ -47793,13 +48008,13 @@ function useUserRepoV2() {
|
|
|
47793
48008
|
);
|
|
47794
48009
|
}
|
|
47795
48010
|
try {
|
|
47796
|
-
_id = new
|
|
48011
|
+
_id = new ObjectId128(_id);
|
|
47797
48012
|
} catch (error) {
|
|
47798
48013
|
throw new BadRequestError198("Invalid ID.");
|
|
47799
48014
|
}
|
|
47800
48015
|
if (field === "defaultOrg") {
|
|
47801
48016
|
try {
|
|
47802
|
-
value = new
|
|
48017
|
+
value = new ObjectId128(value);
|
|
47803
48018
|
} catch (error) {
|
|
47804
48019
|
throw new BadRequestError198("Invalid organization ID.");
|
|
47805
48020
|
}
|
|
@@ -47840,7 +48055,7 @@ function useUserRepoV2() {
|
|
|
47840
48055
|
year
|
|
47841
48056
|
}, session) {
|
|
47842
48057
|
try {
|
|
47843
|
-
_id = new
|
|
48058
|
+
_id = new ObjectId128(_id);
|
|
47844
48059
|
} catch (error) {
|
|
47845
48060
|
throw new BadRequestError198("Invalid user ID format.");
|
|
47846
48061
|
}
|
|
@@ -47870,7 +48085,7 @@ function useUserRepoV2() {
|
|
|
47870
48085
|
}
|
|
47871
48086
|
async function updatePassword({ _id, password }, session) {
|
|
47872
48087
|
try {
|
|
47873
|
-
_id = new
|
|
48088
|
+
_id = new ObjectId128(_id);
|
|
47874
48089
|
} catch (error) {
|
|
47875
48090
|
throw new BadRequestError198("Invalid user ID format.");
|
|
47876
48091
|
}
|