UNPKG

jovo-plugin-class-handler

Version:

Jovo plugin that allows using classes for defining handlers.

29 lines 1.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const DataDecorators_1 = require("./DataDecorators"); const Handler_1 = require("./Handler"); function Intent(options) { if (!options) { options = { name: '', }; } else if (typeof options === 'string') { options = { name: options, }; } const $options = options; return (target, propertyKey, descriptor) => { const name = $options && $options.name ? $options.name : propertyKey.toString(); const dataParams = Reflect.getMetadata(DataDecorators_1.DataParamMetaDataKey, target, propertyKey) || []; const metaData = Reflect.getMetadata(Handler_1.HandlerMetaDataKey, target.constructor) || { state: '', intents: [], }; metaData.intents.push({ key: propertyKey, name, dataParameters: dataParams }); Reflect.defineMetadata(Handler_1.HandlerMetaDataKey, metaData, target.constructor); }; } exports.Intent = Intent; //# sourceMappingURL=Intent.js.map