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