"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SeedSetting1568858861188 = void 0;
const typeorm_1 = require("typeorm");
const setting_base_1 = require("@things-factory/setting-base");
const shell_1 = require("@things-factory/shell");
const opa_app_setting_constants_1 = require("../opa-app-setting-constants");
const SEED_SETTINGS = [
    {
        name: opa_app_setting_constants_1.LOCATION_LABEL_SETTING_KEY,
        description: 'Location label ID',
        value: '',
        category: 'board'
    },
    {
        name: opa_app_setting_constants_1.PALLET_LABEL_SETTING_KEY,
        description: 'Pallet label ID',
        value: '',
        category: 'board'
    },
    {
        name: opa_app_setting_constants_1.REUSABLE_PALLET_LABEL_SETTING_KEY,
        description: 'Reusable pallet label ID',
        value: '',
        category: 'board'
    }
];
class SeedSetting1568858861188 {
    async up(queryRunner) {
        const repository = (0, typeorm_1.getRepository)(setting_base_1.Setting);
        const domainRepository = (0, typeorm_1.getRepository)(shell_1.Domain);
        const domain = await domainRepository.findOne({ name: 'SYSTEM' });
        try {
            SEED_SETTINGS.forEach(async (setting) => {
                await repository.save(Object.assign(Object.assign({}, setting), { domain }));
            });
        }
        catch (e) {
            console.error(e);
        }
    }
    async down(queryRunner) {
        const repository = (0, typeorm_1.getRepository)(setting_base_1.Setting);
        SEED_SETTINGS.reverse().forEach(async (setting) => {
            let record = await repository.findOne({ name: setting.name });
            await repository.remove(record);
        });
    }
}
exports.SeedSetting1568858861188 = SeedSetting1568858861188;
//# sourceMappingURL=1568858861188-SeedSetting.js.map