* Parse a single SubBlockConfig object literal into a TriggerConfigField. * Returns null for blocks that should be skipped (UI-only IDs, text type, readOnly). * Accepts optional `resolverContent` to resolve const-reference field IDs.
( obj: string, uiOnlyIds: Set<string>, resolverContent?: string )
| 3286 | * Accepts optional `resolverContent` to resolve const-reference field IDs. |
| 3287 | */ |
| 3288 | function parseSubBlockObject( |
| 3289 | obj: string, |
| 3290 | uiOnlyIds: Set<string>, |
| 3291 | resolverContent?: string |
| 3292 | ): TriggerConfigField | null { |
| 3293 | let id: string | undefined = /\bid\s*:\s*['"]([^'"]+)['"]/.exec(obj)?.[1] |
| 3294 | |
| 3295 | // Handle const-reference ids: `id: SCREAMING_CASE_IDENTIFIER` |
| 3296 | if (!id) { |
| 3297 | const constRefMatch = /\bid\s*:\s*([A-Z][A-Z0-9_]+)\b/.exec(obj) |
| 3298 | if (constRefMatch) { |
| 3299 | id = resolveConstStringValue(constRefMatch[1], resolverContent ?? '') ?? undefined |
| 3300 | } |
| 3301 | } |
| 3302 | |
| 3303 | if (!id || uiOnlyIds.has(id)) return null |
| 3304 | |
| 3305 | const typeMatch = /\btype\s*:\s*['"]([^'"]+)['"]/.exec(obj) |
| 3306 | if (typeMatch?.[1] === 'text') return null |
| 3307 | if (/\breadOnly\s*:\s*true/.test(obj)) return null |
| 3308 | |
| 3309 | const titleMatch = /\btitle\s*:\s*['"]([^'"]+)['"]/.exec(obj) |
| 3310 | const requiredMatch = /\brequired\s*:\s*(true)/.exec(obj) |
| 3311 | const placeholderMatch = /\bplaceholder\s*:\s*['"]([^'"]+)['"]/.exec(obj) |
| 3312 | const descMatch = /\bdescription\s*:\s*['"]([^'"]+)['"]/.exec(obj) |
| 3313 | |
| 3314 | // Use title as description fallback so oauth-input and other fields without |
| 3315 | // an explicit description still show something meaningful in the docs table. |
| 3316 | const description = descMatch?.[1] ?? (titleMatch ? `${titleMatch[1]}` : undefined) |
| 3317 | |
| 3318 | return { |
| 3319 | id, |
| 3320 | title: titleMatch?.[1] ?? id, |
| 3321 | type: typeMatch?.[1] ?? 'short-input', |
| 3322 | required: Boolean(requiredMatch), |
| 3323 | placeholder: placeholderMatch?.[1], |
| 3324 | description, |
| 3325 | } |
| 3326 | } |
| 3327 | |
| 3328 | /** |
| 3329 | * Resolve a SubBlockConfig builder function to its field definitions. |
no test coverage detected