fix: ensure OCPP payload validation report error details
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 24 Jul 2024 22:14:10 +0000 (00:14 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 24 Jul 2024 22:14:10 +0000 (00:14 +0200)
The validate() is already bound to Ajv and cannot be rebinded to
a different instance.

Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts
src/charging-station/ocpp/1.6/OCPP16RequestService.ts
src/charging-station/ocpp/1.6/OCPP16ResponseService.ts
src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts
src/charging-station/ocpp/2.0/OCPP20RequestService.ts
src/charging-station/ocpp/2.0/OCPP20ResponseService.ts

index f026d0a80b217ff69075f78d74f21da7df70cb4e..d114fe6c00241c429774d959625db4b785cecd01 100644 (file)
@@ -215,8 +215,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16IncomingRequestCommand.CLEAR_CACHE,
@@ -227,8 +226,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16IncomingRequestCommand.UNLOCK_CONNECTOR,
@@ -239,8 +237,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16IncomingRequestCommand.GET_CONFIGURATION,
@@ -251,8 +248,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16IncomingRequestCommand.CHANGE_CONFIGURATION,
@@ -263,8 +259,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16IncomingRequestCommand.GET_DIAGNOSTICS,
@@ -275,8 +270,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16IncomingRequestCommand.GET_COMPOSITE_SCHEDULE,
@@ -287,8 +281,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16IncomingRequestCommand.SET_CHARGING_PROFILE,
@@ -299,8 +292,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16IncomingRequestCommand.CLEAR_CHARGING_PROFILE,
@@ -311,8 +303,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16IncomingRequestCommand.CHANGE_AVAILABILITY,
@@ -323,8 +314,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16IncomingRequestCommand.REMOTE_START_TRANSACTION,
@@ -335,8 +325,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16IncomingRequestCommand.REMOTE_STOP_TRANSACTION,
@@ -347,8 +336,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16IncomingRequestCommand.TRIGGER_MESSAGE,
@@ -359,8 +347,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16IncomingRequestCommand.DATA_TRANSFER,
@@ -371,8 +358,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16IncomingRequestCommand.UPDATE_FIRMWARE,
@@ -383,8 +369,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16IncomingRequestCommand.RESERVE_NOW,
@@ -395,8 +380,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16IncomingRequestCommand.CANCEL_RESERVATION,
@@ -407,8 +391,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
     ])
     // Handle incoming request events
index 7c8e9006d394d26dfa6bc026c1a424075a6c3783..8f8108612111197ee2b300a5fc9b9010d596b414 100644 (file)
@@ -49,8 +49,7 @@ export class OCPP16RequestService extends OCPPRequestService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16RequestCommand.BOOT_NOTIFICATION,
@@ -61,8 +60,7 @@ export class OCPP16RequestService extends OCPPRequestService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION,
@@ -73,8 +71,7 @@ export class OCPP16RequestService extends OCPPRequestService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16RequestCommand.HEARTBEAT,
@@ -85,8 +82,7 @@ export class OCPP16RequestService extends OCPPRequestService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16RequestCommand.METER_VALUES,
@@ -97,8 +93,7 @@ export class OCPP16RequestService extends OCPPRequestService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16RequestCommand.STATUS_NOTIFICATION,
@@ -109,8 +104,7 @@ export class OCPP16RequestService extends OCPPRequestService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16RequestCommand.START_TRANSACTION,
@@ -121,8 +115,7 @@ export class OCPP16RequestService extends OCPPRequestService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16RequestCommand.STOP_TRANSACTION,
@@ -133,8 +126,7 @@ export class OCPP16RequestService extends OCPPRequestService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16RequestCommand.DATA_TRANSFER,
@@ -145,8 +137,7 @@ export class OCPP16RequestService extends OCPPRequestService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16RequestCommand.FIRMWARE_STATUS_NOTIFICATION,
@@ -157,8 +148,7 @@ export class OCPP16RequestService extends OCPPRequestService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
     ])
     this.buildRequestPayload = this.buildRequestPayload.bind(this)
index 654cc4eff44ff876011f192d7a8cc7f83cf5e03e..4fa2dae07f91a5a0edc5a36abb8319366dff18fa 100644 (file)
@@ -108,8 +108,7 @@ export class OCPP16ResponseService extends OCPPResponseService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16RequestCommand.HEARTBEAT,
@@ -120,8 +119,7 @@ export class OCPP16ResponseService extends OCPPResponseService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16RequestCommand.AUTHORIZE,
@@ -132,8 +130,7 @@ export class OCPP16ResponseService extends OCPPResponseService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16RequestCommand.START_TRANSACTION,
@@ -144,8 +141,7 @@ export class OCPP16ResponseService extends OCPPResponseService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16RequestCommand.STOP_TRANSACTION,
@@ -156,8 +152,7 @@ export class OCPP16ResponseService extends OCPPResponseService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16RequestCommand.STATUS_NOTIFICATION,
@@ -168,8 +163,7 @@ export class OCPP16ResponseService extends OCPPResponseService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16RequestCommand.METER_VALUES,
@@ -180,8 +174,7 @@ export class OCPP16ResponseService extends OCPPResponseService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION,
@@ -192,8 +185,7 @@ export class OCPP16ResponseService extends OCPPResponseService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16RequestCommand.DATA_TRANSFER,
@@ -204,8 +196,7 @@ export class OCPP16ResponseService extends OCPPResponseService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16RequestCommand.FIRMWARE_STATUS_NOTIFICATION,
@@ -216,8 +207,7 @@ export class OCPP16ResponseService extends OCPPResponseService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
     ])
     this.incomingRequestResponsePayloadValidateFunctions = new Map<
@@ -233,8 +223,7 @@ export class OCPP16ResponseService extends OCPPResponseService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16IncomingRequestCommand.CLEAR_CACHE,
@@ -245,8 +234,7 @@ export class OCPP16ResponseService extends OCPPResponseService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16IncomingRequestCommand.CHANGE_AVAILABILITY,
@@ -257,8 +245,7 @@ export class OCPP16ResponseService extends OCPPResponseService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16IncomingRequestCommand.UNLOCK_CONNECTOR,
@@ -269,8 +256,7 @@ export class OCPP16ResponseService extends OCPPResponseService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16IncomingRequestCommand.GET_CONFIGURATION,
@@ -281,8 +267,7 @@ export class OCPP16ResponseService extends OCPPResponseService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16IncomingRequestCommand.CHANGE_CONFIGURATION,
@@ -293,8 +278,7 @@ export class OCPP16ResponseService extends OCPPResponseService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16IncomingRequestCommand.GET_COMPOSITE_SCHEDULE,
@@ -305,8 +289,7 @@ export class OCPP16ResponseService extends OCPPResponseService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16IncomingRequestCommand.SET_CHARGING_PROFILE,
@@ -317,8 +300,7 @@ export class OCPP16ResponseService extends OCPPResponseService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16IncomingRequestCommand.CLEAR_CHARGING_PROFILE,
@@ -329,8 +311,7 @@ export class OCPP16ResponseService extends OCPPResponseService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16IncomingRequestCommand.REMOTE_START_TRANSACTION,
@@ -341,8 +322,7 @@ export class OCPP16ResponseService extends OCPPResponseService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16IncomingRequestCommand.REMOTE_STOP_TRANSACTION,
@@ -353,8 +333,7 @@ export class OCPP16ResponseService extends OCPPResponseService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16IncomingRequestCommand.GET_DIAGNOSTICS,
@@ -365,8 +344,7 @@ export class OCPP16ResponseService extends OCPPResponseService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16IncomingRequestCommand.TRIGGER_MESSAGE,
@@ -377,8 +355,7 @@ export class OCPP16ResponseService extends OCPPResponseService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16IncomingRequestCommand.DATA_TRANSFER,
@@ -389,8 +366,7 @@ export class OCPP16ResponseService extends OCPPResponseService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16IncomingRequestCommand.UPDATE_FIRMWARE,
@@ -401,8 +377,7 @@ export class OCPP16ResponseService extends OCPPResponseService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16IncomingRequestCommand.RESERVE_NOW,
@@ -413,8 +388,7 @@ export class OCPP16ResponseService extends OCPPResponseService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP16IncomingRequestCommand.CANCEL_RESERVATION,
@@ -425,8 +399,7 @@ export class OCPP16ResponseService extends OCPPResponseService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
     ])
     this.validatePayload = this.validatePayload.bind(this)
index 5817ede428ddcc624fa0317f541cba74957daea1..5d074f6adb8da0d19055be1f6f9570b3d8c60aae 100644 (file)
@@ -47,8 +47,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
     ])
     this.validatePayload = this.validatePayload.bind(this)
index 0fb6c7f0808e036a6e310a9e666a2cb66e2fcd04..c64de06f5f14eb27f48a8f79a064abb0602c15ab 100644 (file)
@@ -41,8 +41,7 @@ export class OCPP20RequestService extends OCPPRequestService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP20RequestCommand.HEARTBEAT,
@@ -53,8 +52,7 @@ export class OCPP20RequestService extends OCPPRequestService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP20RequestCommand.STATUS_NOTIFICATION,
@@ -65,8 +63,7 @@ export class OCPP20RequestService extends OCPPRequestService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
     ])
     this.buildRequestPayload = this.buildRequestPayload.bind(this)
index d24800b2c5b7bbee36b9500f9392bb654aedd6ba..b846a76a663b43780a7075ed473fa3478f218977 100644 (file)
@@ -57,8 +57,7 @@ export class OCPP20ResponseService extends OCPPResponseService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP20RequestCommand.HEARTBEAT,
@@ -69,8 +68,7 @@ export class OCPP20ResponseService extends OCPPResponseService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
       [
         OCPP20RequestCommand.STATUS_NOTIFICATION,
@@ -81,8 +79,7 @@ export class OCPP20ResponseService extends OCPPResponseService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
     ])
     this.incomingRequestResponsePayloadValidateFunctions = new Map<
@@ -98,8 +95,7 @@ export class OCPP20ResponseService extends OCPPResponseService {
               moduleName,
               'constructor'
             )
-          )
-          .bind(this),
+          ),
       ],
     ])
     this.validatePayload = this.validatePayload.bind(this)