@7365admin1/core 2.31.1 → 2.32.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 +35 -2
- package/dist/index.js +383 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +384 -21
- 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,
|
|
@@ -13065,6 +13094,7 @@ var VisitorStatus = /* @__PURE__ */ ((VisitorStatus2) => {
|
|
|
13065
13094
|
VisitorStatus2["REGISTERED"] = "registered";
|
|
13066
13095
|
VisitorStatus2["UNREGISTERED"] = "unregistered";
|
|
13067
13096
|
VisitorStatus2["PENDING"] = "pending";
|
|
13097
|
+
VisitorStatus2["APPROVED"] = "approved";
|
|
13068
13098
|
return VisitorStatus2;
|
|
13069
13099
|
})(VisitorStatus || {});
|
|
13070
13100
|
var schemaVisitorTransaction = Joi36.object({
|
|
@@ -17467,6 +17497,9 @@ function useBuildingUnitRepo() {
|
|
|
17467
17497
|
return billing;
|
|
17468
17498
|
});
|
|
17469
17499
|
}
|
|
17500
|
+
if (value.owner) {
|
|
17501
|
+
value.owner = new ObjectId48(value.owner);
|
|
17502
|
+
}
|
|
17470
17503
|
try {
|
|
17471
17504
|
const res = await collection.updateOne(
|
|
17472
17505
|
{ _id },
|
|
@@ -22025,7 +22058,7 @@ function useVisitorTransactionService() {
|
|
|
22025
22058
|
unitName: unit?.name,
|
|
22026
22059
|
org: inviter?.org.toString(),
|
|
22027
22060
|
site: inviter?.site.toString(),
|
|
22028
|
-
status: "
|
|
22061
|
+
status: "approved" /* APPROVED */,
|
|
22029
22062
|
invitedId: inviter?._id
|
|
22030
22063
|
};
|
|
22031
22064
|
const result = await _add(payload);
|
|
@@ -22842,6 +22875,14 @@ function usePersonService() {
|
|
|
22842
22875
|
);
|
|
22843
22876
|
}
|
|
22844
22877
|
}
|
|
22878
|
+
if (value.isOwner && value.unit) {
|
|
22879
|
+
const unit = await _getUnitById(value.unit.toString());
|
|
22880
|
+
await updateUnitById(
|
|
22881
|
+
unit?._id?.toString() || "",
|
|
22882
|
+
{ ownerName: value.name, owner: value._id },
|
|
22883
|
+
session
|
|
22884
|
+
);
|
|
22885
|
+
}
|
|
22845
22886
|
await _add(value, session);
|
|
22846
22887
|
await session.commitTransaction();
|
|
22847
22888
|
return "People added successfully.";
|
|
@@ -22865,18 +22906,33 @@ function usePersonService() {
|
|
|
22865
22906
|
throw new BadRequestError100("Person not found.");
|
|
22866
22907
|
}
|
|
22867
22908
|
const isNameUpdated = typeof value.name === "string" && value.name.trim() !== person.name;
|
|
22868
|
-
|
|
22869
|
-
if (isNameUpdated && value.unit) {
|
|
22870
|
-
unit = await _getUnitById(value.unit.toString());
|
|
22871
|
-
}
|
|
22872
|
-
if (unit && unit.owner?.toString() === _id.toString()) {
|
|
22873
|
-
await updateUnitById(
|
|
22874
|
-
unit?._id?.toString() || "",
|
|
22875
|
-
{ ownerName: value.name },
|
|
22876
|
-
session
|
|
22877
|
-
);
|
|
22878
|
-
}
|
|
22909
|
+
const isOwnerChanged = value.isOwner !== person.isOwner;
|
|
22879
22910
|
await _updateById(_id, value, session);
|
|
22911
|
+
if (value.unit && (isNameUpdated || isOwnerChanged || value.isOwner)) {
|
|
22912
|
+
const unit = await _getUnitById(value.unit.toString());
|
|
22913
|
+
if (unit) {
|
|
22914
|
+
let updatePayload = {};
|
|
22915
|
+
if (isOwnerChanged) {
|
|
22916
|
+
if (value.isOwner) {
|
|
22917
|
+
updatePayload.owner = _id;
|
|
22918
|
+
updatePayload.ownerName = value.name || "";
|
|
22919
|
+
} else {
|
|
22920
|
+
updatePayload.owner = "";
|
|
22921
|
+
updatePayload.ownerName = "";
|
|
22922
|
+
}
|
|
22923
|
+
}
|
|
22924
|
+
if (isNameUpdated && value.isOwner && unit.owner?.toString() === _id.toString()) {
|
|
22925
|
+
updatePayload.ownerName = value.name;
|
|
22926
|
+
}
|
|
22927
|
+
if (value.isOwner && (!unit.owner || !unit.ownerName)) {
|
|
22928
|
+
updatePayload.owner = _id;
|
|
22929
|
+
updatePayload.ownerName = value.name || "";
|
|
22930
|
+
}
|
|
22931
|
+
if (Object.keys(updatePayload).length > 0 && unit && unit._id) {
|
|
22932
|
+
await updateUnitById(unit._id.toString(), updatePayload, session);
|
|
22933
|
+
}
|
|
22934
|
+
}
|
|
22935
|
+
}
|
|
22880
22936
|
await session.commitTransaction();
|
|
22881
22937
|
return "Person updated successfully.";
|
|
22882
22938
|
} catch (error) {
|
|
@@ -36807,6 +36863,81 @@ function useStatementOfAccountRepo() {
|
|
|
36807
36863
|
throw new InternalServerError50("Failed to update soa request.");
|
|
36808
36864
|
}
|
|
36809
36865
|
}
|
|
36866
|
+
async function getResidentUserSoa({
|
|
36867
|
+
search = "",
|
|
36868
|
+
page = 1,
|
|
36869
|
+
limit = 10,
|
|
36870
|
+
sort = {},
|
|
36871
|
+
status = "pending",
|
|
36872
|
+
site = "",
|
|
36873
|
+
dateFrom,
|
|
36874
|
+
dateTo,
|
|
36875
|
+
unitId,
|
|
36876
|
+
category
|
|
36877
|
+
}, session) {
|
|
36878
|
+
page = page > 0 ? page - 1 : 0;
|
|
36879
|
+
let dateExpr = {};
|
|
36880
|
+
if (dateFrom && dateTo) {
|
|
36881
|
+
let startDate = new Date(dateFrom);
|
|
36882
|
+
startDate.setHours(0, 0, 0, 0);
|
|
36883
|
+
let endDate = new Date(dateTo);
|
|
36884
|
+
endDate.setHours(23, 59, 59, 999);
|
|
36885
|
+
dateExpr = {
|
|
36886
|
+
$expr: {
|
|
36887
|
+
$and: [
|
|
36888
|
+
{ $gte: ["$createdAt", startDate] },
|
|
36889
|
+
{ $lte: ["$createdAt", endDate] }
|
|
36890
|
+
]
|
|
36891
|
+
}
|
|
36892
|
+
};
|
|
36893
|
+
}
|
|
36894
|
+
const unitSearchRegex = search ? search.trim().replace(/\s+/g, "").replace(/\//g, "\\s*/\\s*") : null;
|
|
36895
|
+
const query = {
|
|
36896
|
+
...status && status !== "all" && { status },
|
|
36897
|
+
...search && {
|
|
36898
|
+
$or: [
|
|
36899
|
+
{ unitOwner: { $regex: search, $options: "i" } },
|
|
36900
|
+
{ unit: { $regex: unitSearchRegex, $options: "i" } },
|
|
36901
|
+
{ email: { $regex: search, $options: "i" } },
|
|
36902
|
+
{ category: { $regex: search, $options: "i" } }
|
|
36903
|
+
]
|
|
36904
|
+
},
|
|
36905
|
+
...ObjectId97.isValid(site) && { site: new ObjectId97(site) },
|
|
36906
|
+
...dateExpr,
|
|
36907
|
+
...ObjectId97.isValid(unitId) && { unitId: new ObjectId97(unitId) },
|
|
36908
|
+
...category && { category }
|
|
36909
|
+
};
|
|
36910
|
+
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
36911
|
+
try {
|
|
36912
|
+
const basePipeline = [
|
|
36913
|
+
{ $match: query },
|
|
36914
|
+
{
|
|
36915
|
+
$addFields: {
|
|
36916
|
+
sortPriority: {
|
|
36917
|
+
$cond: [{ $eq: ["$status", "pending"] }, 1, 2]
|
|
36918
|
+
}
|
|
36919
|
+
}
|
|
36920
|
+
},
|
|
36921
|
+
{
|
|
36922
|
+
$sort: {
|
|
36923
|
+
sortPriority: 1,
|
|
36924
|
+
...sort
|
|
36925
|
+
}
|
|
36926
|
+
},
|
|
36927
|
+
{ $skip: page * limit },
|
|
36928
|
+
{ $limit: limit }
|
|
36929
|
+
];
|
|
36930
|
+
const [items, countResult] = await Promise.all([
|
|
36931
|
+
collection.aggregate(basePipeline, { session }).toArray(),
|
|
36932
|
+
collection.aggregate([{ $match: query }, { $count: "total" }], { session }).toArray()
|
|
36933
|
+
]);
|
|
36934
|
+
const totalCount = countResult[0]?.total || 0;
|
|
36935
|
+
const data = paginate42(items, page, limit, totalCount);
|
|
36936
|
+
return data;
|
|
36937
|
+
} catch (error) {
|
|
36938
|
+
throw error;
|
|
36939
|
+
}
|
|
36940
|
+
}
|
|
36810
36941
|
function delCachedData() {
|
|
36811
36942
|
delNamespace().then(() => {
|
|
36812
36943
|
logger128.log({
|
|
@@ -36827,7 +36958,8 @@ function useStatementOfAccountRepo() {
|
|
|
36827
36958
|
getById,
|
|
36828
36959
|
updateById,
|
|
36829
36960
|
deleteById,
|
|
36830
|
-
updateStatusById
|
|
36961
|
+
updateStatusById,
|
|
36962
|
+
getResidentUserSoa
|
|
36831
36963
|
};
|
|
36832
36964
|
}
|
|
36833
36965
|
|
|
@@ -36984,7 +37116,8 @@ function useStatementOfAccountController() {
|
|
|
36984
37116
|
getById: _getById,
|
|
36985
37117
|
updateById: _updateById,
|
|
36986
37118
|
deleteById: _deleteById,
|
|
36987
|
-
updateStatusById: _updateStatusById
|
|
37119
|
+
updateStatusById: _updateStatusById,
|
|
37120
|
+
getResidentUserSoa: _getResidentUserSoa
|
|
36988
37121
|
} = useStatementOfAccountRepo();
|
|
36989
37122
|
const { add: _add, generatePDF: _generatePDF } = useStatementOfAccountService();
|
|
36990
37123
|
async function add(req, res, next) {
|
|
@@ -37235,6 +37368,57 @@ function useStatementOfAccountController() {
|
|
|
37235
37368
|
return;
|
|
37236
37369
|
}
|
|
37237
37370
|
}
|
|
37371
|
+
async function getResidentUserSoa(req, res, next) {
|
|
37372
|
+
const validation = Joi93.object({
|
|
37373
|
+
page: Joi93.number().integer().min(1).allow("", null).default(1),
|
|
37374
|
+
limit: Joi93.number().integer().min(1).max(100).allow("", null).default(10),
|
|
37375
|
+
status: Joi93.string().optional().allow(null, ""),
|
|
37376
|
+
search: Joi93.string().optional().allow(null, ""),
|
|
37377
|
+
site: Joi93.string().required(),
|
|
37378
|
+
dateFrom: Joi93.string().optional().allow(null, ""),
|
|
37379
|
+
dateTo: Joi93.string().optional().allow(null, ""),
|
|
37380
|
+
unitId: Joi93.string().required(),
|
|
37381
|
+
category: Joi93.string().optional().allow(null, "")
|
|
37382
|
+
});
|
|
37383
|
+
const query = { ...req.query };
|
|
37384
|
+
const { error } = validation.validate(query, {
|
|
37385
|
+
abortEarly: false
|
|
37386
|
+
});
|
|
37387
|
+
if (error) {
|
|
37388
|
+
const messages = error.details.map((d) => d.message).join(", ");
|
|
37389
|
+
logger130.log({ level: "error", message: messages });
|
|
37390
|
+
next(new BadRequestError153(messages));
|
|
37391
|
+
return;
|
|
37392
|
+
}
|
|
37393
|
+
const search = req.query.search ?? "";
|
|
37394
|
+
const page = parseInt(req.query.page ?? "1");
|
|
37395
|
+
const limit = parseInt(req.query.limit ?? "10");
|
|
37396
|
+
const status = req.query.status ?? "active";
|
|
37397
|
+
const site = req.query.site;
|
|
37398
|
+
const dateFrom = req.query.dateFrom ?? "";
|
|
37399
|
+
const dateTo = req.query.dateTo ?? "";
|
|
37400
|
+
const unitId = req.query.unitId;
|
|
37401
|
+
const category = req.query.category ?? "";
|
|
37402
|
+
try {
|
|
37403
|
+
const data = await _getResidentUserSoa({
|
|
37404
|
+
search,
|
|
37405
|
+
page,
|
|
37406
|
+
limit,
|
|
37407
|
+
status,
|
|
37408
|
+
site,
|
|
37409
|
+
dateFrom,
|
|
37410
|
+
dateTo,
|
|
37411
|
+
unitId,
|
|
37412
|
+
category
|
|
37413
|
+
});
|
|
37414
|
+
res.status(200).json(data);
|
|
37415
|
+
return;
|
|
37416
|
+
} catch (error2) {
|
|
37417
|
+
logger130.log({ level: "error", message: error2.message });
|
|
37418
|
+
next(error2);
|
|
37419
|
+
return;
|
|
37420
|
+
}
|
|
37421
|
+
}
|
|
37238
37422
|
return {
|
|
37239
37423
|
add,
|
|
37240
37424
|
getAll,
|
|
@@ -37242,7 +37426,8 @@ function useStatementOfAccountController() {
|
|
|
37242
37426
|
updateById,
|
|
37243
37427
|
deleteById,
|
|
37244
37428
|
generatePDF,
|
|
37245
|
-
updateStatusById
|
|
37429
|
+
updateStatusById,
|
|
37430
|
+
getResidentUserSoa
|
|
37246
37431
|
};
|
|
37247
37432
|
}
|
|
37248
37433
|
|
|
@@ -40391,7 +40576,7 @@ function useOccurrenceEntryService() {
|
|
|
40391
40576
|
value.signature = value.signature ? new ObjectId108(value.signature) : occurrenceEntry.signature._id;
|
|
40392
40577
|
value.eSignature = value.eSignature ? new ObjectId108(value.eSignature) : occurrenceEntry.eSignature;
|
|
40393
40578
|
value.createdAt = /* @__PURE__ */ new Date();
|
|
40394
|
-
value.date =
|
|
40579
|
+
value.date = value.date ? value.date : occurrenceEntry.date;
|
|
40395
40580
|
value.userName = value.userName ? value.userName : occurrenceEntry.signature.name;
|
|
40396
40581
|
value.createdByName = value.createdByName ? value.createdByName : occurrenceEntry.createdByName;
|
|
40397
40582
|
await _updateOccurrenceBookById(dobId, {
|
|
@@ -46762,6 +46947,7 @@ import {
|
|
|
46762
46947
|
InternalServerError as InternalServerError68,
|
|
46763
46948
|
logger as logger175,
|
|
46764
46949
|
makeCacheKey as makeCacheKey64,
|
|
46950
|
+
paginate as paginate57,
|
|
46765
46951
|
toObjectId as toObjectId17,
|
|
46766
46952
|
useAtlas as useAtlas112,
|
|
46767
46953
|
useCache as useCache66
|
|
@@ -46889,13 +47075,117 @@ function useVerificationRepoV2() {
|
|
|
46889
47075
|
);
|
|
46890
47076
|
}
|
|
46891
47077
|
}
|
|
47078
|
+
async function getVerifications({
|
|
47079
|
+
search = "",
|
|
47080
|
+
page = 1,
|
|
47081
|
+
limit = 10,
|
|
47082
|
+
sort = {},
|
|
47083
|
+
status = "active",
|
|
47084
|
+
app = "",
|
|
47085
|
+
type = {},
|
|
47086
|
+
email = ""
|
|
47087
|
+
}) {
|
|
47088
|
+
page = page > 0 ? page - 1 : 0;
|
|
47089
|
+
const query = { status };
|
|
47090
|
+
const cacheOptions = {
|
|
47091
|
+
page,
|
|
47092
|
+
limit,
|
|
47093
|
+
status
|
|
47094
|
+
};
|
|
47095
|
+
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
47096
|
+
cacheOptions.sort = JSON.stringify(sort);
|
|
47097
|
+
if (search) {
|
|
47098
|
+
query.$text = { $search: search };
|
|
47099
|
+
cacheOptions.search = search;
|
|
47100
|
+
}
|
|
47101
|
+
if (app) {
|
|
47102
|
+
query["metadata.app"] = app;
|
|
47103
|
+
cacheOptions["metadata.app"] = app;
|
|
47104
|
+
}
|
|
47105
|
+
if (type && Object.keys(type).length > 0) {
|
|
47106
|
+
query.type = { $in: Object.keys(type) };
|
|
47107
|
+
cacheOptions.type = JSON.stringify(type);
|
|
47108
|
+
}
|
|
47109
|
+
if (email) {
|
|
47110
|
+
query.email = email;
|
|
47111
|
+
cacheOptions.email = email;
|
|
47112
|
+
}
|
|
47113
|
+
const cacheKey = makeCacheKey64(namespace_collection, cacheOptions);
|
|
47114
|
+
const cachedData = await getCache(cacheKey);
|
|
47115
|
+
if (cachedData) {
|
|
47116
|
+
logger175.info(`Cache hit for key: ${cacheKey}`);
|
|
47117
|
+
return cachedData;
|
|
47118
|
+
}
|
|
47119
|
+
try {
|
|
47120
|
+
const items = await collection.aggregate([
|
|
47121
|
+
{ $match: query },
|
|
47122
|
+
{ $sort: sort },
|
|
47123
|
+
{ $skip: page * limit },
|
|
47124
|
+
{ $limit: limit },
|
|
47125
|
+
{
|
|
47126
|
+
$project: {
|
|
47127
|
+
_id: 1,
|
|
47128
|
+
createdAt: 1,
|
|
47129
|
+
email: 1,
|
|
47130
|
+
type: 1,
|
|
47131
|
+
metadata: 1,
|
|
47132
|
+
status: 1
|
|
47133
|
+
}
|
|
47134
|
+
}
|
|
47135
|
+
]).toArray();
|
|
47136
|
+
const length = await collection.countDocuments(query);
|
|
47137
|
+
const data = paginate57(items, page, limit, length);
|
|
47138
|
+
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
47139
|
+
logger175.info(`Cache set for key: ${cacheKey}`);
|
|
47140
|
+
}).catch((err) => {
|
|
47141
|
+
logger175.error(`Failed to set cache for key: ${cacheKey}`, err);
|
|
47142
|
+
});
|
|
47143
|
+
return data;
|
|
47144
|
+
} catch (error) {
|
|
47145
|
+
logger175.log({ level: "error", message: `${error}` });
|
|
47146
|
+
throw error;
|
|
47147
|
+
}
|
|
47148
|
+
}
|
|
47149
|
+
async function updateStatusById(_id, status, session) {
|
|
47150
|
+
try {
|
|
47151
|
+
_id = new ObjectId127(_id);
|
|
47152
|
+
} catch (error) {
|
|
47153
|
+
throw new BadRequestError195("Invalid verification ID format.");
|
|
47154
|
+
}
|
|
47155
|
+
try {
|
|
47156
|
+
const result = await collection.updateOne(
|
|
47157
|
+
{ _id },
|
|
47158
|
+
{ $set: { status, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } },
|
|
47159
|
+
{ session }
|
|
47160
|
+
);
|
|
47161
|
+
delNamespace().then(() => {
|
|
47162
|
+
logger175.info(`Cache cleared for namespace: ${namespace_collection}`);
|
|
47163
|
+
}).catch((err) => {
|
|
47164
|
+
logger175.error(
|
|
47165
|
+
`Failed to clear cache for namespace: ${namespace_collection}`,
|
|
47166
|
+
err
|
|
47167
|
+
);
|
|
47168
|
+
});
|
|
47169
|
+
const cacheKey = makeCacheKey64(namespace_collection, { _id });
|
|
47170
|
+
delCache(cacheKey).then(() => {
|
|
47171
|
+
logger175.info(`Cache deleted for key: ${cacheKey}`);
|
|
47172
|
+
}).catch((err) => {
|
|
47173
|
+
logger175.error(`Failed to delete cache for key: ${cacheKey}`, err);
|
|
47174
|
+
});
|
|
47175
|
+
return result;
|
|
47176
|
+
} catch (error) {
|
|
47177
|
+
throw new InternalServerError68("Error updating verification status.");
|
|
47178
|
+
}
|
|
47179
|
+
}
|
|
46892
47180
|
return {
|
|
46893
47181
|
createIndex,
|
|
46894
47182
|
createTextIndex,
|
|
46895
47183
|
add,
|
|
46896
47184
|
updateVerificationStatusById,
|
|
46897
47185
|
getByVerificationCode,
|
|
46898
|
-
getVerificationById
|
|
47186
|
+
getVerificationById,
|
|
47187
|
+
getVerifications,
|
|
47188
|
+
updateStatusById
|
|
46899
47189
|
};
|
|
46900
47190
|
}
|
|
46901
47191
|
|
|
@@ -46925,7 +47215,8 @@ function useVerificationServiceV2() {
|
|
|
46925
47215
|
const {
|
|
46926
47216
|
add: _add,
|
|
46927
47217
|
updateVerificationStatusById: _updateVerificationStatusById,
|
|
46928
|
-
getByVerificationCode: _getByVerificationCode
|
|
47218
|
+
getByVerificationCode: _getByVerificationCode,
|
|
47219
|
+
updateStatusById: _updateStatusById
|
|
46929
47220
|
} = useVerificationRepoV2();
|
|
46930
47221
|
const {
|
|
46931
47222
|
getUserByEmailStatus: _getUserByEmailStatus,
|
|
@@ -47230,12 +47521,22 @@ function useVerificationServiceV2() {
|
|
|
47230
47521
|
throw new InternalServerError69("Failed to create forget password link.");
|
|
47231
47522
|
}
|
|
47232
47523
|
}
|
|
47524
|
+
async function cancelUserInvitation(id) {
|
|
47525
|
+
try {
|
|
47526
|
+
await _updateStatusById(id, "cancelled");
|
|
47527
|
+
} catch (error) {
|
|
47528
|
+
throw new InternalServerError69(
|
|
47529
|
+
`Error cancelling user invitation: ${error}`
|
|
47530
|
+
);
|
|
47531
|
+
}
|
|
47532
|
+
}
|
|
47233
47533
|
return {
|
|
47234
47534
|
signUp,
|
|
47235
47535
|
verify,
|
|
47236
47536
|
createUserInvite,
|
|
47237
47537
|
createServiceProviderInvite,
|
|
47238
|
-
createForgetPassword
|
|
47538
|
+
createForgetPassword,
|
|
47539
|
+
cancelUserInvitation
|
|
47239
47540
|
};
|
|
47240
47541
|
}
|
|
47241
47542
|
|
|
@@ -47247,8 +47548,10 @@ function useVerificationControllerV2() {
|
|
|
47247
47548
|
verify: _verify,
|
|
47248
47549
|
createUserInvite: _createUserInvite,
|
|
47249
47550
|
createServiceProviderInvite: _createServiceProviderInvite,
|
|
47250
|
-
createForgetPassword: _createForgetPassword
|
|
47551
|
+
createForgetPassword: _createForgetPassword,
|
|
47552
|
+
cancelUserInvitation: _cancelUserInvitation
|
|
47251
47553
|
} = useVerificationServiceV2();
|
|
47554
|
+
const { getVerifications: _getVerifications } = useVerificationRepoV2();
|
|
47252
47555
|
async function verify(req, res, next) {
|
|
47253
47556
|
try {
|
|
47254
47557
|
const schema2 = Joi126.object({ verificationCode: Joi126.string().required() });
|
|
@@ -47364,11 +47667,71 @@ function useVerificationControllerV2() {
|
|
|
47364
47667
|
return;
|
|
47365
47668
|
}
|
|
47366
47669
|
}
|
|
47670
|
+
async function getVerifications(req, res, next) {
|
|
47671
|
+
const schema2 = Joi126.object({
|
|
47672
|
+
search: Joi126.string().optional().allow("", null),
|
|
47673
|
+
page: Joi126.number().integer().min(1).allow("", null).default(1),
|
|
47674
|
+
status: Joi126.string().required(),
|
|
47675
|
+
app: Joi126.string().optional().allow("", null),
|
|
47676
|
+
type: Joi126.alternatives().try(
|
|
47677
|
+
Joi126.array().items(Joi126.string()),
|
|
47678
|
+
Joi126.string().custom((value2) => value2.split(","))
|
|
47679
|
+
).optional().allow("", null),
|
|
47680
|
+
email: Joi126.string().optional().allow("", null)
|
|
47681
|
+
});
|
|
47682
|
+
const { error, value } = schema2.validate(req.query);
|
|
47683
|
+
if (error) {
|
|
47684
|
+
const messages = error.details.map((d) => d.message).join(", ");
|
|
47685
|
+
logger177.log({ level: "error", message: messages });
|
|
47686
|
+
next(new BadRequestError197(messages));
|
|
47687
|
+
return;
|
|
47688
|
+
}
|
|
47689
|
+
const { search, page, status, app, email, type } = value;
|
|
47690
|
+
try {
|
|
47691
|
+
const data = await _getVerifications({
|
|
47692
|
+
search,
|
|
47693
|
+
page,
|
|
47694
|
+
status,
|
|
47695
|
+
app,
|
|
47696
|
+
type,
|
|
47697
|
+
email
|
|
47698
|
+
});
|
|
47699
|
+
res.json(data);
|
|
47700
|
+
return;
|
|
47701
|
+
} catch (error2) {
|
|
47702
|
+
logger177.log({ level: "error", message: `${error2.message}` });
|
|
47703
|
+
next(error2);
|
|
47704
|
+
return;
|
|
47705
|
+
}
|
|
47706
|
+
}
|
|
47707
|
+
async function cancelUserInvitation(req, res, next) {
|
|
47708
|
+
const validation = Joi126.string().hex().required();
|
|
47709
|
+
const otpId = req.params.id;
|
|
47710
|
+
const { error } = validation.validate(otpId);
|
|
47711
|
+
if (error) {
|
|
47712
|
+
logger177.log({ level: "error", message: `${error.message}` });
|
|
47713
|
+
next(new BadRequestError197(error.message));
|
|
47714
|
+
return;
|
|
47715
|
+
}
|
|
47716
|
+
try {
|
|
47717
|
+
await _cancelUserInvitation(otpId);
|
|
47718
|
+
res.json({
|
|
47719
|
+
message: "User invite has been cancelled."
|
|
47720
|
+
});
|
|
47721
|
+
return;
|
|
47722
|
+
} catch (error2) {
|
|
47723
|
+
logger177.log({ level: "error", message: `${error2.message}` });
|
|
47724
|
+
next(error2);
|
|
47725
|
+
return;
|
|
47726
|
+
}
|
|
47727
|
+
}
|
|
47367
47728
|
return {
|
|
47368
47729
|
verify,
|
|
47369
47730
|
createUserInvite,
|
|
47370
47731
|
createServiceProviderInvite,
|
|
47371
|
-
createForgetPassword
|
|
47732
|
+
createForgetPassword,
|
|
47733
|
+
getVerifications,
|
|
47734
|
+
cancelUserInvitation
|
|
47372
47735
|
};
|
|
47373
47736
|
}
|
|
47374
47737
|
|