lexica-dialog-core
Version:
Core server for Lexica dialog agent.
22 lines • 901 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const lodash_1 = require("lodash");
const Api_1 = require("../Api");
const commandsValidationMiddleware = async (context, next) => {
const { commands, uniConfigs } = context;
if (!uniConfigs.has(Api_1.RunTimeConfig.SUSPEND_AUTO_REPLY) ||
(uniConfigs.has(Api_1.RunTimeConfig.SUSPEND_AUTO_REPLY) &&
!uniConfigs.get(Api_1.RunTimeConfig.SUSPEND_AUTO_REPLY).value)) {
if (commands.isEmpty()) {
throw new Api_1.BotError(Api_1.BotErrorCode.INTENT_NOT_FOUND);
}
}
commands.toArray().forEach(command => {
if (lodash_1.isNil(command.intent)) {
throw new Api_1.BotError(Api_1.BotErrorCode.INTENT_NOT_FOUND);
}
});
await next();
};
exports.default = commandsValidationMiddleware;
//# sourceMappingURL=CommandsValidationMiddleware.js.map