UNPKG

@houmak/minerva-mcp-server

Version:

Minerva Model Context Protocol (MCP) Server for Microsoft 365 and Azure integrations

279 lines (278 loc) 9.28 kB
import { logger } from './logger.js'; import { AzureDevOpsManager } from './azure-devops/azure-devops-manager.js'; import { AzureBicepManager } from './azure-bicep/azure-bicep-manager.js'; import { PnPCoreManager } from './pnp-core/pnp-core-manager.js'; import { ConnectorFramework } from './connectors/connector-framework.js'; export class Sprint4Manager { azureDevOps; azureBicep; pnpCore; connectorFramework; config; initialized = false; constructor(config) { this.config = config; this.azureDevOps = new AzureDevOpsManager(config.azureDevOps); this.azureBicep = new AzureBicepManager(config.azureBicep); this.pnpCore = new PnPCoreManager(config.pnpCore); this.connectorFramework = new ConnectorFramework(); } /** * Initialiser tous les composants Sprint 4 */ async initialize() { logger.info('Initializing Sprint 4 features'); try { // Initialiser PnP Core await this.pnpCore.initialize(); // Configurer les connecteurs si activés if (this.config.connectors.enabled) { for (const connectorConfig of this.config.connectors.configs) { await this.connectorFramework.configureConnector(connectorConfig); } } this.initialized = true; logger.info('Sprint 4 features initialized successfully'); } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); logger.error('Failed to initialize Sprint 4 features', { error: errorMessage }); throw error; } } /** * Vérifier le statut de tous les services */ async getStatus() { logger.info('Checking Sprint 4 services status'); try { const [azureDevOps, azureBicep, pnpCore, connectors] = await Promise.all([ this.azureDevOps.isAvailable(), this.azureBicep.isAvailable(), this.pnpCore.isAvailable(), Promise.resolve(true) // Connector framework is always available ]); const status = { azureDevOps, azureBicep, pnpCore, connectors, overall: azureDevOps && azureBicep && pnpCore && connectors }; logger.info('Sprint 4 services status checked', status); return status; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); logger.error('Failed to check Sprint 4 services status', { error: errorMessage }); throw error; } } // ===== Azure DevOps Methods ===== /** * Créer un pipeline Azure DevOps */ async createPipeline(config) { return await this.azureDevOps.createPipeline(config); } /** * Déclencher un build */ async triggerBuild(pipelineId, branch) { return await this.azureDevOps.triggerBuild(pipelineId, branch); } /** * Récupérer les work items */ async getWorkItems(query) { return await this.azureDevOps.getWorkItems(query); } /** * Créer une pull request */ async createPullRequest(repo, source, target, title) { return await this.azureDevOps.createPullRequest(repo, source, target, title); } /** * Obtenir les statistiques du projet */ async getProjectStats() { return await this.azureDevOps.getProjectStats(); } // ===== Azure Bicep Methods ===== /** * Valider un template Bicep */ async validateTemplate(templatePath) { return await this.azureBicep.validateTemplate(templatePath); } /** * Déployer un template Bicep */ async deployTemplate(templatePath, parameters, deploymentName) { return await this.azureBicep.deployTemplate(templatePath, parameters, deploymentName); } /** * Exécuter une analyse what-if */ async whatIf(templatePath, parameters) { return await this.azureBicep.whatIf(templatePath, parameters); } /** * Générer un template Bicep */ async generateTemplate(resourceType, options) { return await this.azureBicep.generateTemplate(resourceType, options); } /** * Obtenir les informations d'un template */ async getTemplateInfo(templatePath) { return await this.azureBicep.getTemplateInfo(templatePath); } // ===== PnP Core Methods ===== /** * Créer un site SharePoint */ async createSite(config) { return await this.pnpCore.createSite(config); } /** * Récupérer les éléments d'une liste */ async getListItems(listId, query, select) { return await this.pnpCore.getListItems(listId, query, select); } /** * Ajouter un élément à une liste */ async addListItem(listId, properties) { return await this.pnpCore.addListItem(listId, properties); } /** * Mettre à jour un élément de liste */ async updateListItem(listId, itemId, properties) { return await this.pnpCore.updateListItem(listId, itemId, properties); } /** * Supprimer un élément de liste */ async deleteListItem(listId, itemId) { return await this.pnpCore.deleteListItem(listId, itemId); } /** * Configurer un webhook */ async setupWebhook(listId, url, events) { return await this.pnpCore.setupWebhook(listId, url, events); } /** * Obtenir les informations du site */ async getSiteInfo() { return await this.pnpCore.getSiteInfo(); } // ===== Connector Methods ===== /** * Enregistrer un connecteur */ async registerConnector(connector) { return await this.connectorFramework.registerConnector(connector); } /** * Exécuter un connecteur */ async executeConnector(name, params) { return await this.connectorFramework.executeConnector(name, params); } /** * Lister tous les connecteurs */ async listConnectors() { return await this.connectorFramework.listConnectors(); } /** * Configurer un connecteur */ async configureConnector(config) { return await this.connectorFramework.configureConnector(config); } /** * Obtenir les statistiques d'utilisation des connecteurs */ async getConnectorStats() { return await this.connectorFramework.getUsageStats(); } // ===== Utility Methods ===== /** * Obtenir un rapport complet de Sprint 4 */ async getSprint4Report() { logger.info('Generating Sprint 4 report'); try { const status = await this.getStatus(); const connectorStats = await this.getConnectorStats(); const report = { timestamp: new Date().toISOString(), version: '1.0.0', status, features: { azureDevOps: { pipelines: 'Available', builds: 'Available', workItems: 'Available', pullRequests: 'Available' }, azureBicep: { validation: 'Available', deployment: 'Available', whatIf: 'Available', generation: 'Available' }, pnpCore: { sites: 'Available', lists: 'Available', items: 'Available', webhooks: 'Available' }, connectors: { framework: 'Available', execution: 'Available', configuration: 'Available' } }, statistics: { connectors: connectorStats, totalFeatures: 16, availableFeatures: Object.values(status).filter(Boolean).length - 1 // Exclude overall }, recommendations: [ 'Monitor Azure DevOps pipeline performance', 'Regularly validate Bicep templates before deployment', 'Set up webhooks for real-time SharePoint notifications', 'Review connector usage statistics monthly' ] }; logger.info('Sprint 4 report generated successfully'); return report; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); logger.error('Failed to generate Sprint 4 report', { error: errorMessage }); throw error; } } /** * Vérifier si Sprint 4 est initialisé */ isInitialized() { return this.initialized; } /** * Obtenir la configuration actuelle */ getConfig() { return this.config; } }