import type { CachedAbTest } from '../middleware/types'; import type { AbTest } from '../types'; /** * Build a plain-object testsByPath map suitable for static generation. * * This is the Record-based equivalent of the internal Map used at runtime. * The result is JSON-serialisable and can be written to a generated TypeScript file * with `generateAbTestsFileContent`. * * @param tests - Array of AbTest entries (e.g. from `transformPageTest`) * @returns Record of normalised control path → CachedAbTest[] */ export declare function buildStaticTestsByPath(tests: AbTest[]): Record; export interface GenerateAbTestsFileOptions { /** * The package to import `CachedAbTest` from in the generated file. * @default "@se-studio/ab-testing" */ importPath?: string; } /** * Generate the content of a static TypeScript file exporting a `testsByPath` constant. * * Apps write this content to e.g. `src/lib/__generated/abTests.ts` at build time, * then import `testsByPath` directly in their middleware — zero async overhead, no KV store needed. * * @example * ```typescript * // management/generateAbTests.ts * import { writeFile } from 'node:fs/promises'; * import { transformPageTest } from '@se-studio/ab-testing/webhook'; * import { buildStaticTestsByPath, generateAbTestsFileContent } from '@se-studio/ab-testing/codegen'; * import { fetchRawPageTests } from '../src/cms/pageTests'; * * const raw = await fetchRawPageTests(); * const tests = raw.map(r => transformPageTest(r)).filter(t => t !== null); * const testsByPath = buildStaticTestsByPath(tests); * await writeFile('./src/lib/__generated/abTests.ts', generateAbTestsFileContent(testsByPath)); * ``` */ export declare function generateAbTestsFileContent(testsByPath: Record, options?: GenerateAbTestsFileOptions): string; //# sourceMappingURL=generator.d.ts.map