import { ISettingsBackend, SettingsCollection, QueryFilter, SettingsRecord, ICamstackAddon, IConfigurable, AddonManifest, AddonContext, CapabilityProviderMap, ConfigUISchema } from '@camstack/types';

/**
 * SQLite implementation of ISettingsBackend.
 *
 * One table per collection, auto-created on first access.
 * All data stored as JSON in a TEXT column.
 * WAL mode for concurrent reads.
 */
declare class SqliteSettingsBackend implements ISettingsBackend {
    private readonly dbPath;
    private db;
    private readonly ensuredTables;
    private readonly runtimeDefaults;
    constructor(dbPath: string, runtimeDefaults?: Record<string, unknown>);
    initialize(): Promise<void>;
    shutdown(): Promise<void>;
    get(collection: SettingsCollection, key: string): Promise<unknown>;
    set(collection: SettingsCollection, key: string, value: unknown): Promise<void>;
    query(collection: SettingsCollection, filter?: QueryFilter): Promise<readonly SettingsRecord[]>;
    insert(collection: SettingsCollection, record: SettingsRecord): Promise<void>;
    update(collection: SettingsCollection, id: string, data: Record<string, unknown>): Promise<void>;
    delete(collection: SettingsCollection, key: string): Promise<void>;
    count(collection: SettingsCollection, filter?: QueryFilter): Promise<number>;
    isEmpty(collection: SettingsCollection): Promise<boolean>;
    /** Get a system setting by dot-notation key */
    getSystem(key: string): unknown;
    /** Set a system setting */
    setSystem(key: string, value: unknown): void;
    /** Get all system settings as flat key-value */
    getAllSystem(): Record<string, unknown>;
    /** Get all settings for an addon */
    getAllAddon(addonId: string): Record<string, unknown>;
    /** Bulk-set all settings for an addon */
    setAllAddon(addonId: string, config: Record<string, unknown>): void;
    /** Get all settings for a provider */
    getAllProvider(providerId: string): Record<string, unknown>;
    /** Set a provider setting */
    setProvider(providerId: string, key: string, value: unknown): void;
    /** Get all settings for a device */
    getAllDevice(deviceId: string): Record<string, unknown>;
    /** Set a device setting */
    setDevice(deviceId: string, key: string, value: unknown): void;
    /** Seed system-settings with runtime defaults (first boot) */
    private seedDefaults;
    private getDb;
    private ensureTable;
    private getAllScoped;
    private setScopedKey;
}

/**
 * SQLite Settings addon — provides persistent settings storage.
 * Capability: 'settings-store' (singleton)
 *
 * Depends on 'storage' capability for resolving the DB file path.
 */
declare class SqliteSettingsAddon implements ICamstackAddon, IConfigurable {
    readonly manifest: AddonManifest;
    private backend;
    initialize(context: AddonContext): Promise<void>;
    shutdown(): Promise<void>;
    getBackend(): SqliteSettingsBackend | null;
    getCapabilityProvider<K extends keyof CapabilityProviderMap>(name: K): CapabilityProviderMap[K] | null;
    getConfigSchema(): ConfigUISchema;
    getConfig(): Record<string, unknown>;
    onConfigChange(_config: Record<string, unknown>): Promise<void>;
}

export { SqliteSettingsAddon as S, SqliteSettingsBackend as a };
