| 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 = [ |
| 23 | `${string}-${string}-${string}-${string}-${string}`, |
| 24 | ProcedureName, |
| 25 | RequestPayload |
| 26 | ] |
| 27 | export type ProtocolResponse = [ |
| 28 | `${string}-${string}-${string}-${string}-${string}`, |
| 29 | ResponsePayload |
| 30 | ] |
| 31 | |
| 32 | export type ProtocolRequestHandler = ( |
| 33 | uuid?: `${string}-${string}-${string}-${string}-${string}`, |
| 34 | procedureName?: ProcedureName, |
| 35 | payload?: RequestPayload |
| 36 | ) => undefined | Promise<undefined> | ResponsePayload | Promise<ResponsePayload> |
| 37 | |
| 38 | export 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 | |
| 66 | export interface RequestPayload extends JsonObject { |
| 67 | hashIds?: string[] |
| 68 | connectorIds?: number[] |
| 69 | } |
| 70 | |
| 71 | export enum ResponseStatus { |
| 72 | SUCCESS = 'success', |
| 73 | FAILURE = 'failure' |
| 74 | } |
| 75 | |
| 76 | export interface ResponsePayload extends JsonObject { |
| 77 | status: ResponseStatus |
| 78 | hashIdsSucceeded?: string[] |
| 79 | hashIdsFailed?: string[] |
| 80 | responsesFailed?: BroadcastChannelResponsePayload[] |
| 81 | } |