/** * Header Builder Utilities * Fluent API for building HTTP headers, following TASK-016 specification */ import type { ApiHeaders, ContentType, AcceptType, AuthType, PlatformType, HeaderBuilderLike } from '@plyaz/types/api'; /** * Header builder with fluent API for constructing HTTP headers * * @example * ```typescript * const headers = new HeaderBuilder() * .auth('Bearer token123') * .contentType('json') * .locale('en-US') * .tenant('acme-corp') * .build(); * ``` */ export declare class HeaderBuilder implements HeaderBuilderLike { private _headers; /** * Get read-only access to headers (for HeaderBuilderLike compatibility) */ get headers(): ApiHeaders; /** * Set authentication header * * @param token - Authentication token or credentials * @param type - Authentication type (Bearer, Basic, ApiKey) * @returns Builder instance for chaining * * @example * ```typescript * builder.auth('token123') // Bearer token123 * builder.auth('token123', 'Basic') // Basic token123 * builder.auth('key123', 'ApiKey') // x-api-key: key123 * ``` */ auth(token: string, type?: AuthType): this; /** * Set content type header * * @param type - Content type (json, form, multipart, or custom) * @returns Builder instance for chaining * * @example * ```typescript * builder.contentType('json') // application/json * builder.contentType('form') // application/x-www-form-urlencoded * builder.contentType('multipart') // multipart/form-data * builder.contentType('application/vnd.api+json') // custom type * ``` */ contentType(type: ContentType): this; /** * Set accept header * * @param type - Accept type (json, xml, html, or custom) * @returns Builder instance for chaining * * @example * ```typescript * builder.accept('json') // application/json * builder.accept('xml') // application/xml * builder.accept('stream') // text/event-stream * ``` */ accept(type: AcceptType): this; /** * Set locale/language headers * * @param locale - Locale string (e.g., 'en-US', 'fr-FR') * @returns Builder instance for chaining * * @example * ```typescript * builder.locale('en-US') // Sets both accept-language and x-locale * ``` */ locale(locale: string): this; /** * Set platform header * * @param platform - Platform identifier * @returns Builder instance for chaining * * @example * ```typescript * builder.platform('ios') // x-platform: ios * builder.platform('web') // x-platform: web * ``` */ platform(platform: PlatformType): this; /** * Set tenant for multi-tenant applications * * @param tenantId - Tenant identifier * @returns Builder instance for chaining * * @example * ```typescript * builder.tenant('acme-corp') // x-tenant-id: acme-corp * ``` */ tenant(tenantId: string): this; /** * Set user context * * @param userId - User identifier * @returns Builder instance for chaining * * @example * ```typescript * builder.user('user123') // x-user-id: user123 * ``` */ user(userId: string): this; /** * Set application version * * @param version - Application version * @returns Builder instance for chaining * * @example * ```typescript * builder.version('1.2.3') // x-app-version: 1.2.3 * ``` */ version(version: string): this; /** * Set feature flags * * @param flags - Feature flags as array or comma-separated string * @returns Builder instance for chaining * * @example * ```typescript * builder.features(['featureA', 'featureB']) // x-feature-flag: featureA,featureB * builder.features('featureA,featureB') // x-feature-flag: featureA,featureB * ``` */ features(flags: string[] | string): this; /** * Set device identifier * * @param deviceId - Device identifier * @returns Builder instance for chaining * * @example * ```typescript * builder.device('device123') // x-device-id: device123 * ``` */ device(deviceId: string): this; /** * Set session identifier * * @param sessionId - Session identifier * @returns Builder instance for chaining * * @example * ```typescript * builder.session('sess_abc123') // x-session-id: sess_abc123 * ``` */ session(sessionId: string): this; /** * Set client identifier * * @param clientId - Client identifier * @returns Builder instance for chaining * * @example * ```typescript * builder.client('mobile-app') // x-client-id: mobile-app * ``` */ client(clientId: string): this; /** * Add correlation ID for distributed tracing * * @param id - Correlation ID (auto-generated if not provided) * @returns Builder instance for chaining * * @example * ```typescript * builder.correlationId() // x-correlation-id: auto-generated * builder.correlationId('corr_123') // x-correlation-id: corr_123 * ``` */ correlationId(id?: string): this; /** * Add request ID for tracking * * @param id - Request ID (auto-generated if not provided) * @returns Builder instance for chaining * * @example * ```typescript * builder.requestId() // x-request-id: auto-generated * builder.requestId('req_123') // x-request-id: req_123 * ``` */ requestId(id?: string): this; /** * Add trace ID for distributed tracing * * @param traceId - Trace ID (auto-generated if not provided) * @returns Builder instance for chaining * * @example * ```typescript * builder.traceId() // x-trace-id: auto-generated * builder.traceId('trace_123') // x-trace-id: trace_123 * ``` */ traceId(traceId?: string): this; /** * Add span ID for distributed tracing * * @param spanId - Span ID * @returns Builder instance for chaining * * @example * ```typescript * builder.spanId('span_123') // x-span-id: span_123 * ``` */ spanId(spanId: string): this; /** * Add AJAX request marker * * @returns Builder instance for chaining * * @example * ```typescript * builder.ajax() // x-requested-with: XMLHttpRequest * ``` */ ajax(): this; /** * Add custom header * * @param key - Header name * @param value - Header value * @returns Builder instance for chaining * * @example * ```typescript * builder.custom('x-custom-header', 'custom-value') * ``` */ custom(key: string, value: string): this; /** * Add multiple headers at once * * @param headers - Headers object to merge * @returns Builder instance for chaining * * @example * ```typescript * builder.merge({ 'x-custom-1': 'value1', 'x-custom-2': 'value2' }) * ``` */ merge(headers: Record): this; /** * Get built headers object * * @returns Headers object ready for use with API requests * * @example * ```typescript * const headers = builder.build(); * await fetch('/api/data', { headers }); * ``` */ build(): ApiHeaders; /** * Clear all headers and reset builder * * @returns Builder instance for chaining */ clear(): this; /** * Remove specific header * * @param key - Header name to remove * @returns Builder instance for chaining */ remove(key: string): this; } /** * Create a new header builder instance * * @returns New HeaderBuilder instance * * @example * ```typescript * import { headers } from '@plyaz/api/headers'; * * const myHeaders = headers() * .auth('Bearer token') * .contentType('json') * .build(); * ``` */ export declare function headers(): HeaderBuilder; //# sourceMappingURL=headerBuilder.d.ts.map