From a6ef1ece74c0d08e86a905571f4f6045c28131cb Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Thu, 28 Dec 2023 13:56:39 +0100 Subject: [PATCH] build: switch to NodeNext module resolution MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .lintstagedrc.js | 5 + .lintstagedrc.json | 5 - .../AutomaticTransactionGenerator.ts | 16 +-- src/charging-station/Bootstrap.ts | 16 +-- src/charging-station/ChargingStation.ts | 22 ++--- src/charging-station/ChargingStationWorker.ts | 10 +- src/charging-station/ConfigurationKeyUtils.ts | 6 +- src/charging-station/Helpers.ts | 10 +- src/charging-station/IdTagsCache.ts | 8 +- src/charging-station/SharedLRUCache.ts | 11 ++- .../ChargingStationWorkerBroadcastChannel.ts | 20 ++-- .../UIServiceWorkerBroadcastChannel.ts | 8 +- .../WorkerBroadcastChannel.ts | 4 +- src/charging-station/index.ts | 8 +- .../ocpp/1.6/OCPP16Constants.ts | 4 +- .../ocpp/1.6/OCPP16IncomingRequestService.ts | 14 +-- .../ocpp/1.6/OCPP16RequestService.ts | 16 +-- .../ocpp/1.6/OCPP16ResponseService.ts | 12 +-- .../ocpp/1.6/OCPP16ServiceUtils.ts | 10 +- .../ocpp/2.0/OCPP20Constants.ts | 7 +- .../ocpp/2.0/OCPP20IncomingRequestService.ts | 12 +-- .../ocpp/2.0/OCPP20RequestService.ts | 16 +-- .../ocpp/2.0/OCPP20ResponseService.ts | 12 +-- .../ocpp/2.0/OCPP20ServiceUtils.ts | 4 +- src/charging-station/ocpp/OCPPConstants.ts | 6 +- .../ocpp/OCPPIncomingRequestService.ts | 12 +-- .../ocpp/OCPPRequestService.ts | 16 +-- .../ocpp/OCPPResponseService.ts | 15 ++- src/charging-station/ocpp/OCPPServiceUtils.ts | 18 ++-- src/charging-station/ocpp/index.ts | 18 ++-- .../ui-server/AbstractUIServer.ts | 8 +- .../ui-server/UIHttpServer.ts | 10 +- .../ui-server/UIServerFactory.ts | 10 +- .../ui-server/UIServerUtils.ts | 4 +- .../ui-server/UIWebSocketServer.ts | 8 +- .../ui-services/AbstractUIService.ts | 12 +-- .../ui-server/ui-services/UIService001.ts | 6 +- .../ui-server/ui-services/UIServiceFactory.ts | 8 +- src/exception/OCPPError.ts | 6 +- src/exception/index.ts | 4 +- src/performance/PerformanceStatistics.ts | 4 +- src/performance/index.ts | 6 +- src/performance/storage/JsonFileStorage.ts | 8 +- src/performance/storage/MikroOrmStorage.ts | 6 +- src/performance/storage/MongoDBStorage.ts | 8 +- src/performance/storage/Storage.ts | 4 +- src/performance/storage/StorageFactory.ts | 12 +-- src/start.ts | 2 +- src/types/ChargingStationConfiguration.ts | 10 +- src/types/ChargingStationInfo.ts | 4 +- src/types/ChargingStationOcppConfiguration.ts | 2 +- src/types/ChargingStationTemplate.ts | 14 +-- src/types/ChargingStationWorker.ts | 20 ++-- src/types/ConfigurationData.ts | 6 +- src/types/ConnectorStatus.ts | 12 +-- src/types/Error.ts | 2 +- src/types/Evse.ts | 4 +- .../MeasurandPerPhaseSampledValueTemplates.ts | 2 +- src/types/Statistics.ts | 6 +- src/types/UIProtocol.ts | 4 +- src/types/WorkerBroadcastChannel.ts | 2 +- src/types/index.ts | 99 ++++++++++--------- src/types/ocpp/1.6/ChargingProfile.ts | 2 +- src/types/ocpp/1.6/MeterValues.ts | 4 +- src/types/ocpp/1.6/Requests.ts | 14 +-- src/types/ocpp/1.6/Responses.ts | 10 +- src/types/ocpp/1.6/Transaction.ts | 4 +- src/types/ocpp/2.0/Common.ts | 4 +- src/types/ocpp/2.0/Requests.ts | 8 +- src/types/ocpp/2.0/Responses.ts | 10 +- src/types/ocpp/2.0/Variables.ts | 4 +- src/types/ocpp/ChargePointErrorCode.ts | 2 +- src/types/ocpp/ChargingProfile.ts | 2 +- src/types/ocpp/Common.ts | 2 +- src/types/ocpp/Configuration.ts | 6 +- src/types/ocpp/ConnectorStatusEnum.ts | 4 +- src/types/ocpp/MeterValues.ts | 2 +- src/types/ocpp/Requests.ts | 18 ++-- src/types/ocpp/Reservation.ts | 2 +- src/types/ocpp/Responses.ts | 16 +-- src/types/ocpp/Transaction.ts | 2 +- src/types/orm/entities/PerformanceData.ts | 2 +- src/types/orm/entities/PerformanceRecord.ts | 2 +- src/utils/AsyncLock.ts | 2 +- .../ChargingStationConfigurationUtils.ts | 6 +- src/utils/Configuration.ts | 10 +- src/utils/ConfigurationUtils.ts | 8 +- src/utils/Constants.ts | 2 +- src/utils/ErrorUtils.ts | 8 +- src/utils/FileUtils.ts | 8 +- src/utils/Logger.ts | 6 +- src/utils/MessageChannelUtils.ts | 6 +- src/utils/StatisticUtils.ts | 2 +- src/utils/Utils.ts | 4 +- src/utils/index.ts | 24 ++--- src/worker/WorkerAbstract.ts | 4 +- src/worker/WorkerConstants.ts | 2 +- src/worker/WorkerDynamicPool.ts | 6 +- src/worker/WorkerFactory.ts | 12 +-- src/worker/WorkerFixedPool.ts | 6 +- src/worker/WorkerSet.ts | 8 +- src/worker/index.ts | 8 +- tests/utils/CircularArray.test.ts | 2 +- tests/utils/ElectricUtils.test.ts | 2 +- tests/utils/StatisticUtils.test.ts | 2 +- tests/utils/Utils.test.ts | 4 +- tsconfig.json | 4 +- 107 files changed, 472 insertions(+), 448 deletions(-) create mode 100644 .lintstagedrc.js delete mode 100644 .lintstagedrc.json diff --git a/.lintstagedrc.js b/.lintstagedrc.js new file mode 100644 index 00000000..2a11a898 --- /dev/null +++ b/.lintstagedrc.js @@ -0,0 +1,5 @@ +export default { + '{src,tests}/**/*.{ts,tsx,cts,mts}': ['prettier --cache --write' /* , 'eslint --cache --fix' */], + '**/*.{json,md,yml,yaml}': ['prettier --cache --write'], + '**/*.{js,jsx,cjs,mjs}': ['prettier --cache --write', 'eslint --cache --fix'], +}; diff --git a/.lintstagedrc.json b/.lintstagedrc.json deleted file mode 100644 index 45cd8477..00000000 --- a/.lintstagedrc.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "{src,tests}/**/*.{ts,tsx,cts,mts}": ["prettier --cache --write", "eslint --cache --fix"], - "**/*.{json,md,yml,yaml}": ["prettier --cache --write"], - "**/*.{js,jsx,cjs,mjs}": ["prettier --cache --write", "eslint --cache --fix"] -} diff --git a/src/charging-station/AutomaticTransactionGenerator.ts b/src/charging-station/AutomaticTransactionGenerator.ts index 95b2c678..abe271fd 100644 --- a/src/charging-station/AutomaticTransactionGenerator.ts +++ b/src/charging-station/AutomaticTransactionGenerator.ts @@ -2,12 +2,12 @@ import { hoursToMilliseconds, secondsToMilliseconds } from 'date-fns'; -import type { ChargingStation } from './ChargingStation'; -import { checkChargingStation } from './Helpers'; -import { IdTagsCache } from './IdTagsCache'; -import { isIdTagAuthorized } from './ocpp'; -import { BaseError } from '../exception'; -import { PerformanceStatistics } from '../performance'; +import type { ChargingStation } from './ChargingStation.js'; +import { checkChargingStation } from './Helpers.js'; +import { IdTagsCache } from './IdTagsCache.js'; +import { isIdTagAuthorized } from './ocpp/index.js'; +import { BaseError } from '../exception/index.js'; +import { PerformanceStatistics } from '../performance/index.js'; import { AuthorizationStatus, RequestCommand, @@ -16,7 +16,7 @@ import { type Status, StopTransactionReason, type StopTransactionResponse, -} from '../types'; +} from '../types/index.js'; import { Constants, cloneObject, @@ -27,7 +27,7 @@ import { logger, secureRandom, sleep, -} from '../utils'; +} from '../utils/index.js'; export class AutomaticTransactionGenerator { private static readonly instances: Map = new Map< diff --git a/src/charging-station/Bootstrap.ts b/src/charging-station/Bootstrap.ts index 503dfb0b..b84de928 100644 --- a/src/charging-station/Bootstrap.ts +++ b/src/charging-station/Bootstrap.ts @@ -8,12 +8,12 @@ import { fileURLToPath } from 'node:url'; import chalk from 'chalk'; import { availableParallelism } from 'poolifier'; -import { waitChargingStationEvents } from './Helpers'; -import type { AbstractUIServer } from './ui-server/AbstractUIServer'; -import { UIServerFactory } from './ui-server/UIServerFactory'; +import { waitChargingStationEvents } from './Helpers.js'; +import type { AbstractUIServer } from './ui-server/AbstractUIServer.js'; +import { UIServerFactory } from './ui-server/UIServerFactory.js'; import { version } from '../../package.json'; -import { BaseError } from '../exception'; -import { type Storage, StorageFactory } from '../performance'; +import { BaseError } from '../exception/index.js'; +import { type Storage, StorageFactory } from '../performance/index.js'; import { type ChargingStationData, type ChargingStationWorkerData, @@ -27,7 +27,7 @@ import { type StorageConfiguration, type UIServerConfiguration, type WorkerConfiguration, -} from '../types'; +} from '../types/index.js'; import { Configuration, Constants, @@ -39,8 +39,8 @@ import { isNullOrUndefined, logPrefix, logger, -} from '../utils'; -import { type WorkerAbstract, WorkerFactory } from '../worker'; +} from '../utils/index.js'; +import { type WorkerAbstract, WorkerFactory } from '../worker/index.js'; const moduleName = 'Bootstrap'; diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 5bc0ec9a..892a6704 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -11,14 +11,14 @@ import { millisecondsToSeconds, secondsToMilliseconds } from 'date-fns'; import merge from 'just-merge'; import { type RawData, WebSocket } from 'ws'; -import { AutomaticTransactionGenerator } from './AutomaticTransactionGenerator'; -import { ChargingStationWorkerBroadcastChannel } from './broadcast-channel/ChargingStationWorkerBroadcastChannel'; +import { AutomaticTransactionGenerator } from './AutomaticTransactionGenerator.js'; +import { ChargingStationWorkerBroadcastChannel } from './broadcast-channel/ChargingStationWorkerBroadcastChannel.js'; import { addConfigurationKey, deleteConfigurationKey, getConfigurationKey, setConfigurationKeyValue, -} from './ConfigurationKeyUtils'; +} from './ConfigurationKeyUtils.js'; import { buildConnectorsMap, checkChargingStation, @@ -43,8 +43,8 @@ import { propagateSerialNumber, stationTemplateToStationInfo, warnTemplateKeysDeprecation, -} from './Helpers'; -import { IdTagsCache } from './IdTagsCache'; +} from './Helpers.js'; +import { IdTagsCache } from './IdTagsCache.js'; import { OCPP16IncomingRequestService, OCPP16RequestService, @@ -59,10 +59,10 @@ import { buildTransactionEndMeterValue, getMessageTypeString, sendAndSetConnectorStatus, -} from './ocpp'; -import { SharedLRUCache } from './SharedLRUCache'; -import { BaseError, OCPPError } from '../exception'; -import { PerformanceStatistics } from '../performance'; +} from './ocpp/index.js'; +import { SharedLRUCache } from './SharedLRUCache.js'; +import { BaseError, OCPPError } from '../exception/index.js'; +import { PerformanceStatistics } from '../performance/index.js'; import { type AutomaticTransactionGeneratorConfiguration, AvailabilityType, @@ -117,7 +117,7 @@ import { type WSError, WebSocketCloseEventStatusCode, type WsOptions, -} from '../types'; +} from '../types/index.js'; import { ACElectricUtils, AsyncLock, @@ -152,7 +152,7 @@ import { secureRandom, sleep, watchJsonFile, -} from '../utils'; +} from '../utils/index.js'; export class ChargingStation extends EventEmitter { public readonly index: number; diff --git a/src/charging-station/ChargingStationWorker.ts b/src/charging-station/ChargingStationWorker.ts index d9e462d0..c8f992f3 100644 --- a/src/charging-station/ChargingStationWorker.ts +++ b/src/charging-station/ChargingStationWorker.ts @@ -4,11 +4,11 @@ import { parentPort } from 'node:worker_threads'; import { ThreadWorker } from 'poolifier'; -import { ChargingStation } from './ChargingStation'; -import { BaseError } from '../exception'; -import type { ChargingStationWorkerData } from '../types'; -import { Configuration } from '../utils'; -import { type WorkerMessage, WorkerMessageEvents } from '../worker'; +import { ChargingStation } from './ChargingStation.js'; +import { BaseError } from '../exception/index.js'; +import type { ChargingStationWorkerData } from '../types/index.js'; +import { Configuration } from '../utils/index.js'; +import { type WorkerMessage, WorkerMessageEvents } from '../worker/index.js'; /** * Creates and starts a charging station instance diff --git a/src/charging-station/ConfigurationKeyUtils.ts b/src/charging-station/ConfigurationKeyUtils.ts index d1d093f7..c7302e70 100644 --- a/src/charging-station/ConfigurationKeyUtils.ts +++ b/src/charging-station/ConfigurationKeyUtils.ts @@ -1,6 +1,6 @@ -import type { ChargingStation } from './ChargingStation'; -import type { ConfigurationKey, ConfigurationKeyType } from '../types'; -import { logger } from '../utils'; +import type { ChargingStation } from './ChargingStation.js'; +import type { ConfigurationKey, ConfigurationKeyType } from '../types/index.js'; +import { logger } from '../utils/index.js'; interface ConfigurationKeyOptions { readonly?: boolean; diff --git a/src/charging-station/Helpers.ts b/src/charging-station/Helpers.ts index 4f34fe18..094205b8 100644 --- a/src/charging-station/Helpers.ts +++ b/src/charging-station/Helpers.ts @@ -22,9 +22,9 @@ import { } from 'date-fns'; import { maxTime } from 'date-fns/constants'; -import type { ChargingStation } from './ChargingStation'; -import { getConfigurationKey } from './ConfigurationKeyUtils'; -import { BaseError } from '../exception'; +import type { ChargingStation } from './ChargingStation.js'; +import { getConfigurationKey } from './ConfigurationKeyUtils.js'; +import { BaseError } from '../exception/index.js'; import { AmpereUnits, AvailabilityType, @@ -52,7 +52,7 @@ import { StandardParametersKey, SupportedFeatureProfiles, Voltage, -} from '../types'; +} from '../types/index.js'; import { ACElectricUtils, Constants, @@ -70,7 +70,7 @@ import { isValidTime, logger, secureRandom, -} from '../utils'; +} from '../utils/index.js'; const moduleName = 'Helpers'; diff --git a/src/charging-station/IdTagsCache.ts b/src/charging-station/IdTagsCache.ts index 5e0ab0b8..3e259fff 100644 --- a/src/charging-station/IdTagsCache.ts +++ b/src/charging-station/IdTagsCache.ts @@ -1,8 +1,8 @@ import { type FSWatcher, readFileSync } from 'node:fs'; -import type { ChargingStation } from './ChargingStation'; -import { getIdTagsFile } from './Helpers'; -import { FileType, IdTagDistribution } from '../types'; +import type { ChargingStation } from './ChargingStation.js'; +import { getIdTagsFile } from './Helpers.js'; +import { FileType, IdTagDistribution } from '../types/index.js'; import { handleFileException, isNotEmptyString, @@ -10,7 +10,7 @@ import { logger, secureRandom, watchJsonFile, -} from '../utils'; +} from '../utils/index.js'; interface IdTagsCacheValueType { idTags: string[]; diff --git a/src/charging-station/SharedLRUCache.ts b/src/charging-station/SharedLRUCache.ts index d55f358e..a06c8452 100644 --- a/src/charging-station/SharedLRUCache.ts +++ b/src/charging-station/SharedLRUCache.ts @@ -1,8 +1,13 @@ import LRUCache from 'mnemonist/lru-map-with-delete.js'; -import { Bootstrap } from './Bootstrap'; -import type { ChargingStationConfiguration, ChargingStationTemplate } from '../types'; -import { isEmptyObject, isNotEmptyArray, isNotEmptyString, isNullOrUndefined } from '../utils'; +import { Bootstrap } from './Bootstrap.js'; +import type { ChargingStationConfiguration, ChargingStationTemplate } from '../types/index.js'; +import { + isEmptyObject, + isNotEmptyArray, + isNotEmptyString, + isNullOrUndefined, +} from '../utils/index.js'; enum CacheType { chargingStationTemplate = 'chargingStationTemplate', diff --git a/src/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.ts b/src/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.ts index 2697397a..5de17e1a 100644 --- a/src/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.ts +++ b/src/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.ts @@ -1,7 +1,7 @@ import { secondsToMilliseconds } from 'date-fns'; -import { WorkerBroadcastChannel } from './WorkerBroadcastChannel'; -import { BaseError, type OCPPError } from '../../exception'; +import { WorkerBroadcastChannel } from './WorkerBroadcastChannel.js'; +import { BaseError, type OCPPError } from '../../exception/index.js'; import { AuthorizationStatus, type AuthorizeRequest, @@ -36,11 +36,17 @@ import { type StatusNotificationResponse, type StopTransactionRequest, type StopTransactionResponse, -} from '../../types'; -import { Constants, convertToInt, isEmptyObject, isNullOrUndefined, logger } from '../../utils'; -import type { ChargingStation } from '../ChargingStation'; -import { getConfigurationKey } from '../ConfigurationKeyUtils'; -import { buildMeterValue } from '../ocpp'; +} from '../../types/index.js'; +import { + Constants, + convertToInt, + isEmptyObject, + isNullOrUndefined, + logger, +} from '../../utils/index.js'; +import type { ChargingStation } from '../ChargingStation.js'; +import { getConfigurationKey } from '../ConfigurationKeyUtils.js'; +import { buildMeterValue } from '../ocpp/index.js'; const moduleName = 'ChargingStationWorkerBroadcastChannel'; diff --git a/src/charging-station/broadcast-channel/UIServiceWorkerBroadcastChannel.ts b/src/charging-station/broadcast-channel/UIServiceWorkerBroadcastChannel.ts index d3282916..62588e0a 100644 --- a/src/charging-station/broadcast-channel/UIServiceWorkerBroadcastChannel.ts +++ b/src/charging-station/broadcast-channel/UIServiceWorkerBroadcastChannel.ts @@ -1,13 +1,13 @@ -import { WorkerBroadcastChannel } from './WorkerBroadcastChannel'; +import { WorkerBroadcastChannel } from './WorkerBroadcastChannel.js'; import { type BroadcastChannelResponse, type BroadcastChannelResponsePayload, type MessageEvent, type ResponsePayload, ResponseStatus, -} from '../../types'; -import { isNullOrUndefined, logger } from '../../utils'; -import type { AbstractUIService } from '../ui-server/ui-services/AbstractUIService'; +} from '../../types/index.js'; +import { isNullOrUndefined, logger } from '../../utils/index.js'; +import type { AbstractUIService } from '../ui-server/ui-services/AbstractUIService.js'; const moduleName = 'UIServiceWorkerBroadcastChannel'; diff --git a/src/charging-station/broadcast-channel/WorkerBroadcastChannel.ts b/src/charging-station/broadcast-channel/WorkerBroadcastChannel.ts index 9102b100..dbd83c5b 100644 --- a/src/charging-station/broadcast-channel/WorkerBroadcastChannel.ts +++ b/src/charging-station/broadcast-channel/WorkerBroadcastChannel.ts @@ -5,8 +5,8 @@ import type { BroadcastChannelResponse, JsonType, MessageEvent, -} from '../../types'; -import { logPrefix, logger, validateUUID } from '../../utils'; +} from '../../types/index.js'; +import { logPrefix, logger, validateUUID } from '../../utils/index.js'; const moduleName = 'WorkerBroadcastChannel'; diff --git a/src/charging-station/index.ts b/src/charging-station/index.ts index ed055a8d..d03a5f77 100644 --- a/src/charging-station/index.ts +++ b/src/charging-station/index.ts @@ -1,10 +1,10 @@ -export { Bootstrap } from './Bootstrap'; -export type { ChargingStation } from './ChargingStation'; +export { Bootstrap } from './Bootstrap.js'; +export type { ChargingStation } from './ChargingStation.js'; export { addConfigurationKey, getConfigurationKey, setConfigurationKeyValue, -} from './ConfigurationKeyUtils'; +} from './ConfigurationKeyUtils.js'; export { canProceedChargingProfile, checkChargingStation, @@ -15,4 +15,4 @@ export { prepareChargingProfileKind, removeExpiredReservations, resetConnectorStatus, -} from './Helpers'; +} from './Helpers.js'; diff --git a/src/charging-station/ocpp/1.6/OCPP16Constants.ts b/src/charging-station/ocpp/1.6/OCPP16Constants.ts index c33e5529..3d1ab3c8 100644 --- a/src/charging-station/ocpp/1.6/OCPP16Constants.ts +++ b/src/charging-station/ocpp/1.6/OCPP16Constants.ts @@ -1,5 +1,5 @@ -import { type ConnectorStatusTransition, OCPP16ChargePointStatus } from '../../../types'; -import { OCPPConstants } from '../OCPPConstants'; +import { type ConnectorStatusTransition, OCPP16ChargePointStatus } from '../../../types/index.js'; +import { OCPPConstants } from '../OCPPConstants.js'; export class OCPP16Constants extends OCPPConstants { static readonly ChargePointStatusChargingStationTransitions: Readonly< diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index 6dae5c8a..f1ea435a 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -16,8 +16,8 @@ import { import { maxTime } from 'date-fns/constants'; import { create } from 'tar'; -import { OCPP16Constants } from './OCPP16Constants'; -import { OCPP16ServiceUtils } from './OCPP16ServiceUtils'; +import { OCPP16Constants } from './OCPP16Constants.js'; +import { OCPP16ServiceUtils } from './OCPP16ServiceUtils.js'; import { type ChargingStation, canProceedChargingProfile, @@ -27,8 +27,8 @@ import { prepareChargingProfileKind, removeExpiredReservations, setConfigurationKeyValue, -} from '../../../charging-station'; -import { OCPPError } from '../../../exception'; +} from '../../../charging-station/index.js'; +import { OCPPError } from '../../../exception/index.js'; import { type ChangeConfigurationRequest, type ChangeConfigurationResponse, @@ -95,7 +95,7 @@ import { type SetChargingProfileResponse, type UnlockConnectorRequest, type UnlockConnectorResponse, -} from '../../../types'; +} from '../../../types/index.js'; import { Constants, convertToDate, @@ -109,8 +109,8 @@ import { isUndefined, logger, sleep, -} from '../../../utils'; -import { OCPPIncomingRequestService } from '../OCPPIncomingRequestService'; +} from '../../../utils/index.js'; +import { OCPPIncomingRequestService } from '../OCPPIncomingRequestService.js'; const moduleName = 'OCPP16IncomingRequestService'; diff --git a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts index b238dc66..2b0375a2 100644 --- a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts @@ -2,10 +2,10 @@ import type { JSONSchemaType } from 'ajv'; -import { OCPP16Constants } from './OCPP16Constants'; -import { OCPP16ServiceUtils } from './OCPP16ServiceUtils'; -import type { ChargingStation } from '../../../charging-station'; -import { OCPPError } from '../../../exception'; +import { OCPP16Constants } from './OCPP16Constants.js'; +import { OCPP16ServiceUtils } from './OCPP16ServiceUtils.js'; +import type { ChargingStation } from '../../../charging-station/index.js'; +import { OCPPError } from '../../../exception/index.js'; import { ErrorType, type JsonObject, @@ -24,10 +24,10 @@ import { type OCPP16StopTransactionRequest, OCPPVersion, type RequestParams, -} from '../../../types'; -import { Constants, generateUUID } from '../../../utils'; -import { OCPPRequestService } from '../OCPPRequestService'; -import type { OCPPResponseService } from '../OCPPResponseService'; +} from '../../../types/index.js'; +import { Constants, generateUUID } from '../../../utils/index.js'; +import { OCPPRequestService } from '../OCPPRequestService.js'; +import type { OCPPResponseService } from '../OCPPResponseService.js'; const moduleName = 'OCPP16RequestService'; diff --git a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts index 7c331b6c..1e64e74b 100644 --- a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts @@ -3,15 +3,15 @@ import type { JSONSchemaType } from 'ajv'; import { secondsToMilliseconds } from 'date-fns'; -import { OCPP16ServiceUtils } from './OCPP16ServiceUtils'; +import { OCPP16ServiceUtils } from './OCPP16ServiceUtils.js'; import { type ChargingStation, addConfigurationKey, getConfigurationKey, hasReservationExpired, resetConnectorStatus, -} from '../../../charging-station'; -import { OCPPError } from '../../../exception'; +} from '../../../charging-station/index.js'; +import { OCPPError } from '../../../exception/index.js'; import { type ChangeConfigurationResponse, ErrorType, @@ -50,9 +50,9 @@ import { type ResponseHandler, type SetChargingProfileResponse, type UnlockConnectorResponse, -} from '../../../types'; -import { Constants, convertToInt, isNullOrUndefined, logger } from '../../../utils'; -import { OCPPResponseService } from '../OCPPResponseService'; +} from '../../../types/index.js'; +import { Constants, convertToInt, isNullOrUndefined, logger } from '../../../utils/index.js'; +import { OCPPResponseService } from '../OCPPResponseService.js'; const moduleName = 'OCPP16ResponseService'; diff --git a/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts b/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts index 4062bc0a..e4d1ebdf 100644 --- a/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts +++ b/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts @@ -11,12 +11,12 @@ import { isWithinInterval, } from 'date-fns'; -import { OCPP16Constants } from './OCPP16Constants'; +import { OCPP16Constants } from './OCPP16Constants.js'; import { type ChargingStation, hasFeatureProfile, hasReservationExpired, -} from '../../../charging-station'; +} from '../../../charging-station/index.js'; import { type GenericResponse, type JsonType, @@ -36,9 +36,9 @@ import { OCPP16StopTransactionReason, type OCPP16SupportedFeatureProfiles, OCPPVersion, -} from '../../../types'; -import { isNotEmptyArray, isNullOrUndefined, logger, roundTo } from '../../../utils'; -import { OCPPServiceUtils } from '../OCPPServiceUtils'; +} from '../../../types/index.js'; +import { isNotEmptyArray, isNullOrUndefined, logger, roundTo } from '../../../utils/index.js'; +import { OCPPServiceUtils } from '../OCPPServiceUtils.js'; export class OCPP16ServiceUtils extends OCPPServiceUtils { public static checkFeatureProfile( diff --git a/src/charging-station/ocpp/2.0/OCPP20Constants.ts b/src/charging-station/ocpp/2.0/OCPP20Constants.ts index c64fe13d..3ae368a3 100644 --- a/src/charging-station/ocpp/2.0/OCPP20Constants.ts +++ b/src/charging-station/ocpp/2.0/OCPP20Constants.ts @@ -1,5 +1,8 @@ -import { type ConnectorStatusTransition, OCPP20ConnectorStatusEnumType } from '../../../types'; -import { OCPPConstants } from '../OCPPConstants'; +import { + type ConnectorStatusTransition, + OCPP20ConnectorStatusEnumType, +} from '../../../types/index.js'; +import { OCPPConstants } from '../OCPPConstants.js'; export class OCPP20Constants extends OCPPConstants { static readonly ChargingStationStatusTransitions: Readonly = diff --git a/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts b/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts index 0d657d99..a48c7e9d 100644 --- a/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts +++ b/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts @@ -2,9 +2,9 @@ import type { JSONSchemaType } from 'ajv'; -import { OCPP20ServiceUtils } from './OCPP20ServiceUtils'; -import type { ChargingStation } from '../../../charging-station'; -import { OCPPError } from '../../../exception'; +import { OCPP20ServiceUtils } from './OCPP20ServiceUtils.js'; +import type { ChargingStation } from '../../../charging-station/index.js'; +import { OCPPError } from '../../../exception/index.js'; import { ErrorType, type IncomingRequestHandler, @@ -12,9 +12,9 @@ import { type OCPP20ClearCacheRequest, OCPP20IncomingRequestCommand, OCPPVersion, -} from '../../../types'; -import { logger } from '../../../utils'; -import { OCPPIncomingRequestService } from '../OCPPIncomingRequestService'; +} from '../../../types/index.js'; +import { logger } from '../../../utils/index.js'; +import { OCPPIncomingRequestService } from '../OCPPIncomingRequestService.js'; const moduleName = 'OCPP20IncomingRequestService'; diff --git a/src/charging-station/ocpp/2.0/OCPP20RequestService.ts b/src/charging-station/ocpp/2.0/OCPP20RequestService.ts index f9f5c268..60b44142 100644 --- a/src/charging-station/ocpp/2.0/OCPP20RequestService.ts +++ b/src/charging-station/ocpp/2.0/OCPP20RequestService.ts @@ -2,10 +2,10 @@ import type { JSONSchemaType } from 'ajv'; -import { OCPP20Constants } from './OCPP20Constants'; -import { OCPP20ServiceUtils } from './OCPP20ServiceUtils'; -import type { ChargingStation } from '../../../charging-station'; -import { OCPPError } from '../../../exception'; +import { OCPP20Constants } from './OCPP20Constants.js'; +import { OCPP20ServiceUtils } from './OCPP20ServiceUtils.js'; +import type { ChargingStation } from '../../../charging-station/index.js'; +import { OCPPError } from '../../../exception/index.js'; import { ErrorType, type JsonObject, @@ -16,10 +16,10 @@ import { type OCPP20StatusNotificationRequest, OCPPVersion, type RequestParams, -} from '../../../types'; -import { generateUUID } from '../../../utils'; -import { OCPPRequestService } from '../OCPPRequestService'; -import type { OCPPResponseService } from '../OCPPResponseService'; +} from '../../../types/index.js'; +import { generateUUID } from '../../../utils/index.js'; +import { OCPPRequestService } from '../OCPPRequestService.js'; +import type { OCPPResponseService } from '../OCPPResponseService.js'; const moduleName = 'OCPP20RequestService'; diff --git a/src/charging-station/ocpp/2.0/OCPP20ResponseService.ts b/src/charging-station/ocpp/2.0/OCPP20ResponseService.ts index 111b114a..98f2afb6 100644 --- a/src/charging-station/ocpp/2.0/OCPP20ResponseService.ts +++ b/src/charging-station/ocpp/2.0/OCPP20ResponseService.ts @@ -2,9 +2,9 @@ import type { JSONSchemaType } from 'ajv'; -import { OCPP20ServiceUtils } from './OCPP20ServiceUtils'; -import { type ChargingStation, addConfigurationKey } from '../../../charging-station'; -import { OCPPError } from '../../../exception'; +import { OCPP20ServiceUtils } from './OCPP20ServiceUtils.js'; +import { type ChargingStation, addConfigurationKey } from '../../../charging-station/index.js'; +import { OCPPError } from '../../../exception/index.js'; import { ErrorType, type JsonType, @@ -18,9 +18,9 @@ import { OCPPVersion, RegistrationStatusEnumType, type ResponseHandler, -} from '../../../types'; -import { logger } from '../../../utils'; -import { OCPPResponseService } from '../OCPPResponseService'; +} from '../../../types/index.js'; +import { logger } from '../../../utils/index.js'; +import { OCPPResponseService } from '../OCPPResponseService.js'; const moduleName = 'OCPP20ResponseService'; diff --git a/src/charging-station/ocpp/2.0/OCPP20ServiceUtils.ts b/src/charging-station/ocpp/2.0/OCPP20ServiceUtils.ts index c924b240..eb4d099b 100644 --- a/src/charging-station/ocpp/2.0/OCPP20ServiceUtils.ts +++ b/src/charging-station/ocpp/2.0/OCPP20ServiceUtils.ts @@ -2,8 +2,8 @@ import type { JSONSchemaType } from 'ajv'; -import { type JsonType, OCPPVersion } from '../../../types'; -import { OCPPServiceUtils } from '../OCPPServiceUtils'; +import { type JsonType, OCPPVersion } from '../../../types/index.js'; +import { OCPPServiceUtils } from '../OCPPServiceUtils.js'; export class OCPP20ServiceUtils extends OCPPServiceUtils { public static parseJsonSchemaFile( diff --git a/src/charging-station/ocpp/OCPPConstants.ts b/src/charging-station/ocpp/OCPPConstants.ts index dbe7834b..8f5f98d6 100644 --- a/src/charging-station/ocpp/OCPPConstants.ts +++ b/src/charging-station/ocpp/OCPPConstants.ts @@ -6,11 +6,11 @@ import { DataTransferStatus, GenericStatus, MeterValueMeasurand, + ReservationStatus, TriggerMessageStatus, UnlockStatus, -} from '../../types'; -import { ReservationStatus } from '../../types/ocpp/Responses'; -import { Constants } from '../../utils'; +} from '../../types/index.js'; +import { Constants } from '../../utils/index.js'; export class OCPPConstants { static readonly OCPP_WEBSOCKET_TIMEOUT = 60000; // Ms diff --git a/src/charging-station/ocpp/OCPPIncomingRequestService.ts b/src/charging-station/ocpp/OCPPIncomingRequestService.ts index c93129bc..06a80e3a 100644 --- a/src/charging-station/ocpp/OCPPIncomingRequestService.ts +++ b/src/charging-station/ocpp/OCPPIncomingRequestService.ts @@ -1,18 +1,18 @@ import Ajv, { type JSONSchemaType, type ValidateFunction } from 'ajv'; import ajvFormats from 'ajv-formats'; -import { OCPPConstants } from './OCPPConstants'; -import { OCPPServiceUtils } from './OCPPServiceUtils'; -import { type ChargingStation, getIdTagsFile } from '../../charging-station'; -import { OCPPError } from '../../exception'; +import { OCPPConstants } from './OCPPConstants.js'; +import { OCPPServiceUtils } from './OCPPServiceUtils.js'; +import { type ChargingStation, getIdTagsFile } from '../../charging-station/index.js'; +import { OCPPError } from '../../exception/index.js'; import type { ClearCacheResponse, HandleErrorParams, IncomingRequestCommand, JsonType, OCPPVersion, -} from '../../types'; -import { logger, setDefaultErrorParams } from '../../utils'; +} from '../../types/index.js'; +import { logger, setDefaultErrorParams } from '../../utils/index.js'; const moduleName = 'OCPPIncomingRequestService'; diff --git a/src/charging-station/ocpp/OCPPRequestService.ts b/src/charging-station/ocpp/OCPPRequestService.ts index b9a75e5f..aeb09c33 100644 --- a/src/charging-station/ocpp/OCPPRequestService.ts +++ b/src/charging-station/ocpp/OCPPRequestService.ts @@ -1,12 +1,12 @@ import Ajv, { type JSONSchemaType, type ValidateFunction } from 'ajv'; import ajvFormats from 'ajv-formats'; -import { OCPPConstants } from './OCPPConstants'; -import type { OCPPResponseService } from './OCPPResponseService'; -import { OCPPServiceUtils } from './OCPPServiceUtils'; -import type { ChargingStation } from '../../charging-station'; -import { OCPPError } from '../../exception'; -import { PerformanceStatistics } from '../../performance'; +import { OCPPConstants } from './OCPPConstants.js'; +import type { OCPPResponseService } from './OCPPResponseService.js'; +import { OCPPServiceUtils } from './OCPPServiceUtils.js'; +import type { ChargingStation } from '../../charging-station/index.js'; +import { OCPPError } from '../../exception/index.js'; +import { PerformanceStatistics } from '../../performance/index.js'; import { ChargingStationEvents, type ErrorCallback, @@ -22,14 +22,14 @@ import { type Response, type ResponseCallback, type ResponseType, -} from '../../types'; +} from '../../types/index.js'; import { cloneObject, formatDurationMilliSeconds, handleSendMessageError, isNullOrUndefined, logger, -} from '../../utils'; +} from '../../utils/index.js'; const moduleName = 'OCPPRequestService'; diff --git a/src/charging-station/ocpp/OCPPResponseService.ts b/src/charging-station/ocpp/OCPPResponseService.ts index b73fee58..9fcfd6ef 100644 --- a/src/charging-station/ocpp/OCPPResponseService.ts +++ b/src/charging-station/ocpp/OCPPResponseService.ts @@ -1,11 +1,16 @@ import Ajv, { type JSONSchemaType, type ValidateFunction } from 'ajv'; import ajvFormats from 'ajv-formats'; -import { OCPPServiceUtils } from './OCPPServiceUtils'; -import type { ChargingStation } from '../../charging-station'; -import { OCPPError } from '../../exception'; -import type { IncomingRequestCommand, JsonType, OCPPVersion, RequestCommand } from '../../types'; -import { logger } from '../../utils'; +import { OCPPServiceUtils } from './OCPPServiceUtils.js'; +import type { ChargingStation } from '../../charging-station/index.js'; +import { OCPPError } from '../../exception/index.js'; +import type { + IncomingRequestCommand, + JsonType, + OCPPVersion, + RequestCommand, +} from '../../types/index.js'; +import { logger } from '../../utils/index.js'; const moduleName = 'OCPPResponseService'; diff --git a/src/charging-station/ocpp/OCPPServiceUtils.ts b/src/charging-station/ocpp/OCPPServiceUtils.ts index 27549405..56961521 100644 --- a/src/charging-station/ocpp/OCPPServiceUtils.ts +++ b/src/charging-station/ocpp/OCPPServiceUtils.ts @@ -5,11 +5,15 @@ import { fileURLToPath } from 'node:url'; import type { DefinedError, ErrorObject, JSONSchemaType } from 'ajv'; import { isDate } from 'date-fns'; -import { OCPP16Constants } from './1.6/OCPP16Constants'; -import { OCPP20Constants } from './2.0/OCPP20Constants'; -import { OCPPConstants } from './OCPPConstants'; -import { type ChargingStation, getConfigurationKey, getIdTagsFile } from '../../charging-station'; -import { BaseError, OCPPError } from '../../exception'; +import { OCPP16Constants } from './1.6/OCPP16Constants.js'; +import { OCPP20Constants } from './2.0/OCPP20Constants.js'; +import { OCPPConstants } from './OCPPConstants.js'; +import { + type ChargingStation, + getConfigurationKey, + getIdTagsFile, +} from '../../charging-station/index.js'; +import { BaseError, OCPPError } from '../../exception/index.js'; import { AuthorizationStatus, type AuthorizeRequest, @@ -42,7 +46,7 @@ import { StandardParametersKey, type StatusNotificationRequest, type StatusNotificationResponse, -} from '../../types'; +} from '../../types/index.js'; import { ACElectricUtils, Constants, @@ -62,7 +66,7 @@ import { max, min, roundTo, -} from '../../utils'; +} from '../../utils/index.js'; export const getMessageTypeString = (messageType: MessageType): string => { switch (messageType) { diff --git a/src/charging-station/ocpp/index.ts b/src/charging-station/ocpp/index.ts index b5abe464..da1b751e 100644 --- a/src/charging-station/ocpp/index.ts +++ b/src/charging-station/ocpp/index.ts @@ -1,11 +1,11 @@ -export { OCPP16IncomingRequestService } from './1.6/OCPP16IncomingRequestService'; -export { OCPP16RequestService } from './1.6/OCPP16RequestService'; -export { OCPP16ResponseService } from './1.6/OCPP16ResponseService'; -export { OCPP20IncomingRequestService } from './2.0/OCPP20IncomingRequestService'; -export { OCPP20RequestService } from './2.0/OCPP20RequestService'; -export { OCPP20ResponseService } from './2.0/OCPP20ResponseService'; -export { OCPPIncomingRequestService } from './OCPPIncomingRequestService'; -export { OCPPRequestService } from './OCPPRequestService'; +export { OCPP16IncomingRequestService } from './1.6/OCPP16IncomingRequestService.js'; +export { OCPP16RequestService } from './1.6/OCPP16RequestService.js'; +export { OCPP16ResponseService } from './1.6/OCPP16ResponseService.js'; +export { OCPP20IncomingRequestService } from './2.0/OCPP20IncomingRequestService.js'; +export { OCPP20RequestService } from './2.0/OCPP20RequestService.js'; +export { OCPP20ResponseService } from './2.0/OCPP20ResponseService.js'; +export { OCPPIncomingRequestService } from './OCPPIncomingRequestService.js'; +export { OCPPRequestService } from './OCPPRequestService.js'; export { buildMeterValue, buildStatusNotificationRequest, @@ -13,4 +13,4 @@ export { getMessageTypeString, isIdTagAuthorized, sendAndSetConnectorStatus, -} from './OCPPServiceUtils'; +} from './OCPPServiceUtils.js'; diff --git a/src/charging-station/ui-server/AbstractUIServer.ts b/src/charging-station/ui-server/AbstractUIServer.ts index d27ea616..c6cc741b 100644 --- a/src/charging-station/ui-server/AbstractUIServer.ts +++ b/src/charging-station/ui-server/AbstractUIServer.ts @@ -3,9 +3,9 @@ import { type Http2Server, createServer } from 'node:http2'; import type { WebSocket } from 'ws'; -import type { AbstractUIService } from './ui-services/AbstractUIService'; -import { UIServiceFactory } from './ui-services/UIServiceFactory'; -import { BaseError } from '../../exception'; +import type { AbstractUIService } from './ui-services/AbstractUIService.js'; +import { UIServiceFactory } from './ui-services/UIServiceFactory.js'; +import { BaseError } from '../../exception/index.js'; import { ApplicationProtocolVersion, AuthenticationType, @@ -17,7 +17,7 @@ import { type RequestPayload, type ResponsePayload, type UIServerConfiguration, -} from '../../types'; +} from '../../types/index.js'; export abstract class AbstractUIServer { public readonly chargingStations: Map; diff --git a/src/charging-station/ui-server/UIHttpServer.ts b/src/charging-station/ui-server/UIHttpServer.ts index 85dbccdf..eeab416d 100644 --- a/src/charging-station/ui-server/UIHttpServer.ts +++ b/src/charging-station/ui-server/UIHttpServer.ts @@ -2,9 +2,9 @@ import type { IncomingMessage, RequestListener, ServerResponse } from 'node:http import { StatusCodes } from 'http-status-codes'; -import { AbstractUIServer } from './AbstractUIServer'; -import { UIServerUtils } from './UIServerUtils'; -import { BaseError } from '../../exception'; +import { AbstractUIServer } from './AbstractUIServer.js'; +import { UIServerUtils } from './UIServerUtils.js'; +import { BaseError } from '../../exception/index.js'; import { ApplicationProtocolVersion, type ProcedureName, @@ -15,7 +15,7 @@ import { type RequestPayload, ResponseStatus, type UIServerConfiguration, -} from '../../types'; +} from '../../types/index.js'; import { Constants, generateUUID, @@ -23,7 +23,7 @@ import { isNullOrUndefined, logPrefix, logger, -} from '../../utils'; +} from '../../utils/index.js'; const moduleName = 'UIHttpServer'; diff --git a/src/charging-station/ui-server/UIServerFactory.ts b/src/charging-station/ui-server/UIServerFactory.ts index d3c34b58..b192ff35 100644 --- a/src/charging-station/ui-server/UIServerFactory.ts +++ b/src/charging-station/ui-server/UIServerFactory.ts @@ -1,14 +1,14 @@ import chalk from 'chalk'; -import type { AbstractUIServer } from './AbstractUIServer'; -import { UIHttpServer } from './UIHttpServer'; -import { UIServerUtils } from './UIServerUtils'; -import { UIWebSocketServer } from './UIWebSocketServer'; +import type { AbstractUIServer } from './AbstractUIServer.js'; +import { UIHttpServer } from './UIHttpServer.js'; +import { UIServerUtils } from './UIServerUtils.js'; +import { UIWebSocketServer } from './UIWebSocketServer.js'; import { ApplicationProtocol, ApplicationProtocolVersion, type UIServerConfiguration, -} from '../../types'; +} from '../../types/index.js'; export class UIServerFactory { private constructor() { diff --git a/src/charging-station/ui-server/UIServerUtils.ts b/src/charging-station/ui-server/UIServerUtils.ts index 95bbba56..e35a1f15 100644 --- a/src/charging-station/ui-server/UIServerUtils.ts +++ b/src/charging-station/ui-server/UIServerUtils.ts @@ -1,7 +1,7 @@ import type { IncomingMessage } from 'node:http'; -import { Protocol, ProtocolVersion } from '../../types'; -import { logPrefix, logger } from '../../utils'; +import { Protocol, ProtocolVersion } from '../../types/index.js'; +import { logPrefix, logger } from '../../utils/index.js'; export class UIServerUtils { private constructor() { diff --git a/src/charging-station/ui-server/UIWebSocketServer.ts b/src/charging-station/ui-server/UIWebSocketServer.ts index e322ef8d..42e4b3c2 100644 --- a/src/charging-station/ui-server/UIWebSocketServer.ts +++ b/src/charging-station/ui-server/UIWebSocketServer.ts @@ -4,14 +4,14 @@ import type { Duplex } from 'node:stream'; import { StatusCodes } from 'http-status-codes'; import { type RawData, WebSocket, WebSocketServer } from 'ws'; -import { AbstractUIServer } from './AbstractUIServer'; -import { UIServerUtils } from './UIServerUtils'; +import { AbstractUIServer } from './AbstractUIServer.js'; +import { UIServerUtils } from './UIServerUtils.js'; import { type ProtocolRequest, type ProtocolResponse, type UIServerConfiguration, WebSocketCloseEventStatusCode, -} from '../../types'; +} from '../../types/index.js'; import { Constants, getWebSocketCloseEventStatusString, @@ -20,7 +20,7 @@ import { logPrefix, logger, validateUUID, -} from '../../utils'; +} from '../../utils/index.js'; 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 e0078c19..8eb450a8 100644 --- a/src/charging-station/ui-server/ui-services/AbstractUIService.ts +++ b/src/charging-station/ui-server/ui-services/AbstractUIService.ts @@ -1,4 +1,4 @@ -import { BaseError, type OCPPError } from '../../../exception'; +import { BaseError, type OCPPError } from '../../../exception/index.js'; import { BroadcastChannelProcedureName, type BroadcastChannelRequestPayload, @@ -10,11 +10,11 @@ import { type RequestPayload, type ResponsePayload, ResponseStatus, -} from '../../../types'; -import { isNotEmptyArray, isNullOrUndefined, logger } from '../../../utils'; -import { Bootstrap } from '../../Bootstrap'; -import { UIServiceWorkerBroadcastChannel } from '../../broadcast-channel/UIServiceWorkerBroadcastChannel'; -import type { AbstractUIServer } from '../AbstractUIServer'; +} from '../../../types/index.js'; +import { isNotEmptyArray, isNullOrUndefined, logger } from '../../../utils/index.js'; +import { Bootstrap } from '../../Bootstrap.js'; +import { UIServiceWorkerBroadcastChannel } from '../../broadcast-channel/UIServiceWorkerBroadcastChannel.js'; +import type { AbstractUIServer } from '../AbstractUIServer.js'; const moduleName = 'AbstractUIService'; diff --git a/src/charging-station/ui-server/ui-services/UIService001.ts b/src/charging-station/ui-server/ui-services/UIService001.ts index e7570c1a..142f97ef 100644 --- a/src/charging-station/ui-server/ui-services/UIService001.ts +++ b/src/charging-station/ui-server/ui-services/UIService001.ts @@ -1,6 +1,6 @@ -import { AbstractUIService } from './AbstractUIService'; -import { type ProtocolRequestHandler, ProtocolVersion } from '../../../types'; -import type { AbstractUIServer } from '../AbstractUIServer'; +import { AbstractUIService } from './AbstractUIService.js'; +import { type ProtocolRequestHandler, ProtocolVersion } from '../../../types/index.js'; +import type { AbstractUIServer } from '../AbstractUIServer.js'; export class UIService001 extends AbstractUIService { constructor(uiServer: AbstractUIServer) { diff --git a/src/charging-station/ui-server/ui-services/UIServiceFactory.ts b/src/charging-station/ui-server/ui-services/UIServiceFactory.ts index 41d60ddd..6b7a0ee2 100644 --- a/src/charging-station/ui-server/ui-services/UIServiceFactory.ts +++ b/src/charging-station/ui-server/ui-services/UIServiceFactory.ts @@ -1,7 +1,7 @@ -import type { AbstractUIService } from './AbstractUIService'; -import { UIService001 } from './UIService001'; -import { ProtocolVersion } from '../../../types'; -import type { AbstractUIServer } from '../AbstractUIServer'; +import type { AbstractUIService } from './AbstractUIService.js'; +import { UIService001 } from './UIService001.js'; +import { ProtocolVersion } from '../../../types/index.js'; +import type { AbstractUIServer } from '../AbstractUIServer.js'; export class UIServiceFactory { private constructor() { diff --git a/src/exception/OCPPError.ts b/src/exception/OCPPError.ts index 5736ad27..4fb9ea16 100644 --- a/src/exception/OCPPError.ts +++ b/src/exception/OCPPError.ts @@ -1,13 +1,13 @@ // Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved. -import { BaseError } from './BaseError'; +import { BaseError } from './BaseError.js'; import { ErrorType, type IncomingRequestCommand, type JsonType, type RequestCommand, -} from '../types'; -import { Constants } from '../utils'; +} from '../types/index.js'; +import { Constants } from '../utils/index.js'; export class OCPPError extends BaseError { code: ErrorType; diff --git a/src/exception/index.ts b/src/exception/index.ts index 5e5b60ca..027f9857 100644 --- a/src/exception/index.ts +++ b/src/exception/index.ts @@ -1,2 +1,2 @@ -export { BaseError } from './BaseError'; -export { OCPPError } from './OCPPError'; +export { BaseError } from './BaseError.js'; +export { OCPPError } from './OCPPError.js'; diff --git a/src/performance/PerformanceStatistics.ts b/src/performance/PerformanceStatistics.ts index 94c189e4..1246e1b2 100644 --- a/src/performance/PerformanceStatistics.ts +++ b/src/performance/PerformanceStatistics.ts @@ -15,7 +15,7 @@ import { type Statistics, type StorageConfiguration, type TimestampedData, -} from '../types'; +} from '../types/index.js'; import { CircularArray, Configuration, @@ -33,7 +33,7 @@ import { min, nthPercentile, stdDeviation, -} from '../utils'; +} from '../utils/index.js'; export class PerformanceStatistics { private static readonly instances: Map = new Map< diff --git a/src/performance/index.ts b/src/performance/index.ts index aae8e4d0..d4d47596 100644 --- a/src/performance/index.ts +++ b/src/performance/index.ts @@ -1,3 +1,3 @@ -export { PerformanceStatistics } from './PerformanceStatistics'; -export { type Storage } from './storage/Storage'; -export { StorageFactory } from './storage/StorageFactory'; +export { PerformanceStatistics } from './PerformanceStatistics.js'; +export { type Storage } from './storage/Storage.js'; +export { StorageFactory } from './storage/StorageFactory.js'; diff --git a/src/performance/storage/JsonFileStorage.ts b/src/performance/storage/JsonFileStorage.ts index 58680181..ff119959 100644 --- a/src/performance/storage/JsonFileStorage.ts +++ b/src/performance/storage/JsonFileStorage.ts @@ -3,16 +3,16 @@ import { closeSync, existsSync, mkdirSync, openSync, writeSync } from 'node:fs'; import { dirname } from 'node:path'; -import { Storage } from './Storage'; -import { BaseError } from '../../exception'; -import { FileType, type Statistics } from '../../types'; +import { Storage } from './Storage.js'; +import { BaseError } from '../../exception/index.js'; +import { FileType, type Statistics } from '../../types/index.js'; import { AsyncLock, AsyncLockType, JSONStringifyWithMapSupport, handleFileException, isNullOrUndefined, -} from '../../utils'; +} from '../../utils/index.js'; export class JsonFileStorage extends Storage { private static performanceRecords: Map; diff --git a/src/performance/storage/MikroOrmStorage.ts b/src/performance/storage/MikroOrmStorage.ts index d1b84b85..8d2cffca 100644 --- a/src/performance/storage/MikroOrmStorage.ts +++ b/src/performance/storage/MikroOrmStorage.ts @@ -9,15 +9,15 @@ import { } from '@mikro-orm/core'; import { TsMorphMetadataProvider } from '@mikro-orm/reflection'; -import { Storage } from './Storage'; +import { Storage } from './Storage.js'; import { type MikroOrmDbType, PerformanceData, PerformanceRecord, type Statistics, StorageType, -} from '../../types'; -import { Constants } from '../../utils'; +} from '../../types/index.js'; +import { Constants } from '../../utils/index.js'; export class MikroOrmStorage extends Storage { private storageType: StorageType; diff --git a/src/performance/storage/MongoDBStorage.ts b/src/performance/storage/MongoDBStorage.ts index 568f7095..e27b33c4 100644 --- a/src/performance/storage/MongoDBStorage.ts +++ b/src/performance/storage/MongoDBStorage.ts @@ -2,10 +2,10 @@ import { MongoClient } from 'mongodb'; -import { Storage } from './Storage'; -import { BaseError } from '../../exception'; -import { type Statistics, StorageType } from '../../types'; -import { Constants } from '../../utils'; +import { Storage } from './Storage.js'; +import { BaseError } from '../../exception/index.js'; +import { type Statistics, StorageType } from '../../types/index.js'; +import { Constants } from '../../utils/index.js'; export class MongoDBStorage extends Storage { private readonly client?: MongoClient; diff --git a/src/performance/storage/Storage.ts b/src/performance/storage/Storage.ts index 4c9ece35..5723dca8 100644 --- a/src/performance/storage/Storage.ts +++ b/src/performance/storage/Storage.ts @@ -8,8 +8,8 @@ import { type HandleErrorParams, type Statistics, StorageType, -} from '../../types'; -import { isNullOrUndefined, logger, setDefaultErrorParams } from '../../utils'; +} from '../../types/index.js'; +import { isNullOrUndefined, logger, setDefaultErrorParams } from '../../utils/index.js'; export abstract class Storage { protected readonly storageUri: URL; diff --git a/src/performance/storage/StorageFactory.ts b/src/performance/storage/StorageFactory.ts index 31d0982e..51a0de50 100644 --- a/src/performance/storage/StorageFactory.ts +++ b/src/performance/storage/StorageFactory.ts @@ -1,12 +1,12 @@ // Copyright Jerome Benoit. 2021-2023. All Rights Reserved. -import { JsonFileStorage } from './JsonFileStorage'; +import { JsonFileStorage } from './JsonFileStorage.js'; // eslint-disable-next-line @typescript-eslint/no-unused-vars -import { MikroOrmStorage } from './MikroOrmStorage'; -import { MongoDBStorage } from './MongoDBStorage'; -import type { Storage } from './Storage'; -import { BaseError } from '../../exception'; -import { StorageType } from '../../types'; +import { MikroOrmStorage } from './MikroOrmStorage.js'; +import { MongoDBStorage } from './MongoDBStorage.js'; +import type { Storage } from './Storage.js'; +import { BaseError } from '../../exception/index.js'; +import { StorageType } from '../../types/index.js'; export class StorageFactory { private constructor() { diff --git a/src/start.ts b/src/start.ts index af569c53..8af14b50 100644 --- a/src/start.ts +++ b/src/start.ts @@ -2,7 +2,7 @@ import chalk from 'chalk'; -import { Bootstrap } from './charging-station'; +import { Bootstrap } from './charging-station/index.js'; try { await Bootstrap.getInstance().start(); diff --git a/src/types/ChargingStationConfiguration.ts b/src/types/ChargingStationConfiguration.ts index 7480459e..82db82d0 100644 --- a/src/types/ChargingStationConfiguration.ts +++ b/src/types/ChargingStationConfiguration.ts @@ -1,8 +1,8 @@ -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'; +import type { ChargingStationAutomaticTransactionGeneratorConfiguration } from './AutomaticTransactionGenerator.js'; +import type { ChargingStationInfoConfiguration } from './ChargingStationInfo.js'; +import type { ChargingStationOcppConfiguration } from './ChargingStationOcppConfiguration.js'; +import type { ConnectorStatus } from './ConnectorStatus.js'; +import type { EvseStatus } from './Evse.js'; interface ConnectorsConfiguration { connectorsStatus?: ConnectorStatus[]; diff --git a/src/types/ChargingStationInfo.ts b/src/types/ChargingStationInfo.ts index c66092c5..9e8da907 100644 --- a/src/types/ChargingStationInfo.ts +++ b/src/types/ChargingStationInfo.ts @@ -1,5 +1,5 @@ -import type { ChargingStationTemplate } from './ChargingStationTemplate'; -import type { FirmwareStatus } from './ocpp/Requests'; +import type { ChargingStationTemplate } from './ChargingStationTemplate.js'; +import type { FirmwareStatus } from './ocpp/Requests.js'; export type ChargingStationInfo = Omit< ChargingStationTemplate, diff --git a/src/types/ChargingStationOcppConfiguration.ts b/src/types/ChargingStationOcppConfiguration.ts index 7bc47aae..e9932701 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 './ocpp/Configuration.js'; export type ConfigurationKey = OCPPConfigurationKey & { visible?: boolean; diff --git a/src/types/ChargingStationTemplate.ts b/src/types/ChargingStationTemplate.ts index 5fd77851..9e9df95f 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 } from './AutomaticTransactionGenerator.js'; +import type { ChargingStationOcppConfiguration } from './ChargingStationOcppConfiguration.js'; +import type { ConnectorStatus } from './ConnectorStatus.js'; +import type { EvseTemplate } from './Evse.js'; +import type { OCPPProtocol } from './ocpp/OCPPProtocol.js'; +import type { OCPPVersion } from './ocpp/OCPPVersion.js'; import type { FirmwareStatus, IncomingRequestCommand, MessageTrigger, RequestCommand, -} from './ocpp/Requests'; +} from './ocpp/Requests.js'; export enum CurrentType { AC = 'AC', diff --git a/src/types/ChargingStationWorker.ts b/src/types/ChargingStationWorker.ts index 64849fc1..5cd73160 100644 --- a/src/types/ChargingStationWorker.ts +++ b/src/types/ChargingStationWorker.ts @@ -1,15 +1,15 @@ import type { WebSocket } from 'ws'; -import type { ChargingStationAutomaticTransactionGeneratorConfiguration } from './AutomaticTransactionGenerator'; -import { ChargingStationEvents } from './ChargingStationEvents'; -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'; +import type { ChargingStationAutomaticTransactionGeneratorConfiguration } from './AutomaticTransactionGenerator.js'; +import { ChargingStationEvents } from './ChargingStationEvents.js'; +import type { ChargingStationInfo } from './ChargingStationInfo.js'; +import type { ChargingStationOcppConfiguration } from './ChargingStationOcppConfiguration.js'; +import type { ConnectorStatus } from './ConnectorStatus.js'; +import type { EvseStatus } from './Evse.js'; +import type { JsonObject } from './JsonType.js'; +import type { BootNotificationResponse } from './ocpp/Responses.js'; +import type { Statistics } from './Statistics.js'; +import { type WorkerData, type WorkerMessage, WorkerMessageEvents } from '../worker/index.js'; interface ChargingStationWorkerOptions extends JsonObject { elementStartDelay?: number; diff --git a/src/types/ConfigurationData.ts b/src/types/ConfigurationData.ts index d1948921..4b636cda 100644 --- a/src/types/ConfigurationData.ts +++ b/src/types/ConfigurationData.ts @@ -3,9 +3,9 @@ import type { ResourceLimits } from 'node:worker_threads'; import type { WorkerChoiceStrategy } from 'poolifier'; -import type { StorageType } from './Storage'; -import type { ApplicationProtocol, AuthenticationType } from './UIProtocol'; -import type { WorkerProcessType } from '../worker'; +import type { StorageType } from './Storage.js'; +import type { ApplicationProtocol, AuthenticationType } from './UIProtocol.js'; +import type { WorkerProcessType } from '../worker/index.js'; type ServerOptions = ListenOptions; diff --git a/src/types/ConnectorStatus.ts b/src/types/ConnectorStatus.ts index c1783eb4..61c8a208 100644 --- a/src/types/ConnectorStatus.ts +++ b/src/types/ConnectorStatus.ts @@ -1,9 +1,9 @@ -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 { Reservation } from './ocpp/Reservation'; +import type { SampledValueTemplate } from './MeasurandPerPhaseSampledValueTemplates.js'; +import type { ChargingProfile } from './ocpp/ChargingProfile.js'; +import type { ConnectorStatusEnum } from './ocpp/ConnectorStatusEnum.js'; +import type { MeterValue } from './ocpp/MeterValues.js'; +import type { AvailabilityType } from './ocpp/Requests.js'; +import type { Reservation } from './ocpp/Reservation.js'; export interface ConnectorStatus { availability: AvailabilityType; diff --git a/src/types/Error.ts b/src/types/Error.ts index 6a7c04e2..46f7569c 100644 --- a/src/types/Error.ts +++ b/src/types/Error.ts @@ -1,4 +1,4 @@ -import type { JsonType } from './JsonType'; +import type { JsonType } from './JsonType.js'; export interface HandleErrorParams { throwError?: boolean; diff --git a/src/types/Evse.ts b/src/types/Evse.ts index f47eb18a..aaf2f664 100644 --- a/src/types/Evse.ts +++ b/src/types/Evse.ts @@ -1,5 +1,5 @@ -import type { ConnectorStatus } from './ConnectorStatus'; -import type { AvailabilityType } from './ocpp/Requests'; +import type { ConnectorStatus } from './ConnectorStatus.js'; +import type { AvailabilityType } from './ocpp/Requests.js'; export interface EvseTemplate { Connectors: Record; diff --git a/src/types/MeasurandPerPhaseSampledValueTemplates.ts b/src/types/MeasurandPerPhaseSampledValueTemplates.ts index 2922db4d..95a73b64 100644 --- a/src/types/MeasurandPerPhaseSampledValueTemplates.ts +++ b/src/types/MeasurandPerPhaseSampledValueTemplates.ts @@ -1,4 +1,4 @@ -import type { SampledValue } from './ocpp/MeterValues'; +import type { SampledValue } from './ocpp/MeterValues.js'; export type SampledValueTemplate = SampledValue & { fluctuationPercent?: number; diff --git a/src/types/Statistics.ts b/src/types/Statistics.ts index 60b2379b..a7abb3f8 100644 --- a/src/types/Statistics.ts +++ b/src/types/Statistics.ts @@ -1,6 +1,6 @@ -import type { IncomingRequestCommand, RequestCommand } from './ocpp/Requests'; -import type { CircularArray } from '../utils'; -import type { WorkerData } from '../worker'; +import type { IncomingRequestCommand, RequestCommand } from './ocpp/Requests.js'; +import type { CircularArray } from '../utils/index.js'; +import type { WorkerData } from '../worker/index.js'; export interface TimestampedData { timestamp: number; diff --git a/src/types/UIProtocol.ts b/src/types/UIProtocol.ts index f4811943..69312eef 100644 --- a/src/types/UIProtocol.ts +++ b/src/types/UIProtocol.ts @@ -1,5 +1,5 @@ -import type { JsonObject } from './JsonType'; -import type { BroadcastChannelResponsePayload } from './WorkerBroadcastChannel'; +import type { JsonObject } from './JsonType.js'; +import type { BroadcastChannelResponsePayload } from './WorkerBroadcastChannel.js'; export enum Protocol { UI = 'ui', diff --git a/src/types/WorkerBroadcastChannel.ts b/src/types/WorkerBroadcastChannel.ts index abc33752..89148fc2 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 './UIProtocol.js'; export type BroadcastChannelRequest = [ string, diff --git a/src/types/index.ts b/src/types/index.ts index cc80f527..4d8b534e 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -10,14 +10,14 @@ export { type RequestPayload, type ResponsePayload, ResponseStatus, -} from './UIProtocol'; +} from './UIProtocol.js'; export { type AutomaticTransactionGeneratorConfiguration, type ChargingStationAutomaticTransactionGeneratorConfiguration, IdTagDistribution, type Status, -} from './AutomaticTransactionGenerator'; -export { type GenericResponse, GenericStatus, RegistrationStatusEnumType } from './ocpp/Common'; +} from './AutomaticTransactionGenerator.js'; +export { type GenericResponse, GenericStatus, RegistrationStatusEnumType } from './ocpp/Common.js'; export { AvailabilityType, type BootNotificationRequest, @@ -39,7 +39,7 @@ export { type ResponseCallback, type ResponseType, type StatusNotificationRequest, -} from './ocpp/Requests'; +} from './ocpp/Requests.js'; export { AvailabilityStatus, type BootNotificationResponse, @@ -54,12 +54,13 @@ export { type FirmwareStatusNotificationResponse, type HeartbeatResponse, type MeterValuesResponse, + ReservationStatus, type Response, type ResponseHandler, type StatusNotificationResponse, TriggerMessageStatus, UnlockStatus, -} from './ocpp/Responses'; +} from './ocpp/Responses.js'; export { AuthorizationStatus, type AuthorizeRequest, @@ -69,8 +70,8 @@ export { StopTransactionReason, type StopTransactionRequest, type StopTransactionResponse, -} from './ocpp/Transaction'; -export { BootReasonEnumType, OCPP20ConnectorStatusEnumType } from './ocpp/2.0/Common'; +} from './ocpp/Transaction.js'; +export { BootReasonEnumType, OCPP20ConnectorStatusEnumType } from './ocpp/2.0/Common.js'; export { BroadcastChannelProcedureName, type BroadcastChannelRequest, @@ -78,7 +79,7 @@ export { type BroadcastChannelResponse, type BroadcastChannelResponsePayload, type MessageEvent, -} from './WorkerBroadcastChannel'; +} from './WorkerBroadcastChannel.js'; export { type ChangeConfigurationRequest, type GetConfigurationRequest, @@ -108,7 +109,7 @@ export { type ResetRequest, type SetChargingProfileRequest, type UnlockConnectorRequest, -} from './ocpp/1.6/Requests'; +} from './ocpp/1.6/Requests.js'; export { type ChangeConfigurationResponse, type GetConfigurationResponse, @@ -128,19 +129,19 @@ export { type OCPP16UpdateFirmwareResponse, type SetChargingProfileResponse, type UnlockConnectorResponse, -} from './ocpp/1.6/Responses'; -export { ChargePointErrorCode } from './ocpp/ChargePointErrorCode'; +} from './ocpp/1.6/Responses.js'; +export { ChargePointErrorCode } from './ocpp/ChargePointErrorCode.js'; export { type ChargingProfile, ChargingProfileKindType, ChargingRateUnitType, type ChargingSchedulePeriod, RecurrencyKindType, -} from './ocpp/ChargingProfile'; +} from './ocpp/ChargingProfile.js'; export type { ChargingStationConfiguration, EvseStatusConfiguration, -} from './ChargingStationConfiguration'; +} from './ChargingStationConfiguration.js'; export { type ChargingStationData, type ChargingStationWorkerData, @@ -148,12 +149,12 @@ export { type ChargingStationWorkerMessageData, ChargingStationWorkerMessageEvents, type EvseStatusWorkerType, -} from './ChargingStationWorker'; -export type { ChargingStationInfo } from './ChargingStationInfo'; +} from './ChargingStationWorker.js'; +export type { ChargingStationInfo } from './ChargingStationInfo.js'; export type { ChargingStationOcppConfiguration, ConfigurationKey, -} from './ChargingStationOcppConfiguration'; +} from './ChargingStationOcppConfiguration.js'; export { AmpereUnits, type ChargingStationTemplate, @@ -162,7 +163,7 @@ export { PowerUnits, Voltage, type WsOptions, -} from './ChargingStationTemplate'; +} from './ChargingStationTemplate.js'; export { ApplicationProtocolVersion, type ConfigurationData, @@ -174,7 +175,7 @@ export { SupervisionUrlDistribution, type UIServerConfiguration, type WorkerConfiguration, -} from './ConfigurationData'; +} from './ConfigurationData.js'; export { type ConfigurationKeyType, ConnectorPhaseRotation, @@ -182,22 +183,22 @@ export { 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'; +} from './ocpp/Configuration.js'; +export type { ConnectorStatus } from './ConnectorStatus.js'; +export { ConnectorStatusEnum, type ConnectorStatusTransition } from './ocpp/ConnectorStatusEnum.js'; +export { DBName, type MikroOrmDbType, StorageType } from './Storage.js'; +export type { EmptyObject } from './EmptyObject.js'; +export { ErrorType } from './ocpp/ErrorType.js'; +export type { EvseTemplate, EvseStatus } from './Evse.js'; +export { FileType } from './FileType.js'; +export type { HandleErrorParams } from './Error.js'; +export type { JsonObject, JsonType } from './JsonType.js'; export type { MeasurandPerPhaseSampledValueTemplates, SampledValueTemplate, -} from './MeasurandPerPhaseSampledValueTemplates'; -export type { MeasurandValues } from './MeasurandValues'; -export { MessageType } from './ocpp/MessageType'; +} from './MeasurandPerPhaseSampledValueTemplates.js'; +export type { MeasurandValues } from './MeasurandValues.js'; +export { MessageType } from './ocpp/MessageType.js'; export { type MeterValue, MeterValueContext, @@ -206,7 +207,7 @@ export { MeterValuePhase, MeterValueUnit, type SampledValue, -} from './ocpp/MeterValues'; +} from './ocpp/MeterValues.js'; export { type OCPP16MeterValue, OCPP16MeterValueContext, @@ -217,7 +218,7 @@ export { type OCPP16MeterValuesRequest, type OCPP16MeterValuesResponse, type OCPP16SampledValue, -} from './ocpp/1.6/MeterValues'; +} from './ocpp/1.6/MeterValues.js'; export { OCPP16AuthorizationStatus, type OCPP16AuthorizeRequest, @@ -227,21 +228,21 @@ export { OCPP16StopTransactionReason, type OCPP16StopTransactionRequest, type OCPP16StopTransactionResponse, -} from './ocpp/1.6/Transaction'; -export { OCPP16ChargePointErrorCode } from './ocpp/1.6/ChargePointErrorCode'; -export { OCPP16ChargePointStatus } from './ocpp/1.6/ChargePointStatus'; +} from './ocpp/1.6/Transaction.js'; +export { OCPP16ChargePointErrorCode } from './ocpp/1.6/ChargePointErrorCode.js'; +export { OCPP16ChargePointStatus } from './ocpp/1.6/ChargePointStatus.js'; export { type OCPP16ChargingProfile, OCPP16ChargingProfilePurposeType, OCPP16ChargingRateUnitType, type OCPP16ChargingSchedule, type OCPP16ChargingSchedulePeriod, -} from './ocpp/1.6/ChargingProfile'; +} from './ocpp/1.6/ChargingProfile.js'; export { OCPP16StandardParametersKey, OCPP16SupportedFeatureProfiles, -} from './ocpp/1.6/Configuration'; -export { OCPP16DiagnosticsStatus } from './ocpp/1.6/DiagnosticsStatus'; +} from './ocpp/1.6/Configuration.js'; +export { OCPP16DiagnosticsStatus } from './ocpp/1.6/DiagnosticsStatus.js'; export { type OCPP20BootNotificationRequest, type OCPP20ClearCacheRequest, @@ -249,26 +250,26 @@ export { OCPP20IncomingRequestCommand, OCPP20RequestCommand, type OCPP20StatusNotificationRequest, -} from './ocpp/2.0/Requests'; +} from './ocpp/2.0/Requests.js'; 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, TimestampedData } from './Statistics'; +} from './ocpp/2.0/Responses.js'; +export { OCPP20OptionalVariableName } from './ocpp/2.0/Variables.js'; +export { OCPPVersion } from './ocpp/OCPPVersion.js'; +export { PerformanceData } from './orm/entities/PerformanceData.js'; +export { PerformanceRecord } from './orm/entities/PerformanceRecord.js'; +export type { Statistics, TimestampedData } from './Statistics.js'; export { type WSError, WebSocketCloseEventStatusCode, WebSocketCloseEventStatusString, -} from './WebSocket'; +} from './WebSocket.js'; export { type Reservation, type ReservationKey, ReservationTerminationReason, -} from './ocpp/Reservation'; -export { ChargingStationEvents } from './ChargingStationEvents'; +} from './ocpp/Reservation.js'; +export { ChargingStationEvents } from './ChargingStationEvents.js'; diff --git a/src/types/ocpp/1.6/ChargingProfile.ts b/src/types/ocpp/1.6/ChargingProfile.ts index 8a50e895..89cf8e4d 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 '../../JsonType.js'; 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 6d102b88..e8d14ef9 100644 --- a/src/types/ocpp/1.6/MeterValues.ts +++ b/src/types/ocpp/1.6/MeterValues.ts @@ -1,5 +1,5 @@ -import type { EmptyObject } from '../../EmptyObject'; -import type { JsonObject } from '../../JsonType'; +import type { EmptyObject } from '../../EmptyObject.js'; +import type { JsonObject } from '../../JsonType.js'; export enum OCPP16MeterValueUnit { WATT_HOUR = 'Wh', diff --git a/src/types/ocpp/1.6/Requests.ts b/src/types/ocpp/1.6/Requests.ts index b14583f0..9c3ece54 100644 --- a/src/types/ocpp/1.6/Requests.ts +++ b/src/types/ocpp/1.6/Requests.ts @@ -1,14 +1,14 @@ -import type { OCPP16ChargePointErrorCode } from './ChargePointErrorCode'; -import type { OCPP16ChargePointStatus } from './ChargePointStatus'; +import type { OCPP16ChargePointErrorCode } from './ChargePointErrorCode.js'; +import type { OCPP16ChargePointStatus } from './ChargePointStatus.js'; import type { OCPP16ChargingProfile, OCPP16ChargingProfilePurposeType, OCPP16ChargingRateUnitType, -} from './ChargingProfile'; -import type { OCPP16StandardParametersKey, OCPP16VendorParametersKey } from './Configuration'; -import type { OCPP16DiagnosticsStatus } from './DiagnosticsStatus'; -import type { EmptyObject } from '../../EmptyObject'; -import type { JsonObject } from '../../JsonType'; +} from './ChargingProfile.js'; +import type { OCPP16StandardParametersKey, OCPP16VendorParametersKey } from './Configuration.js'; +import type { OCPP16DiagnosticsStatus } from './DiagnosticsStatus.js'; +import type { EmptyObject } from '../../EmptyObject.js'; +import type { JsonObject } from '../../JsonType.js'; 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 a42733e8..d813eac0 100644 --- a/src/types/ocpp/1.6/Responses.ts +++ b/src/types/ocpp/1.6/Responses.ts @@ -1,8 +1,8 @@ -import type { OCPP16ChargingSchedule } from './ChargingProfile'; -import type { EmptyObject } from '../../EmptyObject'; -import type { JsonObject } from '../../JsonType'; -import type { GenericStatus, RegistrationStatusEnumType } from '../Common'; -import type { OCPPConfigurationKey } from '../Configuration'; +import type { OCPP16ChargingSchedule } from './ChargingProfile.js'; +import type { EmptyObject } from '../../EmptyObject.js'; +import type { JsonObject } from '../../JsonType.js'; +import type { GenericStatus, RegistrationStatusEnumType } from '../Common.js'; +import type { OCPPConfigurationKey } from '../Configuration.js'; 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 586367d7..49cabf2e 100644 --- a/src/types/ocpp/1.6/Transaction.ts +++ b/src/types/ocpp/1.6/Transaction.ts @@ -1,5 +1,5 @@ -import type { OCPP16MeterValue } from './MeterValues'; -import type { JsonObject } from '../../JsonType'; +import type { OCPP16MeterValue } from './MeterValues.js'; +import type { JsonObject } from '../../JsonType.js'; export enum OCPP16StopTransactionReason { EMERGENCY_STOP = 'EmergencyStop', diff --git a/src/types/ocpp/2.0/Common.ts b/src/types/ocpp/2.0/Common.ts index e9226961..9898ca3c 100644 --- a/src/types/ocpp/2.0/Common.ts +++ b/src/types/ocpp/2.0/Common.ts @@ -1,5 +1,5 @@ -import type { JsonObject } from '../../JsonType'; -import type { GenericStatus } from '../Common'; +import type { JsonObject } from '../../JsonType.js'; +import type { GenericStatus } from '../Common.js'; export enum DataEnumType { // eslint-disable-next-line id-blacklist diff --git a/src/types/ocpp/2.0/Requests.ts b/src/types/ocpp/2.0/Requests.ts index 1b99c272..b91edc9d 100644 --- a/src/types/ocpp/2.0/Requests.ts +++ b/src/types/ocpp/2.0/Requests.ts @@ -2,10 +2,10 @@ import type { BootReasonEnumType, InstallCertificateUseEnumType, OCPP20ConnectorStatusEnumType, -} from './Common'; -import type { OCPP20SetVariableDataType } from './Variables'; -import type { EmptyObject } from '../../EmptyObject'; -import type { JsonObject } from '../../JsonType'; +} from './Common.js'; +import type { OCPP20SetVariableDataType } from './Variables.js'; +import type { EmptyObject } from '../../EmptyObject.js'; +import type { JsonObject } from '../../JsonType.js'; 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 a4ecdadd..38fdda41 100644 --- a/src/types/ocpp/2.0/Responses.ts +++ b/src/types/ocpp/2.0/Responses.ts @@ -2,11 +2,11 @@ import type { GenericStatusEnumType, InstallCertificateStatusEnumType, StatusInfoType, -} from './Common'; -import type { OCPP20SetVariableResultType } from './Variables'; -import type { EmptyObject } from '../../EmptyObject'; -import type { JsonObject } from '../../JsonType'; -import type { RegistrationStatusEnumType } from '../Common'; +} from './Common.js'; +import type { OCPP20SetVariableResultType } from './Variables.js'; +import type { EmptyObject } from '../../EmptyObject.js'; +import type { JsonObject } from '../../JsonType.js'; +import type { RegistrationStatusEnumType } from '../Common.js'; export type OCPP20BootNotificationResponse = { currentTime: Date; diff --git a/src/types/ocpp/2.0/Variables.ts b/src/types/ocpp/2.0/Variables.ts index c08e00f0..87075cbd 100644 --- a/src/types/ocpp/2.0/Variables.ts +++ b/src/types/ocpp/2.0/Variables.ts @@ -1,5 +1,5 @@ -import type { EVSEType, StatusInfoType } from './Common'; -import type { JsonObject } from '../../JsonType'; +import type { EVSEType, StatusInfoType } from './Common.js'; +import type { JsonObject } from '../../JsonType.js'; enum OCPP20ComponentName { AlignedDataCtrlr = 'AlignedDataCtrlr', diff --git a/src/types/ocpp/ChargePointErrorCode.ts b/src/types/ocpp/ChargePointErrorCode.ts index d08f17a0..5fcbee45 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 './1.6/ChargePointErrorCode.js'; export const ChargePointErrorCode = { ...OCPP16ChargePointErrorCode, diff --git a/src/types/ocpp/ChargingProfile.ts b/src/types/ocpp/ChargingProfile.ts index bd67417e..6033ad95 100644 --- a/src/types/ocpp/ChargingProfile.ts +++ b/src/types/ocpp/ChargingProfile.ts @@ -4,7 +4,7 @@ import { OCPP16ChargingRateUnitType, type OCPP16ChargingSchedulePeriod, OCPP16RecurrencyKindType, -} from './1.6/ChargingProfile'; +} from './1.6/ChargingProfile.js'; export type ChargingProfile = OCPP16ChargingProfile; diff --git a/src/types/ocpp/Common.ts b/src/types/ocpp/Common.ts index a4422b18..a1be9be0 100644 --- a/src/types/ocpp/Common.ts +++ b/src/types/ocpp/Common.ts @@ -1,4 +1,4 @@ -import type { JsonObject } from '../JsonType'; +import type { JsonObject } from '../JsonType.js'; export enum GenericStatus { Accepted = 'Accepted', diff --git a/src/types/ocpp/Configuration.ts b/src/types/ocpp/Configuration.ts index 3081f13d..263ff004 100644 --- a/src/types/ocpp/Configuration.ts +++ b/src/types/ocpp/Configuration.ts @@ -2,13 +2,13 @@ import { OCPP16StandardParametersKey, OCPP16SupportedFeatureProfiles, OCPP16VendorParametersKey, -} from './1.6/Configuration'; +} from './1.6/Configuration.js'; import { OCPP20OptionalVariableName, OCPP20RequiredVariableName, OCPP20VendorVariableName, -} from './2.0/Variables'; -import type { JsonObject } from '../JsonType'; +} from './2.0/Variables.js'; +import type { JsonObject } from '../JsonType.js'; export const StandardParametersKey = { ...OCPP16StandardParametersKey, diff --git a/src/types/ocpp/ConnectorStatusEnum.ts b/src/types/ocpp/ConnectorStatusEnum.ts index d3ac3e02..9ed66fa5 100644 --- a/src/types/ocpp/ConnectorStatusEnum.ts +++ b/src/types/ocpp/ConnectorStatusEnum.ts @@ -1,5 +1,5 @@ -import { OCPP16ChargePointStatus } from './1.6/ChargePointStatus'; -import { OCPP20ConnectorStatusEnumType } from './2.0/Common'; +import { OCPP16ChargePointStatus } from './1.6/ChargePointStatus.js'; +import { OCPP20ConnectorStatusEnumType } from './2.0/Common.js'; export const ConnectorStatusEnum = { ...OCPP16ChargePointStatus, diff --git a/src/types/ocpp/MeterValues.ts b/src/types/ocpp/MeterValues.ts index 78cc9af9..9b6a3537 100644 --- a/src/types/ocpp/MeterValues.ts +++ b/src/types/ocpp/MeterValues.ts @@ -6,7 +6,7 @@ import { OCPP16MeterValuePhase, OCPP16MeterValueUnit, type OCPP16SampledValue, -} from './1.6/MeterValues'; +} from './1.6/MeterValues.js'; export const MeterValueUnit = { ...OCPP16MeterValueUnit, diff --git a/src/types/ocpp/Requests.ts b/src/types/ocpp/Requests.ts index 8d19078e..0d60daf5 100644 --- a/src/types/ocpp/Requests.ts +++ b/src/types/ocpp/Requests.ts @@ -1,5 +1,5 @@ -import { OCPP16DiagnosticsStatus } from './1.6/DiagnosticsStatus'; -import type { OCPP16MeterValuesRequest } from './1.6/MeterValues'; +import { OCPP16DiagnosticsStatus } from './1.6/DiagnosticsStatus.js'; +import type { OCPP16MeterValuesRequest } from './1.6/MeterValues.js'; import { OCPP16AvailabilityType, type OCPP16BootNotificationRequest, @@ -14,18 +14,18 @@ import { OCPP16RequestCommand, type OCPP16ReserveNowRequest, type OCPP16StatusNotificationRequest, -} from './1.6/Requests'; -import { OperationalStatusEnumType } from './2.0/Common'; +} from './1.6/Requests.js'; +import { OperationalStatusEnumType } from './2.0/Common.js'; import { type OCPP20BootNotificationRequest, OCPP20IncomingRequestCommand, OCPP20RequestCommand, type OCPP20StatusNotificationRequest, -} 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'; +} from './2.0/Requests.js'; +import type { MessageType } from './MessageType.js'; +import type { ChargingStation } from '../../charging-station/index.js'; +import type { OCPPError } from '../../exception/index.js'; +import type { JsonType } from '../JsonType.js'; export const RequestCommand = { ...OCPP16RequestCommand, diff --git a/src/types/ocpp/Reservation.ts b/src/types/ocpp/Reservation.ts index 61ef6474..8d783a26 100644 --- a/src/types/ocpp/Reservation.ts +++ b/src/types/ocpp/Reservation.ts @@ -1,4 +1,4 @@ -import type { OCPP16ReserveNowRequest } from './1.6/Requests'; +import type { OCPP16ReserveNowRequest } from './1.6/Requests.js'; export type Reservation = OCPP16ReserveNowRequest; diff --git a/src/types/ocpp/Responses.ts b/src/types/ocpp/Responses.ts index 8107e274..e00302ac 100644 --- a/src/types/ocpp/Responses.ts +++ b/src/types/ocpp/Responses.ts @@ -1,4 +1,4 @@ -import type { OCPP16MeterValuesResponse } from './1.6/MeterValues'; +import type { OCPP16MeterValuesResponse } from './1.6/MeterValues.js'; import { OCPP16AvailabilityStatus, type OCPP16BootNotificationResponse, @@ -14,13 +14,13 @@ import { type OCPP16StatusNotificationResponse, OCPP16TriggerMessageStatus, OCPP16UnlockStatus, -} from './1.6/Responses'; -import type { OCPP20BootNotificationResponse, OCPP20ClearCacheResponse } from './2.0/Responses'; -import { type GenericResponse, GenericStatus } from './Common'; -import type { ErrorType } from './ErrorType'; -import type { MessageType } from './MessageType'; -import type { ChargingStation } from '../../charging-station'; -import type { JsonType } from '../JsonType'; +} from './1.6/Responses.js'; +import type { OCPP20BootNotificationResponse, OCPP20ClearCacheResponse } from './2.0/Responses.js'; +import { type GenericResponse, GenericStatus } from './Common.js'; +import type { ErrorType } from './ErrorType.js'; +import type { MessageType } from './MessageType.js'; +import type { ChargingStation } from '../../charging-station/index.js'; +import type { JsonType } from '../JsonType.js'; 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..2a01b004 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 './1.6/Transaction.js'; export const AuthorizationStatus = { ...OCPP16AuthorizationStatus, diff --git a/src/types/orm/entities/PerformanceData.ts b/src/types/orm/entities/PerformanceData.ts index 444241ff..3b046a91 100644 --- a/src/types/orm/entities/PerformanceData.ts +++ b/src/types/orm/entities/PerformanceData.ts @@ -2,7 +2,7 @@ import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'; // eslint-disable-next-line @typescript-eslint/no-unused-vars -import type { PerformanceRecord } from './PerformanceRecord'; +import type { PerformanceRecord } from './PerformanceRecord.js'; @Entity() export class PerformanceData { diff --git a/src/types/orm/entities/PerformanceRecord.ts b/src/types/orm/entities/PerformanceRecord.ts index 997d0100..58bfacad 100644 --- a/src/types/orm/entities/PerformanceRecord.ts +++ b/src/types/orm/entities/PerformanceRecord.ts @@ -2,7 +2,7 @@ import { Collection, Entity, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'; // eslint-disable-next-line @typescript-eslint/no-unused-vars -import type { PerformanceData } from './PerformanceData'; +import type { PerformanceData } from './PerformanceData.js'; @Entity() export class PerformanceRecord { diff --git a/src/utils/AsyncLock.ts b/src/utils/AsyncLock.ts index fe984ceb..ec14a193 100644 --- a/src/utils/AsyncLock.ts +++ b/src/utils/AsyncLock.ts @@ -2,7 +2,7 @@ import Queue from 'mnemonist/queue.js'; -import { Constants } from './Constants'; +import { Constants } from './Constants.js'; export enum AsyncLockType { configuration = 'configuration', diff --git a/src/utils/ChargingStationConfigurationUtils.ts b/src/utils/ChargingStationConfigurationUtils.ts index 34d859c7..b18922a4 100644 --- a/src/utils/ChargingStationConfigurationUtils.ts +++ b/src/utils/ChargingStationConfigurationUtils.ts @@ -1,11 +1,11 @@ -import { isNullOrUndefined } from './Utils'; -import type { ChargingStation } from '../charging-station'; +import { isNullOrUndefined } from './Utils.js'; +import type { ChargingStation } from '../charging-station/index.js'; import type { ChargingStationAutomaticTransactionGeneratorConfiguration, ConnectorStatus, EvseStatusConfiguration, EvseStatusWorkerType, -} from '../types'; +} from '../types/index.js'; export const buildChargingStationAutomaticTransactionGeneratorConfiguration = ( chargingStation: ChargingStation, diff --git a/src/utils/Configuration.ts b/src/utils/Configuration.ts index 31d994f5..1c2e208f 100644 --- a/src/utils/Configuration.ts +++ b/src/utils/Configuration.ts @@ -13,9 +13,9 @@ import { getDefaultPerformanceStorageUri, handleFileException, logPrefix, -} from './ConfigurationUtils'; -import { Constants } from './Constants'; -import { hasOwnProp, isCFEnvironment, isUndefined, once } from './Utils'; +} from './ConfigurationUtils.js'; +import { Constants } from './Constants.js'; +import { hasOwnProp, isCFEnvironment, isUndefined, once } from './Utils.js'; import { ApplicationProtocol, type ConfigurationData, @@ -28,14 +28,14 @@ import { SupervisionUrlDistribution, type UIServerConfiguration, type WorkerConfiguration, -} from '../types'; +} from '../types/index.js'; import { DEFAULT_ELEMENT_START_DELAY, DEFAULT_POOL_MAX_SIZE, DEFAULT_POOL_MIN_SIZE, DEFAULT_WORKER_START_DELAY, WorkerProcessType, -} from '../worker'; +} from '../worker/index.js'; type ConfigurationSectionType = | LogConfiguration diff --git a/src/utils/ConfigurationUtils.ts b/src/utils/ConfigurationUtils.ts index 73bd9ceb..4e03513c 100644 --- a/src/utils/ConfigurationUtils.ts +++ b/src/utils/ConfigurationUtils.ts @@ -3,10 +3,10 @@ import { fileURLToPath } from 'node:url'; import chalk from 'chalk'; -import { Constants } from './Constants'; -import { isNotEmptyString, logPrefix as utilsLogPrefix } from './Utils'; -import { type ElementsPerWorkerType, FileType, StorageType } from '../types'; -import { WorkerProcessType } from '../worker'; +import { Constants } from './Constants.js'; +import { isNotEmptyString, logPrefix as utilsLogPrefix } from './Utils.js'; +import { type ElementsPerWorkerType, FileType, StorageType } from '../types/index.js'; +import { WorkerProcessType } from '../worker/index.js'; export const logPrefix = (): string => { return utilsLogPrefix(' Simulator configuration |'); diff --git a/src/utils/Constants.ts b/src/utils/Constants.ts index d704c15d..4dc07366 100644 --- a/src/utils/Constants.ts +++ b/src/utils/Constants.ts @@ -4,7 +4,7 @@ import { CurrentType, OCPPVersion, VendorParametersKey, -} from '../types'; +} from '../types/index.js'; export class Constants { static readonly DEFAULT_STATION_INFO: Partial = Object.freeze({ diff --git a/src/utils/ErrorUtils.ts b/src/utils/ErrorUtils.ts index 537aa308..e046f1c8 100644 --- a/src/utils/ErrorUtils.ts +++ b/src/utils/ErrorUtils.ts @@ -2,9 +2,9 @@ import process from 'node:process'; import chalk from 'chalk'; -import { logger } from './Logger'; -import { isNotEmptyString } from './Utils'; -import type { ChargingStation } from '../charging-station'; +import { logger } from './Logger.js'; +import { isNotEmptyString } from './Utils.js'; +import type { ChargingStation } from '../charging-station/index.js'; import type { EmptyObject, FileType, @@ -12,7 +12,7 @@ import type { IncomingRequestCommand, JsonType, RequestCommand, -} from '../types'; +} from '../types/index.js'; const defaultErrorParams = { throwError: true, diff --git a/src/utils/FileUtils.ts b/src/utils/FileUtils.ts index ecb945bf..7235011c 100644 --- a/src/utils/FileUtils.ts +++ b/src/utils/FileUtils.ts @@ -1,9 +1,9 @@ import { type FSWatcher, type WatchListener, readFileSync, watch } from 'node:fs'; -import { handleFileException } from './ErrorUtils'; -import { logger } from './Logger'; -import { isNotEmptyString } from './Utils'; -import type { FileType, JsonType } from '../types'; +import { handleFileException } from './ErrorUtils.js'; +import { logger } from './Logger.js'; +import { isNotEmptyString } from './Utils.js'; +import type { FileType, JsonType } from '../types/index.js'; export const watchJsonFile = ( file: string, diff --git a/src/utils/Logger.ts b/src/utils/Logger.ts index 239ec918..ba5fe9eb 100644 --- a/src/utils/Logger.ts +++ b/src/utils/Logger.ts @@ -3,9 +3,9 @@ import { createLogger, format, type transport } from 'winston'; import TransportType from 'winston/lib/winston/transports/index.js'; import DailyRotateFile from 'winston-daily-rotate-file'; -import { Configuration } from './Configuration'; -import { insertAt } from './Utils'; -import { ConfigurationSection, type LogConfiguration } from '../types'; +import { Configuration } from './Configuration.js'; +import { insertAt } from './Utils.js'; +import { ConfigurationSection, type LogConfiguration } from '../types/index.js'; const logConfiguration = Configuration.getConfigurationSection( ConfigurationSection.log, diff --git a/src/utils/MessageChannelUtils.ts b/src/utils/MessageChannelUtils.ts index f3008b50..85d0c483 100644 --- a/src/utils/MessageChannelUtils.ts +++ b/src/utils/MessageChannelUtils.ts @@ -3,14 +3,14 @@ import { buildChargingStationAutomaticTransactionGeneratorConfiguration, buildConnectorsStatus, buildEvsesStatus, -} from './ChargingStationConfigurationUtils'; -import type { ChargingStation } from '../charging-station'; +} from './ChargingStationConfigurationUtils.js'; +import type { ChargingStation } from '../charging-station/index.js'; import { type ChargingStationData, type ChargingStationWorkerMessage, ChargingStationWorkerMessageEvents, type Statistics, -} from '../types'; +} from '../types/index.js'; export const buildStartedMessage = ( chargingStation: ChargingStation, diff --git a/src/utils/StatisticUtils.ts b/src/utils/StatisticUtils.ts index 2ff71b0a..7d2412ee 100644 --- a/src/utils/StatisticUtils.ts +++ b/src/utils/StatisticUtils.ts @@ -1,4 +1,4 @@ -import { isEmptyArray, isNullOrUndefined } from './Utils'; +import { isEmptyArray, isNullOrUndefined } from './Utils.js'; /** * Computes the average of the given data set. diff --git a/src/utils/Utils.ts b/src/utils/Utils.ts index 366ccf98..872c2b04 100644 --- a/src/utils/Utils.ts +++ b/src/utils/Utils.ts @@ -13,8 +13,8 @@ import { secondsToMilliseconds, } from 'date-fns'; -import { Constants } from './Constants'; -import { type TimestampedData, WebSocketCloseEventStatusString } from '../types'; +import { Constants } from './Constants.js'; +import { type TimestampedData, WebSocketCloseEventStatusString } from '../types/index.js'; export const logPrefix = (prefixString = ''): string => { return `${new Date().toLocaleString()}${prefixString}`; diff --git a/src/utils/index.ts b/src/utils/index.ts index 7c876834..20d64cf5 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,28 +1,28 @@ -export { ACElectricUtils, DCElectricUtils } from './ElectricUtils'; -export { AsyncLock, AsyncLockType } from './AsyncLock'; +export { ACElectricUtils, DCElectricUtils } from './ElectricUtils.js'; +export { AsyncLock, AsyncLockType } from './AsyncLock.js'; export { OutputFormat, buildChargingStationAutomaticTransactionGeneratorConfiguration, buildConnectorsStatus, buildEvsesStatus, -} from './ChargingStationConfigurationUtils'; -export { CircularArray } from './CircularArray'; -export { Configuration } from './Configuration'; -export { Constants } from './Constants'; +} from './ChargingStationConfigurationUtils.js'; +export { CircularArray } from './CircularArray.js'; +export { Configuration } from './Configuration.js'; +export { Constants } from './Constants.js'; export { handleFileException, handleUncaughtException, handleUnhandledRejection, handleSendMessageError, setDefaultErrorParams, -} from './ErrorUtils'; -export { watchJsonFile } from './FileUtils'; +} from './ErrorUtils.js'; +export { watchJsonFile } from './FileUtils.js'; export { buildPerformanceStatisticsMessage, buildUpdatedMessage, buildStartedMessage, buildStoppedMessage, -} from './MessageChannelUtils'; +} from './MessageChannelUtils.js'; export { JSONStringifyWithMapSupport, cloneObject, @@ -56,6 +56,6 @@ export { secureRandom, sleep, validateUUID, -} from './Utils'; -export { average, median, nthPercentile, stdDeviation } from './StatisticUtils'; -export { logger } from './Logger'; +} from './Utils.js'; +export { average, median, nthPercentile, stdDeviation } from './StatisticUtils.js'; +export { logger } from './Logger.js'; diff --git a/src/worker/WorkerAbstract.ts b/src/worker/WorkerAbstract.ts index cd4dedf9..e78216de 100644 --- a/src/worker/WorkerAbstract.ts +++ b/src/worker/WorkerAbstract.ts @@ -3,8 +3,8 @@ import { existsSync } from 'node:fs'; import type { PoolInfo } from 'poolifier'; -import type { SetInfo, WorkerData, WorkerOptions } from './WorkerTypes'; -import { defaultErrorHandler, defaultExitHandler } from './WorkerUtils'; +import type { SetInfo, WorkerData, WorkerOptions } from './WorkerTypes.js'; +import { defaultErrorHandler, defaultExitHandler } from './WorkerUtils.js'; export abstract class WorkerAbstract { protected readonly workerScript: string; diff --git a/src/worker/WorkerConstants.ts b/src/worker/WorkerConstants.ts index c7f8065a..654e6f5e 100644 --- a/src/worker/WorkerConstants.ts +++ b/src/worker/WorkerConstants.ts @@ -1,6 +1,6 @@ import { availableParallelism } from 'poolifier'; -import type { WorkerOptions } from './WorkerTypes'; +import type { WorkerOptions } from './WorkerTypes.js'; export const EMPTY_FUNCTION = Object.freeze(() => { /* This is intentional */ diff --git a/src/worker/WorkerDynamicPool.ts b/src/worker/WorkerDynamicPool.ts index 9527d67b..e27e803b 100644 --- a/src/worker/WorkerDynamicPool.ts +++ b/src/worker/WorkerDynamicPool.ts @@ -2,9 +2,9 @@ import type { EventEmitterAsyncResource } from 'node:events'; import { DynamicThreadPool, type PoolInfo } from 'poolifier'; -import { WorkerAbstract } from './WorkerAbstract'; -import type { WorkerData, WorkerOptions } from './WorkerTypes'; -import { randomizeDelay, sleep } from './WorkerUtils'; +import { WorkerAbstract } from './WorkerAbstract.js'; +import type { WorkerData, WorkerOptions } from './WorkerTypes.js'; +import { randomizeDelay, sleep } from './WorkerUtils.js'; export class WorkerDynamicPool extends WorkerAbstract { private readonly pool: DynamicThreadPool; diff --git a/src/worker/WorkerFactory.ts b/src/worker/WorkerFactory.ts index 608e8798..7ae5ddb9 100644 --- a/src/worker/WorkerFactory.ts +++ b/src/worker/WorkerFactory.ts @@ -1,11 +1,11 @@ import { isMainThread } from 'node:worker_threads'; -import type { WorkerAbstract } from './WorkerAbstract'; -import { DEFAULT_WORKER_OPTIONS } from './WorkerConstants'; -import { WorkerDynamicPool } from './WorkerDynamicPool'; -import { WorkerFixedPool } from './WorkerFixedPool'; -import { WorkerSet } from './WorkerSet'; -import { type WorkerData, type WorkerOptions, WorkerProcessType } from './WorkerTypes'; +import type { WorkerAbstract } from './WorkerAbstract.js'; +import { DEFAULT_WORKER_OPTIONS } from './WorkerConstants.js'; +import { WorkerDynamicPool } from './WorkerDynamicPool.js'; +import { WorkerFixedPool } from './WorkerFixedPool.js'; +import { WorkerSet } from './WorkerSet.js'; +import { type WorkerData, type WorkerOptions, WorkerProcessType } from './WorkerTypes.js'; export class WorkerFactory { private constructor() { diff --git a/src/worker/WorkerFixedPool.ts b/src/worker/WorkerFixedPool.ts index f15a1176..9e71c277 100644 --- a/src/worker/WorkerFixedPool.ts +++ b/src/worker/WorkerFixedPool.ts @@ -2,9 +2,9 @@ import type { EventEmitterAsyncResource } from 'node:events'; import { FixedThreadPool, type PoolInfo } from 'poolifier'; -import { WorkerAbstract } from './WorkerAbstract'; -import type { WorkerData, WorkerOptions } from './WorkerTypes'; -import { randomizeDelay, sleep } from './WorkerUtils'; +import { WorkerAbstract } from './WorkerAbstract.js'; +import type { WorkerData, WorkerOptions } from './WorkerTypes.js'; +import { randomizeDelay, sleep } from './WorkerUtils.js'; export class WorkerFixedPool extends WorkerAbstract { private readonly pool: FixedThreadPool; diff --git a/src/worker/WorkerSet.ts b/src/worker/WorkerSet.ts index 047d03ad..b33d917c 100644 --- a/src/worker/WorkerSet.ts +++ b/src/worker/WorkerSet.ts @@ -3,8 +3,8 @@ import { EventEmitterAsyncResource } from 'node:events'; import { SHARE_ENV, Worker } from 'node:worker_threads'; -import { WorkerAbstract } from './WorkerAbstract'; -import { EMPTY_FUNCTION, workerSetVersion } from './WorkerConstants'; +import { WorkerAbstract } from './WorkerAbstract.js'; +import { EMPTY_FUNCTION, workerSetVersion } from './WorkerConstants.js'; import { type SetInfo, type WorkerData, @@ -13,8 +13,8 @@ import { type WorkerOptions, type WorkerSetElement, WorkerSetEvents, -} from './WorkerTypes'; -import { randomizeDelay, sleep } from './WorkerUtils'; +} from './WorkerTypes.js'; +import { randomizeDelay, sleep } from './WorkerUtils.js'; export class WorkerSet extends WorkerAbstract { public readonly emitter: EventEmitterAsyncResource | undefined; diff --git a/src/worker/index.ts b/src/worker/index.ts index a7c3d1ea..32781a6e 100644 --- a/src/worker/index.ts +++ b/src/worker/index.ts @@ -1,15 +1,15 @@ -export type { WorkerAbstract } from './WorkerAbstract'; +export type { WorkerAbstract } from './WorkerAbstract.js'; export { DEFAULT_ELEMENT_START_DELAY, DEFAULT_POOL_MAX_SIZE, DEFAULT_POOL_MIN_SIZE, DEFAULT_WORKER_START_DELAY, -} from './WorkerConstants'; -export { WorkerFactory } from './WorkerFactory'; +} from './WorkerConstants.js'; +export { WorkerFactory } from './WorkerFactory.js'; export { type WorkerData, WorkerEvents, type WorkerMessage, WorkerMessageEvents, WorkerProcessType, -} from './WorkerTypes'; +} from './WorkerTypes.js'; diff --git a/tests/utils/CircularArray.test.ts b/tests/utils/CircularArray.test.ts index 01cff444..358f7408 100644 --- a/tests/utils/CircularArray.test.ts +++ b/tests/utils/CircularArray.test.ts @@ -2,7 +2,7 @@ import { describe, it } from 'node:test'; import { expect } from 'expect'; -import { CircularArray, DEFAULT_CIRCULAR_ARRAY_SIZE } from '../../src/utils/CircularArray'; +import { CircularArray, DEFAULT_CIRCULAR_ARRAY_SIZE } from '../../src/utils/CircularArray.js'; await describe('CircularArray test suite', async () => { await it('Verify that circular array can be instantiated', () => { diff --git a/tests/utils/ElectricUtils.test.ts b/tests/utils/ElectricUtils.test.ts index 449967c2..d0d3b72b 100644 --- a/tests/utils/ElectricUtils.test.ts +++ b/tests/utils/ElectricUtils.test.ts @@ -2,7 +2,7 @@ import { describe, it } from 'node:test'; import { expect } from 'expect'; -import { ACElectricUtils, DCElectricUtils } from '../../src/utils/ElectricUtils'; +import { ACElectricUtils, DCElectricUtils } from '../../src/utils/ElectricUtils.js'; await describe('ElectricUtils test suite', async () => { await it('Verify DCElectricUtils.power()', () => { diff --git a/tests/utils/StatisticUtils.test.ts b/tests/utils/StatisticUtils.test.ts index 38963dbe..a9e61b2e 100644 --- a/tests/utils/StatisticUtils.test.ts +++ b/tests/utils/StatisticUtils.test.ts @@ -2,7 +2,7 @@ import { describe, it } from 'node:test'; import { expect } from 'expect'; -import { average, median, nthPercentile, stdDeviation } from '../../src/utils/StatisticUtils'; +import { average, median, nthPercentile, stdDeviation } from '../../src/utils/StatisticUtils.js'; await describe('StatisticUtils test suite', async () => { await it('Verify average()', () => { diff --git a/tests/utils/Utils.test.ts b/tests/utils/Utils.test.ts index 615f76fa..87777df3 100644 --- a/tests/utils/Utils.test.ts +++ b/tests/utils/Utils.test.ts @@ -3,7 +3,7 @@ import { describe, it } from 'node:test'; import { hoursToMilliseconds, hoursToSeconds } from 'date-fns'; import { expect } from 'expect'; -import { Constants } from '../../src/utils/Constants'; +import { Constants } from '../../src/utils/Constants.js'; import { cloneObject, convertToBoolean, @@ -35,7 +35,7 @@ import { secureRandom, sleep, validateUUID, -} from '../../src/utils/Utils'; +} from '../../src/utils/Utils.js'; await describe('Utils test suite', async () => { await it('Verify generateUUID()/validateUUID()', () => { diff --git a/tsconfig.json b/tsconfig.json index e3252966..a7219929 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,14 +2,14 @@ "$schema": "https://json.schemastore.org/tsconfig", "compilerOptions": { "target": "es2022", - "module": "esnext", + "module": "NodeNext", "lib": ["es2022"], "removeComments": true, "importHelpers": true, "strict": true, - "moduleResolution": "node", + "moduleResolution": "NodeNext", "resolveJsonModule": true, "allowSyntheticDefaultImports": true, "verbatimModuleSyntax": true, -- 2.34.1