@7365admin1/core 3.11.0 → 3.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 +12 -0
- package/dist/index.d.ts +47 -3
- package/dist/index.js +440 -282
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +439 -282
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6267,6 +6267,7 @@ __export(src_exports, {
|
|
|
6267
6267
|
useManpowerSitesSrvc: () => useManpowerSitesSrvc,
|
|
6268
6268
|
useMemberController: () => useMemberController,
|
|
6269
6269
|
useMemberRepo: () => useMemberRepo,
|
|
6270
|
+
useMemberService: () => useMemberService,
|
|
6270
6271
|
useNewDashboardController: () => useNewDashboardController,
|
|
6271
6272
|
useNewDashboardRepo: () => useNewDashboardRepo,
|
|
6272
6273
|
useNfcPatrolLogController: () => useNfcPatrolLogController,
|
|
@@ -10577,6 +10578,56 @@ function useVerificationRepo() {
|
|
|
10577
10578
|
async function findOne(query) {
|
|
10578
10579
|
return await collection.findOne(query);
|
|
10579
10580
|
}
|
|
10581
|
+
async function completePendingInvites({
|
|
10582
|
+
email,
|
|
10583
|
+
orgId,
|
|
10584
|
+
siteId,
|
|
10585
|
+
app,
|
|
10586
|
+
session
|
|
10587
|
+
}) {
|
|
10588
|
+
const orgCandidates = [orgId];
|
|
10589
|
+
try {
|
|
10590
|
+
orgCandidates.push(new import_mongodb13.ObjectId(orgId));
|
|
10591
|
+
} catch {
|
|
10592
|
+
}
|
|
10593
|
+
const query = {
|
|
10594
|
+
email: { $regex: `^${email}$`, $options: "i" },
|
|
10595
|
+
status: "pending",
|
|
10596
|
+
type: {
|
|
10597
|
+
$in: ["user-invite" /* USER_INVITE */, "member-invite" /* MEMBER_INVITE */]
|
|
10598
|
+
},
|
|
10599
|
+
"metadata.org": { $in: orgCandidates }
|
|
10600
|
+
};
|
|
10601
|
+
if (siteId) {
|
|
10602
|
+
const siteCandidates = [siteId];
|
|
10603
|
+
try {
|
|
10604
|
+
siteCandidates.push(new import_mongodb13.ObjectId(siteId));
|
|
10605
|
+
} catch {
|
|
10606
|
+
}
|
|
10607
|
+
query["metadata.siteId"] = { $in: siteCandidates };
|
|
10608
|
+
}
|
|
10609
|
+
if (app) {
|
|
10610
|
+
query["metadata.app"] = app;
|
|
10611
|
+
}
|
|
10612
|
+
try {
|
|
10613
|
+
const result = await collection.updateMany(
|
|
10614
|
+
query,
|
|
10615
|
+
{ $set: { status: "complete", updatedAt: (/* @__PURE__ */ new Date()).toISOString() } },
|
|
10616
|
+
{ session }
|
|
10617
|
+
);
|
|
10618
|
+
delNamespace().then(() => {
|
|
10619
|
+
import_node_server_utils15.logger.info(`Cache cleared for namespace: ${namespace_collection}`);
|
|
10620
|
+
}).catch((err) => {
|
|
10621
|
+
import_node_server_utils15.logger.error(
|
|
10622
|
+
`Failed to clear cache for namespace: ${namespace_collection}`,
|
|
10623
|
+
err
|
|
10624
|
+
);
|
|
10625
|
+
});
|
|
10626
|
+
return result;
|
|
10627
|
+
} catch (error) {
|
|
10628
|
+
throw new import_node_server_utils15.InternalServerError("Failed to complete pending invites.");
|
|
10629
|
+
}
|
|
10630
|
+
}
|
|
10580
10631
|
return {
|
|
10581
10632
|
createIndex,
|
|
10582
10633
|
createTextIndex,
|
|
@@ -10586,7 +10637,8 @@ function useVerificationRepo() {
|
|
|
10586
10637
|
getByIdByType,
|
|
10587
10638
|
updateStatusById,
|
|
10588
10639
|
getByStatus,
|
|
10589
|
-
findOne
|
|
10640
|
+
findOne,
|
|
10641
|
+
completePendingInvites
|
|
10590
10642
|
};
|
|
10591
10643
|
}
|
|
10592
10644
|
|
|
@@ -12163,6 +12215,61 @@ function useVerificationRepoV2() {
|
|
|
12163
12215
|
throw new import_node_server_utils20.InternalServerError("Failed to update verification code.");
|
|
12164
12216
|
}
|
|
12165
12217
|
}
|
|
12218
|
+
async function completePendingInvites({
|
|
12219
|
+
email,
|
|
12220
|
+
orgId,
|
|
12221
|
+
siteId,
|
|
12222
|
+
app,
|
|
12223
|
+
session
|
|
12224
|
+
}) {
|
|
12225
|
+
const orgCandidates = [orgId];
|
|
12226
|
+
try {
|
|
12227
|
+
orgCandidates.push(new import_mongodb18.ObjectId(orgId));
|
|
12228
|
+
} catch {
|
|
12229
|
+
}
|
|
12230
|
+
const query = {
|
|
12231
|
+
email: { $regex: `^${email}$`, $options: "i" },
|
|
12232
|
+
status: "pending" /* PENDING */,
|
|
12233
|
+
type: {
|
|
12234
|
+
$in: ["user-invite" /* USER_INVITE */, "member-invite" /* MEMBER_INVITE */]
|
|
12235
|
+
},
|
|
12236
|
+
"metadata.org": { $in: orgCandidates }
|
|
12237
|
+
};
|
|
12238
|
+
if (siteId) {
|
|
12239
|
+
const siteCandidates = [siteId];
|
|
12240
|
+
try {
|
|
12241
|
+
siteCandidates.push(new import_mongodb18.ObjectId(siteId));
|
|
12242
|
+
} catch {
|
|
12243
|
+
}
|
|
12244
|
+
query["metadata.siteId"] = { $in: siteCandidates };
|
|
12245
|
+
}
|
|
12246
|
+
if (app) {
|
|
12247
|
+
query["metadata.app"] = app;
|
|
12248
|
+
}
|
|
12249
|
+
try {
|
|
12250
|
+
const result = await collection.updateMany(
|
|
12251
|
+
query,
|
|
12252
|
+
{
|
|
12253
|
+
$set: {
|
|
12254
|
+
status: "complete" /* COMPLETE */,
|
|
12255
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
12256
|
+
}
|
|
12257
|
+
},
|
|
12258
|
+
{ session }
|
|
12259
|
+
);
|
|
12260
|
+
delNamespace().then(() => {
|
|
12261
|
+
import_node_server_utils20.logger.info(`Cache cleared for namespace: ${namespace_collection}`);
|
|
12262
|
+
}).catch((err) => {
|
|
12263
|
+
import_node_server_utils20.logger.error(
|
|
12264
|
+
`Failed to clear cache for namespace: ${namespace_collection}`,
|
|
12265
|
+
err
|
|
12266
|
+
);
|
|
12267
|
+
});
|
|
12268
|
+
return result;
|
|
12269
|
+
} catch (error) {
|
|
12270
|
+
throw new import_node_server_utils20.InternalServerError("Failed to complete pending invites.");
|
|
12271
|
+
}
|
|
12272
|
+
}
|
|
12166
12273
|
return {
|
|
12167
12274
|
createIndex,
|
|
12168
12275
|
createTextIndex,
|
|
@@ -12174,7 +12281,8 @@ function useVerificationRepoV2() {
|
|
|
12174
12281
|
updateStatusById,
|
|
12175
12282
|
countPendingOrgInvites,
|
|
12176
12283
|
getPendingVerificationByEmail,
|
|
12177
|
-
updateVerificationCodeById
|
|
12284
|
+
updateVerificationCodeById,
|
|
12285
|
+
completePendingInvites
|
|
12178
12286
|
};
|
|
12179
12287
|
}
|
|
12180
12288
|
|
|
@@ -14262,7 +14370,7 @@ function useMemberService() {
|
|
|
14262
14370
|
getAllByUserId: _getAllByUserId,
|
|
14263
14371
|
completeOnboardingById: _completeOnboardingById
|
|
14264
14372
|
} = useMemberRepo();
|
|
14265
|
-
const { getById: _getVerificationById, updateStatusById } = useVerificationRepo();
|
|
14373
|
+
const { getById: _getVerificationById, updateStatusById, completePendingInvites } = useVerificationRepo();
|
|
14266
14374
|
const { getUserByEmail, updateDefaultOrgByEmail, getUserById } = useUserRepo();
|
|
14267
14375
|
const { getById: getOrgById } = useOrgRepo();
|
|
14268
14376
|
const { getSiteById } = useSiteRepo();
|
|
@@ -14366,6 +14474,13 @@ function useMemberService() {
|
|
|
14366
14474
|
session
|
|
14367
14475
|
);
|
|
14368
14476
|
}
|
|
14477
|
+
await completePendingInvites({
|
|
14478
|
+
email: user.email,
|
|
14479
|
+
orgId,
|
|
14480
|
+
siteId,
|
|
14481
|
+
app,
|
|
14482
|
+
session
|
|
14483
|
+
});
|
|
14369
14484
|
await session?.commitTransaction();
|
|
14370
14485
|
return { member };
|
|
14371
14486
|
} catch (error) {
|
|
@@ -21126,14 +21241,20 @@ var schemaUpdateVisTrans = import_joi37.default.object({
|
|
|
21126
21241
|
import_joi37.default.object({
|
|
21127
21242
|
keyId: import_joi37.default.string().hex().length(24).required(),
|
|
21128
21243
|
status: import_joi37.default.string().optional().allow(null, ""),
|
|
21129
|
-
remarks: import_joi37.default.string().optional().allow(null, "")
|
|
21244
|
+
remarks: import_joi37.default.string().optional().allow(null, ""),
|
|
21245
|
+
receivedDate: import_joi37.default.string().optional().allow(null, ""),
|
|
21246
|
+
lastUpdate: import_joi37.default.string().optional().allow(null, ""),
|
|
21247
|
+
add: import_joi37.default.boolean().optional().allow(null, "")
|
|
21130
21248
|
})
|
|
21131
21249
|
).optional().allow(null),
|
|
21132
21250
|
passKeys: import_joi37.default.array().items(
|
|
21133
21251
|
import_joi37.default.object({
|
|
21134
21252
|
keyId: import_joi37.default.string().hex().length(24).required(),
|
|
21135
21253
|
status: import_joi37.default.string().optional().allow(null, ""),
|
|
21136
|
-
remarks: import_joi37.default.string().optional().allow(null, "")
|
|
21254
|
+
remarks: import_joi37.default.string().optional().allow(null, ""),
|
|
21255
|
+
receivedDate: import_joi37.default.string().optional().allow(null, ""),
|
|
21256
|
+
lastUpdate: import_joi37.default.string().optional().allow(null, ""),
|
|
21257
|
+
add: import_joi37.default.boolean().optional().allow(null, "")
|
|
21137
21258
|
})
|
|
21138
21259
|
).optional().allow(null),
|
|
21139
21260
|
checkInRemarks: import_joi37.default.string().optional().allow("", null),
|
|
@@ -21307,6 +21428,16 @@ async function convertObjectIdUtil(id) {
|
|
|
21307
21428
|
}
|
|
21308
21429
|
}
|
|
21309
21430
|
async function convertObjectIdUtil2(id, fieldName) {
|
|
21431
|
+
try {
|
|
21432
|
+
if (!id)
|
|
21433
|
+
throw new Error(`Invalid ID conversion to ObjectId of ${fieldName}.`);
|
|
21434
|
+
return new import_mongodb40.ObjectId(id);
|
|
21435
|
+
} catch (_) {
|
|
21436
|
+
console.log(`Invalid ID conversion to ObjectId of ${fieldName}. : `, id);
|
|
21437
|
+
throw new Error(`Invalid ID conversion to ObjectId of ${fieldName}.`);
|
|
21438
|
+
}
|
|
21439
|
+
}
|
|
21440
|
+
function convertObjectIdUtilNonAsync(id, fieldName) {
|
|
21310
21441
|
try {
|
|
21311
21442
|
if (!id)
|
|
21312
21443
|
throw new Error(`Invalid ID conversion to ObjectId of ${fieldName}.`);
|
|
@@ -21508,6 +21639,7 @@ function useVisitorTransactionRepo() {
|
|
|
21508
21639
|
preserveNullAndEmptyArrays: true
|
|
21509
21640
|
}
|
|
21510
21641
|
},
|
|
21642
|
+
// 1. Lookup visitorPass into a temporary field
|
|
21511
21643
|
{
|
|
21512
21644
|
$lookup: {
|
|
21513
21645
|
from: "keys",
|
|
@@ -21519,48 +21651,66 @@ function useVisitorTransactionRepo() {
|
|
|
21519
21651
|
from: "qr-code-templates",
|
|
21520
21652
|
localField: "template",
|
|
21521
21653
|
foreignField: "_id",
|
|
21522
|
-
pipeline: [
|
|
21523
|
-
{
|
|
21524
|
-
$project: {
|
|
21525
|
-
_id: 1,
|
|
21526
|
-
prefixPass: 1,
|
|
21527
|
-
name: 1,
|
|
21528
|
-
remarks: 1
|
|
21529
|
-
}
|
|
21530
|
-
}
|
|
21531
|
-
],
|
|
21654
|
+
pipeline: [{ $project: { prefixPass: 1, name: 1 } }],
|
|
21532
21655
|
as: "template"
|
|
21533
21656
|
}
|
|
21534
21657
|
},
|
|
21535
21658
|
{
|
|
21536
21659
|
$project: {
|
|
21537
|
-
_id:
|
|
21538
|
-
|
|
21539
|
-
status: 1,
|
|
21540
|
-
description: 1,
|
|
21541
|
-
remarks: {
|
|
21542
|
-
$arrayElemAt: ["$template.remarks", 0]
|
|
21543
|
-
},
|
|
21544
|
-
templatePrefixPass: {
|
|
21545
|
-
$arrayElemAt: ["$template.prefixPass", 0]
|
|
21546
|
-
},
|
|
21660
|
+
_id: 1,
|
|
21661
|
+
// Kept only for matching purposes
|
|
21547
21662
|
prefixAndName: {
|
|
21548
21663
|
$concat: [
|
|
21549
|
-
{
|
|
21550
|
-
$ifNull: [
|
|
21551
|
-
{ $arrayElemAt: ["$template.prefixPass", 0] },
|
|
21552
|
-
""
|
|
21553
|
-
]
|
|
21554
|
-
},
|
|
21664
|
+
{ $ifNull: [{ $arrayElemAt: ["$template.prefixPass", 0] }, ""] },
|
|
21555
21665
|
{ $ifNull: ["$name", ""] }
|
|
21556
21666
|
]
|
|
21557
21667
|
}
|
|
21558
21668
|
}
|
|
21559
21669
|
}
|
|
21560
21670
|
],
|
|
21561
|
-
as: "
|
|
21671
|
+
as: "visitorPass_lookup"
|
|
21562
21672
|
}
|
|
21563
21673
|
},
|
|
21674
|
+
// 2. Map through original array, keep all fields, and inject prefixAndName
|
|
21675
|
+
{
|
|
21676
|
+
$addFields: {
|
|
21677
|
+
visitorPass: {
|
|
21678
|
+
$map: {
|
|
21679
|
+
input: "$visitorPass",
|
|
21680
|
+
as: "original",
|
|
21681
|
+
in: {
|
|
21682
|
+
// Explicitly retain all original fields from your document
|
|
21683
|
+
keyId: "$$original.keyId",
|
|
21684
|
+
receivedDate: "$$original.receivedDate",
|
|
21685
|
+
status: "$$original.status",
|
|
21686
|
+
lastUpdate: "$$original.lastUpdate",
|
|
21687
|
+
remarks: "$$original.remarks",
|
|
21688
|
+
// Find and extract ONLY the prefixAndName string from lookup
|
|
21689
|
+
prefixAndName: {
|
|
21690
|
+
$let: {
|
|
21691
|
+
vars: {
|
|
21692
|
+
matched: {
|
|
21693
|
+
$arrayElemAt: [
|
|
21694
|
+
{
|
|
21695
|
+
$filter: {
|
|
21696
|
+
input: "$visitorPass_lookup",
|
|
21697
|
+
as: "lookup",
|
|
21698
|
+
cond: { $eq: ["$$lookup._id", "$$original.keyId"] }
|
|
21699
|
+
}
|
|
21700
|
+
},
|
|
21701
|
+
0
|
|
21702
|
+
]
|
|
21703
|
+
}
|
|
21704
|
+
},
|
|
21705
|
+
in: "$$matched.prefixAndName"
|
|
21706
|
+
}
|
|
21707
|
+
}
|
|
21708
|
+
}
|
|
21709
|
+
}
|
|
21710
|
+
}
|
|
21711
|
+
}
|
|
21712
|
+
},
|
|
21713
|
+
// 3. Lookup passKeys into a temporary field
|
|
21564
21714
|
{
|
|
21565
21715
|
$lookup: {
|
|
21566
21716
|
from: "keys",
|
|
@@ -21572,46 +21722,69 @@ function useVisitorTransactionRepo() {
|
|
|
21572
21722
|
from: "qr-code-templates",
|
|
21573
21723
|
localField: "template",
|
|
21574
21724
|
foreignField: "_id",
|
|
21575
|
-
pipeline: [
|
|
21576
|
-
{
|
|
21577
|
-
$project: {
|
|
21578
|
-
_id: 1,
|
|
21579
|
-
prefixPass: 1,
|
|
21580
|
-
name: 1,
|
|
21581
|
-
remarks: 1
|
|
21582
|
-
}
|
|
21583
|
-
}
|
|
21584
|
-
],
|
|
21725
|
+
pipeline: [{ $project: { prefixPass: 1, name: 1 } }],
|
|
21585
21726
|
as: "template"
|
|
21586
21727
|
}
|
|
21587
21728
|
},
|
|
21588
21729
|
{
|
|
21589
21730
|
$project: {
|
|
21590
|
-
_id:
|
|
21591
|
-
keyId: "$_id",
|
|
21592
|
-
status: 1,
|
|
21593
|
-
description: 1,
|
|
21594
|
-
remarks: {
|
|
21595
|
-
$arrayElemAt: ["$template.remarks", 0]
|
|
21596
|
-
},
|
|
21597
|
-
templatePrefixPass: {
|
|
21598
|
-
$arrayElemAt: ["$template.prefixPass", 0]
|
|
21599
|
-
},
|
|
21731
|
+
_id: 1,
|
|
21600
21732
|
prefixAndName: {
|
|
21601
21733
|
$concat: [
|
|
21602
|
-
{
|
|
21603
|
-
$ifNull: [
|
|
21604
|
-
{ $arrayElemAt: ["$template.prefixPass", 0] },
|
|
21605
|
-
""
|
|
21606
|
-
]
|
|
21607
|
-
},
|
|
21734
|
+
{ $ifNull: [{ $arrayElemAt: ["$template.prefixPass", 0] }, ""] },
|
|
21608
21735
|
{ $ifNull: ["$name", ""] }
|
|
21609
21736
|
]
|
|
21610
21737
|
}
|
|
21611
21738
|
}
|
|
21612
21739
|
}
|
|
21613
21740
|
],
|
|
21614
|
-
as: "
|
|
21741
|
+
as: "passKeys_lookup"
|
|
21742
|
+
}
|
|
21743
|
+
},
|
|
21744
|
+
// 4. Map through original passKeys array, keep all fields, inject prefixAndName
|
|
21745
|
+
{
|
|
21746
|
+
$addFields: {
|
|
21747
|
+
passKeys: {
|
|
21748
|
+
$map: {
|
|
21749
|
+
input: "$passKeys",
|
|
21750
|
+
as: "original",
|
|
21751
|
+
in: {
|
|
21752
|
+
// Explicitly retain all original fields from your document
|
|
21753
|
+
keyId: "$$original.keyId",
|
|
21754
|
+
receivedDate: "$$original.receivedDate",
|
|
21755
|
+
status: "$$original.status",
|
|
21756
|
+
lastUpdate: "$$original.lastUpdate",
|
|
21757
|
+
remarks: "$$original.remarks",
|
|
21758
|
+
// Find and extract ONLY the prefixAndName string from lookup
|
|
21759
|
+
prefixAndName: {
|
|
21760
|
+
$let: {
|
|
21761
|
+
vars: {
|
|
21762
|
+
matched: {
|
|
21763
|
+
$arrayElemAt: [
|
|
21764
|
+
{
|
|
21765
|
+
$filter: {
|
|
21766
|
+
input: "$passKeys_lookup",
|
|
21767
|
+
as: "lookup",
|
|
21768
|
+
cond: { $eq: ["$$lookup._id", "$$original.keyId"] }
|
|
21769
|
+
}
|
|
21770
|
+
},
|
|
21771
|
+
0
|
|
21772
|
+
]
|
|
21773
|
+
}
|
|
21774
|
+
},
|
|
21775
|
+
in: "$$matched.prefixAndName"
|
|
21776
|
+
}
|
|
21777
|
+
}
|
|
21778
|
+
}
|
|
21779
|
+
}
|
|
21780
|
+
}
|
|
21781
|
+
}
|
|
21782
|
+
},
|
|
21783
|
+
// 5. Cleanup temporary arrays
|
|
21784
|
+
{
|
|
21785
|
+
$project: {
|
|
21786
|
+
visitorPass_lookup: 0,
|
|
21787
|
+
passKeys_lookup: 0
|
|
21615
21788
|
}
|
|
21616
21789
|
},
|
|
21617
21790
|
{
|
|
@@ -21808,6 +21981,7 @@ function useVisitorTransactionRepo() {
|
|
|
21808
21981
|
}
|
|
21809
21982
|
try {
|
|
21810
21983
|
const updateFields = {};
|
|
21984
|
+
const pushFields = {};
|
|
21811
21985
|
const arrayFilters = [];
|
|
21812
21986
|
Object.keys(value).forEach((key) => {
|
|
21813
21987
|
if (key !== "visitorPass" && key !== "passKeys") {
|
|
@@ -21817,34 +21991,63 @@ function useVisitorTransactionRepo() {
|
|
|
21817
21991
|
});
|
|
21818
21992
|
if (Array.isArray(value.visitorPass)) {
|
|
21819
21993
|
value.visitorPass.forEach((item, index) => {
|
|
21820
|
-
|
|
21821
|
-
|
|
21822
|
-
|
|
21823
|
-
|
|
21824
|
-
|
|
21825
|
-
updateFields[`visitorPass.$[${elementKey}].${itemKey}`] = itemValue;
|
|
21994
|
+
if (item.add === true) {
|
|
21995
|
+
const { add: add2, ...cleanItem } = item;
|
|
21996
|
+
cleanItem.keyId = convertObjectIdUtilNonAsync(cleanItem.keyId, "Pass Id");
|
|
21997
|
+
if (!pushFields["visitorPass"]) {
|
|
21998
|
+
pushFields["visitorPass"] = { $each: [] };
|
|
21826
21999
|
}
|
|
21827
|
-
|
|
21828
|
-
|
|
22000
|
+
pushFields["visitorPass"].$each.push(cleanItem);
|
|
22001
|
+
} else {
|
|
22002
|
+
const elementKey = `vElem${index}`;
|
|
22003
|
+
Object.keys(item).forEach((itemKey) => {
|
|
22004
|
+
if (itemKey !== "keyId") {
|
|
22005
|
+
const typedItemKey = itemKey;
|
|
22006
|
+
let itemValue = item[typedItemKey];
|
|
22007
|
+
updateFields[`visitorPass.$[${elementKey}].${itemKey}`] = itemValue;
|
|
22008
|
+
}
|
|
22009
|
+
});
|
|
22010
|
+
arrayFilters.push({ [`${elementKey}.keyId`]: new import_mongodb41.ObjectId(item.keyId) });
|
|
22011
|
+
}
|
|
21829
22012
|
});
|
|
21830
22013
|
}
|
|
21831
22014
|
if (Array.isArray(value.passKeys)) {
|
|
21832
22015
|
value.passKeys.forEach((item, index) => {
|
|
21833
|
-
|
|
21834
|
-
|
|
21835
|
-
|
|
21836
|
-
|
|
21837
|
-
|
|
21838
|
-
updateFields[`passKeys.$[${elementKey}].${itemKey}`] = itemValue;
|
|
22016
|
+
if (item.add === true) {
|
|
22017
|
+
const { add: add2, ...cleanItem } = item;
|
|
22018
|
+
cleanItem.keyId = convertObjectIdUtilNonAsync(cleanItem.keyId, "Key Id");
|
|
22019
|
+
if (!pushFields["passKeys"]) {
|
|
22020
|
+
pushFields["passKeys"] = { $each: [] };
|
|
21839
22021
|
}
|
|
21840
|
-
|
|
21841
|
-
|
|
22022
|
+
pushFields["passKeys"].$each.push(cleanItem);
|
|
22023
|
+
} else {
|
|
22024
|
+
const elementKey = `pElem${index}`;
|
|
22025
|
+
Object.keys(item).forEach((itemKey) => {
|
|
22026
|
+
if (itemKey !== "keyId") {
|
|
22027
|
+
const typedItemKey = itemKey;
|
|
22028
|
+
let itemValue = item[typedItemKey];
|
|
22029
|
+
updateFields[`passKeys.$[${elementKey}].${itemKey}`] = itemValue;
|
|
22030
|
+
}
|
|
22031
|
+
});
|
|
22032
|
+
arrayFilters.push({ [`${elementKey}.keyId`]: new import_mongodb41.ObjectId(item.keyId) });
|
|
22033
|
+
}
|
|
21842
22034
|
});
|
|
21843
22035
|
}
|
|
22036
|
+
const updatePayload = {};
|
|
22037
|
+
if (Object.keys(updateFields).length > 0) {
|
|
22038
|
+
updatePayload.$set = updateFields;
|
|
22039
|
+
}
|
|
22040
|
+
if (Object.keys(pushFields).length > 0) {
|
|
22041
|
+
updatePayload.$push = pushFields;
|
|
22042
|
+
}
|
|
21844
22043
|
const result = await collection.updateOne(
|
|
21845
22044
|
{ _id: new import_mongodb41.ObjectId(_id) },
|
|
21846
|
-
|
|
21847
|
-
{
|
|
22045
|
+
updatePayload,
|
|
22046
|
+
{
|
|
22047
|
+
...arrayFilters.length > 0 && { arrayFilters },
|
|
22048
|
+
// Only pass if not empty
|
|
22049
|
+
session
|
|
22050
|
+
}
|
|
21848
22051
|
);
|
|
21849
22052
|
return result;
|
|
21850
22053
|
} catch (error) {
|
|
@@ -33537,12 +33740,28 @@ var KeyRepo = class {
|
|
|
33537
33740
|
return Promise.reject("Server internal error.");
|
|
33538
33741
|
}
|
|
33539
33742
|
}
|
|
33540
|
-
static async updateKeyById(keyId, key, site, session, isChild, visitorId) {
|
|
33743
|
+
static async updateKeyById(keyId, key, site, session, isChild, visitorId, isDifferentStatus, isPassKeyVisitorAdd) {
|
|
33541
33744
|
keyId = await convertObjectIdUtil2(keyId, "keyId");
|
|
33542
33745
|
if (site)
|
|
33543
33746
|
site = await convertObjectIdUtil2(site, "Site");
|
|
33544
|
-
if (visitorId)
|
|
33545
|
-
visitorId = await convertObjectIdUtil2(visitorId, "
|
|
33747
|
+
if (visitorId) {
|
|
33748
|
+
visitorId = await convertObjectIdUtil2(visitorId, "Visitor Id");
|
|
33749
|
+
if (!isPassKeyVisitorAdd) {
|
|
33750
|
+
const findOptions = { sort: { _id: -1 } };
|
|
33751
|
+
const latestHistory = await this.collectionDynamic("keys-histories").findOne(
|
|
33752
|
+
{ passOrKeyId: keyId },
|
|
33753
|
+
findOptions
|
|
33754
|
+
);
|
|
33755
|
+
console.log("visitorId", visitorId.toString());
|
|
33756
|
+
console.log("latestHistory.visitorId", latestHistory?.visitorId.toString());
|
|
33757
|
+
if (latestHistory?.visitorId && latestHistory.visitorId?.toString() !== visitorId.toString()) {
|
|
33758
|
+
console.log("Not updating keyId", keyId);
|
|
33759
|
+
return;
|
|
33760
|
+
} else {
|
|
33761
|
+
console.log("updating keyId", keyId);
|
|
33762
|
+
}
|
|
33763
|
+
}
|
|
33764
|
+
}
|
|
33546
33765
|
if (key.updatedBy)
|
|
33547
33766
|
key.updatedBy = await convertObjectIdUtil2(key.updatedBy, "Updated By");
|
|
33548
33767
|
if (!key.status)
|
|
@@ -33550,9 +33769,14 @@ var KeyRepo = class {
|
|
|
33550
33769
|
try {
|
|
33551
33770
|
key.updatedAt = /* @__PURE__ */ new Date();
|
|
33552
33771
|
const query = { _id: keyId, ...site && { site } };
|
|
33553
|
-
let find = query;
|
|
33554
|
-
if (isChild)
|
|
33772
|
+
let find = { ...query };
|
|
33773
|
+
if (isChild) {
|
|
33555
33774
|
find = { parentId: keyId, site };
|
|
33775
|
+
} else {
|
|
33776
|
+
if (isDifferentStatus && typeof key?.status == "string") {
|
|
33777
|
+
find.status = { $ne: key.status };
|
|
33778
|
+
}
|
|
33779
|
+
}
|
|
33556
33780
|
const result = await this.collection().updateMany(
|
|
33557
33781
|
find,
|
|
33558
33782
|
{ $set: key },
|
|
@@ -33578,7 +33802,11 @@ var KeyRepo = class {
|
|
|
33578
33802
|
session
|
|
33579
33803
|
});
|
|
33580
33804
|
} else {
|
|
33581
|
-
|
|
33805
|
+
if (visitorId) {
|
|
33806
|
+
console.log(`visitorId: ${visitorId} keyId: ${keyId} Not Updated`);
|
|
33807
|
+
} else {
|
|
33808
|
+
throw new Error("Failed Updating Keys");
|
|
33809
|
+
}
|
|
33582
33810
|
}
|
|
33583
33811
|
return result;
|
|
33584
33812
|
} catch (error) {
|
|
@@ -33943,40 +34171,6 @@ function useVisitorTransactionService() {
|
|
|
33943
34171
|
}
|
|
33944
34172
|
return normalized;
|
|
33945
34173
|
}
|
|
33946
|
-
async function syncTransactionKeys({
|
|
33947
|
-
current,
|
|
33948
|
-
incoming,
|
|
33949
|
-
site,
|
|
33950
|
-
session
|
|
33951
|
-
}) {
|
|
33952
|
-
const currentIds = current.map((item) => item.keyId.toString());
|
|
33953
|
-
const incomingIds = incoming.map((item) => item.keyId.toString());
|
|
33954
|
-
const currentSet = new Set(currentIds);
|
|
33955
|
-
const incomingSet = new Set(incomingIds);
|
|
33956
|
-
const removedIds = currentIds.filter((id) => !incomingSet.has(id));
|
|
33957
|
-
const addedIds = incomingIds.filter((id) => !currentSet.has(id));
|
|
33958
|
-
for (const keyId of removedIds) {
|
|
33959
|
-
const existingKey = await KeyRepo.getById(keyId);
|
|
33960
|
-
if (!existingKey)
|
|
33961
|
-
continue;
|
|
33962
|
-
if (existingKey.status === "In Use" /* IN_USE */) {
|
|
33963
|
-
await KeyRepo.updateKeyById(
|
|
33964
|
-
keyId,
|
|
33965
|
-
{ status: "Available" /* AVAILABLE */ },
|
|
33966
|
-
site,
|
|
33967
|
-
session
|
|
33968
|
-
);
|
|
33969
|
-
}
|
|
33970
|
-
}
|
|
33971
|
-
for (const keyId of addedIds) {
|
|
33972
|
-
await KeyRepo.updateKeyById(
|
|
33973
|
-
keyId,
|
|
33974
|
-
{ status: "In Use" /* IN_USE */ },
|
|
33975
|
-
site,
|
|
33976
|
-
session
|
|
33977
|
-
);
|
|
33978
|
-
}
|
|
33979
|
-
}
|
|
33980
34174
|
async function add(value) {
|
|
33981
34175
|
const session = import_node_server_utils106.useAtlas.getClient()?.startSession();
|
|
33982
34176
|
const allowedPersonTypes = [
|
|
@@ -34112,7 +34306,9 @@ function useVisitorTransactionService() {
|
|
|
34112
34306
|
value.site,
|
|
34113
34307
|
session,
|
|
34114
34308
|
void 0,
|
|
34115
|
-
visitorId
|
|
34309
|
+
visitorId,
|
|
34310
|
+
void 0,
|
|
34311
|
+
true
|
|
34116
34312
|
);
|
|
34117
34313
|
}
|
|
34118
34314
|
for (const item of preparedPassKeys) {
|
|
@@ -34124,7 +34320,11 @@ function useVisitorTransactionService() {
|
|
|
34124
34320
|
visitorId
|
|
34125
34321
|
},
|
|
34126
34322
|
value.site,
|
|
34127
|
-
session
|
|
34323
|
+
session,
|
|
34324
|
+
void 0,
|
|
34325
|
+
visitorId,
|
|
34326
|
+
void 0,
|
|
34327
|
+
true
|
|
34128
34328
|
);
|
|
34129
34329
|
}
|
|
34130
34330
|
})
|
|
@@ -34155,43 +34355,49 @@ function useVisitorTransactionService() {
|
|
|
34155
34355
|
throw new import_node_server_utils106.BadRequestError("This plate number is blocklisted");
|
|
34156
34356
|
}
|
|
34157
34357
|
await KeyRepo.checkPassKeyAvailability(value.visitorPass, value.passKeys);
|
|
34358
|
+
if (Array.isArray(value.visitorPass)) {
|
|
34359
|
+
for (const item of value.visitorPass) {
|
|
34360
|
+
item.receivedDate = /* @__PURE__ */ new Date();
|
|
34361
|
+
item.status = "Not Returned" /* NOT_RETURNED */;
|
|
34362
|
+
item.lastUpdate = null;
|
|
34363
|
+
item.remarks = "";
|
|
34364
|
+
}
|
|
34365
|
+
}
|
|
34366
|
+
if (Array.isArray(value.passKeys)) {
|
|
34367
|
+
for (const item of value.passKeys) {
|
|
34368
|
+
item.receivedDate = /* @__PURE__ */ new Date();
|
|
34369
|
+
item.status = "Not Returned" /* NOT_RETURNED */;
|
|
34370
|
+
item.lastUpdate = null;
|
|
34371
|
+
item.remarks = "";
|
|
34372
|
+
}
|
|
34373
|
+
}
|
|
34158
34374
|
const result = await _add(value, session);
|
|
34159
34375
|
if (Array.isArray(value.visitorPass)) {
|
|
34160
34376
|
for (const item of value.visitorPass) {
|
|
34161
34377
|
await KeyRepo.updateKeyById(
|
|
34162
34378
|
item.keyId,
|
|
34163
|
-
{
|
|
34164
|
-
status: "In Use" /* IN_USE */,
|
|
34165
|
-
updatedBy: value.createdBy
|
|
34166
|
-
},
|
|
34379
|
+
{ status: "In Use" /* IN_USE */, updatedBy: value.createdBy },
|
|
34167
34380
|
value.site,
|
|
34168
34381
|
session,
|
|
34169
34382
|
void 0,
|
|
34170
|
-
result
|
|
34383
|
+
result,
|
|
34384
|
+
void 0,
|
|
34385
|
+
true
|
|
34171
34386
|
);
|
|
34172
|
-
item.receivedDate = /* @__PURE__ */ new Date();
|
|
34173
|
-
item.status = "Not Returned" /* NOT_RETURNED */;
|
|
34174
|
-
item.lastUpdate = null;
|
|
34175
|
-
item.remarks = "";
|
|
34176
34387
|
}
|
|
34177
34388
|
}
|
|
34178
34389
|
if (Array.isArray(value.passKeys)) {
|
|
34179
34390
|
for (const item of value.passKeys) {
|
|
34180
34391
|
await KeyRepo.updateKeyById(
|
|
34181
34392
|
item.keyId,
|
|
34182
|
-
{
|
|
34183
|
-
status: "In Use" /* IN_USE */,
|
|
34184
|
-
updatedBy: value.createdBy
|
|
34185
|
-
},
|
|
34393
|
+
{ status: "In Use" /* IN_USE */, updatedBy: value.createdBy },
|
|
34186
34394
|
value.site,
|
|
34187
34395
|
session,
|
|
34188
34396
|
void 0,
|
|
34189
|
-
result
|
|
34397
|
+
result,
|
|
34398
|
+
void 0,
|
|
34399
|
+
true
|
|
34190
34400
|
);
|
|
34191
|
-
item.receivedDate = /* @__PURE__ */ new Date();
|
|
34192
|
-
item.status = "Not Returned" /* NOT_RETURNED */;
|
|
34193
|
-
item.lastUpdate = null;
|
|
34194
|
-
item.remarks = "";
|
|
34195
34401
|
}
|
|
34196
34402
|
}
|
|
34197
34403
|
await session?.commitTransaction();
|
|
@@ -34288,54 +34494,98 @@ function useVisitorTransactionService() {
|
|
|
34288
34494
|
}
|
|
34289
34495
|
if (Array.isArray(value.visitorPass)) {
|
|
34290
34496
|
for (const item of value.visitorPass) {
|
|
34291
|
-
|
|
34292
|
-
|
|
34293
|
-
|
|
34294
|
-
|
|
34295
|
-
|
|
34296
|
-
|
|
34297
|
-
|
|
34497
|
+
if (item.add) {
|
|
34498
|
+
await KeyRepo.updateKeyById(
|
|
34499
|
+
item.keyId,
|
|
34500
|
+
{
|
|
34501
|
+
status: "In Use" /* IN_USE */,
|
|
34502
|
+
updatedBy: value.updatedBy
|
|
34503
|
+
},
|
|
34504
|
+
value.site,
|
|
34505
|
+
session,
|
|
34506
|
+
void 0,
|
|
34507
|
+
id
|
|
34508
|
+
);
|
|
34509
|
+
item.receivedDate = /* @__PURE__ */ new Date();
|
|
34510
|
+
item.status = "Not Returned" /* NOT_RETURNED */;
|
|
34511
|
+
item.lastUpdate = null;
|
|
34512
|
+
item.remarks = "";
|
|
34298
34513
|
} else {
|
|
34299
|
-
|
|
34514
|
+
let status = "Invalid";
|
|
34515
|
+
if (item?.status == "Returned" /* RETURNED */) {
|
|
34516
|
+
status = "Available" /* AVAILABLE */;
|
|
34517
|
+
} else if (item?.status == "Removed" /* REMOVED */) {
|
|
34518
|
+
status = "Available" /* AVAILABLE */;
|
|
34519
|
+
} else if (item?.status == "Not Returned" /* NOT_RETURNED */) {
|
|
34520
|
+
status = "In Use" /* IN_USE */;
|
|
34521
|
+
} else if (item?.status && VALID_STATUSES.has(item.status)) {
|
|
34522
|
+
status = item.status;
|
|
34523
|
+
} else {
|
|
34524
|
+
throw new Error("Invalid Visitor Pass Status");
|
|
34525
|
+
}
|
|
34526
|
+
await KeyRepo.updateKeyById(
|
|
34527
|
+
item.keyId,
|
|
34528
|
+
{
|
|
34529
|
+
status,
|
|
34530
|
+
updatedBy: value.updatedBy
|
|
34531
|
+
},
|
|
34532
|
+
value.site,
|
|
34533
|
+
session,
|
|
34534
|
+
void 0,
|
|
34535
|
+
id,
|
|
34536
|
+
true
|
|
34537
|
+
);
|
|
34538
|
+
delete item.receivedDate;
|
|
34539
|
+
item.lastUpdate = /* @__PURE__ */ new Date();
|
|
34300
34540
|
}
|
|
34301
|
-
await KeyRepo.updateKeyById(
|
|
34302
|
-
item.keyId,
|
|
34303
|
-
{
|
|
34304
|
-
status,
|
|
34305
|
-
updatedBy: value.updatedBy
|
|
34306
|
-
},
|
|
34307
|
-
value.site,
|
|
34308
|
-
session,
|
|
34309
|
-
void 0,
|
|
34310
|
-
id
|
|
34311
|
-
);
|
|
34312
|
-
item.lastUpdate = /* @__PURE__ */ new Date();
|
|
34313
34541
|
}
|
|
34314
34542
|
}
|
|
34315
34543
|
if (Array.isArray(value.passKeys)) {
|
|
34316
34544
|
for (const item of value.passKeys) {
|
|
34317
|
-
|
|
34318
|
-
|
|
34319
|
-
|
|
34320
|
-
|
|
34321
|
-
|
|
34322
|
-
|
|
34323
|
-
|
|
34545
|
+
if (item.add) {
|
|
34546
|
+
await KeyRepo.updateKeyById(
|
|
34547
|
+
item.keyId,
|
|
34548
|
+
{
|
|
34549
|
+
status: "In Use" /* IN_USE */,
|
|
34550
|
+
updatedBy: value.updatedBy
|
|
34551
|
+
},
|
|
34552
|
+
value.site,
|
|
34553
|
+
session,
|
|
34554
|
+
void 0,
|
|
34555
|
+
id
|
|
34556
|
+
);
|
|
34557
|
+
item.receivedDate = /* @__PURE__ */ new Date();
|
|
34558
|
+
item.status = "Not Returned" /* NOT_RETURNED */;
|
|
34559
|
+
item.lastUpdate = null;
|
|
34560
|
+
item.remarks = "";
|
|
34324
34561
|
} else {
|
|
34325
|
-
|
|
34562
|
+
let status = "Invalid";
|
|
34563
|
+
if (item?.status == "Returned" /* RETURNED */) {
|
|
34564
|
+
status = "Available" /* AVAILABLE */;
|
|
34565
|
+
} else if (item?.status == "Removed" /* REMOVED */) {
|
|
34566
|
+
status = "Available" /* AVAILABLE */;
|
|
34567
|
+
} else if (item?.status == "Not Returned" /* NOT_RETURNED */) {
|
|
34568
|
+
status = "In Use" /* IN_USE */;
|
|
34569
|
+
} else if (item?.status && VALID_STATUSES.has(item.status)) {
|
|
34570
|
+
status = item.status;
|
|
34571
|
+
} else {
|
|
34572
|
+
throw new Error("Invalid Visitor Pass Status");
|
|
34573
|
+
}
|
|
34574
|
+
await KeyRepo.updateKeyById(
|
|
34575
|
+
item.keyId,
|
|
34576
|
+
{
|
|
34577
|
+
status,
|
|
34578
|
+
updatedBy: value.updatedBy
|
|
34579
|
+
},
|
|
34580
|
+
value.site,
|
|
34581
|
+
session,
|
|
34582
|
+
void 0,
|
|
34583
|
+
id,
|
|
34584
|
+
true
|
|
34585
|
+
);
|
|
34586
|
+
delete item.receivedDate;
|
|
34587
|
+
item.lastUpdate = /* @__PURE__ */ new Date();
|
|
34326
34588
|
}
|
|
34327
|
-
await KeyRepo.updateKeyById(
|
|
34328
|
-
item.keyId,
|
|
34329
|
-
{
|
|
34330
|
-
status,
|
|
34331
|
-
updatedBy: value.updatedBy
|
|
34332
|
-
},
|
|
34333
|
-
value.site,
|
|
34334
|
-
session,
|
|
34335
|
-
void 0,
|
|
34336
|
-
id
|
|
34337
|
-
);
|
|
34338
|
-
item.lastUpdate = /* @__PURE__ */ new Date();
|
|
34339
34589
|
}
|
|
34340
34590
|
}
|
|
34341
34591
|
await _updateVisitorTansactionById(id, value, session);
|
|
@@ -34502,63 +34752,12 @@ function useVisitorTransactionService() {
|
|
|
34502
34752
|
session?.endSession();
|
|
34503
34753
|
}
|
|
34504
34754
|
}
|
|
34505
|
-
async function changeVisitorTransactionKeysById(id, visitorPass, passKeys) {
|
|
34506
|
-
const session = import_node_server_utils106.useAtlas.getClient()?.startSession();
|
|
34507
|
-
if (!session) {
|
|
34508
|
-
throw new Error(
|
|
34509
|
-
"Unable to start session for visitor transaction service."
|
|
34510
|
-
);
|
|
34511
|
-
}
|
|
34512
|
-
try {
|
|
34513
|
-
session.startTransaction();
|
|
34514
|
-
const visitorTransaction = await _getVisitorTransactionById(id);
|
|
34515
|
-
if (!visitorTransaction) {
|
|
34516
|
-
throw new Error("Visitor transaction not found.");
|
|
34517
|
-
}
|
|
34518
|
-
const updatePayload = {};
|
|
34519
|
-
if (visitorPass !== void 0) {
|
|
34520
|
-
const currentVisitorPass = normalizeKeyRefs(
|
|
34521
|
-
visitorTransaction.visitorPass
|
|
34522
|
-
);
|
|
34523
|
-
const incomingVisitorPass = normalizeKeyRefs(visitorPass);
|
|
34524
|
-
await syncTransactionKeys({
|
|
34525
|
-
current: currentVisitorPass,
|
|
34526
|
-
incoming: incomingVisitorPass,
|
|
34527
|
-
site: visitorTransaction.site,
|
|
34528
|
-
session
|
|
34529
|
-
});
|
|
34530
|
-
updatePayload.visitorPass = incomingVisitorPass;
|
|
34531
|
-
}
|
|
34532
|
-
if (passKeys !== void 0) {
|
|
34533
|
-
const currentPassKeys = normalizeKeyRefs(visitorTransaction.passKeys);
|
|
34534
|
-
const incomingPassKeys = normalizeKeyRefs(passKeys);
|
|
34535
|
-
await syncTransactionKeys({
|
|
34536
|
-
current: currentPassKeys,
|
|
34537
|
-
incoming: incomingPassKeys,
|
|
34538
|
-
site: visitorTransaction.site,
|
|
34539
|
-
session
|
|
34540
|
-
});
|
|
34541
|
-
updatePayload.passKeys = incomingPassKeys;
|
|
34542
|
-
}
|
|
34543
|
-
if (Object.keys(updatePayload).length > 0) {
|
|
34544
|
-
await _updateVisitorTansactionById(id, updatePayload, session);
|
|
34545
|
-
}
|
|
34546
|
-
await session.commitTransaction();
|
|
34547
|
-
return "Successfully changed visitor transaction keys.";
|
|
34548
|
-
} catch (error) {
|
|
34549
|
-
await session.abortTransaction();
|
|
34550
|
-
import_node_server_utils106.logger.error("Error in visitor transaction change keys by id:", error);
|
|
34551
|
-
throw error;
|
|
34552
|
-
} finally {
|
|
34553
|
-
session.endSession();
|
|
34554
|
-
}
|
|
34555
|
-
}
|
|
34556
34755
|
return {
|
|
34557
34756
|
add,
|
|
34558
34757
|
updateVisitorTransactionById,
|
|
34559
34758
|
processTransactionDahuaStatus,
|
|
34560
|
-
inviteVisitor
|
|
34561
|
-
changeVisitorTransactionKeysById
|
|
34759
|
+
inviteVisitor
|
|
34760
|
+
// changeVisitorTransactionKeysById,
|
|
34562
34761
|
};
|
|
34563
34762
|
}
|
|
34564
34763
|
|
|
@@ -34569,8 +34768,8 @@ function useVisitorTransactionController() {
|
|
|
34569
34768
|
const {
|
|
34570
34769
|
add: _add,
|
|
34571
34770
|
updateVisitorTransactionById: _updateVisitorTransactionById,
|
|
34572
|
-
inviteVisitor: _inviteVisitor
|
|
34573
|
-
changeVisitorTransactionKeysById: _changeVisitorTransactionKeysById
|
|
34771
|
+
inviteVisitor: _inviteVisitor
|
|
34772
|
+
// changeVisitorTransactionKeysById: _changeVisitorTransactionKeysById,
|
|
34574
34773
|
} = useVisitorTransactionService();
|
|
34575
34774
|
const {
|
|
34576
34775
|
getAll: _getAll,
|
|
@@ -34727,7 +34926,12 @@ function useVisitorTransactionController() {
|
|
|
34727
34926
|
return;
|
|
34728
34927
|
} catch (error2) {
|
|
34729
34928
|
import_node_server_utils107.logger.log({ level: "error", message: error2.message });
|
|
34730
|
-
|
|
34929
|
+
console.log("error", error2);
|
|
34930
|
+
if (error2?.message) {
|
|
34931
|
+
next(new import_node_server_utils107.BadRequestError(error2?.message));
|
|
34932
|
+
} else {
|
|
34933
|
+
next(error2);
|
|
34934
|
+
}
|
|
34731
34935
|
return;
|
|
34732
34936
|
}
|
|
34733
34937
|
}
|
|
@@ -34820,61 +35024,14 @@ function useVisitorTransactionController() {
|
|
|
34820
35024
|
}
|
|
34821
35025
|
}
|
|
34822
35026
|
}
|
|
34823
|
-
async function changeVisitorTransactionKeysById(req, res, next) {
|
|
34824
|
-
const idValidation = import_joi57.default.string().hex().length(24).required();
|
|
34825
|
-
const bodyValidation = import_joi57.default.object({
|
|
34826
|
-
visitorPass: import_joi57.default.array().items(
|
|
34827
|
-
import_joi57.default.object({
|
|
34828
|
-
keyId: import_joi57.default.string().hex().length(24).required()
|
|
34829
|
-
})
|
|
34830
|
-
).optional(),
|
|
34831
|
-
passKeys: import_joi57.default.array().items(
|
|
34832
|
-
import_joi57.default.object({
|
|
34833
|
-
keyId: import_joi57.default.string().hex().length(24).required()
|
|
34834
|
-
})
|
|
34835
|
-
).optional()
|
|
34836
|
-
}).or("visitorPass", "passKeys");
|
|
34837
|
-
const _id = req.params.id;
|
|
34838
|
-
const { error: idError } = idValidation.validate(_id);
|
|
34839
|
-
if (idError) {
|
|
34840
|
-
import_node_server_utils107.logger.log({ level: "error", message: idError.message });
|
|
34841
|
-
next(new import_node_server_utils107.BadRequestError(idError.message));
|
|
34842
|
-
return;
|
|
34843
|
-
}
|
|
34844
|
-
const { error, value } = bodyValidation.validate(req.body, {
|
|
34845
|
-
abortEarly: false
|
|
34846
|
-
});
|
|
34847
|
-
if (error) {
|
|
34848
|
-
const message = error.details.map((d) => d.message).join(", ");
|
|
34849
|
-
import_node_server_utils107.logger.log({ level: "error", message });
|
|
34850
|
-
next(new import_node_server_utils107.BadRequestError(message));
|
|
34851
|
-
return;
|
|
34852
|
-
}
|
|
34853
|
-
try {
|
|
34854
|
-
const { visitorPass, passKeys } = value;
|
|
34855
|
-
const result = await _changeVisitorTransactionKeysById(
|
|
34856
|
-
_id,
|
|
34857
|
-
visitorPass,
|
|
34858
|
-
passKeys
|
|
34859
|
-
);
|
|
34860
|
-
res.status(200).json({
|
|
34861
|
-
message: result || "Successfully changed visitor transaction keys."
|
|
34862
|
-
});
|
|
34863
|
-
return;
|
|
34864
|
-
} catch (error2) {
|
|
34865
|
-
import_node_server_utils107.logger.log({ level: "error", message: error2.message });
|
|
34866
|
-
next(error2);
|
|
34867
|
-
return;
|
|
34868
|
-
}
|
|
34869
|
-
}
|
|
34870
35027
|
return {
|
|
34871
35028
|
add,
|
|
34872
35029
|
getAll,
|
|
34873
35030
|
updateVisitorTansactionById,
|
|
34874
35031
|
deleteVisitorTransaction,
|
|
34875
35032
|
inviteVisitor,
|
|
34876
|
-
getVisitorTransactionById
|
|
34877
|
-
changeVisitorTransactionKeysById
|
|
35033
|
+
getVisitorTransactionById
|
|
35034
|
+
// changeVisitorTransactionKeysById,
|
|
34878
35035
|
};
|
|
34879
35036
|
}
|
|
34880
35037
|
|
|
@@ -69637,6 +69794,7 @@ function useHidAmicoController() {
|
|
|
69637
69794
|
useManpowerSitesSrvc,
|
|
69638
69795
|
useMemberController,
|
|
69639
69796
|
useMemberRepo,
|
|
69797
|
+
useMemberService,
|
|
69640
69798
|
useNewDashboardController,
|
|
69641
69799
|
useNewDashboardRepo,
|
|
69642
69800
|
useNfcPatrolLogController,
|