/**
 * Fluent query builder for log queries
 */
import { globalLogStorage } from '../storage/log-storage.js';
/**
 * Log query builder for fluent query construction
 */
export class LogQueryBuilder {
    query = {};
    /**
     * Set time range
     */
    timeRange(startTime, endTime) {
        this.query.startTime = startTime;
        this.query.endTime = endTime;
        return this;
    }
    /**
     * Set log levels
     */
    levels(...levels) {
        this.query.levels = levels;
        return this;
    }
    /**
     * Exclude log levels
     */
    excludeLevels(...levels) {
        this.query.excludeLevels = levels;
        return this;
    }
    /**
     * Filter by message content
     */
    messageContains(text) {
        this.query.messageContains = text;
        return this;
    }
    /**
     * Filter by message regex
     */
    messageRegex(regex) {
        this.query.messageRegex = regex;
        return this;
    }
    /**
     * Filter by correlation IDs
     */
    correlationIds(...ids) {
        this.query.correlationIds = ids;
        return this;
    }
    /**
     * Filter by sources
     */
    sources(...sources) {
        this.query.sources = sources;
        return this;
    }
    /**
     * Filter by tags
     */
    tags(...tags) {
        this.query.tags = tags;
        return this;
    }
    /**
     * Require tags
     */
    hasTags() {
        this.query.hasTags = true;
        return this;
    }
    /**
     * Set pagination
     */
    limit(limit) {
        this.query.limit = limit;
        return this;
    }
    /**
     * Set offset
     */
    offset(offset) {
        this.query.offset = offset;
        return this;
    }
    /**
     * Set sorting
     */
    sortBy(field, order = 'desc') {
        this.query.sortBy = field;
        this.query.sortOrder = order;
        return this;
    }
    /**
     * Filter by minimum performance duration
     */
    durationMin(min) {
        this.query.durationMin = min;
        return this;
    }
    /**
     * Filter by memory usage threshold
     */
    memoryThreshold(threshold) {
        this.query.memoryThreshold = threshold;
        return this;
    }
    /**
     * Execute the query
     */
    execute() {
        return globalLogStorage.query(this.query);
    }
    /**
     * Get query as JSON
     */
    toJSON() {
        return { ...this.query };
    }
}
/**
 * Create a new log query builder
 */
export function createLogQuery() {
    return new LogQueryBuilder();
}
//# sourceMappingURL=query-builder.js.map