63bb7ca1a5bc61c90bb99a1b62e598478eefa2da
[e-mobility-charging-stations-simulator.git] / src / types / UIProtocol.ts
1 import { 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 uuid?: string,
21 payload?: RequestPayload
22 ) => undefined | Promise<undefined> | ResponsePayload | Promise<ResponsePayload>;
23
24 export enum ProcedureName {
25 LIST_CHARGING_STATIONS = 'listChargingStations',
26 START_CHARGING_STATION = 'startChargingStation',
27 STOP_CHARGING_STATION = 'stopChargingStation',
28 START_TRANSACTION = 'startTransaction',
29 STOP_TRANSACTION = 'stopTransaction',
30 START_SIMULATOR = 'startSimulator',
31 STOP_SIMULATOR = 'stopSimulator',
32 OPEN_CONNECTION = 'openConnection',
33 CLOSE_CONNECTION = 'closeConnection',
34 }
35
36 export interface RequestPayload extends JsonObject {
37 hashId?: string;
38 }
39
40 export enum ResponseStatus {
41 SUCCESS = 'success',
42 FAILURE = 'failure',
43 }
44
45 export interface ResponsePayload extends JsonObject {
46 status: ResponseStatus;
47 }