"use strict";
/**
 * Scanner Types and Interfaces
 * Defines the core data structures for the security scanning engine
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.SCAN_MODE_DEFAULTS = exports.MAX_FILE_SIZE = exports.SPECIAL_FILES = exports.SCANNABLE_EXTENSIONS = void 0;
exports.createCancellationToken = createCancellationToken;
exports.createEmptyDetectorContext = createEmptyDetectorContext;
/**
 * Create a new cancellation token
 *
 * @example
 * const token = createCancellationToken()
 * process.on('SIGINT', () => token.cancel('User interrupted'))
 * const result = await runScan(files, repo, { cancellationToken: token })
 */
function createCancellationToken() {
    const cleanupCallbacks = [];
    const token = {
        cancelled: false,
        reason: undefined,
        cancel(reason) {
            if (!token.cancelled) {
                token.cancelled = true;
                token.reason = reason;
                // Run cleanup callbacks
                cleanupCallbacks.forEach(cb => {
                    try {
                        cb();
                    }
                    catch (e) {
                        // Ignore cleanup errors
                    }
                });
            }
        },
        onCancel(callback) {
            if (token.cancelled) {
                callback(); // Already cancelled, run immediately
            }
            else {
                cleanupCallbacks.push(callback);
            }
        }
    };
    return token;
}
/**
 * Create an empty/default DetectorContext
 * Useful for tests or when context isn't available
 */
function createEmptyDetectorContext() {
    return {
        auth: {
            middleware: null,
            authHelpers: {
                hasThrowingHelpers: false,
                throwingHelperNames: [],
            },
            publicEndpoints: [],
        },
        framework: {
            primary: null,
            frontend: null,
            hasTypeScript: false,
        },
        dataAccess: {
            orm: null,
            hasRLS: false,
            validationLib: null,
        },
        file: {
            isServerOnly: false,
            isClientBundled: false,
            isTestFile: false,
            isConfigFile: false,
            isToolingDir: false,
        },
    };
}
// Supported file extensions for scanning
exports.SCANNABLE_EXTENSIONS = [
    '.js', '.jsx', '.ts', '.tsx', '.mjs', '.cjs',
    '.py', '.rb', '.php', '.go', '.java', '.cs',
    '.env', '.yaml', '.yml', '.json', '.toml',
    '.dockerfile', '.sh', '.bash',
];
// Files to always scan regardless of extension
exports.SPECIAL_FILES = [
    'Dockerfile',
    'docker-compose.yml',
    'docker-compose.yaml',
    '.env',
    '.env.local',
    '.env.production',
    '.env.development',
    'package.json',
    'requirements.txt',
    'Gemfile',
    'go.mod',
];
// Max file size to scan (50KB as per PRD)
exports.MAX_FILE_SIZE = 50 * 1024;
/**
 * Default configurations for each scan mode
 */
exports.SCAN_MODE_DEFAULTS = {
    full: {
        mode: 'full',
        skipAIValidation: false,
        skipLayer3: false,
        maxAIValidationFiles: 50,
        maxLayer3Files: 15,
    },
    incremental: {
        mode: 'incremental',
        skipAIValidation: false,
        skipLayer3: true, // Skip expensive Layer 3 for incremental
        maxAIValidationFiles: 20,
        maxLayer3Files: 5,
    },
};
//# sourceMappingURL=types.js.map