import { Config } from "drizzle-kit"; //#region src/local.d.ts type D1LocalConfig = { /** Migration output directory. Falls back to `migrations_dir` in wrangler config. */ out?: string; /** D1 binding name to look up in `d1_databases`. If omitted and there is exactly one D1 database, it is used automatically. */ binding?: string; /** Explicit path to the wrangler config file. Auto-detected from `cloudflare.config.ts`, `wrangler.jsonc`, `wrangler.toml`, or `wrangler.json` if omitted. */ wranglerConfigPath?: string; /** Mode (`ctx.mode`) passed to a function-form `cloudflare.config.ts`. Falls back to the `CLOUDFLARE_ENV` env var. */ mode?: string; /** D1 database ID. Falls back to `CLOUDFLARE_DATABASE_ID` env var -> wrangler config. */ databaseId?: string; /** Wrangler state directory, corresponding to `--persist-to`. Defaults to `.wrangler/state/v3`. */ persistDir?: string; }; type D1LocalDrizzleConfig = Pick, 'dialect' | 'dbCredentials' | 'out'>; /** * Creates a Drizzle config for local Cloudflare D1 (SQLite via `.wrangler/state/v3/d1`). * * Resolves values through fallback chains: * - `databaseId`: argument -> `CLOUDFLARE_DATABASE_ID` env var -> wrangler config `d1_databases[].database_id` * - `out`: argument -> wrangler config `d1_databases[].migrations_dir` * * @example * ```ts * // Auto-resolve everything from wrangler config * export default defineConfig({ ...d1Config(), schema: './src/db/schema.ts' }) * ``` * * @example * ```ts * // Explicit databaseId with custom persist directory * export default defineConfig({ * ...d1Config({ databaseId: 'abc123', persistDir: './custom/state' }), * schema: './src/db/schema.ts', * }) * ``` * * @param config - Configuration options. All fields are optional if wrangler config is available. * @returns A partial Drizzle config object to spread into `defineConfig` * @throws If `databaseId` cannot be resolved from any source * @throws If multiple D1 databases are found and `binding` is not specified */ declare const d1Config: (config?: D1LocalConfig) => D1LocalDrizzleConfig; //#endregion export { d1Config };