(nodes: FlowNode[])
| 84 | * Scans each node's state-related inputs (startState, *UpdateState) for key definitions. |
| 85 | */ |
| 86 | export function getDefinedStateKeys(nodes: FlowNode[]): string[] { |
| 87 | const keys = new Set<string>() |
| 88 | for (const node of nodes) { |
| 89 | const inputs = node.data?.inputs |
| 90 | if (!inputs || typeof inputs !== 'object') continue |
| 91 | for (const inputName of Object.keys(inputs)) { |
| 92 | if (!STATE_INPUT_PATTERN.test(inputName)) continue |
| 93 | const updates = inputs[inputName] |
| 94 | if (!Array.isArray(updates)) continue |
| 95 | for (const entry of updates) { |
| 96 | if (!entry || typeof entry !== 'object') continue |
| 97 | const key = (entry as StateUpdate).key?.trim() |
| 98 | if (key) { |
| 99 | keys.add(key) |
| 100 | } |
| 101 | } |
| 102 | } |
| 103 | } |
| 104 | return Array.from(keys).sort() |
| 105 | } |
no test coverage detected