@7365admin1/core 3.100.1 → 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 +6 -0
- package/dist/index.d.ts +13 -1
- package/dist/index.js +42 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/test/notification-kind.test.mjs +70 -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({
|
|
@@ -99042,6 +99075,7 @@ export {
|
|
|
99042
99075
|
notificationCategory,
|
|
99043
99076
|
notificationCategoryLabel,
|
|
99044
99077
|
notificationEvents,
|
|
99078
|
+
notificationKind,
|
|
99045
99079
|
notificationRoom,
|
|
99046
99080
|
notifyAccessMode,
|
|
99047
99081
|
notifyRobotFault,
|
|
@@ -99566,6 +99600,7 @@ export {
|
|
|
99566
99600
|
wallsFromOccupancyGrid,
|
|
99567
99601
|
waypointsFor,
|
|
99568
99602
|
withLiveLink,
|
|
99603
|
+
withNotificationKind,
|
|
99569
99604
|
workOrderSchema,
|
|
99570
99605
|
work_orders2_namespace_collection,
|
|
99571
99606
|
work_orders_namespace_collection
|