import { AppContext } from '../types.js';
import { ResolverBase } from '../generic/ResolverBase.js';
/**
 * Configuration options for SQL logging sessions.
 * These options control how SQL statements are captured, formatted, and saved.
 */
export declare class SqlLoggingOptions {
    /** Whether to format SQL output as a database migration file with proper headers */
    formatAsMigration?: boolean;
    /** Optional description or notes for this logging configuration */
    description?: string;
    /** Types of SQL statements to capture: 'queries', 'mutations', or 'both' */
    statementTypes?: 'queries' | 'mutations' | 'both';
    /** String separator to use between SQL statements (e.g., 'GO' for SQL Server) */
    batchSeparator?: string;
    /** Whether to format SQL with proper indentation and line breaks */
    prettyPrint?: boolean;
    /** Whether to include metadata about record changes in the log output */
    logRecordChangeMetadata?: boolean;
    /** Whether to keep log files even if they contain no SQL statements */
    retainEmptyLogFiles?: boolean;
    /** Email address to filter SQL statements by user (when filtering is enabled) */
    filterByUserId?: string;
    /** Array of regex/wildcard patterns to filter SQL statements */
    filterPatterns?: string[];
    /** How to apply patterns: 'include' or 'exclude' (default: exclude) */
    filterType?: 'include' | 'exclude';
    /** Whether to output verbose debug information to console */
    verboseOutput?: boolean;
    /** Default schema name for Flyway migration placeholder replacement */
    defaultSchemaName?: string;
    /** Human-readable name for the logging session */
    sessionName?: string;
}
export declare class SqlLoggingSession {
    /** Unique identifier for this logging session */
    id: string;
    /** Absolute file path where SQL statements are being logged */
    filePath: string;
    /** Timestamp when this logging session was started */
    startTime: Date;
    /** Number of SQL statements captured so far in this session */
    statementCount: number;
    /** Configuration options applied to this logging session */
    options: SqlLoggingOptions;
    /** Human-readable name for this logging session */
    sessionName?: string;
    /** Email address of user whose SQL is being filtered (if filtering enabled) */
    filterByUserId?: string;
}
export declare class SqlLoggingOptionsInput {
    /** Whether to format SQL output as a database migration file with proper headers */
    formatAsMigration?: boolean;
    /** Optional description or notes for this logging configuration */
    description?: string;
    /** Types of SQL statements to capture: 'queries', 'mutations', or 'both' */
    statementTypes?: 'queries' | 'mutations' | 'both';
    /** String separator to use between SQL statements (e.g., 'GO' for SQL Server) */
    batchSeparator?: string;
    /** Whether to format SQL with proper indentation and line breaks */
    prettyPrint?: boolean;
    /** Whether to include metadata about record changes in the log output */
    logRecordChangeMetadata?: boolean;
    /** Whether to keep log files even if they contain no SQL statements */
    retainEmptyLogFiles?: boolean;
    /** Email address to filter SQL statements by user (when filtering is enabled) */
    filterByUserId?: string;
    /** Array of regex/wildcard patterns to filter SQL statements */
    filterPatterns?: string[];
    /** How to apply patterns: 'include' or 'exclude' (default: exclude) */
    filterType?: 'include' | 'exclude';
    /** Whether to output verbose debug information to console */
    verboseOutput?: boolean;
    /** Default schema name for Flyway migration placeholder replacement */
    defaultSchemaName?: string;
    /** Human-readable name for the logging session */
    sessionName?: string;
}
export declare class StartSqlLoggingInput {
    /** Optional custom filename for the SQL log file (auto-generated if not provided) */
    fileName?: string;
    /** Configuration options for the logging session (merged with server defaults) */
    options?: SqlLoggingOptionsInput;
    /** Whether to filter SQL statements to only those from the current user */
    filterToCurrentUser?: boolean;
}
export declare class SqlLoggingConfig {
    /** Whether SQL logging is enabled in the server configuration */
    enabled: boolean;
    /** Default logging options applied to new sessions (can be overridden) */
    defaultOptions: SqlLoggingOptions;
    /** Directory path where SQL log files are allowed to be created */
    allowedLogDirectory: string;
    /** Maximum number of concurrent SQL logging sessions allowed */
    maxActiveSessions: number;
    /** Whether to automatically delete log files that contain no SQL statements */
    autoCleanupEmptyFiles: boolean;
    /** Timeout in milliseconds after which inactive sessions are automatically stopped */
    sessionTimeout: number;
    /** Current number of active SQL logging sessions */
    activeSessionCount: number;
}
/**
 * GraphQL resolver for SQL logging configuration and session management.
 * Provides queries and mutations for controlling SQL logging functionality.
 *
 * **Security**: All operations require Owner-level privileges.
 *
 * @example
 * ```typescript
 * // Start a new logging session
 * const session = await startSqlLogging({
 *   fileName: "my-session.sql",
 *   filterToCurrentUser: true,
 *   options: {
 *     prettyPrint: true,
 *     statementTypes: "both"
 *   }
 * });
 *
 * // Get current configuration
 * const config = await sqlLoggingConfig();
 *
 * // List active sessions
 * const sessions = await activeSqlLoggingSessions();
 *
 * // Stop a session
 * await stopSqlLogging(session.id);
 * ```
 */
export declare class SqlLoggingConfigResolver extends ResolverBase {
    /** Default prefix for auto-generated SQL log filenames */
    private static readonly LOG_FILE_PREFIX;
    /** Track active session timeouts for proper cleanup when sessions are manually stopped */
    private static sessionTimeouts;
    /**
     * Validates that the current user has Owner-level privileges required for SQL logging operations.
     *
     * This method performs authentication and authorization checks:
     * - Verifies user is authenticated (has email in context)
     * - Looks up user in UserCache by email (case-insensitive)
     * - Checks that user Type field equals 'Owner' (trimmed for nchar padding)
     *
     * @param context - The GraphQL application context containing user authentication data
     * @returns Promise resolving to the authenticated UserInfo object
     * @throws Error if user is not authenticated, not found, or lacks Owner privileges
     *
     * @private
     */
    private checkOwnerAccess;
    /**
     * Retrieves the current SQL logging configuration and status information.
     *
     * Returns comprehensive configuration details including:
     * - Whether SQL logging is enabled in server config
     * - Default logging options (formatting, statement types, etc.)
     * - File system settings (log directory, cleanup options)
     * - Session limits and timeout settings
     * - Count of currently active logging sessions
     *
     * @param context - GraphQL context (requires Owner privileges)
     * @returns Promise resolving to complete SQL logging configuration
     * @throws Error if user lacks Owner privileges
     *
     * @example
     * ```graphql
     * query {
     *   sqlLoggingConfig {
     *     enabled
     *     activeSessionCount
     *     maxActiveSessions
     *     allowedLogDirectory
     *     defaultOptions {
     *       prettyPrint
     *       statementTypes
     *     }
     *   }
     * }
     * ```
     */
    sqlLoggingConfig(context: AppContext): Promise<SqlLoggingConfig>;
    /**
     * Retrieves a list of all currently active SQL logging sessions.
     *
     * Returns detailed information for each active session including:
     * - Unique session identifier and file path
     * - Start time and statement count
     * - Session configuration options
     * - User filtering settings
     *
     * @param context - GraphQL context (requires Owner privileges)
     * @returns Promise resolving to array of active SqlLoggingSession objects
     * @throws Error if user lacks Owner privileges
     *
     * @example
     * ```graphql
     * query {
     *   activeSqlLoggingSessions {
     *     id
     *     sessionName
     *     filePath
     *     startTime
     *     statementCount
     *     filterByUserId
     *     options {
     *       prettyPrint
     *       statementTypes
     *     }
     *   }
     * }
     * ```
     */
    activeSqlLoggingSessions(context: AppContext): Promise<SqlLoggingSession[]>;
    /**
     * Creates and starts a new SQL logging session with specified configuration.
     *
     * This mutation:
     * - Validates SQL logging is enabled and session limits
     * - Creates a secure file path within the allowed log directory
     * - Configures session options (filtering, formatting, etc.)
     * - Starts the logging session in SQLServerDataProvider
     * - Sets up automatic cleanup after session timeout
     *
     * @param input - Configuration for the new logging session
     * @param input.fileName - Optional custom filename for the log file
     * @param input.filterToCurrentUser - Whether to filter SQL to current user only
     * @param input.options - Logging options (formatting, statement types, etc.)
     * @param context - GraphQL context (requires Owner privileges)
     * @returns Promise resolving to the created SqlLoggingSession object
     * @throws Error if logging disabled, session limit reached, or invalid file path
     *
     * @example
     * ```graphql
     * mutation {
     *   startSqlLogging(input: {
     *     fileName: "debug-session.sql"
     *     filterToCurrentUser: true
     *     options: {
     *       prettyPrint: true
     *       statementTypes: "both"
     *       sessionName: "Debug Session"
     *     }
     *   }) {
     *     id
     *     filePath
     *     sessionName
     *   }
     * }
     * ```
     */
    startSqlLogging(input: StartSqlLoggingInput, context: AppContext): Promise<SqlLoggingSession>;
    /**
     * Stops and disposes of a specific SQL logging session.
     *
     * This mutation:
     * - Validates the session exists and user has access
     * - Calls dispose() on the session to close file handles
     * - Removes the session from the active sessions map
     * - Performs any configured cleanup operations
     *
     * @param sessionId - Unique identifier of the session to stop
     * @param context - GraphQL context (requires Owner privileges)
     * @returns Promise resolving to true if session was successfully stopped
     * @throws Error if session not found or user lacks Owner privileges
     *
     * @example
     * ```graphql
     * mutation {
     *   stopSqlLogging(sessionId: "session-123-456")
     * }
     * ```
     */
    stopSqlLogging(sessionId: string, context: AppContext): Promise<boolean>;
    /**
     * Stops and disposes of all currently active SQL logging sessions.
     *
     * This is a convenience method that:
     * - Calls DisposeAllSqlLoggingSessions() on the data provider
     * - Ensures all file handles are properly closed
     * - Clears the active sessions map
     * - Performs cleanup for all sessions at once
     *
     * @param context - GraphQL context (requires Owner privileges)
     * @returns Promise resolving to true if all sessions were successfully stopped
     * @throws Error if user lacks Owner privileges
     *
     * @example
     * ```graphql
     * mutation {
     *   stopAllSqlLogging
     * }
     * ```
     */
    stopAllSqlLogging(context: AppContext): Promise<boolean>;
    /**
     * Updates the default SQL logging options for new sessions.
     *
     * **Note**: This updates runtime configuration only, not the static config file.
     * Changes apply to new sessions but do not persist across server restarts.
     * In a production system, consider persisting changes to a database.
     *
     * @param options - New default options to apply (partial update supported)
     * @param context - GraphQL context (requires Owner privileges)
     * @returns Promise resolving to the updated SqlLoggingOptions object
     * @throws Error if SQL logging not configured or user lacks Owner privileges
     *
     * @example
     * ```graphql
     * mutation {
     *   updateSqlLoggingDefaults(options: {
     *     prettyPrint: true
     *     statementTypes: "both"
     *     logRecordChangeMetadata: false
     *   }) {
     *     prettyPrint
     *     statementTypes
     *     formatAsMigration
     *   }
     * }
     * ```
     */
    updateSqlLoggingDefaults(options: SqlLoggingOptionsInput, context: AppContext): Promise<SqlLoggingOptions>;
    /**
     * Reads the contents of a specific SQL log file.
     *
     * This method:
     * - Validates the session exists and user has access
     * - Ensures the file path is within the allowed log directory
     * - Reads the file content with optional line limits
     * - Returns the content as a string
     *
     * @param sessionId - Unique identifier of the logging session
     * @param maxLines - Maximum number of lines to read (optional, defaults to all)
     * @param context - GraphQL context (requires Owner privileges)
     * @returns Promise resolving to the log file content
     * @throws Error if session not found, file not accessible, or user lacks privileges
     *
     * @example
     * ```graphql
     * query {
     *   readSqlLogFile(sessionId: "session-123", maxLines: 100)
     * }
     * ```
     */
    readSqlLogFile(sessionId: string, maxLines: number | null, context: AppContext): Promise<string>;
    /**
     * Debug query to check what the current user email is in the SQL provider.
     * This helps diagnose user filtering issues when SQL statements aren't being captured.
     *
     * Returns a comparison of the user email stored in the SQLServerDataProvider
     * versus the user email from the GraphQL context, which helps identify mismatches
     * that could prevent SQL filtering from working correctly.
     *
     * @param context - GraphQL context containing user information
     * @returns Formatted string showing both email values and whether they match
     * @throws Error if user doesn't have Owner privileges
     */
    debugCurrentUserEmail(context: AppContext): Promise<string>;
    /**
     * Ensures the specified log directory exists, creating it if necessary.
     *
     * This method:
     * - Attempts to access the directory to check if it exists
     * - Creates the directory recursively if it doesn't exist
     * - Handles permission and file system errors gracefully
     *
     * @param dir - Absolute path to the directory to ensure exists
     * @throws Error if directory cannot be created due to permissions or other issues
     *
     * @private
     */
    private ensureDirectoryExists;
    /**
     * Converts SqlLoggingOptions from the provider to the GraphQL-compatible type.
     * The provider's filterPatterns can contain RegExp objects, but GraphQL only supports strings.
     *
     * @param options - Options from SQLServerDataProvider
     * @returns GraphQL-compatible SqlLoggingOptions
     * @private
     */
    private convertOptionsToGraphQL;
}
//# sourceMappingURL=SqlLoggingConfigResolver.d.ts.map