Must run before file replacement/deletion cascades the endpoint edges.
(filePath: string)
| 2638 | |
| 2639 | /** Must run before file replacement/deletion cascades the endpoint edges. */ |
| 2640 | hasSynthesizedEdgesTouchingFile(filePath: string): boolean { |
| 2641 | const owned = "CASE WHEN json_valid(e.metadata) THEN json_extract(e.metadata, '$.synthesizedBy') END IS NOT NULL"; |
| 2642 | for (const endpoint of ['source', 'target']) { |
| 2643 | if (this.db.prepare(`SELECT 1 FROM nodes n JOIN edges e ON e.${endpoint} = n.id |
| 2644 | WHERE n.file_path = ? AND ${owned} LIMIT 1`).get(filePath)) return true; |
| 2645 | } |
| 2646 | // Wiring often lives in a third file, with neither endpoint in it. |
| 2647 | return !!this.db.prepare(`SELECT 1 FROM edges e WHERE ${owned} |
| 2648 | AND CASE WHEN json_valid(e.metadata) THEN json_extract(e.metadata, '$.registeredAt') END >= ? |
| 2649 | AND CASE WHEN json_valid(e.metadata) THEN json_extract(e.metadata, '$.registeredAt') END < ? LIMIT 1` |
| 2650 | ).get(`${filePath}:`, `${filePath};`); |
| 2651 | } |
| 2652 | |
| 2653 | wasSynthesisInput(filePath: string): boolean { |
| 2654 | return !!this.db.prepare('SELECT 1 FROM synthesis_inputs WHERE file_path = ?').get(filePath); |