Skip to content

Commit 1986f25

Browse files
committed
refactor: remove re-export pattern and use direct imports for ADF utilities
1 parent dcf88de commit 1986f25

13 files changed

Lines changed: 33 additions & 62 deletions

src/controllers/atlassian.comments.controller.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ import {
1616
formatCommentsList,
1717
formatAddedCommentConfirmation,
1818
} from './atlassian.comments.formatter.js';
19-
import { markdownToAdf, textToAdf } from '../utils/adf.util.js';
19+
import { markdownToAdf } from '../utils/adf-from-markdown.util.js';
20+
import { textToAdf } from '../utils/adf-from-text.util.js';
2021
import { formatPagination } from '../utils/formatter.util.js';
2122

2223
// Create a contextualized logger for this file

src/controllers/atlassian.comments.formatter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { adfToMarkdown } from '../utils/adf.util.js';
1+
import { adfToMarkdown } from '../utils/adf-to-markdown.util.js';
22
import {
33
formatHeading,
44
formatBulletList,

src/controllers/atlassian.issues.controller.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ import {
1313
import { ControllerResponse } from '../types/common.types.js';
1414
import atlassianIssuesService from '../services/vendor.atlassian.issues.service.js';
1515
import atlassianDevInfoService from '../services/vendor.atlassian.devinfo.service.js';
16-
import {
17-
formatIssuesList,
18-
formatIssueDetails,
19-
formatDevelopmentInfo,
20-
} from './atlassian.issues.formatter.js';
16+
import { formatIssuesList } from './atlassian.issues.list.formatter.js';
17+
import { formatIssueDetails } from './atlassian.issues.details.formatter.js';
18+
import { formatDevelopmentInfo } from './atlassian.issues.development.formatter.js';
2119
import { SearchIssuesParams } from '../services/vendor.atlassian.issues.types.js';
2220
import {
2321
GetIssueToolArgsType,

src/controllers/atlassian.issues.details.formatter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44

55
import { Issue } from '../services/vendor.atlassian.issues.types.js';
6-
import { adfToMarkdown } from '../utils/adf.util.js';
6+
import { adfToMarkdown } from '../utils/adf-to-markdown.util.js';
77
import {
88
formatUrl,
99
formatHeading,

src/controllers/atlassian.issues.formatter.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
* Converts Markdown to Atlassian Document Format (ADF)
33
*/
44

5-
import { Logger } from '../logger.util.js';
6-
import { AdfDocument, AdfNode } from './types.js';
7-
import { textToAdf } from './from-text.js';
5+
import { Logger } from './logger.util.js';
6+
import { AdfDocument, AdfNode } from './adf-types.util.js';
7+
import { textToAdf } from './adf-from-text.util.js';
88

99
const fromMarkdownLogger = Logger.forContext('utils/adf/from-markdown.ts');
1010

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
* Converts plain text to Atlassian Document Format (ADF)
33
*/
44

5-
import { Logger } from '../logger.util.js';
6-
import { AdfDocument, AdfNode } from './types.js';
5+
import { Logger } from './logger.util.js';
6+
import { AdfDocument, AdfNode } from './adf-types.util.js';
77

8-
const fromTextLogger = Logger.forContext('utils/adf/from-text.ts');
8+
const fromTextLogger = Logger.forContext('utils/adf-from-text.util.ts');
99

1010
/**
1111
* Convert plain text to ADF
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Helper functions for processing different ADF node types
33
*/
44

5-
import { AdfNode } from './types.js';
5+
import { AdfNode } from './adf-types.util.js';
66

77
/**
88
* Process ADF content nodes
@@ -99,7 +99,7 @@ export function processParagraph(node: AdfNode): string {
9999

100100
// Process each child node and join them with proper spacing
101101
return node.content
102-
.map((childNode, index) => {
102+
.map((childNode: AdfNode, index: number) => {
103103
// Add a space between text nodes if needed
104104
const needsSpace =
105105
index > 0 &&
@@ -124,7 +124,7 @@ export function processHeading(node: AdfNode): string {
124124
const level = typeof node.attrs.level === 'number' ? node.attrs.level : 1;
125125
const headingMarker = '#'.repeat(level);
126126
const content = node.content
127-
.map((childNode) => processAdfNode(childNode))
127+
.map((childNode: AdfNode) => processAdfNode(childNode))
128128
.join('');
129129

130130
return `${headingMarker} ${content}`;
@@ -138,7 +138,7 @@ export function processBulletList(node: AdfNode): string {
138138
return '';
139139
}
140140

141-
return node.content.map((item) => processAdfNode(item)).join('\n');
141+
return node.content.map((item: AdfNode) => processAdfNode(item)).join('\n');
142142
}
143143

144144
/**
@@ -150,7 +150,7 @@ export function processOrderedList(node: AdfNode): string {
150150
}
151151

152152
return node.content
153-
.map((item, index) => {
153+
.map((item: AdfNode, index: number) => {
154154
const processedItem = processAdfNode(item);
155155
// Replace the first "- " with "1. ", "2. ", etc.
156156
return processedItem.replace(/^- /, `${index + 1}. `);
@@ -167,7 +167,7 @@ export function processListItem(node: AdfNode): string {
167167
}
168168

169169
const content = node.content
170-
.map((childNode) => {
170+
.map((childNode: AdfNode) => {
171171
const processed = processAdfNode(childNode);
172172
// For nested lists, add indentation
173173
if (
@@ -176,7 +176,7 @@ export function processListItem(node: AdfNode): string {
176176
) {
177177
return processed
178178
.split('\n')
179-
.map((line) => ` ${line}`)
179+
.map((line: string) => ` ${line}`)
180180
.join('\n');
181181
}
182182
return processed;
@@ -196,7 +196,7 @@ export function processCodeBlock(node: AdfNode): string {
196196

197197
const language = node.attrs?.language || '';
198198
const code = node.content
199-
.map((childNode) => processAdfNode(childNode))
199+
.map((childNode: AdfNode) => processAdfNode(childNode))
200200
.join('');
201201

202202
return `\`\`\`${language}\n${code}\n\`\`\``;
@@ -211,13 +211,13 @@ export function processBlockquote(node: AdfNode): string {
211211
}
212212

213213
const content = node.content
214-
.map((childNode) => processAdfNode(childNode))
214+
.map((childNode: AdfNode) => processAdfNode(childNode))
215215
.join('\n\n');
216216

217217
// Add > to each line
218218
return content
219219
.split('\n')
220-
.map((line) => `> ${line}`)
220+
.map((line: string) => `> ${line}`)
221221
.join('\n');
222222
}
223223

@@ -230,7 +230,7 @@ export function processMediaGroup(node: AdfNode): string {
230230
}
231231

232232
return node.content
233-
.map((mediaNode) => {
233+
.map((mediaNode: AdfNode) => {
234234
if (mediaNode.type === 'media' && mediaNode.attrs) {
235235
const { id, type } = mediaNode.attrs;
236236
if (type === 'file') {
@@ -279,18 +279,18 @@ export function processTable(node: AdfNode): string {
279279
const rows: string[][] = [];
280280

281281
// Process table rows
282-
node.content.forEach((row) => {
282+
node.content.forEach((row: AdfNode) => {
283283
if (row.type === 'tableRow' && row.content) {
284284
const cells: string[] = [];
285285

286-
row.content.forEach((cell) => {
286+
row.content.forEach((cell: AdfNode) => {
287287
if (
288288
(cell.type === 'tableCell' ||
289289
cell.type === 'tableHeader') &&
290290
cell.content
291291
) {
292292
const cellContent = cell.content
293-
.map((cellNode) => processAdfNode(cellNode))
293+
.map((cellNode: AdfNode) => processAdfNode(cellNode))
294294
.join('');
295295
cells.push(cellContent.trim());
296296
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
* Converts Atlassian Document Format (ADF) to Markdown
33
*/
44

5-
import { Logger } from '../logger.util.js';
6-
import { AdfDocument } from './types.js';
7-
import { processAdfContent } from './node-processors.js';
5+
import { Logger } from './logger.util.js';
6+
import { AdfDocument } from './adf-types.util.js';
7+
import { processAdfContent } from './adf-node-processors.util.js';
88

9-
const toMarkdownLogger = Logger.forContext('utils/adf/to-markdown.ts');
9+
const toMarkdownLogger = Logger.forContext('utils/adf-to-markdown.util.ts');
1010

1111
/**
1212
* Convert Atlassian Document Format (ADF) to Markdown
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Type definitions for Atlassian Document Format (ADF) processing
33
*/
44

5-
import { AdfDocument as ImportedAdfDocument } from '../../services/vendor.atlassian.issues.types.js';
5+
import { AdfDocument as ImportedAdfDocument } from '../services/vendor.atlassian.issues.types.js';
66

77
/**
88
* Interface for ADF node

0 commit comments

Comments
 (0)