| 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 = [ |
| 21 | `${string}-${string}-${string}-${string}-${string}`, |
| 22 | ProcedureName, |
| 23 | RequestPayload |
| 24 | ] |
| 25 | export type ProtocolResponse = [ |
| 26 | `${string}-${string}-${string}-${string}-${string}`, |
| 27 | ResponsePayload |
| 28 | ] |
| 29 | |
| 30 | export type ProtocolRequestHandler = ( |
| 31 | payload: RequestPayload |
| 32 | ) => ResponsePayload | Promise<ResponsePayload> |
| 33 | |
| 34 | export enum ProcedureName { |
| 35 | SIMULATOR_STATE = 'simulatorState', |
| 36 | START_SIMULATOR = 'startSimulator', |
| 37 | STOP_SIMULATOR = 'stopSimulator', |
| 38 | LIST_TEMPLATES = 'listTemplates', |
| 39 | LIST_CHARGING_STATIONS = 'listChargingStations', |
| 40 | ADD_CHARGING_STATIONS = 'addChargingStations', |
| 41 | DELETE_CHARGING_STATIONS = 'deleteChargingStations', |
| 42 | SET_SUPERVISION_URL = 'setSupervisionUrl', |
| 43 | START_CHARGING_STATION = 'startChargingStation', |
| 44 | STOP_CHARGING_STATION = 'stopChargingStation', |
| 45 | OPEN_CONNECTION = 'openConnection', |
| 46 | CLOSE_CONNECTION = 'closeConnection', |
| 47 | START_AUTOMATIC_TRANSACTION_GENERATOR = 'startAutomaticTransactionGenerator', |
| 48 | STOP_AUTOMATIC_TRANSACTION_GENERATOR = 'stopAutomaticTransactionGenerator', |
| 49 | START_TRANSACTION = 'startTransaction', |
| 50 | STOP_TRANSACTION = 'stopTransaction' |
| 51 | } |
| 52 | |
| 53 | export interface RequestPayload extends JsonObject { |
| 54 | hashIds?: string[] |
| 55 | connectorIds?: number[] |
| 56 | } |
| 57 | |
| 58 | export enum ResponseStatus { |
| 59 | SUCCESS = 'success', |
| 60 | FAILURE = 'failure' |
| 61 | } |
| 62 | |
| 63 | export interface ResponsePayload extends JsonObject { |
| 64 | status: ResponseStatus |
| 65 | hashIds?: string[] |
| 66 | } |
| 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 | } |