const moduleName = 'OCPP16IncomingRequestService'
export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
- protected jsonSchemasValidateFunction: Map<
- OCPP16IncomingRequestCommand,
- ValidateFunction<JsonType>
- >
+ protected payloadValidateFunctions: Map<OCPP16IncomingRequestCommand, ValidateFunction<JsonType>>
private readonly incomingRequestHandlers: Map<
OCPP16IncomingRequestCommand,
this.handleRequestCancelReservation.bind(this) as unknown as IncomingRequestHandler
]
])
- this.jsonSchemasValidateFunction = new Map<
+ this.payloadValidateFunctions = new Map<
OCPP16IncomingRequestCommand,
ValidateFunction<JsonType>
>([
commandName: OCPP16IncomingRequestCommand,
commandPayload: JsonType
): boolean {
- if (this.jsonSchemasValidateFunction.has(commandName)) {
+ if (this.payloadValidateFunctions.has(commandName)) {
return this.validateIncomingRequestPayload(chargingStation, commandName, commandPayload)
}
logger.warn(
const moduleName = 'OCPP16RequestService'
export class OCPP16RequestService extends OCPPRequestService {
- protected jsonSchemasValidateFunction: Map<OCPP16RequestCommand, ValidateFunction<JsonType>>
+ protected payloadValidateFunctions: 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.jsonSchemasValidateFunction = new Map<OCPP16RequestCommand, ValidateFunction<JsonType>>([
+ this.payloadValidateFunctions = new Map<OCPP16RequestCommand, ValidateFunction<JsonType>>([
[
OCPP16RequestCommand.AUTHORIZE,
this.ajv
const moduleName = 'OCPP16ResponseService'
export class OCPP16ResponseService extends OCPPResponseService {
- public jsonSchemasIncomingRequestResponseValidateFunction: Map<
+ public incomingRequestResponsePayloadValidateFunctions: Map<
OCPP16IncomingRequestCommand,
ValidateFunction<JsonType>
>
- protected jsonSchemasValidateFunction: Map<OCPP16RequestCommand, ValidateFunction<JsonType>>
+ protected payloadValidateFunctions: Map<OCPP16RequestCommand, ValidateFunction<JsonType>>
private readonly responseHandlers: Map<OCPP16RequestCommand, ResponseHandler>
public constructor () {
[OCPP16RequestCommand.DATA_TRANSFER, this.emptyResponseHandler],
[OCPP16RequestCommand.FIRMWARE_STATUS_NOTIFICATION, this.emptyResponseHandler]
])
- this.jsonSchemasValidateFunction = new Map<OCPP16RequestCommand, ValidateFunction<JsonType>>([
+ this.payloadValidateFunctions = new Map<OCPP16RequestCommand, ValidateFunction<JsonType>>([
[
OCPP16RequestCommand.BOOT_NOTIFICATION,
this.ajv
.bind(this)
]
])
- this.jsonSchemasIncomingRequestResponseValidateFunction = new Map<
+ this.incomingRequestResponsePayloadValidateFunctions = new Map<
OCPP16IncomingRequestCommand,
ValidateFunction<JsonType>
>([
commandName: OCPP16RequestCommand,
payload: JsonType
): boolean {
- if (this.jsonSchemasValidateFunction.has(commandName)) {
+ if (this.payloadValidateFunctions.has(commandName)) {
return this.validateResponsePayload(chargingStation, commandName, payload)
}
logger.warn(
const moduleName = 'OCPP20IncomingRequestService'
export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
- protected jsonSchemasValidateFunction: Map<
- OCPP20IncomingRequestCommand,
- ValidateFunction<JsonType>
- >
+ protected payloadValidateFunctions: Map<OCPP20IncomingRequestCommand, ValidateFunction<JsonType>>
private readonly incomingRequestHandlers: Map<
OCPP20IncomingRequestCommand,
this.incomingRequestHandlers = new Map<OCPP20IncomingRequestCommand, IncomingRequestHandler>([
[OCPP20IncomingRequestCommand.CLEAR_CACHE, this.handleRequestClearCache.bind(this)]
])
- this.jsonSchemasValidateFunction = new Map<
+ this.payloadValidateFunctions = new Map<
OCPP20IncomingRequestCommand,
ValidateFunction<JsonType>
>([
commandName: OCPP20IncomingRequestCommand,
commandPayload: JsonType
): boolean {
- if (this.jsonSchemasValidateFunction.has(commandName)) {
+ if (this.payloadValidateFunctions.has(commandName)) {
return this.validateIncomingRequestPayload(chargingStation, commandName, commandPayload)
}
logger.warn(
const moduleName = 'OCPP20RequestService'
export class OCPP20RequestService extends OCPPRequestService {
- protected jsonSchemasValidateFunction: Map<OCPP20RequestCommand, ValidateFunction<JsonType>>
+ protected payloadValidateFunctions: 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_20, ocppResponseService)
- this.jsonSchemasValidateFunction = new Map<OCPP20RequestCommand, ValidateFunction<JsonType>>([
+ this.payloadValidateFunctions = new Map<OCPP20RequestCommand, ValidateFunction<JsonType>>([
[
OCPP20RequestCommand.BOOT_NOTIFICATION,
this.ajv
const moduleName = 'OCPP20ResponseService'
export class OCPP20ResponseService extends OCPPResponseService {
- public jsonSchemasIncomingRequestResponseValidateFunction: Map<
+ public incomingRequestResponsePayloadValidateFunctions: Map<
OCPP20IncomingRequestCommand,
ValidateFunction<JsonType>
>
- protected jsonSchemasValidateFunction: Map<OCPP20RequestCommand, ValidateFunction<JsonType>>
+ protected payloadValidateFunctions: Map<OCPP20RequestCommand, ValidateFunction<JsonType>>
private readonly responseHandlers: Map<OCPP20RequestCommand, ResponseHandler>
public constructor () {
[OCPP20RequestCommand.HEARTBEAT, this.emptyResponseHandler],
[OCPP20RequestCommand.STATUS_NOTIFICATION, this.emptyResponseHandler]
])
- this.jsonSchemasValidateFunction = new Map<OCPP20RequestCommand, ValidateFunction<JsonType>>([
+ this.payloadValidateFunctions = new Map<OCPP20RequestCommand, ValidateFunction<JsonType>>([
[
OCPP20RequestCommand.BOOT_NOTIFICATION,
this.ajv
.bind(this)
]
])
- this.jsonSchemasIncomingRequestResponseValidateFunction = new Map<
+ this.incomingRequestResponsePayloadValidateFunctions = new Map<
OCPP20IncomingRequestCommand,
ValidateFunction<JsonType>
>([
commandName: OCPP20RequestCommand,
payload: JsonType
): boolean {
- if (this.jsonSchemasValidateFunction.has(commandName)) {
+ if (this.payloadValidateFunctions.has(commandName)) {
return this.validateResponsePayload(chargingStation, commandName, payload)
}
logger.warn(
private static instance: OCPPIncomingRequestService | null = null
private readonly version: OCPPVersion
protected readonly ajv: Ajv
- protected abstract jsonSchemasValidateFunction: Map<
+ protected abstract payloadValidateFunctions: Map<
IncomingRequestCommand,
ValidateFunction<JsonType>
>
if (chargingStation.stationInfo?.ocppStrictCompliance === false) {
return true
}
- const validate = this.jsonSchemasValidateFunction.get(commandName)
+ const validate = this.payloadValidateFunctions.get(commandName)
if (validate?.(payload) === true) {
return true
}
private readonly version: OCPPVersion
private readonly ocppResponseService: OCPPResponseService
protected readonly ajv: Ajv
- protected abstract jsonSchemasValidateFunction: Map<RequestCommand, ValidateFunction<JsonType>>
+ protected abstract payloadValidateFunctions: Map<RequestCommand, ValidateFunction<JsonType>>
protected constructor (version: OCPPVersion, ocppResponseService: OCPPResponseService) {
this.version = version
if (chargingStation.stationInfo?.ocppStrictCompliance === false) {
return true
}
- if (!this.jsonSchemasValidateFunction.has(commandName as RequestCommand)) {
+ if (!this.payloadValidateFunctions.has(commandName as RequestCommand)) {
logger.warn(
`${chargingStation.logPrefix()} ${moduleName}.validateRequestPayload: No JSON schema found for command '${commandName}' PDU validation`
)
return true
}
- const validate = this.jsonSchemasValidateFunction.get(commandName as RequestCommand)
+ const validate = this.payloadValidateFunctions.get(commandName as RequestCommand)
payload = clone<T>(payload)
OCPPServiceUtils.convertDateToISOString<T>(payload)
if (validate?.(payload) === true) {
return true
}
if (
- !this.ocppResponseService.jsonSchemasIncomingRequestResponseValidateFunction.has(
+ !this.ocppResponseService.incomingRequestResponsePayloadValidateFunctions.has(
commandName as IncomingRequestCommand
)
) {
)
return true
}
- const validate =
- this.ocppResponseService.jsonSchemasIncomingRequestResponseValidateFunction.get(
- commandName as IncomingRequestCommand
- )
+ const validate = this.ocppResponseService.incomingRequestResponsePayloadValidateFunctions.get(
+ commandName as IncomingRequestCommand
+ )
payload = clone<T>(payload)
OCPPServiceUtils.convertDateToISOString<T>(payload)
if (validate?.(payload) === true) {
private readonly version: OCPPVersion
protected readonly ajv: Ajv
protected readonly ajvIncomingRequest: Ajv
- protected abstract jsonSchemasValidateFunction: Map<RequestCommand, ValidateFunction<JsonType>>
- public abstract jsonSchemasIncomingRequestResponseValidateFunction: Map<
+ protected abstract payloadValidateFunctions: Map<RequestCommand, ValidateFunction<JsonType>>
+ public abstract incomingRequestResponsePayloadValidateFunctions: Map<
IncomingRequestCommand,
ValidateFunction<JsonType>
>
if (chargingStation.stationInfo?.ocppStrictCompliance === false) {
return true
}
- const validate = this.jsonSchemasValidateFunction.get(commandName)
+ const validate = this.payloadValidateFunctions.get(commandName)
if (validate?.(payload) === true) {
return true
}