/** * Base abstract class implementing IElement interface. * Provides common functionality that all element types can extend. */ import { IElement, IElementMetadata, ElementStatus, ElementRatings, Reference, ElementValidationResult, FeedbackContext } from '../types/elements/index.js'; import { ElementType } from '../portfolio/types.js'; import { MetadataService } from '../services/MetadataService.js'; /** * Normalizes version strings to full semver format (X.Y.Z) * This helps maintain consistency while accepting flexible input formats * * @param version - The version string to normalize * @returns Normalized version string in X.Y.Z format with leading zeros removed * * @example * normalizeVersion("1") // "1.0.0" * normalizeVersion("1.2") // "1.2.0" * normalizeVersion("1.2.3") // "1.2.3" * normalizeVersion("1.0-beta") // "1.0.0-beta" * normalizeVersion("01.02.03") // "1.2.3" (strips leading zeros) */ export declare function normalizeVersion(version: string): string; export declare abstract class BaseElement implements IElement { private static readonly TRANSIENT_METADATA_FIELDS; id: string; type: ElementType; version: string; metadata: IElementMetadata; protected _instructions: string; protected _content: string; get instructions(): string; set instructions(value: string); get content(): string; set content(value: string); references?: Reference[]; extensions?: Record; ratings?: ElementRatings; protected _status: ElementStatus; protected _isDirty: boolean; private readonly MAX_FEEDBACK_HISTORY; constructor(type: ElementType, metadata: Partial | undefined, metadataService: MetadataService); /** * Generate a unique ID for the element based on its name and type. * Format: type_name-slug_timestamp */ protected generateId(name: string): string; /** * Core validation that all elements share. * Subclasses should override and call super.validate() first. */ validate(): ElementValidationResult; /** * Serialize to JSON format for internal use and testing. * Maintains backward compatibility with existing tests. */ serializeToJSON(): string; /** * Default serialization to markdown with YAML frontmatter. * Uses js-yaml for secure YAML generation to prevent injection attacks. * FIX: Changed from JSON to proper markdown format for GitHub portfolio storage. * This ensures elements are readable on GitHub and compatible with collection workflow. */ serialize(): string; /** * Get element content for serialization. * Subclasses should override this to provide their specific content. */ protected getContent?(): string; /** * Recursively remove undefined and null values from an object. * This ensures YAML serialization doesn't fail on undefined values. */ private deepCleanObject; /** * Default deserialization from JSON. * Subclasses can override for custom formats. */ deserialize(data: string): void; /** * Process user feedback and update ratings. */ receiveFeedback(feedback: string, context?: FeedbackContext): void; /** * Simple sentiment analysis. * Subclasses can override for more sophisticated analysis. */ protected analyzeSentiment(feedback: string): 'positive' | 'negative' | 'neutral'; /** * Simple rating inference from feedback. * Subclasses can override for more sophisticated inference. */ protected inferRating(feedback: string): number | undefined; /** * Update user rating with a new value. */ protected updateUserRating(newRating: number): void; /** * Get current element status. */ getStatus(): ElementStatus; /** * Status property getter for convenient access. */ get status(): ElementStatus; /** * Default lifecycle methods - subclasses should override as needed. */ beforeActivate(): Promise; activate(): Promise; afterActivate(): Promise; deactivate(): Promise; /** * Mark element as modified. */ protected markDirty(): void; /** * Check if element has unsaved changes. */ isDirty(): boolean; /** * Mark element as saved. */ markClean(): void; } //# sourceMappingURL=BaseElement.d.ts.map