content-elements.tsā¢8.04 kB
/**
* EuConquisto Composer MCP Server - Content Elements Interface
*
* @version 0.1.0
* @created 2025-06-08
* @updated 2025-06-08
* @author EuConquisto Development Team
*
* @description Comprehensive TypeScript interfaces for all EuConquisto content elements
* including base element types, component configurations, and validation structures.
*
* @testStatus PENDING
* @coverage 0%
*
* @dependencies
* - TypeScript 5.0+
* - Node.js types
*
* @supersedes N/A
* @supersededBy N/A
*/
// Base Element Interfaces
export interface BaseElement {
id: string;
type: string;
name: string;
description?: string;
created: string;
updated: string;
version: string;
metadata?: Record<string, any>;
}
// Content Element Types
export interface TextElement extends BaseElement {
type: 'text';
content: string;
formatting?: {
bold?: boolean;
italic?: boolean;
underline?: boolean;
fontSize?: string;
fontFamily?: string;
color?: string;
backgroundColor?: string;
alignment?: 'left' | 'center' | 'right' | 'justify';
};
}
export interface ImageElement extends BaseElement {
type: 'image';
src: string;
alt: string;
width?: number;
height?: number;
caption?: string;
alignment?: 'left' | 'center' | 'right';
}
export interface VideoElement extends BaseElement {
type: 'video';
src: string;
poster?: string;
width?: number;
height?: number;
autoplay?: boolean;
controls?: boolean;
loop?: boolean;
muted?: boolean;
caption?: string;
}
export interface AudioElement extends BaseElement {
type: 'audio';
src: string;
autoplay?: boolean;
controls?: boolean;
loop?: boolean;
muted?: boolean;
title?: string;
}
export interface QuizElement extends BaseElement {
type: 'quiz';
questions: QuizQuestion[];
settings: {
shuffleQuestions?: boolean;
shuffleAnswers?: boolean;
timeLimit?: number;
maxAttempts?: number;
passingScore?: number;
showResults?: boolean;
showCorrectAnswers?: boolean;
};
}
export interface QuizQuestion {
id: string;
type: 'multiple-choice' | 'single-choice' | 'true-false' | 'fill-blank' | 'essay';
question: string;
answers: QuizAnswer[];
correctAnswers: string[];
explanation?: string;
points?: number;
}
export interface QuizAnswer {
id: string;
text: string;
isCorrect: boolean;
}
export interface InteractiveElement extends BaseElement {
type: 'interactive';
interactionType: 'drag-drop' | 'hotspot' | 'timeline' | 'simulation';
configuration: Record<string, any>;
assets: {
images?: string[];
audio?: string[];
video?: string[];
documents?: string[];
};
}
export interface DocumentElement extends BaseElement {
type: 'document';
documentType: 'pdf' | 'doc' | 'docx' | 'ppt' | 'pptx' | 'txt' | 'html';
src: string;
downloadable?: boolean;
viewable?: boolean;
title?: string;
description?: string;
}
// Composition and Layout Interfaces
export interface ContentComposition {
id: string;
name: string;
description?: string;
elements: CompositionElement[];
layout: LayoutConfiguration;
settings: CompositionSettings;
metadata: CompositionMetadata;
}
export interface CompositionElement {
elementId: string;
position: {
x: number;
y: number;
z?: number;
};
size: {
width: number;
height: number;
};
constraints?: {
minWidth?: number;
maxWidth?: number;
minHeight?: number;
maxHeight?: number;
aspectRatio?: string;
};
styling?: Record<string, any>;
}
export interface LayoutConfiguration {
type: 'grid' | 'flex' | 'absolute' | 'flow';
columns?: number;
rows?: number;
gap?: number;
padding?: number;
margin?: number;
responsive?: ResponsiveBreakpoints;
}
export interface ResponsiveBreakpoints {
mobile?: LayoutConfiguration;
tablet?: LayoutConfiguration;
desktop?: LayoutConfiguration;
wide?: LayoutConfiguration;
}
export interface CompositionSettings {
isPublic: boolean;
allowCopy: boolean;
allowModification: boolean;
requireAuth: boolean;
tags: string[];
category?: string;
difficulty?: 'beginner' | 'intermediate' | 'advanced' | 'expert';
estimatedDuration?: number; // in minutes
}
export interface CompositionMetadata {
created: string;
updated: string;
createdBy: string;
lastModifiedBy: string;
version: string;
status: 'draft' | 'review' | 'published' | 'archived';
analytics?: {
views: number;
interactions: number;
completions: number;
averageScore?: number;
};
}
// Validation Interfaces
export interface ValidationResult {
isValid: boolean;
errors: ValidationError[];
warnings: ValidationWarning[];
score?: number;
}
export interface ValidationError {
field: string;
message: string;
code: string;
severity: 'error' | 'warning' | 'info';
}
export interface ValidationWarning {
field: string;
message: string;
code: string;
suggestion?: string;
}
// Element Factory Interfaces
export interface ElementFactory {
createElement<T extends BaseElement>(type: string, config: Partial<T>): Promise<T>;
validateElement(element: BaseElement): ValidationResult;
duplicateElement<T extends BaseElement>(element: T): Promise<T>;
updateElement<T extends BaseElement>(id: string, updates: Partial<T>): Promise<T>;
deleteElement(id: string): Promise<boolean>;
}
export interface ElementConfiguration {
type: string;
defaultValues: Record<string, any>;
requiredFields: string[];
validationRules: ValidationRule[];
templates?: ElementTemplate[];
}
export interface ValidationRule {
field: string;
type: 'required' | 'min' | 'max' | 'pattern' | 'custom';
value?: any;
message: string;
validator?: (value: any) => boolean;
}
export interface ElementTemplate {
id: string;
name: string;
description?: string;
category: string;
configuration: Record<string, any>;
preview?: string;
}
// Export Configuration
export interface ExportConfiguration {
format: 'json' | 'html' | 'xml' | 'scorm' | 'xapi';
options: {
includeAssets?: boolean;
compressAssets?: boolean;
standalone?: boolean;
responsive?: boolean;
optimization?: 'none' | 'basic' | 'advanced';
};
metadata?: {
title?: string;
description?: string;
author?: string;
version?: string;
language?: string;
};
}
export interface ExportResult {
success: boolean;
format: string;
output: string | Buffer;
assets?: string[];
metadata: {
size: number;
duration: number;
timestamp: string;
};
errors?: string[];
warnings?: string[];
}
// Type Guards
export function isTextElement(element: BaseElement): element is TextElement {
return element.type === 'text';
}
export function isImageElement(element: BaseElement): element is ImageElement {
return element.type === 'image';
}
export function isVideoElement(element: BaseElement): element is VideoElement {
return element.type === 'video';
}
export function isAudioElement(element: BaseElement): element is AudioElement {
return element.type === 'audio';
}
export function isQuizElement(element: BaseElement): element is QuizElement {
return element.type === 'quiz';
}
export function isInteractiveElement(element: BaseElement): element is InteractiveElement {
return element.type === 'interactive';
}
export function isDocumentElement(element: BaseElement): element is DocumentElement {
return element.type === 'document';
}
// Utility Types
export type ContentElementType = TextElement | ImageElement | VideoElement | AudioElement |
QuizElement | InteractiveElement | DocumentElement;
export type ElementType = 'text' | 'image' | 'video' | 'audio' | 'quiz' | 'interactive' | 'document';
export type CompositionStatus = 'draft' | 'review' | 'published' | 'archived';
export type DifficultyLevel = 'beginner' | 'intermediate' | 'advanced' | 'expert';
export type LayoutType = 'grid' | 'flex' | 'absolute' | 'flow';
export type ExportFormat = 'json' | 'html' | 'xml' | 'scorm' | 'xapi';