UNPKG

@aashari/mcp-server-atlassian-jira

Version:

Node.js/TypeScript MCP server for Atlassian Jira. Equips AI systems (LLMs) with tools to list/get projects, search/get issues (using JQL/ID), and view dev info (commits, PRs). Connects AI capabilities directly into Jira project management and issue tracki

98 lines (97 loc) 3.05 kB
"use strict"; /** * Converts plain text to Atlassian Document Format (ADF) */ Object.defineProperty(exports, "__esModule", { value: true }); exports.textToAdf = textToAdf; const logger_util_js_1 = require("./logger.util.js"); const fromTextLogger = logger_util_js_1.Logger.forContext('utils/adf-from-text.util.ts'); /** * Convert plain text to ADF * * @param text - Plain text to convert to ADF * @returns ADF document */ function textToAdf(text) { const methodLogger = fromTextLogger.forMethod('textToAdf'); try { if (!text) { // Return empty document return { version: 1, type: 'doc', content: [], }; } // Split text into paragraphs const paragraphs = text.split(/\r?\n\r?\n/); // Convert each paragraph to an ADF node const content = paragraphs .map((paragraph) => { if (!paragraph.trim()) { return null; // Skip empty paragraphs } // Process paragraph line breaks const lines = paragraph.split(/\r?\n/); if (lines.length === 1) { // Simple paragraph return { type: 'paragraph', content: [ { type: 'text', text: paragraph, }, ], }; } else { // Paragraph with line breaks const textNodes = []; for (let i = 0; i < lines.length; i++) { // Add text node textNodes.push({ type: 'text', text: lines[i], }); // Add hard break if not the last line if (i < lines.length - 1) { textNodes.push({ type: 'hardBreak', }); } } return { type: 'paragraph', content: textNodes, }; } }) .filter(Boolean); // Remove nulls methodLogger.debug(`Converted text to ADF, paragraphs: ${content.length}`); return { version: 1, type: 'doc', content: content, }; } catch (error) { methodLogger.error('Error converting text to ADF:', error); // Return a simple document with the error message return { version: 1, type: 'doc', content: [ { type: 'paragraph', content: [ { type: 'text', text: 'Error converting text format', }, ], }, ], }; } }