]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
refactor: make `eventType` required in `OCPP20TransactionEventOptions`
authorJérôme Benoit <jerome.benoit@sap.com>
Fri, 27 Mar 2026 16:31:41 +0000 (17:31 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Fri, 27 Mar 2026 16:31:41 +0000 (17:31 +0100)
src/charging-station/ocpp/2.0/OCPP20RequestService.ts
src/charging-station/ocpp/2.0/OCPP20ServiceUtils.ts
src/types/ocpp/2.0/Transaction.ts

index 0e5b8261d6dd529bb62a6f19a0e85d30cc9810dd..74b47060a8707ec2f7e2e8a8645e7fbf511c6295 100644 (file)
@@ -1,11 +1,11 @@
 import type { ValidateFunction } from 'ajv'
 
 import type { ChargingStation } from '../../../charging-station/index.js'
+import type { CertificateSigningUseEnumType } from '../../../types/index.js'
 import type { OCPPResponseService } from '../OCPPResponseService.js'
 
 import { OCPPError } from '../../../exception/index.js'
 import {
-  type CertificateSigningUseEnumType,
   ErrorType,
   type JsonObject,
   type JsonType,
index f35a29e10688bfac4a5c9e8c79ab9d4e7c779bf9..1f5ee248fec90d71728a5cc3bf3a1964a1c64734 100644 (file)
@@ -503,7 +503,7 @@ export class OCPP20ServiceUtils extends OCPPServiceUtils {
     triggerReason: OCPP20TriggerReasonEnumType,
     connectorId: number,
     transactionId: string,
-    options: OCPP20TransactionEventOptions = {}
+    options: Omit<OCPP20TransactionEventOptions, 'eventType'> = {}
   ): Promise<OCPP20TransactionEventResponse> {
     try {
       const connectorStatus = chargingStation.getConnectorStatus(connectorId)
@@ -882,12 +882,6 @@ export function buildTransactionEvent (
   commandParams: OCPP20TransactionEventOptions
 ): OCPP20TransactionEventRequest {
   const eventType = commandParams.eventType
-  if (eventType == null) {
-    throw new OCPPError(
-      ErrorType.PROPERTY_CONSTRAINT_VIOLATION,
-      'eventType is required for TransactionEvent'
-    )
-  }
   const defaultTriggerReason =
     eventType === OCPP20TransactionEventEnumType.Ended
       ? OCPP20TriggerReasonEnumType.RemoteStop
index b4b62825140a9bb70109ffac516a954fb82d347a..1992c88d7ace521cbba8496f5480de1ce64faa05 100644 (file)
@@ -276,7 +276,7 @@ export interface OCPP20TransactionEventOptions {
   chargingState?: OCPP20ChargingStateEnumType
   connectorId?: number
   customData?: CustomDataType
-  eventType?: OCPP20TransactionEventEnumType
+  eventType: OCPP20TransactionEventEnumType
   evse?: Partial<OCPP20EVSEType>
   evseId?: number
   idToken?: OCPP20IdTokenType