@dative-gpi/foundation-shared-domain 0.0.230 → 0.1.68
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/actions.ts +6 -0
- package/enums/agendas.ts +6 -0
- package/enums/applications.ts +25 -0
- package/enums/charts.ts +115 -0
- package/enums/customProperties.ts +12 -0
- package/{models/enums/dashboardEnums.ts → enums/dashboards.ts} +4 -3
- package/enums/datas.ts +7 -0
- package/{models/enums/dateEnums.ts → enums/dates.ts} +17 -0
- package/enums/filters.ts +12 -0
- package/enums/index.ts +17 -0
- package/enums/lists.ts +4 -0
- package/enums/messages.ts +16 -0
- package/enums/roles.ts +7 -0
- package/enums/times.ts +11 -0
- package/enums/users.ts +14 -0
- package/models/authTokens/authTokenInfos.ts +3 -3
- package/models/images/imageDetails.ts +11 -0
- package/models/images/{blurHash.ts → imageInfos.ts} +3 -3
- package/models/images/index.ts +2 -1
- package/models/index.ts +3 -3
- package/models/notifications/index.ts +2 -0
- package/models/notifications/notificationDetails.ts +10 -0
- package/models/notifications/notificationInfos.ts +56 -0
- package/models/organisationTypes/organisationTypeDetails.ts +1 -1
- package/models/organisationTypes/organisationTypeInfos.ts +1 -1
- package/models/organisations/organisationDetails.ts +1 -1
- package/models/terminals/terminalInfos.ts +2 -2
- package/models/users/userDetails.ts +0 -3
- package/package.json +2 -2
- package/tools/autoRefresh.ts +22 -0
- package/tools/datesTools.ts +54 -12
- package/tools/index.ts +3 -1
- package/tools/notificationsTools.ts +39 -0
- package/models/enums/applicationEnums.ts +0 -5
- package/models/enums/index.ts +0 -5
- /package/{models/enums/alertEnums.ts → enums/alerts.ts} +0 -0
- /package/{models/enums/deviceEnums.ts → enums/connectivities.ts} +0 -0
package/enums/actions.ts
ADDED
package/enums/agendas.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export enum Scope {
|
|
2
|
+
None = 0,
|
|
3
|
+
Public = 0b1111,
|
|
4
|
+
Application = 0b1000,
|
|
5
|
+
Organisation = 0b0100,
|
|
6
|
+
User = 0b0010,
|
|
7
|
+
UserOrganisation = 0b0001
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export enum ApplicationScope {
|
|
11
|
+
None = 0,
|
|
12
|
+
OrganisationType = 1,
|
|
13
|
+
Organisation = 2
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export enum EntityType {
|
|
17
|
+
None = 0,
|
|
18
|
+
Model = 1,
|
|
19
|
+
Group = 2,
|
|
20
|
+
Location = 3,
|
|
21
|
+
Device = 5,
|
|
22
|
+
User = 6,
|
|
23
|
+
Dashboard = 7,
|
|
24
|
+
Folder = 8
|
|
25
|
+
}
|
package/enums/charts.ts
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
export enum ChartOrigin {
|
|
2
|
+
None = 0,
|
|
3
|
+
Organisation = 1,
|
|
4
|
+
OrganisationType = 2
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export enum ChartType {
|
|
8
|
+
None = 0,
|
|
9
|
+
XY = 1,
|
|
10
|
+
Pie = 2,
|
|
11
|
+
Heatmap = 3,
|
|
12
|
+
Slider = 4,
|
|
13
|
+
Gauge = 5,
|
|
14
|
+
ScoreCard = 6,
|
|
15
|
+
Table = 7
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export enum ColorSets {
|
|
19
|
+
Default = 0,
|
|
20
|
+
Grafana = 1,
|
|
21
|
+
Kelly = 2,
|
|
22
|
+
Armytage = 3,
|
|
23
|
+
ZeileisHornikMurrell = 4,
|
|
24
|
+
Hash = 5
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export enum AxisType {
|
|
28
|
+
None = 0,
|
|
29
|
+
Date = 1,
|
|
30
|
+
Value = 2,
|
|
31
|
+
Category = 3
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export enum SerieType {
|
|
35
|
+
None = 0,
|
|
36
|
+
Lines = 1,
|
|
37
|
+
Area = 2,
|
|
38
|
+
Range = 3,
|
|
39
|
+
Histogram = 4,
|
|
40
|
+
Operation = 5,
|
|
41
|
+
Planning = 6,
|
|
42
|
+
ScatterPlot = 7,
|
|
43
|
+
Top = 8,
|
|
44
|
+
Bars = 9,
|
|
45
|
+
StackedBars = 10,
|
|
46
|
+
Pie = 11,
|
|
47
|
+
Heatmap = 12,
|
|
48
|
+
Slider = 13,
|
|
49
|
+
Gauge = 14,
|
|
50
|
+
ScoreCard = 15,
|
|
51
|
+
Table = 16
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export enum PlotPer {
|
|
55
|
+
None = 0,
|
|
56
|
+
SinglePlot = 1,
|
|
57
|
+
Model = 2,
|
|
58
|
+
Group = 3,
|
|
59
|
+
Location = 4,
|
|
60
|
+
Device = 5
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export enum AggregationType {
|
|
64
|
+
None = 0,
|
|
65
|
+
Sum = 1,
|
|
66
|
+
Cardinal = 2,
|
|
67
|
+
Mean = 3,
|
|
68
|
+
Median = 4,
|
|
69
|
+
First = 5,
|
|
70
|
+
Last = 6,
|
|
71
|
+
Difference = 7,
|
|
72
|
+
Minimum = 8,
|
|
73
|
+
Maximum = 9,
|
|
74
|
+
Range = 10
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export enum PlanningType {
|
|
78
|
+
None = 0,
|
|
79
|
+
UntilNext = 1,
|
|
80
|
+
ElapsedTime = 2,
|
|
81
|
+
SinglePoint = 3
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export enum DisplayAs {
|
|
85
|
+
None = 0,
|
|
86
|
+
Bars = 1,
|
|
87
|
+
Lines = 2,
|
|
88
|
+
Points = 3
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export enum OperationOn {
|
|
92
|
+
None = 0,
|
|
93
|
+
SameGroup = 1,
|
|
94
|
+
SameEntity = 2,
|
|
95
|
+
SameGroupAndEntity = 3
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export enum HeatmapRule {
|
|
99
|
+
None = 0,
|
|
100
|
+
Gradient = 1,
|
|
101
|
+
Ranges = 2,
|
|
102
|
+
Fixed = 3
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export enum PieBreakdown {
|
|
106
|
+
Entity = 0,
|
|
107
|
+
Serie = 1,
|
|
108
|
+
Group = 2
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export enum Position {
|
|
112
|
+
None = 0,
|
|
113
|
+
Abscissa = 1,
|
|
114
|
+
Ordinate = 2
|
|
115
|
+
}
|
package/enums/datas.ts
ADDED
|
@@ -40,4 +40,21 @@ export enum Days {
|
|
|
40
40
|
Saturday = 5,
|
|
41
41
|
Sunday = 6,
|
|
42
42
|
AllDays = 7
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export enum Months {
|
|
46
|
+
None = 0,
|
|
47
|
+
January = 1,
|
|
48
|
+
February = 2,
|
|
49
|
+
March = 3,
|
|
50
|
+
April = 4,
|
|
51
|
+
May = 5,
|
|
52
|
+
June = 6,
|
|
53
|
+
July = 7,
|
|
54
|
+
August = 8,
|
|
55
|
+
September = 9,
|
|
56
|
+
October = 10,
|
|
57
|
+
November = 11,
|
|
58
|
+
December = 12,
|
|
59
|
+
AllMonths = 13
|
|
43
60
|
}
|
package/enums/filters.ts
ADDED
package/enums/index.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from "./actions";
|
|
2
|
+
export * from "./agendas";
|
|
3
|
+
export * from "./alerts";
|
|
4
|
+
export * from "./applications";
|
|
5
|
+
export * from "./charts";
|
|
6
|
+
export * from "./connectivities";
|
|
7
|
+
export * from "./customProperties";
|
|
8
|
+
export * from "./dashboards";
|
|
9
|
+
export * from "./datas";
|
|
10
|
+
export * from "./dates";
|
|
11
|
+
export * from "./filters";
|
|
12
|
+
export * from "./index";
|
|
13
|
+
export * from "./lists";
|
|
14
|
+
export * from "./messages";
|
|
15
|
+
export * from "./roles";
|
|
16
|
+
export * from "./times";
|
|
17
|
+
export * from "./users";
|
package/enums/lists.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export enum MessageType {
|
|
2
|
+
None = 0,
|
|
3
|
+
UserApplicationCreation = 1,
|
|
4
|
+
UserOrganisationCreation = 2,
|
|
5
|
+
OrganisationCreation = 3,
|
|
6
|
+
UserApplicationAffectation = 4,
|
|
7
|
+
UserOrganisationAffectation = 5,
|
|
8
|
+
OrganisationAdminElevation = 6,
|
|
9
|
+
AccountInvitation = 7,
|
|
10
|
+
AccountValidation = 8,
|
|
11
|
+
PasswordReinitialisation = 9,
|
|
12
|
+
AlertCreation = 10,
|
|
13
|
+
AlertResolution = 11,
|
|
14
|
+
ConnectivityAlertCreation = 12,
|
|
15
|
+
ConnectivityAlertResolution = 13
|
|
16
|
+
}
|
package/enums/roles.ts
ADDED
package/enums/times.ts
ADDED
package/enums/users.ts
ADDED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isoToEpoch } from "../../tools";
|
|
2
2
|
|
|
3
3
|
export class AuthTokenInfos {
|
|
4
4
|
id: string;
|
|
@@ -9,8 +9,8 @@ export class AuthTokenInfos {
|
|
|
9
9
|
constructor(params: AuthTokenInfosDTO) {
|
|
10
10
|
this.id = params.id;
|
|
11
11
|
this.label = params.label;
|
|
12
|
-
this.creationDate =
|
|
13
|
-
this.dateMax =
|
|
12
|
+
this.creationDate = isoToEpoch(params.creationDate);
|
|
13
|
+
this.dateMax = isoToEpoch(params.dateMax);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export class
|
|
1
|
+
export class ImageInfos {
|
|
2
2
|
blurHash: string;
|
|
3
3
|
width: number;
|
|
4
4
|
height: number;
|
|
5
5
|
|
|
6
|
-
constructor(params:
|
|
6
|
+
constructor(params: ImageInfosDTO) {
|
|
7
7
|
this.blurHash = params.blurHash;
|
|
8
8
|
this.width = params.width;
|
|
9
9
|
this.height = params.height;
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export interface
|
|
13
|
+
export interface ImageInfosDTO {
|
|
14
14
|
blurHash: string;
|
|
15
15
|
width: number;
|
|
16
16
|
height: number;
|
package/models/images/index.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from "./
|
|
1
|
+
export * from "./imageDetails";
|
|
2
|
+
export * from "./imageInfos";
|
package/models/index.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export * from "./applications";
|
|
2
2
|
export * from "./authTokens";
|
|
3
|
-
export * from "./enums"; // No service
|
|
4
3
|
export * from "./images";
|
|
5
|
-
export * from "./languages";
|
|
4
|
+
export * from "./languages"; // No service
|
|
6
5
|
export * from "./locations";
|
|
6
|
+
export * from "./notifications";
|
|
7
7
|
export * from "./organisations";
|
|
8
|
-
export * from "./organisationTypes";
|
|
8
|
+
export * from "./organisationTypes"; // No service
|
|
9
9
|
export * from "./permissions";
|
|
10
10
|
export * from "./terminals";
|
|
11
11
|
export * from "./timeZones";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { NotificationInfos, type NotificationInfosDTO } from "./notificationInfos";
|
|
2
|
+
|
|
3
|
+
export class NotificationDetails extends NotificationInfos {
|
|
4
|
+
constructor(params: NotificationDetailsDTO) {
|
|
5
|
+
super(params);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface NotificationDetailsDTO extends NotificationInfosDTO {
|
|
10
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
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";
|
|
3
|
+
|
|
4
|
+
export class NotificationInfos {
|
|
5
|
+
id: string;
|
|
6
|
+
title: string;
|
|
7
|
+
body: string;
|
|
8
|
+
pageUrl: string;
|
|
9
|
+
audienceId: string;
|
|
10
|
+
audienceScope: Scope;
|
|
11
|
+
organisationId?: string;
|
|
12
|
+
entityId?: string;
|
|
13
|
+
type: MessageType;
|
|
14
|
+
criticity: Criticity;
|
|
15
|
+
timestamp: number;
|
|
16
|
+
acknowledged: boolean | null;
|
|
17
|
+
acknowledgingTimestamp: number | null;
|
|
18
|
+
|
|
19
|
+
constructor(params: NotificationInfosDTO) {
|
|
20
|
+
this.id = params.id;
|
|
21
|
+
this.title = params.title;
|
|
22
|
+
this.body = params.body;
|
|
23
|
+
this.pageUrl = params.pageUrl;
|
|
24
|
+
this.audienceId = params.audienceId;
|
|
25
|
+
this.audienceScope = params.audienceScope as Scope;
|
|
26
|
+
this.organisationId = params.organisationId;
|
|
27
|
+
this.entityId = params.entityId;
|
|
28
|
+
this.type = params.type as MessageType;
|
|
29
|
+
this.criticity = params.criticity as Criticity;
|
|
30
|
+
this.timestamp = isoToEpoch(params.timestamp);
|
|
31
|
+
this.acknowledged = params.acknowledged;
|
|
32
|
+
this.acknowledgingTimestamp = params.acknowledgingTimestamp ?
|
|
33
|
+
isoToEpoch(params.acknowledgingTimestamp) : null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface NotificationInfosDTO {
|
|
38
|
+
id: string;
|
|
39
|
+
title: string;
|
|
40
|
+
body: string;
|
|
41
|
+
pageUrl: string;
|
|
42
|
+
audienceId: string;
|
|
43
|
+
audienceScope: number;
|
|
44
|
+
organisationId?: string;
|
|
45
|
+
entityId?: string;
|
|
46
|
+
type: number;
|
|
47
|
+
criticity: number;
|
|
48
|
+
timestamp: string;
|
|
49
|
+
acknowledged: boolean | null;
|
|
50
|
+
acknowledgingTimestamp: string | null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface NotificationFilters {
|
|
54
|
+
type?: MessageType | null;
|
|
55
|
+
criticity?: Criticity | null;
|
|
56
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { OrganisationTypeInfosDTO } from "./organisationTypeInfos";
|
|
2
2
|
import { OrganisationTypeInfos } from "./organisationTypeInfos";
|
|
3
|
-
import type { DashboardType } from "
|
|
3
|
+
import type { DashboardType } from "../../enums/dashboards";
|
|
4
4
|
|
|
5
5
|
export class OrganisationTypeDetails extends OrganisationTypeInfos {
|
|
6
6
|
description: string;
|
|
@@ -2,7 +2,7 @@ import type { PermissionInfosDTO } from "../permissions/permissionInfos";
|
|
|
2
2
|
import { PermissionInfos } from "../permissions/permissionInfos";
|
|
3
3
|
import type { OrganisationInfosDTO } from "./organisationInfos";
|
|
4
4
|
import { OrganisationInfos } from "./organisationInfos";
|
|
5
|
-
import type { DashboardType } from "
|
|
5
|
+
import type { DashboardType } from "../../enums/dashboards";
|
|
6
6
|
|
|
7
7
|
export class OrganisationDetails extends OrganisationInfos {
|
|
8
8
|
code: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isoToEpoch } from "../../tools";
|
|
2
2
|
|
|
3
3
|
export class TerminalInfos {
|
|
4
4
|
id: string;
|
|
@@ -17,7 +17,7 @@ export class TerminalInfos {
|
|
|
17
17
|
this.icon = params.icon;
|
|
18
18
|
this.key = params.key;
|
|
19
19
|
this.location = params.location;
|
|
20
|
-
this.lastConnection =
|
|
20
|
+
this.lastConnection = isoToEpoch(params.lastConnection);
|
|
21
21
|
this.token = params.token;
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -6,7 +6,6 @@ export class UserDetails extends UserInfos {
|
|
|
6
6
|
hasSignedPolicies: boolean;
|
|
7
7
|
languageCode: string;
|
|
8
8
|
timeZoneId: string;
|
|
9
|
-
timeZoneOffset: string;
|
|
10
9
|
allowNotifications: boolean;
|
|
11
10
|
allowSms: boolean;
|
|
12
11
|
allowEmails: boolean;
|
|
@@ -18,7 +17,6 @@ export class UserDetails extends UserInfos {
|
|
|
18
17
|
this.hasSignedPolicies = params.hasSignedPolicies;
|
|
19
18
|
this.languageCode = params.languageCode;
|
|
20
19
|
this.timeZoneId = params.timeZoneId;
|
|
21
|
-
this.timeZoneOffset = params.timeZoneOffset;
|
|
22
20
|
this.allowNotifications = params.allowNotifications;
|
|
23
21
|
this.allowSms = params.allowSms;
|
|
24
22
|
this.allowEmails = params.allowEmails;
|
|
@@ -30,7 +28,6 @@ export interface UserDetailsDTO extends UserInfosDTO {
|
|
|
30
28
|
hasSignedPolicies: boolean;
|
|
31
29
|
languageCode: string;
|
|
32
30
|
timeZoneId: string;
|
|
33
|
-
timeZoneOffset: string;
|
|
34
31
|
allowNotifications: boolean;
|
|
35
32
|
allowSms: boolean;
|
|
36
33
|
allowEmails: 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": "0.
|
|
4
|
+
"version": "0.1.68",
|
|
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": "fa2ed7031088f422751fc1d939f2fbe168ae0596"
|
|
16
16
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AutoRefresh } from '../enums';
|
|
2
|
+
|
|
3
|
+
export const autoRefreshToSeconds = (autoRefresh: AutoRefresh): number => {
|
|
4
|
+
switch (autoRefresh) {
|
|
5
|
+
case AutoRefresh.FifteenSeconds:
|
|
6
|
+
return 15;
|
|
7
|
+
case AutoRefresh.ThirtySeconds:
|
|
8
|
+
return 30;
|
|
9
|
+
case AutoRefresh.OneMinute:
|
|
10
|
+
return 60;
|
|
11
|
+
case AutoRefresh.FiveMinutes:
|
|
12
|
+
return 300;
|
|
13
|
+
case AutoRefresh.FifteenMinutes:
|
|
14
|
+
return 900;
|
|
15
|
+
case AutoRefresh.ThirtyMinutes:
|
|
16
|
+
return 1800;
|
|
17
|
+
case AutoRefresh.OneHour:
|
|
18
|
+
return 3600;
|
|
19
|
+
default:
|
|
20
|
+
return 0;
|
|
21
|
+
}
|
|
22
|
+
}
|
package/tools/datesTools.ts
CHANGED
|
@@ -1,13 +1,63 @@
|
|
|
1
1
|
import { parse } from "date-fns";
|
|
2
2
|
|
|
3
|
+
export const ISO_FORMAT: string = "yyyy-MM-dd'T'HH:mm:ss";
|
|
4
|
+
|
|
5
|
+
export const OPTIONS: { [key: string]: Intl.DateTimeFormatOptions } = {
|
|
6
|
+
dayMonthLongOnly: {
|
|
7
|
+
day: "2-digit",
|
|
8
|
+
month: "long"
|
|
9
|
+
},
|
|
10
|
+
shortDate: {
|
|
11
|
+
day: "2-digit",
|
|
12
|
+
month: "2-digit",
|
|
13
|
+
year: "numeric"
|
|
14
|
+
},
|
|
15
|
+
longDate: {
|
|
16
|
+
weekday: "long",
|
|
17
|
+
day: "2-digit",
|
|
18
|
+
month: "long",
|
|
19
|
+
year: "numeric"
|
|
20
|
+
},
|
|
21
|
+
shortTime: {
|
|
22
|
+
day: "2-digit",
|
|
23
|
+
month: "2-digit",
|
|
24
|
+
year: "numeric",
|
|
25
|
+
hour: "2-digit",
|
|
26
|
+
minute: "2-digit",
|
|
27
|
+
second: "2-digit"
|
|
28
|
+
},
|
|
29
|
+
longTime: {
|
|
30
|
+
weekday: "long",
|
|
31
|
+
day: "2-digit",
|
|
32
|
+
month: "long",
|
|
33
|
+
year: "numeric",
|
|
34
|
+
hour: "2-digit",
|
|
35
|
+
minute: "2-digit",
|
|
36
|
+
second: "2-digit"
|
|
37
|
+
},
|
|
38
|
+
monthYearOnly: {
|
|
39
|
+
month: "long",
|
|
40
|
+
year: "numeric"
|
|
41
|
+
},
|
|
42
|
+
time: {
|
|
43
|
+
hour: "2-digit",
|
|
44
|
+
minute: "2-digit",
|
|
45
|
+
second: "2-digit"
|
|
46
|
+
},
|
|
47
|
+
shortTimeOnly: {
|
|
48
|
+
hour: "2-digit",
|
|
49
|
+
minute: "2-digit"
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const isoToEpoch = (value: string): number => {
|
|
54
|
+
return parse(value.substring(0, 19) + "Z", ISO_FORMAT + "X", new Date()).getTime();
|
|
55
|
+
};
|
|
56
|
+
|
|
3
57
|
const BASE = ["now"];
|
|
4
58
|
const WIDGET = ["from", "to"];
|
|
5
59
|
const ALERT = ["alert", "alertstart", "alertend"];
|
|
6
60
|
|
|
7
|
-
const removeArtifacts = (date: string): string => {
|
|
8
|
-
return date.substring(0, 19) + "Z";
|
|
9
|
-
};
|
|
10
|
-
|
|
11
61
|
const fromExpression = (expression: string, variant: 'default' | 'before-after'): boolean => {
|
|
12
62
|
if (
|
|
13
63
|
/^\d{2}\/\d{2}\/\d{4} \d{2}:\d{2}(:\d{2})?$/g.test(expression) ||
|
|
@@ -66,14 +116,6 @@ const fromExpression = (expression: string, variant: 'default' | 'before-after')
|
|
|
66
116
|
return true;
|
|
67
117
|
};
|
|
68
118
|
|
|
69
|
-
export const isoTimeFormat = (timeZone: boolean = false): string => {
|
|
70
|
-
return `yyyy-MM-dd'T'HH:mm:ss${timeZone ? "X" : ""}`;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
export const utcToEpoch = (value: string): number => {
|
|
74
|
-
return parse(removeArtifacts(value), isoTimeFormat(true), new Date()).getTime();
|
|
75
|
-
};
|
|
76
|
-
|
|
77
119
|
export const validateExpression = (expression: string, variant: "default" | "before-after"): boolean => {
|
|
78
120
|
return (fromExpression(expression!, variant));
|
|
79
121
|
};
|
package/tools/index.ts
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
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);
|
package/models/enums/index.ts
DELETED
|
File without changes
|
|
File without changes
|