({ appDataSource, componentNodes, data, orgId, workspaceId }: IExecutePreviewLoader)
| 723 | } |
| 724 | |
| 725 | export const previewChunks = async ({ appDataSource, componentNodes, data, orgId, workspaceId }: IExecutePreviewLoader) => { |
| 726 | try { |
| 727 | if (data.preview) { |
| 728 | if ( |
| 729 | data.loaderId === 'cheerioWebScraper' || |
| 730 | data.loaderId === 'puppeteerWebScraper' || |
| 731 | data.loaderId === 'playwrightWebScraper' |
| 732 | ) { |
| 733 | data.loaderConfig['limit'] = 3 |
| 734 | } |
| 735 | } |
| 736 | if (!data.rehydrated) { |
| 737 | await _normalizeFilePaths(appDataSource, data, null, orgId, workspaceId) |
| 738 | } |
| 739 | let docs = await _splitIntoChunks(appDataSource, componentNodes, data, workspaceId) |
| 740 | const totalChunks = docs.length |
| 741 | // if -1, return all chunks |
| 742 | if (data.previewChunkCount === -1) data.previewChunkCount = totalChunks |
| 743 | // return all docs if the user ask for more than we have |
| 744 | if (totalChunks <= (data.previewChunkCount || 0)) data.previewChunkCount = totalChunks |
| 745 | // return only the first n chunks |
| 746 | if (totalChunks > (data.previewChunkCount || 0)) docs = docs.slice(0, data.previewChunkCount) |
| 747 | |
| 748 | return { chunks: docs, totalChunks: totalChunks, previewChunkCount: data.previewChunkCount } |
| 749 | } catch (error) { |
| 750 | if (error instanceof InternalFlowiseError) { |
| 751 | throw error |
| 752 | } |
| 753 | throw new InternalFlowiseError( |
| 754 | StatusCodes.INTERNAL_SERVER_ERROR, |
| 755 | `Error: documentStoreServices.previewChunks - ${getErrorMessage(error)}` |
| 756 | ) |
| 757 | } |
| 758 | } |
| 759 | |
| 760 | const saveProcessingLoader = async ( |
| 761 | appDataSource: DataSource, |
no test coverage detected