From: Jérôme Benoit Date: Fri, 19 May 2023 20:14:39 +0000 (+0200) Subject: refactor: revert internal exports X-Git-Tag: v1.2.14~45 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=69074173770c04bc5e5aa744b655edf9491daa46;p=e-mobility-charging-stations-simulator.git refactor: revert internal exports Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/index.ts b/src/charging-station/index.ts index db87a0d9..ca33e9f4 100644 --- a/src/charging-station/index.ts +++ b/src/charging-station/index.ts @@ -1,4 +1,3 @@ -export { Bootstrap } from './Bootstrap'; export type { ChargingStation } from './ChargingStation'; export { ChargingStationConfigurationUtils } from './ChargingStationConfigurationUtils'; export { ChargingStationUtils } from './ChargingStationUtils'; diff --git a/src/start.ts b/src/start.ts index ee4d336e..23697aca 100644 --- a/src/start.ts +++ b/src/start.ts @@ -2,7 +2,6 @@ import chalk from 'chalk'; -// import { Bootstrap } from './charging-station'; import { Bootstrap } from './charging-station/Bootstrap'; Bootstrap.getInstance() diff --git a/src/types/ChargingStationConfiguration.ts b/src/types/ChargingStationConfiguration.ts index 9f0d3423..ff855650 100644 --- a/src/types/ChargingStationConfiguration.ts +++ b/src/types/ChargingStationConfiguration.ts @@ -1,10 +1,8 @@ -import type { - ChargingStationAutomaticTransactionGeneratorConfiguration, - ChargingStationInfoConfiguration, - ChargingStationOcppConfiguration, - ConnectorStatus, - EvseStatus, -} from './internal'; +import type { ChargingStationAutomaticTransactionGeneratorConfiguration } from './AutomaticTransactionGenerator'; +import type { ChargingStationInfoConfiguration } from './ChargingStationInfo'; +import type { ChargingStationOcppConfiguration } from './ChargingStationOcppConfiguration'; +import type { ConnectorStatus } from './ConnectorStatus'; +import type { EvseStatus } from './Evse'; type ConnectorsConfiguration = { connectorsStatus?: ConnectorStatus[]; diff --git a/src/types/ChargingStationInfo.ts b/src/types/ChargingStationInfo.ts index e56db709..fff8a1ad 100644 --- a/src/types/ChargingStationInfo.ts +++ b/src/types/ChargingStationInfo.ts @@ -1,4 +1,5 @@ -import type { ChargingStationTemplate, FirmwareStatus } from './internal'; +import type { ChargingStationTemplate } from './ChargingStationTemplate'; +import type { FirmwareStatus } from './ocpp/Requests'; enum x509CertificateType { V2GRootCertificate = 'V2GRootCertificate', diff --git a/src/types/ChargingStationOcppConfiguration.ts b/src/types/ChargingStationOcppConfiguration.ts index bbd1bcfb..834b1d1d 100644 --- a/src/types/ChargingStationOcppConfiguration.ts +++ b/src/types/ChargingStationOcppConfiguration.ts @@ -1,4 +1,4 @@ -import type { OCPPConfigurationKey } from './internal'; +import type { OCPPConfigurationKey } from './ocpp/Configuration'; export type ConfigurationKey = OCPPConfigurationKey & { visible?: boolean; diff --git a/src/types/ChargingStationTemplate.ts b/src/types/ChargingStationTemplate.ts index 23644c7f..e3594d02 100644 --- a/src/types/ChargingStationTemplate.ts +++ b/src/types/ChargingStationTemplate.ts @@ -2,18 +2,18 @@ import type { ClientRequestArgs } from 'node:http'; import type { ClientOptions } from 'ws'; +import type { AutomaticTransactionGeneratorConfiguration } from './AutomaticTransactionGenerator'; +import type { ChargingStationOcppConfiguration } from './ChargingStationOcppConfiguration'; +import type { ConnectorStatus } from './ConnectorStatus'; +import type { EvseTemplate } from './Evse'; +import type { OCPPProtocol } from './ocpp/OCPPProtocol'; +import type { OCPPVersion } from './ocpp/OCPPVersion'; import type { - AutomaticTransactionGeneratorConfiguration, - ChargingStationOcppConfiguration, - ConnectorStatus, - EvseTemplate, FirmwareStatus, IncomingRequestCommand, MessageTrigger, - OCPPProtocol, - OCPPVersion, RequestCommand, -} from './internal'; +} from './ocpp/Requests'; export enum CurrentType { AC = 'AC', diff --git a/src/types/ChargingStationWorker.ts b/src/types/ChargingStationWorker.ts index 3164414a..41ca7aac 100644 --- a/src/types/ChargingStationWorker.ts +++ b/src/types/ChargingStationWorker.ts @@ -1,15 +1,13 @@ import type { WebSocket } from 'ws'; -import type { - BootNotificationResponse, - ChargingStationAutomaticTransactionGeneratorConfiguration, - ChargingStationInfo, - ChargingStationOcppConfiguration, - ConnectorStatus, - EvseStatus, - JsonObject, - Statistics, -} from './internal'; +import type { ChargingStationAutomaticTransactionGeneratorConfiguration } from './AutomaticTransactionGenerator'; +import type { ChargingStationInfo } from './ChargingStationInfo'; +import type { ChargingStationOcppConfiguration } from './ChargingStationOcppConfiguration'; +import type { ConnectorStatus } from './ConnectorStatus'; +import type { EvseStatus } from './Evse'; +import type { JsonObject } from './JsonType'; +import type { BootNotificationResponse } from './ocpp/Responses'; +import type { Statistics } from './Statistics'; import { type WorkerData, type WorkerMessage, WorkerMessageEvents } from '../worker'; interface ChargingStationWorkerOptions extends JsonObject { diff --git a/src/types/ConfigurationData.ts b/src/types/ConfigurationData.ts index 5a6853d2..276feabd 100644 --- a/src/types/ConfigurationData.ts +++ b/src/types/ConfigurationData.ts @@ -2,7 +2,8 @@ import type { ListenOptions } from 'node:net'; import type { WorkerChoiceStrategy } from 'poolifier'; -import type { ApplicationProtocol, AuthenticationType, StorageType } from './internal'; +import type { StorageType } from './Storage'; +import type { ApplicationProtocol, AuthenticationType } from './UIProtocol'; import type { WorkerProcessType } from '../worker'; type ServerOptions = ListenOptions; diff --git a/src/types/ConnectorStatus.ts b/src/types/ConnectorStatus.ts index 02ee914e..d7698107 100644 --- a/src/types/ConnectorStatus.ts +++ b/src/types/ConnectorStatus.ts @@ -1,10 +1,8 @@ -import type { - AvailabilityType, - ChargingProfile, - ConnectorStatusEnum, - MeterValue, - SampledValueTemplate, -} from './internal'; +import type { SampledValueTemplate } from './MeasurandPerPhaseSampledValueTemplates'; +import type { ChargingProfile } from './ocpp/ChargingProfile'; +import type { ConnectorStatusEnum } from './ocpp/ConnectorStatusEnum'; +import type { MeterValue } from './ocpp/MeterValues'; +import type { AvailabilityType } from './ocpp/Requests'; export type ConnectorStatus = { availability: AvailabilityType; diff --git a/src/types/Evse.ts b/src/types/Evse.ts index 275969ba..4b200c20 100644 --- a/src/types/Evse.ts +++ b/src/types/Evse.ts @@ -1,4 +1,5 @@ -import type { AvailabilityType, ConnectorStatus } from './internal'; +import type { ConnectorStatus } from './ConnectorStatus'; +import type { AvailabilityType } from './ocpp/Requests'; export type EvseTemplate = { Connectors: Record; diff --git a/src/types/MeasurandPerPhaseSampledValueTemplates.ts b/src/types/MeasurandPerPhaseSampledValueTemplates.ts index 8f69e41c..73df20be 100644 --- a/src/types/MeasurandPerPhaseSampledValueTemplates.ts +++ b/src/types/MeasurandPerPhaseSampledValueTemplates.ts @@ -1,4 +1,4 @@ -import type { SampledValue } from './internal'; +import type { SampledValue } from './ocpp/MeterValues'; export type SampledValueTemplate = SampledValue & { fluctuationPercent?: number; diff --git a/src/types/Statistics.ts b/src/types/Statistics.ts index 5f22cdaf..59d13108 100644 --- a/src/types/Statistics.ts +++ b/src/types/Statistics.ts @@ -1,4 +1,4 @@ -import type { IncomingRequestCommand, RequestCommand } from './internal'; +import type { IncomingRequestCommand, RequestCommand } from './ocpp/Requests'; import type { CircularArray } from '../utils'; import type { WorkerData } from '../worker'; diff --git a/src/types/UIProtocol.ts b/src/types/UIProtocol.ts index e7635b2e..52b91b97 100644 --- a/src/types/UIProtocol.ts +++ b/src/types/UIProtocol.ts @@ -1,4 +1,5 @@ -import type { BroadcastChannelResponsePayload, JsonObject } from './internal'; +import type { JsonObject } from './JsonType'; +import type { BroadcastChannelResponsePayload } from './WorkerBroadcastChannel'; export enum Protocol { UI = 'ui', diff --git a/src/types/WorkerBroadcastChannel.ts b/src/types/WorkerBroadcastChannel.ts index a7a2e1fa..d2afcb90 100644 --- a/src/types/WorkerBroadcastChannel.ts +++ b/src/types/WorkerBroadcastChannel.ts @@ -1,4 +1,4 @@ -import type { RequestPayload, ResponsePayload } from './internal'; +import type { RequestPayload, ResponsePayload } from './UIProtocol'; export type BroadcastChannelRequest = [ string, diff --git a/src/types/index.ts b/src/types/index.ts index 0b54ba11..27ffb6d7 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -1,217 +1,252 @@ export { - AmpereUnits, ApplicationProtocol, AuthenticationType, - AuthorizationStatus, - type AuthorizeRequest, - type AuthorizeResponse, + ProcedureName, + Protocol, + type ProtocolRequest, + type ProtocolRequestHandler, + type ProtocolResponse, + ProtocolVersion, + type RequestPayload, + type ResponsePayload, + ResponseStatus, +} from './UIProtocol'; +export { type AutomaticTransactionGeneratorConfiguration, - AvailabilityStatus, + type ChargingStationAutomaticTransactionGeneratorConfiguration, + IdTagDistribution, + type Status, +} from './AutomaticTransactionGenerator'; +export { AvailabilityType, type BootNotificationRequest, - type BootNotificationResponse, - BootReasonEnumType, - BroadcastChannelProcedureName, - type BroadcastChannelRequest, - type BroadcastChannelRequestPayload, - type BroadcastChannelResponse, - type BroadcastChannelResponsePayload, type CachedRequest, - type ChangeAvailabilityRequest, - type ChangeAvailabilityResponse, - type ChangeConfigurationRequest, - type ChangeConfigurationResponse, - ChargePointErrorCode, - type ChargingProfile, - ChargingProfileKindType, - ChargingProfileStatus, - ChargingRateUnitType, - type ChargingSchedulePeriod, - type ChargingStationAutomaticTransactionGeneratorConfiguration, - type ChargingStationConfiguration, - type ChargingStationData, - type ChargingStationInfo, - type ChargingStationOcppConfiguration, - type ChargingStationTemplate, - type ChargingStationWorkerData, - type ChargingStationWorkerMessage, - type ChargingStationWorkerMessageData, - ChargingStationWorkerMessageEvents, - type ClearCacheResponse, - type ClearChargingProfileRequest, - type ClearChargingProfileResponse, - ClearChargingProfileStatus, - type ConfigurationData, - type ConfigurationKey, - type ConfigurationKeyType, - ConfigurationStatus, - ConnectorPhaseRotation, - type ConnectorStatus, - ConnectorStatusEnum, - type ConnectorStatusTransition, - CurrentType, - DBName, type DataTransferRequest, - type DataTransferResponse, - DataTransferStatus, type DiagnosticsStatusNotificationRequest, - type DiagnosticsStatusNotificationResponse, - type EmptyObject, type ErrorCallback, - type ErrorResponse, - ErrorType, - type EvseStatus, - type EvseStatusConfiguration, - type EvseTemplate, - FileType, FirmwareStatus, type FirmwareStatusNotificationRequest, - type FirmwareStatusNotificationResponse, - type FirmwareUpgrade, - type GenericResponse, - GenericStatus, - type GetConfigurationRequest, - type GetConfigurationResponse, - type GetDiagnosticsRequest, - type GetDiagnosticsResponse, - type HandleErrorParams, type HeartbeatRequest, - type HeartbeatResponse, - IdTagDistribution, type IncomingRequest, IncomingRequestCommand, type IncomingRequestHandler, - type JsonObject, - type JsonType, - type MeasurandPerPhaseSampledValueTemplates, - type MeasurandValues, - type MessageEvent, MessageTrigger, - MessageType, - type MeterValue, - MeterValueContext, - MeterValueLocation, - MeterValueMeasurand, - type MeterValuePhase, - MeterValueUnit, type MeterValuesRequest, + type OutgoingRequest, + RequestCommand, + type RequestParams, + type ResponseCallback, + type ResponseType, + type StatusNotificationRequest, +} from './ocpp/Requests'; +export { + AvailabilityStatus, + type BootNotificationResponse, + ChargingProfileStatus, + ClearChargingProfileStatus, + type ClearCacheResponse, + ConfigurationStatus, + DataTransferStatus, + type DataTransferResponse, + type DiagnosticsStatusNotificationResponse, + type ErrorResponse, + type FirmwareStatusNotificationResponse, + GenericStatus, + type GenericResponse, + type HeartbeatResponse, type MeterValuesResponse, - type MikroOrmDbType, - OCPP16AuthorizationStatus, - type OCPP16AuthorizeRequest, - type OCPP16AuthorizeResponse, + RegistrationStatusEnumType, + type Response, + type ResponseHandler, + type StatusNotificationResponse, + TriggerMessageStatus, + UnlockStatus, +} from './ocpp/Responses'; +export { + AuthorizationStatus, + type AuthorizeRequest, + type AuthorizeResponse, + type StartTransactionRequest, + type StartTransactionResponse, + StopTransactionReason, + type StopTransactionRequest, + type StopTransactionResponse, +} from './ocpp/Transaction'; +export { BootReasonEnumType, OCPP20ConnectorStatusEnumType } from './ocpp/2.0/Common'; +export { + BroadcastChannelProcedureName, + type BroadcastChannelRequest, + type BroadcastChannelRequestPayload, + type BroadcastChannelResponse, + type BroadcastChannelResponsePayload, + type MessageEvent, +} from './WorkerBroadcastChannel'; +export { + type ChangeAvailabilityRequest, + type ChangeConfigurationRequest, + type ClearChargingProfileRequest, + type GetConfigurationRequest, + type GetDiagnosticsRequest, OCPP16AvailabilityType, type OCPP16BootNotificationRequest, - type OCPP16BootNotificationResponse, - OCPP16ChargePointErrorCode, - OCPP16ChargePointStatus, - type OCPP16ChargingProfile, - OCPP16ChargingProfilePurposeType, - type OCPP16ChargingSchedule, type OCPP16ClearCacheRequest, type OCPP16DataTransferRequest, - type OCPP16DataTransferResponse, - OCPP16DataTransferStatus, OCPP16DataTransferVendorId, - OCPP16DiagnosticsStatus, type OCPP16DiagnosticsStatusNotificationRequest, - type OCPP16DiagnosticsStatusNotificationResponse, OCPP16FirmwareStatus, type OCPP16FirmwareStatusNotificationRequest, - type OCPP16FirmwareStatusNotificationResponse, type OCPP16GetCompositeScheduleRequest, - type OCPP16GetCompositeScheduleResponse, type OCPP16HeartbeatRequest, - type OCPP16HeartbeatResponse, OCPP16IncomingRequestCommand, OCPP16MessageTrigger, + OCPP16RequestCommand, + type OCPP16StatusNotificationRequest, + type OCPP16TriggerMessageRequest, + type OCPP16UpdateFirmwareRequest, + type RemoteStartTransactionRequest, + type RemoteStopTransactionRequest, + type ResetRequest, + type SetChargingProfileRequest, + type UnlockConnectorRequest, +} from './ocpp/1.6/Requests'; +export { + type ChangeAvailabilityResponse, + type ChangeConfigurationResponse, + type ClearChargingProfileResponse, + type GetConfigurationResponse, + type GetDiagnosticsResponse, + type OCPP16BootNotificationResponse, + type OCPP16DataTransferResponse, + OCPP16DataTransferStatus, + type OCPP16DiagnosticsStatusNotificationResponse, + type OCPP16FirmwareStatusNotificationResponse, + type OCPP16GetCompositeScheduleResponse, + type OCPP16HeartbeatResponse, + type OCPP16StatusNotificationResponse, + type OCPP16TriggerMessageResponse, + type OCPP16UpdateFirmwareResponse, + type SetChargingProfileResponse, + type UnlockConnectorResponse, +} from './ocpp/1.6/Responses'; +export { ChargePointErrorCode } from './ocpp/ChargePointErrorCode'; +export { + type ChargingProfile, + ChargingProfileKindType, + ChargingRateUnitType, + type ChargingSchedulePeriod, + RecurrencyKindType, +} from './ocpp/ChargingProfile'; +export type { + ChargingStationConfiguration, + EvseStatusConfiguration, +} from './ChargingStationConfiguration'; +export { + type ChargingStationData, + type ChargingStationWorkerData, + type ChargingStationWorkerMessage, + type ChargingStationWorkerMessageData, + ChargingStationWorkerMessageEvents, +} from './ChargingStationWorker'; +export type { ChargingStationInfo } from './ChargingStationInfo'; +export type { + ChargingStationOcppConfiguration, + ConfigurationKey, +} from './ChargingStationOcppConfiguration'; +export { + AmpereUnits, + type ChargingStationTemplate, + CurrentType, + type FirmwareUpgrade, + PowerUnits, + Voltage, + type WsOptions, +} from './ChargingStationTemplate'; +export { + type ConfigurationData, + type StationTemplateUrl, + type StorageConfiguration, + SupervisionUrlDistribution, + type UIServerConfiguration, + type WorkerConfiguration, +} from './ConfigurationData'; +export { + type ConfigurationKeyType, + ConnectorPhaseRotation, + type OCPPConfigurationKey, + StandardParametersKey, + SupportedFeatureProfiles, + VendorParametersKey, +} from './ocpp/Configuration'; +export type { ConnectorStatus } from './ConnectorStatus'; +export { ConnectorStatusEnum, type ConnectorStatusTransition } from './ocpp/ConnectorStatusEnum'; +export { DBName, type MikroOrmDbType, StorageType } from './Storage'; +export type { EmptyObject } from './EmptyObject'; +export { ErrorType } from './ocpp/ErrorType'; +export type { EvseTemplate, EvseStatus } from './Evse'; +export { FileType } from './FileType'; +export type { HandleErrorParams } from './Error'; +export type { JsonObject, JsonType } from './JsonType'; +export type { + MeasurandPerPhaseSampledValueTemplates, + SampledValueTemplate, +} from './MeasurandPerPhaseSampledValueTemplates'; +export type { MeasurandValues } from './MeasurandValues'; +export { MessageType } from './ocpp/MessageType'; +export { type MeterValue, MeterValueMeasurand, MeterValuePhase } from './ocpp/MeterValues'; +export { + MeterValueContext, + MeterValueLocation, + MeterValueUnit, type OCPP16MeterValue, OCPP16MeterValueMeasurand, OCPP16MeterValuePhase, type OCPP16MeterValuesRequest, type OCPP16MeterValuesResponse, - OCPP16RequestCommand, type OCPP16SampledValue, - OCPP16StandardParametersKey, +} from './ocpp/1.6/MeterValues'; +export { + OCPP16AuthorizationStatus, + type OCPP16AuthorizeRequest, + type OCPP16AuthorizeResponse, type OCPP16StartTransactionRequest, type OCPP16StartTransactionResponse, - type OCPP16StatusNotificationRequest, - type OCPP16StatusNotificationResponse, OCPP16StopTransactionReason, type OCPP16StopTransactionRequest, type OCPP16StopTransactionResponse, +} from './ocpp/1.6/Transaction'; +export { OCPP16ChargePointErrorCode } from './ocpp/1.6/ChargePointErrorCode'; +export { OCPP16ChargePointStatus } from './ocpp/1.6/ChargePointStatus'; +export { + type OCPP16ChargingProfile, + OCPP16ChargingProfilePurposeType, + type OCPP16ChargingSchedule, +} from './ocpp/1.6/ChargingProfile'; +export { + OCPP16StandardParametersKey, OCPP16SupportedFeatureProfiles, - type OCPP16TriggerMessageRequest, - type OCPP16TriggerMessageResponse, - type OCPP16UpdateFirmwareRequest, - type OCPP16UpdateFirmwareResponse, +} from './ocpp/1.6/Configuration'; +export { OCPP16DiagnosticsStatus } from './ocpp/1.6/DiagnosticsStatus'; +export { type OCPP20BootNotificationRequest, - type OCPP20BootNotificationResponse, type OCPP20ClearCacheRequest, - type OCPP20ClearCacheResponse, - OCPP20ConnectorStatusEnumType, type OCPP20HeartbeatRequest, - type OCPP20HeartbeatResponse, OCPP20IncomingRequestCommand, - OCPP20OptionalVariableName, OCPP20RequestCommand, type OCPP20StatusNotificationRequest, - type OCPP20StatusNotificationResponse, - type OCPPConfigurationKey, - OCPPVersion, - type OutgoingRequest, - PerformanceData, - PerformanceRecord, - PowerUnits, - ProcedureName, - Protocol, - type ProtocolRequest, - type ProtocolRequestHandler, - type ProtocolResponse, - ProtocolVersion, - RecurrencyKindType, - RegistrationStatusEnumType, - type RemoteStartTransactionRequest, - type RemoteStopTransactionRequest, - RequestCommand, - type RequestParams, - type RequestPayload, - type ResetRequest, - type Response, - type ResponseCallback, - type ResponseHandler, - type ResponsePayload, - ResponseStatus, - type ResponseType, - type SampledValueTemplate, - type SetChargingProfileRequest, - type SetChargingProfileResponse, - StandardParametersKey, - type StartTransactionRequest, - type StartTransactionResponse, - type StationTemplateUrl, - type Statistics, - type Status, - type StatusNotificationRequest, - type StatusNotificationResponse, - StopTransactionReason, - type StopTransactionRequest, - type StopTransactionResponse, - type StorageConfiguration, - StorageType, - SupervisionUrlDistribution, - SupportedFeatureProfiles, - type TimeSeries, - TriggerMessageStatus, - type UIServerConfiguration, - type UnlockConnectorRequest, - type UnlockConnectorResponse, - UnlockStatus, - VendorParametersKey, - Voltage, +} from './ocpp/2.0/Requests'; +export type { + OCPP20BootNotificationResponse, + OCPP20ClearCacheResponse, + OCPP20HeartbeatResponse, + OCPP20StatusNotificationResponse, +} from './ocpp/2.0/Responses'; +export { OCPP20OptionalVariableName } from './ocpp/2.0/Variables'; +export { OCPPVersion } from './ocpp/OCPPVersion'; +export { PerformanceData } from './orm/entities/PerformanceData'; +export { PerformanceRecord } from './orm/entities/PerformanceRecord'; +export type { Statistics, TimeSeries } from './Statistics'; +export { type WSError, WebSocketCloseEventStatusCode, WebSocketCloseEventStatusString, - type WorkerConfiguration, - type WsOptions, -} from './internal'; +} from './WebSocket'; diff --git a/src/types/internal.ts b/src/types/internal.ts deleted file mode 100644 index 86151c8f..00000000 --- a/src/types/internal.ts +++ /dev/null @@ -1,56 +0,0 @@ -export { OCPP16ChargePointErrorCode } from './ocpp/1.6/ChargePointErrorCode'; -export { OCPP16ChargePointStatus } from './ocpp/1.6/ChargePointStatus'; -export * from './ocpp/1.6/ChargingProfile'; -export * from './ocpp/1.6/Configuration'; -export { OCPP16DiagnosticsStatus } from './ocpp/1.6/DiagnosticsStatus'; -export * from './ocpp/1.6/MeterValues'; -export * from './ocpp/1.6/Requests'; -export * from './ocpp/1.6/Responses'; -export * from './ocpp/1.6/Transaction'; -export * from './ocpp/2.0/Common'; -export * from './ocpp/2.0/Requests'; -export * from './ocpp/2.0/Responses'; -export * from './ocpp/2.0/Variables'; -export * from './ocpp/ChargePointErrorCode'; -export * from './ocpp/ChargingProfile'; -export * from './ocpp/Configuration'; -export * from './ocpp/ConnectorStatusEnum'; -export { ErrorType } from './ocpp/ErrorType'; -export { MessageType } from './ocpp/MessageType'; -export * from './ocpp/MeterValues'; -export { OCPPProtocol } from './ocpp/OCPPProtocol'; -export { OCPPVersion } from './ocpp/OCPPVersion'; -export * from './ocpp/Requests'; -export * from './ocpp/Responses'; -export * from './ocpp/Transaction'; -export * from './orm/entities/PerformanceData'; -export * from './orm/entities/PerformanceRecord'; -export { - type AutomaticTransactionGeneratorConfiguration, - type ChargingStationAutomaticTransactionGeneratorConfiguration, - IdTagDistribution, - type Status, -} from './AutomaticTransactionGenerator'; -export * from './ChargingStationConfiguration'; -export type { ChargingStationInfo, ChargingStationInfoConfiguration } from './ChargingStationInfo'; -export * from './ChargingStationOcppConfiguration'; -export * from './ChargingStationTemplate'; -export * from './ChargingStationWorker'; -export * from './ConfigurationData'; -export type { EvseTemplate, EvseStatus } from './Evse'; -export type { ConnectorStatus } from './ConnectorStatus'; -export type { EmptyObject } from './EmptyObject'; -export type { HandleErrorParams } from './Error'; -export { FileType } from './FileType'; -export type { JsonObject, JsonType } from './JsonType'; -export * from './MeasurandPerPhaseSampledValueTemplates'; -export type { MeasurandValues } from './MeasurandValues'; -export * from './Statistics'; -export * from './Storage'; -export * from './UIProtocol'; -export { - type WSError, - WebSocketCloseEventStatusCode, - WebSocketCloseEventStatusString, -} from './WebSocket'; -export * from './WorkerBroadcastChannel'; diff --git a/src/types/ocpp/1.6/ChargingProfile.ts b/src/types/ocpp/1.6/ChargingProfile.ts index 67e12f97..b2909699 100644 --- a/src/types/ocpp/1.6/ChargingProfile.ts +++ b/src/types/ocpp/1.6/ChargingProfile.ts @@ -1,4 +1,4 @@ -import type { JsonObject } from '../../internal'; +import type { JsonObject } from '../../JsonType'; export interface OCPP16ChargingProfile extends JsonObject { chargingProfileId: number; diff --git a/src/types/ocpp/1.6/MeterValues.ts b/src/types/ocpp/1.6/MeterValues.ts index 5a59230c..74698284 100644 --- a/src/types/ocpp/1.6/MeterValues.ts +++ b/src/types/ocpp/1.6/MeterValues.ts @@ -1,4 +1,5 @@ -import type { EmptyObject, JsonObject } from '../../internal'; +import type { EmptyObject } from '../../EmptyObject'; +import type { JsonObject } from '../../JsonType'; export enum MeterValueUnit { WATT_HOUR = 'Wh', diff --git a/src/types/ocpp/1.6/Requests.ts b/src/types/ocpp/1.6/Requests.ts index 73401d35..60c1787f 100644 --- a/src/types/ocpp/1.6/Requests.ts +++ b/src/types/ocpp/1.6/Requests.ts @@ -1,15 +1,14 @@ +import type { OCPP16ChargePointErrorCode } from './ChargePointErrorCode'; +import type { OCPP16ChargePointStatus } from './ChargePointStatus'; import type { - EmptyObject, - JsonObject, - OCPP16ChargePointErrorCode, - OCPP16ChargePointStatus, OCPP16ChargingProfile, OCPP16ChargingProfilePurposeType, OCPP16ChargingRateUnitType, - OCPP16DiagnosticsStatus, - OCPP16StandardParametersKey, - OCPP16VendorParametersKey, -} from '../../internal'; +} from './ChargingProfile'; +import type { OCPP16StandardParametersKey, OCPP16VendorParametersKey } from './Configuration'; +import type { OCPP16DiagnosticsStatus } from './DiagnosticsStatus'; +import type { EmptyObject } from '../../EmptyObject'; +import type { JsonObject } from '../../JsonType'; export enum OCPP16RequestCommand { BOOT_NOTIFICATION = 'BootNotification', diff --git a/src/types/ocpp/1.6/Responses.ts b/src/types/ocpp/1.6/Responses.ts index e7814c4f..a6683caa 100644 --- a/src/types/ocpp/1.6/Responses.ts +++ b/src/types/ocpp/1.6/Responses.ts @@ -1,11 +1,8 @@ -import type { - EmptyObject, - GenericStatus, - JsonObject, - OCPP16ChargingSchedule, - OCPPConfigurationKey, - RegistrationStatusEnumType, -} from '../../internal'; +import type { OCPP16ChargingSchedule } from './ChargingProfile'; +import type { EmptyObject } from '../../EmptyObject'; +import type { JsonObject } from '../../JsonType'; +import type { OCPPConfigurationKey } from '../Configuration'; +import type { GenericStatus, RegistrationStatusEnumType } from '../Responses'; export interface OCPP16HeartbeatResponse extends JsonObject { currentTime: Date; diff --git a/src/types/ocpp/1.6/Transaction.ts b/src/types/ocpp/1.6/Transaction.ts index 215628f7..4af42747 100644 --- a/src/types/ocpp/1.6/Transaction.ts +++ b/src/types/ocpp/1.6/Transaction.ts @@ -1,4 +1,5 @@ -import type { JsonObject, OCPP16MeterValue } from '../../internal'; +import type { OCPP16MeterValue } from './MeterValues'; +import type { JsonObject } from '../../JsonType'; export enum OCPP16StopTransactionReason { NONE = '', diff --git a/src/types/ocpp/2.0/Common.ts b/src/types/ocpp/2.0/Common.ts index c73c19e3..511cce00 100644 --- a/src/types/ocpp/2.0/Common.ts +++ b/src/types/ocpp/2.0/Common.ts @@ -1,4 +1,5 @@ -import type { GenericStatus, JsonObject } from '../../internal'; +import type { JsonObject } from '../../JsonType'; +import type { GenericStatus } from '../Responses'; export enum DataEnumType { // eslint-disable-next-line id-blacklist @@ -93,7 +94,7 @@ export enum CertificateSigningUseEnumType { V2GCertificate = 'V2GCertificate', } -export type CertificateSignedStatusEnumType = GenericStatus; +export type CertificateSignedStatusEnumType = GenericStatusEnumType; export type CertificateHashDataType = { hashAlgorithm: HashAlgorithmEnumType; diff --git a/src/types/ocpp/2.0/Requests.ts b/src/types/ocpp/2.0/Requests.ts index d584c828..1b99c272 100644 --- a/src/types/ocpp/2.0/Requests.ts +++ b/src/types/ocpp/2.0/Requests.ts @@ -1,11 +1,11 @@ import type { BootReasonEnumType, - EmptyObject, InstallCertificateUseEnumType, - JsonObject, OCPP20ConnectorStatusEnumType, - OCPP20SetVariableDataType, -} from '../../internal'; +} from './Common'; +import type { OCPP20SetVariableDataType } from './Variables'; +import type { EmptyObject } from '../../EmptyObject'; +import type { JsonObject } from '../../JsonType'; export enum OCPP20RequestCommand { BOOT_NOTIFICATION = 'BootNotification', diff --git a/src/types/ocpp/2.0/Responses.ts b/src/types/ocpp/2.0/Responses.ts index 5fac747a..ab6357a9 100644 --- a/src/types/ocpp/2.0/Responses.ts +++ b/src/types/ocpp/2.0/Responses.ts @@ -1,12 +1,12 @@ import type { - EmptyObject, - GenericStatus, + GenericStatusEnumType, InstallCertificateStatusEnumType, - JsonObject, - OCPP20SetVariableResultType, - RegistrationStatusEnumType, StatusInfoType, -} from '../../internal'; +} from './Common'; +import type { OCPP20SetVariableResultType } from './Variables'; +import type { EmptyObject } from '../../EmptyObject'; +import type { JsonObject } from '../../JsonType'; +import type { RegistrationStatusEnumType } from '../Responses'; export type OCPP20BootNotificationResponse = { currentTime: Date; @@ -20,7 +20,7 @@ export type OCPP20HeartbeatResponse = { } & JsonObject; export type OCPP20ClearCacheResponse = { - status: GenericStatus; + status: GenericStatusEnumType; statusInfo?: StatusInfoType; } & JsonObject; diff --git a/src/types/ocpp/2.0/Variables.ts b/src/types/ocpp/2.0/Variables.ts index 0b089567..59b1b023 100644 --- a/src/types/ocpp/2.0/Variables.ts +++ b/src/types/ocpp/2.0/Variables.ts @@ -1,4 +1,5 @@ -import type { EVSEType, JsonObject, StatusInfoType } from '../../internal'; +import type { EVSEType, StatusInfoType } from './Common'; +import type { JsonObject } from '../../JsonType'; enum OCPP20ComponentName { AlignedDataCtrlr = 'AlignedDataCtrlr', diff --git a/src/types/ocpp/ChargePointErrorCode.ts b/src/types/ocpp/ChargePointErrorCode.ts index 9e70845d..d08f17a0 100644 --- a/src/types/ocpp/ChargePointErrorCode.ts +++ b/src/types/ocpp/ChargePointErrorCode.ts @@ -1,4 +1,4 @@ -import { OCPP16ChargePointErrorCode } from '../internal'; +import { OCPP16ChargePointErrorCode } from './1.6/ChargePointErrorCode'; export const ChargePointErrorCode = { ...OCPP16ChargePointErrorCode, diff --git a/src/types/ocpp/ChargingProfile.ts b/src/types/ocpp/ChargingProfile.ts index 0b21f109..bd67417e 100644 --- a/src/types/ocpp/ChargingProfile.ts +++ b/src/types/ocpp/ChargingProfile.ts @@ -4,7 +4,7 @@ import { OCPP16ChargingRateUnitType, type OCPP16ChargingSchedulePeriod, OCPP16RecurrencyKindType, -} from '../internal'; +} from './1.6/ChargingProfile'; export type ChargingProfile = OCPP16ChargingProfile; diff --git a/src/types/ocpp/Configuration.ts b/src/types/ocpp/Configuration.ts index 39739a8f..3081f13d 100644 --- a/src/types/ocpp/Configuration.ts +++ b/src/types/ocpp/Configuration.ts @@ -1,12 +1,14 @@ import { - type JsonObject, OCPP16StandardParametersKey, OCPP16SupportedFeatureProfiles, OCPP16VendorParametersKey, +} from './1.6/Configuration'; +import { OCPP20OptionalVariableName, OCPP20RequiredVariableName, OCPP20VendorVariableName, -} from '../internal'; +} from './2.0/Variables'; +import type { JsonObject } from '../JsonType'; export const StandardParametersKey = { ...OCPP16StandardParametersKey, diff --git a/src/types/ocpp/ConnectorStatusEnum.ts b/src/types/ocpp/ConnectorStatusEnum.ts index 6c251cb7..d3ac3e02 100644 --- a/src/types/ocpp/ConnectorStatusEnum.ts +++ b/src/types/ocpp/ConnectorStatusEnum.ts @@ -1,4 +1,5 @@ -import { OCPP16ChargePointStatus, OCPP20ConnectorStatusEnumType } from '../internal'; +import { OCPP16ChargePointStatus } from './1.6/ChargePointStatus'; +import { OCPP20ConnectorStatusEnumType } from './2.0/Common'; export const ConnectorStatusEnum = { ...OCPP16ChargePointStatus, diff --git a/src/types/ocpp/MeterValues.ts b/src/types/ocpp/MeterValues.ts index 10b8323d..f34a8c17 100644 --- a/src/types/ocpp/MeterValues.ts +++ b/src/types/ocpp/MeterValues.ts @@ -3,7 +3,7 @@ import { OCPP16MeterValueMeasurand, OCPP16MeterValuePhase, type OCPP16SampledValue, -} from '../internal'; +} from './1.6/MeterValues'; export const MeterValueMeasurand = { ...OCPP16MeterValueMeasurand, diff --git a/src/types/ocpp/Requests.ts b/src/types/ocpp/Requests.ts index 72555e64..7eef7b5b 100644 --- a/src/types/ocpp/Requests.ts +++ b/src/types/ocpp/Requests.ts @@ -1,27 +1,29 @@ -import type { ChargingStation } from '../../charging-station'; -import type { OCPPError } from '../../exception'; +import { OCPP16DiagnosticsStatus } from './1.6/DiagnosticsStatus'; +import type { OCPP16MeterValuesRequest } from './1.6/MeterValues'; import { - type JsonType, - type MessageType, OCPP16AvailabilityType, type OCPP16BootNotificationRequest, type OCPP16DataTransferRequest, - OCPP16DiagnosticsStatus, type OCPP16DiagnosticsStatusNotificationRequest, OCPP16FirmwareStatus, type OCPP16FirmwareStatusNotificationRequest, type OCPP16HeartbeatRequest, OCPP16IncomingRequestCommand, OCPP16MessageTrigger, - type OCPP16MeterValuesRequest, OCPP16RequestCommand, type OCPP16StatusNotificationRequest, +} from './1.6/Requests'; +import { OperationalStatusEnumType } from './2.0/Common'; +import { type OCPP20BootNotificationRequest, OCPP20IncomingRequestCommand, OCPP20RequestCommand, type OCPP20StatusNotificationRequest, - OperationalStatusEnumType, -} from '../internal'; +} from './2.0/Requests'; +import type { MessageType } from './MessageType'; +import type { ChargingStation } from '../../charging-station'; +import type { OCPPError } from '../../exception'; +import type { JsonType } from '../JsonType'; export const RequestCommand = { ...OCPP16RequestCommand, diff --git a/src/types/ocpp/Responses.ts b/src/types/ocpp/Responses.ts index f14ef426..24b8b848 100644 --- a/src/types/ocpp/Responses.ts +++ b/src/types/ocpp/Responses.ts @@ -1,8 +1,5 @@ -import type { ChargingStation } from '../../charging-station'; +import type { OCPP16MeterValuesResponse } from './1.6/MeterValues'; import { - type ErrorType, - type JsonType, - type MessageType, OCPP16AvailabilityStatus, type OCPP16BootNotificationResponse, OCPP16ChargingProfileStatus, @@ -13,14 +10,19 @@ import { type OCPP16DiagnosticsStatusNotificationResponse, type OCPP16FirmwareStatusNotificationResponse, type OCPP16HeartbeatResponse, - type OCPP16MeterValuesResponse, type OCPP16StatusNotificationResponse, OCPP16TriggerMessageStatus, OCPP16UnlockStatus, - type OCPP20BootNotificationResponse, - type OCPP20ClearCacheResponse, - type OCPP20StatusNotificationResponse, -} from '../internal'; +} from './1.6/Responses'; +import type { + OCPP20BootNotificationResponse, + OCPP20ClearCacheResponse, + OCPP20StatusNotificationResponse, +} from './2.0/Responses'; +import type { ErrorType } from './ErrorType'; +import type { MessageType } from './MessageType'; +import type { ChargingStation } from '../../charging-station'; +import type { JsonType } from '../JsonType'; export type Response = [MessageType.CALL_RESULT_MESSAGE, string, JsonType]; diff --git a/src/types/ocpp/Transaction.ts b/src/types/ocpp/Transaction.ts index 1ce9d987..2a8a0ad4 100644 --- a/src/types/ocpp/Transaction.ts +++ b/src/types/ocpp/Transaction.ts @@ -7,7 +7,7 @@ import { OCPP16StopTransactionReason, type OCPP16StopTransactionRequest, type OCPP16StopTransactionResponse, -} from '../internal'; +} from './1.6/Transaction'; export const AuthorizationStatus = { ...OCPP16AuthorizationStatus, diff --git a/src/types/orm/entities/PerformanceData.ts b/src/types/orm/entities/PerformanceData.ts index ef847e74..fc7268aa 100644 --- a/src/types/orm/entities/PerformanceData.ts +++ b/src/types/orm/entities/PerformanceData.ts @@ -1,6 +1,6 @@ import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'; -import type { PerformanceRecord } from '../../internal'; +import type { PerformanceRecord } from './PerformanceRecord'; @Entity() export class PerformanceData { diff --git a/src/types/orm/entities/PerformanceRecord.ts b/src/types/orm/entities/PerformanceRecord.ts index 1369377d..06114da6 100644 --- a/src/types/orm/entities/PerformanceRecord.ts +++ b/src/types/orm/entities/PerformanceRecord.ts @@ -1,6 +1,6 @@ import { Collection, Entity, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'; -import type { PerformanceData } from '../../internal'; +import type { PerformanceData } from './PerformanceData'; @Entity() export class PerformanceRecord { diff --git a/src/utils/Configuration.ts b/src/utils/Configuration.ts index 47c5e160..0ed294c0 100644 --- a/src/utils/Configuration.ts +++ b/src/utils/Configuration.ts @@ -7,7 +7,6 @@ import merge from 'just-merge'; import { WorkerChoiceStrategies } from 'poolifier'; import { Constants } from './Constants'; -import { FileUtils } from './FileUtils'; import { Utils } from './Utils'; import { ApplicationProtocol, @@ -349,12 +348,11 @@ export class Configuration { fs.readFileSync(Configuration.configurationFile, 'utf8') ) as ConfigurationData; } catch (error) { - FileUtils.handleFileException( + Configuration.handleFileException( Configuration.configurationFile, FileType.Configuration, error as NodeJS.ErrnoException, - Configuration.logPrefix(), - { consoleOut: true } + Configuration.logPrefix() ); } if (!Configuration.configurationFileWatcher) { @@ -378,16 +376,39 @@ export class Configuration { } }); } catch (error) { - FileUtils.handleFileException( + Configuration.handleFileException( Configuration.configurationFile, FileType.Configuration, error as NodeJS.ErrnoException, - Configuration.logPrefix(), - { consoleOut: true } + Configuration.logPrefix() ); } } + private static handleFileException( + file: string, + fileType: FileType, + error: NodeJS.ErrnoException, + logPrefix: string + ): void { + const prefix = Utils.isNotEmptyString(logPrefix) ? `${logPrefix} ` : ''; + let logMsg: string; + switch (error.code) { + case 'ENOENT': + logMsg = `${fileType} file ${file} not found:`; + break; + case 'EEXIST': + logMsg = `${fileType} file ${file} already exists:`; + break; + case 'EACCES': + logMsg = `${fileType} file ${file} access denied:`; + break; + default: + logMsg = `${fileType} file ${file} error:`; + } + console.warn(`${chalk.green(prefix)}${chalk.yellow(`${logMsg} `)}`, error); + } + private static getDefaultPerformanceStorageUri(storageType: StorageType) { switch (storageType) { case StorageType.JSON_FILE: diff --git a/src/utils/FileUtils.ts b/src/utils/FileUtils.ts index 9b7f62e0..e08fb128 100644 --- a/src/utils/FileUtils.ts +++ b/src/utils/FileUtils.ts @@ -65,8 +65,7 @@ export class FileUtils { logMsg = `${fileType} file ${file} error:`; } if (params?.consoleOut) { - logMsg = `${logMsg} `; - console.warn(`${chalk.green(prefix)}${chalk.yellow(logMsg)}`, error); + console.warn(`${chalk.green(prefix)}${chalk.yellow(`${logMsg} `)}`, error); } else { logger.warn(`${prefix}${logMsg}`, error); }