/**
 * Huan(202110): Assignment and Resolution of Uniform Resource Names
 *  https://datatracker.ietf.org/wg/urn/about/
 */
/// <reference types="node" />
import type { Readable } from 'stream';
import { FileBox } from '../file-box.js';
interface UniformResourceNameRegistryOptions {
    expireMilliseconds?: number;
    storeDir?: string;
}
declare class UniformResourceNameRegistry {
    protected static processExitMap: WeakMap<UniformResourceNameRegistry, Function>;
    /**
     * The directory that store all UUID files
     */
    protected storeDir: string;
    protected expireMilliseconds: number;
    /**
     * Key: expiretime
     * Value: the array of UUID that will expires after the `expiretime` (Key)
     */
    protected uuidExpiringTable: Map<number, string[]>;
    protected purgerTimer?: ReturnType<typeof setInterval>;
    constructor(options?: UniformResourceNameRegistryOptions);
    /**
     * Return a FileBox Interface with the current URN Registry for conience
     */
    getFileBox(): typeof FileBox;
    /**
     * init the UUID registry
     *
     * must be called before use.
     */
    init(): void;
    protected purgeExpiredUuid(): void;
    /**
     * Clean up by calling this.destroy() before process exit
     */
    protected addProcessExitListener(): void;
    protected uuidFileName(uuid: string): string;
    /**
     * @deprecated use `load()` instead
     */
    resolve(uuid: string): Promise<Readable>;
    /**
     * `resolve()` can only be used once.
     *  after resolve(), the UUID will be not exist any more
     */
    load(uuid: string): Promise<Readable>;
    /**
     * @deprecated use `save()` instead
     */
    register(stream: Readable): Promise<string>;
    /**
     * Save the `Readable` stream and return a random UUID
     *  The UUID will be expired after MAX_KEEP_MINUTES
     */
    save(stream: Readable): Promise<string>;
    /**
     * Set a timer to execute delete callback after `expireMilliseconds`
     */
    protected addToExpiringTable(uuid: string): void;
    protected purge(uuid: string): Promise<void>;
    /**
     * destroy the urn registry.
     *
     * This function will be called automatically at `process.on(exit)`
     * however, it till need to be called before the program ends
     *  because there have some timers in eventloop task list
     */
    destroy(): void;
}
export { UniformResourceNameRegistry };
//# sourceMappingURL=uniform-resource-name-registry.d.ts.map