From 732aaf54f8d8271c7be968700eab775f0792ad5e Mon Sep 17 00:00:00 2001 From: claude_code Date: Sat, 20 Jun 2026 04:05:29 +0300 Subject: [PATCH] refactor(import): remove non-functional DOCX/PDF/Confluence import stubs These import paths relied on the private EE module that was deleted from the repo. In the community build they either threw 'enterprise license' (DOCX/PDF) or silently no-op'd (Confluence). The frontend buttons were already removed in 38064064; this cleans up the dead backend stubs. - import.service.ts: drop processDocx/processPdf methods, their dispatcher branches, the pageId computation + insertPage spread, and the now-unused moduleRef param/ModuleRef import - file-import-task.service.ts: drop the Confluence branch and the now-unused moduleRef param/ModuleRef import - import.controller.ts: restrict file extensions to .md/.html and zip sources to generic/notion; update the error message accordingly - file.utils.ts: remove Confluence from the FileImportSource enum - features.ts: remove the unused CONFLUENCE_IMPORT/DOCX_IMPORT/PDF_IMPORT feature keys The isConfluenceImport logic in import-attachment.service.ts is intentionally left in place (real shared attachment-parsing code, not a stub); its removal is a separate, riskier refactor. --- apps/server/src/common/features.ts | 3 - .../integrations/import/import.controller.ts | 8 +- .../services/file-import-task.service.ts | 23 ----- .../import/services/import.service.ts | 97 ------------------- .../integrations/import/utils/file.utils.ts | 1 - 5 files changed, 3 insertions(+), 129 deletions(-) diff --git a/apps/server/src/common/features.ts b/apps/server/src/common/features.ts index c5fd9a20..4a2439d2 100644 --- a/apps/server/src/common/features.ts +++ b/apps/server/src/common/features.ts @@ -6,9 +6,6 @@ export const Feature = { COMMENT_RESOLUTION: 'comment:resolution', PAGE_PERMISSIONS: 'page:permissions', AI: 'ai', - CONFLUENCE_IMPORT: 'import:confluence', - DOCX_IMPORT: 'import:docx', - PDF_IMPORT: 'import:pdf', ATTACHMENT_INDEXING: 'attachment:indexing', SECURITY_SETTINGS: 'security:settings', MCP: 'mcp', diff --git a/apps/server/src/integrations/import/import.controller.ts b/apps/server/src/integrations/import/import.controller.ts index cd2341ea..c47e87ea 100644 --- a/apps/server/src/integrations/import/import.controller.ts +++ b/apps/server/src/integrations/import/import.controller.ts @@ -51,7 +51,7 @@ export class ImportController { @AuthUser() user: User, @AuthWorkspace() workspace: Workspace, ) { - const validFileExtensions = ['.md', '.html', '.docx', '.pdf']; + const validFileExtensions = ['.md', '.html']; const maxFileSize = bytes('30mb'); @@ -101,8 +101,6 @@ export class ImportController { const sourceMap: Record = { '.md': 'markdown', '.html': 'html', - '.docx': 'docx', - '.pdf': 'pdf', }; if (createdPage) { @@ -161,10 +159,10 @@ export class ImportController { const spaceId = file.fields?.spaceId?.value; const source = file.fields?.source?.value; - const validZipSources = ['generic', 'notion', 'confluence']; + const validZipSources = ['generic', 'notion']; if (!validZipSources.includes(source)) { throw new BadRequestException( - 'Invalid import source. Import source must either be generic, notion or confluence.', + 'Invalid import source. Import source must either be generic or notion.', ); } diff --git a/apps/server/src/integrations/import/services/file-import-task.service.ts b/apps/server/src/integrations/import/services/file-import-task.service.ts index 59447b27..40525ddf 100644 --- a/apps/server/src/integrations/import/services/file-import-task.service.ts +++ b/apps/server/src/integrations/import/services/file-import-task.service.ts @@ -32,7 +32,6 @@ import { import { executeTx } from '@docmost/db/utils'; import { BacklinkRepo } from '@docmost/db/repos/backlink/backlink.repo'; import { ImportAttachmentService } from './import-attachment.service'; -import { ModuleRef } from '@nestjs/core'; import { PageService } from '../../../core/page/services/page.service'; import { ImportPageNode } from '../dto/file-task-dto'; import { EventEmitter2 } from '@nestjs/event-emitter'; @@ -54,7 +53,6 @@ export class FileImportTaskService { private readonly backlinkRepo: BacklinkRepo, @InjectKysely() private readonly db: KyselyDB, private readonly importAttachmentService: ImportAttachmentService, - private moduleRef: ModuleRef, private eventEmitter: EventEmitter2, @Inject(AUDIT_SERVICE) private readonly auditService: IAuditService, ) {} @@ -115,27 +113,6 @@ export class FileImportTaskService { }); } - if (fileTask.source === FileImportSource.Confluence) { - let ConfluenceModule: any; - try { - // eslint-disable-next-line @typescript-eslint/no-require-imports - ConfluenceModule = require('./../../../ee/confluence-import/confluence-import.service'); - } catch (err) { - this.logger.error( - 'Confluence import requested but EE module not bundled in this build', - ); - return; - } - const confluenceImportService = this.moduleRef.get( - ConfluenceModule.ConfluenceImportService, - { strict: false }, - ); - - await confluenceImportService.processConfluenceImport({ - extractDir: tmpExtractDir, - fileTask, - }); - } try { await this.updateTaskStatus(fileTaskId, FileTaskStatus.Success, null); await cleanupTmpFile(); diff --git a/apps/server/src/integrations/import/services/import.service.ts b/apps/server/src/integrations/import/services/import.service.ts index c0e6c878..9182dcf1 100644 --- a/apps/server/src/integrations/import/services/import.service.ts +++ b/apps/server/src/integrations/import/services/import.service.ts @@ -28,7 +28,6 @@ import { StorageService } from '../../storage/storage.service'; import { InjectQueue } from '@nestjs/bullmq'; import { Queue } from 'bullmq'; import { QueueJob, QueueName } from '../../queue/constants'; -import { ModuleRef } from '@nestjs/core'; import { load } from 'cheerio'; import { normalizeImportHtml } from '../utils/import-formatter'; @@ -42,7 +41,6 @@ export class ImportService { @InjectKysely() private readonly db: KyselyDB, @InjectQueue(QueueName.FILE_TASK_QUEUE) private readonly fileTaskQueue: Queue, - private moduleRef: ModuleRef, ) {} async importPage( @@ -62,33 +60,11 @@ export class ImportService { let prosemirrorState = null; let createdPage = null; - // For DOCX, we need the page ID upfront so images can reference it - const pageId = - fileExtension === '.docx' || fileExtension === '.pdf' - ? uuid7() - : undefined; - try { if (fileExtension.endsWith('.md')) { prosemirrorState = await this.processMarkdown(fileContent); } else if (fileExtension.endsWith('.html')) { prosemirrorState = await this.processHTML(fileContent); - } else if (fileExtension.endsWith('.docx')) { - prosemirrorState = await this.processDocx( - fileBuffer, - workspaceId, - spaceId, - pageId, - userId, - ); - } else if (fileExtension.endsWith('.pdf')) { - prosemirrorState = await this.processPdf( - fileBuffer, - workspaceId, - spaceId, - pageId, - userId, - ); } } catch (err) { // Surface the real cause instead of a generic mask, so the failure is @@ -117,7 +93,6 @@ export class ImportService { const pagePosition = await this.getNewPagePosition(spaceId); createdPage = await this.pageRepo.insertPage({ - ...(pageId ? { id: pageId } : {}), slugId: generateSlugId(), title: pageTitle, content: prosemirrorJson, @@ -165,78 +140,6 @@ export class ImportService { } } - async processDocx( - fileBuffer: Buffer, - workspaceId: string, - spaceId: string, - pageId: string, - userId: string, - ): Promise { - let DocxImportModule: any; - try { - // eslint-disable-next-line @typescript-eslint/no-require-imports - DocxImportModule = require('./../../../ee/document-import/docx-import.service'); - } catch (err) { - this.logger.error( - 'DOCX import requested but EE module not bundled in this build', - ); - throw new BadRequestException( - 'This feature requires a valid enterprise license.', - ); - } - - const docxImportService = this.moduleRef.get( - DocxImportModule.DocxImportService, - { strict: false }, - ); - - const html = await docxImportService.convertDocxToHtml( - fileBuffer, - workspaceId, - spaceId, - pageId, - userId, - ); - - return this.processHTML(html); - } - - async processPdf( - fileBuffer: Buffer, - workspaceId: string, - spaceId: string, - pageId: string, - userId: string, - ): Promise { - let PdfImportModule: any; - try { - // eslint-disable-next-line @typescript-eslint/no-require-imports - PdfImportModule = require('./../../../ee/document-import/pdf-import.service'); - } catch (err) { - this.logger.error( - 'PDF import requested but EE module not bundled in this build', - ); - throw new BadRequestException( - 'This feature requires a valid enterprise license.', - ); - } - - const pdfImportService = this.moduleRef.get( - PdfImportModule.PdfImportService, - { strict: false }, - ); - - const html = await pdfImportService.convertPdfToHtml( - fileBuffer, - workspaceId, - spaceId, - pageId, - userId, - ); - - return this.processHTML(html); - } - async createYdoc(prosemirrorJson: any): Promise { if (prosemirrorJson) { // this.logger.debug(`Converting prosemirror json state to ydoc`); diff --git a/apps/server/src/integrations/import/utils/file.utils.ts b/apps/server/src/integrations/import/utils/file.utils.ts index 0b27554b..6f804210 100644 --- a/apps/server/src/integrations/import/utils/file.utils.ts +++ b/apps/server/src/integrations/import/utils/file.utils.ts @@ -10,7 +10,6 @@ export enum FileTaskType { export enum FileImportSource { Generic = 'generic', Notion = 'notion', - Confluence = 'confluence', } export enum FileTaskStatus { -- 2.49.1