| 1 | import type { JsonObject } from './JsonType'; |
| 2 | import type { BroadcastChannelResponsePayload } from './WorkerBroadcastChannel'; |
| 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 | } |
| 16 | |
| 17 | export enum ProtocolVersion { |
| 18 | '0.0.1' = '0.0.1', |
| 19 | } |
| 20 | |
| 21 | export type ProtocolRequest = [string, ProcedureName, RequestPayload]; |
| 22 | export type ProtocolResponse = [string, ResponsePayload]; |
| 23 | |
| 24 | export type ProtocolRequestHandler = ( |
| 25 | uuid?: string, |
| 26 | procedureName?: ProcedureName, |
| 27 | payload?: RequestPayload |
| 28 | ) => undefined | Promise<undefined> | ResponsePayload | Promise<ResponsePayload>; |
| 29 | |
| 30 | export enum ProcedureName { |
| 31 | START_SIMULATOR = 'startSimulator', |
| 32 | STOP_SIMULATOR = 'stopSimulator', |
| 33 | LIST_CHARGING_STATIONS = 'listChargingStations', |
| 34 | START_CHARGING_STATION = 'startChargingStation', |
| 35 | STOP_CHARGING_STATION = 'stopChargingStation', |
| 36 | OPEN_CONNECTION = 'openConnection', |
| 37 | CLOSE_CONNECTION = 'closeConnection', |
| 38 | START_AUTOMATIC_TRANSACTION_GENERATOR = 'startAutomaticTransactionGenerator', |
| 39 | STOP_AUTOMATIC_TRANSACTION_GENERATOR = 'stopAutomaticTransactionGenerator', |
| 40 | SET_SUPERVISION_URL = 'setSupervisionUrl', |
| 41 | START_TRANSACTION = 'startTransaction', |
| 42 | STOP_TRANSACTION = 'stopTransaction', |
| 43 | AUTHORIZE = 'authorize', |
| 44 | BOOT_NOTIFICATION = 'bootNotification', |
| 45 | STATUS_NOTIFICATION = 'statusNotification', |
| 46 | HEARTBEAT = 'heartbeat', |
| 47 | METER_VALUES = 'meterValues', |
| 48 | DATA_TRANSFER = 'dataTransfer', |
| 49 | DIAGNOSTICS_STATUS_NOTIFICATION = 'diagnosticsStatusNotification', |
| 50 | FIRMWARE_STATUS_NOTIFICATION = 'firmwareStatusNotification', |
| 51 | } |
| 52 | |
| 53 | export interface RequestPayload extends JsonObject { |
| 54 | hashIds?: string[]; |
| 55 | connectorIds?: number[]; |
| 56 | } |
| 57 | |
| 58 | export enum ResponseStatus { |
| 59 | SUCCESS = 'success', |
| 60 | FAILURE = 'failure', |
| 61 | } |
| 62 | |
| 63 | export interface ResponsePayload extends JsonObject { |
| 64 | status: ResponseStatus; |
| 65 | hashIdsSucceeded?: string[]; |
| 66 | hashIdsFailed?: string[]; |
| 67 | responsesFailed?: BroadcastChannelResponsePayload[]; |
| 68 | } |