"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const typeorm_1 = require("typeorm");
const entities_1 = require("../../../entities");
const thumbnail_1 = require("../../../controllers/thumbnail");
exports.updateBoard = {
    async updateBoard(_, { id, patch }) {
        const repository = typeorm_1.getRepository(entities_1.Board);
        const board = await repository.findOne({ id }, {
            relations: ['group']
        });
        if (patch.model) {
            const { width, height } = JSON.parse(patch.model);
            const base64 = await thumbnail_1.thumbnail({
                model: patch.model
            });
            patch.thumbnail = 'data:image/png;base64,' + base64.toString('base64');
            patch.width = width;
            patch.height = height;
        }
        return await repository.save(Object.assign({}, board, patch));
    }
};
//# sourceMappingURL=update-board.js.map