"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ClickhouseTextToSqlController = void 0;
const logger_1 = __importDefault(require("../../../../logger"));
const clickhouseTextToSqlTool_1 = require("../../../services/argus/tools/clickhouseTextToSqlTool");
class ClickhouseTextToSqlController {
    /**
     * POST /api/argus/tools/text-to-sql
     * Simple test endpoint that:
     *  - Accepts a natural language query in the body
     *  - Uses the ClickHouse text-to-SQL helper to generate and run a query
     *  - Returns the generated SQL and raw rows
     */
    static async textToSql(req, res) {
        try {
            const { query, maxRows } = req.body || {};
            if (!query || typeof query !== 'string') {
                res.status(400).json({
                    success: false,
                    message: 'query is required and must be a non-empty string',
                });
                return;
            }
            const result = await (0, clickhouseTextToSqlTool_1.runClickhouseTextToSql)({
                question: query,
                maxRows: typeof maxRows === 'number' ? maxRows : undefined,
            });
            res.json({
                success: true,
                data: result,
            });
        }
        catch (error) {
            logger_1.default.error(`ClickHouse text-to-sql error: ${error}`);
            res.status(500).json({
                success: false,
                message: error instanceof Error ? error.message : 'Internal server error',
            });
        }
    }
}
exports.ClickhouseTextToSqlController = ClickhouseTextToSqlController;
//# sourceMappingURL=clickhouseTextToSqlController.js.map