···11import type { File } from './files/file';
22import type { BindingKind } from './symbols/types';
3344-export interface ImportSingle {
55- /** Whether this import is type-only. */
66- isTypeOnly: boolean;
77- /** Import flavor. */
88- kind: BindingKind;
99- /**
1010- * The name this symbol will have locally in this file.
1111- * This is where aliasing is applied:
1212- *
1313- * import { Foo as Foo$2 } from "./x"
1414- *
1515- * localName === "Foo$2"
1616- */
1717- localName: string;
1818- /** The exported name of the symbol in its source file. */
1919- sourceName: string;
2020-}
2121-2222-export interface ExportSingle {
44+export interface ExportMember {
235 /**
246 * Name under which the symbol is exported in this file.
257 *
···3618 sourceName: string;
3719}
38203939-export type ExportGroup = Pick<ExportSingle, 'isTypeOnly'> & {
2121+export type ExportModule = Pick<ExportMember, 'isTypeOnly'> & {
4022 /** Whether this module can export all symbols: `export * from 'module'`. */
4123 canExportAll: boolean;
4242- /** List of symbol exported from this module. */
4343- exports: Array<ExportSingle>;
2424+ /** Members exported from this module. */
2525+ exports: Array<ExportMember>;
4426 /** Source file. */
4527 from: File;
4628 /** Namespace export: `export * as ns from 'module'`. Mutually exclusive with `exports`. */
4729 namespaceExport?: string;
4830};
49315050-export type ImportGroup = Pick<ImportSingle, 'isTypeOnly'> & {
3232+export interface ImportMember {
3333+ /** Whether this import is type-only. */
3434+ isTypeOnly: boolean;
3535+ /** Import flavor. */
3636+ kind: BindingKind;
3737+ /**
3838+ * The name this symbol will have locally in this file.
3939+ * This is where aliasing is applied:
4040+ *
4141+ * import { Foo as Foo$2 } from "./x"
4242+ *
4343+ * localName === "Foo$2"
4444+ */
4545+ localName: string;
4646+ /** The exported name of the symbol in its source file. */
4747+ sourceName: string;
4848+}
4949+5050+export type ImportModule = Pick<ImportMember, 'isTypeOnly'> & {
5151 /** Source file. */
5252 from: File;
5353 /** List of symbols imported from this module. */
5454- imports: Array<ImportSingle>;
5454+ imports: Array<ImportMember>;
5555 /** Namespace import: `import * as name from 'module'`. Mutually exclusive with `imports`. */
5656 namespaceImport?: string;
5757};
+7-7
packages/codegen-core/src/files/file.ts
···11-import type { ExportGroup, ImportGroup } from '../bindings';
11+import type { ExportModule, ImportModule } from '../bindings';
22import { fileBrand } from '../brands';
33import { debug } from '../debug';
44import type { Language } from '../languages/types';
···1212 /**
1313 * Exports from this file.
1414 */
1515- private _exports: Array<ExportGroup> = [];
1515+ private _exports: Array<ExportModule> = [];
1616 /**
1717 * File extension (e.g. `.ts`).
1818 */
···2424 /**
2525 * Imports to this file.
2626 */
2727- private _imports: Array<ImportGroup> = [];
2727+ private _imports: Array<ImportModule> = [];
2828 /**
2929 * Language of the file.
3030 */
···7171 /**
7272 * Exports from this file.
7373 */
7474- get exports(): ReadonlyArray<ExportGroup> {
7474+ get exports(): ReadonlyArray<ExportModule> {
7575 return [...this._exports];
7676 }
7777···103103 /**
104104 * Imports to this file.
105105 */
106106- get imports(): ReadonlyArray<ImportGroup> {
106106+ get imports(): ReadonlyArray<ImportModule> {
107107 return [...this._imports];
108108 }
109109···154154 /**
155155 * Add an export group to the file.
156156 */
157157- addExport(group: ExportGroup): void {
157157+ addExport(group: ExportModule): void {
158158 this._exports.push(group);
159159 }
160160161161 /**
162162 * Add an import group to the file.
163163 */
164164- addImport(group: ImportGroup): void {
164164+ addImport(group: ImportModule): void {
165165 this._imports.push(group);
166166 }
167167
+4-4
packages/codegen-core/src/index.ts
···11export type {
22- ExportGroup,
33- ExportSingle,
44- ImportGroup,
55- ImportSingle,
22+ ExportMember,
33+ ExportModule,
44+ ImportMember,
55+ ImportModule,
66} from './bindings';
77export { nodeBrand, symbolBrand } from './brands';
88export { debug } from './debug';
+3-3
packages/codegen-core/src/planner/planner.ts
···11import path from 'node:path';
2233-import type { ExportGroup, ImportGroup } from '../bindings';
33+import type { ExportModule, ImportModule } from '../bindings';
44import type { IProjectRenderMeta } from '../extensions';
55import type { File } from '../files/file';
66import type { IFileIn } from '../files/types';
···174174 });
175175176176 for (const [file, fileMap] of seenByFile) {
177177- const exports = new Map<File, ExportGroup>();
177177+ const exports = new Map<File, ExportModule>();
178178 for (const [, entry] of fileMap) {
179179 const source = sourceFile.get(entry.symbol.id)!;
180180 let exp = exports.get(source);
···285285 });
286286287287 for (const [file, fileMap] of seenByFile) {
288288- const imports = new Map<File, ImportGroup>();
288288+ const imports = new Map<File, ImportModule>();
289289 for (const [, entry] of fileMap) {
290290 const source = entry.dep.file!;
291291 let imp = imports.get(source);
+7-1
packages/openapi-ts/src/ir/context.ts
···11-import { Project } from '@hey-api/codegen-core';
11+import { Project, simpleNameConflictResolver } from '@hey-api/codegen-core';
2233import type { Package } from '~/config/utils/package';
44import { packageFactory } from '~/config/utils/package';
···7070 this.config = config;
7171 this.gen = new Project({
7272 defaultFileName: 'index',
7373+ defaultNameConflictResolver(args) {
7474+ return simpleNameConflictResolver(args);
7575+ },
7376 fileName: (base) => {
7477 const name = buildName({
7578 config: config.output.fileName,
···8285 return name === 'index' || name.endsWith(suffix)
8386 ? name
8487 : `${name}${suffix}`;
8888+ },
8989+ nameConflictResolvers: {
9090+ // TODO: allow overriding via config
8591 },
8692 // TODO: allow overriding via config
8793 renderers: [
+3-3
packages/openapi-ts/src/ts-dsl/render/utils.ts
···11import path from 'node:path';
2233-import type { ExportGroup, File, ImportGroup } from '@hey-api/codegen-core';
33+import type { ExportModule, File, ImportModule } from '@hey-api/codegen-core';
44import ts from 'typescript';
5566const printer = ts.createPrinter({
···7676export type SortModule = string;
7777export type SortKey = [SortGroup, SortDistance, SortModule];
78787979-export type ModuleExport = Omit<ExportGroup, 'from'> & {
7979+export type ModuleExport = Omit<ExportModule, 'from'> & {
8080 /** Module specifier for re-exports, e.g. `./foo`. */
8181 modulePath: string;
8282};
83838484-export type ModuleImport = Omit<ImportGroup, 'from'> & {
8484+export type ModuleImport = Omit<ImportModule, 'from'> & {
8585 /** Module specifier for imports, e.g. `./foo`. */
8686 modulePath: string;
8787};