export type { StorageLocationType } from './storage-location.js';
import type { StorageLocationType } from './storage-location.js';
/** All location types as an array (for iteration) */
export declare const STORAGE_LOCATION_TYPES: readonly StorageLocationType[];
/** Default subdirectory names for filesystem storage */
export declare const DEFAULT_LOCATION_SUBDIRS: Readonly<Record<StorageLocationType, string>>;
/**
 * A storage provider serves file-based storage for one or more location types.
 * Multiple providers can coexist (local filesystem, NAS, S3, etc.).
 * Each addon/system setting selects which provider to use per location type.
 */
export interface StorageResolveInput {
    readonly location: StorageLocationType;
    readonly relativePath: string;
}
export interface StorageWriteInput {
    readonly location: StorageLocationType;
    readonly relativePath: string;
    readonly data: Buffer | NodeJS.ReadableStream;
}
export interface StorageReadInput {
    readonly location: StorageLocationType;
    readonly relativePath: string;
}
export interface StorageExistsInput {
    readonly location: StorageLocationType;
    readonly relativePath: string;
}
export interface StorageListInput {
    readonly location: StorageLocationType;
    readonly prefix?: string;
}
export interface StorageDeleteInput {
    readonly location: StorageLocationType;
    readonly relativePath: string;
}
export interface StorageAvailableSpaceInput {
    readonly location: StorageLocationType;
}
export interface IStorageProvider {
    readonly id: string;
    readonly name: string;
    readonly supportedLocations: readonly StorageLocationType[];
    resolve(input: StorageResolveInput): string;
    write(input: StorageWriteInput): Promise<void>;
    read(input: StorageReadInput): Promise<Buffer>;
    exists(input: StorageExistsInput): Promise<boolean>;
    list(input: StorageListInput): Promise<readonly string[]>;
    delete(input: StorageDeleteInput): Promise<void>;
    getAvailableSpace(input: StorageAvailableSpaceInput): Promise<number | null>;
}
/**
 * All named collections that the settings backend manages.
 * Each collection maps to a logical table/bucket in the backend.
 */
export type SettingsCollection = 'system-settings' | 'addon-settings' | 'provider-settings' | 'device-settings' | 'detection-events' | 'audio-levels' | 'track-trails' | 'recording-segments' | 'recording-thumbnails' | 'recording-policies' | 'recording-storage-config' | 'recording-cleanup-queue' | 'known-faces' | (string & {});
export interface SettingsGetInput {
    readonly namespace?: string;
    readonly collection: SettingsCollection;
    readonly key: string;
}
export interface SettingsSetInput {
    readonly namespace?: string;
    readonly collection: SettingsCollection;
    readonly key: string;
    readonly value: unknown;
}
export interface SettingsQueryInput {
    readonly namespace?: string;
    readonly collection: SettingsCollection;
    readonly filter?: QueryFilter;
}
export interface SettingsInsertInput<T extends object = Record<string, unknown>> {
    readonly namespace?: string;
    readonly collection: SettingsCollection;
    readonly record: SettingsRecord<T>;
}
export interface SettingsUpdateInput {
    readonly namespace?: string;
    readonly collection: SettingsCollection;
    readonly id: string;
    readonly data: Record<string, unknown>;
}
export interface SettingsDeleteInput {
    readonly namespace?: string;
    readonly collection: SettingsCollection;
    readonly key: string;
}
export interface SettingsCountInput {
    readonly namespace?: string;
    readonly collection: SettingsCollection;
    readonly filter?: QueryFilter;
}
export interface SettingsIsEmptyInput {
    readonly namespace?: string;
    readonly collection: SettingsCollection;
}
/**
 * Settings backend — persistent key-value and document storage.
 * Default implementation: SQLite. Can be replaced by Postgres, etc.
 * All methods use object-arg signatures for extensibility.
 */
export interface ISettingsBackend {
    /** Get a single value by key from a collection */
    get(input: SettingsGetInput): Promise<unknown>;
    /** Set a value by key in a collection (upsert) */
    set(input: SettingsSetInput): Promise<void>;
    /** Get all entries matching an optional filter */
    query<T extends object = Record<string, unknown>>(input: SettingsQueryInput): Promise<readonly SettingsRecord<T>[]>;
    /** Insert a new record */
    insert<T extends object = Record<string, unknown>>(input: SettingsInsertInput<T>): Promise<void>;
    /** Update an existing record by ID */
    update(input: SettingsUpdateInput): Promise<void>;
    /** Delete a record by key/ID */
    delete(input: SettingsDeleteInput): Promise<void>;
    /** Count entries in a collection */
    count(input: SettingsCountInput): Promise<number>;
    /** Check if a collection is empty (used for first-boot detection) */
    isEmpty(input: SettingsIsEmptyInput): Promise<boolean>;
    /**
     * Declare a typed (SQL-backed) collection. After declaration, the
     * standard `insert` / `update` / `delete` / `query` methods route to
     * typed columns for this collection instead of the JSON-blob default.
     * Idempotent — re-declaring the same shape is a no-op. Backends
     * without typed-table support should implement this as a no-op so
     * the cap contract stays uniform.
     */
    declareCollection(input: {
        namespace?: string;
        collection: string;
        columns: readonly import('../capabilities/settings-store.cap.js').CollectionColumn[];
        indexes?: readonly import('../capabilities/settings-store.cap.js').CollectionIndex[];
    }): Promise<void>;
    /** Ensure a structured table exists (CREATE TABLE IF NOT EXISTS) */
    ensureTable?(table: string, schema: TableSchema): Promise<void>;
    /** Insert a row into a structured table */
    tableInsert?(table: string, row: Record<string, unknown>): Promise<void>;
    /** Update rows matching a filter */
    tableUpdate?(table: string, filter: Record<string, unknown>, updates: Record<string, unknown>): Promise<number>;
    /** Delete rows matching a filter. Returns count of deleted rows. */
    tableDelete?(table: string, filter: Record<string, unknown>): Promise<number>;
    /** Query rows from a structured table */
    tableQuery?(table: string, options?: TableQueryOptions): Promise<readonly Record<string, unknown>[]>;
    /** Get a single row by primary key or filter */
    tableGet?(table: string, filter: Record<string, unknown>): Promise<Record<string, unknown> | null>;
    /** Count rows matching a filter */
    tableCount?(table: string, filter?: Record<string, unknown>): Promise<number>;
}
export interface SettingsRecord<T extends object = Record<string, unknown>> {
    readonly id: string;
    readonly data: T;
}
export interface QueryFilter {
    where?: Record<string, unknown>;
    whereIn?: Record<string, unknown[]>;
    whereBetween?: Record<string, [unknown, unknown]>;
    orderBy?: {
        field: string;
        direction: 'asc' | 'desc';
    };
    limit?: number;
    offset?: number;
}
/** Column definition for structured tables */
export interface TableColumnSchema {
    readonly name: string;
    /**
     * Logical column type. SQLite has 5 native storage classes; we expose
     * a slightly richer surface so backends can implement marshaling:
     *   - `TEXT`    : plain string
     *   - `INTEGER` : 64-bit signed int (JS `number` round-trip)
     *   - `REAL`    : floating-point
     *   - `JSON`    : object / array serialised to a TEXT column at the
     *                 boundary; deserialised on read
     *   - `BOOLEAN` : `true|false` ↔ INTEGER `1|0` round-trip. The
     *                 backend is responsible for the bi-directional coercion
     *                 so consumer schemas can use canonical `boolean`
     *                 without a per-call preprocess.
     */
    readonly type: 'TEXT' | 'INTEGER' | 'REAL' | 'JSON' | 'BOOLEAN';
    readonly primaryKey?: boolean;
    readonly notNull?: boolean;
    readonly unique?: boolean;
    readonly defaultValue?: string | number | boolean | null;
}
/** Table schema for structured tables */
export interface TableSchema {
    readonly columns: readonly TableColumnSchema[];
    readonly indexes?: readonly TableIndexSchema[];
}
/** Index definition for structured tables */
export interface TableIndexSchema {
    readonly name: string;
    readonly columns: readonly string[];
    readonly unique?: boolean;
}
/** Query options for structured tables */
export interface TableQueryOptions {
    readonly where?: Record<string, unknown>;
    readonly orderBy?: {
        field: string;
        direction: 'asc' | 'desc';
    };
    readonly limit?: number;
    readonly offset?: number;
}
/**
 * Embeddings backend — vector storage with approximate nearest neighbor search.
 * Used for CLIP frame search, face recognition, plate matching.
 * Default implementation: HNSW (usearch/hnswlib). Can be replaced by Qdrant, etc.
 */
export interface IEmbeddingsBackend {
    /** Create or open a named vector index */
    openIndex(name: string, dimensions: number): Promise<IVectorIndex>;
    /** List all index names */
    listIndexes(): Promise<readonly string[]>;
    /** Delete an index and its data */
    deleteIndex(name: string): Promise<void>;
    /** Lifecycle */
    initialize(): Promise<void>;
    shutdown(): Promise<void>;
}
export interface IVectorIndex {
    /** Index name */
    readonly name: string;
    /** Vector dimensions */
    readonly dimensions: number;
    /** Insert a vector with ID and optional metadata */
    insert(id: string, vector: Float32Array, metadata?: Record<string, unknown>): Promise<void>;
    /** Batch insert for performance */
    insertBatch(items: readonly VectorEntry[]): Promise<void>;
    /** Search for nearest neighbors */
    search(query: Float32Array, topK: number, filter?: EmbeddingFilter): Promise<readonly VectorSearchResult[]>;
    /** Delete by ID */
    delete(id: string): Promise<void>;
    /** Count entries in the index */
    count(): Promise<number>;
    /** Flush pending writes to disk */
    flush(): Promise<void>;
}
export interface VectorEntry {
    readonly id: string;
    readonly vector: Float32Array;
    readonly metadata?: Record<string, unknown>;
}
export interface VectorSearchResult {
    readonly id: string;
    /** Similarity score (0-1, higher is more similar) */
    readonly score: number;
    readonly metadata?: Record<string, unknown>;
}
export interface EmbeddingFilter {
    /** Filter by metadata key-value before vector search */
    readonly where?: Record<string, unknown>;
    /** Filter by timestamp range */
    readonly timestampAfter?: number;
    readonly timestampBefore?: number;
    /** Filter by device */
    readonly deviceId?: string;
}
/**
 * A document record in collection-based storage.
 * Used by IStructuredStorage and ElementConfigStore.
 * New code should prefer ISettingsBackend + SettingsRecord.
 */
export interface StorageRecord {
    collection: string;
    id: string;
    data: Record<string, unknown>;
}
/**
 * Collection-based document storage (query, insert, update, delete).
 * Used by ElementConfigStore and StorageManager shim layer.
 * New code should prefer ISettingsBackend.
 */
export interface IStructuredStorage {
    query(collection: string, filter?: QueryFilter): Promise<readonly StorageRecord[]>;
    insert(record: StorageRecord): Promise<StorageRecord>;
    update(collection: string, id: string, data: Record<string, unknown>): Promise<StorageRecord>;
    delete(collection: string, id: string): Promise<void>;
    count(collection: string, filter?: QueryFilter): Promise<number>;
}
/**
 * File-based storage operations.
 * Used by StorageManager and addons for media/model files.
 * New code should prefer IStorageProvider.
 */
export interface IFileStorage {
    readFile(path: string): Promise<Buffer>;
    writeFile(path: string, data: Buffer): Promise<void>;
    deleteFile(path: string): Promise<void>;
    listFiles(prefix?: string): Promise<readonly string[]>;
    getFileUrl(path: string): Promise<string>;
    exists(path: string): Promise<boolean>;
}
/**
 * Combined storage location with optional structured + file storage.
 * Used by StorageManager.getLocation() and ElementConfigStore.
 * New code should prefer IStorageProvider + ISettingsBackend.
 */
export interface IStorageLocation {
    structured?: IStructuredStorage;
    files?: IFileStorage;
}
//# sourceMappingURL=storage.d.ts.map