shokupan 0.10.4 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{analyzer-CKLGLFtx.cjs → analyzer-BAhvpNY_.cjs} +2 -7
- package/dist/{analyzer-CKLGLFtx.cjs.map → analyzer-BAhvpNY_.cjs.map} +1 -1
- package/dist/{analyzer-BqIe1p0R.js → analyzer-CnKnQ5KV.js} +3 -8
- package/dist/{analyzer-BqIe1p0R.js.map → analyzer-CnKnQ5KV.js.map} +1 -1
- package/dist/{analyzer.impl-D9Yi1Hax.cjs → analyzer.impl-CfpMu4-g.cjs} +586 -40
- package/dist/analyzer.impl-CfpMu4-g.cjs.map +1 -0
- package/dist/{analyzer.impl-CV6W1Eq7.js → analyzer.impl-DCiqlXI5.js} +586 -40
- package/dist/analyzer.impl-DCiqlXI5.js.map +1 -0
- package/dist/cli.cjs +206 -18
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +206 -18
- package/dist/cli.js.map +1 -1
- package/dist/context.d.ts +6 -1
- package/dist/index.cjs +2405 -1008
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2402 -1006
- package/dist/index.js.map +1 -1
- package/dist/plugins/application/api-explorer/static/explorer-client.mjs +423 -30
- package/dist/plugins/application/api-explorer/static/style.css +351 -10
- package/dist/plugins/application/api-explorer/static/theme.css +7 -2
- package/dist/plugins/application/asyncapi/generator.d.ts +4 -0
- package/dist/plugins/application/asyncapi/static/asyncapi-client.mjs +154 -22
- package/dist/plugins/application/asyncapi/static/style.css +24 -8
- package/dist/plugins/application/dashboard/fetch-interceptor.d.ts +107 -0
- package/dist/plugins/application/dashboard/metrics-collector.d.ts +38 -2
- package/dist/plugins/application/dashboard/plugin.d.ts +44 -1
- package/dist/plugins/application/dashboard/static/charts.js +127 -62
- package/dist/plugins/application/dashboard/static/client.js +160 -0
- package/dist/plugins/application/dashboard/static/graph.mjs +167 -56
- package/dist/plugins/application/dashboard/static/reactflow.css +20 -10
- package/dist/plugins/application/dashboard/static/registry.js +112 -8
- package/dist/plugins/application/dashboard/static/requests.js +868 -58
- package/dist/plugins/application/dashboard/static/styles.css +186 -14
- package/dist/plugins/application/dashboard/static/tabs.js +44 -9
- package/dist/plugins/application/dashboard/static/theme.css +7 -2
- package/dist/plugins/application/openapi/analyzer.impl.d.ts +61 -1
- package/dist/plugins/application/openapi/openapi.d.ts +3 -0
- package/dist/plugins/application/shared/ast-utils.d.ts +7 -0
- package/dist/router.d.ts +55 -16
- package/dist/shokupan.d.ts +7 -2
- package/dist/util/adapter/adapters.d.ts +19 -0
- package/dist/util/adapter/filesystem.d.ts +20 -0
- package/dist/util/controller-scanner.d.ts +4 -0
- package/dist/util/cpu-monitor.d.ts +2 -0
- package/dist/util/middleware-tracker.d.ts +10 -0
- package/dist/util/types.d.ts +37 -0
- package/package.json +5 -5
- package/dist/analyzer.impl-CV6W1Eq7.js.map +0 -1
- package/dist/analyzer.impl-D9Yi1Hax.cjs.map +0 -1
- package/dist/http-server-BEMPIs33.cjs +0 -85
- package/dist/http-server-BEMPIs33.cjs.map +0 -1
- package/dist/http-server-CCeagTyU.js +0 -68
- package/dist/http-server-CCeagTyU.js.map +0 -1
- package/dist/plugins/application/dashboard/static/poll.js +0 -146
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"analyzer.impl-CV6W1Eq7.js","sources":["../src/plugins/application/openapi/analyzer.impl.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport ts from 'typescript';\n\n/**\n * File information collected during scan\n */\ninterface CollectedFile {\n path: string;\n type: 'ts' | 'tsx' | 'cts' | 'dts' | 'mts' | 'js' | 'jsx' | 'mjs' | 'cjs' | 'map';\n content?: string;\n}\n\n/**\n * Route information extracted from AST\n */\nexport interface RouteInfo {\n method: string;\n path: string;\n handlerName?: string;\n handlerSource?: string;\n requestTypes?: {\n body?: any;\n query?: Record<string, string>;\n params?: Record<string, string>;\n headers?: Record<string, string>;\n };\n responseType?: string;\n responseSchema?: any;\n summary?: string;\n description?: string;\n tags?: string[];\n operationId?: string;\n emits?: { event: string; payload?: any; location?: { startLine: number; endLine: number; }; }[];\n sourceContext?: {\n file: string;\n startLine: number;\n endLine: number;\n highlights?: { startLine: number; endLine: number; type: 'emit' | 'return-success' | 'return-warning'; }[];\n };\n}\n\n/**\n * Dependency information\n */\ninterface DependencyInfo {\n packageName: string;\n version?: string;\n importPath: string;\n isExternal: boolean;\n}\n\n/**\n * Application/Router instance found in code\n */\nexport interface ApplicationInstance {\n name: string;\n filePath: string;\n className: 'Shokupan' | 'ShokupanRouter' | 'Controller';\n controllerPrefix?: string;\n routes: RouteInfo[];\n mounted: MountInfo[];\n}\n\ninterface MountInfo {\n prefix: string;\n target: string; // Controller/Router name or file path\n targetFilePath?: string;\n dependency?: DependencyInfo;\n sourceContext?: {\n file: string;\n startLine: number;\n endLine: number;\n };\n}\n\n/**\n * Main analyzer class\n */\nexport class OpenAPIAnalyzer {\n private files: CollectedFile[] = [];\n private applications: ApplicationInstance[] = [];\n private program?: ts.Program;\n\n private entrypoint?: string;\n\n constructor(private rootDir: string, entrypoint?: string) {\n if (entrypoint) {\n this.entrypoint = path.resolve(entrypoint);\n }\n }\n\n /**\n * Main analysis entry point\n */\n /**\n * Main analysis entry point\n */\n public async analyze(): Promise<{ applications: ApplicationInstance[]; }> {\n // console.log(`Analyzing directory: ${this.rootDir}`);\n\n // Step 1: Parse TypeScript files (which might involve scanning or using entrypoint)\n await this.parseTypeScriptFiles();\n\n // Step 2: Process source maps if needed\n await this.processSourceMaps();\n\n // Step 3: Find Shokupan applications\n await this.findApplications();\n\n // Step 4: Extract route information\n await this.extractRoutes();\n\n // Step 5: Prune unreachable GenericModules\n this.pruneApplications();\n\n // Return the raw application data for further processing\n return { applications: this.applications };\n }\n\n /**\n * Remove GenericModules that are not mounted by any Shokupan application/router\n */\n private pruneApplications(): void {\n const reachable = new Set<string>();\n const queue: ApplicationInstance[] = [];\n\n // Seed with explicit applications (Shokupan, ShokupanRouter, Controller)\n for (const app of this.applications) {\n if (app.name !== 'GenericModule') {\n reachable.add(app.filePath);\n queue.push(app);\n }\n }\n\n // BFS to find all reachable modules via mounts\n while (queue.length > 0) {\n const app = queue.shift()!;\n\n for (const mount of app.mounted) {\n if (mount.targetFilePath && !reachable.has(mount.targetFilePath)) {\n reachable.add(mount.targetFilePath);\n\n // Find the app instance for this file\n const mountedApp = this.applications.find(a => a.filePath === mount.targetFilePath);\n if (mountedApp) {\n queue.push(mountedApp);\n }\n }\n }\n }\n\n // Filter out unreachable GenericModules\n const initialCount = this.applications.length;\n this.applications = this.applications.filter(app => {\n if (app.name === 'GenericModule' && !reachable.has(app.filePath)) {\n // console.log(`[Analyzer] Pruning unreachable module: ${app.filePath}`);\n return false;\n }\n return true;\n });\n\n // console.log(`[Analyzer] Pruned ${initialCount - this.applications.length} unreachable modules.`);\n }\n\n /**\n * Recursively scan directory for TypeScript/JavaScript files\n */\n private async scanDirectory(dir: string): Promise<void> {\n try {\n const entries = fs.readdirSync(dir, { withFileTypes: true });\n\n for (let i = 0; i < entries.length; i++) {\n const entry = entries[i];\n const fullPath = path.join(dir, entry.name);\n\n // Skip node_modules for source files (we'll handle deps separately)\n if (entry.isDirectory()) {\n if ([\"node_modules\", \".git\", \"dist\"].includes(entry.name)) {\n continue;\n }\n await this.scanDirectory(fullPath);\n } else {\n const ext = path.extname(entry.name);\n if ([\".ts\", \".tsx\", \".cts\", \".dts\", \".mts\", \".js\", \".jsx\", \".mjs\", \".cjs\", \".map\"].includes(ext)) {\n this.files.push({ path: fullPath, type: ext.slice(1) as any });\n }\n }\n }\n } catch (error: any) {\n // Silently skip directories that don't exist or can't be read\n if (error.code !== 'ENOENT' && error.code !== 'EACCES') {\n throw error;\n }\n }\n }\n\n /**\n * Process source maps to reconstruct TypeScript\n */\n private async processSourceMaps(): Promise<void> {\n // Find JS files that have corresponding .map files\n const jsFiles = this.files.filter(f => f.type === 'js');\n const mapFiles = this.files.filter(f => f.type === 'map');\n\n for (let i = 0; i < jsFiles.length; i++) {\n const jsFile = jsFiles[i];\n const mapFile = mapFiles.find(m => m.path === jsFile.path + '.map');\n\n if (mapFile && !this.files.some(f => f.path === jsFile.path.replace(/\\.js$/, '.ts'))) {\n // We have .js + .map but no .ts file\n // For now, we'll just parse the JS file directly\n // Full source map reconstruction would require the 'source-map' library\n console.log(`Note: Found ${jsFile.path} with source map but no .ts file. Will parse JS directly.`);\n }\n }\n }\n\n /**\n * Parse TypeScript files and create AST\n */\n private async parseTypeScriptFiles(): Promise<void> {\n let fileNames: string[] = [];\n\n if (this.entrypoint) {\n // If entrypoint is provided, let TypeScript resolve dependencies\n fileNames = [this.entrypoint];\n // console.log(`[Analyzer] Using entrypoint: ${this.entrypoint}`);\n } else {\n // Otherwise, scan the directory manually\n await this.scanDirectory(this.rootDir);\n const tsFiles = this.files.filter(f => f.type === 'ts' || f.type === 'js');\n fileNames = tsFiles.map(f => f.path);\n // console.log(`[Analyzer] Scanning directory, found ${fileNames.length} files`);\n }\n\n // Create TypeScript program\n this.program = ts.createProgram(fileNames, {\n target: ts.ScriptTarget.ESNext,\n module: ts.ModuleKind.ESNext,\n allowJs: true,\n moduleResolution: ts.ModuleResolutionKind.Node10,\n rootDir: this.rootDir,\n skipLibCheck: true,\n skipDefaultLibCheck: true,\n });\n\n // If using entrypoint, update this.files with what TS found in the project\n if (this.entrypoint) {\n this.files = this.program.getSourceFiles()\n .filter(sf => !sf.fileName.includes('node_modules'))\n .map(sf => ({ path: sf.fileName, type: sf.fileName.endsWith('.js') ? 'js' : 'ts' }));\n }\n }\n\n /**\n * Find all Shokupan/ShokupanRouter instances\n */\n private async findApplications(): Promise<void> {\n if (!this.program) return;\n\n const typeChecker = this.program.getTypeChecker();\n\n for (let i = 0; i < this.program.getSourceFiles().length; i++) {\n const sourceFile = this.program.getSourceFiles()[i];\n // Skip node_modules and declaration files/tests\n if (sourceFile.fileName.includes('node_modules')) continue;\n if (sourceFile.isDeclarationFile) continue;\n\n // Allow analyzing test files if we are pointing explicitly to a test directory (fixtures)\n // OR if the file is in a fixtures directory (used for OpenAPI spec generation from test apps)\n // OR if the file IS the entrypoint\n const isTestEnv = this.rootDir.includes('/test/') ||\n this.rootDir.includes('/tests/') ||\n this.rootDir.includes('/fixtures/') ||\n (this.entrypoint && (this.entrypoint.includes('/test/') || this.entrypoint.includes('/tests/')));\n\n const isFixtureFile = sourceFile.fileName.includes('/fixtures/');\n const isEntrypoint = this.entrypoint && sourceFile.fileName === this.entrypoint;\n\n // console.log(`[Analyzer] check ${sourceFile.fileName}: isTestEnv=${isTestEnv}, isFixture=${isFixtureFile}, isEntry=${isEntrypoint}`);\n\n if (!isTestEnv && !isFixtureFile && !isEntrypoint) {\n if (sourceFile.fileName.includes('/test/') || sourceFile.fileName.includes('/tests/')) {\n // console.log(`[Analyzer] Skipping test file: ${sourceFile.fileName}`);\n continue;\n }\n if (sourceFile.fileName.includes('/base_test/')) continue;\n if (sourceFile.fileName.includes('.test.ts') || sourceFile.fileName.includes('.spec.ts')) continue;\n }\n\n ts.forEachChild(sourceFile, (node) => {\n this.visitNode(node, sourceFile, typeChecker);\n });\n }\n }\n\n /**\n * Visit AST node to find application instances\n */\n private visitNode(node: ts.Node, sourceFile: ts.SourceFile, typeChecker: ts.TypeChecker): void {\n // Look for: class FooController ... @Controller(...)\n if (ts.isClassDeclaration(node)) {\n // Check for @Controller decorator\n let isController = false;\n let controllerPrefix: string | undefined;\n let className = node.name?.getText(sourceFile);\n\n const decorators: ts.Decorator[] = (node as any).decorators || node.modifiers?.filter((m: any) => ts.isDecorator(m));\n\n if (decorators) {\n const controllerDecorator = decorators.find((d: any) => {\n const expr = d.expression;\n if (ts.isCallExpression(expr)) {\n const identifier = expr.expression.getText(sourceFile);\n return identifier === 'Controller';\n }\n return false;\n });\n if (controllerDecorator) {\n isController = true;\n const expr = controllerDecorator.expression as ts.CallExpression;\n if (expr.arguments.length > 0 && ts.isStringLiteral(expr.arguments[0])) {\n controllerPrefix = expr.arguments[0].text;\n }\n }\n }\n\n // Fallback: Check for method decorators (@Get, @Post, etc.)\n if (!isController) {\n const hasRouteDecorators = node.members.some(m => {\n // Trust 175 as MethodDeclaration if TS matches mostly, or just check members\n if (ts.isMethodDeclaration(m) || m.kind === 175 || m.kind === 170 || m.kind === 171) {\n const decs = (m as any).decorators || (m as any).modifiers?.filter((mod: any) => ts.isDecorator(mod));\n if (decs) {\n return decs.some((d: any) => {\n const expr = d.expression;\n if (ts.isCallExpression(expr)) {\n const identifier = expr.expression.getText(sourceFile);\n return ['get', 'post', 'put', 'delete', 'patch', 'options', 'head', 'event'].includes(identifier.toLowerCase());\n }\n return false;\n });\n }\n }\n return false;\n });\n if (hasRouteDecorators) {\n isController = true;\n }\n }\n\n if (isController && className) {\n this.applications.push({\n name: className,\n filePath: sourceFile.fileName,\n className: 'Controller',\n controllerPrefix,\n routes: [],\n mounted: []\n });\n }\n }\n\n // Look for: new Shokupan() or new ShokupanRouter()\n if (ts.isVariableDeclaration(node) && node.initializer) {\n if (ts.isNewExpression(node.initializer)) {\n const expr = node.initializer;\n const className = expr.expression.getText(sourceFile);\n\n if (className === 'Shokupan' || className === 'ShokupanRouter') {\n const varName = node.name.getText(sourceFile);\n\n this.applications.push({\n name: varName,\n filePath: sourceFile.fileName,\n className: className as 'Shokupan' | 'ShokupanRouter',\n routes: [],\n mounted: []\n });\n }\n }\n }\n\n // Look for standalone route calls in files that don't instantiate an app\n if (ts.isCallExpression(node)) {\n const expr = node.expression;\n if (ts.isPropertyAccessExpression(expr)) {\n const method = expr.name.getText(sourceFile);\n if (['get', 'post', 'put', 'delete', 'patch', 'options', 'head', 'event', 'on'].includes(method)) {\n const existing = this.applications.find(a => a.filePath === sourceFile.fileName);\n if (!existing) {\n this.applications.push({\n name: 'GenericModule',\n filePath: sourceFile.fileName,\n className: 'Shokupan',\n routes: [],\n mounted: []\n });\n }\n }\n }\n }\n\n // Recursively visit children\n ts.forEachChild(node, (child) => this.visitNode(child, sourceFile, typeChecker));\n }\n\n /**\n * Extract route information from applications\n */\n private async extractRoutes(): Promise<void> {\n if (!this.program) return;\n\n for (let i = 0; i < this.applications.length; i++) {\n const app = this.applications[i];\n const sourceFile = this.program.getSourceFile(app.filePath);\n if (!sourceFile) continue;\n\n this.extractRoutesFromFile(app, sourceFile);\n }\n }\n\n /**\n * Extract routes from a Controller class\n */\n private extractRoutesFromController(app: ApplicationInstance, classNode: ts.ClassDeclaration, sourceFile: ts.SourceFile): void {\n const methods = classNode.members.filter(m => ts.isMethodDeclaration(m) || m.kind === 175);\n\n for (let i = 0; i < methods.length; i++) {\n const method = methods[i];\n const methodNode = method as any; // Cast to any to access decorators in newer/older TS mix\n if (!methodNode.decorators && !methodNode.modifiers) continue;\n\n const decorators = methodNode.decorators || methodNode.modifiers?.filter((m: any) => ts.isDecorator(m));\n if (!decorators) continue;\n\n // Find route decorators: @Get, @Post, etc.\n const routeDecorator = decorators.find((d: any) => {\n const expr = d.expression;\n if (ts.isCallExpression(expr)) {\n const identifier = expr.expression.getText(sourceFile);\n return ['get', 'post', 'put', 'delete', 'patch', 'options', 'head', 'event'].includes(identifier.toLowerCase());\n }\n return false;\n });\n\n if (routeDecorator && ts.isCallExpression(routeDecorator.expression)) {\n const decoratorName = routeDecorator.expression.expression.getText(sourceFile);\n const httpMethod = decoratorName.toUpperCase();\n let routePath = '/';\n\n // Get path\n const pathArg = routeDecorator.expression.arguments[0];\n if (pathArg && ts.isStringLiteral(pathArg)) {\n routePath = pathArg.text;\n }\n\n // Normalize path params: /users/:id -> /users/{id}\n routePath = routePath.replace(/:([a-zA-Z0-9_]+)/g, '{$1}');\n\n // Handler Name (Class.method)\n const handlerName = `${app.name}.${methodNode.name.getText(sourceFile)}`;\n\n // Analyze the method body\n const analysis = this.analyzeHandler(methodNode, sourceFile);\n\n app.routes.push({\n method: httpMethod,\n path: routePath,\n handlerName: handlerName,\n handlerSource: methodNode.getText(sourceFile),\n requestTypes: analysis.requestTypes,\n responseType: analysis.responseType,\n responseSchema: analysis.responseSchema,\n emits: analysis.emits,\n sourceContext: {\n file: sourceFile.fileName,\n startLine: sourceFile.getLineAndCharacterOfPosition(methodNode.getStart()).line + 1,\n endLine: sourceFile.getLineAndCharacterOfPosition(methodNode.getEnd()).line + 1,\n highlights: analysis.highlights\n }\n });\n }\n }\n };\n\n /**\n * Extract routes from a specific file\n */\n private extractRoutesFromFile(app: ApplicationInstance, sourceFile: ts.SourceFile): void {\n if (app.className === 'Controller') {\n const classNode = sourceFile.statements.find(s => ts.isClassDeclaration(s) && s.name?.getText(sourceFile) === app.name) as ts.ClassDeclaration;\n if (classNode) {\n this.extractRoutesFromController(app, classNode, sourceFile);\n }\n } else {\n // Existing logic for app/router instances\n const visit = (node: ts.Node) => {\n // ... (rest of the existing logic)\n // Look for method calls: app.get(...), app.post(...), app.mount(...)\n if (ts.isCallExpression(node)) {\n const expr = node.expression;\n\n if (ts.isPropertyAccessExpression(expr)) {\n const objName = expr.expression.getText(sourceFile);\n const methodName = expr.name.getText(sourceFile);\n\n // Check if this is our application instance\n // For GenericModule, we accept any variable name as it's likely an argument (e.g. app.event)\n if (objName === app.name || (app.name === 'GenericModule' && node.arguments.length >= 2)) {\n // console.log(`[Analyzer] Inspecting route call: ${objName}.${methodName} in ${app.name}`);\n if (['get', 'post', 'put', 'delete', 'patch', 'options', 'head', 'on', 'event'].includes(methodName.toLowerCase())) {\n // Extract route info\n const route = this.extractRouteFromCall(node, sourceFile, methodName.toUpperCase());\n if (route) {\n app.routes.push(route);\n }\n } else if (methodName === 'mount') {\n // Extract mount info\n const mount = this.extractMountFromCall(node, sourceFile);\n if (mount) {\n app.mounted.push(mount);\n }\n }\n }\n }\n }\n\n ts.forEachChild(node, visit);\n };\n\n ts.forEachChild(sourceFile, visit);\n }\n }\n\n /**\n * Extract route information from a route call (e.g., app.get('/path', handler))\n */\n private extractRouteFromCall(node: ts.CallExpression, sourceFile: ts.SourceFile, method: string): RouteInfo | null {\n const args = node.arguments;\n\n if (args.length < 2) return null;\n\n const pathArg = args[0];\n let routePath = '/';\n\n if (ts.isStringLiteral(pathArg)) {\n routePath = pathArg.text;\n } else {\n routePath = '__DYNAMIC_EVENT__';\n }\n\n // Normalize path params: /users/:id -> /users/{id}\n // This ensures matching with runtime-generated keys\n const normalizedPath = routePath.replace(/:([a-zA-Z0-9_]+)/g, '{$1}');\n\n let metadata: any = {};\n\n // Check for metadata argument (3 args: path, metadata, handler)\n if (args.length >= 3 && ts.isObjectLiteralExpression(args[1])) {\n const metaObj = args[1];\n // Extract summary, description, tags, etc.\n const rawMeta = this.convertExpressionToSchema(metaObj, sourceFile, new Map());\n\n // convertExpressionToSchema returns a schema-like object { type: 'object', properties: {...} }\n // But we want the actual values if they are literals.\n // convertExpressionToSchema is designed for SCHEMAS, not values.\n // We need a simpler value extractor or just parse the props directly for this specific case.\n\n for (let i = 0; i < metaObj.properties.length; i++) {\n const prop = metaObj.properties[i];\n if (ts.isPropertyAssignment(prop) && prop.name) {\n const name = prop.name.getText(sourceFile);\n const val = prop.initializer;\n\n if (ts.isStringLiteral(val)) {\n metadata[name] = val.text;\n } else if (ts.isArrayLiteralExpression(val) && name === 'tags') {\n metadata.tags = val.elements\n .filter(e => ts.isStringLiteral(e))\n .map(e => (e as ts.StringLiteral).text);\n } else if (name === 'operationId' && ts.isStringLiteral(val)) {\n metadata.operationId = val.text;\n }\n }\n }\n }\n\n // Extract handler information\n const handlerArg = args[args.length - 1];\n const handlerInfo = this.analyzeHandler(handlerArg, sourceFile);\n\n return {\n method,\n path: normalizedPath,\n handlerName: handlerArg.getText(sourceFile).substring(0, 50), // Truncate for display\n handlerSource: handlerArg.getText(sourceFile),\n requestTypes: handlerInfo.requestTypes,\n responseType: handlerInfo.responseType,\n responseSchema: handlerInfo.responseSchema,\n emits: handlerInfo.emits,\n ...metadata,\n sourceContext: {\n file: sourceFile.fileName,\n startLine: sourceFile.getLineAndCharacterOfPosition(handlerArg.getStart()).line + 1,\n endLine: sourceFile.getLineAndCharacterOfPosition(handlerArg.getEnd()).line + 1,\n highlights: handlerInfo.highlights\n }\n };\n }\n\n /**\n * Analyze a route handler to extract type information\n */\n private analyzeHandler(handler: ts.Node, sourceFile: ts.SourceFile): {\n requestTypes?: RouteInfo['requestTypes'];\n responseType?: string;\n responseSchema?: any;\n emits?: { event: string; payload?: any; location?: { startLine: number; endLine: number; }; }[];\n highlights?: { startLine: number; endLine: number; type: 'emit' | 'return-success' | 'return-warning'; }[];\n } {\n const requestTypes: RouteInfo['requestTypes'] = {};\n let responseType: string | undefined;\n let responseSchema: any | undefined;\n let hasExplicitReturnType = false;\n const emits: { event: string; payload?: any; location?: { startLine: number; endLine: number; }; }[] = [];\n const highlights: { startLine: number; endLine: number; type: 'emit' | 'return-success' | 'return-warning'; }[] = [];\n\n // Simple scope to track variable types (name -> schema)\n const scope = new Map<string, any>();\n\n // Pre-populate scope with function parameters\n if (ts.isFunctionLike(handler)) {\n handler.parameters.forEach(param => {\n if (ts.isIdentifier(param.name) && param.type) {\n const paramName = param.name.getText(sourceFile);\n // Resolving TypeReference for parameters (e.g. User) would require partial type checker or expanded scope logic\n // For now, we rely on basic types\n const paramType = this.convertTypeNodeToSchema(param.type, sourceFile);\n if (paramType) {\n scope.set(paramName, paramType);\n }\n }\n });\n\n // Check for explicit return type annotation\n if (handler.type) {\n const returnSchema = this.convertTypeNodeToSchema(handler.type, sourceFile);\n if (returnSchema) {\n responseSchema = returnSchema;\n responseType = returnSchema.type;\n hasExplicitReturnType = true;\n }\n }\n }\n\n // Helper to analyze an expression that is being returned (either explicitly or implicitly)\n const analyzeReturnExpression = (expr: ts.Expression) => {\n let node = expr;\n // Unwrap await\n if (ts.isAwaitExpression(node)) {\n node = node.expression;\n }\n\n\n // Case 1: return ctx.json(...) or ctx.text(...)\n if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression)) {\n const callObj = node.expression.expression.getText(sourceFile);\n const callProp = node.expression.name.getText(sourceFile);\n\n if (callObj === 'ctx' || callObj.endsWith('.ctx')) {\n if (callProp === 'json') {\n if (node.arguments.length > 0) {\n responseSchema = this.convertExpressionToSchema(node.arguments[0], sourceFile, scope);\n responseType = 'object';\n }\n return;\n }\n else if (callProp === 'text') {\n responseType = 'string';\n return;\n }\n else if (callProp === 'html' || callProp === 'jsx') {\n responseType = 'html';\n return;\n }\n }\n }\n\n // Case 2: Direct object return\n // Only use this if we haven't found a better schema yet, or if it looks specific\n // And if we don't have an explicit return type\n if (!hasExplicitReturnType && (!responseSchema || responseSchema.type === 'object')) {\n const schema = this.convertExpressionToSchema(node, sourceFile, scope);\n if (schema && (schema.type !== 'object' || Object.keys(schema.properties || {}).length > 0)) {\n responseSchema = schema;\n responseType = schema.type;\n }\n }\n\n // Fallback to text matching if schema inference failed and we still don't have a type\n if (!responseSchema && !responseType) {\n const returnText = node.getText(sourceFile);\n if (returnText.startsWith('{')) {\n responseType = 'object';\n } else if (returnText.startsWith('[')) {\n responseType = 'array';\n } else if (returnText.startsWith('\"') || returnText.startsWith(\"'\")) {\n responseType = 'string';\n }\n }\n };\n\n // Handle arrow functions\n let body: ts.Block | undefined;\n // Also check for Kind 175 (Method/Accessor in some TS versions)\n if (ts.isArrowFunction(handler) || ts.isFunctionExpression(handler) || ts.isMethodDeclaration(handler) || handler.kind === 175) {\n // TS method has .body which is FunctionBody (Block) or undefined\n body = (handler as any).body;\n\n // Visit the handler body to find ctx usage\n const visit = (node: ts.Node) => {\n // Track variable declarations\n if (ts.isVariableDeclaration(node)) {\n if (node.initializer && ts.isIdentifier(node.name)) {\n const varName = node.name.getText(sourceFile);\n\n // Check if initializer is a type assertion on ctx.body()\n let initializer = node.initializer;\n if (ts.isAsExpression(initializer)) {\n if (this.isCtxBodyCall(initializer.expression, sourceFile)) {\n const schema = this.convertTypeNodeToSchema(initializer.type, sourceFile);\n if (schema) {\n requestTypes.body = schema;\n scope.set(varName, schema);\n }\n } else {\n const schema = this.convertExpressionToSchema(initializer, sourceFile, scope);\n scope.set(varName, schema);\n }\n } else {\n const schema = this.convertExpressionToSchema(initializer, sourceFile, scope);\n scope.set(varName, schema);\n }\n }\n }\n\n // Check for type assertions on ctx.body()\n if (ts.isAsExpression(node)) {\n if (this.isCtxBodyCall(node.expression, sourceFile)) {\n const schema = this.convertTypeNodeToSchema(node.type, sourceFile);\n if (schema) {\n requestTypes.body = schema;\n\n // Track variables assigned to this body\n if (ts.isVariableDeclaration(node.parent)) {\n const varName = node.parent.name.getText(sourceFile);\n scope.set(varName, schema);\n }\n }\n }\n }\n\n // Look for ctx calls (json, text, html, send, emit) to highlight\n if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression)) {\n const objText = node.expression.expression.getText(sourceFile);\n const propText = node.expression.name.getText(sourceFile);\n\n if (objText === 'ctx' || objText.endsWith('.ctx') || objText === 'this') {\n const startLine = sourceFile.getLineAndCharacterOfPosition(node.getStart()).line + 1;\n const endLine = sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line + 1;\n\n if (['text', 'html', 'jsx'].includes(propText)) {\n // text/html/jsx are always strings, so statically valid\n highlights.push({ startLine, endLine, type: 'return-success' });\n } else if (propText === 'json') {\n // Check if we can extract a schema for the argument\n let isStatic = false;\n if (node.arguments.length > 0) {\n const schema = this.convertExpressionToSchema(node.arguments[0], sourceFile, scope);\n // If schema is not just a bare object or any, it's static\n if (schema && (schema.type !== 'object' || (schema.properties && Object.keys(schema.properties).length > 0))) {\n isStatic = true;\n }\n }\n highlights.push({ startLine, endLine, type: isStatic ? 'return-success' : 'return-warning' });\n } else if (['send', 'emit'].includes(propText)) {\n highlights.push({ startLine, endLine, type: 'emit' });\n }\n }\n }\n\n // Look for ctx usage\n if (ts.isPropertyAccessExpression(node)) {\n const objText = node.expression.getText(sourceFile);\n const propText = node.name.getText(sourceFile);\n\n if (objText === 'ctx' || objText.endsWith('.ctx')) {\n if (propText === 'body') {\n if (!requestTypes.body) {\n requestTypes.body = { type: 'object' };\n }\n } else if (propText === 'query') {\n if (!requestTypes.query) requestTypes.query = {};\n } else if (propText === 'params') {\n if (!requestTypes.params) requestTypes.params = {};\n } else if (propText === 'headers') {\n if (!requestTypes.headers) requestTypes.headers = {};\n }\n }\n }\n\n // Explicit Return\n if (ts.isReturnStatement(node)) {\n const startLine = sourceFile.getLineAndCharacterOfPosition(node.getStart()).line + 1;\n const endLine = sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line + 1;\n\n let isStatic = false;\n if (node.expression) {\n analyzeReturnExpression(node.expression);\n // If analyzeReturnExpression successfully set responseSchema to something specific, it's static\n // Note: analyzeReturnExpression updates local 'responseSchema' variable. \n // We check if it's \"good\"\n if (responseSchema && (responseSchema.type !== 'object' || (responseSchema.properties && Object.keys(responseSchema.properties).length > 0))) {\n isStatic = true;\n }\n } else if (hasExplicitReturnType) {\n // void return or similar\n isStatic = true;\n }\n\n highlights.push({ startLine, endLine, type: isStatic ? 'return-success' : 'return-warning' });\n }\n\n // Implicit Return (Concise Arrow Function)\n // e.g. (ctx) => ctx.json(...) or .then(res => ctx.json(res))\n if (ts.isArrowFunction(node) && !ts.isBlock(node.body)) {\n // For concise arrow function, the body IS the return value\n const startLine = sourceFile.getLineAndCharacterOfPosition(node.body.getStart()).line + 1;\n const endLine = sourceFile.getLineAndCharacterOfPosition(node.body.getEnd()).line + 1;\n\n analyzeReturnExpression(node.body as ts.Expression);\n\n let isStatic = false;\n if (responseSchema && (responseSchema.type !== 'object' || (responseSchema.properties && Object.keys(responseSchema.properties).length > 0))) {\n isStatic = true;\n }\n\n highlights.push({ startLine, endLine, type: isStatic ? 'return-success' : 'return-warning' });\n }\n\n // Implicit Return call (e.g. ctx.json(...) as a statement without return)\n if (ts.isExpressionStatement(node)) {\n analyzeReturnExpression(node.expression);\n\n // Check for ctx.emit() or this.emit()\n if (ts.isCallExpression(node.expression)) {\n const expr = node.expression;\n if (ts.isPropertyAccessExpression(expr.expression)) {\n const objText = expr.expression.expression.getText(sourceFile);\n const propText = expr.expression.name.getText(sourceFile);\n\n if (((objText === 'ctx' || objText.endsWith('.ctx')) || (objText === 'this' || objText.endsWith('.this'))) && propText === 'emit') {\n if (expr.arguments.length >= 1) {\n const eventNameArg = expr.arguments[0];\n if (ts.isStringLiteral(eventNameArg)) {\n const eventName = eventNameArg.text;\n let payload = { type: 'object' };\n\n if (expr.arguments.length >= 2) {\n payload = this.convertExpressionToSchema(expr.arguments[1], sourceFile, scope);\n }\n\n const emitLoc = {\n startLine: sourceFile.getLineAndCharacterOfPosition(expr.getStart()).line + 1,\n endLine: sourceFile.getLineAndCharacterOfPosition(expr.getEnd()).line + 1\n };\n emits.push({ event: eventName, payload, location: emitLoc });\n } else {\n const emitLoc = {\n startLine: sourceFile.getLineAndCharacterOfPosition(expr.getStart()).line + 1,\n endLine: sourceFile.getLineAndCharacterOfPosition(expr.getEnd()).line + 1\n };\n emits.push({ event: '__DYNAMIC_EMIT__', payload: { type: 'object' }, location: emitLoc });\n }\n }\n }\n }\n }\n }\n\n ts.forEachChild(node, visit);\n };\n\n if (ts.isBlock(body)) {\n ts.forEachChild(body, visit);\n } else {\n // Main handler is an implicit return: app.get('/', (ctx) => ctx.json(...))\n analyzeReturnExpression(body);\n // Also verify children (e.g. if body is a CallExpression, verify args??)\n // analyzeReturnExpression analyzes the expression itself.\n // But we ALSO want to visit children to find other usages (request types)\n // or nested arrow functions in a call chain (e.g. chaining .then())\n ts.forEachChild(body, visit);\n }\n }\n\n return { requestTypes, responseType, responseSchema, emits, highlights };\n }\n\n /**\n * Convert an Expression node to an OpenAPI schema (best effort)\n */\n private convertExpressionToSchema(node: ts.Expression, sourceFile: ts.SourceFile, scope: Map<string, any>): any {\n // Object Literal: { a: 1, b: \"text\" }\n if (ts.isObjectLiteralExpression(node)) {\n const schema: any = {\n type: 'object',\n properties: {},\n required: []\n };\n\n for (let i = 0; i < node.properties.length; i++) {\n const prop = node.properties[i];\n if (ts.isPropertyAssignment(prop)) {\n const name = prop.name.getText(sourceFile);\n const valueSchema = this.convertExpressionToSchema(prop.initializer, sourceFile, scope);\n\n schema.properties[name] = valueSchema;\n schema.required.push(name); // Properties in literal return are required\n }\n else if (ts.isShorthandPropertyAssignment(prop)) {\n const name = prop.name.getText(sourceFile);\n // Check scope for variable\n const scopedSchema = scope.get(name);\n schema.properties[name] = scopedSchema || { type: 'object' };\n schema.required.push(name);\n }\n }\n if (schema.required.length === 0) {\n delete schema.required;\n }\n return schema;\n }\n\n // Array Literal: [1, 2]\n if (ts.isArrayLiteralExpression(node)) {\n const schema: any = { type: 'array' };\n if (node.elements.length > 0) {\n // Infer item type from first element\n schema.items = this.convertExpressionToSchema(node.elements[0], sourceFile, scope);\n } else {\n schema.items = {};\n }\n return schema;\n }\n\n // Conditional (Ternary) Expression: cond ? trueVal : falseVal\n if (ts.isConditionalExpression(node)) {\n const trueSchema = this.convertExpressionToSchema(node.whenTrue, sourceFile, scope);\n // const falseSchema = this.convertExpressionToSchema(node.whenFalse, sourceFile, scope);\n\n // Simplified: return true branch schema. Ideally we'd do oneOf\n return trueSchema;\n }\n\n // Template Expression: `Hello ${name}`\n if (ts.isTemplateExpression(node)) {\n return { type: 'string' };\n }\n\n // Identifier (Variable reference)\n if (ts.isIdentifier(node)) {\n const name = node.getText(sourceFile);\n const scopedSchema = scope.get(name);\n if (scopedSchema) return scopedSchema;\n return { type: 'object' }; // Unknown reference\n }\n\n // Literals\n if (ts.isStringLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node)) return { type: 'string' };\n if (ts.isNumericLiteral(node)) return { type: 'number' };\n if (node.kind === ts.SyntaxKind.TrueKeyword || node.kind === ts.SyntaxKind.FalseKeyword) return { type: 'boolean' };\n\n // Unknown\n return { type: 'object' };\n }\n\n /**\n * Check if an expression is a call to ctx.body()\n */\n private isCtxBodyCall(node: ts.Expression, sourceFile: ts.SourceFile): boolean {\n // Handle await ctx.body()\n if (ts.isAwaitExpression(node)) {\n return this.isCtxBodyCall(node.expression, sourceFile);\n }\n\n // Handle ctx.body()\n if (ts.isCallExpression(node)) {\n // Check expression: ctx.body\n if (ts.isPropertyAccessExpression(node.expression)) {\n const objText = node.expression.expression.getText(sourceFile);\n const propText = node.expression.name.getText(sourceFile);\n return (objText === 'ctx' || objText.endsWith('.ctx')) && propText === 'body';\n }\n }\n\n return false;\n }\n\n /**\n * Convert a TypeScript TypeNode to an OpenAPI schema\n */\n private convertTypeNodeToSchema(typeNode: ts.TypeNode, sourceFile: ts.SourceFile): any {\n switch (typeNode.kind) {\n case ts.SyntaxKind.StringKeyword:\n return { type: 'string' };\n case ts.SyntaxKind.NumberKeyword:\n return { type: 'number' };\n case ts.SyntaxKind.BooleanKeyword:\n return { type: 'boolean' };\n case ts.SyntaxKind.AnyKeyword:\n case ts.SyntaxKind.UnknownKeyword:\n return {}; // Any/Unknown -> empty schema (accepts anything)\n\n case ts.SyntaxKind.TypeLiteral: {\n const literal = typeNode as ts.TypeLiteralNode;\n const schema: any = {\n type: 'object',\n properties: {},\n required: []\n };\n\n for (let i = 0; i < literal.members.length; i++) {\n const member = literal.members[i];\n if (ts.isPropertySignature(member) && member.type) {\n const name = member.name.getText(sourceFile);\n const propSchema = this.convertTypeNodeToSchema(member.type, sourceFile);\n\n schema.properties[name] = propSchema;\n\n // Property is required unless it has a question token\n if (!member.questionToken) {\n schema.required.push(name);\n }\n }\n }\n\n if (schema.required.length === 0) {\n delete schema.required;\n }\n\n return schema;\n }\n\n case ts.SyntaxKind.ArrayType: {\n const arrayType = typeNode as ts.ArrayTypeNode;\n return {\n type: 'array',\n items: this.convertTypeNodeToSchema(arrayType.elementType, sourceFile)\n };\n }\n\n // Handle Type References (e.g. Array<string>)\n case ts.SyntaxKind.TypeReference: {\n const typeRef = typeNode as ts.TypeReferenceNode;\n const typeName = typeRef.typeName.getText(sourceFile);\n\n if (typeName === 'Array' && typeRef.typeArguments?.length > 0) {\n return {\n type: 'array',\n items: this.convertTypeNodeToSchema(typeRef.typeArguments[0], sourceFile)\n };\n }\n\n if (typeName === 'Promise' && typeRef.typeArguments?.length > 0) {\n return this.convertTypeNodeToSchema(typeRef.typeArguments[0], sourceFile);\n }\n\n // For other references, we default to string or object as fallback\n // A fuller implementation would resolve the reference\n return { type: 'object', description: `Ref: ${typeName}` };\n }\n\n default:\n return { type: 'object' };\n }\n }\n\n /**\n * Extract mount information from mount call\n */\n private extractMountFromCall(node: ts.CallExpression, sourceFile: ts.SourceFile): MountInfo | null {\n const args = node.arguments;\n\n if (args.length < 2) return null;\n\n const pathArg = args[0];\n const targetArg = args[1];\n\n let prefix = '/';\n if (ts.isStringLiteral(pathArg)) {\n prefix = pathArg.text;\n }\n\n const target = targetArg.getText(sourceFile);\n\n // Check if target is from node_modules\n const dependency = this.checkIfExternalDependency(target, sourceFile);\n let targetFilePath: string | undefined;\n\n if (!dependency) {\n // Check for internal import\n let modulePath: string | undefined;\n ts.forEachChild(sourceFile, (node) => {\n if (targetFilePath || modulePath) return; // Found\n\n if (ts.isImportDeclaration(node)) {\n const specifier = node.moduleSpecifier;\n if (ts.isStringLiteral(specifier)) {\n const path = specifier.text;\n if (path.startsWith('.')) {\n // Check default import: import target from './...'\n if (node.importClause?.name?.getText(sourceFile) === target) {\n modulePath = path;\n }\n // Check named imports: import { target } from './...'\n else if (node.importClause?.namedBindings && ts.isNamedImports(node.importClause.namedBindings)) {\n for (const element of node.importClause.namedBindings.elements) {\n if (element.name.getText(sourceFile) === target) {\n modulePath = path;\n break;\n }\n }\n }\n }\n }\n }\n });\n\n if (modulePath) {\n const dir = path.dirname(sourceFile.fileName);\n const absolutePath = path.resolve(dir, modulePath);\n\n // Try to resolve extension\n const extensions = ['.ts', '.js', '.tsx', '.jsx', '/index.ts', '/index.js'];\n for (const ext of extensions) {\n if (fs.existsSync(absolutePath + ext)) {\n targetFilePath = absolutePath + ext;\n break;\n }\n // If absolutePath ends in /index (implicit)\n // Or if modulePath points to directory\n }\n // Try straight (if user included extension)\n if (!targetFilePath && fs.existsSync(absolutePath)) {\n targetFilePath = absolutePath;\n }\n // Try directory index\n if (!targetFilePath && fs.existsSync(path.join(absolutePath, 'index.ts'))) {\n targetFilePath = path.join(absolutePath, 'index.ts');\n }\n\n // Normalize result?\n }\n }\n\n return {\n prefix,\n target,\n targetFilePath,\n dependency,\n sourceContext: {\n file: sourceFile.fileName,\n startLine: sourceFile.getLineAndCharacterOfPosition(node.getStart()).line + 1,\n endLine: sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line + 1\n }\n };\n }\n\n /**\n * Check if a reference is to an external dependency\n */\n private checkIfExternalDependency(identifier: string, sourceFile: ts.SourceFile): DependencyInfo | undefined {\n // This is a simplified check - in a full implementation, \n // we'd track imports and resolve them\n\n // For now, check if there's an import statement for this identifier\n const imports: ts.ImportDeclaration[] = [];\n\n ts.forEachChild(sourceFile, (node) => {\n if (ts.isImportDeclaration(node)) {\n imports.push(node);\n }\n });\n\n for (let i = 0; i < imports.length; i++) {\n const imp = imports[i];\n const moduleSpecifier = imp.moduleSpecifier;\n if (ts.isStringLiteral(moduleSpecifier)) {\n const modulePath = moduleSpecifier.text;\n\n // Check if it's a node_modules import (no relative path)\n if (!modulePath.startsWith('.') && !modulePath.startsWith('/')) {\n const namedBindings = imp.importClause?.namedBindings;\n\n if (namedBindings && ts.isNamedImports(namedBindings)) {\n for (let j = 0; j < namedBindings.elements.length; j++) {\n const element = namedBindings.elements[j];\n if (element.name.text === identifier) {\n // Try to read package version\n const version = this.getPackageVersion(modulePath);\n\n return {\n packageName: modulePath,\n version,\n importPath: modulePath,\n isExternal: true\n };\n }\n }\n }\n }\n }\n }\n\n return undefined;\n }\n\n /**\n * Get package version from package.json\n */\n private getPackageVersion(packageName: string): string | undefined {\n try {\n const packageJsonPath = path.join(this.rootDir, 'node_modules', packageName, 'package.json');\n if (fs.existsSync(packageJsonPath)) {\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));\n return packageJson.version;\n }\n } catch (e) {\n // Ignore\n }\n return undefined;\n }\n\n /**\n * Generate OpenAPI specification\n */\n public generateOpenAPISpec(): any {\n const paths: Record<string, any> = {};\n\n const collectRoutes = (app: ApplicationInstance, prefix: string = '') => {\n // Add direct routes\n for (let i = 0; i < app.routes.length; i++) {\n const route = app.routes[i];\n // Ensure prefix handles slashes correctly\n const cleanPrefix = prefix.endsWith('/') ? prefix.slice(0, -1) : prefix;\n const cleanPath = route.path.startsWith('/') ? route.path : '/' + route.path;\n const fullPath = (cleanPrefix + cleanPath) || '/';\n\n // Normalization is already done in extractRouteFromCall, but double check\n const pathKey = fullPath.replace(/:([a-zA-Z0-9_]+)/g, '{$1}');\n\n if (!paths[pathKey]) {\n paths[pathKey] = {};\n }\n\n const method = route.method.toLowerCase();\n const operation: any = {\n summary: route.summary || `${route.method.toUpperCase()} ${pathKey}`,\n description: route.description,\n tags: route.tags,\n operationId: route.operationId,\n responses: {\n '200': {\n description: 'Successful response'\n }\n }\n };\n\n // Clean up undefined\n if (!operation.description) delete operation.description;\n if (!operation.tags) delete operation.tags;\n if (!operation.operationId) delete operation.operationId;\n\n // Add inferred response schema\n if (route.responseSchema) {\n operation.responses['200'].content = {\n 'application/json': {\n schema: route.responseSchema\n }\n };\n } else if (route.responseType) {\n // Fallback to basic type\n const contentType = route.responseType === 'string' ? 'text/plain' : 'application/json';\n operation.responses['200'].content = {\n [contentType]: {\n schema: { type: route.responseType }\n }\n };\n } else {\n // Default object\n operation.responses['200'].content = {\n 'application/json': {\n schema: { type: 'object' }\n }\n };\n }\n\n // Add request body schema if available\n if (route.requestTypes?.body) {\n operation.requestBody = {\n content: {\n 'application/json': {\n schema: route.requestTypes.body\n }\n }\n };\n }\n\n // Add query/path parameters\n const parameters: any[] = [];\n\n if (route.requestTypes?.query) {\n const entries = Object.entries(route.requestTypes.query);\n for (let i = 0; i < entries.length; i++) {\n const [key] = entries[i];\n parameters.push({\n name: key,\n in: 'query',\n schema: { type: 'string' }\n });\n }\n }\n\n if (route.requestTypes?.params) {\n // Also check for path params implied by the URL {param}\n // But assume extractRouteFromCall handled explicit ones?\n // Let's just trust requestTypes for now\n const entries = Object.entries(route.requestTypes.params);\n for (let i = 0; i < entries.length; i++) {\n const [key] = entries[i];\n parameters.push({\n name: key,\n in: 'path',\n required: true,\n schema: { type: 'string' }\n });\n }\n }\n\n // Extract params from path if not explicitly typed but present in URL\n // This backfills untyped params so they appear in spec\n const pathParams = pathKey.match(/{([^}]+)}/g);\n if (pathParams) {\n pathParams.forEach(p => {\n const name = p.slice(1, -1);\n if (!parameters.some(param => param.name === name && param.in === 'path')) {\n parameters.push({\n name,\n in: 'path',\n required: true,\n schema: { type: 'string' } // Default to string\n });\n }\n });\n }\n\n if (parameters.length > 0) {\n operation.parameters = parameters;\n }\n\n paths[pathKey][method] = operation;\n }\n\n // Recurse into mounted apps\n for (let i = 0; i < app.mounted.length; i++) {\n const mount = app.mounted[i];\n // We need to resolve the ApplicationInstance for the target\n // The 'mounted' array currently only stores { prefix, target, dependency }\n // We need to find the AppInstance that matches 'target' class name\n\n // Note: This simple matching by class name might be brittle if multiple files have same class name\n // In a full implementation we would resolve the file path.\n const mountedApp = this.applications.find(a => a.name === mount.target || a.className === mount.target);\n\n if (mountedApp) {\n // Prevent infinite recursion\n if (mountedApp === app) continue;\n\n const cleanPrefix = prefix.endsWith('/') ? prefix.slice(0, -1) : prefix;\n const mountPrefix = mount.prefix.startsWith('/') ? mount.prefix : '/' + mount.prefix;\n const nextPrefix = cleanPrefix + mountPrefix;\n\n collectRoutes(mountedApp, nextPrefix);\n }\n }\n };\n\n for (let i = 0; i < this.applications.length; i++) {\n const app = this.applications[i];\n // We only want to start collection from \"root\" apps? \n // Or just collect everything? \n // If we collect everything, we might duplicate routes if they are mounted.\n // Current findApplications finds ALL instances.\n\n // Heuristic: If this app is mounted by another app, don't collect it as root.\n // But we don't have back-references easily.\n // Simplified: Just collect everything for now, but realize that un-mounted routers might show up as root.\n // Ideally we need to find the \"Main\" app (root).\n\n // For now, let's collect all, but we might have duplicates if we traverse mounts.\n // Let's rely on the user to only have one Main entrypoint usually.\n // Or we can try to detect if it is mounted.\n\n const isMounted = this.applications.some(parent =>\n parent.mounted.some(m => m.target === app.name || m.target === app.className)\n );\n\n if (!isMounted) {\n collectRoutes(app);\n }\n }\n\n return {\n openapi: '3.1.0',\n info: {\n title: 'Shokupan API',\n version: '1.0.0',\n description: 'Auto-generated from Shokupan application analysis'\n },\n paths,\n components: {\n schemas: {}\n }\n };\n }\n}\n\n/**\n * Analyze a directory and generate OpenAPI spec\n */\nexport async function analyzeDirectory(directory: string): Promise<any> {\n const analyzer = new OpenAPIAnalyzer(directory);\n return await analyzer.analyze();\n}\n"],"names":["node","path","i"],"mappings":";;;AA+EO,MAAM,gBAAgB;AAAA,EAOzB,YAAoB,SAAiB,YAAqB;AAAtC,SAAA,UAAA;AAChB,QAAI,YAAY;AACZ,WAAK,aAAa,KAAK,QAAQ,UAAU;AAAA,IAC7C;AAAA,EACJ;AAAA,EAVQ,QAAyB,CAAA;AAAA,EACzB,eAAsC,CAAA;AAAA,EACtC;AAAA,EAEA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcR,MAAa,UAA6D;AAItE,UAAM,KAAK,qBAAA;AAGX,UAAM,KAAK,kBAAA;AAGX,UAAM,KAAK,iBAAA;AAGX,UAAM,KAAK,cAAA;AAGX,SAAK,kBAAA;AAGL,WAAO,EAAE,cAAc,KAAK,aAAA;AAAA,EAChC;AAAA;AAAA;AAAA;AAAA,EAKQ,oBAA0B;AAC9B,UAAM,gCAAgB,IAAA;AACtB,UAAM,QAA+B,CAAA;AAGrC,eAAW,OAAO,KAAK,cAAc;AACjC,UAAI,IAAI,SAAS,iBAAiB;AAC9B,kBAAU,IAAI,IAAI,QAAQ;AAC1B,cAAM,KAAK,GAAG;AAAA,MAClB;AAAA,IACJ;AAGA,WAAO,MAAM,SAAS,GAAG;AACrB,YAAM,MAAM,MAAM,MAAA;AAElB,iBAAW,SAAS,IAAI,SAAS;AAC7B,YAAI,MAAM,kBAAkB,CAAC,UAAU,IAAI,MAAM,cAAc,GAAG;AAC9D,oBAAU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AS;AAAA,QACT,aAAa;AAAA,MAAA;AAAA,MAEjB;AAAA,MACA,YAAY;AAAA,QACR,SAAS,CAAA;AAAA,MAAC;AAAA,IACd;AAAA,EAER;AACJ;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"analyzer.impl-D9Yi1Hax.cjs","sources":["../src/plugins/application/openapi/analyzer.impl.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport ts from 'typescript';\n\n/**\n * File information collected during scan\n */\ninterface CollectedFile {\n path: string;\n type: 'ts' | 'tsx' | 'cts' | 'dts' | 'mts' | 'js' | 'jsx' | 'mjs' | 'cjs' | 'map';\n content?: string;\n}\n\n/**\n * Route information extracted from AST\n */\nexport interface RouteInfo {\n method: string;\n path: string;\n handlerName?: string;\n handlerSource?: string;\n requestTypes?: {\n body?: any;\n query?: Record<string, string>;\n params?: Record<string, string>;\n headers?: Record<string, string>;\n };\n responseType?: string;\n responseSchema?: any;\n summary?: string;\n description?: string;\n tags?: string[];\n operationId?: string;\n emits?: { event: string; payload?: any; location?: { startLine: number; endLine: number; }; }[];\n sourceContext?: {\n file: string;\n startLine: number;\n endLine: number;\n highlights?: { startLine: number; endLine: number; type: 'emit' | 'return-success' | 'return-warning'; }[];\n };\n}\n\n/**\n * Dependency information\n */\ninterface DependencyInfo {\n packageName: string;\n version?: string;\n importPath: string;\n isExternal: boolean;\n}\n\n/**\n * Application/Router instance found in code\n */\nexport interface ApplicationInstance {\n name: string;\n filePath: string;\n className: 'Shokupan' | 'ShokupanRouter' | 'Controller';\n controllerPrefix?: string;\n routes: RouteInfo[];\n mounted: MountInfo[];\n}\n\ninterface MountInfo {\n prefix: string;\n target: string; // Controller/Router name or file path\n targetFilePath?: string;\n dependency?: DependencyInfo;\n sourceContext?: {\n file: string;\n startLine: number;\n endLine: number;\n };\n}\n\n/**\n * Main analyzer class\n */\nexport class OpenAPIAnalyzer {\n private files: CollectedFile[] = [];\n private applications: ApplicationInstance[] = [];\n private program?: ts.Program;\n\n private entrypoint?: string;\n\n constructor(private rootDir: string, entrypoint?: string) {\n if (entrypoint) {\n this.entrypoint = path.resolve(entrypoint);\n }\n }\n\n /**\n * Main analysis entry point\n */\n /**\n * Main analysis entry point\n */\n public async analyze(): Promise<{ applications: ApplicationInstance[]; }> {\n // console.log(`Analyzing directory: ${this.rootDir}`);\n\n // Step 1: Parse TypeScript files (which might involve scanning or using entrypoint)\n await this.parseTypeScriptFiles();\n\n // Step 2: Process source maps if needed\n await this.processSourceMaps();\n\n // Step 3: Find Shokupan applications\n await this.findApplications();\n\n // Step 4: Extract route information\n await this.extractRoutes();\n\n // Step 5: Prune unreachable GenericModules\n this.pruneApplications();\n\n // Return the raw application data for further processing\n return { applications: this.applications };\n }\n\n /**\n * Remove GenericModules that are not mounted by any Shokupan application/router\n */\n private pruneApplications(): void {\n const reachable = new Set<string>();\n const queue: ApplicationInstance[] = [];\n\n // Seed with explicit applications (Shokupan, ShokupanRouter, Controller)\n for (const app of this.applications) {\n if (app.name !== 'GenericModule') {\n reachable.add(app.filePath);\n queue.push(app);\n }\n }\n\n // BFS to find all reachable modules via mounts\n while (queue.length > 0) {\n const app = queue.shift()!;\n\n for (const mount of app.mounted) {\n if (mount.targetFilePath && !reachable.has(mount.targetFilePath)) {\n reachable.add(mount.targetFilePath);\n\n // Find the app instance for this file\n const mountedApp = this.applications.find(a => a.filePath === mount.targetFilePath);\n if (mountedApp) {\n queue.push(mountedApp);\n }\n }\n }\n }\n\n // Filter out unreachable GenericModules\n const initialCount = this.applications.length;\n this.applications = this.applications.filter(app => {\n if (app.name === 'GenericModule' && !reachable.has(app.filePath)) {\n // console.log(`[Analyzer] Pruning unreachable module: ${app.filePath}`);\n return false;\n }\n return true;\n });\n\n // console.log(`[Analyzer] Pruned ${initialCount - this.applications.length} unreachable modules.`);\n }\n\n /**\n * Recursively scan directory for TypeScript/JavaScript files\n */\n private async scanDirectory(dir: string): Promise<void> {\n try {\n const entries = fs.readdirSync(dir, { withFileTypes: true });\n\n for (let i = 0; i < entries.length; i++) {\n const entry = entries[i];\n const fullPath = path.join(dir, entry.name);\n\n // Skip node_modules for source files (we'll handle deps separately)\n if (entry.isDirectory()) {\n if ([\"node_modules\", \".git\", \"dist\"].includes(entry.name)) {\n continue;\n }\n await this.scanDirectory(fullPath);\n } else {\n const ext = path.extname(entry.name);\n if ([\".ts\", \".tsx\", \".cts\", \".dts\", \".mts\", \".js\", \".jsx\", \".mjs\", \".cjs\", \".map\"].includes(ext)) {\n this.files.push({ path: fullPath, type: ext.slice(1) as any });\n }\n }\n }\n } catch (error: any) {\n // Silently skip directories that don't exist or can't be read\n if (error.code !== 'ENOENT' && error.code !== 'EACCES') {\n throw error;\n }\n }\n }\n\n /**\n * Process source maps to reconstruct TypeScript\n */\n private async processSourceMaps(): Promise<void> {\n // Find JS files that have corresponding .map files\n const jsFiles = this.files.filter(f => f.type === 'js');\n const mapFiles = this.files.filter(f => f.type === 'map');\n\n for (let i = 0; i < jsFiles.length; i++) {\n const jsFile = jsFiles[i];\n const mapFile = mapFiles.find(m => m.path === jsFile.path + '.map');\n\n if (mapFile && !this.files.some(f => f.path === jsFile.path.replace(/\\.js$/, '.ts'))) {\n // We have .js + .map but no .ts file\n // For now, we'll just parse the JS file directly\n // Full source map reconstruction would require the 'source-map' library\n console.log(`Note: Found ${jsFile.path} with source map but no .ts file. Will parse JS directly.`);\n }\n }\n }\n\n /**\n * Parse TypeScript files and create AST\n */\n private async parseTypeScriptFiles(): Promise<void> {\n let fileNames: string[] = [];\n\n if (this.entrypoint) {\n // If entrypoint is provided, let TypeScript resolve dependencies\n fileNames = [this.entrypoint];\n // console.log(`[Analyzer] Using entrypoint: ${this.entrypoint}`);\n } else {\n // Otherwise, scan the directory manually\n await this.scanDirectory(this.rootDir);\n const tsFiles = this.files.filter(f => f.type === 'ts' || f.type === 'js');\n fileNames = tsFiles.map(f => f.path);\n // console.log(`[Analyzer] Scanning directory, found ${fileNames.length} files`);\n }\n\n // Create TypeScript program\n this.program = ts.createProgram(fileNames, {\n target: ts.ScriptTarget.ESNext,\n module: ts.ModuleKind.ESNext,\n allowJs: true,\n moduleResolution: ts.ModuleResolutionKind.Node10,\n rootDir: this.rootDir,\n skipLibCheck: true,\n skipDefaultLibCheck: true,\n });\n\n // If using entrypoint, update this.files with what TS found in the project\n if (this.entrypoint) {\n this.files = this.program.getSourceFiles()\n .filter(sf => !sf.fileName.includes('node_modules'))\n .map(sf => ({ path: sf.fileName, type: sf.fileName.endsWith('.js') ? 'js' : 'ts' }));\n }\n }\n\n /**\n * Find all Shokupan/ShokupanRouter instances\n */\n private async findApplications(): Promise<void> {\n if (!this.program) return;\n\n const typeChecker = this.program.getTypeChecker();\n\n for (let i = 0; i < this.program.getSourceFiles().length; i++) {\n const sourceFile = this.program.getSourceFiles()[i];\n // Skip node_modules and declaration files/tests\n if (sourceFile.fileName.includes('node_modules')) continue;\n if (sourceFile.isDeclarationFile) continue;\n\n // Allow analyzing test files if we are pointing explicitly to a test directory (fixtures)\n // OR if the file is in a fixtures directory (used for OpenAPI spec generation from test apps)\n // OR if the file IS the entrypoint\n const isTestEnv = this.rootDir.includes('/test/') ||\n this.rootDir.includes('/tests/') ||\n this.rootDir.includes('/fixtures/') ||\n (this.entrypoint && (this.entrypoint.includes('/test/') || this.entrypoint.includes('/tests/')));\n\n const isFixtureFile = sourceFile.fileName.includes('/fixtures/');\n const isEntrypoint = this.entrypoint && sourceFile.fileName === this.entrypoint;\n\n // console.log(`[Analyzer] check ${sourceFile.fileName}: isTestEnv=${isTestEnv}, isFixture=${isFixtureFile}, isEntry=${isEntrypoint}`);\n\n if (!isTestEnv && !isFixtureFile && !isEntrypoint) {\n if (sourceFile.fileName.includes('/test/') || sourceFile.fileName.includes('/tests/')) {\n // console.log(`[Analyzer] Skipping test file: ${sourceFile.fileName}`);\n continue;\n }\n if (sourceFile.fileName.includes('/base_test/')) continue;\n if (sourceFile.fileName.includes('.test.ts') || sourceFile.fileName.includes('.spec.ts')) continue;\n }\n\n ts.forEachChild(sourceFile, (node) => {\n this.visitNode(node, sourceFile, typeChecker);\n });\n }\n }\n\n /**\n * Visit AST node to find application instances\n */\n private visitNode(node: ts.Node, sourceFile: ts.SourceFile, typeChecker: ts.TypeChecker): void {\n // Look for: class FooController ... @Controller(...)\n if (ts.isClassDeclaration(node)) {\n // Check for @Controller decorator\n let isController = false;\n let controllerPrefix: string | undefined;\n let className = node.name?.getText(sourceFile);\n\n const decorators: ts.Decorator[] = (node as any).decorators || node.modifiers?.filter((m: any) => ts.isDecorator(m));\n\n if (decorators) {\n const controllerDecorator = decorators.find((d: any) => {\n const expr = d.expression;\n if (ts.isCallExpression(expr)) {\n const identifier = expr.expression.getText(sourceFile);\n return identifier === 'Controller';\n }\n return false;\n });\n if (controllerDecorator) {\n isController = true;\n const expr = controllerDecorator.expression as ts.CallExpression;\n if (expr.arguments.length > 0 && ts.isStringLiteral(expr.arguments[0])) {\n controllerPrefix = expr.arguments[0].text;\n }\n }\n }\n\n // Fallback: Check for method decorators (@Get, @Post, etc.)\n if (!isController) {\n const hasRouteDecorators = node.members.some(m => {\n // Trust 175 as MethodDeclaration if TS matches mostly, or just check members\n if (ts.isMethodDeclaration(m) || m.kind === 175 || m.kind === 170 || m.kind === 171) {\n const decs = (m as any).decorators || (m as any).modifiers?.filter((mod: any) => ts.isDecorator(mod));\n if (decs) {\n return decs.some((d: any) => {\n const expr = d.expression;\n if (ts.isCallExpression(expr)) {\n const identifier = expr.expression.getText(sourceFile);\n return ['get', 'post', 'put', 'delete', 'patch', 'options', 'head', 'event'].includes(identifier.toLowerCase());\n }\n return false;\n });\n }\n }\n return false;\n });\n if (hasRouteDecorators) {\n isController = true;\n }\n }\n\n if (isController && className) {\n this.applications.push({\n name: className,\n filePath: sourceFile.fileName,\n className: 'Controller',\n controllerPrefix,\n routes: [],\n mounted: []\n });\n }\n }\n\n // Look for: new Shokupan() or new ShokupanRouter()\n if (ts.isVariableDeclaration(node) && node.initializer) {\n if (ts.isNewExpression(node.initializer)) {\n const expr = node.initializer;\n const className = expr.expression.getText(sourceFile);\n\n if (className === 'Shokupan' || className === 'ShokupanRouter') {\n const varName = node.name.getText(sourceFile);\n\n this.applications.push({\n name: varName,\n filePath: sourceFile.fileName,\n className: className as 'Shokupan' | 'ShokupanRouter',\n routes: [],\n mounted: []\n });\n }\n }\n }\n\n // Look for standalone route calls in files that don't instantiate an app\n if (ts.isCallExpression(node)) {\n const expr = node.expression;\n if (ts.isPropertyAccessExpression(expr)) {\n const method = expr.name.getText(sourceFile);\n if (['get', 'post', 'put', 'delete', 'patch', 'options', 'head', 'event', 'on'].includes(method)) {\n const existing = this.applications.find(a => a.filePath === sourceFile.fileName);\n if (!existing) {\n this.applications.push({\n name: 'GenericModule',\n filePath: sourceFile.fileName,\n className: 'Shokupan',\n routes: [],\n mounted: []\n });\n }\n }\n }\n }\n\n // Recursively visit children\n ts.forEachChild(node, (child) => this.visitNode(child, sourceFile, typeChecker));\n }\n\n /**\n * Extract route information from applications\n */\n private async extractRoutes(): Promise<void> {\n if (!this.program) return;\n\n for (let i = 0; i < this.applications.length; i++) {\n const app = this.applications[i];\n const sourceFile = this.program.getSourceFile(app.filePath);\n if (!sourceFile) continue;\n\n this.extractRoutesFromFile(app, sourceFile);\n }\n }\n\n /**\n * Extract routes from a Controller class\n */\n private extractRoutesFromController(app: ApplicationInstance, classNode: ts.ClassDeclaration, sourceFile: ts.SourceFile): void {\n const methods = classNode.members.filter(m => ts.isMethodDeclaration(m) || m.kind === 175);\n\n for (let i = 0; i < methods.length; i++) {\n const method = methods[i];\n const methodNode = method as any; // Cast to any to access decorators in newer/older TS mix\n if (!methodNode.decorators && !methodNode.modifiers) continue;\n\n const decorators = methodNode.decorators || methodNode.modifiers?.filter((m: any) => ts.isDecorator(m));\n if (!decorators) continue;\n\n // Find route decorators: @Get, @Post, etc.\n const routeDecorator = decorators.find((d: any) => {\n const expr = d.expression;\n if (ts.isCallExpression(expr)) {\n const identifier = expr.expression.getText(sourceFile);\n return ['get', 'post', 'put', 'delete', 'patch', 'options', 'head', 'event'].includes(identifier.toLowerCase());\n }\n return false;\n });\n\n if (routeDecorator && ts.isCallExpression(routeDecorator.expression)) {\n const decoratorName = routeDecorator.expression.expression.getText(sourceFile);\n const httpMethod = decoratorName.toUpperCase();\n let routePath = '/';\n\n // Get path\n const pathArg = routeDecorator.expression.arguments[0];\n if (pathArg && ts.isStringLiteral(pathArg)) {\n routePath = pathArg.text;\n }\n\n // Normalize path params: /users/:id -> /users/{id}\n routePath = routePath.replace(/:([a-zA-Z0-9_]+)/g, '{$1}');\n\n // Handler Name (Class.method)\n const handlerName = `${app.name}.${methodNode.name.getText(sourceFile)}`;\n\n // Analyze the method body\n const analysis = this.analyzeHandler(methodNode, sourceFile);\n\n app.routes.push({\n method: httpMethod,\n path: routePath,\n handlerName: handlerName,\n handlerSource: methodNode.getText(sourceFile),\n requestTypes: analysis.requestTypes,\n responseType: analysis.responseType,\n responseSchema: analysis.responseSchema,\n emits: analysis.emits,\n sourceContext: {\n file: sourceFile.fileName,\n startLine: sourceFile.getLineAndCharacterOfPosition(methodNode.getStart()).line + 1,\n endLine: sourceFile.getLineAndCharacterOfPosition(methodNode.getEnd()).line + 1,\n highlights: analysis.highlights\n }\n });\n }\n }\n };\n\n /**\n * Extract routes from a specific file\n */\n private extractRoutesFromFile(app: ApplicationInstance, sourceFile: ts.SourceFile): void {\n if (app.className === 'Controller') {\n const classNode = sourceFile.statements.find(s => ts.isClassDeclaration(s) && s.name?.getText(sourceFile) === app.name) as ts.ClassDeclaration;\n if (classNode) {\n this.extractRoutesFromController(app, classNode, sourceFile);\n }\n } else {\n // Existing logic for app/router instances\n const visit = (node: ts.Node) => {\n // ... (rest of the existing logic)\n // Look for method calls: app.get(...), app.post(...), app.mount(...)\n if (ts.isCallExpression(node)) {\n const expr = node.expression;\n\n if (ts.isPropertyAccessExpression(expr)) {\n const objName = expr.expression.getText(sourceFile);\n const methodName = expr.name.getText(sourceFile);\n\n // Check if this is our application instance\n // For GenericModule, we accept any variable name as it's likely an argument (e.g. app.event)\n if (objName === app.name || (app.name === 'GenericModule' && node.arguments.length >= 2)) {\n // console.log(`[Analyzer] Inspecting route call: ${objName}.${methodName} in ${app.name}`);\n if (['get', 'post', 'put', 'delete', 'patch', 'options', 'head', 'on', 'event'].includes(methodName.toLowerCase())) {\n // Extract route info\n const route = this.extractRouteFromCall(node, sourceFile, methodName.toUpperCase());\n if (route) {\n app.routes.push(route);\n }\n } else if (methodName === 'mount') {\n // Extract mount info\n const mount = this.extractMountFromCall(node, sourceFile);\n if (mount) {\n app.mounted.push(mount);\n }\n }\n }\n }\n }\n\n ts.forEachChild(node, visit);\n };\n\n ts.forEachChild(sourceFile, visit);\n }\n }\n\n /**\n * Extract route information from a route call (e.g., app.get('/path', handler))\n */\n private extractRouteFromCall(node: ts.CallExpression, sourceFile: ts.SourceFile, method: string): RouteInfo | null {\n const args = node.arguments;\n\n if (args.length < 2) return null;\n\n const pathArg = args[0];\n let routePath = '/';\n\n if (ts.isStringLiteral(pathArg)) {\n routePath = pathArg.text;\n } else {\n routePath = '__DYNAMIC_EVENT__';\n }\n\n // Normalize path params: /users/:id -> /users/{id}\n // This ensures matching with runtime-generated keys\n const normalizedPath = routePath.replace(/:([a-zA-Z0-9_]+)/g, '{$1}');\n\n let metadata: any = {};\n\n // Check for metadata argument (3 args: path, metadata, handler)\n if (args.length >= 3 && ts.isObjectLiteralExpression(args[1])) {\n const metaObj = args[1];\n // Extract summary, description, tags, etc.\n const rawMeta = this.convertExpressionToSchema(metaObj, sourceFile, new Map());\n\n // convertExpressionToSchema returns a schema-like object { type: 'object', properties: {...} }\n // But we want the actual values if they are literals.\n // convertExpressionToSchema is designed for SCHEMAS, not values.\n // We need a simpler value extractor or just parse the props directly for this specific case.\n\n for (let i = 0; i < metaObj.properties.length; i++) {\n const prop = metaObj.properties[i];\n if (ts.isPropertyAssignment(prop) && prop.name) {\n const name = prop.name.getText(sourceFile);\n const val = prop.initializer;\n\n if (ts.isStringLiteral(val)) {\n metadata[name] = val.text;\n } else if (ts.isArrayLiteralExpression(val) && name === 'tags') {\n metadata.tags = val.elements\n .filter(e => ts.isStringLiteral(e))\n .map(e => (e as ts.StringLiteral).text);\n } else if (name === 'operationId' && ts.isStringLiteral(val)) {\n metadata.operationId = val.text;\n }\n }\n }\n }\n\n // Extract handler information\n const handlerArg = args[args.length - 1];\n const handlerInfo = this.analyzeHandler(handlerArg, sourceFile);\n\n return {\n method,\n path: normalizedPath,\n handlerName: handlerArg.getText(sourceFile).substring(0, 50), // Truncate for display\n handlerSource: handlerArg.getText(sourceFile),\n requestTypes: handlerInfo.requestTypes,\n responseType: handlerInfo.responseType,\n responseSchema: handlerInfo.responseSchema,\n emits: handlerInfo.emits,\n ...metadata,\n sourceContext: {\n file: sourceFile.fileName,\n startLine: sourceFile.getLineAndCharacterOfPosition(handlerArg.getStart()).line + 1,\n endLine: sourceFile.getLineAndCharacterOfPosition(handlerArg.getEnd()).line + 1,\n highlights: handlerInfo.highlights\n }\n };\n }\n\n /**\n * Analyze a route handler to extract type information\n */\n private analyzeHandler(handler: ts.Node, sourceFile: ts.SourceFile): {\n requestTypes?: RouteInfo['requestTypes'];\n responseType?: string;\n responseSchema?: any;\n emits?: { event: string; payload?: any; location?: { startLine: number; endLine: number; }; }[];\n highlights?: { startLine: number; endLine: number; type: 'emit' | 'return-success' | 'return-warning'; }[];\n } {\n const requestTypes: RouteInfo['requestTypes'] = {};\n let responseType: string | undefined;\n let responseSchema: any | undefined;\n let hasExplicitReturnType = false;\n const emits: { event: string; payload?: any; location?: { startLine: number; endLine: number; }; }[] = [];\n const highlights: { startLine: number; endLine: number; type: 'emit' | 'return-success' | 'return-warning'; }[] = [];\n\n // Simple scope to track variable types (name -> schema)\n const scope = new Map<string, any>();\n\n // Pre-populate scope with function parameters\n if (ts.isFunctionLike(handler)) {\n handler.parameters.forEach(param => {\n if (ts.isIdentifier(param.name) && param.type) {\n const paramName = param.name.getText(sourceFile);\n // Resolving TypeReference for parameters (e.g. User) would require partial type checker or expanded scope logic\n // For now, we rely on basic types\n const paramType = this.convertTypeNodeToSchema(param.type, sourceFile);\n if (paramType) {\n scope.set(paramName, paramType);\n }\n }\n });\n\n // Check for explicit return type annotation\n if (handler.type) {\n const returnSchema = this.convertTypeNodeToSchema(handler.type, sourceFile);\n if (returnSchema) {\n responseSchema = returnSchema;\n responseType = returnSchema.type;\n hasExplicitReturnType = true;\n }\n }\n }\n\n // Helper to analyze an expression that is being returned (either explicitly or implicitly)\n const analyzeReturnExpression = (expr: ts.Expression) => {\n let node = expr;\n // Unwrap await\n if (ts.isAwaitExpression(node)) {\n node = node.expression;\n }\n\n\n // Case 1: return ctx.json(...) or ctx.text(...)\n if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression)) {\n const callObj = node.expression.expression.getText(sourceFile);\n const callProp = node.expression.name.getText(sourceFile);\n\n if (callObj === 'ctx' || callObj.endsWith('.ctx')) {\n if (callProp === 'json') {\n if (node.arguments.length > 0) {\n responseSchema = this.convertExpressionToSchema(node.arguments[0], sourceFile, scope);\n responseType = 'object';\n }\n return;\n }\n else if (callProp === 'text') {\n responseType = 'string';\n return;\n }\n else if (callProp === 'html' || callProp === 'jsx') {\n responseType = 'html';\n return;\n }\n }\n }\n\n // Case 2: Direct object return\n // Only use this if we haven't found a better schema yet, or if it looks specific\n // And if we don't have an explicit return type\n if (!hasExplicitReturnType && (!responseSchema || responseSchema.type === 'object')) {\n const schema = this.convertExpressionToSchema(node, sourceFile, scope);\n if (schema && (schema.type !== 'object' || Object.keys(schema.properties || {}).length > 0)) {\n responseSchema = schema;\n responseType = schema.type;\n }\n }\n\n // Fallback to text matching if schema inference failed and we still don't have a type\n if (!responseSchema && !responseType) {\n const returnText = node.getText(sourceFile);\n if (returnText.startsWith('{')) {\n responseType = 'object';\n } else if (returnText.startsWith('[')) {\n responseType = 'array';\n } else if (returnText.startsWith('\"') || returnText.startsWith(\"'\")) {\n responseType = 'string';\n }\n }\n };\n\n // Handle arrow functions\n let body: ts.Block | undefined;\n // Also check for Kind 175 (Method/Accessor in some TS versions)\n if (ts.isArrowFunction(handler) || ts.isFunctionExpression(handler) || ts.isMethodDeclaration(handler) || handler.kind === 175) {\n // TS method has .body which is FunctionBody (Block) or undefined\n body = (handler as any).body;\n\n // Visit the handler body to find ctx usage\n const visit = (node: ts.Node) => {\n // Track variable declarations\n if (ts.isVariableDeclaration(node)) {\n if (node.initializer && ts.isIdentifier(node.name)) {\n const varName = node.name.getText(sourceFile);\n\n // Check if initializer is a type assertion on ctx.body()\n let initializer = node.initializer;\n if (ts.isAsExpression(initializer)) {\n if (this.isCtxBodyCall(initializer.expression, sourceFile)) {\n const schema = this.convertTypeNodeToSchema(initializer.type, sourceFile);\n if (schema) {\n requestTypes.body = schema;\n scope.set(varName, schema);\n }\n } else {\n const schema = this.convertExpressionToSchema(initializer, sourceFile, scope);\n scope.set(varName, schema);\n }\n } else {\n const schema = this.convertExpressionToSchema(initializer, sourceFile, scope);\n scope.set(varName, schema);\n }\n }\n }\n\n // Check for type assertions on ctx.body()\n if (ts.isAsExpression(node)) {\n if (this.isCtxBodyCall(node.expression, sourceFile)) {\n const schema = this.convertTypeNodeToSchema(node.type, sourceFile);\n if (schema) {\n requestTypes.body = schema;\n\n // Track variables assigned to this body\n if (ts.isVariableDeclaration(node.parent)) {\n const varName = node.parent.name.getText(sourceFile);\n scope.set(varName, schema);\n }\n }\n }\n }\n\n // Look for ctx calls (json, text, html, send, emit) to highlight\n if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression)) {\n const objText = node.expression.expression.getText(sourceFile);\n const propText = node.expression.name.getText(sourceFile);\n\n if (objText === 'ctx' || objText.endsWith('.ctx') || objText === 'this') {\n const startLine = sourceFile.getLineAndCharacterOfPosition(node.getStart()).line + 1;\n const endLine = sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line + 1;\n\n if (['text', 'html', 'jsx'].includes(propText)) {\n // text/html/jsx are always strings, so statically valid\n highlights.push({ startLine, endLine, type: 'return-success' });\n } else if (propText === 'json') {\n // Check if we can extract a schema for the argument\n let isStatic = false;\n if (node.arguments.length > 0) {\n const schema = this.convertExpressionToSchema(node.arguments[0], sourceFile, scope);\n // If schema is not just a bare object or any, it's static\n if (schema && (schema.type !== 'object' || (schema.properties && Object.keys(schema.properties).length > 0))) {\n isStatic = true;\n }\n }\n highlights.push({ startLine, endLine, type: isStatic ? 'return-success' : 'return-warning' });\n } else if (['send', 'emit'].includes(propText)) {\n highlights.push({ startLine, endLine, type: 'emit' });\n }\n }\n }\n\n // Look for ctx usage\n if (ts.isPropertyAccessExpression(node)) {\n const objText = node.expression.getText(sourceFile);\n const propText = node.name.getText(sourceFile);\n\n if (objText === 'ctx' || objText.endsWith('.ctx')) {\n if (propText === 'body') {\n if (!requestTypes.body) {\n requestTypes.body = { type: 'object' };\n }\n } else if (propText === 'query') {\n if (!requestTypes.query) requestTypes.query = {};\n } else if (propText === 'params') {\n if (!requestTypes.params) requestTypes.params = {};\n } else if (propText === 'headers') {\n if (!requestTypes.headers) requestTypes.headers = {};\n }\n }\n }\n\n // Explicit Return\n if (ts.isReturnStatement(node)) {\n const startLine = sourceFile.getLineAndCharacterOfPosition(node.getStart()).line + 1;\n const endLine = sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line + 1;\n\n let isStatic = false;\n if (node.expression) {\n analyzeReturnExpression(node.expression);\n // If analyzeReturnExpression successfully set responseSchema to something specific, it's static\n // Note: analyzeReturnExpression updates local 'responseSchema' variable. \n // We check if it's \"good\"\n if (responseSchema && (responseSchema.type !== 'object' || (responseSchema.properties && Object.keys(responseSchema.properties).length > 0))) {\n isStatic = true;\n }\n } else if (hasExplicitReturnType) {\n // void return or similar\n isStatic = true;\n }\n\n highlights.push({ startLine, endLine, type: isStatic ? 'return-success' : 'return-warning' });\n }\n\n // Implicit Return (Concise Arrow Function)\n // e.g. (ctx) => ctx.json(...) or .then(res => ctx.json(res))\n if (ts.isArrowFunction(node) && !ts.isBlock(node.body)) {\n // For concise arrow function, the body IS the return value\n const startLine = sourceFile.getLineAndCharacterOfPosition(node.body.getStart()).line + 1;\n const endLine = sourceFile.getLineAndCharacterOfPosition(node.body.getEnd()).line + 1;\n\n analyzeReturnExpression(node.body as ts.Expression);\n\n let isStatic = false;\n if (responseSchema && (responseSchema.type !== 'object' || (responseSchema.properties && Object.keys(responseSchema.properties).length > 0))) {\n isStatic = true;\n }\n\n highlights.push({ startLine, endLine, type: isStatic ? 'return-success' : 'return-warning' });\n }\n\n // Implicit Return call (e.g. ctx.json(...) as a statement without return)\n if (ts.isExpressionStatement(node)) {\n analyzeReturnExpression(node.expression);\n\n // Check for ctx.emit() or this.emit()\n if (ts.isCallExpression(node.expression)) {\n const expr = node.expression;\n if (ts.isPropertyAccessExpression(expr.expression)) {\n const objText = expr.expression.expression.getText(sourceFile);\n const propText = expr.expression.name.getText(sourceFile);\n\n if (((objText === 'ctx' || objText.endsWith('.ctx')) || (objText === 'this' || objText.endsWith('.this'))) && propText === 'emit') {\n if (expr.arguments.length >= 1) {\n const eventNameArg = expr.arguments[0];\n if (ts.isStringLiteral(eventNameArg)) {\n const eventName = eventNameArg.text;\n let payload = { type: 'object' };\n\n if (expr.arguments.length >= 2) {\n payload = this.convertExpressionToSchema(expr.arguments[1], sourceFile, scope);\n }\n\n const emitLoc = {\n startLine: sourceFile.getLineAndCharacterOfPosition(expr.getStart()).line + 1,\n endLine: sourceFile.getLineAndCharacterOfPosition(expr.getEnd()).line + 1\n };\n emits.push({ event: eventName, payload, location: emitLoc });\n } else {\n const emitLoc = {\n startLine: sourceFile.getLineAndCharacterOfPosition(expr.getStart()).line + 1,\n endLine: sourceFile.getLineAndCharacterOfPosition(expr.getEnd()).line + 1\n };\n emits.push({ event: '__DYNAMIC_EMIT__', payload: { type: 'object' }, location: emitLoc });\n }\n }\n }\n }\n }\n }\n\n ts.forEachChild(node, visit);\n };\n\n if (ts.isBlock(body)) {\n ts.forEachChild(body, visit);\n } else {\n // Main handler is an implicit return: app.get('/', (ctx) => ctx.json(...))\n analyzeReturnExpression(body);\n // Also verify children (e.g. if body is a CallExpression, verify args??)\n // analyzeReturnExpression analyzes the expression itself.\n // But we ALSO want to visit children to find other usages (request types)\n // or nested arrow functions in a call chain (e.g. chaining .then())\n ts.forEachChild(body, visit);\n }\n }\n\n return { requestTypes, responseType, responseSchema, emits, highlights };\n }\n\n /**\n * Convert an Expression node to an OpenAPI schema (best effort)\n */\n private convertExpressionToSchema(node: ts.Expression, sourceFile: ts.SourceFile, scope: Map<string, any>): any {\n // Object Literal: { a: 1, b: \"text\" }\n if (ts.isObjectLiteralExpression(node)) {\n const schema: any = {\n type: 'object',\n properties: {},\n required: []\n };\n\n for (let i = 0; i < node.properties.length; i++) {\n const prop = node.properties[i];\n if (ts.isPropertyAssignment(prop)) {\n const name = prop.name.getText(sourceFile);\n const valueSchema = this.convertExpressionToSchema(prop.initializer, sourceFile, scope);\n\n schema.properties[name] = valueSchema;\n schema.required.push(name); // Properties in literal return are required\n }\n else if (ts.isShorthandPropertyAssignment(prop)) {\n const name = prop.name.getText(sourceFile);\n // Check scope for variable\n const scopedSchema = scope.get(name);\n schema.properties[name] = scopedSchema || { type: 'object' };\n schema.required.push(name);\n }\n }\n if (schema.required.length === 0) {\n delete schema.required;\n }\n return schema;\n }\n\n // Array Literal: [1, 2]\n if (ts.isArrayLiteralExpression(node)) {\n const schema: any = { type: 'array' };\n if (node.elements.length > 0) {\n // Infer item type from first element\n schema.items = this.convertExpressionToSchema(node.elements[0], sourceFile, scope);\n } else {\n schema.items = {};\n }\n return schema;\n }\n\n // Conditional (Ternary) Expression: cond ? trueVal : falseVal\n if (ts.isConditionalExpression(node)) {\n const trueSchema = this.convertExpressionToSchema(node.whenTrue, sourceFile, scope);\n // const falseSchema = this.convertExpressionToSchema(node.whenFalse, sourceFile, scope);\n\n // Simplified: return true branch schema. Ideally we'd do oneOf\n return trueSchema;\n }\n\n // Template Expression: `Hello ${name}`\n if (ts.isTemplateExpression(node)) {\n return { type: 'string' };\n }\n\n // Identifier (Variable reference)\n if (ts.isIdentifier(node)) {\n const name = node.getText(sourceFile);\n const scopedSchema = scope.get(name);\n if (scopedSchema) return scopedSchema;\n return { type: 'object' }; // Unknown reference\n }\n\n // Literals\n if (ts.isStringLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node)) return { type: 'string' };\n if (ts.isNumericLiteral(node)) return { type: 'number' };\n if (node.kind === ts.SyntaxKind.TrueKeyword || node.kind === ts.SyntaxKind.FalseKeyword) return { type: 'boolean' };\n\n // Unknown\n return { type: 'object' };\n }\n\n /**\n * Check if an expression is a call to ctx.body()\n */\n private isCtxBodyCall(node: ts.Expression, sourceFile: ts.SourceFile): boolean {\n // Handle await ctx.body()\n if (ts.isAwaitExpression(node)) {\n return this.isCtxBodyCall(node.expression, sourceFile);\n }\n\n // Handle ctx.body()\n if (ts.isCallExpression(node)) {\n // Check expression: ctx.body\n if (ts.isPropertyAccessExpression(node.expression)) {\n const objText = node.expression.expression.getText(sourceFile);\n const propText = node.expression.name.getText(sourceFile);\n return (objText === 'ctx' || objText.endsWith('.ctx')) && propText === 'body';\n }\n }\n\n return false;\n }\n\n /**\n * Convert a TypeScript TypeNode to an OpenAPI schema\n */\n private convertTypeNodeToSchema(typeNode: ts.TypeNode, sourceFile: ts.SourceFile): any {\n switch (typeNode.kind) {\n case ts.SyntaxKind.StringKeyword:\n return { type: 'string' };\n case ts.SyntaxKind.NumberKeyword:\n return { type: 'number' };\n case ts.SyntaxKind.BooleanKeyword:\n return { type: 'boolean' };\n case ts.SyntaxKind.AnyKeyword:\n case ts.SyntaxKind.UnknownKeyword:\n return {}; // Any/Unknown -> empty schema (accepts anything)\n\n case ts.SyntaxKind.TypeLiteral: {\n const literal = typeNode as ts.TypeLiteralNode;\n const schema: any = {\n type: 'object',\n properties: {},\n required: []\n };\n\n for (let i = 0; i < literal.members.length; i++) {\n const member = literal.members[i];\n if (ts.isPropertySignature(member) && member.type) {\n const name = member.name.getText(sourceFile);\n const propSchema = this.convertTypeNodeToSchema(member.type, sourceFile);\n\n schema.properties[name] = propSchema;\n\n // Property is required unless it has a question token\n if (!member.questionToken) {\n schema.required.push(name);\n }\n }\n }\n\n if (schema.required.length === 0) {\n delete schema.required;\n }\n\n return schema;\n }\n\n case ts.SyntaxKind.ArrayType: {\n const arrayType = typeNode as ts.ArrayTypeNode;\n return {\n type: 'array',\n items: this.convertTypeNodeToSchema(arrayType.elementType, sourceFile)\n };\n }\n\n // Handle Type References (e.g. Array<string>)\n case ts.SyntaxKind.TypeReference: {\n const typeRef = typeNode as ts.TypeReferenceNode;\n const typeName = typeRef.typeName.getText(sourceFile);\n\n if (typeName === 'Array' && typeRef.typeArguments?.length > 0) {\n return {\n type: 'array',\n items: this.convertTypeNodeToSchema(typeRef.typeArguments[0], sourceFile)\n };\n }\n\n if (typeName === 'Promise' && typeRef.typeArguments?.length > 0) {\n return this.convertTypeNodeToSchema(typeRef.typeArguments[0], sourceFile);\n }\n\n // For other references, we default to string or object as fallback\n // A fuller implementation would resolve the reference\n return { type: 'object', description: `Ref: ${typeName}` };\n }\n\n default:\n return { type: 'object' };\n }\n }\n\n /**\n * Extract mount information from mount call\n */\n private extractMountFromCall(node: ts.CallExpression, sourceFile: ts.SourceFile): MountInfo | null {\n const args = node.arguments;\n\n if (args.length < 2) return null;\n\n const pathArg = args[0];\n const targetArg = args[1];\n\n let prefix = '/';\n if (ts.isStringLiteral(pathArg)) {\n prefix = pathArg.text;\n }\n\n const target = targetArg.getText(sourceFile);\n\n // Check if target is from node_modules\n const dependency = this.checkIfExternalDependency(target, sourceFile);\n let targetFilePath: string | undefined;\n\n if (!dependency) {\n // Check for internal import\n let modulePath: string | undefined;\n ts.forEachChild(sourceFile, (node) => {\n if (targetFilePath || modulePath) return; // Found\n\n if (ts.isImportDeclaration(node)) {\n const specifier = node.moduleSpecifier;\n if (ts.isStringLiteral(specifier)) {\n const path = specifier.text;\n if (path.startsWith('.')) {\n // Check default import: import target from './...'\n if (node.importClause?.name?.getText(sourceFile) === target) {\n modulePath = path;\n }\n // Check named imports: import { target } from './...'\n else if (node.importClause?.namedBindings && ts.isNamedImports(node.importClause.namedBindings)) {\n for (const element of node.importClause.namedBindings.elements) {\n if (element.name.getText(sourceFile) === target) {\n modulePath = path;\n break;\n }\n }\n }\n }\n }\n }\n });\n\n if (modulePath) {\n const dir = path.dirname(sourceFile.fileName);\n const absolutePath = path.resolve(dir, modulePath);\n\n // Try to resolve extension\n const extensions = ['.ts', '.js', '.tsx', '.jsx', '/index.ts', '/index.js'];\n for (const ext of extensions) {\n if (fs.existsSync(absolutePath + ext)) {\n targetFilePath = absolutePath + ext;\n break;\n }\n // If absolutePath ends in /index (implicit)\n // Or if modulePath points to directory\n }\n // Try straight (if user included extension)\n if (!targetFilePath && fs.existsSync(absolutePath)) {\n targetFilePath = absolutePath;\n }\n // Try directory index\n if (!targetFilePath && fs.existsSync(path.join(absolutePath, 'index.ts'))) {\n targetFilePath = path.join(absolutePath, 'index.ts');\n }\n\n // Normalize result?\n }\n }\n\n return {\n prefix,\n target,\n targetFilePath,\n dependency,\n sourceContext: {\n file: sourceFile.fileName,\n startLine: sourceFile.getLineAndCharacterOfPosition(node.getStart()).line + 1,\n endLine: sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line + 1\n }\n };\n }\n\n /**\n * Check if a reference is to an external dependency\n */\n private checkIfExternalDependency(identifier: string, sourceFile: ts.SourceFile): DependencyInfo | undefined {\n // This is a simplified check - in a full implementation, \n // we'd track imports and resolve them\n\n // For now, check if there's an import statement for this identifier\n const imports: ts.ImportDeclaration[] = [];\n\n ts.forEachChild(sourceFile, (node) => {\n if (ts.isImportDeclaration(node)) {\n imports.push(node);\n }\n });\n\n for (let i = 0; i < imports.length; i++) {\n const imp = imports[i];\n const moduleSpecifier = imp.moduleSpecifier;\n if (ts.isStringLiteral(moduleSpecifier)) {\n const modulePath = moduleSpecifier.text;\n\n // Check if it's a node_modules import (no relative path)\n if (!modulePath.startsWith('.') && !modulePath.startsWith('/')) {\n const namedBindings = imp.importClause?.namedBindings;\n\n if (namedBindings && ts.isNamedImports(namedBindings)) {\n for (let j = 0; j < namedBindings.elements.length; j++) {\n const element = namedBindings.elements[j];\n if (element.name.text === identifier) {\n // Try to read package version\n const version = this.getPackageVersion(modulePath);\n\n return {\n packageName: modulePath,\n version,\n importPath: modulePath,\n isExternal: true\n };\n }\n }\n }\n }\n }\n }\n\n return undefined;\n }\n\n /**\n * Get package version from package.json\n */\n private getPackageVersion(packageName: string): string | undefined {\n try {\n const packageJsonPath = path.join(this.rootDir, 'node_modules', packageName, 'package.json');\n if (fs.existsSync(packageJsonPath)) {\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));\n return packageJson.version;\n }\n } catch (e) {\n // Ignore\n }\n return undefined;\n }\n\n /**\n * Generate OpenAPI specification\n */\n public generateOpenAPISpec(): any {\n const paths: Record<string, any> = {};\n\n const collectRoutes = (app: ApplicationInstance, prefix: string = '') => {\n // Add direct routes\n for (let i = 0; i < app.routes.length; i++) {\n const route = app.routes[i];\n // Ensure prefix handles slashes correctly\n const cleanPrefix = prefix.endsWith('/') ? prefix.slice(0, -1) : prefix;\n const cleanPath = route.path.startsWith('/') ? route.path : '/' + route.path;\n const fullPath = (cleanPrefix + cleanPath) || '/';\n\n // Normalization is already done in extractRouteFromCall, but double check\n const pathKey = fullPath.replace(/:([a-zA-Z0-9_]+)/g, '{$1}');\n\n if (!paths[pathKey]) {\n paths[pathKey] = {};\n }\n\n const method = route.method.toLowerCase();\n const operation: any = {\n summary: route.summary || `${route.method.toUpperCase()} ${pathKey}`,\n description: route.description,\n tags: route.tags,\n operationId: route.operationId,\n responses: {\n '200': {\n description: 'Successful response'\n }\n }\n };\n\n // Clean up undefined\n if (!operation.description) delete operation.description;\n if (!operation.tags) delete operation.tags;\n if (!operation.operationId) delete operation.operationId;\n\n // Add inferred response schema\n if (route.responseSchema) {\n operation.responses['200'].content = {\n 'application/json': {\n schema: route.responseSchema\n }\n };\n } else if (route.responseType) {\n // Fallback to basic type\n const contentType = route.responseType === 'string' ? 'text/plain' : 'application/json';\n operation.responses['200'].content = {\n [contentType]: {\n schema: { type: route.responseType }\n }\n };\n } else {\n // Default object\n operation.responses['200'].content = {\n 'application/json': {\n schema: { type: 'object' }\n }\n };\n }\n\n // Add request body schema if available\n if (route.requestTypes?.body) {\n operation.requestBody = {\n content: {\n 'application/json': {\n schema: route.requestTypes.body\n }\n }\n };\n }\n\n // Add query/path parameters\n const parameters: any[] = [];\n\n if (route.requestTypes?.query) {\n const entries = Object.entries(route.requestTypes.query);\n for (let i = 0; i < entries.length; i++) {\n const [key] = entries[i];\n parameters.push({\n name: key,\n in: 'query',\n schema: { type: 'string' }\n });\n }\n }\n\n if (route.requestTypes?.params) {\n // Also check for path params implied by the URL {param}\n // But assume extractRouteFromCall handled explicit ones?\n // Let's just trust requestTypes for now\n const entries = Object.entries(route.requestTypes.params);\n for (let i = 0; i < entries.length; i++) {\n const [key] = entries[i];\n parameters.push({\n name: key,\n in: 'path',\n required: true,\n schema: { type: 'string' }\n });\n }\n }\n\n // Extract params from path if not explicitly typed but present in URL\n // This backfills untyped params so they appear in spec\n const pathParams = pathKey.match(/{([^}]+)}/g);\n if (pathParams) {\n pathParams.forEach(p => {\n const name = p.slice(1, -1);\n if (!parameters.some(param => param.name === name && param.in === 'path')) {\n parameters.push({\n name,\n in: 'path',\n required: true,\n schema: { type: 'string' } // Default to string\n });\n }\n });\n }\n\n if (parameters.length > 0) {\n operation.parameters = parameters;\n }\n\n paths[pathKey][method] = operation;\n }\n\n // Recurse into mounted apps\n for (let i = 0; i < app.mounted.length; i++) {\n const mount = app.mounted[i];\n // We need to resolve the ApplicationInstance for the target\n // The 'mounted' array currently only stores { prefix, target, dependency }\n // We need to find the AppInstance that matches 'target' class name\n\n // Note: This simple matching by class name might be brittle if multiple files have same class name\n // In a full implementation we would resolve the file path.\n const mountedApp = this.applications.find(a => a.name === mount.target || a.className === mount.target);\n\n if (mountedApp) {\n // Prevent infinite recursion\n if (mountedApp === app) continue;\n\n const cleanPrefix = prefix.endsWith('/') ? prefix.slice(0, -1) : prefix;\n const mountPrefix = mount.prefix.startsWith('/') ? mount.prefix : '/' + mount.prefix;\n const nextPrefix = cleanPrefix + mountPrefix;\n\n collectRoutes(mountedApp, nextPrefix);\n }\n }\n };\n\n for (let i = 0; i < this.applications.length; i++) {\n const app = this.applications[i];\n // We only want to start collection from \"root\" apps? \n // Or just collect everything? \n // If we collect everything, we might duplicate routes if they are mounted.\n // Current findApplications finds ALL instances.\n\n // Heuristic: If this app is mounted by another app, don't collect it as root.\n // But we don't have back-references easily.\n // Simplified: Just collect everything for now, but realize that un-mounted routers might show up as root.\n // Ideally we need to find the \"Main\" app (root).\n\n // For now, let's collect all, but we might have duplicates if we traverse mounts.\n // Let's rely on the user to only have one Main entrypoint usually.\n // Or we can try to detect if it is mounted.\n\n const isMounted = this.applications.some(parent =>\n parent.mounted.some(m => m.target === app.name || m.target === app.className)\n );\n\n if (!isMounted) {\n collectRoutes(app);\n }\n }\n\n return {\n openapi: '3.1.0',\n info: {\n title: 'Shokupan API',\n version: '1.0.0',\n description: 'Auto-generated from Shokupan application analysis'\n },\n paths,\n components: {\n schemas: {}\n }\n };\n }\n}\n\n/**\n * Analyze a directory and generate OpenAPI spec\n */\nexport async function analyzeDirectory(directory: string): Promise<any> {\n const analyzer = new OpenAPIAnalyzer(directory);\n return await analyzer.analyze();\n}\n"],"names":["node","path","i"],"mappings":";;;;;AA+EO,MAAM,gBAAgB;AAAA,EAOzB,YAAoB,SAAiB,YAAqB;AAAtC,SAAA,UAAA;AAChB,QAAI,YAAY;AACZ,WAAK,aAAa,KAAK,QAAQ,UAAU;AAAA,IAC7C;AAAA,EACJ;AAAA,EAVQ,QAAyB,CAAA;AAAA,EACzB,eAAsC,CAAA;AAAA,EACtC;AAAA,EAEA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcR,MAAa,UAA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,OAAO,MAAM,GAAG,EAAE,IAAI;AACjE,gBAAM,cAAc,MAAM,OAAO,WAAW,GAAG,IAAI,MAAM,SAAS,MAAM,MAAM;AAC9E,gBAAM,aAAa,cAAc;AAEjC,wBAAc,YAAY,UAAU;AAAA,QACxC;AAAA,MACJ;AAAA,IACJ;AAEA,aAAS,IAAI,GAAG,IAAI,KAAK,aAAa,QAAQ,KAAK;AAC/C,YAAM,MAAM,KAAK,aAAa,CAAC;AAe/B,YAAM,YAAY,KAAK,aAAa;AAAA,QAAK,CAAA,WACrC,OAAO,QAAQ,KAAK,CAAA,MAAK,EAAE,WAAW,IAAI,QAAQ,EAAE,WAAW,IAAI,SAAS;AAAA,MAAA;AAGhF,UAAI,CAAC,WAAW;AACZ,sBAAc,GAAG;AAAA,MACrB;AAAA,IACJ;AAEA,WAAO;AAAA,MACH,SAAS;AAAA,MACT,MAAM;AAAA,QACF,OAAO;AAAA,QACP,SAAS;AAAA,QACT,aAAa;AAAA,MAAA;AAAA,MAEjB;AAAA,MACA,YAAY;AAAA,QACR,SAAS,CAAA;AAAA,MAAC;AAAA,IACd;AAAA,EAER;AACJ;;"}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const http = require("node:http");
|
|
4
|
-
require("node:https");
|
|
5
|
-
function _interopNamespaceDefault(e) {
|
|
6
|
-
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
7
|
-
if (e) {
|
|
8
|
-
for (const k in e) {
|
|
9
|
-
if (k !== "default") {
|
|
10
|
-
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
11
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: () => e[k]
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
n.default = e;
|
|
19
|
-
return Object.freeze(n);
|
|
20
|
-
}
|
|
21
|
-
const http__namespace = /* @__PURE__ */ _interopNamespaceDefault(http);
|
|
22
|
-
function createHttpServer() {
|
|
23
|
-
return async (options) => {
|
|
24
|
-
const server = http__namespace.createServer(async (req, res) => {
|
|
25
|
-
const url = new URL(req.url, `http://${req.headers.host}`);
|
|
26
|
-
const request = new Request(url.toString(), {
|
|
27
|
-
method: req.method,
|
|
28
|
-
headers: req.headers,
|
|
29
|
-
body: ["GET", "HEAD"].includes(req.method) ? void 0 : new ReadableStream({
|
|
30
|
-
start(controller) {
|
|
31
|
-
req.on("data", (chunk) => controller.enqueue(chunk));
|
|
32
|
-
req.on("end", () => controller.close());
|
|
33
|
-
req.on("error", (err) => controller.error(err));
|
|
34
|
-
}
|
|
35
|
-
}),
|
|
36
|
-
// Required for Node.js undici when sending a body
|
|
37
|
-
duplex: "half"
|
|
38
|
-
});
|
|
39
|
-
const response = await options.fetch(request, fauxServer);
|
|
40
|
-
res.statusCode = response.status;
|
|
41
|
-
response.headers.forEach((v, k) => res.setHeader(k, v));
|
|
42
|
-
if (response.body) {
|
|
43
|
-
const buffer = await response.arrayBuffer();
|
|
44
|
-
res.end(Buffer.from(buffer));
|
|
45
|
-
} else {
|
|
46
|
-
res.end();
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
const fauxServer = {
|
|
50
|
-
stop: () => {
|
|
51
|
-
server.close();
|
|
52
|
-
return Promise.resolve();
|
|
53
|
-
},
|
|
54
|
-
upgrade(req, options2) {
|
|
55
|
-
return false;
|
|
56
|
-
},
|
|
57
|
-
reload(options2) {
|
|
58
|
-
return fauxServer;
|
|
59
|
-
},
|
|
60
|
-
get port() {
|
|
61
|
-
const addr = server.address();
|
|
62
|
-
if (typeof addr === "object" && addr !== null) {
|
|
63
|
-
return addr.port;
|
|
64
|
-
}
|
|
65
|
-
return options.port;
|
|
66
|
-
},
|
|
67
|
-
hostname: options.hostname,
|
|
68
|
-
development: options.development,
|
|
69
|
-
pendingRequests: 0,
|
|
70
|
-
requestIP: (req) => null,
|
|
71
|
-
publish: () => 0,
|
|
72
|
-
subscriberCount: () => 0,
|
|
73
|
-
url: new URL(`http://${options.hostname}:${options.port}`),
|
|
74
|
-
// Expose the raw Node.js server for generic socket/websocket support (e.g. Socket.IO)
|
|
75
|
-
nodeServer: server
|
|
76
|
-
};
|
|
77
|
-
return new Promise((resolve) => {
|
|
78
|
-
server.listen(options.port, options.hostname, () => {
|
|
79
|
-
resolve(fauxServer);
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
exports.createHttpServer = createHttpServer;
|
|
85
|
-
//# sourceMappingURL=http-server-BEMPIs33.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http-server-BEMPIs33.cjs","sources":["../src/plugins/application/http-server.ts"],"sourcesContent":["import type { Server } from \"bun\";\nimport * as http from \"node:http\";\nimport * as https from \"node:https\";\nimport type { ServerFactory } from \"../../util/types\";\n\n/**\n * Creates a server factory that uses the standard Node.js `http` module.\n * @returns A ServerFactory compatible with Shokupan.\n */\nexport function createHttpServer(): ServerFactory {\n return async (options: any): Promise<Server<any>> => {\n const server = http.createServer(async (req, res) => {\n const url = new URL(req.url!, `http://${req.headers.host}`);\n const request = new Request(url.toString(), {\n method: req.method,\n headers: req.headers as any,\n body: ['GET', 'HEAD'].includes(req.method!) ? undefined : new ReadableStream({\n start(controller) {\n req.on('data', chunk => controller.enqueue(chunk));\n req.on('end', () => controller.close());\n req.on('error', err => controller.error(err));\n }\n }) as any,\n // Required for Node.js undici when sending a body\n duplex: 'half'\n } as any);\n\n const response = await options.fetch(request, fauxServer);\n\n res.statusCode = response.status;\n response.headers.forEach((v, k) => res.setHeader(k, v));\n\n if (response.body) {\n // Optimize: Use arrayBuffer for direct conversion instead of async iteration\n const buffer = await response.arrayBuffer();\n res.end(Buffer.from(buffer));\n } else {\n res.end();\n }\n });\n\n const fauxServer: Server<any> = {\n stop: () => {\n server.close();\n return Promise.resolve(); // Bun.Server stop usually returns void but in type definition it might vary.\n },\n upgrade(req, options) {\n return false;\n },\n reload(options) {\n return fauxServer as any;\n },\n get port() {\n const addr = server.address();\n if (typeof addr === 'object' && addr !== null) {\n return addr.port;\n }\n return options.port;\n },\n hostname: options.hostname,\n development: options.development,\n pendingRequests: 0,\n requestIP: (req) => null,\n publish: () => 0,\n subscriberCount: () => 0,\n url: new URL(`http://${options.hostname}:${options.port}`),\n // Expose the raw Node.js server for generic socket/websocket support (e.g. Socket.IO)\n nodeServer: server\n } as unknown as Server<any>;\n\n return new Promise((resolve) => {\n server.listen(options.port, options.hostname, () => {\n resolve(fauxServer);\n });\n });\n };\n}\n\n/**\n * Creates a server factory that uses the standard Node.js `https` module.\n * @param sslOptions - Node.js HTTPS options (key, cert, etc.)\n * @returns A ServerFactory compatible with Shokupan.\n */\nexport function createHttpsServer(sslOptions: https.ServerOptions): ServerFactory {\n return async (options: any): Promise<Server<any>> => {\n const server = https.createServer(sslOptions, async (req, res) => {\n const url = new URL(req.url!, `https://${req.headers.host}`);\n const request = new Request(url.toString(), {\n method: req.method,\n headers: req.headers as any,\n body: ['GET', 'HEAD'].includes(req.method!) ? undefined : new ReadableStream({\n start(controller) {\n req.on('data', chunk => controller.enqueue(chunk));\n req.on('end', () => controller.close());\n req.on('error', err => controller.error(err));\n }\n }) as any,\n // Required for Node.js undici when sending a body\n duplex: 'half'\n } as any);\n\n const response = await options.fetch(request, fauxServer);\n\n res.statusCode = response.status;\n response.headers.forEach((v, k) => res.setHeader(k, v));\n\n if (response.body) {\n // Optimize: Use arrayBuffer for direct conversion instead of async iteration\n const buffer = await response.arrayBuffer();\n res.end(Buffer.from(buffer));\n } else {\n res.end();\n }\n });\n\n const fauxServer: Server<any> = {\n stop: () => {\n server.close();\n },\n upgrade(req, options) {\n return false;\n },\n reload(options) {\n return fauxServer as any;\n },\n get port() {\n const addr = server.address();\n if (typeof addr === 'object' && addr !== null) {\n return addr.port;\n }\n return options.port;\n },\n hostname: options.hostname,\n development: options.development,\n pendingRequests: 0,\n requestIP: (req) => null,\n publish: () => 0,\n subscriberCount: () => 0,\n url: new URL(`https://${options.hostname}:${options.port}`),\n // Expose the raw Node.js server for generic socket/websocket support\n nodeServer: server\n } as unknown as Server<any>;\n\n return new Promise((resolve) => {\n server.listen(options.port, options.hostname, () => {\n resolve(fauxServer);\n });\n });\n };\n}\n"],"names":["http","options"],"mappings":";;;;;;;;;;;;;;;;;;;;;AASO,SAAS,mBAAkC;AAC9C,SAAO,OAAO,YAAuC;AACjD,UAAM,SAASA,gBAAK,aAAa,OAAO,KAAK,QAAQ;AACjD,YAAM,MAAM,IAAI,IAAI,IAAI,KAAM,UAAU,IAAI,QAAQ,IAAI,EAAE;AAC1D,YAAM,UAAU,IAAI,QAAQ,IAAI,YAAY;AAAA,QACxC,QAAQ,IAAI;AAAA,QACZ,SAAS,IAAI;AAAA,QACb,MAAM,CAAC,OAAO,MAAM,EAAE,SAAS,IAAI,MAAO,IAAI,SAAY,IAAI,eAAe;AAAA,UACzE,MAAM,YAAY;AACd,gBAAI,GAAG,QAAQ,CAAA,UAAS,WAAW,QAAQ,KAAK,CAAC;AACjD,gBAAI,GAAG,OAAO,MAAM,WAAW,OAAO;AACtC,gBAAI,GAAG,SAAS,CAAA,QAAO,WAAW,MAAM,GAAG,CAAC;AAAA,UAChD;AAAA,QAAA,CACH;AAAA;AAAA,QAED,QAAQ;AAAA,MAAA,CACJ;AAER,YAAM,WAAW,MAAM,QAAQ,MAAM,SAAS,UAAU;AAExD,UAAI,aAAa,SAAS;AAC1B,eAAS,QAAQ,QAAQ,CAAC,GAAG,MAAM,IAAI,UAAU,GAAG,CAAC,CAAC;AAEtD,UAAI,SAAS,MAAM;AAEf,cAAM,SAAS,MAAM,SAAS,YAAA;AAC9B,YAAI,IAAI,OAAO,KAAK,MAAM,CAAC;AAAA,MAC/B,OAAO;AACH,YAAI,IAAA;AAAA,MACR;AAAA,IACJ,CAAC;AAED,UAAM,aAA0B;AAAA,MAC5B,MAAM,MAAM;AACR,eAAO,MAAA;AACP,eAAO,QAAQ,QAAA;AAAA,MACnB;AAAA,MACA,QAAQ,KAAKC,UAAS;AAClB,eAAO;AAAA,MACX;AAAA,MACA,OAAOA,UAAS;AACZ,eAAO;AAAA,MACX;AAAA,MACA,IAAI,OAAO;AACP,cAAM,OAAO,OAAO,QAAA;AACpB,YAAI,OAAO,SAAS,YAAY,SAAS,MAAM;AAC3C,iBAAO,KAAK;AAAA,QAChB;AACA,eAAO,QAAQ;AAAA,MACnB;AAAA,MACA,UAAU,QAAQ;AAAA,MAClB,aAAa,QAAQ;AAAA,MACrB,iBAAiB;AAAA,MACjB,WAAW,CAAC,QAAQ;AAAA,MACpB,SAAS,MAAM;AAAA,MACf,iBAAiB,MAAM;AAAA,MACvB,KAAK,IAAI,IAAI,UAAU,QAAQ,QAAQ,IAAI,QAAQ,IAAI,EAAE;AAAA;AAAA,MAEzD,YAAY;AAAA,IAAA;AAGhB,WAAO,IAAI,QAAQ,CAAC,YAAY;AAC5B,aAAO,OAAO,QAAQ,MAAM,QAAQ,UAAU,MAAM;AAChD,gBAAQ,UAAU;AAAA,MACtB,CAAC;AAAA,IACL,CAAC;AAAA,EACL;AACJ;;"}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import * as http from "node:http";
|
|
2
|
-
import "node:https";
|
|
3
|
-
function createHttpServer() {
|
|
4
|
-
return async (options) => {
|
|
5
|
-
const server = http.createServer(async (req, res) => {
|
|
6
|
-
const url = new URL(req.url, `http://${req.headers.host}`);
|
|
7
|
-
const request = new Request(url.toString(), {
|
|
8
|
-
method: req.method,
|
|
9
|
-
headers: req.headers,
|
|
10
|
-
body: ["GET", "HEAD"].includes(req.method) ? void 0 : new ReadableStream({
|
|
11
|
-
start(controller) {
|
|
12
|
-
req.on("data", (chunk) => controller.enqueue(chunk));
|
|
13
|
-
req.on("end", () => controller.close());
|
|
14
|
-
req.on("error", (err) => controller.error(err));
|
|
15
|
-
}
|
|
16
|
-
}),
|
|
17
|
-
// Required for Node.js undici when sending a body
|
|
18
|
-
duplex: "half"
|
|
19
|
-
});
|
|
20
|
-
const response = await options.fetch(request, fauxServer);
|
|
21
|
-
res.statusCode = response.status;
|
|
22
|
-
response.headers.forEach((v, k) => res.setHeader(k, v));
|
|
23
|
-
if (response.body) {
|
|
24
|
-
const buffer = await response.arrayBuffer();
|
|
25
|
-
res.end(Buffer.from(buffer));
|
|
26
|
-
} else {
|
|
27
|
-
res.end();
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
const fauxServer = {
|
|
31
|
-
stop: () => {
|
|
32
|
-
server.close();
|
|
33
|
-
return Promise.resolve();
|
|
34
|
-
},
|
|
35
|
-
upgrade(req, options2) {
|
|
36
|
-
return false;
|
|
37
|
-
},
|
|
38
|
-
reload(options2) {
|
|
39
|
-
return fauxServer;
|
|
40
|
-
},
|
|
41
|
-
get port() {
|
|
42
|
-
const addr = server.address();
|
|
43
|
-
if (typeof addr === "object" && addr !== null) {
|
|
44
|
-
return addr.port;
|
|
45
|
-
}
|
|
46
|
-
return options.port;
|
|
47
|
-
},
|
|
48
|
-
hostname: options.hostname,
|
|
49
|
-
development: options.development,
|
|
50
|
-
pendingRequests: 0,
|
|
51
|
-
requestIP: (req) => null,
|
|
52
|
-
publish: () => 0,
|
|
53
|
-
subscriberCount: () => 0,
|
|
54
|
-
url: new URL(`http://${options.hostname}:${options.port}`),
|
|
55
|
-
// Expose the raw Node.js server for generic socket/websocket support (e.g. Socket.IO)
|
|
56
|
-
nodeServer: server
|
|
57
|
-
};
|
|
58
|
-
return new Promise((resolve) => {
|
|
59
|
-
server.listen(options.port, options.hostname, () => {
|
|
60
|
-
resolve(fauxServer);
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
export {
|
|
66
|
-
createHttpServer
|
|
67
|
-
};
|
|
68
|
-
//# sourceMappingURL=http-server-CCeagTyU.js.map
|