/**
 * Database & user management for the cockpit: list databases/users and create a
 * database or an app user over the active driver. MySQL/MariaDB run as root via
 * the pantry UNIX socket; Postgres over local TCP — mirroring the provisioning
 * path in {@link import('../drivers/shared/db-provision')}.
 */
import type { CloudConfig, DatabaseConfig, EnvironmentType } from '@ts-cloud/core';
export type DbEngine = 'mysql' | 'mariadb' | 'postgres';
/** Valid SQL identifier for a database/user name (kept strict for safety). */
export declare function isValidDbIdentifier(value: string): boolean;
export declare function resolveDbEngine(config: CloudConfig): DbEngine;
export declare function buildListScript(engine: DbEngine, database?: DatabaseConfig): string[];
export declare function buildCreateDatabaseScript(engine: DbEngine, name: string, database?: DatabaseConfig): string[];
export interface CreateUserInput {
    username: string;
    password: string;
    database?: string;
    access?: 'all' | 'readonly';
}
export declare function buildCreateUserScript(engine: DbEngine, input: CreateUserInput, database?: DatabaseConfig): string[];
export declare function parseDbList(output: string): {
    databases: string[];
    users: string[];
};
interface DbRunResult {
    ok: boolean;
    stdout?: string;
    stderr?: string;
    error?: string;
}
export declare function listDatabases(config: CloudConfig, environment: EnvironmentType): Promise<DbRunResult & {
    engine: DbEngine;
    databases: string[];
    users: string[];
}>;
export declare function createDatabase(config: CloudConfig, environment: EnvironmentType, name: string): Promise<DbRunResult>;
export declare function createDatabaseUser(config: CloudConfig, environment: EnvironmentType, input: CreateUserInput): Promise<DbRunResult>;
/** Where per-database dumps are written on the box. */
export declare const DB_BACKUP_DIR = "/var/backups/ts-cloud/databases";
/**
 * Script that dumps a single database to a timestamped, gzipped file. The name
 * is a validated SQL identifier (no shell metacharacters), so it is safe to
 * embed directly. The timestamp is computed on the box. Postgres connects over
 * the local unix socket for a co-located engine, or TCP with credentials for
 * an external host (see {@link pgAdminCommand}).
 */
export declare function buildBackupScript(engine: DbEngine, name: string, destDir?: string, database?: DatabaseConfig): string[];
/** Script that lists the most recent dumps (newest first). */
export declare function buildListBackupsScript(destDir?: string): string[];
export declare function parseBackups(output: string): Array<{
    file: string;
    database: string;
}>;
/** Dump a single database to a gzipped file on the box. */
export declare function backupDatabase(config: CloudConfig, environment: EnvironmentType, name: string): Promise<DbRunResult & {
    database: string;
}>;
/** List the per-database dumps present on the box. */
export declare function listDatabaseBackups(config: CloudConfig, environment: EnvironmentType): Promise<DbRunResult & {
    backups: Array<{
        file: string;
        database: string;
    }>;
}>;
export {};
