feat: set supervision url through the UI protocol
[e-mobility-charging-stations-simulator.git] / src / types / UIProtocol.ts
1 import type { BroadcastChannelResponsePayload, JsonObject } from './internal';
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 procedureName?: ProcedureName,
26 payload?: RequestPayload
27 ) => undefined | Promise<undefined> | ResponsePayload | Promise<ResponsePayload>;
28
29 export enum ProcedureName {
30 START_SIMULATOR = 'startSimulator',
31 STOP_SIMULATOR = 'stopSimulator',
32 LIST_CHARGING_STATIONS = 'listChargingStations',
33 START_CHARGING_STATION = 'startChargingStation',
34 STOP_CHARGING_STATION = 'stopChargingStation',
35 OPEN_CONNECTION = 'openConnection',
36 CLOSE_CONNECTION = 'closeConnection',
37 START_AUTOMATIC_TRANSACTION_GENERATOR = 'startAutomaticTransactionGenerator',
38 STOP_AUTOMATIC_TRANSACTION_GENERATOR = 'stopAutomaticTransactionGenerator',
39 SET_SUPERVISION_URL = 'setSupervisionUrl',
40 START_TRANSACTION = 'startTransaction',
41 STOP_TRANSACTION = 'stopTransaction',
42 AUTHORIZE = 'authorize',
43 BOOT_NOTIFICATION = 'bootNotification',
44 STATUS_NOTIFICATION = 'statusNotification',
45 HEARTBEAT = 'heartbeat',
46 METER_VALUES = 'meterValues',
47 DATA_TRANSFER = 'dataTransfer',
48 DIAGNOSTICS_STATUS_NOTIFICATION = 'diagnosticsStatusNotification',
49 FIRMWARE_STATUS_NOTIFICATION = 'firmwareStatusNotification',
50 }
51
52 export interface RequestPayload extends JsonObject {
53 hashIds?: string[];
54 connectorIds?: number[];
55 }
56
57 export enum ResponseStatus {
58 SUCCESS = 'success',
59 FAILURE = 'failure',
60 }
61
62 export interface ResponsePayload extends JsonObject {
63 status: ResponseStatus;
64 hashIdsSucceeded?: string[];
65 hashIdsFailed?: string[];
66 responsesFailed?: BroadcastChannelResponsePayload[];
67 }