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

Function selectBestTrigger

apps/sim/lib/workflows/triggers/trigger-utils.ts:315–331  ·  view source on GitHub ↗
(
  candidates: StartBlockCandidate<T>[],
  edges?: Array<{ source: string; target: string }>
)

Source from the content-addressed store, hash-verified

313 * If multiple disjoint paths exist, returns one trigger per path
314 */
315export function selectBestTrigger<T extends { type: string; subBlocks?: Record<string, unknown> }>(
316 candidates: StartBlockCandidate<T>[],
317 edges?: Array<{ source: string; target: string }>
318): StartBlockCandidate<T>[] {
319 if (candidates.length === 0) {
320 throw new Error('No trigger candidates provided')
321 }
322
323 // If edges provided, group by path and select best from each group
324 if (edges) {
325 const groups = groupTriggersByPath(candidates, edges)
326 return groups.map((group) => selectBestFromGroup(group))
327 }
328
329 // Otherwise just select the single best trigger
330 return [selectBestFromGroup(candidates)]
331}
332
333/**
334 * Selects the best trigger from a group based on priority

Callers 2

resolveTriggerRunOptionsFunction · 0.90
executeWorkflowFunction · 0.90

Calls 2

groupTriggersByPathFunction · 0.85
selectBestFromGroupFunction · 0.85

Tested by

no test coverage detected