@7365admin1/core 2.12.0 → 2.13.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 +6 -0
- package/dist/index.d.ts +43 -4
- package/dist/index.js +582 -117
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +582 -117
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4968,7 +4968,8 @@ function useMemberRepo() {
|
|
|
4968
4968
|
try {
|
|
4969
4969
|
const data = await collection.find({
|
|
4970
4970
|
role: { $in: roles },
|
|
4971
|
-
type,
|
|
4971
|
+
// type,
|
|
4972
|
+
// ...(type && { type }),
|
|
4972
4973
|
status: "active"
|
|
4973
4974
|
}).toArray();
|
|
4974
4975
|
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
@@ -7073,7 +7074,7 @@ function useMemberService() {
|
|
|
7073
7074
|
throw new import_node_server_utils30.BadRequestError("No owner role found.");
|
|
7074
7075
|
}
|
|
7075
7076
|
const roles = owner.map((r) => r._id?.toString() ?? "");
|
|
7076
|
-
const ownerMembers = await getByRoles(roles, type);
|
|
7077
|
+
const ownerMembers = await getByRoles(roles, type = "");
|
|
7077
7078
|
if (!ownerMembers.length) {
|
|
7078
7079
|
throw new import_node_server_utils30.BadRequestError("No owner members found.");
|
|
7079
7080
|
}
|
|
@@ -14733,7 +14734,7 @@ function MPerson(value) {
|
|
|
14733
14734
|
return {
|
|
14734
14735
|
_id: value._id,
|
|
14735
14736
|
name: value.name,
|
|
14736
|
-
contact: value.contact,
|
|
14737
|
+
contact: value.contact ?? "",
|
|
14737
14738
|
block: value.block,
|
|
14738
14739
|
level: value.level,
|
|
14739
14740
|
unit: value.unit,
|
|
@@ -15186,7 +15187,8 @@ function usePersonRepo() {
|
|
|
15186
15187
|
$or: [
|
|
15187
15188
|
{ name: { $regex: search, $options: "i" } },
|
|
15188
15189
|
{ email: { $regex: search, $options: "i" } },
|
|
15189
|
-
{ nric: { $regex: search, $options: "i" } }
|
|
15190
|
+
{ nric: { $regex: search, $options: "i" } },
|
|
15191
|
+
{ "plates.plateNumber": { $regex: search, $options: "i" } }
|
|
15190
15192
|
]
|
|
15191
15193
|
},
|
|
15192
15194
|
...import_mongodb44.ObjectId.isValid(org) && { org: new import_mongodb44.ObjectId(org) },
|
|
@@ -18559,7 +18561,7 @@ function useVisitorTransactionService() {
|
|
|
18559
18561
|
} else {
|
|
18560
18562
|
const payload = {
|
|
18561
18563
|
name: value.name || "",
|
|
18562
|
-
contact: value.contact,
|
|
18564
|
+
contact: value.contact ?? "",
|
|
18563
18565
|
nric,
|
|
18564
18566
|
type: value.type,
|
|
18565
18567
|
companyName: value.company ? [value.company] : [],
|
|
@@ -23627,16 +23629,26 @@ function useDocumentManagementRepo() {
|
|
|
23627
23629
|
site = ""
|
|
23628
23630
|
}) {
|
|
23629
23631
|
page = page > 0 ? page - 1 : 0;
|
|
23632
|
+
try {
|
|
23633
|
+
site = new import_mongodb70.ObjectId(site);
|
|
23634
|
+
} catch (error) {
|
|
23635
|
+
throw new import_node_server_utils128.BadRequestError("Invalid site ID format.");
|
|
23636
|
+
}
|
|
23630
23637
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
23631
23638
|
const cacheOptions = {
|
|
23632
23639
|
page,
|
|
23633
23640
|
limit,
|
|
23634
23641
|
status,
|
|
23642
|
+
site: site?.toString(),
|
|
23635
23643
|
sort: JSON.stringify(sort)
|
|
23636
23644
|
};
|
|
23637
23645
|
const query = {
|
|
23638
23646
|
...status ? { $and: [{ status }, { status: { $ne: "deleted" } }] } : { status: { $ne: "deleted" } }
|
|
23639
23647
|
};
|
|
23648
|
+
if (site) {
|
|
23649
|
+
query.site = site;
|
|
23650
|
+
cacheOptions.site = site;
|
|
23651
|
+
}
|
|
23640
23652
|
if (search) {
|
|
23641
23653
|
query.$or = [
|
|
23642
23654
|
{ name: { $regex: search, $options: "i" } },
|
|
@@ -27249,11 +27261,11 @@ var EAccessCardTypes = /* @__PURE__ */ ((EAccessCardTypes2) => {
|
|
|
27249
27261
|
EAccessCardTypes2["QR"] = "QRCODE";
|
|
27250
27262
|
return EAccessCardTypes2;
|
|
27251
27263
|
})(EAccessCardTypes || {});
|
|
27252
|
-
var EAccessCardUserTypes = /* @__PURE__ */ ((
|
|
27253
|
-
|
|
27254
|
-
|
|
27255
|
-
|
|
27256
|
-
return
|
|
27264
|
+
var EAccessCardUserTypes = /* @__PURE__ */ ((EAccessCardUserTypes3) => {
|
|
27265
|
+
EAccessCardUserTypes3["RESIDENT"] = "Resident/Tenant";
|
|
27266
|
+
EAccessCardUserTypes3["CONTRACTOR"] = "Contractor";
|
|
27267
|
+
EAccessCardUserTypes3["VISITOR"] = "Visitor";
|
|
27268
|
+
return EAccessCardUserTypes3;
|
|
27257
27269
|
})(EAccessCardUserTypes || {});
|
|
27258
27270
|
var AccessTypeProps = /* @__PURE__ */ ((AccessTypeProps2) => {
|
|
27259
27271
|
AccessTypeProps2["NORMAL"] = "Normal";
|
|
@@ -27350,6 +27362,114 @@ var MAccessCard = class {
|
|
|
27350
27362
|
// src/repositories/access-management.repo.ts
|
|
27351
27363
|
var import_node_server_utils149 = require("@7365admin1/node-server-utils");
|
|
27352
27364
|
var import_mongodb83 = require("mongodb");
|
|
27365
|
+
|
|
27366
|
+
// src/utils/access-management.ts
|
|
27367
|
+
var import_fs2 = __toESM(require("fs"));
|
|
27368
|
+
var import_path = __toESM(require("path"));
|
|
27369
|
+
var import_axios = __toESM(require("axios"));
|
|
27370
|
+
var import_crypto = __toESM(require("crypto"));
|
|
27371
|
+
var ALGORITHM = "aes-256-gcm";
|
|
27372
|
+
var SECRET_KEY = import_crypto.default.createSecretKey(
|
|
27373
|
+
new Uint8Array(import_crypto.default.createHash("sha256").update("acm-secret-key").digest())
|
|
27374
|
+
);
|
|
27375
|
+
function decryptAcmUrl(encryptedText) {
|
|
27376
|
+
const [ivB64, authTagB64, encryptedB64] = encryptedText.split(":");
|
|
27377
|
+
const iv = Buffer.from(ivB64, "base64");
|
|
27378
|
+
const authTag = Buffer.from(authTagB64, "base64");
|
|
27379
|
+
const encrypted = Buffer.from(encryptedB64, "base64");
|
|
27380
|
+
const decipher = import_crypto.default.createDecipheriv(
|
|
27381
|
+
ALGORITHM,
|
|
27382
|
+
SECRET_KEY,
|
|
27383
|
+
new Uint8Array(iv)
|
|
27384
|
+
);
|
|
27385
|
+
decipher.setAuthTag(new Uint8Array(authTag));
|
|
27386
|
+
const decrypted = Buffer.concat([
|
|
27387
|
+
decipher.update(encrypted),
|
|
27388
|
+
decipher.final()
|
|
27389
|
+
]);
|
|
27390
|
+
return decrypted.toString("utf8");
|
|
27391
|
+
}
|
|
27392
|
+
var minifyXml = (xml) => {
|
|
27393
|
+
return xml.replace(/>\s+</g, "><").replace(/\n/g, "").replace(/\r/g, "").replace(/\t/g, "").trim();
|
|
27394
|
+
};
|
|
27395
|
+
var readTemplate = (name, params) => {
|
|
27396
|
+
const template = import_fs2.default.readFileSync(
|
|
27397
|
+
import_path.default.join(__dirname, `../src/public/xml-templates/${name}.xml`),
|
|
27398
|
+
"utf-8"
|
|
27399
|
+
);
|
|
27400
|
+
if (!params)
|
|
27401
|
+
return minifyXml(template);
|
|
27402
|
+
const replacedTemplate = Object.entries(params).reduce(
|
|
27403
|
+
(acc, [key, value]) => acc.replace(`{{${key}}}`, value),
|
|
27404
|
+
template
|
|
27405
|
+
);
|
|
27406
|
+
return minifyXml(replacedTemplate);
|
|
27407
|
+
};
|
|
27408
|
+
async function sendCommand(command, url) {
|
|
27409
|
+
try {
|
|
27410
|
+
const decrypt = decryptAcmUrl(url);
|
|
27411
|
+
const response = await import_axios.default.post(decrypt, {
|
|
27412
|
+
command
|
|
27413
|
+
});
|
|
27414
|
+
if (response.status === 200 || response.status === 201)
|
|
27415
|
+
return response.data;
|
|
27416
|
+
} catch (error) {
|
|
27417
|
+
return Promise.reject(error);
|
|
27418
|
+
}
|
|
27419
|
+
}
|
|
27420
|
+
var formatDoorAccessLevels = (data) => {
|
|
27421
|
+
const doorAccessLevels = data.RESULT.TRACKID.SUB_RESULT.ACCESS_LEVEL;
|
|
27422
|
+
return doorAccessLevels.map((door) => {
|
|
27423
|
+
return {
|
|
27424
|
+
name: door._.trim(),
|
|
27425
|
+
// Remove any leading/trailing spaces
|
|
27426
|
+
no: door.$.NO
|
|
27427
|
+
// Extract the number
|
|
27428
|
+
};
|
|
27429
|
+
});
|
|
27430
|
+
};
|
|
27431
|
+
var formatLiftAccessLevels = (data, search) => {
|
|
27432
|
+
const liftAccessLevels = data.RESULT.TRACKID.SUB_RESULT.LIFT_ACCESS_LEVEL;
|
|
27433
|
+
const result = liftAccessLevels.map((level) => {
|
|
27434
|
+
return {
|
|
27435
|
+
name: level._.trim(),
|
|
27436
|
+
no: level.$.NO
|
|
27437
|
+
};
|
|
27438
|
+
});
|
|
27439
|
+
if (search) {
|
|
27440
|
+
return result.filter(
|
|
27441
|
+
(item) => item.name.toLowerCase().includes(search.toLowerCase())
|
|
27442
|
+
);
|
|
27443
|
+
}
|
|
27444
|
+
return result;
|
|
27445
|
+
};
|
|
27446
|
+
var formatAccessGroup = (data, search) => {
|
|
27447
|
+
const accessGroup = data.RESULT.TRACKID.SUB_RESULT.ACCESS_GROUP;
|
|
27448
|
+
const result = accessGroup.map((ag) => {
|
|
27449
|
+
return {
|
|
27450
|
+
no: ag._.trim(),
|
|
27451
|
+
name: ag.$.NAME
|
|
27452
|
+
};
|
|
27453
|
+
});
|
|
27454
|
+
if (search) {
|
|
27455
|
+
return result.filter(
|
|
27456
|
+
(item) => item.name.toLowerCase().includes(search.toLowerCase())
|
|
27457
|
+
);
|
|
27458
|
+
}
|
|
27459
|
+
return result;
|
|
27460
|
+
};
|
|
27461
|
+
var formatEntryPassDate = (date) => {
|
|
27462
|
+
if (!date)
|
|
27463
|
+
return null;
|
|
27464
|
+
const newDate = new Date(date);
|
|
27465
|
+
const year = newDate.getFullYear();
|
|
27466
|
+
const month = String(newDate.getMonth() + 1).padStart(2, "0");
|
|
27467
|
+
const day = String(newDate.getDate()).padStart(2, "0");
|
|
27468
|
+
return `${year}${month}${day}`;
|
|
27469
|
+
};
|
|
27470
|
+
|
|
27471
|
+
// src/repositories/access-management.repo.ts
|
|
27472
|
+
var import_xml2js = require("xml2js");
|
|
27353
27473
|
function UseAccessManagementRepo() {
|
|
27354
27474
|
function collection() {
|
|
27355
27475
|
const db = import_node_server_utils149.useAtlas.getDb();
|
|
@@ -28135,6 +28255,255 @@ function UseAccessManagementRepo() {
|
|
|
28135
28255
|
await session?.endSession();
|
|
28136
28256
|
}
|
|
28137
28257
|
}
|
|
28258
|
+
async function accessandLiftCardsRepo(params) {
|
|
28259
|
+
try {
|
|
28260
|
+
const { accessLevel, liftAccessLevel, site, userType, type } = params;
|
|
28261
|
+
const siteId = new import_mongodb83.ObjectId(site);
|
|
28262
|
+
const query = {
|
|
28263
|
+
site: { $in: [siteId] },
|
|
28264
|
+
userType,
|
|
28265
|
+
type,
|
|
28266
|
+
userId: null,
|
|
28267
|
+
assignedUnit: null,
|
|
28268
|
+
accessLevel,
|
|
28269
|
+
liftAccessLevel,
|
|
28270
|
+
isActivated: true
|
|
28271
|
+
};
|
|
28272
|
+
const result = await collection().aggregate([
|
|
28273
|
+
{
|
|
28274
|
+
$match: query
|
|
28275
|
+
},
|
|
28276
|
+
{
|
|
28277
|
+
$facet: {
|
|
28278
|
+
counts: [{ $count: "count" }]
|
|
28279
|
+
}
|
|
28280
|
+
}
|
|
28281
|
+
], { allowDiskUse: true }).toArray();
|
|
28282
|
+
return result;
|
|
28283
|
+
} catch (error) {
|
|
28284
|
+
throw new Error(error.message);
|
|
28285
|
+
}
|
|
28286
|
+
}
|
|
28287
|
+
async function replaceCardRepo(params) {
|
|
28288
|
+
const session = import_node_server_utils149.useAtlas.getClient()?.startSession();
|
|
28289
|
+
try {
|
|
28290
|
+
session?.startTransaction();
|
|
28291
|
+
const siteId = new import_mongodb83.ObjectId(params.site);
|
|
28292
|
+
const userId = new import_mongodb83.ObjectId(params.userId);
|
|
28293
|
+
const cardId = new import_mongodb83.ObjectId(params.cardId);
|
|
28294
|
+
const quantity = 1;
|
|
28295
|
+
const cardCredentials = await collection().findOneAndUpdate(
|
|
28296
|
+
{ _id: cardId },
|
|
28297
|
+
{ $set: { replacementStatus: "Issuance" } },
|
|
28298
|
+
{ returnDocument: "after" }
|
|
28299
|
+
);
|
|
28300
|
+
const unit = [cardCredentials?.assignedUnit];
|
|
28301
|
+
const date = /* @__PURE__ */ new Date();
|
|
28302
|
+
const endDate = new Date(date.setFullYear(date.getFullYear() + 10));
|
|
28303
|
+
const res = await collection().aggregate([{ $sort: { cardNo: -1 } }, { $limit: 2 }]).toArray();
|
|
28304
|
+
const prevCard = res && res?.[1]?.cardNo || "-1";
|
|
28305
|
+
const currentCard = res && res?.[0]?.cardNo || "0";
|
|
28306
|
+
let availableCardNo = [];
|
|
28307
|
+
let num = parseInt(prevCard, 10) + 1;
|
|
28308
|
+
while (availableCardNo.length < (unit.length > 0 ? unit.length : quantity)) {
|
|
28309
|
+
if (num === parseInt(currentCard, 10)) {
|
|
28310
|
+
num++;
|
|
28311
|
+
}
|
|
28312
|
+
availableCardNo.push(num);
|
|
28313
|
+
num++;
|
|
28314
|
+
}
|
|
28315
|
+
const cardNumbers = availableCardNo.map((no) => no.toString().padStart(10, "0"));
|
|
28316
|
+
const accessCards = [];
|
|
28317
|
+
const convertedUnits = unit.map((obj) => new import_mongodb83.ObjectId(obj));
|
|
28318
|
+
for (let j = 0; j < (unit.length > 0 ? unit.length : quantity); j++) {
|
|
28319
|
+
accessCards.push(
|
|
28320
|
+
new MAccessCard({
|
|
28321
|
+
userId,
|
|
28322
|
+
site: siteId,
|
|
28323
|
+
type: cardCredentials?.type,
|
|
28324
|
+
accessLevel: cardCredentials?.accessLevel,
|
|
28325
|
+
accessGroup: cardCredentials?.accessGroup,
|
|
28326
|
+
accessType: cardCredentials?.accessType,
|
|
28327
|
+
cardNo: cardNumbers[j],
|
|
28328
|
+
pin: "123456",
|
|
28329
|
+
qrData: "092222",
|
|
28330
|
+
startDate: /* @__PURE__ */ new Date(),
|
|
28331
|
+
endDate,
|
|
28332
|
+
isActivated: true,
|
|
28333
|
+
isAntiPassBack: false,
|
|
28334
|
+
isLiftCard: cardCredentials?.isLiftCard ? true : false,
|
|
28335
|
+
liftAccessLevel: cardCredentials?.liftAccessLevel,
|
|
28336
|
+
userType: cardCredentials?.userType,
|
|
28337
|
+
doorName: cardCredentials?.doorName,
|
|
28338
|
+
liftName: cardCredentials?.liftName,
|
|
28339
|
+
assignedUnit: convertedUnits[j],
|
|
28340
|
+
replacementStatus: "Issuance",
|
|
28341
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
28342
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
28343
|
+
})
|
|
28344
|
+
);
|
|
28345
|
+
}
|
|
28346
|
+
const commands = accessCards.map((item, index) => {
|
|
28347
|
+
let ag = null;
|
|
28348
|
+
if (item.accessGroup !== void 0) {
|
|
28349
|
+
if (item.accessGroup?.length > 0) {
|
|
28350
|
+
ag = item.accessGroup.map((g) => `<GROUP_NAME>${g}</GROUP_NAME>`).join("\n ");
|
|
28351
|
+
}
|
|
28352
|
+
}
|
|
28353
|
+
const command = {
|
|
28354
|
+
commandId1: index * 2 + 1,
|
|
28355
|
+
commandId2: index * 2 + 2,
|
|
28356
|
+
staffName: `STAFF-${item._id.toString().slice(-10)}`,
|
|
28357
|
+
staffNo1: `STAFF-${item._id.toString().slice(-10)}`,
|
|
28358
|
+
staffNo2: `STAFF-${item._id.toString().slice(-10)}`,
|
|
28359
|
+
dateOfJoin: formatEntryPassDate(item.startDate),
|
|
28360
|
+
accessLevel: item.accessLevel ?? "0",
|
|
28361
|
+
cardNo: item.cardNo,
|
|
28362
|
+
pin: typeof item.pin === "string" && item.pin.trim() !== "" ? item.pin : "123456",
|
|
28363
|
+
startDate: formatEntryPassDate(item.startDate),
|
|
28364
|
+
endDate: formatEntryPassDate(item.endDate),
|
|
28365
|
+
cardType: 0,
|
|
28366
|
+
isActivated: item.isActivated ? 1 : 0,
|
|
28367
|
+
isAntiPassBack: item.isAntiPassBack ? 1 : 0,
|
|
28368
|
+
isLiftCard: item.isLiftCard ? 1 : 0,
|
|
28369
|
+
isLiftActivate: item.isLiftCard ? 1 : 0,
|
|
28370
|
+
liftAccessLevel: item.liftAccessLevel || 1,
|
|
28371
|
+
liftAccessStartDate: formatEntryPassDate(item.liftAccessStartDate) || "19770510",
|
|
28372
|
+
liftAccessEndDate: formatEntryPassDate(item.liftAccessEndDate) || "19770510",
|
|
28373
|
+
accessGroup: ag
|
|
28374
|
+
};
|
|
28375
|
+
return readTemplate(`${item.accessLevel !== null ? "add-card" : "add-card-lift"}`, { ...command });
|
|
28376
|
+
}).flat();
|
|
28377
|
+
const response = await sendCommand(commands.join("").toString(), params.acm_url);
|
|
28378
|
+
const result = await (0, import_xml2js.parseStringPromise)(response, { explicitArray: false });
|
|
28379
|
+
if (result && result.RESULT.$.STCODE !== "0") {
|
|
28380
|
+
throw new Error("Command failed, server error.");
|
|
28381
|
+
}
|
|
28382
|
+
const card = await collection().insertMany(accessCards);
|
|
28383
|
+
await session?.commitTransaction();
|
|
28384
|
+
return card;
|
|
28385
|
+
} catch (error) {
|
|
28386
|
+
await session?.abortTransaction();
|
|
28387
|
+
throw new Error(error.message);
|
|
28388
|
+
} finally {
|
|
28389
|
+
await session?.endSession();
|
|
28390
|
+
}
|
|
28391
|
+
}
|
|
28392
|
+
async function updateNFCStatusRepo(params) {
|
|
28393
|
+
const session = import_node_server_utils149.useAtlas.getClient()?.startSession();
|
|
28394
|
+
try {
|
|
28395
|
+
session?.startTransaction();
|
|
28396
|
+
const results = [];
|
|
28397
|
+
for (let nfc of params.nfcList) {
|
|
28398
|
+
nfc._id = new import_mongodb83.ObjectId(nfc._id);
|
|
28399
|
+
const card = await collection().findOne({ _id: nfc._id }, { session });
|
|
28400
|
+
if (card) {
|
|
28401
|
+
const updateFields = {
|
|
28402
|
+
status: nfc.status,
|
|
28403
|
+
vmsRemarks: nfc?.vmsRemarks,
|
|
28404
|
+
userId: null,
|
|
28405
|
+
updatedAt: nfc?.updatedAt ?? /* @__PURE__ */ new Date()
|
|
28406
|
+
};
|
|
28407
|
+
if (nfc.status !== "Returned") {
|
|
28408
|
+
updateFields.isActivated = false;
|
|
28409
|
+
} else {
|
|
28410
|
+
updateFields.isActivated = true;
|
|
28411
|
+
}
|
|
28412
|
+
const res = await collection().updateOne({ _id: card._id }, { $set: updateFields }, { session });
|
|
28413
|
+
results.push({ nfcId: nfc._id, modifiedCount: res.modifiedCount });
|
|
28414
|
+
}
|
|
28415
|
+
}
|
|
28416
|
+
await session?.commitTransaction();
|
|
28417
|
+
return results;
|
|
28418
|
+
} catch (error) {
|
|
28419
|
+
await session?.abortTransaction();
|
|
28420
|
+
throw new Error(error.message);
|
|
28421
|
+
} finally {
|
|
28422
|
+
await session?.endSession();
|
|
28423
|
+
}
|
|
28424
|
+
}
|
|
28425
|
+
async function doorAndLiftDropdownRepo(params) {
|
|
28426
|
+
try {
|
|
28427
|
+
const { site, type, userType } = params;
|
|
28428
|
+
const id = new import_mongodb83.ObjectId(site);
|
|
28429
|
+
const res = collection().aggregate([
|
|
28430
|
+
{
|
|
28431
|
+
$match: {
|
|
28432
|
+
site: { $in: [id] },
|
|
28433
|
+
type,
|
|
28434
|
+
userType,
|
|
28435
|
+
isActivated: true,
|
|
28436
|
+
assignedUnit: null,
|
|
28437
|
+
userId: null,
|
|
28438
|
+
$or: [
|
|
28439
|
+
{ $and: [{ doorName: { $ne: null } }, { doorName: { $ne: "" } }, { accessLevel: { $ne: null } }] },
|
|
28440
|
+
{ $and: [{ liftName: { $ne: null } }, { liftName: { $ne: "" } }, { liftAccessLevel: { $ne: null } }] }
|
|
28441
|
+
]
|
|
28442
|
+
}
|
|
28443
|
+
},
|
|
28444
|
+
{
|
|
28445
|
+
$facet: {
|
|
28446
|
+
totalCount: [{ $count: "count" }],
|
|
28447
|
+
accessData: [
|
|
28448
|
+
{
|
|
28449
|
+
$group: {
|
|
28450
|
+
_id: null,
|
|
28451
|
+
accessLevels: {
|
|
28452
|
+
$addToSet: {
|
|
28453
|
+
$cond: [
|
|
28454
|
+
{ $and: [{ $ne: ["$doorName", null] }, { $ne: ["$doorName", ""] }, { $ne: ["$accessLevel", null] }] },
|
|
28455
|
+
{ name: "$doorName", no: "$accessLevel" },
|
|
28456
|
+
"$$REMOVE"
|
|
28457
|
+
]
|
|
28458
|
+
}
|
|
28459
|
+
},
|
|
28460
|
+
liftAccessLevels: {
|
|
28461
|
+
$addToSet: {
|
|
28462
|
+
$cond: [
|
|
28463
|
+
{ $and: [{ $ne: ["$liftName", null] }, { $ne: ["$liftName", ""] }, { $ne: ["$liftAccessLevel", null] }] },
|
|
28464
|
+
{ name: "$liftName", no: "$liftAccessLevel" },
|
|
28465
|
+
"$$REMOVE"
|
|
28466
|
+
]
|
|
28467
|
+
}
|
|
28468
|
+
}
|
|
28469
|
+
}
|
|
28470
|
+
},
|
|
28471
|
+
{
|
|
28472
|
+
$project: {
|
|
28473
|
+
_id: 0,
|
|
28474
|
+
accessLevels: 1,
|
|
28475
|
+
liftAccessLevels: 1
|
|
28476
|
+
}
|
|
28477
|
+
}
|
|
28478
|
+
]
|
|
28479
|
+
}
|
|
28480
|
+
}
|
|
28481
|
+
]).toArray();
|
|
28482
|
+
return res;
|
|
28483
|
+
} catch (error) {
|
|
28484
|
+
throw new Error(error.message);
|
|
28485
|
+
}
|
|
28486
|
+
}
|
|
28487
|
+
async function cardReplacementRepo(params) {
|
|
28488
|
+
const session = import_node_server_utils149.useAtlas.getClient()?.startSession();
|
|
28489
|
+
try {
|
|
28490
|
+
const { cardId, remarks } = params;
|
|
28491
|
+
const id = new import_mongodb83.ObjectId(cardId);
|
|
28492
|
+
session?.startTransaction();
|
|
28493
|
+
const card = await collection().findOneAndUpdate(
|
|
28494
|
+
{ _id: id },
|
|
28495
|
+
{ $set: { remarks, replacementStatus: "Pending", requestDate: /* @__PURE__ */ new Date(), isActivated: false } },
|
|
28496
|
+
{ returnDocument: "after", session }
|
|
28497
|
+
);
|
|
28498
|
+
await session?.commitTransaction();
|
|
28499
|
+
return card;
|
|
28500
|
+
} catch (error) {
|
|
28501
|
+
await session?.abortTransaction();
|
|
28502
|
+
throw new Error(error.message);
|
|
28503
|
+
} finally {
|
|
28504
|
+
await session?.endSession();
|
|
28505
|
+
}
|
|
28506
|
+
}
|
|
28138
28507
|
return {
|
|
28139
28508
|
createIndexes,
|
|
28140
28509
|
createIndexForEntrypass,
|
|
@@ -28145,111 +28514,20 @@ function UseAccessManagementRepo() {
|
|
|
28145
28514
|
availableAccessCardsRepo,
|
|
28146
28515
|
userTypeAccessCardsRepo,
|
|
28147
28516
|
assignedAccessCardsRepo,
|
|
28148
|
-
acknowlegdeCardRepo
|
|
28517
|
+
acknowlegdeCardRepo,
|
|
28518
|
+
accessandLiftCardsRepo,
|
|
28519
|
+
replaceCardRepo,
|
|
28520
|
+
updateNFCStatusRepo,
|
|
28521
|
+
doorAndLiftDropdownRepo,
|
|
28522
|
+
cardReplacementRepo
|
|
28149
28523
|
};
|
|
28150
28524
|
}
|
|
28151
28525
|
|
|
28152
28526
|
// src/controllers/access-management.controller.ts
|
|
28153
28527
|
var import_joi85 = __toESM(require("joi"));
|
|
28154
28528
|
|
|
28155
|
-
// src/utils/access-management.ts
|
|
28156
|
-
var import_fs2 = __toESM(require("fs"));
|
|
28157
|
-
var import_path = __toESM(require("path"));
|
|
28158
|
-
var import_axios = __toESM(require("axios"));
|
|
28159
|
-
var import_crypto = __toESM(require("crypto"));
|
|
28160
|
-
var ALGORITHM = "aes-256-gcm";
|
|
28161
|
-
var SECRET_KEY = import_crypto.default.createSecretKey(
|
|
28162
|
-
new Uint8Array(import_crypto.default.createHash("sha256").update("acm-secret-key").digest())
|
|
28163
|
-
);
|
|
28164
|
-
function decryptAcmUrl(encryptedText) {
|
|
28165
|
-
const [ivB64, authTagB64, encryptedB64] = encryptedText.split(":");
|
|
28166
|
-
const iv = Buffer.from(ivB64, "base64");
|
|
28167
|
-
const authTag = Buffer.from(authTagB64, "base64");
|
|
28168
|
-
const encrypted = Buffer.from(encryptedB64, "base64");
|
|
28169
|
-
const decipher = import_crypto.default.createDecipheriv(
|
|
28170
|
-
ALGORITHM,
|
|
28171
|
-
SECRET_KEY,
|
|
28172
|
-
new Uint8Array(iv)
|
|
28173
|
-
);
|
|
28174
|
-
decipher.setAuthTag(new Uint8Array(authTag));
|
|
28175
|
-
const decrypted = Buffer.concat([
|
|
28176
|
-
decipher.update(encrypted),
|
|
28177
|
-
decipher.final()
|
|
28178
|
-
]);
|
|
28179
|
-
return decrypted.toString("utf8");
|
|
28180
|
-
}
|
|
28181
|
-
var minifyXml = (xml) => {
|
|
28182
|
-
return xml.replace(/>\s+</g, "><").replace(/\n/g, "").replace(/\r/g, "").replace(/\t/g, "").trim();
|
|
28183
|
-
};
|
|
28184
|
-
var readTemplate = (name, params) => {
|
|
28185
|
-
const template = import_fs2.default.readFileSync(
|
|
28186
|
-
import_path.default.join(__dirname, `../src/public/xml-templates/${name}.xml`),
|
|
28187
|
-
"utf-8"
|
|
28188
|
-
);
|
|
28189
|
-
if (!params)
|
|
28190
|
-
return minifyXml(template);
|
|
28191
|
-
const replacedTemplate = Object.entries(params).reduce(
|
|
28192
|
-
(acc, [key, value]) => acc.replace(`{{${key}}}`, value),
|
|
28193
|
-
template
|
|
28194
|
-
);
|
|
28195
|
-
return minifyXml(replacedTemplate);
|
|
28196
|
-
};
|
|
28197
|
-
async function sendCommand(command, url) {
|
|
28198
|
-
try {
|
|
28199
|
-
const decrypt = decryptAcmUrl(url);
|
|
28200
|
-
const response = await import_axios.default.post(decrypt, {
|
|
28201
|
-
command
|
|
28202
|
-
});
|
|
28203
|
-
if (response.status === 200 || response.status === 201)
|
|
28204
|
-
return response.data;
|
|
28205
|
-
} catch (error) {
|
|
28206
|
-
return Promise.reject(error);
|
|
28207
|
-
}
|
|
28208
|
-
}
|
|
28209
|
-
var formatDoorAccessLevels = (data) => {
|
|
28210
|
-
const doorAccessLevels = data.RESULT.TRACKID.SUB_RESULT.ACCESS_LEVEL;
|
|
28211
|
-
return doorAccessLevels.map((door) => {
|
|
28212
|
-
return {
|
|
28213
|
-
name: door._.trim(),
|
|
28214
|
-
// Remove any leading/trailing spaces
|
|
28215
|
-
no: door.$.NO
|
|
28216
|
-
// Extract the number
|
|
28217
|
-
};
|
|
28218
|
-
});
|
|
28219
|
-
};
|
|
28220
|
-
var formatLiftAccessLevels = (data, search) => {
|
|
28221
|
-
const liftAccessLevels = data.RESULT.TRACKID.SUB_RESULT.LIFT_ACCESS_LEVEL;
|
|
28222
|
-
const result = liftAccessLevels.map((level) => {
|
|
28223
|
-
return {
|
|
28224
|
-
name: level._.trim(),
|
|
28225
|
-
no: level.$.NO
|
|
28226
|
-
};
|
|
28227
|
-
});
|
|
28228
|
-
if (search) {
|
|
28229
|
-
return result.filter(
|
|
28230
|
-
(item) => item.name.toLowerCase().includes(search.toLowerCase())
|
|
28231
|
-
);
|
|
28232
|
-
}
|
|
28233
|
-
return result;
|
|
28234
|
-
};
|
|
28235
|
-
var formatAccessGroup = (data, search) => {
|
|
28236
|
-
const accessGroup = data.RESULT.TRACKID.SUB_RESULT.ACCESS_GROUP;
|
|
28237
|
-
const result = accessGroup.map((ag) => {
|
|
28238
|
-
return {
|
|
28239
|
-
no: ag._.trim(),
|
|
28240
|
-
name: ag.$.NAME
|
|
28241
|
-
};
|
|
28242
|
-
});
|
|
28243
|
-
if (search) {
|
|
28244
|
-
return result.filter(
|
|
28245
|
-
(item) => item.name.toLowerCase().includes(search.toLowerCase())
|
|
28246
|
-
);
|
|
28247
|
-
}
|
|
28248
|
-
return result;
|
|
28249
|
-
};
|
|
28250
|
-
|
|
28251
28529
|
// src/services/access-management.service.ts
|
|
28252
|
-
var
|
|
28530
|
+
var import_xml2js2 = require("xml2js");
|
|
28253
28531
|
var import_node_server_utils150 = require("@7365admin1/node-server-utils");
|
|
28254
28532
|
var namespace = "cache:acm";
|
|
28255
28533
|
function useAccessManagementSvc() {
|
|
@@ -28261,7 +28539,12 @@ function useAccessManagementSvc() {
|
|
|
28261
28539
|
availableAccessCardsRepo,
|
|
28262
28540
|
userTypeAccessCardsRepo,
|
|
28263
28541
|
assignedAccessCardsRepo,
|
|
28264
|
-
acknowlegdeCardRepo
|
|
28542
|
+
acknowlegdeCardRepo,
|
|
28543
|
+
accessandLiftCardsRepo,
|
|
28544
|
+
replaceCardRepo,
|
|
28545
|
+
updateNFCStatusRepo,
|
|
28546
|
+
doorAndLiftDropdownRepo,
|
|
28547
|
+
cardReplacementRepo
|
|
28265
28548
|
} = UseAccessManagementRepo();
|
|
28266
28549
|
const addPhysicalCardSvc = async (payload) => {
|
|
28267
28550
|
try {
|
|
@@ -28303,7 +28586,7 @@ function useAccessManagementSvc() {
|
|
|
28303
28586
|
}
|
|
28304
28587
|
const command = readTemplate("door-levels");
|
|
28305
28588
|
const response = await sendCommand(command, params.acm_url);
|
|
28306
|
-
const res = await (0,
|
|
28589
|
+
const res = await (0, import_xml2js2.parseStringPromise)(response, { explicitArray: false });
|
|
28307
28590
|
const format = await formatDoorAccessLevels(res);
|
|
28308
28591
|
await setCache({ key, data: format, ttlSeconds: 60, redis });
|
|
28309
28592
|
redis.lrem(listKey, 0, key).then(() => redis.lpush(listKey, key)).then(() => redis.ltrim(listKey, 0, 9)).catch(console.error);
|
|
@@ -28326,7 +28609,7 @@ function useAccessManagementSvc() {
|
|
|
28326
28609
|
}
|
|
28327
28610
|
const command = readTemplate("lift-levels");
|
|
28328
28611
|
const response = await sendCommand(command, params.acm_url);
|
|
28329
|
-
const res = await (0,
|
|
28612
|
+
const res = await (0, import_xml2js2.parseStringPromise)(response, { explicitArray: false });
|
|
28330
28613
|
const format = await formatLiftAccessLevels(res);
|
|
28331
28614
|
await setCache({ key, data: format, ttlSeconds: 60, redis });
|
|
28332
28615
|
redis.lrem(listKey, 0, key).then(() => redis.lpush(listKey, key)).then(() => redis.ltrim(listKey, 0, 9)).catch(console.error);
|
|
@@ -28349,7 +28632,7 @@ function useAccessManagementSvc() {
|
|
|
28349
28632
|
}
|
|
28350
28633
|
const command = readTemplate("access-group");
|
|
28351
28634
|
const response = await sendCommand(command, params.acm_url);
|
|
28352
|
-
const res = await (0,
|
|
28635
|
+
const res = await (0, import_xml2js2.parseStringPromise)(response, { explicitArray: false });
|
|
28353
28636
|
const format = await formatAccessGroup(res);
|
|
28354
28637
|
await setCache({ key, data: format, ttlSeconds: 60, redis });
|
|
28355
28638
|
redis.lrem(listKey, 0, key).then(() => redis.lpush(listKey, key)).then(() => redis.ltrim(listKey, 0, 9)).catch(console.error);
|
|
@@ -28406,6 +28689,46 @@ function useAccessManagementSvc() {
|
|
|
28406
28689
|
throw new Error(err.message);
|
|
28407
28690
|
}
|
|
28408
28691
|
};
|
|
28692
|
+
const accessandLiftCardsSvc = async (params) => {
|
|
28693
|
+
try {
|
|
28694
|
+
const response = await accessandLiftCardsRepo({ ...params });
|
|
28695
|
+
return response;
|
|
28696
|
+
} catch (err) {
|
|
28697
|
+
throw new Error(err.message);
|
|
28698
|
+
}
|
|
28699
|
+
};
|
|
28700
|
+
const replaceCardSvc = async (params) => {
|
|
28701
|
+
try {
|
|
28702
|
+
const response = await replaceCardRepo({ ...params });
|
|
28703
|
+
return response;
|
|
28704
|
+
} catch (err) {
|
|
28705
|
+
throw new Error(err.message);
|
|
28706
|
+
}
|
|
28707
|
+
};
|
|
28708
|
+
const updateNFCStatusSvc = async (params) => {
|
|
28709
|
+
try {
|
|
28710
|
+
const response = await updateNFCStatusRepo({ ...params });
|
|
28711
|
+
return response;
|
|
28712
|
+
} catch (err) {
|
|
28713
|
+
throw new Error(err.message);
|
|
28714
|
+
}
|
|
28715
|
+
};
|
|
28716
|
+
const doorAndLiftDropdownSvc = async (params) => {
|
|
28717
|
+
try {
|
|
28718
|
+
const response = await doorAndLiftDropdownRepo({ ...params });
|
|
28719
|
+
return response;
|
|
28720
|
+
} catch (err) {
|
|
28721
|
+
throw new Error(err.message);
|
|
28722
|
+
}
|
|
28723
|
+
};
|
|
28724
|
+
const cardReplacementSvc = async (params) => {
|
|
28725
|
+
try {
|
|
28726
|
+
const response = await cardReplacementRepo({ ...params });
|
|
28727
|
+
return response;
|
|
28728
|
+
} catch (err) {
|
|
28729
|
+
throw new Error(err.message);
|
|
28730
|
+
}
|
|
28731
|
+
};
|
|
28409
28732
|
return {
|
|
28410
28733
|
addPhysicalCardSvc,
|
|
28411
28734
|
addNonPhysicalCardSvc,
|
|
@@ -28417,7 +28740,12 @@ function useAccessManagementSvc() {
|
|
|
28417
28740
|
availableAccessCardsSvc,
|
|
28418
28741
|
userTypeAccessCardsSvc,
|
|
28419
28742
|
assignedAccessCardsSvc,
|
|
28420
|
-
acknowlegdeCardSvc
|
|
28743
|
+
acknowlegdeCardSvc,
|
|
28744
|
+
accessandLiftCardsSvc,
|
|
28745
|
+
replaceCardSvc,
|
|
28746
|
+
updateNFCStatusSvc,
|
|
28747
|
+
doorAndLiftDropdownSvc,
|
|
28748
|
+
cardReplacementSvc
|
|
28421
28749
|
};
|
|
28422
28750
|
}
|
|
28423
28751
|
|
|
@@ -28434,7 +28762,12 @@ function useAccessManagementController() {
|
|
|
28434
28762
|
availableAccessCardsSvc,
|
|
28435
28763
|
userTypeAccessCardsSvc,
|
|
28436
28764
|
assignedAccessCardsSvc,
|
|
28437
|
-
acknowlegdeCardSvc
|
|
28765
|
+
acknowlegdeCardSvc,
|
|
28766
|
+
accessandLiftCardsSvc,
|
|
28767
|
+
replaceCardSvc,
|
|
28768
|
+
updateNFCStatusSvc,
|
|
28769
|
+
doorAndLiftDropdownSvc,
|
|
28770
|
+
cardReplacementSvc
|
|
28438
28771
|
} = useAccessManagementSvc();
|
|
28439
28772
|
const addPhysicalCard = async (req, res) => {
|
|
28440
28773
|
try {
|
|
@@ -28506,7 +28839,7 @@ function useAccessManagementController() {
|
|
|
28506
28839
|
accessGroup: import_joi85.default.array().items(import_joi85.default.string().required()).required(),
|
|
28507
28840
|
userType: import_joi85.default.string().required(),
|
|
28508
28841
|
doorName: import_joi85.default.string().required(),
|
|
28509
|
-
liftName: import_joi85.default.string().
|
|
28842
|
+
liftName: import_joi85.default.string().optional().allow("", null),
|
|
28510
28843
|
unit: import_joi85.default.array().items(import_joi85.default.string()).optional().allow(null),
|
|
28511
28844
|
startDate: import_joi85.default.date().required(),
|
|
28512
28845
|
endDate: import_joi85.default.date().required(),
|
|
@@ -28737,6 +29070,123 @@ function useAccessManagementController() {
|
|
|
28737
29070
|
});
|
|
28738
29071
|
}
|
|
28739
29072
|
};
|
|
29073
|
+
const accessandLiftCards = async (req, res) => {
|
|
29074
|
+
try {
|
|
29075
|
+
const {
|
|
29076
|
+
accessLevel = null,
|
|
29077
|
+
liftAccessLevel = null,
|
|
29078
|
+
site,
|
|
29079
|
+
userType,
|
|
29080
|
+
type
|
|
29081
|
+
} = req.query;
|
|
29082
|
+
const schema2 = import_joi85.default.object({
|
|
29083
|
+
accessLevel: import_joi85.default.string().optional().allow("", null),
|
|
29084
|
+
liftAccessLevel: import_joi85.default.string().optional().allow("", null),
|
|
29085
|
+
site: import_joi85.default.string().hex().required(),
|
|
29086
|
+
userType: import_joi85.default.string().valid(...Object.values(EAccessCardUserTypes)).required(),
|
|
29087
|
+
type: import_joi85.default.string().valid(...Object.values(EAccessCardTypes)).required()
|
|
29088
|
+
});
|
|
29089
|
+
const { error } = schema2.validate({ accessLevel, liftAccessLevel, site, userType, type });
|
|
29090
|
+
if (error) {
|
|
29091
|
+
return res.status(400).json({ message: error.message });
|
|
29092
|
+
}
|
|
29093
|
+
const result = await accessandLiftCardsSvc({ accessLevel, liftAccessLevel, site, userType, type });
|
|
29094
|
+
return res.status(200).json({ message: "Success", data: result });
|
|
29095
|
+
} catch (error) {
|
|
29096
|
+
return res.status(500).json({
|
|
29097
|
+
data: null,
|
|
29098
|
+
message: error.message
|
|
29099
|
+
});
|
|
29100
|
+
}
|
|
29101
|
+
};
|
|
29102
|
+
const replaceCard = async (req, res) => {
|
|
29103
|
+
try {
|
|
29104
|
+
const { userId, cardId, site, acm_url } = req.body;
|
|
29105
|
+
const schema2 = import_joi85.default.object({
|
|
29106
|
+
userId: import_joi85.default.string().required(),
|
|
29107
|
+
cardId: import_joi85.default.string().required(),
|
|
29108
|
+
site: import_joi85.default.string().required(),
|
|
29109
|
+
acm_url: import_joi85.default.string().required()
|
|
29110
|
+
});
|
|
29111
|
+
const { error } = schema2.validate({ userId, cardId, site, acm_url });
|
|
29112
|
+
if (error) {
|
|
29113
|
+
return res.status(400).json({ message: error.message });
|
|
29114
|
+
}
|
|
29115
|
+
const result = await replaceCardSvc({ userId, cardId, site, acm_url });
|
|
29116
|
+
return res.status(200).json({ message: "Success", data: result });
|
|
29117
|
+
} catch (error) {
|
|
29118
|
+
return res.status(500).json({
|
|
29119
|
+
data: null,
|
|
29120
|
+
message: error.message
|
|
29121
|
+
});
|
|
29122
|
+
}
|
|
29123
|
+
};
|
|
29124
|
+
const updateNFCStatus = async (req, res) => {
|
|
29125
|
+
try {
|
|
29126
|
+
const { nfcList = [], visitorId } = req.body;
|
|
29127
|
+
const schema2 = import_joi85.default.object({
|
|
29128
|
+
nfcList: import_joi85.default.array().items({
|
|
29129
|
+
_id: import_joi85.default.string().hex().length(24).required(),
|
|
29130
|
+
status: import_joi85.default.string().required(),
|
|
29131
|
+
vmsRemarks: import_joi85.default.string().allow(null, "").optional(),
|
|
29132
|
+
updatedAt: import_joi85.default.date().optional().allow(null, "")
|
|
29133
|
+
}),
|
|
29134
|
+
visitorId: import_joi85.default.string().optional().allow(null, "")
|
|
29135
|
+
});
|
|
29136
|
+
const { error } = schema2.validate({ nfcList, visitorId });
|
|
29137
|
+
if (error) {
|
|
29138
|
+
return res.status(400).json({ message: error.message });
|
|
29139
|
+
}
|
|
29140
|
+
const result = await updateNFCStatusSvc({ nfcList, visitorId });
|
|
29141
|
+
return res.status(200).json({ message: "Success", data: result });
|
|
29142
|
+
} catch (error) {
|
|
29143
|
+
return res.status(500).json({
|
|
29144
|
+
data: null,
|
|
29145
|
+
message: error.message
|
|
29146
|
+
});
|
|
29147
|
+
}
|
|
29148
|
+
};
|
|
29149
|
+
const doorAndLiftDropdown = async (req, res) => {
|
|
29150
|
+
try {
|
|
29151
|
+
const { site, type, userType } = req.query;
|
|
29152
|
+
const schema2 = import_joi85.default.object({
|
|
29153
|
+
site: import_joi85.default.string().hex().required(),
|
|
29154
|
+
type: import_joi85.default.string().required(),
|
|
29155
|
+
userType: import_joi85.default.string().required()
|
|
29156
|
+
});
|
|
29157
|
+
const { error } = schema2.validate({ site, type, userType });
|
|
29158
|
+
if (error) {
|
|
29159
|
+
return res.status(400).json({ message: error.message });
|
|
29160
|
+
}
|
|
29161
|
+
const result = await doorAndLiftDropdownSvc({ site, type, userType });
|
|
29162
|
+
return res.status(200).json({ message: "Success", data: result });
|
|
29163
|
+
} catch (error) {
|
|
29164
|
+
return res.status(500).json({
|
|
29165
|
+
data: null,
|
|
29166
|
+
message: error.message
|
|
29167
|
+
});
|
|
29168
|
+
}
|
|
29169
|
+
};
|
|
29170
|
+
const cardReplacement = async (req, res) => {
|
|
29171
|
+
try {
|
|
29172
|
+
const { cardId, remarks } = req.body;
|
|
29173
|
+
const schema2 = import_joi85.default.object({
|
|
29174
|
+
cardId: import_joi85.default.string().required(),
|
|
29175
|
+
remarks: import_joi85.default.string().optional().allow("", null)
|
|
29176
|
+
});
|
|
29177
|
+
const { error } = schema2.validate({ cardId, remarks });
|
|
29178
|
+
if (error) {
|
|
29179
|
+
return res.status(400).json({ message: error.message });
|
|
29180
|
+
}
|
|
29181
|
+
const result = await cardReplacementSvc({ cardId, remarks });
|
|
29182
|
+
return res.status(200).json({ message: "Success", data: result });
|
|
29183
|
+
} catch (error) {
|
|
29184
|
+
return res.status(500).json({
|
|
29185
|
+
data: null,
|
|
29186
|
+
message: error.message
|
|
29187
|
+
});
|
|
29188
|
+
}
|
|
29189
|
+
};
|
|
28740
29190
|
return {
|
|
28741
29191
|
addPhysicalCard,
|
|
28742
29192
|
addNonPhysicalCard,
|
|
@@ -28748,7 +29198,12 @@ function useAccessManagementController() {
|
|
|
28748
29198
|
availableAccessCards,
|
|
28749
29199
|
userTypeAccessCards,
|
|
28750
29200
|
assignedAccessCards,
|
|
28751
|
-
acknowlegdeCard
|
|
29201
|
+
acknowlegdeCard,
|
|
29202
|
+
accessandLiftCards,
|
|
29203
|
+
replaceCard,
|
|
29204
|
+
updateNFCStatus,
|
|
29205
|
+
doorAndLiftDropdown,
|
|
29206
|
+
cardReplacement
|
|
28752
29207
|
};
|
|
28753
29208
|
}
|
|
28754
29209
|
|
|
@@ -34318,16 +34773,26 @@ function useOnlineFormRepo() {
|
|
|
34318
34773
|
site = ""
|
|
34319
34774
|
}) {
|
|
34320
34775
|
page = page > 0 ? page - 1 : 0;
|
|
34776
|
+
try {
|
|
34777
|
+
site = new import_mongodb103.ObjectId(site);
|
|
34778
|
+
} catch (error) {
|
|
34779
|
+
throw new import_node_server_utils184.BadRequestError("Invalid site ID format.");
|
|
34780
|
+
}
|
|
34321
34781
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
34322
34782
|
const cacheOptions = {
|
|
34323
34783
|
page,
|
|
34324
34784
|
limit,
|
|
34325
34785
|
status,
|
|
34786
|
+
site: site?.toString(),
|
|
34326
34787
|
sort: JSON.stringify(sort)
|
|
34327
34788
|
};
|
|
34328
34789
|
const query = {
|
|
34329
34790
|
...status ? { $and: [{ status }, { status: { $ne: "deleted" } }] } : { status: { $ne: "deleted" } }
|
|
34330
34791
|
};
|
|
34792
|
+
if (site) {
|
|
34793
|
+
query.site = site;
|
|
34794
|
+
cacheOptions.site = site;
|
|
34795
|
+
}
|
|
34331
34796
|
if (search) {
|
|
34332
34797
|
query.$or = [{ name: { $regex: search, $options: "i" } }];
|
|
34333
34798
|
cacheOptions.search = search;
|
|
@@ -34671,7 +35136,7 @@ function useOnlineFormController() {
|
|
|
34671
35136
|
}
|
|
34672
35137
|
async function deleteOnlineFormById(req, res, next) {
|
|
34673
35138
|
const validation = import_joi106.default.string().hex().required();
|
|
34674
|
-
const _id = req.
|
|
35139
|
+
const _id = req.query.id;
|
|
34675
35140
|
const { error } = validation.validate(_id);
|
|
34676
35141
|
if (error) {
|
|
34677
35142
|
import_node_server_utils185.logger.log({ level: "error", message: error.message });
|