Commit | Line | Data |
---|---|---|
66a7748d JB |
1 | import type { JsonObject } from './JsonType.js' |
2 | import type { BroadcastChannelResponsePayload } from './WorkerBroadcastChannel.js' | |
d1888640 | 3 | |
4198ad5c | 4 | export enum Protocol { |
a223d9be | 5 | UI = 'ui' |
4198ad5c | 6 | } |
8244f5f0 | 7 | |
675fa8e3 JB |
8 | export enum ApplicationProtocol { |
9 | HTTP = 'http', | |
a223d9be | 10 | WS = 'ws' |
675fa8e3 JB |
11 | } |
12 | ||
eb3abc4f | 13 | export enum AuthenticationType { |
a223d9be | 14 | BASIC_AUTH = 'basic-auth' |
eb3abc4f JB |
15 | } |
16 | ||
8244f5f0 | 17 | export enum ProtocolVersion { |
a223d9be | 18 | '0.0.1' = '0.0.1' |
8244f5f0 JB |
19 | } |
20 | ||
66a7748d JB |
21 | export type ProtocolRequest = [string, ProcedureName, RequestPayload] |
22 | export type ProtocolResponse = [string, ResponsePayload] | |
89b7a234 JB |
23 | |
24 | export type ProtocolRequestHandler = ( | |
4e3ff94d | 25 | uuid?: string, |
5e8e29f4 | 26 | procedureName?: ProcedureName, |
66a7748d JB |
27 | payload?: RequestPayload |
28 | ) => undefined | Promise<undefined> | ResponsePayload | Promise<ResponsePayload> | |
89b7a234 | 29 | |
32de5a57 | 30 | export enum ProcedureName { |
5e8e29f4 JB |
31 | START_SIMULATOR = 'startSimulator', |
32 | STOP_SIMULATOR = 'stopSimulator', | |
42e341c4 | 33 | LIST_TEMPLATES = 'listTemplates', |
ee0f106b | 34 | LIST_CHARGING_STATIONS = 'listChargingStations', |
89b7a234 JB |
35 | START_CHARGING_STATION = 'startChargingStation', |
36 | STOP_CHARGING_STATION = 'stopChargingStation', | |
db2336d9 JB |
37 | OPEN_CONNECTION = 'openConnection', |
38 | CLOSE_CONNECTION = 'closeConnection', | |
4f69be04 JB |
39 | START_AUTOMATIC_TRANSACTION_GENERATOR = 'startAutomaticTransactionGenerator', |
40 | STOP_AUTOMATIC_TRANSACTION_GENERATOR = 'stopAutomaticTransactionGenerator', | |
269de583 | 41 | SET_SUPERVISION_URL = 'setSupervisionUrl', |
5e8e29f4 JB |
42 | START_TRANSACTION = 'startTransaction', |
43 | STOP_TRANSACTION = 'stopTransaction', | |
1984f194 | 44 | AUTHORIZE = 'authorize', |
8bfbc743 | 45 | BOOT_NOTIFICATION = 'bootNotification', |
a9ed42b2 | 46 | STATUS_NOTIFICATION = 'statusNotification', |
10db00b2 | 47 | HEARTBEAT = 'heartbeat', |
d3195f0a | 48 | METER_VALUES = 'meterValues', |
91a7d3ea | 49 | DATA_TRANSFER = 'dataTransfer', |
c9a4f9ea | 50 | DIAGNOSTICS_STATUS_NOTIFICATION = 'diagnosticsStatusNotification', |
a223d9be | 51 | FIRMWARE_STATUS_NOTIFICATION = 'firmwareStatusNotification' |
8244f5f0 | 52 | } |
5612b691 | 53 | |
89b7a234 | 54 | export interface RequestPayload extends JsonObject { |
66a7748d JB |
55 | hashIds?: string[] |
56 | connectorIds?: number[] | |
89b7a234 | 57 | } |
8244f5f0 | 58 | |
32de5a57 LM |
59 | export enum ResponseStatus { |
60 | SUCCESS = 'success', | |
a223d9be | 61 | FAILURE = 'failure' |
32de5a57 LM |
62 | } |
63 | ||
64 | export interface ResponsePayload extends JsonObject { | |
66a7748d JB |
65 | status: ResponseStatus |
66 | hashIdsSucceeded?: string[] | |
67 | hashIdsFailed?: string[] | |
68 | responsesFailed?: BroadcastChannelResponsePayload[] | |
32de5a57 | 69 | } |