import { FutureContainer } from '../models/future/future-types';
import { FutureEndState } from '../services/future';
import { CancellablePromise } from '../types/cancellable-promise';
/**
 * Rejection raised when the awaited future ends in FAIL / ABORT / CANCEL.
 * `reason` carries the backend's reason code (e.g. a ReasonException id),
 * so callers can map it to user-facing messages.
 */
export declare class FutureCallError extends Error {
    readonly endState: FutureEndState;
    readonly reason?: string;
    readonly futureId?: string;
    constructor(endState: FutureEndState, reason?: string, futureId?: string);
    get isCancelled(): boolean;
}
export interface AwaitFutureCallOptions {
    /** Alias the wrapped method registers its future under (@kosFuture alias). */
    alias?: string;
    /**
     * Reject with a timeout error if the future has not reached an end state
     * within this window. Unset = wait indefinitely.
     */
    timeoutMs?: number;
}
/**
 * Invoke a @kosFuture method on a future-aware model and return a
 * CancellablePromise that settles from the future's end state:
 *
 * - resolves with the method's response once the future ends in SUCCESS
 * - rejects with {@link FutureCallError} on FAIL / ABORT / CANCEL
 * - rejects with the service error if the call itself throws
 * - resolves with the response when the call turns out not to be
 *   future-tracked (no future was produced)
 *
 * The future created by the call is captured reactively (the @kosFuture
 * wrapper registers it on the model's futureHandler before the request is
 * sent), so no timing hacks are needed and concurrent operations on other
 * aliases are unaffected.
 *
 * @example Awaiting real completion from a command
 * ```typescript
 * try {
 *   await awaitFutureCall(artifact, (a) =>
 *     a.publishImportedKab(path, version, qualifier)
 *   );
 *   studio.notifications.success("Published");
 * } catch (e) {
 *   if (e instanceof FutureCallError && !e.isCancelled) {
 *     studio.notifications.error(mapReason(e.reason));
 *   }
 * }
 * ```
 *
 * @example Cancellation and progress
 * ```typescript
 * const call = awaitFutureCall(model, (m) => m.performOperation());
 * const stop = call.onProgressUpdate((p, status) => render(p, status));
 * // later: await call.cancel();
 * ```
 */
export declare function awaitFutureCall<T extends FutureContainer, R>(model: T, methodCall: (model: T) => Promise<R>, options?: AwaitFutureCallOptions): CancellablePromise<R>;
//# sourceMappingURL=await-future-call.d.ts.map