@7365admin1/core 3.23.0 → 3.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.d.ts +13 -4
- package/dist/index.js +328 -118
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +327 -118
- 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
|
|
@@ -14418,8 +14436,10 @@ function useMemberService() {
|
|
|
14418
14436
|
orgName: org?.name || "",
|
|
14419
14437
|
user: _user?._id?.toString() || "",
|
|
14420
14438
|
name: _user?.name || "",
|
|
14439
|
+
email: invite.email,
|
|
14421
14440
|
role: invite.metadata?.role?.toString() || "",
|
|
14422
14441
|
type: invite.metadata?.app ?? "organization",
|
|
14442
|
+
dateInvited: invite.createdAt,
|
|
14423
14443
|
siteId: invite.metadata?.siteId?.toString() || "",
|
|
14424
14444
|
siteName: invite.metadata?.siteName || ""
|
|
14425
14445
|
},
|
|
@@ -14466,8 +14486,10 @@ function useMemberService() {
|
|
|
14466
14486
|
orgName: org.name || "",
|
|
14467
14487
|
user: user._id?.toString() || "",
|
|
14468
14488
|
name: user?.email,
|
|
14489
|
+
email: user.email,
|
|
14469
14490
|
role: roleId,
|
|
14470
14491
|
type: app,
|
|
14492
|
+
dateInvited: (/* @__PURE__ */ new Date()).toISOString(),
|
|
14471
14493
|
siteId: siteId ?? "",
|
|
14472
14494
|
siteName: siteName ?? "",
|
|
14473
14495
|
onboardingRequired,
|
|
@@ -24035,6 +24057,7 @@ function useDahuaService() {
|
|
|
24035
24057
|
);
|
|
24036
24058
|
}
|
|
24037
24059
|
async function getTrafficJunction(camera, signal, onDetected) {
|
|
24060
|
+
console.log(`getTrafficJunction camera object`, camera);
|
|
24038
24061
|
while (!signal.aborted) {
|
|
24039
24062
|
let bufferQueue = null;
|
|
24040
24063
|
let response = null;
|
|
@@ -27401,119 +27424,123 @@ function useVehicleService() {
|
|
|
27401
27424
|
if (!session) {
|
|
27402
27425
|
throw new Error("Unable to start session for vehicle service.");
|
|
27403
27426
|
}
|
|
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
27427
|
try {
|
|
27419
27428
|
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"
|
|
27429
|
+
const vehicle = await _getVehicleById(_id);
|
|
27430
|
+
const plate = vehicle.plates.find((p) => p._id.toString() === _id);
|
|
27431
|
+
const _name = vehicle.name;
|
|
27432
|
+
const _plateNumber = plate?.plateNumber;
|
|
27433
|
+
const _start = vehicle.start;
|
|
27434
|
+
const _end = vehicle.end;
|
|
27435
|
+
const _recNo = plate.recNo;
|
|
27436
|
+
const _type = value.type ? value.type : plate.type;
|
|
27437
|
+
if (value.peopleId) {
|
|
27438
|
+
value.peopleId = new import_mongodb49.ObjectId(value.peopleId);
|
|
27439
|
+
}
|
|
27440
|
+
const { name, plateNumber, start, end, recNo, type, unit, site, block, level, ...rest } = value;
|
|
27441
|
+
if (_name != name || _plateNumber != plateNumber) {
|
|
27442
|
+
const startDahua = value.start ? formatDahuaDate(new Date(value.start)) : formatDahuaDate(new Date(_start));
|
|
27443
|
+
const endDahua = value.end ? formatDahuaDate(new Date(value.end)) : formatDahuaDate(new Date(_end));
|
|
27444
|
+
if (name || plateNumber || start || end) {
|
|
27445
|
+
const siteCameras = [];
|
|
27446
|
+
let page = 1;
|
|
27447
|
+
let pages = 1;
|
|
27448
|
+
const limit = 20;
|
|
27449
|
+
do {
|
|
27450
|
+
const siteCameraReq = await _getAllSiteCameras({
|
|
27451
|
+
site,
|
|
27452
|
+
type: "anpr",
|
|
27453
|
+
direction: ["both", "entry", "residents"],
|
|
27454
|
+
page,
|
|
27455
|
+
limit
|
|
27456
|
+
});
|
|
27457
|
+
pages = siteCameraReq.pages || 1;
|
|
27458
|
+
siteCameras.push(...siteCameraReq.items);
|
|
27459
|
+
page++;
|
|
27460
|
+
} while (page < pages);
|
|
27461
|
+
if (!siteCameras.length) {
|
|
27462
|
+
throw new import_node_server_utils78.BadRequestError("No site cameras found.");
|
|
27463
|
+
}
|
|
27464
|
+
for (const camera of siteCameras) {
|
|
27465
|
+
const { host, username, password } = camera;
|
|
27466
|
+
if (_plateNumber != plateNumber) {
|
|
27467
|
+
console.log("updateVehicleById _plateNumber != plateNumber", _plateNumber, plateNumber);
|
|
27468
|
+
const removePlateNumber = {
|
|
27469
|
+
host,
|
|
27470
|
+
username,
|
|
27471
|
+
password,
|
|
27472
|
+
mode: plate.type === "blocklist" /* BLOCKLIST */ ? "TrafficBlackList" /* TRAFFIC_BLACKLIST */ : "TrafficRedList" /* TRAFFIC_REDLIST */,
|
|
27473
|
+
//whitelist or blocklist
|
|
27474
|
+
recno: _recNo
|
|
27475
|
+
};
|
|
27476
|
+
const responseForDeletion = await _removePlateNumber(
|
|
27477
|
+
removePlateNumber
|
|
27516
27478
|
);
|
|
27479
|
+
if (responseForDeletion?.statusCode !== 200) {
|
|
27480
|
+
throw new import_node_server_utils78.BadRequestError(
|
|
27481
|
+
"Failed to delete plate number to ANPR"
|
|
27482
|
+
);
|
|
27483
|
+
}
|
|
27484
|
+
const dahuaPayload = {
|
|
27485
|
+
host,
|
|
27486
|
+
username,
|
|
27487
|
+
password,
|
|
27488
|
+
plateNumber,
|
|
27489
|
+
mode: value.type === "blocklist" /* BLOCKLIST */ ? "TrafficBlackList" /* TRAFFIC_BLACKLIST */ : "TrafficRedList" /* TRAFFIC_REDLIST */,
|
|
27490
|
+
//whitelist or blocklist
|
|
27491
|
+
owner: name,
|
|
27492
|
+
...startDahua ? { start: startDahua } : {},
|
|
27493
|
+
...endDahua ? { end: endDahua } : {}
|
|
27494
|
+
};
|
|
27495
|
+
const dahuaResponse = await _addPlateNumber(dahuaPayload);
|
|
27496
|
+
if (dahuaResponse?.statusCode !== 200) {
|
|
27497
|
+
throw new import_node_server_utils78.BadRequestError(
|
|
27498
|
+
"Failed to update plate number to ANPR"
|
|
27499
|
+
);
|
|
27500
|
+
}
|
|
27501
|
+
const responseData = dahuaResponse?.data?.toString("utf-8") ?? "";
|
|
27502
|
+
value.recNo = responseData.split("=")[1]?.trim();
|
|
27503
|
+
if (value.peopleId && value.recNo) {
|
|
27504
|
+
await _pushVehicleById(
|
|
27505
|
+
value.peopleId,
|
|
27506
|
+
{
|
|
27507
|
+
plateNumber,
|
|
27508
|
+
recNo: value.recNo
|
|
27509
|
+
},
|
|
27510
|
+
session
|
|
27511
|
+
);
|
|
27512
|
+
}
|
|
27513
|
+
} else {
|
|
27514
|
+
console.log("updateVehicleById _plateNumber == plateNumber", _plateNumber, plateNumber);
|
|
27515
|
+
const dahuaPayload = {
|
|
27516
|
+
host,
|
|
27517
|
+
username,
|
|
27518
|
+
password,
|
|
27519
|
+
plateNumber,
|
|
27520
|
+
// recno: _recNo,
|
|
27521
|
+
mode: _type === "blocklist" /* BLOCKLIST */ ? "TrafficBlackList" /* TRAFFIC_BLACKLIST */ : "TrafficRedList" /* TRAFFIC_REDLIST */,
|
|
27522
|
+
start: startDahua,
|
|
27523
|
+
end: endDahua,
|
|
27524
|
+
owner: name ? name : _name
|
|
27525
|
+
};
|
|
27526
|
+
const dahuaResponse = await _addPlateNumber(dahuaPayload);
|
|
27527
|
+
const responseData = dahuaResponse?.data?.toString("utf-8") ?? "";
|
|
27528
|
+
value.recNo = responseData.split("=")[1]?.trim();
|
|
27529
|
+
if (value.peopleId && value.recNo) {
|
|
27530
|
+
await _pushVehicleById(
|
|
27531
|
+
value.peopleId,
|
|
27532
|
+
{
|
|
27533
|
+
plateNumber,
|
|
27534
|
+
recNo: value.recNo
|
|
27535
|
+
},
|
|
27536
|
+
session
|
|
27537
|
+
);
|
|
27538
|
+
}
|
|
27539
|
+
if (dahuaResponse?.statusCode !== 200) {
|
|
27540
|
+
throw new import_node_server_utils78.BadRequestError(
|
|
27541
|
+
"Failed to update plate number to ANPR"
|
|
27542
|
+
);
|
|
27543
|
+
}
|
|
27517
27544
|
}
|
|
27518
27545
|
}
|
|
27519
27546
|
}
|
|
@@ -27524,6 +27551,12 @@ function useVehicleService() {
|
|
|
27524
27551
|
...plateNumber && { plateNumber },
|
|
27525
27552
|
...start && { start },
|
|
27526
27553
|
...end && { end },
|
|
27554
|
+
...block && {
|
|
27555
|
+
block: typeof block === "string" ? new import_mongodb49.ObjectId(block) : block
|
|
27556
|
+
},
|
|
27557
|
+
...level && {
|
|
27558
|
+
level: typeof level === "string" ? new import_mongodb49.ObjectId(level) : level
|
|
27559
|
+
},
|
|
27527
27560
|
...unit && {
|
|
27528
27561
|
unit: typeof unit === "string" ? new import_mongodb49.ObjectId(unit) : unit
|
|
27529
27562
|
},
|
|
@@ -31297,9 +31330,9 @@ function useVehicleController() {
|
|
|
31297
31330
|
site: import_joi48.default.string().hex().length(24).required(),
|
|
31298
31331
|
name: import_joi48.default.string().optional().allow("", null),
|
|
31299
31332
|
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),
|
|
31333
|
+
block: import_joi48.default.string().hex().length(24).allow("", null),
|
|
31334
|
+
level: import_joi48.default.string().hex().length(24).optional().allow("", null),
|
|
31335
|
+
unit: import_joi48.default.string().hex().length(24).optional().allow("", null),
|
|
31303
31336
|
plateNumber: import_joi48.default.string().optional().allow("", null),
|
|
31304
31337
|
nric: import_joi48.default.string().optional().allow("", null),
|
|
31305
31338
|
start: import_joi48.default.string().isoDate().optional().allow(null, ""),
|
|
@@ -31329,7 +31362,11 @@ function useVehicleController() {
|
|
|
31329
31362
|
return;
|
|
31330
31363
|
} catch (error) {
|
|
31331
31364
|
import_node_server_utils92.logger.log({ level: "error", message: error.message });
|
|
31332
|
-
|
|
31365
|
+
if (error?.message) {
|
|
31366
|
+
next(new import_node_server_utils92.BadRequestError(error?.message));
|
|
31367
|
+
} else {
|
|
31368
|
+
next(error);
|
|
31369
|
+
}
|
|
31333
31370
|
return;
|
|
31334
31371
|
}
|
|
31335
31372
|
}
|
|
@@ -68038,7 +68075,7 @@ var BidType = /* @__PURE__ */ ((BidType2) => {
|
|
|
68038
68075
|
})(BidType || {});
|
|
68039
68076
|
var BidStatus = /* @__PURE__ */ ((BidStatus3) => {
|
|
68040
68077
|
BidStatus3["PENDING"] = "pending";
|
|
68041
|
-
BidStatus3["
|
|
68078
|
+
BidStatus3["SOLD"] = "sold";
|
|
68042
68079
|
BidStatus3["RESERVED"] = "reserved";
|
|
68043
68080
|
BidStatus3["CANCELLED"] = "cancelled";
|
|
68044
68081
|
return BidStatus3;
|
|
@@ -69294,6 +69331,9 @@ var schemaHidAmicoSync = import_joi151.default.object({
|
|
|
69294
69331
|
var schemaHidAmicoExecuteActions = import_joi151.default.object({
|
|
69295
69332
|
actions: import_joi151.default.array().items(import_joi151.default.object().unknown(true)).min(1).required()
|
|
69296
69333
|
}).unknown(true);
|
|
69334
|
+
var schemaHidAmicoIntercomCall = import_joi151.default.object({
|
|
69335
|
+
target: import_joi151.default.string().trim().required()
|
|
69336
|
+
}).unknown(true);
|
|
69297
69337
|
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
69338
|
var schemaHidAmicoSetConfiguration = import_joi151.default.object().unknown(true);
|
|
69299
69339
|
var schemaHidAmicoObjectOperation = import_joi151.default.object({
|
|
@@ -69699,6 +69739,32 @@ var import_crypto3 = __toESM(require("crypto"));
|
|
|
69699
69739
|
var import_axios4 = __toESM(require("axios"));
|
|
69700
69740
|
var import_node_server_utils262 = require("@7365admin1/node-server-utils");
|
|
69701
69741
|
var PASSWORD_PREFIX = "v1";
|
|
69742
|
+
var PJSIP_CONFIGURATION_KEYS = [
|
|
69743
|
+
"enabled",
|
|
69744
|
+
"server_ip",
|
|
69745
|
+
"server_port",
|
|
69746
|
+
"server_outbound_port",
|
|
69747
|
+
"server_outbound_port_range",
|
|
69748
|
+
"numeric_branch_enabled",
|
|
69749
|
+
"branch",
|
|
69750
|
+
"login",
|
|
69751
|
+
"peer_to_peer_enabled",
|
|
69752
|
+
"reg_status_query_period",
|
|
69753
|
+
"server_retry_interval",
|
|
69754
|
+
"max_call_time",
|
|
69755
|
+
"auto_answer_enabled",
|
|
69756
|
+
"auto_answer_delay",
|
|
69757
|
+
"auto_call_button_enabled",
|
|
69758
|
+
"rex_enabled",
|
|
69759
|
+
"dialing_display_mode",
|
|
69760
|
+
"auto_call_target",
|
|
69761
|
+
"custom_identifier_auto_call",
|
|
69762
|
+
"video_enabled",
|
|
69763
|
+
"open_door_enabled",
|
|
69764
|
+
"open_door_command",
|
|
69765
|
+
"mic_volume",
|
|
69766
|
+
"speaker_volume"
|
|
69767
|
+
];
|
|
69702
69768
|
function getSecretKey() {
|
|
69703
69769
|
const secret = process.env.HID_AMICO_SECRET || process.env.ACCESS_TOKEN_SECRET || "iservice365-hid-amico";
|
|
69704
69770
|
return import_crypto3.default.createHash("sha256").update(secret).digest();
|
|
@@ -69745,6 +69811,28 @@ function toHidRequestError(error, path5) {
|
|
|
69745
69811
|
}
|
|
69746
69812
|
return error;
|
|
69747
69813
|
}
|
|
69814
|
+
function getErrorMessage(error) {
|
|
69815
|
+
return String(error?.message || "");
|
|
69816
|
+
}
|
|
69817
|
+
function isSipStatusUnavailable(error) {
|
|
69818
|
+
const message = getErrorMessage(error).toLowerCase();
|
|
69819
|
+
return message.includes("/get_sip_status.fcgi") && (message.includes("unable to obtain sip status") || message.includes("status 400"));
|
|
69820
|
+
}
|
|
69821
|
+
function normalizePjsipConfiguration(response) {
|
|
69822
|
+
const data = response?.data || response || {};
|
|
69823
|
+
return data.pjsip || data.data?.pjsip || data.result?.pjsip || {};
|
|
69824
|
+
}
|
|
69825
|
+
function buildSipStatusFallback(configurationResponse, nativeError) {
|
|
69826
|
+
const configuration = normalizePjsipConfiguration(configurationResponse);
|
|
69827
|
+
const enabled = String(configuration?.enabled ?? "0") === "1";
|
|
69828
|
+
return {
|
|
69829
|
+
status: enabled ? 100 : -1,
|
|
69830
|
+
statusText: enabled ? "SIP status unavailable" : "SIP disabled",
|
|
69831
|
+
nativeStatusAvailable: false,
|
|
69832
|
+
nativeError: getErrorMessage(nativeError),
|
|
69833
|
+
configuration
|
|
69834
|
+
};
|
|
69835
|
+
}
|
|
69748
69836
|
var HidAmicoClient = class {
|
|
69749
69837
|
constructor(reader) {
|
|
69750
69838
|
this.reader = reader;
|
|
@@ -69890,6 +69978,27 @@ var HidAmicoClient = class {
|
|
|
69890
69978
|
const res = await this.post(this.url("/set_configuration.fcgi"), payload);
|
|
69891
69979
|
return res.data;
|
|
69892
69980
|
}
|
|
69981
|
+
async getSipStatus() {
|
|
69982
|
+
if (!this.session) {
|
|
69983
|
+
await this.login();
|
|
69984
|
+
}
|
|
69985
|
+
const res = await this.post(this.url("/get_sip_status.fcgi"), {});
|
|
69986
|
+
return res.data;
|
|
69987
|
+
}
|
|
69988
|
+
async makeSipCall(target) {
|
|
69989
|
+
if (!this.session) {
|
|
69990
|
+
await this.login();
|
|
69991
|
+
}
|
|
69992
|
+
const res = await this.post(this.url("/make_sip_call.fcgi"), { target });
|
|
69993
|
+
return res.data;
|
|
69994
|
+
}
|
|
69995
|
+
async finalizeSipCall() {
|
|
69996
|
+
if (!this.session) {
|
|
69997
|
+
await this.login();
|
|
69998
|
+
}
|
|
69999
|
+
const res = await this.post(this.url("/finalize_sip_call.fcgi"), {});
|
|
70000
|
+
return res.data;
|
|
70001
|
+
}
|
|
69893
70002
|
};
|
|
69894
70003
|
function normalizeBatches(payload) {
|
|
69895
70004
|
if (Array.isArray(payload?.objects)) {
|
|
@@ -70164,6 +70273,63 @@ function useHidAmicoService() {
|
|
|
70164
70273
|
await client.logout();
|
|
70165
70274
|
}
|
|
70166
70275
|
}
|
|
70276
|
+
async function getIntercomStatus(id) {
|
|
70277
|
+
const reader = await getActiveReader(id);
|
|
70278
|
+
const client = new HidAmicoClient(reader);
|
|
70279
|
+
try {
|
|
70280
|
+
await client.login();
|
|
70281
|
+
let result;
|
|
70282
|
+
try {
|
|
70283
|
+
result = await client.getSipStatus();
|
|
70284
|
+
} catch (error) {
|
|
70285
|
+
if (!isSipStatusUnavailable(error)) {
|
|
70286
|
+
throw error;
|
|
70287
|
+
}
|
|
70288
|
+
const configuration = await client.getConfiguration({ pjsip: PJSIP_CONFIGURATION_KEYS });
|
|
70289
|
+
result = buildSipStatusFallback(configuration, error);
|
|
70290
|
+
}
|
|
70291
|
+
await repo.updateById(id, { lastSeenAt: /* @__PURE__ */ new Date() });
|
|
70292
|
+
await repo.addEvent({ reader: id, site: reader.site, type: "intercom_status", payload: result });
|
|
70293
|
+
return result;
|
|
70294
|
+
} catch (error) {
|
|
70295
|
+
await repo.addEvent({ reader: id, site: reader.site, type: "intercom_status_failed", payload: { message: error.message } });
|
|
70296
|
+
throw error;
|
|
70297
|
+
} finally {
|
|
70298
|
+
await client.logout();
|
|
70299
|
+
}
|
|
70300
|
+
}
|
|
70301
|
+
async function makeIntercomCall(id, target) {
|
|
70302
|
+
const reader = await getActiveReader(id);
|
|
70303
|
+
const client = new HidAmicoClient(reader);
|
|
70304
|
+
try {
|
|
70305
|
+
await client.login();
|
|
70306
|
+
const result = await client.makeSipCall(target);
|
|
70307
|
+
await repo.updateById(id, { lastSeenAt: /* @__PURE__ */ new Date() });
|
|
70308
|
+
await repo.addEvent({ reader: id, site: reader.site, type: "intercom_call", payload: { target, result } });
|
|
70309
|
+
return result;
|
|
70310
|
+
} catch (error) {
|
|
70311
|
+
await repo.addEvent({ reader: id, site: reader.site, type: "intercom_call_failed", payload: { target, message: error.message } });
|
|
70312
|
+
throw error;
|
|
70313
|
+
} finally {
|
|
70314
|
+
await client.logout();
|
|
70315
|
+
}
|
|
70316
|
+
}
|
|
70317
|
+
async function finalizeIntercomCall(id) {
|
|
70318
|
+
const reader = await getActiveReader(id);
|
|
70319
|
+
const client = new HidAmicoClient(reader);
|
|
70320
|
+
try {
|
|
70321
|
+
await client.login();
|
|
70322
|
+
const result = await client.finalizeSipCall();
|
|
70323
|
+
await repo.updateById(id, { lastSeenAt: /* @__PURE__ */ new Date() });
|
|
70324
|
+
await repo.addEvent({ reader: id, site: reader.site, type: "intercom_hangup", payload: result || {} });
|
|
70325
|
+
return result;
|
|
70326
|
+
} catch (error) {
|
|
70327
|
+
await repo.addEvent({ reader: id, site: reader.site, type: "intercom_hangup_failed", payload: { message: error.message } });
|
|
70328
|
+
throw error;
|
|
70329
|
+
} finally {
|
|
70330
|
+
await client.logout();
|
|
70331
|
+
}
|
|
70332
|
+
}
|
|
70167
70333
|
return {
|
|
70168
70334
|
listReaders,
|
|
70169
70335
|
createReader,
|
|
@@ -70182,7 +70348,10 @@ function useHidAmicoService() {
|
|
|
70182
70348
|
getDoorState,
|
|
70183
70349
|
executeActions,
|
|
70184
70350
|
getConfiguration,
|
|
70185
|
-
setConfiguration
|
|
70351
|
+
setConfiguration,
|
|
70352
|
+
getIntercomStatus,
|
|
70353
|
+
makeIntercomCall,
|
|
70354
|
+
finalizeIntercomCall
|
|
70186
70355
|
};
|
|
70187
70356
|
}
|
|
70188
70357
|
|
|
@@ -70439,6 +70608,43 @@ function useHidAmicoController() {
|
|
|
70439
70608
|
next(error);
|
|
70440
70609
|
}
|
|
70441
70610
|
}
|
|
70611
|
+
async function getIntercomStatus(req, res, next) {
|
|
70612
|
+
const { error, value } = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
70613
|
+
if (error) {
|
|
70614
|
+
next(new import_node_server_utils263.BadRequestError(error.message));
|
|
70615
|
+
return;
|
|
70616
|
+
}
|
|
70617
|
+
try {
|
|
70618
|
+
res.json({ data: await service.getIntercomStatus(value.readerId) });
|
|
70619
|
+
} catch (error2) {
|
|
70620
|
+
next(error2);
|
|
70621
|
+
}
|
|
70622
|
+
}
|
|
70623
|
+
async function makeIntercomCall(req, res, next) {
|
|
70624
|
+
const params = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
70625
|
+
const body = schemaHidAmicoIntercomCall.validate(req.body ?? {});
|
|
70626
|
+
if (params.error || body.error) {
|
|
70627
|
+
next(new import_node_server_utils263.BadRequestError(params.error?.message || body.error?.message));
|
|
70628
|
+
return;
|
|
70629
|
+
}
|
|
70630
|
+
try {
|
|
70631
|
+
res.json({ data: await service.makeIntercomCall(params.value.readerId, body.value.target) });
|
|
70632
|
+
} catch (error) {
|
|
70633
|
+
next(error);
|
|
70634
|
+
}
|
|
70635
|
+
}
|
|
70636
|
+
async function finalizeIntercomCall(req, res, next) {
|
|
70637
|
+
const { error, value } = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
70638
|
+
if (error) {
|
|
70639
|
+
next(new import_node_server_utils263.BadRequestError(error.message));
|
|
70640
|
+
return;
|
|
70641
|
+
}
|
|
70642
|
+
try {
|
|
70643
|
+
res.json({ data: await service.finalizeIntercomCall(value.readerId) });
|
|
70644
|
+
} catch (error2) {
|
|
70645
|
+
next(error2);
|
|
70646
|
+
}
|
|
70647
|
+
}
|
|
70442
70648
|
return {
|
|
70443
70649
|
listReaders,
|
|
70444
70650
|
createReader,
|
|
@@ -70457,7 +70663,10 @@ function useHidAmicoController() {
|
|
|
70457
70663
|
executeActions,
|
|
70458
70664
|
getConfiguration,
|
|
70459
70665
|
setConfiguration,
|
|
70460
|
-
runObjectOperation
|
|
70666
|
+
runObjectOperation,
|
|
70667
|
+
getIntercomStatus,
|
|
70668
|
+
makeIntercomCall,
|
|
70669
|
+
finalizeIntercomCall
|
|
70461
70670
|
};
|
|
70462
70671
|
}
|
|
70463
70672
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -70669,6 +70878,7 @@ function useHidAmicoController() {
|
|
|
70669
70878
|
schemaHidAmicoIdentity,
|
|
70670
70879
|
schemaHidAmicoIdentityIdParams,
|
|
70671
70880
|
schemaHidAmicoIdentityQuery,
|
|
70881
|
+
schemaHidAmicoIntercomCall,
|
|
70672
70882
|
schemaHidAmicoLogQuery,
|
|
70673
70883
|
schemaHidAmicoNotificationParams,
|
|
70674
70884
|
schemaHidAmicoObjectOperation,
|