From: Jérôme Benoit Date: Thu, 15 Sep 2022 20:59:02 +0000 (+0200) Subject: Convert types to native type X-Git-Tag: v1.1.74~36 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=83e00df1c1ba02de8b637ca4cb0464eb909ebb18;p=e-mobility-charging-stations-simulator.git Convert types to native type Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 1845d35b..93042f20 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -14,7 +14,7 @@ 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 ChargingStationOcppConfiguration from '../types/ChargingStationOcppConfiguration'; +import type { ChargingStationOcppConfiguration } from '../types/ChargingStationOcppConfiguration'; import ChargingStationTemplate, { CurrentType, PowerUnits, diff --git a/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts b/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts index 62fa8e50..f5c4df73 100644 --- a/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts +++ b/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts @@ -2,10 +2,11 @@ import OCPPError from '../../../exception/OCPPError'; import { CurrentType, Voltage } from '../../../types/ChargingStationTemplate'; -import type MeasurandPerPhaseSampledValueTemplates from '../../../types/MeasurandPerPhaseSampledValueTemplates'; -// eslint-disable-next-line no-duplicate-imports -import type { SampledValueTemplate } from '../../../types/MeasurandPerPhaseSampledValueTemplates'; -import type MeasurandValues from '../../../types/MeasurandValues'; +import type { + MeasurandPerPhaseSampledValueTemplates, + SampledValueTemplate, +} from '../../../types/MeasurandPerPhaseSampledValueTemplates'; +import type { MeasurandValues } from '../../../types/MeasurandValues'; import { OCPP16StandardParametersKey, OCPP16SupportedFeatureProfiles, diff --git a/src/types/ChargingStationConfiguration.ts b/src/types/ChargingStationConfiguration.ts index b81f7675..9fd5c247 100644 --- a/src/types/ChargingStationConfiguration.ts +++ b/src/types/ChargingStationConfiguration.ts @@ -1,5 +1,5 @@ import type { ChargingStationInfoConfiguration } from './ChargingStationInfo'; -import type ChargingStationOcppConfiguration from './ChargingStationOcppConfiguration'; +import type { ChargingStationOcppConfiguration } from './ChargingStationOcppConfiguration'; export default interface ChargingStationConfiguration extends ChargingStationInfoConfiguration, diff --git a/src/types/ChargingStationInfo.ts b/src/types/ChargingStationInfo.ts index 192e5771..03273e2a 100644 --- a/src/types/ChargingStationInfo.ts +++ b/src/types/ChargingStationInfo.ts @@ -21,6 +21,6 @@ export default interface ChargingStationInfo maximumAmperage?: number; // Always in Ampere } -export interface ChargingStationInfoConfiguration { +export type ChargingStationInfoConfiguration = { stationInfo?: ChargingStationInfo; -} +}; diff --git a/src/types/ChargingStationOcppConfiguration.ts b/src/types/ChargingStationOcppConfiguration.ts index b6d9ec92..77c38f04 100644 --- a/src/types/ChargingStationOcppConfiguration.ts +++ b/src/types/ChargingStationOcppConfiguration.ts @@ -5,6 +5,6 @@ export interface ConfigurationKey extends OCPPConfigurationKey { reboot?: boolean; } -export default interface ChargingStationOcppConfiguration { +export type ChargingStationOcppConfiguration = { configurationKey?: ConfigurationKey[]; -} +}; diff --git a/src/types/ChargingStationTemplate.ts b/src/types/ChargingStationTemplate.ts index 1c68743d..acf70e49 100644 --- a/src/types/ChargingStationTemplate.ts +++ b/src/types/ChargingStationTemplate.ts @@ -3,7 +3,7 @@ import type { ClientRequestArgs } from 'http'; import type { ClientOptions } from 'ws'; import type { AutomaticTransactionGeneratorConfiguration } from './AutomaticTransactionGenerator'; -import type ChargingStationOcppConfiguration from './ChargingStationOcppConfiguration'; +import type { ChargingStationOcppConfiguration } from './ChargingStationOcppConfiguration'; import type { ConnectorStatus } from './ConnectorStatus'; import type { OCPPProtocol } from './ocpp/OCPPProtocol'; import type { OCPPVersion } from './ocpp/OCPPVersion'; @@ -35,10 +35,10 @@ export enum Voltage { export type WsOptions = ClientOptions & ClientRequestArgs; -interface CommandsSupport { +type CommandsSupport = { incomingCommands: Record; outgoingCommands?: Record; -} +}; export default interface ChargingStationTemplate { templateHash?: string; diff --git a/src/types/ConfigurationData.ts b/src/types/ConfigurationData.ts index fb67bced..ba9fb14c 100644 --- a/src/types/ConfigurationData.ts +++ b/src/types/ConfigurationData.ts @@ -14,12 +14,12 @@ export enum SupervisionUrlDistribution { SEQUENTIAL = 'sequential', } -export interface StationTemplateUrl { +export type StationTemplateUrl = { file: string; numberOfStations: number; -} +}; -export interface UIServerConfiguration { +export type UIServerConfiguration = { enabled?: boolean; type?: ApplicationProtocol; options?: ServerOptions; @@ -29,15 +29,15 @@ export interface UIServerConfiguration { username?: string; password?: string; }; -} +}; -export interface StorageConfiguration { +export type StorageConfiguration = { enabled?: boolean; type?: StorageType; uri?: string; -} +}; -export interface WorkerConfiguration { +export type WorkerConfiguration = { processType?: WorkerProcessType; startDelay?: number; elementsPerWorker?: number; @@ -45,9 +45,9 @@ export interface WorkerConfiguration { poolMinSize?: number; poolMaxSize?: number; poolStrategy?: WorkerChoiceStrategy; -} +}; -export default interface ConfigurationData { +export type ConfigurationData = { supervisionUrls?: string | string[]; supervisionUrlDistribution?: SupervisionUrlDistribution; stationTemplateUrls: StationTemplateUrl[]; @@ -77,4 +77,4 @@ export default interface ConfigurationData { logFile?: string; logErrorFile?: string; logConsole?: boolean; -} +}; diff --git a/src/types/ConnectorStatus.ts b/src/types/ConnectorStatus.ts index abf0c45d..209cd42e 100644 --- a/src/types/ConnectorStatus.ts +++ b/src/types/ConnectorStatus.ts @@ -4,7 +4,7 @@ import type { ChargingProfile } from './ocpp/ChargingProfile'; import type { MeterValue } from './ocpp/MeterValues'; import type { AvailabilityType } from './ocpp/Requests'; -export interface ConnectorStatus { +export type ConnectorStatus = { availability: AvailabilityType; bootStatus?: ChargePointStatus; status?: ChargePointStatus; @@ -22,4 +22,4 @@ export interface ConnectorStatus { transactionEnergyActiveImportRegisterValue?: number; // In Wh transactionBeginMeterValue?: MeterValue; chargingProfiles?: ChargingProfile[]; -} +}; diff --git a/src/types/Error.ts b/src/types/Error.ts index b27f2457..76e3005f 100644 --- a/src/types/Error.ts +++ b/src/types/Error.ts @@ -1,5 +1,5 @@ -export interface HandleErrorParams { +export type HandleErrorParams = { throwError?: boolean; consoleOut?: boolean; errorResponse?: T; -} +}; diff --git a/src/types/MeasurandPerPhaseSampledValueTemplates.ts b/src/types/MeasurandPerPhaseSampledValueTemplates.ts index 2fb8f9ba..34ead1a5 100644 --- a/src/types/MeasurandPerPhaseSampledValueTemplates.ts +++ b/src/types/MeasurandPerPhaseSampledValueTemplates.ts @@ -4,8 +4,8 @@ export interface SampledValueTemplate extends SampledValue { fluctuationPercent?: number; } -export default interface MeasurandPerPhaseSampledValueTemplates { +export type MeasurandPerPhaseSampledValueTemplates = { L1?: SampledValueTemplate; L2?: SampledValueTemplate; L3?: SampledValueTemplate; -} +}; diff --git a/src/types/MeasurandValues.ts b/src/types/MeasurandValues.ts index d66a7645..9adfbf05 100644 --- a/src/types/MeasurandValues.ts +++ b/src/types/MeasurandValues.ts @@ -1,6 +1,6 @@ -export default interface MeasurandValues { +export type MeasurandValues = { L1: number; L2: number; L3: number; allPhases: number; -} +}; diff --git a/src/types/Statistics.ts b/src/types/Statistics.ts index 628ad28b..26f6bc9f 100644 --- a/src/types/Statistics.ts +++ b/src/types/Statistics.ts @@ -1,12 +1,12 @@ import type { CircularArray } from '../utils/CircularArray'; import type { WorkerData } from './Worker'; -export interface TimeSeries { +export type TimeSeries = { timestamp: number; value: number; -} +}; -export interface StatisticsData { +export type StatisticsData = { countRequest: number; countResponse: number; countError: number; @@ -20,7 +20,7 @@ export interface StatisticsData { medTimeMeasurement: number; ninetyFiveThPercentileTimeMeasurement: number; stdDevTimeMeasurement: number; -} +}; export default interface Statistics extends WorkerData { id: string; diff --git a/src/types/Worker.ts b/src/types/Worker.ts index 9d9692a7..c2594b9a 100644 --- a/src/types/Worker.ts +++ b/src/types/Worker.ts @@ -8,7 +8,7 @@ export enum WorkerProcessType { STATIC_POOL = 'staticPool', } -export interface WorkerOptions { +export type WorkerOptions = { workerStartDelay?: number; elementStartDelay?: number; poolMaxSize?: number; @@ -16,19 +16,19 @@ export interface WorkerOptions { elementsPerWorker?: number; poolOptions?: PoolOptions; messageHandler?: (message: unknown) => void | Promise; -} +}; export type WorkerData = Record; -export interface WorkerSetElement { +export type WorkerSetElement = { worker: Worker; numberOfWorkerElements: number; -} +}; -export interface WorkerMessage { +export type WorkerMessage = { id: WorkerMessageEvents; data: T; -} +}; export enum WorkerMessageEvents { START_WORKER_ELEMENT = 'startWorkerElement', diff --git a/src/types/ocpp/Requests.ts b/src/types/ocpp/Requests.ts index 99a3f817..052bfc6b 100644 --- a/src/types/ocpp/Requests.ts +++ b/src/types/ocpp/Requests.ts @@ -21,10 +21,10 @@ export const RequestCommand = { export type OutgoingRequest = [MessageType.CALL_MESSAGE, string, RequestCommand, JsonType]; -export interface RequestParams { +export type RequestParams = { skipBufferingOnError?: boolean; triggerMessage?: boolean; -} +}; export type IncomingRequestCommand = OCPP16IncomingRequestCommand; diff --git a/src/types/ocpp/Responses.ts b/src/types/ocpp/Responses.ts index 43250047..c57510ae 100644 --- a/src/types/ocpp/Responses.ts +++ b/src/types/ocpp/Responses.ts @@ -39,9 +39,9 @@ export enum DefaultStatus { REJECTED = 'Rejected', } -export interface DefaultResponse { +export type DefaultResponse = { status: DefaultStatus; -} +}; export type RegistrationStatus = OCPP16RegistrationStatus; diff --git a/src/ui/web/src/types/ConfigurationType.ts b/src/ui/web/src/types/ConfigurationType.ts index f07f565e..9b748082 100644 --- a/src/ui/web/src/types/ConfigurationType.ts +++ b/src/ui/web/src/types/ConfigurationType.ts @@ -1,11 +1,11 @@ -export interface BaseConfig { +export type BaseConfig = { uiServer: UIServerConfig; -} +}; -interface UIServerConfig { +type UIServerConfig = { host: string; port: number; protocol: string; username?: string; password?: string; -} +}; diff --git a/src/utils/Configuration.ts b/src/utils/Configuration.ts index afc992f8..c90c214d 100644 --- a/src/utils/Configuration.ts +++ b/src/utils/Configuration.ts @@ -4,12 +4,13 @@ import { fileURLToPath } from 'url'; import chalk from 'chalk'; -import ConfigurationData, { - StationTemplateUrl, - StorageConfiguration, +import { + type ConfigurationData, + type StationTemplateUrl, + type StorageConfiguration, SupervisionUrlDistribution, - UIServerConfiguration, - WorkerConfiguration, + type UIServerConfiguration, + type WorkerConfiguration, } from '../types/ConfigurationData'; import type { EmptyObject } from '../types/EmptyObject'; import type { HandleErrorParams } from '../types/Error';