import type { NextRequest } from 'next/server'; import { NextResponse } from 'next/server'; import type { AbTestAssignment } from '../types'; import type { AbTestMiddlewareConfig, AbTestResult, CachedAbTest } from './types'; /** * Create an A/B test middleware handler. * * This factory function returns a middleware handler that can be called * from your Next.js middleware to process A/B test assignments. * * @param config - Middleware configuration * @returns Async function that processes requests and returns NextResponse or null */ export declare function createAbTestMiddleware(config: AbTestMiddlewareConfig): (request: NextRequest) => Promise; /** * Low-level function to process an A/B test request. * Use this if you need more control over the response handling. */ export declare function processAbTestRequest(pathname: string, searchParams: URLSearchParams, cookieValue: string | undefined, store: ReturnType, cacheTtlMs: number, devTestData?: AbTestMiddlewareConfig['devTestData'], options?: Pick): Promise; /** * Options for the static A/B test middleware. */ export interface StaticAbTestMiddlewareOptions { /** Name of the cookie used to store A/B test assignments. @default "ab-test-info" */ cookieName?: string; /** Cookie max age in seconds. @default 2592000 (30 days) */ cookieMaxAge?: number; /** * Path prefix to prepend when rewriting to a variant. * e.g. "/page-test" → rewrites to "/page-test/slug" instead of "/slug". * @default "" (no prefix) */ variantPathPrefix?: string; /** Optional function to skip processing for certain pathnames. */ shouldProcess?: (pathname: string) => boolean; /** Optional callback when a cookie assignment fails validation. */ onValidationFailure?: (testId: string, assignment: AbTestAssignment) => void; /** * Remove cookie entries for tests no longer in the active config. * @default true */ pruneStaleAssignments?: boolean; /** * When injecting url_params, skip keys already present on the request URL. * @default true */ respectExistingUrlParams?: boolean; } /** * Create a synchronous A/B test middleware from a pre-generated static testsByPath map. */ export declare function createStaticAbTestMiddleware(staticTestsByPath: Record, options?: StaticAbTestMiddlewareOptions): (request: NextRequest) => NextResponse | null; //# sourceMappingURL=handler.d.ts.map