import { GeneratorArg, GeneratorContext, GeneratorFile, GeneratorFlag, GeneratorSpec, KickCliPlugin as KickCliPlugin$1, KickCliPluginContext as KickCliPluginContext$1, KickPluginConflictError, defineCliPlugin, defineGenerator } from "@forinda/kickjs-cli-kit"; import "commander"; //#region src/commands/add.d.ts type AppRuntime = 'express' | 'fastify' | 'h3'; //#endregion //#region src/commands/doctor.d.ts /** * `kick doctor` — pre-flight checks for a KickJS project's dev * environment. Detects common misconfigs before they bite, with an * actionable fix hint for each problem. * * Sibling command to `kick check --deploy`, which scans for production * readiness (JWT, CORS, helmet, etc.). Doctor is the dev-setup * counterpart — "is my environment correctly wired?" * * Extending: adopters can ship their own checks by exporting a * `doctor.checks` array from `kick.config.ts`. Each {@link DoctorCheck} * receives the same {@link DoctorContext} the built-ins use and * returns one or more {@link DoctorResult}s. The framework stays * ORM-agnostic — Prisma / Drizzle / Mongoose-specific checks belong * in their respective adapters or in adopter config, not in core. */ interface DoctorContext { cwd: string; pkg: any | null; /** * The project's tsconfig with its full `extends` chain already merged * into `compilerOptions`. `undefined` = no tsconfig.json; `null` = one * exists but couldn't be parsed. Checks should distinguish the two — * they call for different advice. */ tsconfig: any | null | undefined; /** * The project's HTTP runtime — from kick.config `runtime`, else sniffed from * deps, else `express`. Lets engine-aware checks (engine peers, the upload * multipart driver) validate against the right backend. */ runtime: AppRuntime; } interface DoctorResult { /** Short label for the check (printed first). */ name: string; status: 'pass' | 'warn' | 'fail'; /** Optional extra context after the label (e.g. resolved version). */ message?: string; /** Multi-line actionable fix shown when status is `warn` or `fail`. */ fix?: string; } type DoctorCheck = (ctx: DoctorContext) => DoctorResult | DoctorResult[] | null | Promise; /** * Shape of a doctor extension — the `doctor` block on `KickConfig`, * also the publishable unit that plugins and shared modules use to * ship a bundle of related checks. */ interface DoctorExtension { /** Extra checks merged after the built-ins. */ checks?: DoctorCheck[]; } /** * Identity helper for adopters / plugins authoring a doctor extension. * * Provides type inference + autocomplete on the `checks` array without * requiring an explicit `: DoctorExtension` annotation. Mirrors the * `defineConfig` pattern. * * @example * ```ts * // doctor-checks/prisma.ts (shared across projects, or shipped as a * // standalone package) * import { defineDoctorExtension } from '@forinda/kickjs-cli' * import { existsSync } from 'node:fs' * import { join } from 'node:path' * * export const prismaDoctor = defineDoctorExtension({ * checks: [ * (ctx) => { * if (!existsSync(join(ctx.cwd, 'prisma/schema.prisma'))) return null * const generated = join(ctx.cwd, 'node_modules/@prisma/client/default.js') * return existsSync(generated) * ? { name: 'Prisma client generated', status: 'pass' } * : { name: 'Prisma client generated', status: 'fail', fix: 'pnpm exec prisma generate' } * }, * ], * }) * * // kick.config.ts * import { defineConfig } from '@forinda/kickjs-cli' * import { prismaDoctor } from './doctor-checks/prisma' * * export default defineConfig({ doctor: prismaDoctor }) * ``` */ declare function defineDoctorExtension(ext: DoctorExtension): DoctorExtension; /** * Identity helper for a single doctor check. Pairs with * `defineDoctorExtension` when assembling an extension from separate * per-check files, and gives the same type-inference win for one-offs. * * @example * ```ts * import { defineDoctorCheck } from '@forinda/kickjs-cli' * * export const checkJwtSecretLength = defineDoctorCheck((ctx) => { * const v = process.env.JWT_SECRET * if (!v || v.length < 32) { * return { * name: 'JWT_SECRET ≥ 32 chars', * status: 'warn', * fix: 'Generate a strong secret: openssl rand -hex 32', * } * } * return { name: 'JWT_SECRET ≥ 32 chars', status: 'pass' } * }) * ``` */ declare function defineDoctorCheck(check: DoctorCheck): DoctorCheck; //#endregion //#region src/plugin/types.d.ts /** CLI plugin context with the host config narrowed to `KickConfig`. */ type KickCliPluginContext = KickCliPluginContext$1; /** A CLI plugin with the host config narrowed to `KickConfig`. */ type KickCliPlugin = KickCliPlugin$1; //#endregion //#region src/config.d.ts /** A custom command that developers can register via kick.config.ts */ interface KickCommandDefinition { /** The command name (e.g. 'db:migrate', 'seed', 'proto:gen') */ name: string; /** Description shown in --help */ description: string; /** * Shell command(s) to run. Can be a single string or an array of * sequential steps. Use {args} as a placeholder for CLI arguments. * * @example * 'npx drizzle-kit migrate' * ['npx drizzle-kit generate', 'npx drizzle-kit migrate'] */ steps: string | string[]; /** Optional aliases (e.g. ['migrate'] for 'db:migrate') */ aliases?: string[]; } /** Project pattern — controls what generators produce and which deps are installed */ type ProjectPattern = 'rest' | 'minimal'; /** Package manager used for `kick add` and other dep-installing commands */ type PackageManager = 'pnpm' | 'npm' | 'yarn' | 'bun'; /** * Built-in repository type with first-class code generation support. * * Only `inmemory` remains built-in (zero-dep, framework-owned). The * `prisma` and `drizzle` ORM presets are **deprecated** — they now * scaffold a generic custom-repository stub like any other name (see * {@link DEPRECATED_REPO_TYPES}). Bring your own DB by passing a name: * `repo: { name: 'postgres' }`. */ type BuiltinRepoType$1 = 'inmemory'; /** Custom repository type — generates a stub with TODO markers */ interface CustomRepoType { name: string; } /** Repository type — built-in string or custom object */ type RepoTypeConfig = BuiltinRepoType$1 | CustomRepoType; /** * Supported schema validators for `kick typegen` body/query/params * type extraction. * * - `'zod'` — emits `import('zod').infer` (default) * - `'kickjs-schema'` — emits `InferSchemaOutput` from * `@forinda/kickjs-schema`, works with Zod, Valibot, Yup, and any * Standard Schema v1 or KickSchema adapter * - `false` — disables schema-driven body typing (fields stay `unknown`) */ type SchemaValidator = 'zod' | 'kickjs-schema' | false; /** * One entry in the typed `assetMap` config record (`assets-plan.md`). * Each entry names a source directory whose files become addressable * via the `assets..*` typed accessor at runtime. */ interface AssetMapEntry { /** * Source directory, relative to project root. Required. The directory * must exist when `kick build` runs — `loadKickConfig` warns when an * entry points at a missing directory but doesn't fail the load * (the typegen + build steps surface the error in context instead). */ src: string; /** * Destination directory inside `dist/`. Defaults to `dist//` * where `` is the assetMap key. Override when the consumer of * the assets expects a non-standard layout (e.g. an existing * downstream tool reads from `dist/templates/...`). */ dest?: string; /** * Glob pattern for which files to include. Defaults to `**\/*` (all * files). Files that don't match are NOT copied — `assetMap` is * selective by design (unlike `copyDirs` which copies everything). */ glob?: string; /** * How file extensions feed into manifest keys. Default `'auto'`. * * - `'strip'` — drop the extension. `pages/index.pug` → * `'pages/index'`. Two siblings with the same basename collide; * last-walk-order wins, others are silently dropped. Opt-in * only — kept for backward compatibility with projects that * relied on this contract. * - `'with-extension'` — keep every extension on every key. Best * when the namespace holds extension siblings (`index.pug` + * `index.html` + `index.css` in `src/pages/`); every file * reaches the manifest under its full path. * - `'auto'` — strip when basenames are unique, keep extensions * on collision groups. Singleton files keep their short key; * `pages/index.{pug,html,css}` becomes * `pages/index.pug` / `pages/index.html` / `pages/index.css`. * No data loss; non-colliding namespaces stay on the short * keys they had before. * * @default 'auto' */ keys?: 'auto' | 'strip' | 'with-extension'; } /** * Database settings consumed by `kick db generate`, `kick db migrate`, * and the M4.C composite-type detection gate. Mirrors the runtime * `DbConfig` shape from `@forinda/kickjs-db` — duplicated here so * adopters who only install `@forinda/kickjs-cli` can set the block * without pulling `@forinda/kickjs-db` types into their kick.config.ts * resolution. The CLI loads kick.config.ts through `loadKickConfig`, * then `resolveDbConfig` re-reads this block from the same module and * normalises defaults (`schemaPath` / `migrationsDir` / `dialect`). * * @example * ```ts * defineConfig({ * db: { * schemaPath: 'src/db/schema.ts', * migrationsDir: 'db/migrations', * dialect: 'postgres', * connectionString: process.env.DATABASE_URL, * }, * }) * ``` */ interface KickDbConfigBlock { /** * Path to the schema module (`pgEnum` / `table` declarations). * Defaults to `'src/db/schema.ts'`. */ schemaPath?: string; /** * Where `kick db generate` writes migration directories. Defaults * to `'db/migrations'`. */ migrationsDir?: string; /** SQL dialect. Defaults to `'postgres'`. */ dialect?: 'postgres' | 'sqlite' | 'mysql'; /** * Postgres connection string for the built-in pgAdapter path. Read * from the `DATABASE_URL` env var when omitted. Used by * `kick db migrate*` and the M4.C composite-type gate at * `kick db generate`. */ connectionString?: string; /** * Escape hatch: a factory returning a fully-constructed * MigrationAdapter (typed loosely here so the CLI types don't pull * `@forinda/kickjs-db` into adopter projects that don't import it). * Takes precedence over `connectionString` when both are set. */ adapter?: () => unknown | Promise; } /** Typegen settings — controls .kickjs/types/* generation */ interface TypegenConfig { /** * Source directory to scan for controllers and decorators. * Defaults to `'src'`. */ srcDir?: string; /** * Output directory for generated `.d.ts` files. * Defaults to `'.kickjs/types'`. */ outDir?: string; /** * Schema validator used to derive `body` types from route metadata. * * - `'zod'` — emit `z.infer>` for any schema * referenced as a named identifier in `@Get/@Post/...({ body, query, params })`. * - `false` — disable schema-driven body typing. * * Future: `'joi' | 'yup' | 'json-schema'` plus a `{ name; module }` * escape hatch for custom adapters. * * @default 'zod' */ schemaValidator?: SchemaValidator; /** * Path to the project's env schema file (relative to project root). * Must default-export a `defineEnv(...)` schema for typegen to emit * the typed `KickEnv` global registry. * * Set to `false` to disable env typing entirely. * * @default 'src/env.ts' */ envFile?: string | false; /** * Built-in or user typegen plugin ids to skip during `kick typegen`, * `kick dev`, and `kick typegen --watch`. * * The plugin still loads and merge-time conflict detection still * runs — only the `generate()` invocation is skipped — so adopters * who want to hand-write `KickDbRegister` (manual typeof-schema * augmentation) can disable `'kick/db'` and keep the rest: * * @example * typegen: { * disable: ['kick/db'], // hand-written register.ts owns the type * } * * Unrecognised ids are ignored — the list is treated as a wishlist, * not a strict registry. */ disable?: string[]; } /** Module generation settings — controls how `kick g module` produces code */ interface ModuleConfig { /** Where modules live (default: 'src/modules') */ dir?: string; /** * Default repository implementation for generators. * * Built-in types (string): `'drizzle'`, `'inmemory'`, `'prisma'` * — generate fully working repository code. * * Custom types (object): `{ name: 'typeorm' }` * — generate a stub repository with TODO markers. * * @example * repo: 'prisma' // built-in * repo: { name: 'typeorm' } // custom */ repo?: RepoTypeConfig; /** Schema output directory (e.g. 'src/db/schema' for Drizzle, 'prisma/' for Prisma) */ schemaDir?: string; /** * Whether to pluralize module names in generated code. * When true (default), `kick g module user` creates `src/modules/users/`. * When false, it creates `src/modules/user/` and uses singular names throughout. */ pluralize?: boolean; /** * Import path for the Prisma generated client in `--repo prisma` templates. * Must resolve within `src/` for path alias compatibility. * * @default '@prisma/client' (Prisma 5/6) * @example * prismaClientPath: '@/generated/prisma/client' // Prisma 7+ * prismaClientPath: './generated/prisma/client' // relative */ prismaClientPath?: string; /** * Module declaration style emitted by `kick g module` and the * project scaffold. * * - `'define'` (default) — `defineModule({ name, build: () => ({...}) })` * factory form. Mirrors `defineAdapter` / `definePlugin` / * `defineContextDecorator`. * - `'class'` — legacy `class FooModule implements AppModule { ... }` * form. Still fully supported by the framework loader; pin to this * value for projects that prefer the class shape (existing-codebase * consistency, class-decorator setups, etc). * * The framework runtime accepts both shapes regardless of this * setting — the flag controls codegen output only. `kick g module` * inserts the matching call form into `src/modules/index.ts` * (`Module()` vs `Module`); `kick rm module` matches both. * * @default 'define' */ style?: 'define' | 'class'; } /** Configuration for the kick.config.ts file */ interface KickConfig { /** * Project pattern — controls default generator behavior. * - 'rest' — Express + Swagger (default) * - 'ddd' — Full DDD modules with use cases, entities, value objects * - 'cqrs' — CQRS with commands, queries, events, WebSocket + queue * - 'minimal' — Bare Express with no scaffolding */ pattern?: ProjectPattern; /** * Module generation settings — directory, repo type, pluralization, schema dir. * * @example * modules: { * dir: 'src/modules', * repo: 'prisma', * pluralize: false, * schemaDir: 'prisma/', * } */ modules?: ModuleConfig; /** * Package manager used by `kick add` (and any future dep-installing command) * to install dependencies. When set, overrides lockfile auto-detection so * commands always use the project's intended package manager. * * Priority (highest first): * 1. `--pm` flag on the CLI * 2. `packageManager` in kick.config * 3. `packageManager` field in package.json (corepack convention) * 4. Lockfile detection (pnpm-lock.yaml → pnpm, yarn.lock → yarn) * 5. `'npm'` * * @example * packageManager: 'pnpm' */ packageManager?: PackageManager; /** * The HTTP runtime the app boots on — the engine passed to * `bootstrap({ runtime })`. Written by `kick new --runtime`, and read by * dep-aware commands so they install / validate the engine-correct peers: * - `kick add upload` picks the multipart driver (express → `multer`, * fastify → `@fastify/multipart`, h3 → built-in, no driver) * - `kick doctor` checks the engine peers + upload driver are present * - the `kick/runtime` typegen emits the `KickRuntimeRegister` augmentation * that flips the runtime-typed escape hatches (`AdapterContext.app`, * `getRuntimeApp()`) to the engine's native types * * Defaults to `'express'` when unset (the default engine). * * @example * runtime: 'fastify' */ runtime?: 'express' | 'fastify' | 'h3'; /** * DI token scope prefix used by code generators. Every scaffolded * `createToken('//')` substitutes this string * for ``. Generators emit org-scoped tokens out of the box * so adopter projects pass `kick-lint`'s `token-reserved-prefix` * rule (which forbids the reserved `kick/` prefix on third-party * code) without manual rename. * * Resolution order (highest first): * 1. This field, when set * 2. `package.json` `name` field — `@scope/pkg` → `'scope'`, * bare `pkg` → `'pkg'` * 3. Fallback `'app'` * * @example * tokenScope: 'mycorp' * // → createToken<...>('mycorp/users/repository') */ tokenScope?: string; /** * Directories to copy to dist/ after build. * Useful for EJS templates, email templates, static assets, etc. * * @example * ```ts * copyDirs: [ * 'src/views', // copies to dist/src/views * { src: 'src/views', dest: 'dist/views' }, // custom dest * 'src/emails', * ] * ``` */ copyDirs?: Array; /** * Build output settings. The asset manager + `kick build`'s copy * steps honour these — adopters who use Vite's `build.outDir = * 'out'` (or any non-default) should mirror the value here so * `assets.x.y()` paths line up with where Vite actually wrote. * * @example * ```ts * build: { outDir: 'out' } * ``` */ build?: { /** * Output directory, relative to project root. Defaults to * `'dist'`. The asset manager emits its manifest + copies * assetMap entries into this directory (under a per-namespace * subdirectory by default; override per-entry via `dest`). */ outDir?: string; }; /** * Typed, addressable assets — see `assets-plan.md`. Each entry maps * a logical namespace name to a source directory. The build pipeline * auto-derives the necessary copy step + emits a manifest at * `dist/.kickjs-assets.json`; the runtime exposes * `import { assets } from '@forinda/kickjs'` so adopters can resolve * paths without dev/prod branching. * * `copyDirs` is unchanged — `assetMap` is a separate, opt-in surface. * Adopters who want raw directory copies keep using `copyDirs`; those * who want typed addressable assets add `assetMap` entries. * * @example * ```ts * assetMap: { * mails: { src: 'src/templates/mails' }, * reports: { src: 'src/templates/reports', glob: '**\/*.{ejs,html}' }, * schemas: { src: 'src/schemas', glob: '**\/*.json' }, * } * ``` */ assetMap?: Record; /** * Typegen settings — controls `.kickjs/types/*` generation including * the schema validator used for body type extraction. * * @example * ```ts * typegen: { * schemaValidator: 'zod', * } * ``` */ typegen?: TypegenConfig; /** * Dev-server (`kick dev`) settings. */ dev?: { /** * Run the project's TypeScript checker (`tsgo --noEmit`, falling * back to `tsc --noEmit`) after each debounced change and surface * diagnostics in the dev console + a `kickjs:typecheck` HMR event. * Equivalent to the `kick dev --typecheck` flag. * * @default false */ typecheck?: boolean; }; /** * Database settings — schema path, migrations dir, dialect, * connection string, optional adapter factory. Consumed by * `kick db generate` / `kick db migrate*`. See {@link KickDbConfigBlock}. */ db?: KickDbConfigBlock; /** Custom commands that extend the CLI */ commands?: KickCommandDefinition[]; /** * CLI plugins — bundled commands + typegens contributed by external * packages (e.g. `@forinda/kickjs-cli-drizzle`). Plugin commands * appear first; adopter `commands` overrides plugin commands of the * same name. Duplicate commands or typegen ids across two plugins * fail-fast at CLI startup. * * @example * import { drizzlePlugin } from '@forinda/kickjs-cli-drizzle' * export default defineConfig({ * plugins: [drizzlePlugin({ schemaPath: 'src/db/schema' })], * }) */ plugins?: KickCliPlugin[]; /** Code style overrides (auto-detected from prettier when possible) */ style?: { semicolons?: boolean; quotes?: 'single' | 'double'; trailingComma?: 'all' | 'es5' | 'none'; indent?: number; }; /** * Extensibility hook for `kick doctor`. Adopters add their own * environment / project-shape checks here; each function receives * the same context the built-in checks see and returns a result (or * `null` to skip). * * The framework stays ORM- and stack-agnostic — Prisma-specific, * Drizzle-specific, deploy-target-specific checks belong in adopter * config (or in adapter packages that ship doctor extensions), * never in core. * * @example * ```ts * import { existsSync } from 'node:fs' * import { join } from 'node:path' * import { defineConfig } from '@forinda/kickjs-cli' * * export default defineConfig({ * doctor: { * checks: [ * (ctx) => { * if (!existsSync(join(ctx.cwd, 'prisma/schema.prisma'))) return null * const generated = join(ctx.cwd, 'node_modules/@prisma/client/default.js') * return existsSync(generated) * ? { name: 'Prisma client generated', status: 'pass' } * : { * name: 'Prisma client generated', * status: 'fail', * fix: 'Run: pnpm exec prisma generate', * } * }, * ], * }, * }) * ``` */ doctor?: DoctorExtension; } /** Helper to define a type-safe kick.config.ts */ declare function defineConfig(config: KickConfig): KickConfig; /** * Load `kick.config.*` starting from `startDir` and walking up toward * the filesystem root until a config file is found. Returns `null` * when no config exists anywhere on the way up. * * Walking up means adopters can run `kick ` from any subdirectory * (e.g. `src/modules/users/`) and still pick up the project's config — * before this change a nested-cwd invocation silently saw `null` and * fell back to framework defaults. * * TypeScript configs (`.ts`) are loaded via `jiti` when available; * `.js` / `.mjs` use native `import()`; `.json` uses `JSON.parse`. The * jiti import is dynamic + best-effort: if the dep is missing we * surface a warning telling the adopter how to install it, instead of * silently dropping the config (which is what the previous bare-catch * did). */ declare function loadKickConfig(startDir: string): Promise; //#endregion //#region src/generators/templates/types.d.ts /** * Module declaration style emitted by the module-index templates. * * - `'define'` — `defineModule({ name, build: () => ({...}) })` * factory form. The recommended pattern; matches `defineAdapter` * / `definePlugin` / `defineContextDecorator` parity. * - `'class'` — legacy `class FooModule implements AppModule { ... }` * form. Still fully supported by the framework loader; pin via * `kick.config.ts > modules.style: 'class'` for projects that * prefer the class shape (existing codebase consistency, custom * class-decorator setups, etc.). * * Default `'define'` for new code. The `kick g module` orchestrator * inserts the matching shape into `src/modules/index.ts` (`Module()` * vs `Module`); `kick rm module` matches both. */ type ModuleStyle = 'define' | 'class'; //#endregion //#region src/generators/module.d.ts type BuiltinRepoType = 'inmemory'; type RepoType = BuiltinRepoType | (string & {}); interface GenerateModuleOptions { name: string; modulesDir: string; noEntity?: boolean; noTests?: boolean; repo?: RepoType; minimal?: boolean; force?: boolean; pattern?: ProjectPattern; dryRun?: boolean; /** When false, skip pluralization — use singular names for folders, routes, and classes */ pluralize?: boolean; /** Prisma client import path (default: '@prisma/client', Prisma 7+: '@/generated/prisma/client') */ prismaClientPath?: string; /** * DI-token scope prefix substituted into emitted `createToken()` * literals. Resolved by the orchestrating command from * `kick.config.ts > tokenScope` or the project's package.json. * Falls back to `'app'` when not set so the generator can be called * without a config in tests/fixtures. */ tokenScope?: string; /** * Module declaration style — `'define'` (factory, default) or * `'class'` (legacy). Resolved by the orchestrating command from * `kick.config.ts > modules.style`. */ style?: ModuleStyle; } /** * Generate a module — structure depends on the project pattern. * * Patterns: * rest — flat folder: controller + service + DTOs + repo (default) * minimal — just controller + module index */ declare function generateModule(options: GenerateModuleOptions): Promise; //#endregion //#region src/generators/adapter.d.ts interface GenerateAdapterOptions { name: string; outDir: string; } /** * Scaffold a `defineAdapter()` factory under `src/adapters/.adapter.ts`. * * v4 dropped the `class implements AppAdapter` pattern in favour of the * `defineAdapter()` factory (architecture.md §21.3.4). The generated * template uses the new factory shape so adopters get a working * adapter with all four lifecycle hooks (beforeMount, beforeStart, * afterStart, shutdown), a typed config object with defaults, and the * factory's call / `.scoped()` / `.async()` surfaces — without * writing a single class. */ declare function generateAdapter(options: GenerateAdapterOptions): Promise; //#endregion //#region src/generators/middleware.d.ts interface GenerateMiddlewareOptions { name: string; outDir?: string; moduleName?: string; modulesDir?: string; pattern?: ProjectPattern; pluralize?: boolean; /** * The engine from `kick.config.ts`. Global middleware is connect-style on * every runtime, but only Express hands the handler an `express.Request` — * Fastify passes `request.raw` and h3 the node objects, so `node:http` is * the honest type there (and those projects have no `express` dependency to * import types from). */ runtime?: KickConfig['runtime']; } declare function generateMiddleware(options: GenerateMiddlewareOptions): Promise; //#endregion //#region src/generators/guard.d.ts interface GenerateGuardOptions { name: string; outDir?: string; moduleName?: string; modulesDir?: string; pattern?: ProjectPattern; pluralize?: boolean; } declare function generateGuard(options: GenerateGuardOptions): Promise; //#endregion //#region src/generators/service.d.ts interface GenerateServiceOptions { name: string; outDir?: string; moduleName?: string; modulesDir?: string; pattern?: ProjectPattern; pluralize?: boolean; } declare function generateService(options: GenerateServiceOptions): Promise; //#endregion //#region src/generators/controller.d.ts interface GenerateControllerOptions { name: string; outDir?: string; moduleName?: string; modulesDir?: string; pattern?: ProjectPattern; pluralize?: boolean; } declare function generateController(options: GenerateControllerOptions): Promise; //#endregion //#region src/generators/dto.d.ts interface GenerateDtoOptions { name: string; outDir?: string; moduleName?: string; modulesDir?: string; pattern?: ProjectPattern; pluralize?: boolean; } declare function generateDto(options: GenerateDtoOptions): Promise; //#endregion //#region src/generators/project.d.ts type ProjectTemplate = 'rest' | 'minimal'; type SchemaLib = 'zod' | 'valibot' | 'yup'; interface InitProjectOptions { name: string; directory: string; packageManager?: 'pnpm' | 'npm' | 'yarn' | 'bun'; initGit?: boolean; installDeps?: boolean; template?: ProjectTemplate; defaultRepo?: string; packages?: string[]; /** Schema library to scaffold env / DTOs with. Defaults to `zod`. */ schemaLib?: SchemaLib; /** HTTP engine to scaffold. Defaults to `express`. */ runtime?: 'express' | 'fastify' | 'h3'; /** Wire `SpaAdapter` at this clientDir (fullstack template). */ spaClientDir?: string; } /** Scaffold a new KickJS project */ declare function initProject(options: InitProjectOptions): Promise; //#endregion //#region src/utils/project-root.d.ts /** * Walk up from `startDir` looking for the project root. A directory * counts as the root when it contains any of: * - `kick.config.{ts,js,mjs,json}` (strongest signal) * - `package.json` (fallback when no config file exists yet) * * Returns the absolute path of the first matching directory, or * `startDir` itself when nothing was found (no surprises — callers * that didn't find a config still get a reasonable cwd). * * `kick.config.*` wins over `package.json` when both appear at * different levels, so adopters running `kick typegen` from `src/` * land on the project root that owns the config, not on the nearest * workspace package boundary in a monorepo. */ declare function findProjectRoot(startDir?: string): string; //#endregion //#region src/typegen/scanner.d.ts /** * Static scanner for KickJS decorated classes and DI tokens. * * Walks `src/**\/*.ts` (excluding tests and node_modules) and extracts: * * - Decorated classes (`@Service`, `@Controller`, `@Repository`, etc.) * - `createToken('name')` definitions * - `@Inject('literal')` calls * * The output feeds the type generator, which emits `.kickjs/types/*.d.ts` * files used by the user's tsc to make `container.resolve()` and module * discovery type-safe. * * This is intentionally regex-based (not AST-based) to avoid the * ts-morph / typescript compiler dependency. Pattern from * `packages/vite/src/module-discovery.ts` which already uses regex * to detect `*.module.ts` exports. * * ## Collision detection * * Two classes with the same name across different files is a collision. * The scanner records all collisions in `ScanResult.collisions` so the * caller (generator) can decide whether to hard-error or auto-namespace. * * @module @forinda/kickjs-cli/typegen/scanner */ /** Decorators that mark a class as DI-managed */ declare const DECORATOR_NAMES: readonly ['Service', 'Controller', 'Repository', 'Injectable', 'Component', 'Module']; type DecoratorName = (typeof DECORATOR_NAMES)[number]; /** A single discovered decorated class */ interface DiscoveredClass { /** Class name (e.g., 'UserService') */ className: string; /** Decorator that marked it (e.g., 'Service') */ decorator: DecoratorName; /** Absolute file path */ filePath: string; /** Path relative to scan root, with forward slashes */ relativePath: string; /** True if exported as `default` */ isDefault: boolean; } /** A single route handler discovered on a controller class */ interface DiscoveredRoute { /** Owning controller class name (e.g. 'UserController') */ controller: string; /** Handler method name on the controller (e.g. 'getUser') */ method: string; /** HTTP verb (uppercase) */ httpMethod: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'; /** Route path including parameter placeholders (e.g. '/:id/posts/:postId') */ path: string; /** URL path parameter names extracted from `:placeholder` segments */ pathParams: string[]; /** * Whitelisted query field names extracted from `@ApiQueryParams({...})`. * `null` means no `@ApiQueryParams` was found on this method (so the * generator emits an unconstrained `query` shape). An empty array means * the decorator existed but no fields could be statically extracted * (e.g. an opaque imported config). */ queryFilterable: string[] | null; querySortable: string[] | null; querySearchable: string[] | null; /** * Schema identifiers referenced from the route decorator's second arg * (e.g. `@Post('/', { body: createTaskSchema })`). `null` means no * such reference; the value carries the identifier and the resolved * import source (relative module path) if known. */ bodySchema: SchemaRef | null; querySchema: SchemaRef | null; paramsSchema: SchemaRef | null; /** * Declared response contract from the route decorator * (`@Get('/', { response: schema })`). When present it WINS over * return-type inference in the emitted `response` field — and the same * declaration drives the Swagger success-response schema. */ responseSchema?: SchemaRef | null; /** Absolute file path of the controller */ filePath: string; /** Path relative to scan root, with forward slashes */ relativePath: string; /** * True when the controller class is `export default` — the response * typegen hoists `import type { default as _Cn }` instead of a named * import. Optional so regex-path extraction and old fixtures stay valid. */ controllerIsDefaultExport?: boolean; /** * Module-mount-joined path (`/tasks/:id` for a controller mounted at * `/tasks` with `@Get('/:id')`). Excludes the bootstrap `/api/v{n}` * prefix (not statically scannable). The KickRoutes.Api flat map keys * on this — the bare `path` would collide across controllers and 404 * against real URLs. Optional for old fixtures; falls back to `path`. */ mountedPath?: string; /** * Every decorator applied to this route's method or its controller * class, minus the HTTP verb decorators. Unclassified on purpose — the * join phase decides which are context contributors, which are known * framework decorators, and which are unrecognised (and therefore make * the route's key set unprovable). */ appliedDecorators?: DecoratorRef[]; /** * Union of context keys proven populated for this route, or `null` when * completeness could not be established. `null` is emitted as `string` * (no narrowing) — never as an empty union, which would wrongly reject * every `ctx.require()` call on the route. */ contextKeys?: string[] | null; } /** A decorator as written at a call site, with its import resolved. */ interface DecoratorRef { /** The decorator's local binding name, e.g. `LoadTenant`. */ identifier: string; /** * Module specifier it was imported from; `''` when declared in the same * file, `null` when the binding could not be resolved at all. */ source: string | null; } /** A statically-resolved schema identifier reference */ interface SchemaRef { /** The identifier as written (e.g. `createTaskSchema`) */ identifier: string; /** * Resolved module specifier (relative path or bare module name) where * the identifier is defined. `null` means the source could not be * statically determined (the generator falls back to `unknown`). */ source: string | null; } /** A `createToken('name')` call discovered in source */ interface DiscoveredToken { /** The literal string passed to `createToken()` */ name: string; /** The const variable name on the LHS, if any */ variable: string | null; /** Absolute file path */ filePath: string; /** Path relative to scan root, with forward slashes */ relativePath: string; } /** An `@Inject('literal')` call discovered in source */ interface DiscoveredInject { /** The literal string passed to `@Inject()` */ name: string; /** Absolute file path */ filePath: string; /** Path relative to scan root, with forward slashes */ relativePath: string; } /** A name collision — same class name in two or more files */ interface ClassCollision { /** The colliding class name */ className: string; /** All files declaring the class */ classes: DiscoveredClass[]; } /** * Information about a discovered env schema file. The typegen * generator uses this to emit a `KickEnv` + `NodeJS.ProcessEnv` * augmentation that flows through to `@Value` and `process.env`. * * `null` means no env file was found at the configured location. */ interface DiscoveredEnv { /** Absolute path to the env schema file */ filePath: string; /** Path relative to scan root, with forward slashes */ relativePath: string; } /** * A plugin or adapter discovered in source — either via `defineAdapter({ name })` * / `definePlugin({ name })` calls, or via a class that `implements AppAdapter` * and declares a string-literal `name` field. * * The `name` here is the literal string passed to the framework (the value * `dependsOn` references), NOT the symbol on the LHS. `defineAdapter` lets * authors choose any name they want; the symbol is irrelevant at runtime. */ interface DiscoveredPluginOrAdapter { /** Whether this is a plugin (`definePlugin`) or adapter (`defineAdapter` / class) */ kind: 'plugin' | 'adapter'; /** The string literal passed as `name` (the value `dependsOn` references) */ name: string; /** Absolute file path */ filePath: string; /** Path relative to scan root, with forward slashes */ relativePath: string; } /** * A context key discovered from a `defineContextDecorator({ key })` or * `defineHttpContextDecorator({ key })` call (including the curried * `.withParams

()({ key })` form). Feeds the `kick/context` typegen * plugin, which emits the `ContextKeys` augmentation so `dependsOn` * typo-checking is automatic and complete. */ interface DiscoveredContextKey { /** The literal `key:` value the contributor writes. */ key: string; /** * The binding the decorator was assigned to — `LoadTenant` for * `export const LoadTenant = defineHttpContextDecorator({ key: 'tenant' })`. * * `null` when the call isn't a simple `const X = …` initialiser (inline * in an array, returned from a factory, …). Needed to map an applied * `@LoadTenant` decorator back to the key it populates, which is what * lets per-route context-key narrowing work at all; a `null` binding * simply can't be resolved from a decorator site, so routes using it * degrade to unnarrowed rather than guessing. */ exportName: string | null; /** Absolute file path. */ filePath: string; /** Path relative to scan root, with forward slashes. */ relativePath: string; } /** * A `defineAugmentation('Name', meta)` call discovered in source. Plugins * call this to advertise an augmentable interface so the typegen can list * every augmentation surface in one generated file. */ interface DiscoveredAugmentation { /** The literal string passed as the first arg to `defineAugmentation` */ name: string; /** Optional `description` extracted from the second-arg object literal */ description: string | null; /** Optional `example` extracted from the second-arg object literal */ example: string | null; /** Absolute file path */ filePath: string; /** Path relative to scan root, with forward slashes */ relativePath: string; } /** * A decorated class whose file sits inside a module directory but * isn't picked up by any of the module's `import.meta.glob(...)` * patterns. Surfaced as a typegen warning per forinda/kick-js#235 §4 * so adopters notice silent registration drift before it bites them * at runtime with a `MissingContributorError` or wrong code path. */ interface OrphanedClass { /** The decorated class name */ className: string; /** Absolute path of the class file */ filePath: string; /** Path relative to scan root, with forward slashes */ relativePath: string; /** Absolute path of the module file whose globs didn't match */ moduleFilePath: string; /** The decorator name (`Service`, `Controller`, `Repository`, …) */ decorator: DecoratorName; } /** Aggregated scanner output */ interface ScanResult { classes: DiscoveredClass[]; routes: DiscoveredRoute[]; tokens: DiscoveredToken[]; injects: DiscoveredInject[]; collisions: ClassCollision[]; /** Discovered env schema file (or null if none found at the configured path) */ env: DiscoveredEnv | null; /** Plugins/adapters discovered via `defineAdapter`/`definePlugin`/`implements AppAdapter` */ pluginsAndAdapters: DiscoveredPluginOrAdapter[]; /** Augmentation interfaces declared via `defineAugmentation('Name', meta)` */ augmentations: DiscoveredAugmentation[]; /** Context keys from `define(Http)ContextDecorator({ key })` calls */ contextKeys: DiscoveredContextKey[]; /** * Decorated classes that sit inside a module directory but aren't * picked up by any of the module's `import.meta.glob(...)` patterns. * Empty when every decorator file is matched. forinda/kick-js#235 §4. */ orphanedClasses: OrphanedClass[]; } /** Options for the scanner */ interface ScanOptions { /** Root directory to scan (e.g., absolute path to `src`) */ root: string; /** Project root used to compute relative paths (e.g., process.cwd()) */ cwd: string; /** Glob-like extensions to scan */ extensions?: string[]; /** Substrings that exclude a path (matched against relative path) */ exclude?: string[]; /** * Path to the env schema file, relative to `cwd`. Defaults to * `'src/env.ts'`. The file must contain a `defineEnv(...)` call * with a default export for the typegen to emit a typed `KickEnv` * augmentation. If the file does not exist or doesn't match the * expected shape, env typing is skipped silently. */ envFile?: string; /** * Directory for the persistent per-file extraction cache. When set, * unchanged files (matched by `mtimeMs:size` signature) are served * from `/scan.json` instead of being re-read and re-scanned. * Omit to disable caching (every scan is a cold read — the original * behaviour). Typically `/.kickjs/cache`. */ cacheDir?: string; } /** A precise set of filesystem changes, as reported by a watcher. */ interface ScanDelta { /** Files added or modified since the last scan (absolute or cwd-relative). */ changed: string[]; /** Files deleted since the last scan. */ removed: string[]; } //#endregion //#region src/typegen/plugin.d.ts interface TypegenLogger { info(msg: string): void; warn(msg: string): void; error(msg: string): void; } interface TypegenContext { cwd: string; config: KickConfig; /** Dynamic-import a TS module (Node loader). Used by plugins that need to * read the adopter's schema / route map / asset registry at generate time. */ importTs(absPath: string): Promise; /** Write under `cwd`. Caller passes a relPath (e.g. `.kickjs/types/foo.d.ts`). */ writeFile(relPath: string, contents: string): Promise; /** * Run `scanProject` once per typegen pass, memoizing the result so * multiple plugins (`kick/routes`, `kick/env`, future adopter plugins) * share a single fs walk + AST extraction. * * The runner uses an order-independent cache key derived from the * resolved options (`root`, `cwd`, `extensions`, `exclude`, `envFile`) * — semantically equal options hit the cache regardless of how the * caller built the literal. (We deliberately don't `JSON.stringify` * the options for caching since that would be sensitive to property * insertion order.) Plugins that don't need scanner data can ignore * this method entirely. * * Implementation lives in the runner so test harnesses can inject * a stub scanner; plugins only see the function. */ getScanResult(opts: ScanOptions): Promise; log: TypegenLogger; } interface TypegenPlugin { /** Stable id — used as filename: `.kickjs/types/${id}` (slashes → `__`). */ id: string; /** Glob patterns the Vite watcher subscribes to; change → re-run this plugin. */ inputs: string[]; /** * Output filename extension. Default `.d.ts` — the right choice for * pure module-augmentation plugins (kick/db, kick/assets) since * declaration files don't need the runtime-import dance. * * `kick/routes` overrides to `.ts` because it emits hoisted * `import type {...} from '...'` lines at the top of the file. Inline * `import('...').X` references inside `.d.ts` silently degrade to * `unknown` under `moduleResolution: 'bundler'`; emitting `.ts` * sidesteps that quirk and gets full type resolution. * * Adopter-supplied plugins should leave this unset unless they hit * the same hoisted-import constraint. */ outExtension?: string; /** * Return the augmentation source (without banner — runner prepends). * Return null to skip emission (e.g. no schema file present). */ generate(ctx: TypegenContext): Promise; } interface TypegenPluginResult { id: string; status: 'written' | 'unchanged' | 'skipped' | 'error' | 'drifted'; outFile?: string; } /** * Identity factory for {@link TypegenPlugin}. Returns the spec verbatim. * Exists for type inference and forward-compatibility — future * fields can be added with defaults without breaking adopters. * * Mirrors {@link defineGenerator} ergonomics. Use at the call site so * the plugin's `generate(ctx)` body gets a fully-typed `ctx` without * an explicit annotation: * * @example * ```ts * import { defineTypegen } from '@forinda/kickjs-cli' * * export const drizzleTypegen = defineTypegen({ * id: 'drizzle', * inputs: ['src/db/schema.ts'], * async generate(ctx) { * const schema = await ctx.importTs(`${ctx.cwd}/src/db/schema.ts`) * return `// declare module …` * }, * }) * ``` */ declare function defineTypegen(spec: TypegenPlugin): TypegenPlugin; //#endregion //#region src/typegen/token-conventions.d.ts interface TokenConventionWarning { token: string; variable: string | null; filePath: string; reason: string; suggestion?: string; } //#endregion //#region src/typegen/index.d.ts /** * Result of a typegen run — useful for logging and tests. Computed from * the scan result + asset discovery; the per-file emission itself is now * owned entirely by the typegen plugins (see `builtin/`). */ interface GenerateResult { /** Number of registry-decorated classes (KickJsRegistry entries) */ registryEntries: number; /** Number of unique service tokens (classes + createToken + @Inject literals) */ serviceTokens: number; /** Number of module tokens */ moduleTokens: number; /** Number of route entries */ routeEntries: number; /** Number of unique plugin/adapter names */ pluginEntries: number; /** Number of unique `defineAugmentation` calls */ augmentationEntries: number; /** Number of typed asset entries */ assetEntries: number; /** Whether a typed env augmentation will be emitted */ envWritten: boolean; /** Files written this pass (barrel + plugin outputs), for the sweep */ written: string[]; /** Number of collisions (only > 0 with allowDuplicates) */ resolvedCollisions: number; } /** Options for `runTypegen` */ interface RunTypegenOptions { /** Project root (defaults to `process.cwd()`) */ cwd?: string; /** Source directory to scan (defaults to `src`) */ srcDir?: string; /** Output directory (defaults to `.kickjs/types`) */ outDir?: string; /** Suppress console output */ silent?: boolean; /** * Patch module `import.meta.glob(...)` calls in place to cover decorated * classes the scanner flags as orphaned (their file isn't imported by any * module glob, so the decorator never fires at runtime). Wired to * `kick typegen --fix`. Off by default — diagnostics only. */ fix?: boolean; /** * When `true`, duplicate class names are auto-namespaced by file path * instead of throwing. `kick dev` enables this so the dev server is * never blocked by an in-progress rename. CLI default is `false` so * `kick typegen` (and CI) catches collisions early. */ allowDuplicates?: boolean; /** * Disable the persistent per-file scan cache (`.kickjs/cache/scan.json`). * Every file is re-read + re-extracted from cold. Escape hatch for the * rare `mtimeMs:size` signature collision (a file edited so fast its * mtime + size are unchanged) where the cache would serve a stale * extract. Wired to `kick typegen --no-cache` / `kick dev --no-typegen-cache`. */ noCache?: boolean; /** * Schema validator used to derive `body`/`query`/`params` types from * route metadata. Currently only `'zod'` is supported; `false` (the * default) leaves these fields as `unknown`. Loaded from * `kick.config.ts` `typegen.schemaValidator` when invoked via the CLI. */ schemaValidator?: 'zod' | 'kickjs-schema' | false; /** * Path to the env schema file (relative to `cwd`). The file must * default-export a `defineEnv(...)` schema for the typed `KickEnv` * augmentation to be emitted. Defaults to `'src/env.ts'`. Set to * `false` to disable env typing entirely. */ envFile?: string | false; /** * Asset map from `kick.config.ts`. When set, `runTypegen` walks * each entry's `src` directory + emits `.kickjs/types/assets.d.ts` * augmenting `KickAssets` for autocomplete on `assets.x.y()` and * `@Asset('x/y')`. Omit to skip the asset typegen pass entirely. */ assetMap?: Record; /** * Whether `runTypegen` should also run the TypegenPlugin pipeline * (`runAllPluginTypegens`) after the legacy generator pass. Defaults * to `true` so single-shot callers (kick g, commands/typegen, tests) * keep getting a fully-refreshed `.kickjs/types/` from one entry * point. `watchTypegen` flips this to `false` because it manages * the plugin pass itself + would otherwise double-run it on every * filesystem trigger. */ runPlugins?: boolean; /** * Exact watcher delta (Vite chokidar events). When present, the scan * runs incrementally — re-extracting only the changed files and * skipping the directory walk — and the same delta is forwarded to * the plugin pass. `kick dev` supplies this on every file change. */ changedFiles?: ScanDelta; } /** * Run a single typegen pass: scan source files, generate `.d.ts` files. * * Returns the discovered scan result alongside the generation result so * callers (`kick dev`, devtools) can log them or feed them to other tools. * * Throws `TokenCollisionError` if duplicate class names are found and * `allowDuplicates` is false. */ declare function runTypegen(opts?: RunTypegenOptions): Promise<{ scan: ScanResult; result: GenerateResult; /** Token convention warnings — empty when every literal matches §22.2. */ tokenWarnings: TokenConventionWarning[]; }>; /** * Post-plugin-pass finalisation: write the `.kickjs/.gitignore` guard * and sweep stale legacy files. Shared by `runTypegen` (single-shot * mode) and the split-mode callers (`kick typegen` / `kick dev` / * watch) so the artifact-writing + sweep stay identical across both. * * No barrel `index.d.ts` is emitted: the scaffolded tsconfig pulls * `.kickjs/types/**` in via `include` globs, so every `declare module` * / `declare global` augmentation in the per-plugin files applies by * inclusion. The old barrel + its `ServiceToken`/`ModuleToken` * re-exports were redundant; they're swept as legacy orphans. * * Returns the list of files considered "written" this pass (the plugin * outputs) for the caller's bookkeeping. */ declare function writeTypegenArtifacts(outDir: string, pluginResults: readonly TypegenPluginResult[], silent: boolean): Promise; //#endregion //#region src/typegen/run-plugins.d.ts interface RunAllPluginTypegensOptions { cwd: string; /** Pre-loaded kick.config.ts (saves a re-read). */ config: KickConfig | null; /** Suppress per-plugin status logging. Errors still swallowed when true. */ silent?: boolean; /** CI gate — fail (do not write) on the first plugin whose output drifted. */ check?: boolean; /** * Exact watcher delta. Forwarded to the scanner so the plugin pass * scans incrementally (changed files only) instead of re-walking the * whole tree. Used by `kick dev`'s file-change handler. */ changedFiles?: ScanDelta; } declare function runAllPluginTypegens(opts: RunAllPluginTypegensOptions): Promise; //#endregion //#region src/asset-manager/build.d.ts /** Wire-format version for `dist/.kickjs-assets.json`. Bump on shape change. */ declare const ASSET_MANIFEST_VERSION: 1; /** On-disk manifest format (`dist/.kickjs-assets.json`). */ interface AssetManifest { version: typeof ASSET_MANIFEST_VERSION; /** * Logical key → manifest-relative path. Logical key is * `/` where `` is the file path under `src` * with the extension stripped + path separators normalised. * * Path values are relative to the manifest file's directory so the * runtime can resolve them with a single `path.resolve(manifestDir, * entry)` regardless of where dist/ lives. */ entries: Record; } interface BuildAssetsOptions { /** Project root — resolved for every relative path in the entry. */ cwd: string; /** * Output dir for the manifest + per-namespace asset copies. When * omitted, falls back to `config.build?.outDir` (resolved against * `cwd`), then to `dist/` under cwd. Adopters with a custom Vite * `build.outDir` should set `kick.config.ts.build.outDir` to match. */ distDir?: string; /** Suppress per-entry log lines. Default: false. */ silent?: boolean; } /** One entry in the per-build summary returned by `buildAssets`. */ interface BuildAssetsEntryResult { namespace: string; src: string; dest: string; /** * Number of files actually written this run. On an incremental * rebuild where nothing changed this is 0 even though the manifest * still lists every matched file. */ filesCopied: number; } /** Aggregated outcome of `buildAssets`. */ interface BuildAssetsResult { manifestPath: string; entries: BuildAssetsEntryResult[]; /** `entries` merged into a single record — useful for tests + tooling. */ manifest: AssetManifest; } /** * Run the full asset build for a loaded config: * * 1. For each `assetMap` entry, glob → copy → manifest stub. * 2. Write `dist/.kickjs-assets.json`. * * Returns a summary including the manifest contents. No-op (and no * manifest written) when `assetMap` is empty / missing — the build * pipeline shouldn't litter `dist/` with empty manifests for * adopters who don't use the feature. */ declare function buildAssets(config: KickConfig | null, opts: BuildAssetsOptions): Promise; //#endregion //#region src/typegen/dev-watcher.d.ts /** * `globalThis` key claiming typegen ownership for the current process. * Set by `kick dev` (which boots Vite in-process) so the vite plugin's * own watcher never double-runs the pipeline. */ declare const TYPEGEN_OWNER_KEY = "__kickjs_typegen_owner"; type TypegenWatchEvent = 'add' | 'change' | 'unlink' | 'unlinkDir'; /** Injectable pipeline — production uses the real functions. */ interface TypegenDevPipeline { runTypegen: typeof runTypegen; runAllPluginTypegens: typeof runAllPluginTypegens; writeTypegenArtifacts: typeof writeTypegenArtifacts; buildAssets: typeof buildAssets; } interface TypegenDevWatcherOptions { cwd: string; /** Pre-loaded kick.config.ts (null when the project has none). */ config: KickConfig | null; /** * Warning sink — wired by the caller to `console.warn` plus whatever * HMR broadcast it has (e.g. the `kickjs:typegen-error` custom event). */ emitWarning: (message: string) => void; /** * Invoked after each pass's plugin chain settles (success or failure). * `kick dev` uses it to schedule the `--typecheck` worker against * fresh `.kickjs/types`. */ onPassComplete?: () => void; /** Debounce window in ms. @default 100 */ debounceMs?: number; /** Test seam — defaults to the real typegen pipeline. */ pipeline?: TypegenDevPipeline; } interface TypegenDevWatcher { /** Feed a chokidar-style watcher event into the debounce window. */ handleWatchEvent(event: TypegenWatchEvent, file: string): void; /** * Run one full (non-incremental) pass immediately — startup catch-up * for callers that didn't run typegen before the server booted. */ runOnce(): void; /** * Absolute `assetMap..src` roots. Vite's default watcher ignores * extensions it doesn't compile, so callers should `watcher.add(...)` * these to receive template-file events at all. */ assetSrcRoots: readonly string[]; /** Cancel any pending debounced pass. */ dispose(): void; } declare function createTypegenDevWatcher(opts: TypegenDevWatcherOptions): TypegenDevWatcher; //#endregion //#region src/generator-extension/discover.d.ts /** * One row in the discovered registry. `source` is the npm package name * the generator came from — surfaced in error messages so adopters can * see which plugin owns a given generator. */ interface DiscoveredGenerator { source: string; spec: GeneratorSpec; } /** * Plugin discovery result, kept around even when no generators were * registered so callers can distinguish "no plugins installed" from * "no plugins matched the requested name." */ interface DiscoveryResult { generators: DiscoveredGenerator[]; /** Packages whose `kickjs.generators` was loaded successfully. */ loaded: string[]; /** * Packages we tried to load but failed — typically a missing entry * file or a default export that wasn't an array of GeneratorSpec. */ failed: Array<{ source: string; reason: string; }>; } //#endregion //#region src/generator-extension/context.d.ts /** * Build a {@link GeneratorContext} from the raw name + invocation * arguments. Centralises the case-transformation logic so every plugin * generator sees the same shape regardless of how the name was typed * on the command line (`Post` vs `post` vs `user_post`). */ declare function buildGeneratorContext(input: { name: string; args?: string[]; flags?: Record; modulesDir?: string; cwd?: string; /** * Resolved project root. When omitted, derived from {@link cwd} via * `findProjectRoot()` so adopter-facing call sites stay zero-config. * Callers that already know the root (e.g. `cli.ts` after one upfront * resolution) should pass it through to avoid redundant fs walks. */ projectRoot?: string; pluralize?: boolean; }): GeneratorContext; //#endregion //#region src/utils/naming.d.ts /** Convert a name to PascalCase */ declare function toPascalCase(name: string): string; /** Convert a name to camelCase */ declare function toCamelCase(name: string): string; /** Convert a name to kebab-case */ declare function toKebabCase(name: string): string; /** * Pluralize a kebab-case name for directory/file names. * Uses the `pluralize` npm package for correct English pluralization * including irregulars (person → people, status → statuses, child → children). */ declare function pluralize(name: string): string; //#endregion export { type DiscoveredGenerator, type DiscoveryResult, type DoctorCheck, type DoctorContext, type DoctorExtension, type DoctorResult, type GeneratorArg, type GeneratorContext, type GeneratorFile, type GeneratorFlag, type GeneratorSpec, type KickCliPlugin, type KickCliPluginContext, type KickCommandDefinition, type KickConfig, type KickDbConfigBlock, KickPluginConflictError, TYPEGEN_OWNER_KEY, type TypegenContext, type TypegenDevWatcher, type TypegenDevWatcherOptions, type TypegenPlugin, type TypegenPluginResult, type TypegenWatchEvent, buildGeneratorContext, createTypegenDevWatcher, defineCliPlugin, defineConfig, defineDoctorCheck, defineDoctorExtension, defineGenerator, defineTypegen, findProjectRoot, generateAdapter, generateController, generateDto, generateGuard, generateMiddleware, generateModule, generateService, initProject, loadKickConfig, pluralize, toCamelCase, toKebabCase, toPascalCase }; //# sourceMappingURL=index.d.mts.map