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

Function extractTriggerOutputs

scripts/generate-docs.ts:3225–3250  ·  view source on GitHub ↗

* Extract the outputs object from a TriggerConfig segment. * Handles both inline `outputs: { ... }` and function-call patterns * like `outputs: buildIssueOutputs()`, resolving builder functions * from the trigger file itself and its sibling `utils.ts`.

(
  segment: string,
  fileContent: string,
  utilsContent: string
)

Source from the content-addressed store, hash-verified

3223 * from the trigger file itself and its sibling `utils.ts`.
3224 */
3225function extractTriggerOutputs(
3226 segment: string,
3227 fileContent: string,
3228 utilsContent: string
3229): Record<string, any> {
3230 // 1. Inline outputs: outputs: { ... }
3231 const outputsMatch = /\boutputs\s*:\s*\{/.exec(segment)
3232 if (outputsMatch) {
3233 const openPos = segment.indexOf('{', outputsMatch.index + outputsMatch[0].length - 1)
3234 if (openPos !== -1) {
3235 const closePos = findMatchingClose(segment, openPos)
3236 if (closePos !== -1) {
3237 const outputsContent = segment.substring(openPos + 1, closePos - 1).trim()
3238 return parseToolOutputsField(outputsContent)
3239 }
3240 }
3241 }
3242
3243 // 2. Function-call outputs: outputs: buildFoo()
3244 const funcCallMatch = /\boutputs\s*:\s*(\w+)\s*\(\s*\)/.exec(segment)
3245 if (funcCallMatch) {
3246 return resolveTriggerBuilderFunction(funcCallMatch[1], fileContent, utilsContent)
3247 }
3248
3249 return {}
3250}
3251
3252/**
3253 * Lazy-loaded cache of all TypeScript files in `lib/webhooks/providers/`.

Callers 1

buildFullTriggerRegistryFunction · 0.85

Calls 3

findMatchingCloseFunction · 0.85
parseToolOutputsFieldFunction · 0.85

Tested by

no test coverage detected