import { Logger } from '@foxpage/foxpage-shared';
import { Application, ManagerBase, ManagerEvents, Relations, ResourceUpdateInfo } from '@foxpage/foxpage-types';
import { FPEventEmitterInstance } from './event';
export type ManagerBaseOptions = {
    /**
     * types: package,page,template,variable,...
     *
     * @type {string}
     */
    type: string;
    /**
     * disk cache config
     *
     * @type {{
     *     enable: boolean;
     *     path: string;
     *   }}
     */
    diskCache?: {
        enable: boolean;
    };
    /**
     * lru cache config
     *
     * @type {{
     *     size: number;
     *   }}
     */
    lruCache?: {
        size?: number;
        cloned?: boolean;
    };
};
/**
 * manager base
 *
 * @export
 * @abstract
 * @class ManagerBase
 */
export declare abstract class ManagerBaseImpl<T> extends FPEventEmitterInstance<ManagerEvents> implements ManagerBase<T> {
    /**
     * application id
     *
     * @type {string}
     */
    readonly appId: string;
    /**
     * application id
     *
     * @type {string}
     */
    readonly appSlug: string;
    /**
     * hot resources
     *
     * @type {ResourceCache}
     */
    private hotResources;
    /**
     * cold resources
     *
     * @private
     * @type {ResourceCache}
     */
    private diskResources?;
    /**
     * need update source keys
     * for record the no update source key, call the thread to refresh next request
     * @private
     * @type {string[]}
     */
    private needUpdates;
    /**
     * logger
     *
     * @protected
     * @type {Logger}
     */
    protected logger: Logger;
    constructor(app: Application, opt?: ManagerBaseOptions);
    /**
     * DATA_PULL listener
     *
     * @protected
     * @param {ResourceUpdateInfo} _data
     */
    protected onPull(_data: ResourceUpdateInfo): Promise<void>;
    /**
     * DATA_STASH listener
     *
     * @protected
     * @param {Relations} _data
     */
    protected onStash(_data: Relations): void;
    /**
     * create source instance
     *
     * @protected
     * @param {T} _data
     */
    protected abstract createInstance(_data: T | any): Promise<T>;
    /**
     * fetch source from server func
     *
     * @protected
     * @abstract
     * @param {string[]} outs
     * @return {*}  {(Promise<T[] | undefined>)}
     */
    protected abstract onFetch(outs: string[], opt?: {
        autoCache?: boolean;
    }): Promise<T[] | undefined>;
    /**
     * add source
     *
     * @protected
     * @param {string} key
     * @param {T} content
     * @param {T} instance
     */
    protected addOne<K extends T | any>(key: string, content: K, instance: T): void;
    /**
     * find source from local
     * find from hot cache,
     * if not exist will find from disk
     * @protected
     * @param {string} key
     * @return {*}
     */
    protected findOneFromLocal(key: string): Promise<T | null | undefined>;
    /**
     *
     * @param key
     * @returns
     */
    protected findOne(key: string): T | null | undefined;
    /**
     * [batch] find all sources from local via source keys
     *
     * @protected
     * @param {string[]} keys
     * @return {*}
     */
    protected findFromLocal(keys: string[]): Promise<Awaited<NonNullable<Awaited<T>>>[]>;
    /**
     * remove source
     *
     * @protected
     * @param {string} key
     */
    protected removeOne(key: string): void;
    /**
     * [batch] remove all sources from via source keys
     *
     * @protected
     * @param {string[]} keys
     * @memberof ManagerBaseImpl
     */
    protected remove(keys: string[]): void;
    /**
     * check if has the source
     *
     * @protected
     * @param {string} key
     * @return {*}
     */
    protected has(key: string): Promise<boolean | undefined>;
    /**
     * add no updates
     *
     * @param {string[]} keys
     * @protected
     */
    protected markNeedUpdates(keys?: string[]): void;
    /**
     * remove the no updates
     *
     * @param {string[]} keys
     * @protected
     */
    protected removeNeedUpdates(keys?: string[]): void;
    /**
     * if exist the no update source
     *
     * @protected
     * @param {string} key
     * @return {boolean}
     */
    protected existInNeedUpdates(key: string): boolean;
    /**
     * chunk
     * if exist local will add to ins, or add to outs
     *
     * @protected
     * @param {string[]} keys
     * @return {*}  {Promise<string[][]>} [ins, outs, invalids] ins(in local), outs(not in local), invalids(in local but is not valid)
     */
    protected chunk(keys: string[]): Promise<string[][]>;
    /**
     * get sources
     * first get local source, then fetch outs via fetch func with opt
     * @protected
     * @param {string[]} keys
     * @param {{ autoFetch: boolean }} opt
     * @return {*}  {Promise<T[]>}
     */
    protected find(keys: string[], opt?: {
        autoFetch: boolean;
        autoCache?: boolean;
    }): Promise<T[]>;
    /**
     * filter not exist list
     *
     * @protected
     * @param {string[]} list
     * @return {*}
     */
    protected filterExists(list: string[]): Promise<string[]>;
    /**
     * exist the source
     *
     * @param {string} key
     */
    exist(key: string): Promise<boolean>;
    /**
     * memory count
     */
    protected getHotCount(): number;
    protected getDiskCount(): number | undefined;
    /**
     * destroy the resource
     */
    destroy(): void;
}
