import { Config } from "drizzle-kit"; //#region src/http.d.ts type D1HttpConfig = { /** 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; /** Cloudflare account ID. Falls back to `CLOUDFLARE_ACCOUNT_ID` env var -> wrangler config -> wrangler account cache. */ accountId?: string; /** D1 database ID. Falls back to `CLOUDFLARE_DATABASE_ID` env var -> wrangler config. */ databaseId?: string; /** Cloudflare API token. Falls back to `CLOUDFLARE_D1_TOKEN` / `CLOUDFLARE_API_TOKEN` env vars -> `wrangler auth token --json` CLI. */ token?: string; }; type D1HttpDrizzleConfig = Pick, 'dialect' | 'driver' | 'dbCredentials' | 'out'>; /** * Creates a Drizzle config for Cloudflare D1 via HTTP (remote). * * Resolves values through fallback chains: * - `accountId`: argument -> `CLOUDFLARE_ACCOUNT_ID` env var -> wrangler config `account_id` -> wrangler account cache * - `databaseId`: argument -> `CLOUDFLARE_DATABASE_ID` env var -> wrangler config `d1_databases[].database_id` * - `token`: argument -> `CLOUDFLARE_D1_TOKEN` / `CLOUDFLARE_API_TOKEN` env vars -> `wrangler auth token --json` CLI * - `out`: argument -> wrangler config `d1_databases[].migrations_dir` * * @example * ```ts * // Auto-resolve everything from wrangler config and environment * export default defineConfig({ ...d1Config(), schema: './src/db/schema.ts' }) * ``` * * @example * ```ts * // Fully explicit * export default defineConfig({ * ...d1Config({ * accountId: 'my-account-id', * databaseId: 'my-db-id', * token: 'my-api-token', * }), * schema: './src/db/schema.ts', * }) * ``` * * @param config - Configuration options. All fields are optional if wrangler config and credentials are available. * @returns A partial Drizzle config object to spread into `defineConfig` * @throws If `accountId`, `databaseId`, or `token` cannot be resolved from any source * @throws If multiple D1 databases are found and `binding` is not specified */ declare const d1Config: (config?: D1HttpConfig) => D1HttpDrizzleConfig; //#endregion export { D1HttpConfig, d1Config };