"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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CoreMailSentMcpTools = void 0;
const common_1 = require("@nestjs/common");
const mail_sent_service_1 = require("../../mail-sent/mail-sent.service");
const mcp_tool_decorator_1 = require("../decorators/mcp-tool.decorator");
let CoreMailSentMcpTools = class CoreMailSentMcpTools {
    constructor(mailSentService) {
        this.mailSentService = mailSentService;
    }
    async listMailSent(args, _context) {
        var _a, _b, _c, _d, _e;
        return this.mailSentService.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 : 'id',
            sortOrder: (_e = args.sortOrder) !== null && _e !== void 0 ? _e : 'asc',
            fields: '',
            status: args.status,
            hasError: args.hasError,
            recipientEmail: args.recipientEmail,
            createdAtFrom: args.createdAtFrom,
            createdAtTo: args.createdAtTo,
        });
    }
    async getMailSent(args, context) {
        return this.mailSentService.get(context.locale, args.id);
    }
    async deleteMailSent(args, context) {
        return this.mailSentService.delete(context.locale, { ids: args.ids });
    }
};
exports.CoreMailSentMcpTools = CoreMailSentMcpTools;
__decorate([
    (0, mcp_tool_decorator_1.McpTool)({
        name: 'core.mail-sent.list',
        description: 'Lists sent mail records with optional filters. 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' },
                status: { type: 'string', description: 'Filter by status (e.g. sent, failed)' },
                hasError: { type: 'boolean', description: 'Filter by error presence' },
                recipientEmail: { type: 'string', description: 'Filter by recipient email' },
                createdAtFrom: { type: 'string', description: 'Start date filter (ISO 8601)' },
                createdAtTo: { type: 'string', description: 'End date filter (ISO 8601)' },
            },
        },
        readOnly: true,
    }),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, Object]),
    __metadata("design:returntype", Promise)
], CoreMailSentMcpTools.prototype, "listMailSent", null);
__decorate([
    (0, mcp_tool_decorator_1.McpTool)({
        name: 'core.mail-sent.get',
        description: 'Returns a single sent mail record by ID. Admin only.',
        inputSchema: {
            type: 'object',
            properties: {
                id: { type: 'number', description: 'Sent mail record ID' },
            },
            required: ['id'],
        },
        readOnly: true,
    }),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, Object]),
    __metadata("design:returntype", Promise)
], CoreMailSentMcpTools.prototype, "getMailSent", null);
__decorate([
    (0, mcp_tool_decorator_1.McpTool)({
        name: 'core.mail-sent.delete',
        description: 'Deletes one or more sent mail records by their IDs. Admin only.',
        inputSchema: {
            type: 'object',
            properties: {
                ids: { type: 'array', items: { type: 'number' }, description: 'Sent mail record IDs to delete' },
            },
            required: ['ids'],
        },
    }),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, Object]),
    __metadata("design:returntype", Promise)
], CoreMailSentMcpTools.prototype, "deleteMailSent", null);
exports.CoreMailSentMcpTools = CoreMailSentMcpTools = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [mail_sent_service_1.MailSentService])
], CoreMailSentMcpTools);
//# sourceMappingURL=core-mail-sent.mcp-tools.js.map