@dative-gpi/foundation-shared-domain 1.0.158 → 1.0.159-notification
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/enums/applications.ts
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Scope } from "../../enums";
|
|
2
|
+
|
|
3
|
+
export class NotificationAudience {
|
|
4
|
+
id: string;
|
|
5
|
+
targetId: string;
|
|
6
|
+
targetScope: Scope;
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
constructor(params: NotificationAudienceDTO) {
|
|
10
|
+
this.id = params.id;
|
|
11
|
+
this.targetId = params.targetId;
|
|
12
|
+
this.targetScope = params.targetScope as Scope;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface NotificationAudienceDTO {
|
|
17
|
+
id: string;
|
|
18
|
+
targetId: string;
|
|
19
|
+
targetScope: number;
|
|
20
|
+
}
|
|
@@ -2,16 +2,15 @@ import { type MessageType } from "../../enums/messages";
|
|
|
2
2
|
import { isoToEpoch } from "../../tools/datesTools";
|
|
3
3
|
import { Scope } from "../../enums/applications";
|
|
4
4
|
import { Criticity } from "../../enums/alerts";
|
|
5
|
+
import { NotificationAudience } from "./notificationAudience";
|
|
5
6
|
|
|
6
7
|
export class NotificationInfos {
|
|
7
8
|
id: string;
|
|
8
9
|
title: string;
|
|
9
10
|
body: string;
|
|
10
11
|
pageUrl: string;
|
|
11
|
-
|
|
12
|
-
audienceScope: Scope;
|
|
12
|
+
audiences: NotificationAudience[];
|
|
13
13
|
organisationId?: string;
|
|
14
|
-
entityId?: string;
|
|
15
14
|
type: MessageType;
|
|
16
15
|
criticity: Criticity;
|
|
17
16
|
timestamp: number;
|
|
@@ -23,10 +22,8 @@ export class NotificationInfos {
|
|
|
23
22
|
this.title = params.title;
|
|
24
23
|
this.body = params.body;
|
|
25
24
|
this.pageUrl = params.pageUrl;
|
|
26
|
-
this.
|
|
27
|
-
this.audienceScope = params.audienceScope as Scope;
|
|
25
|
+
this.audiences = params.audiences.map((a: NotificationAudience) => new NotificationAudience(a));
|
|
28
26
|
this.organisationId = params.organisationId;
|
|
29
|
-
this.entityId = params.entityId;
|
|
30
27
|
this.type = params.type as MessageType;
|
|
31
28
|
this.criticity = params.criticity as Criticity;
|
|
32
29
|
this.timestamp = isoToEpoch(params.timestamp);
|
|
@@ -40,7 +37,7 @@ export class NotificationInfos {
|
|
|
40
37
|
application: boolean,
|
|
41
38
|
criticity: Criticity,
|
|
42
39
|
organisationId?: string | null,
|
|
43
|
-
userId?: string | null
|
|
40
|
+
userId?: string | null
|
|
44
41
|
): NotificationInfos[] => notifications.filter((n: NotificationInfos) => {
|
|
45
42
|
if (n.acknowledged) {
|
|
46
43
|
return false;
|
|
@@ -48,15 +45,22 @@ export class NotificationInfos {
|
|
|
48
45
|
if (![Criticity.None, n.criticity].includes(criticity)) {
|
|
49
46
|
return false;
|
|
50
47
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
48
|
+
|
|
49
|
+
return n.audiences.some(a => {
|
|
50
|
+
switch (a.targetScope) {
|
|
51
|
+
case Scope.OrganisationType:
|
|
52
|
+
case Scope.Organisation:
|
|
53
|
+
case Scope.UserOrganisation:
|
|
54
|
+
return Boolean(organisationId && n.organisationId && n.organisationId === organisationId);
|
|
55
|
+
case Scope.User:
|
|
56
|
+
return Boolean(userId && a.targetId === userId);
|
|
57
|
+
case Scope.Application:
|
|
58
|
+
case Scope.Public:
|
|
59
|
+
return Boolean(application);
|
|
60
|
+
default:
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
60
64
|
});
|
|
61
65
|
|
|
62
66
|
static getForDrawer = (
|
|
@@ -78,10 +82,8 @@ export interface NotificationInfosDTO {
|
|
|
78
82
|
title: string;
|
|
79
83
|
body: string;
|
|
80
84
|
pageUrl: string;
|
|
81
|
-
|
|
82
|
-
audienceScope: number;
|
|
85
|
+
audiences: NotificationAudience[];
|
|
83
86
|
organisationId?: string;
|
|
84
|
-
entityId?: string;
|
|
85
87
|
type: number;
|
|
86
88
|
criticity: number;
|
|
87
89
|
timestamp: string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dative-gpi/foundation-shared-domain",
|
|
3
3
|
"sideEffects": false,
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.159-notification",
|
|
5
5
|
"description": "",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -12,5 +12,5 @@
|
|
|
12
12
|
"peerDependencies": {
|
|
13
13
|
"date-fns": "^3.6.0"
|
|
14
14
|
},
|
|
15
|
-
"gitHead": "
|
|
15
|
+
"gitHead": "bd9f45c4be8554c7778b5388f3d60d25c9244054"
|
|
16
16
|
}
|