"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.ToolHooksController = void 0;
const common_1 = require("@nestjs/common");
const swagger_1 = require("@nestjs/swagger");
const tool_hooks_service_1 = require("./tool-hooks.service");
const create_tool_hook_dto_1 = require("./dto/create-tool-hook.dto");
const update_tool_hook_dto_1 = require("./dto/update-tool-hook.dto");
let ToolHooksController = class ToolHooksController {
    constructor(toolHooksService) {
        this.toolHooksService = toolHooksService;
    }
    findAll() {
        return this.toolHooksService.findAll();
    }
    listScripts() {
        return this.toolHooksService.listScripts();
    }
    getTemplate(toolName) {
        return { content: this.toolHooksService.generateTemplate(toolName) };
    }
    getSamplePayload(toolName, timing) {
        return this.toolHooksService.generateSamplePayload(toolName, timing);
    }
    testHook(body) {
        return this.toolHooksService.testHook(body.script_filename, body.payload);
    }
    createScript(body) {
        return this.toolHooksService.createScript(body.filename, body.content);
    }
    create(createToolHookDto) {
        return this.toolHooksService.create(createToolHookDto);
    }
    update(id, updateToolHookDto) {
        return this.toolHooksService.update(id, updateToolHookDto);
    }
    remove(id) {
        return this.toolHooksService.remove(id);
    }
};
exports.ToolHooksController = ToolHooksController;
__decorate([
    (0, common_1.Get)(),
    (0, swagger_1.ApiOperation)({ summary: 'List all tool hooks' }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'List of tool hooks' }),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], ToolHooksController.prototype, "findAll", null);
__decorate([
    (0, common_1.Get)('scripts'),
    (0, swagger_1.ApiOperation)({ summary: 'List available hook scripts' }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'List of script filenames' }),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], ToolHooksController.prototype, "listScripts", null);
__decorate([
    (0, common_1.Get)('template/:toolName'),
    (0, swagger_1.ApiOperation)({ summary: 'Get template for a new hook script' }),
    (0, swagger_1.ApiParam)({ name: 'toolName', description: 'Name of the tool' }),
    (0, swagger_1.ApiResponse)({
        status: 200,
        description: 'Template content',
        schema: { properties: { content: { type: 'string' } } },
    }),
    __param(0, (0, common_1.Param)('toolName')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", void 0)
], ToolHooksController.prototype, "getTemplate", null);
__decorate([
    (0, common_1.Get)('sample-payload'),
    (0, swagger_1.ApiOperation)({ summary: 'Get sample payload for testing' }),
    (0, swagger_1.ApiQuery)({ name: 'toolName', description: 'Name of the tool' }),
    (0, swagger_1.ApiQuery)({
        name: 'timing',
        description: 'Hook timing',
        enum: ['before', 'after'],
    }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Sample payload object' }),
    __param(0, (0, common_1.Query)('toolName')),
    __param(1, (0, common_1.Query)('timing')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String]),
    __metadata("design:returntype", void 0)
], ToolHooksController.prototype, "getSamplePayload", null);
__decorate([
    (0, common_1.Post)('test'),
    (0, common_1.HttpCode)(200),
    (0, swagger_1.ApiOperation)({ summary: 'Test a hook script with payload' }),
    (0, swagger_1.ApiBody)({
        schema: {
            properties: {
                script_filename: { type: 'string' },
                payload: { type: 'object' },
            },
        },
    }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Test result' }),
    __param(0, (0, common_1.Body)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", void 0)
], ToolHooksController.prototype, "testHook", null);
__decorate([
    (0, common_1.Post)('scripts'),
    (0, common_1.HttpCode)(204),
    (0, swagger_1.ApiOperation)({ summary: 'Create a new hook script file' }),
    (0, swagger_1.ApiBody)({
        schema: {
            properties: {
                filename: { type: 'string', example: 'my-hook.ts' },
                content: { type: 'string', description: 'Script content' },
            },
        },
    }),
    (0, swagger_1.ApiResponse)({ status: 204, description: 'Script created' }),
    __param(0, (0, common_1.Body)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", void 0)
], ToolHooksController.prototype, "createScript", null);
__decorate([
    (0, common_1.Post)(),
    (0, common_1.HttpCode)(201),
    (0, swagger_1.ApiOperation)({ summary: 'Create a tool hook configuration' }),
    (0, swagger_1.ApiResponse)({ status: 201, description: 'Tool hook created' }),
    __param(0, (0, common_1.Body)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [create_tool_hook_dto_1.CreateToolHookDto]),
    __metadata("design:returntype", void 0)
], ToolHooksController.prototype, "create", null);
__decorate([
    (0, common_1.Put)(':id'),
    (0, swagger_1.ApiOperation)({ summary: 'Update a tool hook' }),
    (0, swagger_1.ApiParam)({ name: 'id', description: 'Tool hook UUID', format: 'uuid' }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Tool hook updated' }),
    (0, swagger_1.ApiResponse)({ status: 404, description: 'Tool hook not found' }),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, common_1.Body)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, update_tool_hook_dto_1.UpdateToolHookDto]),
    __metadata("design:returntype", void 0)
], ToolHooksController.prototype, "update", null);
__decorate([
    (0, common_1.Delete)(':id'),
    (0, common_1.HttpCode)(204),
    (0, swagger_1.ApiOperation)({ summary: 'Delete a tool hook' }),
    (0, swagger_1.ApiParam)({ name: 'id', description: 'Tool hook UUID', format: 'uuid' }),
    (0, swagger_1.ApiResponse)({ status: 204, description: 'Tool hook deleted' }),
    (0, swagger_1.ApiResponse)({ status: 404, description: 'Tool hook not found' }),
    __param(0, (0, common_1.Param)('id')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", void 0)
], ToolHooksController.prototype, "remove", null);
exports.ToolHooksController = ToolHooksController = __decorate([
    (0, swagger_1.ApiTags)('tool-hooks'),
    (0, common_1.Controller)('tool-hooks'),
    __metadata("design:paramtypes", [tool_hooks_service_1.ToolHooksService])
], ToolHooksController);
//# sourceMappingURL=tool-hooks.controller.js.map