-import type ChargingStation from './ChargingStation';
-import type { ConfigurationKey } from '../types/ChargingStationOcppConfiguration';
-import type { StandardParametersKey } from '../types/ocpp/Configuration';
-import logger from '../utils/Logger';
+import type { ChargingStation } from './internal';
+import type { ConfigurationKey, ConfigurationKeyType } from '../types';
+import { logger } from '../utils';
type ConfigurationKeyOptions = { readonly?: boolean; visible?: boolean; reboot?: boolean };
type DeleteConfigurationKeyParams = { save?: boolean; caseInsensitive?: boolean };
public static getConfigurationKey(
chargingStation: ChargingStation,
- key: string | StandardParametersKey,
+ key: ConfigurationKeyType,
caseInsensitive = false
): ConfigurationKey | undefined {
- return chargingStation.ocppConfiguration.configurationKey.find(configElement => {
+ return chargingStation.ocppConfiguration?.configurationKey?.find((configElement) => {
if (caseInsensitive) {
return configElement.key.toLowerCase() === key.toLowerCase();
}
public static addConfigurationKey(
chargingStation: ChargingStation,
- key: string | StandardParametersKey,
+ key: ConfigurationKeyType,
value: string,
options: ConfigurationKeyOptions = {
readonly: false,
keyFound = undefined;
}
if (!keyFound) {
- chargingStation.ocppConfiguration.configurationKey.push({
+ chargingStation.ocppConfiguration?.configurationKey?.push({
key,
readonly: options.readonly,
value,
public static setConfigurationKeyValue(
chargingStation: ChargingStation,
- key: string | StandardParametersKey,
+ key: ConfigurationKeyType,
value: string,
caseInsensitive = false
): void {
public static deleteConfigurationKey(
chargingStation: ChargingStation,
- key: string | StandardParametersKey,
+ key: ConfigurationKeyType,
params: DeleteConfigurationKeyParams = { save: true, caseInsensitive: false }
- ): ConfigurationKey[] {
+ ): ConfigurationKey[] | undefined {
const keyFound = ChargingStationConfigurationUtils.getConfigurationKey(
chargingStation,
key,
params?.caseInsensitive
);
if (keyFound) {
- const deletedConfigurationKey = chargingStation.ocppConfiguration.configurationKey.splice(
+ const deletedConfigurationKey = chargingStation.ocppConfiguration?.configurationKey?.splice(
chargingStation.ocppConfiguration.configurationKey.indexOf(keyFound),
1
);