@dative-gpi/foundation-shared-domain 1.0.127 → 1.0.128-fix-mobile

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.
@@ -1,7 +1,5 @@
1
- import type { LanguageInfosDTO } from "../languages/languageInfos";
2
- import { LanguageInfos } from "../languages/languageInfos";
3
- import type { ApplicationInfosDTO } from "./applicationInfos";
4
- import { ApplicationInfos } from "./applicationInfos";
1
+ import { LanguageInfos, type LanguageInfosDTO } from "../languages/languageInfos";
2
+ import { ApplicationInfos, type ApplicationInfosDTO } from "./applicationInfos";
5
3
 
6
4
  export class ApplicationDetails extends ApplicationInfos {
7
5
  languages: LanguageInfos[];
@@ -1,4 +1,4 @@
1
- import { isoToEpoch } from "../../tools";
1
+ import { isoToEpoch } from "../../tools/datesTools";
2
2
 
3
3
  export class AuthTokenInfos {
4
4
  id: string;
@@ -1,7 +1,6 @@
1
1
  import { ImageInfos, type ImageInfosDTO } from "./imageInfos";
2
2
 
3
3
  export class ImageDetails extends ImageInfos {
4
-
5
4
  constructor(params: ImageDetailsDTO) {
6
5
  super(params);
7
6
  }
@@ -1,5 +1,4 @@
1
- import type { LanguageInfosDTO } from "./languageInfos";
2
- import { LanguageInfos } from "./languageInfos";
1
+ import { LanguageInfos, type LanguageInfosDTO } from "./languageInfos";
3
2
 
4
3
  export class LanguageDetails extends LanguageInfos {
5
4
  constructor(params: LanguageDetailsDTO) {
@@ -1,5 +1,7 @@
1
- import { type Criticity, type MessageType, type Scope } from "@dative-gpi/foundation-shared-domain/enums";
2
- import { isoToEpoch } from "@dative-gpi/foundation-shared-domain/tools";
1
+ import { type MessageType } from "../../enums/messages";
2
+ import { isoToEpoch } from "../../tools/datesTools";
3
+ import { Scope } from "../../enums/applications";
4
+ import { Criticity } from "../../enums/alerts";
3
5
 
4
6
  export class NotificationInfos {
5
7
  id: string;
@@ -32,6 +34,43 @@ export class NotificationInfos {
32
34
  this.acknowledgingTimestamp = params.acknowledgingTimestamp ?
33
35
  isoToEpoch(params.acknowledgingTimestamp) : null;
34
36
  }
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);
35
74
  }
36
75
 
37
76
  export interface NotificationInfosDTO {
@@ -1,6 +1,5 @@
1
- import type { OrganisationTypeInfosDTO } from "./organisationTypeInfos";
2
- import { OrganisationTypeInfos } from "./organisationTypeInfos";
3
- import type { DashboardType } from "../../enums/dashboards";
1
+ import { OrganisationTypeInfos, type OrganisationTypeInfosDTO } from "./organisationTypeInfos";
2
+ import { type DashboardType } from "../../enums/dashboards";
4
3
 
5
4
  export class OrganisationTypeDetails extends OrganisationTypeInfos {
6
5
  description: string;
@@ -1,8 +1,6 @@
1
- import type { PermissionInfosDTO } from "../permissions/permissionInfos";
2
- import { PermissionInfos } from "../permissions/permissionInfos";
3
- import type { OrganisationInfosDTO } from "./organisationInfos";
4
- import { OrganisationInfos } from "./organisationInfos";
5
- import type { DashboardType } from "../../enums/dashboards";
1
+ import { PermissionInfos, type PermissionInfosDTO } from "../permissions/permissionInfos";
2
+ import { OrganisationInfos, type OrganisationInfosDTO } from "./organisationInfos";
3
+ import { type DashboardType } from "../../enums/dashboards";
6
4
 
7
5
  export class OrganisationDetails extends OrganisationInfos {
8
6
  code: string;
@@ -1,5 +1,4 @@
1
- import type { PermissionInfosDTO } from "./permissionInfos";
2
- import { PermissionInfos } from "./permissionInfos";
1
+ import { PermissionInfos, type PermissionInfosDTO } from "./permissionInfos";
3
2
 
4
3
  export class PermissionDetails extends PermissionInfos {
5
4
  constructor(params: PermissionDetailsDTO) {
@@ -1,4 +1,4 @@
1
- import { isoToEpoch } from "../../tools";
1
+ import { isoToEpoch } from "../../tools/datesTools";
2
2
 
3
3
  export class TerminalInfos {
4
4
  id: string;
@@ -1,5 +1,4 @@
1
- import type { TimeZoneInfosDTO } from "./timeZoneInfos";
2
- import { TimeZoneInfos } from "./timeZoneInfos";
1
+ import { TimeZoneInfos, type TimeZoneInfosDTO } from "./timeZoneInfos";
3
2
 
4
3
  export class TimeZoneDetails extends TimeZoneInfos {
5
4
  constructor(params: TimeZoneDetailsDTO) {
@@ -1,5 +1,4 @@
1
- import type { TranslationInfosDTO } from "./translationInfos";
2
- import { TranslationInfos } from "./translationInfos";
1
+ import { TranslationInfos, type TranslationInfosDTO } from "./translationInfos";
3
2
 
4
3
  export class TranslationDetails extends TranslationInfos {
5
4
  constructor(params: TranslationDetailsDTO) {
@@ -1,5 +1,4 @@
1
- import type { UserInfosDTO } from "./userInfos";
2
- import { UserInfos } from "./userInfos";
1
+ import { UserInfos, type UserInfosDTO } from "./userInfos";
3
2
 
4
3
  export class UserDetails extends UserInfos {
5
4
  adminAccess: boolean;
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.127",
4
+ "version": "1.0.128-fix-mobile",
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": "b0ad78457ad86632d841709d3fc3951a8e44c667"
15
+ "gitHead": "099789bb7c9a4134f9ee0aba08d805b673cbb977"
16
16
  }
package/tools/index.ts CHANGED
@@ -1,6 +1,4 @@
1
1
  export * from "./autoRefresh";
2
2
  export * from "./datesTools";
3
- export * from "./deviceExplorerElements";
4
3
  export * from "./enumTools";
5
- export * from "./notificationsTools";
6
4
  export * from "./single";
@@ -1,34 +0,0 @@
1
- import { type DeviceExplorerElementInfos, type DeviceOrganisationInfos, type GroupInfos } from "@dative-gpi/foundation-core-domain/models";
2
-
3
- import { DeviceExplorerElementType } from "../enums";
4
-
5
- export const fromDeviceOrganisation = (deviceOrganisation: DeviceOrganisationInfos): DeviceExplorerElementInfos => ({
6
- ...deviceOrganisation,
7
- type: DeviceExplorerElementType.DeviceOrganisation,
8
- parentId: deviceOrganisation.groupId,
9
- icon: null,
10
- groupsIds: null,
11
- deviceOrganisationsIds: null,
12
- modelsIds: null,
13
- recursiveGroupsIds: null,
14
- recursiveDeviceOrganisationsIds: null,
15
- recursiveModelsIds: null
16
- });
17
-
18
- export const fromGroup = (group: GroupInfos): DeviceExplorerElementInfos => ({
19
- ...group,
20
- type: DeviceExplorerElementType.Group,
21
- manufacturerLabel: null,
22
- articleLabel: null,
23
- modelLabel: null,
24
- ownerLabel: null,
25
- managerName: null,
26
- unrestricted: null,
27
- online: null,
28
- meta: null,
29
- modelStatuses: null,
30
- status: null,
31
- connectivity: null,
32
- alerts: null,
33
- worstAlert: null
34
- });
@@ -1,39 +0,0 @@
1
- import { type NotificationInfos } from "../models";
2
- import { Criticity, Scope } from "../enums";
3
-
4
- export const getFromAudience = (
5
- notifications: NotificationInfos[],
6
- application: boolean,
7
- criticity: Criticity,
8
- organisationId?: string | null,
9
- userId?: string | null,
10
- ): NotificationInfos[] => notifications.filter((n: NotificationInfos) => {
11
- if (n.acknowledged) {
12
- return false;
13
- }
14
- if (![Criticity.None, n.criticity].includes(criticity)) {
15
- return false;
16
- }
17
- switch (n.audienceScope) {
18
- case Scope.Organisation :
19
- case Scope.UserOrganisation: return organisationId && n.organisationId && n.organisationId === organisationId;
20
- case Scope.User : return userId && n.audienceId === userId;
21
- case Scope.Application :
22
- case Scope.Public : return application;
23
-
24
- }
25
- return false;
26
- });
27
-
28
- export const getForDrawer = (
29
- notifications: NotificationInfos[],
30
- organisationId: string,
31
- userId: string,
32
- criticity: Criticity = Criticity.None
33
- ): NotificationInfos[] => getFromAudience(notifications, true, criticity, organisationId, userId);
34
-
35
- export const getForCard = (
36
- notifications: NotificationInfos[],
37
- organisationId: string,
38
- criticity: Criticity = Criticity.None
39
- ): NotificationInfos[] => getFromAudience(notifications, false, criticity, organisationId, null);