@7365admin1/core 3.23.0 → 3.25.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 +15 -4
- package/dist/index.js +378 -121
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +377 -121
- package/dist/index.mjs.map +1 -1
- package/docs/hid-amico-diagram.md +2 -2
- package/docs/hid-amico-integration.md +33 -8
- package/docs/hid-amico-postman-api.md +4 -2
- package/docs/hid-amico-ui-design-scope.md +4 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6096,6 +6096,7 @@ __export(src_exports, {
|
|
|
6096
6096
|
schemaHidAmicoIdentity: () => schemaHidAmicoIdentity,
|
|
6097
6097
|
schemaHidAmicoIdentityIdParams: () => schemaHidAmicoIdentityIdParams,
|
|
6098
6098
|
schemaHidAmicoIdentityQuery: () => schemaHidAmicoIdentityQuery,
|
|
6099
|
+
schemaHidAmicoIntercomCall: () => schemaHidAmicoIntercomCall,
|
|
6099
6100
|
schemaHidAmicoLogQuery: () => schemaHidAmicoLogQuery,
|
|
6100
6101
|
schemaHidAmicoNotificationParams: () => schemaHidAmicoNotificationParams,
|
|
6101
6102
|
schemaHidAmicoObjectOperation: () => schemaHidAmicoObjectOperation,
|
|
@@ -9225,6 +9226,7 @@ function MMember(value) {
|
|
|
9225
9226
|
const schema2 = import_joi7.default.object({
|
|
9226
9227
|
_id: import_joi7.default.string().hex().optional().allow("", null),
|
|
9227
9228
|
name: import_joi7.default.string().required(),
|
|
9229
|
+
email: import_joi7.default.string().email().optional().allow("", null),
|
|
9228
9230
|
user: import_joi7.default.string().hex().required(),
|
|
9229
9231
|
type: import_joi7.default.string().required(),
|
|
9230
9232
|
role: import_joi7.default.string().hex().optional().allow("", null),
|
|
@@ -9233,6 +9235,7 @@ function MMember(value) {
|
|
|
9233
9235
|
siteId: import_joi7.default.string().hex().optional().allow("", null),
|
|
9234
9236
|
siteName: import_joi7.default.string().optional().allow("", null),
|
|
9235
9237
|
status: import_joi7.default.string().optional().allow("", null),
|
|
9238
|
+
dateInvited: import_joi7.default.string().optional().allow("", null),
|
|
9236
9239
|
onboardingRequired: import_joi7.default.boolean().optional(),
|
|
9237
9240
|
onboardingCompleted: import_joi7.default.boolean().optional(),
|
|
9238
9241
|
onboardingCompletedAt: import_joi7.default.string().optional().allow("", null),
|
|
@@ -9275,6 +9278,7 @@ function MMember(value) {
|
|
|
9275
9278
|
return {
|
|
9276
9279
|
_id: value._id,
|
|
9277
9280
|
name: value.name,
|
|
9281
|
+
email: value.email ?? "",
|
|
9278
9282
|
user: value.user ?? "",
|
|
9279
9283
|
type: value.type,
|
|
9280
9284
|
role: value.role ?? "",
|
|
@@ -9283,6 +9287,7 @@ function MMember(value) {
|
|
|
9283
9287
|
siteId: value.siteId ?? "",
|
|
9284
9288
|
siteName: value.siteName ?? "",
|
|
9285
9289
|
status: value.status || "active",
|
|
9290
|
+
dateInvited: value.dateInvited ?? value.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
9286
9291
|
onboardingRequired: value.onboardingRequired ?? false,
|
|
9287
9292
|
onboardingCompleted: value.onboardingCompleted ?? !value.onboardingRequired,
|
|
9288
9293
|
onboardingCompletedAt: value.onboardingCompletedAt ?? "",
|
|
@@ -9579,7 +9584,8 @@ function useMemberRepo() {
|
|
|
9579
9584
|
page,
|
|
9580
9585
|
limit,
|
|
9581
9586
|
type,
|
|
9582
|
-
status
|
|
9587
|
+
status,
|
|
9588
|
+
projectionVersion: 2
|
|
9583
9589
|
};
|
|
9584
9590
|
if (org) {
|
|
9585
9591
|
try {
|
|
@@ -9630,15 +9636,27 @@ function useMemberRepo() {
|
|
|
9630
9636
|
}
|
|
9631
9637
|
},
|
|
9632
9638
|
{ $unwind: { path: "$roles", preserveNullAndEmptyArrays: true } },
|
|
9639
|
+
{
|
|
9640
|
+
$lookup: {
|
|
9641
|
+
from: "users",
|
|
9642
|
+
localField: "user",
|
|
9643
|
+
foreignField: "_id",
|
|
9644
|
+
as: "users",
|
|
9645
|
+
pipeline: [{ $project: { email: 1 } }]
|
|
9646
|
+
}
|
|
9647
|
+
},
|
|
9648
|
+
{ $unwind: { path: "$users", preserveNullAndEmptyArrays: true } },
|
|
9633
9649
|
{
|
|
9634
9650
|
$project: {
|
|
9635
9651
|
name: 1,
|
|
9652
|
+
email: { $ifNull: ["$email", "$users.email"] },
|
|
9636
9653
|
user: 1,
|
|
9637
9654
|
roleName: "$roles.name",
|
|
9638
9655
|
role: "$roles._id",
|
|
9639
9656
|
org: 1,
|
|
9640
9657
|
orgName: 1,
|
|
9641
9658
|
status: 1,
|
|
9659
|
+
dateInvited: { $ifNull: ["$dateInvited", "$createdAt"] },
|
|
9642
9660
|
siteId: 1,
|
|
9643
9661
|
siteName: 1,
|
|
9644
9662
|
type: 1
|
|
@@ -10360,6 +10378,7 @@ var MVerification = class {
|
|
|
10360
10378
|
}
|
|
10361
10379
|
}
|
|
10362
10380
|
this.metadata = { ...value.metadata };
|
|
10381
|
+
this.roleName = value.roleName;
|
|
10363
10382
|
this.status = value.status ?? "pending";
|
|
10364
10383
|
this.createdAt = value.createdAt ?? /* @__PURE__ */ new Date();
|
|
10365
10384
|
this.updatedAt = value.updatedAt ?? null;
|
|
@@ -10512,6 +10531,16 @@ function useVerificationRepo() {
|
|
|
10512
10531
|
{ $sort: sort },
|
|
10513
10532
|
{ $skip: page * limit },
|
|
10514
10533
|
{ $limit: limit },
|
|
10534
|
+
{
|
|
10535
|
+
$lookup: {
|
|
10536
|
+
from: "roles",
|
|
10537
|
+
localField: "metadata.role",
|
|
10538
|
+
foreignField: "_id",
|
|
10539
|
+
as: "roles",
|
|
10540
|
+
pipeline: [{ $project: { name: 1 } }]
|
|
10541
|
+
}
|
|
10542
|
+
},
|
|
10543
|
+
{ $unwind: { path: "$roles", preserveNullAndEmptyArrays: true } },
|
|
10515
10544
|
{
|
|
10516
10545
|
$project: {
|
|
10517
10546
|
_id: 1,
|
|
@@ -10519,6 +10548,7 @@ function useVerificationRepo() {
|
|
|
10519
10548
|
email: 1,
|
|
10520
10549
|
type: 1,
|
|
10521
10550
|
metadata: 1,
|
|
10551
|
+
roleName: "$roles.name",
|
|
10522
10552
|
status: 1
|
|
10523
10553
|
}
|
|
10524
10554
|
}
|
|
@@ -14418,8 +14448,10 @@ function useMemberService() {
|
|
|
14418
14448
|
orgName: org?.name || "",
|
|
14419
14449
|
user: _user?._id?.toString() || "",
|
|
14420
14450
|
name: _user?.name || "",
|
|
14451
|
+
email: invite.email,
|
|
14421
14452
|
role: invite.metadata?.role?.toString() || "",
|
|
14422
14453
|
type: invite.metadata?.app ?? "organization",
|
|
14454
|
+
dateInvited: invite.createdAt,
|
|
14423
14455
|
siteId: invite.metadata?.siteId?.toString() || "",
|
|
14424
14456
|
siteName: invite.metadata?.siteName || ""
|
|
14425
14457
|
},
|
|
@@ -14466,8 +14498,10 @@ function useMemberService() {
|
|
|
14466
14498
|
orgName: org.name || "",
|
|
14467
14499
|
user: user._id?.toString() || "",
|
|
14468
14500
|
name: user?.email,
|
|
14501
|
+
email: user.email,
|
|
14469
14502
|
role: roleId,
|
|
14470
14503
|
type: app,
|
|
14504
|
+
dateInvited: (/* @__PURE__ */ new Date()).toISOString(),
|
|
14471
14505
|
siteId: siteId ?? "",
|
|
14472
14506
|
siteName: siteName ?? "",
|
|
14473
14507
|
onboardingRequired,
|
|
@@ -22140,7 +22174,7 @@ function useVisitorTransactionRepo() {
|
|
|
22140
22174
|
session,
|
|
22141
22175
|
sort: { checkIn: -1 },
|
|
22142
22176
|
returnDocument: "after",
|
|
22143
|
-
projection: { _id: 1, site: 1 }
|
|
22177
|
+
projection: { _id: 1, site: 1, type: 1 }
|
|
22144
22178
|
}
|
|
22145
22179
|
);
|
|
22146
22180
|
return result;
|
|
@@ -23739,7 +23773,7 @@ function useDahuaService() {
|
|
|
23739
23773
|
try {
|
|
23740
23774
|
const result = await _checkOutBySiteAndPlate(site, plateNumber2);
|
|
23741
23775
|
console.log("checkOutBySiteAndPlate result", result);
|
|
23742
|
-
if (onDetected2 && result?.
|
|
23776
|
+
if (onDetected2 && result?.type != "resident" && result?.site) {
|
|
23743
23777
|
onDetected2({ reload: true, site: result?.site?.toString(), siteName: camera?.siteName, cameraDirection: camera?.direction, direction });
|
|
23744
23778
|
}
|
|
23745
23779
|
return result;
|
|
@@ -23813,7 +23847,7 @@ function useDahuaService() {
|
|
|
23813
23847
|
loggerDahua.info(`${camera?.siteName}-${camera?.direction}] Unregistered vehicle with plate ${plateNumber2} and transaction ID ${insert?._id}`);
|
|
23814
23848
|
}
|
|
23815
23849
|
}
|
|
23816
|
-
if (insert?.
|
|
23850
|
+
if (insert?.status == "unregistered" /* UNREGISTERED */ && insert?.site && onDetected2) {
|
|
23817
23851
|
onDetected2({ _id: insert?._id, site: insert?.site?.toString(), plateNumber: insert?.plateNumber, cameraDirection: camera?.direction, direction });
|
|
23818
23852
|
}
|
|
23819
23853
|
return insert;
|
|
@@ -24035,6 +24069,7 @@ function useDahuaService() {
|
|
|
24035
24069
|
);
|
|
24036
24070
|
}
|
|
24037
24071
|
async function getTrafficJunction(camera, signal, onDetected) {
|
|
24072
|
+
console.log(`getTrafficJunction camera object`, camera);
|
|
24038
24073
|
while (!signal.aborted) {
|
|
24039
24074
|
let bufferQueue = null;
|
|
24040
24075
|
let response = null;
|
|
@@ -27401,119 +27436,123 @@ function useVehicleService() {
|
|
|
27401
27436
|
if (!session) {
|
|
27402
27437
|
throw new Error("Unable to start session for vehicle service.");
|
|
27403
27438
|
}
|
|
27404
|
-
const vehicle = await _getVehicleById(_id);
|
|
27405
|
-
const plate = vehicle.plates.find((p) => p._id.toString() === _id);
|
|
27406
|
-
const _name = value.name ? value.name : vehicle.name;
|
|
27407
|
-
const _plateNumber = plate?.plateNumber;
|
|
27408
|
-
const _start = vehicle.start;
|
|
27409
|
-
const _end = vehicle.end;
|
|
27410
|
-
const _recNo = plate.recNo;
|
|
27411
|
-
const _type = value.type ? value.type : plate.type;
|
|
27412
|
-
if (value.peopleId) {
|
|
27413
|
-
value.peopleId = new import_mongodb49.ObjectId(value.peopleId);
|
|
27414
|
-
}
|
|
27415
|
-
const { name, plateNumber, start, end, recNo, type, unit, site, ...rest } = value;
|
|
27416
|
-
const startDahua = value.start ? formatDahuaDate(new Date(value.start)) : formatDahuaDate(new Date(_start));
|
|
27417
|
-
const endDahua = value.end ? formatDahuaDate(new Date(value.end)) : formatDahuaDate(new Date(_end));
|
|
27418
27439
|
try {
|
|
27419
27440
|
session.startTransaction();
|
|
27420
|
-
|
|
27421
|
-
|
|
27422
|
-
|
|
27423
|
-
|
|
27424
|
-
|
|
27425
|
-
|
|
27426
|
-
|
|
27427
|
-
|
|
27428
|
-
|
|
27429
|
-
|
|
27430
|
-
|
|
27431
|
-
|
|
27432
|
-
|
|
27433
|
-
|
|
27434
|
-
|
|
27435
|
-
|
|
27436
|
-
|
|
27437
|
-
|
|
27438
|
-
|
|
27439
|
-
|
|
27440
|
-
|
|
27441
|
-
|
|
27442
|
-
|
|
27443
|
-
|
|
27444
|
-
|
|
27445
|
-
|
|
27446
|
-
|
|
27447
|
-
|
|
27448
|
-
|
|
27449
|
-
|
|
27450
|
-
|
|
27451
|
-
|
|
27452
|
-
|
|
27453
|
-
);
|
|
27454
|
-
|
|
27455
|
-
|
|
27456
|
-
|
|
27457
|
-
|
|
27458
|
-
|
|
27459
|
-
|
|
27460
|
-
|
|
27461
|
-
|
|
27462
|
-
|
|
27463
|
-
|
|
27464
|
-
|
|
27465
|
-
|
|
27466
|
-
|
|
27467
|
-
|
|
27468
|
-
|
|
27469
|
-
};
|
|
27470
|
-
const dahuaResponse = await _addPlateNumber(dahuaPayload);
|
|
27471
|
-
if (dahuaResponse?.statusCode !== 200) {
|
|
27472
|
-
throw new import_node_server_utils78.BadRequestError(
|
|
27473
|
-
"Failed to update plate number to ANPR"
|
|
27474
|
-
);
|
|
27475
|
-
}
|
|
27476
|
-
const responseData = dahuaResponse?.data?.toString("utf-8") ?? "";
|
|
27477
|
-
value.recNo = responseData.split("=")[1]?.trim();
|
|
27478
|
-
const normalizedPlateNumber = Array.isArray(plateNumber) ? plateNumber[0] : plateNumber;
|
|
27479
|
-
if (value.peopleId && value.recNo) {
|
|
27480
|
-
await _pushVehicleById(
|
|
27481
|
-
value.peopleId,
|
|
27482
|
-
{
|
|
27483
|
-
plateNumber: normalizedPlateNumber,
|
|
27484
|
-
recNo: value.recNo
|
|
27485
|
-
},
|
|
27486
|
-
session
|
|
27487
|
-
);
|
|
27488
|
-
}
|
|
27489
|
-
} else {
|
|
27490
|
-
const dahuaPayload = {
|
|
27491
|
-
host,
|
|
27492
|
-
username,
|
|
27493
|
-
password,
|
|
27494
|
-
plateNumber: plateNumber ? plateNumber : _plateNumber,
|
|
27495
|
-
recno: _recNo,
|
|
27496
|
-
mode: _type === "blocklist" /* BLOCKLIST */ ? "TrafficBlackList" /* TRAFFIC_BLACKLIST */ : "TrafficRedList" /* TRAFFIC_REDLIST */,
|
|
27497
|
-
start: startDahua,
|
|
27498
|
-
end: endDahua,
|
|
27499
|
-
owner: name ? name : _name
|
|
27500
|
-
};
|
|
27501
|
-
const dahuaResponse = await _updatePlateNumber(dahuaPayload);
|
|
27502
|
-
const normalizedPlateNumber = Array.isArray(plateNumber) ? plateNumber[0] : plateNumber;
|
|
27503
|
-
if (value.peopleId && value.recNo) {
|
|
27504
|
-
await _pushVehicleById(
|
|
27505
|
-
value.peopleId,
|
|
27506
|
-
{
|
|
27507
|
-
plateNumber: normalizedPlateNumber,
|
|
27508
|
-
recNo: _recNo
|
|
27509
|
-
},
|
|
27510
|
-
session
|
|
27511
|
-
);
|
|
27512
|
-
}
|
|
27513
|
-
if (dahuaResponse?.statusCode !== 200) {
|
|
27514
|
-
throw new import_node_server_utils78.BadRequestError(
|
|
27515
|
-
"Failed to update plate number to ANPR"
|
|
27441
|
+
const vehicle = await _getVehicleById(_id);
|
|
27442
|
+
const plate = vehicle.plates.find((p) => p._id.toString() === _id);
|
|
27443
|
+
const _name = vehicle.name;
|
|
27444
|
+
const _plateNumber = plate?.plateNumber;
|
|
27445
|
+
const _start = vehicle.start;
|
|
27446
|
+
const _end = vehicle.end;
|
|
27447
|
+
const _recNo = plate.recNo;
|
|
27448
|
+
const _type = value.type ? value.type : plate.type;
|
|
27449
|
+
if (value.peopleId) {
|
|
27450
|
+
value.peopleId = new import_mongodb49.ObjectId(value.peopleId);
|
|
27451
|
+
}
|
|
27452
|
+
const { name, plateNumber, start, end, recNo, type, unit, site, block, level, ...rest } = value;
|
|
27453
|
+
if (_name != name || _plateNumber != plateNumber) {
|
|
27454
|
+
const startDahua = value.start ? formatDahuaDate(new Date(value.start)) : formatDahuaDate(new Date(_start));
|
|
27455
|
+
const endDahua = value.end ? formatDahuaDate(new Date(value.end)) : formatDahuaDate(new Date(_end));
|
|
27456
|
+
if (name || plateNumber || start || end) {
|
|
27457
|
+
const siteCameras = [];
|
|
27458
|
+
let page = 1;
|
|
27459
|
+
let pages = 1;
|
|
27460
|
+
const limit = 20;
|
|
27461
|
+
do {
|
|
27462
|
+
const siteCameraReq = await _getAllSiteCameras({
|
|
27463
|
+
site,
|
|
27464
|
+
type: "anpr",
|
|
27465
|
+
direction: ["both", "entry", "residents"],
|
|
27466
|
+
page,
|
|
27467
|
+
limit
|
|
27468
|
+
});
|
|
27469
|
+
pages = siteCameraReq.pages || 1;
|
|
27470
|
+
siteCameras.push(...siteCameraReq.items);
|
|
27471
|
+
page++;
|
|
27472
|
+
} while (page < pages);
|
|
27473
|
+
if (!siteCameras.length) {
|
|
27474
|
+
throw new import_node_server_utils78.BadRequestError("No site cameras found.");
|
|
27475
|
+
}
|
|
27476
|
+
for (const camera of siteCameras) {
|
|
27477
|
+
const { host, username, password } = camera;
|
|
27478
|
+
if (_plateNumber != plateNumber) {
|
|
27479
|
+
console.log("updateVehicleById _plateNumber != plateNumber", _plateNumber, plateNumber);
|
|
27480
|
+
const removePlateNumber = {
|
|
27481
|
+
host,
|
|
27482
|
+
username,
|
|
27483
|
+
password,
|
|
27484
|
+
mode: plate.type === "blocklist" /* BLOCKLIST */ ? "TrafficBlackList" /* TRAFFIC_BLACKLIST */ : "TrafficRedList" /* TRAFFIC_REDLIST */,
|
|
27485
|
+
//whitelist or blocklist
|
|
27486
|
+
recno: _recNo
|
|
27487
|
+
};
|
|
27488
|
+
const responseForDeletion = await _removePlateNumber(
|
|
27489
|
+
removePlateNumber
|
|
27516
27490
|
);
|
|
27491
|
+
if (responseForDeletion?.statusCode !== 200) {
|
|
27492
|
+
throw new import_node_server_utils78.BadRequestError(
|
|
27493
|
+
"Failed to delete plate number to ANPR"
|
|
27494
|
+
);
|
|
27495
|
+
}
|
|
27496
|
+
const dahuaPayload = {
|
|
27497
|
+
host,
|
|
27498
|
+
username,
|
|
27499
|
+
password,
|
|
27500
|
+
plateNumber,
|
|
27501
|
+
mode: value.type === "blocklist" /* BLOCKLIST */ ? "TrafficBlackList" /* TRAFFIC_BLACKLIST */ : "TrafficRedList" /* TRAFFIC_REDLIST */,
|
|
27502
|
+
//whitelist or blocklist
|
|
27503
|
+
owner: name,
|
|
27504
|
+
...startDahua ? { start: startDahua } : {},
|
|
27505
|
+
...endDahua ? { end: endDahua } : {}
|
|
27506
|
+
};
|
|
27507
|
+
const dahuaResponse = await _addPlateNumber(dahuaPayload);
|
|
27508
|
+
if (dahuaResponse?.statusCode !== 200) {
|
|
27509
|
+
throw new import_node_server_utils78.BadRequestError(
|
|
27510
|
+
"Failed to update plate number to ANPR"
|
|
27511
|
+
);
|
|
27512
|
+
}
|
|
27513
|
+
const responseData = dahuaResponse?.data?.toString("utf-8") ?? "";
|
|
27514
|
+
value.recNo = responseData.split("=")[1]?.trim();
|
|
27515
|
+
if (value.peopleId && value.recNo) {
|
|
27516
|
+
await _pushVehicleById(
|
|
27517
|
+
value.peopleId,
|
|
27518
|
+
{
|
|
27519
|
+
plateNumber,
|
|
27520
|
+
recNo: value.recNo
|
|
27521
|
+
},
|
|
27522
|
+
session
|
|
27523
|
+
);
|
|
27524
|
+
}
|
|
27525
|
+
} else {
|
|
27526
|
+
console.log("updateVehicleById _plateNumber == plateNumber", _plateNumber, plateNumber);
|
|
27527
|
+
const dahuaPayload = {
|
|
27528
|
+
host,
|
|
27529
|
+
username,
|
|
27530
|
+
password,
|
|
27531
|
+
plateNumber,
|
|
27532
|
+
// recno: _recNo,
|
|
27533
|
+
mode: _type === "blocklist" /* BLOCKLIST */ ? "TrafficBlackList" /* TRAFFIC_BLACKLIST */ : "TrafficRedList" /* TRAFFIC_REDLIST */,
|
|
27534
|
+
start: startDahua,
|
|
27535
|
+
end: endDahua,
|
|
27536
|
+
owner: name ? name : _name
|
|
27537
|
+
};
|
|
27538
|
+
const dahuaResponse = await _addPlateNumber(dahuaPayload);
|
|
27539
|
+
const responseData = dahuaResponse?.data?.toString("utf-8") ?? "";
|
|
27540
|
+
value.recNo = responseData.split("=")[1]?.trim();
|
|
27541
|
+
if (value.peopleId && value.recNo) {
|
|
27542
|
+
await _pushVehicleById(
|
|
27543
|
+
value.peopleId,
|
|
27544
|
+
{
|
|
27545
|
+
plateNumber,
|
|
27546
|
+
recNo: value.recNo
|
|
27547
|
+
},
|
|
27548
|
+
session
|
|
27549
|
+
);
|
|
27550
|
+
}
|
|
27551
|
+
if (dahuaResponse?.statusCode !== 200) {
|
|
27552
|
+
throw new import_node_server_utils78.BadRequestError(
|
|
27553
|
+
"Failed to update plate number to ANPR"
|
|
27554
|
+
);
|
|
27555
|
+
}
|
|
27517
27556
|
}
|
|
27518
27557
|
}
|
|
27519
27558
|
}
|
|
@@ -27524,6 +27563,12 @@ function useVehicleService() {
|
|
|
27524
27563
|
...plateNumber && { plateNumber },
|
|
27525
27564
|
...start && { start },
|
|
27526
27565
|
...end && { end },
|
|
27566
|
+
...block && {
|
|
27567
|
+
block: typeof block === "string" ? new import_mongodb49.ObjectId(block) : block
|
|
27568
|
+
},
|
|
27569
|
+
...level && {
|
|
27570
|
+
level: typeof level === "string" ? new import_mongodb49.ObjectId(level) : level
|
|
27571
|
+
},
|
|
27527
27572
|
...unit && {
|
|
27528
27573
|
unit: typeof unit === "string" ? new import_mongodb49.ObjectId(unit) : unit
|
|
27529
27574
|
},
|
|
@@ -31297,9 +31342,9 @@ function useVehicleController() {
|
|
|
31297
31342
|
site: import_joi48.default.string().hex().length(24).required(),
|
|
31298
31343
|
name: import_joi48.default.string().optional().allow("", null),
|
|
31299
31344
|
phoneNumber: import_joi48.default.string().optional().allow("", null),
|
|
31300
|
-
block: import_joi48.default.
|
|
31301
|
-
level: import_joi48.default.string().optional().allow("", null),
|
|
31302
|
-
unit: import_joi48.default.string().optional().allow("", null),
|
|
31345
|
+
block: import_joi48.default.string().hex().length(24).allow("", null),
|
|
31346
|
+
level: import_joi48.default.string().hex().length(24).optional().allow("", null),
|
|
31347
|
+
unit: import_joi48.default.string().hex().length(24).optional().allow("", null),
|
|
31303
31348
|
plateNumber: import_joi48.default.string().optional().allow("", null),
|
|
31304
31349
|
nric: import_joi48.default.string().optional().allow("", null),
|
|
31305
31350
|
start: import_joi48.default.string().isoDate().optional().allow(null, ""),
|
|
@@ -31329,7 +31374,11 @@ function useVehicleController() {
|
|
|
31329
31374
|
return;
|
|
31330
31375
|
} catch (error) {
|
|
31331
31376
|
import_node_server_utils92.logger.log({ level: "error", message: error.message });
|
|
31332
|
-
|
|
31377
|
+
if (error?.message) {
|
|
31378
|
+
next(new import_node_server_utils92.BadRequestError(error?.message));
|
|
31379
|
+
} else {
|
|
31380
|
+
next(error);
|
|
31381
|
+
}
|
|
31333
31382
|
return;
|
|
31334
31383
|
}
|
|
31335
31384
|
}
|
|
@@ -48879,22 +48928,52 @@ function useAccessManagementSvc() {
|
|
|
48879
48928
|
}
|
|
48880
48929
|
};
|
|
48881
48930
|
const liftAccessLevelsSvc = async (params) => {
|
|
48931
|
+
const { getCache: getCache2, setCache: setCache2 } = (0, import_node_server_utils159.useCache)(namespace);
|
|
48932
|
+
const cacheKey = (0, import_node_server_utils159.makeCacheKey)(namespace, {
|
|
48933
|
+
user: params.user,
|
|
48934
|
+
resource: "lift-levels"
|
|
48935
|
+
});
|
|
48936
|
+
const cachedData = await getCache2(cacheKey);
|
|
48937
|
+
if (cachedData) {
|
|
48938
|
+
import_node_server_utils159.logger.info(`Cache hit for key: ${cacheKey}`);
|
|
48939
|
+
return cachedData;
|
|
48940
|
+
}
|
|
48882
48941
|
try {
|
|
48883
48942
|
const command = readTemplate("lift-levels");
|
|
48884
48943
|
const response = await sendCommand(command, params.acm_url);
|
|
48885
48944
|
const res = await (0, import_xml2js3.parseStringPromise)(response, { explicitArray: false });
|
|
48886
48945
|
const format2 = await formatLiftAccessLevels(res);
|
|
48946
|
+
setCache2(cacheKey, format2, 60).then(() => {
|
|
48947
|
+
import_node_server_utils159.logger.info(`Cache set for key: ${cacheKey}`);
|
|
48948
|
+
}).catch((err) => {
|
|
48949
|
+
import_node_server_utils159.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
|
|
48950
|
+
});
|
|
48887
48951
|
return format2;
|
|
48888
48952
|
} catch (error) {
|
|
48889
48953
|
throw new Error(error.message);
|
|
48890
48954
|
}
|
|
48891
48955
|
};
|
|
48892
48956
|
const accessGroupsSvc = async (params) => {
|
|
48957
|
+
const { getCache: getCache2, setCache: setCache2 } = (0, import_node_server_utils159.useCache)(namespace);
|
|
48958
|
+
const cacheKey = (0, import_node_server_utils159.makeCacheKey)(namespace, {
|
|
48959
|
+
user: params.user,
|
|
48960
|
+
resource: "access-groups"
|
|
48961
|
+
});
|
|
48962
|
+
const cachedData = await getCache2(cacheKey);
|
|
48963
|
+
if (cachedData) {
|
|
48964
|
+
import_node_server_utils159.logger.info(`Cache hit for key: ${cacheKey}`);
|
|
48965
|
+
return cachedData;
|
|
48966
|
+
}
|
|
48893
48967
|
try {
|
|
48894
48968
|
const command = readTemplate("access-group");
|
|
48895
48969
|
const response = await sendCommand(command, params.acm_url);
|
|
48896
48970
|
const res = await (0, import_xml2js3.parseStringPromise)(response, { explicitArray: false });
|
|
48897
48971
|
const format2 = await formatAccessGroup(res);
|
|
48972
|
+
setCache2(cacheKey, format2, 60).then(() => {
|
|
48973
|
+
import_node_server_utils159.logger.info(`Cache set for key: ${cacheKey}`);
|
|
48974
|
+
}).catch((err) => {
|
|
48975
|
+
import_node_server_utils159.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
|
|
48976
|
+
});
|
|
48898
48977
|
return format2;
|
|
48899
48978
|
} catch (err) {
|
|
48900
48979
|
throw new Error(err.message);
|
|
@@ -52694,6 +52773,7 @@ function useStatementOfAccountService() {
|
|
|
52694
52773
|
unit_billings = unit_billings.map((unit) => {
|
|
52695
52774
|
try {
|
|
52696
52775
|
unit._id = unit._id.toString();
|
|
52776
|
+
unit.paidBy = unit.paidBy.toString();
|
|
52697
52777
|
} catch {
|
|
52698
52778
|
throw new import_node_server_utils172.BadRequestError("Invalid unit id format/type");
|
|
52699
52779
|
}
|
|
@@ -68038,7 +68118,7 @@ var BidType = /* @__PURE__ */ ((BidType2) => {
|
|
|
68038
68118
|
})(BidType || {});
|
|
68039
68119
|
var BidStatus = /* @__PURE__ */ ((BidStatus3) => {
|
|
68040
68120
|
BidStatus3["PENDING"] = "pending";
|
|
68041
|
-
BidStatus3["
|
|
68121
|
+
BidStatus3["SOLD"] = "sold";
|
|
68042
68122
|
BidStatus3["RESERVED"] = "reserved";
|
|
68043
68123
|
BidStatus3["CANCELLED"] = "cancelled";
|
|
68044
68124
|
return BidStatus3;
|
|
@@ -68127,6 +68207,7 @@ function useBidPrelovedService() {
|
|
|
68127
68207
|
const { add: _addBid } = useBidPrelovedRepo();
|
|
68128
68208
|
const { add: _addChannel, getByParticipants: _getByParticipants } = useChannelPrelovedRepo();
|
|
68129
68209
|
const { add: _addChat } = useChatPrelovedRepo();
|
|
68210
|
+
const { updateStatus } = usePostPrelovedRepo();
|
|
68130
68211
|
async function createBid(value) {
|
|
68131
68212
|
const client = import_node_server_utils254.useAtlas.getClient();
|
|
68132
68213
|
if (!client)
|
|
@@ -68172,6 +68253,9 @@ function useBidPrelovedService() {
|
|
|
68172
68253
|
},
|
|
68173
68254
|
session
|
|
68174
68255
|
);
|
|
68256
|
+
if (value.type === "reserve") {
|
|
68257
|
+
await updateStatus(postId, "reserved" /* RESERVED */, session);
|
|
68258
|
+
}
|
|
68175
68259
|
await session.commitTransaction();
|
|
68176
68260
|
return { bidId };
|
|
68177
68261
|
} catch (error) {
|
|
@@ -69294,6 +69378,9 @@ var schemaHidAmicoSync = import_joi151.default.object({
|
|
|
69294
69378
|
var schemaHidAmicoExecuteActions = import_joi151.default.object({
|
|
69295
69379
|
actions: import_joi151.default.array().items(import_joi151.default.object().unknown(true)).min(1).required()
|
|
69296
69380
|
}).unknown(true);
|
|
69381
|
+
var schemaHidAmicoIntercomCall = import_joi151.default.object({
|
|
69382
|
+
target: import_joi151.default.string().trim().required()
|
|
69383
|
+
}).unknown(true);
|
|
69297
69384
|
var schemaHidAmicoConfiguration = import_joi151.default.object().pattern(import_joi151.default.string(), import_joi151.default.array().items(import_joi151.default.string())).min(1).unknown(true);
|
|
69298
69385
|
var schemaHidAmicoSetConfiguration = import_joi151.default.object().unknown(true);
|
|
69299
69386
|
var schemaHidAmicoObjectOperation = import_joi151.default.object({
|
|
@@ -69699,6 +69786,32 @@ var import_crypto3 = __toESM(require("crypto"));
|
|
|
69699
69786
|
var import_axios4 = __toESM(require("axios"));
|
|
69700
69787
|
var import_node_server_utils262 = require("@7365admin1/node-server-utils");
|
|
69701
69788
|
var PASSWORD_PREFIX = "v1";
|
|
69789
|
+
var PJSIP_CONFIGURATION_KEYS = [
|
|
69790
|
+
"enabled",
|
|
69791
|
+
"server_ip",
|
|
69792
|
+
"server_port",
|
|
69793
|
+
"server_outbound_port",
|
|
69794
|
+
"server_outbound_port_range",
|
|
69795
|
+
"numeric_branch_enabled",
|
|
69796
|
+
"branch",
|
|
69797
|
+
"login",
|
|
69798
|
+
"peer_to_peer_enabled",
|
|
69799
|
+
"reg_status_query_period",
|
|
69800
|
+
"server_retry_interval",
|
|
69801
|
+
"max_call_time",
|
|
69802
|
+
"auto_answer_enabled",
|
|
69803
|
+
"auto_answer_delay",
|
|
69804
|
+
"auto_call_button_enabled",
|
|
69805
|
+
"rex_enabled",
|
|
69806
|
+
"dialing_display_mode",
|
|
69807
|
+
"auto_call_target",
|
|
69808
|
+
"custom_identifier_auto_call",
|
|
69809
|
+
"video_enabled",
|
|
69810
|
+
"open_door_enabled",
|
|
69811
|
+
"open_door_command",
|
|
69812
|
+
"mic_volume",
|
|
69813
|
+
"speaker_volume"
|
|
69814
|
+
];
|
|
69702
69815
|
function getSecretKey() {
|
|
69703
69816
|
const secret = process.env.HID_AMICO_SECRET || process.env.ACCESS_TOKEN_SECRET || "iservice365-hid-amico";
|
|
69704
69817
|
return import_crypto3.default.createHash("sha256").update(secret).digest();
|
|
@@ -69745,6 +69858,28 @@ function toHidRequestError(error, path5) {
|
|
|
69745
69858
|
}
|
|
69746
69859
|
return error;
|
|
69747
69860
|
}
|
|
69861
|
+
function getErrorMessage(error) {
|
|
69862
|
+
return String(error?.message || "");
|
|
69863
|
+
}
|
|
69864
|
+
function isSipStatusUnavailable(error) {
|
|
69865
|
+
const message = getErrorMessage(error).toLowerCase();
|
|
69866
|
+
return message.includes("/get_sip_status.fcgi") && (message.includes("unable to obtain sip status") || message.includes("status 400"));
|
|
69867
|
+
}
|
|
69868
|
+
function normalizePjsipConfiguration(response) {
|
|
69869
|
+
const data = response?.data || response || {};
|
|
69870
|
+
return data.pjsip || data.data?.pjsip || data.result?.pjsip || {};
|
|
69871
|
+
}
|
|
69872
|
+
function buildSipStatusFallback(configurationResponse, nativeError) {
|
|
69873
|
+
const configuration = normalizePjsipConfiguration(configurationResponse);
|
|
69874
|
+
const enabled = String(configuration?.enabled ?? "0") === "1";
|
|
69875
|
+
return {
|
|
69876
|
+
status: enabled ? 100 : -1,
|
|
69877
|
+
statusText: enabled ? "SIP status unavailable" : "SIP disabled",
|
|
69878
|
+
nativeStatusAvailable: false,
|
|
69879
|
+
nativeError: getErrorMessage(nativeError),
|
|
69880
|
+
configuration
|
|
69881
|
+
};
|
|
69882
|
+
}
|
|
69748
69883
|
var HidAmicoClient = class {
|
|
69749
69884
|
constructor(reader) {
|
|
69750
69885
|
this.reader = reader;
|
|
@@ -69890,6 +70025,27 @@ var HidAmicoClient = class {
|
|
|
69890
70025
|
const res = await this.post(this.url("/set_configuration.fcgi"), payload);
|
|
69891
70026
|
return res.data;
|
|
69892
70027
|
}
|
|
70028
|
+
async getSipStatus() {
|
|
70029
|
+
if (!this.session) {
|
|
70030
|
+
await this.login();
|
|
70031
|
+
}
|
|
70032
|
+
const res = await this.post(this.url("/get_sip_status.fcgi"), {});
|
|
70033
|
+
return res.data;
|
|
70034
|
+
}
|
|
70035
|
+
async makeSipCall(target) {
|
|
70036
|
+
if (!this.session) {
|
|
70037
|
+
await this.login();
|
|
70038
|
+
}
|
|
70039
|
+
const res = await this.post(this.url("/make_sip_call.fcgi"), { target });
|
|
70040
|
+
return res.data;
|
|
70041
|
+
}
|
|
70042
|
+
async finalizeSipCall() {
|
|
70043
|
+
if (!this.session) {
|
|
70044
|
+
await this.login();
|
|
70045
|
+
}
|
|
70046
|
+
const res = await this.post(this.url("/finalize_sip_call.fcgi"), {});
|
|
70047
|
+
return res.data;
|
|
70048
|
+
}
|
|
69893
70049
|
};
|
|
69894
70050
|
function normalizeBatches(payload) {
|
|
69895
70051
|
if (Array.isArray(payload?.objects)) {
|
|
@@ -70164,6 +70320,63 @@ function useHidAmicoService() {
|
|
|
70164
70320
|
await client.logout();
|
|
70165
70321
|
}
|
|
70166
70322
|
}
|
|
70323
|
+
async function getIntercomStatus(id) {
|
|
70324
|
+
const reader = await getActiveReader(id);
|
|
70325
|
+
const client = new HidAmicoClient(reader);
|
|
70326
|
+
try {
|
|
70327
|
+
await client.login();
|
|
70328
|
+
let result;
|
|
70329
|
+
try {
|
|
70330
|
+
result = await client.getSipStatus();
|
|
70331
|
+
} catch (error) {
|
|
70332
|
+
if (!isSipStatusUnavailable(error)) {
|
|
70333
|
+
throw error;
|
|
70334
|
+
}
|
|
70335
|
+
const configuration = await client.getConfiguration({ pjsip: PJSIP_CONFIGURATION_KEYS });
|
|
70336
|
+
result = buildSipStatusFallback(configuration, error);
|
|
70337
|
+
}
|
|
70338
|
+
await repo.updateById(id, { lastSeenAt: /* @__PURE__ */ new Date() });
|
|
70339
|
+
await repo.addEvent({ reader: id, site: reader.site, type: "intercom_status", payload: result });
|
|
70340
|
+
return result;
|
|
70341
|
+
} catch (error) {
|
|
70342
|
+
await repo.addEvent({ reader: id, site: reader.site, type: "intercom_status_failed", payload: { message: error.message } });
|
|
70343
|
+
throw error;
|
|
70344
|
+
} finally {
|
|
70345
|
+
await client.logout();
|
|
70346
|
+
}
|
|
70347
|
+
}
|
|
70348
|
+
async function makeIntercomCall(id, target) {
|
|
70349
|
+
const reader = await getActiveReader(id);
|
|
70350
|
+
const client = new HidAmicoClient(reader);
|
|
70351
|
+
try {
|
|
70352
|
+
await client.login();
|
|
70353
|
+
const result = await client.makeSipCall(target);
|
|
70354
|
+
await repo.updateById(id, { lastSeenAt: /* @__PURE__ */ new Date() });
|
|
70355
|
+
await repo.addEvent({ reader: id, site: reader.site, type: "intercom_call", payload: { target, result } });
|
|
70356
|
+
return result;
|
|
70357
|
+
} catch (error) {
|
|
70358
|
+
await repo.addEvent({ reader: id, site: reader.site, type: "intercom_call_failed", payload: { target, message: error.message } });
|
|
70359
|
+
throw error;
|
|
70360
|
+
} finally {
|
|
70361
|
+
await client.logout();
|
|
70362
|
+
}
|
|
70363
|
+
}
|
|
70364
|
+
async function finalizeIntercomCall(id) {
|
|
70365
|
+
const reader = await getActiveReader(id);
|
|
70366
|
+
const client = new HidAmicoClient(reader);
|
|
70367
|
+
try {
|
|
70368
|
+
await client.login();
|
|
70369
|
+
const result = await client.finalizeSipCall();
|
|
70370
|
+
await repo.updateById(id, { lastSeenAt: /* @__PURE__ */ new Date() });
|
|
70371
|
+
await repo.addEvent({ reader: id, site: reader.site, type: "intercom_hangup", payload: result || {} });
|
|
70372
|
+
return result;
|
|
70373
|
+
} catch (error) {
|
|
70374
|
+
await repo.addEvent({ reader: id, site: reader.site, type: "intercom_hangup_failed", payload: { message: error.message } });
|
|
70375
|
+
throw error;
|
|
70376
|
+
} finally {
|
|
70377
|
+
await client.logout();
|
|
70378
|
+
}
|
|
70379
|
+
}
|
|
70167
70380
|
return {
|
|
70168
70381
|
listReaders,
|
|
70169
70382
|
createReader,
|
|
@@ -70182,7 +70395,10 @@ function useHidAmicoService() {
|
|
|
70182
70395
|
getDoorState,
|
|
70183
70396
|
executeActions,
|
|
70184
70397
|
getConfiguration,
|
|
70185
|
-
setConfiguration
|
|
70398
|
+
setConfiguration,
|
|
70399
|
+
getIntercomStatus,
|
|
70400
|
+
makeIntercomCall,
|
|
70401
|
+
finalizeIntercomCall
|
|
70186
70402
|
};
|
|
70187
70403
|
}
|
|
70188
70404
|
|
|
@@ -70439,6 +70655,43 @@ function useHidAmicoController() {
|
|
|
70439
70655
|
next(error);
|
|
70440
70656
|
}
|
|
70441
70657
|
}
|
|
70658
|
+
async function getIntercomStatus(req, res, next) {
|
|
70659
|
+
const { error, value } = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
70660
|
+
if (error) {
|
|
70661
|
+
next(new import_node_server_utils263.BadRequestError(error.message));
|
|
70662
|
+
return;
|
|
70663
|
+
}
|
|
70664
|
+
try {
|
|
70665
|
+
res.json({ data: await service.getIntercomStatus(value.readerId) });
|
|
70666
|
+
} catch (error2) {
|
|
70667
|
+
next(error2);
|
|
70668
|
+
}
|
|
70669
|
+
}
|
|
70670
|
+
async function makeIntercomCall(req, res, next) {
|
|
70671
|
+
const params = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
70672
|
+
const body = schemaHidAmicoIntercomCall.validate(req.body ?? {});
|
|
70673
|
+
if (params.error || body.error) {
|
|
70674
|
+
next(new import_node_server_utils263.BadRequestError(params.error?.message || body.error?.message));
|
|
70675
|
+
return;
|
|
70676
|
+
}
|
|
70677
|
+
try {
|
|
70678
|
+
res.json({ data: await service.makeIntercomCall(params.value.readerId, body.value.target) });
|
|
70679
|
+
} catch (error) {
|
|
70680
|
+
next(error);
|
|
70681
|
+
}
|
|
70682
|
+
}
|
|
70683
|
+
async function finalizeIntercomCall(req, res, next) {
|
|
70684
|
+
const { error, value } = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
70685
|
+
if (error) {
|
|
70686
|
+
next(new import_node_server_utils263.BadRequestError(error.message));
|
|
70687
|
+
return;
|
|
70688
|
+
}
|
|
70689
|
+
try {
|
|
70690
|
+
res.json({ data: await service.finalizeIntercomCall(value.readerId) });
|
|
70691
|
+
} catch (error2) {
|
|
70692
|
+
next(error2);
|
|
70693
|
+
}
|
|
70694
|
+
}
|
|
70442
70695
|
return {
|
|
70443
70696
|
listReaders,
|
|
70444
70697
|
createReader,
|
|
@@ -70457,7 +70710,10 @@ function useHidAmicoController() {
|
|
|
70457
70710
|
executeActions,
|
|
70458
70711
|
getConfiguration,
|
|
70459
70712
|
setConfiguration,
|
|
70460
|
-
runObjectOperation
|
|
70713
|
+
runObjectOperation,
|
|
70714
|
+
getIntercomStatus,
|
|
70715
|
+
makeIntercomCall,
|
|
70716
|
+
finalizeIntercomCall
|
|
70461
70717
|
};
|
|
70462
70718
|
}
|
|
70463
70719
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -70669,6 +70925,7 @@ function useHidAmicoController() {
|
|
|
70669
70925
|
schemaHidAmicoIdentity,
|
|
70670
70926
|
schemaHidAmicoIdentityIdParams,
|
|
70671
70927
|
schemaHidAmicoIdentityQuery,
|
|
70928
|
+
schemaHidAmicoIntercomCall,
|
|
70672
70929
|
schemaHidAmicoLogQuery,
|
|
70673
70930
|
schemaHidAmicoNotificationParams,
|
|
70674
70931
|
schemaHidAmicoObjectOperation,
|