import { EventEmitter } from 'events';
import { Environment } from '../../models/Environment.js';
import { type Logger, type ILogObj } from '../../lib/logging/index.js';
import { IRequestLog } from '../../models/RequestLog.js';
import { ProjectFolder } from '../../models/ProjectFolder.js';
import { ProjectRequest } from '../../models/ProjectRequest.js';
import { IHttpRequest } from '../../models/HttpRequest.js';
import { HttpProject } from '../../models/HttpProject.js';
import { VariablesProcessor } from '../variables/VariablesProcessor.js';
import { IProjectExecutionResult, IRequestRunnerOptions, IRequestRunnerRunOptions, IRunResult } from './InteropInterfaces.js';
import { State } from './enums.js';
import { CookieJar } from '../../cookies/CookieJar.js';
import { ProjectItem } from '../../models/ProjectItem.js';
export interface ProjectRequestRunner {
    /**
     * The request object is prepared and about to be sent to the HTTP engine
     */
    on(event: 'request', listener: (key: string, request: IHttpRequest) => void): this;
    /**
     * The response is ready.
     */
    on(event: 'response', listener: (key: string, log: IRequestLog) => void): this;
    /**
     * There was a general error during the request
     */
    on(event: 'error', listener: (key: string, log: IRequestLog, message: string) => void): this;
    /**
     * The request object is prepared and about to be sent to the HTTP engine
     */
    once(event: 'request', listener: (key: string, request: IHttpRequest) => void): this;
    /**
     * The response is ready.
     */
    once(event: 'response', listener: (key: string, log: IRequestLog) => void): this;
    /**
     * There was a general error during the request
     */
    once(event: 'error', listener: (key: string, log: IRequestLog, message: string) => void): this;
}
/**
 * Runs requests in a project.
 * Developers can run the entire project with the `recursive` flag set. They can also
 * set the starting point with the `parent` options.
 *
 * Requests are executed in order defined in the folder.
 */
export declare class ProjectRequestRunner extends EventEmitter {
    logger?: Logger<ILogObj>;
    project: HttpProject;
    /**
     * An instance of a cookie jar (store) to put/read cookies.
     */
    cookies?: CookieJar;
    protected masterEnvironment?: Environment;
    protected extraVariables?: Record<string, string>;
    /**
     * The variables processor instance.
     */
    protected variablesProcessor: VariablesProcessor;
    protected _state: State;
    get state(): State;
    constructor(project: HttpProject, opts?: IRequestRunnerOptions);
    /**
     * Runs the request from the project root or a specified folder.
     * @param options Run options.
     * @returns A promise with the run result.
     */
    run(options?: IRequestRunnerRunOptions): Promise<IProjectExecutionResult>;
    /**
     * Creates an async iterator that allows to iterate over execution results.
     * The result is yielded after the request is executed.
     *
     * @param options The iterator configuration.
     */
    protected runIterator(options?: IRequestRunnerRunOptions, variables?: Record<string, string>): AsyncGenerator<IRunResult>;
    protected _runIterator(items: ProjectItem[], variables: Record<string, string>, options: IRequestRunnerRunOptions): AsyncGenerator<IRunResult>;
    /**
     * Aborts the current run.
     * The promise returned by the `run()` method will reject if not yet resolved.
     */
    abort(): void;
    /**
     * Allows to iterate over project requests recursively and execute each request
     * in order. The generator yields the `RunResult` for the request.
     *
     * Example:
     *
     * ```javascript
     * const runner = new ProjectRequestRunner(...);
     * for await (let runResult of runner) {
     *  console.log(runResult);
     * }
     * ```
     */
    [Symbol.asyncIterator](): AsyncGenerator<IRunResult>;
    private _runItem;
    protected execute(request: ProjectRequest, variables: Record<string, string>): Promise<IRunResult>;
    protected getVariables(parent: HttpProject | ProjectFolder): Promise<Record<string, string>>;
    protected createEnvironment(parent: HttpProject | ProjectFolder): Promise<Record<string, string>>;
    /**
     * Reads the list of the environments to apply to this runtime.
     */
    protected readEnvironments(parent: HttpProject | ProjectFolder): Promise<Environment[]>;
    /**
     * Reads the variables and the base URI from the passed environments.
     */
    protected applyVariables(environments: Environment[]): Promise<Record<string, string>>;
}
//# sourceMappingURL=ProjectRequestRunner.d.ts.map