import type { FetchAPI } from '../types.cjs';
import type { Plugin } from './types.cjs';
export interface GenerateRequestIdPayload<TContext> {
    request: Request;
    fetchAPI: FetchAPI;
    context: TContext;
}
export interface RequestIdOptions<TContext> {
    /**
     * Function to generate a request ID
     *
     * Ignored when the host integration already assigned an id to the native request object (see
     * {@link getHostRequestId}), or when `trustHeader` is enabled and `headerName` is available in
     * the request headers.
     */
    generateRequestId?: GenerateRequestIdFn<TContext>;
    /**
     * Header name to use for request ID
     *
     * Default: `x-request-id`
     */
    headerName?: string;
    /**
     * Use the incoming request's `headerName` header as the request id, when present.
     *
     * Turn this off when the server is directly reachable by clients, rather than only through a
     * proxy or gateway that sets the header itself - otherwise any client can pick its own request
     * id (and have it correlated across your logs as if it were trusted), including one already in
     * use for another request.
     *
     * Has no effect when the host integration already assigned an id to the native request object
     * (see {@link getHostRequestId}), which always takes precedence so Yoga's logs agree with the
     * host's own.
     *
     * @default true
     */
    trustHeader?: boolean;
}
export type GenerateRequestIdFn<TContext> = (payload: GenerateRequestIdPayload<TContext>) => string;
export declare const defaultGenerateRequestId: GenerateRequestIdFn<any>;
export declare const defaultRequestIdHeader: string;
export declare function getRequestIdHeaderName<TContext>(opts?: RequestIdOptions<TContext>): string;
/**
 * Correlates everything happening while handling a request under a single request id.
 *
 * A request id the host integration already set on the native request object (see
 * {@link getHostRequestId}) is preferred first, so Yoga's logs always agree with the host's own;
 * otherwise, if `trustHeader` is enabled (the default), the `x-request-id` header of the
 * incoming request is used if present and usable (see {@link getRequestId}); otherwise, one is
 * generated. It is then added to the server context's `log`ger as the `requestId` attribute, and
 * set on the outgoing response's headers.
 */
export declare function useRequestId<TServerContext extends Record<string, any>>(opts?: RequestIdOptions<TServerContext>): Plugin<{}, TServerContext>;
