import { HttpProject } from '../../models/HttpProject.js';
import { ProjectFolder } from '../../models/ProjectFolder.js';
import { Environment } from '../../models/Environment.js';
import { IRequestLog } from '../../models/RequestLog.js';
import { IHttpRequest } from '../../models/HttpRequest.js';
import { ProjectRequestRunner } from './ProjectRequestRunner.js';
import { IProjectExecutionIteration, IProjectExecutionLog } from '../../models/ProjectExecution.js';
import { BaseRunner } from './BaseRunner.js';
import { IProjectRunnerOptions, IRequestRunnerOptions } from './InteropInterfaces.js';
import { State } from './enums.js';
type ProjectParent = HttpProject | ProjectFolder;
export interface ProjectRunner {
    /**
     * Event dispatched when an iteration is about to start.
     */
    on(event: 'before-iteration', listener: (index: number, iterated: boolean) => void): this;
    /**
     * Event dispatched when an iteration finished.
     */
    on(event: 'after-iteration', listener: (index: number, iterated: boolean) => void): this;
    /**
     * Event dispatched before the iteration is going to sleep for the set period of time.
     */
    on(event: 'before-sleep', listener: () => void): this;
    /**
     * Event dispatched after the iteration is woke up.
     */
    on(event: 'after-sleep', listener: () => void): this;
    /**
     * 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;
    /**
     * Event dispatched when an iteration is about to start.
     */
    once(event: 'before-iteration', listener: (index: number, iterated: boolean) => void): this;
    /**
     * Event dispatched when an iteration finished.
     */
    once(event: 'after-iteration', listener: (index: number, iterated: boolean) => void): this;
    /**
     * Event dispatched before the iteration is going to sleep for the set period of time.
     */
    once(event: 'before-sleep', listener: () => void): this;
    /**
     * Event dispatched after the iteration is woke up.
     */
    once(event: 'after-sleep', listener: () => 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;
}
/**
 * A class to be extended to run an entire API Project for the given configuration options.
 *
 * The main purpose of this class (and its children) is to iterate over requests
 * in the project and execute them one-by-one.
 *
 * Implementations allow to execute the requests in a serial model or in parallel mode, where
 * a separate workers are created to run the same HTTP requests in each worker.
 *
 * This class generates a run report which other programs can use to build all kinds of UIs
 * around the data collected during the run.
 */
export declare abstract class ProjectRunner extends BaseRunner {
    /**
     * The HTTP project to run requests from.
     */
    project?: HttpProject;
    /**
     * The execution options for the project.
     */
    options?: IProjectRunnerOptions;
    /**
     * The root object (project or a folder) where the program starts iterating over the requests.
     */
    root?: ProjectParent;
    /**
     * The selected environment to apply to the requests.
     */
    environment?: Environment;
    /**
     * This is used with `--iterations`. The index of the current iteration.
     */
    protected index: number;
    /**
     * The currently executed iteration loop.
     */
    protected currentIteration?: IProjectExecutionIteration;
    /**
     * The number of remaining iterations to run.
     */
    protected remaining: number;
    /**
     * Whether the configuration allows iterations (the parallel mode).
     */
    protected hasIterations: boolean;
    /**
     * When set it won't amit any event.
     * This can be used in a background worker when events are never handled.
     */
    noEmit: boolean;
    /**
     * When executing, this is the last user request runner.
     */
    protected _runner?: ProjectRequestRunner;
    protected _state: State;
    get state(): State;
    protected _signal?: AbortSignal;
    /**
     * The abort signal to set on this request.
     * Aborts the request when the signal fires.
     * @type {(AbortSignal | undefined)}
     */
    get signal(): AbortSignal | undefined;
    set signal(value: AbortSignal | undefined);
    constructor();
    /**
     * A required step before running the project.
     * It configures the execution context. It may throw an error when configuration is not valid.
     */
    configure(project: HttpProject, opts?: IProjectRunnerOptions): Promise<void>;
    /**
     * Executes the requests in the project.
     * @returns The execution log created by calling the `createReport()` function.
     */
    abstract execute(): Promise<IProjectExecutionLog>;
    /**
     * Aborts the current run.
     * The promise returned by the `execute()` method will reject if not yet resolved.
     */
    abort(): void;
    /**
     * Handler for the `abort` event on the `AbortSignal`.
     */
    protected _abortHandler(): void;
    /**
     * Creates the report of the execution.
     */
    protected createReport(): Promise<IProjectExecutionLog>;
    /**
     * Reads the environment data to use with the execution.
     * If the configured environment is a location of a file
     * it is read as API Client's environment and used in the execution.
     * Otherwise it searches for the environment in the list of the defined
     * environments by the name of the key.
     *
     * It throws when the environment cannot be found or when the file contents is invalid.
     */
    protected getEnvironment(): Promise<Environment | undefined>;
    protected getProjectRunnerOptions(): Promise<IRequestRunnerOptions>;
    /**
     * Runs the requests from the project as configured.
     */
    protected executeIteration(): Promise<void>;
    /**
     * Retargets the "request" event from the factory.
     */
    protected _requestHandler(key: string, request: IHttpRequest): void;
    /**
     * Retargets the "response" event from the factory.
     */
    protected _responseHandler(key: string, log: IRequestLog): void;
    /**
     * Retargets the "error" event from the factory.
     */
    protected _errorHandler(key: string, log: IRequestLog, message: string): void;
    /**
     * @returns Reads the system variables based on the library configuration.
     */
    protected prepareVariables(): Record<string, string>;
    private _readSystemVariables;
}
export {};
//# sourceMappingURL=ProjectRunner.d.ts.map