UNPKG

mcp-quiz-server

Version:

🧠 AI-Powered Quiz Management via Model Context Protocol (MCP) - Create, manage, and take quizzes directly from VS Code, Claude, and other AI agents.

86 lines (85 loc) • 2.55 kB
"use strict"; /** * @fileoverview Delete Quiz Command - Clean Architecture Application Layer * @version 1.0.0 * @since 2025-07-30 * @module DeleteQuizCommand * @description Command for deleting quizzes with validation and audit trails * * @architecture * Layer: Application (Command) * Pattern: Command Pattern + Validation * Dependencies: Domain entities, validation * * @relationships * USED_BY: * - DeleteQuizCommandHandler (Application Layer) * - MCP delete-quiz tool (Infrastructure) * - HTTP delete endpoints (Infrastructure) * * @contributors Claude Code Agent * @testCoverage Command validation tests, integration tests */ Object.defineProperty(exports, "__esModule", { value: true }); exports.DeleteQuizCommand = void 0; const QuizId_1 = require("../../domain/value-objects/QuizId"); /** * Delete Quiz Command * * @description Represents a request to delete a quiz with proper validation * and audit trail information. * * @example * ```typescript * const command = new DeleteQuizCommand({ * quizId: 'quiz-123', * confirmDelete: true, * requestedBy: 'admin-user', * reason: 'Outdated content' * }); * ``` * * @since 2025-07-30 * @author Claude Code Agent */ class DeleteQuizCommand { constructor(data) { // Validate required fields if (!data.quizId) { throw new Error('Quiz ID is required'); } if (data.confirmDelete !== true) { throw new Error('Delete confirmation is required for safety'); } // Create value objects this.quizId = QuizId_1.QuizId.fromString(data.quizId); this.confirmDelete = data.confirmDelete; this.requestedBy = data.requestedBy || 'anonymous'; this.reason = data.reason || 'No reason provided'; this.metadata = { ...data.metadata, timestamp: new Date().toISOString(), }; } /** * Get audit trail information */ getAuditInfo() { return { action: 'DELETE_QUIZ', resource: 'quiz', resourceId: this.quizId.value, requestedBy: this.requestedBy, reason: this.reason, timestamp: this.metadata.timestamp, metadata: this.metadata, }; } /** * Convert to string representation for logging */ toString() { return `DeleteQuizCommand(quizId=${this.quizId.value}, requestedBy=${this.requestedBy})`; } } exports.DeleteQuizCommand = DeleteQuizCommand;