@honestjs/rpc-plugin 1.0.1 → 1.1.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/README.md CHANGED
@@ -58,7 +58,8 @@ The plugin generates a single comprehensive file that includes both the client a
58
58
  - **Type-safe parameters**: Path, query, and body parameters with proper typing
59
59
  - **Flexible request options**: Clean separation of params, query, body, and headers
60
60
  - **Error handling**: Built-in error handling with custom ApiError class
61
- - **Authentication support**: Easy header and auth token management
61
+ - **Header management**: Easy custom header management
62
+ - **Custom fetch support**: Inject custom fetch implementations for testing, middleware, and compatibility
62
63
  - **Integrated types**: All DTOs, interfaces, and utility types included in the same file
63
64
 
64
65
  ```typescript
@@ -81,12 +82,21 @@ const user = await apiClient.users.getById({
81
82
  params: { id: '123' }
82
83
  })
83
84
 
84
- // Set default authentication
85
- apiClient.setDefaultAuth('your-jwt-token')
86
-
87
85
  // Set custom headers
88
86
  apiClient.setDefaultHeaders({
89
- 'X-API-Key': 'your-api-key'
87
+ 'X-API-Key': 'your-api-key',
88
+ Authorization: 'Bearer your-jwt-token'
89
+ })
90
+
91
+ // Use with custom fetch function (e.g., for testing or custom logic)
92
+ const customFetch = (input: RequestInfo | URL, init?: RequestInit) => {
93
+ console.log('Making request to:', input)
94
+ return fetch(input, init)
95
+ }
96
+
97
+ const apiClientWithCustomFetch = new ApiClient('http://localhost:3000', {
98
+ fetchFn: customFetch,
99
+ defaultHeaders: { 'X-Custom-Header': 'value' }
90
100
  })
91
101
  ```
92
102
 
@@ -97,6 +107,96 @@ The generated `client.ts` file contains everything you need:
97
107
  - **Utility types** like RequestOptions and ApiResponse
98
108
  - **Generated interfaces** from your controller types
99
109
 
110
+ ## Custom Fetch Functions
111
+
112
+ The RPC client supports custom fetch implementations, which is useful for:
113
+
114
+ - **Testing**: Inject mock fetch functions for unit testing
115
+ - **Custom Logic**: Add logging, retries, or other middleware
116
+ - **Environment Compatibility**: Use different fetch implementations (node-fetch, undici, etc.)
117
+ - **Interceptors**: Wrap requests with custom logic before/after execution
118
+
119
+ ### Basic Custom Fetch Example
120
+
121
+ ```typescript
122
+ // Simple logging wrapper
123
+ const loggingFetch = (input: RequestInfo | URL, init?: RequestInit) => {
124
+ console.log(`[${new Date().toISOString()}] Making ${init?.method || 'GET'} request to:`, input)
125
+ return fetch(input, init)
126
+ }
127
+
128
+ const apiClient = new ApiClient('http://localhost:3000', {
129
+ fetchFn: loggingFetch
130
+ })
131
+ ```
132
+
133
+ ### Advanced Custom Fetch Examples
134
+
135
+ ```typescript
136
+ // Retry logic with exponential backoff
137
+ const retryFetch = (maxRetries = 3) => {
138
+ return async (input: RequestInfo | URL, init?: RequestInit) => {
139
+ for (let i = 0; i <= maxRetries; i++) {
140
+ try {
141
+ const response = await fetch(input, init)
142
+ if (response.ok) return response
143
+
144
+ if (i === maxRetries) return response
145
+
146
+ // Wait with exponential backoff
147
+ await new Promise((resolve) => setTimeout(resolve, Math.pow(2, i) * 1000))
148
+ } catch (error) {
149
+ if (i === maxRetries) throw error
150
+ }
151
+ }
152
+ throw new Error('Max retries exceeded')
153
+ }
154
+ }
155
+
156
+ const apiClientWithRetry = new ApiClient('http://localhost:3000', {
157
+ fetchFn: retryFetch(3)
158
+ })
159
+
160
+ // Request/response interceptor
161
+ const interceptorFetch = (input: RequestInfo | URL, init?: RequestInit) => {
162
+ // Pre-request logic
163
+ const enhancedInit = {
164
+ ...init,
165
+ headers: {
166
+ ...init?.headers,
167
+ 'X-Request-ID': crypto.randomUUID()
168
+ }
169
+ }
170
+
171
+ return fetch(input, enhancedInit).then((response) => {
172
+ // Post-response logic
173
+ console.log(`Response status: ${response.status}`)
174
+ return response
175
+ })
176
+ }
177
+
178
+ const apiClientWithInterceptor = new ApiClient('http://localhost:3000', {
179
+ fetchFn: interceptorFetch
180
+ })
181
+ ```
182
+
183
+ ### Testing with Custom Fetch
184
+
185
+ ```typescript
186
+ // Mock fetch for testing
187
+ const mockFetch = jest.fn().mockResolvedValue({
188
+ ok: true,
189
+ json: () => Promise.resolve({ data: { id: '123', name: 'Test User' } })
190
+ })
191
+
192
+ const testApiClient = new ApiClient('http://test.com', {
193
+ fetchFn: mockFetch
194
+ })
195
+
196
+ // Your test can now verify the mock was called
197
+ expect(mockFetch).toHaveBeenCalledWith('http://test.com/api/v1/users/123', expect.objectContaining({ method: 'GET' }))
198
+ ```
199
+
100
200
  ## How It Works
101
201
 
102
202
  ### 1. Route Analysis
package/dist/index.d.mts CHANGED
@@ -66,6 +66,10 @@ type RequestOptions<TParams = never, TQuery = never, TBody = never, THeaders = n
66
66
  } : {
67
67
  headers: THeaders;
68
68
  });
69
+ /**
70
+ * Custom fetch function type that matches the standard fetch API
71
+ */
72
+ type FetchFunction = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
69
73
  /**
70
74
  * API Response wrapper
71
75
  */
@@ -330,4 +334,4 @@ declare const BUILTIN_TYPES: Set<string>;
330
334
  */
331
335
  declare const GENERIC_TYPES: Set<string>;
332
336
 
333
- export { ApiError, type ApiResponse, BUILTIN_TYPES, BUILTIN_UTILITY_TYPES, ClientGeneratorService, type ControllerGroups, DEFAULT_OPTIONS, type ExtendedRouteInfo, GENERIC_TYPES, type GeneratedClientInfo, LOG_PREFIX, type ParameterMetadataWithType, RPCPlugin, type RPCPluginOptions, type RequestOptions, RouteAnalyzerService, type RouteParameter, SchemaGeneratorService, type SchemaInfo, buildFullApiPath, buildFullPath, camelCase, extractNamedType, generateTypeImports, generateTypeScriptInterface, mapJsonSchemaTypeToTypeScript, safeToString };
337
+ export { ApiError, type ApiResponse, BUILTIN_TYPES, BUILTIN_UTILITY_TYPES, ClientGeneratorService, type ControllerGroups, DEFAULT_OPTIONS, type ExtendedRouteInfo, type FetchFunction, GENERIC_TYPES, type GeneratedClientInfo, LOG_PREFIX, type ParameterMetadataWithType, RPCPlugin, type RPCPluginOptions, type RequestOptions, RouteAnalyzerService, type RouteParameter, SchemaGeneratorService, type SchemaInfo, buildFullApiPath, buildFullPath, camelCase, extractNamedType, generateTypeImports, generateTypeScriptInterface, mapJsonSchemaTypeToTypeScript, safeToString };
package/dist/index.d.ts CHANGED
@@ -66,6 +66,10 @@ type RequestOptions<TParams = never, TQuery = never, TBody = never, THeaders = n
66
66
  } : {
67
67
  headers: THeaders;
68
68
  });
69
+ /**
70
+ * Custom fetch function type that matches the standard fetch API
71
+ */
72
+ type FetchFunction = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
69
73
  /**
70
74
  * API Response wrapper
71
75
  */
@@ -330,4 +334,4 @@ declare const BUILTIN_TYPES: Set<string>;
330
334
  */
331
335
  declare const GENERIC_TYPES: Set<string>;
332
336
 
333
- export { ApiError, type ApiResponse, BUILTIN_TYPES, BUILTIN_UTILITY_TYPES, ClientGeneratorService, type ControllerGroups, DEFAULT_OPTIONS, type ExtendedRouteInfo, GENERIC_TYPES, type GeneratedClientInfo, LOG_PREFIX, type ParameterMetadataWithType, RPCPlugin, type RPCPluginOptions, type RequestOptions, RouteAnalyzerService, type RouteParameter, SchemaGeneratorService, type SchemaInfo, buildFullApiPath, buildFullPath, camelCase, extractNamedType, generateTypeImports, generateTypeScriptInterface, mapJsonSchemaTypeToTypeScript, safeToString };
337
+ export { ApiError, type ApiResponse, BUILTIN_TYPES, BUILTIN_UTILITY_TYPES, ClientGeneratorService, type ControllerGroups, DEFAULT_OPTIONS, type ExtendedRouteInfo, type FetchFunction, GENERIC_TYPES, type GeneratedClientInfo, LOG_PREFIX, type ParameterMetadataWithType, RPCPlugin, type RPCPluginOptions, type RequestOptions, RouteAnalyzerService, type RouteParameter, SchemaGeneratorService, type SchemaInfo, buildFullApiPath, buildFullPath, camelCase, extractNamedType, generateTypeImports, generateTypeScriptInterface, mapJsonSchemaTypeToTypeScript, safeToString };
package/dist/index.js CHANGED
@@ -197,6 +197,14 @@ export type RequestOptions<
197
197
  (TBody extends undefined ? object : { body: TBody }) &
198
198
  (THeaders extends undefined ? object : { headers: THeaders })
199
199
 
200
+ /**
201
+ * Custom fetch function type that matches the standard fetch API
202
+ */
203
+ export type FetchFunction = (
204
+ input: RequestInfo | URL,
205
+ init?: RequestInit
206
+ ) => Promise<Response>
207
+
200
208
  // Generated DTOs and types from integrated Schema Generation
201
209
  ${this.generateSchemaTypes(schemas)}
202
210
 
@@ -224,6 +232,17 @@ ${this.generateSchemaTypes(schemas)}
224
232
  * const newUser = await apiClient.users.createUser({
225
233
  * body: { name: 'John', email: 'john@example.com' }
226
234
  * })
235
+ *
236
+ * // Use with custom fetch function (e.g., for testing or custom logic)
237
+ * const customFetch = (input: RequestInfo | URL, init?: RequestInit) => {
238
+ * console.log('Making request to:', input)
239
+ * return fetch(input, init)
240
+ * }
241
+ *
242
+ * const apiClientWithCustomFetch = new ApiClient('http://localhost:3000', {
243
+ * fetchFn: customFetch,
244
+ * defaultHeaders: { 'X-Custom-Header': 'value' }
245
+ * })
227
246
  * \`\`\`
228
247
  *
229
248
  * @generated This class is auto-generated by RPCPlugin
@@ -231,13 +250,21 @@ ${this.generateSchemaTypes(schemas)}
231
250
  export class ApiClient {
232
251
  private baseUrl: string
233
252
  private defaultHeaders: Record<string, string>
253
+ private fetchFn: FetchFunction
234
254
 
235
- constructor(baseUrl: string, defaultHeaders: Record<string, string> = {}) {
255
+ constructor(
256
+ baseUrl: string,
257
+ options: {
258
+ defaultHeaders?: Record<string, string>
259
+ fetchFn?: FetchFunction
260
+ } = {}
261
+ ) {
236
262
  this.baseUrl = baseUrl.replace(/\\/$/, '')
237
263
  this.defaultHeaders = {
238
264
  'Content-Type': 'application/json',
239
- ...defaultHeaders
265
+ ...options.defaultHeaders
240
266
  }
267
+ this.fetchFn = options.fetchFn || fetch
241
268
  }
242
269
 
243
270
  /**
@@ -248,13 +275,6 @@ export class ApiClient {
248
275
  return this
249
276
  }
250
277
 
251
- /**
252
- * Set default authorization header
253
- */
254
- setDefaultAuth(token: string): this {
255
- this.defaultHeaders.Authorization = \`Bearer \${token}\`
256
- return this
257
- }
258
278
 
259
279
  /**
260
280
  * Make an HTTP request with flexible options
@@ -298,7 +318,7 @@ export class ApiClient {
298
318
  }
299
319
 
300
320
  try {
301
- const response = await fetch(url.toString(), requestOptions)
321
+ const response = await this.fetchFn(url.toString(), requestOptions)
302
322
  const responseData = await response.json()
303
323
 
304
324
  if (!response.ok) {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/rpc.plugin.ts","../src/constants/defaults.ts","../src/services/client-generator.service.ts","../src/utils/path-utils.ts","../src/utils/string-utils.ts","../src/services/route-analyzer.service.ts","../src/services/schema-generator.service.ts","../src/utils/schema-utils.ts","../src/utils/type-utils.ts"],"sourcesContent":["// Main plugin export\nexport { RPCPlugin } from './rpc.plugin'\n\n// Export all types\nexport type {\n\tApiError,\n\tApiResponse,\n\tControllerGroups,\n\tExtendedRouteInfo,\n\tGeneratedClientInfo,\n\tParameterMetadataWithType,\n\tRequestOptions,\n\tRouteParameter,\n\tRPCPluginOptions,\n\tSchemaInfo\n} from './types'\n\n// Export services for advanced usage\nexport { ClientGeneratorService } from './services/client-generator.service'\nexport { RouteAnalyzerService } from './services/route-analyzer.service'\nexport { SchemaGeneratorService } from './services/schema-generator.service'\n\n// Export utilities for custom implementations\nexport * from './utils/path-utils'\nexport * from './utils/schema-utils'\nexport * from './utils/string-utils'\nexport * from './utils/type-utils'\n\n// Export constants\nexport * from './constants/defaults'\n","import fs from 'fs'\nimport type { Application, IPlugin } from 'honestjs'\nimport type { Hono } from 'hono'\nimport path from 'path'\n\nimport { DEFAULT_OPTIONS, LOG_PREFIX } from './constants/defaults'\nimport { ClientGeneratorService } from './services/client-generator.service'\nimport { RouteAnalyzerService } from './services/route-analyzer.service'\nimport { SchemaGeneratorService } from './services/schema-generator.service'\nimport type { ExtendedRouteInfo, GeneratedClientInfo, SchemaInfo } from './types'\n\n/**\n * Configuration options for the RPCPlugin\n */\nexport interface RPCPluginOptions {\n\treadonly controllerPattern?: string\n\treadonly tsConfigPath?: string\n\treadonly outputDir?: string\n\treadonly generateOnInit?: boolean\n}\n\n/**\n * Comprehensive RPC plugin that combines route analysis, schema generation, and client generation\n */\nexport class RPCPlugin implements IPlugin {\n\tprivate readonly controllerPattern: string\n\tprivate readonly tsConfigPath: string\n\tprivate readonly outputDir: string\n\tprivate readonly generateOnInit: boolean\n\n\t// Services\n\tprivate readonly routeAnalyzer: RouteAnalyzerService\n\tprivate readonly schemaGenerator: SchemaGeneratorService\n\tprivate readonly clientGenerator: ClientGeneratorService\n\n\t// Internal state\n\tprivate analyzedRoutes: ExtendedRouteInfo[] = []\n\tprivate analyzedSchemas: SchemaInfo[] = []\n\tprivate generatedInfo: GeneratedClientInfo | null = null\n\n\tconstructor(options: RPCPluginOptions = {}) {\n\t\tthis.controllerPattern = options.controllerPattern ?? DEFAULT_OPTIONS.controllerPattern\n\t\tthis.tsConfigPath = options.tsConfigPath ?? path.resolve(process.cwd(), DEFAULT_OPTIONS.tsConfigPath)\n\t\tthis.outputDir = options.outputDir ?? path.resolve(process.cwd(), DEFAULT_OPTIONS.outputDir)\n\t\tthis.generateOnInit = options.generateOnInit ?? DEFAULT_OPTIONS.generateOnInit\n\n\t\t// Initialize services\n\t\tthis.routeAnalyzer = new RouteAnalyzerService(this.controllerPattern, this.tsConfigPath)\n\t\tthis.schemaGenerator = new SchemaGeneratorService(this.controllerPattern, this.tsConfigPath)\n\t\tthis.clientGenerator = new ClientGeneratorService(this.outputDir)\n\n\t\tthis.validateConfiguration()\n\t}\n\n\t/**\n\t * Validates the plugin configuration\n\t */\n\tprivate validateConfiguration(): void {\n\t\tconst errors: string[] = []\n\n\t\tif (!this.controllerPattern?.trim()) {\n\t\t\terrors.push('Controller pattern cannot be empty')\n\t\t}\n\n\t\tif (!this.tsConfigPath?.trim()) {\n\t\t\terrors.push('TypeScript config path cannot be empty')\n\t\t} else {\n\t\t\tif (!fs.existsSync(this.tsConfigPath)) {\n\t\t\t\terrors.push(`TypeScript config file not found at: ${this.tsConfigPath}`)\n\t\t\t}\n\t\t}\n\n\t\tif (!this.outputDir?.trim()) {\n\t\t\terrors.push('Output directory cannot be empty')\n\t\t}\n\n\t\tif (errors.length > 0) {\n\t\t\tthrow new Error(`Configuration validation failed: ${errors.join(', ')}`)\n\t\t}\n\n\t\tthis.log(\n\t\t\t`Configuration validated: controllerPattern=${this.controllerPattern}, tsConfigPath=${this.tsConfigPath}, outputDir=${this.outputDir}`\n\t\t)\n\t}\n\n\t/**\n\t * Called after all modules are registered\n\t */\n\tafterModulesRegistered = async (app: Application, hono: Hono): Promise<void> => {\n\t\tif (this.generateOnInit) {\n\t\t\tawait this.analyzeEverything()\n\t\t}\n\t}\n\n\t/**\n\t * Main analysis method that coordinates all three components\n\t */\n\tprivate async analyzeEverything(): Promise<void> {\n\t\ttry {\n\t\t\tthis.log('Starting comprehensive RPC analysis...')\n\n\t\t\t// Clear previous analysis results to prevent memory leaks\n\t\t\tthis.analyzedRoutes = []\n\t\t\tthis.analyzedSchemas = []\n\t\t\tthis.generatedInfo = null\n\n\t\t\t// Step 1: Analyze routes and extract type information\n\t\t\tthis.analyzedRoutes = await this.routeAnalyzer.analyzeControllerMethods()\n\n\t\t\t// Step 2: Generate schemas from the types we found\n\t\t\tthis.analyzedSchemas = await this.schemaGenerator.generateSchemas()\n\n\t\t\t// Step 3: Generate the RPC client\n\t\t\tthis.generatedInfo = await this.clientGenerator.generateClient(this.analyzedRoutes, this.analyzedSchemas)\n\n\t\t\tthis.log(\n\t\t\t\t`✅ RPC analysis complete: ${this.analyzedRoutes.length} routes, ${this.analyzedSchemas.length} schemas`\n\t\t\t)\n\t\t} catch (error) {\n\t\t\tthis.logError('Error during RPC analysis:', error)\n\t\t\t// Ensure cleanup happens even on error\n\t\t\tthis.dispose()\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t/**\n\t * Manually trigger analysis (useful for testing or re-generation)\n\t */\n\tasync analyze(): Promise<void> {\n\t\tawait this.analyzeEverything()\n\t}\n\n\t/**\n\t * Get the analyzed routes\n\t */\n\tgetRoutes(): readonly ExtendedRouteInfo[] {\n\t\treturn this.analyzedRoutes\n\t}\n\n\t/**\n\t * Get the analyzed schemas\n\t */\n\tgetSchemas(): readonly SchemaInfo[] {\n\t\treturn this.analyzedSchemas\n\t}\n\n\t/**\n\t * Get the generation info\n\t */\n\tgetGenerationInfo(): GeneratedClientInfo | null {\n\t\treturn this.generatedInfo\n\t}\n\n\t/**\n\t * Cleanup resources to prevent memory leaks\n\t */\n\tdispose(): void {\n\t\tthis.routeAnalyzer.dispose()\n\t\tthis.schemaGenerator.dispose()\n\t\tthis.log('Resources cleaned up')\n\t}\n\n\t// ============================================================================\n\t// LOGGING UTILITIES\n\t// ============================================================================\n\n\t/**\n\t * Logs a message with the plugin prefix\n\t */\n\tprivate log(message: string): void {\n\t\tconsole.log(`${LOG_PREFIX} ${message}`)\n\t}\n\n\t/**\n\t * Logs an error with the plugin prefix\n\t */\n\tprivate logError(message: string, error?: unknown): void {\n\t\tconsole.error(`${LOG_PREFIX} ${message}`, error || '')\n\t}\n}\n","/**\n * Default configuration options for the RPCPlugin\n */\nexport const DEFAULT_OPTIONS = {\n\tcontrollerPattern: 'src/modules/*/*.controller.ts',\n\ttsConfigPath: 'tsconfig.json',\n\toutputDir: './generated/rpc',\n\tgenerateOnInit: true\n} as const\n\n/**\n * Log prefix for the RPC plugin\n */\nexport const LOG_PREFIX = '[ RPCPlugin ]'\n\n/**\n * Built-in TypeScript types that should not be imported\n */\nexport const BUILTIN_UTILITY_TYPES = new Set([\n\t'Partial',\n\t'Required',\n\t'Readonly',\n\t'Pick',\n\t'Omit',\n\t'Record',\n\t'Exclude',\n\t'Extract',\n\t'ReturnType',\n\t'InstanceType'\n])\n\n/**\n * Built-in TypeScript types that should be skipped\n */\nexport const BUILTIN_TYPES = new Set(['string', 'number', 'boolean', 'any', 'void', 'unknown'])\n\n/**\n * Generic type names that should be unwrapped\n */\nexport const GENERIC_TYPES = new Set(['Array', 'Promise', 'Partial'])\n","import fs from 'fs/promises'\nimport path from 'path'\nimport type { ControllerGroups, ExtendedRouteInfo, RouteParameter } from '../types/route.types'\nimport type { GeneratedClientInfo, SchemaInfo } from '../types/schema.types'\nimport { buildFullApiPath } from '../utils/path-utils'\nimport { camelCase, safeToString } from '../utils/string-utils'\n\n/**\n * Service for generating TypeScript RPC clients\n */\nexport class ClientGeneratorService {\n\tconstructor(private readonly outputDir: string) {}\n\n\t/**\n\t * Generates the TypeScript RPC client\n\t */\n\tasync generateClient(\n\t\troutes: readonly ExtendedRouteInfo[],\n\t\tschemas: readonly SchemaInfo[]\n\t): Promise<GeneratedClientInfo> {\n\t\tawait fs.mkdir(this.outputDir, { recursive: true })\n\n\t\tawait this.generateClientFile(routes, schemas)\n\n\t\tconst generatedInfo: GeneratedClientInfo = {\n\t\t\tclientFile: path.join(this.outputDir, 'client.ts'),\n\t\t\tgeneratedAt: new Date().toISOString()\n\t\t}\n\n\t\treturn generatedInfo\n\t}\n\n\t/**\n\t * Generates the main client file with types included\n\t */\n\tprivate async generateClientFile(\n\t\troutes: readonly ExtendedRouteInfo[],\n\t\tschemas: readonly SchemaInfo[]\n\t): Promise<void> {\n\t\tconst clientContent = this.generateClientContent(routes, schemas)\n\t\tconst clientPath = path.join(this.outputDir, 'client.ts')\n\t\tawait fs.writeFile(clientPath, clientContent, 'utf-8')\n\t}\n\n\t/**\n\t * Generates the client TypeScript content with types included\n\t */\n\tprivate generateClientContent(routes: readonly ExtendedRouteInfo[], schemas: readonly SchemaInfo[]): string {\n\t\tconst controllerGroups = this.groupRoutesByController(routes)\n\n\t\treturn `// ============================================================================\n// TYPES SECTION\n// ============================================================================\n\n/**\n * API Response wrapper\n */\nexport interface ApiResponse<T = any> {\n\tdata: T\n\tmessage?: string\n\tsuccess: boolean\n}\n\n/**\n * API Error class\n */\nexport class ApiError extends Error {\n\tconstructor(\n\t\tpublic statusCode: number,\n\t\tmessage: string\n\t) {\n\t\tsuper(message)\n\t\tthis.name = 'ApiError'\n\t}\n}\n\n/**\n * Clean separation of concerns for request options\n */\nexport type RequestOptions<\n\tTParams = undefined,\n\tTQuery = undefined,\n\tTBody = undefined,\n\tTHeaders = undefined\n> = (TParams extends undefined ? object : { params: TParams }) &\n\t(TQuery extends undefined ? object : { query: TQuery }) &\n\t(TBody extends undefined ? object : { body: TBody }) &\n\t(THeaders extends undefined ? object : { headers: THeaders })\n\n// Generated DTOs and types from integrated Schema Generation\n${this.generateSchemaTypes(schemas)}\n\n// ============================================================================\n// CLIENT SECTION\n// ============================================================================\n\n/**\n * Generated RPC Client\n * \n * This class provides a type-safe HTTP client for interacting with your API endpoints.\n * It's automatically generated by the RPCPlugin based on your controller definitions.\n * \n * @example\n * \\`\\`\\`typescript\n * const apiClient = new ApiClient('http://localhost:3000')\n * \n * // Make a request to get users\n * const response = await apiClient.users.getUsers()\n * \n * // Make a request with parameters\n * const user = await apiClient.users.getUser({ params: { id: '123' } })\n * \n * // Make a request with body data\n * const newUser = await apiClient.users.createUser({ \n * body: { name: 'John', email: 'john@example.com' } \n * })\n * \\`\\`\\`\n * \n * @generated This class is auto-generated by RPCPlugin\n */\nexport class ApiClient {\n\tprivate baseUrl: string\n\tprivate defaultHeaders: Record<string, string>\n\n\tconstructor(baseUrl: string, defaultHeaders: Record<string, string> = {}) {\n\t\tthis.baseUrl = baseUrl.replace(/\\\\/$/, '')\n\t\tthis.defaultHeaders = {\n\t\t\t'Content-Type': 'application/json',\n\t\t\t...defaultHeaders\n\t\t}\n\t}\n\n\t/**\n\t * Set default headers for all requests\n\t */\n\tsetDefaultHeaders(headers: Record<string, string>): this {\n\t\tthis.defaultHeaders = { ...this.defaultHeaders, ...headers }\n\t\treturn this\n\t}\n\n\t/**\n\t * Set default authorization header\n\t */\n\tsetDefaultAuth(token: string): this {\n\t\tthis.defaultHeaders.Authorization = \\`Bearer \\${token}\\`\n\t\treturn this\n\t}\n\n\t/**\n\t * Make an HTTP request with flexible options\n\t */\n\tprivate async request<T>(\n\t\tmethod: string,\n\t\tpath: string,\n\t\toptions: RequestOptions<any, any, any, any> = {}\n\t): Promise<ApiResponse<T>> {\n\t\tconst { params, query, body, headers = {} } = options as any\n\t\t\n\t\t// Build the final URL with path parameters\n\t\tlet finalPath = path\n\t\tif (params) {\n\t\t\tObject.entries(params).forEach(([key, value]) => {\n\t\t\t\tfinalPath = finalPath.replace(\\`:\\${key}\\`, String(value))\n\t\t\t})\n\t\t}\n\n\t\tconst url = new URL(finalPath, this.baseUrl)\n\t\t\n\t\t// Add query parameters\n\t\tif (query) {\n\t\t\tObject.entries(query).forEach(([key, value]) => {\n\t\t\t\tif (value !== undefined && value !== null) {\n\t\t\t\t\turl.searchParams.append(key, String(value))\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\n\t\t// Merge default headers with request-specific headers\n\t\tconst finalHeaders = { ...this.defaultHeaders, ...headers }\n\n\t\tconst requestOptions: RequestInit = {\n\t\t\tmethod,\n\t\t\theaders: finalHeaders,\n\t\t}\n\n\t\tif (body && method !== 'GET') {\n\t\t\trequestOptions.body = JSON.stringify(body)\n\t\t}\n\n\t\ttry {\n\t\t\tconst response = await fetch(url.toString(), requestOptions)\n\t\t\tconst responseData = await response.json()\n\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow new ApiError(response.status, responseData.message || 'Request failed')\n\t\t\t}\n\n\t\t\treturn responseData\n\t\t} catch (error) {\n\t\t\tif (error instanceof ApiError) {\n\t\t\t\tthrow error\n\t\t\t}\n\t\t\tthrow new ApiError(0, error instanceof Error ? error.message : 'Network error')\n\t\t}\n\t}\n\n${this.generateControllerMethods(controllerGroups)}\n}\n`\n\t}\n\n\t/**\n\t * Generates controller methods for the client\n\t */\n\tprivate generateControllerMethods(controllerGroups: ControllerGroups): string {\n\t\tlet methods = ''\n\n\t\tfor (const [controllerName, routes] of controllerGroups) {\n\t\t\tconst className = controllerName.replace(/Controller$/, '')\n\t\t\tmethods += `\n\t// ${className} Controller\n`\n\t\t\tmethods += `\tget ${camelCase(className)}() {\n`\n\t\t\tmethods += `\t\treturn {\n`\n\n\t\t\tfor (const route of routes) {\n\t\t\t\tconst methodName = camelCase(safeToString(route.handler))\n\t\t\t\tconst httpMethod = safeToString(route.method).toLowerCase()\n\t\t\t\tconst { pathParams, queryParams, bodyParams } = this.analyzeRouteParameters(route)\n\n\t\t\t\tconst hasRequiredParams =\n\t\t\t\t\tpathParams.length > 0 ||\n\t\t\t\t\tqueryParams.some((p) => p.required) ||\n\t\t\t\t\t(bodyParams.length > 0 && httpMethod !== 'get')\n\n\t\t\t\t// Generate the method signature with proper typing\n\t\t\t\tmethods += `\t\t\t${methodName}: async (options${hasRequiredParams ? '' : '?'}: RequestOptions<`\n\n\t\t\t\t// Path parameters type\n\t\t\t\tif (pathParams.length > 0) {\n\t\t\t\t\tconst pathParamTypes = pathParams.map((p) => {\n\t\t\t\t\t\tconst paramName = p.name\n\t\t\t\t\t\tconst paramType = p.type || 'any'\n\t\t\t\t\t\treturn `${paramName}: ${paramType}`\n\t\t\t\t\t})\n\t\t\t\t\tmethods += `{ ${pathParamTypes.join(', ')} }`\n\t\t\t\t} else {\n\t\t\t\t\tmethods += 'undefined'\n\t\t\t\t}\n\n\t\t\t\tmethods += ', '\n\n\t\t\t\t// Query parameters type\n\t\t\t\tif (queryParams.length > 0) {\n\t\t\t\t\tconst queryParamTypes = queryParams.map((p) => {\n\t\t\t\t\t\tconst paramName = p.name\n\t\t\t\t\t\tconst paramType = p.type || 'any'\n\t\t\t\t\t\treturn `${paramName}: ${paramType}`\n\t\t\t\t\t})\n\t\t\t\t\tmethods += `{ ${queryParamTypes.join(', ')} }`\n\t\t\t\t} else {\n\t\t\t\t\tmethods += 'undefined'\n\t\t\t\t}\n\n\t\t\t\tmethods += ', '\n\n\t\t\t\t// Body type\n\t\t\t\tif (bodyParams.length > 0) {\n\t\t\t\t\tconst bodyParamTypes = bodyParams.map((p) => {\n\t\t\t\t\t\tconst paramType = p.type || 'any'\n\t\t\t\t\t\treturn paramType\n\t\t\t\t\t})\n\t\t\t\t\t// Use the first body parameter type, not 'any'\n\t\t\t\t\tmethods += bodyParamTypes[0] || 'any'\n\t\t\t\t} else {\n\t\t\t\t\tmethods += 'undefined'\n\t\t\t\t}\n\n\t\t\t\tmethods += ', '\n\n\t\t\t\t// Headers type - always optional for now, but could be made conditional\n\t\t\t\tmethods += 'undefined'\n\n\t\t\t\t// Extract return type from route analysis for better type safety\n\t\t\t\tconst returnType = this.extractReturnType(route.returns)\n\t\t\t\tmethods += `>): Promise<ApiResponse<${returnType}>> => {\n`\n\n\t\t\t\t// Build the full API path using route information\n\t\t\t\tlet requestPath = buildFullApiPath(route)\n\n\t\t\t\t// Replace path parameters with placeholders for dynamic substitution\n\t\t\t\tif (pathParams.length > 0) {\n\t\t\t\t\tfor (const pathParam of pathParams) {\n\t\t\t\t\t\tconst paramName = pathParam.name\n\t\t\t\t\t\tconst placeholder = `:${String(pathParam.data)}`\n\t\t\t\t\t\trequestPath = requestPath.replace(placeholder, `:${paramName}`)\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tmethods += `\t\t\t\treturn this.request<${returnType}>('${httpMethod.toUpperCase()}', \\`${requestPath}\\`, options)\n`\n\t\t\t\tmethods += `\t\t\t},\n`\n\t\t\t}\n\n\t\t\tmethods += `\t\t}\n`\n\t\t\tmethods += `\t}\n`\n\t\t}\n\n\t\treturn methods\n\t}\n\n\t/**\n\t * Extracts the proper return type from route analysis\n\t */\n\tprivate extractReturnType(returns?: string): string {\n\t\tif (!returns) return 'any'\n\n\t\t// Handle Promise<T> types\n\t\tconst promiseMatch = returns.match(/Promise<(.+)>/)\n\t\tif (promiseMatch) {\n\t\t\treturn promiseMatch[1]\n\t\t}\n\n\t\t// Handle other types\n\t\treturn returns\n\t}\n\n\t/**\n\t * Generates schema types from integrated schema generation\n\t */\n\tprivate generateSchemaTypes(schemas: readonly SchemaInfo[]): string {\n\t\tif (schemas.length === 0) {\n\t\t\treturn '// No schemas available from integrated Schema Generation\\n'\n\t\t}\n\n\t\tlet content = '// Schema types from integrated Schema Generation\\n'\n\t\tfor (const schemaInfo of schemas) {\n\t\t\tif (schemaInfo.typescriptType) {\n\t\t\t\tcontent += `${schemaInfo.typescriptType}\\n\\n`\n\t\t\t}\n\t\t}\n\t\treturn content\n\t}\n\n\t/**\n\t * Groups routes by controller for better organization\n\t */\n\tprivate groupRoutesByController(routes: readonly ExtendedRouteInfo[]): ControllerGroups {\n\t\tconst groups = new Map<string, ExtendedRouteInfo[]>()\n\n\t\tfor (const route of routes) {\n\t\t\tconst controller = safeToString(route.controller)\n\t\t\tif (!groups.has(controller)) {\n\t\t\t\tgroups.set(controller, [])\n\t\t\t}\n\t\t\tgroups.get(controller)!.push(route)\n\t\t}\n\n\t\treturn groups\n\t}\n\n\t/**\n\t * Analyzes route parameters to determine their types and usage\n\t */\n\tprivate analyzeRouteParameters(route: ExtendedRouteInfo): {\n\t\tpathParams: readonly RouteParameter[]\n\t\tqueryParams: readonly RouteParameter[]\n\t\tbodyParams: readonly RouteParameter[]\n\t} {\n\t\tconst parameters = route.parameters || []\n\t\tconst method = String(route.method || '').toLowerCase()\n\n\t\tconst isInPath = (p: RouteParameter): boolean => {\n\t\t\t// Check if this parameter corresponds to a path segment\n\t\t\t// For path parameters, the data field should contain the path segment name\n\t\t\tconst pathSegment = p.data\n\t\t\treturn !!pathSegment && typeof pathSegment === 'string' && route.path.includes(`:${pathSegment}`)\n\t\t}\n\n\t\t// path params are always required if they exist in the path\n\t\tconst pathParams = parameters.filter((p) => isInPath(p)).map((p) => ({ ...p, required: true }))\n\n\t\t// body is required if any body param exists for non-GET\n\t\tconst rawBody = parameters.filter((p) => !isInPath(p) && method !== 'get')\n\t\tconst bodyParams = rawBody.map((p) => ({\n\t\t\t...p,\n\t\t\trequired: true\n\t\t}))\n\n\t\t// query requiredness comes from analyzer if available; default optional\n\t\tconst queryParams = parameters\n\t\t\t.filter((p) => !isInPath(p) && method === 'get')\n\t\t\t.map((p) => ({\n\t\t\t\t...p,\n\t\t\t\trequired: p.required === true // default false if not provided\n\t\t\t}))\n\n\t\treturn { pathParams, queryParams, bodyParams }\n\t}\n}\n","import type { ParameterMetadata } from 'honestjs'\nimport type { ExtendedRouteInfo } from '../types/route.types'\n\n/**\n * Builds the full path with parameter placeholders\n */\nexport function buildFullPath(basePath: string, parameters: readonly ParameterMetadata[]): string {\n\tif (!basePath || typeof basePath !== 'string') return '/'\n\n\tlet path = basePath\n\n\tif (parameters && Array.isArray(parameters)) {\n\t\tfor (const param of parameters) {\n\t\t\tif (param.data && typeof param.data === 'string' && param.data.startsWith(':')) {\n\t\t\t\tconst paramName = param.data.slice(1)\n\t\t\t\tpath = path.replace(`:${paramName}`, `\\${${paramName}}`)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn path\n}\n\n/**\n * Builds the full API path using route information\n */\nexport function buildFullApiPath(route: ExtendedRouteInfo): string {\n\tconst prefix = route.prefix || ''\n\tconst version = route.version || ''\n\tconst routePath = route.route || ''\n\tconst path = route.path || ''\n\n\tlet fullPath = ''\n\n\t// Add prefix (e.g., /api)\n\tif (prefix && prefix !== '/') {\n\t\tfullPath += prefix.replace(/^\\/+|\\/+$/g, '')\n\t}\n\n\t// Add version (e.g., /v1)\n\tif (version && version !== '/') {\n\t\tfullPath += `/${version.replace(/^\\/+|\\/+$/g, '')}`\n\t}\n\n\t// Add route (e.g., /users)\n\tif (routePath && routePath !== '/') {\n\t\tfullPath += `/${routePath.replace(/^\\/+|\\/+$/g, '')}`\n\t}\n\n\t// Add path (e.g., /:id or /)\n\tif (path && path !== '/') {\n\t\tfullPath += `/${path.replace(/^\\/+|\\/+$/g, '')}`\n\t} else if (path === '/') {\n\t\tfullPath += '/'\n\t}\n\n\treturn fullPath || '/'\n}\n","/**\n * Safely converts a value to string, handling symbols and other types\n */\nexport function safeToString(value: unknown): string {\n\tif (typeof value === 'string') return value\n\tif (typeof value === 'symbol') return value.description || 'Symbol'\n\treturn String(value)\n}\n\n/**\n * Converts a string to camelCase\n */\nexport function camelCase(str: string): string {\n\treturn str.charAt(0).toLowerCase() + str.slice(1)\n}\n","import { RouteRegistry, type ParameterMetadata, type RouteInfo } from 'honestjs'\nimport { ClassDeclaration, MethodDeclaration, Project } from 'ts-morph'\nimport type { ExtendedRouteInfo, ParameterMetadataWithType } from '../types/route.types'\nimport { buildFullPath } from '../utils/path-utils'\nimport { safeToString } from '../utils/string-utils'\n\n/**\n * Service for analyzing controller methods and extracting type information\n */\nexport class RouteAnalyzerService {\n\tconstructor(\n\t\tprivate readonly controllerPattern: string,\n\t\tprivate readonly tsConfigPath: string\n\t) {}\n\n\t// Track projects for cleanup\n\tprivate projects: Project[] = []\n\n\t/**\n\t * Analyzes controller methods to extract type information\n\t */\n\tasync analyzeControllerMethods(): Promise<ExtendedRouteInfo[]> {\n\t\tconst routes = RouteRegistry.getRoutes()\n\t\tif (!routes?.length) {\n\t\t\treturn []\n\t\t}\n\n\t\tconst project = this.createProject()\n\t\tconst controllers = this.findControllerClasses(project)\n\n\t\tif (controllers.size === 0) {\n\t\t\treturn []\n\t\t}\n\n\t\treturn this.processRoutes(routes, controllers)\n\t}\n\n\t/**\n\t * Creates a new ts-morph project\n\t */\n\tprivate createProject(): Project {\n\t\tconst project = new Project({\n\t\t\ttsConfigFilePath: this.tsConfigPath\n\t\t})\n\n\t\tproject.addSourceFilesAtPaths([this.controllerPattern])\n\t\tthis.projects.push(project)\n\t\treturn project\n\t}\n\n\t/**\n\t * Cleanup resources to prevent memory leaks\n\t */\n\tdispose(): void {\n\t\tthis.projects.forEach((project) => {\n\t\t\t// Remove all source files to free memory\n\t\t\tproject.getSourceFiles().forEach((file) => project.removeSourceFile(file))\n\t\t})\n\t\tthis.projects = []\n\t}\n\n\t/**\n\t * Finds controller classes in the project\n\t */\n\tprivate findControllerClasses(project: Project): Map<string, ClassDeclaration> {\n\t\tconst controllers = new Map<string, ClassDeclaration>()\n\t\tconst files = project.getSourceFiles()\n\n\t\tfor (const sourceFile of files) {\n\t\t\tconst classes = sourceFile.getClasses()\n\n\t\t\tfor (const classDeclaration of classes) {\n\t\t\t\tconst className = classDeclaration.getName()\n\n\t\t\t\tif (className?.endsWith('Controller')) {\n\t\t\t\t\tcontrollers.set(className, classDeclaration)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn controllers\n\t}\n\n\t/**\n\t * Processes all routes and extracts type information\n\t */\n\tprivate processRoutes(\n\t\troutes: readonly RouteInfo[],\n\t\tcontrollers: Map<string, ClassDeclaration>\n\t): ExtendedRouteInfo[] {\n\t\tconst analyzedRoutes: ExtendedRouteInfo[] = []\n\t\tconst errors: Error[] = []\n\n\t\tfor (const route of routes) {\n\t\t\ttry {\n\t\t\t\tconst extendedRoute = this.createExtendedRoute(route, controllers)\n\t\t\t\tanalyzedRoutes.push(extendedRoute)\n\t\t\t} catch (routeError) {\n\t\t\t\tconst error = routeError instanceof Error ? routeError : new Error(String(routeError))\n\t\t\t\terrors.push(error)\n\t\t\t\tconsole.error(\n\t\t\t\t\t`Error processing route ${safeToString(route.controller)}.${safeToString(route.handler)}:`,\n\t\t\t\t\trouteError\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\n\t\t// If there were any errors, throw a comprehensive error\n\t\tif (errors.length > 0) {\n\t\t\tthrow new Error(`Failed to process ${errors.length} routes: ${errors.map((e) => e.message).join(', ')}`)\n\t\t}\n\n\t\treturn analyzedRoutes\n\t}\n\n\t/**\n\t * Creates an extended route with type information\n\t */\n\tprivate createExtendedRoute(route: RouteInfo, controllers: Map<string, ClassDeclaration>): ExtendedRouteInfo {\n\t\tconst controllerName = safeToString(route.controller)\n\t\tconst handlerName = safeToString(route.handler)\n\n\t\tconst controllerClass = controllers.get(controllerName)\n\t\tlet returns: string | undefined\n\t\tlet parameters: readonly ParameterMetadataWithType[] | undefined\n\n\t\tif (controllerClass) {\n\t\t\tconst handlerMethod = controllerClass.getMethods().find((method) => method.getName() === handlerName)\n\n\t\t\tif (handlerMethod) {\n\t\t\t\treturns = this.getReturnType(handlerMethod)\n\t\t\t\tparameters = this.getParametersWithTypes(handlerMethod, route.parameters || [])\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tcontroller: controllerName,\n\t\t\thandler: handlerName,\n\t\t\tmethod: safeToString(route.method).toUpperCase(),\n\t\t\tprefix: route.prefix,\n\t\t\tversion: route.version,\n\t\t\troute: route.route,\n\t\t\tpath: route.path,\n\t\t\tfullPath: buildFullPath(route.path, route.parameters),\n\t\t\tparameters,\n\t\t\treturns\n\t\t}\n\t}\n\n\t/**\n\t * Gets the return type of a method\n\t */\n\tprivate getReturnType(method: MethodDeclaration): string {\n\t\tconst type = method.getReturnType()\n\t\tconst typeText = type.getText(method)\n\n\t\tconst aliasSymbol = type.getAliasSymbol()\n\t\tif (aliasSymbol) {\n\t\t\treturn aliasSymbol.getName()\n\t\t}\n\n\t\treturn typeText.replace(/import\\(\".*?\"\\)\\./g, '')\n\t}\n\n\t/**\n\t * Gets parameters with their types\n\t */\n\tprivate getParametersWithTypes(\n\t\tmethod: MethodDeclaration,\n\t\tparameters: readonly ParameterMetadata[]\n\t): readonly ParameterMetadataWithType[] {\n\t\tconst result: ParameterMetadataWithType[] = []\n\t\tconst declaredParams = method.getParameters()\n\t\tconst sortedParams = [...parameters].sort((a, b) => a.index - b.index)\n\n\t\tfor (const param of sortedParams) {\n\t\t\tconst index = param.index\n\n\t\t\tif (index < declaredParams.length) {\n\t\t\t\tconst declaredParam = declaredParams[index]\n\t\t\t\tconst paramName = declaredParam.getName()\n\t\t\t\tconst paramType = declaredParam\n\t\t\t\t\t.getType()\n\t\t\t\t\t.getText()\n\t\t\t\t\t.replace(/import\\(\".*?\"\\)\\./g, '')\n\n\t\t\t\tresult.push({\n\t\t\t\t\tindex,\n\t\t\t\t\tname: paramName,\n\t\t\t\t\ttype: paramType,\n\t\t\t\t\trequired: true,\n\t\t\t\t\tdata: param.data,\n\t\t\t\t\tfactory: param.factory,\n\t\t\t\t\tmetatype: param.metatype\n\t\t\t\t})\n\t\t\t} else {\n\t\t\t\tresult.push({\n\t\t\t\t\tindex,\n\t\t\t\t\tname: `param${index}`,\n\t\t\t\t\ttype: param.metatype?.name || 'unknown',\n\t\t\t\t\trequired: true,\n\t\t\t\t\tdata: param.data,\n\t\t\t\t\tfactory: param.factory,\n\t\t\t\t\tmetatype: param.metatype\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\treturn result\n\t}\n}\n","import { createGenerator } from 'ts-json-schema-generator'\nimport { MethodDeclaration, Project } from 'ts-morph'\nimport type { SchemaInfo } from '../types/schema.types'\nimport { generateTypeScriptInterface } from '../utils/schema-utils'\nimport { extractNamedType } from '../utils/type-utils'\n\n/**\n * Service for generating JSON schemas from TypeScript types used in controllers\n */\nexport class SchemaGeneratorService {\n\tconstructor(\n\t\tprivate readonly controllerPattern: string,\n\t\tprivate readonly tsConfigPath: string\n\t) {}\n\n\t// Track projects for cleanup\n\tprivate projects: Project[] = []\n\n\t/**\n\t * Generates JSON schemas from types used in controllers\n\t */\n\tasync generateSchemas(): Promise<SchemaInfo[]> {\n\t\tconst project = this.createProject()\n\t\tconst sourceFiles = project.getSourceFiles(this.controllerPattern)\n\n\t\tconst collectedTypes = this.collectTypesFromControllers(sourceFiles)\n\t\treturn this.processTypes(collectedTypes)\n\t}\n\n\t/**\n\t * Creates a new ts-morph project\n\t */\n\tprivate createProject(): Project {\n\t\tconst project = new Project({\n\t\t\ttsConfigFilePath: this.tsConfigPath\n\t\t})\n\n\t\tproject.addSourceFilesAtPaths([this.controllerPattern])\n\t\tthis.projects.push(project)\n\t\treturn project\n\t}\n\n\t/**\n\t * Cleanup resources to prevent memory leaks\n\t */\n\tdispose(): void {\n\t\tthis.projects.forEach((project) => {\n\t\t\t// Remove all source files to free memory\n\t\t\tproject.getSourceFiles().forEach((file) => project.removeSourceFile(file))\n\t\t})\n\t\tthis.projects = []\n\t}\n\n\t/**\n\t * Collects types from controller files\n\t */\n\tprivate collectTypesFromControllers(sourceFiles: readonly any[]): Set<string> {\n\t\tconst collectedTypes = new Set<string>()\n\n\t\tfor (const file of sourceFiles) {\n\t\t\tfor (const cls of file.getClasses()) {\n\t\t\t\tfor (const method of cls.getMethods()) {\n\t\t\t\t\tthis.collectTypesFromMethod(method, collectedTypes)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn collectedTypes\n\t}\n\n\t/**\n\t * Collects types from a single method\n\t */\n\tprivate collectTypesFromMethod(method: MethodDeclaration, collectedTypes: Set<string>): void {\n\t\t// Collect parameter types\n\t\tfor (const param of method.getParameters()) {\n\t\t\tconst type = extractNamedType(param.getType())\n\t\t\tif (type) collectedTypes.add(type)\n\t\t}\n\n\t\t// Collect return type\n\t\tconst returnType = method.getReturnType()\n\t\tconst innerType = returnType.getTypeArguments()[0] ?? returnType\n\t\tconst type = extractNamedType(innerType)\n\t\tif (type) collectedTypes.add(type)\n\t}\n\n\t/**\n\t * Processes collected types to generate schemas\n\t */\n\tprivate async processTypes(collectedTypes: Set<string>): Promise<SchemaInfo[]> {\n\t\tconst schemas: SchemaInfo[] = []\n\n\t\tfor (const typeName of collectedTypes) {\n\t\t\ttry {\n\t\t\t\tconst schema = await this.generateSchemaForType(typeName)\n\t\t\t\tconst typescriptType = generateTypeScriptInterface(typeName, schema)\n\n\t\t\t\tschemas.push({\n\t\t\t\t\ttype: typeName,\n\t\t\t\t\tschema,\n\t\t\t\t\ttypescriptType\n\t\t\t\t})\n\t\t\t} catch (err) {\n\t\t\t\tconsole.error(`Failed to generate schema for ${typeName}:`, err)\n\t\t\t}\n\t\t}\n\n\t\treturn schemas\n\t}\n\n\t/**\n\t * Generates schema for a specific type\n\t */\n\tprivate async generateSchemaForType(typeName: string): Promise<Record<string, any>> {\n\t\ttry {\n\t\t\tconst generator = createGenerator({\n\t\t\t\tpath: this.controllerPattern,\n\t\t\t\ttsconfig: this.tsConfigPath,\n\t\t\t\ttype: typeName,\n\t\t\t\tskipTypeCheck: false // Enable type checking for better error detection\n\t\t\t})\n\n\t\t\treturn generator.createSchema(typeName)\n\t\t} catch (error) {\n\t\t\tconsole.error(`Failed to generate schema for type ${typeName}:`, error)\n\t\t\t// Return a basic schema structure as fallback\n\t\t\treturn {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {},\n\t\t\t\trequired: []\n\t\t\t}\n\t\t}\n\t}\n}\n","/**\n * Maps JSON schema types to TypeScript types\n */\nexport function mapJsonSchemaTypeToTypeScript(schema: Record<string, any>): string {\n\tconst type = schema.type as string\n\n\tswitch (type) {\n\t\tcase 'string':\n\t\t\tif (schema.enum && Array.isArray(schema.enum)) {\n\t\t\t\treturn `'${schema.enum.join(\"' | '\")}'`\n\t\t\t}\n\t\t\treturn 'string'\n\t\tcase 'number':\n\t\tcase 'integer':\n\t\t\treturn 'number'\n\t\tcase 'boolean':\n\t\t\treturn 'boolean'\n\t\tcase 'array': {\n\t\t\tconst itemType = mapJsonSchemaTypeToTypeScript(schema.items || {})\n\t\t\treturn `${itemType}[]`\n\t\t}\n\t\tcase 'object':\n\t\t\treturn 'Record<string, any>'\n\t\tdefault:\n\t\t\treturn 'any'\n\t}\n}\n\n/**\n * Generates TypeScript interface from JSON schema\n */\nexport function generateTypeScriptInterface(typeName: string, schema: Record<string, any>): string {\n\ttry {\n\t\tconst typeDefinition = schema.definitions?.[typeName]\n\t\tif (!typeDefinition) {\n\t\t\treturn `export interface ${typeName} {\\n\\t// No schema definition found\\n}`\n\t\t}\n\n\t\tconst properties = typeDefinition.properties || {}\n\t\tconst required = typeDefinition.required || []\n\n\t\tlet interfaceCode = `export interface ${typeName} {\\n`\n\n\t\tfor (const [propName, propSchema] of Object.entries(properties)) {\n\t\t\tconst isRequired = required.includes(propName)\n\t\t\tconst type = mapJsonSchemaTypeToTypeScript(propSchema as Record<string, any>)\n\t\t\tconst optional = isRequired ? '' : '?'\n\n\t\t\tinterfaceCode += `\\t${propName}${optional}: ${type}\\n`\n\t\t}\n\n\t\tinterfaceCode += '}'\n\t\treturn interfaceCode\n\t} catch (error) {\n\t\tconsole.error(`Failed to generate TypeScript interface for ${typeName}:`, error)\n\t\treturn `export interface ${typeName} {\\n\\t// Failed to generate interface\\n}`\n\t}\n}\n","import type { Type } from 'ts-morph'\nimport { BUILTIN_TYPES, BUILTIN_UTILITY_TYPES, GENERIC_TYPES } from '../constants/defaults'\n\n/**\n * Extracts a named type from a TypeScript type\n */\nexport function extractNamedType(type: Type): string | null {\n\tconst symbol = type.getAliasSymbol() || type.getSymbol()\n\tif (!symbol) return null\n\n\tconst name = symbol.getName()\n\n\t// Handle generic types by unwrapping them\n\tif (GENERIC_TYPES.has(name)) {\n\t\tconst inner = type.getAliasTypeArguments()?.[0] || type.getTypeArguments()?.[0]\n\t\treturn inner ? extractNamedType(inner) : null\n\t}\n\n\t// Skip built-in types\n\tif (BUILTIN_TYPES.has(name)) return null\n\n\treturn name\n}\n\n/**\n * Generates type imports for the client\n */\nexport function generateTypeImports(routes: readonly any[]): string {\n\tconst types = new Set<string>()\n\n\tfor (const route of routes) {\n\t\t// Collect parameter types\n\t\tif (route.parameters) {\n\t\t\tfor (const param of route.parameters) {\n\t\t\t\tif (param.type && !['string', 'number', 'boolean'].includes(param.type)) {\n\t\t\t\t\t// Extract type name from complex types like Partial<CreateUserDto> or User[]\n\t\t\t\t\tconst typeMatch = param.type.match(/(\\w+)(?:<.*>)?/)\n\t\t\t\t\tif (typeMatch) {\n\t\t\t\t\t\tconst typeName = typeMatch[1]\n\t\t\t\t\t\t// Don't import built-in TypeScript utility types\n\t\t\t\t\t\tif (!BUILTIN_UTILITY_TYPES.has(typeName)) {\n\t\t\t\t\t\t\ttypes.add(typeName)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Collect return types\n\t\tif (route.returns) {\n\t\t\tconst returnType = route.returns.replace(/Promise<(.+)>/, '$1')\n\t\t\t// Extract base type name from array types (e.g., 'User[]' -> 'User')\n\t\t\tconst baseType = returnType.replace(/\\[\\]$/, '')\n\t\t\tif (!['string', 'number', 'boolean', 'any', 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AAK,gBAAgB,gBAAgB;AAGlE,WAAK,gBAAgB,MAAM,KAAK,gBAAgB,eAAe,KAAK,gBAAgB,KAAK,eAAe;AAExG,WAAK;AAAA,QACJ,iCAA4B,KAAK,eAAe,MAAM,YAAY,KAAK,gBAAgB,MAAM;AAAA,MAC9F;AAAA,IACD,SAAS,OAAO;AACf,WAAK,SAAS,8BAA8B,KAAK;AAEjD,WAAK,QAAQ;AACb,YAAM;AAAA,IACP;AAAA,EACD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,UAAyB;AAC9B,UAAM,KAAK,kBAAkB;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA,EAKA,YAA0C;AACzC,WAAO,KAAK;AAAA,EACb;AAAA;AAAA;AAAA;AAAA,EAKA,aAAoC;AACnC,WAAO,KAAK;AAAA,EACb;AAAA;AAAA;AAAA;AAAA,EAKA,oBAAgD;AAC/C,WAAO,KAAK;AAAA,EACb;AAAA;AAAA;AAAA;AAAA,EAKA,UAAgB;AACf,SAAK,cAAc,QAAQ;AAC3B,SAAK,gBAAgB,QAAQ;AAC7B,SAAK,IAAI,sBAAsB;AAAA,EAChC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASQ,IAAI,SAAuB;AAClC,YAAQ,IAAI,GAAG,UAAU,IAAI,OAAO,EAAE;AAAA,EACvC;AAAA;AAAA;AAAA;AAAA,EAKQ,SAAS,SAAiB,OAAuB;AACxD,YAAQ,MAAM,GAAG,UAAU,IAAI,OAAO,IAAI,SAAS,EAAE;AAAA,EACtD;AACD;","names":["import_path","path","fs","path","import_ts_morph","type","path","fs"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/rpc.plugin.ts","../src/constants/defaults.ts","../src/services/client-generator.service.ts","../src/utils/path-utils.ts","../src/utils/string-utils.ts","../src/services/route-analyzer.service.ts","../src/services/schema-generator.service.ts","../src/utils/schema-utils.ts","../src/utils/type-utils.ts"],"sourcesContent":["// Main plugin export\nexport { RPCPlugin } from './rpc.plugin'\n\n// Export all types\nexport type {\n\tApiError,\n\tApiResponse,\n\tControllerGroups,\n\tExtendedRouteInfo,\n\tFetchFunction,\n\tGeneratedClientInfo,\n\tParameterMetadataWithType,\n\tRequestOptions,\n\tRouteParameter,\n\tRPCPluginOptions,\n\tSchemaInfo\n} from './types'\n\n// Export services for advanced usage\nexport { ClientGeneratorService } from './services/client-generator.service'\nexport { RouteAnalyzerService } from './services/route-analyzer.service'\nexport { SchemaGeneratorService } from './services/schema-generator.service'\n\n// Export utilities for custom implementations\nexport * from './utils/path-utils'\nexport * from './utils/schema-utils'\nexport * from './utils/string-utils'\nexport * from './utils/type-utils'\n\n// Export constants\nexport * from './constants/defaults'\n","import fs from 'fs'\nimport type { Application, IPlugin } from 'honestjs'\nimport type { Hono } from 'hono'\nimport path from 'path'\n\nimport { DEFAULT_OPTIONS, LOG_PREFIX } from './constants/defaults'\nimport { ClientGeneratorService } from './services/client-generator.service'\nimport { RouteAnalyzerService } from './services/route-analyzer.service'\nimport { SchemaGeneratorService } from './services/schema-generator.service'\nimport type { ExtendedRouteInfo, GeneratedClientInfo, SchemaInfo } from './types'\n\n/**\n * Configuration options for the RPCPlugin\n */\nexport interface RPCPluginOptions {\n\treadonly controllerPattern?: string\n\treadonly tsConfigPath?: string\n\treadonly outputDir?: string\n\treadonly generateOnInit?: boolean\n}\n\n/**\n * Comprehensive RPC plugin that combines route analysis, schema generation, and client generation\n */\nexport class RPCPlugin implements IPlugin {\n\tprivate readonly controllerPattern: string\n\tprivate readonly tsConfigPath: string\n\tprivate readonly outputDir: string\n\tprivate readonly generateOnInit: boolean\n\n\t// Services\n\tprivate readonly routeAnalyzer: RouteAnalyzerService\n\tprivate readonly schemaGenerator: SchemaGeneratorService\n\tprivate readonly clientGenerator: ClientGeneratorService\n\n\t// Internal state\n\tprivate analyzedRoutes: ExtendedRouteInfo[] = []\n\tprivate analyzedSchemas: SchemaInfo[] = []\n\tprivate generatedInfo: GeneratedClientInfo | null = null\n\n\tconstructor(options: RPCPluginOptions = {}) {\n\t\tthis.controllerPattern = options.controllerPattern ?? DEFAULT_OPTIONS.controllerPattern\n\t\tthis.tsConfigPath = options.tsConfigPath ?? path.resolve(process.cwd(), DEFAULT_OPTIONS.tsConfigPath)\n\t\tthis.outputDir = options.outputDir ?? path.resolve(process.cwd(), DEFAULT_OPTIONS.outputDir)\n\t\tthis.generateOnInit = options.generateOnInit ?? DEFAULT_OPTIONS.generateOnInit\n\n\t\t// Initialize services\n\t\tthis.routeAnalyzer = new RouteAnalyzerService(this.controllerPattern, this.tsConfigPath)\n\t\tthis.schemaGenerator = new SchemaGeneratorService(this.controllerPattern, this.tsConfigPath)\n\t\tthis.clientGenerator = new ClientGeneratorService(this.outputDir)\n\n\t\tthis.validateConfiguration()\n\t}\n\n\t/**\n\t * Validates the plugin configuration\n\t */\n\tprivate validateConfiguration(): void {\n\t\tconst errors: string[] = []\n\n\t\tif (!this.controllerPattern?.trim()) {\n\t\t\terrors.push('Controller pattern cannot be empty')\n\t\t}\n\n\t\tif (!this.tsConfigPath?.trim()) {\n\t\t\terrors.push('TypeScript config path cannot be empty')\n\t\t} else {\n\t\t\tif (!fs.existsSync(this.tsConfigPath)) {\n\t\t\t\terrors.push(`TypeScript config file not found at: ${this.tsConfigPath}`)\n\t\t\t}\n\t\t}\n\n\t\tif (!this.outputDir?.trim()) {\n\t\t\terrors.push('Output directory cannot be empty')\n\t\t}\n\n\t\tif (errors.length > 0) {\n\t\t\tthrow new Error(`Configuration validation failed: ${errors.join(', ')}`)\n\t\t}\n\n\t\tthis.log(\n\t\t\t`Configuration validated: controllerPattern=${this.controllerPattern}, tsConfigPath=${this.tsConfigPath}, outputDir=${this.outputDir}`\n\t\t)\n\t}\n\n\t/**\n\t * Called after all modules are registered\n\t */\n\tafterModulesRegistered = async (app: Application, hono: Hono): Promise<void> => {\n\t\tif (this.generateOnInit) {\n\t\t\tawait this.analyzeEverything()\n\t\t}\n\t}\n\n\t/**\n\t * Main analysis method that coordinates all three components\n\t */\n\tprivate async analyzeEverything(): Promise<void> {\n\t\ttry {\n\t\t\tthis.log('Starting comprehensive RPC analysis...')\n\n\t\t\t// Clear previous analysis results to prevent memory leaks\n\t\t\tthis.analyzedRoutes = []\n\t\t\tthis.analyzedSchemas = []\n\t\t\tthis.generatedInfo = null\n\n\t\t\t// Step 1: Analyze routes and extract type information\n\t\t\tthis.analyzedRoutes = await this.routeAnalyzer.analyzeControllerMethods()\n\n\t\t\t// Step 2: Generate schemas from the types we found\n\t\t\tthis.analyzedSchemas = await this.schemaGenerator.generateSchemas()\n\n\t\t\t// Step 3: Generate the RPC client\n\t\t\tthis.generatedInfo = await this.clientGenerator.generateClient(this.analyzedRoutes, this.analyzedSchemas)\n\n\t\t\tthis.log(\n\t\t\t\t`✅ RPC analysis complete: ${this.analyzedRoutes.length} routes, ${this.analyzedSchemas.length} schemas`\n\t\t\t)\n\t\t} catch (error) {\n\t\t\tthis.logError('Error during RPC analysis:', error)\n\t\t\t// Ensure cleanup happens even on error\n\t\t\tthis.dispose()\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t/**\n\t * Manually trigger analysis (useful for testing or re-generation)\n\t */\n\tasync analyze(): Promise<void> {\n\t\tawait this.analyzeEverything()\n\t}\n\n\t/**\n\t * Get the analyzed routes\n\t */\n\tgetRoutes(): readonly ExtendedRouteInfo[] {\n\t\treturn this.analyzedRoutes\n\t}\n\n\t/**\n\t * Get the analyzed schemas\n\t */\n\tgetSchemas(): readonly SchemaInfo[] {\n\t\treturn this.analyzedSchemas\n\t}\n\n\t/**\n\t * Get the generation info\n\t */\n\tgetGenerationInfo(): GeneratedClientInfo | null {\n\t\treturn this.generatedInfo\n\t}\n\n\t/**\n\t * Cleanup resources to prevent memory leaks\n\t */\n\tdispose(): void {\n\t\tthis.routeAnalyzer.dispose()\n\t\tthis.schemaGenerator.dispose()\n\t\tthis.log('Resources cleaned up')\n\t}\n\n\t// ============================================================================\n\t// LOGGING UTILITIES\n\t// ============================================================================\n\n\t/**\n\t * Logs a message with the plugin prefix\n\t */\n\tprivate log(message: string): void {\n\t\tconsole.log(`${LOG_PREFIX} ${message}`)\n\t}\n\n\t/**\n\t * Logs an error with the plugin prefix\n\t */\n\tprivate logError(message: string, error?: unknown): void {\n\t\tconsole.error(`${LOG_PREFIX} ${message}`, error || '')\n\t}\n}\n","/**\n * Default configuration options for the RPCPlugin\n */\nexport const DEFAULT_OPTIONS = {\n\tcontrollerPattern: 'src/modules/*/*.controller.ts',\n\ttsConfigPath: 'tsconfig.json',\n\toutputDir: './generated/rpc',\n\tgenerateOnInit: true\n} as const\n\n/**\n * Log prefix for the RPC plugin\n */\nexport const LOG_PREFIX = '[ RPCPlugin ]'\n\n/**\n * Built-in TypeScript types that should not be imported\n */\nexport const BUILTIN_UTILITY_TYPES = new Set([\n\t'Partial',\n\t'Required',\n\t'Readonly',\n\t'Pick',\n\t'Omit',\n\t'Record',\n\t'Exclude',\n\t'Extract',\n\t'ReturnType',\n\t'InstanceType'\n])\n\n/**\n * Built-in TypeScript types that should be skipped\n */\nexport const BUILTIN_TYPES = new Set(['string', 'number', 'boolean', 'any', 'void', 'unknown'])\n\n/**\n * Generic type names that should be unwrapped\n */\nexport const GENERIC_TYPES = new Set(['Array', 'Promise', 'Partial'])\n","import fs from 'fs/promises'\nimport path from 'path'\nimport type { ControllerGroups, ExtendedRouteInfo, RouteParameter } from '../types/route.types'\nimport type { GeneratedClientInfo, SchemaInfo } from '../types/schema.types'\nimport { buildFullApiPath } from '../utils/path-utils'\nimport { camelCase, safeToString } from '../utils/string-utils'\n\n/**\n * Service for generating TypeScript RPC clients\n */\nexport class ClientGeneratorService {\n\tconstructor(private readonly outputDir: string) {}\n\n\t/**\n\t * Generates the TypeScript RPC client\n\t */\n\tasync generateClient(\n\t\troutes: readonly ExtendedRouteInfo[],\n\t\tschemas: readonly SchemaInfo[]\n\t): Promise<GeneratedClientInfo> {\n\t\tawait fs.mkdir(this.outputDir, { recursive: true })\n\n\t\tawait this.generateClientFile(routes, schemas)\n\n\t\tconst generatedInfo: GeneratedClientInfo = {\n\t\t\tclientFile: path.join(this.outputDir, 'client.ts'),\n\t\t\tgeneratedAt: new Date().toISOString()\n\t\t}\n\n\t\treturn generatedInfo\n\t}\n\n\t/**\n\t * Generates the main client file with types included\n\t */\n\tprivate async generateClientFile(\n\t\troutes: readonly ExtendedRouteInfo[],\n\t\tschemas: readonly SchemaInfo[]\n\t): Promise<void> {\n\t\tconst clientContent = this.generateClientContent(routes, schemas)\n\t\tconst clientPath = path.join(this.outputDir, 'client.ts')\n\t\tawait fs.writeFile(clientPath, clientContent, 'utf-8')\n\t}\n\n\t/**\n\t * Generates the client TypeScript content with types included\n\t */\n\tprivate generateClientContent(routes: readonly ExtendedRouteInfo[], schemas: readonly SchemaInfo[]): string {\n\t\tconst controllerGroups = this.groupRoutesByController(routes)\n\n\t\treturn `// ============================================================================\n// TYPES SECTION\n// ============================================================================\n\n/**\n * API Response wrapper\n */\nexport interface ApiResponse<T = any> {\n\tdata: T\n\tmessage?: string\n\tsuccess: boolean\n}\n\n/**\n * API Error class\n */\nexport class ApiError extends Error {\n\tconstructor(\n\t\tpublic statusCode: number,\n\t\tmessage: string\n\t) {\n\t\tsuper(message)\n\t\tthis.name = 'ApiError'\n\t}\n}\n\n/**\n * Clean separation of concerns for request options\n */\nexport type RequestOptions<\n\tTParams = undefined,\n\tTQuery = undefined,\n\tTBody = undefined,\n\tTHeaders = undefined\n> = (TParams extends undefined ? object : { params: TParams }) &\n\t(TQuery extends undefined ? object : { query: TQuery }) &\n\t(TBody extends undefined ? object : { body: TBody }) &\n\t(THeaders extends undefined ? object : { headers: THeaders })\n\n/**\n * Custom fetch function type that matches the standard fetch API\n */\nexport type FetchFunction = (\n\tinput: RequestInfo | URL,\n\tinit?: RequestInit\n) => Promise<Response>\n\n// Generated DTOs and types from integrated Schema Generation\n${this.generateSchemaTypes(schemas)}\n\n// ============================================================================\n// CLIENT SECTION\n// ============================================================================\n\n/**\n * Generated RPC Client\n * \n * This class provides a type-safe HTTP client for interacting with your API endpoints.\n * It's automatically generated by the RPCPlugin based on your controller definitions.\n * \n * @example\n * \\`\\`\\`typescript\n * const apiClient = new ApiClient('http://localhost:3000')\n * \n * // Make a request to get users\n * const response = await apiClient.users.getUsers()\n * \n * // Make a request with parameters\n * const user = await apiClient.users.getUser({ params: { id: '123' } })\n * \n * // Make a request with body data\n * const newUser = await apiClient.users.createUser({ \n * body: { name: 'John', email: 'john@example.com' } \n * })\n * \n * // Use with custom fetch function (e.g., for testing or custom logic)\n * const customFetch = (input: RequestInfo | URL, init?: RequestInit) => {\n * console.log('Making request to:', input)\n * return fetch(input, init)\n * }\n * \n * const apiClientWithCustomFetch = new ApiClient('http://localhost:3000', {\n * fetchFn: customFetch,\n * defaultHeaders: { 'X-Custom-Header': 'value' }\n * })\n * \\`\\`\\`\n * \n * @generated This class is auto-generated by RPCPlugin\n */\nexport class ApiClient {\n\tprivate baseUrl: string\n\tprivate defaultHeaders: Record<string, string>\n\tprivate fetchFn: FetchFunction\n\n\tconstructor(\n\t\tbaseUrl: string, \n\t\toptions: {\n\t\t\tdefaultHeaders?: Record<string, string>\n\t\t\tfetchFn?: FetchFunction\n\t\t} = {}\n\t) {\n\t\tthis.baseUrl = baseUrl.replace(/\\\\/$/, '')\n\t\tthis.defaultHeaders = {\n\t\t\t'Content-Type': 'application/json',\n\t\t\t...options.defaultHeaders\n\t\t}\n\t\tthis.fetchFn = options.fetchFn || fetch\n\t}\n\n\t/**\n\t * Set default headers for all requests\n\t */\n\tsetDefaultHeaders(headers: Record<string, string>): this {\n\t\tthis.defaultHeaders = { ...this.defaultHeaders, ...headers }\n\t\treturn this\n\t}\n\n\n\t/**\n\t * Make an HTTP request with flexible options\n\t */\n\tprivate async request<T>(\n\t\tmethod: string,\n\t\tpath: string,\n\t\toptions: RequestOptions<any, any, any, any> = {}\n\t): Promise<ApiResponse<T>> {\n\t\tconst { params, query, body, headers = {} } = options as any\n\t\t\n\t\t// Build the final URL with path parameters\n\t\tlet finalPath = path\n\t\tif (params) {\n\t\t\tObject.entries(params).forEach(([key, value]) => {\n\t\t\t\tfinalPath = finalPath.replace(\\`:\\${key}\\`, String(value))\n\t\t\t})\n\t\t}\n\n\t\tconst url = new URL(finalPath, this.baseUrl)\n\t\t\n\t\t// Add query parameters\n\t\tif (query) {\n\t\t\tObject.entries(query).forEach(([key, value]) => {\n\t\t\t\tif (value !== undefined && value !== null) {\n\t\t\t\t\turl.searchParams.append(key, String(value))\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\n\t\t// Merge default headers with request-specific headers\n\t\tconst finalHeaders = { ...this.defaultHeaders, ...headers }\n\n\t\tconst requestOptions: RequestInit = {\n\t\t\tmethod,\n\t\t\theaders: finalHeaders,\n\t\t}\n\n\t\tif (body && method !== 'GET') {\n\t\t\trequestOptions.body = JSON.stringify(body)\n\t\t}\n\n\t\ttry {\n\t\t\tconst response = await this.fetchFn(url.toString(), requestOptions)\n\t\t\tconst responseData = await response.json()\n\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow new ApiError(response.status, responseData.message || 'Request failed')\n\t\t\t}\n\n\t\t\treturn responseData\n\t\t} catch (error) {\n\t\t\tif (error instanceof ApiError) {\n\t\t\t\tthrow error\n\t\t\t}\n\t\t\tthrow new ApiError(0, error instanceof Error ? error.message : 'Network error')\n\t\t}\n\t}\n\n${this.generateControllerMethods(controllerGroups)}\n}\n`\n\t}\n\n\t/**\n\t * Generates controller methods for the client\n\t */\n\tprivate generateControllerMethods(controllerGroups: ControllerGroups): string {\n\t\tlet methods = ''\n\n\t\tfor (const [controllerName, routes] of controllerGroups) {\n\t\t\tconst className = controllerName.replace(/Controller$/, '')\n\t\t\tmethods += `\n\t// ${className} Controller\n`\n\t\t\tmethods += `\tget ${camelCase(className)}() {\n`\n\t\t\tmethods += `\t\treturn {\n`\n\n\t\t\tfor (const route of routes) {\n\t\t\t\tconst methodName = camelCase(safeToString(route.handler))\n\t\t\t\tconst httpMethod = safeToString(route.method).toLowerCase()\n\t\t\t\tconst { pathParams, queryParams, bodyParams } = this.analyzeRouteParameters(route)\n\n\t\t\t\tconst hasRequiredParams =\n\t\t\t\t\tpathParams.length > 0 ||\n\t\t\t\t\tqueryParams.some((p) => p.required) ||\n\t\t\t\t\t(bodyParams.length > 0 && httpMethod !== 'get')\n\n\t\t\t\t// Generate the method signature with proper typing\n\t\t\t\tmethods += `\t\t\t${methodName}: async (options${hasRequiredParams ? '' : '?'}: RequestOptions<`\n\n\t\t\t\t// Path parameters type\n\t\t\t\tif (pathParams.length > 0) {\n\t\t\t\t\tconst pathParamTypes = pathParams.map((p) => {\n\t\t\t\t\t\tconst paramName = p.name\n\t\t\t\t\t\tconst paramType = p.type || 'any'\n\t\t\t\t\t\treturn `${paramName}: ${paramType}`\n\t\t\t\t\t})\n\t\t\t\t\tmethods += `{ ${pathParamTypes.join(', ')} }`\n\t\t\t\t} else {\n\t\t\t\t\tmethods += 'undefined'\n\t\t\t\t}\n\n\t\t\t\tmethods += ', '\n\n\t\t\t\t// Query parameters type\n\t\t\t\tif (queryParams.length > 0) {\n\t\t\t\t\tconst queryParamTypes = queryParams.map((p) => {\n\t\t\t\t\t\tconst paramName = p.name\n\t\t\t\t\t\tconst paramType = p.type || 'any'\n\t\t\t\t\t\treturn `${paramName}: ${paramType}`\n\t\t\t\t\t})\n\t\t\t\t\tmethods += `{ ${queryParamTypes.join(', ')} }`\n\t\t\t\t} else {\n\t\t\t\t\tmethods += 'undefined'\n\t\t\t\t}\n\n\t\t\t\tmethods += ', '\n\n\t\t\t\t// Body type\n\t\t\t\tif (bodyParams.length > 0) {\n\t\t\t\t\tconst bodyParamTypes = bodyParams.map((p) => {\n\t\t\t\t\t\tconst paramType = p.type || 'any'\n\t\t\t\t\t\treturn paramType\n\t\t\t\t\t})\n\t\t\t\t\t// Use the first body parameter type, not 'any'\n\t\t\t\t\tmethods += bodyParamTypes[0] || 'any'\n\t\t\t\t} else {\n\t\t\t\t\tmethods += 'undefined'\n\t\t\t\t}\n\n\t\t\t\tmethods += ', '\n\n\t\t\t\t// Headers type - always optional for now, but could be made conditional\n\t\t\t\tmethods += 'undefined'\n\n\t\t\t\t// Extract return type from route analysis for better type safety\n\t\t\t\tconst returnType = this.extractReturnType(route.returns)\n\t\t\t\tmethods += `>): Promise<ApiResponse<${returnType}>> => {\n`\n\n\t\t\t\t// Build the full API path using route information\n\t\t\t\tlet requestPath = buildFullApiPath(route)\n\n\t\t\t\t// Replace path parameters with placeholders for dynamic substitution\n\t\t\t\tif (pathParams.length > 0) {\n\t\t\t\t\tfor (const pathParam of pathParams) {\n\t\t\t\t\t\tconst paramName = pathParam.name\n\t\t\t\t\t\tconst placeholder = `:${String(pathParam.data)}`\n\t\t\t\t\t\trequestPath = requestPath.replace(placeholder, `:${paramName}`)\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tmethods += `\t\t\t\treturn this.request<${returnType}>('${httpMethod.toUpperCase()}', \\`${requestPath}\\`, options)\n`\n\t\t\t\tmethods += `\t\t\t},\n`\n\t\t\t}\n\n\t\t\tmethods += `\t\t}\n`\n\t\t\tmethods += `\t}\n`\n\t\t}\n\n\t\treturn methods\n\t}\n\n\t/**\n\t * Extracts the proper return type from route analysis\n\t */\n\tprivate extractReturnType(returns?: string): string {\n\t\tif (!returns) return 'any'\n\n\t\t// Handle Promise<T> types\n\t\tconst promiseMatch = returns.match(/Promise<(.+)>/)\n\t\tif (promiseMatch) {\n\t\t\treturn promiseMatch[1]\n\t\t}\n\n\t\t// Handle other types\n\t\treturn returns\n\t}\n\n\t/**\n\t * Generates schema types from integrated schema generation\n\t */\n\tprivate generateSchemaTypes(schemas: readonly SchemaInfo[]): string {\n\t\tif (schemas.length === 0) {\n\t\t\treturn '// No schemas available from integrated Schema Generation\\n'\n\t\t}\n\n\t\tlet content = '// Schema types from integrated Schema Generation\\n'\n\t\tfor (const schemaInfo of schemas) {\n\t\t\tif (schemaInfo.typescriptType) {\n\t\t\t\tcontent += `${schemaInfo.typescriptType}\\n\\n`\n\t\t\t}\n\t\t}\n\t\treturn content\n\t}\n\n\t/**\n\t * Groups routes by controller for better organization\n\t */\n\tprivate groupRoutesByController(routes: readonly ExtendedRouteInfo[]): ControllerGroups {\n\t\tconst groups = new Map<string, ExtendedRouteInfo[]>()\n\n\t\tfor (const route of routes) {\n\t\t\tconst controller = safeToString(route.controller)\n\t\t\tif (!groups.has(controller)) {\n\t\t\t\tgroups.set(controller, [])\n\t\t\t}\n\t\t\tgroups.get(controller)!.push(route)\n\t\t}\n\n\t\treturn groups\n\t}\n\n\t/**\n\t * Analyzes route parameters to determine their types and usage\n\t */\n\tprivate analyzeRouteParameters(route: ExtendedRouteInfo): {\n\t\tpathParams: readonly RouteParameter[]\n\t\tqueryParams: readonly RouteParameter[]\n\t\tbodyParams: readonly RouteParameter[]\n\t} {\n\t\tconst parameters = route.parameters || []\n\t\tconst method = String(route.method || '').toLowerCase()\n\n\t\tconst isInPath = (p: RouteParameter): boolean => {\n\t\t\t// Check if this parameter corresponds to a path segment\n\t\t\t// For path parameters, the data field should contain the path segment name\n\t\t\tconst pathSegment = p.data\n\t\t\treturn !!pathSegment && typeof pathSegment === 'string' && route.path.includes(`:${pathSegment}`)\n\t\t}\n\n\t\t// path params are always required if they exist in the path\n\t\tconst pathParams = parameters.filter((p) => isInPath(p)).map((p) => ({ ...p, required: true }))\n\n\t\t// body is required if any body param exists for non-GET\n\t\tconst rawBody = parameters.filter((p) => !isInPath(p) && method !== 'get')\n\t\tconst bodyParams = rawBody.map((p) => ({\n\t\t\t...p,\n\t\t\trequired: true\n\t\t}))\n\n\t\t// query requiredness comes from analyzer if available; default optional\n\t\tconst queryParams = parameters\n\t\t\t.filter((p) => !isInPath(p) && method === 'get')\n\t\t\t.map((p) => ({\n\t\t\t\t...p,\n\t\t\t\trequired: p.required === true // default false if not provided\n\t\t\t}))\n\n\t\treturn { pathParams, queryParams, bodyParams }\n\t}\n}\n","import type { ParameterMetadata } from 'honestjs'\nimport type { ExtendedRouteInfo } from '../types/route.types'\n\n/**\n * Builds the full path with parameter placeholders\n */\nexport function buildFullPath(basePath: string, parameters: readonly ParameterMetadata[]): string {\n\tif (!basePath || typeof basePath !== 'string') return '/'\n\n\tlet path = basePath\n\n\tif (parameters && Array.isArray(parameters)) {\n\t\tfor (const param of parameters) {\n\t\t\tif (param.data && typeof param.data === 'string' && param.data.startsWith(':')) {\n\t\t\t\tconst paramName = param.data.slice(1)\n\t\t\t\tpath = path.replace(`:${paramName}`, `\\${${paramName}}`)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn path\n}\n\n/**\n * Builds the full API path using route information\n */\nexport function buildFullApiPath(route: ExtendedRouteInfo): string {\n\tconst prefix = route.prefix || ''\n\tconst version = route.version || ''\n\tconst routePath = route.route || ''\n\tconst path = route.path || ''\n\n\tlet fullPath = ''\n\n\t// Add prefix (e.g., /api)\n\tif (prefix && prefix !== '/') {\n\t\tfullPath += prefix.replace(/^\\/+|\\/+$/g, '')\n\t}\n\n\t// Add version (e.g., /v1)\n\tif (version && version !== '/') {\n\t\tfullPath += `/${version.replace(/^\\/+|\\/+$/g, '')}`\n\t}\n\n\t// Add route (e.g., /users)\n\tif (routePath && routePath !== '/') {\n\t\tfullPath += `/${routePath.replace(/^\\/+|\\/+$/g, '')}`\n\t}\n\n\t// Add path (e.g., /:id or /)\n\tif (path && path !== '/') {\n\t\tfullPath += `/${path.replace(/^\\/+|\\/+$/g, '')}`\n\t} else if (path === '/') {\n\t\tfullPath += '/'\n\t}\n\n\treturn fullPath || '/'\n}\n","/**\n * Safely converts a value to string, handling symbols and other types\n */\nexport function safeToString(value: unknown): string {\n\tif (typeof value === 'string') return value\n\tif (typeof value === 'symbol') return value.description || 'Symbol'\n\treturn String(value)\n}\n\n/**\n * Converts a string to camelCase\n */\nexport function camelCase(str: string): string {\n\treturn str.charAt(0).toLowerCase() + str.slice(1)\n}\n","import { RouteRegistry, type ParameterMetadata, type RouteInfo } from 'honestjs'\nimport { ClassDeclaration, MethodDeclaration, Project } from 'ts-morph'\nimport type { ExtendedRouteInfo, ParameterMetadataWithType } from '../types/route.types'\nimport { buildFullPath } from '../utils/path-utils'\nimport { safeToString } from '../utils/string-utils'\n\n/**\n * Service for analyzing controller methods and extracting type information\n */\nexport class RouteAnalyzerService {\n\tconstructor(\n\t\tprivate readonly controllerPattern: string,\n\t\tprivate readonly tsConfigPath: string\n\t) {}\n\n\t// Track projects for cleanup\n\tprivate projects: Project[] = []\n\n\t/**\n\t * Analyzes controller methods to extract type information\n\t */\n\tasync analyzeControllerMethods(): Promise<ExtendedRouteInfo[]> {\n\t\tconst routes = RouteRegistry.getRoutes()\n\t\tif (!routes?.length) {\n\t\t\treturn []\n\t\t}\n\n\t\tconst project = this.createProject()\n\t\tconst controllers = this.findControllerClasses(project)\n\n\t\tif (controllers.size === 0) {\n\t\t\treturn []\n\t\t}\n\n\t\treturn this.processRoutes(routes, controllers)\n\t}\n\n\t/**\n\t * Creates a new ts-morph project\n\t */\n\tprivate createProject(): Project {\n\t\tconst project = new Project({\n\t\t\ttsConfigFilePath: this.tsConfigPath\n\t\t})\n\n\t\tproject.addSourceFilesAtPaths([this.controllerPattern])\n\t\tthis.projects.push(project)\n\t\treturn project\n\t}\n\n\t/**\n\t * Cleanup resources to prevent memory leaks\n\t */\n\tdispose(): void {\n\t\tthis.projects.forEach((project) => {\n\t\t\t// Remove all source files to free memory\n\t\t\tproject.getSourceFiles().forEach((file) => project.removeSourceFile(file))\n\t\t})\n\t\tthis.projects = []\n\t}\n\n\t/**\n\t * Finds controller classes in the project\n\t */\n\tprivate findControllerClasses(project: Project): Map<string, ClassDeclaration> {\n\t\tconst controllers = new Map<string, ClassDeclaration>()\n\t\tconst files = project.getSourceFiles()\n\n\t\tfor (const sourceFile of files) {\n\t\t\tconst classes = sourceFile.getClasses()\n\n\t\t\tfor (const classDeclaration of classes) {\n\t\t\t\tconst className = classDeclaration.getName()\n\n\t\t\t\tif (className?.endsWith('Controller')) {\n\t\t\t\t\tcontrollers.set(className, classDeclaration)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn controllers\n\t}\n\n\t/**\n\t * Processes all routes and extracts type information\n\t */\n\tprivate processRoutes(\n\t\troutes: readonly RouteInfo[],\n\t\tcontrollers: Map<string, ClassDeclaration>\n\t): ExtendedRouteInfo[] {\n\t\tconst analyzedRoutes: ExtendedRouteInfo[] = []\n\t\tconst errors: Error[] = []\n\n\t\tfor (const route of routes) {\n\t\t\ttry {\n\t\t\t\tconst extendedRoute = this.createExtendedRoute(route, controllers)\n\t\t\t\tanalyzedRoutes.push(extendedRoute)\n\t\t\t} catch (routeError) {\n\t\t\t\tconst error = routeError instanceof Error ? routeError : new Error(String(routeError))\n\t\t\t\terrors.push(error)\n\t\t\t\tconsole.error(\n\t\t\t\t\t`Error processing route ${safeToString(route.controller)}.${safeToString(route.handler)}:`,\n\t\t\t\t\trouteError\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\n\t\t// If there were any errors, throw a comprehensive error\n\t\tif (errors.length > 0) {\n\t\t\tthrow new Error(`Failed to process ${errors.length} routes: ${errors.map((e) => e.message).join(', ')}`)\n\t\t}\n\n\t\treturn analyzedRoutes\n\t}\n\n\t/**\n\t * Creates an extended route with type information\n\t */\n\tprivate createExtendedRoute(route: RouteInfo, controllers: Map<string, ClassDeclaration>): ExtendedRouteInfo {\n\t\tconst controllerName = safeToString(route.controller)\n\t\tconst handlerName = safeToString(route.handler)\n\n\t\tconst controllerClass = controllers.get(controllerName)\n\t\tlet returns: string | undefined\n\t\tlet parameters: readonly ParameterMetadataWithType[] | undefined\n\n\t\tif (controllerClass) {\n\t\t\tconst handlerMethod = controllerClass.getMethods().find((method) => method.getName() === handlerName)\n\n\t\t\tif (handlerMethod) {\n\t\t\t\treturns = this.getReturnType(handlerMethod)\n\t\t\t\tparameters = this.getParametersWithTypes(handlerMethod, route.parameters || [])\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tcontroller: controllerName,\n\t\t\thandler: handlerName,\n\t\t\tmethod: safeToString(route.method).toUpperCase(),\n\t\t\tprefix: route.prefix,\n\t\t\tversion: route.version,\n\t\t\troute: route.route,\n\t\t\tpath: route.path,\n\t\t\tfullPath: buildFullPath(route.path, route.parameters),\n\t\t\tparameters,\n\t\t\treturns\n\t\t}\n\t}\n\n\t/**\n\t * Gets the return type of a method\n\t */\n\tprivate getReturnType(method: MethodDeclaration): string {\n\t\tconst type = method.getReturnType()\n\t\tconst typeText = type.getText(method)\n\n\t\tconst aliasSymbol = type.getAliasSymbol()\n\t\tif (aliasSymbol) {\n\t\t\treturn aliasSymbol.getName()\n\t\t}\n\n\t\treturn typeText.replace(/import\\(\".*?\"\\)\\./g, '')\n\t}\n\n\t/**\n\t * Gets parameters with their types\n\t */\n\tprivate getParametersWithTypes(\n\t\tmethod: MethodDeclaration,\n\t\tparameters: readonly ParameterMetadata[]\n\t): readonly ParameterMetadataWithType[] {\n\t\tconst result: ParameterMetadataWithType[] = []\n\t\tconst declaredParams = method.getParameters()\n\t\tconst sortedParams = [...parameters].sort((a, b) => a.index - b.index)\n\n\t\tfor (const param of sortedParams) {\n\t\t\tconst index = param.index\n\n\t\t\tif (index < declaredParams.length) {\n\t\t\t\tconst declaredParam = declaredParams[index]\n\t\t\t\tconst paramName = declaredParam.getName()\n\t\t\t\tconst paramType = declaredParam\n\t\t\t\t\t.getType()\n\t\t\t\t\t.getText()\n\t\t\t\t\t.replace(/import\\(\".*?\"\\)\\./g, '')\n\n\t\t\t\tresult.push({\n\t\t\t\t\tindex,\n\t\t\t\t\tname: paramName,\n\t\t\t\t\ttype: paramType,\n\t\t\t\t\trequired: true,\n\t\t\t\t\tdata: param.data,\n\t\t\t\t\tfactory: param.factory,\n\t\t\t\t\tmetatype: param.metatype\n\t\t\t\t})\n\t\t\t} else {\n\t\t\t\tresult.push({\n\t\t\t\t\tindex,\n\t\t\t\t\tname: `param${index}`,\n\t\t\t\t\ttype: param.metatype?.name || 'unknown',\n\t\t\t\t\trequired: true,\n\t\t\t\t\tdata: param.data,\n\t\t\t\t\tfactory: param.factory,\n\t\t\t\t\tmetatype: param.metatype\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\treturn result\n\t}\n}\n","import { createGenerator } from 'ts-json-schema-generator'\nimport { MethodDeclaration, Project } from 'ts-morph'\nimport type { SchemaInfo } from '../types/schema.types'\nimport { generateTypeScriptInterface } from '../utils/schema-utils'\nimport { extractNamedType } from '../utils/type-utils'\n\n/**\n * Service for generating JSON schemas from TypeScript types used in controllers\n */\nexport class SchemaGeneratorService {\n\tconstructor(\n\t\tprivate readonly controllerPattern: string,\n\t\tprivate readonly tsConfigPath: string\n\t) {}\n\n\t// Track projects for cleanup\n\tprivate projects: Project[] = []\n\n\t/**\n\t * Generates JSON schemas from types used in controllers\n\t */\n\tasync generateSchemas(): Promise<SchemaInfo[]> {\n\t\tconst project = this.createProject()\n\t\tconst sourceFiles = project.getSourceFiles(this.controllerPattern)\n\n\t\tconst collectedTypes = this.collectTypesFromControllers(sourceFiles)\n\t\treturn this.processTypes(collectedTypes)\n\t}\n\n\t/**\n\t * Creates a new ts-morph project\n\t */\n\tprivate createProject(): Project {\n\t\tconst project = new Project({\n\t\t\ttsConfigFilePath: this.tsConfigPath\n\t\t})\n\n\t\tproject.addSourceFilesAtPaths([this.controllerPattern])\n\t\tthis.projects.push(project)\n\t\treturn project\n\t}\n\n\t/**\n\t * Cleanup resources to prevent memory leaks\n\t */\n\tdispose(): void {\n\t\tthis.projects.forEach((project) => {\n\t\t\t// Remove all source files to free memory\n\t\t\tproject.getSourceFiles().forEach((file) => project.removeSourceFile(file))\n\t\t})\n\t\tthis.projects = []\n\t}\n\n\t/**\n\t * Collects types from controller files\n\t */\n\tprivate collectTypesFromControllers(sourceFiles: readonly any[]): Set<string> {\n\t\tconst collectedTypes = new Set<string>()\n\n\t\tfor (const file of sourceFiles) {\n\t\t\tfor (const cls of file.getClasses()) {\n\t\t\t\tfor (const method of cls.getMethods()) {\n\t\t\t\t\tthis.collectTypesFromMethod(method, collectedTypes)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn collectedTypes\n\t}\n\n\t/**\n\t * Collects types from a single method\n\t */\n\tprivate collectTypesFromMethod(method: MethodDeclaration, collectedTypes: Set<string>): void {\n\t\t// Collect parameter types\n\t\tfor (const param of method.getParameters()) {\n\t\t\tconst type = extractNamedType(param.getType())\n\t\t\tif (type) collectedTypes.add(type)\n\t\t}\n\n\t\t// Collect return type\n\t\tconst returnType = method.getReturnType()\n\t\tconst innerType = returnType.getTypeArguments()[0] ?? returnType\n\t\tconst type = extractNamedType(innerType)\n\t\tif (type) collectedTypes.add(type)\n\t}\n\n\t/**\n\t * Processes collected types to generate schemas\n\t */\n\tprivate async processTypes(collectedTypes: Set<string>): Promise<SchemaInfo[]> {\n\t\tconst schemas: SchemaInfo[] = []\n\n\t\tfor (const typeName of collectedTypes) {\n\t\t\ttry {\n\t\t\t\tconst schema = await this.generateSchemaForType(typeName)\n\t\t\t\tconst typescriptType = generateTypeScriptInterface(typeName, schema)\n\n\t\t\t\tschemas.push({\n\t\t\t\t\ttype: typeName,\n\t\t\t\t\tschema,\n\t\t\t\t\ttypescriptType\n\t\t\t\t})\n\t\t\t} catch (err) {\n\t\t\t\tconsole.error(`Failed to generate schema for ${typeName}:`, err)\n\t\t\t}\n\t\t}\n\n\t\treturn schemas\n\t}\n\n\t/**\n\t * Generates schema for a specific type\n\t */\n\tprivate async generateSchemaForType(typeName: string): Promise<Record<string, any>> {\n\t\ttry {\n\t\t\tconst generator = createGenerator({\n\t\t\t\tpath: this.controllerPattern,\n\t\t\t\ttsconfig: this.tsConfigPath,\n\t\t\t\ttype: typeName,\n\t\t\t\tskipTypeCheck: false // Enable type checking for better error detection\n\t\t\t})\n\n\t\t\treturn generator.createSchema(typeName)\n\t\t} catch (error) {\n\t\t\tconsole.error(`Failed to generate schema for type ${typeName}:`, error)\n\t\t\t// Return a basic schema structure as fallback\n\t\t\treturn {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {},\n\t\t\t\trequired: []\n\t\t\t}\n\t\t}\n\t}\n}\n","/**\n * Maps JSON schema types to TypeScript types\n */\nexport function mapJsonSchemaTypeToTypeScript(schema: Record<string, any>): string {\n\tconst type = schema.type as string\n\n\tswitch (type) {\n\t\tcase 'string':\n\t\t\tif (schema.enum && Array.isArray(schema.enum)) {\n\t\t\t\treturn `'${schema.enum.join(\"' | '\")}'`\n\t\t\t}\n\t\t\treturn 'string'\n\t\tcase 'number':\n\t\tcase 'integer':\n\t\t\treturn 'number'\n\t\tcase 'boolean':\n\t\t\treturn 'boolean'\n\t\tcase 'array': {\n\t\t\tconst itemType = mapJsonSchemaTypeToTypeScript(schema.items || {})\n\t\t\treturn `${itemType}[]`\n\t\t}\n\t\tcase 'object':\n\t\t\treturn 'Record<string, any>'\n\t\tdefault:\n\t\t\treturn 'any'\n\t}\n}\n\n/**\n * Generates TypeScript interface from JSON schema\n */\nexport function generateTypeScriptInterface(typeName: string, schema: Record<string, any>): string {\n\ttry {\n\t\tconst typeDefinition = schema.definitions?.[typeName]\n\t\tif (!typeDefinition) {\n\t\t\treturn `export interface ${typeName} {\\n\\t// No schema definition found\\n}`\n\t\t}\n\n\t\tconst properties = typeDefinition.properties || {}\n\t\tconst required = typeDefinition.required || []\n\n\t\tlet interfaceCode = `export interface ${typeName} {\\n`\n\n\t\tfor (const [propName, propSchema] of Object.entries(properties)) {\n\t\t\tconst isRequired = required.includes(propName)\n\t\t\tconst type = mapJsonSchemaTypeToTypeScript(propSchema as Record<string, any>)\n\t\t\tconst optional = isRequired ? '' : '?'\n\n\t\t\tinterfaceCode += `\\t${propName}${optional}: ${type}\\n`\n\t\t}\n\n\t\tinterfaceCode += '}'\n\t\treturn interfaceCode\n\t} catch (error) {\n\t\tconsole.error(`Failed to generate TypeScript interface for ${typeName}:`, error)\n\t\treturn `export interface ${typeName} {\\n\\t// Failed to generate interface\\n}`\n\t}\n}\n","import type { Type } from 'ts-morph'\nimport { BUILTIN_TYPES, BUILTIN_UTILITY_TYPES, GENERIC_TYPES } from '../constants/defaults'\n\n/**\n * Extracts a named type from a TypeScript type\n */\nexport function extractNamedType(type: Type): string | null {\n\tconst symbol = type.getAliasSymbol() || type.getSymbol()\n\tif (!symbol) return null\n\n\tconst name = symbol.getName()\n\n\t// Handle generic types by unwrapping them\n\tif (GENERIC_TYPES.has(name)) {\n\t\tconst inner = type.getAliasTypeArguments()?.[0] || type.getTypeArguments()?.[0]\n\t\treturn inner ? extractNamedType(inner) : null\n\t}\n\n\t// Skip built-in types\n\tif (BUILTIN_TYPES.has(name)) return null\n\n\treturn name\n}\n\n/**\n * Generates type imports for the client\n */\nexport function generateTypeImports(routes: readonly any[]): string {\n\tconst types = new Set<string>()\n\n\tfor (const route of routes) {\n\t\t// Collect parameter types\n\t\tif (route.parameters) {\n\t\t\tfor (const param of route.parameters) {\n\t\t\t\tif (param.type && !['string', 'number', 'boolean'].includes(param.type)) {\n\t\t\t\t\t// Extract type name from complex types like Partial<CreateUserDto> or User[]\n\t\t\t\t\tconst typeMatch = param.type.match(/(\\w+)(?:<.*>)?/)\n\t\t\t\t\tif (typeMatch) {\n\t\t\t\t\t\tconst typeName = typeMatch[1]\n\t\t\t\t\t\t// Don't import built-in TypeScript utility types\n\t\t\t\t\t\tif (!BUILTIN_UTILITY_TYPES.has(typeName)) {\n\t\t\t\t\t\t\ttypes.add(typeName)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Collect return types\n\t\tif (route.returns) {\n\t\t\tconst returnType = route.returns.replace(/Promise<(.+)>/, '$1')\n\t\t\t// Extract base type name from array types (e.g., 'User[]' -> 'User')\n\t\t\tconst baseType = returnType.replace(/\\[\\]$/, '')\n\t\t\tif (!['string', 'number', 'boolean', 'any', 'void', 'unknown'].includes(baseType)) {\n\t\t\t\ttypes.add(baseType)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn Array.from(types).join(', ')\n}\n"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,kBAAkB,MAAM,KAAK,gBAAgB,gBAAgB;AAGlE,WAAK,gBAAgB,MAAM,KAAK,gBAAgB,eAAe,KAAK,gBAAgB,KAAK,eAAe;AAExG,WAAK;AAAA,QACJ,iCAA4B,KAAK,eAAe,MAAM,YAAY,KAAK,gBAAgB,MAAM;AAAA,MAC9F;AAAA,IACD,SAAS,OAAO;AACf,WAAK,SAAS,8BAA8B,KAAK;AAEjD,WAAK,QAAQ;AACb,YAAM;AAAA,IACP;AAAA,EACD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,UAAyB;AAC9B,UAAM,KAAK,kBAAkB;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA,EAKA,YAA0C;AACzC,WAAO,KAAK;AAAA,EACb;AAAA;AAAA;AAAA;AAAA,EAKA,aAAoC;AACnC,WAAO,KAAK;AAAA,EACb;AAAA;AAAA;AAAA;AAAA,EAKA,oBAAgD;AAC/C,WAAO,KAAK;AAAA,EACb;AAAA;AAAA;AAAA;AAAA,EAKA,UAAgB;AACf,SAAK,cAAc,QAAQ;AAC3B,SAAK,gBAAgB,QAAQ;AAC7B,SAAK,IAAI,sBAAsB;AAAA,EAChC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASQ,IAAI,SAAuB;AAClC,YAAQ,IAAI,GAAG,UAAU,IAAI,OAAO,EAAE;AAAA,EACvC;AAAA;AAAA;AAAA;AAAA,EAKQ,SAAS,SAAiB,OAAuB;AACxD,YAAQ,MAAM,GAAG,UAAU,IAAI,OAAO,IAAI,SAAS,EAAE;AAAA,EACtD;AACD;","names":["import_path","path","fs","path","import_ts_morph","type","path","fs"]}
package/dist/index.mjs CHANGED
@@ -145,6 +145,14 @@ export type RequestOptions<
145
145
  (TBody extends undefined ? object : { body: TBody }) &
146
146
  (THeaders extends undefined ? object : { headers: THeaders })
147
147
 
148
+ /**
149
+ * Custom fetch function type that matches the standard fetch API
150
+ */
151
+ export type FetchFunction = (
152
+ input: RequestInfo | URL,
153
+ init?: RequestInit
154
+ ) => Promise<Response>
155
+
148
156
  // Generated DTOs and types from integrated Schema Generation
149
157
  ${this.generateSchemaTypes(schemas)}
150
158
 
@@ -172,6 +180,17 @@ ${this.generateSchemaTypes(schemas)}
172
180
  * const newUser = await apiClient.users.createUser({
173
181
  * body: { name: 'John', email: 'john@example.com' }
174
182
  * })
183
+ *
184
+ * // Use with custom fetch function (e.g., for testing or custom logic)
185
+ * const customFetch = (input: RequestInfo | URL, init?: RequestInit) => {
186
+ * console.log('Making request to:', input)
187
+ * return fetch(input, init)
188
+ * }
189
+ *
190
+ * const apiClientWithCustomFetch = new ApiClient('http://localhost:3000', {
191
+ * fetchFn: customFetch,
192
+ * defaultHeaders: { 'X-Custom-Header': 'value' }
193
+ * })
175
194
  * \`\`\`
176
195
  *
177
196
  * @generated This class is auto-generated by RPCPlugin
@@ -179,13 +198,21 @@ ${this.generateSchemaTypes(schemas)}
179
198
  export class ApiClient {
180
199
  private baseUrl: string
181
200
  private defaultHeaders: Record<string, string>
201
+ private fetchFn: FetchFunction
182
202
 
183
- constructor(baseUrl: string, defaultHeaders: Record<string, string> = {}) {
203
+ constructor(
204
+ baseUrl: string,
205
+ options: {
206
+ defaultHeaders?: Record<string, string>
207
+ fetchFn?: FetchFunction
208
+ } = {}
209
+ ) {
184
210
  this.baseUrl = baseUrl.replace(/\\/$/, '')
185
211
  this.defaultHeaders = {
186
212
  'Content-Type': 'application/json',
187
- ...defaultHeaders
213
+ ...options.defaultHeaders
188
214
  }
215
+ this.fetchFn = options.fetchFn || fetch
189
216
  }
190
217
 
191
218
  /**
@@ -196,13 +223,6 @@ export class ApiClient {
196
223
  return this
197
224
  }
198
225
 
199
- /**
200
- * Set default authorization header
201
- */
202
- setDefaultAuth(token: string): this {
203
- this.defaultHeaders.Authorization = \`Bearer \${token}\`
204
- return this
205
- }
206
226
 
207
227
  /**
208
228
  * Make an HTTP request with flexible options
@@ -246,7 +266,7 @@ export class ApiClient {
246
266
  }
247
267
 
248
268
  try {
249
- const response = await fetch(url.toString(), requestOptions)
269
+ const response = await this.fetchFn(url.toString(), requestOptions)
250
270
  const responseData = await response.json()
251
271
 
252
272
  if (!response.ok) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/rpc.plugin.ts","../src/constants/defaults.ts","../src/services/client-generator.service.ts","../src/utils/path-utils.ts","../src/utils/string-utils.ts","../src/services/route-analyzer.service.ts","../src/services/schema-generator.service.ts","../src/utils/schema-utils.ts","../src/utils/type-utils.ts"],"sourcesContent":["import fs from 'fs'\nimport type { Application, IPlugin } from 'honestjs'\nimport type { Hono } from 'hono'\nimport path from 'path'\n\nimport { DEFAULT_OPTIONS, LOG_PREFIX } from './constants/defaults'\nimport { ClientGeneratorService } from './services/client-generator.service'\nimport { RouteAnalyzerService } from './services/route-analyzer.service'\nimport { SchemaGeneratorService } from './services/schema-generator.service'\nimport type { ExtendedRouteInfo, GeneratedClientInfo, SchemaInfo } from './types'\n\n/**\n * Configuration options for the RPCPlugin\n */\nexport interface RPCPluginOptions {\n\treadonly controllerPattern?: string\n\treadonly tsConfigPath?: string\n\treadonly outputDir?: string\n\treadonly generateOnInit?: boolean\n}\n\n/**\n * Comprehensive RPC plugin that combines route analysis, schema generation, and client generation\n */\nexport class RPCPlugin implements IPlugin {\n\tprivate readonly controllerPattern: string\n\tprivate readonly tsConfigPath: string\n\tprivate readonly outputDir: string\n\tprivate readonly generateOnInit: boolean\n\n\t// Services\n\tprivate readonly routeAnalyzer: RouteAnalyzerService\n\tprivate readonly schemaGenerator: SchemaGeneratorService\n\tprivate readonly clientGenerator: ClientGeneratorService\n\n\t// Internal state\n\tprivate analyzedRoutes: ExtendedRouteInfo[] = []\n\tprivate analyzedSchemas: SchemaInfo[] = []\n\tprivate generatedInfo: GeneratedClientInfo | null = null\n\n\tconstructor(options: RPCPluginOptions = {}) {\n\t\tthis.controllerPattern = options.controllerPattern ?? DEFAULT_OPTIONS.controllerPattern\n\t\tthis.tsConfigPath = options.tsConfigPath ?? path.resolve(process.cwd(), DEFAULT_OPTIONS.tsConfigPath)\n\t\tthis.outputDir = options.outputDir ?? path.resolve(process.cwd(), DEFAULT_OPTIONS.outputDir)\n\t\tthis.generateOnInit = options.generateOnInit ?? DEFAULT_OPTIONS.generateOnInit\n\n\t\t// Initialize services\n\t\tthis.routeAnalyzer = new RouteAnalyzerService(this.controllerPattern, this.tsConfigPath)\n\t\tthis.schemaGenerator = new SchemaGeneratorService(this.controllerPattern, this.tsConfigPath)\n\t\tthis.clientGenerator = new ClientGeneratorService(this.outputDir)\n\n\t\tthis.validateConfiguration()\n\t}\n\n\t/**\n\t * Validates the plugin configuration\n\t */\n\tprivate validateConfiguration(): void {\n\t\tconst errors: string[] = []\n\n\t\tif (!this.controllerPattern?.trim()) {\n\t\t\terrors.push('Controller pattern cannot be empty')\n\t\t}\n\n\t\tif (!this.tsConfigPath?.trim()) {\n\t\t\terrors.push('TypeScript config path cannot be empty')\n\t\t} else {\n\t\t\tif (!fs.existsSync(this.tsConfigPath)) {\n\t\t\t\terrors.push(`TypeScript config file not found at: ${this.tsConfigPath}`)\n\t\t\t}\n\t\t}\n\n\t\tif (!this.outputDir?.trim()) {\n\t\t\terrors.push('Output directory cannot be empty')\n\t\t}\n\n\t\tif (errors.length > 0) {\n\t\t\tthrow new Error(`Configuration validation failed: ${errors.join(', ')}`)\n\t\t}\n\n\t\tthis.log(\n\t\t\t`Configuration validated: controllerPattern=${this.controllerPattern}, tsConfigPath=${this.tsConfigPath}, outputDir=${this.outputDir}`\n\t\t)\n\t}\n\n\t/**\n\t * Called after all modules are registered\n\t */\n\tafterModulesRegistered = async (app: Application, hono: Hono): Promise<void> => {\n\t\tif (this.generateOnInit) {\n\t\t\tawait this.analyzeEverything()\n\t\t}\n\t}\n\n\t/**\n\t * Main analysis method that coordinates all three components\n\t */\n\tprivate async analyzeEverything(): Promise<void> {\n\t\ttry {\n\t\t\tthis.log('Starting comprehensive RPC analysis...')\n\n\t\t\t// Clear previous analysis results to prevent memory leaks\n\t\t\tthis.analyzedRoutes = []\n\t\t\tthis.analyzedSchemas = []\n\t\t\tthis.generatedInfo = null\n\n\t\t\t// Step 1: Analyze routes and extract type information\n\t\t\tthis.analyzedRoutes = await this.routeAnalyzer.analyzeControllerMethods()\n\n\t\t\t// Step 2: Generate schemas from the types we found\n\t\t\tthis.analyzedSchemas = await this.schemaGenerator.generateSchemas()\n\n\t\t\t// Step 3: Generate the RPC client\n\t\t\tthis.generatedInfo = await this.clientGenerator.generateClient(this.analyzedRoutes, this.analyzedSchemas)\n\n\t\t\tthis.log(\n\t\t\t\t`✅ RPC analysis complete: ${this.analyzedRoutes.length} routes, ${this.analyzedSchemas.length} schemas`\n\t\t\t)\n\t\t} catch (error) {\n\t\t\tthis.logError('Error during RPC analysis:', error)\n\t\t\t// Ensure cleanup happens even on error\n\t\t\tthis.dispose()\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t/**\n\t * Manually trigger analysis (useful for testing or re-generation)\n\t */\n\tasync analyze(): Promise<void> {\n\t\tawait this.analyzeEverything()\n\t}\n\n\t/**\n\t * Get the analyzed routes\n\t */\n\tgetRoutes(): readonly ExtendedRouteInfo[] {\n\t\treturn this.analyzedRoutes\n\t}\n\n\t/**\n\t * Get the analyzed schemas\n\t */\n\tgetSchemas(): readonly SchemaInfo[] {\n\t\treturn this.analyzedSchemas\n\t}\n\n\t/**\n\t * Get the generation info\n\t */\n\tgetGenerationInfo(): GeneratedClientInfo | null {\n\t\treturn this.generatedInfo\n\t}\n\n\t/**\n\t * Cleanup resources to prevent memory leaks\n\t */\n\tdispose(): void {\n\t\tthis.routeAnalyzer.dispose()\n\t\tthis.schemaGenerator.dispose()\n\t\tthis.log('Resources cleaned up')\n\t}\n\n\t// ============================================================================\n\t// LOGGING UTILITIES\n\t// ============================================================================\n\n\t/**\n\t * Logs a message with the plugin prefix\n\t */\n\tprivate log(message: string): void {\n\t\tconsole.log(`${LOG_PREFIX} ${message}`)\n\t}\n\n\t/**\n\t * Logs an error with the plugin prefix\n\t */\n\tprivate logError(message: string, error?: unknown): void {\n\t\tconsole.error(`${LOG_PREFIX} ${message}`, error || '')\n\t}\n}\n","/**\n * Default configuration options for the RPCPlugin\n */\nexport const DEFAULT_OPTIONS = {\n\tcontrollerPattern: 'src/modules/*/*.controller.ts',\n\ttsConfigPath: 'tsconfig.json',\n\toutputDir: './generated/rpc',\n\tgenerateOnInit: true\n} as const\n\n/**\n * Log prefix for the RPC plugin\n */\nexport const LOG_PREFIX = '[ RPCPlugin ]'\n\n/**\n * Built-in TypeScript types that should not be imported\n */\nexport const BUILTIN_UTILITY_TYPES = new Set([\n\t'Partial',\n\t'Required',\n\t'Readonly',\n\t'Pick',\n\t'Omit',\n\t'Record',\n\t'Exclude',\n\t'Extract',\n\t'ReturnType',\n\t'InstanceType'\n])\n\n/**\n * Built-in TypeScript types that should be skipped\n */\nexport const BUILTIN_TYPES = new Set(['string', 'number', 'boolean', 'any', 'void', 'unknown'])\n\n/**\n * Generic type names that should be unwrapped\n */\nexport const GENERIC_TYPES = new Set(['Array', 'Promise', 'Partial'])\n","import fs from 'fs/promises'\nimport path from 'path'\nimport type { ControllerGroups, ExtendedRouteInfo, RouteParameter } from '../types/route.types'\nimport type { GeneratedClientInfo, SchemaInfo } from '../types/schema.types'\nimport { buildFullApiPath } from '../utils/path-utils'\nimport { camelCase, safeToString } from '../utils/string-utils'\n\n/**\n * Service for generating TypeScript RPC clients\n */\nexport class ClientGeneratorService {\n\tconstructor(private readonly outputDir: string) {}\n\n\t/**\n\t * Generates the TypeScript RPC client\n\t */\n\tasync generateClient(\n\t\troutes: readonly ExtendedRouteInfo[],\n\t\tschemas: readonly SchemaInfo[]\n\t): Promise<GeneratedClientInfo> {\n\t\tawait fs.mkdir(this.outputDir, { recursive: true })\n\n\t\tawait this.generateClientFile(routes, schemas)\n\n\t\tconst generatedInfo: GeneratedClientInfo = {\n\t\t\tclientFile: path.join(this.outputDir, 'client.ts'),\n\t\t\tgeneratedAt: new Date().toISOString()\n\t\t}\n\n\t\treturn generatedInfo\n\t}\n\n\t/**\n\t * Generates the main client file with types included\n\t */\n\tprivate async generateClientFile(\n\t\troutes: readonly ExtendedRouteInfo[],\n\t\tschemas: readonly SchemaInfo[]\n\t): Promise<void> {\n\t\tconst clientContent = this.generateClientContent(routes, schemas)\n\t\tconst clientPath = path.join(this.outputDir, 'client.ts')\n\t\tawait fs.writeFile(clientPath, clientContent, 'utf-8')\n\t}\n\n\t/**\n\t * Generates the client TypeScript content with types included\n\t */\n\tprivate generateClientContent(routes: readonly ExtendedRouteInfo[], schemas: readonly SchemaInfo[]): string {\n\t\tconst controllerGroups = this.groupRoutesByController(routes)\n\n\t\treturn `// ============================================================================\n// TYPES SECTION\n// ============================================================================\n\n/**\n * API Response wrapper\n */\nexport interface ApiResponse<T = any> {\n\tdata: T\n\tmessage?: string\n\tsuccess: boolean\n}\n\n/**\n * API Error class\n */\nexport class ApiError extends Error {\n\tconstructor(\n\t\tpublic statusCode: number,\n\t\tmessage: string\n\t) {\n\t\tsuper(message)\n\t\tthis.name = 'ApiError'\n\t}\n}\n\n/**\n * Clean separation of concerns for request options\n */\nexport type RequestOptions<\n\tTParams = undefined,\n\tTQuery = undefined,\n\tTBody = undefined,\n\tTHeaders = undefined\n> = (TParams extends undefined ? object : { params: TParams }) &\n\t(TQuery extends undefined ? object : { query: TQuery }) &\n\t(TBody extends undefined ? object : { body: TBody }) &\n\t(THeaders extends undefined ? object : { headers: THeaders })\n\n// Generated DTOs and types from integrated Schema Generation\n${this.generateSchemaTypes(schemas)}\n\n// ============================================================================\n// CLIENT SECTION\n// ============================================================================\n\n/**\n * Generated RPC Client\n * \n * This class provides a type-safe HTTP client for interacting with your API endpoints.\n * It's automatically generated by the RPCPlugin based on your controller definitions.\n * \n * @example\n * \\`\\`\\`typescript\n * const apiClient = new ApiClient('http://localhost:3000')\n * \n * // Make a request to get users\n * const response = await apiClient.users.getUsers()\n * \n * // Make a request with parameters\n * const user = await apiClient.users.getUser({ params: { id: '123' } })\n * \n * // Make a request with body data\n * const newUser = await apiClient.users.createUser({ \n * body: { name: 'John', email: 'john@example.com' } \n * })\n * \\`\\`\\`\n * \n * @generated This class is auto-generated by RPCPlugin\n */\nexport class ApiClient {\n\tprivate baseUrl: string\n\tprivate defaultHeaders: Record<string, string>\n\n\tconstructor(baseUrl: string, defaultHeaders: Record<string, string> = {}) {\n\t\tthis.baseUrl = baseUrl.replace(/\\\\/$/, '')\n\t\tthis.defaultHeaders = {\n\t\t\t'Content-Type': 'application/json',\n\t\t\t...defaultHeaders\n\t\t}\n\t}\n\n\t/**\n\t * Set default headers for all requests\n\t */\n\tsetDefaultHeaders(headers: Record<string, string>): this {\n\t\tthis.defaultHeaders = { ...this.defaultHeaders, ...headers }\n\t\treturn this\n\t}\n\n\t/**\n\t * Set default authorization header\n\t */\n\tsetDefaultAuth(token: string): this {\n\t\tthis.defaultHeaders.Authorization = \\`Bearer \\${token}\\`\n\t\treturn this\n\t}\n\n\t/**\n\t * Make an HTTP request with flexible options\n\t */\n\tprivate async request<T>(\n\t\tmethod: string,\n\t\tpath: string,\n\t\toptions: RequestOptions<any, any, any, any> = {}\n\t): Promise<ApiResponse<T>> {\n\t\tconst { params, query, body, headers = {} } = options as any\n\t\t\n\t\t// Build the final URL with path parameters\n\t\tlet finalPath = path\n\t\tif (params) {\n\t\t\tObject.entries(params).forEach(([key, value]) => {\n\t\t\t\tfinalPath = finalPath.replace(\\`:\\${key}\\`, String(value))\n\t\t\t})\n\t\t}\n\n\t\tconst url = new URL(finalPath, this.baseUrl)\n\t\t\n\t\t// Add query parameters\n\t\tif (query) {\n\t\t\tObject.entries(query).forEach(([key, value]) => {\n\t\t\t\tif (value !== undefined && value !== null) {\n\t\t\t\t\turl.searchParams.append(key, String(value))\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\n\t\t// Merge default headers with request-specific headers\n\t\tconst finalHeaders = { ...this.defaultHeaders, ...headers }\n\n\t\tconst requestOptions: RequestInit = {\n\t\t\tmethod,\n\t\t\theaders: finalHeaders,\n\t\t}\n\n\t\tif (body && method !== 'GET') {\n\t\t\trequestOptions.body = JSON.stringify(body)\n\t\t}\n\n\t\ttry {\n\t\t\tconst response = await fetch(url.toString(), requestOptions)\n\t\t\tconst responseData = await response.json()\n\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow new ApiError(response.status, responseData.message || 'Request failed')\n\t\t\t}\n\n\t\t\treturn responseData\n\t\t} catch (error) {\n\t\t\tif (error instanceof ApiError) {\n\t\t\t\tthrow error\n\t\t\t}\n\t\t\tthrow new ApiError(0, error instanceof Error ? error.message : 'Network error')\n\t\t}\n\t}\n\n${this.generateControllerMethods(controllerGroups)}\n}\n`\n\t}\n\n\t/**\n\t * Generates controller methods for the client\n\t */\n\tprivate generateControllerMethods(controllerGroups: ControllerGroups): string {\n\t\tlet methods = ''\n\n\t\tfor (const [controllerName, routes] of controllerGroups) {\n\t\t\tconst className = controllerName.replace(/Controller$/, '')\n\t\t\tmethods += `\n\t// ${className} Controller\n`\n\t\t\tmethods += `\tget ${camelCase(className)}() {\n`\n\t\t\tmethods += `\t\treturn {\n`\n\n\t\t\tfor (const route of routes) {\n\t\t\t\tconst methodName = camelCase(safeToString(route.handler))\n\t\t\t\tconst httpMethod = safeToString(route.method).toLowerCase()\n\t\t\t\tconst { pathParams, queryParams, bodyParams } = this.analyzeRouteParameters(route)\n\n\t\t\t\tconst hasRequiredParams =\n\t\t\t\t\tpathParams.length > 0 ||\n\t\t\t\t\tqueryParams.some((p) => p.required) ||\n\t\t\t\t\t(bodyParams.length > 0 && httpMethod !== 'get')\n\n\t\t\t\t// Generate the method signature with proper typing\n\t\t\t\tmethods += `\t\t\t${methodName}: async (options${hasRequiredParams ? '' : '?'}: RequestOptions<`\n\n\t\t\t\t// Path parameters type\n\t\t\t\tif (pathParams.length > 0) {\n\t\t\t\t\tconst pathParamTypes = pathParams.map((p) => {\n\t\t\t\t\t\tconst paramName = p.name\n\t\t\t\t\t\tconst paramType = p.type || 'any'\n\t\t\t\t\t\treturn `${paramName}: ${paramType}`\n\t\t\t\t\t})\n\t\t\t\t\tmethods += `{ ${pathParamTypes.join(', ')} }`\n\t\t\t\t} else {\n\t\t\t\t\tmethods += 'undefined'\n\t\t\t\t}\n\n\t\t\t\tmethods += ', '\n\n\t\t\t\t// Query parameters type\n\t\t\t\tif (queryParams.length > 0) {\n\t\t\t\t\tconst queryParamTypes = queryParams.map((p) => {\n\t\t\t\t\t\tconst paramName = p.name\n\t\t\t\t\t\tconst paramType = p.type || 'any'\n\t\t\t\t\t\treturn `${paramName}: ${paramType}`\n\t\t\t\t\t})\n\t\t\t\t\tmethods += `{ ${queryParamTypes.join(', ')} }`\n\t\t\t\t} else {\n\t\t\t\t\tmethods += 'undefined'\n\t\t\t\t}\n\n\t\t\t\tmethods += ', '\n\n\t\t\t\t// Body type\n\t\t\t\tif (bodyParams.length > 0) {\n\t\t\t\t\tconst bodyParamTypes = bodyParams.map((p) => {\n\t\t\t\t\t\tconst paramType = p.type || 'any'\n\t\t\t\t\t\treturn paramType\n\t\t\t\t\t})\n\t\t\t\t\t// Use the first body parameter type, not 'any'\n\t\t\t\t\tmethods += bodyParamTypes[0] || 'any'\n\t\t\t\t} else {\n\t\t\t\t\tmethods += 'undefined'\n\t\t\t\t}\n\n\t\t\t\tmethods += ', '\n\n\t\t\t\t// Headers type - always optional for now, but could be made conditional\n\t\t\t\tmethods += 'undefined'\n\n\t\t\t\t// Extract return type from route analysis for better type safety\n\t\t\t\tconst returnType = this.extractReturnType(route.returns)\n\t\t\t\tmethods += `>): Promise<ApiResponse<${returnType}>> => {\n`\n\n\t\t\t\t// Build the full API path using route information\n\t\t\t\tlet requestPath = buildFullApiPath(route)\n\n\t\t\t\t// Replace path parameters with placeholders for dynamic substitution\n\t\t\t\tif (pathParams.length > 0) {\n\t\t\t\t\tfor (const pathParam of pathParams) {\n\t\t\t\t\t\tconst paramName = pathParam.name\n\t\t\t\t\t\tconst placeholder = `:${String(pathParam.data)}`\n\t\t\t\t\t\trequestPath = requestPath.replace(placeholder, `:${paramName}`)\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tmethods += `\t\t\t\treturn this.request<${returnType}>('${httpMethod.toUpperCase()}', \\`${requestPath}\\`, options)\n`\n\t\t\t\tmethods += `\t\t\t},\n`\n\t\t\t}\n\n\t\t\tmethods += `\t\t}\n`\n\t\t\tmethods += `\t}\n`\n\t\t}\n\n\t\treturn methods\n\t}\n\n\t/**\n\t * Extracts the proper return type from route analysis\n\t */\n\tprivate extractReturnType(returns?: string): string {\n\t\tif (!returns) return 'any'\n\n\t\t// Handle Promise<T> types\n\t\tconst promiseMatch = returns.match(/Promise<(.+)>/)\n\t\tif (promiseMatch) {\n\t\t\treturn promiseMatch[1]\n\t\t}\n\n\t\t// Handle other types\n\t\treturn returns\n\t}\n\n\t/**\n\t * Generates schema types from integrated schema generation\n\t */\n\tprivate generateSchemaTypes(schemas: readonly SchemaInfo[]): string {\n\t\tif (schemas.length === 0) {\n\t\t\treturn '// No schemas available from integrated Schema Generation\\n'\n\t\t}\n\n\t\tlet content = '// Schema types from integrated Schema Generation\\n'\n\t\tfor (const schemaInfo of schemas) {\n\t\t\tif (schemaInfo.typescriptType) {\n\t\t\t\tcontent += `${schemaInfo.typescriptType}\\n\\n`\n\t\t\t}\n\t\t}\n\t\treturn content\n\t}\n\n\t/**\n\t * Groups routes by controller for better organization\n\t */\n\tprivate groupRoutesByController(routes: readonly ExtendedRouteInfo[]): ControllerGroups {\n\t\tconst groups = new Map<string, ExtendedRouteInfo[]>()\n\n\t\tfor (const route of routes) {\n\t\t\tconst controller = safeToString(route.controller)\n\t\t\tif (!groups.has(controller)) {\n\t\t\t\tgroups.set(controller, [])\n\t\t\t}\n\t\t\tgroups.get(controller)!.push(route)\n\t\t}\n\n\t\treturn groups\n\t}\n\n\t/**\n\t * Analyzes route parameters to determine their types and usage\n\t */\n\tprivate analyzeRouteParameters(route: ExtendedRouteInfo): {\n\t\tpathParams: readonly RouteParameter[]\n\t\tqueryParams: readonly RouteParameter[]\n\t\tbodyParams: readonly RouteParameter[]\n\t} {\n\t\tconst parameters = route.parameters || []\n\t\tconst method = String(route.method || '').toLowerCase()\n\n\t\tconst isInPath = (p: RouteParameter): boolean => {\n\t\t\t// Check if this parameter corresponds to a path segment\n\t\t\t// For path parameters, the data field should contain the path segment name\n\t\t\tconst pathSegment = p.data\n\t\t\treturn !!pathSegment && typeof pathSegment === 'string' && route.path.includes(`:${pathSegment}`)\n\t\t}\n\n\t\t// path params are always required if they exist in the path\n\t\tconst pathParams = parameters.filter((p) => isInPath(p)).map((p) => ({ ...p, required: true }))\n\n\t\t// body is required if any body param exists for non-GET\n\t\tconst rawBody = parameters.filter((p) => !isInPath(p) && method !== 'get')\n\t\tconst bodyParams = rawBody.map((p) => ({\n\t\t\t...p,\n\t\t\trequired: true\n\t\t}))\n\n\t\t// query requiredness comes from analyzer if available; default optional\n\t\tconst queryParams = parameters\n\t\t\t.filter((p) => !isInPath(p) && method === 'get')\n\t\t\t.map((p) => ({\n\t\t\t\t...p,\n\t\t\t\trequired: p.required === true // default false if not provided\n\t\t\t}))\n\n\t\treturn { pathParams, queryParams, bodyParams }\n\t}\n}\n","import type { ParameterMetadata } from 'honestjs'\nimport type { ExtendedRouteInfo } from '../types/route.types'\n\n/**\n * Builds the full path with parameter placeholders\n */\nexport function buildFullPath(basePath: string, parameters: readonly ParameterMetadata[]): string {\n\tif (!basePath || typeof basePath !== 'string') return '/'\n\n\tlet path = basePath\n\n\tif (parameters && Array.isArray(parameters)) {\n\t\tfor (const param of parameters) {\n\t\t\tif (param.data && typeof param.data === 'string' && param.data.startsWith(':')) {\n\t\t\t\tconst paramName = param.data.slice(1)\n\t\t\t\tpath = path.replace(`:${paramName}`, `\\${${paramName}}`)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn path\n}\n\n/**\n * Builds the full API path using route information\n */\nexport function buildFullApiPath(route: ExtendedRouteInfo): string {\n\tconst prefix = route.prefix || ''\n\tconst version = route.version || ''\n\tconst routePath = route.route || ''\n\tconst path = route.path || ''\n\n\tlet fullPath = ''\n\n\t// Add prefix (e.g., /api)\n\tif (prefix && prefix !== '/') {\n\t\tfullPath += prefix.replace(/^\\/+|\\/+$/g, '')\n\t}\n\n\t// Add version (e.g., /v1)\n\tif (version && version !== '/') {\n\t\tfullPath += `/${version.replace(/^\\/+|\\/+$/g, '')}`\n\t}\n\n\t// Add route (e.g., /users)\n\tif (routePath && routePath !== '/') {\n\t\tfullPath += `/${routePath.replace(/^\\/+|\\/+$/g, '')}`\n\t}\n\n\t// Add path (e.g., /:id or /)\n\tif (path && path !== '/') {\n\t\tfullPath += `/${path.replace(/^\\/+|\\/+$/g, '')}`\n\t} else if (path === '/') {\n\t\tfullPath += '/'\n\t}\n\n\treturn fullPath || '/'\n}\n","/**\n * Safely converts a value to string, handling symbols and other types\n */\nexport function safeToString(value: unknown): string {\n\tif (typeof value === 'string') return value\n\tif (typeof value === 'symbol') return value.description || 'Symbol'\n\treturn String(value)\n}\n\n/**\n * Converts a string to camelCase\n */\nexport function camelCase(str: string): string {\n\treturn str.charAt(0).toLowerCase() + str.slice(1)\n}\n","import { RouteRegistry, type ParameterMetadata, type RouteInfo } from 'honestjs'\nimport { ClassDeclaration, MethodDeclaration, Project } from 'ts-morph'\nimport type { ExtendedRouteInfo, ParameterMetadataWithType } from '../types/route.types'\nimport { buildFullPath } from '../utils/path-utils'\nimport { safeToString } from '../utils/string-utils'\n\n/**\n * Service for analyzing controller methods and extracting type information\n */\nexport class RouteAnalyzerService {\n\tconstructor(\n\t\tprivate readonly controllerPattern: string,\n\t\tprivate readonly tsConfigPath: string\n\t) {}\n\n\t// Track projects for cleanup\n\tprivate projects: Project[] = []\n\n\t/**\n\t * Analyzes controller methods to extract type information\n\t */\n\tasync analyzeControllerMethods(): Promise<ExtendedRouteInfo[]> {\n\t\tconst routes = RouteRegistry.getRoutes()\n\t\tif (!routes?.length) {\n\t\t\treturn []\n\t\t}\n\n\t\tconst project = this.createProject()\n\t\tconst controllers = this.findControllerClasses(project)\n\n\t\tif (controllers.size === 0) {\n\t\t\treturn []\n\t\t}\n\n\t\treturn this.processRoutes(routes, controllers)\n\t}\n\n\t/**\n\t * Creates a new ts-morph project\n\t */\n\tprivate createProject(): Project {\n\t\tconst project = new Project({\n\t\t\ttsConfigFilePath: this.tsConfigPath\n\t\t})\n\n\t\tproject.addSourceFilesAtPaths([this.controllerPattern])\n\t\tthis.projects.push(project)\n\t\treturn project\n\t}\n\n\t/**\n\t * Cleanup resources to prevent memory leaks\n\t */\n\tdispose(): void {\n\t\tthis.projects.forEach((project) => {\n\t\t\t// Remove all source files to free memory\n\t\t\tproject.getSourceFiles().forEach((file) => project.removeSourceFile(file))\n\t\t})\n\t\tthis.projects = []\n\t}\n\n\t/**\n\t * Finds controller classes in the project\n\t */\n\tprivate findControllerClasses(project: Project): Map<string, ClassDeclaration> {\n\t\tconst controllers = new Map<string, ClassDeclaration>()\n\t\tconst files = project.getSourceFiles()\n\n\t\tfor (const sourceFile of files) {\n\t\t\tconst classes = sourceFile.getClasses()\n\n\t\t\tfor (const classDeclaration of classes) {\n\t\t\t\tconst className = classDeclaration.getName()\n\n\t\t\t\tif (className?.endsWith('Controller')) {\n\t\t\t\t\tcontrollers.set(className, classDeclaration)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn controllers\n\t}\n\n\t/**\n\t * Processes all routes and extracts type information\n\t */\n\tprivate processRoutes(\n\t\troutes: readonly RouteInfo[],\n\t\tcontrollers: Map<string, ClassDeclaration>\n\t): ExtendedRouteInfo[] {\n\t\tconst analyzedRoutes: ExtendedRouteInfo[] = []\n\t\tconst errors: Error[] = []\n\n\t\tfor (const route of routes) {\n\t\t\ttry {\n\t\t\t\tconst extendedRoute = this.createExtendedRoute(route, controllers)\n\t\t\t\tanalyzedRoutes.push(extendedRoute)\n\t\t\t} catch (routeError) {\n\t\t\t\tconst error = routeError instanceof Error ? routeError : new Error(String(routeError))\n\t\t\t\terrors.push(error)\n\t\t\t\tconsole.error(\n\t\t\t\t\t`Error processing route ${safeToString(route.controller)}.${safeToString(route.handler)}:`,\n\t\t\t\t\trouteError\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\n\t\t// If there were any errors, throw a comprehensive error\n\t\tif (errors.length > 0) {\n\t\t\tthrow new Error(`Failed to process ${errors.length} routes: ${errors.map((e) => e.message).join(', ')}`)\n\t\t}\n\n\t\treturn analyzedRoutes\n\t}\n\n\t/**\n\t * Creates an extended route with type information\n\t */\n\tprivate createExtendedRoute(route: RouteInfo, controllers: Map<string, ClassDeclaration>): ExtendedRouteInfo {\n\t\tconst controllerName = safeToString(route.controller)\n\t\tconst handlerName = safeToString(route.handler)\n\n\t\tconst controllerClass = controllers.get(controllerName)\n\t\tlet returns: string | undefined\n\t\tlet parameters: readonly ParameterMetadataWithType[] | undefined\n\n\t\tif (controllerClass) {\n\t\t\tconst handlerMethod = controllerClass.getMethods().find((method) => method.getName() === handlerName)\n\n\t\t\tif (handlerMethod) {\n\t\t\t\treturns = this.getReturnType(handlerMethod)\n\t\t\t\tparameters = this.getParametersWithTypes(handlerMethod, route.parameters || [])\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tcontroller: controllerName,\n\t\t\thandler: handlerName,\n\t\t\tmethod: safeToString(route.method).toUpperCase(),\n\t\t\tprefix: route.prefix,\n\t\t\tversion: route.version,\n\t\t\troute: route.route,\n\t\t\tpath: route.path,\n\t\t\tfullPath: buildFullPath(route.path, route.parameters),\n\t\t\tparameters,\n\t\t\treturns\n\t\t}\n\t}\n\n\t/**\n\t * Gets the return type of a method\n\t */\n\tprivate getReturnType(method: MethodDeclaration): string {\n\t\tconst type = method.getReturnType()\n\t\tconst typeText = type.getText(method)\n\n\t\tconst aliasSymbol = type.getAliasSymbol()\n\t\tif (aliasSymbol) {\n\t\t\treturn aliasSymbol.getName()\n\t\t}\n\n\t\treturn typeText.replace(/import\\(\".*?\"\\)\\./g, '')\n\t}\n\n\t/**\n\t * Gets parameters with their types\n\t */\n\tprivate getParametersWithTypes(\n\t\tmethod: MethodDeclaration,\n\t\tparameters: readonly ParameterMetadata[]\n\t): readonly ParameterMetadataWithType[] {\n\t\tconst result: ParameterMetadataWithType[] = []\n\t\tconst declaredParams = method.getParameters()\n\t\tconst sortedParams = [...parameters].sort((a, b) => a.index - b.index)\n\n\t\tfor (const param of sortedParams) {\n\t\t\tconst index = param.index\n\n\t\t\tif (index < declaredParams.length) {\n\t\t\t\tconst declaredParam = declaredParams[index]\n\t\t\t\tconst paramName = declaredParam.getName()\n\t\t\t\tconst paramType = declaredParam\n\t\t\t\t\t.getType()\n\t\t\t\t\t.getText()\n\t\t\t\t\t.replace(/import\\(\".*?\"\\)\\./g, '')\n\n\t\t\t\tresult.push({\n\t\t\t\t\tindex,\n\t\t\t\t\tname: paramName,\n\t\t\t\t\ttype: paramType,\n\t\t\t\t\trequired: true,\n\t\t\t\t\tdata: param.data,\n\t\t\t\t\tfactory: param.factory,\n\t\t\t\t\tmetatype: param.metatype\n\t\t\t\t})\n\t\t\t} else {\n\t\t\t\tresult.push({\n\t\t\t\t\tindex,\n\t\t\t\t\tname: `param${index}`,\n\t\t\t\t\ttype: param.metatype?.name || 'unknown',\n\t\t\t\t\trequired: true,\n\t\t\t\t\tdata: param.data,\n\t\t\t\t\tfactory: param.factory,\n\t\t\t\t\tmetatype: param.metatype\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\treturn result\n\t}\n}\n","import { createGenerator } from 'ts-json-schema-generator'\nimport { MethodDeclaration, Project } from 'ts-morph'\nimport type { SchemaInfo } from '../types/schema.types'\nimport { generateTypeScriptInterface } from '../utils/schema-utils'\nimport { extractNamedType } from '../utils/type-utils'\n\n/**\n * Service for generating JSON schemas from TypeScript types used in controllers\n */\nexport class SchemaGeneratorService {\n\tconstructor(\n\t\tprivate readonly controllerPattern: string,\n\t\tprivate readonly tsConfigPath: string\n\t) {}\n\n\t// Track projects for cleanup\n\tprivate projects: Project[] = []\n\n\t/**\n\t * Generates JSON schemas from types used in controllers\n\t */\n\tasync generateSchemas(): Promise<SchemaInfo[]> {\n\t\tconst project = this.createProject()\n\t\tconst sourceFiles = project.getSourceFiles(this.controllerPattern)\n\n\t\tconst collectedTypes = this.collectTypesFromControllers(sourceFiles)\n\t\treturn this.processTypes(collectedTypes)\n\t}\n\n\t/**\n\t * Creates a new ts-morph project\n\t */\n\tprivate createProject(): Project {\n\t\tconst project = new Project({\n\t\t\ttsConfigFilePath: this.tsConfigPath\n\t\t})\n\n\t\tproject.addSourceFilesAtPaths([this.controllerPattern])\n\t\tthis.projects.push(project)\n\t\treturn project\n\t}\n\n\t/**\n\t * Cleanup resources to prevent memory leaks\n\t */\n\tdispose(): void {\n\t\tthis.projects.forEach((project) => {\n\t\t\t// Remove all source files to free memory\n\t\t\tproject.getSourceFiles().forEach((file) => project.removeSourceFile(file))\n\t\t})\n\t\tthis.projects = []\n\t}\n\n\t/**\n\t * Collects types from controller files\n\t */\n\tprivate collectTypesFromControllers(sourceFiles: readonly any[]): Set<string> {\n\t\tconst collectedTypes = new Set<string>()\n\n\t\tfor (const file of sourceFiles) {\n\t\t\tfor (const cls of file.getClasses()) {\n\t\t\t\tfor (const method of cls.getMethods()) {\n\t\t\t\t\tthis.collectTypesFromMethod(method, collectedTypes)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn collectedTypes\n\t}\n\n\t/**\n\t * Collects types from a single method\n\t */\n\tprivate collectTypesFromMethod(method: MethodDeclaration, collectedTypes: Set<string>): void {\n\t\t// Collect parameter types\n\t\tfor (const param of method.getParameters()) {\n\t\t\tconst type = extractNamedType(param.getType())\n\t\t\tif (type) collectedTypes.add(type)\n\t\t}\n\n\t\t// Collect return type\n\t\tconst returnType = method.getReturnType()\n\t\tconst innerType = returnType.getTypeArguments()[0] ?? returnType\n\t\tconst type = extractNamedType(innerType)\n\t\tif (type) collectedTypes.add(type)\n\t}\n\n\t/**\n\t * Processes collected types to generate schemas\n\t */\n\tprivate async processTypes(collectedTypes: Set<string>): Promise<SchemaInfo[]> {\n\t\tconst schemas: SchemaInfo[] = []\n\n\t\tfor (const typeName of collectedTypes) {\n\t\t\ttry {\n\t\t\t\tconst schema = await this.generateSchemaForType(typeName)\n\t\t\t\tconst typescriptType = generateTypeScriptInterface(typeName, schema)\n\n\t\t\t\tschemas.push({\n\t\t\t\t\ttype: typeName,\n\t\t\t\t\tschema,\n\t\t\t\t\ttypescriptType\n\t\t\t\t})\n\t\t\t} catch (err) {\n\t\t\t\tconsole.error(`Failed to generate schema for ${typeName}:`, err)\n\t\t\t}\n\t\t}\n\n\t\treturn schemas\n\t}\n\n\t/**\n\t * Generates schema for a specific type\n\t */\n\tprivate async generateSchemaForType(typeName: string): Promise<Record<string, any>> {\n\t\ttry {\n\t\t\tconst generator = createGenerator({\n\t\t\t\tpath: this.controllerPattern,\n\t\t\t\ttsconfig: this.tsConfigPath,\n\t\t\t\ttype: typeName,\n\t\t\t\tskipTypeCheck: false // Enable type checking for better error detection\n\t\t\t})\n\n\t\t\treturn generator.createSchema(typeName)\n\t\t} catch (error) {\n\t\t\tconsole.error(`Failed to generate schema for type ${typeName}:`, error)\n\t\t\t// Return a basic schema structure as fallback\n\t\t\treturn {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {},\n\t\t\t\trequired: []\n\t\t\t}\n\t\t}\n\t}\n}\n","/**\n * Maps JSON schema types to TypeScript types\n */\nexport function mapJsonSchemaTypeToTypeScript(schema: Record<string, any>): string {\n\tconst type = schema.type as string\n\n\tswitch (type) {\n\t\tcase 'string':\n\t\t\tif (schema.enum && Array.isArray(schema.enum)) {\n\t\t\t\treturn `'${schema.enum.join(\"' | '\")}'`\n\t\t\t}\n\t\t\treturn 'string'\n\t\tcase 'number':\n\t\tcase 'integer':\n\t\t\treturn 'number'\n\t\tcase 'boolean':\n\t\t\treturn 'boolean'\n\t\tcase 'array': {\n\t\t\tconst itemType = mapJsonSchemaTypeToTypeScript(schema.items || {})\n\t\t\treturn `${itemType}[]`\n\t\t}\n\t\tcase 'object':\n\t\t\treturn 'Record<string, any>'\n\t\tdefault:\n\t\t\treturn 'any'\n\t}\n}\n\n/**\n * Generates TypeScript interface from JSON schema\n */\nexport function generateTypeScriptInterface(typeName: string, schema: Record<string, any>): string {\n\ttry {\n\t\tconst typeDefinition = schema.definitions?.[typeName]\n\t\tif (!typeDefinition) {\n\t\t\treturn `export interface ${typeName} {\\n\\t// No schema definition found\\n}`\n\t\t}\n\n\t\tconst properties = typeDefinition.properties || {}\n\t\tconst required = typeDefinition.required || []\n\n\t\tlet interfaceCode = `export interface ${typeName} {\\n`\n\n\t\tfor (const [propName, propSchema] of Object.entries(properties)) {\n\t\t\tconst isRequired = required.includes(propName)\n\t\t\tconst type = mapJsonSchemaTypeToTypeScript(propSchema as Record<string, any>)\n\t\t\tconst optional = isRequired ? '' : '?'\n\n\t\t\tinterfaceCode += `\\t${propName}${optional}: ${type}\\n`\n\t\t}\n\n\t\tinterfaceCode += '}'\n\t\treturn interfaceCode\n\t} catch (error) {\n\t\tconsole.error(`Failed to generate TypeScript interface for ${typeName}:`, error)\n\t\treturn `export interface ${typeName} {\\n\\t// Failed to generate interface\\n}`\n\t}\n}\n","import type { Type } from 'ts-morph'\nimport { BUILTIN_TYPES, BUILTIN_UTILITY_TYPES, GENERIC_TYPES } from '../constants/defaults'\n\n/**\n * Extracts a named type from a TypeScript type\n */\nexport function extractNamedType(type: Type): string | null {\n\tconst symbol = type.getAliasSymbol() || type.getSymbol()\n\tif (!symbol) return null\n\n\tconst name = symbol.getName()\n\n\t// Handle generic types by unwrapping them\n\tif (GENERIC_TYPES.has(name)) {\n\t\tconst inner = type.getAliasTypeArguments()?.[0] || type.getTypeArguments()?.[0]\n\t\treturn inner ? extractNamedType(inner) : null\n\t}\n\n\t// Skip built-in types\n\tif (BUILTIN_TYPES.has(name)) return null\n\n\treturn name\n}\n\n/**\n * Generates type imports for the client\n */\nexport function generateTypeImports(routes: readonly any[]): string {\n\tconst types = new Set<string>()\n\n\tfor (const route of routes) {\n\t\t// Collect parameter types\n\t\tif (route.parameters) {\n\t\t\tfor (const param of route.parameters) {\n\t\t\t\tif (param.type && !['string', 'number', 'boolean'].includes(param.type)) {\n\t\t\t\t\t// Extract type name from complex types like Partial<CreateUserDto> or User[]\n\t\t\t\t\tconst typeMatch = param.type.match(/(\\w+)(?:<.*>)?/)\n\t\t\t\t\tif (typeMatch) {\n\t\t\t\t\t\tconst typeName = typeMatch[1]\n\t\t\t\t\t\t// Don't import built-in TypeScript utility types\n\t\t\t\t\t\tif (!BUILTIN_UTILITY_TYPES.has(typeName)) {\n\t\t\t\t\t\t\ttypes.add(typeName)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Collect return types\n\t\tif (route.returns) {\n\t\t\tconst returnType = route.returns.replace(/Promise<(.+)>/, '$1')\n\t\t\t// Extract base type name from array types (e.g., 'User[]' -> 'User')\n\t\t\tconst baseType = returnType.replace(/\\[\\]$/, '')\n\t\t\tif (!['string', 'number', 'boolean', 'any', 'void', 'unknown'].includes(baseType)) {\n\t\t\t\ttypes.add(baseType)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn Array.from(types).join(', ')\n}\n"],"mappings":";AAAA,OAAOA,SAAQ;AAGf,OAAOC,WAAU;;;ACAV,IAAM,kBAAkB;AAAA,EAC9B,mBAAmB;AAAA,EACnB,cAAc;AAAA,EACd,WAAW;AAAA,EACX,gBAAgB;AACjB;AAKO,IAAM,aAAa;AAKnB,IAAM,wBAAwB,oBAAI,IAAI;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,CAAC;AAKM,IAAM,gBAAgB,oBAAI,IAAI,CAAC,UAAU,UAAU,WAAW,OAAO,QAAQ,SAAS,CAAC;AAKvF,IAAM,gBAAgB,oBAAI,IAAI,CAA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;AAAA;AAAA;AAAA,EASQ,IAAI,SAAuB;AAClC,YAAQ,IAAI,GAAG,UAAU,IAAI,OAAO,EAAE;AAAA,EACvC;AAAA;AAAA;AAAA;AAAA,EAKQ,SAAS,SAAiB,OAAuB;AACxD,YAAQ,MAAM,GAAG,UAAU,IAAI,OAAO,IAAI,SAAS,EAAE;AAAA,EACtD;AACD;","names":["fs","path","path","Project","Project","type","path","fs"]}
1
+ {"version":3,"sources":["../src/rpc.plugin.ts","../src/constants/defaults.ts","../src/services/client-generator.service.ts","../src/utils/path-utils.ts","../src/utils/string-utils.ts","../src/services/route-analyzer.service.ts","../src/services/schema-generator.service.ts","../src/utils/schema-utils.ts","../src/utils/type-utils.ts"],"sourcesContent":["import fs from 'fs'\nimport type { Application, IPlugin } from 'honestjs'\nimport type { Hono } from 'hono'\nimport path from 'path'\n\nimport { DEFAULT_OPTIONS, LOG_PREFIX } from './constants/defaults'\nimport { ClientGeneratorService } from './services/client-generator.service'\nimport { RouteAnalyzerService } from './services/route-analyzer.service'\nimport { SchemaGeneratorService } from './services/schema-generator.service'\nimport type { ExtendedRouteInfo, GeneratedClientInfo, SchemaInfo } from './types'\n\n/**\n * Configuration options for the RPCPlugin\n */\nexport interface RPCPluginOptions {\n\treadonly controllerPattern?: string\n\treadonly tsConfigPath?: string\n\treadonly outputDir?: string\n\treadonly generateOnInit?: boolean\n}\n\n/**\n * Comprehensive RPC plugin that combines route analysis, schema generation, and client generation\n */\nexport class RPCPlugin implements IPlugin {\n\tprivate readonly controllerPattern: string\n\tprivate readonly tsConfigPath: string\n\tprivate readonly outputDir: string\n\tprivate readonly generateOnInit: boolean\n\n\t// Services\n\tprivate readonly routeAnalyzer: RouteAnalyzerService\n\tprivate readonly schemaGenerator: SchemaGeneratorService\n\tprivate readonly clientGenerator: ClientGeneratorService\n\n\t// Internal state\n\tprivate analyzedRoutes: ExtendedRouteInfo[] = []\n\tprivate analyzedSchemas: SchemaInfo[] = []\n\tprivate generatedInfo: GeneratedClientInfo | null = null\n\n\tconstructor(options: RPCPluginOptions = {}) {\n\t\tthis.controllerPattern = options.controllerPattern ?? DEFAULT_OPTIONS.controllerPattern\n\t\tthis.tsConfigPath = options.tsConfigPath ?? path.resolve(process.cwd(), DEFAULT_OPTIONS.tsConfigPath)\n\t\tthis.outputDir = options.outputDir ?? path.resolve(process.cwd(), DEFAULT_OPTIONS.outputDir)\n\t\tthis.generateOnInit = options.generateOnInit ?? DEFAULT_OPTIONS.generateOnInit\n\n\t\t// Initialize services\n\t\tthis.routeAnalyzer = new RouteAnalyzerService(this.controllerPattern, this.tsConfigPath)\n\t\tthis.schemaGenerator = new SchemaGeneratorService(this.controllerPattern, this.tsConfigPath)\n\t\tthis.clientGenerator = new ClientGeneratorService(this.outputDir)\n\n\t\tthis.validateConfiguration()\n\t}\n\n\t/**\n\t * Validates the plugin configuration\n\t */\n\tprivate validateConfiguration(): void {\n\t\tconst errors: string[] = []\n\n\t\tif (!this.controllerPattern?.trim()) {\n\t\t\terrors.push('Controller pattern cannot be empty')\n\t\t}\n\n\t\tif (!this.tsConfigPath?.trim()) {\n\t\t\terrors.push('TypeScript config path cannot be empty')\n\t\t} else {\n\t\t\tif (!fs.existsSync(this.tsConfigPath)) {\n\t\t\t\terrors.push(`TypeScript config file not found at: ${this.tsConfigPath}`)\n\t\t\t}\n\t\t}\n\n\t\tif (!this.outputDir?.trim()) {\n\t\t\terrors.push('Output directory cannot be empty')\n\t\t}\n\n\t\tif (errors.length > 0) {\n\t\t\tthrow new Error(`Configuration validation failed: ${errors.join(', ')}`)\n\t\t}\n\n\t\tthis.log(\n\t\t\t`Configuration validated: controllerPattern=${this.controllerPattern}, tsConfigPath=${this.tsConfigPath}, outputDir=${this.outputDir}`\n\t\t)\n\t}\n\n\t/**\n\t * Called after all modules are registered\n\t */\n\tafterModulesRegistered = async (app: Application, hono: Hono): Promise<void> => {\n\t\tif (this.generateOnInit) {\n\t\t\tawait this.analyzeEverything()\n\t\t}\n\t}\n\n\t/**\n\t * Main analysis method that coordinates all three components\n\t */\n\tprivate async analyzeEverything(): Promise<void> {\n\t\ttry {\n\t\t\tthis.log('Starting comprehensive RPC analysis...')\n\n\t\t\t// Clear previous analysis results to prevent memory leaks\n\t\t\tthis.analyzedRoutes = []\n\t\t\tthis.analyzedSchemas = []\n\t\t\tthis.generatedInfo = null\n\n\t\t\t// Step 1: Analyze routes and extract type information\n\t\t\tthis.analyzedRoutes = await this.routeAnalyzer.analyzeControllerMethods()\n\n\t\t\t// Step 2: Generate schemas from the types we found\n\t\t\tthis.analyzedSchemas = await this.schemaGenerator.generateSchemas()\n\n\t\t\t// Step 3: Generate the RPC client\n\t\t\tthis.generatedInfo = await this.clientGenerator.generateClient(this.analyzedRoutes, this.analyzedSchemas)\n\n\t\t\tthis.log(\n\t\t\t\t`✅ RPC analysis complete: ${this.analyzedRoutes.length} routes, ${this.analyzedSchemas.length} schemas`\n\t\t\t)\n\t\t} catch (error) {\n\t\t\tthis.logError('Error during RPC analysis:', error)\n\t\t\t// Ensure cleanup happens even on error\n\t\t\tthis.dispose()\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t/**\n\t * Manually trigger analysis (useful for testing or re-generation)\n\t */\n\tasync analyze(): Promise<void> {\n\t\tawait this.analyzeEverything()\n\t}\n\n\t/**\n\t * Get the analyzed routes\n\t */\n\tgetRoutes(): readonly ExtendedRouteInfo[] {\n\t\treturn this.analyzedRoutes\n\t}\n\n\t/**\n\t * Get the analyzed schemas\n\t */\n\tgetSchemas(): readonly SchemaInfo[] {\n\t\treturn this.analyzedSchemas\n\t}\n\n\t/**\n\t * Get the generation info\n\t */\n\tgetGenerationInfo(): GeneratedClientInfo | null {\n\t\treturn this.generatedInfo\n\t}\n\n\t/**\n\t * Cleanup resources to prevent memory leaks\n\t */\n\tdispose(): void {\n\t\tthis.routeAnalyzer.dispose()\n\t\tthis.schemaGenerator.dispose()\n\t\tthis.log('Resources cleaned up')\n\t}\n\n\t// ============================================================================\n\t// LOGGING UTILITIES\n\t// ============================================================================\n\n\t/**\n\t * Logs a message with the plugin prefix\n\t */\n\tprivate log(message: string): void {\n\t\tconsole.log(`${LOG_PREFIX} ${message}`)\n\t}\n\n\t/**\n\t * Logs an error with the plugin prefix\n\t */\n\tprivate logError(message: string, error?: unknown): void {\n\t\tconsole.error(`${LOG_PREFIX} ${message}`, error || '')\n\t}\n}\n","/**\n * Default configuration options for the RPCPlugin\n */\nexport const DEFAULT_OPTIONS = {\n\tcontrollerPattern: 'src/modules/*/*.controller.ts',\n\ttsConfigPath: 'tsconfig.json',\n\toutputDir: './generated/rpc',\n\tgenerateOnInit: true\n} as const\n\n/**\n * Log prefix for the RPC plugin\n */\nexport const LOG_PREFIX = '[ RPCPlugin ]'\n\n/**\n * Built-in TypeScript types that should not be imported\n */\nexport const BUILTIN_UTILITY_TYPES = new Set([\n\t'Partial',\n\t'Required',\n\t'Readonly',\n\t'Pick',\n\t'Omit',\n\t'Record',\n\t'Exclude',\n\t'Extract',\n\t'ReturnType',\n\t'InstanceType'\n])\n\n/**\n * Built-in TypeScript types that should be skipped\n */\nexport const BUILTIN_TYPES = new Set(['string', 'number', 'boolean', 'any', 'void', 'unknown'])\n\n/**\n * Generic type names that should be unwrapped\n */\nexport const GENERIC_TYPES = new Set(['Array', 'Promise', 'Partial'])\n","import fs from 'fs/promises'\nimport path from 'path'\nimport type { ControllerGroups, ExtendedRouteInfo, RouteParameter } from '../types/route.types'\nimport type { GeneratedClientInfo, SchemaInfo } from '../types/schema.types'\nimport { buildFullApiPath } from '../utils/path-utils'\nimport { camelCase, safeToString } from '../utils/string-utils'\n\n/**\n * Service for generating TypeScript RPC clients\n */\nexport class ClientGeneratorService {\n\tconstructor(private readonly outputDir: string) {}\n\n\t/**\n\t * Generates the TypeScript RPC client\n\t */\n\tasync generateClient(\n\t\troutes: readonly ExtendedRouteInfo[],\n\t\tschemas: readonly SchemaInfo[]\n\t): Promise<GeneratedClientInfo> {\n\t\tawait fs.mkdir(this.outputDir, { recursive: true })\n\n\t\tawait this.generateClientFile(routes, schemas)\n\n\t\tconst generatedInfo: GeneratedClientInfo = {\n\t\t\tclientFile: path.join(this.outputDir, 'client.ts'),\n\t\t\tgeneratedAt: new Date().toISOString()\n\t\t}\n\n\t\treturn generatedInfo\n\t}\n\n\t/**\n\t * Generates the main client file with types included\n\t */\n\tprivate async generateClientFile(\n\t\troutes: readonly ExtendedRouteInfo[],\n\t\tschemas: readonly SchemaInfo[]\n\t): Promise<void> {\n\t\tconst clientContent = this.generateClientContent(routes, schemas)\n\t\tconst clientPath = path.join(this.outputDir, 'client.ts')\n\t\tawait fs.writeFile(clientPath, clientContent, 'utf-8')\n\t}\n\n\t/**\n\t * Generates the client TypeScript content with types included\n\t */\n\tprivate generateClientContent(routes: readonly ExtendedRouteInfo[], schemas: readonly SchemaInfo[]): string {\n\t\tconst controllerGroups = this.groupRoutesByController(routes)\n\n\t\treturn `// ============================================================================\n// TYPES SECTION\n// ============================================================================\n\n/**\n * API Response wrapper\n */\nexport interface ApiResponse<T = any> {\n\tdata: T\n\tmessage?: string\n\tsuccess: boolean\n}\n\n/**\n * API Error class\n */\nexport class ApiError extends Error {\n\tconstructor(\n\t\tpublic statusCode: number,\n\t\tmessage: string\n\t) {\n\t\tsuper(message)\n\t\tthis.name = 'ApiError'\n\t}\n}\n\n/**\n * Clean separation of concerns for request options\n */\nexport type RequestOptions<\n\tTParams = undefined,\n\tTQuery = undefined,\n\tTBody = undefined,\n\tTHeaders = undefined\n> = (TParams extends undefined ? object : { params: TParams }) &\n\t(TQuery extends undefined ? object : { query: TQuery }) &\n\t(TBody extends undefined ? object : { body: TBody }) &\n\t(THeaders extends undefined ? object : { headers: THeaders })\n\n/**\n * Custom fetch function type that matches the standard fetch API\n */\nexport type FetchFunction = (\n\tinput: RequestInfo | URL,\n\tinit?: RequestInit\n) => Promise<Response>\n\n// Generated DTOs and types from integrated Schema Generation\n${this.generateSchemaTypes(schemas)}\n\n// ============================================================================\n// CLIENT SECTION\n// ============================================================================\n\n/**\n * Generated RPC Client\n * \n * This class provides a type-safe HTTP client for interacting with your API endpoints.\n * It's automatically generated by the RPCPlugin based on your controller definitions.\n * \n * @example\n * \\`\\`\\`typescript\n * const apiClient = new ApiClient('http://localhost:3000')\n * \n * // Make a request to get users\n * const response = await apiClient.users.getUsers()\n * \n * // Make a request with parameters\n * const user = await apiClient.users.getUser({ params: { id: '123' } })\n * \n * // Make a request with body data\n * const newUser = await apiClient.users.createUser({ \n * body: { name: 'John', email: 'john@example.com' } \n * })\n * \n * // Use with custom fetch function (e.g., for testing or custom logic)\n * const customFetch = (input: RequestInfo | URL, init?: RequestInit) => {\n * console.log('Making request to:', input)\n * return fetch(input, init)\n * }\n * \n * const apiClientWithCustomFetch = new ApiClient('http://localhost:3000', {\n * fetchFn: customFetch,\n * defaultHeaders: { 'X-Custom-Header': 'value' }\n * })\n * \\`\\`\\`\n * \n * @generated This class is auto-generated by RPCPlugin\n */\nexport class ApiClient {\n\tprivate baseUrl: string\n\tprivate defaultHeaders: Record<string, string>\n\tprivate fetchFn: FetchFunction\n\n\tconstructor(\n\t\tbaseUrl: string, \n\t\toptions: {\n\t\t\tdefaultHeaders?: Record<string, string>\n\t\t\tfetchFn?: FetchFunction\n\t\t} = {}\n\t) {\n\t\tthis.baseUrl = baseUrl.replace(/\\\\/$/, '')\n\t\tthis.defaultHeaders = {\n\t\t\t'Content-Type': 'application/json',\n\t\t\t...options.defaultHeaders\n\t\t}\n\t\tthis.fetchFn = options.fetchFn || fetch\n\t}\n\n\t/**\n\t * Set default headers for all requests\n\t */\n\tsetDefaultHeaders(headers: Record<string, string>): this {\n\t\tthis.defaultHeaders = { ...this.defaultHeaders, ...headers }\n\t\treturn this\n\t}\n\n\n\t/**\n\t * Make an HTTP request with flexible options\n\t */\n\tprivate async request<T>(\n\t\tmethod: string,\n\t\tpath: string,\n\t\toptions: RequestOptions<any, any, any, any> = {}\n\t): Promise<ApiResponse<T>> {\n\t\tconst { params, query, body, headers = {} } = options as any\n\t\t\n\t\t// Build the final URL with path parameters\n\t\tlet finalPath = path\n\t\tif (params) {\n\t\t\tObject.entries(params).forEach(([key, value]) => {\n\t\t\t\tfinalPath = finalPath.replace(\\`:\\${key}\\`, String(value))\n\t\t\t})\n\t\t}\n\n\t\tconst url = new URL(finalPath, this.baseUrl)\n\t\t\n\t\t// Add query parameters\n\t\tif (query) {\n\t\t\tObject.entries(query).forEach(([key, value]) => {\n\t\t\t\tif (value !== undefined && value !== null) {\n\t\t\t\t\turl.searchParams.append(key, String(value))\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\n\t\t// Merge default headers with request-specific headers\n\t\tconst finalHeaders = { ...this.defaultHeaders, ...headers }\n\n\t\tconst requestOptions: RequestInit = {\n\t\t\tmethod,\n\t\t\theaders: finalHeaders,\n\t\t}\n\n\t\tif (body && method !== 'GET') {\n\t\t\trequestOptions.body = JSON.stringify(body)\n\t\t}\n\n\t\ttry {\n\t\t\tconst response = await this.fetchFn(url.toString(), requestOptions)\n\t\t\tconst responseData = await response.json()\n\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow new ApiError(response.status, responseData.message || 'Request failed')\n\t\t\t}\n\n\t\t\treturn responseData\n\t\t} catch (error) {\n\t\t\tif (error instanceof ApiError) {\n\t\t\t\tthrow error\n\t\t\t}\n\t\t\tthrow new ApiError(0, error instanceof Error ? error.message : 'Network error')\n\t\t}\n\t}\n\n${this.generateControllerMethods(controllerGroups)}\n}\n`\n\t}\n\n\t/**\n\t * Generates controller methods for the client\n\t */\n\tprivate generateControllerMethods(controllerGroups: ControllerGroups): string {\n\t\tlet methods = ''\n\n\t\tfor (const [controllerName, routes] of controllerGroups) {\n\t\t\tconst className = controllerName.replace(/Controller$/, '')\n\t\t\tmethods += `\n\t// ${className} Controller\n`\n\t\t\tmethods += `\tget ${camelCase(className)}() {\n`\n\t\t\tmethods += `\t\treturn {\n`\n\n\t\t\tfor (const route of routes) {\n\t\t\t\tconst methodName = camelCase(safeToString(route.handler))\n\t\t\t\tconst httpMethod = safeToString(route.method).toLowerCase()\n\t\t\t\tconst { pathParams, queryParams, bodyParams } = this.analyzeRouteParameters(route)\n\n\t\t\t\tconst hasRequiredParams =\n\t\t\t\t\tpathParams.length > 0 ||\n\t\t\t\t\tqueryParams.some((p) => p.required) ||\n\t\t\t\t\t(bodyParams.length > 0 && httpMethod !== 'get')\n\n\t\t\t\t// Generate the method signature with proper typing\n\t\t\t\tmethods += `\t\t\t${methodName}: async (options${hasRequiredParams ? '' : '?'}: RequestOptions<`\n\n\t\t\t\t// Path parameters type\n\t\t\t\tif (pathParams.length > 0) {\n\t\t\t\t\tconst pathParamTypes = pathParams.map((p) => {\n\t\t\t\t\t\tconst paramName = p.name\n\t\t\t\t\t\tconst paramType = p.type || 'any'\n\t\t\t\t\t\treturn `${paramName}: ${paramType}`\n\t\t\t\t\t})\n\t\t\t\t\tmethods += `{ ${pathParamTypes.join(', ')} }`\n\t\t\t\t} else {\n\t\t\t\t\tmethods += 'undefined'\n\t\t\t\t}\n\n\t\t\t\tmethods += ', '\n\n\t\t\t\t// Query parameters type\n\t\t\t\tif (queryParams.length > 0) {\n\t\t\t\t\tconst queryParamTypes = queryParams.map((p) => {\n\t\t\t\t\t\tconst paramName = p.name\n\t\t\t\t\t\tconst paramType = p.type || 'any'\n\t\t\t\t\t\treturn `${paramName}: ${paramType}`\n\t\t\t\t\t})\n\t\t\t\t\tmethods += `{ ${queryParamTypes.join(', ')} }`\n\t\t\t\t} else {\n\t\t\t\t\tmethods += 'undefined'\n\t\t\t\t}\n\n\t\t\t\tmethods += ', '\n\n\t\t\t\t// Body type\n\t\t\t\tif (bodyParams.length > 0) {\n\t\t\t\t\tconst bodyParamTypes = bodyParams.map((p) => {\n\t\t\t\t\t\tconst paramType = p.type || 'any'\n\t\t\t\t\t\treturn paramType\n\t\t\t\t\t})\n\t\t\t\t\t// Use the first body parameter type, not 'any'\n\t\t\t\t\tmethods += bodyParamTypes[0] || 'any'\n\t\t\t\t} else {\n\t\t\t\t\tmethods += 'undefined'\n\t\t\t\t}\n\n\t\t\t\tmethods += ', '\n\n\t\t\t\t// Headers type - always optional for now, but could be made conditional\n\t\t\t\tmethods += 'undefined'\n\n\t\t\t\t// Extract return type from route analysis for better type safety\n\t\t\t\tconst returnType = this.extractReturnType(route.returns)\n\t\t\t\tmethods += `>): Promise<ApiResponse<${returnType}>> => {\n`\n\n\t\t\t\t// Build the full API path using route information\n\t\t\t\tlet requestPath = buildFullApiPath(route)\n\n\t\t\t\t// Replace path parameters with placeholders for dynamic substitution\n\t\t\t\tif (pathParams.length > 0) {\n\t\t\t\t\tfor (const pathParam of pathParams) {\n\t\t\t\t\t\tconst paramName = pathParam.name\n\t\t\t\t\t\tconst placeholder = `:${String(pathParam.data)}`\n\t\t\t\t\t\trequestPath = requestPath.replace(placeholder, `:${paramName}`)\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tmethods += `\t\t\t\treturn this.request<${returnType}>('${httpMethod.toUpperCase()}', \\`${requestPath}\\`, options)\n`\n\t\t\t\tmethods += `\t\t\t},\n`\n\t\t\t}\n\n\t\t\tmethods += `\t\t}\n`\n\t\t\tmethods += `\t}\n`\n\t\t}\n\n\t\treturn methods\n\t}\n\n\t/**\n\t * Extracts the proper return type from route analysis\n\t */\n\tprivate extractReturnType(returns?: string): string {\n\t\tif (!returns) return 'any'\n\n\t\t// Handle Promise<T> types\n\t\tconst promiseMatch = returns.match(/Promise<(.+)>/)\n\t\tif (promiseMatch) {\n\t\t\treturn promiseMatch[1]\n\t\t}\n\n\t\t// Handle other types\n\t\treturn returns\n\t}\n\n\t/**\n\t * Generates schema types from integrated schema generation\n\t */\n\tprivate generateSchemaTypes(schemas: readonly SchemaInfo[]): string {\n\t\tif (schemas.length === 0) {\n\t\t\treturn '// No schemas available from integrated Schema Generation\\n'\n\t\t}\n\n\t\tlet content = '// Schema types from integrated Schema Generation\\n'\n\t\tfor (const schemaInfo of schemas) {\n\t\t\tif (schemaInfo.typescriptType) {\n\t\t\t\tcontent += `${schemaInfo.typescriptType}\\n\\n`\n\t\t\t}\n\t\t}\n\t\treturn content\n\t}\n\n\t/**\n\t * Groups routes by controller for better organization\n\t */\n\tprivate groupRoutesByController(routes: readonly ExtendedRouteInfo[]): ControllerGroups {\n\t\tconst groups = new Map<string, ExtendedRouteInfo[]>()\n\n\t\tfor (const route of routes) {\n\t\t\tconst controller = safeToString(route.controller)\n\t\t\tif (!groups.has(controller)) {\n\t\t\t\tgroups.set(controller, [])\n\t\t\t}\n\t\t\tgroups.get(controller)!.push(route)\n\t\t}\n\n\t\treturn groups\n\t}\n\n\t/**\n\t * Analyzes route parameters to determine their types and usage\n\t */\n\tprivate analyzeRouteParameters(route: ExtendedRouteInfo): {\n\t\tpathParams: readonly RouteParameter[]\n\t\tqueryParams: readonly RouteParameter[]\n\t\tbodyParams: readonly RouteParameter[]\n\t} {\n\t\tconst parameters = route.parameters || []\n\t\tconst method = String(route.method || '').toLowerCase()\n\n\t\tconst isInPath = (p: RouteParameter): boolean => {\n\t\t\t// Check if this parameter corresponds to a path segment\n\t\t\t// For path parameters, the data field should contain the path segment name\n\t\t\tconst pathSegment = p.data\n\t\t\treturn !!pathSegment && typeof pathSegment === 'string' && route.path.includes(`:${pathSegment}`)\n\t\t}\n\n\t\t// path params are always required if they exist in the path\n\t\tconst pathParams = parameters.filter((p) => isInPath(p)).map((p) => ({ ...p, required: true }))\n\n\t\t// body is required if any body param exists for non-GET\n\t\tconst rawBody = parameters.filter((p) => !isInPath(p) && method !== 'get')\n\t\tconst bodyParams = rawBody.map((p) => ({\n\t\t\t...p,\n\t\t\trequired: true\n\t\t}))\n\n\t\t// query requiredness comes from analyzer if available; default optional\n\t\tconst queryParams = parameters\n\t\t\t.filter((p) => !isInPath(p) && method === 'get')\n\t\t\t.map((p) => ({\n\t\t\t\t...p,\n\t\t\t\trequired: p.required === true // default false if not provided\n\t\t\t}))\n\n\t\treturn { pathParams, queryParams, bodyParams }\n\t}\n}\n","import type { ParameterMetadata } from 'honestjs'\nimport type { ExtendedRouteInfo } from '../types/route.types'\n\n/**\n * Builds the full path with parameter placeholders\n */\nexport function buildFullPath(basePath: string, parameters: readonly ParameterMetadata[]): string {\n\tif (!basePath || typeof basePath !== 'string') return '/'\n\n\tlet path = basePath\n\n\tif (parameters && Array.isArray(parameters)) {\n\t\tfor (const param of parameters) {\n\t\t\tif (param.data && typeof param.data === 'string' && param.data.startsWith(':')) {\n\t\t\t\tconst paramName = param.data.slice(1)\n\t\t\t\tpath = path.replace(`:${paramName}`, `\\${${paramName}}`)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn path\n}\n\n/**\n * Builds the full API path using route information\n */\nexport function buildFullApiPath(route: ExtendedRouteInfo): string {\n\tconst prefix = route.prefix || ''\n\tconst version = route.version || ''\n\tconst routePath = route.route || ''\n\tconst path = route.path || ''\n\n\tlet fullPath = ''\n\n\t// Add prefix (e.g., /api)\n\tif (prefix && prefix !== '/') {\n\t\tfullPath += prefix.replace(/^\\/+|\\/+$/g, '')\n\t}\n\n\t// Add version (e.g., /v1)\n\tif (version && version !== '/') {\n\t\tfullPath += `/${version.replace(/^\\/+|\\/+$/g, '')}`\n\t}\n\n\t// Add route (e.g., /users)\n\tif (routePath && routePath !== '/') {\n\t\tfullPath += `/${routePath.replace(/^\\/+|\\/+$/g, '')}`\n\t}\n\n\t// Add path (e.g., /:id or /)\n\tif (path && path !== '/') {\n\t\tfullPath += `/${path.replace(/^\\/+|\\/+$/g, '')}`\n\t} else if (path === '/') {\n\t\tfullPath += '/'\n\t}\n\n\treturn fullPath || '/'\n}\n","/**\n * Safely converts a value to string, handling symbols and other types\n */\nexport function safeToString(value: unknown): string {\n\tif (typeof value === 'string') return value\n\tif (typeof value === 'symbol') return value.description || 'Symbol'\n\treturn String(value)\n}\n\n/**\n * Converts a string to camelCase\n */\nexport function camelCase(str: string): string {\n\treturn str.charAt(0).toLowerCase() + str.slice(1)\n}\n","import { RouteRegistry, type ParameterMetadata, type RouteInfo } from 'honestjs'\nimport { ClassDeclaration, MethodDeclaration, Project } from 'ts-morph'\nimport type { ExtendedRouteInfo, ParameterMetadataWithType } from '../types/route.types'\nimport { buildFullPath } from '../utils/path-utils'\nimport { safeToString } from '../utils/string-utils'\n\n/**\n * Service for analyzing controller methods and extracting type information\n */\nexport class RouteAnalyzerService {\n\tconstructor(\n\t\tprivate readonly controllerPattern: string,\n\t\tprivate readonly tsConfigPath: string\n\t) {}\n\n\t// Track projects for cleanup\n\tprivate projects: Project[] = []\n\n\t/**\n\t * Analyzes controller methods to extract type information\n\t */\n\tasync analyzeControllerMethods(): Promise<ExtendedRouteInfo[]> {\n\t\tconst routes = RouteRegistry.getRoutes()\n\t\tif (!routes?.length) {\n\t\t\treturn []\n\t\t}\n\n\t\tconst project = this.createProject()\n\t\tconst controllers = this.findControllerClasses(project)\n\n\t\tif (controllers.size === 0) {\n\t\t\treturn []\n\t\t}\n\n\t\treturn this.processRoutes(routes, controllers)\n\t}\n\n\t/**\n\t * Creates a new ts-morph project\n\t */\n\tprivate createProject(): Project {\n\t\tconst project = new Project({\n\t\t\ttsConfigFilePath: this.tsConfigPath\n\t\t})\n\n\t\tproject.addSourceFilesAtPaths([this.controllerPattern])\n\t\tthis.projects.push(project)\n\t\treturn project\n\t}\n\n\t/**\n\t * Cleanup resources to prevent memory leaks\n\t */\n\tdispose(): void {\n\t\tthis.projects.forEach((project) => {\n\t\t\t// Remove all source files to free memory\n\t\t\tproject.getSourceFiles().forEach((file) => project.removeSourceFile(file))\n\t\t})\n\t\tthis.projects = []\n\t}\n\n\t/**\n\t * Finds controller classes in the project\n\t */\n\tprivate findControllerClasses(project: Project): Map<string, ClassDeclaration> {\n\t\tconst controllers = new Map<string, ClassDeclaration>()\n\t\tconst files = project.getSourceFiles()\n\n\t\tfor (const sourceFile of files) {\n\t\t\tconst classes = sourceFile.getClasses()\n\n\t\t\tfor (const classDeclaration of classes) {\n\t\t\t\tconst className = classDeclaration.getName()\n\n\t\t\t\tif (className?.endsWith('Controller')) {\n\t\t\t\t\tcontrollers.set(className, classDeclaration)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn controllers\n\t}\n\n\t/**\n\t * Processes all routes and extracts type information\n\t */\n\tprivate processRoutes(\n\t\troutes: readonly RouteInfo[],\n\t\tcontrollers: Map<string, ClassDeclaration>\n\t): ExtendedRouteInfo[] {\n\t\tconst analyzedRoutes: ExtendedRouteInfo[] = []\n\t\tconst errors: Error[] = []\n\n\t\tfor (const route of routes) {\n\t\t\ttry {\n\t\t\t\tconst extendedRoute = this.createExtendedRoute(route, controllers)\n\t\t\t\tanalyzedRoutes.push(extendedRoute)\n\t\t\t} catch (routeError) {\n\t\t\t\tconst error = routeError instanceof Error ? routeError : new Error(String(routeError))\n\t\t\t\terrors.push(error)\n\t\t\t\tconsole.error(\n\t\t\t\t\t`Error processing route ${safeToString(route.controller)}.${safeToString(route.handler)}:`,\n\t\t\t\t\trouteError\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\n\t\t// If there were any errors, throw a comprehensive error\n\t\tif (errors.length > 0) {\n\t\t\tthrow new Error(`Failed to process ${errors.length} routes: ${errors.map((e) => e.message).join(', ')}`)\n\t\t}\n\n\t\treturn analyzedRoutes\n\t}\n\n\t/**\n\t * Creates an extended route with type information\n\t */\n\tprivate createExtendedRoute(route: RouteInfo, controllers: Map<string, ClassDeclaration>): ExtendedRouteInfo {\n\t\tconst controllerName = safeToString(route.controller)\n\t\tconst handlerName = safeToString(route.handler)\n\n\t\tconst controllerClass = controllers.get(controllerName)\n\t\tlet returns: string | undefined\n\t\tlet parameters: readonly ParameterMetadataWithType[] | undefined\n\n\t\tif (controllerClass) {\n\t\t\tconst handlerMethod = controllerClass.getMethods().find((method) => method.getName() === handlerName)\n\n\t\t\tif (handlerMethod) {\n\t\t\t\treturns = this.getReturnType(handlerMethod)\n\t\t\t\tparameters = this.getParametersWithTypes(handlerMethod, route.parameters || [])\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tcontroller: controllerName,\n\t\t\thandler: handlerName,\n\t\t\tmethod: safeToString(route.method).toUpperCase(),\n\t\t\tprefix: route.prefix,\n\t\t\tversion: route.version,\n\t\t\troute: route.route,\n\t\t\tpath: route.path,\n\t\t\tfullPath: buildFullPath(route.path, route.parameters),\n\t\t\tparameters,\n\t\t\treturns\n\t\t}\n\t}\n\n\t/**\n\t * Gets the return type of a method\n\t */\n\tprivate getReturnType(method: MethodDeclaration): string {\n\t\tconst type = method.getReturnType()\n\t\tconst typeText = type.getText(method)\n\n\t\tconst aliasSymbol = type.getAliasSymbol()\n\t\tif (aliasSymbol) {\n\t\t\treturn aliasSymbol.getName()\n\t\t}\n\n\t\treturn typeText.replace(/import\\(\".*?\"\\)\\./g, '')\n\t}\n\n\t/**\n\t * Gets parameters with their types\n\t */\n\tprivate getParametersWithTypes(\n\t\tmethod: MethodDeclaration,\n\t\tparameters: readonly ParameterMetadata[]\n\t): readonly ParameterMetadataWithType[] {\n\t\tconst result: ParameterMetadataWithType[] = []\n\t\tconst declaredParams = method.getParameters()\n\t\tconst sortedParams = [...parameters].sort((a, b) => a.index - b.index)\n\n\t\tfor (const param of sortedParams) {\n\t\t\tconst index = param.index\n\n\t\t\tif (index < declaredParams.length) {\n\t\t\t\tconst declaredParam = declaredParams[index]\n\t\t\t\tconst paramName = declaredParam.getName()\n\t\t\t\tconst paramType = declaredParam\n\t\t\t\t\t.getType()\n\t\t\t\t\t.getText()\n\t\t\t\t\t.replace(/import\\(\".*?\"\\)\\./g, '')\n\n\t\t\t\tresult.push({\n\t\t\t\t\tindex,\n\t\t\t\t\tname: paramName,\n\t\t\t\t\ttype: paramType,\n\t\t\t\t\trequired: true,\n\t\t\t\t\tdata: param.data,\n\t\t\t\t\tfactory: param.factory,\n\t\t\t\t\tmetatype: param.metatype\n\t\t\t\t})\n\t\t\t} else {\n\t\t\t\tresult.push({\n\t\t\t\t\tindex,\n\t\t\t\t\tname: `param${index}`,\n\t\t\t\t\ttype: param.metatype?.name || 'unknown',\n\t\t\t\t\trequired: true,\n\t\t\t\t\tdata: param.data,\n\t\t\t\t\tfactory: param.factory,\n\t\t\t\t\tmetatype: param.metatype\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\treturn result\n\t}\n}\n","import { createGenerator } from 'ts-json-schema-generator'\nimport { MethodDeclaration, Project } from 'ts-morph'\nimport type { SchemaInfo } from '../types/schema.types'\nimport { generateTypeScriptInterface } from '../utils/schema-utils'\nimport { extractNamedType } from '../utils/type-utils'\n\n/**\n * Service for generating JSON schemas from TypeScript types used in controllers\n */\nexport class SchemaGeneratorService {\n\tconstructor(\n\t\tprivate readonly controllerPattern: string,\n\t\tprivate readonly tsConfigPath: string\n\t) {}\n\n\t// Track projects for cleanup\n\tprivate projects: Project[] = []\n\n\t/**\n\t * Generates JSON schemas from types used in controllers\n\t */\n\tasync generateSchemas(): Promise<SchemaInfo[]> {\n\t\tconst project = this.createProject()\n\t\tconst sourceFiles = project.getSourceFiles(this.controllerPattern)\n\n\t\tconst collectedTypes = this.collectTypesFromControllers(sourceFiles)\n\t\treturn this.processTypes(collectedTypes)\n\t}\n\n\t/**\n\t * Creates a new ts-morph project\n\t */\n\tprivate createProject(): Project {\n\t\tconst project = new Project({\n\t\t\ttsConfigFilePath: this.tsConfigPath\n\t\t})\n\n\t\tproject.addSourceFilesAtPaths([this.controllerPattern])\n\t\tthis.projects.push(project)\n\t\treturn project\n\t}\n\n\t/**\n\t * Cleanup resources to prevent memory leaks\n\t */\n\tdispose(): void {\n\t\tthis.projects.forEach((project) => {\n\t\t\t// Remove all source files to free memory\n\t\t\tproject.getSourceFiles().forEach((file) => project.removeSourceFile(file))\n\t\t})\n\t\tthis.projects = []\n\t}\n\n\t/**\n\t * Collects types from controller files\n\t */\n\tprivate collectTypesFromControllers(sourceFiles: readonly any[]): Set<string> {\n\t\tconst collectedTypes = new Set<string>()\n\n\t\tfor (const file of sourceFiles) {\n\t\t\tfor (const cls of file.getClasses()) {\n\t\t\t\tfor (const method of cls.getMethods()) {\n\t\t\t\t\tthis.collectTypesFromMethod(method, collectedTypes)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn collectedTypes\n\t}\n\n\t/**\n\t * Collects types from a single method\n\t */\n\tprivate collectTypesFromMethod(method: MethodDeclaration, collectedTypes: Set<string>): void {\n\t\t// Collect parameter types\n\t\tfor (const param of method.getParameters()) {\n\t\t\tconst type = extractNamedType(param.getType())\n\t\t\tif (type) collectedTypes.add(type)\n\t\t}\n\n\t\t// Collect return type\n\t\tconst returnType = method.getReturnType()\n\t\tconst innerType = returnType.getTypeArguments()[0] ?? returnType\n\t\tconst type = extractNamedType(innerType)\n\t\tif (type) collectedTypes.add(type)\n\t}\n\n\t/**\n\t * Processes collected types to generate schemas\n\t */\n\tprivate async processTypes(collectedTypes: Set<string>): Promise<SchemaInfo[]> {\n\t\tconst schemas: SchemaInfo[] = []\n\n\t\tfor (const typeName of collectedTypes) {\n\t\t\ttry {\n\t\t\t\tconst schema = await this.generateSchemaForType(typeName)\n\t\t\t\tconst typescriptType = generateTypeScriptInterface(typeName, schema)\n\n\t\t\t\tschemas.push({\n\t\t\t\t\ttype: typeName,\n\t\t\t\t\tschema,\n\t\t\t\t\ttypescriptType\n\t\t\t\t})\n\t\t\t} catch (err) {\n\t\t\t\tconsole.error(`Failed to generate schema for ${typeName}:`, err)\n\t\t\t}\n\t\t}\n\n\t\treturn schemas\n\t}\n\n\t/**\n\t * Generates schema for a specific type\n\t */\n\tprivate async generateSchemaForType(typeName: string): Promise<Record<string, any>> {\n\t\ttry {\n\t\t\tconst generator = createGenerator({\n\t\t\t\tpath: this.controllerPattern,\n\t\t\t\ttsconfig: this.tsConfigPath,\n\t\t\t\ttype: typeName,\n\t\t\t\tskipTypeCheck: false // Enable type checking for better error detection\n\t\t\t})\n\n\t\t\treturn generator.createSchema(typeName)\n\t\t} catch (error) {\n\t\t\tconsole.error(`Failed to generate schema for type ${typeName}:`, error)\n\t\t\t// Return a basic schema structure as fallback\n\t\t\treturn {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {},\n\t\t\t\trequired: []\n\t\t\t}\n\t\t}\n\t}\n}\n","/**\n * Maps JSON schema types to TypeScript types\n */\nexport function mapJsonSchemaTypeToTypeScript(schema: Record<string, any>): string {\n\tconst type = schema.type as string\n\n\tswitch (type) {\n\t\tcase 'string':\n\t\t\tif (schema.enum && Array.isArray(schema.enum)) {\n\t\t\t\treturn `'${schema.enum.join(\"' | '\")}'`\n\t\t\t}\n\t\t\treturn 'string'\n\t\tcase 'number':\n\t\tcase 'integer':\n\t\t\treturn 'number'\n\t\tcase 'boolean':\n\t\t\treturn 'boolean'\n\t\tcase 'array': {\n\t\t\tconst itemType = mapJsonSchemaTypeToTypeScript(schema.items || {})\n\t\t\treturn `${itemType}[]`\n\t\t}\n\t\tcase 'object':\n\t\t\treturn 'Record<string, any>'\n\t\tdefault:\n\t\t\treturn 'any'\n\t}\n}\n\n/**\n * Generates TypeScript interface from JSON schema\n */\nexport function generateTypeScriptInterface(typeName: string, schema: Record<string, any>): string {\n\ttry {\n\t\tconst typeDefinition = schema.definitions?.[typeName]\n\t\tif (!typeDefinition) {\n\t\t\treturn `export interface ${typeName} {\\n\\t// No schema definition found\\n}`\n\t\t}\n\n\t\tconst properties = typeDefinition.properties || {}\n\t\tconst required = typeDefinition.required || []\n\n\t\tlet interfaceCode = `export interface ${typeName} {\\n`\n\n\t\tfor (const [propName, propSchema] of Object.entries(properties)) {\n\t\t\tconst isRequired = required.includes(propName)\n\t\t\tconst type = mapJsonSchemaTypeToTypeScript(propSchema as Record<string, any>)\n\t\t\tconst optional = isRequired ? '' : '?'\n\n\t\t\tinterfaceCode += `\\t${propName}${optional}: ${type}\\n`\n\t\t}\n\n\t\tinterfaceCode += '}'\n\t\treturn interfaceCode\n\t} catch (error) {\n\t\tconsole.error(`Failed to generate TypeScript interface for ${typeName}:`, error)\n\t\treturn `export interface ${typeName} {\\n\\t// Failed to generate interface\\n}`\n\t}\n}\n","import type { Type } from 'ts-morph'\nimport { BUILTIN_TYPES, BUILTIN_UTILITY_TYPES, GENERIC_TYPES } from '../constants/defaults'\n\n/**\n * Extracts a named type from a TypeScript type\n */\nexport function extractNamedType(type: Type): string | null {\n\tconst symbol = type.getAliasSymbol() || type.getSymbol()\n\tif (!symbol) return null\n\n\tconst name = symbol.getName()\n\n\t// Handle generic types by unwrapping them\n\tif (GENERIC_TYPES.has(name)) {\n\t\tconst inner = type.getAliasTypeArguments()?.[0] || type.getTypeArguments()?.[0]\n\t\treturn inner ? extractNamedType(inner) : null\n\t}\n\n\t// Skip built-in types\n\tif (BUILTIN_TYPES.has(name)) return null\n\n\treturn name\n}\n\n/**\n * Generates type imports for the client\n */\nexport function generateTypeImports(routes: readonly any[]): string {\n\tconst types = new Set<string>()\n\n\tfor (const route of routes) {\n\t\t// Collect parameter types\n\t\tif (route.parameters) {\n\t\t\tfor (const param of route.parameters) {\n\t\t\t\tif (param.type && !['string', 'number', 'boolean'].includes(param.type)) {\n\t\t\t\t\t// Extract type name from complex types like Partial<CreateUserDto> or User[]\n\t\t\t\t\tconst typeMatch = param.type.match(/(\\w+)(?:<.*>)?/)\n\t\t\t\t\tif (typeMatch) {\n\t\t\t\t\t\tconst typeName = typeMatch[1]\n\t\t\t\t\t\t// Don't import built-in TypeScript utility types\n\t\t\t\t\t\tif (!BUILTIN_UTILITY_TYPES.has(typeName)) {\n\t\t\t\t\t\t\ttypes.add(typeName)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Collect return types\n\t\tif (route.returns) {\n\t\t\tconst returnType = route.returns.replace(/Promise<(.+)>/, '$1')\n\t\t\t// Extract base type name from array types (e.g., 'User[]' -> 'User')\n\t\t\tconst baseType = returnType.replace(/\\[\\]$/, '')\n\t\t\tif (!['string', 'number', 'boolean', 'any', 'void', 'unknown'].includes(baseType)) {\n\t\t\t\ttypes.add(baseType)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn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MAAM,YAAY,KAAK,gBAAgB,MAAM;AAAA,MAC9F;AAAA,IACD,SAAS,OAAO;AACf,WAAK,SAAS,8BAA8B,KAAK;AAEjD,WAAK,QAAQ;AACb,YAAM;AAAA,IACP;AAAA,EACD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,UAAyB;AAC9B,UAAM,KAAK,kBAAkB;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA,EAKA,YAA0C;AACzC,WAAO,KAAK;AAAA,EACb;AAAA;AAAA;AAAA;AAAA,EAKA,aAAoC;AACnC,WAAO,KAAK;AAAA,EACb;AAAA;AAAA;AAAA;AAAA,EAKA,oBAAgD;AAC/C,WAAO,KAAK;AAAA,EACb;AAAA;AAAA;AAAA;AAAA,EAKA,UAAgB;AACf,SAAK,cAAc,QAAQ;AAC3B,SAAK,gBAAgB,QAAQ;AAC7B,SAAK,IAAI,sBAAsB;AAAA,EAChC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASQ,IAAI,SAAuB;AAClC,YAAQ,IAAI,GAAG,UAAU,IAAI,OAAO,EAAE;AAAA,EACvC;AAAA;AAAA;AAAA;AAAA,EAKQ,SAAS,SAAiB,OAAuB;AACxD,YAAQ,MAAM,GAAG,UAAU,IAAI,OAAO,IAAI,SAAS,EAAE;AAAA,EACtD;AACD;","names":["fs","path","path","Project","Project","type","path","fs"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@honestjs/rpc-plugin",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "RPC plugin for HonestJS framework",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",