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

Function getTriggerOptions

apps/sim/lib/logs/get-trigger-options.ts:25–68  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

23 * Results are cached after first call for performance (~98% faster on subsequent calls).
24 */
25export function getTriggerOptions(): TriggerOption[] {
26 if (cachedTriggerOptions) {
27 return cachedTriggerOptions
28 }
29
30 const triggers = getAllTriggers()
31 const providerMap = new Map<string, TriggerOption>()
32
33 const coreTypes: TriggerOption[] = [
34 { value: 'manual', label: 'Manual', color: '#6b7280' },
35 { value: 'api', label: 'API', color: '#2563eb' },
36 { value: 'schedule', label: 'Schedule', color: '#059669' },
37 { value: 'chat', label: 'Chat', color: '#7c3aed' },
38 { value: 'webhook', label: 'Webhook', color: '#ea580c' },
39 { value: 'mcp', label: 'MCP', color: '#dc2626' },
40 { value: 'copilot', label: 'Sim agent', color: '#ec4899' },
41 { value: 'mothership', label: 'Sim agent', color: '#ec4899' },
42 { value: 'workflow', label: 'Workflow', color: '#0369a1' },
43 ]
44
45 for (const trigger of triggers) {
46 const provider = trigger.provider
47
48 // Skip generic webhook and already processed providers
49 if (!provider || providerMap.has(provider) || provider === 'generic') {
50 continue
51 }
52
53 const block = getLatestBlock(provider)
54
55 providerMap.set(provider, {
56 value: provider,
57 label: block?.name || formatProviderName(provider),
58 color: block?.bgColor || '#6b7280',
59 })
60 }
61
62 const integrationOptions = Array.from(providerMap.values()).sort((a, b) =>
63 a.label.localeCompare(b.label)
64 )
65
66 cachedTriggerOptions = [...coreTypes, ...integrationOptions]
67 return cachedTriggerOptions
68}
69
70/**
71 * Formats a provider name into a display-friendly label

Callers 3

LogsFunction · 0.90
LogsFilterPanelFunction · 0.90

Calls 4

getAllTriggersFunction · 0.90
getLatestBlockFunction · 0.90
formatProviderNameFunction · 0.85
setMethod · 0.65

Tested by

no test coverage detected