"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getBoardByName = void 0;
const typeorm_1 = require("typeorm");
const shell_1 = require("@things-factory/shell");
const board_service_1 = require("@things-factory/board-service");
const power_plant_model_1 = require("../power-plant/power-plant-model");
const getBoardByName = async (name, domainId) => {
    const domains = await (await (0, power_plant_model_1.getDomainListByTypeBuilder)(domainId))
        .select('pp_d.id', 'id')
        .addSelect('pp_d.parent_id', 'parentId')
        .getRawMany();
    const domainIds = domains.map(d => d.id);
    const parentIds = domains.map(d => d.parentId);
    return await (0, shell_1.getRepository)(board_service_1.Board).findOne({
        where: {
            domain: { id: (0, typeorm_1.In)([...domainIds, ...parentIds].filter(Boolean)) },
            name
        }
    });
};
exports.getBoardByName = getBoardByName;
//# sourceMappingURL=sunflow-override-model.js.map