From 2896e06dc8d72adf7150b23c941079f622f6f37c Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 13 Feb 2023 20:55:35 +0100 Subject: [PATCH] refactor(simulator): switch to internal modules export/import design pattern MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit should close all issues related circular module dependencies Signed-off-by: Jérôme Benoit --- rollup.config.mjs | 2 +- .../AutomaticTransactionGenerator.ts | 6 +-- src/charging-station/Bootstrap.ts | 3 +- src/charging-station/ChargingStation.ts | 31 ++++++++----- .../ChargingStationConfigurationUtils.ts | 2 +- src/charging-station/ChargingStationUtils.ts | 2 +- src/charging-station/ChargingStationWorker.ts | 3 +- .../ChargingStationWorkerBroadcastChannel.ts | 8 ++-- src/charging-station/MessageChannelUtils.ts | 2 +- .../UIServiceWorkerBroadcastChannel.ts | 3 +- src/charging-station/index.ts | 8 +++- src/charging-station/internal.ts | 13 +++++- .../ocpp/1.6/OCPP16IncomingRequestService.ts | 12 ++--- .../ocpp/1.6/OCPP16RequestService.ts | 12 +++-- .../ocpp/1.6/OCPP16ResponseService.ts | 6 +-- .../ocpp/1.6/OCPP16ServiceUtils.ts | 4 +- .../ocpp/2.0/OCPP20IncomingRequestService.ts | 5 +- .../ocpp/2.0/OCPP20RequestService.ts | 12 +++-- .../ocpp/2.0/OCPP20ResponseService.ts | 6 +-- .../ocpp/2.0/OCPP20ServiceUtils.ts | 2 +- .../ocpp/OCPPIncomingRequestService.ts | 6 +-- .../ocpp/OCPPRequestService.ts | 8 ++-- .../ocpp/OCPPResponseService.ts | 4 +- src/charging-station/ocpp/OCPPServiceUtils.ts | 3 +- src/charging-station/ocpp/index.ts | 24 +++++----- src/charging-station/ocpp/internal.ts | 15 ++++++ .../ui-server/UIHttpServer.ts | 3 +- .../ui-server/UIServerFactory.ts | 3 +- .../ui-server/UIWebSocketServer.ts | 3 +- .../ui-services/AbstractUIService.ts | 3 +- src/exception/OCPPError.ts | 2 +- src/exception/index.ts | 3 +- src/exception/internal.ts | 2 + src/performance/PerformanceStatistics.ts | 2 +- src/performance/index.ts | 4 +- src/performance/internal.ts | 7 +++ src/performance/storage/JsonFileStorage.ts | 2 +- src/performance/storage/MikroOrmStorage.ts | 2 +- src/performance/storage/MongoDBStorage.ts | 2 +- src/performance/storage/StorageFactory.ts | 5 +- src/types/ChargingStationConfiguration.ts | 8 ++-- src/types/ChargingStationInfo.ts | 3 +- src/types/ChargingStationOcppConfiguration.ts | 2 +- src/types/ChargingStationTemplate.ts | 12 ++--- src/types/ChargingStationWorker.ts | 14 +++--- src/types/ConfigurationData.ts | 3 +- src/types/ConnectorStatus.ts | 12 +++-- src/types/Statistics.ts | 2 +- src/types/UIProtocol.ts | 3 +- src/types/WorkerBroadcastChannel.ts | 2 +- src/types/index.ts | 46 +------------------ src/types/internal.ts | 45 ++++++++++++++++++ src/types/ocpp/1.6/ChargingProfile.ts | 2 +- src/types/ocpp/1.6/MeterValues.ts | 3 +- src/types/ocpp/1.6/Requests.ts | 17 ++++--- src/types/ocpp/1.6/Responses.ts | 10 ++-- src/types/ocpp/1.6/Transaction.ts | 3 +- src/types/ocpp/2.0/Requests.ts | 3 +- src/types/ocpp/2.0/Responses.ts | 9 ++-- src/types/ocpp/ChargePointErrorCode.ts | 2 +- src/types/ocpp/ChargingProfile.ts | 2 +- src/types/ocpp/Configuration.ts | 6 +-- src/types/ocpp/ConnectorStatusEnum.ts | 3 +- src/types/ocpp/MeterValues.ts | 2 +- src/types/ocpp/Requests.ts | 16 +++---- src/types/ocpp/Responses.ts | 20 ++++---- src/types/ocpp/Transaction.ts | 2 +- src/types/orm/entities/PerformanceData.ts | 2 +- src/types/orm/entities/PerformanceRecord.ts | 2 +- src/worker/index.ts | 8 ++-- 70 files changed, 273 insertions(+), 236 deletions(-) create mode 100644 src/charging-station/ocpp/internal.ts create mode 100644 src/exception/internal.ts create mode 100644 src/performance/internal.ts create mode 100644 src/types/internal.ts diff --git a/rollup.config.mjs b/rollup.config.mjs index 6b113491..b97343c8 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -12,7 +12,7 @@ export default { output: [ { dir: 'dist', - format: 'es', + format: 'esm', exports: 'auto', sourcemap: true, preserveModules: true, diff --git a/src/charging-station/AutomaticTransactionGenerator.ts b/src/charging-station/AutomaticTransactionGenerator.ts index e6b3dbf4..8bb33b81 100644 --- a/src/charging-station/AutomaticTransactionGenerator.ts +++ b/src/charging-station/AutomaticTransactionGenerator.ts @@ -2,10 +2,10 @@ import { AsyncResource } from 'async_hooks'; -import type { ChargingStation } from './ChargingStation'; -import { ChargingStationUtils } from './ChargingStationUtils'; +import { type ChargingStation, ChargingStationUtils } from './internal'; import { BaseError } from '../exception'; -import { PerformanceStatistics } from '../performance'; +// import { PerformanceStatistics } from '../performance'; +import { PerformanceStatistics } from '../performance/PerformanceStatistics'; import { AuthorizationStatus, type AuthorizeRequest, diff --git a/src/charging-station/Bootstrap.ts b/src/charging-station/Bootstrap.ts index c35464d1..f5322532 100644 --- a/src/charging-station/Bootstrap.ts +++ b/src/charging-station/Bootstrap.ts @@ -6,8 +6,7 @@ import { type Worker, isMainThread } from 'worker_threads'; import chalk from 'chalk'; -import { ChargingStationUtils } from './ChargingStationUtils'; -import { type AbstractUIServer, UIServerFactory } from './internal'; +import { type AbstractUIServer, ChargingStationUtils, UIServerFactory } from './internal'; import { version } from '../../package.json'; import { BaseError } from '../exception'; import { type Storage, StorageFactory } from '../performance'; diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 29119f92..fe6bd0d9 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -9,27 +9,34 @@ import { parentPort } from 'worker_threads'; import merge from 'just-merge'; import WebSocket, { type RawData } from 'ws'; -import { AuthorizedTagsCache } from './AuthorizedTagsCache'; -import { AutomaticTransactionGenerator } from './AutomaticTransactionGenerator'; -import { ChargingStationConfigurationUtils } from './ChargingStationConfigurationUtils'; -import { ChargingStationUtils } from './ChargingStationUtils'; -import { ChargingStationWorkerBroadcastChannel } from './ChargingStationWorkerBroadcastChannel'; -import { MessageChannelUtils } from './MessageChannelUtils'; import { - OCPP16IncomingRequestService, + AuthorizedTagsCache, + AutomaticTransactionGenerator, + ChargingStationConfigurationUtils, + ChargingStationUtils, + ChargingStationWorkerBroadcastChannel, + MessageChannelUtils, + SharedLRUCache, +} from './internal'; +import { + // OCPP16IncomingRequestService, OCPP16RequestService, - OCPP16ResponseService, + // OCPP16ResponseService, OCPP16ServiceUtils, OCPP20IncomingRequestService, OCPP20RequestService, - OCPP20ResponseService, + // OCPP20ResponseService, type OCPPIncomingRequestService, type OCPPRequestService, - OCPPServiceUtils, + // OCPPServiceUtils, } from './ocpp'; -import { SharedLRUCache } from './SharedLRUCache'; +import { OCPP16IncomingRequestService } from './ocpp/1.6/OCPP16IncomingRequestService'; +import { OCPP16ResponseService } from './ocpp/1.6/OCPP16ResponseService'; +import { OCPP20ResponseService } from './ocpp/2.0/OCPP20ResponseService'; +import { OCPPServiceUtils } from './ocpp/OCPPServiceUtils'; import { BaseError, OCPPError } from '../exception'; -import { PerformanceStatistics } from '../performance'; +// import { PerformanceStatistics } from '../performance'; +import { PerformanceStatistics } from '../performance/PerformanceStatistics'; import { type AutomaticTransactionGeneratorConfiguration, AvailabilityType, diff --git a/src/charging-station/ChargingStationConfigurationUtils.ts b/src/charging-station/ChargingStationConfigurationUtils.ts index 541fd445..342fe6d2 100644 --- a/src/charging-station/ChargingStationConfigurationUtils.ts +++ b/src/charging-station/ChargingStationConfigurationUtils.ts @@ -1,4 +1,4 @@ -import type { ChargingStation } from './ChargingStation'; +import type { ChargingStation } from './internal'; import type { ConfigurationKey, StandardParametersKey } from '../types'; import { logger } from '../utils/Logger'; diff --git a/src/charging-station/ChargingStationUtils.ts b/src/charging-station/ChargingStationUtils.ts index 92ed0406..7254734a 100644 --- a/src/charging-station/ChargingStationUtils.ts +++ b/src/charging-station/ChargingStationUtils.ts @@ -4,7 +4,7 @@ import { fileURLToPath } from 'node:url'; import moment from 'moment'; -import type { ChargingStation } from './ChargingStation'; +import type { ChargingStation } from './internal'; import { BaseError } from '../exception'; import { AmpereUnits, diff --git a/src/charging-station/ChargingStationWorker.ts b/src/charging-station/ChargingStationWorker.ts index d28204e3..3a1859a4 100644 --- a/src/charging-station/ChargingStationWorker.ts +++ b/src/charging-station/ChargingStationWorker.ts @@ -4,8 +4,7 @@ import { parentPort, workerData } from 'worker_threads'; import { ThreadWorker } from 'poolifier'; -import { ChargingStation } from './ChargingStation'; -import { ChargingStationUtils } from './ChargingStationUtils'; +import { ChargingStation, ChargingStationUtils } from './internal'; import type { ChargingStationWorkerData } from '../types'; import { Utils } from '../utils/Utils'; import { WorkerConstants, type WorkerMessage, WorkerMessageEvents } from '../worker'; diff --git a/src/charging-station/ChargingStationWorkerBroadcastChannel.ts b/src/charging-station/ChargingStationWorkerBroadcastChannel.ts index 1a2943a7..02febe4a 100644 --- a/src/charging-station/ChargingStationWorkerBroadcastChannel.ts +++ b/src/charging-station/ChargingStationWorkerBroadcastChannel.ts @@ -1,7 +1,9 @@ -import type { ChargingStation } from './ChargingStation'; -import { ChargingStationConfigurationUtils } from './ChargingStationConfigurationUtils'; +import { + type ChargingStation, + ChargingStationConfigurationUtils, + WorkerBroadcastChannel, +} from './internal'; import { OCPP16ServiceUtils } from './ocpp'; -import { WorkerBroadcastChannel } from './WorkerBroadcastChannel'; import { BaseError, type OCPPError } from '../exception'; import { AuthorizationStatus, diff --git a/src/charging-station/MessageChannelUtils.ts b/src/charging-station/MessageChannelUtils.ts index d8f1aa10..749a21dd 100644 --- a/src/charging-station/MessageChannelUtils.ts +++ b/src/charging-station/MessageChannelUtils.ts @@ -1,4 +1,4 @@ -import type { ChargingStation } from './ChargingStation'; +import type { ChargingStation } from './internal'; import { type ChargingStationData, type ChargingStationWorkerMessage, diff --git a/src/charging-station/UIServiceWorkerBroadcastChannel.ts b/src/charging-station/UIServiceWorkerBroadcastChannel.ts index 3a21bc73..d9e74639 100644 --- a/src/charging-station/UIServiceWorkerBroadcastChannel.ts +++ b/src/charging-station/UIServiceWorkerBroadcastChannel.ts @@ -1,5 +1,4 @@ -import type { AbstractUIService } from './internal'; -import { WorkerBroadcastChannel } from './WorkerBroadcastChannel'; +import { type AbstractUIService, WorkerBroadcastChannel } from './internal'; import { type BroadcastChannelResponse, type BroadcastChannelResponsePayload, diff --git a/src/charging-station/index.ts b/src/charging-station/index.ts index c365e0b9..3b7660fe 100644 --- a/src/charging-station/index.ts +++ b/src/charging-station/index.ts @@ -1 +1,7 @@ -export { Bootstrap } from './internal'; +export { + Bootstrap, + type ChargingStation, + ChargingStationConfigurationUtils, + ChargingStationUtils, + MessageChannelUtils, +} from './internal'; diff --git a/src/charging-station/internal.ts b/src/charging-station/internal.ts index 314c9685..1f2fef1f 100644 --- a/src/charging-station/internal.ts +++ b/src/charging-station/internal.ts @@ -1,8 +1,19 @@ +export * from './AuthorizedTagsCache'; +export * from './AutomaticTransactionGenerator'; export * from './Bootstrap'; +export * from './ChargingStation'; +export * from './ChargingStationConfigurationUtils'; +export * from './ChargingStationUtils'; +export * from './ChargingStationWorkerBroadcastChannel'; +export * from './MessageChannelUtils'; +export * from './SharedLRUCache'; +export * from './UIServiceWorkerBroadcastChannel'; +export * from './WorkerBroadcastChannel'; export * from './ui-server/AbstractUIServer'; export * from './ui-server/UIHttpServer'; -export * from './ui-server/UIWebSocketServer'; export * from './ui-server/UIServerFactory'; +export * from './ui-server/UIServerUtils'; +export * from './ui-server/UIWebSocketServer'; export * from './ui-server/ui-services/AbstractUIService'; export * from './ui-server/ui-services/UIService001'; export * from './ui-server/ui-services/UIServiceFactory'; diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index e6b8cc97..029c422e 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -8,7 +8,11 @@ import type { JSONSchemaType } from 'ajv'; import { Client, type FTPResponse } from 'basic-ftp'; import tar from 'tar'; -import { OCPP16ServiceUtils } from './OCPP16ServiceUtils'; +import { + type ChargingStation, + ChargingStationConfigurationUtils, + ChargingStationUtils, +} from '../../../charging-station'; import { OCPPError } from '../../../exception'; import { type ChangeAvailabilityRequest, @@ -76,11 +80,7 @@ import { import { Constants } from '../../../utils/Constants'; import { logger } from '../../../utils/Logger'; import { Utils } from '../../../utils/Utils'; -import type { ChargingStation } from '../../ChargingStation'; -import { ChargingStationConfigurationUtils } from '../../ChargingStationConfigurationUtils'; -import { ChargingStationUtils } from '../../ChargingStationUtils'; -import { OCPPConstants } from '../OCPPConstants'; -import { OCPPIncomingRequestService } from '../OCPPIncomingRequestService'; +import { OCPP16ServiceUtils, OCPPConstants, OCPPIncomingRequestService } from '../internal'; const moduleName = 'OCPP16IncomingRequestService'; diff --git a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts index efbd603c..7686e734 100644 --- a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts @@ -2,7 +2,7 @@ import type { JSONSchemaType } from 'ajv'; -import { OCPP16ServiceUtils } from './OCPP16ServiceUtils'; +import type { ChargingStation } from '../../../charging-station'; import { OCPPError } from '../../../exception'; import { ErrorType, @@ -24,10 +24,12 @@ import { } from '../../../types'; import { Constants } from '../../../utils/Constants'; import { Utils } from '../../../utils/Utils'; -import type { ChargingStation } from '../../ChargingStation'; -import { OCPPConstants } from '../OCPPConstants'; -import { OCPPRequestService } from '../OCPPRequestService'; -import type { OCPPResponseService } from '../OCPPResponseService'; +import { + OCPP16ServiceUtils, + OCPPConstants, + OCPPRequestService, + type OCPPResponseService, +} from '../internal'; const moduleName = 'OCPP16RequestService'; diff --git a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts index 958f1a5d..540ce937 100644 --- a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts @@ -2,7 +2,7 @@ import type { JSONSchemaType } from 'ajv'; -import { OCPP16ServiceUtils } from './OCPP16ServiceUtils'; +import { type ChargingStation, ChargingStationConfigurationUtils } from '../../../charging-station'; import { OCPPError } from '../../../exception'; import { type ChangeAvailabilityResponse, @@ -47,9 +47,7 @@ import { import { Constants } from '../../../utils/Constants'; import { logger } from '../../../utils/Logger'; import { Utils } from '../../../utils/Utils'; -import type { ChargingStation } from '../../ChargingStation'; -import { ChargingStationConfigurationUtils } from '../../ChargingStationConfigurationUtils'; -import { OCPPResponseService } from '../OCPPResponseService'; +import { OCPP16ServiceUtils, OCPPResponseService } from '../internal'; const moduleName = 'OCPP16ResponseService'; diff --git a/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts b/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts index 528a8aa7..f57eaa8e 100644 --- a/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts +++ b/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts @@ -5,6 +5,7 @@ import { fileURLToPath } from 'node:url'; import type { JSONSchemaType } from 'ajv'; +import type { ChargingStation } from '../../../charging-station'; import { OCPPError } from '../../../exception'; import { CurrentType, @@ -32,8 +33,7 @@ import { Constants } from '../../../utils/Constants'; import { ACElectricUtils, DCElectricUtils } from '../../../utils/ElectricUtils'; import { logger } from '../../../utils/Logger'; import { Utils } from '../../../utils/Utils'; -import type { ChargingStation } from '../../ChargingStation'; -import { OCPPServiceUtils } from '../OCPPServiceUtils'; +import { OCPPServiceUtils } from '../internal'; export class OCPP16ServiceUtils extends OCPPServiceUtils { public static checkFeatureProfile( diff --git a/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts b/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts index 95169e2b..1c700272 100644 --- a/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts +++ b/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts @@ -2,7 +2,7 @@ import type { JSONSchemaType } from 'ajv'; -import { OCPP20ServiceUtils } from './OCPP20ServiceUtils'; +import type { ChargingStation } from '../../../charging-station'; import { OCPPError } from '../../../exception'; import { ErrorType, @@ -14,8 +14,7 @@ import { OCPPVersion, } from '../../../types'; import { logger } from '../../../utils/Logger'; -import type { ChargingStation } from '../../ChargingStation'; -import { OCPPIncomingRequestService } from '../OCPPIncomingRequestService'; +import { OCPP20ServiceUtils, OCPPIncomingRequestService } from '../internal'; const moduleName = 'OCPP20IncomingRequestService'; diff --git a/src/charging-station/ocpp/2.0/OCPP20RequestService.ts b/src/charging-station/ocpp/2.0/OCPP20RequestService.ts index bf8119c5..7c137b48 100644 --- a/src/charging-station/ocpp/2.0/OCPP20RequestService.ts +++ b/src/charging-station/ocpp/2.0/OCPP20RequestService.ts @@ -2,7 +2,7 @@ import type { JSONSchemaType } from 'ajv'; -import { OCPP20ServiceUtils } from './OCPP20ServiceUtils'; +import type { ChargingStation } from '../../../charging-station'; import { OCPPError } from '../../../exception'; import { ErrorType, @@ -16,10 +16,12 @@ import { type RequestParams, } from '../../../types'; import { Utils } from '../../../utils/Utils'; -import type { ChargingStation } from '../../ChargingStation'; -import { OCPPConstants } from '../OCPPConstants'; -import { OCPPRequestService } from '../OCPPRequestService'; -import type { OCPPResponseService } from '../OCPPResponseService'; +import { + OCPP20ServiceUtils, + OCPPConstants, + OCPPRequestService, + type OCPPResponseService, +} from '../internal'; const moduleName = 'OCPP20RequestService'; diff --git a/src/charging-station/ocpp/2.0/OCPP20ResponseService.ts b/src/charging-station/ocpp/2.0/OCPP20ResponseService.ts index 4866b5c5..7e460ef1 100644 --- a/src/charging-station/ocpp/2.0/OCPP20ResponseService.ts +++ b/src/charging-station/ocpp/2.0/OCPP20ResponseService.ts @@ -2,7 +2,7 @@ import type { JSONSchemaType } from 'ajv'; -import { OCPP20ServiceUtils } from './OCPP20ServiceUtils'; +import { type ChargingStation, ChargingStationConfigurationUtils } from '../../../charging-station'; import { OCPPError } from '../../../exception'; import { ErrorType, @@ -20,9 +20,7 @@ import { type ResponseHandler, } from '../../../types'; import { logger } from '../../../utils/Logger'; -import type { ChargingStation } from '../../ChargingStation'; -import { ChargingStationConfigurationUtils } from '../../ChargingStationConfigurationUtils'; -import { OCPPResponseService } from '../OCPPResponseService'; +import { OCPP20ServiceUtils, OCPPResponseService } from '../internal'; const moduleName = 'OCPP20ResponseService'; diff --git a/src/charging-station/ocpp/2.0/OCPP20ServiceUtils.ts b/src/charging-station/ocpp/2.0/OCPP20ServiceUtils.ts index 38b80968..9fb61bd0 100644 --- a/src/charging-station/ocpp/2.0/OCPP20ServiceUtils.ts +++ b/src/charging-station/ocpp/2.0/OCPP20ServiceUtils.ts @@ -6,7 +6,7 @@ import { fileURLToPath } from 'node:url'; import type { JSONSchemaType } from 'ajv'; import { type JsonType, OCPPVersion } from '../../../types'; -import { OCPPServiceUtils } from '../OCPPServiceUtils'; +import { OCPPServiceUtils } from '../internal'; export class OCPP20ServiceUtils extends OCPPServiceUtils { public static parseJsonSchemaFile( diff --git a/src/charging-station/ocpp/OCPPIncomingRequestService.ts b/src/charging-station/ocpp/OCPPIncomingRequestService.ts index 00059f4b..de036e70 100644 --- a/src/charging-station/ocpp/OCPPIncomingRequestService.ts +++ b/src/charging-station/ocpp/OCPPIncomingRequestService.ts @@ -3,8 +3,8 @@ import { AsyncResource } from 'async_hooks'; import Ajv, { type JSONSchemaType } from 'ajv'; import ajvFormats from 'ajv-formats'; -import { OCPPConstants } from './OCPPConstants'; -import { OCPPServiceUtils } from './OCPPServiceUtils'; +import { OCPPConstants, OCPPServiceUtils } from './internal'; +import { type ChargingStation, ChargingStationUtils } from '../../charging-station'; import { OCPPError } from '../../exception'; import type { ClearCacheResponse, @@ -15,8 +15,6 @@ import type { OCPPVersion, } from '../../types'; import { logger } from '../../utils/Logger'; -import type { ChargingStation } from '../ChargingStation'; -import { ChargingStationUtils } from '../ChargingStationUtils'; const moduleName = 'OCPPIncomingRequestService'; diff --git a/src/charging-station/ocpp/OCPPRequestService.ts b/src/charging-station/ocpp/OCPPRequestService.ts index 4ef39b52..e58a1d43 100644 --- a/src/charging-station/ocpp/OCPPRequestService.ts +++ b/src/charging-station/ocpp/OCPPRequestService.ts @@ -1,10 +1,11 @@ import Ajv, { type JSONSchemaType } from 'ajv'; import ajvFormats from 'ajv-formats'; -import type { OCPPResponseService } from './OCPPResponseService'; -import { OCPPServiceUtils } from './OCPPServiceUtils'; +import { type OCPPResponseService, OCPPServiceUtils } from './internal'; +import type { ChargingStation } from '../../charging-station'; import { OCPPError } from '../../exception'; -import { PerformanceStatistics } from '../../performance'; +// import { PerformanceStatistics } from '../../performance'; +import { PerformanceStatistics } from '../../performance/PerformanceStatistics'; import { type EmptyObject, type ErrorCallback, @@ -26,7 +27,6 @@ import { import { Constants } from '../../utils/Constants'; import { logger } from '../../utils/Logger'; import { Utils } from '../../utils/Utils'; -import type { ChargingStation } from '../ChargingStation'; const moduleName = 'OCPPRequestService'; diff --git a/src/charging-station/ocpp/OCPPResponseService.ts b/src/charging-station/ocpp/OCPPResponseService.ts index ab17b05a..c66a16da 100644 --- a/src/charging-station/ocpp/OCPPResponseService.ts +++ b/src/charging-station/ocpp/OCPPResponseService.ts @@ -1,7 +1,8 @@ import Ajv, { type JSONSchemaType } from 'ajv'; import ajvFormats from 'ajv-formats'; -import { OCPPServiceUtils } from './OCPPServiceUtils'; +import { OCPPServiceUtils } from './internal'; +import type { ChargingStation } from '../../charging-station'; import { OCPPError } from '../../exception'; import type { IncomingRequestCommand, @@ -11,7 +12,6 @@ import type { RequestCommand, } from '../../types'; import { logger } from '../../utils/Logger'; -import type { ChargingStation } from '../ChargingStation'; const moduleName = 'OCPPResponseService'; diff --git a/src/charging-station/ocpp/OCPPServiceUtils.ts b/src/charging-station/ocpp/OCPPServiceUtils.ts index 4b232033..9d410963 100644 --- a/src/charging-station/ocpp/OCPPServiceUtils.ts +++ b/src/charging-station/ocpp/OCPPServiceUtils.ts @@ -2,6 +2,7 @@ import fs from 'node:fs'; import type { DefinedError, ErrorObject, JSONSchemaType } from 'ajv'; +import { type ChargingStation, ChargingStationConfigurationUtils } from '../../charging-station'; import { BaseError } from '../../exception'; import { ChargePointErrorCode, @@ -27,8 +28,6 @@ import { Constants } from '../../utils/Constants'; import { FileUtils } from '../../utils/FileUtils'; import { logger } from '../../utils/Logger'; import { Utils } from '../../utils/Utils'; -import type { ChargingStation } from '../ChargingStation'; -import { ChargingStationConfigurationUtils } from '../ChargingStationConfigurationUtils'; export class OCPPServiceUtils { protected constructor() { diff --git a/src/charging-station/ocpp/index.ts b/src/charging-station/ocpp/index.ts index bf43676f..a7681be6 100644 --- a/src/charging-station/ocpp/index.ts +++ b/src/charging-station/ocpp/index.ts @@ -1,11 +1,13 @@ -export { OCPPIncomingRequestService } from './OCPPIncomingRequestService'; -export { OCPPRequestService } from './OCPPRequestService'; -export { OCPPServiceUtils } from './OCPPServiceUtils'; -export { OCPP16IncomingRequestService } from './1.6/OCPP16IncomingRequestService'; -export { OCPP16RequestService } from './1.6/OCPP16RequestService'; -export { OCPP16ResponseService } from './1.6/OCPP16ResponseService'; -// FIXME: shall not be exported -export { OCPP16ServiceUtils } from './1.6/OCPP16ServiceUtils'; -export { OCPP20IncomingRequestService } from './2.0/OCPP20IncomingRequestService'; -export { OCPP20RequestService } from './2.0/OCPP20RequestService'; -export { OCPP20ResponseService } from './2.0/OCPP20ResponseService'; +export { + OCPP20ResponseService, + OCPP20RequestService, + OCPP20IncomingRequestService, + // FIXME: shall not be exported + OCPP16ServiceUtils, + OCPPIncomingRequestService, + OCPP16ResponseService, + OCPPRequestService, + OCPPServiceUtils, + OCPP16IncomingRequestService, + OCPP16RequestService, +} from './internal'; diff --git a/src/charging-station/ocpp/internal.ts b/src/charging-station/ocpp/internal.ts new file mode 100644 index 00000000..c8755707 --- /dev/null +++ b/src/charging-station/ocpp/internal.ts @@ -0,0 +1,15 @@ +export * from './1.6/OCPP16IncomingRequestService'; +export * from './1.6/OCPP16RequestService'; +export * from './1.6/OCPP16ResponseService'; +export * from './1.6/OCPP16ServiceUtils'; + +export * from './2.0/OCPP20IncomingRequestService'; +export * from './2.0/OCPP20RequestService'; +export * from './2.0/OCPP20ResponseService'; +export * from './2.0/OCPP20ServiceUtils'; + +export * from './OCPPConstants'; +export * from './OCPPIncomingRequestService'; +export * from './OCPPRequestService'; +export * from './OCPPResponseService'; +export * from './OCPPServiceUtils'; diff --git a/src/charging-station/ui-server/UIHttpServer.ts b/src/charging-station/ui-server/UIHttpServer.ts index 08ea7ff0..546c7642 100644 --- a/src/charging-station/ui-server/UIHttpServer.ts +++ b/src/charging-station/ui-server/UIHttpServer.ts @@ -2,7 +2,6 @@ import type { IncomingMessage, RequestListener, ServerResponse } from 'http'; import { StatusCodes } from 'http-status-codes'; -import { UIServerUtils } from './UIServerUtils'; import { BaseError } from '../../exception'; import { type ProcedureName, @@ -16,7 +15,7 @@ import { } from '../../types'; import { logger } from '../../utils/Logger'; import { Utils } from '../../utils/Utils'; -import { AbstractUIServer } from '../internal'; +import { AbstractUIServer, UIServerUtils } from '../internal'; const moduleName = 'UIHttpServer'; diff --git a/src/charging-station/ui-server/UIServerFactory.ts b/src/charging-station/ui-server/UIServerFactory.ts index 612054f6..ea95c527 100644 --- a/src/charging-station/ui-server/UIServerFactory.ts +++ b/src/charging-station/ui-server/UIServerFactory.ts @@ -1,9 +1,8 @@ import chalk from 'chalk'; -import { UIServerUtils } from './UIServerUtils'; import { ApplicationProtocol, type UIServerConfiguration } from '../../types'; import { Configuration } from '../../utils/Configuration'; -import { type AbstractUIServer, UIHttpServer, UIWebSocketServer } from '../internal'; +import { type AbstractUIServer, UIHttpServer, UIServerUtils, UIWebSocketServer } from '../internal'; export class UIServerFactory { private constructor() { diff --git a/src/charging-station/ui-server/UIWebSocketServer.ts b/src/charging-station/ui-server/UIWebSocketServer.ts index d5e6ff80..c05ec625 100644 --- a/src/charging-station/ui-server/UIWebSocketServer.ts +++ b/src/charging-station/ui-server/UIWebSocketServer.ts @@ -4,7 +4,6 @@ import type internal from 'stream'; import { StatusCodes } from 'http-status-codes'; import WebSocket, { type RawData, WebSocketServer } from 'ws'; -import { UIServerUtils } from './UIServerUtils'; import { type ProtocolRequest, type ProtocolResponse, @@ -13,7 +12,7 @@ import { } from '../../types'; import { logger } from '../../utils/Logger'; import { Utils } from '../../utils/Utils'; -import { AbstractUIServer } from '../internal'; +import { AbstractUIServer, UIServerUtils } from '../internal'; const moduleName = 'UIWebSocketServer'; diff --git a/src/charging-station/ui-server/ui-services/AbstractUIService.ts b/src/charging-station/ui-server/ui-services/AbstractUIService.ts index b471b6cc..d3d1231d 100644 --- a/src/charging-station/ui-server/ui-services/AbstractUIService.ts +++ b/src/charging-station/ui-server/ui-services/AbstractUIService.ts @@ -12,8 +12,7 @@ import { } from '../../../types'; import { logger } from '../../../utils/Logger'; import { Utils } from '../../../utils/Utils'; -import { type AbstractUIServer, Bootstrap } from '../../internal'; -import { UIServiceWorkerBroadcastChannel } from '../../UIServiceWorkerBroadcastChannel'; +import { type AbstractUIServer, Bootstrap, UIServiceWorkerBroadcastChannel } from '../../internal'; const moduleName = 'AbstractUIService'; diff --git a/src/exception/OCPPError.ts b/src/exception/OCPPError.ts index 8ccc4fbf..3b23cc3b 100644 --- a/src/exception/OCPPError.ts +++ b/src/exception/OCPPError.ts @@ -1,6 +1,6 @@ // Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved. -import { BaseError } from './BaseError'; +import { BaseError } from './internal'; import { ErrorType, type IncomingRequestCommand, diff --git a/src/exception/index.ts b/src/exception/index.ts index 5e5b60ca..3d4b3f90 100644 --- a/src/exception/index.ts +++ b/src/exception/index.ts @@ -1,2 +1 @@ -export { BaseError } from './BaseError'; -export { OCPPError } from './OCPPError'; +export { BaseError, OCPPError } from './internal'; diff --git a/src/exception/internal.ts b/src/exception/internal.ts new file mode 100644 index 00000000..49abdfcb --- /dev/null +++ b/src/exception/internal.ts @@ -0,0 +1,2 @@ +export * from './BaseError'; +export * from './OCPPError'; diff --git a/src/performance/PerformanceStatistics.ts b/src/performance/PerformanceStatistics.ts index 79650c8f..cfc19be8 100644 --- a/src/performance/PerformanceStatistics.ts +++ b/src/performance/PerformanceStatistics.ts @@ -4,7 +4,7 @@ import type { URL } from 'node:url'; import { PerformanceEntry, PerformanceObserver, performance } from 'perf_hooks'; import { parentPort } from 'worker_threads'; -import { MessageChannelUtils } from '../charging-station/MessageChannelUtils'; +import { MessageChannelUtils } from '../charging-station'; import { type IncomingRequestCommand, MessageType, diff --git a/src/performance/index.ts b/src/performance/index.ts index 1b61c465..258dbc01 100644 --- a/src/performance/index.ts +++ b/src/performance/index.ts @@ -1,3 +1 @@ -export { PerformanceStatistics } from './PerformanceStatistics'; -export { Storage } from './storage/Storage'; -export { StorageFactory } from './storage/StorageFactory'; +export { PerformanceStatistics, type Storage, StorageFactory } from './internal'; diff --git a/src/performance/internal.ts b/src/performance/internal.ts new file mode 100644 index 00000000..af79c9cd --- /dev/null +++ b/src/performance/internal.ts @@ -0,0 +1,7 @@ +export * from './storage/JsonFileStorage'; +export * from './storage/MikroOrmStorage'; +export * from './storage/MongoDBStorage'; +export * from './storage/Storage'; +export * from './storage/StorageFactory'; + +export * from './PerformanceStatistics'; diff --git a/src/performance/storage/JsonFileStorage.ts b/src/performance/storage/JsonFileStorage.ts index 3128c862..91a2d426 100644 --- a/src/performance/storage/JsonFileStorage.ts +++ b/src/performance/storage/JsonFileStorage.ts @@ -4,10 +4,10 @@ import fs from 'node:fs'; import lockfile from 'proper-lockfile'; -import { Storage } from './Storage'; import { FileType, type Statistics } from '../../types'; import { FileUtils } from '../../utils/FileUtils'; import { Utils } from '../../utils/Utils'; +import { Storage } from '../internal'; export class JsonFileStorage extends Storage { private fd: number | null = null; diff --git a/src/performance/storage/MikroOrmStorage.ts b/src/performance/storage/MikroOrmStorage.ts index 5d236f27..021bc28b 100644 --- a/src/performance/storage/MikroOrmStorage.ts +++ b/src/performance/storage/MikroOrmStorage.ts @@ -3,7 +3,6 @@ import { Configuration, Connection, IDatabaseDriver, MikroORM, Options } from '@mikro-orm/core'; import { TsMorphMetadataProvider } from '@mikro-orm/reflection'; -import { Storage } from './Storage'; import { type MikroORMDBType, PerformanceData, @@ -12,6 +11,7 @@ import { StorageType, } from '../../types'; import { Constants } from '../../utils/Constants'; +import { Storage } from '../internal'; export class MikroOrmStorage extends Storage { private storageType: StorageType; diff --git a/src/performance/storage/MongoDBStorage.ts b/src/performance/storage/MongoDBStorage.ts index 32532ead..cebab8c7 100644 --- a/src/performance/storage/MongoDBStorage.ts +++ b/src/performance/storage/MongoDBStorage.ts @@ -2,9 +2,9 @@ import { MongoClient } from 'mongodb'; -import { Storage } from './Storage'; import { type Statistics, StorageType } from '../../types'; import { Constants } from '../../utils/Constants'; +import { Storage } from '../internal'; export class MongoDBStorage extends Storage { private readonly client: MongoClient | null; diff --git a/src/performance/storage/StorageFactory.ts b/src/performance/storage/StorageFactory.ts index 09b58a15..5a3b2e12 100644 --- a/src/performance/storage/StorageFactory.ts +++ b/src/performance/storage/StorageFactory.ts @@ -1,10 +1,7 @@ // Copyright Jerome Benoit. 2021-2023. All Rights Reserved. -import { JsonFileStorage } from './JsonFileStorage'; -import { MikroOrmStorage } from './MikroOrmStorage'; -import { MongoDBStorage } from './MongoDBStorage'; -import type { Storage } from './Storage'; import { StorageType } from '../../types'; +import { JsonFileStorage, MikroOrmStorage, MongoDBStorage, type Storage } from '../internal'; export class StorageFactory { private constructor() { diff --git a/src/types/ChargingStationConfiguration.ts b/src/types/ChargingStationConfiguration.ts index f0107a65..09509038 100644 --- a/src/types/ChargingStationConfiguration.ts +++ b/src/types/ChargingStationConfiguration.ts @@ -1,6 +1,8 @@ -import type { ChargingStationAutomaticTransactionGeneratorConfiguration } from './AutomaticTransactionGenerator'; -import type { ChargingStationInfoConfiguration } from './ChargingStationInfo'; -import type { ChargingStationOcppConfiguration } from './ChargingStationOcppConfiguration'; +import type { + ChargingStationAutomaticTransactionGeneratorConfiguration, + ChargingStationInfoConfiguration, + ChargingStationOcppConfiguration, +} from './internal'; export type ChargingStationConfiguration = ChargingStationInfoConfiguration & ChargingStationOcppConfiguration & diff --git a/src/types/ChargingStationInfo.ts b/src/types/ChargingStationInfo.ts index 29ff6fb7..0d23c1cf 100644 --- a/src/types/ChargingStationInfo.ts +++ b/src/types/ChargingStationInfo.ts @@ -1,5 +1,4 @@ -import type { ChargingStationTemplate } from './ChargingStationTemplate'; -import type { FirmwareStatus } from './ocpp/Requests'; +import type { ChargingStationTemplate, FirmwareStatus } from './internal'; export type ChargingStationInfo = Omit< ChargingStationTemplate, diff --git a/src/types/ChargingStationOcppConfiguration.ts b/src/types/ChargingStationOcppConfiguration.ts index 834b1d1d..bbd1bcfb 100644 --- a/src/types/ChargingStationOcppConfiguration.ts +++ b/src/types/ChargingStationOcppConfiguration.ts @@ -1,4 +1,4 @@ -import type { OCPPConfigurationKey } from './ocpp/Configuration'; +import type { OCPPConfigurationKey } from './internal'; export type ConfigurationKey = OCPPConfigurationKey & { visible?: boolean; diff --git a/src/types/ChargingStationTemplate.ts b/src/types/ChargingStationTemplate.ts index 5c44ede9..36a481ff 100644 --- a/src/types/ChargingStationTemplate.ts +++ b/src/types/ChargingStationTemplate.ts @@ -2,17 +2,17 @@ import type { ClientRequestArgs } from 'http'; import type { ClientOptions } from 'ws'; -import type { AutomaticTransactionGeneratorConfiguration } from './AutomaticTransactionGenerator'; -import type { ChargingStationOcppConfiguration } from './ChargingStationOcppConfiguration'; -import type { ConnectorStatus } from './ConnectorStatus'; -import type { OCPPProtocol } from './ocpp/OCPPProtocol'; -import type { OCPPVersion } from './ocpp/OCPPVersion'; import type { + AutomaticTransactionGeneratorConfiguration, + ChargingStationOcppConfiguration, + ConnectorStatus, FirmwareStatus, IncomingRequestCommand, MessageTrigger, + OCPPProtocol, + OCPPVersion, RequestCommand, -} from './ocpp/Requests'; +} from './internal'; export enum CurrentType { AC = 'AC', diff --git a/src/types/ChargingStationWorker.ts b/src/types/ChargingStationWorker.ts index 9a9d3574..cd2cb005 100644 --- a/src/types/ChargingStationWorker.ts +++ b/src/types/ChargingStationWorker.ts @@ -1,11 +1,13 @@ import type { WebSocket } from 'ws'; -import type { ChargingStationAutomaticTransactionGeneratorConfiguration } from './AutomaticTransactionGenerator'; -import type { ChargingStationInfo } from './ChargingStationInfo'; -import type { ConnectorStatus } from './ConnectorStatus'; -import type { JsonObject } from './JsonType'; -import type { BootNotificationResponse } from './ocpp/Responses'; -import type { Statistics } from './Statistics'; +import type { + BootNotificationResponse, + ChargingStationAutomaticTransactionGeneratorConfiguration, + ChargingStationInfo, + ConnectorStatus, + JsonObject, + Statistics, +} from './internal'; import { type WorkerData, type WorkerMessage, WorkerMessageEvents } from '../worker'; export interface ChargingStationWorkerOptions extends JsonObject { diff --git a/src/types/ConfigurationData.ts b/src/types/ConfigurationData.ts index 9688010a..0e70094b 100644 --- a/src/types/ConfigurationData.ts +++ b/src/types/ConfigurationData.ts @@ -2,8 +2,7 @@ import type { ListenOptions } from 'net'; import type { WorkerChoiceStrategy } from 'poolifier'; -import type { StorageType } from './Storage'; -import type { ApplicationProtocol, AuthenticationType } from './UIProtocol'; +import type { ApplicationProtocol, AuthenticationType, StorageType } from './internal'; import type { WorkerProcessType } from '../worker'; export type ServerOptions = ListenOptions; diff --git a/src/types/ConnectorStatus.ts b/src/types/ConnectorStatus.ts index d7698107..02ee914e 100644 --- a/src/types/ConnectorStatus.ts +++ b/src/types/ConnectorStatus.ts @@ -1,8 +1,10 @@ -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'; +import type { + AvailabilityType, + ChargingProfile, + ConnectorStatusEnum, + MeterValue, + SampledValueTemplate, +} from './internal'; export type ConnectorStatus = { availability: AvailabilityType; diff --git a/src/types/Statistics.ts b/src/types/Statistics.ts index 782adae2..f43da99b 100644 --- a/src/types/Statistics.ts +++ b/src/types/Statistics.ts @@ -1,4 +1,4 @@ -import type { IncomingRequestCommand, RequestCommand } from './ocpp/Requests'; +import type { IncomingRequestCommand, RequestCommand } from './internal'; import type { CircularArray } from '../utils/CircularArray'; import type { WorkerData } from '../worker'; diff --git a/src/types/UIProtocol.ts b/src/types/UIProtocol.ts index 3b6592a5..20405161 100644 --- a/src/types/UIProtocol.ts +++ b/src/types/UIProtocol.ts @@ -1,5 +1,4 @@ -import type { JsonObject } from './JsonType'; -import type { BroadcastChannelResponsePayload } from './WorkerBroadcastChannel'; +import type { BroadcastChannelResponsePayload, JsonObject } from './internal'; export enum Protocol { UI = 'ui', diff --git a/src/types/WorkerBroadcastChannel.ts b/src/types/WorkerBroadcastChannel.ts index 2c174cd5..3656fe3a 100644 --- a/src/types/WorkerBroadcastChannel.ts +++ b/src/types/WorkerBroadcastChannel.ts @@ -1,4 +1,4 @@ -import type { RequestPayload, ResponsePayload } from './UIProtocol'; +import type { RequestPayload, ResponsePayload } from './internal'; export type BroadcastChannelRequest = [ string, diff --git a/src/types/index.ts b/src/types/index.ts index f0a947a4..d4ae9b14 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -1,45 +1 @@ -export * from './ocpp/ChargePointErrorCode'; -export * from './ocpp/ChargingProfile'; -export * from './ocpp/Configuration'; -export * from './ocpp/ConnectorStatusEnum'; -export * from './ocpp/ErrorType'; -export * from './ocpp/MessageType'; -export * from './ocpp/MeterValues'; -export * from './ocpp/OCPPProtocol'; -export * from './ocpp/OCPPVersion'; -export * from './ocpp/Requests'; -export * from './ocpp/Responses'; -export * from './ocpp/Transaction'; -export * from './ocpp/1.6/ChargePointErrorCode'; -export * from './ocpp/1.6/ChargePointStatus'; -export * from './ocpp/1.6/ChargingProfile'; -export * from './ocpp/1.6/Configuration'; -export * 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/Requests'; -export * from './ocpp/2.0/Responses'; -export * from './ocpp/2.0/Variables'; -export * from './orm/entities/PerformanceData'; -export * from './orm/entities/PerformanceRecord'; -export * from './AutomaticTransactionGenerator'; -export * from './ChargingStationConfiguration'; -export * from './ChargingStationInfo'; -export * from './ChargingStationOcppConfiguration'; -export * from './ChargingStationTemplate'; -export * from './ChargingStationWorker'; -export * from './ConfigurationData'; -export * from './ConnectorStatus'; -export * from './EmptyObject'; -export * from './Error'; -export * from './FileType'; -export * from './JsonType'; -export * from './MeasurandPerPhaseSampledValueTemplates'; -export * from './MeasurandValues'; -export * from './Statistics'; -export * from './Storage'; -export * from './UIProtocol'; -export * from './WebSocket'; -export * from './WorkerBroadcastChannel'; +export * from './internal'; diff --git a/src/types/internal.ts b/src/types/internal.ts new file mode 100644 index 00000000..105c983c --- /dev/null +++ b/src/types/internal.ts @@ -0,0 +1,45 @@ +export * from './ocpp/1.6/ChargePointErrorCode'; +export * from './ocpp/1.6/ChargePointStatus'; +export * from './ocpp/1.6/ChargingProfile'; +export * from './ocpp/1.6/Configuration'; +export * 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/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 * from './ocpp/ErrorType'; +export * from './ocpp/MessageType'; +export * from './ocpp/MeterValues'; +export * from './ocpp/OCPPProtocol'; +export * 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 * from './AutomaticTransactionGenerator'; +export * from './ChargingStationConfiguration'; +export * from './ChargingStationInfo'; +export * from './ChargingStationOcppConfiguration'; +export * from './ChargingStationTemplate'; +export * from './ChargingStationWorker'; +export * from './ConfigurationData'; +export * from './ConnectorStatus'; +export * from './EmptyObject'; +export * from './Error'; +export * from './FileType'; +export * from './JsonType'; +export * from './MeasurandPerPhaseSampledValueTemplates'; +export * from './MeasurandValues'; +export * from './Statistics'; +export * from './Storage'; +export * from './UIProtocol'; +export * from './WebSocket'; +export * from './WorkerBroadcastChannel'; diff --git a/src/types/ocpp/1.6/ChargingProfile.ts b/src/types/ocpp/1.6/ChargingProfile.ts index 529bfd1d..1b925bca 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 '../../JsonType'; +import type { JsonObject } from '../../internal'; 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 0cfca50e..9fcff5e3 100644 --- a/src/types/ocpp/1.6/MeterValues.ts +++ b/src/types/ocpp/1.6/MeterValues.ts @@ -1,5 +1,4 @@ -import type { EmptyObject } from '../../EmptyObject'; -import type { JsonObject } from '../../JsonType'; +import type { EmptyObject, JsonObject } from '../../internal'; 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 89316dc6..079c1dbb 100644 --- a/src/types/ocpp/1.6/Requests.ts +++ b/src/types/ocpp/1.6/Requests.ts @@ -1,10 +1,13 @@ -import type { OCPP16ChargePointErrorCode } from './ChargePointErrorCode'; -import type { OCPP16ChargePointStatus } from './ChargePointStatus'; -import type { ChargingProfilePurposeType, OCPP16ChargingProfile } from './ChargingProfile'; -import type { OCPP16StandardParametersKey } from './Configuration'; -import type { OCPP16DiagnosticsStatus } from './DiagnosticsStatus'; -import type { EmptyObject } from '../../EmptyObject'; -import type { JsonObject } from '../../JsonType'; +import type { + ChargingProfilePurposeType, + EmptyObject, + JsonObject, + OCPP16ChargePointErrorCode, + OCPP16ChargePointStatus, + OCPP16ChargingProfile, + OCPP16DiagnosticsStatus, + OCPP16StandardParametersKey, +} from '../../internal'; 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 84648e47..1724ce18 100644 --- a/src/types/ocpp/1.6/Responses.ts +++ b/src/types/ocpp/1.6/Responses.ts @@ -1,7 +1,9 @@ -import type { EmptyObject } from '../../EmptyObject'; -import type { JsonObject } from '../../JsonType'; -import type { OCPPConfigurationKey } from '../Configuration'; -import type { RegistrationStatusEnumType } from '../Responses'; +import type { + EmptyObject, + JsonObject, + OCPPConfigurationKey, + RegistrationStatusEnumType, +} from '../../internal'; 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 e2aa3d81..8824d1bc 100644 --- a/src/types/ocpp/1.6/Transaction.ts +++ b/src/types/ocpp/1.6/Transaction.ts @@ -1,5 +1,4 @@ -import type { OCPP16MeterValue } from './MeterValues'; -import type { JsonObject } from '../../JsonType'; +import type { JsonObject, OCPP16MeterValue } from '../../internal'; export enum OCPP16StopTransactionReason { NONE = '', diff --git a/src/types/ocpp/2.0/Requests.ts b/src/types/ocpp/2.0/Requests.ts index 407fdfe4..c42cd8bb 100644 --- a/src/types/ocpp/2.0/Requests.ts +++ b/src/types/ocpp/2.0/Requests.ts @@ -1,5 +1,4 @@ -import type { EmptyObject } from '../../EmptyObject'; -import type { JsonObject } from '../../JsonType'; +import type { EmptyObject, JsonObject } from '../../internal'; 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 04cd462b..3f4d2f42 100644 --- a/src/types/ocpp/2.0/Responses.ts +++ b/src/types/ocpp/2.0/Responses.ts @@ -1,6 +1,9 @@ -import type { EmptyObject } from '../../EmptyObject'; -import type { JsonObject } from '../../JsonType'; -import type { GenericStatus, RegistrationStatusEnumType } from '../Responses'; +import type { + EmptyObject, + GenericStatus, + JsonObject, + RegistrationStatusEnumType, +} from '../../internal'; export type StatusInfoType = { reasonCode: string; diff --git a/src/types/ocpp/ChargePointErrorCode.ts b/src/types/ocpp/ChargePointErrorCode.ts index d08f17a0..9e70845d 100644 --- a/src/types/ocpp/ChargePointErrorCode.ts +++ b/src/types/ocpp/ChargePointErrorCode.ts @@ -1,4 +1,4 @@ -import { OCPP16ChargePointErrorCode } from './1.6/ChargePointErrorCode'; +import { OCPP16ChargePointErrorCode } from '../internal'; export const ChargePointErrorCode = { ...OCPP16ChargePointErrorCode, diff --git a/src/types/ocpp/ChargingProfile.ts b/src/types/ocpp/ChargingProfile.ts index 83710272..643e38db 100644 --- a/src/types/ocpp/ChargingProfile.ts +++ b/src/types/ocpp/ChargingProfile.ts @@ -2,7 +2,7 @@ import { type OCPP16ChargingProfile, OCPP16ChargingRateUnitType, type OCPP16ChargingSchedulePeriod, -} from './1.6/ChargingProfile'; +} from '../internal'; export type ChargingProfile = OCPP16ChargingProfile; diff --git a/src/types/ocpp/Configuration.ts b/src/types/ocpp/Configuration.ts index 9aeb91dc..297b403c 100644 --- a/src/types/ocpp/Configuration.ts +++ b/src/types/ocpp/Configuration.ts @@ -1,14 +1,12 @@ import { + type JsonObject, OCPP16StandardParametersKey, OCPP16SupportedFeatureProfiles, OCPP16VendorDefaultParametersKey, -} from './1.6/Configuration'; -import { OCPP20OptionalVariableName, OCPP20RequiredVariableName, OCPP20VendorVariableName, -} from './2.0/Variables'; -import type { JsonObject } from '../JsonType'; +} from '../internal'; export const StandardParametersKey = { ...OCPP16StandardParametersKey, diff --git a/src/types/ocpp/ConnectorStatusEnum.ts b/src/types/ocpp/ConnectorStatusEnum.ts index 929d59cd..a98e15d9 100644 --- a/src/types/ocpp/ConnectorStatusEnum.ts +++ b/src/types/ocpp/ConnectorStatusEnum.ts @@ -1,5 +1,4 @@ -import { OCPP16ChargePointStatus } from './1.6/ChargePointStatus'; -import { OCPP20ConnectorStatusEnumType } from './2.0/Requests'; +import { OCPP16ChargePointStatus, OCPP20ConnectorStatusEnumType } from '../internal'; export const ConnectorStatusEnum = { ...OCPP16ChargePointStatus, diff --git a/src/types/ocpp/MeterValues.ts b/src/types/ocpp/MeterValues.ts index f34a8c17..10b8323d 100644 --- a/src/types/ocpp/MeterValues.ts +++ b/src/types/ocpp/MeterValues.ts @@ -3,7 +3,7 @@ import { OCPP16MeterValueMeasurand, OCPP16MeterValuePhase, type OCPP16SampledValue, -} from './1.6/MeterValues'; +} from '../internal'; export const MeterValueMeasurand = { ...OCPP16MeterValueMeasurand, diff --git a/src/types/ocpp/Requests.ts b/src/types/ocpp/Requests.ts index 8ef05664..ff238094 100644 --- a/src/types/ocpp/Requests.ts +++ b/src/types/ocpp/Requests.ts @@ -1,28 +1,26 @@ -import { OCPP16DiagnosticsStatus } from './1.6/DiagnosticsStatus'; -import type { OCPP16MeterValuesRequest } from './1.6/MeterValues'; +import type { ChargingStation } from '../../charging-station'; +import type { OCPPError } from '../../exception'; 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 { type OCPP20BootNotificationRequest, OCPP20IncomingRequestCommand, OCPP20RequestCommand, type OCPP20StatusNotificationRequest, -} from './2.0/Requests'; -import type { MessageType } from './MessageType'; -import type { ChargingStation } from '../../charging-station/ChargingStation'; -import type { OCPPError } from '../../exception'; -import type { JsonType } from '../JsonType'; +} from '../internal'; export const RequestCommand = { ...OCPP16RequestCommand, diff --git a/src/types/ocpp/Responses.ts b/src/types/ocpp/Responses.ts index c61b5463..ae6ae45d 100644 --- a/src/types/ocpp/Responses.ts +++ b/src/types/ocpp/Responses.ts @@ -1,5 +1,8 @@ -import type { OCPP16MeterValuesResponse } from './1.6/MeterValues'; +import type { ChargingStation } from '../../charging-station'; import { + type ErrorType, + type JsonType, + type MessageType, OCPP16AvailabilityStatus, type OCPP16BootNotificationResponse, OCPP16ChargingProfileStatus, @@ -10,19 +13,14 @@ import { type OCPP16DiagnosticsStatusNotificationResponse, type OCPP16FirmwareStatusNotificationResponse, type OCPP16HeartbeatResponse, + type OCPP16MeterValuesResponse, type OCPP16StatusNotificationResponse, OCPP16TriggerMessageStatus, OCPP16UnlockStatus, -} 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/ChargingStation'; -import type { JsonType } from '../JsonType'; + type OCPP20BootNotificationResponse, + type OCPP20ClearCacheResponse, + type OCPP20StatusNotificationResponse, +} from '../internal'; export type Response = [MessageType.CALL_RESULT_MESSAGE, string, JsonType]; diff --git a/src/types/ocpp/Transaction.ts b/src/types/ocpp/Transaction.ts index 2a8a0ad4..1ce9d987 100644 --- a/src/types/ocpp/Transaction.ts +++ b/src/types/ocpp/Transaction.ts @@ -7,7 +7,7 @@ import { OCPP16StopTransactionReason, type OCPP16StopTransactionRequest, type OCPP16StopTransactionResponse, -} from './1.6/Transaction'; +} from '../internal'; export const AuthorizationStatus = { ...OCPP16AuthorizationStatus, diff --git a/src/types/orm/entities/PerformanceData.ts b/src/types/orm/entities/PerformanceData.ts index fc7268aa..ef847e74 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 './PerformanceRecord'; +import type { PerformanceRecord } from '../../internal'; @Entity() export class PerformanceData { diff --git a/src/types/orm/entities/PerformanceRecord.ts b/src/types/orm/entities/PerformanceRecord.ts index 06114da6..1369377d 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 './PerformanceData'; +import type { PerformanceData } from '../../internal'; @Entity() export class PerformanceRecord { diff --git a/src/worker/index.ts b/src/worker/index.ts index 9fa37055..036ddaf1 100644 --- a/src/worker/index.ts +++ b/src/worker/index.ts @@ -1,10 +1,10 @@ -export { WorkerAbstract } from './WorkerAbstract'; +export type { WorkerAbstract } from './WorkerAbstract'; export { WorkerConstants } from './WorkerConstants'; export { WorkerFactory } from './WorkerFactory'; export { WorkerProcessType, - WorkerData, - WorkerMessage, + type WorkerData, + type WorkerMessage, WorkerMessageEvents, - MessageHandler, + type MessageHandler, } from './WorkerTypes'; -- 2.34.1