@7365admin1/core 3.7.0 → 3.7.1
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 +6 -0
- package/dist/index.d.ts +7 -6
- package/dist/index.js +147 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +147 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -428,12 +428,12 @@ type TKeyValuePair<K extends string | number | symbol = string, V = any> = {
|
|
|
428
428
|
};
|
|
429
429
|
|
|
430
430
|
declare function useVerificationService(): {
|
|
431
|
-
createUserInvite: ({ email, metadata }: {
|
|
431
|
+
createUserInvite: ({ email, metadata, }: {
|
|
432
432
|
email: string;
|
|
433
433
|
metadata: TKeyValuePair;
|
|
434
434
|
}) => Promise<bson.ObjectId>;
|
|
435
435
|
createForgetPassword: (email: string) => Promise<string>;
|
|
436
|
-
createServiceProviderInvite: ({ email, orgId, siteId, siteName }: {
|
|
436
|
+
createServiceProviderInvite: ({ email, orgId, siteId, siteName, }: {
|
|
437
437
|
email: string;
|
|
438
438
|
orgId: string;
|
|
439
439
|
siteId: string;
|
|
@@ -443,20 +443,20 @@ declare function useVerificationService(): {
|
|
|
443
443
|
verify: (id: string) => Promise<TVerification>;
|
|
444
444
|
cancelUserInvitation: (id: string) => Promise<void>;
|
|
445
445
|
updateStatusById: (_id: string, status: string) => Promise<string>;
|
|
446
|
-
signUp: ({ email, metadata }: {
|
|
446
|
+
signUp: ({ email, metadata, }: {
|
|
447
447
|
email: string;
|
|
448
448
|
metadata: TKeyValuePair;
|
|
449
449
|
}) => Promise<bson.ObjectId>;
|
|
450
450
|
checkExpiredInvitation: () => Promise<string>;
|
|
451
|
-
createSimpleUserInvite: ({ email, metadata }: {
|
|
451
|
+
createSimpleUserInvite: ({ email, metadata, }: {
|
|
452
452
|
email: string;
|
|
453
453
|
metadata: TKeyValuePair;
|
|
454
454
|
}) => Promise<string[]>;
|
|
455
|
-
createSimpleMemberInvite: ({ email, metadata }: {
|
|
455
|
+
createSimpleMemberInvite: ({ email, metadata, }: {
|
|
456
456
|
email: string;
|
|
457
457
|
metadata: TKeyValuePair;
|
|
458
458
|
}) => Promise<bson.ObjectId>;
|
|
459
|
-
createSimpleServiceProviderInvite: ({ email, app, name, role, orgId, siteId, siteName }: {
|
|
459
|
+
createSimpleServiceProviderInvite: ({ email, app, name, role, orgId, siteId, siteName, }: {
|
|
460
460
|
email: string;
|
|
461
461
|
app?: string | undefined;
|
|
462
462
|
name?: string | undefined;
|
|
@@ -2357,6 +2357,7 @@ declare function useVehicleRepo(): {
|
|
|
2357
2357
|
pageRange: string;
|
|
2358
2358
|
}>;
|
|
2359
2359
|
getVehicleBySiteAndPlateNumber: (plateNumber: string, site: string | ObjectId, category: string | ObjectId, status: string) => Promise<TVehicle | null>;
|
|
2360
|
+
getBlocklistedVehicleByPlateNumber: (plateNumber: string, site?: string) => Promise<bson.Document>;
|
|
2360
2361
|
};
|
|
2361
2362
|
|
|
2362
2363
|
declare function formatDahuaDate(date: Date): string;
|
package/dist/index.js
CHANGED
|
@@ -12253,9 +12253,7 @@ function useVerificationService() {
|
|
|
12253
12253
|
...metadata,
|
|
12254
12254
|
app
|
|
12255
12255
|
},
|
|
12256
|
-
expireAt: new Date(
|
|
12257
|
-
Date.now() + 72 * 60 * 60 * 1e3
|
|
12258
|
-
).toISOString(),
|
|
12256
|
+
expireAt: new Date(Date.now() + 72 * 60 * 60 * 1e3).toISOString(),
|
|
12259
12257
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
12260
12258
|
};
|
|
12261
12259
|
const createdId = await add(value);
|
|
@@ -12274,10 +12272,7 @@ function useVerificationService() {
|
|
|
12274
12272
|
hasPestControl: app === "pest_control_services",
|
|
12275
12273
|
hasPoolMaintenance: app === "pool_maintenance_services"
|
|
12276
12274
|
},
|
|
12277
|
-
filePath: (0, import_node_server_utils21.getDirectory)(
|
|
12278
|
-
__dirname,
|
|
12279
|
-
"./public/handlebars/user-invite"
|
|
12280
|
-
)
|
|
12275
|
+
filePath: (0, import_node_server_utils21.getDirectory)(__dirname, "./public/handlebars/user-invite")
|
|
12281
12276
|
});
|
|
12282
12277
|
await mailer.sendMail({
|
|
12283
12278
|
to: email,
|
|
@@ -12420,7 +12415,15 @@ function useVerificationService() {
|
|
|
12420
12415
|
throw error2;
|
|
12421
12416
|
}
|
|
12422
12417
|
}
|
|
12423
|
-
async function createSimpleServiceProviderInvite({
|
|
12418
|
+
async function createSimpleServiceProviderInvite({
|
|
12419
|
+
email,
|
|
12420
|
+
app,
|
|
12421
|
+
name,
|
|
12422
|
+
role,
|
|
12423
|
+
orgId,
|
|
12424
|
+
siteId,
|
|
12425
|
+
siteName
|
|
12426
|
+
}) {
|
|
12424
12427
|
const schema2 = import_joi11.default.object({
|
|
12425
12428
|
email: import_joi11.default.string().email().lowercase().required(),
|
|
12426
12429
|
app: import_joi11.default.string().allow("", null),
|
|
@@ -12462,7 +12465,10 @@ function useVerificationService() {
|
|
|
12462
12465
|
};
|
|
12463
12466
|
try {
|
|
12464
12467
|
const id = await _add(value);
|
|
12465
|
-
const filePath = (0, import_node_server_utils21.getDirectory)(
|
|
12468
|
+
const filePath = (0, import_node_server_utils21.getDirectory)(
|
|
12469
|
+
__dirname,
|
|
12470
|
+
`./public/handlebars/${value.type}`
|
|
12471
|
+
);
|
|
12466
12472
|
const link = `${APP_MAIN}/verify/${value.type}/${id}`;
|
|
12467
12473
|
const emailContent = (0, import_node_server_utils21.compileHandlebar)({
|
|
12468
12474
|
context: {
|
|
@@ -21254,6 +21260,15 @@ async function convertObjectIdUtil(id) {
|
|
|
21254
21260
|
return Promise.reject("Invalid ID conversion to ObjectId");
|
|
21255
21261
|
}
|
|
21256
21262
|
}
|
|
21263
|
+
async function convertObjectIdUtil2(id, fieldName) {
|
|
21264
|
+
try {
|
|
21265
|
+
if (!id)
|
|
21266
|
+
throw new Error(`Invalid ID conversion to ObjectId of ${fieldName}.`);
|
|
21267
|
+
return new import_mongodb40.ObjectId(id);
|
|
21268
|
+
} catch (_) {
|
|
21269
|
+
throw new Error(`Invalid ID conversion to ObjectId of ${fieldName}.`);
|
|
21270
|
+
}
|
|
21271
|
+
}
|
|
21257
21272
|
|
|
21258
21273
|
// src/repositories/visitor-transaction.repo.ts
|
|
21259
21274
|
var import_moment_timezone = __toESM(require("moment-timezone"));
|
|
@@ -23047,6 +23062,38 @@ function useVehicleRepo() {
|
|
|
23047
23062
|
throw error;
|
|
23048
23063
|
}
|
|
23049
23064
|
}
|
|
23065
|
+
async function getBlocklistedVehicleByPlateNumber(plateNumber, site) {
|
|
23066
|
+
if (!plateNumber) {
|
|
23067
|
+
throw new import_node_server_utils71.BadRequestError("Plate number is required");
|
|
23068
|
+
}
|
|
23069
|
+
const baseQuery = {
|
|
23070
|
+
type: "blocklist" /* BLOCKLIST */,
|
|
23071
|
+
plateNumber,
|
|
23072
|
+
...site && {
|
|
23073
|
+
site: typeof site === "string" ? new import_mongodb43.ObjectId(site) : site
|
|
23074
|
+
}
|
|
23075
|
+
};
|
|
23076
|
+
try {
|
|
23077
|
+
const pipeline = [
|
|
23078
|
+
{ $match: baseQuery },
|
|
23079
|
+
{
|
|
23080
|
+
$addFields: {
|
|
23081
|
+
latestDate: { $max: ["$createdAt", "$updatedAt"] }
|
|
23082
|
+
}
|
|
23083
|
+
},
|
|
23084
|
+
{ $sort: { latestDate: -1 } },
|
|
23085
|
+
{
|
|
23086
|
+
$project: {
|
|
23087
|
+
latestDate: 0
|
|
23088
|
+
}
|
|
23089
|
+
}
|
|
23090
|
+
];
|
|
23091
|
+
const [result] = await collection.aggregate(pipeline).toArray();
|
|
23092
|
+
return result;
|
|
23093
|
+
} catch (error) {
|
|
23094
|
+
throw error;
|
|
23095
|
+
}
|
|
23096
|
+
}
|
|
23050
23097
|
return {
|
|
23051
23098
|
createIndex,
|
|
23052
23099
|
createTextIndex,
|
|
@@ -23065,7 +23112,8 @@ function useVehicleRepo() {
|
|
|
23065
23112
|
bulkUpsertVehicles,
|
|
23066
23113
|
getSpecificVehicleById,
|
|
23067
23114
|
getBlocklistedVehicles,
|
|
23068
|
-
getVehicleBySiteAndPlateNumber
|
|
23115
|
+
getVehicleBySiteAndPlateNumber,
|
|
23116
|
+
getBlocklistedVehicleByPlateNumber
|
|
23069
23117
|
};
|
|
23070
23118
|
}
|
|
23071
23119
|
|
|
@@ -33400,6 +33448,71 @@ var KeyRepo = class {
|
|
|
33400
33448
|
return Promise.reject("Failed to delete key");
|
|
33401
33449
|
}
|
|
33402
33450
|
}
|
|
33451
|
+
static async getById2(id) {
|
|
33452
|
+
return this.collection().aggregate([
|
|
33453
|
+
{ $match: { _id: new import_mongodb61.ObjectId(id) } },
|
|
33454
|
+
{
|
|
33455
|
+
$lookup: {
|
|
33456
|
+
from: "qr-code-templates",
|
|
33457
|
+
localField: "template",
|
|
33458
|
+
foreignField: "_id",
|
|
33459
|
+
as: "QRTemplateInfo"
|
|
33460
|
+
}
|
|
33461
|
+
},
|
|
33462
|
+
{
|
|
33463
|
+
$unwind: {
|
|
33464
|
+
path: "$QRTemplateInfo",
|
|
33465
|
+
preserveNullAndEmptyArrays: true
|
|
33466
|
+
}
|
|
33467
|
+
},
|
|
33468
|
+
{
|
|
33469
|
+
$addFields: {
|
|
33470
|
+
prefixPass: { $toUpper: "$QRTemplateInfo.prefixPass" },
|
|
33471
|
+
prefixKey: { $toUpper: "$QRTemplateInfo.prefixKey" },
|
|
33472
|
+
templateName: "$QRTemplateInfo.name"
|
|
33473
|
+
}
|
|
33474
|
+
},
|
|
33475
|
+
{
|
|
33476
|
+
$addFields: {
|
|
33477
|
+
prefixAndName: {
|
|
33478
|
+
$cond: {
|
|
33479
|
+
if: { $or: [{ $not: "$prefixPass" }, { $not: "$prefixKey" }] },
|
|
33480
|
+
then: "$name",
|
|
33481
|
+
else: {
|
|
33482
|
+
$cond: {
|
|
33483
|
+
if: { $eq: ["$passType", "pass-key"] },
|
|
33484
|
+
then: { $concat: ["$prefixKey", "$name"] },
|
|
33485
|
+
else: { $concat: ["$prefixPass", "$name"] }
|
|
33486
|
+
}
|
|
33487
|
+
}
|
|
33488
|
+
}
|
|
33489
|
+
}
|
|
33490
|
+
}
|
|
33491
|
+
}
|
|
33492
|
+
]).toArray().then((results) => results.length ? results[0] : null);
|
|
33493
|
+
}
|
|
33494
|
+
static async checkPassKeyAvailability(visitorPass, passKeys) {
|
|
33495
|
+
if (Array.isArray(visitorPass) && visitorPass.length > 0) {
|
|
33496
|
+
for (let i = 0; i < visitorPass.length; i++) {
|
|
33497
|
+
let pass = await convertObjectIdUtil2(visitorPass[i].keyId, "Pass ID");
|
|
33498
|
+
const getPass = await this.getById2(pass);
|
|
33499
|
+
if (!getPass)
|
|
33500
|
+
throw new Error("Pass not found");
|
|
33501
|
+
if (getPass?.status && getPass?.status.toLowerCase() != "Available".toLowerCase())
|
|
33502
|
+
throw new Error(`Pass ${getPass?.prefixAndName} is ${getPass?.status}`);
|
|
33503
|
+
}
|
|
33504
|
+
}
|
|
33505
|
+
if (Array.isArray(passKeys) && passKeys.length > 0) {
|
|
33506
|
+
for (let i = 0; i < passKeys.length; i++) {
|
|
33507
|
+
let key = await convertObjectIdUtil2(passKeys[i].keyId, "Key ID");
|
|
33508
|
+
const getPass = await this.getById2(key);
|
|
33509
|
+
if (!getPass)
|
|
33510
|
+
throw new Error(`Key not found`);
|
|
33511
|
+
if (getPass?.status && getPass?.status.toLowerCase() != "Available".toLowerCase())
|
|
33512
|
+
throw new Error(`Pass ${getPass?.prefixAndName} is ${getPass?.status}`);
|
|
33513
|
+
}
|
|
33514
|
+
}
|
|
33515
|
+
}
|
|
33403
33516
|
};
|
|
33404
33517
|
|
|
33405
33518
|
// src/services/visitor-transaction.service.ts
|
|
@@ -33436,7 +33549,9 @@ function useVisitorTransactionService() {
|
|
|
33436
33549
|
} = useDahuaService();
|
|
33437
33550
|
const { getAllSites: _getAllSites } = useSiteRepo();
|
|
33438
33551
|
const { getByUserId: _getByUserId } = usePersonRepo();
|
|
33439
|
-
const {
|
|
33552
|
+
const {
|
|
33553
|
+
getBlocklistedVehicleByPlateNumber: _getBlocklistedVehicleByPlateNumber
|
|
33554
|
+
} = useVehicleRepo();
|
|
33440
33555
|
const { getById: _getUnitById } = useBuildingUnitRepo();
|
|
33441
33556
|
function extractKeyId(item) {
|
|
33442
33557
|
if (!item)
|
|
@@ -33514,6 +33629,13 @@ function useVisitorTransactionService() {
|
|
|
33514
33629
|
const start = value.checkIn ? new Date(value.checkIn) : /* @__PURE__ */ new Date();
|
|
33515
33630
|
try {
|
|
33516
33631
|
session?.startTransaction();
|
|
33632
|
+
if (value.plateNumber) {
|
|
33633
|
+
const result2 = await _getBlocklistedVehicleByPlateNumber(
|
|
33634
|
+
value.plateNumber
|
|
33635
|
+
);
|
|
33636
|
+
if (result2)
|
|
33637
|
+
throw new import_node_server_utils106.BadRequestError("Plate number is blocklisted");
|
|
33638
|
+
}
|
|
33517
33639
|
let camera;
|
|
33518
33640
|
if (value.site && value.plateNumber) {
|
|
33519
33641
|
try {
|
|
@@ -33579,6 +33701,7 @@ function useVisitorTransactionService() {
|
|
|
33579
33701
|
for (let i = 0; i < value.members.length; i += chunkSize) {
|
|
33580
33702
|
const chunk = value.members.slice(i, i + chunkSize);
|
|
33581
33703
|
for (const member of chunk) {
|
|
33704
|
+
await KeyRepo.checkPassKeyAvailability(member.visitorPass, member.passKeys);
|
|
33582
33705
|
if (member.visitorPass && Array.isArray(member.visitorPass) && member.visitorPass.length > 0) {
|
|
33583
33706
|
for (const vp of member.visitorPass) {
|
|
33584
33707
|
try {
|
|
@@ -33665,6 +33788,7 @@ function useVisitorTransactionService() {
|
|
|
33665
33788
|
if (found === 1)
|
|
33666
33789
|
throw new import_node_server_utils106.BadRequestError("This plate number is blocklisted");
|
|
33667
33790
|
}
|
|
33791
|
+
await KeyRepo.checkPassKeyAvailability(value.visitorPass, value.passKeys);
|
|
33668
33792
|
if (value.visitorPass && Array.isArray(value.visitorPass) && value.visitorPass.length > 0 && value.visitorPass) {
|
|
33669
33793
|
for (const vp of value.visitorPass) {
|
|
33670
33794
|
try {
|
|
@@ -33712,7 +33836,9 @@ function useVisitorTransactionService() {
|
|
|
33712
33836
|
password,
|
|
33713
33837
|
plateNumber: value?.plateNumber
|
|
33714
33838
|
});
|
|
33715
|
-
import_node_server_utils106.logger.info(`Barrier command sent successfully to ${host}`, {
|
|
33839
|
+
import_node_server_utils106.logger.info(`Barrier command sent successfully to ${host}`, {
|
|
33840
|
+
response: openBarrier
|
|
33841
|
+
});
|
|
33716
33842
|
} catch (error) {
|
|
33717
33843
|
import_node_server_utils106.logger.error(
|
|
33718
33844
|
`Failed to open barrier at host ${host}. Critical system error:`,
|
|
@@ -33852,7 +33978,9 @@ function useVisitorTransactionService() {
|
|
|
33852
33978
|
password,
|
|
33853
33979
|
plateNumber: value?.plateNumber
|
|
33854
33980
|
});
|
|
33855
|
-
import_node_server_utils106.logger.info(`Barrier command sent successfully to ${host}`, {
|
|
33981
|
+
import_node_server_utils106.logger.info(`Barrier command sent successfully to ${host}`, {
|
|
33982
|
+
response: openBarrier
|
|
33983
|
+
});
|
|
33856
33984
|
} catch (error) {
|
|
33857
33985
|
import_node_server_utils106.logger.error(
|
|
33858
33986
|
`Failed to open barrier at host ${host}. Critical system error:`,
|
|
@@ -34065,7 +34193,12 @@ function useVisitorTransactionController() {
|
|
|
34065
34193
|
return;
|
|
34066
34194
|
} catch (error) {
|
|
34067
34195
|
import_node_server_utils107.logger.log({ level: "error", message: error.message });
|
|
34068
|
-
|
|
34196
|
+
console.log("error", error);
|
|
34197
|
+
if (error?.message) {
|
|
34198
|
+
next(new import_node_server_utils107.BadRequestError(error?.message));
|
|
34199
|
+
} else {
|
|
34200
|
+
next(error);
|
|
34201
|
+
}
|
|
34069
34202
|
return;
|
|
34070
34203
|
}
|
|
34071
34204
|
}
|