@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.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
|
|
@@ -9930,6 +9947,7 @@ var MVerification = class {
|
|
|
9930
9947
|
}
|
|
9931
9948
|
}
|
|
9932
9949
|
this.metadata = { ...value.metadata };
|
|
9950
|
+
this.roleName = value.roleName;
|
|
9933
9951
|
this.status = value.status ?? "pending";
|
|
9934
9952
|
this.createdAt = value.createdAt ?? /* @__PURE__ */ new Date();
|
|
9935
9953
|
this.updatedAt = value.updatedAt ?? null;
|
|
@@ -10082,6 +10100,16 @@ function useVerificationRepo() {
|
|
|
10082
10100
|
{ $sort: sort },
|
|
10083
10101
|
{ $skip: page * limit },
|
|
10084
10102
|
{ $limit: limit },
|
|
10103
|
+
{
|
|
10104
|
+
$lookup: {
|
|
10105
|
+
from: "roles",
|
|
10106
|
+
localField: "metadata.role",
|
|
10107
|
+
foreignField: "_id",
|
|
10108
|
+
as: "roles",
|
|
10109
|
+
pipeline: [{ $project: { name: 1 } }]
|
|
10110
|
+
}
|
|
10111
|
+
},
|
|
10112
|
+
{ $unwind: { path: "$roles", preserveNullAndEmptyArrays: true } },
|
|
10085
10113
|
{
|
|
10086
10114
|
$project: {
|
|
10087
10115
|
_id: 1,
|
|
@@ -10089,6 +10117,7 @@ function useVerificationRepo() {
|
|
|
10089
10117
|
email: 1,
|
|
10090
10118
|
type: 1,
|
|
10091
10119
|
metadata: 1,
|
|
10120
|
+
roleName: "$roles.name",
|
|
10092
10121
|
status: 1
|
|
10093
10122
|
}
|
|
10094
10123
|
}
|
|
@@ -14046,8 +14075,10 @@ function useMemberService() {
|
|
|
14046
14075
|
orgName: org?.name || "",
|
|
14047
14076
|
user: _user?._id?.toString() || "",
|
|
14048
14077
|
name: _user?.name || "",
|
|
14078
|
+
email: invite.email,
|
|
14049
14079
|
role: invite.metadata?.role?.toString() || "",
|
|
14050
14080
|
type: invite.metadata?.app ?? "organization",
|
|
14081
|
+
dateInvited: invite.createdAt,
|
|
14051
14082
|
siteId: invite.metadata?.siteId?.toString() || "",
|
|
14052
14083
|
siteName: invite.metadata?.siteName || ""
|
|
14053
14084
|
},
|
|
@@ -14094,8 +14125,10 @@ function useMemberService() {
|
|
|
14094
14125
|
orgName: org.name || "",
|
|
14095
14126
|
user: user._id?.toString() || "",
|
|
14096
14127
|
name: user?.email,
|
|
14128
|
+
email: user.email,
|
|
14097
14129
|
role: roleId,
|
|
14098
14130
|
type: app,
|
|
14131
|
+
dateInvited: (/* @__PURE__ */ new Date()).toISOString(),
|
|
14099
14132
|
siteId: siteId ?? "",
|
|
14100
14133
|
siteName: siteName ?? "",
|
|
14101
14134
|
onboardingRequired,
|
|
@@ -21878,7 +21911,7 @@ function useVisitorTransactionRepo() {
|
|
|
21878
21911
|
session,
|
|
21879
21912
|
sort: { checkIn: -1 },
|
|
21880
21913
|
returnDocument: "after",
|
|
21881
|
-
projection: { _id: 1, site: 1 }
|
|
21914
|
+
projection: { _id: 1, site: 1, type: 1 }
|
|
21882
21915
|
}
|
|
21883
21916
|
);
|
|
21884
21917
|
return result;
|
|
@@ -23486,7 +23519,7 @@ function useDahuaService() {
|
|
|
23486
23519
|
try {
|
|
23487
23520
|
const result = await _checkOutBySiteAndPlate(site, plateNumber2);
|
|
23488
23521
|
console.log("checkOutBySiteAndPlate result", result);
|
|
23489
|
-
if (onDetected2 && result?.
|
|
23522
|
+
if (onDetected2 && result?.type != "resident" && result?.site) {
|
|
23490
23523
|
onDetected2({ reload: true, site: result?.site?.toString(), siteName: camera?.siteName, cameraDirection: camera?.direction, direction });
|
|
23491
23524
|
}
|
|
23492
23525
|
return result;
|
|
@@ -23560,7 +23593,7 @@ function useDahuaService() {
|
|
|
23560
23593
|
loggerDahua.info(`${camera?.siteName}-${camera?.direction}] Unregistered vehicle with plate ${plateNumber2} and transaction ID ${insert?._id}`);
|
|
23561
23594
|
}
|
|
23562
23595
|
}
|
|
23563
|
-
if (insert?.
|
|
23596
|
+
if (insert?.status == "unregistered" /* UNREGISTERED */ && insert?.site && onDetected2) {
|
|
23564
23597
|
onDetected2({ _id: insert?._id, site: insert?.site?.toString(), plateNumber: insert?.plateNumber, cameraDirection: camera?.direction, direction });
|
|
23565
23598
|
}
|
|
23566
23599
|
return insert;
|
|
@@ -23782,6 +23815,7 @@ function useDahuaService() {
|
|
|
23782
23815
|
);
|
|
23783
23816
|
}
|
|
23784
23817
|
async function getTrafficJunction(camera, signal, onDetected) {
|
|
23818
|
+
console.log(`getTrafficJunction camera object`, camera);
|
|
23785
23819
|
while (!signal.aborted) {
|
|
23786
23820
|
let bufferQueue = null;
|
|
23787
23821
|
let response = null;
|
|
@@ -27172,119 +27206,123 @@ function useVehicleService() {
|
|
|
27172
27206
|
if (!session) {
|
|
27173
27207
|
throw new Error("Unable to start session for vehicle service.");
|
|
27174
27208
|
}
|
|
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
27209
|
try {
|
|
27190
27210
|
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"
|
|
27211
|
+
const vehicle = await _getVehicleById(_id);
|
|
27212
|
+
const plate = vehicle.plates.find((p) => p._id.toString() === _id);
|
|
27213
|
+
const _name = vehicle.name;
|
|
27214
|
+
const _plateNumber = plate?.plateNumber;
|
|
27215
|
+
const _start = vehicle.start;
|
|
27216
|
+
const _end = vehicle.end;
|
|
27217
|
+
const _recNo = plate.recNo;
|
|
27218
|
+
const _type = value.type ? value.type : plate.type;
|
|
27219
|
+
if (value.peopleId) {
|
|
27220
|
+
value.peopleId = new ObjectId49(value.peopleId);
|
|
27221
|
+
}
|
|
27222
|
+
const { name, plateNumber, start, end, recNo, type, unit, site, block, level, ...rest } = value;
|
|
27223
|
+
if (_name != name || _plateNumber != plateNumber) {
|
|
27224
|
+
const startDahua = value.start ? formatDahuaDate(new Date(value.start)) : formatDahuaDate(new Date(_start));
|
|
27225
|
+
const endDahua = value.end ? formatDahuaDate(new Date(value.end)) : formatDahuaDate(new Date(_end));
|
|
27226
|
+
if (name || plateNumber || start || end) {
|
|
27227
|
+
const siteCameras = [];
|
|
27228
|
+
let page = 1;
|
|
27229
|
+
let pages = 1;
|
|
27230
|
+
const limit = 20;
|
|
27231
|
+
do {
|
|
27232
|
+
const siteCameraReq = await _getAllSiteCameras({
|
|
27233
|
+
site,
|
|
27234
|
+
type: "anpr",
|
|
27235
|
+
direction: ["both", "entry", "residents"],
|
|
27236
|
+
page,
|
|
27237
|
+
limit
|
|
27238
|
+
});
|
|
27239
|
+
pages = siteCameraReq.pages || 1;
|
|
27240
|
+
siteCameras.push(...siteCameraReq.items);
|
|
27241
|
+
page++;
|
|
27242
|
+
} while (page < pages);
|
|
27243
|
+
if (!siteCameras.length) {
|
|
27244
|
+
throw new BadRequestError75("No site cameras found.");
|
|
27245
|
+
}
|
|
27246
|
+
for (const camera of siteCameras) {
|
|
27247
|
+
const { host, username, password } = camera;
|
|
27248
|
+
if (_plateNumber != plateNumber) {
|
|
27249
|
+
console.log("updateVehicleById _plateNumber != plateNumber", _plateNumber, plateNumber);
|
|
27250
|
+
const removePlateNumber = {
|
|
27251
|
+
host,
|
|
27252
|
+
username,
|
|
27253
|
+
password,
|
|
27254
|
+
mode: plate.type === "blocklist" /* BLOCKLIST */ ? "TrafficBlackList" /* TRAFFIC_BLACKLIST */ : "TrafficRedList" /* TRAFFIC_REDLIST */,
|
|
27255
|
+
//whitelist or blocklist
|
|
27256
|
+
recno: _recNo
|
|
27257
|
+
};
|
|
27258
|
+
const responseForDeletion = await _removePlateNumber(
|
|
27259
|
+
removePlateNumber
|
|
27287
27260
|
);
|
|
27261
|
+
if (responseForDeletion?.statusCode !== 200) {
|
|
27262
|
+
throw new BadRequestError75(
|
|
27263
|
+
"Failed to delete plate number to ANPR"
|
|
27264
|
+
);
|
|
27265
|
+
}
|
|
27266
|
+
const dahuaPayload = {
|
|
27267
|
+
host,
|
|
27268
|
+
username,
|
|
27269
|
+
password,
|
|
27270
|
+
plateNumber,
|
|
27271
|
+
mode: value.type === "blocklist" /* BLOCKLIST */ ? "TrafficBlackList" /* TRAFFIC_BLACKLIST */ : "TrafficRedList" /* TRAFFIC_REDLIST */,
|
|
27272
|
+
//whitelist or blocklist
|
|
27273
|
+
owner: name,
|
|
27274
|
+
...startDahua ? { start: startDahua } : {},
|
|
27275
|
+
...endDahua ? { end: endDahua } : {}
|
|
27276
|
+
};
|
|
27277
|
+
const dahuaResponse = await _addPlateNumber(dahuaPayload);
|
|
27278
|
+
if (dahuaResponse?.statusCode !== 200) {
|
|
27279
|
+
throw new BadRequestError75(
|
|
27280
|
+
"Failed to update plate number to ANPR"
|
|
27281
|
+
);
|
|
27282
|
+
}
|
|
27283
|
+
const responseData = dahuaResponse?.data?.toString("utf-8") ?? "";
|
|
27284
|
+
value.recNo = responseData.split("=")[1]?.trim();
|
|
27285
|
+
if (value.peopleId && value.recNo) {
|
|
27286
|
+
await _pushVehicleById(
|
|
27287
|
+
value.peopleId,
|
|
27288
|
+
{
|
|
27289
|
+
plateNumber,
|
|
27290
|
+
recNo: value.recNo
|
|
27291
|
+
},
|
|
27292
|
+
session
|
|
27293
|
+
);
|
|
27294
|
+
}
|
|
27295
|
+
} else {
|
|
27296
|
+
console.log("updateVehicleById _plateNumber == plateNumber", _plateNumber, plateNumber);
|
|
27297
|
+
const dahuaPayload = {
|
|
27298
|
+
host,
|
|
27299
|
+
username,
|
|
27300
|
+
password,
|
|
27301
|
+
plateNumber,
|
|
27302
|
+
// recno: _recNo,
|
|
27303
|
+
mode: _type === "blocklist" /* BLOCKLIST */ ? "TrafficBlackList" /* TRAFFIC_BLACKLIST */ : "TrafficRedList" /* TRAFFIC_REDLIST */,
|
|
27304
|
+
start: startDahua,
|
|
27305
|
+
end: endDahua,
|
|
27306
|
+
owner: name ? name : _name
|
|
27307
|
+
};
|
|
27308
|
+
const dahuaResponse = await _addPlateNumber(dahuaPayload);
|
|
27309
|
+
const responseData = dahuaResponse?.data?.toString("utf-8") ?? "";
|
|
27310
|
+
value.recNo = responseData.split("=")[1]?.trim();
|
|
27311
|
+
if (value.peopleId && value.recNo) {
|
|
27312
|
+
await _pushVehicleById(
|
|
27313
|
+
value.peopleId,
|
|
27314
|
+
{
|
|
27315
|
+
plateNumber,
|
|
27316
|
+
recNo: value.recNo
|
|
27317
|
+
},
|
|
27318
|
+
session
|
|
27319
|
+
);
|
|
27320
|
+
}
|
|
27321
|
+
if (dahuaResponse?.statusCode !== 200) {
|
|
27322
|
+
throw new BadRequestError75(
|
|
27323
|
+
"Failed to update plate number to ANPR"
|
|
27324
|
+
);
|
|
27325
|
+
}
|
|
27288
27326
|
}
|
|
27289
27327
|
}
|
|
27290
27328
|
}
|
|
@@ -27295,6 +27333,12 @@ function useVehicleService() {
|
|
|
27295
27333
|
...plateNumber && { plateNumber },
|
|
27296
27334
|
...start && { start },
|
|
27297
27335
|
...end && { end },
|
|
27336
|
+
...block && {
|
|
27337
|
+
block: typeof block === "string" ? new ObjectId49(block) : block
|
|
27338
|
+
},
|
|
27339
|
+
...level && {
|
|
27340
|
+
level: typeof level === "string" ? new ObjectId49(level) : level
|
|
27341
|
+
},
|
|
27298
27342
|
...unit && {
|
|
27299
27343
|
unit: typeof unit === "string" ? new ObjectId49(unit) : unit
|
|
27300
27344
|
},
|
|
@@ -31102,9 +31146,9 @@ function useVehicleController() {
|
|
|
31102
31146
|
site: Joi48.string().hex().length(24).required(),
|
|
31103
31147
|
name: Joi48.string().optional().allow("", null),
|
|
31104
31148
|
phoneNumber: Joi48.string().optional().allow("", null),
|
|
31105
|
-
block: Joi48.
|
|
31106
|
-
level: Joi48.string().optional().allow("", null),
|
|
31107
|
-
unit: Joi48.string().optional().allow("", null),
|
|
31149
|
+
block: Joi48.string().hex().length(24).allow("", null),
|
|
31150
|
+
level: Joi48.string().hex().length(24).optional().allow("", null),
|
|
31151
|
+
unit: Joi48.string().hex().length(24).optional().allow("", null),
|
|
31108
31152
|
plateNumber: Joi48.string().optional().allow("", null),
|
|
31109
31153
|
nric: Joi48.string().optional().allow("", null),
|
|
31110
31154
|
start: Joi48.string().isoDate().optional().allow(null, ""),
|
|
@@ -31134,7 +31178,11 @@ function useVehicleController() {
|
|
|
31134
31178
|
return;
|
|
31135
31179
|
} catch (error) {
|
|
31136
31180
|
logger68.log({ level: "error", message: error.message });
|
|
31137
|
-
|
|
31181
|
+
if (error?.message) {
|
|
31182
|
+
next(new BadRequestError87(error?.message));
|
|
31183
|
+
} else {
|
|
31184
|
+
next(error);
|
|
31185
|
+
}
|
|
31138
31186
|
return;
|
|
31139
31187
|
}
|
|
31140
31188
|
}
|
|
@@ -48883,22 +48931,52 @@ function useAccessManagementSvc() {
|
|
|
48883
48931
|
}
|
|
48884
48932
|
};
|
|
48885
48933
|
const liftAccessLevelsSvc = async (params) => {
|
|
48934
|
+
const { getCache: getCache2, setCache: setCache2 } = useCache48(namespace);
|
|
48935
|
+
const cacheKey = makeCacheKey46(namespace, {
|
|
48936
|
+
user: params.user,
|
|
48937
|
+
resource: "lift-levels"
|
|
48938
|
+
});
|
|
48939
|
+
const cachedData = await getCache2(cacheKey);
|
|
48940
|
+
if (cachedData) {
|
|
48941
|
+
logger125.info(`Cache hit for key: ${cacheKey}`);
|
|
48942
|
+
return cachedData;
|
|
48943
|
+
}
|
|
48886
48944
|
try {
|
|
48887
48945
|
const command = readTemplate("lift-levels");
|
|
48888
48946
|
const response = await sendCommand(command, params.acm_url);
|
|
48889
48947
|
const res = await parseStringPromise3(response, { explicitArray: false });
|
|
48890
48948
|
const format2 = await formatLiftAccessLevels(res);
|
|
48949
|
+
setCache2(cacheKey, format2, 60).then(() => {
|
|
48950
|
+
logger125.info(`Cache set for key: ${cacheKey}`);
|
|
48951
|
+
}).catch((err) => {
|
|
48952
|
+
logger125.error(`Failed to set cache for key: ${cacheKey}`, err);
|
|
48953
|
+
});
|
|
48891
48954
|
return format2;
|
|
48892
48955
|
} catch (error) {
|
|
48893
48956
|
throw new Error(error.message);
|
|
48894
48957
|
}
|
|
48895
48958
|
};
|
|
48896
48959
|
const accessGroupsSvc = async (params) => {
|
|
48960
|
+
const { getCache: getCache2, setCache: setCache2 } = useCache48(namespace);
|
|
48961
|
+
const cacheKey = makeCacheKey46(namespace, {
|
|
48962
|
+
user: params.user,
|
|
48963
|
+
resource: "access-groups"
|
|
48964
|
+
});
|
|
48965
|
+
const cachedData = await getCache2(cacheKey);
|
|
48966
|
+
if (cachedData) {
|
|
48967
|
+
logger125.info(`Cache hit for key: ${cacheKey}`);
|
|
48968
|
+
return cachedData;
|
|
48969
|
+
}
|
|
48897
48970
|
try {
|
|
48898
48971
|
const command = readTemplate("access-group");
|
|
48899
48972
|
const response = await sendCommand(command, params.acm_url);
|
|
48900
48973
|
const res = await parseStringPromise3(response, { explicitArray: false });
|
|
48901
48974
|
const format2 = await formatAccessGroup(res);
|
|
48975
|
+
setCache2(cacheKey, format2, 60).then(() => {
|
|
48976
|
+
logger125.info(`Cache set for key: ${cacheKey}`);
|
|
48977
|
+
}).catch((err) => {
|
|
48978
|
+
logger125.error(`Failed to set cache for key: ${cacheKey}`, err);
|
|
48979
|
+
});
|
|
48902
48980
|
return format2;
|
|
48903
48981
|
} catch (err) {
|
|
48904
48982
|
throw new Error(err.message);
|
|
@@ -52738,6 +52816,7 @@ function useStatementOfAccountService() {
|
|
|
52738
52816
|
unit_billings = unit_billings.map((unit) => {
|
|
52739
52817
|
try {
|
|
52740
52818
|
unit._id = unit._id.toString();
|
|
52819
|
+
unit.paidBy = unit.paidBy.toString();
|
|
52741
52820
|
} catch {
|
|
52742
52821
|
throw new BadRequestError156("Invalid unit id format/type");
|
|
52743
52822
|
}
|
|
@@ -68304,7 +68383,7 @@ var BidType = /* @__PURE__ */ ((BidType2) => {
|
|
|
68304
68383
|
})(BidType || {});
|
|
68305
68384
|
var BidStatus = /* @__PURE__ */ ((BidStatus3) => {
|
|
68306
68385
|
BidStatus3["PENDING"] = "pending";
|
|
68307
|
-
BidStatus3["
|
|
68386
|
+
BidStatus3["SOLD"] = "sold";
|
|
68308
68387
|
BidStatus3["RESERVED"] = "reserved";
|
|
68309
68388
|
BidStatus3["CANCELLED"] = "cancelled";
|
|
68310
68389
|
return BidStatus3;
|
|
@@ -68397,6 +68476,7 @@ function useBidPrelovedService() {
|
|
|
68397
68476
|
const { add: _addBid } = useBidPrelovedRepo();
|
|
68398
68477
|
const { add: _addChannel, getByParticipants: _getByParticipants } = useChannelPrelovedRepo();
|
|
68399
68478
|
const { add: _addChat } = useChatPrelovedRepo();
|
|
68479
|
+
const { updateStatus } = usePostPrelovedRepo();
|
|
68400
68480
|
async function createBid(value) {
|
|
68401
68481
|
const client = useAtlas129.getClient();
|
|
68402
68482
|
if (!client)
|
|
@@ -68442,6 +68522,9 @@ function useBidPrelovedService() {
|
|
|
68442
68522
|
},
|
|
68443
68523
|
session
|
|
68444
68524
|
);
|
|
68525
|
+
if (value.type === "reserve") {
|
|
68526
|
+
await updateStatus(postId, "reserved" /* RESERVED */, session);
|
|
68527
|
+
}
|
|
68445
68528
|
await session.commitTransaction();
|
|
68446
68529
|
return { bidId };
|
|
68447
68530
|
} catch (error) {
|
|
@@ -69573,6 +69656,9 @@ var schemaHidAmicoSync = Joi151.object({
|
|
|
69573
69656
|
var schemaHidAmicoExecuteActions = Joi151.object({
|
|
69574
69657
|
actions: Joi151.array().items(Joi151.object().unknown(true)).min(1).required()
|
|
69575
69658
|
}).unknown(true);
|
|
69659
|
+
var schemaHidAmicoIntercomCall = Joi151.object({
|
|
69660
|
+
target: Joi151.string().trim().required()
|
|
69661
|
+
}).unknown(true);
|
|
69576
69662
|
var schemaHidAmicoConfiguration = Joi151.object().pattern(Joi151.string(), Joi151.array().items(Joi151.string())).min(1).unknown(true);
|
|
69577
69663
|
var schemaHidAmicoSetConfiguration = Joi151.object().unknown(true);
|
|
69578
69664
|
var schemaHidAmicoObjectOperation = Joi151.object({
|
|
@@ -69984,6 +70070,32 @@ import crypto5 from "crypto";
|
|
|
69984
70070
|
import axios4 from "axios";
|
|
69985
70071
|
import { BadRequestError as BadRequestError230 } from "@7365admin1/node-server-utils";
|
|
69986
70072
|
var PASSWORD_PREFIX = "v1";
|
|
70073
|
+
var PJSIP_CONFIGURATION_KEYS = [
|
|
70074
|
+
"enabled",
|
|
70075
|
+
"server_ip",
|
|
70076
|
+
"server_port",
|
|
70077
|
+
"server_outbound_port",
|
|
70078
|
+
"server_outbound_port_range",
|
|
70079
|
+
"numeric_branch_enabled",
|
|
70080
|
+
"branch",
|
|
70081
|
+
"login",
|
|
70082
|
+
"peer_to_peer_enabled",
|
|
70083
|
+
"reg_status_query_period",
|
|
70084
|
+
"server_retry_interval",
|
|
70085
|
+
"max_call_time",
|
|
70086
|
+
"auto_answer_enabled",
|
|
70087
|
+
"auto_answer_delay",
|
|
70088
|
+
"auto_call_button_enabled",
|
|
70089
|
+
"rex_enabled",
|
|
70090
|
+
"dialing_display_mode",
|
|
70091
|
+
"auto_call_target",
|
|
70092
|
+
"custom_identifier_auto_call",
|
|
70093
|
+
"video_enabled",
|
|
70094
|
+
"open_door_enabled",
|
|
70095
|
+
"open_door_command",
|
|
70096
|
+
"mic_volume",
|
|
70097
|
+
"speaker_volume"
|
|
70098
|
+
];
|
|
69987
70099
|
function getSecretKey() {
|
|
69988
70100
|
const secret = process.env.HID_AMICO_SECRET || process.env.ACCESS_TOKEN_SECRET || "iservice365-hid-amico";
|
|
69989
70101
|
return crypto5.createHash("sha256").update(secret).digest();
|
|
@@ -70030,6 +70142,28 @@ function toHidRequestError(error, path5) {
|
|
|
70030
70142
|
}
|
|
70031
70143
|
return error;
|
|
70032
70144
|
}
|
|
70145
|
+
function getErrorMessage(error) {
|
|
70146
|
+
return String(error?.message || "");
|
|
70147
|
+
}
|
|
70148
|
+
function isSipStatusUnavailable(error) {
|
|
70149
|
+
const message = getErrorMessage(error).toLowerCase();
|
|
70150
|
+
return message.includes("/get_sip_status.fcgi") && (message.includes("unable to obtain sip status") || message.includes("status 400"));
|
|
70151
|
+
}
|
|
70152
|
+
function normalizePjsipConfiguration(response) {
|
|
70153
|
+
const data = response?.data || response || {};
|
|
70154
|
+
return data.pjsip || data.data?.pjsip || data.result?.pjsip || {};
|
|
70155
|
+
}
|
|
70156
|
+
function buildSipStatusFallback(configurationResponse, nativeError) {
|
|
70157
|
+
const configuration = normalizePjsipConfiguration(configurationResponse);
|
|
70158
|
+
const enabled = String(configuration?.enabled ?? "0") === "1";
|
|
70159
|
+
return {
|
|
70160
|
+
status: enabled ? 100 : -1,
|
|
70161
|
+
statusText: enabled ? "SIP status unavailable" : "SIP disabled",
|
|
70162
|
+
nativeStatusAvailable: false,
|
|
70163
|
+
nativeError: getErrorMessage(nativeError),
|
|
70164
|
+
configuration
|
|
70165
|
+
};
|
|
70166
|
+
}
|
|
70033
70167
|
var HidAmicoClient = class {
|
|
70034
70168
|
constructor(reader) {
|
|
70035
70169
|
this.reader = reader;
|
|
@@ -70175,6 +70309,27 @@ var HidAmicoClient = class {
|
|
|
70175
70309
|
const res = await this.post(this.url("/set_configuration.fcgi"), payload);
|
|
70176
70310
|
return res.data;
|
|
70177
70311
|
}
|
|
70312
|
+
async getSipStatus() {
|
|
70313
|
+
if (!this.session) {
|
|
70314
|
+
await this.login();
|
|
70315
|
+
}
|
|
70316
|
+
const res = await this.post(this.url("/get_sip_status.fcgi"), {});
|
|
70317
|
+
return res.data;
|
|
70318
|
+
}
|
|
70319
|
+
async makeSipCall(target) {
|
|
70320
|
+
if (!this.session) {
|
|
70321
|
+
await this.login();
|
|
70322
|
+
}
|
|
70323
|
+
const res = await this.post(this.url("/make_sip_call.fcgi"), { target });
|
|
70324
|
+
return res.data;
|
|
70325
|
+
}
|
|
70326
|
+
async finalizeSipCall() {
|
|
70327
|
+
if (!this.session) {
|
|
70328
|
+
await this.login();
|
|
70329
|
+
}
|
|
70330
|
+
const res = await this.post(this.url("/finalize_sip_call.fcgi"), {});
|
|
70331
|
+
return res.data;
|
|
70332
|
+
}
|
|
70178
70333
|
};
|
|
70179
70334
|
function normalizeBatches(payload) {
|
|
70180
70335
|
if (Array.isArray(payload?.objects)) {
|
|
@@ -70449,6 +70604,63 @@ function useHidAmicoService() {
|
|
|
70449
70604
|
await client.logout();
|
|
70450
70605
|
}
|
|
70451
70606
|
}
|
|
70607
|
+
async function getIntercomStatus(id) {
|
|
70608
|
+
const reader = await getActiveReader(id);
|
|
70609
|
+
const client = new HidAmicoClient(reader);
|
|
70610
|
+
try {
|
|
70611
|
+
await client.login();
|
|
70612
|
+
let result;
|
|
70613
|
+
try {
|
|
70614
|
+
result = await client.getSipStatus();
|
|
70615
|
+
} catch (error) {
|
|
70616
|
+
if (!isSipStatusUnavailable(error)) {
|
|
70617
|
+
throw error;
|
|
70618
|
+
}
|
|
70619
|
+
const configuration = await client.getConfiguration({ pjsip: PJSIP_CONFIGURATION_KEYS });
|
|
70620
|
+
result = buildSipStatusFallback(configuration, error);
|
|
70621
|
+
}
|
|
70622
|
+
await repo.updateById(id, { lastSeenAt: /* @__PURE__ */ new Date() });
|
|
70623
|
+
await repo.addEvent({ reader: id, site: reader.site, type: "intercom_status", payload: result });
|
|
70624
|
+
return result;
|
|
70625
|
+
} catch (error) {
|
|
70626
|
+
await repo.addEvent({ reader: id, site: reader.site, type: "intercom_status_failed", payload: { message: error.message } });
|
|
70627
|
+
throw error;
|
|
70628
|
+
} finally {
|
|
70629
|
+
await client.logout();
|
|
70630
|
+
}
|
|
70631
|
+
}
|
|
70632
|
+
async function makeIntercomCall(id, target) {
|
|
70633
|
+
const reader = await getActiveReader(id);
|
|
70634
|
+
const client = new HidAmicoClient(reader);
|
|
70635
|
+
try {
|
|
70636
|
+
await client.login();
|
|
70637
|
+
const result = await client.makeSipCall(target);
|
|
70638
|
+
await repo.updateById(id, { lastSeenAt: /* @__PURE__ */ new Date() });
|
|
70639
|
+
await repo.addEvent({ reader: id, site: reader.site, type: "intercom_call", payload: { target, result } });
|
|
70640
|
+
return result;
|
|
70641
|
+
} catch (error) {
|
|
70642
|
+
await repo.addEvent({ reader: id, site: reader.site, type: "intercom_call_failed", payload: { target, message: error.message } });
|
|
70643
|
+
throw error;
|
|
70644
|
+
} finally {
|
|
70645
|
+
await client.logout();
|
|
70646
|
+
}
|
|
70647
|
+
}
|
|
70648
|
+
async function finalizeIntercomCall(id) {
|
|
70649
|
+
const reader = await getActiveReader(id);
|
|
70650
|
+
const client = new HidAmicoClient(reader);
|
|
70651
|
+
try {
|
|
70652
|
+
await client.login();
|
|
70653
|
+
const result = await client.finalizeSipCall();
|
|
70654
|
+
await repo.updateById(id, { lastSeenAt: /* @__PURE__ */ new Date() });
|
|
70655
|
+
await repo.addEvent({ reader: id, site: reader.site, type: "intercom_hangup", payload: result || {} });
|
|
70656
|
+
return result;
|
|
70657
|
+
} catch (error) {
|
|
70658
|
+
await repo.addEvent({ reader: id, site: reader.site, type: "intercom_hangup_failed", payload: { message: error.message } });
|
|
70659
|
+
throw error;
|
|
70660
|
+
} finally {
|
|
70661
|
+
await client.logout();
|
|
70662
|
+
}
|
|
70663
|
+
}
|
|
70452
70664
|
return {
|
|
70453
70665
|
listReaders,
|
|
70454
70666
|
createReader,
|
|
@@ -70467,7 +70679,10 @@ function useHidAmicoService() {
|
|
|
70467
70679
|
getDoorState,
|
|
70468
70680
|
executeActions,
|
|
70469
70681
|
getConfiguration,
|
|
70470
|
-
setConfiguration
|
|
70682
|
+
setConfiguration,
|
|
70683
|
+
getIntercomStatus,
|
|
70684
|
+
makeIntercomCall,
|
|
70685
|
+
finalizeIntercomCall
|
|
70471
70686
|
};
|
|
70472
70687
|
}
|
|
70473
70688
|
|
|
@@ -70724,6 +70939,43 @@ function useHidAmicoController() {
|
|
|
70724
70939
|
next(error);
|
|
70725
70940
|
}
|
|
70726
70941
|
}
|
|
70942
|
+
async function getIntercomStatus(req, res, next) {
|
|
70943
|
+
const { error, value } = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
70944
|
+
if (error) {
|
|
70945
|
+
next(new BadRequestError231(error.message));
|
|
70946
|
+
return;
|
|
70947
|
+
}
|
|
70948
|
+
try {
|
|
70949
|
+
res.json({ data: await service.getIntercomStatus(value.readerId) });
|
|
70950
|
+
} catch (error2) {
|
|
70951
|
+
next(error2);
|
|
70952
|
+
}
|
|
70953
|
+
}
|
|
70954
|
+
async function makeIntercomCall(req, res, next) {
|
|
70955
|
+
const params = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
70956
|
+
const body = schemaHidAmicoIntercomCall.validate(req.body ?? {});
|
|
70957
|
+
if (params.error || body.error) {
|
|
70958
|
+
next(new BadRequestError231(params.error?.message || body.error?.message));
|
|
70959
|
+
return;
|
|
70960
|
+
}
|
|
70961
|
+
try {
|
|
70962
|
+
res.json({ data: await service.makeIntercomCall(params.value.readerId, body.value.target) });
|
|
70963
|
+
} catch (error) {
|
|
70964
|
+
next(error);
|
|
70965
|
+
}
|
|
70966
|
+
}
|
|
70967
|
+
async function finalizeIntercomCall(req, res, next) {
|
|
70968
|
+
const { error, value } = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
70969
|
+
if (error) {
|
|
70970
|
+
next(new BadRequestError231(error.message));
|
|
70971
|
+
return;
|
|
70972
|
+
}
|
|
70973
|
+
try {
|
|
70974
|
+
res.json({ data: await service.finalizeIntercomCall(value.readerId) });
|
|
70975
|
+
} catch (error2) {
|
|
70976
|
+
next(error2);
|
|
70977
|
+
}
|
|
70978
|
+
}
|
|
70727
70979
|
return {
|
|
70728
70980
|
listReaders,
|
|
70729
70981
|
createReader,
|
|
@@ -70742,7 +70994,10 @@ function useHidAmicoController() {
|
|
|
70742
70994
|
executeActions,
|
|
70743
70995
|
getConfiguration,
|
|
70744
70996
|
setConfiguration,
|
|
70745
|
-
runObjectOperation
|
|
70997
|
+
runObjectOperation,
|
|
70998
|
+
getIntercomStatus,
|
|
70999
|
+
makeIntercomCall,
|
|
71000
|
+
finalizeIntercomCall
|
|
70746
71001
|
};
|
|
70747
71002
|
}
|
|
70748
71003
|
export {
|
|
@@ -70953,6 +71208,7 @@ export {
|
|
|
70953
71208
|
schemaHidAmicoIdentity,
|
|
70954
71209
|
schemaHidAmicoIdentityIdParams,
|
|
70955
71210
|
schemaHidAmicoIdentityQuery,
|
|
71211
|
+
schemaHidAmicoIntercomCall,
|
|
70956
71212
|
schemaHidAmicoLogQuery,
|
|
70957
71213
|
schemaHidAmicoNotificationParams,
|
|
70958
71214
|
schemaHidAmicoObjectOperation,
|