6e120337197d3ea39b65a48517b6e9f554e9eaa2
[e-mobility-charging-stations-simulator.git] / src / types / UIProtocol.ts
1 import type { JsonObject } from './JsonType.js'
2 import type { BroadcastChannelResponsePayload } from './WorkerBroadcastChannel.js'
3
4 export enum Protocol {
5 UI = 'ui'
6 }
7
8 export enum ApplicationProtocol {
9 HTTP = 'http',
10 WS = 'ws'
11 }
12
13 export enum AuthenticationType {
14 BASIC_AUTH = 'basic-auth',
15 PROTOCOL_BASIC_AUTH = 'protocol-basic-auth'
16 }
17
18 export enum ProtocolVersion {
19 '0.0.1' = '0.0.1'
20 }
21
22 export type ProtocolRequest = [string, ProcedureName, RequestPayload]
23 export type ProtocolResponse = [string, ResponsePayload]
24
25 export type ProtocolRequestHandler = (
26 uuid?: string,
27 procedureName?: ProcedureName,
28 payload?: RequestPayload
29 ) => undefined | Promise<undefined> | ResponsePayload | Promise<ResponsePayload>
30
31 export enum ProcedureName {
32 START_SIMULATOR = 'startSimulator',
33 STOP_SIMULATOR = 'stopSimulator',
34 LIST_TEMPLATES = 'listTemplates',
35 LIST_CHARGING_STATIONS = 'listChargingStations',
36 ADD_CHARGING_STATIONS = 'addChargingStations',
37 DELETE_CHARGING_STATIONS = 'deleteChargingStations',
38 PERFORMANCE_STATISTICS = 'performanceStatistics',
39 START_CHARGING_STATION = 'startChargingStation',
40 STOP_CHARGING_STATION = 'stopChargingStation',
41 OPEN_CONNECTION = 'openConnection',
42 CLOSE_CONNECTION = 'closeConnection',
43 START_AUTOMATIC_TRANSACTION_GENERATOR = 'startAutomaticTransactionGenerator',
44 STOP_AUTOMATIC_TRANSACTION_GENERATOR = 'stopAutomaticTransactionGenerator',
45 SET_SUPERVISION_URL = 'setSupervisionUrl',
46 START_TRANSACTION = 'startTransaction',
47 STOP_TRANSACTION = 'stopTransaction',
48 AUTHORIZE = 'authorize',
49 BOOT_NOTIFICATION = 'bootNotification',
50 STATUS_NOTIFICATION = 'statusNotification',
51 HEARTBEAT = 'heartbeat',
52 METER_VALUES = 'meterValues',
53 DATA_TRANSFER = 'dataTransfer',
54 DIAGNOSTICS_STATUS_NOTIFICATION = 'diagnosticsStatusNotification',
55 FIRMWARE_STATUS_NOTIFICATION = 'firmwareStatusNotification'
56 }
57
58 export interface RequestPayload extends JsonObject {
59 hashIds?: string[]
60 connectorIds?: number[]
61 }
62
63 export enum ResponseStatus {
64 SUCCESS = 'success',
65 FAILURE = 'failure'
66 }
67
68 export interface ResponsePayload extends JsonObject {
69 status: ResponseStatus
70 hashIdsSucceeded?: string[]
71 hashIdsFailed?: string[]
72 responsesFailed?: BroadcastChannelResponsePayload[]
73 }