"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 __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CoreIntegrationEventsMcpTools = void 0;
const common_1 = require("@nestjs/common");
const integration_event_catalog_service_1 = require("../../webhook-integration/integration-event-catalog.service");
const mcp_tool_decorator_1 = require("../decorators/mcp-tool.decorator");
let CoreIntegrationEventsMcpTools = class CoreIntegrationEventsMcpTools {
    constructor(catalogService) {
        this.catalogService = catalogService;
    }
    async listIntegrationEvents(args, _context) {
        var _a, _b, _c, _d, _e;
        return this.catalogService.list({
            page: (_a = args.page) !== null && _a !== void 0 ? _a : 1,
            pageSize: (_b = args.pageSize) !== null && _b !== void 0 ? _b : 20,
            search: (_c = args.search) !== null && _c !== void 0 ? _c : '',
            sortField: (_d = args.sortField) !== null && _d !== void 0 ? _d : 'slug',
            sortOrder: (_e = args.sortOrder) !== null && _e !== void 0 ? _e : 'asc',
            fields: '',
        });
    }
    async getIntegrationEventOptions(_args, _context) {
        return this.catalogService.options();
    }
    async getIntegrationEvent(args, _context) {
        return this.catalogService.get(args.id);
    }
    async createIntegrationEvent(args, _context) {
        return this.catalogService.create(args);
    }
    async updateIntegrationEvent(args, _context) {
        const { id } = args, data = __rest(args, ["id"]);
        return this.catalogService.update(id, data);
    }
    async deleteIntegrationEvents(args, _context) {
        return this.catalogService.delete({ ids: args.ids });
    }
};
exports.CoreIntegrationEventsMcpTools = CoreIntegrationEventsMcpTools;
__decorate([
    (0, mcp_tool_decorator_1.McpTool)({
        name: 'core.integration-events.list',
        description: 'Lists integration event catalog entries with optional pagination. Admin only.',
        inputSchema: {
            type: 'object',
            properties: {
                page: { type: 'number', description: 'Page number (default: 1)' },
                pageSize: { type: 'number', description: 'Items per page (default: 20)' },
                search: { type: 'string', description: 'Search term' },
                sortField: { type: 'string', description: 'Field to sort by' },
                sortOrder: { type: 'string', enum: ['asc', 'desc'], description: 'Sort direction' },
            },
        },
        readOnly: true,
    }),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, Object]),
    __metadata("design:returntype", Promise)
], CoreIntegrationEventsMcpTools.prototype, "listIntegrationEvents", null);
__decorate([
    (0, mcp_tool_decorator_1.McpTool)({
        name: 'core.integration-events.options',
        description: 'Returns active integration event options (for dropdown selection). Admin only.',
        inputSchema: { type: 'object', properties: {} },
        readOnly: true,
    }),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, Object]),
    __metadata("design:returntype", Promise)
], CoreIntegrationEventsMcpTools.prototype, "getIntegrationEventOptions", null);
__decorate([
    (0, mcp_tool_decorator_1.McpTool)({
        name: 'core.integration-events.get',
        description: 'Returns a single integration event catalog entry by ID. Admin only.',
        inputSchema: {
            type: 'object',
            properties: {
                id: { type: 'number', description: 'Event catalog entry ID' },
            },
            required: ['id'],
        },
        readOnly: true,
    }),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, Object]),
    __metadata("design:returntype", Promise)
], CoreIntegrationEventsMcpTools.prototype, "getIntegrationEvent", null);
__decorate([
    (0, mcp_tool_decorator_1.McpTool)({
        name: 'core.integration-events.create',
        description: 'Creates a new integration event catalog entry. Admin only.',
        inputSchema: {
            type: 'object',
            properties: {
                slug: { type: 'string', description: 'Event slug (unique identifier)' },
                name: { type: 'string', description: 'Event display name' },
                module: { type: 'string', description: 'Module this event belongs to' },
                description: { type: 'string', description: 'Event description' },
                status: { type: 'string', description: 'Event status (active, inactive)' },
            },
            required: ['slug', 'name'],
        },
    }),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, Object]),
    __metadata("design:returntype", Promise)
], CoreIntegrationEventsMcpTools.prototype, "createIntegrationEvent", null);
__decorate([
    (0, mcp_tool_decorator_1.McpTool)({
        name: 'core.integration-events.update',
        description: 'Updates an integration event catalog entry by ID. Admin only.',
        inputSchema: {
            type: 'object',
            properties: {
                id: { type: 'number', description: 'Event catalog entry ID' },
                slug: { type: 'string', description: 'New slug' },
                name: { type: 'string', description: 'New display name' },
                description: { type: 'string', description: 'New description' },
                status: { type: 'string', description: 'New status' },
            },
            required: ['id'],
        },
    }),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, Object]),
    __metadata("design:returntype", Promise)
], CoreIntegrationEventsMcpTools.prototype, "updateIntegrationEvent", null);
__decorate([
    (0, mcp_tool_decorator_1.McpTool)({
        name: 'core.integration-events.delete',
        description: 'Deletes one or more integration event catalog entries by their IDs. Admin only.',
        inputSchema: {
            type: 'object',
            properties: {
                ids: { type: 'array', items: { type: 'number' }, description: 'Entry IDs to delete' },
            },
            required: ['ids'],
        },
    }),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, Object]),
    __metadata("design:returntype", Promise)
], CoreIntegrationEventsMcpTools.prototype, "deleteIntegrationEvents", null);
exports.CoreIntegrationEventsMcpTools = CoreIntegrationEventsMcpTools = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [integration_event_catalog_service_1.IntegrationEventCatalogService])
], CoreIntegrationEventsMcpTools);
//# sourceMappingURL=core-integration-events.mcp-tools.js.map