//#region imports
import { Taon, TaonController, GET, POST, Body, Query, } from 'taon/lib';
import { CoreModels } from 'tnp-core/lib';
import { TaonBaseCliWorkerController } from 'tnp-helpers/lib';
import { DevMode } from './dev-mode.models';
import { DevModeRepository } from './dev-mode.repository';
//#endregion
let DevModeController = class DevModeController extends TaonBaseCliWorkerController {
    devModeRepository = this.injectKvRepository(DevModeRepository);
    //#region  get all dev mode projects for given framework version
    setAsLeadProjectAndReturnDependcies(body, dirtyBuild) {
        //#region @backendFunc
        return async (req, res) => {
            body = DevMode.ProjectBuildNotificaiton.from(body);
            return await this.devModeRepository.setAsLeadProjectAndReturnDependcies(body, dirtyBuild);
        };
        //#endregion
    }
    //#endregion
    getWhatShouldBeRebuild(body) {
        //#region @backendFunc
        return async (req, res) => {
            body = DevMode.ProjectBuildNotificaiton.from(body);
            return await this.devModeRepository.getWhatShouldBeRebuild(body);
        };
        //#endregion
    }
    //#region  get all dev mode projects for given framework version
    finishLeadBuildAndUnregisterLeadProject(body) {
        //#region @backendFunc
        return async (req, res) => {
            body = DevMode.ProjectBuildNotificaiton.from(body);
            return await this.devModeRepository.finishLeadBuildAndUnregisterLeadProject(body);
        };
        //#endregion
    }
    //#endregion
    //#region  check if still build leader
    checkIfStillBuildLeader(body) {
        //#region @backendFunc
        return async (req, res) => {
            body = DevMode.ProjectBuildNotificaiton.from(body);
            return await this.devModeRepository.checkIfStillBuildLeader(body);
        };
        //#endregion
    }
    //#endregion
    //#region API
    //#region API / update dev mode pool
    updatePool(body) {
        //#region @backendFunc
        return async (req, res) => {
            body = DevMode.ProjectBuildNotificaiton.from(body);
            return this.devModeRepository.updatePool(body);
        };
        //#endregion
    }
    //#endregion
    //#region API / delete from dev mode pool
    deleteFromPool(body) {
        //#region @backendFunc
        return async (req, res) => {
            body = DevMode.ProjectBuildNotificaiton.from(body);
            return this.devModeRepository.deleteFromPool(body);
        };
        //#endregion
    }
    //#endregion
    //#region API / get all dev mode projects for given framework version
    getAllDevModeProjects(frameworkVersion) {
        //#region @backendFunc
        return async (req, res) => {
            const data = await this.devModeRepository.getPoolOfDevModePorjects(frameworkVersion);
            return data;
        };
        //#endregion
    }
    //#endregion
    //#region API / get all framework version in dev mode
    getAllFrameworkVersionInDevMode() {
        //#region @backendFunc
        return async (req, res) => {
            const data = await this.devModeRepository.getAllFrameworkVersionInDevMode();
            return data;
        };
        //#endregion
    }
    //#endregion
    //#region API / get db location
    getDbLocation() {
        //#region @backendFunc
        return async (req, res) => {
            const data = await this.devModeRepository.jsonDbLocation;
            return data;
        };
        //#endregion
    }
    //#endregion
    //#region API / get log messages
    getLogMessages(last) {
        //#region @backendFunc
        return async (req, res) => {
            const data = await this.devModeRepository
                .getAllLogMessage()
                .slice(-1 * Number(last));
            return data;
        };
        //#endregion
    }
    //#endregion
    //#region API / get log messages
    clearLogMessages() {
        //#region @backendFunc
        return async (req, res) => {
            await this.devModeRepository.clearMessage();
            return true;
        };
        //#endregion
    }
};
__decorate([
    POST(),
    __param(0, Body()),
    __param(1, Query('dirtyBuild')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [DevMode.ProjectBuildNotificaiton, Object]),
    __metadata("design:returntype", Object)
], DevModeController.prototype, "setAsLeadProjectAndReturnDependcies", null);
__decorate([
    GET(),
    __param(0, Body()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [DevMode.ProjectBuildNotificaiton]),
    __metadata("design:returntype", Object)
], DevModeController.prototype, "getWhatShouldBeRebuild", null);
__decorate([
    POST(),
    __param(0, Body()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [DevMode.ProjectBuildNotificaiton]),
    __metadata("design:returntype", Object)
], DevModeController.prototype, "finishLeadBuildAndUnregisterLeadProject", null);
__decorate([
    GET(),
    __param(0, Body()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [DevMode.ProjectBuildNotificaiton]),
    __metadata("design:returntype", Object)
], DevModeController.prototype, "checkIfStillBuildLeader", null);
__decorate([
    POST(),
    __param(0, Body()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [DevMode.ProjectBuildNotificaiton]),
    __metadata("design:returntype", Object)
], DevModeController.prototype, "updatePool", null);
__decorate([
    POST(),
    __param(0, Body()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [DevMode.ProjectBuildNotificaiton]),
    __metadata("design:returntype", Object)
], DevModeController.prototype, "deleteFromPool", null);
__decorate([
    GET(),
    __param(0, Query('frameworkVersion')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", Object)
], DevModeController.prototype, "getAllDevModeProjects", null);
__decorate([
    GET(),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Object)
], DevModeController.prototype, "getAllFrameworkVersionInDevMode", null);
__decorate([
    GET(),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Object)
], DevModeController.prototype, "getDbLocation", null);
__decorate([
    GET(),
    __param(0, Query('last')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Number]),
    __metadata("design:returntype", Object)
], DevModeController.prototype, "getLogMessages", null);
__decorate([
    GET(),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Object)
], DevModeController.prototype, "clearLogMessages", null);
DevModeController = __decorate([
    TaonController({
        className: 'DevModeController',
    })
], DevModeController);
export { DevModeController };
//# sourceMappingURL=dev-mode.controller.js.map