From: Jérôme Benoit Date: Fri, 27 Mar 2026 16:31:41 +0000 (+0100) Subject: refactor: make `eventType` required in `OCPP20TransactionEventOptions` X-Git-Tag: ocpp-server@v4.0.0~34 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=243cf560728b40d456525a4911b1091d13fc9649;p=e-mobility-charging-stations-simulator.git refactor: make `eventType` required in `OCPP20TransactionEventOptions` --- 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