| 595 | } |
| 596 | |
| 597 | function insertWorkspaceId(importedData: any, activeWorkspaceId?: string) { |
| 598 | if (!activeWorkspaceId) return importedData |
| 599 | importedData.forEach((item: any) => { |
| 600 | if (item.type === 'Tool') { |
| 601 | // TODO: This is a temporary fix where export data for CustomTemplate type Tool need to be changed in the future. |
| 602 | // Also handles backward compatibility for previously exported data where CustomTemplate type Tool does not have flowData field. |
| 603 | item.flowData = JSON.stringify({ |
| 604 | iconSrc: item.iconSrc, |
| 605 | schema: item.schema, |
| 606 | func: item.func |
| 607 | }) |
| 608 | } |
| 609 | item.workspaceId = activeWorkspaceId |
| 610 | }) |
| 611 | return importedData |
| 612 | } |
| 613 | |
| 614 | async function saveBatch(manager: EntityManager, entity: any, items: any[], batchSize = 900) { |
| 615 | for (let i = 0; i < items.length; i += batchSize) { |