(
result: Extract<ResolveByTagOperationResult, { ok: false }>,
allEndpoints: EndpointInfo[]
)
| 555 | } |
| 556 | |
| 557 | function printTagOperationResolveError( |
| 558 | result: Extract<ResolveByTagOperationResult, { ok: false }>, |
| 559 | allEndpoints: EndpointInfo[] |
| 560 | ): void { |
| 561 | if (result.reason === 'no_tag') { |
| 562 | const tags = [...new Set(allEndpoints.flatMap(ep => ep.tags || []))].sort(); |
| 563 | const preview = tags.slice(0, 25).join(', '); |
| 564 | output.error( |
| 565 | `No operations use tag "${result.tag}".${tags.length > 0 ? ` Example tags: ${preview}${tags.length > 25 ? ', …' : ''}.` : ''} Run \`vercel api ls --format json\` to inspect tags.` |
| 566 | ); |
| 567 | return; |
| 568 | } |
| 569 | |
| 570 | if (result.reason === 'no_operation') { |
| 571 | const ids = result.tagMatches |
| 572 | .map(ep => ep.operationId) |
| 573 | .filter(Boolean) |
| 574 | .sort(); |
| 575 | output.error( |
| 576 | `No operation matches "${result.operationHint}" under tag "${result.tag}".${ids.length > 0 ? ` Operations include: ${ids.slice(0, 20).join(', ')}${ids.length > 20 ? ', …' : ''}.` : ''}` |
| 577 | ); |
| 578 | return; |
| 579 | } |
| 580 | |
| 581 | const lines = result.tagMatches.map( |
| 582 | ep => ` ${ep.operationId} ${ep.method} ${ep.path}` |
| 583 | ); |
| 584 | output.error( |
| 585 | `Multiple operations match "${result.operationHint}" under tag "${result.tag}":\n${lines.join('\n')}` |
| 586 | ); |
| 587 | } |
| 588 | |
| 589 | async function executeApiRequest( |
| 590 | client: Client, |
no test coverage detected