"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LlmCallLogsController = void 0;
const common_1 = require("@nestjs/common");
const swagger_1 = require("@nestjs/swagger");
const llm_call_logs_service_1 = require("./llm-call-logs.service");
const llm_call_log_entity_1 = require("../core-entities/llm-call-log.entity");
let LlmCallLogsController = class LlmCallLogsController {
    constructor(llmCallLogsService) {
        this.llmCallLogsService = llmCallLogsService;
    }
    async findAll(sessionId, sessionInputId, provider, status, limit, offset) {
        return this.llmCallLogsService.findAll({
            sessionId,
            sessionInputId,
            provider,
            status,
            limit: limit ? parseInt(limit, 10) : undefined,
            offset: offset ? parseInt(offset, 10) : undefined,
        });
    }
    async findBySessionInputId(inputId, limit, offset) {
        return this.llmCallLogsService.findBySessionInputId(inputId, limit ? parseInt(limit, 10) : undefined, offset ? parseInt(offset, 10) : undefined);
    }
    async findBySessionId(sessionId, limit, offset) {
        return this.llmCallLogsService.findBySessionId(sessionId, limit ? parseInt(limit, 10) : undefined, offset ? parseInt(offset, 10) : undefined);
    }
    async findById(id) {
        try {
            return await this.llmCallLogsService.findById(id);
        }
        catch (error) {
            throw new common_1.NotFoundException(error.message || 'LLM call log not found');
        }
    }
};
exports.LlmCallLogsController = LlmCallLogsController;
__decorate([
    (0, common_1.Get)(),
    (0, swagger_1.ApiOperation)({
        summary: 'List LLM call logs with filters',
        description: 'Query LLM call logs with optional filters for session, input, provider, or status. Supports pagination.',
    }),
    (0, swagger_1.ApiQuery)({
        name: 'sessionId',
        required: false,
        description: 'Filter by session UUID',
    }),
    (0, swagger_1.ApiQuery)({
        name: 'sessionInputId',
        required: false,
        description: 'Filter by session input UUID',
    }),
    (0, swagger_1.ApiQuery)({
        name: 'provider',
        required: false,
        description: 'Filter by provider name (e.g., openrouter, ollama)',
    }),
    (0, swagger_1.ApiQuery)({
        name: 'status',
        required: false,
        description: 'Filter by status (pending, success, error)',
    }),
    (0, swagger_1.ApiQuery)({
        name: 'limit',
        required: false,
        description: 'Maximum number of results',
        example: 50,
    }),
    (0, swagger_1.ApiQuery)({
        name: 'offset',
        required: false,
        description: 'Offset for pagination',
        example: 0,
    }),
    (0, swagger_1.ApiResponse)({
        status: 200,
        description: 'List of LLM call logs with total count',
        schema: {
            properties: {
                logs: {
                    type: 'array',
                    items: { $ref: '#/components/schemas/LlmCallLog' },
                },
                total: { type: 'number' },
            },
        },
    }),
    __param(0, (0, common_1.Query)('sessionId')),
    __param(1, (0, common_1.Query)('sessionInputId')),
    __param(2, (0, common_1.Query)('provider')),
    __param(3, (0, common_1.Query)('status')),
    __param(4, (0, common_1.Query)('limit')),
    __param(5, (0, common_1.Query)('offset')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String, String, String, String, String]),
    __metadata("design:returntype", Promise)
], LlmCallLogsController.prototype, "findAll", null);
__decorate([
    (0, common_1.Get)('session-input/:inputId'),
    (0, swagger_1.ApiOperation)({
        summary: 'Get logs for a specific session input',
        description: 'Returns all LLM call logs associated with a specific session input.',
    }),
    (0, swagger_1.ApiParam)({
        name: 'inputId',
        description: 'Session input UUID',
        format: 'uuid',
    }),
    (0, swagger_1.ApiQuery)({ name: 'limit', required: false, description: 'Maximum results' }),
    (0, swagger_1.ApiQuery)({
        name: 'offset',
        required: false,
        description: 'Pagination offset',
    }),
    (0, swagger_1.ApiResponse)({
        status: 200,
        description: 'List of logs for the input',
        schema: {
            properties: { logs: { type: 'array' }, total: { type: 'number' } },
        },
    }),
    __param(0, (0, common_1.Param)('inputId')),
    __param(1, (0, common_1.Query)('limit')),
    __param(2, (0, common_1.Query)('offset')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String, String]),
    __metadata("design:returntype", Promise)
], LlmCallLogsController.prototype, "findBySessionInputId", null);
__decorate([
    (0, common_1.Get)('session/:sessionId'),
    (0, swagger_1.ApiOperation)({
        summary: 'Get logs for a session',
        description: 'Returns all LLM call logs associated with a session.',
    }),
    (0, swagger_1.ApiParam)({ name: 'sessionId', description: 'Session UUID', format: 'uuid' }),
    (0, swagger_1.ApiQuery)({ name: 'limit', required: false, description: 'Maximum results' }),
    (0, swagger_1.ApiQuery)({
        name: 'offset',
        required: false,
        description: 'Pagination offset',
    }),
    (0, swagger_1.ApiResponse)({
        status: 200,
        description: 'List of logs for the session',
        schema: {
            properties: { logs: { type: 'array' }, total: { type: 'number' } },
        },
    }),
    __param(0, (0, common_1.Param)('sessionId')),
    __param(1, (0, common_1.Query)('limit')),
    __param(2, (0, common_1.Query)('offset')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String, String]),
    __metadata("design:returntype", Promise)
], LlmCallLogsController.prototype, "findBySessionId", null);
__decorate([
    (0, common_1.Get)(':id'),
    (0, swagger_1.ApiOperation)({ summary: 'Get a single LLM call log by ID' }),
    (0, swagger_1.ApiParam)({ name: 'id', description: 'Log UUID', format: 'uuid' }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Log found', type: llm_call_log_entity_1.LlmCallLog }),
    (0, swagger_1.ApiResponse)({ status: 404, description: 'Log not found' }),
    __param(0, (0, common_1.Param)('id')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", Promise)
], LlmCallLogsController.prototype, "findById", null);
exports.LlmCallLogsController = LlmCallLogsController = __decorate([
    (0, swagger_1.ApiTags)('llm-call-logs'),
    (0, common_1.Controller)('llm-call-logs'),
    __metadata("design:paramtypes", [llm_call_logs_service_1.LlmCallLogsService])
], LlmCallLogsController);
//# sourceMappingURL=llm-call-logs.controller.js.map