// tools/create-spec-tech/ficha-arch.ts — Architecture-specific section helpers
import specTemplates from '../../config/spec-templates.json' with { type: 'json' };
/**
 * Get the stack terminology label for interfaces/types section.
 */
export function getStackTerminology(knowledge) {
    if (!knowledge?.language) {
        return 'Interfaces/Types';
    }
    const lang = knowledge.language.toLowerCase();
    const terminologyMap = specTemplates.stackTerminology;
    const terminology = terminologyMap[lang];
    return terminology?.types ?? 'Interfaces/Types';
}
/**
 * Generate architecture-specific sections for the ficha técnica.
 */
export function getArchitectureSections(knowledge) {
    if (!knowledge) {
        return [];
    }
    const arch = knowledge.architecture.primary;
    const lines = [];
    // Layer-based architectures
    const layeredArchs = new Set([
        'layered',
        'clean-architecture',
        'hexagonal',
        'onion',
        'ddd',
        'mvvm',
        'mvc',
        'mvp',
    ]);
    if (layeredArchs.has(arch) && knowledge.architecture.layers.length > 0) {
        lines.push('## Architecture Layers', '');
        lines.push('| Layer | Responsibility |');
        lines.push('|-------|---------------|');
        for (const layer of knowledge.architecture.layers) {
            lines.push(`| ${layer.name} | ${layer.responsibility} |`);
        }
        lines.push('');
    }
    // Domain-driven patterns
    if (arch === 'ddd' || arch === 'hexagonal' || arch === 'clean-architecture') {
        lines.push('## Domain Model', '');
        lines.push('- Aggregates: (list aggregates affected)');
        lines.push('- Value Objects: (list value objects)');
        lines.push('- Domain Events: (list events emitted)');
        lines.push('- Repositories: (list repository interfaces)');
        lines.push('');
    }
    // CQRS/Event-sourcing
    if (arch === 'cqrs' || arch === 'event-sourcing') {
        lines.push('## Commands & Queries', '');
        lines.push('### Commands');
        lines.push('- (list commands this spec introduces)');
        lines.push('');
        lines.push('### Queries');
        lines.push('- (list queries this spec introduces)');
        lines.push('');
        if (arch === 'event-sourcing') {
            lines.push('### Events');
            lines.push('- (list domain events and their schemas)');
            lines.push('');
        }
    }
    // Microservices / service-oriented
    if (arch === 'microservices') {
        lines.push('## Service Boundaries', '');
        lines.push('| Service | Role | API |');
        lines.push('|---------|------|-----|');
        lines.push('| (service name) | (responsibility) | (REST/gRPC/events) |');
        lines.push('');
    }
    // Serverless
    if (arch === 'serverless') {
        lines.push('## Functions / Handlers', '');
        lines.push('| Function | Trigger | Runtime |');
        lines.push('|----------|---------|---------|');
        lines.push('| (function name) | (HTTP/event/cron) | (runtime) |');
        lines.push('');
    }
    // Module boundaries
    if (knowledge.architecture.boundaries.length > 0) {
        lines.push('## Module Boundaries', '');
        for (const boundary of knowledge.architecture.boundaries) {
            lines.push(`- **${boundary.name}**: ${boundary.publicApi.join(', ') || '(define public API)'}`);
        }
        lines.push('');
    }
    // Communication patterns
    if (knowledge.architecture.communicationPatterns.length > 0) {
        lines.push(`## Communication Patterns: ${knowledge.architecture.communicationPatterns.join(', ')}`, '');
    }
    // Deployment units
    if (knowledge.architecture.deploymentUnits.length > 0) {
        lines.push(`## Deployment Units: ${knowledge.architecture.deploymentUnits.join(', ')}`, '');
    }
    return lines;
}
//# sourceMappingURL=ficha-arch.js.map