@7nohe/openapi-react-query-codegen
Version:
OpenAPI React Query Codegen
52 lines (51 loc) • 2.31 kB
text/typescript
import type { PathLike } from "node:fs";
import { type ClassDeclaration, type ParameterDeclaration, type SourceFile, type VariableDeclaration } from "ts-morph";
import ts from "typescript";
import type { LimitedUserConfig } from "./cli.mjs";
export declare const capitalizeFirstLetter: (str: string) => string;
export declare const lowercaseFirstLetter: (str: string) => string;
export declare const getVariableArrowFunctionParameters: (variable: VariableDeclaration) => ParameterDeclaration[];
export declare const getNameFromVariable: (variable: VariableDeclaration) => string;
export type FunctionDescription = {
node: SourceFile;
method: VariableDeclaration;
methodBlock?: ts.Block;
httpMethodName: string;
jsDoc: string;
isDeprecated: boolean;
};
export declare function exists(f: PathLike): Promise<boolean>;
/**
* Build a common type name by prepending the Common namespace.
*/
export declare function BuildCommonTypeName(name: string | ts.Identifier): ts.Identifier;
/**
* Safely parse a value into a number. Checks for NaN and Infinity.
* Returns NaN if the string is not a valid number.
* @param value The value to parse.
* @returns The parsed number or NaN if the value is not a valid number.
*/
export declare function safeParseNumber(value: unknown): number;
export declare function extractPropertiesFromObjectParam(param: ParameterDeclaration): {
name: string;
optional: boolean;
type: import("ts-morph").Type<import("ts-morph").ts.Type> | undefined;
}[];
/**
* Replace the import("...") surrounding the type if there is one.
* This can happen when the type is imported from another file, but
* we are already importing all the types from that file.
*
* https://regex101.com/r/3DyHaQ/1
*
* TODO: Replace with a more robust solution.
*/
export declare function getShortType(type: string): string;
export declare function getClassesFromService(node: SourceFile): {
className: string;
klass: ClassDeclaration;
}[];
export declare function getClassNameFromClassNode(klass: ClassDeclaration): string;
export declare function formatOptions(options: LimitedUserConfig): LimitedUserConfig;
export declare function buildRequestsOutputPath(outputPath: string): string;
export declare function buildQueriesOutputPath(outputPath: string): string;