import { KeyValueStore, KeyValueStoreOptions } from "./types";
export type UnknownFn = (...args: unknown[]) => unknown;
export declare const STORAGE_HOOK_ON_FUNCTION: StorageHookOnFunction[];
export declare function isStorageHookOnFunction(key: unknown): key is StorageHookOnFunction;
export type StorageHookOn = (StorageHookOnFunction);
export type StorageHookOnFunction = ("clear" | "delete" | "get" | "has" | "increment" | "keys" | "set" | "values");
export declare const STORAGE_HOOK_BEFORE: "before";
export declare const STORAGE_HOOK_AFTER: "after";
export declare const STORAGE_HOOK_DEFAULT: "after";
export type StorageHookStage = (typeof STORAGE_HOOK_BEFORE | typeof STORAGE_HOOK_AFTER);
export type StorageHookValue<T, O extends StorageHookOnFunction, R = ReturnType<KeyValueStore<T>[O]>> = (R extends Promise<infer Z> ? Z : R) | undefined;
export type StorageHookReturnValue<T, O extends StorageHookOnFunction> = StorageHookValue<T, O> | Promise<StorageHookValue<T, O>>;
export interface StorageHook<T = unknown, O extends StorageHookOn = StorageHookOn> {
    on: O;
    stage?: StorageHookStage;
    handler: StorageHookFn<T, O>;
}
export type StorageHookFn<T = unknown, O extends StorageHookOnFunction = StorageHookOnFunction> = (...args: [...Parameters<KeyValueStore<T>[O]>, StorageHookValue<T, O>]) => StorageHookReturnValue<T, O> | void;
export interface StorageHookConstructFn<T = unknown> {
    (store: KeyValueStore<T>): KeyValueStore<T> | undefined | void;
}
export type StorageHooks<T = unknown> = {
    [O in StorageHookOn]: StorageHook<T, O>[];
};
export interface Builder<T = unknown, ST extends KeyValueStore<T> = KeyValueStore<T>> {
    <O extends StorageHookOnFunction>(on: O, fn: StorageHookFn<T, O>, options?: Omit<StorageHook<T, O>, "handler" | "on">): Builder<T, ST>;
    <O extends StorageHookOn>(hook: StorageHook<T, O>): Builder<T, ST>;
    hooks: StorageHooks<T>;
    build<SST extends ST>(store: SST): SST;
    build(name: string, options?: KeyValueStoreOptions): ST;
    use: Builder<T, ST>;
}
export interface BuilderKeyValueStore<T> extends KeyValueStore<T> {
    builder: Builder<T>;
}
export declare function builder<T>(hooks?: StorageHooks<T>): Builder<T, KeyValueStore<T>>;
