@dative-gpi/foundation-shared-domain 1.0.159-notification → 1.0.159-sankey

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.
@@ -2,7 +2,6 @@ export enum Scope {
2
2
  None = 0,
3
3
  Public = 0b1111,
4
4
  Application = 0b1000,
5
- OrganisationType = 0b10000,
6
5
  Organisation = 0b0100,
7
6
  User = 0b0010,
8
7
  UserOrganisation = 0b0001
@@ -1,3 +1,2 @@
1
- export * from "./notificationAudience";
2
1
  export * from "./notificationDetails";
3
2
  export * from "./notificationInfos";
@@ -2,15 +2,16 @@ 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";
6
5
 
7
6
  export class NotificationInfos {
8
7
  id: string;
9
8
  title: string;
10
9
  body: string;
11
10
  pageUrl: string;
12
- audiences: NotificationAudience[];
11
+ audienceId: string;
12
+ audienceScope: Scope;
13
13
  organisationId?: string;
14
+ entityId?: string;
14
15
  type: MessageType;
15
16
  criticity: Criticity;
16
17
  timestamp: number;
@@ -22,8 +23,10 @@ export class NotificationInfos {
22
23
  this.title = params.title;
23
24
  this.body = params.body;
24
25
  this.pageUrl = params.pageUrl;
25
- this.audiences = params.audiences.map((a: NotificationAudience) => new NotificationAudience(a));
26
+ this.audienceId = params.audienceId;
27
+ this.audienceScope = params.audienceScope as Scope;
26
28
  this.organisationId = params.organisationId;
29
+ this.entityId = params.entityId;
27
30
  this.type = params.type as MessageType;
28
31
  this.criticity = params.criticity as Criticity;
29
32
  this.timestamp = isoToEpoch(params.timestamp);
@@ -37,7 +40,7 @@ export class NotificationInfos {
37
40
  application: boolean,
38
41
  criticity: Criticity,
39
42
  organisationId?: string | null,
40
- userId?: string | null
43
+ userId?: string | null,
41
44
  ): NotificationInfos[] => notifications.filter((n: NotificationInfos) => {
42
45
  if (n.acknowledged) {
43
46
  return false;
@@ -45,22 +48,15 @@ export class NotificationInfos {
45
48
  if (![Criticity.None, n.criticity].includes(criticity)) {
46
49
  return false;
47
50
  }
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
- });
51
+ switch (n.audienceScope) {
52
+ case Scope.Organisation :
53
+ case Scope.UserOrganisation: return organisationId && n.organisationId && n.organisationId === organisationId;
54
+ case Scope.User : return userId && n.audienceId === userId;
55
+ case Scope.Application :
56
+ case Scope.Public : return application;
57
+
58
+ }
59
+ return false;
64
60
  });
65
61
 
66
62
  static getForDrawer = (
@@ -82,8 +78,10 @@ export interface NotificationInfosDTO {
82
78
  title: string;
83
79
  body: string;
84
80
  pageUrl: string;
85
- audiences: NotificationAudience[];
81
+ audienceId: string;
82
+ audienceScope: number;
86
83
  organisationId?: string;
84
+ entityId?: string;
87
85
  type: number;
88
86
  criticity: number;
89
87
  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.159-notification",
4
+ "version": "1.0.159-sankey",
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": "bd9f45c4be8554c7778b5388f3d60d25c9244054"
15
+ "gitHead": "2e082499c169cb28d4480d2fb76993f1240d9c87"
16
16
  }
@@ -1,20 +0,0 @@
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
- }