node: true
},
parserOptions: {
- ecmaVersion: 2022,
- sourceType: 'module'
+ sourceType: 'module',
+ ecmaVersion: 2022
},
- plugins: ['import'],
+ plugins: ['simple-import-sort', 'import'],
extends: ['eslint:recommended', 'plugin:import/recommended'],
settings: {
'import/resolver': {
}
},
rules: {
- 'sort-imports': [
- 'error',
- {
- ignoreCase: false,
- ignoreDeclarationSort: true,
- ignoreMemberSort: false,
- memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
- allowSeparatedGroups: true
- }
- ],
- 'import/order': [
- 'error',
- {
- groups: [
- 'builtin', // Built-in imports (come from NodeJS native) go first
- 'external', // <- External imports
- 'internal', // <- Absolute imports
- ['sibling', 'parent'], // <- Relative imports, the sibling and parent types they can be mingled together
- 'index', // <- Index imports
- 'unknown' // <- Unknown
- ],
- 'newlines-between': 'always',
- alphabetize: {
- /* Sort in ascending order. Options: ["ignore", "asc", "desc"] */
- order: 'asc',
- /* Ignore case. Options: [true, false] */
- caseInsensitive: true
- }
- }
- ]
+ 'simple-import-sort/imports': 'error',
+ 'simple-import-sort/exports': 'error'
+ // 'sort-imports': [
+ // 'error',
+ // {
+ // ignoreCase: false,
+ // ignoreDeclarationSort: true,
+ // ignoreMemberSort: false,
+ // memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
+ // allowSeparatedGroups: true
+ // }
+ // ],
+ // 'import/order': [
+ // 'error',
+ // {
+ // groups: [
+ // 'builtin', // Built-in imports (come from NodeJS native) go first
+ // 'external', // <- External imports
+ // 'internal', // <- Absolute imports
+ // ['sibling', 'parent'], // <- Relative imports, the sibling and parent types they can be mingled together
+ // 'index', // <- Index imports
+ // 'unknown' // <- Unknown
+ // ],
+ // 'newlines-between': 'always',
+ // alphabetize: {
+ // /* Sort in ascending order. Options: ["ignore", "asc", "desc"] */
+ // order: 'asc',
+ // /* Ignore case. Options: [true, false] */
+ // caseInsensitive: true
+ // }
+ // }
+ // ]
},
overrides: [
{
"eslint-define-config": "^2.1.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.1",
+ "eslint-plugin-simple-import-sort": "^12.0.0",
"eslint-plugin-jsdoc": "^48.2.1",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-tsdoc": "^0.2.17",
eslint-plugin-n:
specifier: ^16.6.2
version: 16.6.2(eslint@8.57.0)
+ eslint-plugin-simple-import-sort:
+ specifier: ^12.0.0
+ version: 12.0.0(eslint@8.57.0)
eslint-plugin-tsdoc:
specifier: ^0.2.17
version: 0.2.17
import { hoursToMilliseconds, secondsToMilliseconds } from 'date-fns'
-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 {
type StopTransactionResponse
} from '../types/index.js'
import {
- Constants,
clone,
+ Constants,
convertToDate,
formatDurationMilliSeconds,
getRandomInteger,
isValidDate,
- logPrefix,
logger,
+ logPrefix,
secureRandom,
sleep
} from '../utils/index.js'
+import type { ChargingStation } from './ChargingStation.js'
+import { checkChargingStation } from './Helpers.js'
+import { IdTagsCache } from './IdTagsCache.js'
+import { isIdTagAuthorized } from './ocpp/index.js'
export class AutomaticTransactionGenerator {
private static readonly instances: Map<string, AutomaticTransactionGenerator> = new Map<
import process, { exit } from 'node:process'
import { fileURLToPath } from 'node:url'
import { isMainThread } from 'node:worker_threads'
-import type { Worker } from 'worker_threads'
import chalk from 'chalk'
-import { type MessageHandler, availableParallelism } from 'poolifier'
+import { availableParallelism, type MessageHandler } from 'poolifier'
+import type { Worker } from 'worker_threads'
-import { buildTemplateName, 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/index.js'
import { type Storage, StorageFactory } from '../performance/index.js'
type WorkerConfiguration
} from '../types/index.js'
import {
+ buildTemplateStatisticsPayload,
Configuration,
Constants,
- buildTemplateStatisticsPayload,
formatDurationMilliSeconds,
generateUUID,
handleUncaughtException,
handleUnhandledRejection,
isAsyncFunction,
isNotEmptyArray,
- logPrefix,
- logger
+ logger,
+ logPrefix
} from '../utils/index.js'
import { type WorkerAbstract, WorkerFactory } from '../worker/index.js'
+import { buildTemplateName, waitChargingStationEvents } from './Helpers.js'
+import type { AbstractUIServer } from './ui-server/AbstractUIServer.js'
+import { UIServerFactory } from './ui-server/UIServerFactory.js'
const moduleName = 'Bootstrap'
import { createHash } from 'node:crypto'
import { EventEmitter } from 'node:events'
-import { type FSWatcher, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
+import { existsSync, type FSWatcher, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
import { dirname, join } from 'node:path'
import { URL } from 'node:url'
import { parentPort } from 'node:worker_threads'
import { mergeDeepRight } from 'rambda'
import { type RawData, WebSocket } from 'ws'
-import { AutomaticTransactionGenerator } from './AutomaticTransactionGenerator.js'
-import { ChargingStationWorkerBroadcastChannel } from './broadcast-channel/ChargingStationWorkerBroadcastChannel.js'
-import {
- addConfigurationKey,
- deleteConfigurationKey,
- getConfigurationKey,
- setConfigurationKeyValue
-} from './ConfigurationKeyUtils.js'
-import {
- buildConnectorsMap,
- buildTemplateName,
- checkChargingStation,
- checkConfiguration,
- checkConnectorsConfiguration,
- checkStationInfoConnectorStatus,
- checkTemplate,
- createBootNotificationRequest,
- createSerialNumber,
- getAmperageLimitationUnitDivider,
- getBootConnectorStatus,
- getChargingStationConnectorChargingProfilesPowerLimit,
- getChargingStationId,
- getDefaultVoltageOut,
- getHashId,
- getIdTagsFile,
- getMaxNumberOfEvses,
- getNumberOfReservableConnectors,
- getPhaseRotationValue,
- hasFeatureProfile,
- hasReservationExpired,
- initializeConnectorsMapStatus,
- propagateSerialNumber,
- setChargingStationOptions,
- stationTemplateToStationInfo,
- warnTemplateKeysDeprecation
-} from './Helpers.js'
-import { IdTagsCache } from './IdTagsCache.js'
-import {
- OCPP16IncomingRequestService,
- OCPP16RequestService,
- OCPP16ResponseService,
- OCPP20IncomingRequestService,
- OCPP20RequestService,
- OCPP20ResponseService,
- type OCPPIncomingRequestService,
- type OCPPRequestService,
- buildMeterValue,
- buildTransactionEndMeterValue,
- getMessageTypeString,
- sendAndSetConnectorStatus
-} from './ocpp/index.js'
-import { SharedLRUCache } from './SharedLRUCache.js'
import { BaseError, OCPPError } from '../exception/index.js'
import { PerformanceStatistics } from '../performance/index.js'
import {
SupervisionUrlDistribution,
SupportedFeatureProfiles,
type Voltage,
- type WSError,
WebSocketCloseEventStatusCode,
+ type WSError,
type WsOptions
} from '../types/index.js'
import {
ACElectricUtils,
AsyncLock,
AsyncLockType,
- Configuration,
- Constants,
- DCElectricUtils,
buildAddedMessage,
buildChargingStationAutomaticTransactionGeneratorConfiguration,
buildConnectorsStatus,
buildStoppedMessage,
buildUpdatedMessage,
clone,
+ Configuration,
+ Constants,
convertToBoolean,
convertToDate,
convertToInt,
+ DCElectricUtils,
exponentialDelay,
formatDurationMilliSeconds,
formatDurationSeconds,
handleFileException,
isNotEmptyArray,
isNotEmptyString,
- logPrefix,
logger,
+ logPrefix,
min,
once,
roundTo,
sleep,
watchJsonFile
} from '../utils/index.js'
+import { AutomaticTransactionGenerator } from './AutomaticTransactionGenerator.js'
+import { ChargingStationWorkerBroadcastChannel } from './broadcast-channel/ChargingStationWorkerBroadcastChannel.js'
+import {
+ addConfigurationKey,
+ deleteConfigurationKey,
+ getConfigurationKey,
+ setConfigurationKeyValue
+} from './ConfigurationKeyUtils.js'
+import {
+ buildConnectorsMap,
+ buildTemplateName,
+ checkChargingStation,
+ checkConfiguration,
+ checkConnectorsConfiguration,
+ checkStationInfoConnectorStatus,
+ checkTemplate,
+ createBootNotificationRequest,
+ createSerialNumber,
+ getAmperageLimitationUnitDivider,
+ getBootConnectorStatus,
+ getChargingStationConnectorChargingProfilesPowerLimit,
+ getChargingStationId,
+ getDefaultVoltageOut,
+ getHashId,
+ getIdTagsFile,
+ getMaxNumberOfEvses,
+ getNumberOfReservableConnectors,
+ getPhaseRotationValue,
+ hasFeatureProfile,
+ hasReservationExpired,
+ initializeConnectorsMapStatus,
+ propagateSerialNumber,
+ setChargingStationOptions,
+ stationTemplateToStationInfo,
+ warnTemplateKeysDeprecation
+} from './Helpers.js'
+import { IdTagsCache } from './IdTagsCache.js'
+import {
+ buildMeterValue,
+ buildTransactionEndMeterValue,
+ getMessageTypeString,
+ OCPP16IncomingRequestService,
+ OCPP16RequestService,
+ OCPP16ResponseService,
+ OCPP20IncomingRequestService,
+ OCPP20RequestService,
+ OCPP20ResponseService,
+ type OCPPIncomingRequestService,
+ type OCPPRequestService,
+ sendAndSetConnectorStatus
+} from './ocpp/index.js'
+import { SharedLRUCache } from './SharedLRUCache.js'
export class ChargingStation extends EventEmitter {
public readonly index: number
import { ThreadWorker } from 'poolifier'
-import { ChargingStation } from './ChargingStation.js'
import { BaseError } from '../exception/index.js'
import type {
ChargingStationData,
ChargingStationWorkerEventError,
ChargingStationWorkerMessage
} from '../types/index.js'
-import { Configuration, buildChargingStationDataPayload } from '../utils/index.js'
+import { buildChargingStationDataPayload, Configuration } from '../utils/index.js'
import { type WorkerMessage, WorkerMessageEvents } from '../worker/index.js'
+import { ChargingStation } from './ChargingStation.js'
export let chargingStationWorker: object
if (Configuration.workerPoolInUse()) {
-import type { ChargingStation } from './ChargingStation.js'
import type { ConfigurationKey, ConfigurationKeyType } from '../types/index.js'
import { logger } from '../utils/index.js'
+import type { ChargingStation } from './ChargingStation.js'
interface ConfigurationKeyOptions {
readonly?: boolean
import chalk from 'chalk'
import {
- type Interval,
addDays,
addSeconds,
addWeeks,
differenceInDays,
differenceInSeconds,
differenceInWeeks,
+ type Interval,
isAfter,
isBefore,
isDate,
} from 'date-fns'
import { maxTime } from 'date-fns/constants'
-import type { ChargingStation } from './ChargingStation.js'
-import { getConfigurationKey } from './ConfigurationKeyUtils.js'
import { BaseError } from '../exception/index.js'
import {
AmpereUnits,
} from '../types/index.js'
import {
ACElectricUtils,
- Constants,
- DCElectricUtils,
clone,
+ Constants,
convertToDate,
convertToInt,
+ DCElectricUtils,
isArraySorted,
isEmptyObject,
isEmptyString,
logger,
secureRandom
} from '../utils/index.js'
+import type { ChargingStation } from './ChargingStation.js'
+import { getConfigurationKey } from './ConfigurationKeyUtils.js'
const moduleName = 'Helpers'
import { type FSWatcher, readFileSync } from 'node:fs'
-import type { ChargingStation } from './ChargingStation.js'
-import { getIdTagsFile } from './Helpers.js'
import { FileType, IdTagDistribution } from '../types/index.js'
import {
handleFileException,
isNotEmptyString,
- logPrefix,
logger,
+ logPrefix,
secureRandom,
watchJsonFile
} from '../utils/index.js'
+import type { ChargingStation } from './ChargingStation.js'
+import { getIdTagsFile } from './Helpers.js'
interface IdTagsCacheValueType {
idTags: string[]
import { LRUMapWithDelete as LRUCache } from 'mnemonist'
-import { Bootstrap } from './Bootstrap.js'
import type { ChargingStationConfiguration, ChargingStationTemplate } from '../types/index.js'
import { isEmptyObject, isNotEmptyArray, isNotEmptyString } from '../utils/index.js'
+import { Bootstrap } from './Bootstrap.js'
enum CacheType {
chargingStationTemplate = 'chargingStationTemplate',
import { secondsToMilliseconds } from 'date-fns'
-import { WorkerBroadcastChannel } from './WorkerBroadcastChannel.js'
import { BaseError, type OCPPError } from '../../exception/index.js'
import {
AuthorizationStatus,
import type { ChargingStation } from '../ChargingStation.js'
import { getConfigurationKey } from '../ConfigurationKeyUtils.js'
import { buildMeterValue } from '../ocpp/index.js'
+import { WorkerBroadcastChannel } from './WorkerBroadcastChannel.js'
const moduleName = 'ChargingStationWorkerBroadcastChannel'
-import { WorkerBroadcastChannel } from './WorkerBroadcastChannel.js'
import {
type BroadcastChannelResponse,
type BroadcastChannelResponsePayload,
} from '../../types/index.js'
import { logger } from '../../utils/index.js'
import type { AbstractUIService } from '../ui-server/ui-services/AbstractUIService.js'
+import { WorkerBroadcastChannel } from './WorkerBroadcastChannel.js'
const moduleName = 'UIServiceWorkerBroadcastChannel'
JsonType,
MessageEvent
} from '../../types/index.js'
-import { logPrefix, logger, validateUUID } from '../../utils/index.js'
+import { logger, logPrefix, validateUUID } from '../../utils/index.js'
const moduleName = 'WorkerBroadcastChannel'
import { createWriteStream, readdirSync } from 'node:fs'
import { dirname, extname, join, resolve } from 'node:path'
-import { URL, fileURLToPath } from 'node:url'
+import { fileURLToPath, URL } from 'node:url'
import type { ValidateFunction } from 'ajv'
import { Client, type FTPResponse } from 'basic-ftp'
import {
- type Interval,
addSeconds,
differenceInSeconds,
+ type Interval,
isDate,
secondsToMilliseconds
} from 'date-fns'
import { maxTime } from 'date-fns/constants'
import { create } from 'tar'
-import { OCPP16Constants } from './OCPP16Constants.js'
-import { OCPP16ServiceUtils } from './OCPP16ServiceUtils.js'
import {
- type ChargingStation,
canProceedChargingProfile,
+ type ChargingStation,
checkChargingStation,
getConfigurationKey,
getConnectorChargingProfiles,
sleep
} from '../../../utils/index.js'
import { OCPPIncomingRequestService } from '../OCPPIncomingRequestService.js'
+import { OCPP16Constants } from './OCPP16Constants.js'
+import { OCPP16ServiceUtils } from './OCPP16ServiceUtils.js'
const moduleName = 'OCPP16IncomingRequestService'
import type { ValidateFunction } from 'ajv'
-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 {
import { Constants, generateUUID } from '../../../utils/index.js'
import { OCPPRequestService } from '../OCPPRequestService.js'
import type { OCPPResponseService } from '../OCPPResponseService.js'
+import { OCPP16Constants } from './OCPP16Constants.js'
+import { OCPP16ServiceUtils } from './OCPP16ServiceUtils.js'
const moduleName = 'OCPP16RequestService'
import type { ValidateFunction } from 'ajv'
import { secondsToMilliseconds } from 'date-fns'
-import { OCPP16ServiceUtils } from './OCPP16ServiceUtils.js'
import {
- type ChargingStation,
addConfigurationKey,
+ type ChargingStation,
getConfigurationKey,
hasReservationExpired,
resetConnectorStatus
} from '../../../types/index.js'
import { Constants, convertToInt, isAsyncFunction, logger } from '../../../utils/index.js'
import { OCPPResponseService } from '../OCPPResponseService.js'
+import { OCPP16ServiceUtils } from './OCPP16ServiceUtils.js'
const moduleName = 'OCPP16ResponseService'
import type { JSONSchemaType } from 'ajv'
import {
- type Interval,
addSeconds,
areIntervalsOverlapping,
differenceInSeconds,
+ type Interval,
isAfter,
isBefore,
isWithinInterval
} from 'date-fns'
-import { OCPP16Constants } from './OCPP16Constants.js'
import {
type ChargingStation,
hasFeatureProfile,
} from '../../../types/index.js'
import { convertToDate, isNotEmptyArray, logger, roundTo } from '../../../utils/index.js'
import { OCPPServiceUtils } from '../OCPPServiceUtils.js'
+import { OCPP16Constants } from './OCPP16Constants.js'
export class OCPP16ServiceUtils extends OCPPServiceUtils {
public static checkFeatureProfile (
import type { ValidateFunction } from 'ajv'
-import { OCPP20ServiceUtils } from './OCPP20ServiceUtils.js'
import type { ChargingStation } from '../../../charging-station/index.js'
import { OCPPError } from '../../../exception/index.js'
import {
} from '../../../types/index.js'
import { isAsyncFunction, logger } from '../../../utils/index.js'
import { OCPPIncomingRequestService } from '../OCPPIncomingRequestService.js'
+import { OCPP20ServiceUtils } from './OCPP20ServiceUtils.js'
const moduleName = 'OCPP20IncomingRequestService'
import type { ValidateFunction } from 'ajv'
-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 {
import { generateUUID } from '../../../utils/index.js'
import { OCPPRequestService } from '../OCPPRequestService.js'
import type { OCPPResponseService } from '../OCPPResponseService.js'
+import { OCPP20Constants } from './OCPP20Constants.js'
+import { OCPP20ServiceUtils } from './OCPP20ServiceUtils.js'
const moduleName = 'OCPP20RequestService'
import type { ValidateFunction } from 'ajv'
-import { OCPP20ServiceUtils } from './OCPP20ServiceUtils.js'
-import { type ChargingStation, addConfigurationKey } from '../../../charging-station/index.js'
+import { addConfigurationKey, type ChargingStation } from '../../../charging-station/index.js'
import { OCPPError } from '../../../exception/index.js'
import {
ErrorType,
} from '../../../types/index.js'
import { isAsyncFunction, logger } from '../../../utils/index.js'
import { OCPPResponseService } from '../OCPPResponseService.js'
+import { OCPP20ServiceUtils } from './OCPP20ServiceUtils.js'
const moduleName = 'OCPP20ResponseService'
import _Ajv, { type ValidateFunction } from 'ajv'
import _ajvFormats from 'ajv-formats'
-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 {
OCPPVersion
} from '../../types/index.js'
import { logger, setDefaultErrorParams } from '../../utils/index.js'
+import { OCPPConstants } from './OCPPConstants.js'
+import { OCPPServiceUtils } from './OCPPServiceUtils.js'
type Ajv = _Ajv.default
// eslint-disable-next-line @typescript-eslint/no-redeclare
const Ajv = _Ajv.default
import _Ajv, { type ValidateFunction } from 'ajv'
import _ajvFormats from 'ajv-formats'
-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'
handleSendMessageError,
logger
} from '../../utils/index.js'
+import { OCPPConstants } from './OCPPConstants.js'
+import type { OCPPResponseService } from './OCPPResponseService.js'
+import { OCPPServiceUtils } from './OCPPServiceUtils.js'
type Ajv = _Ajv.default
// eslint-disable-next-line @typescript-eslint/no-redeclare
const Ajv = _Ajv.default
import _Ajv, { type ValidateFunction } from 'ajv'
import _ajvFormats from 'ajv-formats'
-import { OCPPServiceUtils } from './OCPPServiceUtils.js'
import type { ChargingStation } from '../../charging-station/index.js'
import { OCPPError } from '../../exception/index.js'
import type {
RequestCommand
} from '../../types/index.js'
import { Constants, logger } from '../../utils/index.js'
+import { OCPPServiceUtils } from './OCPPServiceUtils.js'
type Ajv = _Ajv.default
// eslint-disable-next-line @typescript-eslint/no-redeclare
const Ajv = _Ajv.default
import type { DefinedError, ErrorObject, JSONSchemaType } from 'ajv'
import { isDate } from 'date-fns'
-import { OCPP16Constants } from './1.6/OCPP16Constants.js'
-import { OCPP20Constants } from './2.0/OCPP20Constants.js'
-import { OCPPConstants } from './OCPPConstants.js'
import {
type ChargingStation,
getConfigurationKey,
import {
ACElectricUtils,
Constants,
- DCElectricUtils,
convertToFloat,
convertToInt,
+ DCElectricUtils,
getRandomFloatFluctuatedRounded,
getRandomFloatRounded,
getRandomInteger,
handleFileException,
isNotEmptyArray,
isNotEmptyString,
- logPrefix,
logger,
+ logPrefix,
max,
min,
roundTo
} from '../../utils/index.js'
+import { OCPP16Constants } from './1.6/OCPP16Constants.js'
+import { OCPP20Constants } from './2.0/OCPP20Constants.js'
+import { OCPPConstants } from './OCPPConstants.js'
export const getMessageTypeString = (messageType: MessageType | undefined): string => {
switch (messageType) {
import { type IncomingMessage, Server, type ServerResponse } from 'node:http'
-import { type Http2Server, createServer } from 'node:http2'
+import { createServer, type Http2Server } from 'node:http2'
import type { WebSocket } from 'ws'
-import type { AbstractUIService } from './ui-services/AbstractUIService.js'
-import { UIServiceFactory } from './ui-services/UIServiceFactory.js'
-import { getUsernameAndPasswordFromAuthorizationToken } from './UIServerUtils.js'
import { BaseError } from '../../exception/index.js'
import {
ApplicationProtocolVersion,
type UIServerConfiguration
} from '../../types/index.js'
import { logger } from '../../utils/index.js'
+import type { AbstractUIService } from './ui-services/AbstractUIService.js'
+import { UIServiceFactory } from './ui-services/UIServiceFactory.js'
+import { getUsernameAndPasswordFromAuthorizationToken } from './UIServerUtils.js'
const moduleName = 'AbstractUIServer'
import { StatusCodes } from 'http-status-codes'
-import { AbstractUIServer } from './AbstractUIServer.js'
-import { isProtocolAndVersionSupported } from './UIServerUtils.js'
import { BaseError } from '../../exception/index.js'
import {
ApplicationProtocolVersion,
} from '../../types/index.js'
import {
Constants,
- JSONStringifyWithMapSupport,
generateUUID,
isNotEmptyString,
- logPrefix,
- logger
+ JSONStringifyWithMapSupport,
+ logger,
+ logPrefix
} from '../../utils/index.js'
+import { AbstractUIServer } from './AbstractUIServer.js'
+import { isProtocolAndVersionSupported } from './UIServerUtils.js'
const moduleName = 'UIHttpServer'
import chalk from 'chalk'
-import type { AbstractUIServer } from './AbstractUIServer.js'
-import { UIHttpServer } from './UIHttpServer.js'
-import { isLoopback } from './UIServerUtils.js'
-import { UIWebSocketServer } from './UIWebSocketServer.js'
import { BaseError } from '../../exception/index.js'
import {
ApplicationProtocol,
AuthenticationType,
type UIServerConfiguration
} from '../../types/index.js'
+import type { AbstractUIServer } from './AbstractUIServer.js'
+import { UIHttpServer } from './UIHttpServer.js'
+import { isLoopback } from './UIServerUtils.js'
+import { UIWebSocketServer } from './UIWebSocketServer.js'
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
export class UIServerFactory {
import { BaseError } from '../../exception/index.js'
import { Protocol, ProtocolVersion } from '../../types/index.js'
-import { logPrefix, logger } from '../../utils/index.js'
+import { logger, logPrefix } from '../../utils/index.js'
export const getUsernameAndPasswordFromAuthorizationToken = (
authorizationToken: string,
import { StatusCodes } from 'http-status-codes'
import { type RawData, WebSocket, WebSocketServer } from 'ws'
-import { AbstractUIServer } from './AbstractUIServer.js'
-import {
- getProtocolAndVersion,
- handleProtocols,
- isProtocolAndVersionSupported
-} from './UIServerUtils.js'
import {
type ProtocolRequest,
type ProtocolResponse,
} from '../../types/index.js'
import {
Constants,
- JSONStringifyWithMapSupport,
getWebSocketCloseEventStatusString,
isNotEmptyString,
- logPrefix,
+ JSONStringifyWithMapSupport,
logger,
+ logPrefix,
validateUUID
} from '../../utils/index.js'
+import { AbstractUIServer } from './AbstractUIServer.js'
+import {
+ getProtocolAndVersion,
+ handleProtocols,
+ isProtocolAndVersionSupported
+} from './UIServerUtils.js'
const moduleName = 'UIWebSocketServer'
-import { AbstractUIService } from './AbstractUIService.js'
import { type ProtocolRequestHandler, ProtocolVersion } from '../../../types/index.js'
import type { AbstractUIServer } from '../AbstractUIServer.js'
+import { AbstractUIService } from './AbstractUIService.js'
export class UIService001 extends AbstractUIService {
constructor (uiServer: AbstractUIServer) {
-import type { AbstractUIService } from './AbstractUIService.js'
-import { UIService001 } from './UIService001.js'
import { ProtocolVersion } from '../../../types/index.js'
import type { AbstractUIServer } from '../AbstractUIServer.js'
+import type { AbstractUIService } from './AbstractUIService.js'
+import { UIService001 } from './UIService001.js'
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
export class UIServiceFactory {
// Partial Copyright Jerome Benoit. 2021-2024. All Rights Reserved.
-import { BaseError } from './BaseError.js'
import type { ErrorType, IncomingRequestCommand, JsonType, RequestCommand } from '../types/index.js'
import { Constants } from '../utils/index.js'
+import { BaseError } from './BaseError.js'
export class OCPPError extends BaseError {
code: ErrorType
// Partial Copyright Jerome Benoit. 2021-2024. All Rights Reserved.
-import { type PerformanceEntry, PerformanceObserver, performance } from 'node:perf_hooks'
+import { performance, type PerformanceEntry, PerformanceObserver } from 'node:perf_hooks'
import type { URL } from 'node:url'
import { parentPort } from 'node:worker_threads'
type TimestampedData
} from '../types/index.js'
import {
+ average,
+ buildPerformanceStatisticsMessage,
CircularArray,
Configuration,
Constants,
- JSONStringifyWithMapSupport,
- average,
- buildPerformanceStatisticsMessage,
extractTimeSeriesValues,
formatDurationSeconds,
generateUUID,
- logPrefix,
+ JSONStringifyWithMapSupport,
logger,
+ logPrefix,
max,
median,
min,
import { closeSync, existsSync, mkdirSync, openSync, writeSync } from 'node:fs'
import { dirname } from 'node:path'
-import { Storage } from './Storage.js'
import { BaseError } from '../../exception/index.js'
import { FileType, type Statistics } from '../../types/index.js'
import {
AsyncLock,
AsyncLockType,
- JSONStringifyWithMapSupport,
- handleFileException
+ handleFileException,
+ JSONStringifyWithMapSupport
} from '../../utils/index.js'
+import { Storage } from './Storage.js'
export class JsonFileStorage extends Storage {
private fd?: number
import { MikroORM as MariaDbORM, type Options as MariaDbOptions } from '@mikro-orm/mariadb'
import { MikroORM as SqliteORM, type Options as SqliteOptions } from '@mikro-orm/sqlite'
-import { Storage } from './Storage.js'
import { type PerformanceRecord, type Statistics, StorageType } from '../../types/index.js'
import { Constants } from '../../utils/index.js'
+import { Storage } from './Storage.js'
export class MikroOrmStorage extends Storage {
private readonly storageType: StorageType
import { MongoClient } from 'mongodb'
-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'
+import { Storage } from './Storage.js'
export class MongoDBStorage extends Storage {
private readonly client?: MongoClient
// Copyright Jerome Benoit. 2021-2024. All Rights Reserved.
-import { Storage } from './Storage.js'
import type { Statistics } from '../../types/index.js'
+import { Storage } from './Storage.js'
export class None extends Storage {
constructor () {
// Copyright Jerome Benoit. 2021-2024. All Rights Reserved.
+import { BaseError } from '../../exception/index.js'
+import { StorageType } from '../../types/index.js'
import { JsonFileStorage } from './JsonFileStorage.js'
import { MikroOrmStorage } from './MikroOrmStorage.js'
import { MongoDBStorage } from './MongoDBStorage.js'
import { None } from './None.js'
import type { Storage } from './Storage.js'
-import { BaseError } from '../../exception/index.js'
-import { StorageType } from '../../types/index.js'
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
export class StorageFactory {
import type { WebSocket } from 'ws'
+import { type WorkerData, type WorkerMessage, WorkerMessageEvents } from '../worker/index.js'
import type { ChargingStationAutomaticTransactionGeneratorConfiguration } from './AutomaticTransactionGenerator.js'
import { ChargingStationEvents } from './ChargingStationEvents.js'
import type { ChargingStationInfo } from './ChargingStationInfo.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'
export interface ChargingStationOptions extends JsonObject {
supervisionUrls?: string | string[]
import type { WorkerChoiceStrategy } from 'poolifier'
+import type { WorkerProcessType } from '../worker/index.js'
import type { StorageType } from './Storage.js'
import type { ApplicationProtocol, AuthenticationType } from './UIProtocol.js'
-import type { WorkerProcessType } from '../worker/index.js'
type ServerOptions = ListenOptions
-import type { IncomingRequestCommand, RequestCommand } from './ocpp/Requests.js'
import type { CircularArray } from '../utils/index.js'
import type { WorkerData } from '../worker/index.js'
+import type { IncomingRequestCommand, RequestCommand } from './ocpp/Requests.js'
export interface TimestampedData {
timestamp: number
-export {
- ApplicationProtocol,
- AuthenticationType,
- ProcedureName,
- Protocol,
- type ProtocolRequest,
- type ProtocolRequestHandler,
- type ProtocolResponse,
- ProtocolVersion,
- type RequestPayload,
- type ResponsePayload,
- ResponseStatus,
- type SimulatorState,
- type TemplateStatistics
-} from './UIProtocol.js'
export {
type AutomaticTransactionGeneratorConfiguration,
type ChargingStationAutomaticTransactionGeneratorConfiguration,
IdTagDistribution,
type Status
} from './AutomaticTransactionGenerator.js'
-export { type GenericResponse, GenericStatus, RegistrationStatusEnumType } from './ocpp/Common.js'
+export type {
+ ChargingStationConfiguration,
+ EvseStatusConfiguration
+} from './ChargingStationConfiguration.js'
+export { ChargingStationEvents } from './ChargingStationEvents.js'
+export type { ChargingStationInfo } from './ChargingStationInfo.js'
+export type {
+ ChargingStationOcppConfiguration,
+ ConfigurationKey
+} from './ChargingStationOcppConfiguration.js'
export {
- AvailabilityType,
- type BootNotificationRequest,
- type CachedRequest,
- type DataTransferRequest,
- type DiagnosticsStatusNotificationRequest,
- type ErrorCallback,
- FirmwareStatus,
- type FirmwareStatusNotificationRequest,
- type HeartbeatRequest,
- type IncomingRequest,
- IncomingRequestCommand,
- type IncomingRequestHandler,
- MessageTrigger,
- type MeterValuesRequest,
- type OutgoingRequest,
- RequestCommand,
- type RequestParams,
- type ResponseCallback,
- type ResponseType,
- type StatusNotificationRequest
-} from './ocpp/Requests.js'
+ AmpereUnits,
+ type ChargingStationTemplate,
+ CurrentType,
+ type FirmwareUpgrade,
+ PowerUnits,
+ Voltage,
+ type WsOptions
+} from './ChargingStationTemplate.js'
export {
- AvailabilityStatus,
- type BootNotificationResponse,
- ChargingProfileStatus,
- type ClearCacheResponse,
- ClearChargingProfileStatus,
- ConfigurationStatus,
- type DataTransferResponse,
- DataTransferStatus,
- type DiagnosticsStatusNotificationResponse,
- type ErrorResponse,
- type FirmwareStatusNotificationResponse,
- type HeartbeatResponse,
- type MeterValuesResponse,
- ReservationStatus,
- type Response,
- type ResponseHandler,
- type StatusNotificationResponse,
- TriggerMessageStatus,
- UnlockStatus
-} from './ocpp/Responses.js'
+ type ChargingStationData,
+ type ChargingStationOptions,
+ type ChargingStationWorkerData,
+ type ChargingStationWorkerEventError,
+ type ChargingStationWorkerMessage,
+ type ChargingStationWorkerMessageData,
+ ChargingStationWorkerMessageEvents,
+ type EvseStatusWorkerType
+} from './ChargingStationWorker.js'
export {
- AuthorizationStatus,
- type AuthorizeRequest,
- type AuthorizeResponse,
- type StartTransactionRequest,
- type StartTransactionResponse,
- StopTransactionReason,
- type StopTransactionRequest,
- type StopTransactionResponse
-} from './ocpp/Transaction.js'
-export { BootReasonEnumType, OCPP20ConnectorStatusEnumType } from './ocpp/2.0/Common.js'
+ ApplicationProtocolVersion,
+ type ConfigurationData,
+ ConfigurationSection,
+ type ElementsPerWorkerType,
+ type LogConfiguration,
+ type StationTemplateUrl,
+ type StorageConfiguration,
+ SupervisionUrlDistribution,
+ type UIServerConfiguration,
+ type WorkerConfiguration
+} from './ConfigurationData.js'
+export type { ConnectorStatus } from './ConnectorStatus.js'
+export type { EmptyObject } from './EmptyObject.js'
+export type { HandleErrorParams } from './Error.js'
+export type { EvseStatus, EvseTemplate } from './Evse.js'
+export { FileType } from './FileType.js'
+export type { JsonObject, JsonType } from './JsonType.js'
+export type {
+ MeasurandPerPhaseSampledValueTemplates,
+ SampledValueTemplate
+} from './MeasurandPerPhaseSampledValueTemplates.js'
+export type { MeasurandValues } from './MeasurandValues.js'
+export { OCPP16ChargePointErrorCode } from './ocpp/1.6/ChargePointErrorCode.js'
+export { OCPP16ChargePointStatus } from './ocpp/1.6/ChargePointStatus.js'
export {
- BroadcastChannelProcedureName,
- type BroadcastChannelRequest,
- type BroadcastChannelRequestPayload,
- type BroadcastChannelResponse,
- type BroadcastChannelResponsePayload,
- type MessageEvent
-} from './WorkerBroadcastChannel.js'
+ type OCPP16ChargingProfile,
+ OCPP16ChargingProfilePurposeType,
+ OCPP16ChargingRateUnitType,
+ type OCPP16ChargingSchedule,
+ type OCPP16ChargingSchedulePeriod
+} from './ocpp/1.6/ChargingProfile.js'
+export {
+ OCPP16StandardParametersKey,
+ OCPP16SupportedFeatureProfiles
+} from './ocpp/1.6/Configuration.js'
+export { OCPP16DiagnosticsStatus } from './ocpp/1.6/DiagnosticsStatus.js'
+export {
+ type OCPP16MeterValue,
+ OCPP16MeterValueContext,
+ OCPP16MeterValueLocation,
+ OCPP16MeterValueMeasurand,
+ OCPP16MeterValuePhase,
+ type OCPP16MeterValuesRequest,
+ type OCPP16MeterValuesResponse,
+ OCPP16MeterValueUnit,
+ type OCPP16SampledValue
+} from './ocpp/1.6/MeterValues.js'
export {
type ChangeConfigurationRequest,
type GetConfigurationRequest,
type SetChargingProfileResponse,
type UnlockConnectorResponse
} from './ocpp/1.6/Responses.js'
+export {
+ OCPP16AuthorizationStatus,
+ type OCPP16AuthorizeRequest,
+ type OCPP16AuthorizeResponse,
+ type OCPP16StartTransactionRequest,
+ type OCPP16StartTransactionResponse,
+ OCPP16StopTransactionReason,
+ type OCPP16StopTransactionRequest,
+ type OCPP16StopTransactionResponse
+} from './ocpp/1.6/Transaction.js'
+export { BootReasonEnumType, OCPP20ConnectorStatusEnumType } from './ocpp/2.0/Common.js'
+export {
+ type OCPP20BootNotificationRequest,
+ type OCPP20ClearCacheRequest,
+ type OCPP20HeartbeatRequest,
+ OCPP20IncomingRequestCommand,
+ OCPP20RequestCommand,
+ type OCPP20StatusNotificationRequest
+} from './ocpp/2.0/Requests.js'
+export type {
+ OCPP20BootNotificationResponse,
+ OCPP20ClearCacheResponse,
+ OCPP20HeartbeatResponse,
+ OCPP20StatusNotificationResponse
+} from './ocpp/2.0/Responses.js'
+export { OCPP20OptionalVariableName } from './ocpp/2.0/Variables.js'
export { ChargePointErrorCode } from './ocpp/ChargePointErrorCode.js'
export {
type ChargingProfile,
type ChargingSchedulePeriod,
RecurrencyKindType
} from './ocpp/ChargingProfile.js'
-export type {
- ChargingStationConfiguration,
- EvseStatusConfiguration
-} from './ChargingStationConfiguration.js'
-export {
- type ChargingStationData,
- type ChargingStationWorkerData,
- type ChargingStationWorkerEventError,
- type ChargingStationWorkerMessage,
- type ChargingStationWorkerMessageData,
- ChargingStationWorkerMessageEvents,
- type ChargingStationOptions,
- type EvseStatusWorkerType
-} from './ChargingStationWorker.js'
-export type { ChargingStationInfo } from './ChargingStationInfo.js'
-export type {
- ChargingStationOcppConfiguration,
- ConfigurationKey
-} from './ChargingStationOcppConfiguration.js'
-export {
- AmpereUnits,
- type ChargingStationTemplate,
- CurrentType,
- type FirmwareUpgrade,
- PowerUnits,
- Voltage,
- type WsOptions
-} from './ChargingStationTemplate.js'
-export {
- ApplicationProtocolVersion,
- type ConfigurationData,
- ConfigurationSection,
- type ElementsPerWorkerType,
- type LogConfiguration,
- type StationTemplateUrl,
- type StorageConfiguration,
- SupervisionUrlDistribution,
- type UIServerConfiguration,
- type WorkerConfiguration
-} from './ConfigurationData.js'
+export { type GenericResponse, GenericStatus, RegistrationStatusEnumType } from './ocpp/Common.js'
export {
type ConfigurationKeyType,
ConnectorPhaseRotation,
SupportedFeatureProfiles,
VendorParametersKey
} from './ocpp/Configuration.js'
-export type { ConnectorStatus } from './ConnectorStatus.js'
export { ConnectorStatusEnum, type ConnectorStatusTransition } from './ocpp/ConnectorStatusEnum.js'
-export { DBName, 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.js'
-export type { MeasurandValues } from './MeasurandValues.js'
export { MessageType } from './ocpp/MessageType.js'
export {
type MeterValue,
MeterValueUnit,
type SampledValue
} from './ocpp/MeterValues.js'
+export { OCPPVersion } from './ocpp/OCPPVersion.js'
export {
- type OCPP16MeterValue,
- OCPP16MeterValueContext,
- OCPP16MeterValueLocation,
- OCPP16MeterValueMeasurand,
- OCPP16MeterValuePhase,
- OCPP16MeterValueUnit,
- type OCPP16MeterValuesRequest,
- type OCPP16MeterValuesResponse,
- type OCPP16SampledValue
-} from './ocpp/1.6/MeterValues.js'
-export {
- OCPP16AuthorizationStatus,
- type OCPP16AuthorizeRequest,
- type OCPP16AuthorizeResponse,
- type OCPP16StartTransactionRequest,
- type OCPP16StartTransactionResponse,
- OCPP16StopTransactionReason,
- type OCPP16StopTransactionRequest,
- type OCPP16StopTransactionResponse
-} from './ocpp/1.6/Transaction.js'
-export { OCPP16ChargePointErrorCode } from './ocpp/1.6/ChargePointErrorCode.js'
-export { OCPP16ChargePointStatus } from './ocpp/1.6/ChargePointStatus.js'
+ AvailabilityType,
+ type BootNotificationRequest,
+ type CachedRequest,
+ type DataTransferRequest,
+ type DiagnosticsStatusNotificationRequest,
+ type ErrorCallback,
+ FirmwareStatus,
+ type FirmwareStatusNotificationRequest,
+ type HeartbeatRequest,
+ type IncomingRequest,
+ IncomingRequestCommand,
+ type IncomingRequestHandler,
+ MessageTrigger,
+ type MeterValuesRequest,
+ type OutgoingRequest,
+ RequestCommand,
+ type RequestParams,
+ type ResponseCallback,
+ type ResponseType,
+ type StatusNotificationRequest
+} from './ocpp/Requests.js'
export {
- type OCPP16ChargingProfile,
- OCPP16ChargingProfilePurposeType,
- OCPP16ChargingRateUnitType,
- type OCPP16ChargingSchedule,
- type OCPP16ChargingSchedulePeriod
-} from './ocpp/1.6/ChargingProfile.js'
+ type Reservation,
+ type ReservationKey,
+ ReservationTerminationReason
+} from './ocpp/Reservation.js'
export {
- OCPP16StandardParametersKey,
- OCPP16SupportedFeatureProfiles
-} from './ocpp/1.6/Configuration.js'
-export { OCPP16DiagnosticsStatus } from './ocpp/1.6/DiagnosticsStatus.js'
+ AvailabilityStatus,
+ type BootNotificationResponse,
+ ChargingProfileStatus,
+ type ClearCacheResponse,
+ ClearChargingProfileStatus,
+ ConfigurationStatus,
+ type DataTransferResponse,
+ DataTransferStatus,
+ type DiagnosticsStatusNotificationResponse,
+ type ErrorResponse,
+ type FirmwareStatusNotificationResponse,
+ type HeartbeatResponse,
+ type MeterValuesResponse,
+ ReservationStatus,
+ type Response,
+ type ResponseHandler,
+ type StatusNotificationResponse,
+ TriggerMessageStatus,
+ UnlockStatus
+} from './ocpp/Responses.js'
export {
- type OCPP20BootNotificationRequest,
- type OCPP20ClearCacheRequest,
- type OCPP20HeartbeatRequest,
- OCPP20IncomingRequestCommand,
- OCPP20RequestCommand,
- type OCPP20StatusNotificationRequest
-} from './ocpp/2.0/Requests.js'
-export type {
- OCPP20BootNotificationResponse,
- OCPP20ClearCacheResponse,
- OCPP20HeartbeatResponse,
- OCPP20StatusNotificationResponse
-} from './ocpp/2.0/Responses.js'
-export { OCPP20OptionalVariableName } from './ocpp/2.0/Variables.js'
-export { OCPPVersion } from './ocpp/OCPPVersion.js'
+ AuthorizationStatus,
+ type AuthorizeRequest,
+ type AuthorizeResponse,
+ type StartTransactionRequest,
+ type StartTransactionResponse,
+ StopTransactionReason,
+ type StopTransactionRequest,
+ type StopTransactionResponse
+} from './ocpp/Transaction.js'
export { PerformanceRecord } from './orm/entities/PerformanceRecord.js'
export type {
InternalTemplateStatistics,
StatisticsData,
TimestampedData
} from './Statistics.js'
+export { DBName, StorageType } from './Storage.js'
+export {
+ ApplicationProtocol,
+ AuthenticationType,
+ ProcedureName,
+ Protocol,
+ type ProtocolRequest,
+ type ProtocolRequestHandler,
+ type ProtocolResponse,
+ ProtocolVersion,
+ type RequestPayload,
+ type ResponsePayload,
+ ResponseStatus,
+ type SimulatorState,
+ type TemplateStatistics
+} from './UIProtocol.js'
export {
- type WSError,
WebSocketCloseEventStatusCode,
- WebSocketCloseEventStatusString
+ WebSocketCloseEventStatusString,
+ type WSError
} from './WebSocket.js'
export {
- type Reservation,
- type ReservationKey,
- ReservationTerminationReason
-} from './ocpp/Reservation.js'
-export { ChargingStationEvents } from './ChargingStationEvents.js'
+ BroadcastChannelProcedureName,
+ type BroadcastChannelRequest,
+ type BroadcastChannelRequestPayload,
+ type BroadcastChannelResponse,
+ type BroadcastChannelResponsePayload,
+ type MessageEvent
+} from './WorkerBroadcastChannel.js'
+import type { EmptyObject } from '../../EmptyObject.js'
+import type { JsonObject } from '../../JsonType.js'
import type { OCPP16ChargePointErrorCode } from './ChargePointErrorCode.js'
import type { OCPP16ChargePointStatus } from './ChargePointStatus.js'
import type {
} 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',
-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'
+import type { OCPP16ChargingSchedule } from './ChargingProfile.js'
export interface OCPP16HeartbeatResponse extends JsonObject {
currentTime: Date
-import type { OCPP16MeterValue } from './MeterValues.js'
import type { JsonObject } from '../../JsonType.js'
+import type { OCPP16MeterValue } from './MeterValues.js'
export enum OCPP16StopTransactionReason {
EMERGENCY_STOP = 'EmergencyStop',
+import type { EmptyObject } from '../../EmptyObject.js'
+import type { JsonObject } from '../../JsonType.js'
import type {
BootReasonEnumType,
InstallCertificateUseEnumType,
OCPP20ConnectorStatusEnumType
} 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',
+import type { EmptyObject } from '../../EmptyObject.js'
+import type { JsonObject } from '../../JsonType.js'
+import type { RegistrationStatusEnumType } from '../Common.js'
import type {
GenericStatusEnumType,
InstallCertificateStatusEnumType,
StatusInfoType
} 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 interface OCPP20BootNotificationResponse extends JsonObject {
currentTime: Date
-import type { EVSEType, StatusInfoType } from './Common.js'
import type { JsonObject } from '../../JsonType.js'
+import type { EVSEType, StatusInfoType } from './Common.js'
enum OCPP20ComponentName {
AlignedDataCtrlr = 'AlignedDataCtrlr',
+import type { JsonObject } from '../JsonType.js'
import {
OCPP16StandardParametersKey,
OCPP16SupportedFeatureProfiles,
OCPP20RequiredVariableName,
OCPP20VendorVariableName
} from './2.0/Variables.js'
-import type { JsonObject } from '../JsonType.js'
export const StandardParametersKey = {
...OCPP16StandardParametersKey,
+import type { ChargingStation } from '../../charging-station/index.js'
+import type { OCPPError } from '../../exception/index.js'
+import type { JsonType } from '../JsonType.js'
import { OCPP16DiagnosticsStatus } from './1.6/DiagnosticsStatus.js'
import type { OCPP16MeterValuesRequest } from './1.6/MeterValues.js'
import {
type OCPP20StatusNotificationRequest
} 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,
+import type { ChargingStation } from '../../charging-station/index.js'
+import type { JsonType } from '../JsonType.js'
import type { OCPP16MeterValuesResponse } from './1.6/MeterValues.js'
import {
OCPP16AvailabilityStatus,
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]
import chalk from 'chalk'
import { mergeDeepRight } from 'rambda'
-import {
- buildPerformanceUriFilePath,
- checkWorkerElementsPerWorker,
- checkWorkerProcessType,
- getDefaultPerformanceStorageUri,
- handleFileException,
- logPrefix
-} from './ConfigurationUtils.js'
-import { Constants } from './Constants.js'
-import { hasOwnProp, isCFEnvironment, once } from './Utils.js'
import {
ApplicationProtocol,
ApplicationProtocolVersion,
DEFAULT_WORKER_START_DELAY,
WorkerProcessType
} from '../worker/index.js'
+import {
+ buildPerformanceUriFilePath,
+ checkWorkerElementsPerWorker,
+ checkWorkerProcessType,
+ getDefaultPerformanceStorageUri,
+ handleFileException,
+ logPrefix
+} from './ConfigurationUtils.js'
+import { Constants } from './Constants.js'
+import { hasOwnProp, isCFEnvironment, once } from './Utils.js'
type ConfigurationSectionType =
| LogConfiguration
import chalk from 'chalk'
-import { Constants } from './Constants.js'
-import { isNotEmptyString, logPrefix as utilsLogPrefix } from './Utils.js'
import { type ElementsPerWorkerType, type FileType, StorageType } from '../types/index.js'
import { WorkerProcessType } from '../worker/index.js'
+import { Constants } from './Constants.js'
+import { isNotEmptyString, logPrefix as utilsLogPrefix } from './Utils.js'
export const logPrefix = (): string => {
return utilsLogPrefix(' Simulator configuration |')
import chalk from 'chalk'
-import { logger } from './Logger.js'
-import { isNotEmptyString } from './Utils.js'
import type { ChargingStation } from '../charging-station/index.js'
import type {
EmptyObject,
JsonType,
RequestCommand
} from '../types/index.js'
+import { logger } from './Logger.js'
+import { isNotEmptyString } from './Utils.js'
const defaultErrorParams = {
throwError: true,
-import { type FSWatcher, type WatchListener, readFileSync, watch } from 'node:fs'
+import { type FSWatcher, readFileSync, watch, type WatchListener } from 'node:fs'
+import type { FileType, JsonType } from '../types/index.js'
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 = <T extends JsonType>(
file: string,
import TransportType from 'winston/lib/winston/transports/index.js'
import DailyRotateFile from 'winston-daily-rotate-file'
+import { ConfigurationSection, type LogConfiguration } from '../types/index.js'
import { Configuration } from './Configuration.js'
import { insertAt } from './Utils.js'
-import { ConfigurationSection, type LogConfiguration } from '../types/index.js'
const logConfiguration = Configuration.getConfigurationSection<LogConfiguration>(
ConfigurationSection.log
-import {
- OutputFormat,
- buildChargingStationAutomaticTransactionGeneratorConfiguration,
- buildConnectorsStatus,
- buildEvsesStatus
-} from './ChargingStationConfigurationUtils.js'
-import { clone } from './Utils.js'
import type { ChargingStation } from '../charging-station/index.js'
import {
type ChargingStationData,
type Statistics,
type TemplateStatistics
} from '../types/index.js'
+import {
+ buildChargingStationAutomaticTransactionGeneratorConfiguration,
+ buildConnectorsStatus,
+ buildEvsesStatus,
+ OutputFormat
+} from './ChargingStationConfigurationUtils.js'
+import { clone } from './Utils.js'
export const buildAddedMessage = (
chargingStation: ChargingStation
secondsToMilliseconds
} from 'date-fns'
-import { Constants } from './Constants.js'
import {
type EmptyObject,
type ProtocolResponse,
type TimestampedData,
WebSocketCloseEventStatusString
} from '../types/index.js'
+import { Constants } from './Constants.js'
export const logPrefix = (prefixString = ''): string => {
return `${new Date().toLocaleString()}${prefixString}`
-export { ACElectricUtils, DCElectricUtils } from './ElectricUtils.js'
export { AsyncLock, AsyncLockType } from './AsyncLock.js'
export {
- OutputFormat,
buildChargingStationAutomaticTransactionGeneratorConfiguration,
buildConnectorsStatus,
- buildEvsesStatus
+ buildEvsesStatus,
+ OutputFormat
} from './ChargingStationConfigurationUtils.js'
export { CircularArray } from './CircularArray.js'
export { Configuration } from './Configuration.js'
export { Constants } from './Constants.js'
+export { ACElectricUtils, DCElectricUtils } from './ElectricUtils.js'
export {
handleFileException,
handleSendMessageError,
setDefaultErrorParams
} from './ErrorUtils.js'
export { watchJsonFile } from './FileUtils.js'
+export { logger } from './Logger.js'
export {
buildAddedMessage,
buildChargingStationDataPayload,
buildTemplateStatisticsPayload,
buildUpdatedMessage
} from './MessageChannelUtils.js'
+export { average, median, nthPercentile, stdDeviation } from './StatisticUtils.js'
export {
- JSONStringifyWithMapSupport,
clone,
convertToBoolean,
convertToDate,
isNotEmptyArray,
isNotEmptyString,
isValidDate,
+ JSONStringifyWithMapSupport,
logPrefix,
max,
min,
sleep,
validateUUID
} from './Utils.js'
-export { average, median, nthPercentile, stdDeviation } from './StatisticUtils.js'
-export { logger } from './Logger.js'