diff --git a/server/src/services/documentParser.ts b/server/src/services/documentParser.ts index ba54ceb..a99f6ab 100644 --- a/server/src/services/documentParser.ts +++ b/server/src/services/documentParser.ts @@ -1,8 +1,8 @@ import officeParser from 'officeparser'; import WordExtractor from 'word-extractor'; import * as XLSX from 'xlsx'; -import * as PPT from 'ppt'; -import * as CFB from 'cfb'; +import PPT from 'ppt'; +import CFB from 'cfb'; export const GEMINI_NATIVE_TYPES = [ 'application/pdf', diff --git a/server/src/types/legacy-office.d.ts b/server/src/types/legacy-office.d.ts index 3f91c0f..16d6c00 100644 --- a/server/src/types/legacy-office.d.ts +++ b/server/src/types/legacy-office.d.ts @@ -20,9 +20,15 @@ declare module 'ppt' { to_text(pres: PPTPresentation): string[]; } - export function readFile(filename: string, opts?: { WTF?: number; dump?: number }): PPTPresentation; - export function parse_pptcfb(cfb: CFB.Container, opts?: object): PPTPresentation; - export const utils: PPTUtils; + interface PPTModule { + version: string; + readFile(filename: string, opts?: { WTF?: number; dump?: number }): PPTPresentation; + parse_pptcfb(cfb: CFBContainer, opts?: object): PPTPresentation; + utils: PPTUtils; + } + + const PPT: PPTModule; + export default PPT; } declare module 'cfb' { @@ -32,7 +38,7 @@ declare module 'cfb' { content?: Buffer; } - interface Container { + interface CFBContainer { FileIndex: CFBEntry[]; FullPaths: string[]; } @@ -41,6 +47,16 @@ declare module 'cfb' { type?: 'file' | 'buffer' | 'base64' | 'binary' | 'array'; } - export function read(data: Buffer | string | ArrayBuffer, opts?: ReadOptions): Container; - export function parse(data: Buffer | number[]): Container; + interface CFBModule { + read(data: Buffer | string | ArrayBuffer, opts?: ReadOptions): CFBContainer; + parse(data: Buffer | number[]): CFBContainer; + } + + const CFB: CFBModule; + export default CFB; +} + +// Re-export for global use +declare global { + type CFBContainer = import('cfb').CFBContainer; }