import { EventEmitter } from 'node:events';
import { type Database, type RootDatabase } from 'lmdb';
import { makeTable } from './Table.ts';
import { RocksDatabase } from '@harperfast/rocksdb-js';
declare const DEFINED_TABLES: unique symbol;
export declare const NON_REPLICATING_SYSTEM_TABLES: string[];
export type Table = ReturnType<typeof makeTable> & {
    indexingOperation?: any;
    origin?: string;
    schemaVersion?: number;
};
export interface Tables {
    [tableName: string]: Table;
    [DEFINED_TABLES]?: Set<string>;
}
export interface Databases {
    [databaseName: string]: Tables;
}
interface LMDBDatabase extends Database {
    customIndex?: any;
    isIndexing?: boolean;
    indexNulls?: boolean;
}
interface LMDBRootDatabase extends RootDatabase {
    auditStore?: LMDBRootDatabase;
    databaseName?: string;
    dbisDb?: LMDBDatabase;
    isLegacy?: boolean;
    needsDeletion?: boolean;
    path?: string;
    status?: 'open' | 'closed';
}
interface RocksDatabaseEx extends RocksDatabase {
    customIndex?: any;
    env: Record<string, any>;
    isLegacy?: boolean;
    isIndexing?: boolean;
    indexNulls?: boolean;
    getEntry?: (id: string | number | (string | number)[] | Buffer, options?: any) => {
        value: any;
    };
}
interface RocksRootDatabase extends RocksDatabaseEx {
    auditStore?: RocksDatabaseEx;
    databaseName?: string;
    dbisDb?: RocksDatabaseEx;
}
export type RootDatabaseKind = LMDBRootDatabase | RocksRootDatabase;
export type DatabaseWatcherEventMap = {
    updateTable: [table: Table, originIsNotCluster?: boolean];
    dropTable: [tableName: string, databaseName: string];
    dropDatabase: [databaseName: string];
};
export declare const databaseEventsEmitter: EventEmitter<DatabaseWatcherEventMap>;
export declare const tables: Tables;
export declare const databases: Databases;
/**
 * This gets the set of tables from the default database ("data").
 */
export declare function getTables(): Tables;
/**
 * This provides the main entry point for getting the set of all Harper tables (organized by schemas/databases).
 * This proactively scans the known
 * databases/schemas directories and finds any databases and opens them. This done proactively so that there is a fast
 * object available to all consumers that doesn't require runtime checks for database open states.
 * This also attaches the audit store associated with table. Note that legacy tables had a single audit table per db table
 * but in newer multi-table databases, there is one consistent, integrated audit table for the database since transactions
 * can span any tables in the database.
 */
export declare function getDatabases(): Databases;
/**
 * This is responsible for reading the internal dbi of a single database file to get a list of all the tables and
 * their indexed or registered attributes
 * @param path
 * @param defaultTable
 * @param databaseName
 */
export declare function readMetaDb(path: string, defaultTable?: string, databaseName?: string, auditPath?: string, isLegacy?: boolean): RootDatabaseKind;
export declare function resetDatabases(): Databases;
interface TableDefinition {
    table: string;
    database?: string;
    path?: string;
    expiration?: number;
    eviction?: number;
    scanInterval?: number;
    audit?: boolean;
    sealed?: boolean;
    splitSegments?: boolean;
    replicate?: boolean;
    trackDeletes?: boolean;
    attributes: any[];
    schemaDefined?: boolean;
    origin?: string;
}
/**
 * Get root store for a database
 * @param options
 * @returns
 */
export declare function database({ database: databaseName, table: tableName }: {
    database: any;
    table: any;
}): any;
/**
 * Delete the database
 * @param databaseName
 */
export declare function dropDatabase(databaseName: any): Promise<void>;
/**
 * This can be called to ensure that the specified table exists and if it does not exist, it should be created.
 * @param tableName
 * @param databaseName
 * @param customPath
 * @param expiration
 * @param eviction
 * @param scanInterval
 * @param attributes
 * @param audit
 * @param sealed
 * @param splitSegments
 * @param replicate
 */
export declare function table<TableResourceType>(tableDefinition: TableDefinition): TableResourceType;
export declare function dropTableMeta({ table: tableName, database: databaseName }: {
    table: any;
    database: any;
}): Promise<any[]>;
export declare function onUpdatedTable(listener: (table: Table) => void): {
    remove(): void;
};
export declare function onRemovedTable(listener: (tableName: string, databaseName: string) => void): {
    remove(): void;
};
export declare function onRemovedDB(listener: (databaseName: string) => void): {
    remove(): void;
};
export declare function getDefaultCompression(): {
    startingOffset: number;
};
export {};
