import type { AbTest, AbTestVariantConfig, IBlobStore } from '../types'; /** Legacy CMS configuration shape accepted during migration. */ interface LegacyVariantConfig { weight: number; variant_label?: string; reporting_event?: string; hubspot_event_name?: string; utm_content?: string; url_params?: Record; reporting_params?: Record; } /** * Raw PageTest data from Contentful (before transformation). * This interface represents the expected shape of data from your Contentful fetch. */ export interface RawPageTest { /** Contentful system metadata */ sys: { id: string; }; /** CMS label for the test */ cmsLabel?: string | null; /** Whether the test is enabled */ enabled?: boolean | null; /** Optional tracking label override */ trackingLabel?: string | null; /** Optional search parameters to match */ searchParameters?: string | null; /** When true, inject url_params from the assigned bucket */ injectUrlParams?: boolean | null; /** Variant configuration JSON */ configuration?: LegacyVariantConfig[] | null; /** Control page reference */ control?: { sys?: { id: string; }; slug?: string | null; } | null; /** Variants collection */ variantsCollection?: { items?: Array<{ sys: { id: string; }; slug?: string | null; } | null> | null; } | null; } /** * Configuration for the webhook handler. */ export interface WebhookHandlerConfig { /** * Function to fetch all active PageTest entries from Contentful. * This should return the raw data from your GraphQL or REST API call. */ fetchPageTests: () => Promise; /** * Function to get the blob store instance. */ getStore: () => IBlobStore | Promise>; /** * Optional secret for webhook authentication. * If provided, the webhook will validate the x-contentful-webhook-secret header. */ webhookSecret?: string; /** * Optional callback when a test is skipped (e.g., no control slug). */ onSkippedTest?: (testId: string, reason: string) => void; /** * Optional revalidation function to call after updating the store. * Useful for clearing Next.js cache tags. */ revalidate?: () => void | Promise; } /** * Result of processing the webhook. */ export interface WebhookResult { /** Whether the webhook was processed successfully */ success: boolean; /** Number of tests stored */ count: number; /** Optional error message */ error?: string; } /** * Normalize a single bucket config, accepting legacy field names. */ export declare function normalizeVariantConfig(raw: LegacyVariantConfig): AbTestVariantConfig; /** * Transform raw Contentful PageTest data into AbTest format. */ export declare function transformPageTest(raw: RawPageTest, onSkipped?: (testId: string, reason: string) => void): AbTest | null; /** * Process all PageTest entries and store them in the blob store. * * @param config - Webhook handler configuration * @returns Result with success status and count */ export declare function processAbTestWebhook(config: WebhookHandlerConfig): Promise; /** * Create a Next.js API route handler for the A/B test webhook. */ export declare function createWebhookHandler(config: WebhookHandlerConfig): (request: Request) => Promise; export {}; //# sourceMappingURL=handler.d.ts.map