import { Observable } from 'rxjs';
import { ReactiveIDBObjectStore } from './reactive-idb-object-store';
import { ReactiveIDBTransaction } from './reactive-idb-transaction';
export interface ReactiveIDBTransformer<T> {
    serialize: (obj: T) => unknown;
    deserialize: (value: unknown) => T;
}
export interface ReactiveIDBIndexSchema {
    name: string;
    keyPath?: string | string[];
    options?: IDBIndexParameters;
}
export interface ReactiveIDBStoreSchema {
    name: string;
    options?: IDBObjectStoreParameters;
    indexes?: (ReactiveIDBIndexSchema | string)[];
}
export interface ReactiveIDBDatabaseSchema {
    version: number;
    stores: (ReactiveIDBStoreSchema | string)[];
}
/**
 * Options to pass to the ReactiveIDBDatabase constructor
 */
export interface ReactiveIDBDatabaseOptions {
    /**
     * Name of this database
     */
    name: string;
    /**
     * @default `[]`
     */
    schema?: ReactiveIDBDatabaseSchema[];
    /**
     * IDBFactory to use to create the database if different from `window.indexeddb`
     *
     * @default `window.indexeddb`
     */
    factory?: IDBFactory;
    /**
     * Custom onUpgrade method to execute when database version has changed
     *
     * @param database
     * @param versionChangeEvent
     */
    onUpgrade?: (database: IDBDatabase, oldVersion: number, newVersion: number | null, transaction: IDBTransaction) => void;
    onBlocked?: (event: Event) => void;
    /**
     * Should the database be closed on version changed
     */
    autoCloseOnVersionChange?: boolean;
}
export declare class ReactiveIDBDatabase {
    private readonly database;
    /**
     * Returns the name of the database.
     */
    get name(): string;
    /**
     * Returns a list of the names of object stores in the database.
     */
    get objectStoreNames(): DOMStringList;
    /**
     * Returns the version of the database.
     */
    get version(): number;
    /**
     * @param database
     */
    constructor(database: IDBDatabase);
    /**
     *
     * @param options
     */
    static create(options: ReactiveIDBDatabaseOptions): Observable<ReactiveIDBDatabase>;
    /**
     * Closes the connection once all running transactions have finished.
     */
    close(): void;
    /**
     * Returns a new transaction with the given mode ("readonly" or "readwrite") and scope which can be a single object store name or an array of names.
     */
    transaction(names: string | string[], mode?: IDBTransactionMode): ReactiveIDBTransaction;
    /**
     *
     * @param names
     * @param mode
     */
    transaction$(names: string | string[], mode?: IDBTransactionMode): Observable<ReactiveIDBTransaction>;
    /**
     * Creates a new object store with the given name and options and returns a new IDBObjectStore.
     *
     * Throws a "InvalidStateError" DOMException if not called within an upgrade transaction.
     */
    createObjectStore(name: string, options?: IDBObjectStoreParameters): ReactiveIDBObjectStore;
    /**
     * Deletes the object store with the given name.
     *
     * Throws a "InvalidStateError" DOMException if not called within an upgrade transaction.
     */
    deleteObjectStore(name: string): void;
    /**
     *
     * @param type
     * @param listener
     * @param options
     */
    addEventListener<K extends keyof IDBDatabaseEventMap>(type: K, listener: (this: IDBDatabase, ev: IDBDatabaseEventMap[K]) => void, options?: boolean | AddEventListenerOptions): void;
    /**
     *
     * @param type
     * @param listener
     * @param options
     */
    removeEventListener<K extends keyof IDBDatabaseEventMap>(type: K, listener: (this: IDBDatabase, ev: IDBDatabaseEventMap[K]) => void, options?: boolean | EventListenerOptions): void;
    /**
     *
     * @param onBlocked
     */
    clear$(onBlocked?: (event: Event) => void): Observable<void>;
}
