@dative-gpi/foundation-shared-domain 1.0.157-notif-update-v2 → 1.0.158-maps2

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,18 +48,15 @@ export class NotificationInfos {
45
48
  if (![Criticity.None, n.criticity].includes(criticity)) {
46
49
  return false;
47
50
  }
48
-
49
- let showNotification = false;
50
- for (const a of n.audiences) {
51
- switch (a.targetScope) {
52
- case Scope.Organisation:
53
- case Scope.UserOrganisation: showNotification = showNotification || (organisationId && n.organisationId && n.organisationId === organisationId) as boolean;
54
- case Scope.User: showNotification = showNotification || (userId && a.targetId === userId) as boolean;
55
- case Scope.Application:
56
- case Scope.Public: showNotification = showNotification || application as boolean;
57
- }
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
58
  }
59
- return showNotification;
59
+ return false;
60
60
  });
61
61
 
62
62
  static getForDrawer = (
@@ -78,8 +78,10 @@ export interface NotificationInfosDTO {
78
78
  title: string;
79
79
  body: string;
80
80
  pageUrl: string;
81
- audiences: NotificationAudience[];
81
+ audienceId: string;
82
+ audienceScope: number;
82
83
  organisationId?: string;
84
+ entityId?: string;
83
85
  type: number;
84
86
  criticity: number;
85
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.157-notif-update-v2",
4
+ "version": "1.0.158-maps2",
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": "d2fe03e1334c0c0bf4e1d31fee0132c07c8ccf35"
15
+ "gitHead": "99a7e7aebf7e4bb0687672dfb8f7cc6a54ba923a"
16
16
  }
@@ -1,23 +0,0 @@
1
- import type { Scope } from "../../enums";
2
-
3
- export class NotificationAudience {
4
- id: string;
5
- notificationId: string;
6
- targetId: string;
7
- targetScope: Scope;
8
-
9
-
10
- constructor(params: NotificationAudienceDTO) {
11
- this.id = params.id;
12
- this.notificationId = params.notificationId;
13
- this.targetId = params.targetId;
14
- this.targetScope = params.targetScope as Scope;
15
- }
16
- }
17
-
18
- export interface NotificationAudienceDTO {
19
- id: string;
20
- notificationId: string;
21
- targetId: string;
22
- targetScope: number;
23
- }