|
1 | | -import type { SerializedWorkflow } from '@/serializer/types' |
2 | | - |
3 | 1 | /** |
4 | 2 | * Shared utility for calculating block paths and accessible connections. |
5 | 3 | * Used by both frontend (useBlockConnections) and backend (InputResolver) to ensure consistency. |
@@ -65,36 +63,4 @@ export class BlockPathCalculator { |
65 | 63 |
|
66 | 64 | return Array.from(pathNodes) |
67 | 65 | } |
68 | | - |
69 | | - /** |
70 | | - * Calculates accessible blocks for all blocks in a workflow. |
71 | | - * This ensures consistent block reference resolution across frontend and backend. |
72 | | - * |
73 | | - * @param workflow - The serialized workflow |
74 | | - * @returns Map of block ID to Set of accessible block IDs |
75 | | - */ |
76 | | - static calculateAccessibleBlocksForWorkflow( |
77 | | - workflow: SerializedWorkflow |
78 | | - ): Map<string, Set<string>> { |
79 | | - const accessibleMap = new Map<string, Set<string>>() |
80 | | - |
81 | | - for (const block of workflow.blocks) { |
82 | | - const accessibleBlocks = new Set<string>() |
83 | | - |
84 | | - // Find all blocks along paths leading to this block |
85 | | - const pathNodes = BlockPathCalculator.findAllPathNodes(workflow.connections, block.id) |
86 | | - pathNodes.forEach((nodeId) => accessibleBlocks.add(nodeId)) |
87 | | - |
88 | | - // Only add starter block if it's actually upstream (already in pathNodes) |
89 | | - // Don't add it just because it exists on the canvas |
90 | | - const starterBlock = workflow.blocks.find((b) => b.metadata?.id === 'starter') |
91 | | - if (starterBlock && starterBlock.id !== block.id && pathNodes.includes(starterBlock.id)) { |
92 | | - accessibleBlocks.add(starterBlock.id) |
93 | | - } |
94 | | - |
95 | | - accessibleMap.set(block.id, accessibleBlocks) |
96 | | - } |
97 | | - |
98 | | - return accessibleMap |
99 | | - } |
100 | 66 | } |
0 commit comments