"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.archivePromptsLibrary = void 0;
const drizzle_orm_1 = require("drizzle-orm");
const database_1 = require("../../../database");
const tables_1 = require("../../../database/tables");
const logger_1 = __importDefault(require("../../../logger"));
const archivePromptsLibrary = async (req, res) => {
    try {
        const { libraryId } = req.params;
        const db = await (0, database_1.getDb)();
        const [result] = await db
            .update(tables_1.promptsLibraryTable)
            .set({
            is_archived: true,
            updatedAt: new Date()
        })
            .where((0, drizzle_orm_1.eq)(tables_1.promptsLibraryTable.id, libraryId))
            .returning({
            id: tables_1.promptsLibraryTable.id,
            is_archived: tables_1.promptsLibraryTable.is_archived,
        });
        if (!result) {
            res.status(404).json({
                success: false,
                message: 'Prompt library not found',
            });
            return;
        }
        logger_1.default.info(`Archived prompt library ${libraryId}`);
        res.json({
            success: true,
            message: 'Prompt library archived successfully',
            data: result,
        });
    }
    catch (error) {
        logger_1.default.error(`Error archiving prompt library: ${error}`);
        res.status(500).json({
            success: false,
            message: 'Failed to archive prompt library',
        });
    }
};
exports.archivePromptsLibrary = archivePromptsLibrary;
//# sourceMappingURL=archive-prompts-library.js.map