UNPKG

kubernetes-fluent-client

Version:

A @kubernetes/client-node fluent API wrapper that leverages K8s Server Side Apply.

125 lines 5.54 kB
import { GenerateOptions } from "./generate.js"; import { CustomResourceDefinition } from "./upstream.js"; type CRDResult = { name: string; crd: CustomResourceDefinition; version: string; }; type ClassContextResult = { line: string; insideClass: boolean; braceBalance: number; }; /** * Performs post-processing on generated TypeScript files. * * @param allResults The array of CRD results. * @param opts The options for post-processing. */ export declare function postProcessing(allResults: CRDResult[], opts: GenerateOptions): Promise<void>; /** * Creates a map linking each file to its corresponding CRD result. * * @param allResults - The array of CRD results. * @returns A map linking file names to their corresponding CRD results. */ export declare function mapFilesToCRD(allResults: CRDResult[]): Record<string, CRDResult>; /** * Processes the list of files, applying CRD post-processing to each. * * @param files - The list of file names to process. * @param fileResultMap - A map linking file names to their corresponding CRD results. * @param opts - Options for the generation process. */ export declare function processFiles(files: string[], fileResultMap: Record<string, CRDResult>, opts: GenerateOptions): Promise<void>; /** * Handles the processing of a single file: reading, modifying, and writing back to disk. * * @param filePath - The path to the file to be processed. * @param fileResult - The associated CRD result for this file. * @param fileResult.name - The name of the schema. * @param fileResult.crd - The CustomResourceDefinition object. * @param fileResult.version - The version of the CRD. * @param opts - Options for the generation process. */ export declare function processAndModifySingleFile(filePath: string, fileResult: CRDResult, opts: GenerateOptions): void; /** * Processes the TypeScript file content, applying wrapping and property modifications. * * @param content The content of the TypeScript file. * @param name The name of the schema. * @param crd The CustomResourceDefinition object. * @param version The version of the CRD. * @param opts The options for processing. * @returns The processed TypeScript file content. */ export declare function applyCRDPostProcessing(content: string, name: string, crd: CustomResourceDefinition, version: string, opts: GenerateOptions): string; /** * Retrieves the properties of the `GenericKind` class, excluding dynamic properties like `[key: string]: any`. * * @returns An array of property names that belong to `GenericKind`. */ export declare function getGenericKindProperties(): string[]; /** * Collects interface names from TypeScript file lines. * * @param lines The lines of the file content. * @returns A set of found interface names. */ export declare function collectInterfaceNames(lines: string[]): Set<string>; /** * Identifies whether a line declares a class that extends `GenericKind`. * * @param line The current line of code. * @returns True if the line defines a class that extends `GenericKind`, false otherwise. */ export declare function isClassExtendingGenericKind(line: string): boolean; /** * Adjusts the brace balance to determine if the parser is within a class definition. * * @param line The current line of code. * @param braceBalance The current balance of curly braces. * @returns The updated brace balance. */ export declare function updateBraceBalance(line: string, braceBalance: number): number; /** * Wraps the generated TypeScript file with fluent client elements (`GenericKind` and `RegisterKind`). * * @param lines The generated TypeScript lines. * @param name The name of the schema. * @param crd The CustomResourceDefinition object. * @param version The version of the CRD. * @param npmPackage The NPM package name for the fluent client. * @returns The processed TypeScript lines. */ export declare function wrapWithFluentClient(lines: string[], name: string, crd: CustomResourceDefinition, version: string, npmPackage?: string): string[]; /** * Processes the lines of the TypeScript file, focusing on classes extending `GenericKind`. * * @param lines The lines of the file content. * @param genericKindProperties The list of properties from `GenericKind`. * @param foundInterfaces The set of found interfaces in the file. * @returns The processed lines. */ export declare function processLines(lines: string[], genericKindProperties: string[], foundInterfaces: Set<string>): string[]; /** * Processes a single line inside a class extending `GenericKind`. * * @param line The current line of code. * @param insideClass Whether we are inside a class context. * @param braceBalance The current brace balance to detect when we exit the class. * @param genericKindProperties The list of properties from `GenericKind`. * @param foundInterfaces The set of found interfaces in the file. * @returns An object containing the updated line, updated insideClass flag, and braceBalance. */ export declare function processClassContext(line: string, insideClass: boolean, braceBalance: number, genericKindProperties: string[], foundInterfaces: Set<string>): ClassContextResult; /** * Handles logging for errors with stack trace. * * @param error The error object to log. * @param filePath The path of the file being processed. * @param logFn The logging function. */ export declare function logError(error: Error, filePath: string, logFn: (msg: string) => void): void; export {}; //# sourceMappingURL=postProcessing.d.ts.map