Refine sonar-project.properties
[e-mobility-charging-stations-simulator.git] / ui / web / src / types / UIProtocol.ts
1 import type { JsonObject } from './JsonType';
2
3 export enum Protocol {
4 UI = 'ui',
5 }
6
7 export enum ApplicationProtocol {
8 HTTP = 'http',
9 WS = 'ws',
10 }
11
12 export enum ProtocolVersion {
13 '0.0.1' = '0.0.1',
14 }
15
16 export type ProtocolRequest = [string, ProcedureName, RequestPayload];
17 export type ProtocolResponse = [string, ResponsePayload];
18
19 export type ProtocolRequestHandler = (
20 payload: RequestPayload
21 ) => ResponsePayload | Promise<ResponsePayload>;
22
23 export enum ProcedureName {
24 START_SIMULATOR = 'startSimulator',
25 STOP_SIMULATOR = 'stopSimulator',
26 LIST_CHARGING_STATIONS = 'listChargingStations',
27 START_CHARGING_STATION = 'startChargingStation',
28 STOP_CHARGING_STATION = 'stopChargingStation',
29 OPEN_CONNECTION = 'openConnection',
30 CLOSE_CONNECTION = 'closeConnection',
31 START_AUTOMATIC_TRANSACTION_GENERATOR = 'startAutomaticTransactionGenerator',
32 STOP_AUTOMATIC_TRANSACTION_GENERATOR = 'stopAutomaticTransactionGenerator',
33 START_TRANSACTION = 'startTransaction',
34 STOP_TRANSACTION = 'stopTransaction',
35 }
36
37 export interface RequestPayload extends JsonObject {
38 hashIds?: string[];
39 connectorId?: number;
40 connectorIds?: number[];
41 }
42
43 export enum ResponseStatus {
44 SUCCESS = 'success',
45 FAILURE = 'failure',
46 }
47
48 export interface ResponsePayload extends JsonObject {
49 status: ResponseStatus;
50 hashIds?: string[];
51 }