| 11 | * // => ['question', 'node1.data.instance'] |
| 12 | */ |
| 13 | export function extractVariables(text: string): string[] { |
| 14 | const matches: string[] = [] |
| 15 | let match: RegExpExecArray | null |
| 16 | // Reset lastIndex for safety (global regex) |
| 17 | VARIABLE_REGEX.lastIndex = 0 |
| 18 | while ((match = VARIABLE_REGEX.exec(text)) !== null) { |
| 19 | const inside = match[1].trim() |
| 20 | // Skip JSON-like content (e.g. {{"key": "value"}}) |
| 21 | if (!inside.includes(':')) { |
| 22 | matches.push(inside) |
| 23 | } |
| 24 | } |
| 25 | return matches |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * Recursively walk edges backward from `nodeId` to collect **all** ancestor nodes |