(obj, segments, operationId)
| 27 | |
| 28 | // Build nested object structure from path segments (same as core generate-wrapper) |
| 29 | function buildNestedObject(obj, segments, operationId) { |
| 30 | if (segments.length === 0) return operationId |
| 31 | |
| 32 | const [first, ...rest] = segments |
| 33 | const key = toCamelCase(first) |
| 34 | |
| 35 | if (rest.length === 0) { |
| 36 | const existing = obj[key] |
| 37 | if (typeof existing === 'string') |
| 38 | obj[key] = { [toActionKey(existing)]: existing, [toActionKey(operationId)]: operationId } |
| 39 | else if (existing && typeof existing === 'object' && !Array.isArray(existing)) |
| 40 | obj[key][toActionKey(operationId)] = operationId |
| 41 | else obj[key] = operationId |
| 42 | |
| 43 | return obj |
| 44 | } |
| 45 | |
| 46 | const existing = obj[key] |
| 47 | if (typeof existing === 'string') obj[key] = { [toActionKey(existing)]: existing } |
| 48 | |
| 49 | if (!obj[key] || typeof obj[key] === 'string') obj[key] = {} |
| 50 | |
| 51 | buildNestedObject(obj[key], rest, operationId) |
| 52 | return obj |
| 53 | } |
| 54 | |
| 55 | // Traverse nested structure and collect { path, operationId } for each leaf |
| 56 | function collectCommandSpecs(obj, pathPrefix = [], acc = []) { |
no test coverage detected