"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.CoreSessionsMcpTools = void 0;
const common_1 = require("@nestjs/common");
const api_pagination_1 = require("@hed-hog/api-pagination");
const session_service_1 = require("../../session/session.service");
const mcp_tool_decorator_1 = require("../decorators/mcp-tool.decorator");
let CoreSessionsMcpTools = class CoreSessionsMcpTools {
    constructor(sessionService) {
        this.sessionService = sessionService;
    }
    async getActiveSessions(args, context) {
        var _a, _b;
        return this.sessionService.getUserSessionsActive({
            page: (_a = args.page) !== null && _a !== void 0 ? _a : 1,
            pageSize: (_b = args.pageSize) !== null && _b !== void 0 ? _b : 20,
            search: '',
            sortField: 'id',
            sortOrder: api_pagination_1.PageOrderDirection.Asc,
            fields: '',
        }, context.userId, context.locale);
    }
    async getAllSessions(args, context) {
        var _a, _b;
        return this.sessionService.getUserSessions({
            page: (_a = args.page) !== null && _a !== void 0 ? _a : 1,
            pageSize: (_b = args.pageSize) !== null && _b !== void 0 ? _b : 20,
            search: '',
            sortField: 'id',
            sortOrder: api_pagination_1.PageOrderDirection.Asc,
            fields: '',
        }, context.userId, context.locale);
    }
    async revokeSession(args, context) {
        return this.sessionService.revokeUserSession(context.userId, args.sessionId, context.locale);
    }
    async revokeAllSessions(_args, context) {
        return this.sessionService.revokeAllSessions(context.userId);
    }
    async revokeAllOtherSessions(_args, context) {
        return this.sessionService.revokeAllOtherSessions(context.userId, Number(context.sessionId));
    }
};
exports.CoreSessionsMcpTools = CoreSessionsMcpTools;
__decorate([
    (0, mcp_tool_decorator_1.McpTool)({
        name: 'core.sessions.active',
        description: 'Returns active sessions for the authenticated user.',
        inputSchema: {
            type: 'object',
            properties: {
                page: { type: 'number', description: 'Page number (default: 1)' },
                pageSize: { type: 'number', description: 'Items per page (default: 20)' },
            },
        },
        readOnly: true,
    }),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, Object]),
    __metadata("design:returntype", Promise)
], CoreSessionsMcpTools.prototype, "getActiveSessions", null);
__decorate([
    (0, mcp_tool_decorator_1.McpTool)({
        name: 'core.sessions.all',
        description: 'Returns all sessions (active and revoked) for the authenticated user.',
        inputSchema: {
            type: 'object',
            properties: {
                page: { type: 'number', description: 'Page number (default: 1)' },
                pageSize: { type: 'number', description: 'Items per page (default: 20)' },
            },
        },
        readOnly: true,
    }),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, Object]),
    __metadata("design:returntype", Promise)
], CoreSessionsMcpTools.prototype, "getAllSessions", null);
__decorate([
    (0, mcp_tool_decorator_1.McpTool)({
        name: 'core.sessions.revoke',
        description: 'Revokes a specific session for the authenticated user.',
        inputSchema: {
            type: 'object',
            properties: {
                sessionId: { type: 'number', description: 'Session ID to revoke' },
            },
            required: ['sessionId'],
        },
    }),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, Object]),
    __metadata("design:returntype", Promise)
], CoreSessionsMcpTools.prototype, "revokeSession", null);
__decorate([
    (0, mcp_tool_decorator_1.McpTool)({
        name: 'core.sessions.revoke-all',
        description: 'Revokes all sessions for the authenticated user.',
        inputSchema: { type: 'object', properties: {} },
    }),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, Object]),
    __metadata("design:returntype", Promise)
], CoreSessionsMcpTools.prototype, "revokeAllSessions", null);
__decorate([
    (0, mcp_tool_decorator_1.McpTool)({
        name: 'core.sessions.revoke-all-other',
        description: 'Revokes all sessions except the current one for the authenticated user.',
        inputSchema: { type: 'object', properties: {} },
    }),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, Object]),
    __metadata("design:returntype", Promise)
], CoreSessionsMcpTools.prototype, "revokeAllOtherSessions", null);
exports.CoreSessionsMcpTools = CoreSessionsMcpTools = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [session_service_1.SessionService])
], CoreSessionsMcpTools);
//# sourceMappingURL=core-sessions.mcp-tools.js.map