build(deps-dev): apply updates
[e-mobility-charging-stations-simulator.git] / src / types / UIProtocol.ts
CommitLineData
66a7748d
JB
1import type { JsonObject } from './JsonType.js'
2import type { BroadcastChannelResponsePayload } from './WorkerBroadcastChannel.js'
d1888640 3
4198ad5c 4export enum Protocol {
a223d9be 5 UI = 'ui'
4198ad5c 6}
8244f5f0 7
675fa8e3
JB
8export enum ApplicationProtocol {
9 HTTP = 'http',
a223d9be 10 WS = 'ws'
675fa8e3
JB
11}
12
eb3abc4f 13export enum AuthenticationType {
329eab0e
JB
14 BASIC_AUTH = 'basic-auth',
15 PROTOCOL_BASIC_AUTH = 'protocol-basic-auth'
eb3abc4f
JB
16}
17
8244f5f0 18export enum ProtocolVersion {
a223d9be 19 '0.0.1' = '0.0.1'
8244f5f0
JB
20}
21
2c5c7443
JB
22export type ProtocolRequest = [
23 `${string}-${string}-${string}-${string}-${string}`,
24 ProcedureName,
25 RequestPayload
26]
27export type ProtocolResponse = [
28 `${string}-${string}-${string}-${string}-${string}`,
29 ResponsePayload
30]
89b7a234
JB
31
32export type ProtocolRequestHandler = (
2c5c7443 33 uuid?: `${string}-${string}-${string}-${string}-${string}`,
5e8e29f4 34 procedureName?: ProcedureName,
66a7748d
JB
35 payload?: RequestPayload
36) => undefined | Promise<undefined> | ResponsePayload | Promise<ResponsePayload>
89b7a234 37
32de5a57 38export enum ProcedureName {
240fa4da 39 SIMULATOR_STATE = 'simulatorState',
5e8e29f4
JB
40 START_SIMULATOR = 'startSimulator',
41 STOP_SIMULATOR = 'stopSimulator',
42e341c4 42 LIST_TEMPLATES = 'listTemplates',
ee0f106b 43 LIST_CHARGING_STATIONS = 'listChargingStations',
c5ecc04d 44 ADD_CHARGING_STATIONS = 'addChargingStations',
09e5a7a8 45 DELETE_CHARGING_STATIONS = 'deleteChargingStations',
a66bbcfe 46 PERFORMANCE_STATISTICS = 'performanceStatistics',
89b7a234
JB
47 START_CHARGING_STATION = 'startChargingStation',
48 STOP_CHARGING_STATION = 'stopChargingStation',
db2336d9
JB
49 OPEN_CONNECTION = 'openConnection',
50 CLOSE_CONNECTION = 'closeConnection',
4f69be04
JB
51 START_AUTOMATIC_TRANSACTION_GENERATOR = 'startAutomaticTransactionGenerator',
52 STOP_AUTOMATIC_TRANSACTION_GENERATOR = 'stopAutomaticTransactionGenerator',
269de583 53 SET_SUPERVISION_URL = 'setSupervisionUrl',
5e8e29f4
JB
54 START_TRANSACTION = 'startTransaction',
55 STOP_TRANSACTION = 'stopTransaction',
1984f194 56 AUTHORIZE = 'authorize',
8bfbc743 57 BOOT_NOTIFICATION = 'bootNotification',
a9ed42b2 58 STATUS_NOTIFICATION = 'statusNotification',
10db00b2 59 HEARTBEAT = 'heartbeat',
d3195f0a 60 METER_VALUES = 'meterValues',
91a7d3ea 61 DATA_TRANSFER = 'dataTransfer',
c9a4f9ea 62 DIAGNOSTICS_STATUS_NOTIFICATION = 'diagnosticsStatusNotification',
a223d9be 63 FIRMWARE_STATUS_NOTIFICATION = 'firmwareStatusNotification'
8244f5f0 64}
5612b691 65
89b7a234 66export interface RequestPayload extends JsonObject {
66a7748d
JB
67 hashIds?: string[]
68 connectorIds?: number[]
89b7a234 69}
8244f5f0 70
32de5a57
LM
71export enum ResponseStatus {
72 SUCCESS = 'success',
a223d9be 73 FAILURE = 'failure'
32de5a57
LM
74}
75
76export interface ResponsePayload extends JsonObject {
66a7748d
JB
77 status: ResponseStatus
78 hashIdsSucceeded?: string[]
79 hashIdsFailed?: string[]
80 responsesFailed?: BroadcastChannelResponsePayload[]
32de5a57 81}