import { PerformanceData } from './src/types/orm/entities/PerformanceData';
import { PerformanceRecord } from './src/types/orm/entities/PerformanceRecord';
-import Constants from './src/utils/Constants';
+import { Constants } from './src/utils/Constants';
export default {
metadataProvider: TsMorphMetadataProvider,
import fs from 'node:fs';
-import { FileType } from '../types/FileType';
-import FileUtils from '../utils/FileUtils';
-import logger from '../utils/Logger';
-import Utils from '../utils/Utils';
+import { FileType } from '../types';
+import { FileUtils } from '../utils/FileUtils';
+import { logger } from '../utils/Logger';
+import { Utils } from '../utils/Utils';
-export default class AuthorizedTagsCache {
+export class AuthorizedTagsCache {
private static instance: AuthorizedTagsCache | null = null;
private readonly tagsCaches: Map<string, string[]>;
private readonly FSWatchers: Map<string, fs.FSWatcher | undefined>;
import { AsyncResource } from 'async_hooks';
-import type ChargingStation from './ChargingStation';
+import type { ChargingStation } from './ChargingStation';
import { ChargingStationUtils } from './ChargingStationUtils';
-import BaseError from '../exception/BaseError';
-import PerformanceStatistics from '../performance/PerformanceStatistics';
-import {
- type AutomaticTransactionGeneratorConfiguration,
- IdTagDistribution,
- type Status,
-} from '../types/AutomaticTransactionGenerator';
-import { RequestCommand } from '../types/ocpp/Requests';
+import { BaseError } from '../exception';
+import { PerformanceStatistics } from '../performance/PerformanceStatistics';
import {
AuthorizationStatus,
type AuthorizeRequest,
type AuthorizeResponse,
+ type AutomaticTransactionGeneratorConfiguration,
+ IdTagDistribution,
+ RequestCommand,
type StartTransactionRequest,
type StartTransactionResponse,
+ type Status,
StopTransactionReason,
type StopTransactionResponse,
-} from '../types/ocpp/Transaction';
-import Constants from '../utils/Constants';
-import logger from '../utils/Logger';
-import Utils from '../utils/Utils';
+} from '../types';
+import { Constants } from '../utils/Constants';
+import { logger } from '../utils/Logger';
+import { Utils } from '../utils/Utils';
const moduleName = 'AutomaticTransactionGenerator';
-export default class AutomaticTransactionGenerator extends AsyncResource {
+export class AutomaticTransactionGenerator extends AsyncResource {
private static readonly instances: Map<string, AutomaticTransactionGenerator> = new Map<
string,
AutomaticTransactionGenerator
import { ChargingStationUtils } from './ChargingStationUtils';
import type { AbstractUIServer } from './ui-server/AbstractUIServer';
-import UIServerFactory from './ui-server/UIServerFactory';
+import { UIServerFactory } from './ui-server/UIServerFactory';
import { version } from '../../package.json';
-import BaseError from '../exception/BaseError';
+import { BaseError } from '../exception';
import type { Storage } from '../performance/storage/Storage';
import { StorageFactory } from '../performance/storage/StorageFactory';
import {
type ChargingStationWorkerMessage,
type ChargingStationWorkerMessageData,
ChargingStationWorkerMessageEvents,
-} from '../types/ChargingStationWorker';
-import type { StationTemplateUrl } from '../types/ConfigurationData';
-import type { Statistics } from '../types/Statistics';
-import type { MessageHandler } from '../types/Worker';
-import Configuration from '../utils/Configuration';
-import logger from '../utils/Logger';
-import Utils from '../utils/Utils';
-import type WorkerAbstract from '../worker/WorkerAbstract';
-import WorkerFactory from '../worker/WorkerFactory';
+ type StationTemplateUrl,
+ type Statistics,
+} from '../types';
+import { Configuration } from '../utils/Configuration';
+import { logger } from '../utils/Logger';
+import { Utils } from '../utils/Utils';
+import { type MessageHandler, type WorkerAbstract, WorkerFactory } from '../worker';
const moduleName = 'Bootstrap';
import merge from 'just-merge';
import WebSocket, { type RawData } from 'ws';
-import AuthorizedTagsCache from './AuthorizedTagsCache';
-import AutomaticTransactionGenerator from './AutomaticTransactionGenerator';
+import { AuthorizedTagsCache } from './AuthorizedTagsCache';
+import { AutomaticTransactionGenerator } from './AutomaticTransactionGenerator';
import { ChargingStationConfigurationUtils } from './ChargingStationConfigurationUtils';
import { ChargingStationUtils } from './ChargingStationUtils';
-import ChargingStationWorkerBroadcastChannel from './ChargingStationWorkerBroadcastChannel';
+import { ChargingStationWorkerBroadcastChannel } from './ChargingStationWorkerBroadcastChannel';
import { MessageChannelUtils } from './MessageChannelUtils';
-import OCPP16IncomingRequestService from './ocpp/1.6/OCPP16IncomingRequestService';
-import OCPP16RequestService from './ocpp/1.6/OCPP16RequestService';
-import OCPP16ResponseService from './ocpp/1.6/OCPP16ResponseService';
+import { OCPP16IncomingRequestService } from './ocpp/1.6/OCPP16IncomingRequestService';
+import { OCPP16RequestService } from './ocpp/1.6/OCPP16RequestService';
+import { OCPP16ResponseService } from './ocpp/1.6/OCPP16ResponseService';
import { OCPP16ServiceUtils } from './ocpp/1.6/OCPP16ServiceUtils';
-import OCPP20IncomingRequestService from './ocpp/2.0/OCPP20IncomingRequestService';
-import OCPP20RequestService from './ocpp/2.0/OCPP20RequestService';
-import OCPP20ResponseService from './ocpp/2.0/OCPP20ResponseService';
-import type OCPPIncomingRequestService from './ocpp/OCPPIncomingRequestService';
-import type OCPPRequestService from './ocpp/OCPPRequestService';
+import { OCPP20IncomingRequestService } from './ocpp/2.0/OCPP20IncomingRequestService';
+import { OCPP20RequestService } from './ocpp/2.0/OCPP20RequestService';
+import { OCPP20ResponseService } from './ocpp/2.0/OCPP20ResponseService';
+import type { OCPPIncomingRequestService } from './ocpp/OCPPIncomingRequestService';
+import type { OCPPRequestService } from './ocpp/OCPPRequestService';
import { OCPPServiceUtils } from './ocpp/OCPPServiceUtils';
-import SharedLRUCache from './SharedLRUCache';
-import BaseError from '../exception/BaseError';
-import OCPPError from '../exception/OCPPError';
-import PerformanceStatistics from '../performance/PerformanceStatistics';
-import type { AutomaticTransactionGeneratorConfiguration } from '../types/AutomaticTransactionGenerator';
-import type { ChargingStationConfiguration } from '../types/ChargingStationConfiguration';
-import type { ChargingStationInfo } from '../types/ChargingStationInfo';
-import type { ChargingStationOcppConfiguration } from '../types/ChargingStationOcppConfiguration';
-import {
- type ChargingStationTemplate,
- CurrentType,
- type FirmwareUpgrade,
- PowerUnits,
- type WsOptions,
-} from '../types/ChargingStationTemplate';
-import { SupervisionUrlDistribution } from '../types/ConfigurationData';
-import type { ConnectorStatus } from '../types/ConnectorStatus';
-import { FileType } from '../types/FileType';
-import type { JsonType } from '../types/JsonType';
-import {
- ConnectorPhaseRotation,
- StandardParametersKey,
- SupportedFeatureProfiles,
- VendorDefaultParametersKey,
-} from '../types/ocpp/Configuration';
-import { ConnectorStatusEnum } from '../types/ocpp/ConnectorStatusEnum';
-import { ErrorType } from '../types/ocpp/ErrorType';
-import { MessageType } from '../types/ocpp/MessageType';
-import { MeterValue, MeterValueMeasurand } from '../types/ocpp/MeterValues';
-import { OCPPVersion } from '../types/ocpp/OCPPVersion';
+import { SharedLRUCache } from './SharedLRUCache';
+import { BaseError, OCPPError } from '../exception';
+import { PerformanceStatistics } from '../performance/PerformanceStatistics';
import {
+ type AutomaticTransactionGeneratorConfiguration,
AvailabilityType,
type BootNotificationRequest,
+ type BootNotificationResponse,
type CachedRequest,
+ type ChargingStationConfiguration,
+ type ChargingStationInfo,
+ type ChargingStationOcppConfiguration,
+ type ChargingStationTemplate,
+ ConnectorPhaseRotation,
+ ConnectorStatus,
+ ConnectorStatusEnum,
+ CurrentType,
type ErrorCallback,
+ type ErrorResponse,
+ ErrorType,
+ FileType,
FirmwareStatus,
type FirmwareStatusNotificationRequest,
+ type FirmwareStatusNotificationResponse,
+ type FirmwareUpgrade,
type HeartbeatRequest,
+ type HeartbeatResponse,
type IncomingRequest,
- IncomingRequestCommand,
+ type IncomingRequestCommand,
+ type JsonType,
+ MessageType,
+ type MeterValue,
+ MeterValueMeasurand,
type MeterValuesRequest,
+ type MeterValuesResponse,
+ OCPPVersion,
type OutgoingRequest,
+ PowerUnits,
+ RegistrationStatusEnumType,
RequestCommand,
+ type Response,
type ResponseCallback,
+ StandardParametersKey,
type StatusNotificationRequest,
-} from '../types/ocpp/Requests';
-import {
- type BootNotificationResponse,
- type ErrorResponse,
- type FirmwareStatusNotificationResponse,
- type HeartbeatResponse,
- type MeterValuesResponse,
- RegistrationStatusEnumType,
- type Response,
type StatusNotificationResponse,
-} from '../types/ocpp/Responses';
-import {
StopTransactionReason,
type StopTransactionRequest,
type StopTransactionResponse,
-} from '../types/ocpp/Transaction';
-import { WSError, WebSocketCloseEventStatusCode } from '../types/WebSocket';
-import Configuration from '../utils/Configuration';
-import Constants from '../utils/Constants';
+ SupervisionUrlDistribution,
+ SupportedFeatureProfiles,
+ VendorDefaultParametersKey,
+ type WSError,
+ WebSocketCloseEventStatusCode,
+ type WsOptions,
+} from '../types';
+import { Configuration } from '../utils/Configuration';
+import { Constants } from '../utils/Constants';
import { ACElectricUtils, DCElectricUtils } from '../utils/ElectricUtils';
-import FileUtils from '../utils/FileUtils';
-import logger from '../utils/Logger';
-import Utils from '../utils/Utils';
+import { FileUtils } from '../utils/FileUtils';
+import { logger } from '../utils/Logger';
+import { Utils } from '../utils/Utils';
-export default class ChargingStation {
+export class ChargingStation {
public readonly index: number;
public readonly templateFile: string;
public stationInfo!: ChargingStationInfo;
-import type ChargingStation from './ChargingStation';
-import type { ConfigurationKey } from '../types/ChargingStationOcppConfiguration';
-import type { StandardParametersKey } from '../types/ocpp/Configuration';
-import logger from '../utils/Logger';
+import type { ChargingStation } from './ChargingStation';
+import type { ConfigurationKey, StandardParametersKey } from '../types';
+import { logger } from '../utils/Logger';
type ConfigurationKeyOptions = { readonly?: boolean; visible?: boolean; reboot?: boolean };
type DeleteConfigurationKeyParams = { save?: boolean; caseInsensitive?: boolean };
import moment from 'moment';
-import type ChargingStation from './ChargingStation';
-import BaseError from '../exception/BaseError';
-import type { ChargingStationInfo } from '../types/ChargingStationInfo';
+import type { ChargingStation } from './ChargingStation';
+import { BaseError } from '../exception';
import {
AmpereUnits,
- type ChargingStationTemplate,
- CurrentType,
- Voltage,
-} from '../types/ChargingStationTemplate';
-import { ChargingProfileKindType, RecurrencyKindType } from '../types/ocpp/1.6/ChargingProfile';
-import type { OCPP16BootNotificationRequest } from '../types/ocpp/1.6/Requests';
-import { BootReasonEnumType, type OCPP20BootNotificationRequest } from '../types/ocpp/2.0/Requests';
-import {
+ type BootNotificationRequest,
+ BootReasonEnumType,
type ChargingProfile,
+ ChargingProfileKindType,
ChargingRateUnitType,
type ChargingSchedulePeriod,
-} from '../types/ocpp/ChargingProfile';
-import { OCPPVersion } from '../types/ocpp/OCPPVersion';
-import type { BootNotificationRequest } from '../types/ocpp/Requests';
-import { WorkerProcessType } from '../types/Worker';
-import Configuration from '../utils/Configuration';
-import Constants from '../utils/Constants';
+ type ChargingStationInfo,
+ type ChargingStationTemplate,
+ CurrentType,
+ type OCPP16BootNotificationRequest,
+ type OCPP20BootNotificationRequest,
+ OCPPVersion,
+ RecurrencyKindType,
+ Voltage,
+} from '../types';
+import { Configuration } from '../utils/Configuration';
+import { Constants } from '../utils/Constants';
import { ACElectricUtils, DCElectricUtils } from '../utils/ElectricUtils';
-import logger from '../utils/Logger';
-import Utils from '../utils/Utils';
+import { logger } from '../utils/Logger';
+import { Utils } from '../utils/Utils';
+import { WorkerProcessType } from '../worker';
const moduleName = 'ChargingStationUtils';
import { ThreadWorker } from 'poolifier';
-import ChargingStation from './ChargingStation';
+import { ChargingStation } from './ChargingStation';
import { ChargingStationUtils } from './ChargingStationUtils';
-import type { ChargingStationWorkerData } from '../types/ChargingStationWorker';
-import { type WorkerMessage, WorkerMessageEvents } from '../types/Worker';
-import Utils from '../utils/Utils';
-import WorkerConstants from '../worker/WorkerConstants';
+import type { ChargingStationWorkerData } from '../types';
+import { Utils } from '../utils/Utils';
+import { WorkerConstants, type WorkerMessage, WorkerMessageEvents } from '../worker';
// Conditionally export ThreadWorker instance for pool usage
export let threadWorker: ThreadWorker;
-import type ChargingStation from './ChargingStation';
+import type { ChargingStation } from './ChargingStation';
import { ChargingStationConfigurationUtils } from './ChargingStationConfigurationUtils';
import { OCPP16ServiceUtils } from './ocpp/1.6/OCPP16ServiceUtils';
-import WorkerBroadcastChannel from './WorkerBroadcastChannel';
-import BaseError from '../exception/BaseError';
-import type OCPPError from '../exception/OCPPError';
-import { StandardParametersKey } from '../types/ocpp/Configuration';
+import { WorkerBroadcastChannel } from './WorkerBroadcastChannel';
+import { BaseError, type OCPPError } from '../exception';
import {
+ AuthorizationStatus,
+ type AuthorizeRequest,
+ type AuthorizeResponse,
type BootNotificationRequest,
- type DataTransferRequest,
- type DiagnosticsStatusNotificationRequest,
- type FirmwareStatusNotificationRequest,
- type HeartbeatRequest,
- type MeterValuesRequest,
- RequestCommand,
- type RequestParams,
- type StatusNotificationRequest,
-} from '../types/ocpp/Requests';
-import {
type BootNotificationResponse,
+ BroadcastChannelProcedureName,
+ type BroadcastChannelRequest,
+ type BroadcastChannelRequestPayload,
+ type BroadcastChannelResponsePayload,
+ type DataTransferRequest,
type DataTransferResponse,
DataTransferStatus,
+ type DiagnosticsStatusNotificationRequest,
type DiagnosticsStatusNotificationResponse,
+ type FirmwareStatusNotificationRequest,
type FirmwareStatusNotificationResponse,
+ type HeartbeatRequest,
type HeartbeatResponse,
+ type MessageEvent,
+ type MeterValuesRequest,
type MeterValuesResponse,
RegistrationStatusEnumType,
- type StatusNotificationResponse,
-} from '../types/ocpp/Responses';
-import {
- AuthorizationStatus,
- type AuthorizeRequest,
- type AuthorizeResponse,
+ RequestCommand,
+ type RequestParams,
+ ResponseStatus,
+ StandardParametersKey,
type StartTransactionRequest,
type StartTransactionResponse,
+ type StatusNotificationRequest,
+ type StatusNotificationResponse,
type StopTransactionRequest,
type StopTransactionResponse,
-} from '../types/ocpp/Transaction';
-import { ResponseStatus } from '../types/UIProtocol';
-import {
- BroadcastChannelProcedureName,
- type BroadcastChannelRequest,
- type BroadcastChannelRequestPayload,
- type BroadcastChannelResponsePayload,
- type MessageEvent,
-} from '../types/WorkerBroadcastChannel';
-import Constants from '../utils/Constants';
-import logger from '../utils/Logger';
-import Utils from '../utils/Utils';
+} from '../types';
+import { Constants } from '../utils/Constants';
+import { logger } from '../utils/Logger';
+import { Utils } from '../utils/Utils';
const moduleName = 'ChargingStationWorkerBroadcastChannel';
requestPayload?: BroadcastChannelRequestPayload
) => Promise<CommandResponse | void> | void;
-export default class ChargingStationWorkerBroadcastChannel extends WorkerBroadcastChannel {
+export class ChargingStationWorkerBroadcastChannel extends WorkerBroadcastChannel {
private readonly commandHandlers: Map<BroadcastChannelProcedureName, CommandHandler>;
private readonly chargingStation: ChargingStation;
-import type ChargingStation from './ChargingStation';
+import type { ChargingStation } from './ChargingStation';
import {
type ChargingStationData,
type ChargingStationWorkerMessage,
ChargingStationWorkerMessageEvents,
-} from '../types/ChargingStationWorker';
-import type { Statistics } from '../types/Statistics';
+ type Statistics,
+} from '../types';
export class MessageChannelUtils {
private constructor() {
import LRUCache from 'mnemonist/lru-map-with-delete';
import { Bootstrap } from '../internal';
-import type { ChargingStationConfiguration } from '../types/ChargingStationConfiguration';
-import type { ChargingStationTemplate } from '../types/ChargingStationTemplate';
-import Utils from '../utils/Utils';
+import type { ChargingStationConfiguration, ChargingStationTemplate } from '../types';
+import { Utils } from '../utils/Utils';
enum CacheType {
CHARGING_STATION_TEMPLATE = 'chargingStationTemplate',
type CacheableType = ChargingStationTemplate | ChargingStationConfiguration;
-export default class SharedLRUCache {
+export class SharedLRUCache {
private static instance: SharedLRUCache | null = null;
private readonly lruCache: LRUCache<string, CacheableType>;
-import type AbstractUIService from './ui-server/ui-services/AbstractUIService';
-import WorkerBroadcastChannel from './WorkerBroadcastChannel';
-import { type ResponsePayload, ResponseStatus } from '../types/UIProtocol';
-import type {
- BroadcastChannelResponse,
- BroadcastChannelResponsePayload,
- MessageEvent,
-} from '../types/WorkerBroadcastChannel';
-import logger from '../utils/Logger';
+import type { AbstractUIService } from './ui-server/ui-services/AbstractUIService';
+import { WorkerBroadcastChannel } from './WorkerBroadcastChannel';
+import {
+ type BroadcastChannelResponse,
+ type BroadcastChannelResponsePayload,
+ type MessageEvent,
+ type ResponsePayload,
+ ResponseStatus,
+} from '../types';
+import { logger } from '../utils/Logger';
const moduleName = 'UIServiceWorkerBroadcastChannel';
responses: BroadcastChannelResponsePayload[];
};
-export default class UIServiceWorkerBroadcastChannel extends WorkerBroadcastChannel {
+export class UIServiceWorkerBroadcastChannel extends WorkerBroadcastChannel {
private readonly uiService: AbstractUIService;
private readonly responses: Map<string, Responses>;
import { BroadcastChannel } from 'worker_threads';
-import type { JsonType } from '../types/JsonType';
import type {
BroadcastChannelRequest,
BroadcastChannelResponse,
+ JsonType,
MessageEvent,
-} from '../types/WorkerBroadcastChannel';
-import logger from '../utils/Logger';
-import Utils from '../utils/Utils';
+} from '../types';
+import { logger } from '../utils/Logger';
+import { Utils } from '../utils/Utils';
const moduleName = 'WorkerBroadcastChannel';
-export default abstract class WorkerBroadcastChannel extends BroadcastChannel {
+export abstract class WorkerBroadcastChannel extends BroadcastChannel {
protected constructor() {
super('worker');
}
import tar from 'tar';
import { OCPP16ServiceUtils } from './OCPP16ServiceUtils';
-import OCPPError from '../../../exception/OCPPError';
-import type { JsonObject, JsonType } from '../../../types/JsonType';
-import { OCPP16ChargePointErrorCode } from '../../../types/ocpp/1.6/ChargePointErrorCode';
-import { OCPP16ChargePointStatus } from '../../../types/ocpp/1.6/ChargePointStatus';
-import {
- ChargingProfilePurposeType,
- type OCPP16ChargingProfile,
-} from '../../../types/ocpp/1.6/ChargingProfile';
-import {
- OCPP16StandardParametersKey,
- OCPP16SupportedFeatureProfiles,
-} from '../../../types/ocpp/1.6/Configuration';
-import { OCPP16DiagnosticsStatus } from '../../../types/ocpp/1.6/DiagnosticsStatus';
+import { OCPPError } from '../../../exception';
import {
type ChangeAvailabilityRequest,
+ type ChangeAvailabilityResponse,
type ChangeConfigurationRequest,
+ type ChangeConfigurationResponse,
+ ChargingProfilePurposeType,
type ClearChargingProfileRequest,
+ type ClearChargingProfileResponse,
+ ErrorType,
+ type GenericResponse,
type GetConfigurationRequest,
+ type GetConfigurationResponse,
type GetDiagnosticsRequest,
+ type GetDiagnosticsResponse,
+ type IncomingRequestHandler,
+ type JsonObject,
+ type JsonType,
+ OCPP16AuthorizationStatus,
+ type OCPP16AuthorizeRequest,
+ type OCPP16AuthorizeResponse,
OCPP16AvailabilityType,
type OCPP16BootNotificationRequest,
+ type OCPP16BootNotificationResponse,
+ OCPP16ChargePointErrorCode,
+ OCPP16ChargePointStatus,
+ type OCPP16ChargingProfile,
type OCPP16ClearCacheRequest,
type OCPP16DataTransferRequest,
+ type OCPP16DataTransferResponse,
+ OCPP16DataTransferStatus,
OCPP16DataTransferVendorId,
+ OCPP16DiagnosticsStatus,
type OCPP16DiagnosticsStatusNotificationRequest,
+ type OCPP16DiagnosticsStatusNotificationResponse,
OCPP16FirmwareStatus,
type OCPP16FirmwareStatusNotificationRequest,
+ type OCPP16FirmwareStatusNotificationResponse,
type OCPP16HeartbeatRequest,
+ type OCPP16HeartbeatResponse,
OCPP16IncomingRequestCommand,
OCPP16MessageTrigger,
OCPP16RequestCommand,
+ OCPP16StandardParametersKey,
+ type OCPP16StartTransactionRequest,
+ type OCPP16StartTransactionResponse,
type OCPP16StatusNotificationRequest,
+ type OCPP16StatusNotificationResponse,
+ OCPP16StopTransactionReason,
+ OCPP16SupportedFeatureProfiles,
type OCPP16TriggerMessageRequest,
+ type OCPP16TriggerMessageResponse,
type OCPP16UpdateFirmwareRequest,
+ type OCPP16UpdateFirmwareResponse,
+ type OCPPConfigurationKey,
+ OCPPVersion,
type RemoteStartTransactionRequest,
type RemoteStopTransactionRequest,
type ResetRequest,
type SetChargingProfileRequest,
- type UnlockConnectorRequest,
-} from '../../../types/ocpp/1.6/Requests';
-import {
- type ChangeAvailabilityResponse,
- type ChangeConfigurationResponse,
- type ClearChargingProfileResponse,
- type GetConfigurationResponse,
- type GetDiagnosticsResponse,
- type OCPP16BootNotificationResponse,
- type OCPP16DataTransferResponse,
- OCPP16DataTransferStatus,
- type OCPP16DiagnosticsStatusNotificationResponse,
- type OCPP16FirmwareStatusNotificationResponse,
- type OCPP16HeartbeatResponse,
- type OCPP16StatusNotificationResponse,
- type OCPP16TriggerMessageResponse,
- type OCPP16UpdateFirmwareResponse,
type SetChargingProfileResponse,
+ type UnlockConnectorRequest,
type UnlockConnectorResponse,
-} from '../../../types/ocpp/1.6/Responses';
-import {
- OCPP16AuthorizationStatus,
- type OCPP16AuthorizeRequest,
- type OCPP16AuthorizeResponse,
- type OCPP16StartTransactionRequest,
- type OCPP16StartTransactionResponse,
- OCPP16StopTransactionReason,
-} from '../../../types/ocpp/1.6/Transaction';
-import type { OCPPConfigurationKey } from '../../../types/ocpp/Configuration';
-import { ErrorType } from '../../../types/ocpp/ErrorType';
-import { OCPPVersion } from '../../../types/ocpp/OCPPVersion';
-import type { IncomingRequestHandler } from '../../../types/ocpp/Requests';
-import type { GenericResponse } from '../../../types/ocpp/Responses';
-import Constants from '../../../utils/Constants';
-import logger from '../../../utils/Logger';
-import Utils from '../../../utils/Utils';
-import type ChargingStation from '../../ChargingStation';
+} from '../../../types';
+import { Constants } from '../../../utils/Constants';
+import { logger } from '../../../utils/Logger';
+import { Utils } from '../../../utils/Utils';
+import type { ChargingStation } from '../../ChargingStation';
import { ChargingStationConfigurationUtils } from '../../ChargingStationConfigurationUtils';
import { ChargingStationUtils } from '../../ChargingStationUtils';
-import OCPPConstants from '../OCPPConstants';
-import OCPPIncomingRequestService from '../OCPPIncomingRequestService';
+import { OCPPConstants } from '../OCPPConstants';
+import { OCPPIncomingRequestService } from '../OCPPIncomingRequestService';
const moduleName = 'OCPP16IncomingRequestService';
-export default class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
+export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
protected jsonSchemas: Map<OCPP16IncomingRequestCommand, JSONSchemaType<JsonObject>>;
private incomingRequestHandlers: Map<OCPP16IncomingRequestCommand, IncomingRequestHandler>;
import type { JSONSchemaType } from 'ajv';
import { OCPP16ServiceUtils } from './OCPP16ServiceUtils';
-import OCPPError from '../../../exception/OCPPError';
-import type { JsonObject, JsonType } from '../../../types/JsonType';
-import type { OCPP16MeterValuesRequest } from '../../../types/ocpp/1.6/MeterValues';
+import { OCPPError } from '../../../exception';
import {
+ ErrorType,
+ type JsonObject,
+ type JsonType,
+ type OCPP16AuthorizeRequest,
type OCPP16BootNotificationRequest,
type OCPP16DataTransferRequest,
type OCPP16DiagnosticsStatusNotificationRequest,
type OCPP16FirmwareStatusNotificationRequest,
type OCPP16HeartbeatRequest,
+ type OCPP16MeterValuesRequest,
OCPP16RequestCommand,
+ type OCPP16StartTransactionRequest,
type OCPP16StatusNotificationRequest,
-} from '../../../types/ocpp/1.6/Requests';
-import type {
- OCPP16AuthorizeRequest,
- OCPP16StartTransactionRequest,
- OCPP16StopTransactionRequest,
-} from '../../../types/ocpp/1.6/Transaction';
-import { ErrorType } from '../../../types/ocpp/ErrorType';
-import { OCPPVersion } from '../../../types/ocpp/OCPPVersion';
-import type { RequestParams } from '../../../types/ocpp/Requests';
-import Constants from '../../../utils/Constants';
-import Utils from '../../../utils/Utils';
-import type ChargingStation from '../../ChargingStation';
-import OCPPConstants from '../OCPPConstants';
-import OCPPRequestService from '../OCPPRequestService';
-import type OCPPResponseService from '../OCPPResponseService';
+ type OCPP16StopTransactionRequest,
+ OCPPVersion,
+ type RequestParams,
+} from '../../../types';
+import { Constants } from '../../../utils/Constants';
+import { Utils } from '../../../utils/Utils';
+import type { ChargingStation } from '../../ChargingStation';
+import { OCPPConstants } from '../OCPPConstants';
+import { OCPPRequestService } from '../OCPPRequestService';
+import type { OCPPResponseService } from '../OCPPResponseService';
const moduleName = 'OCPP16RequestService';
-export default class OCPP16RequestService extends OCPPRequestService {
+export class OCPP16RequestService extends OCPPRequestService {
protected jsonSchemas: Map<OCPP16RequestCommand, JSONSchemaType<JsonObject>>;
public constructor(ocppResponseService: OCPPResponseService) {
import type { JSONSchemaType } from 'ajv';
import { OCPP16ServiceUtils } from './OCPP16ServiceUtils';
-import OCPPError from '../../../exception/OCPPError';
-import type { JsonObject, JsonType } from '../../../types/JsonType';
-import { OCPP16ChargePointErrorCode } from '../../../types/ocpp/1.6/ChargePointErrorCode';
-import { OCPP16ChargePointStatus } from '../../../types/ocpp/1.6/ChargePointStatus';
-import { OCPP16StandardParametersKey } from '../../../types/ocpp/1.6/Configuration';
-import type {
- OCPP16MeterValuesRequest,
- OCPP16MeterValuesResponse,
-} from '../../../types/ocpp/1.6/MeterValues';
-import {
- type OCPP16BootNotificationRequest,
- OCPP16IncomingRequestCommand,
- OCPP16RequestCommand,
- type OCPP16StatusNotificationRequest,
-} from '../../../types/ocpp/1.6/Requests';
-import type {
- ChangeAvailabilityResponse,
- ChangeConfigurationResponse,
- ClearChargingProfileResponse,
- GetConfigurationResponse,
- GetDiagnosticsResponse,
- OCPP16BootNotificationResponse,
- OCPP16DataTransferResponse,
- OCPP16DiagnosticsStatusNotificationResponse,
- OCPP16FirmwareStatusNotificationResponse,
- OCPP16HeartbeatResponse,
- OCPP16StatusNotificationResponse,
- OCPP16TriggerMessageResponse,
- OCPP16UpdateFirmwareResponse,
- SetChargingProfileResponse,
- UnlockConnectorResponse,
-} from '../../../types/ocpp/1.6/Responses';
+import { OCPPError } from '../../../exception';
import {
+ type ChangeAvailabilityResponse,
+ type ChangeConfigurationResponse,
+ type ClearChargingProfileResponse,
+ ErrorType,
+ type GenericResponse,
+ type GetConfigurationResponse,
+ type GetDiagnosticsResponse,
+ type JsonObject,
+ type JsonType,
OCPP16AuthorizationStatus,
type OCPP16AuthorizeRequest,
type OCPP16AuthorizeResponse,
+ type OCPP16BootNotificationRequest,
+ type OCPP16BootNotificationResponse,
+ OCPP16ChargePointErrorCode,
+ OCPP16ChargePointStatus,
+ type OCPP16DataTransferResponse,
+ type OCPP16DiagnosticsStatusNotificationResponse,
+ type OCPP16FirmwareStatusNotificationResponse,
+ type OCPP16HeartbeatResponse,
+ OCPP16IncomingRequestCommand,
+ type OCPP16MeterValuesRequest,
+ type OCPP16MeterValuesResponse,
+ OCPP16RequestCommand,
+ OCPP16StandardParametersKey,
type OCPP16StartTransactionRequest,
type OCPP16StartTransactionResponse,
+ type OCPP16StatusNotificationRequest,
+ type OCPP16StatusNotificationResponse,
type OCPP16StopTransactionRequest,
type OCPP16StopTransactionResponse,
-} from '../../../types/ocpp/1.6/Transaction';
-import { ErrorType } from '../../../types/ocpp/ErrorType';
-import { OCPPVersion } from '../../../types/ocpp/OCPPVersion';
-import {
- type GenericResponse,
+ type OCPP16TriggerMessageResponse,
+ type OCPP16UpdateFirmwareResponse,
+ OCPPVersion,
RegistrationStatusEnumType,
type ResponseHandler,
-} from '../../../types/ocpp/Responses';
-import Constants from '../../../utils/Constants';
-import logger from '../../../utils/Logger';
-import Utils from '../../../utils/Utils';
-import type ChargingStation from '../../ChargingStation';
+ type SetChargingProfileResponse,
+ type UnlockConnectorResponse,
+} from '../../../types';
+import { Constants } from '../../../utils/Constants';
+import { logger } from '../../../utils/Logger';
+import { Utils } from '../../../utils/Utils';
+import type { ChargingStation } from '../../ChargingStation';
import { ChargingStationConfigurationUtils } from '../../ChargingStationConfigurationUtils';
-import OCPPResponseService from '../OCPPResponseService';
+import { OCPPResponseService } from '../OCPPResponseService';
const moduleName = 'OCPP16ResponseService';
-export default class OCPP16ResponseService extends OCPPResponseService {
+export class OCPP16ResponseService extends OCPPResponseService {
public jsonIncomingRequestResponseSchemas: Map<
OCPP16IncomingRequestCommand,
JSONSchemaType<JsonObject>
import type { JSONSchemaType } from 'ajv';
-import OCPPError from '../../../exception/OCPPError';
-import { CurrentType, Voltage } from '../../../types/ChargingStationTemplate';
-import type { JsonType } from '../../../types/JsonType';
-import type {
- MeasurandPerPhaseSampledValueTemplates,
- SampledValueTemplate,
-} from '../../../types/MeasurandPerPhaseSampledValueTemplates';
-import type { MeasurandValues } from '../../../types/MeasurandValues';
-import type { OCPP16ChargingProfile } from '../../../types/ocpp/1.6/ChargingProfile';
-import {
- OCPP16StandardParametersKey,
- OCPP16SupportedFeatureProfiles,
-} from '../../../types/ocpp/1.6/Configuration';
+import { OCPPError } from '../../../exception';
import {
+ CurrentType,
+ ErrorType,
+ type JsonType,
+ type MeasurandPerPhaseSampledValueTemplates,
+ type MeasurandValues,
MeterValueContext,
MeterValueLocation,
MeterValueUnit,
+ type OCPP16ChargingProfile,
+ type OCPP16IncomingRequestCommand,
type OCPP16MeterValue,
OCPP16MeterValueMeasurand,
OCPP16MeterValuePhase,
- type OCPP16SampledValue,
-} from '../../../types/ocpp/1.6/MeterValues';
-import {
- type OCPP16IncomingRequestCommand,
OCPP16RequestCommand,
-} from '../../../types/ocpp/1.6/Requests';
-import { ErrorType } from '../../../types/ocpp/ErrorType';
-import { OCPPVersion } from '../../../types/ocpp/OCPPVersion';
-import Constants from '../../../utils/Constants';
+ type OCPP16SampledValue,
+ OCPP16StandardParametersKey,
+ type OCPP16SupportedFeatureProfiles,
+ OCPPVersion,
+ type SampledValueTemplate,
+ Voltage,
+} from '../../../types';
+import { Constants } from '../../../utils/Constants';
import { ACElectricUtils, DCElectricUtils } from '../../../utils/ElectricUtils';
-import logger from '../../../utils/Logger';
-import Utils from '../../../utils/Utils';
-import type ChargingStation from '../../ChargingStation';
+import { logger } from '../../../utils/Logger';
+import { Utils } from '../../../utils/Utils';
+import type { ChargingStation } from '../../ChargingStation';
import { OCPPServiceUtils } from '../OCPPServiceUtils';
export class OCPP16ServiceUtils extends OCPPServiceUtils {
import type { JSONSchemaType } from 'ajv';
import { OCPP20ServiceUtils } from './OCPP20ServiceUtils';
-import OCPPError from '../../../exception/OCPPError';
-import type { JsonObject, JsonType } from '../../../types/JsonType';
+import { OCPPError } from '../../../exception';
import {
+ ErrorType,
+ type IncomingRequestHandler,
+ type JsonObject,
+ type JsonType,
type OCPP20ClearCacheRequest,
OCPP20IncomingRequestCommand,
-} from '../../../types/ocpp/2.0/Requests';
-import { ErrorType } from '../../../types/ocpp/ErrorType';
-import { OCPPVersion } from '../../../types/ocpp/OCPPVersion';
-import type { IncomingRequestHandler } from '../../../types/ocpp/Requests';
-import logger from '../../../utils/Logger';
-import type ChargingStation from '../../ChargingStation';
-import OCPPIncomingRequestService from '../OCPPIncomingRequestService';
+ OCPPVersion,
+} from '../../../types';
+import { logger } from '../../../utils/Logger';
+import type { ChargingStation } from '../../ChargingStation';
+import { OCPPIncomingRequestService } from '../OCPPIncomingRequestService';
const moduleName = 'OCPP20IncomingRequestService';
-export default class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
+export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
protected jsonSchemas: Map<OCPP20IncomingRequestCommand, JSONSchemaType<JsonObject>>;
private incomingRequestHandlers: Map<OCPP20IncomingRequestCommand, IncomingRequestHandler>;
import type { JSONSchemaType } from 'ajv';
import { OCPP20ServiceUtils } from './OCPP20ServiceUtils';
-import OCPPError from '../../../exception/OCPPError';
-import type { JsonObject, JsonType } from '../../../types/JsonType';
+import { OCPPError } from '../../../exception';
import {
+ ErrorType,
+ type JsonObject,
+ type JsonType,
type OCPP20BootNotificationRequest,
type OCPP20HeartbeatRequest,
OCPP20RequestCommand,
type OCPP20StatusNotificationRequest,
-} from '../../../types/ocpp/2.0/Requests';
-import { ErrorType } from '../../../types/ocpp/ErrorType';
-import { OCPPVersion } from '../../../types/ocpp/OCPPVersion';
-import type { RequestParams } from '../../../types/ocpp/Requests';
-import Utils from '../../../utils/Utils';
-import type ChargingStation from '../../ChargingStation';
-import OCPPConstants from '../OCPPConstants';
-import OCPPRequestService from '../OCPPRequestService';
-import type OCPPResponseService from '../OCPPResponseService';
+ OCPPVersion,
+ type RequestParams,
+} from '../../../types';
+import { Utils } from '../../../utils/Utils';
+import type { ChargingStation } from '../../ChargingStation';
+import { OCPPConstants } from '../OCPPConstants';
+import { OCPPRequestService } from '../OCPPRequestService';
+import type { OCPPResponseService } from '../OCPPResponseService';
const moduleName = 'OCPP20RequestService';
-export default class OCPP20RequestService extends OCPPRequestService {
+export class OCPP20RequestService extends OCPPRequestService {
protected jsonSchemas: Map<OCPP20RequestCommand, JSONSchemaType<JsonObject>>;
public constructor(ocppResponseService: OCPPResponseService) {
import type { JSONSchemaType } from 'ajv';
import { OCPP20ServiceUtils } from './OCPP20ServiceUtils';
-import OCPPError from '../../../exception/OCPPError';
-import type { JsonObject, JsonType } from '../../../types/JsonType';
+import { OCPPError } from '../../../exception';
import {
+ ErrorType,
+ type JsonObject,
+ type JsonType,
+ OCPP16StandardParametersKey,
+ type OCPP20BootNotificationResponse,
+ type OCPP20ClearCacheResponse,
+ type OCPP20HeartbeatResponse,
OCPP20IncomingRequestCommand,
OCPP20RequestCommand,
-} from '../../../types/ocpp/2.0/Requests';
-import type {
- OCPP20BootNotificationResponse,
- OCPP20ClearCacheResponse,
- OCPP20HeartbeatResponse,
- OCPP20StatusNotificationResponse,
-} from '../../../types/ocpp/2.0/Responses';
-import { ErrorType } from '../../../types/ocpp/ErrorType';
-import { OCPPVersion } from '../../../types/ocpp/OCPPVersion';
-import { RegistrationStatusEnumType, ResponseHandler } from '../../../types/ocpp/Responses';
-import logger from '../../../utils/Logger';
-import type ChargingStation from '../../ChargingStation';
-import OCPPResponseService from '../OCPPResponseService';
+ type OCPP20StatusNotificationResponse,
+ OCPPVersion,
+ RegistrationStatusEnumType,
+ type ResponseHandler,
+} from '../../../types';
+import { logger } from '../../../utils/Logger';
+import type { ChargingStation } from '../../ChargingStation';
+import { ChargingStationConfigurationUtils } from '../../ChargingStationConfigurationUtils';
+import { OCPPResponseService } from '../OCPPResponseService';
const moduleName = 'OCPP20ResponseService';
-export default class OCPP20ResponseService extends OCPPResponseService {
+export class OCPP20ResponseService extends OCPPResponseService {
public jsonIncomingRequestResponseSchemas: Map<
OCPP20IncomingRequestCommand,
JSONSchemaType<JsonObject>
payload: OCPP20BootNotificationResponse
): void {
if (payload.status === RegistrationStatusEnumType.ACCEPTED) {
- // ChargingStationConfigurationUtils.addConfigurationKey(
- // chargingStation,
- // OCPP16StandardParametersKey.HeartbeatInterval,
- // payload.interval.toString(),
- // {},
- // { overwrite: true, save: true }
- // );
- // ChargingStationConfigurationUtils.addConfigurationKey(
- // chargingStation,
- // OCPP16StandardParametersKey.HeartBeatInterval,
- // payload.interval.toString(),
- // { visible: false },
- // { overwrite: true, save: true }
- // );
+ ChargingStationConfigurationUtils.addConfigurationKey(
+ chargingStation,
+ OCPP16StandardParametersKey.HeartbeatInterval,
+ payload.interval.toString(),
+ {},
+ { overwrite: true, save: true }
+ );
+ ChargingStationConfigurationUtils.addConfigurationKey(
+ chargingStation,
+ OCPP16StandardParametersKey.HeartBeatInterval,
+ payload.interval.toString(),
+ { visible: false },
+ { overwrite: true, save: true }
+ );
chargingStation.heartbeatSetInterval
? chargingStation.restartHeartbeat()
: chargingStation.startHeartbeat();
import type { JSONSchemaType } from 'ajv';
-import type { JsonType } from '../../../types/JsonType';
-import { OCPPVersion } from '../../../types/ocpp/OCPPVersion';
+import { type JsonType, OCPPVersion } from '../../../types';
import { OCPPServiceUtils } from '../OCPPServiceUtils';
export class OCPP20ServiceUtils extends OCPPServiceUtils {
GenericStatus,
TriggerMessageStatus,
UnlockStatus,
-} from '../../types/ocpp/Responses';
+} from '../../types';
-export default class OCPPConstants {
+export class OCPPConstants {
static readonly OCPP_REQUEST_EMPTY = Object.freeze({});
static readonly OCPP_RESPONSE_EMPTY = Object.freeze({});
static readonly OCPP_RESPONSE_ACCEPTED = Object.freeze({ status: GenericStatus.ACCEPTED });
import Ajv, { type JSONSchemaType } from 'ajv';
import ajvFormats from 'ajv-formats';
-import OCPPConstants from './OCPPConstants';
+import { OCPPConstants } from './OCPPConstants';
import { OCPPServiceUtils } from './OCPPServiceUtils';
-import OCPPError from '../../exception/OCPPError';
-import type { HandleErrorParams } from '../../types/Error';
-import type { JsonObject, JsonType } from '../../types/JsonType';
-import type { OCPPVersion } from '../../types/ocpp/OCPPVersion';
-import type { IncomingRequestCommand } from '../../types/ocpp/Requests';
-import type { ClearCacheResponse } from '../../types/ocpp/Responses';
-import logger from '../../utils/Logger';
-import type ChargingStation from '../ChargingStation';
+import { OCPPError } from '../../exception';
+import type {
+ ClearCacheResponse,
+ HandleErrorParams,
+ IncomingRequestCommand,
+ JsonObject,
+ JsonType,
+ OCPPVersion,
+} from '../../types';
+import { logger } from '../../utils/Logger';
+import type { ChargingStation } from '../ChargingStation';
import { ChargingStationUtils } from '../ChargingStationUtils';
const moduleName = 'OCPPIncomingRequestService';
-export default abstract class OCPPIncomingRequestService extends AsyncResource {
+export abstract class OCPPIncomingRequestService extends AsyncResource {
private static instance: OCPPIncomingRequestService | null = null;
private readonly version: OCPPVersion;
private readonly ajv: Ajv;
import Ajv, { type JSONSchemaType } from 'ajv';
import ajvFormats from 'ajv-formats';
-import type OCPPResponseService from './OCPPResponseService';
+import type { OCPPResponseService } from './OCPPResponseService';
import { OCPPServiceUtils } from './OCPPServiceUtils';
-import OCPPError from '../../exception/OCPPError';
-import PerformanceStatistics from '../../performance/PerformanceStatistics';
-import type { EmptyObject } from '../../types/EmptyObject';
-import type { HandleErrorParams } from '../../types/Error';
-import type { JsonObject, JsonType } from '../../types/JsonType';
-import { ErrorType } from '../../types/ocpp/ErrorType';
-import { MessageType } from '../../types/ocpp/MessageType';
-import type { OCPPVersion } from '../../types/ocpp/OCPPVersion';
+import { OCPPError } from '../../exception';
+import { PerformanceStatistics } from '../../performance/PerformanceStatistics';
import {
+ type EmptyObject,
type ErrorCallback,
+ type ErrorResponse,
+ ErrorType,
+ type HandleErrorParams,
type IncomingRequestCommand,
+ type JsonObject,
+ type JsonType,
+ MessageType,
+ type OCPPVersion,
type OutgoingRequest,
RequestCommand,
type RequestParams,
+ type Response,
type ResponseCallback,
type ResponseType,
-} from '../../types/ocpp/Requests';
-import type { ErrorResponse, Response } from '../../types/ocpp/Responses';
-import Constants from '../../utils/Constants';
-import logger from '../../utils/Logger';
-import Utils from '../../utils/Utils';
-import type ChargingStation from '../ChargingStation';
+} from '../../types';
+import { Constants } from '../../utils/Constants';
+import { logger } from '../../utils/Logger';
+import { Utils } from '../../utils/Utils';
+import type { ChargingStation } from '../ChargingStation';
const moduleName = 'OCPPRequestService';
-export default abstract class OCPPRequestService {
+export abstract class OCPPRequestService {
private static instance: OCPPRequestService | null = null;
private readonly version: OCPPVersion;
private readonly ajv: Ajv;
import ajvFormats from 'ajv-formats';
import { OCPPServiceUtils } from './OCPPServiceUtils';
-import OCPPError from '../../exception/OCPPError';
-import type { JsonObject, JsonType } from '../../types/JsonType';
-import type { OCPPVersion } from '../../types/ocpp/OCPPVersion';
-import type { IncomingRequestCommand, RequestCommand } from '../../types/ocpp/Requests';
-import logger from '../../utils/Logger';
-import type ChargingStation from '../ChargingStation';
+import { OCPPError } from '../../exception';
+import type {
+ IncomingRequestCommand,
+ JsonObject,
+ JsonType,
+ OCPPVersion,
+ RequestCommand,
+} from '../../types';
+import { logger } from '../../utils/Logger';
+import type { ChargingStation } from '../ChargingStation';
const moduleName = 'OCPPResponseService';
-export default abstract class OCPPResponseService {
+export abstract class OCPPResponseService {
private static instance: OCPPResponseService | null = null;
private readonly version: OCPPVersion;
private readonly ajv: Ajv;
import type { DefinedError, ErrorObject, JSONSchemaType } from 'ajv';
-import BaseError from '../../exception/BaseError';
-import { FileType } from '../../types/FileType';
-import type { JsonObject, JsonType } from '../../types/JsonType';
-import type { SampledValueTemplate } from '../../types/MeasurandPerPhaseSampledValueTemplates';
-import type { OCPP16StatusNotificationRequest } from '../../types/ocpp/1.6/Requests';
-import type { OCPP20StatusNotificationRequest } from '../../types/ocpp/2.0/Requests';
-import { ChargePointErrorCode } from '../../types/ocpp/ChargePointErrorCode';
-import { StandardParametersKey } from '../../types/ocpp/Configuration';
-import type { ConnectorStatusEnum } from '../../types/ocpp/ConnectorStatusEnum';
-import { ErrorType } from '../../types/ocpp/ErrorType';
-import { MessageType } from '../../types/ocpp/MessageType';
-import { MeterValueMeasurand, type MeterValuePhase } from '../../types/ocpp/MeterValues';
-import { OCPPVersion } from '../../types/ocpp/OCPPVersion';
+import { BaseError } from '../../exception';
import {
+ ChargePointErrorCode,
+ type ConnectorStatusEnum,
+ ErrorType,
+ FileType,
IncomingRequestCommand,
+ type JsonObject,
+ type JsonType,
MessageTrigger,
+ MessageType,
+ MeterValueMeasurand,
+ type MeterValuePhase,
+ type OCPP16StatusNotificationRequest,
+ type OCPP20StatusNotificationRequest,
+ OCPPVersion,
RequestCommand,
+ type SampledValueTemplate,
+ StandardParametersKey,
type StatusNotificationRequest,
-} from '../../types/ocpp/Requests';
-import Constants from '../../utils/Constants';
-import FileUtils from '../../utils/FileUtils';
-import logger from '../../utils/Logger';
-import Utils from '../../utils/Utils';
-import type ChargingStation from '../ChargingStation';
+} from '../../types';
+import { Constants } from '../../utils/Constants';
+import { FileUtils } from '../../utils/FileUtils';
+import { logger } from '../../utils/Logger';
+import { Utils } from '../../utils/Utils';
+import type { ChargingStation } from '../ChargingStation';
import { ChargingStationConfigurationUtils } from '../ChargingStationConfigurationUtils';
export class OCPPServiceUtils {
import type { WebSocket } from 'ws';
-import type AbstractUIService from './ui-services/AbstractUIService';
-import UIServiceFactory from './ui-services/UIServiceFactory';
-import type { ChargingStationData } from '../../types/ChargingStationWorker';
-import type { UIServerConfiguration } from '../../types/ConfigurationData';
+import type { AbstractUIService } from './ui-services/AbstractUIService';
+import { UIServiceFactory } from './ui-services/UIServiceFactory';
import {
AuthenticationType,
+ type ChargingStationData,
type ProcedureName,
type ProtocolRequest,
type ProtocolResponse,
type ProtocolVersion,
type RequestPayload,
type ResponsePayload,
-} from '../../types/UIProtocol';
+ type UIServerConfiguration,
+} from '../../types';
export abstract class AbstractUIServer {
public readonly chargingStations: Map<string, ChargingStationData>;
import { AbstractUIServer } from './AbstractUIServer';
import { UIServerUtils } from './UIServerUtils';
-import BaseError from '../../exception/BaseError';
-import type { UIServerConfiguration } from '../../types/ConfigurationData';
+import { BaseError } from '../../exception';
import {
type ProcedureName,
type Protocol,
type ProtocolVersion,
type RequestPayload,
ResponseStatus,
-} from '../../types/UIProtocol';
-import logger from '../../utils/Logger';
-import Utils from '../../utils/Utils';
+ type UIServerConfiguration,
+} from '../../types';
+import { logger } from '../../utils/Logger';
+import { Utils } from '../../utils/Utils';
const moduleName = 'UIHttpServer';
-export default class UIHttpServer extends AbstractUIServer {
+export class UIHttpServer extends AbstractUIServer {
public constructor(protected readonly uiServerConfiguration: UIServerConfiguration) {
super(uiServerConfiguration);
}
import chalk from 'chalk';
import type { AbstractUIServer } from './AbstractUIServer';
-import UIHttpServer from './UIHttpServer';
+import { UIHttpServer } from './UIHttpServer';
import { UIServerUtils } from './UIServerUtils';
-import UIWebSocketServer from './UIWebSocketServer';
-import type { UIServerConfiguration } from '../../types/ConfigurationData';
-import { ApplicationProtocol } from '../../types/UIProtocol';
-import Configuration from '../../utils/Configuration';
+import { UIWebSocketServer } from './UIWebSocketServer';
+import { ApplicationProtocol, type UIServerConfiguration } from '../../types';
+import { Configuration } from '../../utils/Configuration';
-export default class UIServerFactory {
+export class UIServerFactory {
private constructor() {
// This is intentional
}
import type { IncomingMessage } from 'http';
-import { Protocol, ProtocolVersion } from '../../types/UIProtocol';
-import logger from '../../utils/Logger';
-import Utils from '../../utils/Utils';
+import { Protocol, ProtocolVersion } from '../../types';
+import { logger } from '../../utils/Logger';
+import { Utils } from '../../utils/Utils';
export class UIServerUtils {
private constructor() {
import { AbstractUIServer } from './AbstractUIServer';
import { UIServerUtils } from './UIServerUtils';
-import type { UIServerConfiguration } from '../../types/ConfigurationData';
-import type { ProtocolRequest, ProtocolResponse } from '../../types/UIProtocol';
-import { WebSocketCloseEventStatusCode } from '../../types/WebSocket';
-import logger from '../../utils/Logger';
-import Utils from '../../utils/Utils';
+import {
+ type ProtocolRequest,
+ type ProtocolResponse,
+ type UIServerConfiguration,
+ WebSocketCloseEventStatusCode,
+} from '../../types';
+import { logger } from '../../utils/Logger';
+import { Utils } from '../../utils/Utils';
const moduleName = 'UIWebSocketServer';
-export default class UIWebSocketServer extends AbstractUIServer {
+export class UIWebSocketServer extends AbstractUIServer {
private readonly webSocketServer: WebSocketServer;
public constructor(protected readonly uiServerConfiguration: UIServerConfiguration) {
-import BaseError from '../../../exception/BaseError';
-import type OCPPError from '../../../exception/OCPPError';
+import { BaseError, type OCPPError } from '../../../exception';
import { Bootstrap } from '../../../internal';
import {
+ BroadcastChannelProcedureName,
+ type BroadcastChannelRequestPayload,
ProcedureName,
type ProtocolRequest,
type ProtocolRequestHandler,
type RequestPayload,
type ResponsePayload,
ResponseStatus,
-} from '../../../types/UIProtocol';
-import {
- BroadcastChannelProcedureName,
- type BroadcastChannelRequestPayload,
-} from '../../../types/WorkerBroadcastChannel';
-import logger from '../../../utils/Logger';
-import Utils from '../../../utils/Utils';
-import UIServiceWorkerBroadcastChannel from '../../UIServiceWorkerBroadcastChannel';
+} from '../../../types';
+import { logger } from '../../../utils/Logger';
+import { Utils } from '../../../utils/Utils';
+import { UIServiceWorkerBroadcastChannel } from '../../UIServiceWorkerBroadcastChannel';
import type { AbstractUIServer } from '../AbstractUIServer';
const moduleName = 'AbstractUIService';
-export default abstract class AbstractUIService {
+export abstract class AbstractUIService {
protected static readonly ProcedureNameToBroadCastChannelProcedureNameMap: Omit<
Record<ProcedureName, BroadcastChannelProcedureName>,
| ProcedureName.START_SIMULATOR
-import AbstractUIService from './AbstractUIService';
-import {
- ProcedureName,
- type ProtocolRequestHandler,
- ProtocolVersion,
-} from '../../../types/UIProtocol';
+import { AbstractUIService } from './AbstractUIService';
+import { type ProcedureName, type ProtocolRequestHandler, ProtocolVersion } from '../../../types';
import type { AbstractUIServer } from '../AbstractUIServer';
-export default class UIService001 extends AbstractUIService {
+export class UIService001 extends AbstractUIService {
constructor(uiServer: AbstractUIServer) {
super(uiServer, ProtocolVersion['0.0.1']);
for (const procedureName of Object.keys(
-import type AbstractUIService from './AbstractUIService';
-import UIService001 from './UIService001';
-import { ProtocolVersion } from '../../../types/UIProtocol';
+import type { AbstractUIService } from './AbstractUIService';
+import { UIService001 } from './UIService001';
+import { ProtocolVersion } from '../../../types';
import type { AbstractUIServer } from '../AbstractUIServer';
-export default class UIServiceFactory {
+export class UIServiceFactory {
private constructor() {
// This is intentional
}
-export default class BaseError extends Error {
+export class BaseError extends Error {
public constructor(message?: string) {
super(message);
this.name = new.target.name;
// Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
-import BaseError from './BaseError';
-import type { JsonType } from '../types/JsonType';
-import { ErrorType } from '../types/ocpp/ErrorType';
-import type { IncomingRequestCommand, RequestCommand } from '../types/ocpp/Requests';
+import { BaseError } from './BaseError';
+import {
+ ErrorType,
+ type IncomingRequestCommand,
+ type JsonType,
+ type RequestCommand,
+} from '../types';
-export default class OCPPError extends BaseError {
+export class OCPPError extends BaseError {
code: ErrorType;
command?: RequestCommand | IncomingRequestCommand;
details?: JsonType;
--- /dev/null
+export * from './BaseError';
+export * from './OCPPError';
import { parentPort } from 'worker_threads';
import { MessageChannelUtils } from '../charging-station/MessageChannelUtils';
-import { MessageType } from '../types/ocpp/MessageType';
-import type { IncomingRequestCommand, RequestCommand } from '../types/ocpp/Requests';
-import type { Statistics, TimeSeries } from '../types/Statistics';
+import {
+ type IncomingRequestCommand,
+ MessageType,
+ type RequestCommand,
+ type Statistics,
+ type TimeSeries,
+} from '../types';
import { CircularArray } from '../utils/CircularArray';
-import Configuration from '../utils/Configuration';
-import Constants from '../utils/Constants';
-import logger from '../utils/Logger';
-import Utils from '../utils/Utils';
+import { Configuration } from '../utils/Configuration';
+import { Constants } from '../utils/Constants';
+import { logger } from '../utils/Logger';
+import { Utils } from '../utils/Utils';
-export default class PerformanceStatistics {
+export class PerformanceStatistics {
private static readonly instances: Map<string, PerformanceStatistics> = new Map<
string,
PerformanceStatistics
import lockfile from 'proper-lockfile';
import { Storage } from './Storage';
-import { FileType } from '../../types/FileType';
-import type { Statistics } from '../../types/Statistics';
-import FileUtils from '../../utils/FileUtils';
-import Utils from '../../utils/Utils';
+import { FileType, type Statistics } from '../../types';
+import { FileUtils } from '../../utils/FileUtils';
+import { Utils } from '../../utils/Utils';
export class JsonFileStorage extends Storage {
private fd: number | null = null;
import { TsMorphMetadataProvider } from '@mikro-orm/reflection';
import { Storage } from './Storage';
-import { PerformanceData } from '../../types/orm/entities/PerformanceData';
-import { PerformanceRecord } from '../../types/orm/entities/PerformanceRecord';
-import type { Statistics } from '../../types/Statistics';
-import { MikroORMDBType, StorageType } from '../../types/Storage';
-import Constants from '../../utils/Constants';
+import {
+ type MikroORMDBType,
+ PerformanceData,
+ PerformanceRecord,
+ type Statistics,
+ StorageType,
+} from '../../types';
+import { Constants } from '../../utils/Constants';
export class MikroOrmStorage extends Storage {
private storageType: StorageType;
import { MongoClient } from 'mongodb';
import { Storage } from './Storage';
-import type { Statistics } from '../../types/Statistics';
-import { StorageType } from '../../types/Storage';
-import Constants from '../../utils/Constants';
+import { type Statistics, StorageType } from '../../types';
+import { Constants } from '../../utils/Constants';
export class MongoDBStorage extends Storage {
private readonly client: MongoClient | null;
import { URL } from 'node:url';
-import type { EmptyObject } from '../../types/EmptyObject';
-import type { HandleErrorParams } from '../../types/Error';
-import type { Statistics } from '../../types/Statistics';
-import { DBName, StorageType } from '../../types/Storage';
-import logger from '../../utils/Logger';
-import Utils from '../../utils/Utils';
+import {
+ DBName,
+ type EmptyObject,
+ type HandleErrorParams,
+ type Statistics,
+ StorageType,
+} from '../../types';
+import { logger } from '../../utils/Logger';
+import { Utils } from '../../utils/Utils';
export abstract class Storage {
protected readonly storageUri: URL;
import { MikroOrmStorage } from './MikroOrmStorage';
import { MongoDBStorage } from './MongoDBStorage';
import type { Storage } from './Storage';
-import { StorageType } from '../../types/Storage';
+import { StorageType } from '../../types';
export class StorageFactory {
private constructor() {
import type { JsonObject } from './JsonType';
import type { BootNotificationResponse } from './ocpp/Responses';
import type { Statistics } from './Statistics';
-import { WorkerData, WorkerMessage, WorkerMessageEvents } from './Worker';
+import { type WorkerData, type WorkerMessage, WorkerMessageEvents } from '../worker';
export interface ChargingStationWorkerOptions extends JsonObject {
elementStartDelay?: number;
import type { StorageType } from './Storage';
import type { ApplicationProtocol, AuthenticationType } from './UIProtocol';
-import type { WorkerProcessType } from './Worker';
+import type { WorkerProcessType } from '../worker';
export type ServerOptions = ListenOptions;
import type { IncomingRequestCommand, RequestCommand } from './ocpp/Requests';
-import type { WorkerData } from './Worker';
import type { CircularArray } from '../utils/CircularArray';
+import type { WorkerData } from '../worker';
export type TimeSeries = {
timestamp: number;
--- /dev/null
+export * from './ocpp/ChargePointErrorCode';
+export * from './ocpp/ChargingProfile';
+export * from './ocpp/Configuration';
+export * from './ocpp/ConnectorStatusEnum';
+export * from './ocpp/ErrorType';
+export * from './ocpp/MessageType';
+export * from './ocpp/MeterValues';
+export * from './ocpp/OCPPProtocol';
+export * from './ocpp/OCPPVersion';
+export * from './ocpp/Requests';
+export * from './ocpp/Responses';
+export * from './ocpp/Transaction';
+export * from './ocpp/1.6/ChargePointErrorCode';
+export * from './ocpp/1.6/ChargePointStatus';
+export * from './ocpp/1.6/ChargingProfile';
+export * from './ocpp/1.6/Configuration';
+export * from './ocpp/1.6/DiagnosticsStatus';
+export * from './ocpp/1.6/MeterValues';
+export * from './ocpp/1.6/Requests';
+export * from './ocpp/1.6/Responses';
+export * from './ocpp/1.6/Transaction';
+export * from './ocpp/2.0/Requests';
+export * from './ocpp/2.0/Responses';
+export * from './orm/entities/PerformanceData';
+export * from './orm/entities/PerformanceRecord';
+export * from './AutomaticTransactionGenerator';
+export * from './ChargingStationConfiguration';
+export * from './ChargingStationInfo';
+export * from './ChargingStationOcppConfiguration';
+export * from './ChargingStationTemplate';
+export * from './ChargingStationWorker';
+export * from './ConfigurationData';
+export * from './ConnectorStatus';
+export * from './EmptyObject';
+export * from './Error';
+export * from './FileType';
+export * from './JsonType';
+export * from './MeasurandPerPhaseSampledValueTemplates';
+export * from './MeasurandValues';
+export * from './Statistics';
+export * from './Storage';
+export * from './UIProtocol';
+export * from './WebSocket';
+export * from './WorkerBroadcastChannel';
type OCPP20StatusNotificationRequest,
} from './2.0/Requests';
import type { MessageType } from './MessageType';
-import type ChargingStation from '../../charging-station/ChargingStation';
-import type OCPPError from '../../exception/OCPPError';
+import type { ChargingStation } from '../../charging-station/ChargingStation';
+import type { OCPPError } from '../../exception';
import type { JsonType } from '../JsonType';
export const RequestCommand = {
} from './2.0/Responses';
import type { ErrorType } from './ErrorType';
import type { MessageType } from './MessageType';
-import type ChargingStation from '../../charging-station/ChargingStation';
+import type { ChargingStation } from '../../charging-station/ChargingStation';
import type { JsonType } from '../JsonType';
export type Response = [MessageType.CALL_RESULT_MESSAGE, string, JsonType];
import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core';
-import { PerformanceRecord } from './PerformanceRecord';
+import type { PerformanceRecord } from './PerformanceRecord';
@Entity()
export class PerformanceData {
import merge from 'just-merge';
import { WorkerChoiceStrategies } from 'poolifier';
-import Constants from './Constants';
+import { Constants } from './Constants';
import {
+ ApplicationProtocol,
type ConfigurationData,
+ type EmptyObject,
+ FileType,
+ type HandleErrorParams,
type StationTemplateUrl,
type StorageConfiguration,
+ StorageType,
SupervisionUrlDistribution,
type UIServerConfiguration,
type WorkerConfiguration,
-} from '../types/ConfigurationData';
-import type { EmptyObject } from '../types/EmptyObject';
-import type { HandleErrorParams } from '../types/Error';
-import { FileType } from '../types/FileType';
-import { StorageType } from '../types/Storage';
-import { ApplicationProtocol } from '../types/UIProtocol';
-import { WorkerProcessType } from '../types/Worker';
-import WorkerConstants from '../worker/WorkerConstants';
+} from '../types';
+import { WorkerConstants, WorkerProcessType } from '../worker';
-export default class Configuration {
+export class Configuration {
private static configurationFile = path.join(
path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../'),
'assets',
-import { MeterValueMeasurand } from '../types/ocpp/MeterValues';
+import { MeterValueMeasurand } from '../types';
-export default class Constants {
+export class Constants {
static readonly OCPP_DEFAULT_BOOT_NOTIFICATION_INTERVAL = 60000; // Ms
static readonly OCPP_WEBSOCKET_TIMEOUT = 60000; // Ms
static readonly OCPP_TRIGGER_MESSAGE_DELAY = 500; // Ms
import chalk from 'chalk';
-import logger from './Logger';
-import Utils from './Utils';
-import type { EmptyObject } from '../types/EmptyObject';
-import type { HandleErrorParams } from '../types/Error';
-import type { FileType } from '../types/FileType';
-import type { JsonType } from '../types/JsonType';
+import { logger } from './Logger';
+import { Utils } from './Utils';
+import type { EmptyObject, FileType, HandleErrorParams, JsonType } from '../types';
-export default class FileUtils {
+export class FileUtils {
private constructor() {
// This is intentional
}
import TransportType from 'winston/lib/winston/transports';
import DailyRotateFile from 'winston-daily-rotate-file';
-import Configuration from './Configuration';
-import Utils from './Utils';
+import { Configuration } from './Configuration';
+import { Utils } from './Utils';
let transports: transport[];
if (Configuration.getLogRotate() === true) {
);
}
-export default logger;
+export { logger };
import clone from 'just-clone';
-import Constants from './Constants';
-import { WebSocketCloseEventStatusString } from '../types/WebSocket';
+import { Constants } from './Constants';
+import { WebSocketCloseEventStatusString } from '../types';
-export default class Utils {
+export class Utils {
private constructor() {
// This is intentional
}
import fs from 'node:fs';
-import WorkerConstants from './WorkerConstants';
-import type { WorkerData, WorkerOptions } from '../types/Worker';
+import { WorkerConstants } from './WorkerConstants';
+import type { WorkerData, WorkerOptions } from './WorkerTypes';
-export default abstract class WorkerAbstract<T extends WorkerData> {
+export abstract class WorkerAbstract<T extends WorkerData> {
protected readonly workerScript: string;
protected readonly workerOptions: WorkerOptions;
public abstract readonly size: number;
-export default class WorkerConstants {
+export class WorkerConstants {
static readonly DEFAULT_ELEMENT_START_DELAY = 0;
static readonly DEFAULT_WORKER_START_DELAY = 500;
static readonly POOL_MAX_INACTIVE_TIME = 60000;
import { DynamicThreadPool, type ErrorHandler, type ExitHandler } from 'poolifier';
-import WorkerAbstract from './WorkerAbstract';
+import { WorkerAbstract } from './WorkerAbstract';
+import type { WorkerData, WorkerOptions } from './WorkerTypes';
import { WorkerUtils } from './WorkerUtils';
-import type { WorkerData, WorkerOptions } from '../types/Worker';
-import Utils from '../utils/Utils';
-export default class WorkerDynamicPool extends WorkerAbstract<WorkerData> {
+export class WorkerDynamicPool extends WorkerAbstract<WorkerData> {
private readonly pool: DynamicThreadPool<WorkerData>;
/**
await this.pool.execute(elementData);
// Start element sequentially to optimize memory at startup
this.workerOptions.elementStartDelay > 0 &&
- (await Utils.sleep(this.workerOptions.elementStartDelay));
+ (await WorkerUtils.sleep(this.workerOptions.elementStartDelay));
}
}
import type { PoolOptions } from 'poolifier';
-import type WorkerAbstract from './WorkerAbstract';
-import WorkerConstants from './WorkerConstants';
-import WorkerDynamicPool from './WorkerDynamicPool';
-import WorkerSet from './WorkerSet';
-import WorkerStaticPool from './WorkerStaticPool';
-import { type WorkerData, type WorkerOptions, WorkerProcessType } from '../types/Worker';
+import type { WorkerAbstract } from './WorkerAbstract';
+import { WorkerConstants } from './WorkerConstants';
+import { WorkerDynamicPool } from './WorkerDynamicPool';
+import { WorkerSet } from './WorkerSet';
+import { WorkerStaticPool } from './WorkerStaticPool';
+import { type WorkerData, type WorkerOptions, WorkerProcessType } from './WorkerTypes';
-export default class WorkerFactory {
+export class WorkerFactory {
private constructor() {
// This is intentional
}
import { Worker } from 'worker_threads';
-import WorkerAbstract from './WorkerAbstract';
-import { WorkerUtils } from './WorkerUtils';
+import { WorkerAbstract } from './WorkerAbstract';
import {
type MessageHandler,
type WorkerData,
WorkerMessageEvents,
type WorkerOptions,
type WorkerSetElement,
-} from '../types/Worker';
-import Utils from '../utils/Utils';
+} from './WorkerTypes';
+import { WorkerUtils } from './WorkerUtils';
-export default class WorkerSet extends WorkerAbstract<WorkerData> {
+export class WorkerSet extends WorkerAbstract<WorkerData> {
private readonly workerSet: Set<WorkerSetElement>;
/**
this.getLastWorkerSetElement().numberOfWorkerElements++;
// Start element sequentially to optimize memory at startup
if (this.workerOptions.elementStartDelay > 0) {
- await Utils.sleep(this.workerOptions.elementStartDelay);
+ await WorkerUtils.sleep(this.workerOptions.elementStartDelay);
}
}
this.workerSet.add({ worker, numberOfWorkerElements: 0 });
// Start worker sequentially to optimize memory at startup
this.workerOptions.workerStartDelay > 0 &&
- (await Utils.sleep(this.workerOptions.workerStartDelay));
+ (await WorkerUtils.sleep(this.workerOptions.workerStartDelay));
}
private getLastWorkerSetElement(): WorkerSetElement {
import { type ErrorHandler, type ExitHandler, FixedThreadPool } from 'poolifier';
-import WorkerAbstract from './WorkerAbstract';
+import { WorkerAbstract } from './WorkerAbstract';
+import type { WorkerData, WorkerOptions } from './WorkerTypes';
import { WorkerUtils } from './WorkerUtils';
-import type { WorkerData, WorkerOptions } from '../types/Worker';
-import Utils from '../utils/Utils';
-export default class WorkerStaticPool extends WorkerAbstract<WorkerData> {
+export class WorkerStaticPool extends WorkerAbstract<WorkerData> {
private readonly pool: FixedThreadPool<WorkerData>;
/**
await this.pool.execute(elementData);
// Start element sequentially to optimize memory at startup
this.workerOptions.elementStartDelay > 0 &&
- (await Utils.sleep(this.workerOptions.elementStartDelay));
+ (await WorkerUtils.sleep(this.workerOptions.elementStartDelay));
}
}
// This is intentional
}
+ public static async sleep(milliSeconds: number): Promise<NodeJS.Timeout> {
+ return new Promise((resolve) => setTimeout(resolve as () => void, milliSeconds));
+ }
+
public static defaultExitHandler = (code: number): void => {
if (code !== 0) {
console.error(chalk.red(`Worker exited with error exit code: ${code.toString()}`));
--- /dev/null
+export * from './WorkerAbstract';
+export * from './WorkerConstants';
+export * from './WorkerFactory';
+export {
+ WorkerProcessType,
+ WorkerData,
+ WorkerMessage,
+ WorkerMessageEvents,
+ MessageHandler,
+} from './WorkerTypes';
import expect from 'expect';
-import Constants from '../../src/utils/Constants';
-import Utils from '../../src/utils/Utils';
+import { Constants } from '../../src/utils/Constants';
+import { Utils } from '../../src/utils/Utils';
describe('Utils test suite', () => {
it('Verify generateUUID()/validateUUID()', () => {