/**
 * SpecVerse v3.1 AI View Generator
 *
 * Transforms parsed AST into AI-optimized specification for code generation
 * Expands conventions and infers implementation details while preserving business rules
 */
import { SpecVerseAST } from '@specverse/types';
export interface AIOptimizedAttribute {
    name: string;
    type: string;
    constraints: {
        required: boolean;
        unique: boolean;
        min?: number;
        max?: number;
        pattern?: string;
        format?: string;
    };
    dbMapping: {
        columnName: string;
        columnType: string;
        index?: boolean;
        nullable: boolean;
        defaultValue?: any;
    };
    validation: {
        rules: string[];
        errorMessages?: {
            [rule: string]: string;
        };
    };
    metadata: {
        searchable?: boolean;
        encrypted?: boolean;
        audit?: boolean;
    };
}
export interface AIOptimizedRelationship {
    name: string;
    type: 'hasMany' | 'hasOne' | 'belongsTo' | 'manyToMany';
    target: string;
    foreignKey: string;
    joinStrategy: 'eager' | 'lazy';
    cascadeOperations: string[];
    joinTable?: {
        name: string;
        columns: {
            [key: string]: string;
        };
    };
}
export interface AIOptimizedBehavior {
    name: string;
    signature: string;
    implementation: {
        preconditions: string[];
        postconditions: string[];
        sideEffects: string[];
        steps: string[];
        transactional: boolean;
    };
    metadata: {
        async: boolean;
        cacheable: boolean;
        idempotent: boolean;
    };
}
export interface ServiceOperationHint {
    type: 'findUnique' | 'findMany' | 'create' | 'update' | 'delete' | 'upsert' | 'aggregate' | 'custom' | 'validate';
    complexity: 'simple' | 'nested' | 'aggregated';
    transactional: boolean;
    targetOperation?: 'create' | 'update' | 'evolve';
    includes?: string[];
    queryHints?: {
        pagination?: boolean;
        sorting?: boolean;
        filtering?: boolean;
        search?: boolean;
    };
    validation?: {
        schema?: string;
        library?: 'zod' | 'yup' | 'class-validator' | 'joi';
    };
    caching?: {
        enabled: boolean;
        ttl?: number;
        key?: string;
    };
}
export interface AIOptimizedEndpoint {
    method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
    path: string;
    operation?: string;
    parameters: {
        path: {
            [name: string]: AIOptimizedAttribute;
        };
        query: {
            [name: string]: AIOptimizedAttribute;
        };
        body: {
            [name: string]: AIOptimizedAttribute;
        };
    };
    responseType: {
        success: string;
        error: string;
    };
    businessRules: {
        preconditions: string[];
        postconditions: string[];
    };
    metadata: {
        authenticated: boolean;
        authorized: string[];
        rateLimit?: {
            requests: number;
            window: string;
        };
        readOnly?: boolean;
        dryRun?: boolean;
        validationMode?: 'strict' | 'lenient';
        validationOnly?: boolean;
        targetOperation?: 'create' | 'update' | 'evolve';
    };
    serviceOperation?: ServiceOperationHint;
}
export interface AIOptimizedSubscription {
    name: string;
    eventTypes: string[];
    handler: string;
    filterExpression?: string;
    processingMode: 'sync' | 'async';
    retryPolicy?: {
        maxRetries: number;
        backoffStrategy: 'linear' | 'exponential';
    };
}
export interface AIOptimizedModel {
    name: string;
    attributes: AIOptimizedAttribute[];
    relationships: AIOptimizedRelationship[];
    behaviors: AIOptimizedBehavior[];
    lifecycle: {
        states: string[];
        transitions: {
            [action: string]: {
                from: string;
                to: string;
                condition?: string;
            };
        };
        currentStateField: string;
    };
    dbMapping: {
        tableName: string;
        schema?: string;
        indexes: string[];
    };
    metadata?: {
        id?: any;
        audit?: any;
        softDelete?: any;
        label?: string | string[];
        status?: any;
        version?: any;
    };
}
export interface AIOptimizedController {
    name: string;
    model?: string;
    modelReference: string;
    basePath?: string;
    endpoints: AIOptimizedEndpoint[];
    subscriptions: AIOptimizedSubscription[];
    middleware: string[];
}
export interface AIOptimizedService {
    name: string;
    operations: AIOptimizedBehavior[];
    subscriptions: AIOptimizedSubscription[];
    dependencies: string[];
}
export interface AIOptimizedView {
    name: string;
    type?: string;
    description?: string;
    model?: string | string[];
    uiComponents?: {
        [name: string]: any;
    };
    subscriptions: AIOptimizedSubscription[];
    components: {
        [name: string]: {
            type: string;
            props: any;
            dataBindings: string[];
        };
    };
    routing: {
        path: string;
        params?: string[];
    };
}
export interface AIOptimizedEvent {
    name: string;
    payload: AIOptimizedAttribute[];
    metadata: {
        persistent: boolean;
        ttl?: number;
        priority?: 'low' | 'normal' | 'high';
    };
}
export interface AIOptimizedSpec {
    metadata: {
        component?: string;
        deployment?: string;
        instance?: string;
        version?: string;
        description?: string;
        tags?: string[];
        manifest?: ManifestConfig;
    };
    imports: {
        from: string;
        items: {
            name: string;
            type: string;
        }[];
    }[];
    exports: {
        type: string;
        items: string[];
    }[];
    models: AIOptimizedModel[];
    controllers: AIOptimizedController[];
    services: AIOptimizedService[];
    views: AIOptimizedView[];
    events: AIOptimizedEvent[];
    infrastructure: {
        database: {
            type: string;
            migrations: boolean;
            seedData: boolean;
        };
        messaging: {
            type: string;
            queues: string[];
        };
        caching: {
            type: string;
            ttl: number;
        };
    };
}
export interface ManifestConfig {
    implementationType?: string;
    customizations?: {
        [key: string]: any;
    };
    codeGeneration?: {
        validation?: {
            library: string;
        };
        orm?: {
            library: string;
            features?: string[];
        };
        authentication?: {
            strategy: string;
        };
        [key: string]: any;
    };
}
export interface GenerationOptions {
    deployment?: string;
    instance?: string;
    manifest?: ManifestConfig;
}
export declare class AIViewGenerator {
    /**
     * Generate AI-optimized specification from parsed AST
     *
     * @param ast - Parsed SpecVerse AST
     * @param options - Optional generation options for deployment filtering
     */
    generate(ast: SpecVerseAST, options?: GenerationOptions): AIOptimizedSpec;
    /**
     * Expand imports into structured format
     */
    private expandImports;
    /**
     * Expand exports into categorized structure
     */
    private expandExports;
    /**
     * Optimize model with database mappings and expanded metadata
     */
    private optimizeModel;
    /**
     * Optimize attribute with full implementation details
     * v3.3: Uses explicit model metadata instead of heuristics
     */
    private optimizeAttribute;
    /**
     * Optimize relationship with foreign key inference
     */
    private optimizeRelationship;
    /**
     * Optimize behavior/action/operation with metadata
     */
    private optimizeBehavior;
    /**
     * Optimize controller with endpoint expansion
     */
    private optimizeController;
    /**
     * Optimize service with dependency inference
     */
    private optimizeService;
    /**
     * Optimize view with component structure
     */
    private optimizeView;
    /**
     * Optimize event with metadata
     */
    private optimizeEvent;
    /**
     * Optimize subscriptions into structured format
     */
    private optimizeSubscriptions;
    /**
     * Expand CURVED operations into REST endpoints
     * Auto-generates all CURVED operations (Create, Update, Retrieve, Validate, Evolve, Delete)
     * Operations are generated by default unless explicitly disabled
     */
    private expandCuredEndpoints;
    /**
     * Expand validate operation into validation endpoint (v3.3+)
     * Always generates a single unified validation endpoint that accepts operation context
     */
    private expandValidateEndpoints;
    /**
     * Create endpoint from custom action
     */
    private createEndpoint;
    /**
     * Helper methods for inference and conversion
     */
    private inferDbType;
    private inferPattern;
    private inferFormat;
    private inferForeignKey;
    private inferJoinTableName;
    /**
     * Infer service operation hints for code generation
     * Provides Prisma-style operation types, transaction hints, and query optimization metadata
     */
    private inferServiceOperation;
    private inferIndexes;
    private generateValidationRules;
    /**
     * v3.3: Check if field should be encrypted based on type (not name patterns)
     * No longer uses brittle heuristics like name.includes('password')
     */
    private isEncryptedField;
    /**
     * v3.3: Check if field is an audit field using explicit metadata
     * Replaces brittle heuristic that matched hardcoded field names
     */
    private isAuditField;
    private generateMethodSignature;
    private inferTransactional;
    private inferAsync;
    private inferCacheable;
    private inferIdempotent;
    private extractParameters;
    private createIdAttribute;
    private createPaginationAttribute;
    private inferHttpMethod;
    private expandComponents;
    private inferDependencies;
    private inferInfrastructure;
    /**
     * String conversion utilities
     */
    private toSnakeCase;
    private toKebabCase;
}
//# sourceMappingURL=ai-view-generator.d.ts.map