@dative-gpi/foundation-shared-domain 1.0.159 → 1.0.161-alert-tile

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,6 +2,7 @@ export enum Scope {
2
2
  None = 0,
3
3
  Public = 0b1111,
4
4
  Application = 0b1000,
5
+ OrganisationType = 0b10000,
5
6
  Organisation = 0b0100,
6
7
  User = 0b0010,
7
8
  UserOrganisation = 0b0001
package/enums/index.ts CHANGED
@@ -13,6 +13,7 @@ export * from "./filters";
13
13
  export * from "./index";
14
14
  export * from "./lists";
15
15
  export * from "./messages";
16
+ export * from "./playlists";
16
17
  export * from "./roles";
17
18
  export * from "./times";
18
19
  export * from "./users";
@@ -0,0 +1,5 @@
1
+ export enum VisualisationMode {
2
+ None = 0,
3
+ Simple = 1,
4
+ Presentation = 2
5
+ }
@@ -1,2 +1,3 @@
1
+ export * from "./notificationAudience";
1
2
  export * from "./notificationDetails";
2
3
  export * from "./notificationInfos";
@@ -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
+ }
@@ -1,17 +1,15 @@
1
1
  import { type MessageType } from "../../enums/messages";
2
2
  import { isoToEpoch } from "../../tools/datesTools";
3
- import { Scope } from "../../enums/applications";
4
- import { Criticity } from "../../enums/alerts";
3
+ import type { Criticity } from "../../enums/alerts";
4
+ import { NotificationAudience } from "./notificationAudience";
5
5
 
6
6
  export class NotificationInfos {
7
7
  id: string;
8
8
  title: string;
9
9
  body: string;
10
10
  pageUrl: string;
11
- audienceId: string;
12
- audienceScope: Scope;
11
+ audiences: NotificationAudience[];
13
12
  organisationId?: string;
14
- entityId?: string;
15
13
  type: MessageType;
16
14
  criticity: Criticity;
17
15
  timestamp: number;
@@ -23,10 +21,8 @@ export class NotificationInfos {
23
21
  this.title = params.title;
24
22
  this.body = params.body;
25
23
  this.pageUrl = params.pageUrl;
26
- this.audienceId = params.audienceId;
27
- this.audienceScope = params.audienceScope as Scope;
24
+ this.audiences = params.audiences.map((a: NotificationAudience) => new NotificationAudience(a));
28
25
  this.organisationId = params.organisationId;
29
- this.entityId = params.entityId;
30
26
  this.type = params.type as MessageType;
31
27
  this.criticity = params.criticity as Criticity;
32
28
  this.timestamp = isoToEpoch(params.timestamp);
@@ -34,43 +30,6 @@ export class NotificationInfos {
34
30
  this.acknowledgingTimestamp = params.acknowledgingTimestamp ?
35
31
  isoToEpoch(params.acknowledgingTimestamp) : null;
36
32
  }
37
-
38
- static getFromAudience = (
39
- notifications: NotificationInfos[],
40
- application: boolean,
41
- criticity: Criticity,
42
- organisationId?: string | null,
43
- userId?: string | null,
44
- ): NotificationInfos[] => notifications.filter((n: NotificationInfos) => {
45
- if (n.acknowledged) {
46
- return false;
47
- }
48
- if (![Criticity.None, n.criticity].includes(criticity)) {
49
- return false;
50
- }
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;
60
- });
61
-
62
- static getForDrawer = (
63
- notifications: NotificationInfos[],
64
- organisationId: string,
65
- userId: string,
66
- criticity: Criticity = Criticity.None
67
- ): NotificationInfos[] => NotificationInfos.getFromAudience(notifications, true, criticity, organisationId, userId);
68
-
69
- static getForCard = (
70
- notifications: NotificationInfos[],
71
- organisationId: string,
72
- criticity: Criticity = Criticity.None
73
- ): NotificationInfos[] => NotificationInfos.getFromAudience(notifications, false, criticity, organisationId, null);
74
33
  }
75
34
 
76
35
  export interface NotificationInfosDTO {
@@ -78,10 +37,8 @@ export interface NotificationInfosDTO {
78
37
  title: string;
79
38
  body: string;
80
39
  pageUrl: string;
81
- audienceId: string;
82
- audienceScope: number;
40
+ audiences: NotificationAudience[];
83
41
  organisationId?: string;
84
- entityId?: string;
85
42
  type: number;
86
43
  criticity: number;
87
44
  timestamp: string;
@@ -6,21 +6,19 @@ import type { DashboardType } from "../../enums/dashboards";
6
6
 
7
7
  export class OrganisationDetails extends OrganisationInfos {
8
8
  code: string;
9
- organisationTypeId: string;
10
9
  mainDashboardId: string | null;
11
10
  mainDashboardType: DashboardType;
12
11
  description: string;
13
12
  locationsCount: number;
14
13
  groupsCount: number;
15
14
  deviceOrganisationsCount: number;
16
- alertsCount : number;
15
+ alertsCount: number;
17
16
  permissions: PermissionInfos[];
18
17
 
19
18
  constructor(params: OrganisationDetailsDTO) {
20
19
  super(params);
21
20
 
22
21
  this.code = params.code;
23
- this.organisationTypeId = params.organisationTypeId;
24
22
  this.mainDashboardType = params.mainDashboardType;
25
23
  this.mainDashboardId = params.mainDashboardId;
26
24
  this.description = params.description;
@@ -34,14 +32,13 @@ export class OrganisationDetails extends OrganisationInfos {
34
32
 
35
33
  export interface OrganisationDetailsDTO extends OrganisationInfosDTO {
36
34
  code: string;
37
- organisationTypeId: string;
38
35
  mainDashboardId: string | null;
39
36
  mainDashboardType: DashboardType;
40
37
  description: string;
41
38
  locationsCount: number;
42
39
  groupsCount: number;
43
40
  deviceOrganisationsCount: number;
44
- alertsCount : number;
41
+ alertsCount: number;
45
42
  permissions: PermissionInfosDTO[];
46
43
  }
47
44
 
@@ -1,5 +1,6 @@
1
1
  export class OrganisationInfos {
2
2
  id: string;
3
+ organisationTypeId: string;
3
4
  imageId: string | null;
4
5
  label: string;
5
6
  userOrganisationsCount: number;
@@ -8,6 +9,7 @@ export class OrganisationInfos {
8
9
 
9
10
  constructor(params: OrganisationInfosDTO) {
10
11
  this.id = params.id;
12
+ this.organisationTypeId = params.organisationTypeId;
11
13
  this.imageId = params.imageId;
12
14
  this.label = params.label;
13
15
  this.userOrganisationsCount = params.userOrganisationsCount;
@@ -18,6 +20,7 @@ export class OrganisationInfos {
18
20
 
19
21
  export interface OrganisationInfosDTO {
20
22
  id: string;
23
+ organisationTypeId: string;
21
24
  imageId: string | null;
22
25
  label: string;
23
26
  userOrganisationsCount: number;
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",
4
+ "version": "1.0.161-alert-tile",
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": "6dc1450ba15bca7f6d032595ee08eb51eedca25b"
15
+ "gitHead": "21e74ffda11147c0413a3424fe0df561560bcab3"
16
16
  }