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 { 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, options?: RequestOptions): Record; /** * 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, unwrap: (d: unknown) => T, requestWithRetry: (fn: () => Promise) => Promise, 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; /** * Execute a generated SDK function with full middleware pipeline. * Handles headers, retry, unwrapping, and error conversion. */ execute(fn: (...args: any[]) => Promise, params: Record, options?: RequestOptions): Promise; /** * Execute a delete operation that returns true on success. */ executeDelete(fn: (...args: any[]) => Promise, params: Record, options?: RequestOptions): Promise; /** * Execute a raw GET request to a custom (non-generated) endpoint. * Used for endpoints implemented as custom Phoenix controllers. */ rawGet(url: string, options?: RequestOptions): Promise; /** * 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(url: string, options?: RequestOptions): Promise>; /** * 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(url: string, body: FormData, options?: RequestOptions): Promise; /** * Execute a raw POST request to a custom (non-generated) endpoint. * Used for endpoints implemented as custom Phoenix controllers. */ rawPost(url: string, body?: unknown, options?: RequestOptions): Promise; /** * Execute a raw PATCH request to a custom (non-generated) endpoint. * Used for endpoints implemented as custom Phoenix controllers. */ rawPatch(url: string, body?: unknown, options?: RequestOptions): Promise; /** * Execute a raw DELETE request to a custom (non-generated) endpoint. */ rawDelete(url: string, options?: RequestOptions): Promise; /** * 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(fn: (...args: any[]) => Promise, queryBuilder: (page: number, pageSize: number) => Record, options?: RequestOptions): (page: number, pageSize: number) => Promise>; /** * 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>; /** * 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>; } //# sourceMappingURL=request-builder.d.ts.map