adk-typescript
Version:
TypeScript port of Google's Agent Development Kit (ADK)
96 lines (95 loc) • 2.96 kB
TypeScript
import { ApiParameter } from '../common/common';
/**
* Generates parameters for TypeScript functions from an OpenAPI operation.
*
* This class processes an OpenApiOperation object and provides helper methods
* to extract information needed to generate TypeScript function declarations,
* docstrings, signatures, and JSON schemas. It handles parameter processing,
* name deduplication, and type hint generation.
*/
export declare class OperationParser {
/**
* The OpenAPI operation
*/
operation: any;
/**
* Parameters for the operation
*/
params: ApiParameter[];
/**
* Return value for the operation
*/
returnValue: ApiParameter | null;
/**
* Initializes the OperationParser with an OpenApiOperation.
*
* @param operation The OpenApiOperation object or a dictionary to process
* @param shouldParse Whether to parse the operation during initialization
*/
constructor(operation: any, shouldParse?: boolean);
/**
* Creates an OperationParser with pre-defined params and return value
*
* @param operation The OpenApiOperation object
* @param params Parameters for the operation
* @param returnValue Return value for the operation
* @returns A new OperationParser instance
*/
static load(operation: any, params: ApiParameter[], returnValue?: ApiParameter | null): OperationParser;
/**
* Processes parameters from the OpenAPI operation
*/
private _processOperationParameters;
/**
* Processes the request body from the OpenAPI operation
*/
private _processRequestBody;
/**
* Deduplicates parameter names to avoid conflicts
*/
private _dedupeParamNames;
/**
* Processes the return value from the OpenAPI operation
*/
private _processReturnValue;
/**
* Returns the generated function name
* @returns The function name
*/
getFunctionName(): string;
/**
* Returns the return type hint string (like 'string', 'number', etc.)
* @returns The return type hint
*/
getReturnTypeHint(): string;
/**
* Returns the return type value
* @returns The return type value
*/
getReturnTypeValue(): any;
/**
* Returns the list of Parameter objects
* @returns The parameters
*/
getParameters(): ApiParameter[];
/**
* Returns the return value Parameter object
* @returns The return value
*/
getReturnValue(): ApiParameter | null;
/**
* Returns the name of the auth scheme for this operation from the spec
* @returns The auth scheme name
*/
getAuthSchemeName(): string;
/**
* Returns the generated JSDoc string
* @returns The JSDoc string
*/
getJSDocString(): string;
/**
* Returns the JSON schema for the function arguments
* @returns The JSON schema
*/
getJsonSchema(): Record<string, any>;
}