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.

52 lines 2.3 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.AsDataEndpoint = void 0; const _1 = require("."); /** * 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. */ const AsDataEndpoint = function (namespace, method, querySchema, bodySchema, paramSchema, headerSchema, responseSchema, tags, security, description) { return (target, propertyKey, descriptor) => { if (!Reflect.hasMetadata(_1.METADATA_DATA_ENDPOINTS, target.constructor)) { Reflect.defineMetadata(_1.METADATA_DATA_ENDPOINTS, [], target.constructor); } const dataEndpoints = Reflect.getMetadata(_1.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(_1.METADATA_DATA_ENDPOINTS, dataEndpoints, target.constructor); }; }; exports.AsDataEndpoint = AsDataEndpoint; //# sourceMappingURL=AsDataEndpoint.js.map