// SPEC-597-EXEMPT: canonical mapping (npm-package↔framework, keyword catalogue)
// — must enumerate framework names by design; no detection logic to migrate.
// engine/resilience-detector/middleware-detector.ts — Middleware framework detection (SPEC-034)
const FRAMEWORK_SIGNALS = [
    {
        name: 'express',
        pattern: 'express',
        language: 'nodejs',
        chain: ['cors', 'body-parser', 'auth', 'rate-limit', 'validation', 'handler'],
    },
    {
        name: 'fastify',
        pattern: 'fastify',
        language: 'nodejs',
        chain: ['onRequest', 'preValidation', 'preHandler', 'handler', 'onSend'],
    },
    {
        name: 'hono',
        pattern: 'hono',
        language: 'nodejs',
        chain: ['auth', 'rate-limit', 'handler'],
    },
    {
        name: 'nestjs',
        pattern: '@nestjs/core',
        language: 'nodejs',
        chain: ['Guards', 'Interceptors', 'Pipes', 'handler', 'Filters'],
    },
    {
        name: 'koa',
        pattern: 'koa',
        language: 'nodejs',
        chain: ['error-handler', 'auth', 'logger', 'handler'],
    },
    {
        name: 'django',
        pattern: 'django',
        language: 'python',
        chain: ['SecurityMiddleware', 'SessionMiddleware', 'AuthenticationMiddleware', 'handler'],
    },
    {
        name: 'fastapi',
        pattern: 'fastapi',
        language: 'python',
        chain: ['CORSMiddleware', 'auth-dependency', 'validation', 'handler'],
    },
    {
        name: 'spring-boot',
        pattern: 'spring-boot',
        language: 'java',
        chain: ['SecurityFilterChain', 'HandlerInterceptor', 'handler'],
    },
    {
        name: 'aspnet-core',
        pattern: 'microsoft.aspnetcore',
        language: 'dotnet',
        chain: ['ExceptionHandler', 'HTTPS', 'Auth', 'RateLimiting', 'Endpoint'],
    },
    {
        name: 'gin',
        pattern: 'gin-gonic/gin',
        language: 'go',
        chain: ['recovery', 'logger', 'auth', 'handler'],
    },
    {
        name: 'chi',
        pattern: 'go-chi/chi',
        language: 'go',
        chain: ['Recoverer', 'Logger', 'auth', 'handler'],
    },
];
const LANG_ALIASES = {
    typescript: 'nodejs',
    javascript: 'nodejs',
    kotlin: 'java',
};
/**
 * Detects middleware frameworks from dependencies.
 */
export function detectMiddlewareFrameworks(deps, language) {
    const depsLower = deps.map((d) => d.toLowerCase());
    const normalizedLang = LANG_ALIASES[language] ?? language;
    const detected = [];
    let detectedChain = [];
    for (const signal of FRAMEWORK_SIGNALS) {
        if (signal.language !== normalizedLang) {
            continue;
        }
        if (depsLower.some((d) => d.includes(signal.pattern))) {
            detected.push(signal.name);
            if (detectedChain.length === 0) {
                detectedChain = signal.chain;
            }
        }
    }
    return { frameworks: detected, typicalChain: detectedChain };
}
//# sourceMappingURL=middleware-detector.js.map