From: Jérôme Benoit Date: Tue, 31 Mar 2026 23:32:29 +0000 (+0200) Subject: refactor(ocpp): consolidate Ajv type alias in OCPPServiceUtils X-Git-Tag: ocpp-server@v4.2.0~25 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=478f8019331e7b6256d6e783f90cba19217a7bb6;p=e-mobility-charging-stations-simulator.git refactor(ocpp): consolidate Ajv type alias in OCPPServiceUtils Export the Ajv type alias from OCPPServiceUtils and import it in OCPPIncomingRequestService, OCPPRequestService, and OCPPResponseService instead of each file duplicating the _Ajv.default type extraction. --- diff --git a/src/charging-station/ocpp/OCPPIncomingRequestService.ts b/src/charging-station/ocpp/OCPPIncomingRequestService.ts index 45c8f6b7..57d1f5a3 100644 --- a/src/charging-station/ocpp/OCPPIncomingRequestService.ts +++ b/src/charging-station/ocpp/OCPPIncomingRequestService.ts @@ -1,4 +1,4 @@ -import type { default as _Ajv, ValidateFunction } from 'ajv' +import type { ValidateFunction } from 'ajv' import { EventEmitter } from 'node:events' @@ -12,9 +12,7 @@ import { type OCPPVersion, } from '../../types/index.js' import { isAsyncFunction, logger } from '../../utils/index.js' -import { ajvErrorsToErrorType, createAjv } from './OCPPServiceUtils.js' - -type Ajv = _Ajv.default +import { type Ajv, ajvErrorsToErrorType, createAjv } from './OCPPServiceUtils.js' const moduleName = 'OCPPIncomingRequestService' diff --git a/src/charging-station/ocpp/OCPPRequestService.ts b/src/charging-station/ocpp/OCPPRequestService.ts index 8ddf85e5..5385a9a1 100644 --- a/src/charging-station/ocpp/OCPPRequestService.ts +++ b/src/charging-station/ocpp/OCPPRequestService.ts @@ -1,4 +1,4 @@ -import type { default as _Ajv, ValidateFunction } from 'ajv' +import type { ValidateFunction } from 'ajv' import type { ChargingStation } from '../../charging-station/index.js' import type { OCPPResponseService } from './OCPPResponseService.js' @@ -31,9 +31,12 @@ import { logger, } from '../../utils/index.js' import { OCPPConstants } from './OCPPConstants.js' -import { ajvErrorsToErrorType, convertDateToISOString, createAjv } from './OCPPServiceUtils.js' - -type Ajv = _Ajv.default +import { + type Ajv, + ajvErrorsToErrorType, + convertDateToISOString, + createAjv, +} from './OCPPServiceUtils.js' const moduleName = 'OCPPRequestService' diff --git a/src/charging-station/ocpp/OCPPResponseService.ts b/src/charging-station/ocpp/OCPPResponseService.ts index 44f15090..2975025a 100644 --- a/src/charging-station/ocpp/OCPPResponseService.ts +++ b/src/charging-station/ocpp/OCPPResponseService.ts @@ -1,4 +1,4 @@ -import type { default as _Ajv, ValidateFunction } from 'ajv' +import type { ValidateFunction } from 'ajv' import type { ChargingStation } from '../../charging-station/index.js' @@ -12,9 +12,7 @@ import { type ResponseHandler, } from '../../types/index.js' import { Constants, isAsyncFunction, logger } from '../../utils/index.js' -import { ajvErrorsToErrorType, createAjv } from './OCPPServiceUtils.js' - -type Ajv = _Ajv.default +import { type Ajv, ajvErrorsToErrorType, createAjv } from './OCPPServiceUtils.js' const moduleName = 'OCPPResponseService' diff --git a/src/charging-station/ocpp/OCPPServiceUtils.ts b/src/charging-station/ocpp/OCPPServiceUtils.ts index 8995aaae..b9996f4a 100644 --- a/src/charging-station/ocpp/OCPPServiceUtils.ts +++ b/src/charging-station/ocpp/OCPPServiceUtils.ts @@ -67,7 +67,7 @@ import { OCPPConstants } from './OCPPConstants.js' const moduleName = 'OCPPServiceUtils' -type Ajv = _Ajv.default +export type Ajv = _Ajv.default // eslint-disable-next-line @typescript-eslint/no-redeclare const Ajv = _Ajv.default const ajvFormats = _ajvFormats.default