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

Function parseConstFieldContent

scripts/generate-docs.ts:1606–1729  ·  view source on GitHub ↗
(
  fieldContent: string,
  toolPrefix: string,
  typesContent: string,
  depth: number
)

Source from the content-addressed store, hash-verified

1604}
1605
1606function parseConstFieldContent(
1607 fieldContent: string,
1608 toolPrefix: string,
1609 typesContent: string,
1610 depth: number
1611): any {
1612 const typeMatch = fieldContent.match(/type\s*:\s*['"]([^'"]+)['"]/)
1613 const description = extractDescription(fieldContent)
1614
1615 if (!typeMatch) return null
1616
1617 const fieldType = typeMatch[1]
1618
1619 const result: any = {
1620 type: fieldType,
1621 description: description || '',
1622 }
1623
1624 // Check for properties - either inline or const reference
1625 if (fieldType === 'object' || fieldType === 'json') {
1626 // Check for const reference first
1627 const propsConstMatch = fieldContent.match(/properties\s*:\s*([A-Z][A-Z_0-9]+)/)
1628 if (propsConstMatch) {
1629 const resolvedProps = resolveConstFromTypesContent(
1630 propsConstMatch[1],
1631 typesContent,
1632 toolPrefix,
1633 depth + 1
1634 )
1635 if (resolvedProps) {
1636 result.properties = resolvedProps
1637 }
1638 } else {
1639 // Check for inline properties
1640 const propertiesStart = fieldContent.search(/properties\s*:\s*\{/)
1641 if (propertiesStart !== -1) {
1642 const braceStart = fieldContent.indexOf('{', propertiesStart)
1643 const braceEnd = findMatchingClose(fieldContent, braceStart)
1644
1645 if (braceEnd !== -1) {
1646 const propertiesContent = fieldContent.substring(braceStart + 1, braceEnd - 1).trim()
1647 result.properties = parseConstProperties(
1648 propertiesContent,
1649 toolPrefix,
1650 typesContent,
1651 depth + 1
1652 )
1653 }
1654 }
1655 }
1656 }
1657
1658 // Check for items (arrays)
1659 const itemsConstMatch = fieldContent.match(/items\s*:\s*([A-Z][A-Z_0-9]+)/)
1660 if (itemsConstMatch) {
1661 const resolvedItems = resolveConstFromTypesContent(
1662 itemsConstMatch[1],
1663 typesContent,

Callers 3

resolveConstReferenceFunction · 0.85
parseConstPropertiesFunction · 0.85

Calls 4

extractDescriptionFunction · 0.85
findMatchingCloseFunction · 0.85
parseConstPropertiesFunction · 0.85

Tested by

no test coverage detected