fix: use homebrew async locking primitive to order file writing
[e-mobility-charging-stations-simulator.git] / src / charging-station / ocpp / 2.0 / OCPP20IncomingRequestService.ts
index 95169e2b0d88f548a6829bde7cbeed6a314f3991..2d1ebd4dba73c1aa5367d4a6754b9b0e87833f9e 100644 (file)
@@ -2,7 +2,7 @@
 
 import type { JSONSchemaType } from 'ajv';
 
-import { OCPP20ServiceUtils } from './OCPP20ServiceUtils';
+import type { ChargingStation } from '../../../charging-station';
 import { OCPPError } from '../../../exception';
 import {
   ErrorType,
@@ -13,9 +13,8 @@ import {
   OCPP20IncomingRequestCommand,
   OCPPVersion,
 } from '../../../types';
-import { logger } from '../../../utils/Logger';
-import type { ChargingStation } from '../../ChargingStation';
-import { OCPPIncomingRequestService } from '../OCPPIncomingRequestService';
+import { logger } from '../../../utils';
+import { OCPP20ServiceUtils, OCPPIncomingRequestService } from '../internal';
 
 const moduleName = 'OCPP20IncomingRequestService';
 
@@ -24,9 +23,9 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
   private incomingRequestHandlers: Map<OCPP20IncomingRequestCommand, IncomingRequestHandler>;
 
   public constructor() {
-    if (new.target?.name === moduleName) {
-      throw new TypeError(`Cannot construct ${new.target?.name} instances directly`);
-    }
+    // if (new.target?.name === moduleName) {
+    //   throw new TypeError(`Cannot construct ${new.target?.name} instances directly`);
+    // }
     super(OCPPVersion.VERSION_20);
     this.incomingRequestHandlers = new Map<OCPP20IncomingRequestCommand, IncomingRequestHandler>([
       [OCPP20IncomingRequestCommand.CLEAR_CACHE, this.handleRequestClearCache.bind(this)],
@@ -41,7 +40,11 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
         ),
       ],
     ]);
-    this.validatePayload.bind(this);
+    this.validatePayload = this.validatePayload.bind(this) as (
+      chargingStation: ChargingStation,
+      commandName: OCPP20IncomingRequestCommand,
+      commandPayload: JsonType
+    ) => boolean;
   }
 
   public async incomingRequestHandler(