+ private static checkDeprecatedConfigurationKeys() {
+ // connection timeout
+ Configuration.warnDeprecatedConfigurationKey(
+ 'autoReconnectTimeout',
+ undefined,
+ "Use 'ConnectionTimeOut' OCPP parameter in charging station template instead",
+ );
+ Configuration.warnDeprecatedConfigurationKey(
+ 'connectionTimeout',
+ undefined,
+ "Use 'ConnectionTimeOut' OCPP parameter in charging station template instead",
+ );
+ // connection retries
+ Configuration.warnDeprecatedConfigurationKey(
+ 'autoReconnectMaxRetries',
+ undefined,
+ 'Use it in charging station template instead',
+ );
+ // station template url(s)
+ Configuration.warnDeprecatedConfigurationKey(
+ 'stationTemplateURLs',
+ undefined,
+ "Use 'stationTemplateUrls' instead",
+ );
+ !isUndefined(
+ Configuration.getConfigurationData()?.['stationTemplateURLs' as keyof ConfigurationData],
+ ) &&
+ (Configuration.getConfigurationData()!.stationTemplateUrls =
+ Configuration.getConfigurationData()![
+ 'stationTemplateURLs' as keyof ConfigurationData
+ ] as StationTemplateUrl[]);
+ Configuration.getConfigurationData()?.stationTemplateUrls.forEach(
+ (stationTemplateUrl: StationTemplateUrl) => {
+ if (!isUndefined(stationTemplateUrl?.['numberOfStation' as keyof StationTemplateUrl])) {
+ console.error(
+ `${chalk.green(Configuration.logPrefix())} ${chalk.red(
+ `Deprecated configuration key 'numberOfStation' usage for template file '${stationTemplateUrl.file}' in 'stationTemplateUrls'. Use 'numberOfStations' instead`,
+ )}`,
+ );
+ }
+ },
+ );
+ // supervision url(s)
+ Configuration.warnDeprecatedConfigurationKey(
+ 'supervisionURLs',
+ undefined,
+ "Use 'supervisionUrls' instead",
+ );
+ // supervision urls distribution
+ Configuration.warnDeprecatedConfigurationKey(
+ 'distributeStationToTenantEqually',
+ undefined,
+ "Use 'supervisionUrlDistribution' instead",
+ );
+ Configuration.warnDeprecatedConfigurationKey(
+ 'distributeStationsToTenantsEqually',
+ undefined,
+ "Use 'supervisionUrlDistribution' instead",
+ );
+ // worker section
+ Configuration.warnDeprecatedConfigurationKey(
+ 'useWorkerPool',
+ undefined,
+ `Use '${ConfigurationSection.worker}' section to define the type of worker process model instead`,
+ );
+ Configuration.warnDeprecatedConfigurationKey(
+ 'workerProcess',
+ undefined,
+ `Use '${ConfigurationSection.worker}' section to define the type of worker process model instead`,
+ );
+ Configuration.warnDeprecatedConfigurationKey(
+ 'workerStartDelay',
+ undefined,
+ `Use '${ConfigurationSection.worker}' section to define the worker start delay instead`,
+ );
+ Configuration.warnDeprecatedConfigurationKey(
+ 'chargingStationsPerWorker',
+ undefined,
+ `Use '${ConfigurationSection.worker}' section to define the number of element(s) per worker instead`,
+ );
+ Configuration.warnDeprecatedConfigurationKey(
+ 'elementStartDelay',
+ undefined,
+ `Use '${ConfigurationSection.worker}' section to define the worker's element start delay instead`,
+ );
+ Configuration.warnDeprecatedConfigurationKey(
+ 'workerPoolMinSize',
+ undefined,
+ `Use '${ConfigurationSection.worker}' section to define the worker pool minimum size instead`,
+ );
+ Configuration.warnDeprecatedConfigurationKey(
+ 'workerPoolSize',
+ undefined,
+ `Use '${ConfigurationSection.worker}' section to define the worker pool maximum size instead`,
+ );
+ Configuration.warnDeprecatedConfigurationKey(
+ 'workerPoolMaxSize',
+ undefined,
+ `Use '${ConfigurationSection.worker}' section to define the worker pool maximum size instead`,
+ );
+ Configuration.warnDeprecatedConfigurationKey(
+ 'workerPoolStrategy',
+ undefined,
+ `Use '${ConfigurationSection.worker}' section to define the worker pool strategy instead`,
+ );
+ Configuration.warnDeprecatedConfigurationKey(
+ 'poolStrategy',
+ ConfigurationSection.worker,
+ 'Not publicly exposed to end users',
+ );
+ if (
+ Configuration.getConfigurationData()?.worker?.processType ===
+ ('staticPool' as WorkerProcessType)
+ ) {
+ console.error(
+ `${chalk.green(Configuration.logPrefix())} ${chalk.red(
+ `Deprecated configuration 'staticPool' value usage in worker section 'processType' field. Use '${WorkerProcessType.fixedPool}' value instead`,
+ )}`,
+ );
+ }
+ // log section
+ Configuration.warnDeprecatedConfigurationKey(
+ 'logEnabled',
+ undefined,
+ `Use '${ConfigurationSection.log}' section to define the logging enablement instead`,
+ );
+ Configuration.warnDeprecatedConfigurationKey(
+ 'logFile',
+ undefined,
+ `Use '${ConfigurationSection.log}' section to define the log file instead`,
+ );
+ Configuration.warnDeprecatedConfigurationKey(
+ 'logErrorFile',
+ undefined,
+ `Use '${ConfigurationSection.log}' section to define the log error file instead`,
+ );
+ Configuration.warnDeprecatedConfigurationKey(
+ 'logConsole',
+ undefined,
+ `Use '${ConfigurationSection.log}' section to define the console logging enablement instead`,
+ );
+ Configuration.warnDeprecatedConfigurationKey(
+ 'logStatisticsInterval',
+ undefined,
+ `Use '${ConfigurationSection.log}' section to define the log statistics interval instead`,
+ );
+ Configuration.warnDeprecatedConfigurationKey(
+ 'logLevel',
+ undefined,
+ `Use '${ConfigurationSection.log}' section to define the log level instead`,
+ );
+ Configuration.warnDeprecatedConfigurationKey(
+ 'logFormat',
+ undefined,
+ `Use '${ConfigurationSection.log}' section to define the log format instead`,
+ );
+ Configuration.warnDeprecatedConfigurationKey(
+ 'logRotate',
+ undefined,
+ `Use '${ConfigurationSection.log}' section to define the log rotation enablement instead`,
+ );
+ Configuration.warnDeprecatedConfigurationKey(
+ 'logMaxFiles',
+ undefined,
+ `Use '${ConfigurationSection.log}' section to define the log maximum files instead`,
+ );
+ Configuration.warnDeprecatedConfigurationKey(
+ 'logMaxSize',
+ undefined,
+ `Use '${ConfigurationSection.log}' section to define the log maximum size instead`,
+ );
+ // performanceStorage section
+ Configuration.warnDeprecatedConfigurationKey(
+ 'URI',
+ ConfigurationSection.performanceStorage,
+ "Use 'uri' instead",
+ );
+ // uiServer section
+ if (hasOwnProp(Configuration.getConfigurationData(), 'uiWebSocketServer')) {
+ console.error(
+ `${chalk.green(Configuration.logPrefix())} ${chalk.red(
+ `Deprecated configuration section 'uiWebSocketServer' usage. Use '${ConfigurationSection.uiServer}' instead`,
+ )}`,
+ );
+ }
+ }
+
+ private static warnDeprecatedConfigurationKey(
+ key: string,
+ sectionName?: string,
+ logMsgToAppend = '',
+ ) {
+ if (
+ sectionName &&
+ !isUndefined(
+ Configuration.getConfigurationData()?.[sectionName as keyof ConfigurationData],
+ ) &&
+ !isUndefined(
+ (
+ Configuration.getConfigurationData()?.[sectionName as keyof ConfigurationData] as Record<
+ string,
+ unknown
+ >
+ )?.[key],
+ )
+ ) {
+ console.error(
+ `${chalk.green(Configuration.logPrefix())} ${chalk.red(
+ `Deprecated configuration key '${key}' usage in section '${sectionName}'${
+ logMsgToAppend.trim().length > 0 ? `. ${logMsgToAppend}` : ''
+ }`,
+ )}`,
+ );
+ } else if (
+ !isUndefined(Configuration.getConfigurationData()?.[key as keyof ConfigurationData])
+ ) {
+ console.error(
+ `${chalk.green(Configuration.logPrefix())} ${chalk.red(
+ `Deprecated configuration key '${key}' usage${
+ logMsgToAppend.trim().length > 0 ? `. ${logMsgToAppend}` : ''
+ }`,
+ )}`,
+ );
+ }
+ }
+
+ private static getConfigurationData(): ConfigurationData | undefined {
+ if (!Configuration.configurationData) {
+ try {
+ Configuration.configurationData = JSON.parse(
+ readFileSync(Configuration.configurationFile, 'utf8'),
+ ) as ConfigurationData;
+ if (!Configuration.configurationFileWatcher) {
+ Configuration.configurationFileWatcher = Configuration.getConfigurationFileWatcher();
+ }
+ } catch (error) {
+ Configuration.handleFileException(
+ Configuration.configurationFile,
+ FileType.Configuration,
+ error as NodeJS.ErrnoException,
+ Configuration.logPrefix(),
+ );
+ }
+ }
+ return Configuration.configurationData;