"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var McpConfigSeedingService_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.McpConfigSeedingService = void 0;
const common_1 = require("@nestjs/common");
const typeorm_1 = require("@nestjs/typeorm");
const typeorm_2 = require("typeorm");
const core_entities_1 = require("../core-entities");
const default_configs_1 = require("./data/mcp-configs/default-configs");
let McpConfigSeedingService = McpConfigSeedingService_1 = class McpConfigSeedingService {
    constructor(mcpConfigRepository) {
        this.mcpConfigRepository = mcpConfigRepository;
        this.logger = new common_1.Logger(McpConfigSeedingService_1.name);
    }
    async seed() {
        const existingConfigs = await this.mcpConfigRepository.find();
        const existingConfigNames = existingConfigs.map((c) => c.server_name);
        const configsToSeed = default_configs_1.defaultMcpConfigs.filter((c) => !existingConfigNames.includes(c.server_name));
        if (configsToSeed.length > 0) {
            this.logger.log(`Seeding ${configsToSeed.length} new MCP configs...`);
            const newConfigs = this.mcpConfigRepository.create(configsToSeed);
            const savedConfigs = await this.mcpConfigRepository.save(newConfigs);
            for (const savedConfig of savedConfigs) {
                this.logger.log(`Seeded MCP config: ${savedConfig.server_name}`);
            }
        }
        else {
            this.logger.log('MCP configs are up to date. No seeding required.');
        }
    }
};
exports.McpConfigSeedingService = McpConfigSeedingService;
exports.McpConfigSeedingService = McpConfigSeedingService = McpConfigSeedingService_1 = __decorate([
    (0, common_1.Injectable)(),
    __param(0, (0, typeorm_1.InjectRepository)(core_entities_1.McpConfig)),
    __metadata("design:paramtypes", [typeorm_2.Repository])
], McpConfigSeedingService);
//# sourceMappingURL=mcp-config-seeding.service.js.map