@dative-gpi/foundation-shared-domain 1.0.66 → 1.0.67-map-edit
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/applications.ts +1 -0
- package/enums/dashboards.ts +2 -1
- package/enums/dates.ts +6 -0
- package/enums/deviceExplorerElements.ts +5 -0
- package/enums/index.ts +4 -0
- package/enums/playlists.ts +5 -0
- package/enums/reports.ts +5 -0
- package/enums/widgetTemplates.ts +5 -0
- package/models/authTokens/authTokenInfos.ts +1 -1
- package/models/images/imageDetails.ts +0 -1
- package/models/index.ts +4 -2
- package/models/legalInformations/index.ts +2 -0
- package/models/legalInformations/legalInformationDetails.ts +10 -0
- package/models/legalInformations/legalInformationInfos.ts +17 -0
- package/models/locations/index.ts +0 -1
- package/models/notifications/index.ts +1 -0
- package/models/notifications/notificationAudience.ts +25 -0
- package/models/notifications/notificationInfos.ts +17 -14
- package/models/organisations/organisationDetails.ts +2 -5
- package/models/organisations/organisationInfos.ts +27 -21
- package/models/terminals/terminalInfos.ts +1 -1
- package/models/userLegalInformations/index.ts +2 -0
- package/models/userLegalInformations/userLegalInformationDetails.ts +14 -0
- package/models/userLegalInformations/userLegalInformationInfos.ts +17 -0
- package/package.json +2 -2
- package/tools/aggregationTools.ts +45 -0
- package/tools/datesTools.ts +10 -0
- package/tools/enumTools.ts +5 -0
- package/tools/index.ts +4 -3
- package/models/locations/area.ts +0 -7
- package/tools/notificationsTools.ts +0 -39
package/enums/applications.ts
CHANGED
package/enums/dashboards.ts
CHANGED
package/enums/dates.ts
CHANGED
package/enums/index.ts
CHANGED
|
@@ -8,10 +8,14 @@ export * from "./customProperties";
|
|
|
8
8
|
export * from "./dashboards";
|
|
9
9
|
export * from "./datas";
|
|
10
10
|
export * from "./dates";
|
|
11
|
+
export * from "./deviceExplorerElements";
|
|
11
12
|
export * from "./filters";
|
|
12
13
|
export * from "./index";
|
|
13
14
|
export * from "./lists";
|
|
14
15
|
export * from "./messages";
|
|
16
|
+
export * from "./playlists";
|
|
15
17
|
export * from "./roles";
|
|
16
18
|
export * from "./times";
|
|
17
19
|
export * from "./users";
|
|
20
|
+
export * from "./widgetTemplates";
|
|
21
|
+
export * from "./reports";
|
package/enums/reports.ts
ADDED
package/models/index.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
export * from "./applications";
|
|
2
2
|
export * from "./authTokens";
|
|
3
3
|
export * from "./images";
|
|
4
|
-
export * from "./languages";
|
|
4
|
+
export * from "./languages"; // No service
|
|
5
|
+
export * from "./legalInformations";
|
|
5
6
|
export * from "./locations";
|
|
6
7
|
export * from "./notifications";
|
|
7
8
|
export * from "./organisations";
|
|
8
|
-
export * from "./organisationTypes";
|
|
9
|
+
export * from "./organisationTypes"; // No service
|
|
9
10
|
export * from "./permissions";
|
|
10
11
|
export * from "./terminals";
|
|
11
12
|
export * from "./timeZones";
|
|
12
13
|
export * from "./translations";
|
|
14
|
+
export * from "./userLegalInformations";
|
|
13
15
|
export * from "./users";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { LegalInformationInfos, type LegalInformationInfosDTO } from "./legalInformationInfos";
|
|
2
|
+
|
|
3
|
+
export class LegalInformationDetails extends LegalInformationInfos {
|
|
4
|
+
constructor(params: LegalInformationDetailsDTO) {
|
|
5
|
+
super(params);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface LegalInformationDetailsDTO extends LegalInformationInfosDTO {
|
|
10
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export class LegalInformationInfos {
|
|
2
|
+
id: string;
|
|
3
|
+
privacyPolicyId: string;
|
|
4
|
+
generalConditionsId: string;
|
|
5
|
+
|
|
6
|
+
constructor(params: LegalInformationInfosDTO) {
|
|
7
|
+
this.id = params.id;
|
|
8
|
+
this.privacyPolicyId = params.privacyPolicyId;
|
|
9
|
+
this.generalConditionsId = params.generalConditionsId;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface LegalInformationInfosDTO {
|
|
14
|
+
id: string;
|
|
15
|
+
privacyPolicyId: string;
|
|
16
|
+
generalConditionsId: string;
|
|
17
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface NotificationAudienceFilters {
|
|
23
|
+
targetScope?: Scope | null;
|
|
24
|
+
targetId?: string | null;
|
|
25
|
+
}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { isoToEpoch } from "
|
|
1
|
+
import { type MessageType } from "../../enums/messages";
|
|
2
|
+
import { isoToEpoch } from "../../tools/datesTools";
|
|
3
|
+
import type { Criticity } from "../../enums/alerts";
|
|
4
|
+
import { NotificationAudience, type NotificationAudienceFilters } from "./notificationAudience";
|
|
3
5
|
|
|
4
6
|
export class NotificationInfos {
|
|
5
7
|
id: string;
|
|
6
8
|
title: string;
|
|
7
9
|
body: string;
|
|
8
10
|
pageUrl: string;
|
|
9
|
-
|
|
10
|
-
audienceScope: Scope;
|
|
11
|
-
organisationId?: string;
|
|
12
|
-
entityId?: string;
|
|
11
|
+
audiences: NotificationAudience[];
|
|
13
12
|
type: MessageType;
|
|
14
13
|
criticity: Criticity;
|
|
14
|
+
imageId: string | null;
|
|
15
|
+
icon: string;
|
|
16
|
+
color: string;
|
|
15
17
|
timestamp: number;
|
|
16
18
|
acknowledged: boolean | null;
|
|
17
19
|
acknowledgingTimestamp: number | null;
|
|
@@ -21,10 +23,10 @@ export class NotificationInfos {
|
|
|
21
23
|
this.title = params.title;
|
|
22
24
|
this.body = params.body;
|
|
23
25
|
this.pageUrl = params.pageUrl;
|
|
24
|
-
this.
|
|
25
|
-
this.
|
|
26
|
-
this.
|
|
27
|
-
this.
|
|
26
|
+
this.imageId = params.imageId;
|
|
27
|
+
this.icon = params.icon;
|
|
28
|
+
this.color = params.color;
|
|
29
|
+
this.audiences = params.audiences.map((a: NotificationAudience) => new NotificationAudience(a));
|
|
28
30
|
this.type = params.type as MessageType;
|
|
29
31
|
this.criticity = params.criticity as Criticity;
|
|
30
32
|
this.timestamp = isoToEpoch(params.timestamp);
|
|
@@ -39,10 +41,10 @@ export interface NotificationInfosDTO {
|
|
|
39
41
|
title: string;
|
|
40
42
|
body: string;
|
|
41
43
|
pageUrl: string;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
audiences: NotificationAudience[];
|
|
45
|
+
imageId: string | null;
|
|
46
|
+
icon: string;
|
|
47
|
+
color: string;
|
|
46
48
|
type: number;
|
|
47
49
|
criticity: number;
|
|
48
50
|
timestamp: string;
|
|
@@ -53,4 +55,5 @@ export interface NotificationInfosDTO {
|
|
|
53
55
|
export interface NotificationFilters {
|
|
54
56
|
type?: MessageType | null;
|
|
55
57
|
criticity?: Criticity | null;
|
|
58
|
+
audiences?: NotificationAudienceFilters[] | null;
|
|
56
59
|
}
|
|
@@ -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
|
|
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
|
|
41
|
+
alertsCount: number;
|
|
45
42
|
permissions: PermissionInfosDTO[];
|
|
46
43
|
}
|
|
47
44
|
|
|
@@ -1,30 +1,36 @@
|
|
|
1
1
|
export class OrganisationInfos {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
id: string;
|
|
3
|
+
organisationTypeId: string;
|
|
4
|
+
imageId: string | null;
|
|
5
|
+
label: string;
|
|
6
|
+
userOrganisationsCount: number;
|
|
7
|
+
adminId: string | null;
|
|
8
|
+
adminName: string | null;
|
|
9
|
+
currentUserOrganisationId: string | null;
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
constructor(params: OrganisationInfosDTO) {
|
|
12
|
+
this.id = params.id;
|
|
13
|
+
this.organisationTypeId = params.organisationTypeId;
|
|
14
|
+
this.imageId = params.imageId;
|
|
15
|
+
this.label = params.label;
|
|
16
|
+
this.userOrganisationsCount = params.userOrganisationsCount;
|
|
17
|
+
this.adminId = params.adminId;
|
|
18
|
+
this.adminName = params.adminName;
|
|
19
|
+
this.currentUserOrganisationId = params.currentUserOrganisationId;
|
|
20
|
+
}
|
|
17
21
|
}
|
|
18
22
|
|
|
19
23
|
export interface OrganisationInfosDTO {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
id: string;
|
|
25
|
+
organisationTypeId: string;
|
|
26
|
+
imageId: string | null;
|
|
27
|
+
label: string;
|
|
28
|
+
userOrganisationsCount: number;
|
|
29
|
+
adminId: string | null;
|
|
30
|
+
adminName: string | null;
|
|
31
|
+
currentUserOrganisationId: string | null;
|
|
26
32
|
}
|
|
27
33
|
|
|
28
34
|
export interface OrganisationFilters {
|
|
29
|
-
|
|
35
|
+
search?: string | null;
|
|
30
36
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { UserLegalInformationInfos, type UserLegalInformationInfosDTO } from "./userLegalInformationInfos";
|
|
2
|
+
|
|
3
|
+
export class UserLegalInformationDetails extends UserLegalInformationInfos {
|
|
4
|
+
constructor(params: UserLegalInformationDetailsDTO) {
|
|
5
|
+
super(params);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface UserLegalInformationDetailsDTO extends UserLegalInformationInfosDTO {
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface CreateUserLegalInformationDTO {
|
|
13
|
+
legalInformationId: string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export class UserLegalInformationInfos {
|
|
2
|
+
id: string;
|
|
3
|
+
userId: string;
|
|
4
|
+
legalInformationId: string;
|
|
5
|
+
|
|
6
|
+
constructor(params: UserLegalInformationInfosDTO) {
|
|
7
|
+
this.id = params.id;
|
|
8
|
+
this.userId = params.userId;
|
|
9
|
+
this.legalInformationId = params.legalInformationId;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface UserLegalInformationInfosDTO {
|
|
14
|
+
id: string;
|
|
15
|
+
userId: string;
|
|
16
|
+
legalInformationId: string;
|
|
17
|
+
}
|
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.
|
|
4
|
+
"version": "1.0.67-map-edit",
|
|
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": "725635256ebf2bb6450c38e5a3077fb907ea550c"
|
|
16
16
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { AggregationType } from '@dative-gpi/foundation-shared-domain/enums';
|
|
2
|
+
|
|
3
|
+
type ReducerFn = (prev: number, curr: number, index: number, array: number[]) => number;
|
|
4
|
+
|
|
5
|
+
const reducers: Partial<Record<AggregationType, ReducerFn>> = {
|
|
6
|
+
[AggregationType.Sum]: (a, b) => a + b,
|
|
7
|
+
[AggregationType.First]: (a) => a,
|
|
8
|
+
[AggregationType.Last]: (_, b) => b,
|
|
9
|
+
[AggregationType.Difference]: (a, b) => b - a,
|
|
10
|
+
[AggregationType.Maximum]: (a, b) => Math.max(a, b),
|
|
11
|
+
[AggregationType.Minimum]: (a, b) => Math.min(a, b),
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const aggregationFactory = (type: AggregationType): ReducerFn => {
|
|
15
|
+
const reducer = reducers[type];
|
|
16
|
+
if (!reducer) {
|
|
17
|
+
throw new Error(`Aggregation "${type}" must be handled explicitly.`);
|
|
18
|
+
}
|
|
19
|
+
return reducer;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const computeAggregation = (type: AggregationType, values: number[]): number => {
|
|
23
|
+
if (!values.length) {
|
|
24
|
+
throw new Error('Cannot aggregate empty array.');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
switch (type) {
|
|
28
|
+
case AggregationType.Mean:
|
|
29
|
+
const sum = values.reduce((a, b) => a + b, 0);
|
|
30
|
+
return sum / values.length;
|
|
31
|
+
|
|
32
|
+
case AggregationType.Median:
|
|
33
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
34
|
+
const mid = Math.floor(sorted.length / 2);
|
|
35
|
+
return sorted.length % 2 === 0
|
|
36
|
+
? (sorted[mid - 1] + sorted[mid]) / 2
|
|
37
|
+
: sorted[mid];
|
|
38
|
+
|
|
39
|
+
case AggregationType.Cardinal:
|
|
40
|
+
return values.length;
|
|
41
|
+
|
|
42
|
+
default:
|
|
43
|
+
return values.reduce(aggregationFactory(type));
|
|
44
|
+
}
|
|
45
|
+
}
|
package/tools/datesTools.ts
CHANGED
|
@@ -7,6 +7,10 @@ export const OPTIONS: { [key: string]: Intl.DateTimeFormatOptions } = {
|
|
|
7
7
|
day: "2-digit",
|
|
8
8
|
month: "long"
|
|
9
9
|
},
|
|
10
|
+
dayMonthShortOnly: {
|
|
11
|
+
day: "2-digit",
|
|
12
|
+
month: "2-digit"
|
|
13
|
+
},
|
|
10
14
|
shortDate: {
|
|
11
15
|
day: "2-digit",
|
|
12
16
|
month: "2-digit",
|
|
@@ -18,6 +22,12 @@ export const OPTIONS: { [key: string]: Intl.DateTimeFormatOptions } = {
|
|
|
18
22
|
month: "long",
|
|
19
23
|
year: "numeric"
|
|
20
24
|
},
|
|
25
|
+
monthShortTime: {
|
|
26
|
+
day: "2-digit",
|
|
27
|
+
month: "2-digit",
|
|
28
|
+
hour: "2-digit",
|
|
29
|
+
minute: "2-digit"
|
|
30
|
+
},
|
|
21
31
|
shortTime: {
|
|
22
32
|
day: "2-digit",
|
|
23
33
|
month: "2-digit",
|
package/tools/index.ts
CHANGED
package/models/locations/area.ts
DELETED
|
@@ -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);
|