import { IFileStorage, StorageLocationName, IStorageLocation, ICamstackAddon, IConfigurable, AddonManifest, AddonContext, CapabilityProviderMap, ConfigUISchema } from '@camstack/types';

declare class FileSystemStorage implements IFileStorage {
    private readonly basePath;
    constructor(basePath: string);
    readFile(filePath: string): Promise<Buffer>;
    writeFile(filePath: string, data: Buffer): Promise<void>;
    deleteFile(filePath: string): Promise<void>;
    listFiles(prefix?: string): Promise<readonly string[]>;
    getFileUrl(_path: string): Promise<string>;
    exists(filePath: string): Promise<boolean>;
}
/** @deprecated Use FilesystemStorageProvider + SqliteSettingsBackend instead */
declare class SqliteStorageProvider {
    private mainDb;
    private sharedStructured;
    private readonly locations;
    initialize(): Promise<void>;
    /**
     * Configure all storage locations.
     * ONE single SQLite database (camstack.db) is used for ALL structured storage.
     * File-based locations use the filesystem at their configured path.
     */
    configure(config: {
        locations: Record<string, string>;
    }): Promise<void>;
    getLocation(name: StorageLocationName): IStorageLocation;
    shutdown(): Promise<void>;
    export(_locationName: StorageLocationName): Promise<Buffer>;
    import(_locationName: StorageLocationName, _data: Buffer): Promise<void>;
}

declare class SqliteStorageAddon implements ICamstackAddon, IConfigurable {
    readonly manifest: AddonManifest;
    private provider;
    initialize(context: AddonContext): Promise<void>;
    shutdown(): Promise<void>;
    getProvider(): SqliteStorageProvider;
    getCapabilityProvider<K extends keyof CapabilityProviderMap>(name: K): CapabilityProviderMap[K] | null;
    getConfigSchema(): ConfigUISchema;
    getConfig(): Record<string, unknown>;
    onConfigChange(_config: Record<string, unknown>): Promise<void>;
}

/**
 * Thin wrapper over better-sqlite3 that manages the four settings tables:
 * system_settings, addon_settings, provider_settings, device_settings.
 *
 * All values are stored as JSON text and deserialized on read.
 */
declare class SettingsStore {
    private readonly db;
    constructor(dbPath: string);
    getSystem(key: string): unknown;
    setSystem(key: string, value: unknown): void;
    getAllSystem(): Record<string, unknown>;
    getAddon(addonId: string, key: string): unknown;
    setAddon(addonId: string, key: string, value: unknown): void;
    getAllAddon(addonId: string): Record<string, unknown>;
    /** Bulk-replace all keys for an addon (within a transaction). */
    setAllAddon(addonId: string, config: Record<string, unknown>): void;
    getProvider(providerId: string, key: string): unknown;
    setProvider(providerId: string, key: string, value: unknown): void;
    getAllProvider(providerId: string): Record<string, unknown>;
    getDevice(deviceId: string, key: string): unknown;
    setDevice(deviceId: string, key: string, value: unknown): void;
    getAllDevice(deviceId: string): Record<string, unknown>;
    /** Close the SQLite connection (call on shutdown). */
    close(): void;
    /** Check if system_settings is empty (used for first-boot seeding). */
    isSystemSettingsEmpty(): boolean;
    /** Seed system_settings with RUNTIME_DEFAULTS (only on first boot). */
    seedDefaults(): void;
    private initTables;
}

/** Core table DDL statements -- executed on first boot */
declare const CORE_TABLE_DDL: readonly string[];
/** Addon table schema declaration */
interface AddonTableSchema {
    readonly name: string;
    readonly columns: ReadonlyArray<{
        readonly name: string;
        readonly type: 'TEXT' | 'INTEGER' | 'REAL' | 'JSON';
        readonly primaryKey?: boolean;
        readonly notNull?: boolean;
    }>;
    readonly indexes?: ReadonlyArray<{
        readonly name: string;
        readonly columns: readonly string[];
        readonly unique?: boolean;
    }>;
}
/** Generate CREATE TABLE DDL from addon schema */
declare function addonTableToDdl(schema: AddonTableSchema): string[];

export { type AddonTableSchema as A, CORE_TABLE_DDL as C, FileSystemStorage as F, SettingsStore as S, SqliteStorageAddon as a, SqliteStorageProvider as b, addonTableToDdl as c };
