Skip to content

Commit 5b80f49

Browse files
committed
update
1 parent 1d06a9c commit 5b80f49

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/configuration/apiCommunicationUtils.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,30 @@ import { ApiCommunication, Topic } from './parsedApiConfigurationTypes';
33
// Définir un type plus large pour couvrir les cas transformés depuis le XML
44
export type RawCommunication = {
55
attributes?: Partial<ApiCommunication['attributes']>;
6+
componentCode?: string;
7+
stateMachineCode?: string;
8+
eventType?: string;
9+
event?: string;
10+
eventCode?: string;
611
topic?: { value?: string; type?: string } | { value?: string; type?: string }[];
712
};
813

914
export function normalizeCommunication(input: RawCommunication): ApiCommunication {
10-
const attr = input.attributes ?? {};
11-
1215
return {
1316
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,
1922
},
2023
topic: normalizeTopic(input.topic),
2124
};
2225
}
2326

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] {
2530
if (!topic) {
2631
return [{ value: '' }];
2732
}

0 commit comments

Comments
 (0)