@@ -3,25 +3,30 @@ import { ApiCommunication, Topic } from './parsedApiConfigurationTypes';
3
3
// Définir un type plus large pour couvrir les cas transformés depuis le XML
4
4
export type RawCommunication = {
5
5
attributes ?: Partial < ApiCommunication [ 'attributes' ] > ;
6
+ componentCode ?: string ;
7
+ stateMachineCode ?: string ;
8
+ eventType ?: string ;
9
+ event ?: string ;
10
+ eventCode ?: string ;
6
11
topic ?: { value ?: string ; type ?: string } | { value ?: string ; type ?: string } [ ] ;
7
12
} ;
8
13
9
14
export function normalizeCommunication ( input : RawCommunication ) : ApiCommunication {
10
- const attr = input . attributes ?? { } ;
11
-
12
15
return {
13
16
attributes : {
14
- componentCode : attr . componentCode ?? '' ,
15
- stateMachineCode : attr . stateMachineCode ,
16
- eventType : attr . eventType ,
17
- event : attr . event ,
18
- eventCode : attr . eventCode ,
17
+ componentCode : input . componentCode ?? input . attributes ? .componentCode ?? '' ,
18
+ stateMachineCode : input . stateMachineCode ?? input . attributes ? .stateMachineCode ,
19
+ eventType : input . eventType ?? input . attributes ? .eventType ,
20
+ event : input . event ?? input . attributes ? .event ,
21
+ eventCode : input . eventCode ?? input . attributes ? .eventCode ,
19
22
} ,
20
23
topic : normalizeTopic ( input . topic ) ,
21
24
} ;
22
25
}
23
26
24
- function normalizeTopic ( topic : { value ?: string ; type ?: string } | { value ?: string ; type ?: string } [ ] | undefined ) : [ Topic ] {
27
+ function normalizeTopic (
28
+ topic : { value ?: string ; type ?: string } | { value ?: string ; type ?: string } [ ] | undefined
29
+ ) : [ Topic ] {
25
30
if ( ! topic ) {
26
31
return [ { value : '' } ] ;
27
32
}
0 commit comments