/** * Source Request Builder * * Fluent builder for constructing HTTP requests with consistent * headers, authentication, and timeout handling. * * @since v1.37.0 */ import type { ZodSchema } from 'zod'; /** * Authentication type for requests */ export type AuthType = 'bearer' | 'api-key' | 'basic'; /** * Request builder options */ export interface RequestBuilderOptions { /** Base URL for all requests */ baseUrl?: string; /** Default timeout in milliseconds */ timeout?: number; /** Default User-Agent header */ userAgent?: string; /** Source name for error context */ sourceName?: string; } /** * Request options for individual requests */ export interface RequestOptions { /** Request headers */ headers?: Record; /** Request timeout in milliseconds */ timeout?: number; /** Request body (for POST/PUT) */ body?: unknown; /** HTTP method */ method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'; } /** * Fluent request builder for source API calls * * @example * ```typescript * const builder = new SourceRequestBuilder({ * baseUrl: 'https://api.modrinth.com/v2', * userAgent: 'Pluginator/1.0', * }); * * const data = await builder * .withAuth('bearer', token) * .get('/project/sodium', ProjectSchema); * ``` */ export declare class SourceRequestBuilder { private baseUrl; private timeout; private userAgent; private sourceName; private headers; constructor(options?: RequestBuilderOptions); /** * Clone the builder with current settings */ clone(): SourceRequestBuilder; /** * Set authentication header */ withAuth(type: AuthType, credentials: string, keyHeader?: string): this; /** * Set custom User-Agent */ withUserAgent(userAgent: string): this; /** * Set request timeout */ withTimeout(ms: number): this; /** * Set base URL */ withBaseUrl(baseUrl: string): this; /** * Set source name for error context */ withSourceName(name: string): this; /** * Add custom header */ withHeader(key: string, value: string): this; /** * Add multiple headers */ withHeaders(headers: Record): this; /** * Build the full URL */ private buildUrl; /** * Execute a fetch request with error handling */ private fetchWithErrorHandling; /** * Make a GET request * * @param path - URL path (will be appended to baseUrl) * @param schema - Optional Zod schema for response validation */ get(path: string, schema?: ZodSchema): Promise; /** * Make a POST request */ post(path: string, body?: unknown, schema?: ZodSchema): Promise; /** * Make a raw request without JSON parsing (for binary data) */ getRaw(path: string): Promise; /** * Make a HEAD request (useful for checking if a resource exists) */ head(path: string): Promise; } /** * Create a pre-configured request builder for a specific source */ export declare function createSourceRequestBuilder(sourceName: string, options?: Omit): SourceRequestBuilder; //# sourceMappingURL=request-builder.d.ts.map