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

Function buildMatcher

apps/sim/blocks/integration-matcher.ts:49–73  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

47let cachedList: readonly IntegrationDescriptor[] | null = null
48
49function buildMatcher(): IntegrationMatcher {
50 const byName = new Map<string, IntegrationDescriptor>()
51 const names: string[] = []
52
53 for (const block of getCanonicalBlocksByCategory('tools')) {
54 if (!block.name || block.name.trim().length < 2) continue
55 const displayName = normalizeDisplayName(block.name)
56 const key = displayName.toLowerCase()
57 if (byName.has(key)) continue
58 byName.set(key, {
59 blockType: block.type,
60 name: displayName,
61 icon: block.icon,
62 bgColor: block.bgColor,
63 })
64 names.push(displayName)
65 }
66
67 names.sort((a, b) => b.length - a.length)
68 const regex = names.length
69 ? new RegExp(`(?<![A-Za-z0-9_])(${names.map(escapeRegex).join('|')})(?![A-Za-z0-9_])`, 'gi')
70 : null
71
72 return { regex, byName }
73}
74
75/**
76 * Lazily builds (once per session) and returns the precomputed integration

Callers 1

getIntegrationMatcherFunction · 0.85

Calls 5

normalizeDisplayNameFunction · 0.85
joinMethod · 0.80
setMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected