Coding style cleanups
[e-mobility-charging-stations-simulator.git] / 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 AuthenticationType {
13 BASIC_AUTH = 'basic-auth',
14 }
15
16 export enum ProtocolVersion {
17 '0.0.1' = '0.0.1',
18 }
19
20 export type ProtocolRequest = [string, ProcedureName, RequestPayload];
21 export type ProtocolResponse = [string, ResponsePayload];
22
23 export type ProtocolRequestHandler = (
24 uuid?: string,
25 payload?: RequestPayload
26 ) => undefined | Promise<undefined> | ResponsePayload | Promise<ResponsePayload>;
27
28 export enum ProcedureName {
29 LIST_CHARGING_STATIONS = 'listChargingStations',
30 START_CHARGING_STATION = 'startChargingStation',
31 STOP_CHARGING_STATION = 'stopChargingStation',
32 START_SIMULATOR = 'startSimulator',
33 STOP_SIMULATOR = 'stopSimulator',
34 OPEN_CONNECTION = 'openConnection',
35 CLOSE_CONNECTION = 'closeConnection',
36 START_TRANSACTION = 'startTransaction',
37 STOP_TRANSACTION = 'stopTransaction',
38 START_AUTOMATIC_TRANSACTION_GENERATOR = 'startAutomaticTransactionGenerator',
39 STOP_AUTOMATIC_TRANSACTION_GENERATOR = 'stopAutomaticTransactionGenerator',
40 }
41
42 export interface RequestPayload extends JsonObject {
43 hashIds?: string[];
44 connectorIds?: number[];
45 }
46
47 export enum ResponseStatus {
48 SUCCESS = 'success',
49 FAILURE = 'failure',
50 }
51
52 export interface ResponsePayload extends JsonObject {
53 status: ResponseStatus;
54 hashIdsSucceeded?: string[];
55 hashIdsFailed?: string[];
56 }