@7365admin1/core 3.100.0 → 3.101.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 +26 -1
- package/dist/index.js +67 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +64 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/test/e2e/site-camera-password.e2e.test.mjs +274 -0
- package/test/notification-kind.test.mjs +70 -0
- package/test/site-camera-password.test.mjs +49 -0
package/dist/index.mjs
CHANGED
|
@@ -10440,6 +10440,26 @@ async function filterByAccess(userIds, context, data) {
|
|
|
10440
10440
|
}
|
|
10441
10441
|
}
|
|
10442
10442
|
|
|
10443
|
+
// src/utils/notification-kind.util.ts
|
|
10444
|
+
var NOT_A_KIND = /* @__PURE__ */ new Set(["", "other", "platform"]);
|
|
10445
|
+
function notificationKind(data, category) {
|
|
10446
|
+
if (data?.kind)
|
|
10447
|
+
return String(data.kind);
|
|
10448
|
+
const module = String(data?.module ?? "");
|
|
10449
|
+
if (!NOT_A_KIND.has(module))
|
|
10450
|
+
return module;
|
|
10451
|
+
const fromCategory = String(category ?? "");
|
|
10452
|
+
return NOT_A_KIND.has(fromCategory) ? "" : fromCategory;
|
|
10453
|
+
}
|
|
10454
|
+
function withNotificationKind(data, category) {
|
|
10455
|
+
if (!data?.params?.id)
|
|
10456
|
+
return data;
|
|
10457
|
+
const kind = notificationKind(data, category);
|
|
10458
|
+
if (!kind)
|
|
10459
|
+
return data;
|
|
10460
|
+
return { ...data, params: { ...data.params, kind } };
|
|
10461
|
+
}
|
|
10462
|
+
|
|
10443
10463
|
// src/services/notification.service.ts
|
|
10444
10464
|
var { addMany: _addNotification } = useNotificationRepo();
|
|
10445
10465
|
var { filterRecipients: _filterRecipients } = useNotificationPreferenceRepo();
|
|
@@ -10450,6 +10470,7 @@ function toStringArray(recipient) {
|
|
|
10450
10470
|
async function send(userIds, title, body, data, isForMAMobileApp = false, appSlug, category) {
|
|
10451
10471
|
try {
|
|
10452
10472
|
const key = category || data?.module || "other";
|
|
10473
|
+
data = withNotificationKind(data, category);
|
|
10453
10474
|
userIds = await filterByAccess(userIds, { category: key, siteId: data?.siteId });
|
|
10454
10475
|
const inAppIds = await _filterRecipients(userIds, key, "inApp");
|
|
10455
10476
|
if (inAppIds.length) {
|
|
@@ -10540,6 +10561,7 @@ var NotificationService = class {
|
|
|
10540
10561
|
`${what} is now on iService365.`,
|
|
10541
10562
|
{
|
|
10542
10563
|
module: "platform",
|
|
10564
|
+
kind: "client",
|
|
10543
10565
|
screen: "",
|
|
10544
10566
|
params: { id: payload.orgId.toString() }
|
|
10545
10567
|
},
|
|
@@ -10581,7 +10603,7 @@ var NotificationService = class {
|
|
|
10581
10603
|
staff,
|
|
10582
10604
|
title,
|
|
10583
10605
|
body,
|
|
10584
|
-
{ module: "platform", screen: "", params: { id: payload.robotId } },
|
|
10606
|
+
{ module: "platform", kind: "robot", screen: "", params: { id: payload.robotId } },
|
|
10585
10607
|
false,
|
|
10586
10608
|
void 0,
|
|
10587
10609
|
"platform"
|
|
@@ -10596,7 +10618,7 @@ var NotificationService = class {
|
|
|
10596
10618
|
staff,
|
|
10597
10619
|
title,
|
|
10598
10620
|
body,
|
|
10599
|
-
{ module: "platform", screen: "", params: { id: payload.robotId } },
|
|
10621
|
+
{ module: "platform", kind: "robot", screen: "", params: { id: payload.robotId } },
|
|
10600
10622
|
false,
|
|
10601
10623
|
void 0,
|
|
10602
10624
|
"platform"
|
|
@@ -10795,7 +10817,13 @@ var NotificationService = class {
|
|
|
10795
10817
|
toStringArray(payload.to),
|
|
10796
10818
|
`${payload.providerName} ${verb} your invitation`,
|
|
10797
10819
|
payload.accepted ? `${payload.providerName} accepted your invitation to provide services at ${payload.siteName}. They can now see the site in their own app.` : `${payload.providerName} declined your invitation to provide services at ${payload.siteName}.`,
|
|
10798
|
-
{
|
|
10820
|
+
{
|
|
10821
|
+
module: "other",
|
|
10822
|
+
kind: "serviceProviderInviteAnswer",
|
|
10823
|
+
screen: "",
|
|
10824
|
+
// `site`, not `siteId`: the row stays unscoped on purpose (see above).
|
|
10825
|
+
...payload.invitationId ? { params: { id: payload.invitationId, ...payload.siteId ? { site: payload.siteId } : {} } } : {}
|
|
10826
|
+
},
|
|
10799
10827
|
false,
|
|
10800
10828
|
void 0,
|
|
10801
10829
|
"serviceProviderInvite"
|
|
@@ -10862,7 +10890,10 @@ var NotificationService = class {
|
|
|
10862
10890
|
body: `${which} has been ${payload.action} on your site's emergency contact list. Check the number is right before it is needed.`,
|
|
10863
10891
|
data: {
|
|
10864
10892
|
contactId: payload.contactId?.toString(),
|
|
10865
|
-
action: payload.action
|
|
10893
|
+
action: payload.action,
|
|
10894
|
+
// The page is the site's contact list, so the site stands in when a
|
|
10895
|
+
// removed contact has no id left to name.
|
|
10896
|
+
params: payload.contactId || payload.siteId ? { id: (payload.contactId ?? payload.siteId).toString() } : void 0
|
|
10866
10897
|
}
|
|
10867
10898
|
});
|
|
10868
10899
|
}
|
|
@@ -12822,7 +12853,9 @@ function useServiceProviderInviteService() {
|
|
|
12822
12853
|
to,
|
|
12823
12854
|
accepted,
|
|
12824
12855
|
providerName: providerName || providerOrg?.name || String(invite.email ?? ""),
|
|
12825
|
-
siteName: invite.metadata?.siteName ?? "the site"
|
|
12856
|
+
siteName: invite.metadata?.siteName ?? "the site",
|
|
12857
|
+
invitationId: invite._id?.toString(),
|
|
12858
|
+
siteId: invite.metadata?.siteId?.toString?.()
|
|
12826
12859
|
});
|
|
12827
12860
|
} catch (error) {
|
|
12828
12861
|
logger22.log({
|
|
@@ -17350,6 +17383,12 @@ var schemaUpdateSiteCamera = Joi23.object({
|
|
|
17350
17383
|
status: Joi23.string().optional().valid("active", "inactive", "deleted"),
|
|
17351
17384
|
name: Joi23.string().optional().allow(null, "")
|
|
17352
17385
|
});
|
|
17386
|
+
function keepStoredPassword(value) {
|
|
17387
|
+
if (value && typeof value === "object" && !String(value.password ?? "").trim()) {
|
|
17388
|
+
delete value.password;
|
|
17389
|
+
}
|
|
17390
|
+
return value;
|
|
17391
|
+
}
|
|
17353
17392
|
var schemaSiteCamera = Joi23.object({
|
|
17354
17393
|
_id: Joi23.string().hex().optional(),
|
|
17355
17394
|
site: Joi23.string().hex().required(),
|
|
@@ -21681,13 +21720,13 @@ function useDahuaService() {
|
|
|
21681
21720
|
cameraRegistry.get(cameraId)?.abort();
|
|
21682
21721
|
cameraRegistry.delete(cameraId);
|
|
21683
21722
|
}
|
|
21684
|
-
const controller = new AbortController();
|
|
21685
|
-
cameraRegistry.set(cameraId, controller);
|
|
21686
21723
|
const onDetectedHandler = onDetected || _savedOnDetected;
|
|
21687
21724
|
if (!onDetectedHandler) {
|
|
21688
21725
|
loggerDahua.error(`No plate detection handler registered for camera ${cameraId}`);
|
|
21689
21726
|
return;
|
|
21690
21727
|
}
|
|
21728
|
+
const controller = new AbortController();
|
|
21729
|
+
cameraRegistry.set(cameraId, controller);
|
|
21691
21730
|
camera.site = camera?.site?.toString();
|
|
21692
21731
|
getTrafficJunction(
|
|
21693
21732
|
camera,
|
|
@@ -22316,9 +22355,17 @@ function useDahuaService() {
|
|
|
22316
22355
|
return anprRevokeThrew(error2);
|
|
22317
22356
|
}
|
|
22318
22357
|
}
|
|
22358
|
+
function setPlateHandler(onDetected) {
|
|
22359
|
+
_savedOnDetected = onDetected;
|
|
22360
|
+
}
|
|
22361
|
+
function isListening(cameraId) {
|
|
22362
|
+
return cameraRegistry.has(String(cameraId));
|
|
22363
|
+
}
|
|
22319
22364
|
return {
|
|
22320
22365
|
getSnapshot,
|
|
22321
22366
|
listenToCamera,
|
|
22367
|
+
setPlateHandler,
|
|
22368
|
+
isListening,
|
|
22322
22369
|
addPlateNumber,
|
|
22323
22370
|
removePlateNumber,
|
|
22324
22371
|
clearPlateList,
|
|
@@ -22673,6 +22720,7 @@ function useSiteCameraRepo() {
|
|
|
22673
22720
|
}
|
|
22674
22721
|
}
|
|
22675
22722
|
async function updateById(_id, value, session) {
|
|
22723
|
+
keepStoredPassword(value);
|
|
22676
22724
|
const { error } = schemaUpdateSiteCamera.validate(value);
|
|
22677
22725
|
if (error) {
|
|
22678
22726
|
logger37.info(`Site Camera Management: ${error.message}`);
|
|
@@ -37054,7 +37102,7 @@ function useSiteService() {
|
|
|
37054
37102
|
const guardPosts = siteData?.metadata?.guardPosts ?? 0;
|
|
37055
37103
|
if (guardPost < guardPosts) {
|
|
37056
37104
|
const siteCamera = await getBySiteGuardPost(site, guardPost);
|
|
37057
|
-
logger69.info("siteCamera: " +
|
|
37105
|
+
logger69.info("siteCamera: " + String(siteCamera?._id ?? "none"));
|
|
37058
37106
|
if (siteCamera) {
|
|
37059
37107
|
throw new BadRequestError94(
|
|
37060
37108
|
`Failed to update guard post, an ANPR camera is assigned to guard post 1-${siteData?.metadata?.guardPosts}.`
|
|
@@ -41523,6 +41571,8 @@ function useSiteCameraService() {
|
|
|
41523
41571
|
}
|
|
41524
41572
|
}
|
|
41525
41573
|
async function listenToCapturedPlateNumber(onDetected) {
|
|
41574
|
+
if (onDetected)
|
|
41575
|
+
dahuaService.setPlateHandler(onDetected);
|
|
41526
41576
|
const siteCameras = [];
|
|
41527
41577
|
let page = 1;
|
|
41528
41578
|
let pages = 1;
|
|
@@ -42066,7 +42116,7 @@ function useSiteCameraController() {
|
|
|
42066
42116
|
delete req.body.confirmClearCameraLists;
|
|
42067
42117
|
delete req.body.skipPlateSync;
|
|
42068
42118
|
}
|
|
42069
|
-
const value = req.body;
|
|
42119
|
+
const value = keepStoredPassword(req.body ?? {});
|
|
42070
42120
|
const id = req.params.id ?? "";
|
|
42071
42121
|
const refusal = applyDerivedHost(value);
|
|
42072
42122
|
if (refusal) {
|
|
@@ -42112,6 +42162,7 @@ function useSiteCameraController() {
|
|
|
42112
42162
|
let filled = null;
|
|
42113
42163
|
if (fill.allow || fill.block) {
|
|
42114
42164
|
await _clearPlateLists(camera.site, id, fill);
|
|
42165
|
+
const password = update?.password ?? (await _findOne({ _id: new ObjectId84(id) }, { password: 1 }))?.password;
|
|
42115
42166
|
try {
|
|
42116
42167
|
filled = await useVehicleService().fillCameraLists(
|
|
42117
42168
|
camera.site,
|
|
@@ -42119,7 +42170,7 @@ function useSiteCameraController() {
|
|
|
42119
42170
|
id,
|
|
42120
42171
|
host: update?.host,
|
|
42121
42172
|
username: update?.username,
|
|
42122
|
-
password
|
|
42173
|
+
password
|
|
42123
42174
|
},
|
|
42124
42175
|
fill
|
|
42125
42176
|
);
|
|
@@ -98992,6 +99043,7 @@ export {
|
|
|
98992
99043
|
isTermsCurrent,
|
|
98993
99044
|
isTrackingStale,
|
|
98994
99045
|
isValidTimezone,
|
|
99046
|
+
keepStoredPassword,
|
|
98995
99047
|
levelPixelToMetres,
|
|
98996
99048
|
levelScale,
|
|
98997
99049
|
levelSolids,
|
|
@@ -99023,6 +99075,7 @@ export {
|
|
|
99023
99075
|
notificationCategory,
|
|
99024
99076
|
notificationCategoryLabel,
|
|
99025
99077
|
notificationEvents,
|
|
99078
|
+
notificationKind,
|
|
99026
99079
|
notificationRoom,
|
|
99027
99080
|
notifyAccessMode,
|
|
99028
99081
|
notifyRobotFault,
|
|
@@ -99547,6 +99600,7 @@ export {
|
|
|
99547
99600
|
wallsFromOccupancyGrid,
|
|
99548
99601
|
waypointsFor,
|
|
99549
99602
|
withLiveLink,
|
|
99603
|
+
withNotificationKind,
|
|
99550
99604
|
workOrderSchema,
|
|
99551
99605
|
work_orders2_namespace_collection,
|
|
99552
99606
|
work_orders_namespace_collection
|