import { Schema, StrictSchema } from '@based/schema';
import { CreateObj } from './modify/create.js';
import { SchemaTypeDef } from '@based/schema/def';
import { ModifyCtx } from './flushModify.js';
import { BasedDbQuery, QueryByAliasObj } from './query/BasedDbQuery.js';
import { ModifyRes } from './modify/ModifyRes.js';
import { DbServer } from '../server/index.js';
import { TransformFns } from '../server/migrate/index.js';
import { ModifyOpts } from './modify/types.js';
import { OnClose, OnData, OnError } from './query/subscription/types.js';
export type DbClientHooks = {
    setSchema(schema: StrictSchema, fromStart?: boolean, transformFns?: TransformFns): Promise<DbServer['schema']>;
    flushModify(buf: Uint8Array): Promise<{
        offsets: Record<number, number>;
        dbWriteTime?: number;
    }>;
    getQueryBuf(buf: Uint8Array): Promise<Uint8Array>;
    subscribe(q: BasedDbQuery, onData: OnData, onError?: OnError): OnClose;
};
type DbClientOpts = {
    hooks: DbClientHooks;
    maxModifySize?: number;
    flushTime?: number;
    debug?: boolean;
};
type DbClientSchema = StrictSchema & {
    lastId: number;
};
export declare class DbClient {
    constructor({ hooks, maxModifySize, flushTime, debug, }: DbClientOpts);
    flushTime: number;
    flushReady: () => void;
    flushIsReady: Promise<void>;
    hooks: DbClientHooks;
    schema: DbClientSchema;
    schemaTypesParsed: Record<string, SchemaTypeDef>;
    schemaTypesParsedById: Record<number, SchemaTypeDef>;
    writeTime: number;
    isDraining: boolean;
    modifyCtx: ModifyCtx;
    maxModifySize: number;
    upserting: Map<number, {
        o: Record<string, any>;
        p: Promise<number | ModifyRes>;
    }>;
    schemaChecksum: number;
    schemaProcessing: number;
    schemaPromise: Promise<DbServer['schema']>;
    setSchema(schema: Schema, fromStart?: boolean, transformFns?: TransformFns): Promise<StrictSchema>;
    putLocalSchema(schema: any): DbClientSchema;
    create(type: string, obj?: CreateObj, opts?: ModifyOpts): ModifyRes;
    copy(type: string, target: number | ModifyRes, objOrTransformFn?: Record<string, any> | ((item: Record<string, any>) => Promise<any>)): Promise<ModifyRes>;
    query(type: string, id?: number | ModifyRes | (number | ModifyRes)[] | QueryByAliasObj | QueryByAliasObj[] | Uint32Array): BasedDbQuery;
    query(): BasedDbQuery;
    update(type: string, id: number | ModifyRes, value: any, opts?: ModifyOpts): ModifyRes;
    update(type: string, value: Record<string, any> & {
        id: number | ModifyRes;
    }, opts?: ModifyOpts): ModifyRes;
    update(value: Record<string, any>, opts?: ModifyOpts): ModifyRes;
    upsert(type: string, obj: Record<string, any>, opts?: ModifyOpts): Promise<any>;
    delete(type: string, id: number | ModifyRes): ModifyRes;
    expire(type: string, id: number | ModifyRes, seconds: number): void;
    destroy(): void;
    stop(): void;
    drain(): Promise<number>;
    isModified(): Promise<void>;
    schemaIsSet(): Promise<true>;
    listeners?: {
        schema?: Set<(schema: DbClientSchema) => void>;
    };
    on(event: 'schema', cb: (schema: DbClientSchema) => void): void;
    off(event: 'schema', cb: (schema: DbClientSchema) => void): void;
}
export {};
