| 15 | // --- Internal analysis helpers used by handleRead and individual handlers --- |
| 16 | |
| 17 | function computeStructure(file: DeepnoteFile) { |
| 18 | const blockCounts: Record<string, number> = {} |
| 19 | let totalBlocks = 0 |
| 20 | |
| 21 | for (const notebook of file.project.notebooks) { |
| 22 | for (const block of notebook.blocks) { |
| 23 | blockCounts[block.type] = (blockCounts[block.type] || 0) + 1 |
| 24 | totalBlocks++ |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | return { |
| 29 | projectName: file.project.name, |
| 30 | projectId: file.project.id, |
| 31 | notebooks: file.project.notebooks.map(n => ({ |
| 32 | name: n.name, |
| 33 | id: n.id, |
| 34 | blockCount: n.blocks.length, |
| 35 | isModule: n.isModule || false, |
| 36 | })), |
| 37 | totalBlocks, |
| 38 | blockCounts, |
| 39 | hasIntegrations: (file.project.integrations?.length || 0) > 0, |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | function computeStats(file: DeepnoteFile) { |
| 44 | // Use CLI's analysis function for consistency |