{"version":3,"sources":["/home/pitok/Projects/framework-bun/packages/buntok-core/dist/cli/index.cjs","../../src/cli/commands/build.ts","../../src/cli/commands/check.ts","../../src/cli/commands/create.ts","../../src/cli/generators/controller.ts","../../src/cli/generators/repository.ts","../../src/cli/generators/service.ts","../../src/cli/commands/db.ts","../../src/cli/commands/init.ts","../../src/cli/commands/make-docs.ts","../../node_modules/@asteasolutions/zod-to-openapi/dist/index.mjs","../../src/cli/index.ts"],"names":["join","existsSync","result","_a","referencedSchema","registry"],"mappings":"AAAA;AACA;AACE;AACA;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACF,yDAA8B;AAC9B;AACA;ACbA,4BAAqB;AACrB,wBAA2B;AAE3B,MAAA,SAAsB,YAAA,CAAA,EAAe;AACpC,EAAA,MAAM,YAAA,EAAc,OAAA,CAAQ,GAAA,CAAI,CAAA;AAChC,EAAA,MAAM,WAAA,EAAa,wBAAA,WAAK,EAAa,WAAW,CAAA;AAChD,EAAA,MAAM,OAAA,EAAS,wBAAA,WAAK,EAAa,SAAS,CAAA;AAE1C,EAAA,GAAA,CAAI,CAAC,4BAAA,UAAqB,CAAA,EAAG;AAC5B,IAAA,OAAA,CAAQ,KAAA,CAAM,2CAAsC,CAAA;AACpD,IAAA,OAAA,CAAQ,SAAA,EAAW,CAAA;AACnB,IAAA,MAAA;AAAA,EACD;AAGA,EAAA,IAAI,SAAA,EAAqB,CAAC,CAAA;AAC1B,EAAA,MAAM,QAAA,EAAU,wBAAA,WAAK,EAAa,cAAc,CAAA;AAChD,EAAA,GAAA,CAAI,4BAAA,OAAkB,CAAA,EAAG;AACxB,IAAA,MAAM,IAAA,EAAM,MAAM,GAAA,CAAI,IAAA,CAAK,OAAO,CAAA,CAAE,IAAA,CAAK,CAAA;AACzC,IAAA,SAAA,EAAW;AAAA,MACV,GAAG,MAAA,CAAO,IAAA,CAAK,GAAA,CAAI,aAAA,GAAgB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ACyB,MAAA;AAC7B,MAAA;AACI,IAAA;AACkB,MAAA;AACtB,MAAA;AACQ,IAAA;AACS,MAAA;AAChB,QAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACD,MAAA;AAEyB,MAAA;AAGvB,QAAA;AAGF,MAAA;AACuB,MAAA;AAAyC,uBAAA;AAClD,MAAA;AACH,MAAA;AACQ,MAAA;AACnB,MAAA;AACD,IAAA;AACD,EAAA;AACD;AAEK;AX+gFyC;AACA;AACA","file":"/home/pitok/Projects/framework-bun/packages/buntok-core/dist/cli/index.cjs","sourcesContent":[null,"import { join } from \"node:path\";\nimport { existsSync } from \"node:fs\";\n\nexport async function buildCommand() {\n\tconst projectRoot = process.cwd();\n\tconst entryPoint = join(projectRoot, \"server.ts\");\n\tconst outDir = join(projectRoot, \".buntok\");\n\n\tif (!existsSync(entryPoint)) {\n\t\tconsole.error(\"\\x1b[31m❌ server.ts not found\\x1b[0m\");\n\t\tprocess.exitCode = 1;\n\t\treturn;\n\t}\n\n\t// Read user's package.json to know their dependencies\n\tlet userDeps: string[] = [];\n\tconst pkgPath = join(projectRoot, \"package.json\");\n\tif (existsSync(pkgPath)) {\n\t\tconst pkg = await Bun.file(pkgPath).json();\n\t\tuserDeps = [\n\t\t\t...Object.keys(pkg.dependencies || {}),\n\t\t\t...Object.keys(pkg.devDependencies || {}),\n\t\t];\n\t}\n\n\t// BunTok peer deps (optional, user installs these)\n\tconst peerDeps = [\n\t\t\"@apollo/server\",\n\t\t\"graphql\",\n\t\t\"graphql-yoga\",\n\t\t\"@opentelemetry/api\",\n\t\t\"@opentelemetry/sdk-node\",\n\t\t\"@opentelemetry/resources\",\n\t\t\"@opentelemetry/semantic-conventions\",\n\t\t\"@opentelemetry/sdk-trace-node\",\n\t\t\"@opentelemetry/exporter-trace-otlp-http\",\n\t\t\"ioredis\",\n\t\t\"bullmq\",\n\t\t\"amqplib\",\n\t];\n\n\tconst external = [...new Set([...peerDeps, ...userDeps])];\n\n\tconsole.log(\"\\x1b[36m🔨 Building project...\\x1b[0m\");\n\n\tconst result = await Bun.build({\n\t\tentrypoints: [entryPoint],\n\t\toutdir: outDir,\n\t\ttarget: \"bun\",\n\t\ttsconfig: join(projectRoot, \"tsconfig.json\"),\n\t\texternal,\n\t});\n\n\tif (!result.success) {\n\t\tconsole.error(\"\\x1b[31m❌ Build failed:\\x1b[0m\");\n\t\tfor (const log of result.logs) {\n\t\t\tconsole.error(log);\n\t\t}\n\t\tprocess.exitCode = 1;\n\t\treturn;\n\t}\n\n\tconsole.log(\"\\x1b[32m✅ Build successful → .buntok/server.js\\x1b[0m\");\n\tconsole.log(\"\\x1b[90m  Deploy: copy .buntok/ + node_modules/ + package.json to server\\x1b[0m\");\n}\n","import { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\nexport async function checkCommand(): Promise<void> {\n\tconst cwd = process.cwd();\n\tconst tsconfigPath = join(cwd, \"tsconfig.json\");\n\n\tif (!existsSync(tsconfigPath)) {\n\t\tconsole.error(\n\t\t\t\"\\x1b[31mError: tsconfig.json not found. Run `buntok init` first.\\x1b[0m\",\n\t\t);\n\t\tprocess.exitCode = 1;\n\t\treturn;\n\t}\n\n\tconsole.log(\"\\x1b[36m  Running type check...\\x1b[0m\\n\");\n\n\tconst proc = Bun.spawnSync(\n\t\t[\"bunx\", \"tsc\", \"--noEmit\", \"--project\", tsconfigPath],\n\t\t{ cwd },\n\t);\n\n\tif (proc.exitCode === 0) {\n\t\tconsole.log(\"\\n\\x1b[32m  ✓ Type check passed\\x1b[0m\\n\");\n\t} else {\n\t\tconsole.log(\"\\n\\x1b[31m  ✗ Type check failed\\x1b[0m\\n\");\n\t}\n\n\tprocess.exitCode = proc.exitCode ?? 1;\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport fs from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { generateController } from \"../generators/controller.js\";\nimport { generateRepository } from \"../generators/repository.js\";\nimport { generateService } from \"../generators/service.js\";\n\ninterface CreateOptions {\n\trepo: boolean;\n\tservice: boolean;\n\tcontroller: boolean;\n\tall: boolean;\n\tdryRun: boolean;\n}\n\nfunction parseOptions(args: string[]): CreateOptions {\n\tconst options: CreateOptions = {\n\t\trepo: false,\n\t\tservice: false,\n\t\tcontroller: false,\n\t\tall: true,\n\t\tdryRun: false,\n\t};\n\n\tfor (const arg of args) {\n\t\tswitch (arg) {\n\t\t\tcase \"--repo\":\n\t\t\t\toptions.repo = true;\n\t\t\t\toptions.all = false;\n\t\t\t\tbreak;\n\t\t\tcase \"--service\":\n\t\t\t\toptions.service = true;\n\t\t\t\toptions.all = false;\n\t\t\t\tbreak;\n\t\t\tcase \"--controller\":\n\t\t\t\toptions.controller = true;\n\t\t\t\toptions.all = false;\n\t\t\t\tbreak;\n\t\t\tcase \"--dry-run\":\n\t\t\t\toptions.dryRun = true;\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\t// If any specific option is set, don't generate all\n\tif (!options.all) {\n\t\treturn options;\n\t}\n\n\t// Generate all by default\n\treturn {\n\t\trepo: true,\n\t\tservice: true,\n\t\tcontroller: true,\n\t\tall: false,\n\t\tdryRun: options.dryRun,\n\t};\n}\n\nasync function ensureDirectories(_entityName: string) {\n\tconst dirs = [\"src/repositories\", \"src/services\", \"src/controllers\"];\n\n\tawait Promise.all(\n\t\tdirs.map(async (dir) => {\n\t\t\tif (!existsSync(dir)) {\n\t\t\t\tawait fs.mkdir(dir, { recursive: true });\n\t\t\t}\n\t\t}),\n\t);\n}\n\nfunction toPascalCase(str: string): string {\n\treturn str\n\t\t.split(/[-_]/)\n\t\t.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n\t\t.join(\"\");\n}\n\nexport async function createCommand(entityName: string, args: string[]) {\n\tconst options = parseOptions(args);\n\tconst pascalName = toPascalCase(entityName);\n\n\tconst prefix = options.dryRun ? \"\\x1b[33m[DRY RUN]\\x1b[0m \" : \"\";\n\tconsole.log(`\\n${prefix}\\x1b[36mCreating ${pascalName} entity...\\x1b[0m\\n`);\n\n\t// Ensure directories exist (skip in dry-run)\n\tif (!options.dryRun) {\n\t\tawait ensureDirectories(entityName);\n\t}\n\n\tconst results: string[] = [];\n\tconst generatedFiles: string[] = [];\n\tconst tasks: Promise<void>[] = [];\n\n\t// Helper to generate file asynchronously\n\tconst generateFile = async (\n\t\tpath: string,\n\t\tcontentGenerator: () => string,\n\t\ttype: string,\n\t) => {\n\t\tif (options.dryRun) {\n\t\t\tconst content = contentGenerator();\n\t\t\tresults.push(`[DRY RUN] ${type}: ${path}`);\n\t\t\tconsole.log(`\\n\\x1b[90m--- ${path} ---\\x1b[0m`);\n\t\t\tconsole.log(content);\n\t\t\tconsole.log(`\\x1b[90m--- end ---\\x1b[0m\\n`);\n\t\t\treturn;\n\t\t}\n\t\tif (!existsSync(path)) {\n\t\t\tawait fs.writeFile(path, contentGenerator());\n\t\t\tresults.push(`✓ ${type}: ${path}`);\n\t\t\tgeneratedFiles.push(path);\n\t\t} else {\n\t\t\tresults.push(`• ${type}: ${path} (already exists)`);\n\t\t}\n\t};\n\n\tif (options.repo) {\n\t\ttasks.push(\n\t\t\tgenerateFile(\n\t\t\t\tjoin(\"src/repositories\", `${entityName}.repository.ts`),\n\t\t\t\t() => generateRepository(entityName, pascalName),\n\t\t\t\t\"Repository\",\n\t\t\t),\n\t\t);\n\t}\n\n\tif (options.service) {\n\t\ttasks.push(\n\t\t\tgenerateFile(\n\t\t\t\tjoin(\"src/services\", `${entityName}.service.ts`),\n\t\t\t\t() => generateService(entityName, pascalName, options.repo),\n\t\t\t\t\"Service\",\n\t\t\t),\n\t\t);\n\t}\n\n\tif (options.controller) {\n\t\ttasks.push(\n\t\t\tgenerateFile(\n\t\t\t\tjoin(\"src/controllers\", `${entityName}.controller.ts`),\n\t\t\t\t() => generateController(entityName, pascalName, options.service),\n\t\t\t\t\"Controller\",\n\t\t\t),\n\t\t);\n\t}\n\n\t// Execute all file generations concurrently\n\tawait Promise.all(tasks);\n\n\t// Auto-format generated files with Biome if available (skip in dry-run)\n\tif (generatedFiles.length > 0 && !options.dryRun) {\n\t\tconst biomeProc = Bun.spawnSync(\n\t\t\t[\"bunx\", \"biome\", \"format\", \"--write\", ...generatedFiles],\n\t\t\t{\n\t\t\t\tstdio: [\"ignore\", \"ignore\", \"ignore\"],\n\t\t\t},\n\t\t);\n\t\tif (biomeProc.exitCode === 0) {\n\t\t\tconsole.log(\n\t\t\t\t\"\\x1b[90m✨ Auto-formatted generated files with Biome\\x1b[0m\\n\",\n\t\t\t);\n\t\t}\n\t}\n\n\t// Auto-register in src/index.ts (skip in dry-run)\n\tconst indexPath = join(\"src\", \"index.ts\");\n\tif (existsSync(indexPath) && !options.dryRun) {\n\t\tconst indexContent = readFileSync(indexPath, \"utf-8\");\n\n\t\t// Build imports\n\t\tconst imports: string[] = [];\n\t\tconst instantiations: string[] = [];\n\n\t\t// Only register repo + service if full chain (they're needed by controller)\n\t\tif (options.repo && options.service) {\n\t\t\timports.push(`import { ${pascalName}Repository } from \"@/repositories/${entityName}.repository\";`);\n\t\t\tinstantiations.push(`const ${entityName}Repository = new ${pascalName}Repository();`);\n\t\t}\n\n\t\tif (options.service) {\n\t\t\tconst repoArg = options.repo ? `(${entityName}Repository)` : \"\";\n\t\t\tinstantiations.push(`const ${entityName}Service = new ${pascalName}Service${repoArg};`);\n\t\t\tif (!options.repo) {\n\t\t\t\timports.push(`import { ${pascalName}Service } from \"@/services/${entityName}.service\";`);\n\t\t\t}\n\t\t}\n\n\t\t// Always register controller\n\t\t{\n\t\t\timports.push(`import { ${pascalName}Controller } from \"@/controllers/${entityName}.controller\";`);\n\t\t\tconst serviceArg = options.service ? `(${entityName}Service)` : \"\";\n\t\t\tinstantiations.push(`app.registerController(new ${pascalName}Controller${serviceArg});`);\n\t\t}\n\n\t\tconst importBlock = imports.join(\"\\n\");\n\t\tconst instantiationBlock = instantiations.join(\"\\n\");\n\n\t\tif (!indexContent.includes(importBlock)) {\n\t\t\tconst lines = indexContent.split(\"\\n\");\n\n\t\t\t// Find the last import line and insert after it\n\t\t\tlet lastImportIndex = -1;\n\t\t\tfor (let i = 0; i < lines.length; i++) {\n\t\t\t\tif (lines[i]?.startsWith(\"import \")) {\n\t\t\t\t\tlastImportIndex = i;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (lastImportIndex !== -1) {\n\t\t\t\tlines.splice(lastImportIndex + 1, 0, importBlock);\n\t\t\t} else {\n\t\t\t\tlines.unshift(importBlock);\n\t\t\t}\n\n\t\t\t// Find app.registerController or app.listen and insert before it\n\t\t\tconst content = lines.join(\"\\n\");\n\t\t\tconst updatedContent = content.replace(\n\t\t\t\t/(app\\.(registerController|listen)\\s*\\()/,\n\t\t\t\t`${instantiationBlock}\\n\\n$1`,\n\t\t\t);\n\n\t\t\tawait fs.writeFile(indexPath, updatedContent);\n\t\t\tconsole.log(\n\t\t\t\t`\\x1b[32m✔ Registered ${pascalName} in src/index.ts\\x1b[0m`,\n\t\t\t);\n\t\t} else {\n\t\t\tconsole.log(\n\t\t\t\t`\\x1b[90m• src/index.ts: ${pascalName} already registered\\x1b[0m`,\n\t\t\t);\n\t\t}\n\t}\n\n\t// Print results\n\tconsole.log(options.dryRun ? \"\\x1b[33mWould generate:\\x1b[0m\" : \"\\x1b[32mGenerated files:\\x1b[0m\");\n\tfor (const result of results.sort()) {\n\t\tconsole.log(`  ${result}`);\n\t}\n\n\tif (options.dryRun) {\n\t\tconsole.log(`\\n\\x1b[33mRun without --dry-run to create these files.\\x1b[0m\\n`);\n\t} else {\n\t\tconsole.log(`\n\\x1b[36mNext steps:\\x1b[0m\n  1. Start dev server: \\x1b[33mbun run dev\\x1b[0m\n`);\n\t}\n}\n","export function generateController(\n\tentityName: string,\n\tpascalName: string,\n\twithService: boolean = true,\n): string {\n\tif (withService) {\n\t\treturn `import { Controller, BaseController } from \"@buntok/core\";\nimport { ${pascalName}Service } from \"@/services/${entityName}.service\";\n\n@Controller(\"/${entityName}s\")\nexport class ${pascalName}Controller extends BaseController<${pascalName}> {\n  constructor(private readonly ${entityName}Service: ${pascalName}Service) {\n    super(${entityName}Service);\n  }\n}\n`;\n\t}\n\n\treturn `import { Controller, Get, Post, Put, Delete } from \"@buntok/core\";\nimport type { Context } from \"@buntok/core\";\n\n@Controller(\"/${entityName}s\")\nexport class ${pascalName}Controller {\n  @Get(\"/\")\n  async getAll(ctx: Context) {\n    return ctx.success([], \"Records retrieved successfully\");\n  }\n\n  @Get(\"/:id\")\n  async getById(ctx: Context) {\n    return ctx.success({ id: ctx.params.id }, \"Record retrieved successfully\");\n  }\n\n  @Post(\"/\")\n  async create(ctx: Context) {\n    const data = await ctx.body<any>();\n    return ctx.success(data, \"Record created successfully\", 201);\n  }\n\n  @Put(\"/:id\")\n  async update(ctx: Context) {\n    const data = await ctx.body<any>();\n    return ctx.success({ id: ctx.params.id, ...data }, \"Record updated successfully\");\n  }\n\n  @Delete(\"/:id\")\n  async delete(ctx: Context) {\n    return ctx.success(null, \"Record deleted successfully\");\n  }\n}\n`;\n}\n","export function generateRepository(\n\tentityName: string,\n\tpascalName: string,\n): string {\n\treturn `import { BaseRepository } from \"@buntok/prisma\";\n// Replace with your own Prisma client instance\nimport { prisma } from \"@/lib/prisma\";\nimport type { ${pascalName}, PrismaClient, Prisma } from \"@prisma/client\";\n\nexport class ${pascalName}Repository extends BaseRepository<\n  ${pascalName},\n  PrismaClient,\n  Prisma.${pascalName}CreateInput,\n  Prisma.${pascalName}UpdateInput\n> {\n  constructor() {\n    super(prisma, \"${entityName}\");\n  }\n}\n`;\n}\n","export function generateService(\n\tentityName: string,\n\tpascalName: string,\n\twithRepo: boolean = true,\n): string {\n\tif (withRepo) {\n\t\treturn `import { BaseService } from \"@buntok/core\";\nimport { ${pascalName}Repository } from \"@/repositories/${entityName}.repository\";\nimport type { ${pascalName} } from \"@prisma/client\";\n\nexport class ${pascalName}Service extends BaseService<${pascalName}> {\n  constructor(private readonly ${entityName}Repository: ${pascalName}Repository) {\n    super(${entityName}Repository);\n  }\n}\n`;\n\t}\n\n\treturn `export class ${pascalName}Service {\n  async getAll(): Promise<any[]> {\n    return [];\n  }\n\n  async getById(id: string): Promise<any> {\n    return { id };\n  }\n\n  async create(data: any): Promise<any> {\n    return data;\n  }\n\n  async update(id: string, data: any): Promise<any> {\n    return { id, ...data };\n  }\n\n  async delete(id: string): Promise<boolean> {\n    return true;\n  }\n}\n`;\n}\n","import { execSync } from \"node:child_process\";\nimport { existsSync, readFileSync } from \"node:fs\";\n\ntype DbCommand = \"migrate\" | \"seed\" | \"reset\" | \"generate\" | \"studio\" | \"status\";\n\nfunction detectOrm(): \"prisma\" | \"drizzle\" | \"typeorm\" | null {\n\t// Check for Prisma\n\tif (existsSync(\"prisma/schema.prisma\") || existsSync(\"prisma/schema.ts\")) {\n\t\treturn \"prisma\";\n\t}\n\n\t// Check for Drizzle\n\tif (existsSync(\"drizzle.config.ts\") || existsSync(\"drizzle.config.js\")) {\n\t\treturn \"drizzle\";\n\t}\n\n\t// Check for TypeORM\n\tif (existsSync(\"ormconfig.json\") || existsSync(\"ormconfig.ts\") || existsSync(\"ormconfig.js\")) {\n\t\treturn \"typeorm\";\n\t}\n\n\t// Check package.json dependencies\n\tif (existsSync(\"package.json\")) {\n\t\tconst pkg = JSON.parse(readFileSync(\"package.json\", \"utf-8\"));\n\t\tconst allDeps = { ...pkg.dependencies, ...pkg.devDependencies };\n\n\t\tif (allDeps[\"@prisma/client\"] || allDeps[\"prisma\"]) return \"prisma\";\n\t\tif (allDeps[\"drizzle-orm\"] || allDeps[\"drizzle-kit\"]) return \"drizzle\";\n\t\tif (allDeps[\"typeorm\"]) return \"typeorm\";\n\t}\n\n\treturn null;\n}\n\nfunction runCommand(cmd: string): void {\n\tconsole.log(`\\x1b[90m$ ${cmd}\\x1b[0m`);\n\ttry {\n\t\texecSync(cmd, { stdio: \"inherit\", cwd: process.cwd() });\n\t} catch {\n\t\t// Command already printed its error\n\t\tprocess.exitCode = 1;\n\t}\n}\n\nfunction prismaCommand(subcommand: string, args: string[]): void {\n\tconst cmd = `npx prisma ${subcommand} ${args.join(\" \")}`.trim();\n\trunCommand(cmd);\n}\n\nfunction drizzleCommand(subcommand: string, args: string[]): void {\n\tconst commands: Record<string, string> = {\n\t\tmigrate: \"drizzle-kit generate\",\n\t\tseed: \"drizzle-kit seed\",\n\t\treset: \"drizzle-kit drop\",\n\t\tstatus: \"drizzle-kit check\",\n\t\tgenerate: \"drizzle-kit generate\",\n\t\tstudio: \"drizzle-kit studio\",\n\t};\n\tconst cmd = `${commands[subcommand] ?? subcommand} ${args.join(\" \")}`.trim();\n\trunCommand(cmd);\n}\n\nfunction typeormCommand(subcommand: string, args: string[]): void {\n\tconst commands: Record<string, string> = {\n\t\tmigrate: \"typeorm migration:run\",\n\t\tseed: \"typeorm seed\",\n\t\treset: \"typeorm migration:revert\",\n\t\tgenerate: \"typeorm migration:generate\",\n\t\tstatus: \"typeorm migration:show\",\n\t\tstudio: \"echo 'TypeORM does not have a built-in studio command'\",\n\t};\n\tconst cmd = `${commands[subcommand] ?? subcommand} ${args.join(\" \")}`.trim();\n\trunCommand(cmd);\n}\n\nfunction printUsage(): void {\n\tconsole.log(`\n\\x1b[36mUsage:\\x1b[0m\n  buntok db <command> [args]\n\n\\x1b[36mCommands:\\x1b[0m\n  migrate [name]      Run pending migrations\n  seed                Seed database\n  reset               Reset database (drop & recreate)\n  generate            Generate migration from schema changes\n  studio              Open database GUI\n  status              Show migration status\n\n\\x1b[36mSupported ORMs:\\x1b[0m\n  Prisma, Drizzle, TypeORM (auto-detected)\n\n\\x1b[36mExamples:\\x1b[0m\n  buntok db migrate                    # Run pending migrations\n  buntok db migrate add user_table     # Create new migration\n  buntok db seed                       # Seed database\n  buntok db studio                     # Open Prisma Studio / etc\n`);\n}\n\nexport async function dbCommand(args: string[]): Promise<void> {\n\tconst subcommand = args[0] as DbCommand | undefined;\n\n\tif (!subcommand) {\n\t\tprintUsage();\n\t\treturn;\n\t}\n\n\tconst validCommands: DbCommand[] = [\"migrate\", \"seed\", \"reset\", \"generate\", \"studio\", \"status\"];\n\tif (!validCommands.includes(subcommand)) {\n\t\tconsole.error(`\\x1b[31mUnknown command: ${subcommand}\\x1b[0m`);\n\t\tprintUsage();\n\t\tprocess.exitCode = 1;\n\t\treturn;\n\t}\n\n\tconst orm = detectOrm();\n\tif (!orm) {\n\t\tconsole.error(\"\\x1b[31mCould not detect ORM.\\x1b[0m\");\n\t\tconsole.error(\"Supported: Prisma, Drizzle, TypeORM\");\n\t\tconsole.error(\"Make sure you have one installed in package.json.\");\n\t\tprocess.exitCode = 1;\n\t\treturn;\n\t}\n\n\tconsole.log(`\\x1b[36mDetected ORM: ${orm}\\x1b[0m`);\n\n\tconst subArgs = args.slice(1);\n\tswitch (orm) {\n\t\tcase \"prisma\":\n\t\t\tprismaCommand(subcommand, subArgs);\n\t\t\tbreak;\n\t\tcase \"drizzle\":\n\t\t\tdrizzleCommand(subcommand, subArgs);\n\t\t\tbreak;\n\t\tcase \"typeorm\":\n\t\t\ttypeormCommand(subcommand, subArgs);\n\t\t\tbreak;\n\t}\n}\n","import { existsSync, readFileSync, writeFileSync, mkdirSync } from \"node:fs\";\nimport { join, dirname } from \"node:path\";\nimport { execSync } from \"node:child_process\";\nimport { createInterface } from \"node:readline\";\n\nconst __dirname = import.meta.dir;\n\nfunction askQuestion(question: string, defaultValue = true): Promise<boolean> {\n\treturn new Promise((resolve) => {\n\t\tconst rl = createInterface({\n\t\t\tinput: process.stdin,\n\t\t\toutput: process.stdout,\n\t\t});\n\n\t\trl.question(question, (answer) => {\n\t\t\trl.close();\n\t\t\tconst normalized = answer.trim().toLowerCase();\n\t\t\tif (normalized === \"\") return resolve(defaultValue);\n\t\t\tresolve(normalized === \"y\" || normalized === \"yes\");\n\t\t});\n\t});\n}\n\nconst REQUIRED_SCRIPTS: Record<string, string> = {\n\tdev: \"bun --watch server.ts\",\n\tbuild: \"bunx buntok build\",\n\tstart: \"bun .buntok/server.js\",\n\tcheck: \"bunx @biomejs/biome check --write .\",\n\tformat: \"bunx @biomejs/biome format --write .\",\n\tlint: \"bunx @biomejs/biome lint .\",\n};\n\nconst BIOME_CONFIG = {\n\tvcs: {\n\t\tenabled: true,\n\t\tclientKind: \"git\",\n\t\tuseIgnoreFile: true,\n\t},\n\tfiles: {\n\t\tignoreUnknown: true,\n\t\tincludes: [\"**\", \"!**/node_modules\", \"!**/dist\", \"!**/.buntok\", \"!**/coverage\"],\n\t},\n\tformatter: {\n\t\tenabled: true,\n\t\tindentStyle: \"tab\",\n\t\tindentWidth: 2,\n\t\tlineWidth: 100,\n\t\tlineEnding: \"lf\",\n\t},\n\tlinter: {\n\t\tenabled: true,\n\t\trules: {\n\t\t\tpreset: \"recommended\",\n\t\t\tsuspicious: {\n\t\t\t\tnoExplicitAny: \"off\",\n\t\t\t},\n\t\t},\n\t},\n\tjavascript: {\n\t\tformatter: {\n\t\t\tquoteStyle: \"double\",\n\t\t\ttrailingCommas: \"all\",\n\t\t},\n\t},\n};\n\n\nconst TSCONFIG_TEMPLATE = {\n\tcompilerOptions: {\n\t\t// Environment setup & latest features\n\t\tlib: [\"ESNext\"],\n\t\ttarget: \"ESNext\",\n\t\tmodule: \"Preserve\",\n\t\tmoduleDetection: \"force\",\n\t\tjsx: \"react-jsx\",\n\t\tallowJs: true,\n\t\ttypes: [\"bun\", \"node\"],\n\n\t\t// Bundler mode\n\t\tmoduleResolution: \"bundler\",\n\t\tallowImportingTsExtensions: true,\n\t\tverbatimModuleSyntax: true,\n\t\tnoEmit: true,\n\n\t\t// Strictness Options for TS 7+\n\t\tstrict: true,\n\t\tnoUncheckedIndexedAccess: true,\n\t\texactOptionalPropertyTypes: true,\n\t\tnoImplicitOverride: true,\n\t\tnoFallthroughCasesInSwitch: true,\n\t\tisolatedModules: true,\n\t\tskipLibCheck: true,\n\n\t\t// Path alias\n\t\tpaths: {\n\t\t\t\"@/*\": [\"./src/*\"],\n\t\t},\n\t},\n\tinclude: [\"src/**/*\"],\n\texclude: [\"node_modules\", \".buntok\"],\n};\n\nconst VSCODE_SETTINGS = {\n\t\"editor.formatOnSave\": true,\n\t\"editor.defaultFormatter\": \"biomejs.biome\",\n\t\"editor.codeActionsOnSave\": {\n\t\t\"source.fixAll.biome\": \"explicit\",\n\t\t\"source.organizeImports.biome\": \"explicit\",\n\t},\n};\n\nconst INDEX_TEMPLATE = `import { App } from \"@buntok/core\";\n\nexport const app = new App();\n\napp.get(\"/\", (ctx) => {\n  return ctx.json({ message: \"Hello from Buntok!\" });\n});\n\nexport default app;\n`;\n\nconst ENV_TS_TEMPLATE = `import { App, z } from \"@buntok/core\";\n\nexport const env = App.validateEnv({\n\tPORT: z.coerce.number().default(1212),\n\tAUTH_STORE: z.enum([\"header\", \"cookie\"]).default(\"header\"),\n\tAUTH_COOKIE: z.string().default(\"session\"),\n\tNODE_ENV: z.enum([\"development\", \"production\", \"test\"]).default(\"development\"),\n});\n`;\n\nfunction findSkillMdSource(): string | null {\n\t// 1. Relative path (works when running from @buntok/core package)\n\tconst relativePath = join(\n\t\t__dirname,\n\t\t\"..\",\n\t\t\"..\",\n\t\t\"scripts\",\n\t\t\"buntok-skill\",\n\t\t\"SKILL.md\",\n\t);\n\tif (existsSync(relativePath)) return relativePath;\n\n\t// 2. Resolve from @buntok/core package (works when running from buntok CLI)\n\ttry {\n\t\t// biome-ignore lint: dynamic import for package resolution\n\t\tconst pkgJson = require.resolve(\"@buntok/core/package.json\");\n\t\tconst pkgDir = dirname(pkgJson);\n\t\tconst skillPath = join(pkgDir, \"scripts\", \"buntok-skill\", \"SKILL.md\");\n\t\tif (existsSync(skillPath)) return skillPath;\n\t} catch {\n\t\t// package not found\n\t}\n\n\treturn null;\n}\n\nfunction copySkillMd(projectRoot: string): boolean {\n\tconst sourceSkill = findSkillMdSource();\n\n\tif (!sourceSkill) {\n\t\tconsole.warn(\n\t\t\t\"\\x1b[33m⚠ SKILL.md not found in @buntok/core, skipping.\\x1b[0m\",\n\t\t);\n\t\treturn false;\n\t}\n\n\tconst skillDir = join(projectRoot, \".agents\", \"skills\", \"buntok-skill\");\n\tconst destSkill = join(skillDir, \"SKILL.md\");\n\n\tif (!existsSync(skillDir)) {\n\t\tmkdirSync(skillDir, { recursive: true });\n\t}\n\n\twriteFileSync(destSkill, readFileSync(sourceSkill, \"utf-8\"), \"utf-8\");\n\tconsole.log(`\\x1b[32m✓ Created\\x1b[0m .agents/skills/buntok-skill/SKILL.md`);\n\treturn true;\n}\n\nfunction updatePackageJson(projectRoot: string): boolean {\n\tconst pkgPath = join(projectRoot, \"package.json\");\n\n\tlet pkg: { name?: string; scripts?: Record<string, string>; devDependencies?: Record<string, string> };\n\tif (existsSync(pkgPath)) {\n\t\tpkg = JSON.parse(readFileSync(pkgPath, \"utf-8\"));\n\t} else {\n\t\tconst folderName = projectRoot.split(\"/\").pop() || \"my-app\";\n\t\tpkg = { name: folderName, scripts: {}, devDependencies: {} };\n\t}\n\n\tif (!pkg.scripts) pkg.scripts = {};\n\n\tlet added = 0;\n\tfor (const [key, value] of Object.entries(REQUIRED_SCRIPTS)) {\n\t\tif (!pkg.scripts[key]) {\n\t\t\tpkg.scripts[key] = value;\n\t\t\tadded++;\n\t\t}\n\t}\n\n\tif (added === 0) {\n\t\tconsole.log(\"\\x1b[90m• package.json: all scripts already present\\x1b[0m\");\n\t\treturn false;\n\t}\n\n\twriteFileSync(pkgPath, JSON.stringify(pkg, null, 2) + \"\\n\", \"utf-8\");\n\tconsole.log(`\\x1b[32m✓ Updated\\x1b[0m package.json (added ${added} scripts)`);\n\treturn true;\n}\n\nfunction stripJsonComments(text: string): string {\n\t// Remove single-line comments (// ...) but not inside strings\n\treturn text.replace(/(?<![\"':].*)\\/\\/.*$/gm, \"\");\n}\n\nfunction setupTsconfig(projectRoot: string): boolean {\n\tconst tsconfigPath = join(projectRoot, \"tsconfig.json\");\n\n\tif (existsSync(tsconfigPath)) {\n\t\t// Merge paths into existing tsconfig\n\t\tconst raw = readFileSync(tsconfigPath, \"utf-8\");\n\t\tconst existing = JSON.parse(stripJsonComments(raw));\n\t\tif (!existing.compilerOptions) existing.compilerOptions = {};\n\t\tif (!existing.compilerOptions.paths) {\n\t\t\texisting.compilerOptions.paths = { \"@/*\": [\"./src/*\"] };\n\t\t\twriteFileSync(tsconfigPath, JSON.stringify(existing, null, 2) + \"\\n\", \"utf-8\");\n\t\t\tconsole.log(\"\\x1b[32m✓ Updated\\x1b[0m tsconfig.json (added path alias)\");\n\t\t\treturn true;\n\t\t}\n\t\tif (!existing.compilerOptions.paths[\"@/*\"]) {\n\t\t\texisting.compilerOptions.paths[\"@/*\"] = [\"./src/*\"];\n\t\t\twriteFileSync(tsconfigPath, JSON.stringify(existing, null, 2) + \"\\n\", \"utf-8\");\n\t\t\tconsole.log(\"\\x1b[32m✓ Updated\\x1b[0m tsconfig.json (added path alias)\");\n\t\t\treturn true;\n\t\t}\n\t\tconsole.log(\"\\x1b[90m• tsconfig.json: path alias already present\\x1b[0m\");\n\t\treturn false;\n\t}\n\n\t// Create new tsconfig\n\twriteFileSync(tsconfigPath, JSON.stringify(TSCONFIG_TEMPLATE, null, 2) + \"\\n\", \"utf-8\");\n\tconsole.log(\"\\x1b[32m✓ Created\\x1b[0m tsconfig.json\");\n\treturn true;\n}\n\nfunction setupBiome(projectRoot: string): boolean {\n\tconst biomePath = join(projectRoot, \"biome.json\");\n\n\tif (existsSync(biomePath)) {\n\t\tconsole.log(\"\\x1b[90m• biome.json: already exists, skipping\\x1b[0m\");\n\t\treturn false;\n\t}\n\n\t// Check if @biomejs/biome is installed\n\tconst pkgPath = join(projectRoot, \"package.json\");\n\tlet needsInstall = false;\n\tif (existsSync(pkgPath)) {\n\t\tconst pkg = JSON.parse(readFileSync(pkgPath, \"utf-8\"));\n\t\tconst allDeps = {\n\t\t\t...pkg.dependencies,\n\t\t\t...pkg.devDependencies,\n\t\t};\n\t\tneedsInstall = !allDeps[\"@biomejs/biome\"];\n\t}\n\n\tif (needsInstall) {\n\t\tconsole.log(\"\\x1b[90m• Installing @biomejs/biome...\\x1b[0m\");\n\t\ttry {\n\t\t\texecSync(\"bun add -d @biomejs/biome\", {\n\t\t\t\tcwd: projectRoot,\n\t\t\t\tstdio: \"ignore\",\n\t\t\t});\n\t\t\tconsole.log(\"\\x1b[32m✓ Installed\\x1b[0m @biomejs/biome\");\n\t\t} catch {\n\t\t\tconsole.warn(\n\t\t\t\t\"\\x1b[33m⚠ Failed to install @biomejs/biome, please install manually\\x1b[0m\",\n\t\t\t);\n\t\t}\n\t}\n\n\twriteFileSync(biomePath, JSON.stringify(BIOME_CONFIG, null, 2) + \"\\n\", \"utf-8\");\n\tconsole.log(\"\\x1b[32m✓ Created\\x1b[0m biome.json\");\n\treturn true;\n}\n\nfunction createIndexFile(projectRoot: string): boolean {\n\tconst srcDir = join(projectRoot, \"src\");\n\tconst indexPath = join(srcDir, \"index.ts\");\n\n\tif (existsSync(indexPath)) {\n\t\tconsole.log(\"\\x1b[90m• src/index.ts: already exists, skipping\\x1b[0m\");\n\t\treturn false;\n\t}\n\n\tif (!existsSync(srcDir)) {\n\t\tmkdirSync(srcDir, { recursive: true });\n\t}\n\n\twriteFileSync(indexPath, INDEX_TEMPLATE, \"utf-8\");\n\tconsole.log(\"\\x1b[32m✓ Created\\x1b[0m src/index.ts\");\n\treturn true;\n}\n\nfunction createEnvTsFile(projectRoot: string): boolean {\n\tconst srcDir = join(projectRoot, \"src\");\n\tconst envTsPath = join(srcDir, \"env.ts\");\n\n\tif (existsSync(envTsPath)) {\n\t\tconsole.log(\"\\x1b[90m• src/env.ts: already exists, skipping\\x1b[0m\");\n\t\treturn false;\n\t}\n\n\tif (!existsSync(srcDir)) {\n\t\tmkdirSync(srcDir, { recursive: true });\n\t}\n\n\twriteFileSync(envTsPath, ENV_TS_TEMPLATE, \"utf-8\");\n\tconsole.log(\"\\x1b[32m✓ Created\\x1b[0m src/env.ts\");\n\treturn true;\n}\n\nfunction setupVscode(projectRoot: string): boolean {\n\tconst vscodeDir = join(projectRoot, \".vscode\");\n\tconst settingsPath = join(vscodeDir, \"settings.json\");\n\n\tif (existsSync(settingsPath)) {\n\t\tconsole.log(\"\\x1b[90m• .vscode/settings.json: already exists, skipping\\x1b[0m\");\n\t\treturn false;\n\t}\n\n\tif (!existsSync(vscodeDir)) {\n\t\tmkdirSync(vscodeDir, { recursive: true });\n\t}\n\n\twriteFileSync(settingsPath, JSON.stringify(VSCODE_SETTINGS, null, 2) + \"\\n\", \"utf-8\");\n\tconsole.log(\"\\x1b[32m✓ Created\\x1b[0m .vscode/settings.json\");\n\treturn true;\n}\n\nconst ENV_CONTENT = `# Buntok Configuration\nPORT=1212\nAUTH_STORE=header\nAUTH_COOKIE=session\n`;\n\nconst ENV_EXAMPLE_CONTENT = `# Buntok Configuration\n#\n# PORT: port is using for the app\n# AUTH_STORE: Where to store/read JWT tokens\n#   - \"header\" (default): Read from Authorization: Bearer <token> header\n#   - \"cookie\": Read from HttpOnly cookie (set AUTH_COOKIE for cookie name)\n#\n# AUTH_COOKIE: Cookie name for JWT storage (only used when AUTH_STORE=cookie)\n#\nPORT=1212\nAUTH_STORE=header\nAUTH_COOKIE=session\n`;\n\nconst VERCEL_JSON_TEMPLATE = {\n\t$schema: \"https://openapi.vercel.sh/vercel.json\",\n\tframework: \"bun\",\n\tbunVersion: \"1.4.x\",\n};\n\nconst SERVER_TS_TEMPLATE = `import { app } from \"./src/index\";\nimport { env } from \"./src/env\";\n\napp.listen(env.PORT);\n`;\n\nconst GITIGNORE_CONTENT = `# Dependencies\nnode_modules/\n\n# Build output\n.buntok/\n\n# Environment\n.env\n.env.local\n.env.*.local\n\n# IDE\n.vscode/\n.idea/\n*.swp\n*.swo\n*~\n\n# OS\n.DS_Store\nThumbs.db\n\n# Buntok\n.buntok/\n\n# Logs\n*.log\nnpm-debug.log*\n\n# Coverage\ncoverage/\n`;\n\nconst DOCKERFILE_TEMPLATE = `# Builder\nFROM oven/bun:1-alpine AS builder\nWORKDIR /app\n\nCOPY package.json bun.lock* ./\nRUN bun install --frozen-lockfile --production\n\nCOPY src/ src/\nCOPY server.ts ./\nCOPY tsconfig.json ./\nCOPY package.json ./\n\nRUN bunx buntok build\n\n# Production\nFROM oven/bun:1-alpine\nWORKDIR /app\n\nCOPY --from=builder /app/.buntok .buntok\nCOPY --from=builder /app/node_modules node_modules\nCOPY --from=builder /app/package.json ./\n\nEXPOSE 1212\n\nENV NODE_ENV=production\nENV PORT=1212\n\nCMD [\"bun\", \".buntok/server.js\"]\n`;\n\nconst DOCKERIGNORE_CONTENT = `node_modules\ndist\n.buntok\n*.log\n.env\n.env.*\ncoverage\n`;\n\nfunction createEnvFiles(projectRoot: string): boolean {\n\tconst envPath = join(projectRoot, \".env\");\n\tconst envExamplePath = join(projectRoot, \".env.example\");\n\tlet created = false;\n\n\tif (!existsSync(envPath)) {\n\t\twriteFileSync(envPath, ENV_CONTENT, \"utf-8\");\n\t\tconsole.log(\"\\x1b[32m✓ Created\\x1b[0m .env\");\n\t\tcreated = true;\n\t} else {\n\t\tconsole.log(\"\\x1b[90m• .env: already exists, skipping\\x1b[0m\");\n\t}\n\n\tif (!existsSync(envExamplePath)) {\n\t\twriteFileSync(envExamplePath, ENV_EXAMPLE_CONTENT, \"utf-8\");\n\t\tconsole.log(\"\\x1b[32m✓ Created\\x1b[0m .env.example\");\n\t\tcreated = true;\n\t} else {\n\t\tconsole.log(\"\\x1b[90m• .env.example: already exists, skipping\\x1b[0m\");\n\t}\n\n\treturn created;\n}\n\nfunction createGitignore(projectRoot: string): boolean {\n\tconst gitignorePath = join(projectRoot, \".gitignore\");\n\n\tif (existsSync(gitignorePath)) {\n\t\tconsole.log(\"\\x1b[90m• .gitignore: already exists, skipping\\x1b[0m\");\n\t\treturn false;\n\t}\n\n\twriteFileSync(gitignorePath, GITIGNORE_CONTENT, \"utf-8\");\n\tconsole.log(\"\\x1b[32m✓ Created\\x1b[0m .gitignore\");\n\treturn true;\n}\n\nfunction createVercelJson(projectRoot: string): boolean {\n\tconst vercelPath = join(projectRoot, \"vercel.json\");\n\n\tif (existsSync(vercelPath)) {\n\t\tconsole.log(\"\\x1b[90m• vercel.json: already exists, skipping\\x1b[0m\");\n\t\treturn false;\n\t}\n\n\twriteFileSync(vercelPath, JSON.stringify(VERCEL_JSON_TEMPLATE, null, 2) + \"\\n\", \"utf-8\");\n\tconsole.log(\"\\x1b[32m✓ Created\\x1b[0m vercel.json\");\n\n\t// Create empty public/ directory (Vercel requires it for static files)\n\tconst publicDir = join(projectRoot, \"public\");\n\tif (!existsSync(publicDir)) {\n\t\tmkdirSync(publicDir, { recursive: true });\n\t\twriteFileSync(join(publicDir, \".gitkeep\"), \"\");\n\t}\n\n\treturn true;\n}\n\nfunction createServerTsFile(projectRoot: string): boolean {\n\tconst serverPath = join(projectRoot, \"server.ts\");\n\n\tif (existsSync(serverPath)) {\n\t\tconsole.log(\"\\x1b[90m• server.ts: already exists, skipping\\x1b[0m\");\n\t\treturn false;\n\t}\n\n\twriteFileSync(serverPath, SERVER_TS_TEMPLATE, \"utf-8\");\n\tconsole.log(\"\\x1b[32m✓ Created\\x1b[0m server.ts\");\n\treturn true;\n}\n\nfunction updateDevScript(projectRoot: string): boolean {\n\tconst pkgPath = join(projectRoot, \"package.json\");\n\tif (!existsSync(pkgPath)) return false;\n\n\tconst pkg = JSON.parse(readFileSync(pkgPath, \"utf-8\"));\n\tif (!pkg.scripts) return false;\n\n\tif (pkg.scripts.dev === \"bun --watch src/index.ts\") {\n\t\tpkg.scripts.dev = \"bun --watch server.ts\";\n\t\twriteFileSync(pkgPath, JSON.stringify(pkg, null, 2) + \"\\n\", \"utf-8\");\n\t\tconsole.log(\"\\x1b[32m✓ Updated\\x1b[0m package.json (dev → server.ts)\");\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n\nfunction createDockerfile(projectRoot: string): boolean {\n\tconst dockerfilePath = join(projectRoot, \"Dockerfile\");\n\tconst dockerignorePath = join(projectRoot, \".dockerignore\");\n\n\tlet created = false;\n\n\tif (!existsSync(dockerfilePath)) {\n\t\twriteFileSync(dockerfilePath, DOCKERFILE_TEMPLATE, \"utf-8\");\n\t\tconsole.log(\"\\x1b[32m✓ Created\\x1b[0m Dockerfile\");\n\t\tcreated = true;\n\t} else {\n\t\tconsole.log(\"\\x1b[90m• Dockerfile: already exists, skipping\\x1b[0m\");\n\t}\n\n\tif (!existsSync(dockerignorePath)) {\n\t\twriteFileSync(dockerignorePath, DOCKERIGNORE_CONTENT, \"utf-8\");\n\t\tconsole.log(\"\\x1b[32m✓ Created\\x1b[0m .dockerignore\");\n\t\tcreated = true;\n\t} else {\n\t\tconsole.log(\"\\x1b[90m• .dockerignore: already exists, skipping\\x1b[0m\");\n\t}\n\n\treturn created;\n}\n\nexport async function initCommand() {\n\tconst projectRoot = process.cwd();\n\n\tcopySkillMd(projectRoot);\n\tupdatePackageJson(projectRoot);\n\tsetupTsconfig(projectRoot);\n\tsetupBiome(projectRoot);\n\tsetupVscode(projectRoot);\n\tcreateEnvTsFile(projectRoot);\n\tcreateIndexFile(projectRoot);\n\tcreateEnvFiles(projectRoot);\n\tcreateGitignore(projectRoot);\n\tupdateDevScript(projectRoot);\n\n\tconst vercelPath = join(projectRoot, \"vercel.json\");\n\tif (!existsSync(vercelPath)) {\n\t\tconsole.log(\"\");\n\t\tconst useVercel = await askQuestion(\n\t\t\t\"\\x1b[36mDo you want to deploy to Vercel? (y/N): \\x1b[0m\",\n\t\t\tfalse,\n\t\t);\n\t\tif (useVercel) {\n\t\t\tcreateVercelJson(projectRoot);\n\t\t}\n\t} else {\n\t\tconsole.log(\"\\x1b[90m• vercel.json: already exists, skipping\\x1b[0m\");\n\t}\n\n\tcreateServerTsFile(projectRoot);\n\n\tconst dockerfilePath = join(projectRoot, \"Dockerfile\");\n\tif (!existsSync(dockerfilePath)) {\n\t\tconsole.log(\"\");\n\t\tconst useDocker = await askQuestion(\n\t\t\t\"\\x1b[36mDo you want to add Docker support? (Y/n): \\x1b[0m\",\n\t\t\ttrue,\n\t\t);\n\t\tif (useDocker) {\n\t\t\tcreateDockerfile(projectRoot);\n\t\t}\n\t} else {\n\t\tconsole.log(\"\\x1b[90m• Dockerfile: already exists, skipping\\x1b[0m\");\n\t}\n}\n","import { mkdirSync, writeFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport {\n\textendZodWithOpenApi,\n\tOpenAPIRegistry,\n\tOpenApiGeneratorV3,\n} from \"@asteasolutions/zod-to-openapi\";\nimport { z } from \"zod\";\n\nextendZodWithOpenApi(z);\n\n/**\n * Recursively walk a Zod schema and replace any type that zod-to-openapi\n * cannot handle (e.g. ZodFile from Zod v4) with a safe fallback so that\n * docs generation never crashes on an unsupported schema node.\n */\n// biome-ignore lint/suspicious/noExplicitAny: schema introspection requires any\nfunction sanitizeSchema(schema: any): any {\n\tif (!schema || typeof schema !== \"object\" || !schema._def) return schema;\n\n\tconst typeName: string = schema._def?.typeName ?? schema._def?.type ?? \"\";\n\n\t// ZodFile (Zod v4) → OpenAPI string format:binary\n\tif (typeName === \"ZodFile\" || typeName === \"file\") {\n\t\treturn z.string().openapi({ format: \"binary\", description: \"Binary file\" });\n\t}\n\n\t// For all other types, return as-is - zod-to-openapi handles them\n\t// Only recurse into containers we know how to handle safely\n\tif (typeName === \"ZodObject\" || typeName === \"object\") {\n\t\tconst shape =\n\t\t\ttypeof schema._def.shape === \"function\"\n\t\t\t\t? schema._def.shape()\n\t\t\t\t: (schema._def.shape ?? {});\n\t\tconst newShape: Record<string, unknown> = {};\n\t\tfor (const [key, value] of Object.entries(shape)) {\n\t\t\tnewShape[key] = sanitizeSchema(value);\n\t\t}\n\t\treturn z.object(newShape as Record<string, z.ZodTypeAny>);\n\t}\n\n\tif (typeName === \"ZodArray\" || typeName === \"array\") {\n\t\tconst element = schema._def?.element ?? schema._def?.type;\n\t\treturn z.array(sanitizeSchema(element));\n\t}\n\n\tif (typeName === \"ZodOptional\" || typeName === \"optional\") {\n\t\treturn sanitizeSchema(schema._def.innerType).optional();\n\t}\n\tif (typeName === \"ZodNullable\" || typeName === \"nullable\") {\n\t\treturn sanitizeSchema(schema._def.innerType).nullable();\n\t}\n\n\t// Default: return original schema (don't reconstruct unknown types)\n\treturn schema;\n}\n\nexport async function makeDocsCommand() {\n\tconsole.log(\"\\x1b[36mGenerating OpenAPI documentation...\\x1b[0m\");\n\n\t// Prevent the user's app from starting its HTTP server during import\n\tprocess.env.BUNTOK_DOCS_BUILD = \"1\";\n\n\tconst entryPath = resolve(process.cwd(), \"src/index.ts\");\n\n\ttry {\n\t\tconsole.log(`\\x1b[90mLoading app from ${entryPath}...\\x1b[0m`);\n\n\t\tconst userApp = await import(entryPath);\n\t\tconst appInstance = userApp.app || userApp.default;\n\n\t\tif (!appInstance?.openApiDocs) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Could not find an exported 'app' instance in src/index.ts. Make sure you export your app: `export const app = new App();`\",\n\t\t\t);\n\t\t}\n\n\t\tconst docsConfig = appInstance._apiDocsConfig;\n\t\tconst registry = new OpenAPIRegistry();\n\n\t\tlet skipped = 0;\n\n\t\tfor (const doc of appInstance.openApiDocs) {\n\t\t\t// Convert express-style params /users/:id → OpenAPI /users/{id}\n\t\t\tconst openapiPath = doc.path.replace(/:([a-zA-Z0-9_]+)/g, \"{$1}\");\n\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: RouteConfig populated dynamically\n\t\t\tconst routeConfig: any = {\n\t\t\t\tmethod: doc.method,\n\t\t\t\tpath: openapiPath,\n\t\t\t\tresponses: {},\n\t\t\t};\n\n\t\t\tif (doc.request.params || doc.request.query || doc.request.body) {\n\t\t\t\trouteConfig.request = {};\n\t\t\t\tif (doc.request.params)\n\t\t\t\t\trouteConfig.request.params = sanitizeSchema(doc.request.params);\n\t\t\t\tif (doc.request.query)\n\t\t\t\t\trouteConfig.request.query = sanitizeSchema(doc.request.query);\n\t\t\t\tif (doc.request.body) {\n\t\t\t\t\tconst contentType = doc.request.bodyContentType || \"application/json\";\n\t\t\t\t\trouteConfig.request.body = {\n\t\t\t\t\t\tcontent: {\n\t\t\t\t\t\t\t[contentType]: { schema: sanitizeSchema(doc.request.body) },\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (doc.responses.length > 0) {\n\t\t\t\tfor (const res of doc.responses) {\n\t\t\t\t\trouteConfig.responses[res.status.toString()] = {\n\t\t\t\t\t\tdescription: res.description,\n\t\t\t\t\t\tcontent: {\n\t\t\t\t\t\t\t\"application/json\": { schema: sanitizeSchema(res.schema) },\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\trouteConfig.responses[\"200\"] = { description: \"Success\" };\n\t\t\t}\n\n\t\t\t// Per-route error handling: one bad schema should not abort everything\n\t\t\ttry {\n\t\t\t\tregistry.registerPath(routeConfig);\n\t\t\t} catch (err) {\n\t\t\t\tskipped++;\n\t\t\t\tconst label = `${doc.method.toUpperCase()} ${doc.path}`;\n\t\t\t\tif (err instanceof Error) {\n\t\t\t\t\tconsole.warn(`\\x1b[33m  ⚠ Skipping ${label}: ${err.message}\\x1b[0m`);\n\t\t\t\t} else {\n\t\t\t\t\tconsole.warn(`\\x1b[33m  ⚠ Skipping ${label}: unknown error\\x1b[0m`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst generator = new OpenApiGeneratorV3(registry.definitions);\n\t\tconst document = generator.generateDocument({\n\t\t\topenapi: \"3.0.0\",\n\t\t\tinfo: {\n\t\t\t\tversion: docsConfig?.version ?? \"1.0.0\",\n\t\t\t\ttitle: docsConfig?.title ?? \"Buntok API Documentation\",\n\t\t\t\tdescription: docsConfig?.description ?? \"Auto-generated OpenAPI docs from Zod schemas\",\n\t\t\t},\n\t\t});\n\n\t\t// Output directory: public/docs/\n\t\tconst docsDir = resolve(process.cwd(), \"public/docs\");\n\t\tmkdirSync(docsDir, { recursive: true });\n\n\t\tconst swaggerPath = resolve(docsDir, \"swagger.json\");\n\t\twriteFileSync(swaggerPath, JSON.stringify(document, null, 2));\n\t\tconsole.log(\n\t\t\t`\\x1b[32m✔ swagger.json generated at public/docs/swagger.json\\x1b[0m`,\n\t\t);\n\n\t\tconsole.log(`\\n\\x1b[36mNext steps:\\x1b[0m`);\n\t\tconsole.log(\n\t\t\t`\\x1b[90m  Add app.apiDocs() to your src/index.ts:\\x1b[0m`,\n\t\t);\n\t\tconsole.log(\n\t\t\t`\\x1b[90m    app.apiDocs({ path: \"/docs\", title: \"My API\" });\\x1b[0m`,\n\t\t);\n\t\tconsole.log();\n\t\tprocess.exit(0);\n\t} catch (error) {\n\t\tconsole.error(\"\\x1b[31mFailed to generate docs:\\x1b[0m\");\n\t\tconsole.error(error);\n\t\tprocess.exit(1);\n\t}\n}\n","/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise, SuppressedError, Symbol */\r\n\r\n\r\nfunction __rest(s, e) {\r\n    var t = {};\r\n    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n        t[p] = s[p];\r\n    if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n                t[p[i]] = s[p[i]];\r\n        }\r\n    return t;\r\n}\r\n\r\ntypeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\r\n    var e = new Error(message);\r\n    return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\r\n};\n\nconst ZodTypeKeys = {\n    ZodAny: 'any',\n    ZodArray: 'array',\n    ZodBigInt: 'bigint',\n    ZodBoolean: 'boolean',\n    ZodDefault: 'default',\n    ZodPrefault: 'prefault',\n    ZodTransform: 'transform',\n    ZodEnum: 'enum',\n    ZodIntersection: 'intersection',\n    ZodLazy: 'lazy',\n    ZodLiteral: 'literal',\n    ZodNever: 'never',\n    ZodNull: 'null',\n    ZodNullable: 'nullable',\n    ZodNumber: 'number',\n    ZodNonOptional: 'nonoptional',\n    ZodObject: 'object',\n    ZodOptional: 'optional',\n    ZodPipe: 'pipe',\n    ZodReadonly: 'readonly',\n    ZodRecord: 'record',\n    ZodString: 'string',\n    ZodTuple: 'tuple',\n    ZodType: 'type',\n    ZodUnion: 'union',\n    ZodDiscriminatedUnion: 'union',\n    ZodUnknown: 'unknown',\n    ZodVoid: 'void',\n    ZodDate: 'date',\n    ZodTemplateLiteral: 'template_literal',\n};\nfunction isZodType(schema, typeNames) {\n    const typeNamesArray = Array.isArray(typeNames) ? typeNames : [typeNames];\n    return typeNamesArray.some(typeName => {\n        var _a;\n        const typeNameMatch = ((_a = schema === null || schema === void 0 ? void 0 : schema.def) === null || _a === void 0 ? void 0 : _a.type) === ZodTypeKeys[typeName];\n        if (typeName === 'ZodDiscriminatedUnion') {\n            return (typeNameMatch &&\n                'discriminator' in schema.def);\n        }\n        return typeNameMatch;\n    });\n}\nfunction isAnyZodType(schema) {\n    return schema && 'def' in schema;\n}\n/**\n * The schema.isNullable() is deprecated. This is the suggested replacement\n * as this was how isNullable operated beforehand.\n */\nfunction isNullableSchema(schema) {\n    return schema.safeParse(null).success;\n}\n/**\n * The schema.isOptional() is deprecated. This is the suggested replacement\n * as this was how isOptional operated beforehand.\n */\nfunction isOptionalSchema(schema) {\n    return schema.safeParse(undefined).success;\n}\n\nclass $ZodRegistry {\n    constructor() {\n        this._map = new Map();\n        this._idmap = new Map();\n    }\n    add(schema, ..._meta) {\n        const meta = _meta[0];\n        this._map.set(schema, meta);\n        if (meta && typeof meta === \"object\" && \"id\" in meta) {\n            if (this._idmap.has(meta.id)) {\n                throw new Error(`ID ${meta.id} already exists in the registry`);\n            }\n            this._idmap.set(meta.id, schema);\n        }\n        return this;\n    }\n    clear() {\n        this._map = new Map();\n        this._idmap = new Map();\n        return this;\n    }\n    remove(schema) {\n        const meta = this._map.get(schema);\n        if (meta && typeof meta === \"object\" && \"id\" in meta) {\n            this._idmap.delete(meta.id);\n        }\n        this._map.delete(schema);\n        return this;\n    }\n    get(schema) {\n        // return this._map.get(schema) as any;\n        // inherit metadata\n        const p = schema._zod.parent;\n        if (p) {\n            const pm = { ...(this.get(p) ?? {}) };\n            delete pm.id; // do not inherit id\n            return { ...pm, ...this._map.get(schema) };\n        }\n        return this._map.get(schema);\n    }\n    has(schema) {\n        return this._map.has(schema);\n    }\n}\n// registries\nfunction registry() {\n    return new $ZodRegistry();\n}\n\nfunction isEqual(x, y) {\n    if (x === null || x === undefined || y === null || y === undefined) {\n        return x === y;\n    }\n    if (x === y || x.valueOf() === y.valueOf()) {\n        return true;\n    }\n    if (Array.isArray(x)) {\n        if (!Array.isArray(y)) {\n            return false;\n        }\n        if (x.length !== y.length) {\n            return false;\n        }\n    }\n    // if they are strictly equal, they both need to be object at least\n    if (!(x instanceof Object) || !(y instanceof Object)) {\n        return false;\n    }\n    // recursive object equality check\n    const keysX = Object.keys(x);\n    return (Object.keys(y).every(keyY => keysX.indexOf(keyY) !== -1) &&\n        keysX.every(key => isEqual(x[key], y[key])));\n}\nclass ObjectSet {\n    constructor() {\n        this.buckets = new Map();\n    }\n    put(value) {\n        const hashCode = this.hashCodeOf(value);\n        const itemsByCode = this.buckets.get(hashCode);\n        if (!itemsByCode) {\n            this.buckets.set(hashCode, [value]);\n            return;\n        }\n        const alreadyHasItem = itemsByCode.some(_ => isEqual(_, value));\n        if (!alreadyHasItem) {\n            itemsByCode.push(value);\n        }\n    }\n    contains(value) {\n        const hashCode = this.hashCodeOf(value);\n        const itemsByCode = this.buckets.get(hashCode);\n        if (!itemsByCode) {\n            return false;\n        }\n        return itemsByCode.some(_ => isEqual(_, value));\n    }\n    values() {\n        return [...this.buckets.values()].flat();\n    }\n    stats() {\n        let totalBuckets = 0;\n        let totalValues = 0;\n        let collisions = 0;\n        for (const bucket of this.buckets.values()) {\n            totalBuckets += 1;\n            totalValues += bucket.length;\n            if (bucket.length > 1) {\n                collisions += 1;\n            }\n        }\n        const hashEffectiveness = totalBuckets / totalValues;\n        return { totalBuckets, collisions, totalValues, hashEffectiveness };\n    }\n    hashCodeOf(object) {\n        let hashCode = 0;\n        if (Array.isArray(object)) {\n            for (let i = 0; i < object.length; i++) {\n                hashCode ^= this.hashCodeOf(object[i]) * i;\n            }\n            return hashCode;\n        }\n        if (typeof object === 'string') {\n            for (let i = 0; i < object.length; i++) {\n                hashCode ^= object.charCodeAt(i) * i;\n            }\n            return hashCode;\n        }\n        if (typeof object === 'number') {\n            return object;\n        }\n        if (typeof object === 'object') {\n            for (const [key, value] of Object.entries(object)) {\n                hashCode ^= this.hashCodeOf(key) + this.hashCodeOf(value !== null && value !== void 0 ? value : '');\n            }\n        }\n        return hashCode;\n    }\n}\n\nfunction isUndefined(value) {\n    return value === undefined;\n}\nfunction mapValues(object, mapper) {\n    const result = {};\n    Object.entries(object).forEach(([key, value]) => {\n        result[key] = mapper(value);\n    });\n    return result;\n}\nfunction omit(object, keys) {\n    const result = {};\n    Object.entries(object).forEach(([key, value]) => {\n        if (!keys.some(keyToOmit => keyToOmit === key)) {\n            result[key] = value;\n        }\n    });\n    return result;\n}\nfunction omitBy(object, predicate) {\n    const result = {};\n    Object.entries(object).forEach(([key, value]) => {\n        if (!predicate(value, key)) {\n            result[key] = value;\n        }\n    });\n    return result;\n}\nfunction compact(arr) {\n    return arr.filter((elem) => !isUndefined(elem));\n}\nconst objectEquals = isEqual;\nfunction uniq(values) {\n    const set = new ObjectSet();\n    values.forEach(value => set.put(value));\n    return [...set.values()];\n}\nfunction isString(val) {\n    return typeof val === 'string';\n}\nfunction sortObjectByKeys(obj) {\n    return Object.fromEntries(Object.entries(obj).sort(([leftKey], [rightKey]) => leftKey.localeCompare(rightKey)));\n}\n\n/**\n * @deprecated This is not really deprecated but this should always be used with\n * caution. Using it may alter the behavior of the library and the generated schemas.\n */\nconst zodToOpenAPIRegistry = registry();\nclass Metadata {\n    static collectMetadata(schema, metadata) {\n        const currentMetadata = this.getMetadataFromRegistry(schema);\n        const _internal = Object.assign(Object.assign({}, currentMetadata === null || currentMetadata === void 0 ? void 0 : currentMetadata._internal), metadata === null || metadata === void 0 ? void 0 : metadata._internal);\n        const param = Object.assign(Object.assign({}, currentMetadata === null || currentMetadata === void 0 ? void 0 : currentMetadata.param), metadata === null || metadata === void 0 ? void 0 : metadata.param);\n        const totalMetadata = Object.assign(Object.assign(Object.assign(Object.assign({}, (Object.keys(_internal).length > 0 ? { _internal } : {})), currentMetadata), metadata), (Object.keys(param).length > 0 ? { param } : {}));\n        if (isZodType(schema, [\n            'ZodOptional',\n            'ZodNullable',\n            'ZodDefault',\n            'ZodPrefault',\n            'ZodReadonly',\n            'ZodNonOptional',\n        ]) &&\n            isAnyZodType(schema._zod.def.innerType)) {\n            return this.collectMetadata(schema._zod.def.innerType, totalMetadata);\n        }\n        if (isZodType(schema, 'ZodPipe')) {\n            const inSchema = schema._zod.def.in;\n            const outSchema = schema._zod.def.out;\n            // meaning preprocess\n            if (isZodType(inSchema, 'ZodTransform') && isAnyZodType(outSchema)) {\n                return this.collectMetadata(outSchema, totalMetadata);\n            }\n            if (isAnyZodType(inSchema)) {\n                // meaning transform\n                return this.collectMetadata(inSchema, totalMetadata);\n            }\n        }\n        return totalMetadata;\n    }\n    /**\n     * @deprecated Use one of `getOpenApiMetadata` or `getInternalMetadata` instead\n     */\n    static getMetadata(zodSchema) {\n        return this.collectMetadata(zodSchema);\n    }\n    static getOpenApiMetadata(zodSchema) {\n        const metadata = this.collectMetadata(zodSchema);\n        const _a = metadata !== null && metadata !== void 0 ? metadata : {}, { _internal } = _a, rest = __rest(_a, [\"_internal\"]);\n        return rest;\n    }\n    static getInternalMetadata(zodSchema) {\n        var _a;\n        return (_a = this.collectMetadata(zodSchema)) === null || _a === void 0 ? void 0 : _a._internal;\n    }\n    static getParamMetadata(zodSchema) {\n        const metadata = this.collectMetadata(zodSchema);\n        return Object.assign(Object.assign({}, metadata), { \n            // A description provided from .openapi() should be taken with higher precedence\n            param: Object.assign(Object.assign({}, ((metadata === null || metadata === void 0 ? void 0 : metadata.description) ? { description: metadata.description } : {})), metadata === null || metadata === void 0 ? void 0 : metadata.param) });\n    }\n    /**\n     * A method that omits all custom keys added to the regular OpenAPI\n     * metadata properties\n     */\n    static buildSchemaMetadata(metadata) {\n        return omitBy(omit(metadata, ['param', '_internal']), isUndefined);\n    }\n    static buildParameterMetadata(metadata) {\n        return omitBy(metadata, isUndefined);\n    }\n    static applySchemaMetadata(initialData, metadata) {\n        return omitBy(Object.assign(Object.assign({}, initialData), this.buildSchemaMetadata(metadata)), isUndefined);\n    }\n    static getRefId(zodSchema) {\n        var _a;\n        return (_a = this.getInternalMetadata(zodSchema)) === null || _a === void 0 ? void 0 : _a.refId;\n    }\n    static unwrapChained(schema) {\n        return this.unwrapUntil(schema);\n    }\n    static getDefaultValue(zodSchema) {\n        var _a;\n        const unwrapped = (_a = this.unwrapUntil(zodSchema, 'ZodDefault')) !== null && _a !== void 0 ? _a : this.unwrapUntil(zodSchema, 'ZodPrefault');\n        return unwrapped === null || unwrapped === void 0 ? void 0 : unwrapped._zod.def.defaultValue;\n    }\n    static unwrapUntil(schema, typeName) {\n        if (typeName && isZodType(schema, typeName)) {\n            return schema;\n        }\n        if (isZodType(schema, [\n            'ZodOptional',\n            'ZodNullable',\n            'ZodDefault',\n            'ZodPrefault',\n            'ZodReadonly',\n            'ZodNonOptional',\n        ]) &&\n            isAnyZodType(schema._zod.def.innerType)) {\n            return this.unwrapUntil(schema._zod.def.innerType, typeName);\n        }\n        if (isZodType(schema, 'ZodPipe')) {\n            const inSchema = schema._zod.def.in;\n            const outSchema = schema._zod.def.out;\n            // meaning preprocess\n            if (isZodType(inSchema, 'ZodTransform') && isAnyZodType(outSchema)) {\n                return this.unwrapUntil(outSchema, typeName);\n            }\n            // meaning transform\n            if (isAnyZodType(inSchema)) {\n                return this.unwrapUntil(inSchema, typeName);\n            }\n        }\n        return typeName ? undefined : schema;\n    }\n    static getMetadataFromInternalRegistry(zodSchema) {\n        return zodToOpenAPIRegistry.get(zodSchema);\n    }\n    static getMetadataFromRegistry(zodSchema) {\n        const internal = this.getMetadataFromInternalRegistry(zodSchema);\n        const general = zodSchema.meta();\n        if (!internal) {\n            return general;\n        }\n        const { _internal } = internal, rest = __rest(internal, [\"_internal\"]);\n        const _a = general !== null && general !== void 0 ? general : {}, { id, title } = _a, restGeneral = __rest(_a, [\"id\", \"title\"]);\n        return Object.assign(Object.assign(Object.assign({ _internal: Object.assign(Object.assign({}, (id ? { refId: id } : {})), _internal) }, rest), (title ? { description: title } : {})), restGeneral);\n    }\n    static setMetadataInRegistry(zodSchema, metadata) {\n        zodToOpenAPIRegistry.add(zodSchema, metadata);\n    }\n}\n\nfunction preserveMetadataFromModifier(zodSchema, modifier) {\n    const zodModifier = zodSchema[modifier];\n    if (typeof zodModifier !== 'function') {\n        return;\n    }\n    zodSchema[modifier] = function (...args) {\n        const result = zodModifier.apply(this, args);\n        const meta = Metadata.getMetadataFromRegistry(this);\n        if (meta) {\n            Metadata.setMetadataInRegistry(result, meta);\n        }\n        return result;\n    };\n}\nfunction extendZodWithOpenApi(zod) {\n    if (typeof zod.ZodType.prototype.openapi !== 'undefined') {\n        // This zod instance is already extended with the required methods,\n        // doing it again will just result in multiple wrapper methods for\n        // `optional` and `nullable`\n        return;\n    }\n    zod.ZodType.prototype.openapi = function (...args) {\n        const { refId, metadata, options } = getOpenApiConfiguration(...args);\n        const _a = metadata !== null && metadata !== void 0 ? metadata : {}, { param } = _a, restOfOpenApi = __rest(_a, [\"param\"]);\n        const allMetadata = Metadata.getMetadataFromRegistry(this);\n        const _b = allMetadata !== null && allMetadata !== void 0 ? allMetadata : {}, { _internal: internalMetadata } = _b, currentMetadata = __rest(_b, [\"_internal\"]);\n        const _internal = Object.assign(Object.assign(Object.assign({}, internalMetadata), options), (refId ? { refId } : undefined));\n        const resultMetadata = Object.assign(Object.assign(Object.assign({}, currentMetadata), restOfOpenApi), ((currentMetadata === null || currentMetadata === void 0 ? void 0 : currentMetadata.param) || param\n            ? {\n                param: Object.assign(Object.assign({}, currentMetadata === null || currentMetadata === void 0 ? void 0 : currentMetadata.param), param),\n            }\n            : undefined));\n        // We need to create a new instance of the schema so that sequential\n        // calls to .openapi from keys do not override each other\n        // See the test in metadata-overrides.spec.ts (only adds overrides for new metadata properties)\n        const result = new this.constructor(this._def);\n        function setMetadata(schema) {\n            Metadata.setMetadataInRegistry(schema, Object.assign(Object.assign({}, (Object.keys(_internal).length > 0 ? { _internal } : undefined)), resultMetadata));\n        }\n        setMetadata(result);\n        /**\n         * In order to handle z.json() which is implemented as:\n         *\n         * const jsonSchema = lazy(() => { return union([ ... ]) });\n         * return jsonSchema;\n         *\n         * We need to not only set the metadata to the resulting schema (which would be different\n         * from `jsonSchema`), but also to the original lazy schema so that the _internal metadata (refId)\n         * is also present in the internally used `jsonSchema`.\n         */\n        if (isZodType(result, 'ZodLazy')) {\n            setMetadata(this);\n        }\n        if (isZodType(result, 'ZodObject')) {\n            const currentMetadata = Metadata.getMetadataFromRegistry(result);\n            const originalExtend = result.extend;\n            result.extend = function (...args) {\n                const extendedResult = originalExtend.apply(result, args);\n                const _a = currentMetadata !== null && currentMetadata !== void 0 ? currentMetadata : {}, { _internal } = _a, rest = __rest(_a, [\"_internal\"]);\n                Metadata.setMetadataInRegistry(extendedResult, {\n                    _internal: {\n                        extendedFrom: (_internal === null || _internal === void 0 ? void 0 : _internal.refId)\n                            ? { refId: _internal.refId, schema: result }\n                            : _internal === null || _internal === void 0 ? void 0 : _internal.extendedFrom,\n                    },\n                });\n                // This is hacky. Yes we can do that directly in the meta call above,\n                // but that would not override future calls to .extend. That's why\n                // we call openapi explicitly here. And in that case might as well add the metadata\n                // here instead of through the meta call\n                return extendedResult.openapi(rest);\n            };\n            preserveMetadataFromModifier(result, 'catchall');\n        }\n        preserveMetadataFromModifier(result, 'optional');\n        preserveMetadataFromModifier(result, 'nullable');\n        preserveMetadataFromModifier(result, 'default');\n        preserveMetadataFromModifier(result, 'transform');\n        preserveMetadataFromModifier(result, 'refine');\n        preserveMetadataFromModifier(result, 'length');\n        preserveMetadataFromModifier(result, 'min');\n        preserveMetadataFromModifier(result, 'max');\n        const originalMeta = result.meta;\n        result.meta = function (...args) {\n            const result = originalMeta.apply(this, args);\n            if (args[0]) {\n                const meta = Metadata.getMetadataFromInternalRegistry(this);\n                if (meta) {\n                    Metadata.setMetadataInRegistry(result, Object.assign(Object.assign({}, meta), args[0]));\n                }\n            }\n            return result;\n        };\n        return result;\n    };\n}\nfunction getOpenApiConfiguration(refOrOpenapi, metadataOrOptions, options) {\n    if (typeof refOrOpenapi === 'string') {\n        return {\n            refId: refOrOpenapi,\n            metadata: metadataOrOptions,\n            options,\n        };\n    }\n    return {\n        refId: undefined,\n        metadata: refOrOpenapi,\n        options: metadataOrOptions,\n    };\n}\n\nfunction getOpenApiMetadata(zodSchema) {\n    var _a;\n    return omitBy((_a = Metadata.getOpenApiMetadata(zodSchema)) !== null && _a !== void 0 ? _a : {}, isUndefined);\n}\nfunction getRefId(zodSchema) {\n    return Metadata.getRefId(zodSchema);\n}\n\nclass OpenAPIRegistry {\n    constructor(parents) {\n        this.parents = parents;\n        this._definitions = [];\n    }\n    get definitions() {\n        var _a, _b;\n        const parentDefinitions = (_b = (_a = this.parents) === null || _a === void 0 ? void 0 : _a.flatMap(par => par._definitions)) !== null && _b !== void 0 ? _b : [];\n        return [...parentDefinitions, ...this._definitions];\n    }\n    /**\n     * Registers a new component schema under /components/schemas/${name}\n     */\n    register(refId, zodSchema) {\n        const schemaWithRefId = this.schemaWithRefId(refId, zodSchema);\n        this._definitions.push({ type: 'schema', schema: schemaWithRefId });\n        return schemaWithRefId;\n    }\n    /**\n     * Registers a new parameter schema under /components/parameters/${name}\n     */\n    registerParameter(refId, zodSchema) {\n        var _a, _b, _c;\n        const schemaWithRefId = this.schemaWithRefId(refId, zodSchema);\n        const currentMetadata = (_a = Metadata.getOpenApiMetadata(schemaWithRefId)) !== null && _a !== void 0 ? _a : {};\n        const schemaWithMetadata = schemaWithRefId.openapi(Object.assign(Object.assign({}, currentMetadata), { param: Object.assign(Object.assign({}, currentMetadata === null || currentMetadata === void 0 ? void 0 : currentMetadata.param), { name: (_c = (_b = currentMetadata === null || currentMetadata === void 0 ? void 0 : currentMetadata.param) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : refId }) }));\n        this._definitions.push({\n            type: 'parameter',\n            schema: schemaWithMetadata,\n        });\n        return schemaWithMetadata;\n    }\n    /**\n     * Registers a new path that would be generated under paths:\n     */\n    registerPath(route) {\n        this._definitions.push({\n            type: 'route',\n            route,\n        });\n    }\n    /**\n     * Registers a new webhook that would be generated under webhooks:\n     */\n    registerWebhook(webhook) {\n        this._definitions.push({\n            type: 'webhook',\n            webhook,\n        });\n    }\n    /**\n     * Registers a raw OpenAPI component. Use this if you have a simple object instead of a Zod schema.\n     *\n     * @param type The component type, e.g. `schemas`, `responses`, `securitySchemes`, etc.\n     * @param name The name of the object, it is the key under the component\n     *             type in the resulting OpenAPI document\n     * @param component The actual object to put there\n     */\n    registerComponent(type, name, component) {\n        this._definitions.push({\n            type: 'component',\n            componentType: type,\n            name,\n            component,\n        });\n        return {\n            name,\n            ref: { $ref: `#/components/${type}/${name}` },\n        };\n    }\n    schemaWithRefId(refId, zodSchema) {\n        return zodSchema.openapi(refId);\n    }\n}\n\nclass ZodToOpenAPIError {\n    constructor(message) {\n        this.message = message;\n    }\n}\nclass ConflictError extends ZodToOpenAPIError {\n    constructor(message, data) {\n        super(message);\n        this.data = data;\n    }\n}\nclass MissingParameterDataError extends ZodToOpenAPIError {\n    constructor(data) {\n        super(`Missing parameter data, please specify \\`${data.missingField}\\` and other OpenAPI parameter props using the \\`param\\` field of \\`schema.openapi\\``);\n        this.data = data;\n    }\n}\nfunction enhanceMissingParametersError(action, paramsToAdd) {\n    try {\n        return action();\n    }\n    catch (error) {\n        if (error instanceof MissingParameterDataError) {\n            throw new MissingParameterDataError(Object.assign(Object.assign({}, error.data), paramsToAdd));\n        }\n        throw error;\n    }\n}\nclass UnknownZodTypeError extends ZodToOpenAPIError {\n    constructor(data) {\n        super(`Unknown zod object type, please specify \\`type\\` and other OpenAPI props using \\`schema.openapi\\`.`);\n        this.data = data;\n    }\n}\n\nclass ArrayTransformer {\n    transform(zodSchema, mapNullableType, mapItems) {\n        var _a, _b, _c, _d;\n        const itemType = zodSchema.def.element;\n        const minItems = (_b = (_a = zodSchema.def.checks) === null || _a === void 0 ? void 0 : _a.find((check) => check._zod.def.check === 'min_length')) === null || _b === void 0 ? void 0 : _b._zod.def.minimum;\n        const maxItems = (_d = (_c = zodSchema.def.checks) === null || _c === void 0 ? void 0 : _c.find((check) => check._zod.def.check === 'max_length')) === null || _d === void 0 ? void 0 : _d._zod.def.maximum;\n        return Object.assign(Object.assign({}, mapNullableType('array')), { items: isAnyZodType(itemType) ? mapItems(itemType) : {}, minItems,\n            maxItems });\n    }\n}\n\nclass BigIntTransformer {\n    transform(mapNullableType) {\n        return Object.assign(Object.assign({}, mapNullableType('string')), { pattern: `^\\d+$` });\n    }\n}\n\nclass DiscriminatedUnionTransformer {\n    transform(zodSchema, isNullable, mapNullableOfArray, mapItem, generateSchemaRef) {\n        const options = [...zodSchema.def.options];\n        const optionSchema = options.map(mapItem);\n        if (isNullable) {\n            return {\n                oneOf: mapNullableOfArray(optionSchema, isNullable),\n            };\n        }\n        const discriminator = zodSchema._zod.def.discriminator;\n        if (!discriminator) {\n            console.error('No discriminator found for discriminated union', zodSchema);\n            return {\n                oneOf: optionSchema,\n            };\n        }\n        return {\n            oneOf: optionSchema,\n            discriminator: this.mapDiscriminator(options, discriminator, generateSchemaRef),\n        };\n    }\n    mapDiscriminator(zodObjects, discriminator, generateSchemaRef) {\n        // All schemas must be registered to use a discriminator\n        if (zodObjects.some(obj => Metadata.getRefId(obj) === undefined)) {\n            return undefined;\n        }\n        const mapping = {};\n        zodObjects.forEach(obj => {\n            var _a;\n            const refId = Metadata.getRefId(obj); // type-checked earlier\n            const value = (_a = obj.def.shape) === null || _a === void 0 ? void 0 : _a[discriminator];\n            if (isZodType(value, 'ZodEnum')) {\n                // Native enums have their keys as both number and strings however the number is an\n                // internal representation and the string is the access point for a documentation\n                const keys = Object.values(value._zod.def.entries).filter(isString);\n                keys.forEach((enumValue) => {\n                    mapping[enumValue] = generateSchemaRef(refId);\n                });\n                return;\n            }\n            const literalValue = value === null || value === void 0 ? void 0 : value.def.values[0];\n            mapping[literalValue] = generateSchemaRef(refId);\n        });\n        return {\n            propertyName: discriminator,\n            mapping,\n        };\n    }\n}\n\n/**\n * Numeric enums have a reverse mapping https://www.typescriptlang.org/docs/handbook/enums.html#reverse-mappings\n * whereas string ones don't.\n *\n * This function checks if an enum is fully numeric - i.e all values are numbers or not.\n * And filters out only the actual enum values when a reverse mapping is apparent.\n */\nfunction enumInfo(enumObject) {\n    const keysExceptReverseMappings = Object.keys(enumObject).filter(key => typeof enumObject[enumObject[key]] !== 'number');\n    const values = keysExceptReverseMappings.map(key => enumObject[key]);\n    const numericCount = values.filter(_ => typeof _ === 'number').length;\n    const type = numericCount === 0\n        ? 'string'\n        : numericCount === values.length\n            ? 'numeric'\n            : 'mixed';\n    return { values, type };\n}\n\nclass EnumTransformer {\n    transform(zodSchema, isNullable, mapNullableType) {\n        const { type, values } = enumInfo(zodSchema._zod.def.entries);\n        if (type === 'mixed') {\n            // enum Test {\n            //   A = 42,\n            //   B = 'test',\n            // }\n            //\n            // const result = z.nativeEnum(Test).parse('42');\n            //\n            // This is an error, so we can't just say it's a 'string'\n            throw new ZodToOpenAPIError('Enum has mixed string and number values, please specify the OpenAPI type manually');\n        }\n        return Object.assign(Object.assign({}, mapNullableType(type === 'numeric' ? 'integer' : 'string')), { enum: isNullable ? [...values, null] : values });\n    }\n}\n\nclass IntersectionTransformer {\n    transform(zodSchema, isNullable, mapNullableOfArray, mapItem) {\n        const subtypes = this.flattenIntersectionTypes(zodSchema);\n        const allOfSchema = {\n            allOf: subtypes.map(mapItem),\n        };\n        if (isNullable) {\n            return {\n                anyOf: mapNullableOfArray([allOfSchema], isNullable),\n            };\n        }\n        return allOfSchema;\n    }\n    flattenIntersectionTypes(schema) {\n        if (!isZodType(schema, 'ZodIntersection')) {\n            return [schema];\n        }\n        const leftSubTypes = isAnyZodType(schema._zod.def.left)\n            ? this.flattenIntersectionTypes(schema._zod.def.left)\n            : [];\n        const rightSubTypes = isAnyZodType(schema._zod.def.right)\n            ? this.flattenIntersectionTypes(schema._zod.def.right)\n            : [];\n        return [...leftSubTypes, ...rightSubTypes];\n    }\n}\n\nclass LiteralTransformer {\n    constructor() {\n        this.bigIntTransformer = new BigIntTransformer();\n    }\n    transform(zodSchema, mapNullableType) {\n        const type = typeof zodSchema.def.values[0];\n        if (type === 'boolean' ||\n            type === 'number' ||\n            type === 'string' ||\n            type === 'object') {\n            return Object.assign(Object.assign({}, mapNullableType(type)), { enum: [zodSchema.def.values[0]] });\n        }\n        if (type === 'bigint') {\n            return this.bigIntTransformer.transform(mapNullableType);\n        }\n        // Zod doesn't really support anything else anyways\n        return mapNullableType('null');\n    }\n}\n\nclass NumberTransformer {\n    transform(zodSchema, mapNullableType, getNumberChecks) {\n        var _a;\n        return Object.assign(Object.assign(Object.assign({}, mapNullableType('number')), mapNullableType(zodSchema.format === 'safeint' ? 'integer' : 'number')), getNumberChecks((_a = zodSchema.def.checks) !== null && _a !== void 0 ? _a : []));\n    }\n}\n\nclass ObjectTransformer {\n    transform(zodSchema, defaultValue, mapNullableType, mapItem) {\n        var _a;\n        const extendedFrom = (_a = Metadata.getInternalMetadata(zodSchema)) === null || _a === void 0 ? void 0 : _a.extendedFrom;\n        const required = this.requiredKeysOf(zodSchema);\n        const properties = mapValues(zodSchema.def.shape, mapItem);\n        if (!extendedFrom) {\n            return Object.assign(Object.assign(Object.assign(Object.assign({}, mapNullableType('object')), { properties, default: defaultValue }), (required.length > 0 ? { required } : {})), this.generateAdditionalProperties(zodSchema, mapItem));\n        }\n        const parent = extendedFrom.schema;\n        // We want to generate the parent schema so that it can be referenced down the line\n        mapItem(parent);\n        const keysRequiredByParent = this.requiredKeysOf(parent);\n        const propsOfParent = mapValues(parent === null || parent === void 0 ? void 0 : parent.def.shape, mapItem);\n        const propertiesToAdd = Object.fromEntries(Object.entries(properties).filter(([key, type]) => {\n            return !objectEquals(propsOfParent[key], type);\n        }));\n        const additionallyRequired = required.filter(prop => !keysRequiredByParent.includes(prop));\n        const objectData = Object.assign(Object.assign(Object.assign(Object.assign({}, mapNullableType('object')), { default: defaultValue, properties: propertiesToAdd }), (additionallyRequired.length > 0\n            ? { required: additionallyRequired }\n            : {})), this.generateAdditionalProperties(zodSchema, mapItem));\n        return {\n            allOf: [\n                { $ref: `#/components/schemas/${extendedFrom.refId}` },\n                objectData,\n            ],\n        };\n    }\n    generateAdditionalProperties(zodSchema, mapItem) {\n        const catchallSchema = zodSchema.def.catchall;\n        if (!catchallSchema) {\n            return {};\n        }\n        if (isZodType(catchallSchema, 'ZodNever')) {\n            return { additionalProperties: false };\n        }\n        if (isAnyZodType(catchallSchema)) {\n            return { additionalProperties: mapItem(catchallSchema) };\n        }\n        return {};\n    }\n    requiredKeysOf(objectSchema) {\n        return Object.entries(objectSchema.def.shape)\n            .filter(([_key, type]) => !isOptionalSchema(type))\n            .map(([key, _type]) => key);\n    }\n}\n\nclass RecordTransformer {\n    transform(zodSchema, mapNullableType, mapItem) {\n        const propertiesType = zodSchema.valueType;\n        const keyType = zodSchema.keyType;\n        const propertiesSchema = isAnyZodType(propertiesType)\n            ? mapItem(propertiesType)\n            : {};\n        if (isZodType(keyType, 'ZodEnum')) {\n            // Native enums have their keys as both number and strings however the number is an\n            // internal representation and the string is the access point for a documentation\n            const keys = Object.values(keyType._zod.def.entries).filter(isString);\n            const properties = keys.reduce((acc, curr) => (Object.assign(Object.assign({}, acc), { [curr]: propertiesSchema })), {});\n            return Object.assign(Object.assign({}, mapNullableType('object')), { properties });\n        }\n        return Object.assign(Object.assign({}, mapNullableType('object')), { additionalProperties: propertiesSchema });\n    }\n}\n\nfunction isZodCheckLengthEquals(check) {\n    return check._zod.def.check === 'length_equals';\n}\nfunction isZodCheckRegex(check) {\n    return (check._zod.def.check === 'string_format' &&\n        check._zod.def.format === 'regex');\n}\nclass StringTransformer {\n    transform(zodSchema, mapNullableType) {\n        var _a, _b, _c, _d;\n        const regexCheck = (_a = zodSchema.def.checks) === null || _a === void 0 ? void 0 : _a.find(isZodCheckRegex);\n        // toString generates an additional / at the beginning and end of the pattern\n        const pattern = regexCheck === null || regexCheck === void 0 ? void 0 : regexCheck._zod.def.pattern.toString().replace(/^\\/|\\/$/g, '');\n        const check = (_b = zodSchema.def.checks) === null || _b === void 0 ? void 0 : _b.find(isZodCheckLengthEquals);\n        const length = check === null || check === void 0 ? void 0 : check._zod.def.length;\n        const maxLength = Number.isFinite(zodSchema.minLength)\n            ? (_c = zodSchema.minLength) !== null && _c !== void 0 ? _c : undefined\n            : undefined;\n        const minLength = Number.isFinite(zodSchema.maxLength)\n            ? (_d = zodSchema.maxLength) !== null && _d !== void 0 ? _d : undefined\n            : undefined;\n        return Object.assign(Object.assign({}, mapNullableType('string')), { \n            // FIXME: https://github.com/colinhacks/zod/commit/d78047e9f44596a96d637abb0ce209cd2732d88c\n            minLength: length !== null && length !== void 0 ? length : maxLength, maxLength: length !== null && length !== void 0 ? length : minLength, format: this.mapStringFormat(zodSchema), pattern });\n    }\n    /**\n     * Attempts to map Zod strings to known formats\n     * https://json-schema.org/understanding-json-schema/reference/string.html#built-in-formats\n     */\n    mapStringFormat(zodString) {\n        if (zodString.format === 'uuid')\n            return 'uuid';\n        if (zodString.format === 'email')\n            return 'email';\n        if (zodString.format === 'url')\n            return 'uri';\n        if (zodString.format === 'date')\n            return 'date';\n        if (zodString.format === 'datetime')\n            return 'date-time';\n        if (zodString.format === 'cuid')\n            return 'cuid';\n        if (zodString.format === 'cuid2')\n            return 'cuid2';\n        if (zodString.format === 'ulid')\n            return 'ulid';\n        if (zodString.format === 'ipv4')\n            return 'ip';\n        if (zodString.format === 'ipv6')\n            return 'ip';\n        if (zodString.format === 'emoji')\n            return 'emoji';\n        return undefined;\n    }\n}\n\nclass TupleTransformer {\n    constructor(versionSpecifics) {\n        this.versionSpecifics = versionSpecifics;\n    }\n    transform(zodSchema, mapNullableType, mapItem) {\n        const items = zodSchema._zod.def.items;\n        const schemas = items.map(item => isAnyZodType(item) ? mapItem(item) : {});\n        return Object.assign(Object.assign({}, mapNullableType('array')), this.versionSpecifics.mapTupleItems(schemas));\n    }\n}\n\nclass UnionTransformer {\n    constructor(options) {\n        this.options = options;\n    }\n    transform(zodSchema, mapNullableOfArray, mapItem) {\n        var _a, _b, _c;\n        const internalMetadata = Metadata.getInternalMetadata(zodSchema);\n        const preferredType = (_c = (_a = internalMetadata === null || internalMetadata === void 0 ? void 0 : internalMetadata.unionPreferredType) !== null && _a !== void 0 ? _a : (_b = this.options) === null || _b === void 0 ? void 0 : _b.unionPreferredType) !== null && _c !== void 0 ? _c : 'anyOf';\n        const options = this.flattenUnionTypes(zodSchema);\n        const schemas = options.map(schema => {\n            // If any of the underlying schemas of a union is .nullable then the whole union\n            // would be nullable. `mapNullableOfArray` would place it where it belongs.\n            // Therefor we are stripping the additional nullables from the inner schemas\n            // See https://github.com/asteasolutions/zod-to-openapi/issues/149\n            const optionToGenerate = this.unwrapNullable(schema);\n            return mapItem(optionToGenerate);\n        });\n        return {\n            [preferredType]: mapNullableOfArray(schemas),\n        };\n    }\n    flattenUnionTypes(schema) {\n        if (!isZodType(schema, 'ZodUnion')) {\n            return [schema];\n        }\n        const options = schema.def.options;\n        return options.flatMap(option => isAnyZodType(option) ? this.flattenUnionTypes(option) : []);\n    }\n    unwrapNullable(schema) {\n        if (isZodType(schema, 'ZodNullable')) {\n            const unwrapped = schema.unwrap();\n            if (isAnyZodType(unwrapped)) {\n                return this.unwrapNullable(unwrapped);\n            }\n        }\n        return schema;\n    }\n}\n\nclass DateTransformer {\n    transform(mapNullableType) {\n        return Object.assign(Object.assign({}, mapNullableType('string')), { format: 'date-time' });\n    }\n}\n\nclass LazyTransformer {\n    transform(zodSchema, mapItem, mapNullableType, mapNullableRef) {\n        const result = mapItem(zodSchema._zod.def.getter());\n        return LazyTransformer.mapRecursive(result, mapNullableType, mapNullableRef);\n    }\n    static mapRecursive(schema, mapNullableType, mapNullableRef) {\n        if ('$ref' in schema) {\n            return mapNullableRef(schema);\n        }\n        if (schema.type) {\n            return Object.assign(Object.assign({}, schema), mapNullableType(schema.type));\n        }\n        return schema;\n    }\n}\n\nclass TemplateLiteralTransformer {\n    transform(zodSchema, mapNullableType) {\n        const parts = zodSchema.def.parts;\n        const contentPattern = parts\n            .map(part => this.generatePattern(part))\n            .join('');\n        return Object.assign(Object.assign({}, mapNullableType('string')), { pattern: `^${contentPattern}$` });\n    }\n    generatePattern(part) {\n        if (typeof part === 'string' ||\n            typeof part === 'number' ||\n            typeof part === 'boolean' ||\n            typeof part === 'bigint' ||\n            part === null ||\n            part === undefined) {\n            return this.escapeRegex(String(part));\n        }\n        if (isZodType(part, 'ZodLiteral')) {\n            const value = part.def.values[0];\n            return this.escapeRegex(String(value));\n        }\n        if (isZodType(part, 'ZodNumber')) {\n            return '[+-]?\\\\d+(\\\\.\\\\d+)?';\n        }\n        if (isZodType(part, 'ZodBoolean')) {\n            return '(true|false)';\n        }\n        if (isZodType(part, 'ZodEnum')) {\n            const { values } = enumInfo(part.def.entries);\n            return `(${values.map(v => this.escapeRegex(String(v))).join('|')})`;\n        }\n        return '.*';\n    }\n    escapeRegex(str) {\n        return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n    }\n}\n\nclass OpenApiTransformer {\n    constructor(versionSpecifics, options) {\n        this.versionSpecifics = versionSpecifics;\n        this.objectTransformer = new ObjectTransformer();\n        this.stringTransformer = new StringTransformer();\n        this.numberTransformer = new NumberTransformer();\n        this.bigIntTransformer = new BigIntTransformer();\n        this.dateTransformer = new DateTransformer();\n        this.lazyTransformer = new LazyTransformer();\n        this.literalTransformer = new LiteralTransformer();\n        this.templateLiteralTransformer = new TemplateLiteralTransformer();\n        this.enumTransformer = new EnumTransformer();\n        this.arrayTransformer = new ArrayTransformer();\n        this.discriminatedUnionTransformer = new DiscriminatedUnionTransformer();\n        this.intersectionTransformer = new IntersectionTransformer();\n        this.recordTransformer = new RecordTransformer();\n        this.tupleTransformer = new TupleTransformer(versionSpecifics);\n        this.unionTransformer = new UnionTransformer(options);\n    }\n    transform(zodSchema, isNullable, mapItem, generateSchemaRef, defaultValue) {\n        if (isZodType(zodSchema, 'ZodNull')) {\n            return this.versionSpecifics.nullType;\n        }\n        if (isZodType(zodSchema, 'ZodUnknown') || isZodType(zodSchema, 'ZodAny')) {\n            return this.versionSpecifics.mapNullableType(undefined, isNullable);\n        }\n        if (isZodType(zodSchema, 'ZodObject')) {\n            return this.objectTransformer.transform(zodSchema, defaultValue, // verified on TS level from input\n            // verified on TS level from input\n            _ => this.versionSpecifics.mapNullableType(_, isNullable), mapItem);\n        }\n        const schema = this.transformSchemaWithoutDefault(zodSchema, isNullable, mapItem, generateSchemaRef);\n        return Object.assign(Object.assign({}, schema), { default: defaultValue });\n    }\n    transformSchemaWithoutDefault(zodSchema, isNullable, mapItem, generateSchemaRef) {\n        if (isZodType(zodSchema, 'ZodUnknown') || isZodType(zodSchema, 'ZodAny')) {\n            return this.versionSpecifics.mapNullableType(undefined, isNullable);\n        }\n        if (isZodType(zodSchema, 'ZodString')) {\n            return this.stringTransformer.transform(zodSchema, schema => this.versionSpecifics.mapNullableType(schema, isNullable));\n        }\n        if (isZodType(zodSchema, 'ZodNumber')) {\n            return this.numberTransformer.transform(zodSchema, schema => this.versionSpecifics.mapNullableType(schema, isNullable), _ => this.versionSpecifics.getNumberChecks(_));\n        }\n        if (isZodType(zodSchema, 'ZodBigInt')) {\n            return this.bigIntTransformer.transform(schema => this.versionSpecifics.mapNullableType(schema, isNullable));\n        }\n        if (isZodType(zodSchema, 'ZodBoolean')) {\n            return this.versionSpecifics.mapNullableType('boolean', isNullable);\n        }\n        if (isZodType(zodSchema, 'ZodLazy')) {\n            return this.lazyTransformer.transform(zodSchema, mapItem, schema => this.versionSpecifics.mapNullableType(schema, isNullable), schema => this.versionSpecifics.mapNullableOfRef(schema, isNullable));\n        }\n        if (isZodType(zodSchema, 'ZodLiteral')) {\n            return this.literalTransformer.transform(zodSchema, schema => this.versionSpecifics.mapNullableType(schema, isNullable));\n        }\n        if (isZodType(zodSchema, 'ZodTemplateLiteral')) {\n            return this.templateLiteralTransformer.transform(zodSchema, schema => this.versionSpecifics.mapNullableType(schema, isNullable));\n        }\n        if (isZodType(zodSchema, 'ZodEnum')) {\n            return this.enumTransformer.transform(zodSchema, isNullable, schema => this.versionSpecifics.mapNullableType(schema, isNullable));\n        }\n        if (isZodType(zodSchema, 'ZodArray')) {\n            return this.arrayTransformer.transform(zodSchema, _ => this.versionSpecifics.mapNullableType(_, isNullable), mapItem);\n        }\n        if (isZodType(zodSchema, 'ZodTuple')) {\n            return this.tupleTransformer.transform(zodSchema, _ => this.versionSpecifics.mapNullableType(_, isNullable), mapItem);\n        }\n        // Note: It is important that this goes above the union transformer\n        // because the discriminated union is still a union\n        if (isZodType(zodSchema, 'ZodDiscriminatedUnion')) {\n            return this.discriminatedUnionTransformer.transform(zodSchema, isNullable, _ => this.versionSpecifics.mapNullableOfArray(_, isNullable), mapItem, generateSchemaRef);\n        }\n        if (isZodType(zodSchema, 'ZodUnion')) {\n            return this.unionTransformer.transform(zodSchema, _ => this.versionSpecifics.mapNullableOfArray(_, isNullable), mapItem);\n        }\n        if (isZodType(zodSchema, 'ZodIntersection')) {\n            return this.intersectionTransformer.transform(zodSchema, isNullable, _ => this.versionSpecifics.mapNullableOfArray(_, isNullable), mapItem);\n        }\n        if (isZodType(zodSchema, 'ZodRecord')) {\n            return this.recordTransformer.transform(zodSchema, _ => this.versionSpecifics.mapNullableType(_, isNullable), mapItem);\n        }\n        if (isZodType(zodSchema, 'ZodDate')) {\n            return this.dateTransformer.transform(_ => this.versionSpecifics.mapNullableType(_, isNullable));\n        }\n        const refId = Metadata.getRefId(zodSchema);\n        throw new UnknownZodTypeError({\n            currentSchema: zodSchema.def,\n            schemaName: refId,\n        });\n    }\n}\n\nclass OpenAPIGenerator {\n    constructor(definitions, versionSpecifics, options) {\n        this.definitions = definitions;\n        this.versionSpecifics = versionSpecifics;\n        this.options = options;\n        this.schemaRefs = {};\n        this.paramRefs = {};\n        this.pathRefs = {};\n        this.rawComponents = [];\n        this.openApiTransformer = new OpenApiTransformer(versionSpecifics, options);\n        this.sortDefinitions();\n    }\n    generateDocumentData() {\n        this.definitions.forEach(definition => this.generateSingle(definition));\n        return {\n            components: this.buildComponents(),\n            paths: this.pathRefs,\n        };\n    }\n    generateComponents() {\n        this.definitions.forEach(definition => this.generateSingle(definition));\n        return {\n            components: this.buildComponents(),\n        };\n    }\n    buildComponents() {\n        var _a, _b, _c, _d;\n        const rawComponents = {};\n        this.rawComponents.forEach(({ componentType, name, component }) => {\n            var _a;\n            (_a = rawComponents[componentType]) !== null && _a !== void 0 ? _a : (rawComponents[componentType] = {});\n            rawComponents[componentType][name] = component;\n        });\n        const allSchemas = Object.assign(Object.assign({}, ((_a = rawComponents.schemas) !== null && _a !== void 0 ? _a : {})), this.filteredSchemaRefs);\n        const schemas = ((_b = this.options) === null || _b === void 0 ? void 0 : _b.sortComponents) === 'alphabetically'\n            ? sortObjectByKeys(allSchemas)\n            : allSchemas;\n        const allParameters = Object.assign(Object.assign({}, ((_c = rawComponents.parameters) !== null && _c !== void 0 ? _c : {})), this.paramRefs);\n        const parameters = ((_d = this.options) === null || _d === void 0 ? void 0 : _d.sortComponents) === 'alphabetically'\n            ? sortObjectByKeys(allParameters)\n            : allParameters;\n        return Object.assign(Object.assign({}, rawComponents), { schemas, parameters });\n    }\n    isNotPendingRefEntry(entry) {\n        return entry[1] !== 'pending';\n    }\n    get filteredSchemaRefs() {\n        const filtered = Object.entries(this.schemaRefs).filter(this.isNotPendingRefEntry);\n        return Object.fromEntries(filtered);\n    }\n    sortDefinitions() {\n        const generationOrder = [\n            'schema',\n            'parameter',\n            'component',\n            'route',\n        ];\n        this.definitions.sort((left, right) => {\n            // No type means \"plain zod schema\" => it comes as highest priority based on the array above\n            if (!('type' in left)) {\n                if (!('type' in right)) {\n                    return 0;\n                }\n                return -1;\n            }\n            if (!('type' in right)) {\n                return 1;\n            }\n            const leftIndex = generationOrder.findIndex(type => type === left.type);\n            const rightIndex = generationOrder.findIndex(type => type === right.type);\n            return leftIndex - rightIndex;\n        });\n    }\n    generateSingle(definition) {\n        if (!('type' in definition)) {\n            this.generateSchemaWithRef(definition);\n            return;\n        }\n        switch (definition.type) {\n            case 'parameter':\n                this.generateParameterDefinition(definition.schema);\n                return;\n            case 'schema':\n                this.generateSchemaWithRef(definition.schema);\n                return;\n            case 'route':\n                this.generateSingleRoute(definition.route);\n                return;\n            case 'component':\n                this.rawComponents.push(definition);\n                return;\n        }\n    }\n    generateParameterDefinition(zodSchema) {\n        const refId = Metadata.getRefId(zodSchema);\n        const result = this.generateParameter(zodSchema);\n        if (refId) {\n            this.paramRefs[refId] = result;\n        }\n        return result;\n    }\n    getParameterRef(schema, external) {\n        const metadata = Metadata.getOpenApiMetadata(schema);\n        const internalMetadata = Metadata.getInternalMetadata(schema);\n        const parameterMetadata = metadata === null || metadata === void 0 ? void 0 : metadata.param;\n        const existingRef = (internalMetadata === null || internalMetadata === void 0 ? void 0 : internalMetadata.refId)\n            ? this.paramRefs[internalMetadata.refId]\n            : undefined;\n        if (!(internalMetadata === null || internalMetadata === void 0 ? void 0 : internalMetadata.refId) || !existingRef) {\n            return undefined;\n        }\n        if ((parameterMetadata && existingRef.in !== parameterMetadata.in) ||\n            ((external === null || external === void 0 ? void 0 : external.in) && existingRef.in !== external.in)) {\n            throw new ConflictError(`Conflicting location for parameter ${existingRef.name}`, {\n                key: 'in',\n                values: compact([\n                    existingRef.in,\n                    external === null || external === void 0 ? void 0 : external.in,\n                    parameterMetadata === null || parameterMetadata === void 0 ? void 0 : parameterMetadata.in,\n                ]),\n            });\n        }\n        if ((parameterMetadata && existingRef.name !== parameterMetadata.name) ||\n            ((external === null || external === void 0 ? void 0 : external.name) && existingRef.name !== (external === null || external === void 0 ? void 0 : external.name))) {\n            throw new ConflictError(`Conflicting names for parameter`, {\n                key: 'name',\n                values: compact([\n                    existingRef.name,\n                    external === null || external === void 0 ? void 0 : external.name,\n                    parameterMetadata === null || parameterMetadata === void 0 ? void 0 : parameterMetadata.name,\n                ]),\n            });\n        }\n        return {\n            $ref: `#/components/parameters/${internalMetadata.refId}`,\n        };\n    }\n    generateInlineParameters(zodSchema, location) {\n        const metadata = Metadata.getOpenApiMetadata(zodSchema);\n        const parameterMetadata = metadata === null || metadata === void 0 ? void 0 : metadata.param;\n        const referencedSchema = this.getParameterRef(zodSchema, { in: location });\n        if (referencedSchema) {\n            return [referencedSchema];\n        }\n        if (isZodType(zodSchema, 'ZodObject')) {\n            const propTypes = zodSchema.def.shape;\n            const parameters = Object.entries(propTypes).map(([key, schema]) => {\n                var _a;\n                const innerMetadata = Metadata.getOpenApiMetadata(schema);\n                const referencedSchema = this.getParameterRef(schema, {\n                    in: location,\n                    name: key,\n                });\n                if (referencedSchema) {\n                    return referencedSchema;\n                }\n                const innerParameterMetadata = innerMetadata === null || innerMetadata === void 0 ? void 0 : innerMetadata.param;\n                if ((innerParameterMetadata === null || innerParameterMetadata === void 0 ? void 0 : innerParameterMetadata.name) &&\n                    innerParameterMetadata.name !== key) {\n                    throw new ConflictError(`Conflicting names for parameter`, {\n                        key: 'name',\n                        values: [key, innerParameterMetadata.name],\n                    });\n                }\n                if ((innerParameterMetadata === null || innerParameterMetadata === void 0 ? void 0 : innerParameterMetadata.in) &&\n                    innerParameterMetadata.in !== location) {\n                    throw new ConflictError(`Conflicting location for parameter ${(_a = innerParameterMetadata.name) !== null && _a !== void 0 ? _a : key}`, {\n                        key: 'in',\n                        values: [location, innerParameterMetadata.in],\n                    });\n                }\n                return this.generateParameter(schema, { name: key, in: location });\n            });\n            return parameters;\n        }\n        if ((parameterMetadata === null || parameterMetadata === void 0 ? void 0 : parameterMetadata.in) && parameterMetadata.in !== location) {\n            throw new ConflictError(`Conflicting location for parameter ${parameterMetadata.name}`, {\n                key: 'in',\n                values: [location, parameterMetadata.in],\n            });\n        }\n        return [this.generateParameter(zodSchema, { in: location })];\n    }\n    generateSimpleParameter(zodSchema, externalParamMetadata) {\n        const metadata = Metadata.getParamMetadata(zodSchema);\n        const paramMetadata = metadata === null || metadata === void 0 ? void 0 : metadata.param;\n        const mergedParamMetadata = Object.assign(Object.assign({}, paramMetadata), externalParamMetadata);\n        // TODO: Why are we not unwrapping here for isNullable as well?\n        const required = !isOptionalSchema(zodSchema) && !isNullableSchema(zodSchema);\n        const schema = this.generateSchemaWithRef(zodSchema);\n        return Object.assign({ schema,\n            required }, (Object.keys(mergedParamMetadata).length > 0\n            ? Metadata.buildParameterMetadata(mergedParamMetadata)\n            : {}));\n    }\n    generateParameter(zodSchema, externalParamMetadata) {\n        var _a, _b;\n        const metadata = Metadata.getOpenApiMetadata(zodSchema);\n        const paramMetadata = metadata === null || metadata === void 0 ? void 0 : metadata.param;\n        const paramName = (_a = externalParamMetadata === null || externalParamMetadata === void 0 ? void 0 : externalParamMetadata.name) !== null && _a !== void 0 ? _a : paramMetadata === null || paramMetadata === void 0 ? void 0 : paramMetadata.name;\n        const paramLocation = (_b = externalParamMetadata === null || externalParamMetadata === void 0 ? void 0 : externalParamMetadata.in) !== null && _b !== void 0 ? _b : paramMetadata === null || paramMetadata === void 0 ? void 0 : paramMetadata.in;\n        if (!paramName) {\n            throw new MissingParameterDataError({ missingField: 'name' });\n        }\n        if (!paramLocation) {\n            throw new MissingParameterDataError({\n                missingField: 'in',\n                paramName,\n            });\n        }\n        const baseParameter = this.generateSimpleParameter(zodSchema, externalParamMetadata);\n        return Object.assign(Object.assign({}, baseParameter), { in: paramLocation, name: paramName });\n    }\n    generateSchemaWithMetadata(zodSchema) {\n        const innerSchema = Metadata.unwrapChained(zodSchema);\n        const metadata = Metadata.getOpenApiMetadata(zodSchema);\n        const defaultValue = Metadata.getDefaultValue(zodSchema);\n        const refId = Metadata.getRefId(zodSchema);\n        // TODO: Do I need a similar implementation as bellow inside constructReferencedOpenAPISchema\n        if (refId && typeof this.schemaRefs[refId] === 'object') {\n            return this.schemaRefs[refId];\n        }\n        // If there is already a pending generation with this name\n        // reference it directly. This means that it is recursive\n        if (refId && this.schemaRefs[refId] === 'pending') {\n            const refSchema = { $ref: this.generateSchemaRef(refId) };\n            return this.versionSpecifics.mapNullableOfRef(refSchema, isNullableSchema(zodSchema));\n        }\n        // We start the generation by setting the ref to pending for\n        // any future recursive definition. It would get set to a proper\n        // value within `generateSchemaWithRef`\n        if (refId && !this.schemaRefs[refId]) {\n            this.schemaRefs[refId] = 'pending';\n        }\n        const result = (metadata === null || metadata === void 0 ? void 0 : metadata.type)\n            ? { type: metadata.type }\n            : this.toOpenAPISchema(innerSchema, isNullableSchema(zodSchema), defaultValue);\n        return metadata\n            ? Metadata.applySchemaMetadata(result, metadata)\n            : omitBy(result, isUndefined);\n    }\n    /**\n     * Same as above but applies nullable\n     */\n    constructReferencedOpenAPISchema(zodSchema) {\n        const metadata = Metadata.getOpenApiMetadata(zodSchema);\n        const innerSchema = Metadata.unwrapChained(zodSchema);\n        const defaultValue = Metadata.getDefaultValue(zodSchema);\n        const isNullable = isNullableSchema(zodSchema);\n        if (metadata === null || metadata === void 0 ? void 0 : metadata.type) {\n            return this.versionSpecifics.mapNullableType(metadata.type, isNullable);\n        }\n        const refId = Metadata.getRefId(zodSchema);\n        if (refId && typeof this.schemaRefs[refId] === 'object') {\n            return LazyTransformer.mapRecursive(this.schemaRefs[refId], schema => this.versionSpecifics.mapNullableType(schema, isNullable), schema => this.versionSpecifics.mapNullableOfRef(schema, isNullable));\n        }\n        // If there is already a pending generation with this name\n        // reference it directly. This means that it is recursive\n        if (refId && this.schemaRefs[refId] === 'pending') {\n            const refSchema = { $ref: this.generateSchemaRef(refId) };\n            return this.versionSpecifics.mapNullableOfRef(refSchema, isNullable);\n        }\n        // We start the generation by setting the ref to pending for\n        // any future recursive definition. It would get set to a proper\n        // value within `generateSchemaWithRef`\n        if (refId && !this.schemaRefs[refId]) {\n            this.schemaRefs[refId] = 'pending';\n        }\n        return this.toOpenAPISchema(innerSchema, isNullable, defaultValue);\n    }\n    /**\n     * Generates an OpenAPI SchemaObject or a ReferenceObject with all the provided metadata applied\n     */\n    generateSimpleSchema(zodSchema) {\n        const metadata = Metadata.getOpenApiMetadata(zodSchema);\n        const refId = Metadata.getRefId(zodSchema);\n        if (!refId || !this.schemaRefs[refId]) {\n            return this.generateSchemaWithMetadata(zodSchema);\n        }\n        const schemaRef = this.schemaRefs[refId];\n        const referenceObject = {\n            $ref: this.generateSchemaRef(refId),\n        };\n        // We are currently calculating this schema or there is nothing\n        if (this.schemaRefs[refId] === 'pending') {\n            return this.versionSpecifics.mapNullableOfRef(referenceObject, isNullableSchema(zodSchema));\n        }\n        // Metadata provided from .openapi() that is new to what we had already registered\n        const newMetadata = omitBy(Metadata.buildSchemaMetadata(metadata !== null && metadata !== void 0 ? metadata : {}), (value, key) => value === undefined || objectEquals(value, schemaRef[key]));\n        // Do not calculate schema metadata overrides if type is provided in .openapi\n        // https://github.com/asteasolutions/zod-to-openapi/pull/52/files/8ff707fe06e222bc573ed46cf654af8ee0b0786d#r996430801\n        if (newMetadata.type) {\n            return {\n                allOf: [referenceObject, newMetadata],\n            };\n        }\n        // New metadata from zodSchema properties.\n        const newSchemaMetadata = omitBy(this.constructReferencedOpenAPISchema(zodSchema), (value, key) => value === undefined || objectEquals(value, schemaRef[key]));\n        const appliedMetadata = Metadata.applySchemaMetadata(newSchemaMetadata, newMetadata);\n        if (Object.keys(appliedMetadata).length > 0) {\n            return {\n                allOf: [referenceObject, appliedMetadata],\n            };\n        }\n        return referenceObject;\n    }\n    /**\n     * Same as `generateSchema` but if the new schema is added into the\n     * referenced schemas, it would return a ReferenceObject and not the\n     * whole result.\n     *\n     * Should be used for nested objects, arrays, etc.\n     */\n    generateSchemaWithRef(zodSchema) {\n        const refId = Metadata.getRefId(zodSchema);\n        if (refId && !this.schemaRefs[refId]) {\n            this.schemaRefs[refId] = this.generateSimpleSchema(zodSchema);\n            return { $ref: this.generateSchemaRef(refId) };\n        }\n        return this.generateSimpleSchema(zodSchema);\n    }\n    generateSchemaRef(refId) {\n        return `#/components/schemas/${refId}`;\n    }\n    getRequestBody(requestBody) {\n        if (!requestBody) {\n            return;\n        }\n        const { content } = requestBody, rest = __rest(requestBody, [\"content\"]);\n        const requestBodyContent = this.getBodyContent(content);\n        return Object.assign(Object.assign({}, rest), { content: requestBodyContent });\n    }\n    getParameters(request) {\n        if (!request) {\n            return [];\n        }\n        const { headers } = request;\n        const query = this.cleanParameter(request.query);\n        const params = this.cleanParameter(request.params);\n        const cookies = this.cleanParameter(request.cookies);\n        const queryParameters = enhanceMissingParametersError(() => (query ? this.generateInlineParameters(query, 'query') : []), { location: 'query' });\n        const pathParameters = enhanceMissingParametersError(() => (params ? this.generateInlineParameters(params, 'path') : []), { location: 'path' });\n        const cookieParameters = enhanceMissingParametersError(() => (cookies ? this.generateInlineParameters(cookies, 'cookie') : []), { location: 'cookie' });\n        const headerParameters = enhanceMissingParametersError(() => {\n            if (Array.isArray(headers)) {\n                return headers.flatMap(header => this.generateInlineParameters(header, 'header'));\n            }\n            const cleanHeaders = this.cleanParameter(headers);\n            return cleanHeaders\n                ? this.generateInlineParameters(cleanHeaders, 'header')\n                : [];\n        }, { location: 'header' });\n        return [\n            ...pathParameters,\n            ...queryParameters,\n            ...headerParameters,\n            ...cookieParameters,\n        ];\n    }\n    cleanParameter(schema) {\n        if (!schema) {\n            return undefined;\n        }\n        if (isZodType(schema, 'ZodPipe')) {\n            const inSchema = schema._zod.def.in;\n            const outSchema = schema._zod.def.out;\n            // meaning transform\n            if (isZodType(inSchema, 'ZodObject')) {\n                return this.cleanParameter(inSchema);\n            }\n            // meaning preprocess\n            if (isZodType(outSchema, 'ZodObject')) {\n                return this.cleanParameter(outSchema);\n            }\n            return undefined;\n        }\n        return schema;\n    }\n    generatePath(route) {\n        const { method, path, request, responses } = route, pathItemConfig = __rest(route, [\"method\", \"path\", \"request\", \"responses\"]);\n        const generatedResponses = mapValues(responses, response => {\n            return this.getResponse(response);\n        });\n        const parameters = enhanceMissingParametersError(() => this.getParameters(request), { route: `${method} ${path}` });\n        const requestBody = this.getRequestBody(request === null || request === void 0 ? void 0 : request.body);\n        const routeDoc = {\n            [method]: Object.assign(Object.assign(Object.assign(Object.assign({}, pathItemConfig), (parameters.length > 0\n                ? {\n                    parameters: [...(pathItemConfig.parameters || []), ...parameters],\n                }\n                : {})), (requestBody ? { requestBody } : {})), { responses: generatedResponses }),\n        };\n        return routeDoc;\n    }\n    generateSingleRoute(route) {\n        const routeDoc = this.generatePath(route);\n        this.pathRefs[route.path] = Object.assign(Object.assign({}, this.pathRefs[route.path]), routeDoc);\n        return routeDoc;\n    }\n    getResponse(response) {\n        if (this.isReferenceObject(response)) {\n            return response;\n        }\n        const { content, headers } = response, rest = __rest(response, [\"content\", \"headers\"]);\n        const responseContent = content\n            ? { content: this.getBodyContent(content) }\n            : {};\n        if (!headers) {\n            return Object.assign(Object.assign({}, rest), responseContent);\n        }\n        const responseHeaders = isZodType(headers, 'ZodObject')\n            ? this.getResponseHeaders(headers)\n            : // This is input data so it is okay to cast in the common generator\n                // since this is the user's responsibility to keep it correct\n                headers;\n        return Object.assign(Object.assign(Object.assign({}, rest), { headers: responseHeaders }), responseContent);\n    }\n    isReferenceObject(schema) {\n        return '$ref' in schema;\n    }\n    getResponseHeaders(headers) {\n        const schemaShape = headers.def.shape;\n        const responseHeaders = mapValues(schemaShape, _ => this.generateSimpleParameter(_));\n        return responseHeaders;\n    }\n    getBodyContent(content) {\n        return mapValues(content, config => {\n            if (!config || !isAnyZodType(config.schema)) {\n                return config;\n            }\n            const { schema: configSchema } = config, rest = __rest(config, [\"schema\"]);\n            const schema = this.generateSchemaWithRef(configSchema);\n            return Object.assign({ schema }, rest);\n        });\n    }\n    toOpenAPISchema(zodSchema, isNullable, defaultValue) {\n        const result = this.openApiTransformer.transform(zodSchema, isNullable, _ => this.generateSchemaWithRef(_), _ => this.generateSchemaRef(_), defaultValue);\n        return result;\n    }\n}\n\nclass OpenApiGeneratorV30Specifics {\n    get nullType() {\n        return { nullable: true };\n    }\n    mapNullableOfArray(objects, isNullable) {\n        if (isNullable &&\n            !objects.some(object => objectEquals(object, this.nullType))) {\n            return [...objects, this.nullType];\n        }\n        return objects;\n    }\n    mapNullableType(type, isNullable) {\n        return Object.assign(Object.assign({}, (type ? { type } : undefined)), (isNullable ? this.nullType : undefined));\n    }\n    mapNullableOfRef(ref, isNullable) {\n        if (isNullable) {\n            return {\n                allOf: [ref, this.nullType],\n            };\n        }\n        return ref;\n    }\n    mapTupleItems(schemas) {\n        const uniqueSchemas = uniq(schemas);\n        return {\n            items: uniqueSchemas.length === 1\n                ? uniqueSchemas[0]\n                : { anyOf: uniqueSchemas },\n            minItems: schemas.length,\n            maxItems: schemas.length,\n        };\n    }\n    getNumberChecks(checks) {\n        return Object.assign({}, ...checks.map(check => {\n            switch (check._zod.def.check) {\n                case 'greater_than': {\n                    const greaterThanCheck = check;\n                    return greaterThanCheck._zod.def.inclusive\n                        ? { minimum: Number(greaterThanCheck._zod.def.value) }\n                        : {\n                            minimum: Number(greaterThanCheck._zod.def.value),\n                            exclusiveMinimum: true,\n                        };\n                }\n                case 'less_than': {\n                    const lessThanCheck = check;\n                    return lessThanCheck._zod.def.inclusive\n                        ? { maximum: Number(lessThanCheck._zod.def.value) }\n                        : {\n                            maximum: Number(lessThanCheck._zod.def.value),\n                            exclusiveMaximum: !lessThanCheck._zod.def.inclusive,\n                        };\n                }\n                default:\n                    return {};\n            }\n        }));\n    }\n}\n\nclass OpenApiGeneratorV3 {\n    constructor(definitions, options) {\n        const specifics = new OpenApiGeneratorV30Specifics();\n        this.generator = new OpenAPIGenerator(definitions, specifics, options);\n    }\n    generateDocument(config) {\n        const baseData = this.generator.generateDocumentData();\n        return Object.assign(Object.assign({}, config), baseData);\n    }\n    generateComponents() {\n        return this.generator.generateComponents();\n    }\n}\n\nclass OpenApiGeneratorV31Specifics {\n    get nullType() {\n        return { type: 'null' };\n    }\n    mapNullableOfArray(objects, isNullable) {\n        if (isNullable &&\n            !objects.some(object => objectEquals(object, this.nullType))) {\n            return [...objects, this.nullType];\n        }\n        return objects;\n    }\n    mapNullableType(type, isNullable) {\n        if (!type) {\n            // 'null' is considered a type in Open API 3.1.0 => not providing a type includes null\n            return {};\n        }\n        // Open API 3.1.0 made the `nullable` key invalid and instead you use type arrays\n        if (isNullable) {\n            const typeArray = Array.isArray(type) ? type : [type];\n            // If the type already contained null we do not want to have it twice.\n            // this is possible for example in z.null usages or z.lazy recursive usages\n            const nullableType = uniq([...typeArray, 'null']);\n            return { type: nullableType };\n        }\n        return { type };\n    }\n    mapNullableOfRef(ref, isNullable) {\n        if (isNullable) {\n            return {\n                oneOf: [ref, this.nullType],\n            };\n        }\n        return ref;\n    }\n    mapTupleItems(schemas) {\n        return {\n            prefixItems: schemas,\n        };\n    }\n    getNumberChecks(checks) {\n        return Object.assign({}, ...checks.map(check => {\n            switch (check._zod.def.check) {\n                case 'greater_than': {\n                    const greaterThanCheck = check;\n                    return greaterThanCheck._zod.def.inclusive\n                        ? { minimum: Number(greaterThanCheck._zod.def.value) }\n                        : { exclusiveMinimum: Number(greaterThanCheck._zod.def.value) };\n                }\n                case 'less_than': {\n                    const lessThanCheck = check;\n                    return lessThanCheck._zod.def.inclusive\n                        ? { maximum: Number(lessThanCheck._zod.def.value) }\n                        : { exclusiveMaximum: Number(lessThanCheck._zod.def.value) };\n                }\n                default:\n                    return {};\n            }\n        }));\n    }\n}\n\nfunction isWebhookDefinition(definition) {\n    return 'type' in definition && definition.type === 'webhook';\n}\nclass OpenApiGeneratorV31 {\n    constructor(definitions, options) {\n        this.definitions = definitions;\n        this.webhookRefs = {};\n        const specifics = new OpenApiGeneratorV31Specifics();\n        this.generator = new OpenAPIGenerator(this.definitions, specifics, options);\n    }\n    generateDocument(config) {\n        const baseDocument = this.generator.generateDocumentData();\n        this.definitions\n            .filter(isWebhookDefinition)\n            .forEach(definition => this.generateSingleWebhook(definition.webhook));\n        return Object.assign(Object.assign(Object.assign({}, config), baseDocument), { webhooks: this.webhookRefs });\n    }\n    generateComponents() {\n        return this.generator.generateComponents();\n    }\n    generateSingleWebhook(route) {\n        const routeDoc = this.generator.generatePath(route);\n        this.webhookRefs[route.path] = Object.assign(Object.assign({}, this.webhookRefs[route.path]), routeDoc);\n        return routeDoc;\n    }\n}\n\nexport { OpenAPIRegistry, OpenApiGeneratorV3, OpenApiGeneratorV31, extendZodWithOpenApi, getOpenApiMetadata, getRefId, zodToOpenAPIRegistry };\n","#!/usr/bin/env bun\n\nimport { buildCommand } from \"./commands/build.js\";\nimport { checkCommand } from \"./commands/check.js\";\nimport { createCommand } from \"./commands/create.js\";\nimport { dbCommand } from \"./commands/db.js\";\nimport { initCommand } from \"./commands/init.js\";\nimport { makeDocsCommand } from \"./commands/make-docs.js\";\nimport { VERSION } from \"../core-exports.js\";\n\nfunction printBanner() {\n\tconsole.log(`\n\\x1b[36m  Buntok CLI v${VERSION}\\x1b[0m\n`);\n}\n\nfunction printUsage() {\n\tconsole.log(`\n\\x1b[36mUsage:\\x1b[0m\n  buntok <command> [arguments] [options]\n\n\\x1b[36mCommands:\\x1b[0m\n  init                   Setup project: copy SKILL.md + configure package.json + generate env.ts\n  build                  Build project for production (output → .buntok/)\n  check                  Run TypeScript type check\n  create <entity>        Generate all files for entity (repo, service, controller)\n  db <command>           Database operations (migrate, seed, reset, generate, studio, status)\n  make:docs              Generate OpenAPI documentation automatically\n\n\\x1b[36mOptions (for create command):\\x1b[0m\n  --repo                 Generate only repository\n  --service              Generate only service\n  --controller           Generate only controller\n  --dry-run              Preview files without writing\n\n\\x1b[36mAliases:\\x1b[0m\n  g, gen, generate       Shortcut for create\n\n\\x1b[36mExamples:\\x1b[0m\n  buntok init                             # Initialize project setup\n  buntok build                            # Build project for production\n  buntok check                            # Run TypeScript type check\n  buntok create user                      # Generate all files for user entity\n  buntok g user --repo --service          # Generate repository and service only\n  buntok g user --dry-run                 # Preview what would be generated\n  buntok db migrate                       # Run pending migrations\n  buntok db seed                          # Seed database\n  buntok make:docs                        # Generate OpenAPI documentation\n`);\n}\n\nexport async function main() {\n\tconst args = process.argv.slice(2);\n\tconst command = args[0];\n\tconst arg1 = args[1];\n\n\tif (!command) {\n\t\tprintBanner();\n\t\tprintUsage();\n\t\tprocess.exitCode = 1;\n\t\treturn;\n\t}\n\n\tswitch (command) {\n\t\tcase \"init\":\n\t\t\tawait initCommand();\n\t\t\tbreak;\n\t\tcase \"build\":\n\t\t\tawait buildCommand();\n\t\t\tbreak;\n\t\tcase \"check\":\n\t\t\tawait checkCommand();\n\t\t\tbreak;\n\t\tcase \"g\":\n\t\tcase \"gen\":\n\t\tcase \"generate\":\n\t\tcase \"create\":\n\t\t\tif (!arg1) {\n\t\t\t\tconsole.error(\n\t\t\t\t\t\"\\x1b[31mError: entity name is required for create command\\x1b[0m\",\n\t\t\t\t);\n\t\t\t\tprocess.exitCode = 1;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait createCommand(arg1, args.slice(2));\n\t\t\tbreak;\n\t\tcase \"db\":\n\t\t\tawait dbCommand(args.slice(1));\n\t\t\tbreak;\n\t\tcase \"make:docs\":\n\t\t\tawait makeDocsCommand();\n\t\t\tbreak;\n\t\tdefault: {\n\t\t\tconst commands = [\n\t\t\t\t\"init\",\n\t\t\t\t\"build\",\n\t\t\t\t\"check\",\n\t\t\t\t\"create\",\n\t\t\t\t\"g\",\n\t\t\t\t\"db\",\n\t\t\t\t\"make:docs\",\n\t\t\t];\n\t\t\t// Simple fuzzy match: prefix or contains\n\t\t\tconst closest = commands.find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.startsWith(command) ||\n\t\t\t\t\tcommand.startsWith(c) ||\n\t\t\t\t\tc.includes(command) ||\n\t\t\t\t\tcommand.includes(c),\n\t\t\t);\n\t\t\tconst hint = closest ? `\\n  Did you mean: buntok ${closest}?` : \"\";\n\t\t\tconsole.error(`\\x1b[31mUnknown command: ${command}\\x1b[0m${hint}`);\n\t\t\tprintUsage();\n\t\t\tprocess.exitCode = 1;\n\t\t\treturn;\n\t\t}\n\t}\n}\n\nmain();\n"]}