import { EActionStatus } from "../../action/enum/EActionStatus"; import { InitAction } from "../../action/InitAction"; import { IAction } from "../../action/interface/IAction"; import { Context } from "../../context/Context"; import { EErrorEngineTypes } from "../../logger/enum/EErrorEngineTypes"; import { EMessageType } from "../../logger/enum/EMessageType"; import { Logger } from "../../logger/Logger"; import { IManager } from "../interface/IManager"; import { v4 as uuidv4 } from "uuid"; export class BaseManager implements IManager { public action!: InitAction; public context!: Context; public logger!: Logger; constructor(action : InitAction, context: Context){ this.setAction(action); this.setContext(context); this.logger = new Logger([EErrorEngineTypes.CONSOLE, EErrorEngineTypes.VIEW]); this.logger.setCallbackMessage(context.getDeterminants().LoggerViewCallback) } public setAction(action: IAction): void { this.action = action; } public getAction(): IAction { return this.action; } public setContext(context: Context): void { this.context = context; } public getContext(): Context { return this.context; } public async performAction(): Promise { return new Promise((resolve)=>{ resolve(EActionStatus.INIT); }); } public checkKeepOut(): boolean { if(this.action.status == EActionStatus.KEEPOUT){ this.logger.log({ id: uuidv4(), title: this.action.type, body: "Action "+this.action.type + " keepout", action: this.action, errors: [], type:EMessageType.WARNING }); return true; }else{ return false; } } }