UNPKG

@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.

35 lines 1.34 kB
"use strict"; // Copyright (c) 2023 S44, LLC // Copyright Contributors to the CitrineOS Project // // SPDX-License-Identifier: Apache 2.0 Object.defineProperty(exports, "__esModule", { value: true }); exports.AsHandler = exports.AS_HANDLER_METADATA = void 0; /** * Decorators for module components. */ exports.AS_HANDLER_METADATA = 'AS_HANDLER_METADATA'; /** * Decorator function for OCPP modules to expose methods within module classes as handlers for given call action. * * @param {CallAction} action - the call action parameter * @return {PropertyDescriptor} - the property descriptor */ const AsHandler = function (protocol, action) { return (target, propertyKey, descriptor) => { if (!Reflect.hasMetadata(exports.AS_HANDLER_METADATA, target.constructor)) { Reflect.defineMetadata(exports.AS_HANDLER_METADATA, [], target.constructor); } const handlers = Reflect.getMetadata(exports.AS_HANDLER_METADATA, target.constructor); handlers.push({ action: action, protocol: protocol, methodName: propertyKey, method: descriptor.value, }); Reflect.defineMetadata(exports.AS_HANDLER_METADATA, handlers, target.constructor); return descriptor; }; }; exports.AsHandler = AsHandler; //# sourceMappingURL=AsHandler.js.map