@kubb/core
Version:
Core functionality for Kubb's plugin-based code generation system, providing the foundation for transforming OpenAPI specifications.
133 lines (130 loc) • 4.26 kB
text/typescript
type BasePath<T extends string = string> = `${T}/`;
type Import = {
/**
* Import name to be used
* @example ["useState"]
* @example "React"
*/
name: string | Array<string | {
propertyName: string;
name?: string;
}>;
/**
* Path for the import
* @example '@kubb/core'
*/
path: string;
/**
* Add `type` prefix to the import, this will result in: `import type { Type } from './path'`.
*/
isTypeOnly?: boolean;
isNameSpace?: boolean;
/**
* When root is set it will get the path with relative getRelativePath(root, path).
*/
root?: string;
};
type Source = {
name?: string;
value?: string;
isTypeOnly?: boolean;
/**
* Has const or type 'export'
* @default false
*/
isExportable?: boolean;
/**
* When set, barrel generation will add this
* @default false
*/
isIndexable?: boolean;
};
type Export = {
/**
* Export name to be used.
* @example ["useState"]
* @example "React"
*/
name?: string | Array<string>;
/**
* Path for the import.
* @example '@kubb/core'
*/
path: string;
/**
* Add `type` prefix to the export, this will result in: `export type { Type } from './path'`.
*/
isTypeOnly?: boolean;
/**
* Make it possible to override the name, this will result in: `export * as aliasName from './path'`.
*/
asAlias?: boolean;
};
type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`;
type Mode = 'single' | 'split';
/**
* Name to be used to dynamicly create the baseName(based on input.path)
* Based on UNIX basename
* @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
*/
type BaseName = `${string}.${string}`;
/**
* Path will be full qualified path to a specified file
*/
type Path = string;
type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`;
type OptionalPath = Path | undefined | null;
type File<TMeta extends object = object> = {
/**
* Name to be used to create the path
* Based on UNIX basename, `${name}.extname`
* @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
*/
baseName: BaseName;
/**
* Path will be full qualified path to a specified file
*/
path: AdvancedPath<BaseName> | Path;
sources: Array<Source>;
imports?: Array<Import>;
exports?: Array<Export>;
/**
* Use extra meta, this is getting used to generate the barrel/index files.
*/
meta?: TMeta;
banner?: string;
footer?: string;
};
type ResolvedImport = Import;
type ResolvedExport = Export;
type ResolvedFile<TMeta extends object = object> = File<TMeta> & {
/**
* @default object-hash
*/
id: string;
/**
* Contains the first part of the baseName, generated based on baseName
* @link https://nodejs.org/api/path.html#pathformatpathobject
*/
name: string;
extname: Extname;
imports: Array<ResolvedImport>;
exports: Array<ResolvedExport>;
};
type types_AdvancedPath<T extends BaseName = BaseName> = AdvancedPath<T>;
type types_BaseName = BaseName;
type types_Export = Export;
type types_Extname = Extname;
type types_File<TMeta extends object = object> = File<TMeta>;
type types_Import = Import;
type types_Mode = Mode;
type types_OptionalPath = OptionalPath;
type types_Path = Path;
type types_ResolvedExport = ResolvedExport;
type types_ResolvedFile<TMeta extends object = object> = ResolvedFile<TMeta>;
type types_ResolvedImport = ResolvedImport;
type types_Source = Source;
declare namespace types {
export type { types_AdvancedPath as AdvancedPath, types_BaseName as BaseName, types_Export as Export, types_Extname as Extname, types_File as File, types_Import as Import, types_Mode as Mode, types_OptionalPath as OptionalPath, types_Path as Path, types_ResolvedExport as ResolvedExport, types_ResolvedFile as ResolvedFile, types_ResolvedImport as ResolvedImport, types_Source as Source };
}
export { type BaseName as B, type Extname as E, type File as F, type Import as I, type Mode as M, type OptionalPath as O, type Path as P, type ResolvedFile as R, type ResolvedImport as a, type Export as b, type ResolvedExport as c, types as t };