import type { Client } from "./_internal/client/index";
import type { RequestOptions } from "./base-client";
import { type StreamMessageChunk, type StreamOptions } from "./streaming";
import type { PaginatedResponse } from "./pagination";
/**
 * Response shape for list endpoints that return `{ data: T[], meta: M }`.
 * Used by rawGetList to preserve pagination metadata from custom controllers.
 */
export interface ListResponse<T, M = {
    count: number;
}> {
    data: T[];
    meta: M;
}
/**
 * Build headers for SDK requests.
 * Merges base headers with per-request overrides and idempotency keys.
 */
export declare function buildHeaders(getHeaders: () => Record<string, string>, options?: RequestOptions): Record<string, string>;
/**
 * RequestBuilder provides a type-safe way to execute SDK requests
 * with consistent header merging, error handling, retry, and unwrapping.
 */
export declare class RequestBuilder {
    private clientInstance;
    private getHeaders;
    private unwrap;
    private requestWithRetry;
    private getBaseUrl;
    constructor(clientInstance: Client, getHeaders: () => Record<string, string>, unwrap: <T>(d: unknown) => T, requestWithRetry: <T>(fn: () => Promise<T>) => Promise<T>, getBaseUrl?: () => string | undefined);
    /**
     * Assert that a baseUrl is configured on this client instance.
     * Raw requests use relative URL paths that require a base URL to resolve.
     * Without one, the fetch runtime throws an opaque "Invalid URL" error.
     * @throws {Error} with a descriptive message when baseUrl is missing.
     */
    private assertBaseUrl;
    /** Get auth headers for manual requests (used by streaming extensions) */
    getRequestHeaders(): Record<string, string>;
    /**
     * Execute a generated SDK function with full middleware pipeline.
     * Handles headers, retry, unwrapping, and error conversion.
     */
    execute<TResponse>(fn: (...args: any[]) => Promise<any>, params: Record<string, unknown>, options?: RequestOptions): Promise<TResponse>;
    /**
     * Execute a delete operation that returns true on success.
     */
    executeDelete(fn: (...args: any[]) => Promise<any>, params: Record<string, unknown>, options?: RequestOptions): Promise<true>;
    /**
     * Execute a raw GET request to a custom (non-generated) endpoint.
     * Used for endpoints implemented as custom Phoenix controllers.
     */
    rawGet<TResponse>(url: string, options?: RequestOptions): Promise<TResponse>;
    /**
     * Execute a raw GET request for list endpoints that return `{ data: T[], meta: M }`.
     * Unlike rawGet which strips the envelope, this preserves pagination metadata.
     * Used for custom controller endpoints that return paginated lists.
     */
    rawGetList<T, M = {
        count: number;
    }>(url: string, options?: RequestOptions): Promise<ListResponse<T, M>>;
    /**
     * Execute a raw multipart/form-data POST request.
     * Used for file upload endpoints (custom Phoenix controllers).
     * Content-Type is omitted from headers so the browser sets the correct
     * multipart boundary automatically from the FormData body.
     */
    rawPostMultipart<TResponse>(url: string, body: FormData, options?: RequestOptions): Promise<TResponse>;
    /**
     * Execute a raw POST request to a custom (non-generated) endpoint.
     * Used for endpoints implemented as custom Phoenix controllers.
     */
    rawPost<TResponse>(url: string, body?: unknown, options?: RequestOptions): Promise<TResponse>;
    /**
     * Execute a raw PATCH request to a custom (non-generated) endpoint.
     * Used for endpoints implemented as custom Phoenix controllers.
     */
    rawPatch<TResponse>(url: string, body?: unknown, options?: RequestOptions): Promise<TResponse>;
    /**
     * Execute a raw DELETE request to a custom (non-generated) endpoint.
     */
    rawDelete<TResponse = void>(url: string, options?: RequestOptions): Promise<TResponse>;
    /**
     * Create a paginated fetcher function for listAll operations.
     * Encapsulates the pattern of calling a generated SDK function with pagination params.
     *
     * @param fn - The generated SDK function (e.g., getAgents)
     * @param queryBuilder - Function that builds the query object with page params
     * @param options - Request options (headers, signal, etc.)
     * @returns A fetcher function for use with paginateToArray
     */
    createPaginatedFetcher<T>(fn: (...args: any[]) => Promise<any>, queryBuilder: (page: number, pageSize: number) => Record<string, unknown>, options?: RequestOptions): (page: number, pageSize: number) => Promise<PaginatedResponse<T>>;
    /**
     * Make a streaming POST request through the client instance,
     * ensuring all interceptors (auth, events, API version, etc.) fire.
     *
     * Uses the client's `post()` method with `parseAs: 'stream'` so the
     * request/response interceptors execute, then wraps the stream body
     * into an SSE message iterator.
     */
    streamRequest(url: string, body: unknown, options?: RequestOptions, streamOptions?: StreamOptions): Promise<AsyncIterableIterator<StreamMessageChunk>>;
    /**
     * Make a streaming GET request through the client instance.
     * Used for subscribing to SSE event streams (e.g., execution streaming).
     */
    streamGetRequest(url: string, options?: RequestOptions, streamOptions?: StreamOptions): Promise<AsyncIterableIterator<StreamMessageChunk>>;
}
//# sourceMappingURL=request-builder.d.ts.map