Convert interface to type
authorJérôme Benoit <jerome.benoit@sap.com>
Sat, 24 Sep 2022 21:57:03 +0000 (23:57 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sat, 24 Sep 2022 21:57:03 +0000 (23:57 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ui-server/ui-services/AbstractUIService.ts
src/types/ChargingStationInfo.ts
src/types/ChargingStationOcppConfiguration.ts
src/types/ChargingStationWorker.ts
src/types/MeasurandPerPhaseSampledValueTemplates.ts
src/utils/ElectricUtils.ts
src/utils/Logger.ts

index 64053c4200c439729828b3112d218c8db8adf703..729b816dd15c2c9d1ee8a0215480601365f598d7 100644 (file)
@@ -24,7 +24,9 @@ const moduleName = 'AbstractUIService';
 export default abstract class AbstractUIService {
   private static readonly ProcedureNameToBroadCastChannelProcedureNameMap: Omit<
     Record<ProcedureName, BroadcastChannelProcedureName>,
-    'startSimulator' | 'stopSimulator' | 'listChargingStations'
+    | ProcedureName.START_SIMULATOR
+    | ProcedureName.STOP_SIMULATOR
+    | ProcedureName.LIST_CHARGING_STATIONS
   > = {
     [ProcedureName.START_CHARGING_STATION]: BroadcastChannelProcedureName.START_CHARGING_STATION,
     [ProcedureName.STOP_CHARGING_STATION]: BroadcastChannelProcedureName.STOP_CHARGING_STATION,
index f83ba030ab8dd08ab7b8e03d0c77203d9f2a1a49..6509887030e2640cd4a1576cd6472e37a193201a 100644 (file)
@@ -1,16 +1,15 @@
 import type { ChargingStationTemplate } from './ChargingStationTemplate';
 
-export interface ChargingStationInfo
-  extends Omit<
-    ChargingStationTemplate,
-    | 'AutomaticTransactionGenerator'
-    | 'Configuration'
-    | 'power'
-    | 'powerUnit'
-    | 'chargeBoxSerialNumberPrefix'
-    | 'chargePointSerialNumberPrefix'
-    | 'meterSerialNumberPrefix'
-  > {
+export type ChargingStationInfo = Omit<
+  ChargingStationTemplate,
+  | 'AutomaticTransactionGenerator'
+  | 'Configuration'
+  | 'power'
+  | 'powerUnit'
+  | 'chargeBoxSerialNumberPrefix'
+  | 'chargePointSerialNumberPrefix'
+  | 'meterSerialNumberPrefix'
+> & {
   hashId: string;
   infoHash?: string;
   chargingStationId?: string;
@@ -19,7 +18,7 @@ export interface ChargingStationInfo
   meterSerialNumber?: string;
   maximumPower?: number; // Always in Watt
   maximumAmperage?: number; // Always in Ampere
-}
+};
 
 export type ChargingStationInfoConfiguration = {
   stationInfo?: ChargingStationInfo;
index 77c38f04971770aebe2dfe300c41f2a427d750e5..834b1d1dd11e4031eba25d7af689f88eab3b3639 100644 (file)
@@ -1,9 +1,9 @@
 import type { OCPPConfigurationKey } from './ocpp/Configuration';
 
-export interface ConfigurationKey extends OCPPConfigurationKey {
+export type ConfigurationKey = OCPPConfigurationKey & {
   visible?: boolean;
   reboot?: boolean;
-}
+};
 
 export type ChargingStationOcppConfiguration = {
   configurationKey?: ConfigurationKey[];
index 3604a85d01e367d8257838c7eab2aedbbb590c4a..ec6e92b52bf1243ab4f1c77b13265b0ca2239a0a 100644 (file)
@@ -1,3 +1,5 @@
+import type { WebSocket } from 'ws';
+
 import type { Status } from './AutomaticTransactionGenerator';
 import type { ChargingStationInfo } from './ChargingStationInfo';
 import type { ConnectorStatus } from './ConnectorStatus';
@@ -19,7 +21,11 @@ export interface ChargingStationWorkerData extends WorkerData {
 export interface ChargingStationData extends WorkerData {
   stationInfo: ChargingStationInfo;
   started: boolean;
-  wsState?: number;
+  wsState?:
+    | typeof WebSocket.CONNECTING
+    | typeof WebSocket.OPEN
+    | typeof WebSocket.CLOSING
+    | typeof WebSocket.CLOSED;
   bootNotificationResponse: BootNotificationResponse;
   connectors: ConnectorStatus[];
   automaticTransactionGeneratorStatuses?: Status[];
@@ -41,7 +47,6 @@ export const ChargingStationWorkerMessageEvents = {
 
 export type ChargingStationWorkerMessageData = ChargingStationData | Statistics;
 
-export interface ChargingStationWorkerMessage<T extends WorkerData>
-  extends Omit<WorkerMessage<T>, 'id'> {
+export type ChargingStationWorkerMessage<T extends WorkerData> = Omit<WorkerMessage<T>, 'id'> & {
   id: ChargingStationWorkerMessageEvents;
-}
+};
index 34ead1a574a9df526b238794753e4a72f96ca51b..2a534b4a5687996b59ebfeb4798849ff61fa2941 100644 (file)
@@ -1,8 +1,8 @@
 import type { SampledValue } from './ocpp/MeterValues';
 
-export interface SampledValueTemplate extends SampledValue {
+export type SampledValueTemplate = SampledValue & {
   fluctuationPercent?: number;
-}
+};
 
 export type MeasurandPerPhaseSampledValueTemplates = {
   L1?: SampledValueTemplate;
index 9f0c680ac890ed02e2b277776c63e66c3c7f9ea8..b779bf1dffa1d83470ae19ed3754e167b3b1b149 100644 (file)
@@ -50,6 +50,10 @@ export class ACElectricUtils {
  * Targeted to DC related values calculation.
  */
 export class DCElectricUtils {
+  private constructor() {
+    // This is intentional
+  }
+
   static power(V: number, I: number): number {
     return V * I;
   }
index 1baea780f3625896b95b43ca62986756bfd847c0..95d5347da47f12f708f003e5a43df5d36a16ec19 100644 (file)
@@ -38,7 +38,7 @@ if (Configuration.getLogRotate()) {
 const logger: Logger = createLogger({
   level: Configuration.getLogLevel(),
   format: format.combine(format.splat(), (format[Configuration.getLogFormat()] as () => Format)()),
-  transports: transports,
+  transports,
 });
 
 //