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

Function parseSubBlockArrayContent

scripts/generate-docs.ts:3412–3452  ·  view source on GitHub ↗

* Parse SubBlockConfig items from within an array body (between the brackets). * Handles inline `{...}` objects and function calls `funcName(...)`.

(
  arrayContent: string,
  uiOnlyIds: Set<string>,
  utilsContent: string
)

Source from the content-addressed store, hash-verified

3410 * Handles inline `{...}` objects and function calls `funcName(...)`.
3411 */
3412function parseSubBlockArrayContent(
3413 arrayContent: string,
3414 uiOnlyIds: Set<string>,
3415 utilsContent: string
3416): TriggerConfigField[] {
3417 const fields: TriggerConfigField[] = []
3418 let i = 0
3419
3420 while (i < arrayContent.length) {
3421 if (arrayContent[i] === '{') {
3422 const j = findMatchingClose(arrayContent, i)
3423 if (j === -1) break
3424 const field = parseSubBlockObject(arrayContent.substring(i, j), uiOnlyIds, utilsContent)
3425 if (field) fields.push(field)
3426 i = j
3427 } else if (/[a-zA-Z_]/.test(arrayContent[i])) {
3428 // Possible function call: funcName(args)
3429 const funcCallMatch = /^(\w+)\s*\(/.exec(arrayContent.substring(i))
3430 if (funcCallMatch && utilsContent) {
3431 const funcName = funcCallMatch[1]
3432 if (funcName !== 'true' && funcName !== 'false' && funcName !== 'null') {
3433 fields.push(...resolveSubBlockBuilderFunction(funcName, utilsContent))
3434 }
3435 // Advance past the function call's closing paren
3436 const openIdx = arrayContent.indexOf('(', i + funcName.length)
3437 if (openIdx !== -1) {
3438 const closeIdx = findMatchingClose(arrayContent, openIdx, '(', ')')
3439 i = closeIdx !== -1 ? closeIdx : openIdx + 1
3440 } else {
3441 i += funcName.length
3442 }
3443 } else {
3444 i++
3445 }
3446 } else {
3447 i++
3448 }
3449 }
3450
3451 return fields
3452}
3453
3454/**
3455 * Extract user-facing configuration fields from a TriggerConfig subBlocks definition.

Callers 2

Calls 5

findMatchingCloseFunction · 0.85
parseSubBlockObjectFunction · 0.85
testMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected