( propertiesContent: string, toolPrefix?: string )
| 2353 | } |
| 2354 | |
| 2355 | function parsePropertiesContent( |
| 2356 | propertiesContent: string, |
| 2357 | toolPrefix?: string |
| 2358 | ): Record<string, any> { |
| 2359 | const properties: Record<string, any> = {} |
| 2360 | |
| 2361 | // First, handle const references at the property level |
| 2362 | // Patterns: "attendees: ATTENDEES_OUTPUT" or "id: BOOKING_DATA_OUTPUT_PROPERTIES.id" |
| 2363 | if (toolPrefix) { |
| 2364 | // Pattern 1: Direct const reference (e.g., "eventType: EVENT_TYPE_OUTPUT,") |
| 2365 | const constRefRegex = /(\w+)\s*:\s*([A-Z][A-Z_0-9]+)\s*(?:,|$)/g |
| 2366 | let constMatch |
| 2367 | while ((constMatch = constRefRegex.exec(propertiesContent)) !== null) { |
| 2368 | const propName = constMatch[1] |
| 2369 | const constName = constMatch[2] |
| 2370 | |
| 2371 | // Skip keywords |
| 2372 | if (propName === 'items' || propName === 'properties' || propName === 'type') { |
| 2373 | continue |
| 2374 | } |
| 2375 | |
| 2376 | // Check if at depth 0 |
| 2377 | const beforeMatch = propertiesContent.substring(0, constMatch.index) |
| 2378 | const openBraces = (beforeMatch.match(/\{/g) || []).length |
| 2379 | const closeBraces = (beforeMatch.match(/\}/g) || []).length |
| 2380 | if (openBraces !== closeBraces) { |
| 2381 | continue |
| 2382 | } |
| 2383 | |
| 2384 | const resolvedConst = resolveConstReference(constName, toolPrefix) |
| 2385 | if (resolvedConst) { |
| 2386 | properties[propName] = resolvedConst |
| 2387 | } |
| 2388 | } |
| 2389 | |
| 2390 | // Pattern 2: Property access on const (e.g., "id: BOOKING_DATA_OUTPUT_PROPERTIES.id,") |
| 2391 | const propAccessRegex = /(\w+)\s*:\s*([A-Z][A-Z_0-9]+)\.(\w+)\s*(?:,|$)/g |
| 2392 | let propAccessMatch |
| 2393 | while ((propAccessMatch = propAccessRegex.exec(propertiesContent)) !== null) { |
| 2394 | const propName = propAccessMatch[1] |
| 2395 | const constName = propAccessMatch[2] |
| 2396 | const accessedProp = propAccessMatch[3] |
| 2397 | |
| 2398 | // Skip keywords |
| 2399 | if (propName === 'items' || propName === 'properties' || propName === 'type') { |
| 2400 | continue |
| 2401 | } |
| 2402 | |
| 2403 | // Skip if already resolved |
| 2404 | if (properties[propName]) { |
| 2405 | continue |
| 2406 | } |
| 2407 | |
| 2408 | // Check if at depth 0 |
| 2409 | const beforeMatch = propertiesContent.substring(0, propAccessMatch.index) |
| 2410 | const openBraces = (beforeMatch.match(/\{/g) || []).length |
| 2411 | const closeBraces = (beforeMatch.match(/\}/g) || []).length |
| 2412 | if (openBraces !== closeBraces) { |
no test coverage detected