import type { ErrorObject } from 'ajv'; import { MessageOrigin, type CallAction, type OcppRequest, type OcppResponse, type OCPPVersionType, type SystemConfig } from '@citrineos/types'; import type { ICache } from '../cache/cache.js'; import type { IMessage } from '../messages/message.js'; import type { IMessageConfirmation } from '../messages/message-confirmation.js'; import type { IMessageHandler } from '../messages/message-handler.js'; import type { IMessageSender } from '../messages/message-sender.js'; import { OCPPValidator } from '../modules/ocpp-validator.js'; import type { IMessageRouter } from './router.js'; import { Call, CallResult, OcppError } from '../../ocpp/rpc/message.js'; import type { ILogObj } from 'tslog'; import { Logger } from 'tslog'; export declare abstract class AbstractMessageRouter implements IMessageRouter { /** * Fields */ protected _ocppValidator: OCPPValidator; protected _cache: ICache; protected _config: SystemConfig; protected _logger: Logger; protected readonly _handler: IMessageHandler; protected readonly _sender: IMessageSender; protected _networkHook: (identifier: string, message: string) => Promise; /** * Constructor of abstract ocpp router. * * @param {OCPPValidator} ocppValidator - The OCPPValidator instance to use for message validation. */ constructor(config: SystemConfig, cache: ICache, handler: IMessageHandler, sender: IMessageSender, networkHook: (identifier: string, message: string) => Promise, logger?: Logger, ocppValidator?: OCPPValidator); /** * Getters & Setters */ get ocppValidator(): OCPPValidator; get cache(): ICache; get sender(): IMessageSender; get handler(): IMessageHandler; get config(): SystemConfig; set networkHook(value: (identifier: string, message: string) => Promise); /** * Sets the system configuration for the module. * * @param {SystemConfig} config - The new configuration to set. */ set config(config: SystemConfig); /** * Public Methods */ handle(message: IMessage): Promise; /** * Protected Methods */ /** * Validates a Call object against its schema. * * @param {string} identifier - The identifier of the EVSE. * @param {Call} message - The Call object to validate. * @param {string} protocol - The subprotocol of the Websocket, i.e. "ocpp1.6" or "ocpp2.0.1". * @return {boolean} - Returns true if the Call object is valid, false otherwise. */ protected _validateCall(identifier: string, message: Call, protocol: string): { isValid: boolean; errors?: ErrorObject[] | null; }; /** * Validates a CallResult object against its schema. * * @param {string} identifier - The identifier of the EVSE. * @param {CallAction} action - The original CallAction. * @param {CallResult} message - The CallResult object to validate. * @param {string} protocol - The protocol of the Websocket. * @return {boolean} - Returns true if the CallResult object is valid, false otherwise. */ protected _validateCallResult(identifier: string, action: CallAction, message: CallResult, protocol: string): { isValid: boolean; errors?: ErrorObject[] | null; }; abstract onMessage(identifier: string, message: string, timestamp: Date, protocol: string): Promise; abstract registerConnection(tenantId: number, ocppConnectionName: string, protocol: string, connectedWebsocketServerConfigId?: string): Promise; abstract deregisterConnection(tenantId: number, ocppConnectionName: string): Promise; abstract sendCall(ocppConnectionName: string, tenantId: number, protocol: OCPPVersionType, action: CallAction, payload: OcppRequest, correlationId?: string, origin?: MessageOrigin): Promise; abstract sendCallResult(correlationId: string, ocppConnectionName: string, tenantId: number, protocol: OCPPVersionType, action: CallAction, payload: OcppResponse, origin?: MessageOrigin): Promise; abstract sendCallError(correlationId: string, ocppConnectionName: string, tenantId: number, protocol: OCPPVersionType, action: CallAction, error: OcppError, origin?: MessageOrigin): Promise; abstract shutdown(): Promise; }