UI protocol: move Insomnia requests collection to its own directory
[e-mobility-charging-stations-simulator.git] / src / types / WorkerBroadcastChannel.ts
index 61a47fa02eb272e0b98ca41efdee3c465d3175c4..788f7d68f864c63f3dce8f88e558d3fc6c94e496 100644 (file)
@@ -1,8 +1,34 @@
-import { ChargingStationData } from './ChargingStationWorker';
+import type { RequestPayload, ResponsePayload } from './UIProtocol';
 
-// TODO: use a base payload type and extends it per procedure name
-export interface WorkerBroadcastChannelData extends ChargingStationData {
+export type BroadcastChannelRequest = [
+  string,
+  BroadcastChannelProcedureName,
+  BroadcastChannelRequestPayload
+];
+export type BroadcastChannelResponse = [string, BroadcastChannelResponsePayload];
+
+export enum BroadcastChannelProcedureName {
+  START_CHARGING_STATION = 'startChargingStation',
+  STOP_CHARGING_STATION = 'stopChargingStation',
+  OPEN_CONNECTION = 'openConnection',
+  CLOSE_CONNECTION = 'closeConnection',
+  START_TRANSACTION = 'startTransaction',
+  STOP_TRANSACTION = 'stopTransaction',
+  START_AUTOMATIC_TRANSACTION_GENERATOR = 'startAutomaticTransactionGenerator',
+  STOP_AUTOMATIC_TRANSACTION_GENERATOR = 'stopAutomaticTransactionGenerator',
+  STATUS_NOTIFICATION = 'statusNotification',
+  HEARTBEAT = 'heartbeat',
+}
+
+export interface BroadcastChannelRequestPayload extends RequestPayload {
   connectorId?: number;
   transactionId?: number;
   idTag?: string;
 }
+
+export interface BroadcastChannelResponsePayload
+  extends Omit<ResponsePayload, 'hashIdsSucceeded' | 'hashIdsFailed' | 'responsesFailed'> {
+  hashId: string;
+}
+
+export type MessageEvent = { data: BroadcastChannelRequest | BroadcastChannelResponse };