/** * Codegen extends-walk + inheritance merge (plan: * `.plans/refactor/queued/codegen-ast.md` · design: `docs/codegen-ast-approach.md`). * * Bridges the per-file `astExtract` reader to what the codegen front-end needs: * a controller's EFFECTIVE middleware (own map, or — matching JS static-getter * inheritance — the nearest ancestor that defines `static get middleware()`) plus * an emittable `binding → specifier` import map for those middlewares, resolved * across relative AND bare-package ancestors. * * This replaced `importResolution.ts` (since deleted). The hard part the regex * version paid for — recovering a binding from a live class by identity matching, * because the registry handed it class objects with no source path — is gone: * the binding IS the import-node name, read directly. What remains is pure path * math (was shared with the old emit): * - a relative ancestor's middleware imports are rebased to the child gen-file * directory (the gen file sits next to the controller); * - a bare-package ancestor's relative imports are rewritten into bare specifiers * rooted at that ancestor's package subpath (the public subpath tree mirrors * `src/`). * * When the controller's `routes` getter isn't a literal, `needsBoot` is set; the * controller can't be statically analyzed and `generateAll` throws (no fallback). */ import { type ExtractResult, type ImportInfo, type MiddlewareScope, type RouteInfo } from './astExtract.ts'; export interface ResolvedImport extends ImportInfo { /** The local binding the gen file emits (`import type from …`). */ binding: string; } /** Per-run cache of parsed sources by absolute path, so a shared ancestor * (e.g. `AbstractController`) is read + parsed once per generation run, not once * per controller. No mtime/persistence — content is stable within a run. */ export type ExtractCache = Map; export interface ResolvedController { className?: string; /** Mount path: the literal `getHttpPath()` return, else `/`. */ urlPrefix: string; routes: RouteInfo[]; /** `get routes()` has a return type annotation (see {@link ExtractResult}). */ routesAnnotated?: boolean; /** Effective middleware (own, or inherited from the nearest defining ancestor). */ middleware: MiddlewareScope[]; /** Emittable import for each middleware binding in `middleware`. */ imports: ResolvedImport[]; /** True when a getter / `getHttpPath` wasn't a literal — not analyzable (throws). */ needsBoot: boolean; reason?: string; } /** * Resolve a controller's routes + effective middleware + emittable imports. * `prefix` is the controller's folder relative to the controllers root (e.g. * `admin` for `controllers/admin/Users.ts`); it feeds the default mount path * exactly as the runtime loader does, so nested controllers mount correctly. */ export declare function resolveController(srcPath: string, prefix?: string, cache?: ExtractCache): Promise;