/** * Alternative API Specification Discovery Module (D-006) * * Automatically discovers alternative API specification formats: * - RAML (RESTful API Modeling Language) * - API Blueprint (Markdown-based) * - WADL (Web Application Description Language) * * This module: * 1. Probes common spec locations for each format * 2. Parses RAML, API Blueprint, and WADL specifications * 3. Extracts endpoints, methods, and parameters * 4. Generates API patterns for discovered endpoints * 5. Integrates with the Discovery Orchestrator */ import type { LearnedApiPattern } from '../types/api-patterns.js'; /** * Supported alternative specification formats */ export type AltSpecFormat = 'raml' | 'api-blueprint' | 'wadl'; /** * Parsed endpoint from any alternative spec */ export interface AltSpecEndpoint { /** HTTP method */ method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS'; /** Path with parameters */ path: string; /** Human-readable summary */ summary?: string; /** Description */ description?: string; /** Path parameters */ pathParams?: string[]; /** Query parameters */ queryParams?: string[]; /** Request body content type */ requestContentType?: string; /** Response content type */ responseContentType?: string; /** Response schema (if available) */ responseSchema?: Record; } /** * Parsed alternative specification */ export interface ParsedAltSpec { /** Format type */ format: AltSpecFormat; /** API title */ title: string; /** API version */ version?: string; /** API description */ description?: string; /** Base URL */ baseUrl?: string; /** Discovered endpoints */ endpoints: AltSpecEndpoint[]; /** When the spec was discovered */ discoveredAt: number; /** URL where the spec was found */ specUrl: string; } /** * Result of alternative spec discovery */ export interface AltSpecDiscoveryResult { /** Whether a spec was found */ found: boolean; /** The parsed spec if found */ spec?: ParsedAltSpec; /** URL where the spec was found */ specUrl?: string; /** Locations that were probed */ probedLocations: string[]; /** Time taken to discover (ms) */ discoveryTime: number; /** Error message if discovery failed */ error?: string; /** Format that was discovered */ format?: AltSpecFormat; } /** * Options for alternative spec discovery */ export interface AltSpecDiscoveryOptions { /** Maximum time to spend probing (ms) */ timeout?: number; /** Only probe these specific locations */ probeLocations?: string[]; /** Skip locations that match these patterns */ skipPatterns?: string[]; /** Headers to send with probe requests */ headers?: Record; /** Custom fetch function */ fetchFn?: (url: string, init?: RequestInit) => Promise; /** Only discover these formats */ formats?: AltSpecFormat[]; } /** * Common locations to probe for RAML specifications */ export declare const RAML_PROBE_LOCATIONS: readonly ["/api.raml", "/docs/api.raml", "/spec/api.raml", "/v1/api.raml", "/api/v1.raml", "/.well-known/api.raml"]; /** * Common locations to probe for API Blueprint specifications */ export declare const API_BLUEPRINT_PROBE_LOCATIONS: readonly ["/api.apib", "/docs/api.apib", "/api.md", "/docs/api.md", "/blueprint.apib", "/spec/api.apib", "/.well-known/api.apib"]; /** * Common locations to probe for WADL specifications */ export declare const WADL_PROBE_LOCATIONS: readonly ["/application.wadl", "/api/wadl", "/wadl", "/api/application.wadl", "/v1/application.wadl", "/.well-known/application.wadl"]; /** * Discover alternative API specifications for a domain * Tries RAML, API Blueprint, and WADL in order */ export declare function discoverAltSpecs(domain: string, options?: AltSpecDiscoveryOptions): Promise; /** * Generate LearnedApiPattern objects from an alternative spec */ export declare function generatePatternsFromAltSpec(spec: ParsedAltSpec, domain: string): LearnedApiPattern[]; /** * Get cached discovery result or discover anew * Uses unified discovery cache with tenant isolation and failed domain tracking */ export declare function discoverAltSpecsCached(domain: string, options?: AltSpecDiscoveryOptions): Promise; /** * Clear the spec cache * @param domain - Optional domain to clear, or all if not specified */ export declare function clearAltSpecCache(domain?: string): Promise; /** * Get cache statistics */ export declare function getAltSpecCacheStats(): Promise<{ size: number; domains: string[]; }>; //# sourceMappingURL=alt-spec-discovery.d.ts.map