/** Build-time analysis of API usage in consumer-supplied TypeScript source. */ import type { ApiOperation } from "./operation-types.js"; /** Identity supplied by the generated SDK operation catalog. */ export type SourceApiOperation = Pick; /** A consumer's raw request wrapper, identified by its resolved function name. */ export type SourceApiRequest = { functionName: string; /** Zero-based argument containing the request path. */ pathArgument: number; /** Zero-based argument containing the options object. */ optionsArgument: number; /** Options property containing query parameters. Defaults to `query`. */ queryProperty?: string; /** Method when the options omit it. Defaults to GET; unknown spreads stay unknown. */ defaultMethod?: string; }; /** Consumer conventions; none of these lists are inferred from command names. */ export type SourceApiAnalysisOptions = { /** Factory names whose returned objects contain deferred callbacks. */ boundaries?: readonly string[]; /** Raw request wrappers to link to the operation catalog. */ requests?: readonly SourceApiRequest[]; /** Query keys to retain. The Sentry `query` key also retains fixed joined terms. */ queryParameters?: readonly string[]; /** Boolean property names to report when explicitly set to true. */ declarationFlags?: readonly string[]; }; /** An operation reachable from a source declaration. */ export type SourceOperationUsage = SourceApiOperation & { /** Known query values or fixed terms; callers may add further filters. */ query?: Record; }; /** A raw request whose identity cannot be established from the public catalog. */ export type UnresolvedApiRequest = { /** Source module, using the caller's source-map keys. */ file: string; /** One-based request call line. */ line: number; /** Known HTTP method, when statically available. */ method?: string; /** Known path template, when statically available. */ path?: string; /** Why no operation was selected. */ reason: string; }; /** Source-derived relationships; no command is executed to obtain them. */ export type SourceApiUsage = { /** Discovered API operations, preserving distinct contexts. */ operations: SourceOperationUsage[]; /** Reachable raw requests that need explicit discovery diagnostics. */ unresolvedRequests: UnresolvedApiRequest[]; /** Known HTTP methods, including unresolved requests and static method properties. */ methods: string[]; }; /** Source relationships and deferred callback boundaries; never executes input code. */ export type SourceApiAnalysis = { /** Source file → exported symbol → reachable API usage. */ exports: Map>; /** Exported boundaries and their consumer-selected factory/flag evidence. */ boundaries: { file: string; name: string; factories: string[]; flags: string[]; }[]; }; /** * Follow function references, imports and barrel exports to SDK calls or known * raw request wrappers. Dynamic paths remain diagnostics rather than guesses. * Boundary factories have their arguments inspected, without traversing the * factory's execution machinery. Reading their returned objects as data does * not inherit callback usage. Results describe static reachability, not a * complete execution trace; dynamic behavior may not be discoverable. */ export declare function analyzeSourceApiUsage(sources: ReadonlyMap, operations: readonly SourceApiOperation[], options?: SourceApiAnalysisOptions): SourceApiAnalysis;