typescript-scaffolder
Version:
 ### Unit Test Coverage: 97.12%
64 lines • 3.09 kB
TypeScript
import { RetryOptions } from "models/retry-definitions";
/**
* Builds the canonical retry-wrapper function name for a given generated endpoint function.
*
* The generator will use this to derive wrapper import symbols like:
* requestWithRetry_GET_person, requestWithRetry_GET_ALL_person, etc.
*
* Keeping this logic centralized ensures consistent naming across imports,
* helper file generation, and call sites.
*
* @param functionName - The generated endpoint function name (e.g., "GET_person").
* @returns The wrapper name (e.g., "requestWithRetry_GET_person").
*/
export declare function buildRetryWrapperName(functionName: string): string;
/**
* Generic retry loop implementation.
* Endpoint-specific generated wrappers should delegate to this, binding the concrete response type.
*
* NOTE: This function is exported for the generator's emitted helper module to import.
* It is not intended to be imported directly by end users.
*
* @param attempt - thunk that performs the request and returns a Promise of a typed AxiosResponse-like object
* @param opts - retry configuration
*/
export declare function requestWithRetryImpl<T>(attempt: () => Promise<T>, opts: RetryOptions): Promise<T>;
/**
* Builds a single exported wrapper function for a given endpoint, binding the concrete response type.
*
* Example output:
* export function requestWithRetry_GET_person(
* attempt: () => Promise<AxiosResponse<Person>>,
* opts: RetryOptions
* ): Promise<AxiosResponse<Person>> {
* return requestWithRetryImpl<AxiosResponse<Person>>(attempt, opts);
* }
*
* This returns a TypeScript code snippet (string) that the generator can place into
* the per-API helper module (e.g., person_api.requestWithRetry.ts).
*
* @param functionName - The generated endpoint function name (e.g., "GET_person").
* @param responseType - The concrete response type name (e.g., "Person" or "PersonList").
*/
export declare function buildEndpointRetryWrapperExport(functionName: string, responseType: string): string;
/**
* Returns the source text for the generic retry implementation that should be
* embedded into each generated helper module (e.g., <fileBase>.requestWithRetry.ts).
*
* NOTE: We embed this code so that generated output has no runtime dependency on the generator.
* The embedded implementation must stay in sync with requestWithRetryImpl in this module.
*/
export declare function buildRetryHelperImplSource(): string;
/**
* Adds all imports needed by <fileBase>.requestWithRetry.ts using ts-morph,
* mirroring the style used by addClientRequiredImports in client-constructors.ts.
*
* - import type { AxiosResponse } from 'axios'
* - import type { RetryOptions } from 'typescript-scaffolder'
* - grouped type-only imports for concrete response types (deduped by module)
*/
export declare function addRetryHelperImportsToSourceFile(sourceFile: import('ts-morph').SourceFile, typeImports: Array<{
typeName: string;
moduleSpecifier: string;
}>, retryDefsModule?: string): void;
//# sourceMappingURL=retry-constructors.d.ts.map