UNPKG

@kubb/core

Version:

Core functionality for Kubb's plugin-based code generation system, providing the foundation for transforming OpenAPI specifications.

127 lines (118 loc) 4.26 kB
import { a as PossiblePromise } from './PluginManager-PDmRCu9k.js'; export { P as ParserModule, d as createFile, b as createFileExport, c as createFileImport, e as createFileParser, g as getDefaultBanner, a as getFileParser } from './parser-C1vOjVEd.js'; import './types-CA8nQKwM.js'; import './logger-BWq-oJU_.js'; import 'consola/utils'; import 'consola'; type FunctionParamsASTWithoutType = { name?: string; type?: string; /** * @default true */ required?: boolean; /** * @default true */ enabled?: boolean; default?: string; }; type FunctionParamsASTWithType = { name?: never; type: string; /** * @default true */ required?: boolean; /** * @default true */ enabled?: boolean; default?: string; }; /** * @deprecated */ type FunctionParamsAST = FunctionParamsASTWithoutType | FunctionParamsASTWithType; /** * @deprecated */ declare class FunctionParams { #private; constructor(); get items(): FunctionParamsAST[]; add(item: FunctionParamsAST | Array<FunctionParamsAST | FunctionParamsAST[] | undefined> | undefined): FunctionParams; static toObject(items: FunctionParamsAST[]): FunctionParamsAST; static toString(items: (FunctionParamsAST | FunctionParamsAST[])[]): string; toObject(): FunctionParamsAST; toString(): string; } declare function isPromise<T>(result: PossiblePromise<T>): result is Promise<T>; declare function isPromiseFulfilledResult<T = unknown>(result: PromiseSettledResult<unknown>): result is PromiseFulfilledResult<T>; declare function isPromiseRejectedResult<T>(result: PromiseSettledResult<unknown>): result is Omit<PromiseRejectedResult, 'reason'> & { reason: T; }; declare function renderTemplate<TData extends Record<string, unknown> = Record<string, unknown>>(template: string, data?: TData | undefined): string; declare function timeout(ms: number): Promise<unknown>; declare function getUniqueName(originalName: string, data: Record<string, number>): string; declare function setUniqueName(originalName: string, data: Record<string, number>): string; type URLObject = { url: string; params?: Record<string, string>; }; type ObjectOptions = { type?: 'path' | 'template'; replacer?: (pathParam: string) => string; stringify?: boolean; }; type Options = { casing?: 'camelcase'; }; declare class URLPath { #private; path: string; constructor(path: string, options?: Options); /** * Convert Swagger path to URLPath(syntax of Express) * @example /pet/{petId} => /pet/:petId */ get URL(): string; get isURL(): boolean; /** * Convert Swagger path to template literals/ template strings(camelcase) * @example /pet/{petId} => `/pet/${petId}` * @example /account/monetary-accountID => `/account/${monetaryAccountId}` * @example /account/userID => `/account/${userId}` */ get template(): string; get object(): URLObject | string; get params(): Record<string, string> | undefined; toObject({ type, replacer, stringify }?: ObjectOptions): URLObject | string; /** * Convert Swagger path to template literals/ template strings(camelcase) * @example /pet/{petId} => `/pet/${petId}` * @example /account/monetary-accountID => `/account/${monetaryAccountId}` * @example /account/userID => `/account/${userId}` */ toTemplateString({ prefix, replacer }?: { prefix?: string; replacer?: (pathParam: string) => string; }): string; getParams(replacer?: (pathParam: string) => string): Record<string, string> | undefined; /** * Convert Swagger path to URLPath(syntax of Express) * @example /pet/{petId} => /pet/:petId */ toURLPath(): string; } declare class Cache<T> { #private; get(key: string): Promise<T | null>; set(key: string, value: T): Promise<void>; delete(key: string): Promise<void>; clear(): Promise<void>; keys(): Promise<string[]>; values(): Promise<T[]>; flush(): Promise<void>; } export { Cache, FunctionParams, type FunctionParamsAST, type URLObject, URLPath, getUniqueName, isPromise, isPromiseFulfilledResult, isPromiseRejectedResult, renderTemplate, setUniqueName, timeout };