Commit | Line | Data |
---|---|---|
66a7748d | 1 | import type { JsonObject } from './JsonType' |
32de5a57 LM |
2 | |
3 | export enum Protocol { | |
a974c8e4 | 4 | UI = 'ui' |
32de5a57 LM |
5 | } |
6 | ||
7 | export enum ApplicationProtocol { | |
217db058 JB |
8 | WS = 'ws', |
9 | WSS = 'wss' | |
32de5a57 LM |
10 | } |
11 | ||
12 | export enum ProtocolVersion { | |
a974c8e4 | 13 | '0.0.1' = '0.0.1' |
32de5a57 LM |
14 | } |
15 | ||
217db058 | 16 | export enum AuthenticationType { |
329eab0e | 17 | PROTOCOL_BASIC_AUTH = 'protocol-basic-auth' |
217db058 JB |
18 | } |
19 | ||
2c5c7443 JB |
20 | export type ProtocolRequest = [ |
21 | `${string}-${string}-${string}-${string}-${string}`, | |
22 | ProcedureName, | |
23 | RequestPayload | |
24 | ] | |
25 | export type ProtocolResponse = [ | |
26 | `${string}-${string}-${string}-${string}-${string}`, | |
27 | ResponsePayload | |
28 | ] | |
4e3ff94d JB |
29 | |
30 | export type ProtocolRequestHandler = ( | |
66a7748d JB |
31 | payload: RequestPayload |
32 | ) => ResponsePayload | Promise<ResponsePayload> | |
4e3ff94d | 33 | |
32de5a57 | 34 | export enum ProcedureName { |
240fa4da | 35 | SIMULATOR_STATE = 'simulatorState', |
757b2ecf JB |
36 | START_SIMULATOR = 'startSimulator', |
37 | STOP_SIMULATOR = 'stopSimulator', | |
c317ae3e | 38 | LIST_TEMPLATES = 'listTemplates', |
32de5a57 | 39 | LIST_CHARGING_STATIONS = 'listChargingStations', |
c317ae3e JB |
40 | ADD_CHARGING_STATIONS = 'addChargingStations', |
41 | DELETE_CHARGING_STATIONS = 'deleteChargingStations', | |
f8696170 | 42 | SET_SUPERVISION_URL = 'setSupervisionUrl', |
4e3ff94d JB |
43 | START_CHARGING_STATION = 'startChargingStation', |
44 | STOP_CHARGING_STATION = 'stopChargingStation', | |
ce7a4fc3 JB |
45 | OPEN_CONNECTION = 'openConnection', |
46 | CLOSE_CONNECTION = 'closeConnection', | |
757b2ecf JB |
47 | START_AUTOMATIC_TRANSACTION_GENERATOR = 'startAutomaticTransactionGenerator', |
48 | STOP_AUTOMATIC_TRANSACTION_GENERATOR = 'stopAutomaticTransactionGenerator', | |
5e8e29f4 | 49 | START_TRANSACTION = 'startTransaction', |
a974c8e4 | 50 | STOP_TRANSACTION = 'stopTransaction' |
32de5a57 | 51 | } |
a65319ba | 52 | |
4e3ff94d | 53 | export interface RequestPayload extends JsonObject { |
66a7748d JB |
54 | hashIds?: string[] |
55 | connectorIds?: number[] | |
4e3ff94d | 56 | } |
32de5a57 LM |
57 | |
58 | export enum ResponseStatus { | |
59 | SUCCESS = 'success', | |
a974c8e4 | 60 | FAILURE = 'failure' |
32de5a57 LM |
61 | } |
62 | ||
63 | export interface ResponsePayload extends JsonObject { | |
66a7748d JB |
64 | status: ResponseStatus |
65 | hashIds?: string[] | |
32de5a57 | 66 | } |
e8237645 JB |
67 | |
68 | interface TemplateStatistics extends JsonObject { | |
69 | configured: number | |
70 | added: number | |
71 | started: number | |
72 | indexes: number[] | |
73 | } | |
74 | ||
75 | export interface SimulatorState extends JsonObject { | |
76 | version: string | |
77 | started: boolean | |
78 | templateStatistics: Record<string, TemplateStatistics> | |
79 | } |