Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
270 changes: 135 additions & 135 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
"husky": "^9.1.7",
"lint-staged": "^17.0.8",
"neostandard": "^0.13.0",
"prettier": "^3.8.4",
"prettier": "^3.8.5",
"rimraf": "^6.1.3",
"semver": "^7.8.5",
"skott": "^0.35.11",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions src/charging-station/ChargingStation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,12 +426,10 @@ export class ChargingStation extends EventEmitter {
* @returns The ATG configuration or undefined if not available
*/
public getAutomaticTransactionGeneratorConfiguration ():
| AutomaticTransactionGeneratorConfiguration
| undefined {
AutomaticTransactionGeneratorConfiguration | undefined {
if (this.automaticTransactionGeneratorConfiguration == null) {
let automaticTransactionGeneratorConfiguration:
| AutomaticTransactionGeneratorConfiguration
| undefined
AutomaticTransactionGeneratorConfiguration | undefined
const stationTemplate = this.getTemplateFromFile()
const stationConfiguration = this.getConfigurationFromFile()
if (
Expand Down
3 changes: 1 addition & 2 deletions src/charging-station/ChargingStationWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import { type WorkerDataError, type WorkerMessage, WorkerMessageEvents } from '.
import { ChargingStation } from './ChargingStation.js'

export let chargingStationWorker:
| object
| ThreadWorker<ChargingStationWorkerData, ChargingStationInfo>
object | ThreadWorker<ChargingStationWorkerData, ChargingStationInfo>
if (Configuration.workerPoolInUse()) {
chargingStationWorker = new ThreadWorker<
ChargingStationWorkerData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,7 @@ export class ChargingStationWorkerBroadcastChannel extends WorkerBroadcastChanne
if (
(
commandResponse as
| OCPP16AuthorizeResponse
| StartTransactionResponse
| StopTransactionResponse
OCPP16AuthorizeResponse | StartTransactionResponse | StopTransactionResponse
).idTagInfo?.status === AuthorizationStatus.ACCEPTED
) {
return ResponseStatus.SUCCESS
Expand Down
10 changes: 6 additions & 4 deletions src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,12 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
switch (requestedMessage) {
case OCPP16MessageTrigger.BootNotification:
chargingStation.ocppRequestService
.requestHandler<
OCPP16BootNotificationRequest,
OCPP16BootNotificationResponse
>(chargingStation, OCPP16RequestCommand.BOOT_NOTIFICATION, chargingStation.bootNotificationRequest as OCPP16BootNotificationRequest, { skipBufferingOnError: true, triggerMessage: true })
.requestHandler<OCPP16BootNotificationRequest, OCPP16BootNotificationResponse>(
chargingStation,
OCPP16RequestCommand.BOOT_NOTIFICATION,
chargingStation.bootNotificationRequest as OCPP16BootNotificationRequest,
{ skipBufferingOnError: true, triggerMessage: true }
)
.catch(errorHandler)
break
case OCPP16MessageTrigger.DiagnosticsStatusNotification:
Expand Down
62 changes: 44 additions & 18 deletions src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -536,10 +536,12 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
switch (requestedMessage) {
case MessageTriggerEnumType.BootNotification:
chargingStation.ocppRequestService
.requestHandler<
OCPP20BootNotificationRequest,
OCPP20BootNotificationResponse
>(chargingStation, OCPP20RequestCommand.BOOT_NOTIFICATION, chargingStation.bootNotificationRequest as OCPP20BootNotificationRequest, { skipBufferingOnError: true, triggerMessage: true })
.requestHandler<OCPP20BootNotificationRequest, OCPP20BootNotificationResponse>(
chargingStation,
OCPP20RequestCommand.BOOT_NOTIFICATION,
chargingStation.bootNotificationRequest as OCPP20BootNotificationRequest,
{ skipBufferingOnError: true, triggerMessage: true }
)
.catch(errorHandler)
break
case MessageTriggerEnumType.FirmwareStatusNotification: {
Expand All @@ -551,24 +553,36 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
.requestHandler<
OCPP20FirmwareStatusNotificationRequest,
OCPP20FirmwareStatusNotificationResponse
>(chargingStation, OCPP20RequestCommand.FIRMWARE_STATUS_NOTIFICATION, { requestId: stationState.activeFirmwareUpdateRequestId, status: firmwareStatus }, { skipBufferingOnError: true, triggerMessage: true })
>(
chargingStation,
OCPP20RequestCommand.FIRMWARE_STATUS_NOTIFICATION,
{ requestId: stationState.activeFirmwareUpdateRequestId, status: firmwareStatus },
{ skipBufferingOnError: true, triggerMessage: true }
)
.catch(errorHandler)
break
}
case MessageTriggerEnumType.Heartbeat:
chargingStation.ocppRequestService
.requestHandler<
OCPP20HeartbeatRequest,
OCPP20HeartbeatResponse
>(chargingStation, OCPP20RequestCommand.HEARTBEAT, OCPP20Constants.OCPP_RESPONSE_EMPTY as OCPP20HeartbeatRequest, { skipBufferingOnError: true, triggerMessage: true })
.requestHandler<OCPP20HeartbeatRequest, OCPP20HeartbeatResponse>(
chargingStation,
OCPP20RequestCommand.HEARTBEAT,
OCPP20Constants.OCPP_RESPONSE_EMPTY as OCPP20HeartbeatRequest,
{ skipBufferingOnError: true, triggerMessage: true }
)
.catch(errorHandler)
break
case MessageTriggerEnumType.LogStatusNotification:
chargingStation.ocppRequestService
.requestHandler<
OCPP20LogStatusNotificationRequest,
OCPP20LogStatusNotificationResponse
>(chargingStation, OCPP20RequestCommand.LOG_STATUS_NOTIFICATION, { status: UploadLogStatusEnumType.Idle }, { skipBufferingOnError: true, triggerMessage: true })
>(
chargingStation,
OCPP20RequestCommand.LOG_STATUS_NOTIFICATION,
{ status: UploadLogStatusEnumType.Idle },
{ skipBufferingOnError: true, triggerMessage: true }
)
.catch(errorHandler)
break
case MessageTriggerEnumType.MeterValues: {
Expand Down Expand Up @@ -3894,10 +3908,16 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
)) {
const resolvedStatus = connectorStatus.status ?? ConnectorStatusEnum.Available
chargingStation.ocppRequestService
.requestHandler<
OCPP20StatusNotificationRequest,
OCPP20StatusNotificationResponse
>(chargingStation, OCPP20RequestCommand.STATUS_NOTIFICATION, { connectorId, connectorStatus: resolvedStatus, evseId } as unknown as OCPP20StatusNotificationRequest, { skipBufferingOnError: true, triggerMessage: true })
.requestHandler<OCPP20StatusNotificationRequest, OCPP20StatusNotificationResponse>(
chargingStation,
OCPP20RequestCommand.STATUS_NOTIFICATION,
{
connectorId,
connectorStatus: resolvedStatus,
evseId,
} as unknown as OCPP20StatusNotificationRequest,
{ skipBufferingOnError: true, triggerMessage: true }
)
.catch(errorHandler)
}
}
Expand All @@ -3912,10 +3932,16 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
const connectorStatus = evseStatus?.connectors.get(evse.connectorId)
const resolvedStatus = connectorStatus?.status ?? ConnectorStatusEnum.Available
chargingStation.ocppRequestService
.requestHandler<
OCPP20StatusNotificationRequest,
OCPP20StatusNotificationResponse
>(chargingStation, OCPP20RequestCommand.STATUS_NOTIFICATION, { connectorId: evse.connectorId, connectorStatus: resolvedStatus, evseId: evse.id } as unknown as OCPP20StatusNotificationRequest, { skipBufferingOnError: true, triggerMessage: true })
.requestHandler<OCPP20StatusNotificationRequest, OCPP20StatusNotificationResponse>(
chargingStation,
OCPP20RequestCommand.STATUS_NOTIFICATION,
{
connectorId: evse.connectorId,
connectorStatus: resolvedStatus,
evseId: evse.id,
} as unknown as OCPP20StatusNotificationRequest,
{ skipBufferingOnError: true, triggerMessage: true }
)
.catch(errorHandler)
} else if (chargingStation.hasEvses) {
this.triggerAllEvseStatusNotifications(chargingStation, errorHandler)
Expand Down
3 changes: 1 addition & 2 deletions src/charging-station/ocpp/2.0/OCPP20RequestService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,7 @@ export class OCPP20RequestService extends OCPPRequestService {
}

const certificateType = (commandParams as JsonObject | undefined)?.certificateType as
| CertificateSigningUseEnumType
| undefined
CertificateSigningUseEnumType | undefined

const requestPayload: OCPP20SignCertificateRequest = {
csr,
Expand Down
3 changes: 1 addition & 2 deletions src/charging-station/ocpp/2.0/OCPP20ServiceUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1155,8 +1155,7 @@ export class OCPP20ServiceUtils {
const endedMeterValues = (connectorStatus?.transactionEndedMeterValues ??
[]) as OCPP20MeterValue[]
const beginMeterValue = connectorStatus?.transactionBeginMeterValue as
| OCPP20MeterValue
| undefined
OCPP20MeterValue | undefined

try {
const measurandsKey = buildConfigKey(
Expand Down
3 changes: 1 addition & 2 deletions src/charging-station/ocpp/OCPPConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,7 @@ export class OCPPConstants {
static readonly OCPP_WEBSOCKET_TIMEOUT_MS = 60000

static readonly UNKNOWN_OCPP_COMMAND = 'unknown OCPP command' as
| IncomingRequestCommand
| RequestCommand
IncomingRequestCommand | RequestCommand

protected constructor () {
// This is intentional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,7 @@ export class OCPPAuthServiceImpl implements OCPPAuthService {

// Get rate limiting stats from cache via remote strategy
let rateLimitStatistics:
| undefined
| { blockedRequests: number; rateLimitedIdentifiers: number; totalChecks: number }
undefined | { blockedRequests: number; rateLimitedIdentifiers: number; totalChecks: number }
const remoteStrategy = this.strategies.get('remote')
if (remoteStrategy?.getStats) {
const strategyStatistics = remoteStrategy.getStats()
Expand Down
3 changes: 1 addition & 2 deletions src/charging-station/ui-server/UIMCPServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,7 @@ export class UIMCPServer extends AbstractUIServer {
// The SDK does not provide a public API for wrapping existing handlers.
// setRequestHandler() replaces handlers entirely, losing Zod→JSON Schema conversion.
const handlers = Reflect.get(mcpServer.server, '_requestHandlers') as
| Map<string, (...args: unknown[]) => Promise<unknown>>
| undefined
Map<string, (...args: unknown[]) => Promise<unknown>> | undefined
if (handlers == null || !(handlers instanceof Map)) {
logger.warn(
`${this.logPrefix(moduleName, 'injectOcppJsonSchemas')} MCP SDK internal API changed — OCPP schema injection disabled`
Expand Down
3 changes: 1 addition & 2 deletions src/types/ChargingStationWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,4 @@ export const ChargingStationWorkerMessageEvents = {
} as const
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type ChargingStationWorkerMessageEvents =
| ChargingStationEvents
| ChargingStationMessageEvents
ChargingStationEvents | ChargingStationMessageEvents
6 changes: 2 additions & 4 deletions src/types/ocpp/ChargingProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,15 @@ export const ChargingProfilePurposeType = {
} as const
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type ChargingProfilePurposeType =
| OCPP16ChargingProfilePurposeType
| OCPP20ChargingProfilePurposeEnumType
OCPP16ChargingProfilePurposeType | OCPP20ChargingProfilePurposeEnumType

export const ChargingProfileKindType = {
...OCPP16ChargingProfileKindType,
...OCPP20ChargingProfileKindEnumType,
} as const
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type ChargingProfileKindType =
| OCPP16ChargingProfileKindType
| OCPP20ChargingProfileKindEnumType
OCPP16ChargingProfileKindType | OCPP20ChargingProfileKindEnumType

export const RecurrencyKindType = {
...OCPP16RecurrencyKindType,
Expand Down
6 changes: 2 additions & 4 deletions src/types/ocpp/Requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ export type DiagnosticsStatusNotificationRequest = OCPP16DiagnosticsStatusNotifi
export type ErrorCallback = (ocppError: OCPPError, requestStatistic?: boolean) => void

export type FirmwareStatusNotificationRequest =
| OCPP16FirmwareStatusNotificationRequest
| OCPP20FirmwareStatusNotificationRequest
OCPP16FirmwareStatusNotificationRequest | OCPP20FirmwareStatusNotificationRequest

// eslint-disable-next-line @typescript-eslint/no-duplicate-type-constituents
export type HeartbeatRequest = OCPP16HeartbeatRequest | OCPP20HeartbeatRequest
Expand Down Expand Up @@ -100,8 +99,7 @@ export type MeterValuesRequest = OCPP16MeterValuesRequest | OCPP20MeterValuesReq
export type ResponseCallback = (payload: JsonType, requestPayload: JsonType) => void

export type StatusNotificationRequest =
| OCPP16StatusNotificationRequest
| OCPP20StatusNotificationRequest
OCPP16StatusNotificationRequest | OCPP20StatusNotificationRequest

export const AvailabilityType = {
...OCPP16AvailabilityType,
Expand Down
3 changes: 1 addition & 2 deletions src/types/ocpp/Responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ import {
import { type GenericResponse, GenericStatus } from './Common.js'

export type BootNotificationResponse =
| OCPP16BootNotificationResponse
| OCPP20BootNotificationResponse
OCPP16BootNotificationResponse | OCPP20BootNotificationResponse

export type CancelReservationResponse = GenericResponse

Expand Down
5 changes: 1 addition & 4 deletions src/utils/Configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ import {
} from './Utils.js'

type ConfigurationSectionType =
| LogConfiguration
| StorageConfiguration
| UIServerConfiguration
| WorkerConfiguration
LogConfiguration | StorageConfiguration | UIServerConfiguration | WorkerConfiguration

const defaultUIServerConfiguration: UIServerConfiguration = {
accessPolicy: {
Expand Down
3 changes: 1 addition & 2 deletions tests/charging-station/ocpp/auth/helpers/MockFactories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,7 @@ export const createMockLocalAuthListManager = (

export const getTestAuthCache = (authService: OCPPAuthService): AuthCache => {
const localStrategy = (authService as OCPPAuthServiceImpl).getStrategy('local') as
| LocalAuthStrategy
| undefined
LocalAuthStrategy | undefined
const cache = localStrategy?.getAuthCache()
assert.ok(cache != null, 'Auth cache must be available for test')
return cache
Expand Down
6 changes: 2 additions & 4 deletions tests/charging-station/ui-server/UIMetricsEndpoint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1671,8 +1671,7 @@ await describe('UIHttpServer /metrics endpoint (issue #851)', async () => {
localServer as unknown as { scheduleClientNotification: () => void }
).scheduleClientNotification()
const installed = Reflect.get(localServer, 'clientNotificationDebounceTimer') as
| NodeJS.Timeout
| undefined
NodeJS.Timeout | undefined
assert.ok(installed !== undefined, 'precondition: debounce timer installed')
const clearedHandles: unknown[] = []
const originalClearTimeout = globalThis.clearTimeout
Expand Down Expand Up @@ -1702,8 +1701,7 @@ await describe('UIHttpServer /metrics endpoint (issue #851)', async () => {
localServer as unknown as { scheduleClientNotification: () => void }
).scheduleClientNotification()
const reinstalled = Reflect.get(localServer, 'clientNotificationDebounceTimer') as
| NodeJS.Timeout
| undefined
NodeJS.Timeout | undefined
assert.ok(reinstalled !== undefined, 'precondition: 2nd timer installed after first stop()')
const beforeStop2 = clearedHandles.length
localServer.stop()
Expand Down
Loading