* Extract the list of trigger IDs from the block's `triggers.available` array. * Handles blocks that declare `triggers: { enabled: true, available: [...] }`.
(blockContent: string)
| 635 | * Handles blocks that declare `triggers: { enabled: true, available: [...] }`. |
| 636 | */ |
| 637 | function extractTriggersAvailable(blockContent: string): string[] { |
| 638 | const triggersMatch = /\btriggers\s*:\s*\{/.exec(blockContent) |
| 639 | if (!triggersMatch) return [] |
| 640 | |
| 641 | const start = triggersMatch.index + triggersMatch[0].length - 1 |
| 642 | const trigEnd = findMatchingClose(blockContent, start) |
| 643 | if (trigEnd === -1) return [] |
| 644 | const triggersContent = blockContent.substring(start, trigEnd) |
| 645 | |
| 646 | if (!/enabled\s*:\s*true/.test(triggersContent)) return [] |
| 647 | |
| 648 | const availableMatch = /available\s*:\s*\[/.exec(triggersContent) |
| 649 | if (!availableMatch) return [] |
| 650 | |
| 651 | const arrayStart = availableMatch.index + availableMatch[0].length - 1 |
| 652 | const arrayEnd = findMatchingClose(triggersContent, arrayStart, '[', ']') |
| 653 | if (arrayEnd === -1) return [] |
| 654 | const arrayContent = triggersContent.substring(arrayStart + 1, arrayEnd - 1) |
| 655 | |
| 656 | const ids: string[] = [] |
| 657 | const idRegex = /['"]([^'"]+)['"]/g |
| 658 | let m |
| 659 | while ((m = idRegex.exec(arrayContent)) !== null) { |
| 660 | ids.push(m[1]) |
| 661 | } |
| 662 | return ids |
| 663 | } |
| 664 | |
| 665 | /** |
| 666 | * Scan all trigger definition files and build a registry mapping trigger IDs |
no test coverage detected