({ inputs }, context)
| 66 | ], |
| 67 | }, |
| 68 | async execute({ inputs }, context) { |
| 69 | context.logger.info(`[FileLoader] Loading file with ID: ${inputs.fileId}`); |
| 70 | |
| 71 | // Use storage interface (not concrete implementation!) |
| 72 | const storage = context.storage; |
| 73 | |
| 74 | if (!storage) { |
| 75 | throw new ConfigurationError( |
| 76 | 'Storage service not available in execution context. Worker must provide IFileStorageService adapter.', |
| 77 | { configKey: 'storage' }, |
| 78 | ); |
| 79 | } |
| 80 | |
| 81 | context.emitProgress('Fetching file from storage...'); |
| 82 | |
| 83 | // Download file using interface |
| 84 | const { buffer, metadata } = await storage.downloadFile(inputs.fileId); |
| 85 | |
| 86 | context.logger.info( |
| 87 | `[FileLoader] Loaded file: ${metadata.fileName} (${metadata.size} bytes, ${metadata.mimeType})`, |
| 88 | ); |
| 89 | |
| 90 | context.emitProgress(`File loaded: ${metadata.fileName}`); |
| 91 | |
| 92 | // Convert to base64 for downstream components |
| 93 | const content = buffer.toString('base64'); |
| 94 | |
| 95 | // Also provide decoded text content |
| 96 | const textContent = buffer.toString('utf-8'); |
| 97 | |
| 98 | return { |
| 99 | file: { |
| 100 | id: metadata.id, |
| 101 | name: metadata.fileName, |
| 102 | mimeType: metadata.mimeType, |
| 103 | size: metadata.size, |
| 104 | content, |
| 105 | }, |
| 106 | textContent, |
| 107 | }; |
| 108 | }, |
| 109 | }); |
| 110 | |
| 111 | componentRegistry.register(definition); |
nothing calls this directly
no test coverage detected