UI protocol: add OCPP heartbeat command support
[e-mobility-charging-stations-simulator.git] / src / types / UIProtocol.ts
CommitLineData
6c1761d4 1import type { JsonObject } from './JsonType';
f53c88d0 2import type { BroadcastChannelResponsePayload } from './WorkerBroadcastChannel';
d1888640 3
4198ad5c
JB
4export enum Protocol {
5 UI = 'ui',
6}
8244f5f0 7
675fa8e3
JB
8export enum ApplicationProtocol {
9 HTTP = 'http',
10 WS = 'ws',
11}
12
eb3abc4f
JB
13export enum AuthenticationType {
14 BASIC_AUTH = 'basic-auth',
15}
16
8244f5f0
JB
17export enum ProtocolVersion {
18 '0.0.1' = '0.0.1',
8244f5f0
JB
19}
20
89b7a234
JB
21export type ProtocolRequest = [string, ProcedureName, RequestPayload];
22export type ProtocolResponse = [string, ResponsePayload];
23
24export type ProtocolRequestHandler = (
4e3ff94d
JB
25 uuid?: string,
26 payload?: RequestPayload
6c8f5d90 27) => undefined | Promise<undefined> | ResponsePayload | Promise<ResponsePayload>;
89b7a234 28
32de5a57 29export enum ProcedureName {
ee0f106b 30 LIST_CHARGING_STATIONS = 'listChargingStations',
89b7a234
JB
31 START_CHARGING_STATION = 'startChargingStation',
32 STOP_CHARGING_STATION = 'stopChargingStation',
32de5a57
LM
33 START_SIMULATOR = 'startSimulator',
34 STOP_SIMULATOR = 'stopSimulator',
db2336d9
JB
35 OPEN_CONNECTION = 'openConnection',
36 CLOSE_CONNECTION = 'closeConnection',
4f69be04
JB
37 START_TRANSACTION = 'startTransaction',
38 STOP_TRANSACTION = 'stopTransaction',
39 START_AUTOMATIC_TRANSACTION_GENERATOR = 'startAutomaticTransactionGenerator',
40 STOP_AUTOMATIC_TRANSACTION_GENERATOR = 'stopAutomaticTransactionGenerator',
a9ed42b2 41 STATUS_NOTIFICATION = 'statusNotification',
10db00b2 42 HEARTBEAT = 'heartbeat',
8244f5f0 43}
5612b691 44
89b7a234 45export interface RequestPayload extends JsonObject {
4eca248c 46 hashIds?: string[];
757b2ecf 47 connectorIds?: number[];
89b7a234 48}
8244f5f0 49
32de5a57
LM
50export enum ResponseStatus {
51 SUCCESS = 'success',
52 FAILURE = 'failure',
53}
54
55export interface ResponsePayload extends JsonObject {
56 status: ResponseStatus;
0d2cec76
JB
57 hashIdsSucceeded?: string[];
58 hashIdsFailed?: string[];
f53c88d0 59 responsesFailed?: BroadcastChannelResponsePayload[];
32de5a57 60}