Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 21, 03:37 UTC
| 1 | export interface ApiPageOperation { |
| 2 | method: string; |
| 3 | path: string; |
| 4 | } |
| 5 | |
| 6 | export interface OpenApiSchemaPageData { |
| 7 | getSchema: () => { |
| 8 | bundled: { |
| 9 | paths?: Record< |
| 10 | string, |
| 11 | Record<string, { deprecated?: boolean } | undefined> | undefined |
| 12 | >; |
| 13 | }; |
| 14 | }; |
| 15 | } |
| 16 | |
| 17 | /** |
| 18 | * Removes the source-level deprecation suffix when a structured lifecycle |
| 19 | * badge is rendered alongside the title. Other contexts keep the raw OpenAPI |
| 20 | * title so they do not lose their only deprecation signal. |
| 21 | */ |
| 22 | export function getApiDisplayTitle(title: string, deprecated: boolean): string { |
| 23 | if (!deprecated) return title; |
| 24 | |
| 25 | return title.replace(/\s+\(deprecated\)\s*$/i, ''); |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * Returns whether any operation rendered by an OpenAPI page is deprecated. |
| 30 | * Operation detail pages currently contain one operation, but checking all of |
| 31 | * them keeps the helper correct for grouped pages too. |
| 32 | */ |
| 33 | export function isApiPageDeprecated( |
| 34 | pageData: OpenApiSchemaPageData, |
| 35 | operations?: ApiPageOperation[], |
| 36 | ): boolean { |
| 37 | if (!operations || operations.length === 0) return false; |
| 38 | |
| 39 | const schema = pageData.getSchema(); |
| 40 | const paths = schema.bundled.paths; |
| 41 | return operations.some( |
| 42 | ({ method, path }) => paths?.[path]?.[method]?.deprecated === true, |
| 43 | ); |
| 44 | } |