@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/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -475,6 +475,7 @@ declare function useOrgRepo(): {
|
|
|
475
475
|
|
|
476
476
|
declare function useOrgController(): {
|
|
477
477
|
add: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
478
|
+
addOnboardingOrg: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
478
479
|
getAll: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
479
480
|
getOrgsByUserId: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
480
481
|
getByName: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
@@ -1816,7 +1817,7 @@ declare function useBuildingUnitRepo(): {
|
|
|
1816
1817
|
}) => Promise<Record<string, any>>;
|
|
1817
1818
|
getById: (_id: string | ObjectId, session?: ClientSession) => Promise<TBuildingUnit>;
|
|
1818
1819
|
getByBuildingLevel: (building: string | ObjectId, level: string) => Promise<TBuildingUnit | null>;
|
|
1819
|
-
updateById: (_id: string | ObjectId, value: Partial<Pick<TBuildingUnit, "name" | "level" | "category" | "buildingName" | "block" | "buildingUnitFiles" | "ownerName" | "billing">>, session?: ClientSession) => Promise<mongodb.UpdateResult<bson.Document>>;
|
|
1820
|
+
updateById: (_id: string | ObjectId, value: Partial<Pick<TBuildingUnit, "name" | "level" | "category" | "buildingName" | "block" | "buildingUnitFiles" | "ownerName" | "billing" | "owner">>, session?: ClientSession) => Promise<mongodb.UpdateResult<bson.Document>>;
|
|
1820
1821
|
getByBuilding: (building: string | ObjectId) => Promise<TBuildingUnit | null>;
|
|
1821
1822
|
deleteById: (_id: string | ObjectId, session?: ClientSession) => Promise<string>;
|
|
1822
1823
|
updateLevelByBuildingLevel: (building: string | ObjectId, level: string, newLevel: string, session?: ClientSession) => Promise<mongodb.UpdateResult<bson.Document>>;
|
|
@@ -2495,7 +2496,8 @@ declare enum VisitorSort {
|
|
|
2495
2496
|
declare enum VisitorStatus {
|
|
2496
2497
|
REGISTERED = "registered",
|
|
2497
2498
|
UNREGISTERED = "unregistered",
|
|
2498
|
-
PENDING = "pending"
|
|
2499
|
+
PENDING = "pending",
|
|
2500
|
+
APPROVED = "approved"
|
|
2499
2501
|
}
|
|
2500
2502
|
type TKeyRef = {
|
|
2501
2503
|
keyId: string | ObjectId;
|
|
@@ -4795,6 +4797,22 @@ declare function useStatementOfAccountRepo(): {
|
|
|
4795
4797
|
updateById: (_id: string | ObjectId, value: Partial<TStatementOfAccount>, session?: ClientSession) => Promise<mongodb.UpdateResult<bson.Document>>;
|
|
4796
4798
|
deleteById: (_id: string | ObjectId) => Promise<number>;
|
|
4797
4799
|
updateStatusById: (_id: string | ObjectId, value: Pick<TStatementOfAccount, "status">, session?: ClientSession) => Promise<mongodb.UpdateResult<bson.Document>>;
|
|
4800
|
+
getResidentUserSoa: ({ search, page, limit, sort, status, site, dateFrom, dateTo, unitId, category, }: {
|
|
4801
|
+
search?: string | undefined;
|
|
4802
|
+
page?: number | undefined;
|
|
4803
|
+
limit?: number | undefined;
|
|
4804
|
+
sort?: Record<string, any> | undefined;
|
|
4805
|
+
status: string;
|
|
4806
|
+
site?: string | undefined;
|
|
4807
|
+
dateFrom?: string | undefined;
|
|
4808
|
+
dateTo?: string | undefined;
|
|
4809
|
+
unitId: string;
|
|
4810
|
+
category: string;
|
|
4811
|
+
}, session?: ClientSession) => Promise<{
|
|
4812
|
+
items: any[];
|
|
4813
|
+
pages: number;
|
|
4814
|
+
pageRange: string;
|
|
4815
|
+
}>;
|
|
4798
4816
|
};
|
|
4799
4817
|
|
|
4800
4818
|
declare function useStatementOfAccountController(): {
|
|
@@ -4805,6 +4823,7 @@ declare function useStatementOfAccountController(): {
|
|
|
4805
4823
|
deleteById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
4806
4824
|
generatePDF: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
4807
4825
|
updateStatusById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
4826
|
+
getResidentUserSoa: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
4808
4827
|
};
|
|
4809
4828
|
|
|
4810
4829
|
type TEntryPassSettings = {
|
|
@@ -6276,6 +6295,17 @@ declare function useVerificationRepoV2(): {
|
|
|
6276
6295
|
updateVerificationStatusById: (_id: string | ObjectId, status: string, session?: ClientSession) => Promise<mongodb.UpdateResult<bson.Document>>;
|
|
6277
6296
|
getByVerificationCode: (verificationCode: string) => Promise<TVerification | null>;
|
|
6278
6297
|
getVerificationById: (id: string | ObjectId) => Promise<TVerificationV2 | null>;
|
|
6298
|
+
getVerifications: ({ search, page, limit, sort, status, app, type, email, }: {
|
|
6299
|
+
search?: string | undefined;
|
|
6300
|
+
page?: number | undefined;
|
|
6301
|
+
limit?: number | undefined;
|
|
6302
|
+
sort?: Record<string, any> | undefined;
|
|
6303
|
+
status: string;
|
|
6304
|
+
app?: string | undefined;
|
|
6305
|
+
type?: Record<string, any> | undefined;
|
|
6306
|
+
email?: string | undefined;
|
|
6307
|
+
}) => Promise<{}>;
|
|
6308
|
+
updateStatusById: (_id: string | ObjectId, status: string, session?: ClientSession) => Promise<mongodb.UpdateResult<bson.Document>>;
|
|
6279
6309
|
};
|
|
6280
6310
|
|
|
6281
6311
|
declare function useVerificationServiceV2(): {
|
|
@@ -6304,6 +6334,7 @@ declare function useVerificationServiceV2(): {
|
|
|
6304
6334
|
siteName: string;
|
|
6305
6335
|
}) => Promise<bson.ObjectId>;
|
|
6306
6336
|
createForgetPassword: (email: string) => Promise<string>;
|
|
6337
|
+
cancelUserInvitation: (id: string) => Promise<void>;
|
|
6307
6338
|
};
|
|
6308
6339
|
|
|
6309
6340
|
declare function useVerificationControllerV2(): {
|
|
@@ -6311,6 +6342,8 @@ declare function useVerificationControllerV2(): {
|
|
|
6311
6342
|
createUserInvite: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
6312
6343
|
createServiceProviderInvite: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
6313
6344
|
createForgetPassword: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
6345
|
+
getVerifications: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
6346
|
+
cancelUserInvitation: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
6314
6347
|
};
|
|
6315
6348
|
|
|
6316
6349
|
declare function useAuthControllerV2(): {
|
package/dist/index.js
CHANGED
|
@@ -7722,6 +7722,34 @@ function useOrgController() {
|
|
|
7722
7722
|
return;
|
|
7723
7723
|
}
|
|
7724
7724
|
}
|
|
7725
|
+
async function addOnboardingOrg(req, res, next) {
|
|
7726
|
+
const validation = import_joi18.default.object({
|
|
7727
|
+
name: import_joi18.default.string().required(),
|
|
7728
|
+
type: import_joi18.default.string().required(),
|
|
7729
|
+
nature: import_joi18.default.string().valid(...allowedNatures).required(),
|
|
7730
|
+
email: import_joi18.default.string().email().optional().allow("", null),
|
|
7731
|
+
contact: import_joi18.default.string().optional().allow("", null)
|
|
7732
|
+
});
|
|
7733
|
+
const { error } = validation.validate(req.body);
|
|
7734
|
+
if (error) {
|
|
7735
|
+
import_node_server_utils34.logger.log({ level: "error", message: error.message });
|
|
7736
|
+
next(new import_node_server_utils34.BadRequestError(error.message));
|
|
7737
|
+
return;
|
|
7738
|
+
}
|
|
7739
|
+
try {
|
|
7740
|
+
const _id = await _add(req.body);
|
|
7741
|
+
const data = await _getById(_id);
|
|
7742
|
+
res.status(201).json({
|
|
7743
|
+
message: "Successfully created organization.",
|
|
7744
|
+
data
|
|
7745
|
+
});
|
|
7746
|
+
return;
|
|
7747
|
+
} catch (error2) {
|
|
7748
|
+
import_node_server_utils34.logger.log({ level: "error", message: error2.message });
|
|
7749
|
+
next(error2);
|
|
7750
|
+
return;
|
|
7751
|
+
}
|
|
7752
|
+
}
|
|
7725
7753
|
async function getOrgsByUserId(req, res, next) {
|
|
7726
7754
|
const validation = import_joi18.default.object({
|
|
7727
7755
|
search: import_joi18.default.string().optional().allow("", null),
|
|
@@ -7820,6 +7848,7 @@ function useOrgController() {
|
|
|
7820
7848
|
}
|
|
7821
7849
|
return {
|
|
7822
7850
|
add,
|
|
7851
|
+
addOnboardingOrg,
|
|
7823
7852
|
getAll,
|
|
7824
7853
|
getOrgsByUserId,
|
|
7825
7854
|
getByName,
|
|
@@ -13267,6 +13296,7 @@ var VisitorStatus = /* @__PURE__ */ ((VisitorStatus2) => {
|
|
|
13267
13296
|
VisitorStatus2["REGISTERED"] = "registered";
|
|
13268
13297
|
VisitorStatus2["UNREGISTERED"] = "unregistered";
|
|
13269
13298
|
VisitorStatus2["PENDING"] = "pending";
|
|
13299
|
+
VisitorStatus2["APPROVED"] = "approved";
|
|
13270
13300
|
return VisitorStatus2;
|
|
13271
13301
|
})(VisitorStatus || {});
|
|
13272
13302
|
var schemaVisitorTransaction = import_joi36.default.object({
|
|
@@ -17617,6 +17647,9 @@ function useBuildingUnitRepo() {
|
|
|
17617
17647
|
return billing;
|
|
17618
17648
|
});
|
|
17619
17649
|
}
|
|
17650
|
+
if (value.owner) {
|
|
17651
|
+
value.owner = new import_mongodb48.ObjectId(value.owner);
|
|
17652
|
+
}
|
|
17620
17653
|
try {
|
|
17621
17654
|
const res = await collection.updateOne(
|
|
17622
17655
|
{ _id },
|
|
@@ -22127,7 +22160,7 @@ function useVisitorTransactionService() {
|
|
|
22127
22160
|
unitName: unit?.name,
|
|
22128
22161
|
org: inviter?.org.toString(),
|
|
22129
22162
|
site: inviter?.site.toString(),
|
|
22130
|
-
status: "
|
|
22163
|
+
status: "approved" /* APPROVED */,
|
|
22131
22164
|
invitedId: inviter?._id
|
|
22132
22165
|
};
|
|
22133
22166
|
const result = await _add(payload);
|
|
@@ -22930,6 +22963,14 @@ function usePersonService() {
|
|
|
22930
22963
|
);
|
|
22931
22964
|
}
|
|
22932
22965
|
}
|
|
22966
|
+
if (value.isOwner && value.unit) {
|
|
22967
|
+
const unit = await _getUnitById(value.unit.toString());
|
|
22968
|
+
await updateUnitById(
|
|
22969
|
+
unit?._id?.toString() || "",
|
|
22970
|
+
{ ownerName: value.name, owner: value._id },
|
|
22971
|
+
session
|
|
22972
|
+
);
|
|
22973
|
+
}
|
|
22933
22974
|
await _add(value, session);
|
|
22934
22975
|
await session.commitTransaction();
|
|
22935
22976
|
return "People added successfully.";
|
|
@@ -22953,18 +22994,33 @@ function usePersonService() {
|
|
|
22953
22994
|
throw new import_node_server_utils106.BadRequestError("Person not found.");
|
|
22954
22995
|
}
|
|
22955
22996
|
const isNameUpdated = typeof value.name === "string" && value.name.trim() !== person.name;
|
|
22956
|
-
|
|
22957
|
-
if (isNameUpdated && value.unit) {
|
|
22958
|
-
unit = await _getUnitById(value.unit.toString());
|
|
22959
|
-
}
|
|
22960
|
-
if (unit && unit.owner?.toString() === _id.toString()) {
|
|
22961
|
-
await updateUnitById(
|
|
22962
|
-
unit?._id?.toString() || "",
|
|
22963
|
-
{ ownerName: value.name },
|
|
22964
|
-
session
|
|
22965
|
-
);
|
|
22966
|
-
}
|
|
22997
|
+
const isOwnerChanged = value.isOwner !== person.isOwner;
|
|
22967
22998
|
await _updateById(_id, value, session);
|
|
22999
|
+
if (value.unit && (isNameUpdated || isOwnerChanged || value.isOwner)) {
|
|
23000
|
+
const unit = await _getUnitById(value.unit.toString());
|
|
23001
|
+
if (unit) {
|
|
23002
|
+
let updatePayload = {};
|
|
23003
|
+
if (isOwnerChanged) {
|
|
23004
|
+
if (value.isOwner) {
|
|
23005
|
+
updatePayload.owner = _id;
|
|
23006
|
+
updatePayload.ownerName = value.name || "";
|
|
23007
|
+
} else {
|
|
23008
|
+
updatePayload.owner = "";
|
|
23009
|
+
updatePayload.ownerName = "";
|
|
23010
|
+
}
|
|
23011
|
+
}
|
|
23012
|
+
if (isNameUpdated && value.isOwner && unit.owner?.toString() === _id.toString()) {
|
|
23013
|
+
updatePayload.ownerName = value.name;
|
|
23014
|
+
}
|
|
23015
|
+
if (value.isOwner && (!unit.owner || !unit.ownerName)) {
|
|
23016
|
+
updatePayload.owner = _id;
|
|
23017
|
+
updatePayload.ownerName = value.name || "";
|
|
23018
|
+
}
|
|
23019
|
+
if (Object.keys(updatePayload).length > 0 && unit && unit._id) {
|
|
23020
|
+
await updateUnitById(unit._id.toString(), updatePayload, session);
|
|
23021
|
+
}
|
|
23022
|
+
}
|
|
23023
|
+
}
|
|
22968
23024
|
await session.commitTransaction();
|
|
22969
23025
|
return "Person updated successfully.";
|
|
22970
23026
|
} catch (error) {
|
|
@@ -36717,6 +36773,81 @@ function useStatementOfAccountRepo() {
|
|
|
36717
36773
|
throw new import_node_server_utils164.InternalServerError("Failed to update soa request.");
|
|
36718
36774
|
}
|
|
36719
36775
|
}
|
|
36776
|
+
async function getResidentUserSoa({
|
|
36777
|
+
search = "",
|
|
36778
|
+
page = 1,
|
|
36779
|
+
limit = 10,
|
|
36780
|
+
sort = {},
|
|
36781
|
+
status = "pending",
|
|
36782
|
+
site = "",
|
|
36783
|
+
dateFrom,
|
|
36784
|
+
dateTo,
|
|
36785
|
+
unitId,
|
|
36786
|
+
category
|
|
36787
|
+
}, session) {
|
|
36788
|
+
page = page > 0 ? page - 1 : 0;
|
|
36789
|
+
let dateExpr = {};
|
|
36790
|
+
if (dateFrom && dateTo) {
|
|
36791
|
+
let startDate = new Date(dateFrom);
|
|
36792
|
+
startDate.setHours(0, 0, 0, 0);
|
|
36793
|
+
let endDate = new Date(dateTo);
|
|
36794
|
+
endDate.setHours(23, 59, 59, 999);
|
|
36795
|
+
dateExpr = {
|
|
36796
|
+
$expr: {
|
|
36797
|
+
$and: [
|
|
36798
|
+
{ $gte: ["$createdAt", startDate] },
|
|
36799
|
+
{ $lte: ["$createdAt", endDate] }
|
|
36800
|
+
]
|
|
36801
|
+
}
|
|
36802
|
+
};
|
|
36803
|
+
}
|
|
36804
|
+
const unitSearchRegex = search ? search.trim().replace(/\s+/g, "").replace(/\//g, "\\s*/\\s*") : null;
|
|
36805
|
+
const query = {
|
|
36806
|
+
...status && status !== "all" && { status },
|
|
36807
|
+
...search && {
|
|
36808
|
+
$or: [
|
|
36809
|
+
{ unitOwner: { $regex: search, $options: "i" } },
|
|
36810
|
+
{ unit: { $regex: unitSearchRegex, $options: "i" } },
|
|
36811
|
+
{ email: { $regex: search, $options: "i" } },
|
|
36812
|
+
{ category: { $regex: search, $options: "i" } }
|
|
36813
|
+
]
|
|
36814
|
+
},
|
|
36815
|
+
...import_mongodb97.ObjectId.isValid(site) && { site: new import_mongodb97.ObjectId(site) },
|
|
36816
|
+
...dateExpr,
|
|
36817
|
+
...import_mongodb97.ObjectId.isValid(unitId) && { unitId: new import_mongodb97.ObjectId(unitId) },
|
|
36818
|
+
...category && { category }
|
|
36819
|
+
};
|
|
36820
|
+
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
36821
|
+
try {
|
|
36822
|
+
const basePipeline = [
|
|
36823
|
+
{ $match: query },
|
|
36824
|
+
{
|
|
36825
|
+
$addFields: {
|
|
36826
|
+
sortPriority: {
|
|
36827
|
+
$cond: [{ $eq: ["$status", "pending"] }, 1, 2]
|
|
36828
|
+
}
|
|
36829
|
+
}
|
|
36830
|
+
},
|
|
36831
|
+
{
|
|
36832
|
+
$sort: {
|
|
36833
|
+
sortPriority: 1,
|
|
36834
|
+
...sort
|
|
36835
|
+
}
|
|
36836
|
+
},
|
|
36837
|
+
{ $skip: page * limit },
|
|
36838
|
+
{ $limit: limit }
|
|
36839
|
+
];
|
|
36840
|
+
const [items, countResult] = await Promise.all([
|
|
36841
|
+
collection.aggregate(basePipeline, { session }).toArray(),
|
|
36842
|
+
collection.aggregate([{ $match: query }, { $count: "total" }], { session }).toArray()
|
|
36843
|
+
]);
|
|
36844
|
+
const totalCount = countResult[0]?.total || 0;
|
|
36845
|
+
const data = (0, import_node_server_utils164.paginate)(items, page, limit, totalCount);
|
|
36846
|
+
return data;
|
|
36847
|
+
} catch (error) {
|
|
36848
|
+
throw error;
|
|
36849
|
+
}
|
|
36850
|
+
}
|
|
36720
36851
|
function delCachedData() {
|
|
36721
36852
|
delNamespace().then(() => {
|
|
36722
36853
|
import_node_server_utils164.logger.log({
|
|
@@ -36737,7 +36868,8 @@ function useStatementOfAccountRepo() {
|
|
|
36737
36868
|
getById,
|
|
36738
36869
|
updateById,
|
|
36739
36870
|
deleteById,
|
|
36740
|
-
updateStatusById
|
|
36871
|
+
updateStatusById,
|
|
36872
|
+
getResidentUserSoa
|
|
36741
36873
|
};
|
|
36742
36874
|
}
|
|
36743
36875
|
|
|
@@ -36890,7 +37022,8 @@ function useStatementOfAccountController() {
|
|
|
36890
37022
|
getById: _getById,
|
|
36891
37023
|
updateById: _updateById,
|
|
36892
37024
|
deleteById: _deleteById,
|
|
36893
|
-
updateStatusById: _updateStatusById
|
|
37025
|
+
updateStatusById: _updateStatusById,
|
|
37026
|
+
getResidentUserSoa: _getResidentUserSoa
|
|
36894
37027
|
} = useStatementOfAccountRepo();
|
|
36895
37028
|
const { add: _add, generatePDF: _generatePDF } = useStatementOfAccountService();
|
|
36896
37029
|
async function add(req, res, next) {
|
|
@@ -37141,6 +37274,57 @@ function useStatementOfAccountController() {
|
|
|
37141
37274
|
return;
|
|
37142
37275
|
}
|
|
37143
37276
|
}
|
|
37277
|
+
async function getResidentUserSoa(req, res, next) {
|
|
37278
|
+
const validation = import_joi93.default.object({
|
|
37279
|
+
page: import_joi93.default.number().integer().min(1).allow("", null).default(1),
|
|
37280
|
+
limit: import_joi93.default.number().integer().min(1).max(100).allow("", null).default(10),
|
|
37281
|
+
status: import_joi93.default.string().optional().allow(null, ""),
|
|
37282
|
+
search: import_joi93.default.string().optional().allow(null, ""),
|
|
37283
|
+
site: import_joi93.default.string().required(),
|
|
37284
|
+
dateFrom: import_joi93.default.string().optional().allow(null, ""),
|
|
37285
|
+
dateTo: import_joi93.default.string().optional().allow(null, ""),
|
|
37286
|
+
unitId: import_joi93.default.string().required(),
|
|
37287
|
+
category: import_joi93.default.string().optional().allow(null, "")
|
|
37288
|
+
});
|
|
37289
|
+
const query = { ...req.query };
|
|
37290
|
+
const { error } = validation.validate(query, {
|
|
37291
|
+
abortEarly: false
|
|
37292
|
+
});
|
|
37293
|
+
if (error) {
|
|
37294
|
+
const messages = error.details.map((d) => d.message).join(", ");
|
|
37295
|
+
import_node_server_utils166.logger.log({ level: "error", message: messages });
|
|
37296
|
+
next(new import_node_server_utils166.BadRequestError(messages));
|
|
37297
|
+
return;
|
|
37298
|
+
}
|
|
37299
|
+
const search = req.query.search ?? "";
|
|
37300
|
+
const page = parseInt(req.query.page ?? "1");
|
|
37301
|
+
const limit = parseInt(req.query.limit ?? "10");
|
|
37302
|
+
const status = req.query.status ?? "active";
|
|
37303
|
+
const site = req.query.site;
|
|
37304
|
+
const dateFrom = req.query.dateFrom ?? "";
|
|
37305
|
+
const dateTo = req.query.dateTo ?? "";
|
|
37306
|
+
const unitId = req.query.unitId;
|
|
37307
|
+
const category = req.query.category ?? "";
|
|
37308
|
+
try {
|
|
37309
|
+
const data = await _getResidentUserSoa({
|
|
37310
|
+
search,
|
|
37311
|
+
page,
|
|
37312
|
+
limit,
|
|
37313
|
+
status,
|
|
37314
|
+
site,
|
|
37315
|
+
dateFrom,
|
|
37316
|
+
dateTo,
|
|
37317
|
+
unitId,
|
|
37318
|
+
category
|
|
37319
|
+
});
|
|
37320
|
+
res.status(200).json(data);
|
|
37321
|
+
return;
|
|
37322
|
+
} catch (error2) {
|
|
37323
|
+
import_node_server_utils166.logger.log({ level: "error", message: error2.message });
|
|
37324
|
+
next(error2);
|
|
37325
|
+
return;
|
|
37326
|
+
}
|
|
37327
|
+
}
|
|
37144
37328
|
return {
|
|
37145
37329
|
add,
|
|
37146
37330
|
getAll,
|
|
@@ -37148,7 +37332,8 @@ function useStatementOfAccountController() {
|
|
|
37148
37332
|
updateById,
|
|
37149
37333
|
deleteById,
|
|
37150
37334
|
generatePDF,
|
|
37151
|
-
updateStatusById
|
|
37335
|
+
updateStatusById,
|
|
37336
|
+
getResidentUserSoa
|
|
37152
37337
|
};
|
|
37153
37338
|
}
|
|
37154
37339
|
|
|
@@ -40231,7 +40416,7 @@ function useOccurrenceEntryService() {
|
|
|
40231
40416
|
value.signature = value.signature ? new import_mongodb108.ObjectId(value.signature) : occurrenceEntry.signature._id;
|
|
40232
40417
|
value.eSignature = value.eSignature ? new import_mongodb108.ObjectId(value.eSignature) : occurrenceEntry.eSignature;
|
|
40233
40418
|
value.createdAt = /* @__PURE__ */ new Date();
|
|
40234
|
-
value.date =
|
|
40419
|
+
value.date = value.date ? value.date : occurrenceEntry.date;
|
|
40235
40420
|
value.userName = value.userName ? value.userName : occurrenceEntry.signature.name;
|
|
40236
40421
|
value.createdByName = value.createdByName ? value.createdByName : occurrenceEntry.createdByName;
|
|
40237
40422
|
await _updateOccurrenceBookById(dobId, {
|
|
@@ -46640,13 +46825,117 @@ function useVerificationRepoV2() {
|
|
|
46640
46825
|
);
|
|
46641
46826
|
}
|
|
46642
46827
|
}
|
|
46828
|
+
async function getVerifications({
|
|
46829
|
+
search = "",
|
|
46830
|
+
page = 1,
|
|
46831
|
+
limit = 10,
|
|
46832
|
+
sort = {},
|
|
46833
|
+
status = "active",
|
|
46834
|
+
app = "",
|
|
46835
|
+
type = {},
|
|
46836
|
+
email = ""
|
|
46837
|
+
}) {
|
|
46838
|
+
page = page > 0 ? page - 1 : 0;
|
|
46839
|
+
const query = { status };
|
|
46840
|
+
const cacheOptions = {
|
|
46841
|
+
page,
|
|
46842
|
+
limit,
|
|
46843
|
+
status
|
|
46844
|
+
};
|
|
46845
|
+
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
46846
|
+
cacheOptions.sort = JSON.stringify(sort);
|
|
46847
|
+
if (search) {
|
|
46848
|
+
query.$text = { $search: search };
|
|
46849
|
+
cacheOptions.search = search;
|
|
46850
|
+
}
|
|
46851
|
+
if (app) {
|
|
46852
|
+
query["metadata.app"] = app;
|
|
46853
|
+
cacheOptions["metadata.app"] = app;
|
|
46854
|
+
}
|
|
46855
|
+
if (type && Object.keys(type).length > 0) {
|
|
46856
|
+
query.type = { $in: Object.keys(type) };
|
|
46857
|
+
cacheOptions.type = JSON.stringify(type);
|
|
46858
|
+
}
|
|
46859
|
+
if (email) {
|
|
46860
|
+
query.email = email;
|
|
46861
|
+
cacheOptions.email = email;
|
|
46862
|
+
}
|
|
46863
|
+
const cacheKey = (0, import_node_server_utils218.makeCacheKey)(namespace_collection, cacheOptions);
|
|
46864
|
+
const cachedData = await getCache(cacheKey);
|
|
46865
|
+
if (cachedData) {
|
|
46866
|
+
import_node_server_utils218.logger.info(`Cache hit for key: ${cacheKey}`);
|
|
46867
|
+
return cachedData;
|
|
46868
|
+
}
|
|
46869
|
+
try {
|
|
46870
|
+
const items = await collection.aggregate([
|
|
46871
|
+
{ $match: query },
|
|
46872
|
+
{ $sort: sort },
|
|
46873
|
+
{ $skip: page * limit },
|
|
46874
|
+
{ $limit: limit },
|
|
46875
|
+
{
|
|
46876
|
+
$project: {
|
|
46877
|
+
_id: 1,
|
|
46878
|
+
createdAt: 1,
|
|
46879
|
+
email: 1,
|
|
46880
|
+
type: 1,
|
|
46881
|
+
metadata: 1,
|
|
46882
|
+
status: 1
|
|
46883
|
+
}
|
|
46884
|
+
}
|
|
46885
|
+
]).toArray();
|
|
46886
|
+
const length = await collection.countDocuments(query);
|
|
46887
|
+
const data = (0, import_node_server_utils218.paginate)(items, page, limit, length);
|
|
46888
|
+
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
46889
|
+
import_node_server_utils218.logger.info(`Cache set for key: ${cacheKey}`);
|
|
46890
|
+
}).catch((err) => {
|
|
46891
|
+
import_node_server_utils218.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
|
|
46892
|
+
});
|
|
46893
|
+
return data;
|
|
46894
|
+
} catch (error) {
|
|
46895
|
+
import_node_server_utils218.logger.log({ level: "error", message: `${error}` });
|
|
46896
|
+
throw error;
|
|
46897
|
+
}
|
|
46898
|
+
}
|
|
46899
|
+
async function updateStatusById(_id, status, session) {
|
|
46900
|
+
try {
|
|
46901
|
+
_id = new import_mongodb127.ObjectId(_id);
|
|
46902
|
+
} catch (error) {
|
|
46903
|
+
throw new import_node_server_utils218.BadRequestError("Invalid verification ID format.");
|
|
46904
|
+
}
|
|
46905
|
+
try {
|
|
46906
|
+
const result = await collection.updateOne(
|
|
46907
|
+
{ _id },
|
|
46908
|
+
{ $set: { status, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } },
|
|
46909
|
+
{ session }
|
|
46910
|
+
);
|
|
46911
|
+
delNamespace().then(() => {
|
|
46912
|
+
import_node_server_utils218.logger.info(`Cache cleared for namespace: ${namespace_collection}`);
|
|
46913
|
+
}).catch((err) => {
|
|
46914
|
+
import_node_server_utils218.logger.error(
|
|
46915
|
+
`Failed to clear cache for namespace: ${namespace_collection}`,
|
|
46916
|
+
err
|
|
46917
|
+
);
|
|
46918
|
+
});
|
|
46919
|
+
const cacheKey = (0, import_node_server_utils218.makeCacheKey)(namespace_collection, { _id });
|
|
46920
|
+
delCache(cacheKey).then(() => {
|
|
46921
|
+
import_node_server_utils218.logger.info(`Cache deleted for key: ${cacheKey}`);
|
|
46922
|
+
}).catch((err) => {
|
|
46923
|
+
import_node_server_utils218.logger.error(`Failed to delete cache for key: ${cacheKey}`, err);
|
|
46924
|
+
});
|
|
46925
|
+
return result;
|
|
46926
|
+
} catch (error) {
|
|
46927
|
+
throw new import_node_server_utils218.InternalServerError("Error updating verification status.");
|
|
46928
|
+
}
|
|
46929
|
+
}
|
|
46643
46930
|
return {
|
|
46644
46931
|
createIndex,
|
|
46645
46932
|
createTextIndex,
|
|
46646
46933
|
add,
|
|
46647
46934
|
updateVerificationStatusById,
|
|
46648
46935
|
getByVerificationCode,
|
|
46649
|
-
getVerificationById
|
|
46936
|
+
getVerificationById,
|
|
46937
|
+
getVerifications,
|
|
46938
|
+
updateStatusById
|
|
46650
46939
|
};
|
|
46651
46940
|
}
|
|
46652
46941
|
|
|
@@ -46666,7 +46955,8 @@ function useVerificationServiceV2() {
|
|
|
46666
46955
|
const {
|
|
46667
46956
|
add: _add,
|
|
46668
46957
|
updateVerificationStatusById: _updateVerificationStatusById,
|
|
46669
|
-
getByVerificationCode: _getByVerificationCode
|
|
46958
|
+
getByVerificationCode: _getByVerificationCode,
|
|
46959
|
+
updateStatusById: _updateStatusById
|
|
46670
46960
|
} = useVerificationRepoV2();
|
|
46671
46961
|
const {
|
|
46672
46962
|
getUserByEmailStatus: _getUserByEmailStatus,
|
|
@@ -46971,12 +47261,22 @@ function useVerificationServiceV2() {
|
|
|
46971
47261
|
throw new import_node_server_utils219.InternalServerError("Failed to create forget password link.");
|
|
46972
47262
|
}
|
|
46973
47263
|
}
|
|
47264
|
+
async function cancelUserInvitation(id) {
|
|
47265
|
+
try {
|
|
47266
|
+
await _updateStatusById(id, "cancelled");
|
|
47267
|
+
} catch (error) {
|
|
47268
|
+
throw new import_node_server_utils219.InternalServerError(
|
|
47269
|
+
`Error cancelling user invitation: ${error}`
|
|
47270
|
+
);
|
|
47271
|
+
}
|
|
47272
|
+
}
|
|
46974
47273
|
return {
|
|
46975
47274
|
signUp,
|
|
46976
47275
|
verify,
|
|
46977
47276
|
createUserInvite,
|
|
46978
47277
|
createServiceProviderInvite,
|
|
46979
|
-
createForgetPassword
|
|
47278
|
+
createForgetPassword,
|
|
47279
|
+
cancelUserInvitation
|
|
46980
47280
|
};
|
|
46981
47281
|
}
|
|
46982
47282
|
|
|
@@ -46988,8 +47288,10 @@ function useVerificationControllerV2() {
|
|
|
46988
47288
|
verify: _verify,
|
|
46989
47289
|
createUserInvite: _createUserInvite,
|
|
46990
47290
|
createServiceProviderInvite: _createServiceProviderInvite,
|
|
46991
|
-
createForgetPassword: _createForgetPassword
|
|
47291
|
+
createForgetPassword: _createForgetPassword,
|
|
47292
|
+
cancelUserInvitation: _cancelUserInvitation
|
|
46992
47293
|
} = useVerificationServiceV2();
|
|
47294
|
+
const { getVerifications: _getVerifications } = useVerificationRepoV2();
|
|
46993
47295
|
async function verify(req, res, next) {
|
|
46994
47296
|
try {
|
|
46995
47297
|
const schema2 = import_joi126.default.object({ verificationCode: import_joi126.default.string().required() });
|
|
@@ -47105,11 +47407,71 @@ function useVerificationControllerV2() {
|
|
|
47105
47407
|
return;
|
|
47106
47408
|
}
|
|
47107
47409
|
}
|
|
47410
|
+
async function getVerifications(req, res, next) {
|
|
47411
|
+
const schema2 = import_joi126.default.object({
|
|
47412
|
+
search: import_joi126.default.string().optional().allow("", null),
|
|
47413
|
+
page: import_joi126.default.number().integer().min(1).allow("", null).default(1),
|
|
47414
|
+
status: import_joi126.default.string().required(),
|
|
47415
|
+
app: import_joi126.default.string().optional().allow("", null),
|
|
47416
|
+
type: import_joi126.default.alternatives().try(
|
|
47417
|
+
import_joi126.default.array().items(import_joi126.default.string()),
|
|
47418
|
+
import_joi126.default.string().custom((value2) => value2.split(","))
|
|
47419
|
+
).optional().allow("", null),
|
|
47420
|
+
email: import_joi126.default.string().optional().allow("", null)
|
|
47421
|
+
});
|
|
47422
|
+
const { error, value } = schema2.validate(req.query);
|
|
47423
|
+
if (error) {
|
|
47424
|
+
const messages = error.details.map((d) => d.message).join(", ");
|
|
47425
|
+
import_node_server_utils220.logger.log({ level: "error", message: messages });
|
|
47426
|
+
next(new import_node_server_utils220.BadRequestError(messages));
|
|
47427
|
+
return;
|
|
47428
|
+
}
|
|
47429
|
+
const { search, page, status, app, email, type } = value;
|
|
47430
|
+
try {
|
|
47431
|
+
const data = await _getVerifications({
|
|
47432
|
+
search,
|
|
47433
|
+
page,
|
|
47434
|
+
status,
|
|
47435
|
+
app,
|
|
47436
|
+
type,
|
|
47437
|
+
email
|
|
47438
|
+
});
|
|
47439
|
+
res.json(data);
|
|
47440
|
+
return;
|
|
47441
|
+
} catch (error2) {
|
|
47442
|
+
import_node_server_utils220.logger.log({ level: "error", message: `${error2.message}` });
|
|
47443
|
+
next(error2);
|
|
47444
|
+
return;
|
|
47445
|
+
}
|
|
47446
|
+
}
|
|
47447
|
+
async function cancelUserInvitation(req, res, next) {
|
|
47448
|
+
const validation = import_joi126.default.string().hex().required();
|
|
47449
|
+
const otpId = req.params.id;
|
|
47450
|
+
const { error } = validation.validate(otpId);
|
|
47451
|
+
if (error) {
|
|
47452
|
+
import_node_server_utils220.logger.log({ level: "error", message: `${error.message}` });
|
|
47453
|
+
next(new import_node_server_utils220.BadRequestError(error.message));
|
|
47454
|
+
return;
|
|
47455
|
+
}
|
|
47456
|
+
try {
|
|
47457
|
+
await _cancelUserInvitation(otpId);
|
|
47458
|
+
res.json({
|
|
47459
|
+
message: "User invite has been cancelled."
|
|
47460
|
+
});
|
|
47461
|
+
return;
|
|
47462
|
+
} catch (error2) {
|
|
47463
|
+
import_node_server_utils220.logger.log({ level: "error", message: `${error2.message}` });
|
|
47464
|
+
next(error2);
|
|
47465
|
+
return;
|
|
47466
|
+
}
|
|
47467
|
+
}
|
|
47108
47468
|
return {
|
|
47109
47469
|
verify,
|
|
47110
47470
|
createUserInvite,
|
|
47111
47471
|
createServiceProviderInvite,
|
|
47112
|
-
createForgetPassword
|
|
47472
|
+
createForgetPassword,
|
|
47473
|
+
getVerifications,
|
|
47474
|
+
cancelUserInvitation
|
|
47113
47475
|
};
|
|
47114
47476
|
}
|
|
47115
47477
|
|