From: Jérôme Benoit Date: Tue, 20 Sep 2022 21:10:08 +0000 (+0200) Subject: Replace more interface with type for types definition X-Git-Tag: v1.1.74~25 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=981ebfbeeb421a4b620aa61861f9ddb313a03f67;p=e-mobility-charging-stations-simulator.git Replace more interface with type for types definition Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index d3c33fc3..0a3d544a 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -12,13 +12,14 @@ import BaseError from '../exception/BaseError'; import OCPPError from '../exception/OCPPError'; import PerformanceStatistics from '../performance/PerformanceStatistics'; import type { AutomaticTransactionGeneratorConfiguration } from '../types/AutomaticTransactionGenerator'; -import type ChargingStationConfiguration from '../types/ChargingStationConfiguration'; -import type ChargingStationInfo from '../types/ChargingStationInfo'; +import type { ChargingStationConfiguration } from '../types/ChargingStationConfiguration'; +import type { ChargingStationInfo } from '../types/ChargingStationInfo'; import type { ChargingStationOcppConfiguration } from '../types/ChargingStationOcppConfiguration'; -import ChargingStationTemplate, { +import { + type ChargingStationTemplate, CurrentType, PowerUnits, - WsOptions, + type WsOptions, } from '../types/ChargingStationTemplate'; import { SupervisionUrlDistribution } from '../types/ConfigurationData'; import type { ConnectorStatus } from '../types/ConnectorStatus'; diff --git a/src/charging-station/ChargingStationUtils.ts b/src/charging-station/ChargingStationUtils.ts index 28f38b46..e6b9c17d 100644 --- a/src/charging-station/ChargingStationUtils.ts +++ b/src/charging-station/ChargingStationUtils.ts @@ -5,9 +5,10 @@ import { fileURLToPath } from 'url'; import moment from 'moment'; import BaseError from '../exception/BaseError'; -import type ChargingStationInfo from '../types/ChargingStationInfo'; -import ChargingStationTemplate, { +import type { ChargingStationInfo } from '../types/ChargingStationInfo'; +import { AmpereUnits, + type ChargingStationTemplate, CurrentType, Voltage, } from '../types/ChargingStationTemplate'; @@ -17,7 +18,7 @@ import type { ChargingProfile, ChargingSchedulePeriod } from '../types/ocpp/Char import { StandardParametersKey } from '../types/ocpp/Configuration'; import { MeterValueMeasurand, MeterValuePhase } from '../types/ocpp/MeterValues'; import { - BootNotificationRequest, + type BootNotificationRequest, IncomingRequestCommand, RequestCommand, } from '../types/ocpp/Requests'; diff --git a/src/charging-station/SharedLRUCache.ts b/src/charging-station/SharedLRUCache.ts index 01e18734..e02f6ac6 100644 --- a/src/charging-station/SharedLRUCache.ts +++ b/src/charging-station/SharedLRUCache.ts @@ -1,7 +1,7 @@ import LRUCache from 'mnemonist/lru-map-with-delete'; -import type ChargingStationConfiguration from '../types/ChargingStationConfiguration'; -import type ChargingStationTemplate from '../types/ChargingStationTemplate'; +import type { ChargingStationConfiguration } from '../types/ChargingStationConfiguration'; +import type { ChargingStationTemplate } from '../types/ChargingStationTemplate'; import Utils from '../utils/Utils'; enum CacheType { diff --git a/src/types/AutomaticTransactionGenerator.ts b/src/types/AutomaticTransactionGenerator.ts index f88659bf..c8ce3c9a 100644 --- a/src/types/AutomaticTransactionGenerator.ts +++ b/src/types/AutomaticTransactionGenerator.ts @@ -28,3 +28,8 @@ export type Status = { skippedConsecutiveTransactions?: number; skippedTransactions?: number; }; + +export type ChargingStationAutomaticTransactionGeneratorConfiguration = { + automaticTransactionGenerator?: AutomaticTransactionGeneratorConfiguration; + automaticTransactionGeneratorStatus?: Status; +}; diff --git a/src/types/ChargingStationConfiguration.ts b/src/types/ChargingStationConfiguration.ts index 9fd5c247..f0107a65 100644 --- a/src/types/ChargingStationConfiguration.ts +++ b/src/types/ChargingStationConfiguration.ts @@ -1,8 +1,9 @@ +import type { ChargingStationAutomaticTransactionGeneratorConfiguration } from './AutomaticTransactionGenerator'; import type { ChargingStationInfoConfiguration } from './ChargingStationInfo'; import type { ChargingStationOcppConfiguration } from './ChargingStationOcppConfiguration'; -export default interface ChargingStationConfiguration - extends ChargingStationInfoConfiguration, - ChargingStationOcppConfiguration { - configurationHash?: string; -} +export type ChargingStationConfiguration = ChargingStationInfoConfiguration & + ChargingStationOcppConfiguration & + ChargingStationAutomaticTransactionGeneratorConfiguration & { + configurationHash?: string; + }; diff --git a/src/types/ChargingStationInfo.ts b/src/types/ChargingStationInfo.ts index 03273e2a..f83ba030 100644 --- a/src/types/ChargingStationInfo.ts +++ b/src/types/ChargingStationInfo.ts @@ -1,6 +1,6 @@ -import type ChargingStationTemplate from './ChargingStationTemplate'; +import type { ChargingStationTemplate } from './ChargingStationTemplate'; -export default interface ChargingStationInfo +export interface ChargingStationInfo extends Omit< ChargingStationTemplate, | 'AutomaticTransactionGenerator' diff --git a/src/types/ChargingStationTemplate.ts b/src/types/ChargingStationTemplate.ts index acf70e49..0d063d51 100644 --- a/src/types/ChargingStationTemplate.ts +++ b/src/types/ChargingStationTemplate.ts @@ -40,7 +40,7 @@ type CommandsSupport = { outgoingCommands?: Record; }; -export default interface ChargingStationTemplate { +export type ChargingStationTemplate = { templateHash?: string; supervisionUrls?: string | string[]; supervisionUrlOcppConfiguration?: boolean; @@ -96,4 +96,4 @@ export default interface ChargingStationTemplate { Configuration?: ChargingStationOcppConfiguration; AutomaticTransactionGenerator?: AutomaticTransactionGeneratorConfiguration; Connectors: Record; -} +}; diff --git a/src/types/ChargingStationWorker.ts b/src/types/ChargingStationWorker.ts index 58e10ce8..3604a85d 100644 --- a/src/types/ChargingStationWorker.ts +++ b/src/types/ChargingStationWorker.ts @@ -1,5 +1,5 @@ import type { Status } from './AutomaticTransactionGenerator'; -import type ChargingStationInfo from './ChargingStationInfo'; +import type { ChargingStationInfo } from './ChargingStationInfo'; import type { ConnectorStatus } from './ConnectorStatus'; import type { JsonObject } from './JsonType'; import type { BootNotificationResponse } from './ocpp/Responses';