MCPcopy Index your code
hub / github.com/simstudioai/sim / buildTriggerRegistry

Function buildTriggerRegistry

scripts/generate-docs.ts:669–718  ·  view source on GitHub ↗

* Scan all trigger definition files and build a registry mapping trigger IDs * to their human-readable name and description.

()

Source from the content-addressed store, hash-verified

667 * to their human-readable name and description.
668 */
669async function buildTriggerRegistry(): Promise<Map<string, TriggerInfo>> {
670 const registry = new Map<string, TriggerInfo>()
671 const SKIP = new Set(['index.ts', 'registry.ts', 'types.ts', 'constants.ts', 'utils.ts'])
672
673 const triggerFiles = (await glob(`${TRIGGERS_PATH}/**/*.ts`)).filter(
674 (f) => !SKIP.has(path.basename(f)) && !f.includes('.test.')
675 )
676
677 for (const file of triggerFiles) {
678 try {
679 const content = fs.readFileSync(file, 'utf-8')
680
681 // A file may export multiple TriggerConfig objects (e.g. v1 + v2 in
682 // the same file). Extract all exported configs by splitting on the
683 // export boundaries and parsing each one independently.
684 const exportRegex = /export\s+const\s+\w+\s*:\s*TriggerConfig\s*=\s*\{/g
685 let exportMatch
686 const exportStarts: number[] = []
687
688 while ((exportMatch = exportRegex.exec(content)) !== null) {
689 exportStarts.push(exportMatch.index)
690 }
691
692 // If no typed exports found, fall back to simple regex on whole file
693 const segments =
694 exportStarts.length > 0
695 ? exportStarts.map((start, i) => content.substring(start, exportStarts[i + 1]))
696 : [content]
697
698 for (const segment of segments) {
699 const idMatch = /\bid\s*:\s*['"]([^'"]+)['"]/.exec(segment)
700 const nameMatch = /\bname\s*:\s*['"]([^'"]+)['"]/.exec(segment)
701 const descMatch = /\bdescription\s*:\s*['"]([^'"]+)['"]/.exec(segment)
702
703 if (idMatch && nameMatch) {
704 registry.set(idMatch[1], {
705 id: idMatch[1],
706 name: nameMatch[1],
707 description: descMatch?.[1] ?? '',
708 })
709 }
710 }
711 } catch {
712 // skip unreadable files silently
713 }
714 }
715
716 console.log(`✓ Loaded ${registry.size} trigger definitions`)
717 return registry
718}
719
720/**
721 * Write the icon mapping TypeScript file for the shared integrations data

Callers 1

writeIntegrationsJsonFunction · 0.85

Calls 4

globFunction · 0.85
logMethod · 0.80
setMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected