import { KosParentAware } from './types';
import { KosSubscriptionManager } from './model/kos-subscription-manager';
import { KosOnlineLifecycleManager } from './model/kos-online-lifecycle-manager';
import { KosHttpRouteManager } from './model/kos-http-route-manager';
import { KosFSMManager } from './model/kos-fsm-manager';
import { KosEffectManager } from './model/kos-effects-manager';
import { KosCompanionModelManager } from './model/kos-companion-model-manager';
import { KosChildResolver } from './model/kos-child-resolver';
import { KosLog } from './log';
import { KosModelState } from './lifecycle/constants';
import { KosModelManager } from './kosModelManager';
import { KosContext, KosContextBean } from './context/kos-context-manager';
import { DependencyLifecycle } from '../types/kos-dependency';
import { KosOfflineQueue } from './model/kos-offline-queue';

export interface IKosModelLifecycle {
    init?(context?: KosContext): Promise<void>;
    load?(context?: KosContext): Promise<void>;
    ready?(context?: KosContext): Promise<void>;
    online?(context?: KosContext): Promise<void>;
    offline?(context?: KosContext): Promise<void>;
    unload?(context?: KosContext): void;
    activate?(context?: KosContext): Promise<void>;
    deactivate?(context?: KosContext): Promise<void>;
}
export interface IKosVisitor<T extends IKosDataModel | IKosModel> {
    visit: (model: T) => void;
}
export interface IKosVisitorHost<T extends IKosDataModel | IKosModel> {
    accept?: (visitor: IKosVisitor<T>) => void;
}
export type KosContextLogger = ReturnType<typeof KosLog.getLogger>;
export interface IKosModelLogger {
    logger: KosContextLogger;
}
export interface KosCreationContext extends IKosModelLogger {
    kosContext: KosContextBean;
    [key: string]: any;
}
export interface IKosDataModel extends IKosModelLifecycle, IKosVisitorHost<IKosDataModel> {
    id: string;
    getDependencies?(): void;
    getChildren?: () => IKosDataModel[];
    update?: (values: any) => Promise<void>;
    toJSON?: () => object;
}
export interface IKosCompanionOptions<T extends IKosDataModel = IKosDataModel, O extends object = object> extends KosParentAware {
    companionParent: T;
    data?: O;
}
export interface IKosContainerModel<T extends IKosDataModel, R extends object = Record<string, unknown>> {
    models: T[];
    createModel?: (request: R) => Promise<unknown>;
    deleteModel?: (id: string) => Promise<void>;
    getModel?: (id: string) => T | undefined;
}
export interface ReloadAware {
    reload: () => Promise<void>;
}
export interface UnloadAware {
    unload: () => Promise<void>;
}
export interface UpdateAware<O extends object = Record<string, any>> {
    updateModel: (options: O) => void;
}
export interface IKosModel<DataDef extends IKosDataModel = IKosDataModel> extends IKosCompanionModelContainer, IKosModelLifecycle, IKosVisitorHost<IKosModel> {
    modelId: string;
    status: KosModelState;
    onlineStatus: KosModelState;
    activeStatus: KosModelState;
    modelTypeName: string;
    loaded: boolean;
    fsm: KosFSMManager;
    isReady(): boolean;
    isActive(): boolean;
    isOnline(): boolean;
    whenReady(): Promise<void>;
    whenInitialized(): Promise<void>;
    whenLoaded(): Promise<void>;
    registerSubscribers(): Promise<void>;
    getChildren(): IKosModel[];
    modelData: DataDef;
    modelManager: KosModelManager;
}
interface KosModelParameters<DataType extends IKosDataModel> {
    modelTypeName: string;
    id?: string | number;
    modelData: DataType;
}
interface IKosCreateParam<Options extends object = Record<string, any>> {
    id?: string;
    modelTypeId: string;
    options?: Options;
}
export type IKosDataModelBuilder<D, M extends IKosDataModel> = (data: D) => M;
export type IKosDataModelCreator<M extends IKosDataModel = IKosDataModel, O extends object = Record<string, any>> = (params: IKosCreateParam<O>) => M;
export interface IKosDataModelFactory<D, M extends IKosDataModel> {
    build?: IKosDataModelBuilder<D, M>;
    create?: IKosDataModelCreator<M>;
}
interface IKosCompanionModelContainer {
    clearCompanionModels: () => void;
    addCompanionModel: (model: IKosModel) => void;
    companionModels: KosCompanionModelManager;
}
export declare class KosModel<DataDef extends IKosDataModel = IKosDataModel> implements IKosModel<DataDef>, IKosCompanionModelContainer {
    private _id;
    private _status;
    private _activeStatus;
    private _onlineStatus;
    modelData: DataDef;
    modelTypeName: string;
    initialized: boolean;
    loaded: boolean;
    offlineQueue: KosOfflineQueue;
    subscriptionManager?: KosSubscriptionManager;
    effectManager?: KosEffectManager;
    httpRouteManager?: KosHttpRouteManager;
    onlineLifecycleManager?: KosOnlineLifecycleManager;
    companionManager: KosCompanionModelManager;
    childResolver: KosChildResolver;
    fsm: KosFSMManager;
    constructor({ modelTypeName, id, modelData }: KosModelParameters<DataDef>);
    get companionModels(): KosCompanionModelManager;
    set status(status: KosModelState);
    get status(): KosModelState;
    get modelId(): string;
    get id(): string;
    get activeStatus(): KosModelState;
    set activeStatus(activeStatus: KosModelState);
    get onlineStatus(): KosModelState;
    set onlineStatus(onlineStatus: KosModelState);
    get modelManager(): any;
    isActive(): boolean;
    isOnline(): boolean;
    isReady(): boolean;
    deactivate(): Promise<void>;
    activate(): Promise<void>;
    whenLoaded(): Promise<void>;
    whenInitialized(): Promise<void>;
    whenReady(): Promise<void>;
    ready(): Promise<void>;
    load(): Promise<void>;
    unload(): Promise<void>;
    init(): Promise<void>;
    registerSubscribers(lifecycle?: DependencyLifecycle): Promise<void>;
    online(): Promise<void>;
    offline(): Promise<void>;
    accept(visitor: IKosVisitor<IKosModel>): void;
    getChildren(): IKosModel[];
    addCompanionModel(model: IKosModel<IKosDataModel>): void;
    clearCompanionModels(): void;
}
export {};
//# sourceMappingURL=kosModel.d.ts.map