@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.mjs
CHANGED
|
@@ -10150,6 +10150,56 @@ function useVerificationRepo() {
|
|
|
10150
10150
|
async function findOne(query) {
|
|
10151
10151
|
return await collection.findOne(query);
|
|
10152
10152
|
}
|
|
10153
|
+
async function completePendingInvites({
|
|
10154
|
+
email,
|
|
10155
|
+
orgId,
|
|
10156
|
+
siteId,
|
|
10157
|
+
app,
|
|
10158
|
+
session
|
|
10159
|
+
}) {
|
|
10160
|
+
const orgCandidates = [orgId];
|
|
10161
|
+
try {
|
|
10162
|
+
orgCandidates.push(new ObjectId13(orgId));
|
|
10163
|
+
} catch {
|
|
10164
|
+
}
|
|
10165
|
+
const query = {
|
|
10166
|
+
email: { $regex: `^${email}$`, $options: "i" },
|
|
10167
|
+
status: "pending",
|
|
10168
|
+
type: {
|
|
10169
|
+
$in: ["user-invite" /* USER_INVITE */, "member-invite" /* MEMBER_INVITE */]
|
|
10170
|
+
},
|
|
10171
|
+
"metadata.org": { $in: orgCandidates }
|
|
10172
|
+
};
|
|
10173
|
+
if (siteId) {
|
|
10174
|
+
const siteCandidates = [siteId];
|
|
10175
|
+
try {
|
|
10176
|
+
siteCandidates.push(new ObjectId13(siteId));
|
|
10177
|
+
} catch {
|
|
10178
|
+
}
|
|
10179
|
+
query["metadata.siteId"] = { $in: siteCandidates };
|
|
10180
|
+
}
|
|
10181
|
+
if (app) {
|
|
10182
|
+
query["metadata.app"] = app;
|
|
10183
|
+
}
|
|
10184
|
+
try {
|
|
10185
|
+
const result = await collection.updateMany(
|
|
10186
|
+
query,
|
|
10187
|
+
{ $set: { status: "complete", updatedAt: (/* @__PURE__ */ new Date()).toISOString() } },
|
|
10188
|
+
{ session }
|
|
10189
|
+
);
|
|
10190
|
+
delNamespace().then(() => {
|
|
10191
|
+
logger9.info(`Cache cleared for namespace: ${namespace_collection}`);
|
|
10192
|
+
}).catch((err) => {
|
|
10193
|
+
logger9.error(
|
|
10194
|
+
`Failed to clear cache for namespace: ${namespace_collection}`,
|
|
10195
|
+
err
|
|
10196
|
+
);
|
|
10197
|
+
});
|
|
10198
|
+
return result;
|
|
10199
|
+
} catch (error) {
|
|
10200
|
+
throw new InternalServerError8("Failed to complete pending invites.");
|
|
10201
|
+
}
|
|
10202
|
+
}
|
|
10153
10203
|
return {
|
|
10154
10204
|
createIndex,
|
|
10155
10205
|
createTextIndex,
|
|
@@ -10159,7 +10209,8 @@ function useVerificationRepo() {
|
|
|
10159
10209
|
getByIdByType,
|
|
10160
10210
|
updateStatusById,
|
|
10161
10211
|
getByStatus,
|
|
10162
|
-
findOne
|
|
10212
|
+
findOne,
|
|
10213
|
+
completePendingInvites
|
|
10163
10214
|
};
|
|
10164
10215
|
}
|
|
10165
10216
|
|
|
@@ -11769,6 +11820,61 @@ function useVerificationRepoV2() {
|
|
|
11769
11820
|
throw new InternalServerError11("Failed to update verification code.");
|
|
11770
11821
|
}
|
|
11771
11822
|
}
|
|
11823
|
+
async function completePendingInvites({
|
|
11824
|
+
email,
|
|
11825
|
+
orgId,
|
|
11826
|
+
siteId,
|
|
11827
|
+
app,
|
|
11828
|
+
session
|
|
11829
|
+
}) {
|
|
11830
|
+
const orgCandidates = [orgId];
|
|
11831
|
+
try {
|
|
11832
|
+
orgCandidates.push(new ObjectId18(orgId));
|
|
11833
|
+
} catch {
|
|
11834
|
+
}
|
|
11835
|
+
const query = {
|
|
11836
|
+
email: { $regex: `^${email}$`, $options: "i" },
|
|
11837
|
+
status: "pending" /* PENDING */,
|
|
11838
|
+
type: {
|
|
11839
|
+
$in: ["user-invite" /* USER_INVITE */, "member-invite" /* MEMBER_INVITE */]
|
|
11840
|
+
},
|
|
11841
|
+
"metadata.org": { $in: orgCandidates }
|
|
11842
|
+
};
|
|
11843
|
+
if (siteId) {
|
|
11844
|
+
const siteCandidates = [siteId];
|
|
11845
|
+
try {
|
|
11846
|
+
siteCandidates.push(new ObjectId18(siteId));
|
|
11847
|
+
} catch {
|
|
11848
|
+
}
|
|
11849
|
+
query["metadata.siteId"] = { $in: siteCandidates };
|
|
11850
|
+
}
|
|
11851
|
+
if (app) {
|
|
11852
|
+
query["metadata.app"] = app;
|
|
11853
|
+
}
|
|
11854
|
+
try {
|
|
11855
|
+
const result = await collection.updateMany(
|
|
11856
|
+
query,
|
|
11857
|
+
{
|
|
11858
|
+
$set: {
|
|
11859
|
+
status: "complete" /* COMPLETE */,
|
|
11860
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
11861
|
+
}
|
|
11862
|
+
},
|
|
11863
|
+
{ session }
|
|
11864
|
+
);
|
|
11865
|
+
delNamespace().then(() => {
|
|
11866
|
+
logger13.info(`Cache cleared for namespace: ${namespace_collection}`);
|
|
11867
|
+
}).catch((err) => {
|
|
11868
|
+
logger13.error(
|
|
11869
|
+
`Failed to clear cache for namespace: ${namespace_collection}`,
|
|
11870
|
+
err
|
|
11871
|
+
);
|
|
11872
|
+
});
|
|
11873
|
+
return result;
|
|
11874
|
+
} catch (error) {
|
|
11875
|
+
throw new InternalServerError11("Failed to complete pending invites.");
|
|
11876
|
+
}
|
|
11877
|
+
}
|
|
11772
11878
|
return {
|
|
11773
11879
|
createIndex,
|
|
11774
11880
|
createTextIndex,
|
|
@@ -11780,7 +11886,8 @@ function useVerificationRepoV2() {
|
|
|
11780
11886
|
updateStatusById,
|
|
11781
11887
|
countPendingOrgInvites,
|
|
11782
11888
|
getPendingVerificationByEmail,
|
|
11783
|
-
updateVerificationCodeById
|
|
11889
|
+
updateVerificationCodeById,
|
|
11890
|
+
completePendingInvites
|
|
11784
11891
|
};
|
|
11785
11892
|
}
|
|
11786
11893
|
|
|
@@ -13893,7 +14000,7 @@ function useMemberService() {
|
|
|
13893
14000
|
getAllByUserId: _getAllByUserId,
|
|
13894
14001
|
completeOnboardingById: _completeOnboardingById
|
|
13895
14002
|
} = useMemberRepo();
|
|
13896
|
-
const { getById: _getVerificationById, updateStatusById } = useVerificationRepo();
|
|
14003
|
+
const { getById: _getVerificationById, updateStatusById, completePendingInvites } = useVerificationRepo();
|
|
13897
14004
|
const { getUserByEmail, updateDefaultOrgByEmail, getUserById } = useUserRepo();
|
|
13898
14005
|
const { getById: getOrgById } = useOrgRepo();
|
|
13899
14006
|
const { getSiteById } = useSiteRepo();
|
|
@@ -13997,6 +14104,13 @@ function useMemberService() {
|
|
|
13997
14104
|
session
|
|
13998
14105
|
);
|
|
13999
14106
|
}
|
|
14107
|
+
await completePendingInvites({
|
|
14108
|
+
email: user.email,
|
|
14109
|
+
orgId,
|
|
14110
|
+
siteId,
|
|
14111
|
+
app,
|
|
14112
|
+
session
|
|
14113
|
+
});
|
|
14000
14114
|
await session?.commitTransaction();
|
|
14001
14115
|
return { member };
|
|
14002
14116
|
} catch (error) {
|
|
@@ -20867,14 +20981,20 @@ var schemaUpdateVisTrans = Joi37.object({
|
|
|
20867
20981
|
Joi37.object({
|
|
20868
20982
|
keyId: Joi37.string().hex().length(24).required(),
|
|
20869
20983
|
status: Joi37.string().optional().allow(null, ""),
|
|
20870
|
-
remarks: Joi37.string().optional().allow(null, "")
|
|
20984
|
+
remarks: Joi37.string().optional().allow(null, ""),
|
|
20985
|
+
receivedDate: Joi37.string().optional().allow(null, ""),
|
|
20986
|
+
lastUpdate: Joi37.string().optional().allow(null, ""),
|
|
20987
|
+
add: Joi37.boolean().optional().allow(null, "")
|
|
20871
20988
|
})
|
|
20872
20989
|
).optional().allow(null),
|
|
20873
20990
|
passKeys: Joi37.array().items(
|
|
20874
20991
|
Joi37.object({
|
|
20875
20992
|
keyId: Joi37.string().hex().length(24).required(),
|
|
20876
20993
|
status: Joi37.string().optional().allow(null, ""),
|
|
20877
|
-
remarks: Joi37.string().optional().allow(null, "")
|
|
20994
|
+
remarks: Joi37.string().optional().allow(null, ""),
|
|
20995
|
+
receivedDate: Joi37.string().optional().allow(null, ""),
|
|
20996
|
+
lastUpdate: Joi37.string().optional().allow(null, ""),
|
|
20997
|
+
add: Joi37.boolean().optional().allow(null, "")
|
|
20878
20998
|
})
|
|
20879
20999
|
).optional().allow(null),
|
|
20880
21000
|
checkInRemarks: Joi37.string().optional().allow("", null),
|
|
@@ -21048,6 +21168,16 @@ async function convertObjectIdUtil(id) {
|
|
|
21048
21168
|
}
|
|
21049
21169
|
}
|
|
21050
21170
|
async function convertObjectIdUtil2(id, fieldName) {
|
|
21171
|
+
try {
|
|
21172
|
+
if (!id)
|
|
21173
|
+
throw new Error(`Invalid ID conversion to ObjectId of ${fieldName}.`);
|
|
21174
|
+
return new ObjectId40(id);
|
|
21175
|
+
} catch (_) {
|
|
21176
|
+
console.log(`Invalid ID conversion to ObjectId of ${fieldName}. : `, id);
|
|
21177
|
+
throw new Error(`Invalid ID conversion to ObjectId of ${fieldName}.`);
|
|
21178
|
+
}
|
|
21179
|
+
}
|
|
21180
|
+
function convertObjectIdUtilNonAsync(id, fieldName) {
|
|
21051
21181
|
try {
|
|
21052
21182
|
if (!id)
|
|
21053
21183
|
throw new Error(`Invalid ID conversion to ObjectId of ${fieldName}.`);
|
|
@@ -21249,6 +21379,7 @@ function useVisitorTransactionRepo() {
|
|
|
21249
21379
|
preserveNullAndEmptyArrays: true
|
|
21250
21380
|
}
|
|
21251
21381
|
},
|
|
21382
|
+
// 1. Lookup visitorPass into a temporary field
|
|
21252
21383
|
{
|
|
21253
21384
|
$lookup: {
|
|
21254
21385
|
from: "keys",
|
|
@@ -21260,48 +21391,66 @@ function useVisitorTransactionRepo() {
|
|
|
21260
21391
|
from: "qr-code-templates",
|
|
21261
21392
|
localField: "template",
|
|
21262
21393
|
foreignField: "_id",
|
|
21263
|
-
pipeline: [
|
|
21264
|
-
{
|
|
21265
|
-
$project: {
|
|
21266
|
-
_id: 1,
|
|
21267
|
-
prefixPass: 1,
|
|
21268
|
-
name: 1,
|
|
21269
|
-
remarks: 1
|
|
21270
|
-
}
|
|
21271
|
-
}
|
|
21272
|
-
],
|
|
21394
|
+
pipeline: [{ $project: { prefixPass: 1, name: 1 } }],
|
|
21273
21395
|
as: "template"
|
|
21274
21396
|
}
|
|
21275
21397
|
},
|
|
21276
21398
|
{
|
|
21277
21399
|
$project: {
|
|
21278
|
-
_id:
|
|
21279
|
-
|
|
21280
|
-
status: 1,
|
|
21281
|
-
description: 1,
|
|
21282
|
-
remarks: {
|
|
21283
|
-
$arrayElemAt: ["$template.remarks", 0]
|
|
21284
|
-
},
|
|
21285
|
-
templatePrefixPass: {
|
|
21286
|
-
$arrayElemAt: ["$template.prefixPass", 0]
|
|
21287
|
-
},
|
|
21400
|
+
_id: 1,
|
|
21401
|
+
// Kept only for matching purposes
|
|
21288
21402
|
prefixAndName: {
|
|
21289
21403
|
$concat: [
|
|
21290
|
-
{
|
|
21291
|
-
$ifNull: [
|
|
21292
|
-
{ $arrayElemAt: ["$template.prefixPass", 0] },
|
|
21293
|
-
""
|
|
21294
|
-
]
|
|
21295
|
-
},
|
|
21404
|
+
{ $ifNull: [{ $arrayElemAt: ["$template.prefixPass", 0] }, ""] },
|
|
21296
21405
|
{ $ifNull: ["$name", ""] }
|
|
21297
21406
|
]
|
|
21298
21407
|
}
|
|
21299
21408
|
}
|
|
21300
21409
|
}
|
|
21301
21410
|
],
|
|
21302
|
-
as: "
|
|
21411
|
+
as: "visitorPass_lookup"
|
|
21303
21412
|
}
|
|
21304
21413
|
},
|
|
21414
|
+
// 2. Map through original array, keep all fields, and inject prefixAndName
|
|
21415
|
+
{
|
|
21416
|
+
$addFields: {
|
|
21417
|
+
visitorPass: {
|
|
21418
|
+
$map: {
|
|
21419
|
+
input: "$visitorPass",
|
|
21420
|
+
as: "original",
|
|
21421
|
+
in: {
|
|
21422
|
+
// Explicitly retain all original fields from your document
|
|
21423
|
+
keyId: "$$original.keyId",
|
|
21424
|
+
receivedDate: "$$original.receivedDate",
|
|
21425
|
+
status: "$$original.status",
|
|
21426
|
+
lastUpdate: "$$original.lastUpdate",
|
|
21427
|
+
remarks: "$$original.remarks",
|
|
21428
|
+
// Find and extract ONLY the prefixAndName string from lookup
|
|
21429
|
+
prefixAndName: {
|
|
21430
|
+
$let: {
|
|
21431
|
+
vars: {
|
|
21432
|
+
matched: {
|
|
21433
|
+
$arrayElemAt: [
|
|
21434
|
+
{
|
|
21435
|
+
$filter: {
|
|
21436
|
+
input: "$visitorPass_lookup",
|
|
21437
|
+
as: "lookup",
|
|
21438
|
+
cond: { $eq: ["$$lookup._id", "$$original.keyId"] }
|
|
21439
|
+
}
|
|
21440
|
+
},
|
|
21441
|
+
0
|
|
21442
|
+
]
|
|
21443
|
+
}
|
|
21444
|
+
},
|
|
21445
|
+
in: "$$matched.prefixAndName"
|
|
21446
|
+
}
|
|
21447
|
+
}
|
|
21448
|
+
}
|
|
21449
|
+
}
|
|
21450
|
+
}
|
|
21451
|
+
}
|
|
21452
|
+
},
|
|
21453
|
+
// 3. Lookup passKeys into a temporary field
|
|
21305
21454
|
{
|
|
21306
21455
|
$lookup: {
|
|
21307
21456
|
from: "keys",
|
|
@@ -21313,46 +21462,69 @@ function useVisitorTransactionRepo() {
|
|
|
21313
21462
|
from: "qr-code-templates",
|
|
21314
21463
|
localField: "template",
|
|
21315
21464
|
foreignField: "_id",
|
|
21316
|
-
pipeline: [
|
|
21317
|
-
{
|
|
21318
|
-
$project: {
|
|
21319
|
-
_id: 1,
|
|
21320
|
-
prefixPass: 1,
|
|
21321
|
-
name: 1,
|
|
21322
|
-
remarks: 1
|
|
21323
|
-
}
|
|
21324
|
-
}
|
|
21325
|
-
],
|
|
21465
|
+
pipeline: [{ $project: { prefixPass: 1, name: 1 } }],
|
|
21326
21466
|
as: "template"
|
|
21327
21467
|
}
|
|
21328
21468
|
},
|
|
21329
21469
|
{
|
|
21330
21470
|
$project: {
|
|
21331
|
-
_id:
|
|
21332
|
-
keyId: "$_id",
|
|
21333
|
-
status: 1,
|
|
21334
|
-
description: 1,
|
|
21335
|
-
remarks: {
|
|
21336
|
-
$arrayElemAt: ["$template.remarks", 0]
|
|
21337
|
-
},
|
|
21338
|
-
templatePrefixPass: {
|
|
21339
|
-
$arrayElemAt: ["$template.prefixPass", 0]
|
|
21340
|
-
},
|
|
21471
|
+
_id: 1,
|
|
21341
21472
|
prefixAndName: {
|
|
21342
21473
|
$concat: [
|
|
21343
|
-
{
|
|
21344
|
-
$ifNull: [
|
|
21345
|
-
{ $arrayElemAt: ["$template.prefixPass", 0] },
|
|
21346
|
-
""
|
|
21347
|
-
]
|
|
21348
|
-
},
|
|
21474
|
+
{ $ifNull: [{ $arrayElemAt: ["$template.prefixPass", 0] }, ""] },
|
|
21349
21475
|
{ $ifNull: ["$name", ""] }
|
|
21350
21476
|
]
|
|
21351
21477
|
}
|
|
21352
21478
|
}
|
|
21353
21479
|
}
|
|
21354
21480
|
],
|
|
21355
|
-
as: "
|
|
21481
|
+
as: "passKeys_lookup"
|
|
21482
|
+
}
|
|
21483
|
+
},
|
|
21484
|
+
// 4. Map through original passKeys array, keep all fields, inject prefixAndName
|
|
21485
|
+
{
|
|
21486
|
+
$addFields: {
|
|
21487
|
+
passKeys: {
|
|
21488
|
+
$map: {
|
|
21489
|
+
input: "$passKeys",
|
|
21490
|
+
as: "original",
|
|
21491
|
+
in: {
|
|
21492
|
+
// Explicitly retain all original fields from your document
|
|
21493
|
+
keyId: "$$original.keyId",
|
|
21494
|
+
receivedDate: "$$original.receivedDate",
|
|
21495
|
+
status: "$$original.status",
|
|
21496
|
+
lastUpdate: "$$original.lastUpdate",
|
|
21497
|
+
remarks: "$$original.remarks",
|
|
21498
|
+
// Find and extract ONLY the prefixAndName string from lookup
|
|
21499
|
+
prefixAndName: {
|
|
21500
|
+
$let: {
|
|
21501
|
+
vars: {
|
|
21502
|
+
matched: {
|
|
21503
|
+
$arrayElemAt: [
|
|
21504
|
+
{
|
|
21505
|
+
$filter: {
|
|
21506
|
+
input: "$passKeys_lookup",
|
|
21507
|
+
as: "lookup",
|
|
21508
|
+
cond: { $eq: ["$$lookup._id", "$$original.keyId"] }
|
|
21509
|
+
}
|
|
21510
|
+
},
|
|
21511
|
+
0
|
|
21512
|
+
]
|
|
21513
|
+
}
|
|
21514
|
+
},
|
|
21515
|
+
in: "$$matched.prefixAndName"
|
|
21516
|
+
}
|
|
21517
|
+
}
|
|
21518
|
+
}
|
|
21519
|
+
}
|
|
21520
|
+
}
|
|
21521
|
+
}
|
|
21522
|
+
},
|
|
21523
|
+
// 5. Cleanup temporary arrays
|
|
21524
|
+
{
|
|
21525
|
+
$project: {
|
|
21526
|
+
visitorPass_lookup: 0,
|
|
21527
|
+
passKeys_lookup: 0
|
|
21356
21528
|
}
|
|
21357
21529
|
},
|
|
21358
21530
|
{
|
|
@@ -21549,6 +21721,7 @@ function useVisitorTransactionRepo() {
|
|
|
21549
21721
|
}
|
|
21550
21722
|
try {
|
|
21551
21723
|
const updateFields = {};
|
|
21724
|
+
const pushFields = {};
|
|
21552
21725
|
const arrayFilters = [];
|
|
21553
21726
|
Object.keys(value).forEach((key) => {
|
|
21554
21727
|
if (key !== "visitorPass" && key !== "passKeys") {
|
|
@@ -21558,34 +21731,63 @@ function useVisitorTransactionRepo() {
|
|
|
21558
21731
|
});
|
|
21559
21732
|
if (Array.isArray(value.visitorPass)) {
|
|
21560
21733
|
value.visitorPass.forEach((item, index) => {
|
|
21561
|
-
|
|
21562
|
-
|
|
21563
|
-
|
|
21564
|
-
|
|
21565
|
-
|
|
21566
|
-
updateFields[`visitorPass.$[${elementKey}].${itemKey}`] = itemValue;
|
|
21734
|
+
if (item.add === true) {
|
|
21735
|
+
const { add: add2, ...cleanItem } = item;
|
|
21736
|
+
cleanItem.keyId = convertObjectIdUtilNonAsync(cleanItem.keyId, "Pass Id");
|
|
21737
|
+
if (!pushFields["visitorPass"]) {
|
|
21738
|
+
pushFields["visitorPass"] = { $each: [] };
|
|
21567
21739
|
}
|
|
21568
|
-
|
|
21569
|
-
|
|
21740
|
+
pushFields["visitorPass"].$each.push(cleanItem);
|
|
21741
|
+
} else {
|
|
21742
|
+
const elementKey = `vElem${index}`;
|
|
21743
|
+
Object.keys(item).forEach((itemKey) => {
|
|
21744
|
+
if (itemKey !== "keyId") {
|
|
21745
|
+
const typedItemKey = itemKey;
|
|
21746
|
+
let itemValue = item[typedItemKey];
|
|
21747
|
+
updateFields[`visitorPass.$[${elementKey}].${itemKey}`] = itemValue;
|
|
21748
|
+
}
|
|
21749
|
+
});
|
|
21750
|
+
arrayFilters.push({ [`${elementKey}.keyId`]: new ObjectId41(item.keyId) });
|
|
21751
|
+
}
|
|
21570
21752
|
});
|
|
21571
21753
|
}
|
|
21572
21754
|
if (Array.isArray(value.passKeys)) {
|
|
21573
21755
|
value.passKeys.forEach((item, index) => {
|
|
21574
|
-
|
|
21575
|
-
|
|
21576
|
-
|
|
21577
|
-
|
|
21578
|
-
|
|
21579
|
-
updateFields[`passKeys.$[${elementKey}].${itemKey}`] = itemValue;
|
|
21756
|
+
if (item.add === true) {
|
|
21757
|
+
const { add: add2, ...cleanItem } = item;
|
|
21758
|
+
cleanItem.keyId = convertObjectIdUtilNonAsync(cleanItem.keyId, "Key Id");
|
|
21759
|
+
if (!pushFields["passKeys"]) {
|
|
21760
|
+
pushFields["passKeys"] = { $each: [] };
|
|
21580
21761
|
}
|
|
21581
|
-
|
|
21582
|
-
|
|
21762
|
+
pushFields["passKeys"].$each.push(cleanItem);
|
|
21763
|
+
} else {
|
|
21764
|
+
const elementKey = `pElem${index}`;
|
|
21765
|
+
Object.keys(item).forEach((itemKey) => {
|
|
21766
|
+
if (itemKey !== "keyId") {
|
|
21767
|
+
const typedItemKey = itemKey;
|
|
21768
|
+
let itemValue = item[typedItemKey];
|
|
21769
|
+
updateFields[`passKeys.$[${elementKey}].${itemKey}`] = itemValue;
|
|
21770
|
+
}
|
|
21771
|
+
});
|
|
21772
|
+
arrayFilters.push({ [`${elementKey}.keyId`]: new ObjectId41(item.keyId) });
|
|
21773
|
+
}
|
|
21583
21774
|
});
|
|
21584
21775
|
}
|
|
21776
|
+
const updatePayload = {};
|
|
21777
|
+
if (Object.keys(updateFields).length > 0) {
|
|
21778
|
+
updatePayload.$set = updateFields;
|
|
21779
|
+
}
|
|
21780
|
+
if (Object.keys(pushFields).length > 0) {
|
|
21781
|
+
updatePayload.$push = pushFields;
|
|
21782
|
+
}
|
|
21585
21783
|
const result = await collection.updateOne(
|
|
21586
21784
|
{ _id: new ObjectId41(_id) },
|
|
21587
|
-
|
|
21588
|
-
{
|
|
21785
|
+
updatePayload,
|
|
21786
|
+
{
|
|
21787
|
+
...arrayFilters.length > 0 && { arrayFilters },
|
|
21788
|
+
// Only pass if not empty
|
|
21789
|
+
session
|
|
21790
|
+
}
|
|
21589
21791
|
);
|
|
21590
21792
|
return result;
|
|
21591
21793
|
} catch (error) {
|
|
@@ -33386,12 +33588,28 @@ var KeyRepo = class {
|
|
|
33386
33588
|
return Promise.reject("Server internal error.");
|
|
33387
33589
|
}
|
|
33388
33590
|
}
|
|
33389
|
-
static async updateKeyById(keyId, key, site, session, isChild, visitorId) {
|
|
33591
|
+
static async updateKeyById(keyId, key, site, session, isChild, visitorId, isDifferentStatus, isPassKeyVisitorAdd) {
|
|
33390
33592
|
keyId = await convertObjectIdUtil2(keyId, "keyId");
|
|
33391
33593
|
if (site)
|
|
33392
33594
|
site = await convertObjectIdUtil2(site, "Site");
|
|
33393
|
-
if (visitorId)
|
|
33394
|
-
visitorId = await convertObjectIdUtil2(visitorId, "
|
|
33595
|
+
if (visitorId) {
|
|
33596
|
+
visitorId = await convertObjectIdUtil2(visitorId, "Visitor Id");
|
|
33597
|
+
if (!isPassKeyVisitorAdd) {
|
|
33598
|
+
const findOptions = { sort: { _id: -1 } };
|
|
33599
|
+
const latestHistory = await this.collectionDynamic("keys-histories").findOne(
|
|
33600
|
+
{ passOrKeyId: keyId },
|
|
33601
|
+
findOptions
|
|
33602
|
+
);
|
|
33603
|
+
console.log("visitorId", visitorId.toString());
|
|
33604
|
+
console.log("latestHistory.visitorId", latestHistory?.visitorId.toString());
|
|
33605
|
+
if (latestHistory?.visitorId && latestHistory.visitorId?.toString() !== visitorId.toString()) {
|
|
33606
|
+
console.log("Not updating keyId", keyId);
|
|
33607
|
+
return;
|
|
33608
|
+
} else {
|
|
33609
|
+
console.log("updating keyId", keyId);
|
|
33610
|
+
}
|
|
33611
|
+
}
|
|
33612
|
+
}
|
|
33395
33613
|
if (key.updatedBy)
|
|
33396
33614
|
key.updatedBy = await convertObjectIdUtil2(key.updatedBy, "Updated By");
|
|
33397
33615
|
if (!key.status)
|
|
@@ -33399,9 +33617,14 @@ var KeyRepo = class {
|
|
|
33399
33617
|
try {
|
|
33400
33618
|
key.updatedAt = /* @__PURE__ */ new Date();
|
|
33401
33619
|
const query = { _id: keyId, ...site && { site } };
|
|
33402
|
-
let find = query;
|
|
33403
|
-
if (isChild)
|
|
33620
|
+
let find = { ...query };
|
|
33621
|
+
if (isChild) {
|
|
33404
33622
|
find = { parentId: keyId, site };
|
|
33623
|
+
} else {
|
|
33624
|
+
if (isDifferentStatus && typeof key?.status == "string") {
|
|
33625
|
+
find.status = { $ne: key.status };
|
|
33626
|
+
}
|
|
33627
|
+
}
|
|
33405
33628
|
const result = await this.collection().updateMany(
|
|
33406
33629
|
find,
|
|
33407
33630
|
{ $set: key },
|
|
@@ -33427,7 +33650,11 @@ var KeyRepo = class {
|
|
|
33427
33650
|
session
|
|
33428
33651
|
});
|
|
33429
33652
|
} else {
|
|
33430
|
-
|
|
33653
|
+
if (visitorId) {
|
|
33654
|
+
console.log(`visitorId: ${visitorId} keyId: ${keyId} Not Updated`);
|
|
33655
|
+
} else {
|
|
33656
|
+
throw new Error("Failed Updating Keys");
|
|
33657
|
+
}
|
|
33431
33658
|
}
|
|
33432
33659
|
return result;
|
|
33433
33660
|
} catch (error) {
|
|
@@ -33792,40 +34019,6 @@ function useVisitorTransactionService() {
|
|
|
33792
34019
|
}
|
|
33793
34020
|
return normalized;
|
|
33794
34021
|
}
|
|
33795
|
-
async function syncTransactionKeys({
|
|
33796
|
-
current,
|
|
33797
|
-
incoming,
|
|
33798
|
-
site,
|
|
33799
|
-
session
|
|
33800
|
-
}) {
|
|
33801
|
-
const currentIds = current.map((item) => item.keyId.toString());
|
|
33802
|
-
const incomingIds = incoming.map((item) => item.keyId.toString());
|
|
33803
|
-
const currentSet = new Set(currentIds);
|
|
33804
|
-
const incomingSet = new Set(incomingIds);
|
|
33805
|
-
const removedIds = currentIds.filter((id) => !incomingSet.has(id));
|
|
33806
|
-
const addedIds = incomingIds.filter((id) => !currentSet.has(id));
|
|
33807
|
-
for (const keyId of removedIds) {
|
|
33808
|
-
const existingKey = await KeyRepo.getById(keyId);
|
|
33809
|
-
if (!existingKey)
|
|
33810
|
-
continue;
|
|
33811
|
-
if (existingKey.status === "In Use" /* IN_USE */) {
|
|
33812
|
-
await KeyRepo.updateKeyById(
|
|
33813
|
-
keyId,
|
|
33814
|
-
{ status: "Available" /* AVAILABLE */ },
|
|
33815
|
-
site,
|
|
33816
|
-
session
|
|
33817
|
-
);
|
|
33818
|
-
}
|
|
33819
|
-
}
|
|
33820
|
-
for (const keyId of addedIds) {
|
|
33821
|
-
await KeyRepo.updateKeyById(
|
|
33822
|
-
keyId,
|
|
33823
|
-
{ status: "In Use" /* IN_USE */ },
|
|
33824
|
-
site,
|
|
33825
|
-
session
|
|
33826
|
-
);
|
|
33827
|
-
}
|
|
33828
|
-
}
|
|
33829
34022
|
async function add(value) {
|
|
33830
34023
|
const session = useAtlas50.getClient()?.startSession();
|
|
33831
34024
|
const allowedPersonTypes = [
|
|
@@ -33961,7 +34154,9 @@ function useVisitorTransactionService() {
|
|
|
33961
34154
|
value.site,
|
|
33962
34155
|
session,
|
|
33963
34156
|
void 0,
|
|
33964
|
-
visitorId
|
|
34157
|
+
visitorId,
|
|
34158
|
+
void 0,
|
|
34159
|
+
true
|
|
33965
34160
|
);
|
|
33966
34161
|
}
|
|
33967
34162
|
for (const item of preparedPassKeys) {
|
|
@@ -33973,7 +34168,11 @@ function useVisitorTransactionService() {
|
|
|
33973
34168
|
visitorId
|
|
33974
34169
|
},
|
|
33975
34170
|
value.site,
|
|
33976
|
-
session
|
|
34171
|
+
session,
|
|
34172
|
+
void 0,
|
|
34173
|
+
visitorId,
|
|
34174
|
+
void 0,
|
|
34175
|
+
true
|
|
33977
34176
|
);
|
|
33978
34177
|
}
|
|
33979
34178
|
})
|
|
@@ -34004,43 +34203,49 @@ function useVisitorTransactionService() {
|
|
|
34004
34203
|
throw new BadRequestError100("This plate number is blocklisted");
|
|
34005
34204
|
}
|
|
34006
34205
|
await KeyRepo.checkPassKeyAvailability(value.visitorPass, value.passKeys);
|
|
34206
|
+
if (Array.isArray(value.visitorPass)) {
|
|
34207
|
+
for (const item of value.visitorPass) {
|
|
34208
|
+
item.receivedDate = /* @__PURE__ */ new Date();
|
|
34209
|
+
item.status = "Not Returned" /* NOT_RETURNED */;
|
|
34210
|
+
item.lastUpdate = null;
|
|
34211
|
+
item.remarks = "";
|
|
34212
|
+
}
|
|
34213
|
+
}
|
|
34214
|
+
if (Array.isArray(value.passKeys)) {
|
|
34215
|
+
for (const item of value.passKeys) {
|
|
34216
|
+
item.receivedDate = /* @__PURE__ */ new Date();
|
|
34217
|
+
item.status = "Not Returned" /* NOT_RETURNED */;
|
|
34218
|
+
item.lastUpdate = null;
|
|
34219
|
+
item.remarks = "";
|
|
34220
|
+
}
|
|
34221
|
+
}
|
|
34007
34222
|
const result = await _add(value, session);
|
|
34008
34223
|
if (Array.isArray(value.visitorPass)) {
|
|
34009
34224
|
for (const item of value.visitorPass) {
|
|
34010
34225
|
await KeyRepo.updateKeyById(
|
|
34011
34226
|
item.keyId,
|
|
34012
|
-
{
|
|
34013
|
-
status: "In Use" /* IN_USE */,
|
|
34014
|
-
updatedBy: value.createdBy
|
|
34015
|
-
},
|
|
34227
|
+
{ status: "In Use" /* IN_USE */, updatedBy: value.createdBy },
|
|
34016
34228
|
value.site,
|
|
34017
34229
|
session,
|
|
34018
34230
|
void 0,
|
|
34019
|
-
result
|
|
34231
|
+
result,
|
|
34232
|
+
void 0,
|
|
34233
|
+
true
|
|
34020
34234
|
);
|
|
34021
|
-
item.receivedDate = /* @__PURE__ */ new Date();
|
|
34022
|
-
item.status = "Not Returned" /* NOT_RETURNED */;
|
|
34023
|
-
item.lastUpdate = null;
|
|
34024
|
-
item.remarks = "";
|
|
34025
34235
|
}
|
|
34026
34236
|
}
|
|
34027
34237
|
if (Array.isArray(value.passKeys)) {
|
|
34028
34238
|
for (const item of value.passKeys) {
|
|
34029
34239
|
await KeyRepo.updateKeyById(
|
|
34030
34240
|
item.keyId,
|
|
34031
|
-
{
|
|
34032
|
-
status: "In Use" /* IN_USE */,
|
|
34033
|
-
updatedBy: value.createdBy
|
|
34034
|
-
},
|
|
34241
|
+
{ status: "In Use" /* IN_USE */, updatedBy: value.createdBy },
|
|
34035
34242
|
value.site,
|
|
34036
34243
|
session,
|
|
34037
34244
|
void 0,
|
|
34038
|
-
result
|
|
34245
|
+
result,
|
|
34246
|
+
void 0,
|
|
34247
|
+
true
|
|
34039
34248
|
);
|
|
34040
|
-
item.receivedDate = /* @__PURE__ */ new Date();
|
|
34041
|
-
item.status = "Not Returned" /* NOT_RETURNED */;
|
|
34042
|
-
item.lastUpdate = null;
|
|
34043
|
-
item.remarks = "";
|
|
34044
34249
|
}
|
|
34045
34250
|
}
|
|
34046
34251
|
await session?.commitTransaction();
|
|
@@ -34137,54 +34342,98 @@ function useVisitorTransactionService() {
|
|
|
34137
34342
|
}
|
|
34138
34343
|
if (Array.isArray(value.visitorPass)) {
|
|
34139
34344
|
for (const item of value.visitorPass) {
|
|
34140
|
-
|
|
34141
|
-
|
|
34142
|
-
|
|
34143
|
-
|
|
34144
|
-
|
|
34145
|
-
|
|
34146
|
-
|
|
34345
|
+
if (item.add) {
|
|
34346
|
+
await KeyRepo.updateKeyById(
|
|
34347
|
+
item.keyId,
|
|
34348
|
+
{
|
|
34349
|
+
status: "In Use" /* IN_USE */,
|
|
34350
|
+
updatedBy: value.updatedBy
|
|
34351
|
+
},
|
|
34352
|
+
value.site,
|
|
34353
|
+
session,
|
|
34354
|
+
void 0,
|
|
34355
|
+
id
|
|
34356
|
+
);
|
|
34357
|
+
item.receivedDate = /* @__PURE__ */ new Date();
|
|
34358
|
+
item.status = "Not Returned" /* NOT_RETURNED */;
|
|
34359
|
+
item.lastUpdate = null;
|
|
34360
|
+
item.remarks = "";
|
|
34147
34361
|
} else {
|
|
34148
|
-
|
|
34362
|
+
let status = "Invalid";
|
|
34363
|
+
if (item?.status == "Returned" /* RETURNED */) {
|
|
34364
|
+
status = "Available" /* AVAILABLE */;
|
|
34365
|
+
} else if (item?.status == "Removed" /* REMOVED */) {
|
|
34366
|
+
status = "Available" /* AVAILABLE */;
|
|
34367
|
+
} else if (item?.status == "Not Returned" /* NOT_RETURNED */) {
|
|
34368
|
+
status = "In Use" /* IN_USE */;
|
|
34369
|
+
} else if (item?.status && VALID_STATUSES.has(item.status)) {
|
|
34370
|
+
status = item.status;
|
|
34371
|
+
} else {
|
|
34372
|
+
throw new Error("Invalid Visitor Pass Status");
|
|
34373
|
+
}
|
|
34374
|
+
await KeyRepo.updateKeyById(
|
|
34375
|
+
item.keyId,
|
|
34376
|
+
{
|
|
34377
|
+
status,
|
|
34378
|
+
updatedBy: value.updatedBy
|
|
34379
|
+
},
|
|
34380
|
+
value.site,
|
|
34381
|
+
session,
|
|
34382
|
+
void 0,
|
|
34383
|
+
id,
|
|
34384
|
+
true
|
|
34385
|
+
);
|
|
34386
|
+
delete item.receivedDate;
|
|
34387
|
+
item.lastUpdate = /* @__PURE__ */ new Date();
|
|
34149
34388
|
}
|
|
34150
|
-
await KeyRepo.updateKeyById(
|
|
34151
|
-
item.keyId,
|
|
34152
|
-
{
|
|
34153
|
-
status,
|
|
34154
|
-
updatedBy: value.updatedBy
|
|
34155
|
-
},
|
|
34156
|
-
value.site,
|
|
34157
|
-
session,
|
|
34158
|
-
void 0,
|
|
34159
|
-
id
|
|
34160
|
-
);
|
|
34161
|
-
item.lastUpdate = /* @__PURE__ */ new Date();
|
|
34162
34389
|
}
|
|
34163
34390
|
}
|
|
34164
34391
|
if (Array.isArray(value.passKeys)) {
|
|
34165
34392
|
for (const item of value.passKeys) {
|
|
34166
|
-
|
|
34167
|
-
|
|
34168
|
-
|
|
34169
|
-
|
|
34170
|
-
|
|
34171
|
-
|
|
34172
|
-
|
|
34393
|
+
if (item.add) {
|
|
34394
|
+
await KeyRepo.updateKeyById(
|
|
34395
|
+
item.keyId,
|
|
34396
|
+
{
|
|
34397
|
+
status: "In Use" /* IN_USE */,
|
|
34398
|
+
updatedBy: value.updatedBy
|
|
34399
|
+
},
|
|
34400
|
+
value.site,
|
|
34401
|
+
session,
|
|
34402
|
+
void 0,
|
|
34403
|
+
id
|
|
34404
|
+
);
|
|
34405
|
+
item.receivedDate = /* @__PURE__ */ new Date();
|
|
34406
|
+
item.status = "Not Returned" /* NOT_RETURNED */;
|
|
34407
|
+
item.lastUpdate = null;
|
|
34408
|
+
item.remarks = "";
|
|
34173
34409
|
} else {
|
|
34174
|
-
|
|
34410
|
+
let status = "Invalid";
|
|
34411
|
+
if (item?.status == "Returned" /* RETURNED */) {
|
|
34412
|
+
status = "Available" /* AVAILABLE */;
|
|
34413
|
+
} else if (item?.status == "Removed" /* REMOVED */) {
|
|
34414
|
+
status = "Available" /* AVAILABLE */;
|
|
34415
|
+
} else if (item?.status == "Not Returned" /* NOT_RETURNED */) {
|
|
34416
|
+
status = "In Use" /* IN_USE */;
|
|
34417
|
+
} else if (item?.status && VALID_STATUSES.has(item.status)) {
|
|
34418
|
+
status = item.status;
|
|
34419
|
+
} else {
|
|
34420
|
+
throw new Error("Invalid Visitor Pass Status");
|
|
34421
|
+
}
|
|
34422
|
+
await KeyRepo.updateKeyById(
|
|
34423
|
+
item.keyId,
|
|
34424
|
+
{
|
|
34425
|
+
status,
|
|
34426
|
+
updatedBy: value.updatedBy
|
|
34427
|
+
},
|
|
34428
|
+
value.site,
|
|
34429
|
+
session,
|
|
34430
|
+
void 0,
|
|
34431
|
+
id,
|
|
34432
|
+
true
|
|
34433
|
+
);
|
|
34434
|
+
delete item.receivedDate;
|
|
34435
|
+
item.lastUpdate = /* @__PURE__ */ new Date();
|
|
34175
34436
|
}
|
|
34176
|
-
await KeyRepo.updateKeyById(
|
|
34177
|
-
item.keyId,
|
|
34178
|
-
{
|
|
34179
|
-
status,
|
|
34180
|
-
updatedBy: value.updatedBy
|
|
34181
|
-
},
|
|
34182
|
-
value.site,
|
|
34183
|
-
session,
|
|
34184
|
-
void 0,
|
|
34185
|
-
id
|
|
34186
|
-
);
|
|
34187
|
-
item.lastUpdate = /* @__PURE__ */ new Date();
|
|
34188
34437
|
}
|
|
34189
34438
|
}
|
|
34190
34439
|
await _updateVisitorTansactionById(id, value, session);
|
|
@@ -34351,63 +34600,12 @@ function useVisitorTransactionService() {
|
|
|
34351
34600
|
session?.endSession();
|
|
34352
34601
|
}
|
|
34353
34602
|
}
|
|
34354
|
-
async function changeVisitorTransactionKeysById(id, visitorPass, passKeys) {
|
|
34355
|
-
const session = useAtlas50.getClient()?.startSession();
|
|
34356
|
-
if (!session) {
|
|
34357
|
-
throw new Error(
|
|
34358
|
-
"Unable to start session for visitor transaction service."
|
|
34359
|
-
);
|
|
34360
|
-
}
|
|
34361
|
-
try {
|
|
34362
|
-
session.startTransaction();
|
|
34363
|
-
const visitorTransaction = await _getVisitorTransactionById(id);
|
|
34364
|
-
if (!visitorTransaction) {
|
|
34365
|
-
throw new Error("Visitor transaction not found.");
|
|
34366
|
-
}
|
|
34367
|
-
const updatePayload = {};
|
|
34368
|
-
if (visitorPass !== void 0) {
|
|
34369
|
-
const currentVisitorPass = normalizeKeyRefs(
|
|
34370
|
-
visitorTransaction.visitorPass
|
|
34371
|
-
);
|
|
34372
|
-
const incomingVisitorPass = normalizeKeyRefs(visitorPass);
|
|
34373
|
-
await syncTransactionKeys({
|
|
34374
|
-
current: currentVisitorPass,
|
|
34375
|
-
incoming: incomingVisitorPass,
|
|
34376
|
-
site: visitorTransaction.site,
|
|
34377
|
-
session
|
|
34378
|
-
});
|
|
34379
|
-
updatePayload.visitorPass = incomingVisitorPass;
|
|
34380
|
-
}
|
|
34381
|
-
if (passKeys !== void 0) {
|
|
34382
|
-
const currentPassKeys = normalizeKeyRefs(visitorTransaction.passKeys);
|
|
34383
|
-
const incomingPassKeys = normalizeKeyRefs(passKeys);
|
|
34384
|
-
await syncTransactionKeys({
|
|
34385
|
-
current: currentPassKeys,
|
|
34386
|
-
incoming: incomingPassKeys,
|
|
34387
|
-
site: visitorTransaction.site,
|
|
34388
|
-
session
|
|
34389
|
-
});
|
|
34390
|
-
updatePayload.passKeys = incomingPassKeys;
|
|
34391
|
-
}
|
|
34392
|
-
if (Object.keys(updatePayload).length > 0) {
|
|
34393
|
-
await _updateVisitorTansactionById(id, updatePayload, session);
|
|
34394
|
-
}
|
|
34395
|
-
await session.commitTransaction();
|
|
34396
|
-
return "Successfully changed visitor transaction keys.";
|
|
34397
|
-
} catch (error) {
|
|
34398
|
-
await session.abortTransaction();
|
|
34399
|
-
logger80.error("Error in visitor transaction change keys by id:", error);
|
|
34400
|
-
throw error;
|
|
34401
|
-
} finally {
|
|
34402
|
-
session.endSession();
|
|
34403
|
-
}
|
|
34404
|
-
}
|
|
34405
34603
|
return {
|
|
34406
34604
|
add,
|
|
34407
34605
|
updateVisitorTransactionById,
|
|
34408
34606
|
processTransactionDahuaStatus,
|
|
34409
|
-
inviteVisitor
|
|
34410
|
-
changeVisitorTransactionKeysById
|
|
34607
|
+
inviteVisitor
|
|
34608
|
+
// changeVisitorTransactionKeysById,
|
|
34411
34609
|
};
|
|
34412
34610
|
}
|
|
34413
34611
|
|
|
@@ -34418,8 +34616,8 @@ function useVisitorTransactionController() {
|
|
|
34418
34616
|
const {
|
|
34419
34617
|
add: _add,
|
|
34420
34618
|
updateVisitorTransactionById: _updateVisitorTransactionById,
|
|
34421
|
-
inviteVisitor: _inviteVisitor
|
|
34422
|
-
changeVisitorTransactionKeysById: _changeVisitorTransactionKeysById
|
|
34619
|
+
inviteVisitor: _inviteVisitor
|
|
34620
|
+
// changeVisitorTransactionKeysById: _changeVisitorTransactionKeysById,
|
|
34423
34621
|
} = useVisitorTransactionService();
|
|
34424
34622
|
const {
|
|
34425
34623
|
getAll: _getAll,
|
|
@@ -34576,7 +34774,12 @@ function useVisitorTransactionController() {
|
|
|
34576
34774
|
return;
|
|
34577
34775
|
} catch (error2) {
|
|
34578
34776
|
logger81.log({ level: "error", message: error2.message });
|
|
34579
|
-
|
|
34777
|
+
console.log("error", error2);
|
|
34778
|
+
if (error2?.message) {
|
|
34779
|
+
next(new BadRequestError101(error2?.message));
|
|
34780
|
+
} else {
|
|
34781
|
+
next(error2);
|
|
34782
|
+
}
|
|
34580
34783
|
return;
|
|
34581
34784
|
}
|
|
34582
34785
|
}
|
|
@@ -34669,61 +34872,14 @@ function useVisitorTransactionController() {
|
|
|
34669
34872
|
}
|
|
34670
34873
|
}
|
|
34671
34874
|
}
|
|
34672
|
-
async function changeVisitorTransactionKeysById(req, res, next) {
|
|
34673
|
-
const idValidation = Joi57.string().hex().length(24).required();
|
|
34674
|
-
const bodyValidation = Joi57.object({
|
|
34675
|
-
visitorPass: Joi57.array().items(
|
|
34676
|
-
Joi57.object({
|
|
34677
|
-
keyId: Joi57.string().hex().length(24).required()
|
|
34678
|
-
})
|
|
34679
|
-
).optional(),
|
|
34680
|
-
passKeys: Joi57.array().items(
|
|
34681
|
-
Joi57.object({
|
|
34682
|
-
keyId: Joi57.string().hex().length(24).required()
|
|
34683
|
-
})
|
|
34684
|
-
).optional()
|
|
34685
|
-
}).or("visitorPass", "passKeys");
|
|
34686
|
-
const _id = req.params.id;
|
|
34687
|
-
const { error: idError } = idValidation.validate(_id);
|
|
34688
|
-
if (idError) {
|
|
34689
|
-
logger81.log({ level: "error", message: idError.message });
|
|
34690
|
-
next(new BadRequestError101(idError.message));
|
|
34691
|
-
return;
|
|
34692
|
-
}
|
|
34693
|
-
const { error, value } = bodyValidation.validate(req.body, {
|
|
34694
|
-
abortEarly: false
|
|
34695
|
-
});
|
|
34696
|
-
if (error) {
|
|
34697
|
-
const message = error.details.map((d) => d.message).join(", ");
|
|
34698
|
-
logger81.log({ level: "error", message });
|
|
34699
|
-
next(new BadRequestError101(message));
|
|
34700
|
-
return;
|
|
34701
|
-
}
|
|
34702
|
-
try {
|
|
34703
|
-
const { visitorPass, passKeys } = value;
|
|
34704
|
-
const result = await _changeVisitorTransactionKeysById(
|
|
34705
|
-
_id,
|
|
34706
|
-
visitorPass,
|
|
34707
|
-
passKeys
|
|
34708
|
-
);
|
|
34709
|
-
res.status(200).json({
|
|
34710
|
-
message: result || "Successfully changed visitor transaction keys."
|
|
34711
|
-
});
|
|
34712
|
-
return;
|
|
34713
|
-
} catch (error2) {
|
|
34714
|
-
logger81.log({ level: "error", message: error2.message });
|
|
34715
|
-
next(error2);
|
|
34716
|
-
return;
|
|
34717
|
-
}
|
|
34718
|
-
}
|
|
34719
34875
|
return {
|
|
34720
34876
|
add,
|
|
34721
34877
|
getAll,
|
|
34722
34878
|
updateVisitorTansactionById,
|
|
34723
34879
|
deleteVisitorTransaction,
|
|
34724
34880
|
inviteVisitor,
|
|
34725
|
-
getVisitorTransactionById
|
|
34726
|
-
changeVisitorTransactionKeysById
|
|
34881
|
+
getVisitorTransactionById
|
|
34882
|
+
// changeVisitorTransactionKeysById,
|
|
34727
34883
|
};
|
|
34728
34884
|
}
|
|
34729
34885
|
|
|
@@ -69924,6 +70080,7 @@ export {
|
|
|
69924
70080
|
useManpowerSitesSrvc,
|
|
69925
70081
|
useMemberController,
|
|
69926
70082
|
useMemberRepo,
|
|
70083
|
+
useMemberService,
|
|
69927
70084
|
useNewDashboardController,
|
|
69928
70085
|
useNewDashboardRepo,
|
|
69929
70086
|
useNfcPatrolLogController,
|