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

Function extractStringPropertyFromContent

scripts/generate-docs.ts:1175–1217  ·  view source on GitHub ↗

* Extract a string property from block content. * For top-level properties like 'description', only looks in the portion before nested objects * to avoid matching properties inside nested structures like outputs.

(
  content: string,
  propName: string,
  topLevelOnly = false
)

Source from the content-addressed store, hash-verified

1173 * to avoid matching properties inside nested structures like outputs.
1174 */
1175function extractStringPropertyFromContent(
1176 content: string,
1177 propName: string,
1178 topLevelOnly = false
1179): string | null {
1180 let searchContent = content
1181
1182 // For top-level properties, only search before nested objects like outputs, tools, inputs, subBlocks
1183 if (topLevelOnly) {
1184 const nestedObjectPatterns = [
1185 /\boutputs\s*:\s*\{/,
1186 /\btools\s*:\s*\{/,
1187 /\binputs\s*:\s*\{/,
1188 /\bsubBlocks\s*:\s*\[/,
1189 /\btriggers\s*:\s*\{/,
1190 ]
1191
1192 let cutoffIndex = content.length
1193 for (const pattern of nestedObjectPatterns) {
1194 const match = content.match(pattern)
1195 if (match && match.index !== undefined && match.index < cutoffIndex) {
1196 cutoffIndex = match.index
1197 }
1198 }
1199 searchContent = content.substring(0, cutoffIndex)
1200 }
1201
1202 const singleQuoteMatch = searchContent.match(new RegExp(`${propName}\\s*:\\s*'([^']*)'`, 'm'))
1203 if (singleQuoteMatch) return singleQuoteMatch[1]
1204
1205 const doubleQuoteMatch = searchContent.match(new RegExp(`${propName}\\s*:\\s*"([^"]*)"`, 'm'))
1206 if (doubleQuoteMatch) return doubleQuoteMatch[1]
1207
1208 const templateMatch = searchContent.match(new RegExp(`${propName}\\s*:\\s*\`([^\`]+)\``, 's'))
1209 if (templateMatch) {
1210 let templateContent = templateMatch[1]
1211 templateContent = templateContent.replace(/\$\{[^}]+\}/g, '')
1212 templateContent = templateContent.replace(/\s+/g, ' ').trim()
1213 return templateContent
1214 }
1215
1216 return null
1217}
1218
1219/**
1220 * Extract an enum property value from block content. Maps an `IntegrationType`

Callers 2

generateIconMappingFunction · 0.85

Calls 1

replaceMethod · 0.65

Tested by

no test coverage detected