]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
refactor(ocpp): consolidate Ajv type alias in OCPPServiceUtils
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 31 Mar 2026 23:32:29 +0000 (01:32 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 31 Mar 2026 23:32:29 +0000 (01:32 +0200)
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.

src/charging-station/ocpp/OCPPIncomingRequestService.ts
src/charging-station/ocpp/OCPPRequestService.ts
src/charging-station/ocpp/OCPPResponseService.ts
src/charging-station/ocpp/OCPPServiceUtils.ts

index 45c8f6b7d727c4eca50519e2dfd2d181cecc5359..57d1f5a3c5a604f51f6cbf96da4c9c4d88c9d8df 100644 (file)
@@ -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'
 
index 8ddf85e5d19844b191db8f7c2e444001e739c5b0..5385a9a1805b1a3895573f9c92083c1178245b48 100644 (file)
@@ -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'
 
index 44f15090b68625c9510d346d005dfcc21c561001..2975025a326eb4a647c2af5d28983b1a74574da1 100644 (file)
@@ -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'
 
index 8995aaaeb5608de3973b83afcd5c663c1935ae77..b9996f4a21aa3d375fb4622235b2a0b8dc650bef 100644 (file)
@@ -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