public getConnectorMaximumAvailablePower (connectorId: number): number {
let connectorAmperageLimitationLimit: number | undefined
const amperageLimitation = this.getAmperageLimitation()
- if (
- amperageLimitation != null &&
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- amperageLimitation < this.stationInfo!.maximumAmperage!
- ) {
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ if (amperageLimitation != null && amperageLimitation < this.stationInfo!.maximumAmperage!) {
+ const voltageOut = this.getVoltageOut()
connectorAmperageLimitationLimit =
(this.stationInfo?.currentOutType === CurrentType.AC
? ACElectricUtils.powerTotal(
this.getNumberOfPhases(),
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- this.stationInfo.voltageOut!,
+ voltageOut,
amperageLimitation *
(this.hasEvses ? this.getNumberOfEvses() : this.getNumberOfConnectors())
)
: // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- DCElectricUtils.power(this.stationInfo!.voltageOut!, amperageLimitation)) /
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- this.powerDivider!
+ DCElectricUtils.power(voltageOut, amperageLimitation)) / this.powerDivider!
}
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const connectorMaximumPower = this.stationInfo!.maximumPower! / this.powerDivider!
}
}
+ public getVoltageOut (stationInfo?: ChargingStationInfo): Voltage {
+ return (
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ (stationInfo ?? this.stationInfo!).voltageOut ??
+ getDefaultVoltageOut(this.getCurrentOutType(stationInfo), this.logPrefix(), this.templateFile)
+ )
+ }
+
public getWebSocketPingInterval (): number {
return getConfigurationKey(this, StandardParametersKey.WebSocketPingInterval) != null
? convertToInt(getConfigurationKey(this, StandardParametersKey.WebSocketPingInterval)?.value)
return stationTemplate?.useConnectorId0 ?? Constants.DEFAULT_STATION_INFO.useConnectorId0!
}
- private getVoltageOut (stationInfo?: ChargingStationInfo): Voltage {
- return (
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- (stationInfo ?? this.stationInfo!).voltageOut ??
- getDefaultVoltageOut(this.getCurrentOutType(stationInfo), this.logPrefix(), this.templateFile)
- )
- }
-
private handleErrorMessage (errorResponse: ErrorResponse): void {
const [messageType, messageId, errorType, errorMessage, errorDetails] = errorResponse
if (!this.requests.has(messageId)) {
? limit
: ACElectricUtils.powerTotal(
chargingStation.getNumberOfPhases(),
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- chargingStation.stationInfo.voltageOut!,
+ chargingStation.getVoltageOut(),
limit
)
case CurrentType.DC:
return chargingProfile.chargingSchedule.chargingRateUnit === ChargingRateUnitType.WATT
? limit
- : // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- DCElectricUtils.power(chargingStation.stationInfo.voltageOut!, limit)
+ : DCElectricUtils.power(chargingStation.getVoltageOut(), limit)
default:
logger.error(
`${chargingStation.logPrefix()} ${moduleName}.buildChargingProfilesLimit: ${errorMsg}`
type OCPP16ChargingProfile,
OCPP16ChargingProfilePurposeType,
type OCPP16ChargingSchedule,
- type OCPP16ClearCacheRequest,
type OCPP16ClearChargingProfileRequest,
type OCPP16ClearChargingProfileResponse,
type OCPP16DataTransferRequest,
const moduleName = 'OCPP16IncomingRequestService'
export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
- protected payloadValidateFunctions: Map<OCPP16IncomingRequestCommand, ValidateFunction<JsonType>>
+ protected payloadValidatorFunctions: Map<OCPP16IncomingRequestCommand, ValidateFunction<JsonType>>
private readonly incomingRequestHandlers: Map<
OCPP16IncomingRequestCommand,
this.handleRequestUpdateFirmware.bind(this) as unknown as IncomingRequestHandler,
],
])
- this.payloadValidateFunctions = new Map<
- OCPP16IncomingRequestCommand,
- ValidateFunction<JsonType>
- >([
- [
- OCPP16IncomingRequestCommand.CANCEL_RESERVATION,
- this.ajv.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16CancelReservationRequest>(
- 'assets/json-schemas/ocpp/1.6/CancelReservation.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16IncomingRequestCommand.CHANGE_AVAILABILITY,
- this.ajv.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16ChangeAvailabilityRequest>(
- 'assets/json-schemas/ocpp/1.6/ChangeAvailability.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16IncomingRequestCommand.CHANGE_CONFIGURATION,
- this.ajv.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<ChangeConfigurationRequest>(
- 'assets/json-schemas/ocpp/1.6/ChangeConfiguration.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16IncomingRequestCommand.CLEAR_CACHE,
- this.ajv.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16ClearCacheRequest>(
- 'assets/json-schemas/ocpp/1.6/ClearCache.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16IncomingRequestCommand.CLEAR_CHARGING_PROFILE,
- this.ajv.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16ClearChargingProfileRequest>(
- 'assets/json-schemas/ocpp/1.6/ClearChargingProfile.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16IncomingRequestCommand.DATA_TRANSFER,
- this.ajv.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16DataTransferRequest>(
- 'assets/json-schemas/ocpp/1.6/DataTransfer.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16IncomingRequestCommand.GET_COMPOSITE_SCHEDULE,
- this.ajv.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16GetCompositeScheduleRequest>(
- 'assets/json-schemas/ocpp/1.6/GetCompositeSchedule.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16IncomingRequestCommand.GET_CONFIGURATION,
- this.ajv.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<GetConfigurationRequest>(
- 'assets/json-schemas/ocpp/1.6/GetConfiguration.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16IncomingRequestCommand.GET_DIAGNOSTICS,
- this.ajv.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<GetDiagnosticsRequest>(
- 'assets/json-schemas/ocpp/1.6/GetDiagnostics.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16IncomingRequestCommand.REMOTE_START_TRANSACTION,
- this.ajv.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<RemoteStartTransactionRequest>(
- 'assets/json-schemas/ocpp/1.6/RemoteStartTransaction.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16IncomingRequestCommand.REMOTE_STOP_TRANSACTION,
- this.ajv.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<RemoteStopTransactionRequest>(
- 'assets/json-schemas/ocpp/1.6/RemoteStopTransaction.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16IncomingRequestCommand.RESERVE_NOW,
- this.ajv.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16ReserveNowRequest>(
- 'assets/json-schemas/ocpp/1.6/ReserveNow.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16IncomingRequestCommand.RESET,
- this.ajv.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<ResetRequest>(
- 'assets/json-schemas/ocpp/1.6/Reset.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16IncomingRequestCommand.SET_CHARGING_PROFILE,
- this.ajv.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<SetChargingProfileRequest>(
- 'assets/json-schemas/ocpp/1.6/SetChargingProfile.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16IncomingRequestCommand.TRIGGER_MESSAGE,
- this.ajv.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16TriggerMessageRequest>(
- 'assets/json-schemas/ocpp/1.6/TriggerMessage.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16IncomingRequestCommand.UNLOCK_CONNECTOR,
- this.ajv.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<UnlockConnectorRequest>(
- 'assets/json-schemas/ocpp/1.6/UnlockConnector.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16IncomingRequestCommand.UPDATE_FIRMWARE,
- this.ajv.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16UpdateFirmwareRequest>(
- 'assets/json-schemas/ocpp/1.6/UpdateFirmware.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- ])
+ this.payloadValidatorFunctions = OCPP16ServiceUtils.createPayloadValidatorMap(
+ OCPP16ServiceUtils.createIncomingRequestPayloadConfigs(),
+ OCPP16ServiceUtils.createIncomingRequestFactoryOptions(moduleName, 'constructor'),
+ this.ajv
+ )
// Handle incoming request events
this.on(
OCPP16IncomingRequestCommand.REMOTE_START_TRANSACTION,
commandName: OCPP16IncomingRequestCommand,
commandPayload: JsonType
): boolean {
- if (this.payloadValidateFunctions.has(commandName)) {
+ if (this.payloadValidatorFunctions.has(commandName)) {
return this.validateIncomingRequestPayload(chargingStation, commandName, commandPayload)
}
logger.warn(
ErrorType,
type JsonObject,
type JsonType,
- type OCPP16AuthorizeRequest,
- type OCPP16BootNotificationRequest,
OCPP16ChargePointStatus,
- type OCPP16DataTransferRequest,
- type OCPP16DiagnosticsStatusNotificationRequest,
- type OCPP16FirmwareStatusNotificationRequest,
- type OCPP16HeartbeatRequest,
type OCPP16MeterValue,
- type OCPP16MeterValuesRequest,
OCPP16RequestCommand,
type OCPP16StartTransactionRequest,
- type OCPP16StatusNotificationRequest,
- type OCPP16StopTransactionRequest,
OCPPVersion,
type RequestParams,
} from '../../../types/index.js'
const moduleName = 'OCPP16RequestService'
export class OCPP16RequestService extends OCPPRequestService {
- protected payloadValidateFunctions: Map<OCPP16RequestCommand, ValidateFunction<JsonType>>
+ protected payloadValidatorFunctions: Map<OCPP16RequestCommand, ValidateFunction<JsonType>>
public constructor (ocppResponseService: OCPPResponseService) {
// if (new.target.name === moduleName) {
// throw new TypeError(`Cannot construct ${new.target.name} instances directly`)
// }
super(OCPPVersion.VERSION_16, ocppResponseService)
- this.payloadValidateFunctions = new Map<OCPP16RequestCommand, ValidateFunction<JsonType>>([
- [
- OCPP16RequestCommand.AUTHORIZE,
- this.ajv.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16AuthorizeRequest>(
- 'assets/json-schemas/ocpp/1.6/Authorize.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16RequestCommand.BOOT_NOTIFICATION,
- this.ajv.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16BootNotificationRequest>(
- 'assets/json-schemas/ocpp/1.6/BootNotification.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16RequestCommand.DATA_TRANSFER,
- this.ajv.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16DataTransferRequest>(
- 'assets/json-schemas/ocpp/1.6/DataTransfer.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION,
- this.ajv.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16DiagnosticsStatusNotificationRequest>(
- 'assets/json-schemas/ocpp/1.6/DiagnosticsStatusNotification.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16RequestCommand.FIRMWARE_STATUS_NOTIFICATION,
- this.ajv.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16FirmwareStatusNotificationRequest>(
- 'assets/json-schemas/ocpp/1.6/FirmwareStatusNotification.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16RequestCommand.HEARTBEAT,
- this.ajv.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16HeartbeatRequest>(
- 'assets/json-schemas/ocpp/1.6/Heartbeat.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16RequestCommand.METER_VALUES,
- this.ajv.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16MeterValuesRequest>(
- 'assets/json-schemas/ocpp/1.6/MeterValues.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16RequestCommand.START_TRANSACTION,
- this.ajv.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16StartTransactionRequest>(
- 'assets/json-schemas/ocpp/1.6/StartTransaction.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16RequestCommand.STATUS_NOTIFICATION,
- this.ajv.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16StatusNotificationRequest>(
- 'assets/json-schemas/ocpp/1.6/StatusNotification.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16RequestCommand.STOP_TRANSACTION,
- this.ajv.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16StopTransactionRequest>(
- 'assets/json-schemas/ocpp/1.6/StopTransaction.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- ])
+ this.payloadValidatorFunctions = OCPP16ServiceUtils.createPayloadValidatorMap(
+ OCPP16ServiceUtils.createRequestPayloadConfigs(),
+ OCPP16ServiceUtils.createRequestFactoryOptions(moduleName, 'constructor'),
+ this.ajv
+ )
this.buildRequestPayload = this.buildRequestPayload.bind(this)
}
} from '../../../charging-station/index.js'
import { OCPPError } from '../../../exception/index.js'
import {
- type ChangeConfigurationResponse,
ChargingStationEvents,
ErrorType,
- type GenericResponse,
- type GetConfigurationResponse,
- type GetDiagnosticsResponse,
type JsonType,
OCPP16AuthorizationStatus,
type OCPP16AuthorizeRequest,
type OCPP16AuthorizeResponse,
type OCPP16BootNotificationResponse,
- type OCPP16ChangeAvailabilityResponse,
OCPP16ChargePointStatus,
- type OCPP16ClearChargingProfileResponse,
- type OCPP16DataTransferResponse,
- type OCPP16DiagnosticsStatusNotificationResponse,
- type OCPP16FirmwareStatusNotificationResponse,
- type OCPP16GetCompositeScheduleResponse,
- type OCPP16HeartbeatResponse,
OCPP16IncomingRequestCommand,
type OCPP16MeterValue,
type OCPP16MeterValuesRequest,
type OCPP16MeterValuesResponse,
OCPP16RequestCommand,
- type OCPP16ReserveNowResponse,
OCPP16StandardParametersKey,
type OCPP16StartTransactionRequest,
type OCPP16StartTransactionResponse,
- type OCPP16StatusNotificationResponse,
type OCPP16StopTransactionRequest,
type OCPP16StopTransactionResponse,
- type OCPP16TriggerMessageResponse,
- type OCPP16UpdateFirmwareResponse,
OCPPVersion,
RegistrationStatusEnumType,
ReservationTerminationReason,
type ResponseHandler,
- type SetChargingProfileResponse,
- type UnlockConnectorResponse,
} from '../../../types/index.js'
import { Constants, convertToInt, isAsyncFunction, logger } from '../../../utils/index.js'
import { OCPPResponseService } from '../OCPPResponseService.js'
ValidateFunction<JsonType>
>
- protected payloadValidateFunctions: Map<OCPP16RequestCommand, ValidateFunction<JsonType>>
+ protected payloadValidatorFunctions: Map<OCPP16RequestCommand, ValidateFunction<JsonType>>
private readonly responseHandlers: Map<OCPP16RequestCommand, ResponseHandler>
public constructor () {
this.handleResponseStopTransaction.bind(this) as ResponseHandler,
],
])
- this.payloadValidateFunctions = new Map<OCPP16RequestCommand, ValidateFunction<JsonType>>([
- [
- OCPP16RequestCommand.AUTHORIZE,
- this.ajv.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16AuthorizeResponse>(
- 'assets/json-schemas/ocpp/1.6/AuthorizeResponse.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16RequestCommand.BOOT_NOTIFICATION,
- this.ajv.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16BootNotificationResponse>(
- 'assets/json-schemas/ocpp/1.6/BootNotificationResponse.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16RequestCommand.DATA_TRANSFER,
- this.ajv.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16DataTransferResponse>(
- 'assets/json-schemas/ocpp/1.6/DataTransferResponse.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION,
- this.ajv.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16DiagnosticsStatusNotificationResponse>(
- 'assets/json-schemas/ocpp/1.6/DiagnosticsStatusNotificationResponse.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16RequestCommand.FIRMWARE_STATUS_NOTIFICATION,
- this.ajv.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16FirmwareStatusNotificationResponse>(
- 'assets/json-schemas/ocpp/1.6/FirmwareStatusNotificationResponse.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16RequestCommand.HEARTBEAT,
- this.ajv.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16HeartbeatResponse>(
- 'assets/json-schemas/ocpp/1.6/HeartbeatResponse.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16RequestCommand.METER_VALUES,
- this.ajv.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16MeterValuesResponse>(
- 'assets/json-schemas/ocpp/1.6/MeterValuesResponse.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16RequestCommand.START_TRANSACTION,
- this.ajv.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16StartTransactionResponse>(
- 'assets/json-schemas/ocpp/1.6/StartTransactionResponse.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16RequestCommand.STATUS_NOTIFICATION,
- this.ajv.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16StatusNotificationResponse>(
- 'assets/json-schemas/ocpp/1.6/StatusNotificationResponse.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16RequestCommand.STOP_TRANSACTION,
- this.ajv.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16StopTransactionResponse>(
- 'assets/json-schemas/ocpp/1.6/StopTransactionResponse.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- ])
- this.incomingRequestResponsePayloadValidateFunctions = new Map<
- OCPP16IncomingRequestCommand,
- ValidateFunction<JsonType>
- >([
- [
- OCPP16IncomingRequestCommand.CANCEL_RESERVATION,
- this.ajvIncomingRequest.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<GenericResponse>(
- 'assets/json-schemas/ocpp/1.6/CancelReservationResponse.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16IncomingRequestCommand.CHANGE_AVAILABILITY,
- this.ajvIncomingRequest.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16ChangeAvailabilityResponse>(
- 'assets/json-schemas/ocpp/1.6/ChangeAvailabilityResponse.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16IncomingRequestCommand.CHANGE_CONFIGURATION,
- this.ajvIncomingRequest.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<ChangeConfigurationResponse>(
- 'assets/json-schemas/ocpp/1.6/ChangeConfigurationResponse.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16IncomingRequestCommand.CLEAR_CACHE,
- this.ajvIncomingRequest.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<GenericResponse>(
- 'assets/json-schemas/ocpp/1.6/ClearCacheResponse.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16IncomingRequestCommand.CLEAR_CHARGING_PROFILE,
- this.ajvIncomingRequest.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16ClearChargingProfileResponse>(
- 'assets/json-schemas/ocpp/1.6/ClearChargingProfileResponse.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16IncomingRequestCommand.DATA_TRANSFER,
- this.ajvIncomingRequest.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16DataTransferResponse>(
- 'assets/json-schemas/ocpp/1.6/DataTransferResponse.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16IncomingRequestCommand.GET_COMPOSITE_SCHEDULE,
- this.ajvIncomingRequest.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16GetCompositeScheduleResponse>(
- 'assets/json-schemas/ocpp/1.6/GetCompositeScheduleResponse.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16IncomingRequestCommand.GET_CONFIGURATION,
- this.ajvIncomingRequest.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<GetConfigurationResponse>(
- 'assets/json-schemas/ocpp/1.6/GetConfigurationResponse.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16IncomingRequestCommand.GET_DIAGNOSTICS,
- this.ajvIncomingRequest.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<GetDiagnosticsResponse>(
- 'assets/json-schemas/ocpp/1.6/GetDiagnosticsResponse.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16IncomingRequestCommand.REMOTE_START_TRANSACTION,
- this.ajvIncomingRequest.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<GenericResponse>(
- 'assets/json-schemas/ocpp/1.6/RemoteStartTransactionResponse.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16IncomingRequestCommand.REMOTE_STOP_TRANSACTION,
- this.ajvIncomingRequest.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<GenericResponse>(
- 'assets/json-schemas/ocpp/1.6/RemoteStopTransactionResponse.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16IncomingRequestCommand.RESERVE_NOW,
- this.ajvIncomingRequest.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16ReserveNowResponse>(
- 'assets/json-schemas/ocpp/1.6/ReserveNowResponse.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16IncomingRequestCommand.RESET,
- this.ajvIncomingRequest.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<GenericResponse>(
- 'assets/json-schemas/ocpp/1.6/ResetResponse.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16IncomingRequestCommand.SET_CHARGING_PROFILE,
- this.ajvIncomingRequest.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<SetChargingProfileResponse>(
- 'assets/json-schemas/ocpp/1.6/SetChargingProfileResponse.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16IncomingRequestCommand.TRIGGER_MESSAGE,
- this.ajvIncomingRequest.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16TriggerMessageResponse>(
- 'assets/json-schemas/ocpp/1.6/TriggerMessageResponse.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16IncomingRequestCommand.UNLOCK_CONNECTOR,
- this.ajvIncomingRequest.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<UnlockConnectorResponse>(
- 'assets/json-schemas/ocpp/1.6/UnlockConnectorResponse.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP16IncomingRequestCommand.UPDATE_FIRMWARE,
- this.ajvIncomingRequest.compile(
- OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16UpdateFirmwareResponse>(
- 'assets/json-schemas/ocpp/1.6/UpdateFirmwareResponse.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- ])
+ this.payloadValidatorFunctions = OCPP16ServiceUtils.createPayloadValidatorMap(
+ OCPP16ServiceUtils.createResponsePayloadConfigs(),
+ OCPP16ServiceUtils.createResponseFactoryOptions(moduleName, 'constructor'),
+ this.ajv
+ )
+ this.incomingRequestResponsePayloadValidateFunctions =
+ OCPP16ServiceUtils.createPayloadValidatorMap(
+ OCPP16ServiceUtils.createIncomingRequestResponsePayloadConfigs(),
+ OCPP16ServiceUtils.createIncomingRequestResponseFactoryOptions(moduleName, 'constructor'),
+ this.ajvIncomingRequest
+ )
this.validatePayload = this.validatePayload.bind(this)
}
commandName: OCPP16RequestCommand,
payload: JsonType
): boolean {
- if (this.payloadValidateFunctions.has(commandName)) {
+ if (this.payloadValidatorFunctions.has(commandName)) {
logger.debug(
`${chargingStation.logPrefix()} ${moduleName}.validatePayload: Validating '${commandName}' response payload`
)
type OCPP16ChargingProfile,
type OCPP16ChargingSchedule,
type OCPP16ClearChargingProfileRequest,
- type OCPP16IncomingRequestCommand,
+ OCPP16IncomingRequestCommand,
type OCPP16MeterValue,
OCPP16MeterValueContext,
OCPP16MeterValueUnit,
- type OCPP16RequestCommand,
+ OCPP16RequestCommand,
OCPP16StandardParametersKey,
OCPP16StopTransactionReason,
type OCPP16SupportedFeatureProfiles,
meterValue.sampledValue.push(
OCPP16ServiceUtils.buildSampledValue(
chargingStation.stationInfo?.ocppVersion,
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- sampledValueTemplate!,
+ sampledValueTemplate,
roundTo((meterStart ?? 0) / unitDivider, 4),
OCPP16MeterValueContext.TRANSACTION_BEGIN
)
}
}
+ /**
+ * Factory options for OCPP 1.6 Incoming Request Service
+ * @param moduleName - Name of the OCPP module
+ * @param methodName - Name of the method/command
+ * @returns Factory options object for OCPP 1.6 incoming request validators
+ */
+ public static createIncomingRequestFactoryOptions = (moduleName: string, methodName: string) =>
+ OCPP16ServiceUtils.PayloadValidatorOptions(
+ OCPPVersion.VERSION_16,
+ 'assets/json-schemas/ocpp/1.6',
+ moduleName,
+ methodName
+ )
+
+ /**
+ * OCPP 1.6 Incoming Request Service validator configurations
+ * @returns Array of validator configuration tuples
+ */
+ public static createIncomingRequestPayloadConfigs = (): [
+ OCPP16IncomingRequestCommand,
+ { schemaPath: string }
+ ][] => [
+ [
+ OCPP16IncomingRequestCommand.CANCEL_RESERVATION,
+ OCPP16ServiceUtils.PayloadValidatorConfig('CancelReservation.json'),
+ ],
+ [
+ OCPP16IncomingRequestCommand.CHANGE_AVAILABILITY,
+ OCPP16ServiceUtils.PayloadValidatorConfig('ChangeAvailability.json'),
+ ],
+ [
+ OCPP16IncomingRequestCommand.CHANGE_CONFIGURATION,
+ OCPP16ServiceUtils.PayloadValidatorConfig('ChangeConfiguration.json'),
+ ],
+ [
+ OCPP16IncomingRequestCommand.CLEAR_CACHE,
+ OCPP16ServiceUtils.PayloadValidatorConfig('ClearCache.json'),
+ ],
+ [
+ OCPP16IncomingRequestCommand.CLEAR_CHARGING_PROFILE,
+ OCPP16ServiceUtils.PayloadValidatorConfig('ClearChargingProfile.json'),
+ ],
+ [
+ OCPP16IncomingRequestCommand.DATA_TRANSFER,
+ OCPP16ServiceUtils.PayloadValidatorConfig('DataTransfer.json'),
+ ],
+ [
+ OCPP16IncomingRequestCommand.GET_COMPOSITE_SCHEDULE,
+ OCPP16ServiceUtils.PayloadValidatorConfig('GetCompositeSchedule.json'),
+ ],
+ [
+ OCPP16IncomingRequestCommand.GET_CONFIGURATION,
+ OCPP16ServiceUtils.PayloadValidatorConfig('GetConfiguration.json'),
+ ],
+ [
+ OCPP16IncomingRequestCommand.GET_DIAGNOSTICS,
+ OCPP16ServiceUtils.PayloadValidatorConfig('GetDiagnostics.json'),
+ ],
+ [
+ OCPP16IncomingRequestCommand.REMOTE_START_TRANSACTION,
+ OCPP16ServiceUtils.PayloadValidatorConfig('RemoteStartTransaction.json'),
+ ],
+ [
+ OCPP16IncomingRequestCommand.REMOTE_STOP_TRANSACTION,
+ OCPP16ServiceUtils.PayloadValidatorConfig('RemoteStopTransaction.json'),
+ ],
+ [
+ OCPP16IncomingRequestCommand.RESERVE_NOW,
+ OCPP16ServiceUtils.PayloadValidatorConfig('ReserveNow.json'),
+ ],
+ [OCPP16IncomingRequestCommand.RESET, OCPP16ServiceUtils.PayloadValidatorConfig('Reset.json')],
+ [
+ OCPP16IncomingRequestCommand.SET_CHARGING_PROFILE,
+ OCPP16ServiceUtils.PayloadValidatorConfig('SetChargingProfile.json'),
+ ],
+ [
+ OCPP16IncomingRequestCommand.TRIGGER_MESSAGE,
+ OCPP16ServiceUtils.PayloadValidatorConfig('TriggerMessage.json'),
+ ],
+ [
+ OCPP16IncomingRequestCommand.UNLOCK_CONNECTOR,
+ OCPP16ServiceUtils.PayloadValidatorConfig('UnlockConnector.json'),
+ ],
+ [
+ OCPP16IncomingRequestCommand.UPDATE_FIRMWARE,
+ OCPP16ServiceUtils.PayloadValidatorConfig('UpdateFirmware.json'),
+ ],
+ ]
+
+ /**
+ * Factory options for OCPP 1.6 Incoming Request Response Service
+ * @param moduleName - Name of the OCPP module
+ * @param methodName - Name of the method/command
+ * @returns Factory options object for OCPP 1.6 incoming request response validators
+ */
+ public static createIncomingRequestResponseFactoryOptions = (
+ moduleName: string,
+ methodName: string
+ ) =>
+ OCPP16ServiceUtils.PayloadValidatorOptions(
+ OCPPVersion.VERSION_16,
+ 'assets/json-schemas/ocpp/1.6',
+ moduleName,
+ methodName
+ )
+
+ /**
+ * OCPP 1.6 Incoming Request Response Service validator configurations
+ * @returns Array of validator configuration tuples
+ */
+ public static createIncomingRequestResponsePayloadConfigs = (): [
+ OCPP16IncomingRequestCommand,
+ { schemaPath: string }
+ ][] => [
+ [
+ OCPP16IncomingRequestCommand.CANCEL_RESERVATION,
+ OCPP16ServiceUtils.PayloadValidatorConfig('CancelReservationResponse.json'),
+ ],
+ [
+ OCPP16IncomingRequestCommand.CHANGE_AVAILABILITY,
+ OCPP16ServiceUtils.PayloadValidatorConfig('ChangeAvailabilityResponse.json'),
+ ],
+ [
+ OCPP16IncomingRequestCommand.CHANGE_CONFIGURATION,
+ OCPP16ServiceUtils.PayloadValidatorConfig('ChangeConfigurationResponse.json'),
+ ],
+ [
+ OCPP16IncomingRequestCommand.CLEAR_CACHE,
+ OCPP16ServiceUtils.PayloadValidatorConfig('ClearCacheResponse.json'),
+ ],
+ [
+ OCPP16IncomingRequestCommand.CLEAR_CHARGING_PROFILE,
+ OCPP16ServiceUtils.PayloadValidatorConfig('ClearChargingProfileResponse.json'),
+ ],
+ [
+ OCPP16IncomingRequestCommand.DATA_TRANSFER,
+ OCPP16ServiceUtils.PayloadValidatorConfig('DataTransferResponse.json'),
+ ],
+ [
+ OCPP16IncomingRequestCommand.GET_COMPOSITE_SCHEDULE,
+ OCPP16ServiceUtils.PayloadValidatorConfig('GetCompositeScheduleResponse.json'),
+ ],
+ [
+ OCPP16IncomingRequestCommand.GET_CONFIGURATION,
+ OCPP16ServiceUtils.PayloadValidatorConfig('GetConfigurationResponse.json'),
+ ],
+ [
+ OCPP16IncomingRequestCommand.GET_DIAGNOSTICS,
+ OCPP16ServiceUtils.PayloadValidatorConfig('GetDiagnosticsResponse.json'),
+ ],
+ [
+ OCPP16IncomingRequestCommand.REMOTE_START_TRANSACTION,
+ OCPP16ServiceUtils.PayloadValidatorConfig('RemoteStartTransactionResponse.json'),
+ ],
+ [
+ OCPP16IncomingRequestCommand.REMOTE_STOP_TRANSACTION,
+ OCPP16ServiceUtils.PayloadValidatorConfig('RemoteStopTransactionResponse.json'),
+ ],
+ [
+ OCPP16IncomingRequestCommand.RESERVE_NOW,
+ OCPP16ServiceUtils.PayloadValidatorConfig('ReserveNowResponse.json'),
+ ],
+ [
+ OCPP16IncomingRequestCommand.RESET,
+ OCPP16ServiceUtils.PayloadValidatorConfig('ResetResponse.json'),
+ ],
+ [
+ OCPP16IncomingRequestCommand.SET_CHARGING_PROFILE,
+ OCPP16ServiceUtils.PayloadValidatorConfig('SetChargingProfileResponse.json'),
+ ],
+ [
+ OCPP16IncomingRequestCommand.TRIGGER_MESSAGE,
+ OCPP16ServiceUtils.PayloadValidatorConfig('TriggerMessageResponse.json'),
+ ],
+ [
+ OCPP16IncomingRequestCommand.UNLOCK_CONNECTOR,
+ OCPP16ServiceUtils.PayloadValidatorConfig('UnlockConnectorResponse.json'),
+ ],
+ [
+ OCPP16IncomingRequestCommand.UPDATE_FIRMWARE,
+ OCPP16ServiceUtils.PayloadValidatorConfig('UpdateFirmwareResponse.json'),
+ ],
+ ]
+
+ /**
+ * Factory options for OCPP 1.6 Request Service
+ * @param moduleName - Name of the OCPP module
+ * @param methodName - Name of the method/command
+ * @returns Factory options object for OCPP 1.6 validators
+ */
+ public static createRequestFactoryOptions = (moduleName: string, methodName: string) =>
+ OCPP16ServiceUtils.PayloadValidatorOptions(
+ OCPPVersion.VERSION_16,
+ 'assets/json-schemas/ocpp/1.6',
+ moduleName,
+ methodName
+ )
+
+ /**
+ * OCPP 1.6 Request Service validator configurations
+ * @returns Array of validator configuration tuples
+ */
+ public static createRequestPayloadConfigs = (): [
+ OCPP16RequestCommand,
+ { schemaPath: string }
+ ][] => [
+ [OCPP16RequestCommand.AUTHORIZE, OCPP16ServiceUtils.PayloadValidatorConfig('Authorize.json')],
+ [
+ OCPP16RequestCommand.BOOT_NOTIFICATION,
+ OCPP16ServiceUtils.PayloadValidatorConfig('BootNotification.json'),
+ ],
+ [
+ OCPP16RequestCommand.DATA_TRANSFER,
+ OCPP16ServiceUtils.PayloadValidatorConfig('DataTransfer.json'),
+ ],
+ [
+ OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION,
+ OCPP16ServiceUtils.PayloadValidatorConfig('DiagnosticsStatusNotification.json'),
+ ],
+ [
+ OCPP16RequestCommand.FIRMWARE_STATUS_NOTIFICATION,
+ OCPP16ServiceUtils.PayloadValidatorConfig('FirmwareStatusNotification.json'),
+ ],
+ [OCPP16RequestCommand.HEARTBEAT, OCPP16ServiceUtils.PayloadValidatorConfig('Heartbeat.json')],
+ [
+ OCPP16RequestCommand.METER_VALUES,
+ OCPP16ServiceUtils.PayloadValidatorConfig('MeterValues.json'),
+ ],
+ [
+ OCPP16RequestCommand.START_TRANSACTION,
+ OCPP16ServiceUtils.PayloadValidatorConfig('StartTransaction.json'),
+ ],
+ [
+ OCPP16RequestCommand.STATUS_NOTIFICATION,
+ OCPP16ServiceUtils.PayloadValidatorConfig('StatusNotification.json'),
+ ],
+ [
+ OCPP16RequestCommand.STOP_TRANSACTION,
+ OCPP16ServiceUtils.PayloadValidatorConfig('StopTransaction.json'),
+ ],
+ ]
+
+ /**
+ * Factory options for OCPP 1.6 Response Service
+ * @param moduleName - Name of the OCPP module
+ * @param methodName - Name of the method/command
+ * @returns Factory options object for OCPP 1.6 response validators
+ */
+ public static createResponseFactoryOptions = (moduleName: string, methodName: string) =>
+ OCPP16ServiceUtils.PayloadValidatorOptions(
+ OCPPVersion.VERSION_16,
+ 'assets/json-schemas/ocpp/1.6',
+ moduleName,
+ methodName
+ )
+
+ /**
+ * OCPP 1.6 Response Service validator configurations
+ * @returns Array of validator configuration tuples
+ */
+ public static createResponsePayloadConfigs = (): [
+ OCPP16RequestCommand,
+ { schemaPath: string }
+ ][] => [
+ [
+ OCPP16RequestCommand.AUTHORIZE,
+ OCPP16ServiceUtils.PayloadValidatorConfig('AuthorizeResponse.json'),
+ ],
+ [
+ OCPP16RequestCommand.BOOT_NOTIFICATION,
+ OCPP16ServiceUtils.PayloadValidatorConfig('BootNotificationResponse.json'),
+ ],
+ [
+ OCPP16RequestCommand.DATA_TRANSFER,
+ OCPP16ServiceUtils.PayloadValidatorConfig('DataTransferResponse.json'),
+ ],
+ [
+ OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION,
+ OCPP16ServiceUtils.PayloadValidatorConfig('DiagnosticsStatusNotificationResponse.json'),
+ ],
+ [
+ OCPP16RequestCommand.FIRMWARE_STATUS_NOTIFICATION,
+ OCPP16ServiceUtils.PayloadValidatorConfig('FirmwareStatusNotificationResponse.json'),
+ ],
+ [
+ OCPP16RequestCommand.HEARTBEAT,
+ OCPP16ServiceUtils.PayloadValidatorConfig('HeartbeatResponse.json'),
+ ],
+ [
+ OCPP16RequestCommand.METER_VALUES,
+ OCPP16ServiceUtils.PayloadValidatorConfig('MeterValuesResponse.json'),
+ ],
+ [
+ OCPP16RequestCommand.START_TRANSACTION,
+ OCPP16ServiceUtils.PayloadValidatorConfig('StartTransactionResponse.json'),
+ ],
+ [
+ OCPP16RequestCommand.STATUS_NOTIFICATION,
+ OCPP16ServiceUtils.PayloadValidatorConfig('StatusNotificationResponse.json'),
+ ],
+ [
+ OCPP16RequestCommand.STOP_TRANSACTION,
+ OCPP16ServiceUtils.PayloadValidatorConfig('StopTransactionResponse.json'),
+ ],
+ ]
+
public static hasReservation = (
chargingStation: ChargingStation,
connectorId: number,
moduleName?: string,
methodName?: string
): JSONSchemaType<T> {
- return OCPPServiceUtils.parseJsonSchemaFile<T>(
+ return OCPP16ServiceUtils.parseJsonSchemaFile<T>(
relativePath,
OCPPVersion.VERSION_16,
moduleName,
GetVariableStatusEnumType,
type IncomingRequestHandler,
type JsonType,
- type OCPP20ClearCacheRequest,
OCPP20ComponentName,
OCPP20ConnectorStatusEnumType,
OCPP20DeviceInfoVariableName,
const moduleName = 'OCPP20IncomingRequestService'
export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
- protected payloadValidateFunctions: Map<OCPP20IncomingRequestCommand, ValidateFunction<JsonType>>
+ protected payloadValidatorFunctions: Map<OCPP20IncomingRequestCommand, ValidateFunction<JsonType>>
private readonly incomingRequestHandlers: Map<
OCPP20IncomingRequestCommand,
this.handleRequestSetVariables.bind(this) as unknown as IncomingRequestHandler,
],
])
- this.payloadValidateFunctions = new Map<
- OCPP20IncomingRequestCommand,
- ValidateFunction<JsonType>
- >([
- [
- OCPP20IncomingRequestCommand.CLEAR_CACHE,
- this.ajv.compile(
- OCPP20ServiceUtils.parseJsonSchemaFile<OCPP20ClearCacheRequest>(
- 'assets/json-schemas/ocpp/2.0/ClearCacheRequest.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP20IncomingRequestCommand.GET_BASE_REPORT,
- this.ajv.compile(
- OCPP20ServiceUtils.parseJsonSchemaFile<OCPP20GetBaseReportRequest>(
- 'assets/json-schemas/ocpp/2.0/GetBaseReportRequest.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP20IncomingRequestCommand.GET_VARIABLES,
- this.ajv.compile(
- OCPP20ServiceUtils.parseJsonSchemaFile<OCPP20GetVariablesRequest>(
- 'assets/json-schemas/ocpp/2.0/GetVariablesRequest.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP20IncomingRequestCommand.REQUEST_STOP_TRANSACTION,
- this.ajv.compile(
- OCPP20ServiceUtils.parseJsonSchemaFile<OCPP20RequestStopTransactionRequest>(
- 'assets/json-schemas/ocpp/2.0/RequestStopTransactionRequest.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP20IncomingRequestCommand.RESET,
- this.ajv.compile(
- OCPP20ServiceUtils.parseJsonSchemaFile<OCPP20ResetRequest>(
- 'assets/json-schemas/ocpp/2.0/ResetRequest.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP20IncomingRequestCommand.SET_VARIABLES,
- this.ajv.compile(
- OCPP20ServiceUtils.parseJsonSchemaFile<OCPP20SetVariablesRequest>(
- 'assets/json-schemas/ocpp/2.0/SetVariablesRequest.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- ])
+ this.payloadValidatorFunctions = OCPP20ServiceUtils.createPayloadValidatorMap(
+ OCPP20ServiceUtils.createIncomingRequestPayloadConfigs(),
+ OCPP20ServiceUtils.createIncomingRequestFactoryOptions(moduleName, 'constructor'),
+ this.ajv
+ )
// Handle incoming request events
this.on(
OCPP20IncomingRequestCommand.GET_BASE_REPORT,
commandName: OCPP20IncomingRequestCommand,
commandPayload: JsonType
): boolean {
- if (this.payloadValidateFunctions.has(commandName)) {
+ if (this.payloadValidatorFunctions.has(commandName)) {
return this.validateIncomingRequestPayload(chargingStation, commandName, commandPayload)
}
logger.warn(
ErrorType,
type JsonObject,
type JsonType,
- type OCPP20BootNotificationRequest,
- type OCPP20HeartbeatRequest,
- type OCPP20NotifyReportRequest,
OCPP20RequestCommand,
- type OCPP20StatusNotificationRequest,
OCPPVersion,
type RequestParams,
} from '../../../types/index.js'
const moduleName = 'OCPP20RequestService'
export class OCPP20RequestService extends OCPPRequestService {
- protected payloadValidateFunctions: Map<OCPP20RequestCommand, ValidateFunction<JsonType>>
+ protected payloadValidatorFunctions: Map<OCPP20RequestCommand, ValidateFunction<JsonType>>
public constructor (ocppResponseService: OCPPResponseService) {
// if (new.target.name === moduleName) {
// throw new TypeError(`Cannot construct ${new.target.name} instances directly`)
// }
super(OCPPVersion.VERSION_201, ocppResponseService)
- this.payloadValidateFunctions = new Map<OCPP20RequestCommand, ValidateFunction<JsonType>>([
- [
- OCPP20RequestCommand.BOOT_NOTIFICATION,
- this.ajv.compile(
- OCPP20ServiceUtils.parseJsonSchemaFile<OCPP20BootNotificationRequest>(
- 'assets/json-schemas/ocpp/2.0/BootNotificationRequest.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP20RequestCommand.HEARTBEAT,
- this.ajv.compile(
- OCPP20ServiceUtils.parseJsonSchemaFile<OCPP20HeartbeatRequest>(
- 'assets/json-schemas/ocpp/2.0/HeartbeatRequest.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP20RequestCommand.NOTIFY_REPORT,
- this.ajv.compile(
- OCPP20ServiceUtils.parseJsonSchemaFile<OCPP20NotifyReportRequest>(
- 'assets/json-schemas/ocpp/2.0/NotifyReportRequest.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP20RequestCommand.STATUS_NOTIFICATION,
- this.ajv.compile(
- OCPP20ServiceUtils.parseJsonSchemaFile<OCPP20StatusNotificationRequest>(
- 'assets/json-schemas/ocpp/2.0/StatusNotificationRequest.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- ])
+ this.payloadValidatorFunctions = OCPP20ServiceUtils.createPayloadValidatorMap(
+ OCPP20ServiceUtils.createRequestPayloadConfigs(),
+ OCPP20ServiceUtils.createRequestFactoryOptions(moduleName, 'constructor'),
+ this.ajv
+ )
this.buildRequestPayload = this.buildRequestPayload.bind(this)
}
ErrorType,
type JsonType,
type OCPP20BootNotificationResponse,
- type OCPP20ClearCacheResponse,
- type OCPP20GetBaseReportResponse,
type OCPP20HeartbeatResponse,
OCPP20IncomingRequestCommand,
type OCPP20NotifyReportResponse,
OCPP20OptionalVariableName,
OCPP20RequestCommand,
- type OCPP20RequestStartTransactionResponse,
- type OCPP20RequestStopTransactionResponse,
type OCPP20StatusNotificationResponse,
OCPPVersion,
RegistrationStatusEnumType,
ValidateFunction<JsonType>
>
- protected payloadValidateFunctions: Map<OCPP20RequestCommand, ValidateFunction<JsonType>>
+ protected payloadValidatorFunctions: Map<OCPP20RequestCommand, ValidateFunction<JsonType>>
private readonly responseHandlers: Map<OCPP20RequestCommand, ResponseHandler>
public constructor () {
this.handleResponseStatusNotification.bind(this) as ResponseHandler,
],
])
- this.payloadValidateFunctions = new Map<OCPP20RequestCommand, ValidateFunction<JsonType>>([
- [
- OCPP20RequestCommand.BOOT_NOTIFICATION,
- this.ajv.compile(
- OCPP20ServiceUtils.parseJsonSchemaFile<OCPP20BootNotificationResponse>(
- 'assets/json-schemas/ocpp/2.0/BootNotificationResponse.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP20RequestCommand.HEARTBEAT,
- this.ajv.compile(
- OCPP20ServiceUtils.parseJsonSchemaFile<OCPP20HeartbeatResponse>(
- 'assets/json-schemas/ocpp/2.0/HeartbeatResponse.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP20RequestCommand.NOTIFY_REPORT,
- this.ajv.compile(
- OCPP20ServiceUtils.parseJsonSchemaFile<OCPP20NotifyReportResponse>(
- 'assets/json-schemas/ocpp/2.0/NotifyReportResponse.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP20RequestCommand.STATUS_NOTIFICATION,
- this.ajv.compile(
- OCPP20ServiceUtils.parseJsonSchemaFile<OCPP20StatusNotificationResponse>(
- 'assets/json-schemas/ocpp/2.0/StatusNotificationResponse.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- ])
- this.incomingRequestResponsePayloadValidateFunctions = new Map<
- OCPP20IncomingRequestCommand,
- ValidateFunction<JsonType>
- >([
- [
- OCPP20IncomingRequestCommand.CLEAR_CACHE,
- this.ajvIncomingRequest.compile(
- OCPP20ServiceUtils.parseJsonSchemaFile<OCPP20ClearCacheResponse>(
- 'assets/json-schemas/ocpp/2.0/ClearCacheResponse.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP20IncomingRequestCommand.GET_BASE_REPORT,
- this.ajvIncomingRequest.compile(
- OCPP20ServiceUtils.parseJsonSchemaFile<OCPP20GetBaseReportResponse>(
- 'assets/json-schemas/ocpp/2.0/GetBaseReportResponse.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP20IncomingRequestCommand.REQUEST_START_TRANSACTION,
- this.ajvIncomingRequest.compile(
- OCPP20ServiceUtils.parseJsonSchemaFile<OCPP20RequestStartTransactionResponse>(
- 'assets/json-schemas/ocpp/2.0/RequestStartTransactionResponse.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- [
- OCPP20IncomingRequestCommand.REQUEST_STOP_TRANSACTION,
- this.ajvIncomingRequest.compile(
- OCPP20ServiceUtils.parseJsonSchemaFile<OCPP20RequestStopTransactionResponse>(
- 'assets/json-schemas/ocpp/2.0/RequestStopTransactionResponse.json',
- moduleName,
- 'constructor'
- )
- ),
- ],
- ])
+ this.payloadValidatorFunctions = OCPP20ServiceUtils.createPayloadValidatorMap(
+ OCPP20ServiceUtils.createResponsePayloadConfigs(),
+ OCPP20ServiceUtils.createResponseFactoryOptions(moduleName, 'constructor'),
+ this.ajv
+ )
+ this.incomingRequestResponsePayloadValidateFunctions =
+ OCPP20ServiceUtils.createPayloadValidatorMap(
+ OCPP20ServiceUtils.createIncomingRequestResponsePayloadConfigs(),
+ OCPP20ServiceUtils.createIncomingRequestResponseFactoryOptions(moduleName, 'constructor'),
+ this.ajvIncomingRequest
+ )
this.validatePayload = this.validatePayload.bind(this)
}
commandName: OCPP20RequestCommand,
payload: JsonType
): boolean {
- if (this.payloadValidateFunctions.has(commandName)) {
+ if (this.payloadValidatorFunctions.has(commandName)) {
logger.debug(
`${chargingStation.logPrefix()} ${moduleName}.validatePayload: Validating '${commandName}' response payload`
)
ConnectorStatusEnum,
type GenericResponse,
type JsonType,
+ OCPP20IncomingRequestCommand,
OCPP20RequestCommand,
OCPP20TransactionEventEnumType,
type OCPP20TransactionEventRequest,
import { OCPP20Constants } from './OCPP20Constants.js'
export class OCPP20ServiceUtils extends OCPPServiceUtils {
+ /**
+ * Factory options for OCPP 2.0 Incoming Request Service
+ * @param moduleName - Name of the OCPP module
+ * @param methodName - Name of the method/command
+ * @returns Factory options object for OCPP 2.0 incoming request validators
+ */
+ public static createIncomingRequestFactoryOptions = (moduleName: string, methodName: string) =>
+ OCPP20ServiceUtils.PayloadValidatorOptions(
+ OCPPVersion.VERSION_201,
+ 'assets/json-schemas/ocpp/2.0',
+ moduleName,
+ methodName
+ )
+
+ /**
+ * OCPP 2.0 Incoming Request Service validator configurations
+ * @returns Array of validator configuration tuples
+ */
+ public static createIncomingRequestPayloadConfigs = (): [
+ OCPP20IncomingRequestCommand,
+ { schemaPath: string }
+ ][] => [
+ [
+ OCPP20IncomingRequestCommand.CLEAR_CACHE,
+ OCPP20ServiceUtils.PayloadValidatorConfig('ClearCacheRequest.json'),
+ ],
+ [
+ OCPP20IncomingRequestCommand.GET_BASE_REPORT,
+ OCPP20ServiceUtils.PayloadValidatorConfig('GetBaseReportRequest.json'),
+ ],
+ [
+ OCPP20IncomingRequestCommand.GET_VARIABLES,
+ OCPP20ServiceUtils.PayloadValidatorConfig('GetVariablesRequest.json'),
+ ],
+ [
+ OCPP20IncomingRequestCommand.REQUEST_START_TRANSACTION,
+ OCPP20ServiceUtils.PayloadValidatorConfig('RequestStartTransactionRequest.json'),
+ ],
+ [
+ OCPP20IncomingRequestCommand.REQUEST_STOP_TRANSACTION,
+ OCPP20ServiceUtils.PayloadValidatorConfig('RequestStopTransactionRequest.json'),
+ ],
+ [
+ OCPP20IncomingRequestCommand.RESET,
+ OCPP20ServiceUtils.PayloadValidatorConfig('ResetRequest.json'),
+ ],
+ [
+ OCPP20IncomingRequestCommand.SET_VARIABLES,
+ OCPP20ServiceUtils.PayloadValidatorConfig('SetVariablesRequest.json'),
+ ],
+ ]
+
+ /**
+ * Factory options for OCPP 2.0 Incoming Request Response Service
+ * @param moduleName - Name of the OCPP module
+ * @param methodName - Name of the method/command
+ * @returns Factory options object for OCPP 2.0 incoming request response validators
+ */
+ public static createIncomingRequestResponseFactoryOptions = (
+ moduleName: string,
+ methodName: string
+ ) =>
+ OCPP20ServiceUtils.PayloadValidatorOptions(
+ OCPPVersion.VERSION_201,
+ 'assets/json-schemas/ocpp/2.0',
+ moduleName,
+ methodName
+ )
+
+ /**
+ * Configuration for OCPP 2.0 Incoming Request Response validators
+ * @returns Array of validator configuration tuples
+ */
+ public static createIncomingRequestResponsePayloadConfigs = (): [
+ OCPP20IncomingRequestCommand,
+ { schemaPath: string }
+ ][] => [
+ [
+ OCPP20IncomingRequestCommand.CLEAR_CACHE,
+ OCPP20ServiceUtils.PayloadValidatorConfig('ClearCacheResponse.json'),
+ ],
+ [
+ OCPP20IncomingRequestCommand.GET_BASE_REPORT,
+ OCPP20ServiceUtils.PayloadValidatorConfig('GetBaseReportResponse.json'),
+ ],
+ [
+ OCPP20IncomingRequestCommand.REQUEST_START_TRANSACTION,
+ OCPP20ServiceUtils.PayloadValidatorConfig('RequestStartTransactionResponse.json'),
+ ],
+ [
+ OCPP20IncomingRequestCommand.REQUEST_STOP_TRANSACTION,
+ OCPP20ServiceUtils.PayloadValidatorConfig('RequestStopTransactionResponse.json'),
+ ],
+ ]
+
+ /**
+ * Factory options for OCPP 2.0 Request Service
+ * @param moduleName - Name of the OCPP module
+ * @param methodName - Name of the method/command
+ * @returns Factory options object for OCPP 2.0 validators
+ */
+ public static createRequestFactoryOptions = (moduleName: string, methodName: string) =>
+ OCPP20ServiceUtils.PayloadValidatorOptions(
+ OCPPVersion.VERSION_201,
+ 'assets/json-schemas/ocpp/2.0',
+ moduleName,
+ methodName
+ )
+
+ /**
+ * OCPP 2.0 Request Service validator configurations
+ * @returns Array of validator configuration tuples
+ */
+ public static createRequestPayloadConfigs = (): [
+ OCPP20RequestCommand,
+ { schemaPath: string }
+ ][] => [
+ [
+ OCPP20RequestCommand.BOOT_NOTIFICATION,
+ OCPP20ServiceUtils.PayloadValidatorConfig('BootNotificationRequest.json'),
+ ],
+ [
+ OCPP20RequestCommand.HEARTBEAT,
+ OCPP20ServiceUtils.PayloadValidatorConfig('HeartbeatRequest.json'),
+ ],
+ [
+ OCPP20RequestCommand.NOTIFY_REPORT,
+ OCPP20ServiceUtils.PayloadValidatorConfig('NotifyReportRequest.json'),
+ ],
+ [
+ OCPP20RequestCommand.STATUS_NOTIFICATION,
+ OCPP20ServiceUtils.PayloadValidatorConfig('StatusNotificationRequest.json'),
+ ],
+ ]
+
+ /**
+ * Factory options for OCPP 2.0 Response Service
+ * @param moduleName - Name of the OCPP module
+ * @param methodName - Name of the method/command
+ * @returns Factory options object for OCPP 2.0 response validators
+ */
+ public static createResponseFactoryOptions = (moduleName: string, methodName: string) =>
+ OCPP20ServiceUtils.PayloadValidatorOptions(
+ OCPPVersion.VERSION_201,
+ 'assets/json-schemas/ocpp/2.0',
+ moduleName,
+ methodName
+ )
+
+ /**
+ * OCPP 2.0 Response Service validator configurations
+ * @returns Array of validator configuration tuples
+ */
+ public static createResponsePayloadConfigs = (): [
+ OCPP20RequestCommand,
+ { schemaPath: string }
+ ][] => [
+ [
+ OCPP20RequestCommand.BOOT_NOTIFICATION,
+ OCPP20ServiceUtils.PayloadValidatorConfig('BootNotificationResponse.json'),
+ ],
+ [
+ OCPP20RequestCommand.HEARTBEAT,
+ OCPP20ServiceUtils.PayloadValidatorConfig('HeartbeatResponse.json'),
+ ],
+ [
+ OCPP20RequestCommand.NOTIFY_REPORT,
+ OCPP20ServiceUtils.PayloadValidatorConfig('NotifyReportResponse.json'),
+ ],
+ [
+ OCPP20RequestCommand.STATUS_NOTIFICATION,
+ OCPP20ServiceUtils.PayloadValidatorConfig('StatusNotificationResponse.json'),
+ ],
+ ]
+
public static enforceMessageLimits<
T extends { attributeType?: unknown; component: unknown; variable: unknown }
>(
moduleName?: string,
methodName?: string
): JSONSchemaType<T> {
- return OCPPServiceUtils.parseJsonSchemaFile<T>(
+ return OCPP20ServiceUtils.parseJsonSchemaFile<T>(
relativePath,
OCPPVersion.VERSION_201,
moduleName,
export abstract class OCPPIncomingRequestService extends EventEmitter {
private static instance: null | OCPPIncomingRequestService = null
protected readonly ajv: Ajv
- protected abstract payloadValidateFunctions: Map<
+ protected abstract payloadValidatorFunctions: Map<
IncomingRequestCommand,
ValidateFunction<JsonType>
>
if (chargingStation.stationInfo?.ocppStrictCompliance === false) {
return true
}
- const validate = this.payloadValidateFunctions.get(commandName)
+ const validate = this.payloadValidatorFunctions.get(commandName)
if (validate?.(payload) === true) {
return true
}
export abstract class OCPPRequestService {
private static instance: null | OCPPRequestService = null
protected readonly ajv: Ajv
- protected abstract payloadValidateFunctions: Map<RequestCommand, ValidateFunction<JsonType>>
+ protected abstract payloadValidatorFunctions: Map<RequestCommand, ValidateFunction<JsonType>>
private readonly ocppResponseService: OCPPResponseService
private readonly version: OCPPVersion
if (chargingStation.stationInfo?.ocppStrictCompliance === false) {
return true
}
- if (!this.payloadValidateFunctions.has(commandName as RequestCommand)) {
+ if (!this.payloadValidatorFunctions.has(commandName as RequestCommand)) {
logger.warn(
`${chargingStation.logPrefix()} ${moduleName}.validateRequestPayload: No JSON schema found for command '${commandName}' PDU validation`
)
return true
}
- const validate = this.payloadValidateFunctions.get(commandName as RequestCommand)
+ const validate = this.payloadValidatorFunctions.get(commandName as RequestCommand)
payload = clone<T>(payload)
convertDateToISOString<T>(payload)
if (validate?.(payload) === true) {
protected readonly ajv: Ajv
protected readonly ajvIncomingRequest: Ajv
protected emptyResponseHandler = Constants.EMPTY_FUNCTION
- protected abstract payloadValidateFunctions: Map<RequestCommand, ValidateFunction<JsonType>>
+ protected abstract payloadValidatorFunctions: Map<RequestCommand, ValidateFunction<JsonType>>
private readonly version: OCPPVersion
protected constructor (version: OCPPVersion) {
if (chargingStation.stationInfo?.ocppStrictCompliance === false) {
return true
}
- const validate = this.payloadValidateFunctions.get(commandName)
+ const validate = this.payloadValidatorFunctions.get(commandName)
if (validate?.(payload) === true) {
return true
}
-import type { ErrorObject, JSONSchemaType } from 'ajv'
-
+import _Ajv, { type ErrorObject, type JSONSchemaType, type ValidateFunction } from 'ajv'
import { isDate } from 'date-fns'
import { randomInt } from 'node:crypto'
import { readFileSync } from 'node:fs'
import { OCPP20Constants } from './2.0/OCPP20Constants.js'
import { OCPPConstants } from './OCPPConstants.js'
+type Ajv = _Ajv.default
+// eslint-disable-next-line @typescript-eslint/no-redeclare
+const Ajv = _Ajv.default
+
interface MultiPhaseMeasurandData {
perPhaseTemplates: MeasurandPerPhaseSampledValueTemplates
template: SampledValueTemplate
const voltageSampledValueTemplateValue = isNotEmptyString(voltageSampledValueTemplate.value)
? Number.parseInt(voltageSampledValueTemplate.value)
- : // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- chargingStation.stationInfo.voltageOut!
+ : chargingStation.getVoltageOut()
const fluctuationPercent =
voltageSampledValueTemplate.fluctuationPercent ?? Constants.DEFAULT_FLUCTUATION_PERCENT
const voltageMeasurandValue = getRandomFloatFluctuatedRounded(
if (
chargingStation.getNumberOfPhases() !== 3 ||
(chargingStation.getNumberOfPhases() === 3 &&
- chargingStation.stationInfo.mainVoltageMeterValues === true)
+ chargingStation.stationInfo?.mainVoltageMeterValues === true)
) {
meterValue.sampledValue.push(
buildSampledValue(
voltagePhaseLineToNeutralSampledValueTemplate.value
)
? Number.parseInt(voltagePhaseLineToNeutralSampledValueTemplate.value)
- : // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- chargingStation.stationInfo.voltageOut!
+ : chargingStation.getVoltageOut()
const fluctuationPhaseToNeutralPercent =
voltagePhaseLineToNeutralSampledValueTemplate.fluctuationPercent ??
Constants.DEFAULT_FLUCTUATION_PERCENT
: chargingStation.getNumberOfPhases().toString()
}` as MeterValuePhase
const voltagePhaseLineToLineValueRounded = roundTo(
- Math.sqrt(chargingStation.getNumberOfPhases()) *
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- chargingStation.stationInfo.voltageOut!,
+ Math.sqrt(chargingStation.getNumberOfPhases()) * chargingStation.getVoltageOut(),
2
)
const voltagePhaseLineToLineSampledValueTemplate = getSampledValueTemplate(
connectorMaximumAmperage = ACElectricUtils.amperagePerPhaseFromPower(
chargingStation.getNumberOfPhases(),
connectorMaximumAvailablePower,
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- chargingStation.stationInfo.voltageOut!
+ chargingStation.getVoltageOut()
)
if (chargingStation.getNumberOfPhases() === 3) {
const defaultFluctuatedAmperagePerPhase = isNotEmptyString(currentTemplate.value)
case CurrentType.DC:
connectorMaximumAmperage = DCElectricUtils.amperage(
connectorMaximumAvailablePower,
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- chargingStation.stationInfo.voltageOut!
+ chargingStation.getVoltageOut()
)
currentValues.allPhases = isNotEmptyString(currentTemplate.value)
? getRandomFloatFluctuatedRounded(
? ACElectricUtils.amperagePerPhaseFromPower(
chargingStation.getNumberOfPhases(),
connectorMaximumAvailablePower,
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- chargingStation.stationInfo.voltageOut!
+ chargingStation.getVoltageOut()
)
: DCElectricUtils.amperage(
connectorMaximumAvailablePower,
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- chargingStation.stationInfo.voltageOut!
+ chargingStation.getVoltageOut()
)
const connectorMinimumAmperage = currentMeasurand.template.minimumValue ?? 0
)
}
-function buildSampledValue (
- ocppVersion: OCPPVersion.VERSION_16 | undefined,
- sampledValueTemplate: SampledValueTemplate,
- value: number,
- context?: MeterValueContext,
- phase?: MeterValuePhase
-): OCPP16SampledValue
-function buildSampledValue (
- ocppVersion: OCPPVersion.VERSION_20 | OCPPVersion.VERSION_201 | undefined,
- sampledValueTemplate: SampledValueTemplate,
- value: number,
- context?: MeterValueContext,
- phase?: MeterValuePhase
-): OCPP20SampledValue
/**
* Builds a sampled value object according to the specified OCPP version
* @param ocppVersion - The OCPP version to use for formatting the sampled value
// This is intentional
}
+ /**
+ * Creates a Map of compiled OCPP payload validators from configurations
+ * Reduces code duplication across OCPP services
+ * @param configs - Array of tuples containing command and validator configuration
+ * @param options - Factory options including OCPP version, schema directory, etc.
+ * @param options.ocppVersion - The OCPP version for schema validation
+ * @param options.schemaDir - Directory path containing JSON schemas
+ * @param options.moduleName - Name of the module for logging
+ * @param options.methodName - Name of the method for logging
+ * @param ajvInstance - Configured Ajv instance for validation
+ * @returns Map of commands to their compiled validation functions
+ */
+ public static createPayloadValidatorMap<Command extends JsonType>(
+ configs: [Command, { schemaPath: string }][],
+ options: {
+ methodName: string
+ moduleName: string
+ ocppVersion: OCPPVersion
+ schemaDir: string
+ },
+ ajvInstance: Ajv
+ ): Map<Command, ValidateFunction<JsonType>> {
+ return new Map<Command, ValidateFunction<JsonType>>(
+ configs.map(([command, config]) => {
+ const fullSchemaPath = `${options.schemaDir}/${config.schemaPath}`
+ const schema = OCPPServiceUtils.parseJsonSchemaFile<JsonType>(
+ fullSchemaPath,
+ options.ocppVersion,
+ options.moduleName,
+ options.methodName
+ )
+ return [command, ajvInstance.compile(schema)]
+ })
+ )
+ }
+
public static isConnectorIdValid (
chargingStation: ChargingStation,
ocppCommand: IncomingRequestCommand,
return false
}
+ /**
+ * Configuration for a single payload validator
+ * @param schemaPath - Path to the JSON schema file
+ * @returns Configuration object for payload validator creation
+ */
+ public static readonly PayloadValidatorConfig = (schemaPath: string) =>
+ ({
+ schemaPath,
+ }) as const
+
+ /**
+ * Options for payload validator creation
+ * @param ocppVersion - The OCPP version
+ * @param schemaDir - Directory containing JSON schemas
+ * @param moduleName - Name of the OCPP module
+ * @param methodName - Name of the method/command
+ * @returns Options object for payload validator creation
+ */
+ public static readonly PayloadValidatorOptions = (
+ ocppVersion: OCPPVersion,
+ schemaDir: string,
+ moduleName: string,
+ methodName: string
+ ) =>
+ ({
+ methodName,
+ moduleName,
+ ocppVersion,
+ schemaDir,
+ }) as const
+
protected static parseJsonSchemaFile<T extends JsonType>(
relativePath: string,
ocppVersion: OCPPVersion,