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.

48 lines 2.16 kB
// Copyright (c) 2023 S44, LLC // Copyright Contributors to the CitrineOS Project // // SPDX-License-Identifier: Apache 2.0 import { METADATA_DATA_ENDPOINTS } from '.'; /** * Decorator for use in module API class to expose methods as REST data endpoints. * * @param {OCPP2_0_1_Namespace} namespace - The namespace value. * @param {HttpMethod} method - The HTTP method value. * @param {object} querySchema - The query schema value (optional). * @param {object} bodySchema - The body schema value (optional). * @param {object} paramSchema - The param schema value (optional). * @param {object} headerSchema - The header schema value (optional). * @param {object} responseSchema - The response schema value (optional). * @param {object} tags - The tags value (optional). * @param {object} security - The security value (optional). * @param {string} description - The description (optional). * @return {void} - No return value. */ export const AsDataEndpoint = function (namespace, method, querySchema, bodySchema, paramSchema, headerSchema, responseSchema, tags, security, description) { return (target, propertyKey, descriptor) => { if (!Reflect.hasMetadata(METADATA_DATA_ENDPOINTS, target.constructor)) { Reflect.defineMetadata(METADATA_DATA_ENDPOINTS, [], target.constructor); } const dataEndpoints = Reflect.getMetadata(METADATA_DATA_ENDPOINTS, target.constructor); let tagList = undefined; if (tags) { tagList = Array.isArray(tags) ? tags : [tags]; } dataEndpoints.push({ method: descriptor.value, methodName: propertyKey, namespace: namespace, httpMethod: method, querySchema: querySchema, bodySchema: bodySchema, paramSchema: paramSchema, headerSchema: headerSchema, responseSchema: responseSchema, tags: tagList, description: description, security: security, }); Reflect.defineMetadata(METADATA_DATA_ENDPOINTS, dataEndpoints, target.constructor); }; }; //# sourceMappingURL=AsDataEndpoint.js.map