X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Focpp%2FOCPPResponseService.ts;h=00d539b7c214b1f4ed973299d31836dbcf4b2ae3;hb=4293e5179eabbc8f42a1c06064d15c0ec7d1ca3f;hp=45a3e1f2d5822f5236e0266492935effd38f165d;hpb=298be10c5c800e43b0b9dcd6c50f6d49e2cb786b;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ocpp/OCPPResponseService.ts b/src/charging-station/ocpp/OCPPResponseService.ts index 45a3e1f2..00d539b7 100644 --- a/src/charging-station/ocpp/OCPPResponseService.ts +++ b/src/charging-station/ocpp/OCPPResponseService.ts @@ -1,7 +1,6 @@ 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 { @@ -11,6 +10,7 @@ import type { RequestCommand } from '../../types/index.js' import { Constants, logger } from '../../utils/index.js' +import { ajvErrorsToErrorType } from './OCPPServiceUtils.js' type Ajv = _Ajv.default // eslint-disable-next-line @typescript-eslint/no-redeclare const Ajv = _Ajv.default @@ -23,8 +23,8 @@ export abstract class OCPPResponseService { private readonly version: OCPPVersion protected readonly ajv: Ajv protected readonly ajvIncomingRequest: Ajv - protected abstract jsonSchemasValidateFunction: Map> - public abstract jsonSchemasIncomingRequestResponseValidateFunction: Map< + protected abstract payloadValidateFunctions: Map> + public abstract incomingRequestResponsePayloadValidateFunctions: Map< IncomingRequestCommand, ValidateFunction > @@ -60,7 +60,7 @@ export abstract class OCPPResponseService { 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 } @@ -69,7 +69,7 @@ export abstract class OCPPResponseService { validate?.errors ) throw new OCPPError( - OCPPServiceUtils.ajvErrorsToErrorType(validate?.errors), + ajvErrorsToErrorType(validate?.errors), 'Response PDU is invalid', commandName, JSON.stringify(validate?.errors, undefined, 2)