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

Function buildFullTriggerRegistry

scripts/generate-docs.ts:3526–3581  ·  view source on GitHub ↗

* Build the full trigger registry: id → TriggerFullInfo. * Parses every trigger source file for config fields and output schemas.

()

Source from the content-addressed store, hash-verified

3524 * Parses every trigger source file for config fields and output schemas.
3525 */
3526async function buildFullTriggerRegistry(): Promise<Map<string, TriggerFullInfo>> {
3527 const registry = new Map<string, TriggerFullInfo>()
3528 const SKIP = new Set(['index.ts', 'registry.ts', 'types.ts', 'constants.ts', 'utils.ts'])
3529
3530 const triggerFiles = (await glob(`${TRIGGERS_PATH}/**/*.ts`)).filter(
3531 (f) => !SKIP.has(path.basename(f)) && !f.includes('.test.')
3532 )
3533
3534 for (const file of triggerFiles) {
3535 try {
3536 const content = fs.readFileSync(file, 'utf-8')
3537
3538 // Load sibling utils.ts for resolving builder function outputs
3539 const utilsPath = path.join(path.dirname(file), 'utils.ts')
3540 const utilsContent = fs.existsSync(utilsPath) ? fs.readFileSync(utilsPath, 'utf-8') : ''
3541
3542 const exportRegex = /export\s+const\s+\w+\s*:\s*TriggerConfig\s*=\s*\{/g
3543 let exportMatch: RegExpExecArray | null
3544 const exportStarts: number[] = []
3545 while ((exportMatch = exportRegex.exec(content)) !== null) {
3546 exportStarts.push(exportMatch.index)
3547 }
3548
3549 const segments =
3550 exportStarts.length > 0
3551 ? exportStarts.map((start, i) => content.substring(start, exportStarts[i + 1]))
3552 : [content]
3553
3554 for (const segment of segments) {
3555 const idMatch = /\bid\s*:\s*['"]([^'"]+)['"]/.exec(segment)
3556 const nameMatch = /\bname\s*:\s*['"]([^'"]+)['"]/.exec(segment)
3557 const descMatch = /\bdescription\s*:\s*['"]([^'"]+)['"]/.exec(segment)
3558 const providerMatch = /\bprovider\s*:\s*['"]([^'"]+)['"]/.exec(segment)
3559
3560 if (!idMatch || !nameMatch || !providerMatch) continue
3561
3562 const polling = /\bpolling\s*:\s*true/.test(segment)
3563
3564 registry.set(idMatch[1], {
3565 id: idMatch[1],
3566 name: nameMatch[1],
3567 description: descMatch?.[1] ?? '',
3568 provider: providerMatch[1],
3569 polling,
3570 outputs: extractTriggerOutputs(segment, content, utilsContent),
3571 configFields: extractTriggerConfigFields(segment, content, utilsContent),
3572 })
3573 }
3574 } catch {
3575 // skip unreadable files silently
3576 }
3577 }
3578
3579 console.log(`✓ Loaded full config for ${registry.size} triggers`)
3580 return registry
3581}
3582
3583/**

Callers 1

generateAllTriggerDocsFunction · 0.85

Calls 8

globFunction · 0.85
extractTriggerOutputsFunction · 0.85
joinMethod · 0.80
testMethod · 0.80
logMethod · 0.80
setMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected