From 243cf560728b40d456525a4911b1091d13fc9649 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 27 Mar 2026 17:31:41 +0100 Subject: [PATCH] refactor: make `eventType` required in `OCPP20TransactionEventOptions` --- src/charging-station/ocpp/2.0/OCPP20RequestService.ts | 2 +- src/charging-station/ocpp/2.0/OCPP20ServiceUtils.ts | 8 +------- src/types/ocpp/2.0/Transaction.ts | 2 +- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/charging-station/ocpp/2.0/OCPP20RequestService.ts b/src/charging-station/ocpp/2.0/OCPP20RequestService.ts index 0e5b8261..74b47060 100644 --- a/src/charging-station/ocpp/2.0/OCPP20RequestService.ts +++ b/src/charging-station/ocpp/2.0/OCPP20RequestService.ts @@ -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, diff --git a/src/charging-station/ocpp/2.0/OCPP20ServiceUtils.ts b/src/charging-station/ocpp/2.0/OCPP20ServiceUtils.ts index f35a29e1..1f5ee248 100644 --- a/src/charging-station/ocpp/2.0/OCPP20ServiceUtils.ts +++ b/src/charging-station/ocpp/2.0/OCPP20ServiceUtils.ts @@ -503,7 +503,7 @@ export class OCPP20ServiceUtils extends OCPPServiceUtils { triggerReason: OCPP20TriggerReasonEnumType, connectorId: number, transactionId: string, - options: OCPP20TransactionEventOptions = {} + options: Omit = {} ): Promise { 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 diff --git a/src/types/ocpp/2.0/Transaction.ts b/src/types/ocpp/2.0/Transaction.ts index b4b62825..1992c88d 100644 --- a/src/types/ocpp/2.0/Transaction.ts +++ b/src/types/ocpp/2.0/Transaction.ts @@ -276,7 +276,7 @@ export interface OCPP20TransactionEventOptions { chargingState?: OCPP20ChargingStateEnumType connectorId?: number customData?: CustomDataType - eventType?: OCPP20TransactionEventEnumType + eventType: OCPP20TransactionEventEnumType evse?: Partial evseId?: number idToken?: OCPP20IdTokenType -- 2.43.0