5b3efcdcef1efb81cccc8eeddc5525ccda0797f1
[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 WS = 'ws',
9 WSS = 'wss'
10 }
11
12 export enum ProtocolVersion {
13 '0.0.1' = '0.0.1'
14 }
15
16 export enum AuthenticationType {
17 PROTOCOL_BASIC_AUTH = 'protocol-basic-auth'
18 }
19
20 export type ProtocolRequest = [string, ProcedureName, RequestPayload]
21 export type ProtocolResponse = [string, ResponsePayload]
22
23 export type ProtocolRequestHandler = (
24 payload: RequestPayload
25 ) => ResponsePayload | Promise<ResponsePayload>
26
27 export enum ProcedureName {
28 SIMULATOR_STATE = 'simulatorState',
29 START_SIMULATOR = 'startSimulator',
30 STOP_SIMULATOR = 'stopSimulator',
31 LIST_TEMPLATES = 'listTemplates',
32 LIST_CHARGING_STATIONS = 'listChargingStations',
33 ADD_CHARGING_STATIONS = 'addChargingStations',
34 DELETE_CHARGING_STATIONS = 'deleteChargingStations',
35 SET_SUPERVISION_URL = 'setSupervisionUrl',
36 START_CHARGING_STATION = 'startChargingStation',
37 STOP_CHARGING_STATION = 'stopChargingStation',
38 OPEN_CONNECTION = 'openConnection',
39 CLOSE_CONNECTION = 'closeConnection',
40 START_AUTOMATIC_TRANSACTION_GENERATOR = 'startAutomaticTransactionGenerator',
41 STOP_AUTOMATIC_TRANSACTION_GENERATOR = 'stopAutomaticTransactionGenerator',
42 START_TRANSACTION = 'startTransaction',
43 STOP_TRANSACTION = 'stopTransaction'
44 }
45
46 export interface RequestPayload extends JsonObject {
47 hashIds?: string[]
48 connectorIds?: number[]
49 }
50
51 export enum ResponseStatus {
52 SUCCESS = 'success',
53 FAILURE = 'failure'
54 }
55
56 export interface ResponsePayload extends JsonObject {
57 status: ResponseStatus
58 hashIds?: string[]
59 }
60
61 interface TemplateStatistics extends JsonObject {
62 configured: number
63 added: number
64 started: number
65 indexes: number[]
66 }
67
68 export interface SimulatorState extends JsonObject {
69 version: string
70 started: boolean
71 templateStatistics: Record<string, TemplateStatistics>
72 }