@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.mjs
CHANGED
|
@@ -8778,6 +8778,7 @@ function MMember(value) {
|
|
|
8778
8778
|
const schema2 = Joi7.object({
|
|
8779
8779
|
_id: Joi7.string().hex().optional().allow("", null),
|
|
8780
8780
|
name: Joi7.string().required(),
|
|
8781
|
+
email: Joi7.string().email().optional().allow("", null),
|
|
8781
8782
|
user: Joi7.string().hex().required(),
|
|
8782
8783
|
type: Joi7.string().required(),
|
|
8783
8784
|
role: Joi7.string().hex().optional().allow("", null),
|
|
@@ -8786,6 +8787,7 @@ function MMember(value) {
|
|
|
8786
8787
|
siteId: Joi7.string().hex().optional().allow("", null),
|
|
8787
8788
|
siteName: Joi7.string().optional().allow("", null),
|
|
8788
8789
|
status: Joi7.string().optional().allow("", null),
|
|
8790
|
+
dateInvited: Joi7.string().optional().allow("", null),
|
|
8789
8791
|
onboardingRequired: Joi7.boolean().optional(),
|
|
8790
8792
|
onboardingCompleted: Joi7.boolean().optional(),
|
|
8791
8793
|
onboardingCompletedAt: Joi7.string().optional().allow("", null),
|
|
@@ -8828,6 +8830,7 @@ function MMember(value) {
|
|
|
8828
8830
|
return {
|
|
8829
8831
|
_id: value._id,
|
|
8830
8832
|
name: value.name,
|
|
8833
|
+
email: value.email ?? "",
|
|
8831
8834
|
user: value.user ?? "",
|
|
8832
8835
|
type: value.type,
|
|
8833
8836
|
role: value.role ?? "",
|
|
@@ -8836,6 +8839,7 @@ function MMember(value) {
|
|
|
8836
8839
|
siteId: value.siteId ?? "",
|
|
8837
8840
|
siteName: value.siteName ?? "",
|
|
8838
8841
|
status: value.status || "active",
|
|
8842
|
+
dateInvited: value.dateInvited ?? value.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
8839
8843
|
onboardingRequired: value.onboardingRequired ?? false,
|
|
8840
8844
|
onboardingCompleted: value.onboardingCompleted ?? !value.onboardingRequired,
|
|
8841
8845
|
onboardingCompletedAt: value.onboardingCompletedAt ?? "",
|
|
@@ -9132,7 +9136,8 @@ function useMemberRepo() {
|
|
|
9132
9136
|
page,
|
|
9133
9137
|
limit,
|
|
9134
9138
|
type,
|
|
9135
|
-
status
|
|
9139
|
+
status,
|
|
9140
|
+
projectionVersion: 2
|
|
9136
9141
|
};
|
|
9137
9142
|
if (org) {
|
|
9138
9143
|
try {
|
|
@@ -9183,15 +9188,27 @@ function useMemberRepo() {
|
|
|
9183
9188
|
}
|
|
9184
9189
|
},
|
|
9185
9190
|
{ $unwind: { path: "$roles", preserveNullAndEmptyArrays: true } },
|
|
9191
|
+
{
|
|
9192
|
+
$lookup: {
|
|
9193
|
+
from: "users",
|
|
9194
|
+
localField: "user",
|
|
9195
|
+
foreignField: "_id",
|
|
9196
|
+
as: "users",
|
|
9197
|
+
pipeline: [{ $project: { email: 1 } }]
|
|
9198
|
+
}
|
|
9199
|
+
},
|
|
9200
|
+
{ $unwind: { path: "$users", preserveNullAndEmptyArrays: true } },
|
|
9186
9201
|
{
|
|
9187
9202
|
$project: {
|
|
9188
9203
|
name: 1,
|
|
9204
|
+
email: { $ifNull: ["$email", "$users.email"] },
|
|
9189
9205
|
user: 1,
|
|
9190
9206
|
roleName: "$roles.name",
|
|
9191
9207
|
role: "$roles._id",
|
|
9192
9208
|
org: 1,
|
|
9193
9209
|
orgName: 1,
|
|
9194
9210
|
status: 1,
|
|
9211
|
+
dateInvited: { $ifNull: ["$dateInvited", "$createdAt"] },
|
|
9195
9212
|
siteId: 1,
|
|
9196
9213
|
siteName: 1,
|
|
9197
9214
|
type: 1
|
|
@@ -14046,8 +14063,10 @@ function useMemberService() {
|
|
|
14046
14063
|
orgName: org?.name || "",
|
|
14047
14064
|
user: _user?._id?.toString() || "",
|
|
14048
14065
|
name: _user?.name || "",
|
|
14066
|
+
email: invite.email,
|
|
14049
14067
|
role: invite.metadata?.role?.toString() || "",
|
|
14050
14068
|
type: invite.metadata?.app ?? "organization",
|
|
14069
|
+
dateInvited: invite.createdAt,
|
|
14051
14070
|
siteId: invite.metadata?.siteId?.toString() || "",
|
|
14052
14071
|
siteName: invite.metadata?.siteName || ""
|
|
14053
14072
|
},
|
|
@@ -14094,8 +14113,10 @@ function useMemberService() {
|
|
|
14094
14113
|
orgName: org.name || "",
|
|
14095
14114
|
user: user._id?.toString() || "",
|
|
14096
14115
|
name: user?.email,
|
|
14116
|
+
email: user.email,
|
|
14097
14117
|
role: roleId,
|
|
14098
14118
|
type: app,
|
|
14119
|
+
dateInvited: (/* @__PURE__ */ new Date()).toISOString(),
|
|
14099
14120
|
siteId: siteId ?? "",
|
|
14100
14121
|
siteName: siteName ?? "",
|
|
14101
14122
|
onboardingRequired,
|
|
@@ -23782,6 +23803,7 @@ function useDahuaService() {
|
|
|
23782
23803
|
);
|
|
23783
23804
|
}
|
|
23784
23805
|
async function getTrafficJunction(camera, signal, onDetected) {
|
|
23806
|
+
console.log(`getTrafficJunction camera object`, camera);
|
|
23785
23807
|
while (!signal.aborted) {
|
|
23786
23808
|
let bufferQueue = null;
|
|
23787
23809
|
let response = null;
|
|
@@ -27172,119 +27194,123 @@ function useVehicleService() {
|
|
|
27172
27194
|
if (!session) {
|
|
27173
27195
|
throw new Error("Unable to start session for vehicle service.");
|
|
27174
27196
|
}
|
|
27175
|
-
const vehicle = await _getVehicleById(_id);
|
|
27176
|
-
const plate = vehicle.plates.find((p) => p._id.toString() === _id);
|
|
27177
|
-
const _name = value.name ? value.name : vehicle.name;
|
|
27178
|
-
const _plateNumber = plate?.plateNumber;
|
|
27179
|
-
const _start = vehicle.start;
|
|
27180
|
-
const _end = vehicle.end;
|
|
27181
|
-
const _recNo = plate.recNo;
|
|
27182
|
-
const _type = value.type ? value.type : plate.type;
|
|
27183
|
-
if (value.peopleId) {
|
|
27184
|
-
value.peopleId = new ObjectId49(value.peopleId);
|
|
27185
|
-
}
|
|
27186
|
-
const { name, plateNumber, start, end, recNo, type, unit, site, ...rest } = value;
|
|
27187
|
-
const startDahua = value.start ? formatDahuaDate(new Date(value.start)) : formatDahuaDate(new Date(_start));
|
|
27188
|
-
const endDahua = value.end ? formatDahuaDate(new Date(value.end)) : formatDahuaDate(new Date(_end));
|
|
27189
27197
|
try {
|
|
27190
27198
|
session.startTransaction();
|
|
27191
|
-
|
|
27192
|
-
|
|
27193
|
-
|
|
27194
|
-
|
|
27195
|
-
|
|
27196
|
-
|
|
27197
|
-
|
|
27198
|
-
|
|
27199
|
-
|
|
27200
|
-
|
|
27201
|
-
|
|
27202
|
-
|
|
27203
|
-
|
|
27204
|
-
|
|
27205
|
-
|
|
27206
|
-
|
|
27207
|
-
|
|
27208
|
-
|
|
27209
|
-
|
|
27210
|
-
|
|
27211
|
-
|
|
27212
|
-
|
|
27213
|
-
|
|
27214
|
-
|
|
27215
|
-
|
|
27216
|
-
|
|
27217
|
-
|
|
27218
|
-
|
|
27219
|
-
|
|
27220
|
-
|
|
27221
|
-
|
|
27222
|
-
|
|
27223
|
-
|
|
27224
|
-
);
|
|
27225
|
-
|
|
27226
|
-
|
|
27227
|
-
|
|
27228
|
-
|
|
27229
|
-
|
|
27230
|
-
|
|
27231
|
-
|
|
27232
|
-
|
|
27233
|
-
|
|
27234
|
-
|
|
27235
|
-
|
|
27236
|
-
|
|
27237
|
-
|
|
27238
|
-
|
|
27239
|
-
|
|
27240
|
-
};
|
|
27241
|
-
const dahuaResponse = await _addPlateNumber(dahuaPayload);
|
|
27242
|
-
if (dahuaResponse?.statusCode !== 200) {
|
|
27243
|
-
throw new BadRequestError75(
|
|
27244
|
-
"Failed to update plate number to ANPR"
|
|
27245
|
-
);
|
|
27246
|
-
}
|
|
27247
|
-
const responseData = dahuaResponse?.data?.toString("utf-8") ?? "";
|
|
27248
|
-
value.recNo = responseData.split("=")[1]?.trim();
|
|
27249
|
-
const normalizedPlateNumber = Array.isArray(plateNumber) ? plateNumber[0] : plateNumber;
|
|
27250
|
-
if (value.peopleId && value.recNo) {
|
|
27251
|
-
await _pushVehicleById(
|
|
27252
|
-
value.peopleId,
|
|
27253
|
-
{
|
|
27254
|
-
plateNumber: normalizedPlateNumber,
|
|
27255
|
-
recNo: value.recNo
|
|
27256
|
-
},
|
|
27257
|
-
session
|
|
27258
|
-
);
|
|
27259
|
-
}
|
|
27260
|
-
} else {
|
|
27261
|
-
const dahuaPayload = {
|
|
27262
|
-
host,
|
|
27263
|
-
username,
|
|
27264
|
-
password,
|
|
27265
|
-
plateNumber: plateNumber ? plateNumber : _plateNumber,
|
|
27266
|
-
recno: _recNo,
|
|
27267
|
-
mode: _type === "blocklist" /* BLOCKLIST */ ? "TrafficBlackList" /* TRAFFIC_BLACKLIST */ : "TrafficRedList" /* TRAFFIC_REDLIST */,
|
|
27268
|
-
start: startDahua,
|
|
27269
|
-
end: endDahua,
|
|
27270
|
-
owner: name ? name : _name
|
|
27271
|
-
};
|
|
27272
|
-
const dahuaResponse = await _updatePlateNumber(dahuaPayload);
|
|
27273
|
-
const normalizedPlateNumber = Array.isArray(plateNumber) ? plateNumber[0] : plateNumber;
|
|
27274
|
-
if (value.peopleId && value.recNo) {
|
|
27275
|
-
await _pushVehicleById(
|
|
27276
|
-
value.peopleId,
|
|
27277
|
-
{
|
|
27278
|
-
plateNumber: normalizedPlateNumber,
|
|
27279
|
-
recNo: _recNo
|
|
27280
|
-
},
|
|
27281
|
-
session
|
|
27282
|
-
);
|
|
27283
|
-
}
|
|
27284
|
-
if (dahuaResponse?.statusCode !== 200) {
|
|
27285
|
-
throw new BadRequestError75(
|
|
27286
|
-
"Failed to update plate number to ANPR"
|
|
27199
|
+
const vehicle = await _getVehicleById(_id);
|
|
27200
|
+
const plate = vehicle.plates.find((p) => p._id.toString() === _id);
|
|
27201
|
+
const _name = vehicle.name;
|
|
27202
|
+
const _plateNumber = plate?.plateNumber;
|
|
27203
|
+
const _start = vehicle.start;
|
|
27204
|
+
const _end = vehicle.end;
|
|
27205
|
+
const _recNo = plate.recNo;
|
|
27206
|
+
const _type = value.type ? value.type : plate.type;
|
|
27207
|
+
if (value.peopleId) {
|
|
27208
|
+
value.peopleId = new ObjectId49(value.peopleId);
|
|
27209
|
+
}
|
|
27210
|
+
const { name, plateNumber, start, end, recNo, type, unit, site, block, level, ...rest } = value;
|
|
27211
|
+
if (_name != name || _plateNumber != plateNumber) {
|
|
27212
|
+
const startDahua = value.start ? formatDahuaDate(new Date(value.start)) : formatDahuaDate(new Date(_start));
|
|
27213
|
+
const endDahua = value.end ? formatDahuaDate(new Date(value.end)) : formatDahuaDate(new Date(_end));
|
|
27214
|
+
if (name || plateNumber || start || end) {
|
|
27215
|
+
const siteCameras = [];
|
|
27216
|
+
let page = 1;
|
|
27217
|
+
let pages = 1;
|
|
27218
|
+
const limit = 20;
|
|
27219
|
+
do {
|
|
27220
|
+
const siteCameraReq = await _getAllSiteCameras({
|
|
27221
|
+
site,
|
|
27222
|
+
type: "anpr",
|
|
27223
|
+
direction: ["both", "entry", "residents"],
|
|
27224
|
+
page,
|
|
27225
|
+
limit
|
|
27226
|
+
});
|
|
27227
|
+
pages = siteCameraReq.pages || 1;
|
|
27228
|
+
siteCameras.push(...siteCameraReq.items);
|
|
27229
|
+
page++;
|
|
27230
|
+
} while (page < pages);
|
|
27231
|
+
if (!siteCameras.length) {
|
|
27232
|
+
throw new BadRequestError75("No site cameras found.");
|
|
27233
|
+
}
|
|
27234
|
+
for (const camera of siteCameras) {
|
|
27235
|
+
const { host, username, password } = camera;
|
|
27236
|
+
if (_plateNumber != plateNumber) {
|
|
27237
|
+
console.log("updateVehicleById _plateNumber != plateNumber", _plateNumber, plateNumber);
|
|
27238
|
+
const removePlateNumber = {
|
|
27239
|
+
host,
|
|
27240
|
+
username,
|
|
27241
|
+
password,
|
|
27242
|
+
mode: plate.type === "blocklist" /* BLOCKLIST */ ? "TrafficBlackList" /* TRAFFIC_BLACKLIST */ : "TrafficRedList" /* TRAFFIC_REDLIST */,
|
|
27243
|
+
//whitelist or blocklist
|
|
27244
|
+
recno: _recNo
|
|
27245
|
+
};
|
|
27246
|
+
const responseForDeletion = await _removePlateNumber(
|
|
27247
|
+
removePlateNumber
|
|
27287
27248
|
);
|
|
27249
|
+
if (responseForDeletion?.statusCode !== 200) {
|
|
27250
|
+
throw new BadRequestError75(
|
|
27251
|
+
"Failed to delete plate number to ANPR"
|
|
27252
|
+
);
|
|
27253
|
+
}
|
|
27254
|
+
const dahuaPayload = {
|
|
27255
|
+
host,
|
|
27256
|
+
username,
|
|
27257
|
+
password,
|
|
27258
|
+
plateNumber,
|
|
27259
|
+
mode: value.type === "blocklist" /* BLOCKLIST */ ? "TrafficBlackList" /* TRAFFIC_BLACKLIST */ : "TrafficRedList" /* TRAFFIC_REDLIST */,
|
|
27260
|
+
//whitelist or blocklist
|
|
27261
|
+
owner: name,
|
|
27262
|
+
...startDahua ? { start: startDahua } : {},
|
|
27263
|
+
...endDahua ? { end: endDahua } : {}
|
|
27264
|
+
};
|
|
27265
|
+
const dahuaResponse = await _addPlateNumber(dahuaPayload);
|
|
27266
|
+
if (dahuaResponse?.statusCode !== 200) {
|
|
27267
|
+
throw new BadRequestError75(
|
|
27268
|
+
"Failed to update plate number to ANPR"
|
|
27269
|
+
);
|
|
27270
|
+
}
|
|
27271
|
+
const responseData = dahuaResponse?.data?.toString("utf-8") ?? "";
|
|
27272
|
+
value.recNo = responseData.split("=")[1]?.trim();
|
|
27273
|
+
if (value.peopleId && value.recNo) {
|
|
27274
|
+
await _pushVehicleById(
|
|
27275
|
+
value.peopleId,
|
|
27276
|
+
{
|
|
27277
|
+
plateNumber,
|
|
27278
|
+
recNo: value.recNo
|
|
27279
|
+
},
|
|
27280
|
+
session
|
|
27281
|
+
);
|
|
27282
|
+
}
|
|
27283
|
+
} else {
|
|
27284
|
+
console.log("updateVehicleById _plateNumber == plateNumber", _plateNumber, plateNumber);
|
|
27285
|
+
const dahuaPayload = {
|
|
27286
|
+
host,
|
|
27287
|
+
username,
|
|
27288
|
+
password,
|
|
27289
|
+
plateNumber,
|
|
27290
|
+
// recno: _recNo,
|
|
27291
|
+
mode: _type === "blocklist" /* BLOCKLIST */ ? "TrafficBlackList" /* TRAFFIC_BLACKLIST */ : "TrafficRedList" /* TRAFFIC_REDLIST */,
|
|
27292
|
+
start: startDahua,
|
|
27293
|
+
end: endDahua,
|
|
27294
|
+
owner: name ? name : _name
|
|
27295
|
+
};
|
|
27296
|
+
const dahuaResponse = await _addPlateNumber(dahuaPayload);
|
|
27297
|
+
const responseData = dahuaResponse?.data?.toString("utf-8") ?? "";
|
|
27298
|
+
value.recNo = responseData.split("=")[1]?.trim();
|
|
27299
|
+
if (value.peopleId && value.recNo) {
|
|
27300
|
+
await _pushVehicleById(
|
|
27301
|
+
value.peopleId,
|
|
27302
|
+
{
|
|
27303
|
+
plateNumber,
|
|
27304
|
+
recNo: value.recNo
|
|
27305
|
+
},
|
|
27306
|
+
session
|
|
27307
|
+
);
|
|
27308
|
+
}
|
|
27309
|
+
if (dahuaResponse?.statusCode !== 200) {
|
|
27310
|
+
throw new BadRequestError75(
|
|
27311
|
+
"Failed to update plate number to ANPR"
|
|
27312
|
+
);
|
|
27313
|
+
}
|
|
27288
27314
|
}
|
|
27289
27315
|
}
|
|
27290
27316
|
}
|
|
@@ -27295,6 +27321,12 @@ function useVehicleService() {
|
|
|
27295
27321
|
...plateNumber && { plateNumber },
|
|
27296
27322
|
...start && { start },
|
|
27297
27323
|
...end && { end },
|
|
27324
|
+
...block && {
|
|
27325
|
+
block: typeof block === "string" ? new ObjectId49(block) : block
|
|
27326
|
+
},
|
|
27327
|
+
...level && {
|
|
27328
|
+
level: typeof level === "string" ? new ObjectId49(level) : level
|
|
27329
|
+
},
|
|
27298
27330
|
...unit && {
|
|
27299
27331
|
unit: typeof unit === "string" ? new ObjectId49(unit) : unit
|
|
27300
27332
|
},
|
|
@@ -31102,9 +31134,9 @@ function useVehicleController() {
|
|
|
31102
31134
|
site: Joi48.string().hex().length(24).required(),
|
|
31103
31135
|
name: Joi48.string().optional().allow("", null),
|
|
31104
31136
|
phoneNumber: Joi48.string().optional().allow("", null),
|
|
31105
|
-
block: Joi48.
|
|
31106
|
-
level: Joi48.string().optional().allow("", null),
|
|
31107
|
-
unit: Joi48.string().optional().allow("", null),
|
|
31137
|
+
block: Joi48.string().hex().length(24).allow("", null),
|
|
31138
|
+
level: Joi48.string().hex().length(24).optional().allow("", null),
|
|
31139
|
+
unit: Joi48.string().hex().length(24).optional().allow("", null),
|
|
31108
31140
|
plateNumber: Joi48.string().optional().allow("", null),
|
|
31109
31141
|
nric: Joi48.string().optional().allow("", null),
|
|
31110
31142
|
start: Joi48.string().isoDate().optional().allow(null, ""),
|
|
@@ -31134,7 +31166,11 @@ function useVehicleController() {
|
|
|
31134
31166
|
return;
|
|
31135
31167
|
} catch (error) {
|
|
31136
31168
|
logger68.log({ level: "error", message: error.message });
|
|
31137
|
-
|
|
31169
|
+
if (error?.message) {
|
|
31170
|
+
next(new BadRequestError87(error?.message));
|
|
31171
|
+
} else {
|
|
31172
|
+
next(error);
|
|
31173
|
+
}
|
|
31138
31174
|
return;
|
|
31139
31175
|
}
|
|
31140
31176
|
}
|
|
@@ -68304,7 +68340,7 @@ var BidType = /* @__PURE__ */ ((BidType2) => {
|
|
|
68304
68340
|
})(BidType || {});
|
|
68305
68341
|
var BidStatus = /* @__PURE__ */ ((BidStatus3) => {
|
|
68306
68342
|
BidStatus3["PENDING"] = "pending";
|
|
68307
|
-
BidStatus3["
|
|
68343
|
+
BidStatus3["SOLD"] = "sold";
|
|
68308
68344
|
BidStatus3["RESERVED"] = "reserved";
|
|
68309
68345
|
BidStatus3["CANCELLED"] = "cancelled";
|
|
68310
68346
|
return BidStatus3;
|
|
@@ -69573,6 +69609,9 @@ var schemaHidAmicoSync = Joi151.object({
|
|
|
69573
69609
|
var schemaHidAmicoExecuteActions = Joi151.object({
|
|
69574
69610
|
actions: Joi151.array().items(Joi151.object().unknown(true)).min(1).required()
|
|
69575
69611
|
}).unknown(true);
|
|
69612
|
+
var schemaHidAmicoIntercomCall = Joi151.object({
|
|
69613
|
+
target: Joi151.string().trim().required()
|
|
69614
|
+
}).unknown(true);
|
|
69576
69615
|
var schemaHidAmicoConfiguration = Joi151.object().pattern(Joi151.string(), Joi151.array().items(Joi151.string())).min(1).unknown(true);
|
|
69577
69616
|
var schemaHidAmicoSetConfiguration = Joi151.object().unknown(true);
|
|
69578
69617
|
var schemaHidAmicoObjectOperation = Joi151.object({
|
|
@@ -69984,6 +70023,32 @@ import crypto5 from "crypto";
|
|
|
69984
70023
|
import axios4 from "axios";
|
|
69985
70024
|
import { BadRequestError as BadRequestError230 } from "@7365admin1/node-server-utils";
|
|
69986
70025
|
var PASSWORD_PREFIX = "v1";
|
|
70026
|
+
var PJSIP_CONFIGURATION_KEYS = [
|
|
70027
|
+
"enabled",
|
|
70028
|
+
"server_ip",
|
|
70029
|
+
"server_port",
|
|
70030
|
+
"server_outbound_port",
|
|
70031
|
+
"server_outbound_port_range",
|
|
70032
|
+
"numeric_branch_enabled",
|
|
70033
|
+
"branch",
|
|
70034
|
+
"login",
|
|
70035
|
+
"peer_to_peer_enabled",
|
|
70036
|
+
"reg_status_query_period",
|
|
70037
|
+
"server_retry_interval",
|
|
70038
|
+
"max_call_time",
|
|
70039
|
+
"auto_answer_enabled",
|
|
70040
|
+
"auto_answer_delay",
|
|
70041
|
+
"auto_call_button_enabled",
|
|
70042
|
+
"rex_enabled",
|
|
70043
|
+
"dialing_display_mode",
|
|
70044
|
+
"auto_call_target",
|
|
70045
|
+
"custom_identifier_auto_call",
|
|
70046
|
+
"video_enabled",
|
|
70047
|
+
"open_door_enabled",
|
|
70048
|
+
"open_door_command",
|
|
70049
|
+
"mic_volume",
|
|
70050
|
+
"speaker_volume"
|
|
70051
|
+
];
|
|
69987
70052
|
function getSecretKey() {
|
|
69988
70053
|
const secret = process.env.HID_AMICO_SECRET || process.env.ACCESS_TOKEN_SECRET || "iservice365-hid-amico";
|
|
69989
70054
|
return crypto5.createHash("sha256").update(secret).digest();
|
|
@@ -70030,6 +70095,28 @@ function toHidRequestError(error, path5) {
|
|
|
70030
70095
|
}
|
|
70031
70096
|
return error;
|
|
70032
70097
|
}
|
|
70098
|
+
function getErrorMessage(error) {
|
|
70099
|
+
return String(error?.message || "");
|
|
70100
|
+
}
|
|
70101
|
+
function isSipStatusUnavailable(error) {
|
|
70102
|
+
const message = getErrorMessage(error).toLowerCase();
|
|
70103
|
+
return message.includes("/get_sip_status.fcgi") && (message.includes("unable to obtain sip status") || message.includes("status 400"));
|
|
70104
|
+
}
|
|
70105
|
+
function normalizePjsipConfiguration(response) {
|
|
70106
|
+
const data = response?.data || response || {};
|
|
70107
|
+
return data.pjsip || data.data?.pjsip || data.result?.pjsip || {};
|
|
70108
|
+
}
|
|
70109
|
+
function buildSipStatusFallback(configurationResponse, nativeError) {
|
|
70110
|
+
const configuration = normalizePjsipConfiguration(configurationResponse);
|
|
70111
|
+
const enabled = String(configuration?.enabled ?? "0") === "1";
|
|
70112
|
+
return {
|
|
70113
|
+
status: enabled ? 100 : -1,
|
|
70114
|
+
statusText: enabled ? "SIP status unavailable" : "SIP disabled",
|
|
70115
|
+
nativeStatusAvailable: false,
|
|
70116
|
+
nativeError: getErrorMessage(nativeError),
|
|
70117
|
+
configuration
|
|
70118
|
+
};
|
|
70119
|
+
}
|
|
70033
70120
|
var HidAmicoClient = class {
|
|
70034
70121
|
constructor(reader) {
|
|
70035
70122
|
this.reader = reader;
|
|
@@ -70175,6 +70262,27 @@ var HidAmicoClient = class {
|
|
|
70175
70262
|
const res = await this.post(this.url("/set_configuration.fcgi"), payload);
|
|
70176
70263
|
return res.data;
|
|
70177
70264
|
}
|
|
70265
|
+
async getSipStatus() {
|
|
70266
|
+
if (!this.session) {
|
|
70267
|
+
await this.login();
|
|
70268
|
+
}
|
|
70269
|
+
const res = await this.post(this.url("/get_sip_status.fcgi"), {});
|
|
70270
|
+
return res.data;
|
|
70271
|
+
}
|
|
70272
|
+
async makeSipCall(target) {
|
|
70273
|
+
if (!this.session) {
|
|
70274
|
+
await this.login();
|
|
70275
|
+
}
|
|
70276
|
+
const res = await this.post(this.url("/make_sip_call.fcgi"), { target });
|
|
70277
|
+
return res.data;
|
|
70278
|
+
}
|
|
70279
|
+
async finalizeSipCall() {
|
|
70280
|
+
if (!this.session) {
|
|
70281
|
+
await this.login();
|
|
70282
|
+
}
|
|
70283
|
+
const res = await this.post(this.url("/finalize_sip_call.fcgi"), {});
|
|
70284
|
+
return res.data;
|
|
70285
|
+
}
|
|
70178
70286
|
};
|
|
70179
70287
|
function normalizeBatches(payload) {
|
|
70180
70288
|
if (Array.isArray(payload?.objects)) {
|
|
@@ -70449,6 +70557,63 @@ function useHidAmicoService() {
|
|
|
70449
70557
|
await client.logout();
|
|
70450
70558
|
}
|
|
70451
70559
|
}
|
|
70560
|
+
async function getIntercomStatus(id) {
|
|
70561
|
+
const reader = await getActiveReader(id);
|
|
70562
|
+
const client = new HidAmicoClient(reader);
|
|
70563
|
+
try {
|
|
70564
|
+
await client.login();
|
|
70565
|
+
let result;
|
|
70566
|
+
try {
|
|
70567
|
+
result = await client.getSipStatus();
|
|
70568
|
+
} catch (error) {
|
|
70569
|
+
if (!isSipStatusUnavailable(error)) {
|
|
70570
|
+
throw error;
|
|
70571
|
+
}
|
|
70572
|
+
const configuration = await client.getConfiguration({ pjsip: PJSIP_CONFIGURATION_KEYS });
|
|
70573
|
+
result = buildSipStatusFallback(configuration, error);
|
|
70574
|
+
}
|
|
70575
|
+
await repo.updateById(id, { lastSeenAt: /* @__PURE__ */ new Date() });
|
|
70576
|
+
await repo.addEvent({ reader: id, site: reader.site, type: "intercom_status", payload: result });
|
|
70577
|
+
return result;
|
|
70578
|
+
} catch (error) {
|
|
70579
|
+
await repo.addEvent({ reader: id, site: reader.site, type: "intercom_status_failed", payload: { message: error.message } });
|
|
70580
|
+
throw error;
|
|
70581
|
+
} finally {
|
|
70582
|
+
await client.logout();
|
|
70583
|
+
}
|
|
70584
|
+
}
|
|
70585
|
+
async function makeIntercomCall(id, target) {
|
|
70586
|
+
const reader = await getActiveReader(id);
|
|
70587
|
+
const client = new HidAmicoClient(reader);
|
|
70588
|
+
try {
|
|
70589
|
+
await client.login();
|
|
70590
|
+
const result = await client.makeSipCall(target);
|
|
70591
|
+
await repo.updateById(id, { lastSeenAt: /* @__PURE__ */ new Date() });
|
|
70592
|
+
await repo.addEvent({ reader: id, site: reader.site, type: "intercom_call", payload: { target, result } });
|
|
70593
|
+
return result;
|
|
70594
|
+
} catch (error) {
|
|
70595
|
+
await repo.addEvent({ reader: id, site: reader.site, type: "intercom_call_failed", payload: { target, message: error.message } });
|
|
70596
|
+
throw error;
|
|
70597
|
+
} finally {
|
|
70598
|
+
await client.logout();
|
|
70599
|
+
}
|
|
70600
|
+
}
|
|
70601
|
+
async function finalizeIntercomCall(id) {
|
|
70602
|
+
const reader = await getActiveReader(id);
|
|
70603
|
+
const client = new HidAmicoClient(reader);
|
|
70604
|
+
try {
|
|
70605
|
+
await client.login();
|
|
70606
|
+
const result = await client.finalizeSipCall();
|
|
70607
|
+
await repo.updateById(id, { lastSeenAt: /* @__PURE__ */ new Date() });
|
|
70608
|
+
await repo.addEvent({ reader: id, site: reader.site, type: "intercom_hangup", payload: result || {} });
|
|
70609
|
+
return result;
|
|
70610
|
+
} catch (error) {
|
|
70611
|
+
await repo.addEvent({ reader: id, site: reader.site, type: "intercom_hangup_failed", payload: { message: error.message } });
|
|
70612
|
+
throw error;
|
|
70613
|
+
} finally {
|
|
70614
|
+
await client.logout();
|
|
70615
|
+
}
|
|
70616
|
+
}
|
|
70452
70617
|
return {
|
|
70453
70618
|
listReaders,
|
|
70454
70619
|
createReader,
|
|
@@ -70467,7 +70632,10 @@ function useHidAmicoService() {
|
|
|
70467
70632
|
getDoorState,
|
|
70468
70633
|
executeActions,
|
|
70469
70634
|
getConfiguration,
|
|
70470
|
-
setConfiguration
|
|
70635
|
+
setConfiguration,
|
|
70636
|
+
getIntercomStatus,
|
|
70637
|
+
makeIntercomCall,
|
|
70638
|
+
finalizeIntercomCall
|
|
70471
70639
|
};
|
|
70472
70640
|
}
|
|
70473
70641
|
|
|
@@ -70724,6 +70892,43 @@ function useHidAmicoController() {
|
|
|
70724
70892
|
next(error);
|
|
70725
70893
|
}
|
|
70726
70894
|
}
|
|
70895
|
+
async function getIntercomStatus(req, res, next) {
|
|
70896
|
+
const { error, value } = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
70897
|
+
if (error) {
|
|
70898
|
+
next(new BadRequestError231(error.message));
|
|
70899
|
+
return;
|
|
70900
|
+
}
|
|
70901
|
+
try {
|
|
70902
|
+
res.json({ data: await service.getIntercomStatus(value.readerId) });
|
|
70903
|
+
} catch (error2) {
|
|
70904
|
+
next(error2);
|
|
70905
|
+
}
|
|
70906
|
+
}
|
|
70907
|
+
async function makeIntercomCall(req, res, next) {
|
|
70908
|
+
const params = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
70909
|
+
const body = schemaHidAmicoIntercomCall.validate(req.body ?? {});
|
|
70910
|
+
if (params.error || body.error) {
|
|
70911
|
+
next(new BadRequestError231(params.error?.message || body.error?.message));
|
|
70912
|
+
return;
|
|
70913
|
+
}
|
|
70914
|
+
try {
|
|
70915
|
+
res.json({ data: await service.makeIntercomCall(params.value.readerId, body.value.target) });
|
|
70916
|
+
} catch (error) {
|
|
70917
|
+
next(error);
|
|
70918
|
+
}
|
|
70919
|
+
}
|
|
70920
|
+
async function finalizeIntercomCall(req, res, next) {
|
|
70921
|
+
const { error, value } = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
70922
|
+
if (error) {
|
|
70923
|
+
next(new BadRequestError231(error.message));
|
|
70924
|
+
return;
|
|
70925
|
+
}
|
|
70926
|
+
try {
|
|
70927
|
+
res.json({ data: await service.finalizeIntercomCall(value.readerId) });
|
|
70928
|
+
} catch (error2) {
|
|
70929
|
+
next(error2);
|
|
70930
|
+
}
|
|
70931
|
+
}
|
|
70727
70932
|
return {
|
|
70728
70933
|
listReaders,
|
|
70729
70934
|
createReader,
|
|
@@ -70742,7 +70947,10 @@ function useHidAmicoController() {
|
|
|
70742
70947
|
executeActions,
|
|
70743
70948
|
getConfiguration,
|
|
70744
70949
|
setConfiguration,
|
|
70745
|
-
runObjectOperation
|
|
70950
|
+
runObjectOperation,
|
|
70951
|
+
getIntercomStatus,
|
|
70952
|
+
makeIntercomCall,
|
|
70953
|
+
finalizeIntercomCall
|
|
70746
70954
|
};
|
|
70747
70955
|
}
|
|
70748
70956
|
export {
|
|
@@ -70953,6 +71161,7 @@ export {
|
|
|
70953
71161
|
schemaHidAmicoIdentity,
|
|
70954
71162
|
schemaHidAmicoIdentityIdParams,
|
|
70955
71163
|
schemaHidAmicoIdentityQuery,
|
|
71164
|
+
schemaHidAmicoIntercomCall,
|
|
70956
71165
|
schemaHidAmicoLogQuery,
|
|
70957
71166
|
schemaHidAmicoNotificationParams,
|
|
70958
71167
|
schemaHidAmicoObjectOperation,
|