@citrineos/base
Version:
The base module for OCPP v2.0.1 including all interfaces. This module is not intended to be used directly, but rather as a dependency for other modules.
73 lines (72 loc) • 3.79 kB
TypeScript
import { FastifyInstance } from 'fastify';
import 'reflect-metadata';
import { ILogObj, Logger } from 'tslog';
import { HttpMethod } from '.';
import { Namespace, OCPP1_6_Namespace, OCPPVersion } from '../..';
import { OCPP2_0_1_Namespace } from '../../ocpp/persistence';
import { CallAction } from '../../ocpp/rpc/message';
import { IModule } from '../modules';
import { IModuleApi } from './ModuleApi';
/**
* Abstract module api class implementation.
*/
export declare abstract class AbstractModuleApi<T extends IModule> implements IModuleApi {
protected readonly _server: FastifyInstance;
protected readonly _module: T;
protected readonly _logger: Logger<ILogObj>;
private readonly _ocppVersion;
constructor(module: T, server: FastifyInstance, ocppVersion: OCPPVersion | null, logger?: Logger<ILogObj>);
/**
* Initializes the API for the given module.
*
* @param {T} module - The module to initialize the API for.
*/
protected _init(module: T): void;
/**
* Add a message route to the server.
*
* @param {CallAction} action - The action to be called.
* @param {Function} method - The method to be executed.
* @param {object} bodySchema - The schema for the route.
* @param {Record<string, any>} optionalQuerystrings - Optional querystrings for the route.
* @return {void}
*/
protected _addMessageRoute(action: CallAction, method: (...args: any[]) => any, bodySchema: object, optionalQuerystrings?: Record<string, any>): void;
/**
* Add a message route to the server.
*
* @param {OCPP2_0_1_Namespace | OCPP1_6_Namespace | Namespace} namespace - The entity type.
* @param {Function} method - The method to be executed.
* @param {HttpMethod} httpMethod - The HTTP method to be used.
* @param {object} querySchema - The schema for the querystring.
* @param {object} paramSchema - The schema for the parameters.
* @param {object} headerSchema - The schema for the headers.
* @param {object} bodySchema - The schema for the body.
* @param {object} responseSchema - The schema for the response.
* @param {string[]} tags - The tags for the route.
* @param {string} description - The description for the route.
* @param {object[]} security - The security for the route.
* @return {void}
*/
protected _addDataRoute(namespace: OCPP2_0_1_Namespace | OCPP1_6_Namespace | Namespace, method: (...args: any[]) => any, httpMethod: HttpMethod, querySchema?: object, paramSchema?: object, headerSchema?: object, bodySchema?: object, responseSchema?: object, tags?: string[], description?: string, security?: object[]): void;
private registerSchemaForOpts;
protected registerSchema: (fastifyInstance: FastifyInstance, schema: any, schemaIdPrefix?: string) => object | null;
protected registerSystemConfigRoutes(module: T): void;
private removeUnknownKeys;
/**
* Convert a {@link CallAction} to a normed lowercase URL path.
*
* @param {CallAction} input - The {@link CallAction} to convert to a URL path.
* @param {string} prefix - The module name.
* @returns {string} - String representation of URL path.
*/
protected _toMessagePath(input: CallAction, prefix?: string): string;
/**
* Convert a namespace to a normed lowercase URL path.
*
* @param {OCPP2_0_1_Namespace | OCPP1_6_Namespace | Namespace} input - The {@link OCPP2_0_1_Namespace} or {@link OCPP1_6_Namespace} or {@link Namespace} to convert to a URL path.
* @param {string} prefix - The module name.
* @returns {string} - String representation of URL path.
*/
protected _toDataPath(input: OCPP2_0_1_Namespace | OCPP1_6_Namespace | Namespace, prefix?: string): string;
}