node-honest 0.0.7 → 0.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.
Files changed (163) hide show
  1. package/dist/index.cjs +2185 -0
  2. package/dist/index.d.cts +1539 -0
  3. package/dist/index.d.ts +1539 -16
  4. package/dist/index.js +2116 -15
  5. package/package.json +12 -9
  6. package/dist/application/plugin-entries.d.ts +0 -13
  7. package/dist/application/plugin-entries.js +0 -38
  8. package/dist/application/startup-guide.d.ts +0 -4
  9. package/dist/application/startup-guide.js +0 -53
  10. package/dist/application-context.d.ts +0 -13
  11. package/dist/application-context.js +0 -22
  12. package/dist/application.d.ts +0 -34
  13. package/dist/application.js +0 -224
  14. package/dist/components/index.d.ts +0 -1
  15. package/dist/components/index.js +0 -1
  16. package/dist/components/layout.component.d.ts +0 -31
  17. package/dist/components/layout.component.js +0 -94
  18. package/dist/constants/index.d.ts +0 -2
  19. package/dist/constants/index.js +0 -2
  20. package/dist/constants/pipeline.constants.d.ts +0 -6
  21. package/dist/constants/pipeline.constants.js +0 -6
  22. package/dist/constants/version.constants.d.ts +0 -5
  23. package/dist/constants/version.constants.js +0 -5
  24. package/dist/decorators/controller.decorator.d.ts +0 -9
  25. package/dist/decorators/controller.decorator.js +0 -16
  26. package/dist/decorators/http-method.decorator.d.ts +0 -43
  27. package/dist/decorators/http-method.decorator.js +0 -44
  28. package/dist/decorators/index.d.ts +0 -11
  29. package/dist/decorators/index.js +0 -11
  30. package/dist/decorators/module.decorator.d.ts +0 -8
  31. package/dist/decorators/module.decorator.js +0 -12
  32. package/dist/decorators/mvc.decorator.d.ts +0 -26
  33. package/dist/decorators/mvc.decorator.js +0 -36
  34. package/dist/decorators/parameter.decorator.d.ts +0 -41
  35. package/dist/decorators/parameter.decorator.js +0 -59
  36. package/dist/decorators/service.decorator.d.ts +0 -6
  37. package/dist/decorators/service.decorator.js +0 -11
  38. package/dist/decorators/use-component.decorator.d.ts +0 -10
  39. package/dist/decorators/use-component.decorator.js +0 -19
  40. package/dist/decorators/use-filters.decorator.d.ts +0 -8
  41. package/dist/decorators/use-filters.decorator.js +0 -17
  42. package/dist/decorators/use-guards.decorator.d.ts +0 -9
  43. package/dist/decorators/use-guards.decorator.js +0 -18
  44. package/dist/decorators/use-middleware.decorator.d.ts +0 -9
  45. package/dist/decorators/use-middleware.decorator.js +0 -18
  46. package/dist/decorators/use-pipes.decorator.d.ts +0 -9
  47. package/dist/decorators/use-pipes.decorator.js +0 -18
  48. package/dist/di/container.d.ts +0 -34
  49. package/dist/di/container.js +0 -114
  50. package/dist/di/index.d.ts +0 -1
  51. package/dist/di/index.js +0 -1
  52. package/dist/errors/framework.error.d.ts +0 -19
  53. package/dist/errors/framework.error.js +0 -23
  54. package/dist/errors/index.d.ts +0 -1
  55. package/dist/errors/index.js +0 -1
  56. package/dist/handlers/error.handler.d.ts +0 -28
  57. package/dist/handlers/error.handler.js +0 -17
  58. package/dist/handlers/index.d.ts +0 -2
  59. package/dist/handlers/index.js +0 -2
  60. package/dist/handlers/not-found.handler.d.ts +0 -14
  61. package/dist/handlers/not-found.handler.js +0 -17
  62. package/dist/helpers/create-error-response.helper.d.ts +0 -25
  63. package/dist/helpers/create-error-response.helper.js +0 -90
  64. package/dist/helpers/create-http-method-decorator.helper.d.ts +0 -16
  65. package/dist/helpers/create-http-method-decorator.helper.js +0 -30
  66. package/dist/helpers/create-param-decorator.helper.d.ts +0 -16
  67. package/dist/helpers/create-param-decorator.helper.js +0 -60
  68. package/dist/helpers/index.d.ts +0 -3
  69. package/dist/helpers/index.js +0 -3
  70. package/dist/interfaces/application-context.interface.d.ts +0 -35
  71. package/dist/interfaces/application-context.interface.js +0 -1
  72. package/dist/interfaces/controller-options.interface.d.ts +0 -17
  73. package/dist/interfaces/controller-options.interface.js +0 -1
  74. package/dist/interfaces/di-container.interface.d.ts +0 -35
  75. package/dist/interfaces/di-container.interface.js +0 -1
  76. package/dist/interfaces/error-response.interface.d.ts +0 -13
  77. package/dist/interfaces/error-response.interface.js +0 -1
  78. package/dist/interfaces/filter.interface.d.ts +0 -20
  79. package/dist/interfaces/filter.interface.js +0 -1
  80. package/dist/interfaces/guard.interface.d.ts +0 -21
  81. package/dist/interfaces/guard.interface.js +0 -1
  82. package/dist/interfaces/handler-invocation.interface.d.ts +0 -10
  83. package/dist/interfaces/handler-invocation.interface.js +0 -1
  84. package/dist/interfaces/honest-options.interface.d.ts +0 -121
  85. package/dist/interfaces/honest-options.interface.js +0 -1
  86. package/dist/interfaces/http-method-options.interface.d.ts +0 -38
  87. package/dist/interfaces/http-method-options.interface.js +0 -1
  88. package/dist/interfaces/index.d.ts +0 -21
  89. package/dist/interfaces/index.js +0 -21
  90. package/dist/interfaces/logger.interface.d.ts +0 -23
  91. package/dist/interfaces/logger.interface.js +0 -1
  92. package/dist/interfaces/metadata-repository.interface.d.ts +0 -30
  93. package/dist/interfaces/metadata-repository.interface.js +0 -1
  94. package/dist/interfaces/middleware.interface.d.ts +0 -22
  95. package/dist/interfaces/middleware.interface.js +0 -1
  96. package/dist/interfaces/module-options.interface.d.ts +0 -18
  97. package/dist/interfaces/module-options.interface.js +0 -1
  98. package/dist/interfaces/parameter-metadata.interface.d.ts +0 -27
  99. package/dist/interfaces/parameter-metadata.interface.js +0 -1
  100. package/dist/interfaces/parameter-resolution.interface.d.ts +0 -14
  101. package/dist/interfaces/parameter-resolution.interface.js +0 -1
  102. package/dist/interfaces/pipe.interface.d.ts +0 -37
  103. package/dist/interfaces/pipe.interface.js +0 -1
  104. package/dist/interfaces/pipeline-context.interface.d.ts +0 -9
  105. package/dist/interfaces/pipeline-context.interface.js +0 -1
  106. package/dist/interfaces/plugin.interface.d.ts +0 -74
  107. package/dist/interfaces/plugin.interface.js +0 -1
  108. package/dist/interfaces/route-definition.interface.d.ts +0 -51
  109. package/dist/interfaces/route-definition.interface.js +0 -1
  110. package/dist/interfaces/route-info.interface.d.ts +0 -42
  111. package/dist/interfaces/route-info.interface.js +0 -1
  112. package/dist/interfaces/service-registry.interface.d.ts +0 -7
  113. package/dist/interfaces/service-registry.interface.js +0 -1
  114. package/dist/loggers/console.logger.d.ts +0 -7
  115. package/dist/loggers/console.logger.js +0 -21
  116. package/dist/loggers/index.d.ts +0 -2
  117. package/dist/loggers/index.js +0 -2
  118. package/dist/loggers/noop.logger.d.ts +0 -7
  119. package/dist/loggers/noop.logger.js +0 -8
  120. package/dist/managers/component.manager.d.ts +0 -48
  121. package/dist/managers/component.manager.js +0 -209
  122. package/dist/managers/handler.invoker.d.ts +0 -7
  123. package/dist/managers/handler.invoker.js +0 -37
  124. package/dist/managers/index.d.ts +0 -5
  125. package/dist/managers/index.js +0 -5
  126. package/dist/managers/parameter.resolver.d.ts +0 -13
  127. package/dist/managers/parameter.resolver.js +0 -57
  128. package/dist/managers/pipeline.executor.d.ts +0 -28
  129. package/dist/managers/pipeline.executor.js +0 -68
  130. package/dist/managers/route.manager.d.ts +0 -36
  131. package/dist/managers/route.manager.js +0 -147
  132. package/dist/registries/index.d.ts +0 -4
  133. package/dist/registries/index.js +0 -4
  134. package/dist/registries/metadata.registry.d.ts +0 -163
  135. package/dist/registries/metadata.registry.js +0 -250
  136. package/dist/registries/metadata.repository.d.ts +0 -30
  137. package/dist/registries/metadata.repository.js +0 -151
  138. package/dist/registries/route.registry.d.ts +0 -16
  139. package/dist/registries/route.registry.js +0 -46
  140. package/dist/registries/service.registry.d.ts +0 -8
  141. package/dist/registries/service.registry.js +0 -9
  142. package/dist/testing/create-controller-test-application.d.ts +0 -5
  143. package/dist/testing/create-controller-test-application.js +0 -11
  144. package/dist/testing/create-service-test-container.d.ts +0 -5
  145. package/dist/testing/create-service-test-container.js +0 -31
  146. package/dist/testing/create-test-application.d.ts +0 -5
  147. package/dist/testing/create-test-application.js +0 -20
  148. package/dist/testing/create-testing-module.d.ts +0 -6
  149. package/dist/testing/create-testing-module.js +0 -13
  150. package/dist/testing/fixtures/application-test-fixtures.d.ts +0 -17
  151. package/dist/testing/fixtures/application-test-fixtures.js +0 -230
  152. package/dist/testing/index.d.ts +0 -5
  153. package/dist/testing/index.js +0 -5
  154. package/dist/testing/testing.interface.d.ts +0 -96
  155. package/dist/testing/testing.interface.js +0 -1
  156. package/dist/types/constructor.type.d.ts +0 -12
  157. package/dist/types/constructor.type.js +0 -1
  158. package/dist/types/index.d.ts +0 -1
  159. package/dist/types/index.js +0 -1
  160. package/dist/utils/common.util.d.ts +0 -117
  161. package/dist/utils/common.util.js +0 -140
  162. package/dist/utils/index.d.ts +0 -1
  163. package/dist/utils/index.js +0 -1
package/dist/index.d.ts CHANGED
@@ -1,16 +1,1539 @@
1
- import 'reflect-metadata';
2
- export * from './application';
3
- export * from './application-context';
4
- export * from './components';
5
- export * from './constants';
6
- export * from './decorators';
7
- export * from './loggers';
8
- export * from './di';
9
- export * from './errors';
10
- export * from './handlers';
11
- export * from './helpers';
12
- export * from './interfaces';
13
- export * from './registries';
14
- export * from './testing';
15
- export * from './types';
16
- export * from './utils';
1
+ import * as hono from 'hono';
2
+ import { Context as Context$1, Next, Hono } from 'hono';
3
+ import * as hono_utils_html from 'hono/utils/html';
4
+ import { PropsWithChildren } from 'hono/jsx';
5
+ import { ContentfulStatusCode } from 'hono/utils/http-status';
6
+
7
+ /**
8
+ * App-level registry where your application can publish and read pipeline data by key.
9
+ * Available to bootstrap code, services, and any code with access to `app`.
10
+ * Enables composition without hard coupling: producers and consumers use namespaced keys.
11
+ */
12
+ interface IApplicationContext {
13
+ /**
14
+ * Get a value by key. Caller provides type for type safety.
15
+ * @param key - Namespaced registry key (e.g. 'app.config', 'openapi.spec')
16
+ * @returns The value or undefined if not set
17
+ */
18
+ get<T>(key: string): T | undefined;
19
+ /**
20
+ * Set a value by key.
21
+ * @param key - Namespaced registry key
22
+ * @param value - Value to store
23
+ */
24
+ set<T>(key: string, value: T): void;
25
+ /**
26
+ * Check if a key is present.
27
+ * @param key - Registry key
28
+ * @returns true if the key exists
29
+ */
30
+ has(key: string): boolean;
31
+ /**
32
+ * Remove a key and its value.
33
+ * @param key - Registry key
34
+ * @returns true if the key existed and was removed
35
+ */
36
+ delete(key: string): boolean;
37
+ /**
38
+ * Iterate over all registered keys.
39
+ */
40
+ keys(): IterableIterator<string>;
41
+ }
42
+
43
+ /**
44
+ * Symbol to use when marking a route as version-neutral
45
+ * Version-neutral routes are accessible both with and without version prefix
46
+ */
47
+ declare const VERSION_NEUTRAL: unique symbol;
48
+
49
+ /**
50
+ * Internal request-context keys used by the Honest runtime pipeline.
51
+ */
52
+ declare const HONEST_PIPELINE_CONTROLLER_KEY = "__honest_controllerClass";
53
+ declare const HONEST_PIPELINE_HANDLER_KEY = "__honest_handlerName";
54
+ declare const HONEST_PIPELINE_BODY_CACHE_KEY = "__honest.body.cache";
55
+
56
+ /**
57
+ * Interface for controller configuration options
58
+ */
59
+ interface ControllerOptions {
60
+ /**
61
+ * API prefix for this controller's routes, overrides global prefix
62
+ */
63
+ prefix?: string | null;
64
+ /**
65
+ * API version for this controller's routes (e.g. 1 becomes /v1), overrides global version
66
+ * Set to null to explicitly opt out of versioning even when global version is set
67
+ * Set to VERSION_NEUTRAL to make routes accessible both with and without version prefix
68
+ * Set to an array of numbers to make routes available at multiple versions
69
+ */
70
+ version?: number | null | typeof VERSION_NEUTRAL | number[];
71
+ }
72
+
73
+ /**
74
+ * Represents a class constructor type
75
+ * Used throughout the framework for type-safe dependency injection and component registration
76
+ *
77
+ * @template T - The type of instance that the constructor creates
78
+ * @example
79
+ * ```ts
80
+ * class MyService {}
81
+ * const myConstructor: Constructor<MyService> = MyService;
82
+ * ```
83
+ */
84
+ type Constructor<T = any> = new (...args: any[]) => T;
85
+
86
+ /**
87
+ * Interface for dependency injection containers
88
+ * Defines the contract that DI containers must implement to work with the Honest framework
89
+ * Handles the creation and management of dependency instances
90
+ */
91
+ interface DiContainer {
92
+ /**
93
+ * Resolves a dependency from the container
94
+ * Creates a new instance or returns an existing one based on the container's configuration
95
+ * @param target - The class constructor to resolve
96
+ * @returns An instance of the requested class with all dependencies injected
97
+ * @throws {Error} If the dependency cannot be resolved
98
+ */
99
+ resolve<T>(target: Constructor<T>): T;
100
+ /**
101
+ * Registers a pre-created instance in the container
102
+ * Used for singleton instances or mocks in testing
103
+ * @param target - The class constructor to register the instance for
104
+ * @param instance - The pre-created instance to use
105
+ * @throws {Error} If registration fails
106
+ */
107
+ register<T>(target: Constructor<T>, instance: T): void;
108
+ /**
109
+ * Checks whether the container already holds an instance for the given class
110
+ * @param target - The class constructor to check
111
+ * @returns true if an instance has been resolved or registered
112
+ */
113
+ has<T>(target: Constructor<T>): boolean;
114
+ /**
115
+ * Removes all cached instances from the container
116
+ * Useful for resetting state between tests
117
+ */
118
+ clear(): void;
119
+ }
120
+
121
+ /**
122
+ * Log level.
123
+ */
124
+ type LogLevel = 'debug' | 'info' | 'warn' | 'error';
125
+ /**
126
+ * Log category used to filter or route events.
127
+ */
128
+ type LogCategory = 'startup' | 'routes' | 'plugins' | 'deprecations' | 'pipeline' | 'di' | 'errors';
129
+ /**
130
+ * Structured log event emitted by Honest runtime components.
131
+ */
132
+ interface LogEvent {
133
+ level: LogLevel;
134
+ category: LogCategory;
135
+ message: string;
136
+ details?: Record<string, unknown>;
137
+ }
138
+ /**
139
+ * Logger contract.
140
+ */
141
+ interface ILogger {
142
+ emit(event: LogEvent): void;
143
+ }
144
+
145
+ interface ErrorResponse {
146
+ status: number;
147
+ message: string;
148
+ timestamp: string;
149
+ path: string;
150
+ requestId?: string;
151
+ code?: string;
152
+ details?: Record<string, any>;
153
+ errors?: Array<{
154
+ property: string;
155
+ constraints: Record<string, string>;
156
+ }>;
157
+ }
158
+
159
+ /**
160
+ * Interface for exception filters
161
+ * Filters handle and transform exceptions thrown during request processing
162
+ */
163
+ interface IFilter {
164
+ /**
165
+ * Method to catch and handle exceptions
166
+ * @param exception - The exception that was thrown
167
+ * @param context - The Hono context object
168
+ * @returns A Response object or undefined if the exception should be passed to the next filter
169
+ */
170
+ catch(exception: Error, context: Context$1): Promise<Response | undefined> | Response | undefined;
171
+ }
172
+ /**
173
+ * Type for exception filters
174
+ * Can be either a class implementing IFilter or an instance of IFilter
175
+ */
176
+ type FilterType = Constructor<IFilter> | IFilter;
177
+
178
+ /**
179
+ * Interface defining a guard.
180
+ * Guards determine whether a request should be handled by the route handler or not.
181
+ */
182
+ interface IGuard {
183
+ /**
184
+ * Method to implement the guard logic.
185
+ * Return true to allow the request to proceed, false to deny.
186
+ *
187
+ * @param context - The Hono context object
188
+ * @returns A boolean or Promise<boolean> indicating if the request is allowed
189
+ */
190
+ canActivate(context: Context$1): boolean | Promise<boolean>;
191
+ }
192
+ /**
193
+ * Type for guard classes
194
+ * Can be either a constructor of IGuard or an instance of IGuard
195
+ */
196
+ type GuardType = Constructor<IGuard> | IGuard;
197
+
198
+ /**
199
+ * Input contract for invoking route handlers and mapping results to HTTP responses.
200
+ */
201
+ interface HandlerInvocationInput {
202
+ handler: (...args: unknown[]) => Promise<unknown> | unknown;
203
+ args: unknown[];
204
+ context: Context$1;
205
+ contextIndex?: number;
206
+ }
207
+
208
+ /**
209
+ * Options for configuring the Honest application
210
+ */
211
+ interface HonestOptions {
212
+ /**
213
+ * Emit actionable startup guidance when initialization fails.
214
+ * - `true` enables concise hints
215
+ * - object form enables verbose hints with additional context
216
+ */
217
+ startupGuide?: boolean | {
218
+ verbose?: boolean;
219
+ };
220
+ /**
221
+ * Enable debug logging for startup diagnostics.
222
+ * - `true` enables all debug logs
223
+ * - object form enables specific categories
224
+ */
225
+ debug?: boolean | {
226
+ routes?: boolean;
227
+ plugins?: boolean;
228
+ pipeline?: boolean;
229
+ di?: boolean;
230
+ startup?: boolean;
231
+ };
232
+ /**
233
+ * Optional logger for structured framework events.
234
+ */
235
+ logger?: ILogger;
236
+ /**
237
+ * Optional strict-mode checks for startup validation.
238
+ */
239
+ strict?: {
240
+ /**
241
+ * When enabled, startup fails if no routes were registered.
242
+ */
243
+ requireRoutes?: boolean;
244
+ };
245
+ /**
246
+ * Optional warnings for unstable/deprecated behavior.
247
+ */
248
+ deprecations?: {
249
+ /**
250
+ * Print pre-v1 instability warning during startup.
251
+ */
252
+ printPreV1Warning?: boolean;
253
+ };
254
+ /**
255
+ * Container instance for dependency injection
256
+ */
257
+ container?: DiContainer;
258
+ /**
259
+ * Hono-specific options
260
+ */
261
+ hono?: {
262
+ /**
263
+ * Whether to use strict matching for routes
264
+ */
265
+ strict?: boolean;
266
+ /**
267
+ * Custom router to use
268
+ */
269
+ router?: any;
270
+ /**
271
+ * Function to extract path from request
272
+ */
273
+ getPath?: (request: Request, options?: any) => string;
274
+ };
275
+ /**
276
+ * Global routing options
277
+ */
278
+ routing?: {
279
+ /**
280
+ * Global API prefix to apply to all routes (e.g. /api)
281
+ */
282
+ prefix?: string;
283
+ /**
284
+ * Global API version to apply to all routes (e.g. 1 becomes /v1)
285
+ * Set to VERSION_NEUTRAL to make routes accessible both with and without version prefix
286
+ * Set to an array of numbers to make routes available at multiple versions
287
+ */
288
+ version?: number | typeof VERSION_NEUTRAL | number[];
289
+ };
290
+ /**
291
+ * Global components to apply to all routes
292
+ */
293
+ components?: {
294
+ /**
295
+ * Global middleware to apply to all routes
296
+ */
297
+ middleware?: MiddlewareType[];
298
+ /**
299
+ * Global guards to apply to all routes
300
+ */
301
+ guards?: GuardType[];
302
+ /**
303
+ * Global pipes to apply to all routes
304
+ */
305
+ pipes?: PipeType[];
306
+ /**
307
+ * Global exception filters to apply to all routes
308
+ */
309
+ filters?: FilterType[];
310
+ };
311
+ /**
312
+ * Plugins for extending the application functionality.
313
+ * Each entry can be a plain plugin or an object with plugin and optional pre/post processors.
314
+ */
315
+ plugins?: PluginEntry[];
316
+ /**
317
+ * Default exception handler to use when no filter matches
318
+ */
319
+ onError?: (error: unknown, context: Context$1) => Response | Promise<Response>;
320
+ /**
321
+ * Default not found handler for routes that don't match any pattern
322
+ */
323
+ notFound?: (context: Context$1) => Response | Promise<Response>;
324
+ }
325
+
326
+ /**
327
+ * Options for HTTP method decorators (@Get, @Post, @Put, @Delete, etc.)
328
+ *
329
+ * @example
330
+ * ```typescript
331
+ * @Get('users', { prefix: 'api', version: 2 })
332
+ * getUsers() {
333
+ * // ...
334
+ * }
335
+ * ```
336
+ */
337
+ interface HttpMethodOptions {
338
+ /**
339
+ * Optional prefix for this specific route, overrides controller and global prefix.
340
+ * Set to null to explicitly remove any prefix for this route.
341
+ *
342
+ * @example
343
+ * ```typescript
344
+ * @Get('users', { prefix: 'api' }) // -> /api/users
345
+ * @Get('users', { prefix: null }) // -> /users (no prefix)
346
+ * @Get('users', { prefix: 'v2/api' }) // -> /v2/api/users
347
+ * ```
348
+ */
349
+ prefix?: string | null;
350
+ /**
351
+ * API version for this specific route, overrides controller and global version.
352
+ *
353
+ * @example
354
+ * ```typescript
355
+ * @Get('users', { version: 1 }) // -> /v1/users
356
+ * @Get('users', { version: null }) // -> /users (no version)
357
+ * @Get('users', { version: VERSION_NEUTRAL }) // -> Both /users and /v1/users
358
+ * @Get('users', { version: [1, 2] }) // -> Both /v1/users and /v2/users
359
+ * ```
360
+ */
361
+ version?: number | null | typeof VERSION_NEUTRAL | number[];
362
+ }
363
+
364
+ /**
365
+ * Interface for HTTP middleware components
366
+ * Middleware can process requests before they reach the route handler
367
+ * and modify both the request and response
368
+ */
369
+ interface IMiddleware {
370
+ /**
371
+ * Processes an HTTP request/response
372
+ * @param c - The Hono context containing request and response information
373
+ * @param next - Function to call the next middleware in the chain
374
+ * @returns A Promise that resolves to a Response or void
375
+ * @throws {Error} If middleware processing fails
376
+ */
377
+ use(c: Context$1, next: Next): Promise<Response | void>;
378
+ }
379
+ /**
380
+ * Type for middleware implementations
381
+ * Can be either a class implementing IMiddleware or an instance of IMiddleware
382
+ */
383
+ type MiddlewareType = Constructor<IMiddleware> | IMiddleware;
384
+
385
+ /**
386
+ * Options for configuring a module
387
+ */
388
+ interface ModuleOptions {
389
+ /**
390
+ * List of controller classes
391
+ */
392
+ controllers?: Constructor[];
393
+ /**
394
+ * List of service classes
395
+ */
396
+ services?: Constructor[];
397
+ /**
398
+ * List of imported modules
399
+ */
400
+ imports?: Constructor[];
401
+ }
402
+
403
+ /**
404
+ * Metadata for route parameters
405
+ */
406
+ interface ParameterMetadata {
407
+ /**
408
+ * Parameter index
409
+ */
410
+ index: number;
411
+ /**
412
+ * Parameter name (body, param, query, etc.)
413
+ */
414
+ name: string;
415
+ /**
416
+ * Additional parameter data (e.g., param name)
417
+ */
418
+ data?: unknown;
419
+ /**
420
+ * Optional factory function to transform the data
421
+ */
422
+ factory: (data: unknown, ctx: Context$1) => unknown | Promise<unknown>;
423
+ /**
424
+ * The class type of the parameter
425
+ */
426
+ metatype?: Constructor<unknown>;
427
+ }
428
+
429
+ /**
430
+ * Metadata about an argument being processed by a pipe
431
+ */
432
+ interface ArgumentMetadata {
433
+ /**
434
+ * The type of argument (body, query, param, header, request, response, context, variable, or custom)
435
+ */
436
+ type: 'body' | 'query' | 'param' | 'header' | 'request' | 'response' | 'context' | 'variable' | string;
437
+ /**
438
+ * The class type of the argument
439
+ */
440
+ metatype?: Constructor<unknown>;
441
+ /**
442
+ * Additional data about the argument
443
+ */
444
+ data?: string;
445
+ }
446
+ /**
447
+ * Interface for transformation pipes
448
+ * Pipes transform input data before it reaches the route handler
449
+ */
450
+ interface IPipe {
451
+ /**
452
+ * Transforms the input value according to the pipe's logic
453
+ * @param value - The value to transform
454
+ * @param metadata - Metadata about the argument being transformed
455
+ * @returns The transformed value, which can be synchronous or asynchronous
456
+ * @throws {Error} If the transformation fails or validation fails
457
+ */
458
+ transform(value: unknown, metadata: ArgumentMetadata): Promise<unknown> | unknown;
459
+ }
460
+ /**
461
+ * Type for pipe implementations
462
+ * Can be either a class implementing IPipe or an instance of IPipe
463
+ */
464
+ type PipeType = Constructor<IPipe> | IPipe;
465
+
466
+ /**
467
+ * Internal metadata for defining a route. This interface is used by the framework
468
+ * to store route information collected from decorators.
469
+ *
470
+ * @example
471
+ * ```typescript
472
+ * // Internal representation of:
473
+ * @Controller('users')
474
+ * class UsersController {
475
+ * @Get(':id')
476
+ * getUser(@Param('id') id: string) {}
477
+ * }
478
+ * ```
479
+ */
480
+ interface RouteDefinition {
481
+ /**
482
+ * Route path relative to the controller's base path.
483
+ * Supports path parameters using colon syntax.
484
+ *
485
+ * @example ':id' | 'users/:userId/posts/:postId' | ''
486
+ */
487
+ path: string;
488
+ /**
489
+ * HTTP method for the route (GET, POST, PUT, DELETE, etc.)
490
+ */
491
+ method: string;
492
+ /**
493
+ * Name of the method in the controller class that handles this route
494
+ */
495
+ handlerName: string | symbol;
496
+ /**
497
+ * Route-specific API version, overrides controller and global version.
498
+ *
499
+ * @example
500
+ * ```typescript
501
+ * version: 1 // -> /v1/...
502
+ * version: null // -> /... (no version)
503
+ * version: VERSION_NEUTRAL // -> Both /... and /v1/...
504
+ * version: [1, 2] // -> Both /v1/... and /v2/...
505
+ * ```
506
+ */
507
+ version?: number | null | typeof VERSION_NEUTRAL | number[];
508
+ /**
509
+ * Route-specific prefix that overrides controller and global prefix.
510
+ * Set to null to explicitly remove any prefix.
511
+ *
512
+ * @example 'api' | 'v2/api' | null
513
+ */
514
+ prefix?: string | null;
515
+ }
516
+
517
+ type MetadataComponentType = 'middleware' | 'guard' | 'pipe' | 'filter';
518
+ interface MetadataComponentTypeMap {
519
+ middleware: MiddlewareType;
520
+ guard: GuardType;
521
+ pipe: PipeType;
522
+ filter: FilterType;
523
+ }
524
+ /**
525
+ * Runtime metadata access contract used by framework managers.
526
+ */
527
+ interface IMetadataRepository {
528
+ hasController(controller: Constructor): boolean;
529
+ getControllerPath(controller: Constructor): string;
530
+ getControllerOptions(controller: Constructor): ControllerOptions;
531
+ getRoutes(controller: Constructor): RouteDefinition[];
532
+ getParameters(controller: Constructor): Map<string | symbol, ParameterMetadata[]>;
533
+ getContextIndices(controller: Constructor): Map<string | symbol, number>;
534
+ getModuleOptions(module: Constructor): ModuleOptions | undefined;
535
+ getControllerComponents<T extends MetadataComponentType>(type: T, controller: Constructor): MetadataComponentTypeMap[T][];
536
+ getHandlerComponents<T extends MetadataComponentType>(type: T, controller: Constructor, handlerName: string | symbol): MetadataComponentTypeMap[T][];
537
+ }
538
+
539
+ /**
540
+ * Input contract for route-parameter resolution.
541
+ */
542
+ interface ParameterResolutionInput {
543
+ controllerName: string;
544
+ handlerName: string | symbol;
545
+ handlerArity: number;
546
+ handlerParams: ReadonlyArray<ParameterMetadata>;
547
+ handlerPipes: ReadonlyArray<IPipe>;
548
+ context: Context$1;
549
+ }
550
+
551
+ /**
552
+ * Request-scoped keys used by the framework pipeline.
553
+ */
554
+ interface PipelineContextValues {
555
+ controllerClass?: Constructor;
556
+ handlerName?: string;
557
+ bodyCache?: unknown;
558
+ }
559
+
560
+ /**
561
+ * Processor callback for plugin pre/post hooks.
562
+ * Receives app, hono, and the application context (registry) for sharing pipeline data.
563
+ */
564
+ type PluginProcessor = (app: Application, hono: Hono, ctx: IApplicationContext) => void | Promise<void>;
565
+ /**
566
+ * Optional metadata for plugin diagnostics.
567
+ */
568
+ interface PluginMeta {
569
+ /**
570
+ * Stable plugin name used for diagnostics.
571
+ */
572
+ name?: string;
573
+ }
574
+ /**
575
+ * Object form of a plugin entry with optional pre/post processors.
576
+ * Processors run before (pre) or after (post) the plugin's lifecycle hooks.
577
+ */
578
+ interface PluginEntryObject {
579
+ plugin: IPlugin | Constructor<IPlugin>;
580
+ /**
581
+ * Optional stable plugin name for diagnostics.
582
+ * Takes precedence over plugin.meta.name.
583
+ */
584
+ name?: string;
585
+ preProcessors?: PluginProcessor[];
586
+ postProcessors?: PluginProcessor[];
587
+ }
588
+ /**
589
+ * Interface for Honest framework plugins
590
+ * Plugins can extend the framework's functionality by hooking into
591
+ * different stages of the application lifecycle
592
+ */
593
+ interface IPlugin {
594
+ /**
595
+ * Optional metadata for plugin diagnostics.
596
+ */
597
+ meta?: PluginMeta;
598
+ /**
599
+ * Application logger, injected by the framework before lifecycle hooks run.
600
+ * Use this to emit structured log events from within plugin code.
601
+ */
602
+ logger?: ILogger;
603
+ /**
604
+ * Hook that runs before module registration begins.
605
+ * Use this to set up plugin functionality that modules might depend on.
606
+ * @param app - The Honest application instance
607
+ * @param hono - The underlying Hono application instance
608
+ */
609
+ beforeModulesRegistered?: (app: Application, hono: Hono) => void | Promise<void>;
610
+ /**
611
+ * Hook that runs after all modules have been registered.
612
+ * Use this to perform cleanup or setup that requires all modules to be ready.
613
+ * @param app - The Honest application instance
614
+ * @param hono - The underlying Hono application instance
615
+ */
616
+ afterModulesRegistered?: (app: Application, hono: Hono) => void | Promise<void>;
617
+ }
618
+ /**
619
+ * Type for plugin implementations
620
+ * Can be either a class implementing IPlugin or an instance of IPlugin
621
+ */
622
+ type PluginType = Constructor<IPlugin> | IPlugin;
623
+ /**
624
+ * Plugin entry: either a plain plugin or an object wrapping a plugin with optional processors.
625
+ * Use the object form to attach preProcessors (run before lifecycle hooks) and postProcessors
626
+ * (run after). Processors receive (app, hono, ctx) where ctx is the application context.
627
+ */
628
+ type PluginEntry = PluginType | PluginEntryObject;
629
+
630
+ /**
631
+ * Route information for registered routes
632
+ */
633
+ interface RouteInfo {
634
+ /**
635
+ * Controller name
636
+ */
637
+ controller: string | symbol;
638
+ /**
639
+ * Handler method name
640
+ */
641
+ handler: string | symbol;
642
+ /**
643
+ * HTTP method
644
+ */
645
+ method: string;
646
+ /**
647
+ * Effective prefix
648
+ */
649
+ prefix: string;
650
+ /**
651
+ * Effective version
652
+ */
653
+ version?: string;
654
+ /**
655
+ * Controller route path
656
+ */
657
+ route: string;
658
+ /**
659
+ * Method path
660
+ */
661
+ path: string;
662
+ /**
663
+ * Complete path (prefix + version + route + path)
664
+ */
665
+ fullPath: string;
666
+ /**
667
+ * Parameter metadata for the handler
668
+ */
669
+ parameters: ParameterMetadata[];
670
+ }
671
+
672
+ /**
673
+ * Contract for checking whether classes are registered as injectable services.
674
+ */
675
+ interface IServiceRegistry {
676
+ isService(service: Constructor): boolean;
677
+ }
678
+
679
+ /**
680
+ * Main application class for the Honest framework.
681
+ *
682
+ * All per-app runtime state (routes, global components, DI container) is
683
+ * instance-based. Static decorator metadata lives in MetadataRegistry and
684
+ * is shared across all Application instances in the same process.
685
+ */
686
+ declare class Application {
687
+ private readonly hono;
688
+ private readonly container;
689
+ private readonly context;
690
+ private readonly routeRegistry;
691
+ private readonly metadataRepository;
692
+ private readonly componentManager;
693
+ private readonly routeManager;
694
+ private readonly logger;
695
+ private readonly options;
696
+ constructor(options: HonestOptions | undefined, metadataRepository: IMetadataRepository);
697
+ private setupErrorHandlers;
698
+ private shouldEmitRouteDiagnostics;
699
+ private emitStartupGuide;
700
+ register(moduleClass: Constructor): Promise<Application>;
701
+ static create(rootModule: Constructor, options?: HonestOptions): Promise<{
702
+ app: Application;
703
+ hono: Hono;
704
+ }>;
705
+ getApp(): Hono;
706
+ getContainer(): DiContainer;
707
+ getContext(): IApplicationContext;
708
+ getRoutes(): ReadonlyArray<RouteInfo>;
709
+ }
710
+
711
+ /**
712
+ * Map-backed implementation of the app-level registry.
713
+ * Used by Application so the app (bootstrap, services, any code with `app`) can share pipeline data by key.
714
+ */
715
+ declare class ApplicationContext implements IApplicationContext {
716
+ private readonly store;
717
+ get<T>(key: string): T | undefined;
718
+ set<T>(key: string, value: T): void;
719
+ has(key: string): boolean;
720
+ delete(key: string): boolean;
721
+ keys(): IterableIterator<string>;
722
+ }
723
+
724
+ type HtmlAttributes = Record<string, string | number | boolean>;
725
+ interface MetaTag {
726
+ property: string;
727
+ content: string;
728
+ name?: string;
729
+ prefix?: string;
730
+ }
731
+ interface SiteData {
732
+ title: string;
733
+ description?: string;
734
+ image?: string;
735
+ url?: string;
736
+ locale?: string;
737
+ type?: string;
738
+ siteName?: string;
739
+ customMeta?: MetaTag[];
740
+ scripts?: (string | {
741
+ src: string;
742
+ async?: boolean;
743
+ defer?: boolean;
744
+ })[];
745
+ stylesheets?: string[];
746
+ favicon?: string;
747
+ twitterCard?: 'summary' | 'summary_large_image' | 'app' | 'player';
748
+ csp?: string;
749
+ htmlAttributes?: HtmlAttributes;
750
+ headAttributes?: HtmlAttributes;
751
+ bodyAttributes?: HtmlAttributes;
752
+ }
753
+ declare const Layout: (props: PropsWithChildren<SiteData>) => hono_utils_html.HtmlEscapedString | Promise<hono_utils_html.HtmlEscapedString>;
754
+
755
+ /**
756
+ * Decorator that marks a class as a controller
757
+ * Controllers are responsible for handling incoming requests and returning responses
758
+ * @param route - The base route for all endpoints in this controller
759
+ * @param options - Configuration options for the controller
760
+ * @returns A class decorator function
761
+ */
762
+ declare function Controller(route?: string, options?: ControllerOptions): ClassDecorator;
763
+
764
+ /**
765
+ * GET method decorator
766
+ * The GET method requests a representation of the specified resource.
767
+ * Requests using GET should only retrieve data and should not contain a request content.
768
+ * @param path - The route path
769
+ */
770
+ declare const Get: (path?: string, options?: HttpMethodOptions) => MethodDecorator;
771
+ /**
772
+ * POST method decorator
773
+ * The POST method submits an entity to the specified resource,
774
+ * often causing a change in state or side effects on the server.
775
+ * @param path - The route path
776
+ */
777
+ declare const Post: (path?: string, options?: HttpMethodOptions) => MethodDecorator;
778
+ /**
779
+ * PUT method decorator
780
+ * The PUT method replaces all current representations of the target resource with the request content.
781
+ * @param path - The route path
782
+ */
783
+ declare const Put: (path?: string, options?: HttpMethodOptions) => MethodDecorator;
784
+ /**
785
+ * DELETE method decorator
786
+ * The DELETE method deletes the specified resource.
787
+ * @param path - The route path
788
+ */
789
+ declare const Delete: (path?: string, options?: HttpMethodOptions) => MethodDecorator;
790
+ /**
791
+ * PATCH method decorator
792
+ * The PATCH method applies partial modifications to a resource.
793
+ * @param path - The route path
794
+ */
795
+ declare const Patch: (path?: string, options?: HttpMethodOptions) => MethodDecorator;
796
+ /**
797
+ * OPTIONS method decorator
798
+ * The OPTIONS method describes the communication options for the target resource.
799
+ * @param path - The route path
800
+ */
801
+ declare const Options: (path?: string, options?: HttpMethodOptions) => MethodDecorator;
802
+ /**
803
+ * ALL method decorator (matches all HTTP methods)
804
+ * @param path - The route path
805
+ */
806
+ declare const All: (path?: string, options?: HttpMethodOptions) => MethodDecorator;
807
+
808
+ /**
809
+ * Decorator that marks a class as a module
810
+ * Modules are used to organize the application structure and dependencies
811
+ * @param options - Configuration options for the module
812
+ * @returns A class decorator function
813
+ */
814
+ declare function Module(options?: ModuleOptions): ClassDecorator;
815
+
816
+ /**
817
+ * Decorator that marks a class as a controller
818
+ * Controllers are responsible for handling incoming requests and returning responses
819
+ * @param route - The base route for all endpoints in this controller
820
+ * @param options - Configuration options for the controller
821
+ * @returns A class decorator function
822
+ */
823
+ declare function View(route?: string, options?: ControllerOptions): ClassDecorator;
824
+ /**
825
+ * GET method decorator
826
+ * The GET method requests a representation of the specified resource.
827
+ * Requests using GET should only retrieve data and should not contain a request content.
828
+ * @param path - The route path
829
+ */
830
+ declare const Page: (path?: string, options?: HttpMethodOptions) => MethodDecorator;
831
+ /**
832
+ * Decorator that marks a class as a module
833
+ * Modules are used to organize the application structure and dependencies
834
+ * @param options - Configuration options for the module
835
+ * @returns A class decorator function
836
+ */
837
+ declare function MvcModule(options?: ModuleOptions & {
838
+ views?: Constructor[];
839
+ }): ClassDecorator;
840
+
841
+ /**
842
+ * Decorator that binds the request body to a parameter
843
+ * @param data - Optional property name to extract from the body
844
+ */
845
+ declare const Body: (data?: unknown) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
846
+ /**
847
+ * Decorator that binds a route parameter to a parameter
848
+ * @param data - The parameter name in the route
849
+ */
850
+ declare const Param: (data?: unknown) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
851
+ /**
852
+ * Decorator that binds a query parameter to a parameter
853
+ * @param data - The query parameter name
854
+ */
855
+ declare const Query: (data?: unknown) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
856
+ /**
857
+ * Decorator that binds a header value to a parameter
858
+ * @param data - The header name
859
+ */
860
+ declare const Header: (data?: unknown) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
861
+ /**
862
+ * Decorator that binds the request object to a parameter
863
+ */
864
+ declare const Req: (data?: unknown) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
865
+ declare const Request$1: (data?: unknown) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
866
+ /**
867
+ * Decorator that binds the response object to a parameter
868
+ */
869
+ declare const Res: (data?: unknown) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
870
+ declare const Response$1: (data?: unknown) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
871
+ /**
872
+ * Decorator that binds the context object to a parameter
873
+ */
874
+ declare const Ctx: (data?: unknown) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
875
+ declare const Context: (data?: unknown) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
876
+ /**
877
+ * Decorator that binds a context variable to a parameter
878
+ * @param data - The variable name to retrieve from context
879
+ */
880
+ declare const Var: (data?: unknown) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
881
+ declare const Variable: (data?: unknown) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
882
+
883
+ /**
884
+ * Decorator that marks a class as a service
885
+ * Services are singleton classes that can be injected as dependencies
886
+ * @returns A class decorator function
887
+ */
888
+ declare function Service(): ClassDecorator;
889
+
890
+ type ComponentType = 'middleware' | 'guard' | 'pipe' | 'filter';
891
+ type ComponentInstance = MiddlewareType | GuardType | PipeType | FilterType;
892
+ interface ComponentTypeMap {
893
+ middleware: MiddlewareType;
894
+ guard: GuardType;
895
+ pipe: PipeType;
896
+ filter: FilterType;
897
+ }
898
+ /**
899
+ * Central registry for managing application metadata
900
+ * Stores and provides access to:
901
+ * - Route definitions and controller configurations
902
+ * - Service and module registrations
903
+ * - Parameter metadata and context indices
904
+ * - Component registrations at global, controller, and handler levels
905
+ */
906
+ declare class MetadataRegistry {
907
+ /**
908
+ * Stores route definitions for each controller
909
+ * Maps controller classes to their route configurations
910
+ */
911
+ private static readonly routes;
912
+ /**
913
+ * Stores base paths for controllers
914
+ * Maps controller classes to their route prefixes
915
+ */
916
+ private static readonly controllers;
917
+ /**
918
+ * Stores configuration options for controllers
919
+ * Includes settings like versioning and prefix options
920
+ */
921
+ private static readonly controllerOptions;
922
+ /**
923
+ * Registry of service classes
924
+ * Used for dependency injection and lifecycle management
925
+ */
926
+ private static readonly services;
927
+ /**
928
+ * Stores configuration options for modules
929
+ * Includes imports, exports, providers, and controllers
930
+ */
931
+ private static readonly modules;
932
+ /**
933
+ * Stores parameter metadata for controller methods
934
+ * Used for parameter transformation and validation
935
+ */
936
+ private static readonly parameters;
937
+ /**
938
+ * Stores indices of context parameters in controller methods
939
+ * Used for optimizing context injection
940
+ */
941
+ private static readonly contextIndices;
942
+ /**
943
+ * Registry for controller-level components
944
+ * Components registered here apply to all routes in a specific controller
945
+ */
946
+ private static readonly controller;
947
+ /**
948
+ * Registry for handler-level components
949
+ * Components registered here apply to specific route handlers
950
+ * Keyed by controller constructor then handler name for collision-safe lookups
951
+ */
952
+ private static readonly handler;
953
+ /**
954
+ * Gets all route definitions for a controller
955
+ * @param controller - The controller class to get routes for
956
+ * @returns Array of route definitions for the controller
957
+ */
958
+ static getRoutes(controller: Constructor): RouteDefinition[];
959
+ /**
960
+ * Set routes for a controller
961
+ */
962
+ static setRoutes(controller: Constructor, routes: RouteDefinition[]): void;
963
+ /**
964
+ * Add a route to a controller
965
+ */
966
+ static addRoute(controller: Constructor, route: RouteDefinition): void;
967
+ /**
968
+ * Get controller path
969
+ */
970
+ static getControllerPath(controller: Constructor): string;
971
+ /**
972
+ * Check if a class is registered as a controller.
973
+ */
974
+ static hasController(controller: Constructor): boolean;
975
+ /**
976
+ * Set controller path
977
+ */
978
+ static setControllerPath(controller: Constructor, path: string): void;
979
+ /**
980
+ * Get controller options
981
+ */
982
+ static getControllerOptions(controller: Constructor): ControllerOptions;
983
+ /**
984
+ * Set controller options
985
+ */
986
+ static setControllerOptions(controller: Constructor, options: ControllerOptions): void;
987
+ /**
988
+ * Check if class is a service
989
+ */
990
+ static isService(service: Constructor): boolean;
991
+ /**
992
+ * Add a service
993
+ */
994
+ static addService(service: Constructor): void;
995
+ /**
996
+ * Get all services
997
+ */
998
+ static getAllServices(): Set<Constructor>;
999
+ /**
1000
+ * Get module options
1001
+ */
1002
+ static getModuleOptions(module: Constructor): ModuleOptions | undefined;
1003
+ /**
1004
+ * Set module options
1005
+ */
1006
+ static setModuleOptions(module: Constructor, options: ModuleOptions): void;
1007
+ /**
1008
+ * Get parameter metadata
1009
+ */
1010
+ static getParameters(controller: Constructor): Map<string | symbol, ParameterMetadata[]>;
1011
+ /**
1012
+ * Set parameter metadata
1013
+ */
1014
+ static setParameterMap(controller: Constructor, params: Map<string | symbol, ParameterMetadata[]>): void;
1015
+ /**
1016
+ * Get context indices
1017
+ */
1018
+ static getContextIndices(controller: Constructor): Map<string | symbol, number>;
1019
+ /**
1020
+ * Set context indices
1021
+ */
1022
+ static setContextIndices(controller: Constructor, indices: Map<string | symbol, number>): void;
1023
+ /**
1024
+ * Register a component at the controller level
1025
+ */
1026
+ static registerController<T extends ComponentType>(type: T, controller: Constructor, component: ComponentTypeMap[T]): void;
1027
+ /**
1028
+ * Get all controller-level components of a specific type for a controller
1029
+ */
1030
+ static getController<T extends ComponentType>(type: T, controller: Constructor): ComponentTypeMap[T][];
1031
+ /**
1032
+ * Register a component at the handler level
1033
+ */
1034
+ static registerHandler<T extends ComponentType>(type: T, controller: Constructor, handlerName: string | symbol, component: ComponentTypeMap[T]): void;
1035
+ /**
1036
+ * Get all handler-level components of a specific type for a handler
1037
+ */
1038
+ static getHandler<T extends ComponentType>(type: T, controller: Constructor, handlerName: string | symbol): ComponentTypeMap[T][];
1039
+ /**
1040
+ * Clears handler-level component registrations created via {@link registerHandler}.
1041
+ * Does not remove decorator-defined routes, controllers, or modules.
1042
+ */
1043
+ static clearHandlerComponents(): void;
1044
+ /**
1045
+ * Clears all registered decorator metadata.
1046
+ * Primarily used for testing. Warning: clearing after importing decorated classes
1047
+ * (e.g. shared fixtures) removes their metadata until those modules are re-evaluated.
1048
+ */
1049
+ static clear(): void;
1050
+ }
1051
+
1052
+ /**
1053
+ * Immutable metadata repository for a single Application instance.
1054
+ * Captures a deep copy of all metadata reachable from a root module at creation time,
1055
+ * isolating the application from later mutations to the static MetadataRegistry.
1056
+ */
1057
+ declare class MetadataRepository implements IMetadataRepository {
1058
+ private readonly controllerPaths;
1059
+ private readonly controllerOptions;
1060
+ private readonly routes;
1061
+ private readonly parameters;
1062
+ private readonly contextIndices;
1063
+ private readonly modules;
1064
+ private readonly controllerComponents;
1065
+ private readonly handlerComponents;
1066
+ static fromRootModule(rootModule: Constructor): MetadataRepository;
1067
+ hasController(controller: Constructor): boolean;
1068
+ getControllerPath(controller: Constructor): string;
1069
+ getControllerOptions(controller: Constructor): ControllerOptions;
1070
+ getRoutes(controller: Constructor): RouteDefinition[];
1071
+ getParameters(controller: Constructor): Map<string | symbol, ParameterMetadata[]>;
1072
+ getContextIndices(controller: Constructor): Map<string | symbol, number>;
1073
+ getModuleOptions(module: Constructor): ModuleOptions | undefined;
1074
+ getControllerComponents<T extends MetadataComponentType>(type: T, controller: Constructor): MetadataComponentTypeMap[T][];
1075
+ getHandlerComponents<T extends MetadataComponentType>(type: T, controller: Constructor, handlerName: string | symbol): MetadataComponentTypeMap[T][];
1076
+ private captureModuleGraph;
1077
+ private captureController;
1078
+ private cloneRouteDefinition;
1079
+ }
1080
+
1081
+ /**
1082
+ * Registry for managing and querying route information in the application.
1083
+ *
1084
+ * Each Application instance owns its own RouteRegistry, ensuring routes
1085
+ * from one app never leak into another.
1086
+ */
1087
+ declare class RouteRegistry {
1088
+ private readonly routes;
1089
+ registerRoute(routeInfo: RouteInfo): void;
1090
+ getRoutes(): ReadonlyArray<RouteInfo>;
1091
+ getRoutesByController(controllerName: string | symbol): ReadonlyArray<RouteInfo>;
1092
+ getRoutesByMethod(method: string): ReadonlyArray<RouteInfo>;
1093
+ getRoutesByPath(pattern: RegExp): ReadonlyArray<RouteInfo>;
1094
+ clear(): void;
1095
+ }
1096
+
1097
+ /**
1098
+ * Adapter exposing service checks through the DI service registry contract.
1099
+ */
1100
+ declare class StaticServiceRegistry implements IServiceRegistry {
1101
+ isService(service: Constructor): boolean;
1102
+ }
1103
+
1104
+ /**
1105
+ * Generic decorator that applies components of a specific type to a controller class or method
1106
+ * @template T - The type of component being applied
1107
+ * @param type - The component type identifier
1108
+ * @param components - Array of components to apply
1109
+ * @returns A decorator function that can be used at class or method level
1110
+ */
1111
+ declare function UseComponent<T extends ComponentType>(type: T, ...components: ComponentTypeMap[T][]): (target: Constructor | object, propertyKey?: string | symbol) => void;
1112
+
1113
+ /**
1114
+ * Decorator that applies exception filters to a controller class or method
1115
+ * @param filters - Array of exception filters to apply
1116
+ * @returns A decorator function that can be used at class or method level
1117
+ */
1118
+ declare function UseFilters(...filters: FilterType[]): (target: Constructor | object, propertyKey?: string | symbol) => void;
1119
+
1120
+ /**
1121
+ * Decorator that applies guards to a controller class or method
1122
+ * Guards determine whether a request should be handled by the route handler
1123
+ * @param guards - Array of guards to apply
1124
+ * @returns A decorator function that can be used at class or method level
1125
+ */
1126
+ declare function UseGuards(...guards: GuardType[]): (target: Constructor | object, propertyKey?: string | symbol) => void;
1127
+
1128
+ /**
1129
+ * Decorator that applies middleware to a controller class or method
1130
+ * Middleware functions run before the route handler and can modify the request/response
1131
+ * @param middleware - Array of middleware functions to apply
1132
+ * @returns A decorator function that can be used at class or method level
1133
+ */
1134
+ declare function UseMiddleware(...middleware: MiddlewareType[]): (target: Constructor | object, propertyKey?: string | symbol) => void;
1135
+
1136
+ /**
1137
+ * Decorator that applies transformation pipes to a controller class or method
1138
+ * Pipes transform input data before it reaches the route handler
1139
+ * @param pipes - Array of pipes to apply
1140
+ * @returns A decorator function that can be used at class or method level
1141
+ */
1142
+ declare function UsePipes(...pipes: PipeType[]): (target: Constructor | object, propertyKey?: string | symbol) => void;
1143
+
1144
+ /**
1145
+ * Default logger that writes structured events to console.
1146
+ */
1147
+ declare class ConsoleLogger implements ILogger {
1148
+ emit(event: LogEvent): void;
1149
+ }
1150
+
1151
+ /**
1152
+ * Logger implementation that intentionally does nothing.
1153
+ */
1154
+ declare class NoopLogger implements ILogger {
1155
+ emit(_event: LogEvent): void;
1156
+ }
1157
+
1158
+ /**
1159
+ * Dependency Injection container that manages class instances and their dependencies
1160
+ */
1161
+ declare class Container implements DiContainer {
1162
+ private readonly serviceRegistry;
1163
+ private readonly logger;
1164
+ private readonly debugDi;
1165
+ constructor(serviceRegistry?: IServiceRegistry, logger?: ILogger, debugDi?: boolean);
1166
+ /**
1167
+ * Map of class constructors to their instances
1168
+ */
1169
+ private instances;
1170
+ private emitLog;
1171
+ /**
1172
+ * Resolves a class instance, creating it if necessary and injecting its dependencies
1173
+ * @param target - The class constructor to resolve
1174
+ * @returns An instance of the target class
1175
+ */
1176
+ resolve<T>(target: Constructor<T>): T;
1177
+ /**
1178
+ * Internal recursive resolver with circular dependency tracking
1179
+ */
1180
+ private resolveWithTracking;
1181
+ /**
1182
+ * Registers a pre-created instance for a class
1183
+ * @param target - The class constructor to register
1184
+ * @param instance - The instance to register
1185
+ */
1186
+ register<T>(target: Constructor<T>, instance: T): void;
1187
+ has<T>(target: Constructor<T>): boolean;
1188
+ clear(): void;
1189
+ }
1190
+
1191
+ interface FrameworkErrorOptions {
1192
+ status?: number;
1193
+ code: string;
1194
+ category: string;
1195
+ remediation?: string;
1196
+ details?: Record<string, unknown>;
1197
+ cause?: unknown;
1198
+ }
1199
+ /**
1200
+ * Structured framework-level error with machine-readable metadata.
1201
+ */
1202
+ declare class FrameworkError extends Error {
1203
+ readonly status?: number;
1204
+ readonly code: string;
1205
+ readonly category: string;
1206
+ readonly remediation?: string;
1207
+ readonly details?: Record<string, unknown>;
1208
+ constructor(message: string, options: FrameworkErrorOptions);
1209
+ }
1210
+
1211
+ /**
1212
+ * Handler for managing application-wide error responses
1213
+ * Provides a consistent way to handle and format error responses across the application
1214
+ */
1215
+ declare class ErrorHandler {
1216
+ /**
1217
+ * Creates a middleware function that handles error responses
1218
+ * @returns A middleware function that formats and returns error responses using createErrorResponse
1219
+ */
1220
+ static handle(): (err: unknown, c: Context$1) => Promise<Response & hono.TypedResponse<{
1221
+ status: number;
1222
+ message: string;
1223
+ timestamp: string;
1224
+ path: string;
1225
+ requestId?: string | undefined;
1226
+ code?: string | undefined;
1227
+ details?: {
1228
+ [x: string]: any;
1229
+ } | undefined;
1230
+ errors?: {
1231
+ property: string;
1232
+ constraints: {
1233
+ [x: string]: string;
1234
+ };
1235
+ }[] | undefined;
1236
+ }, -1 | 100 | 102 | 103 | 200 | 201 | 202 | 203 | 206 | 207 | 208 | 226 | 300 | 301 | 302 | 303 | 305 | 306 | 307 | 308 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511, "json">>;
1237
+ }
1238
+
1239
+ /**
1240
+ * Handler for managing 404 Not Found responses
1241
+ * Provides a consistent way to handle requests to non-existent routes
1242
+ */
1243
+ declare class NotFoundHandler {
1244
+ /**
1245
+ * Creates a middleware function that handles 404 Not Found responses
1246
+ * @returns A middleware function that returns a JSON response with a 404 status
1247
+ */
1248
+ static handle(): (c: Context$1) => Promise<Response & hono.TypedResponse<{
1249
+ message: string;
1250
+ }, 404, "json">>;
1251
+ }
1252
+
1253
+ /**
1254
+ * Creates a standardized error response object
1255
+ * @param exception - The error or exception object to process
1256
+ * @param context - The Hono context object containing request information
1257
+ * @param options - Optional configuration for the error response
1258
+ * @param options.status - HTTP status code to override the default
1259
+ * @param options.title - Custom error message to override the default
1260
+ * @param options.detail - Additional error details
1261
+ * @param options.code - Custom error code
1262
+ * @param options.additionalDetails - Extra information to include in the response
1263
+ * @returns Object containing the formatted error response and HTTP status code
1264
+ */
1265
+ declare function createErrorResponse(exception: unknown, context: Context$1, options?: {
1266
+ status?: number;
1267
+ title?: string;
1268
+ detail?: string;
1269
+ code?: string;
1270
+ additionalDetails?: Record<string, unknown>;
1271
+ }): {
1272
+ response: ErrorResponse;
1273
+ status: ContentfulStatusCode;
1274
+ };
1275
+
1276
+ /**
1277
+ * Creates a decorator factory for HTTP method handlers
1278
+ * @param method - The HTTP method type (GET, POST, PUT, etc.)
1279
+ * @returns A method decorator factory that accepts a path and options
1280
+ * @example
1281
+ * ```ts
1282
+ * const Get = createHttpMethodDecorator(HttpMethod.GET);
1283
+ *
1284
+ * class Controller {
1285
+ * @Get('/users')
1286
+ * getUsers() { }
1287
+ * }
1288
+ * ```
1289
+ */
1290
+ declare function createHttpMethodDecorator(method: string): (path?: string, options?: HttpMethodOptions) => MethodDecorator;
1291
+
1292
+ /**
1293
+ * Creates a parameter decorator factory for route handlers
1294
+ * @template T - The type of the parameter value after transformation
1295
+ * @param type - The type identifier for the parameter
1296
+ * @param factory - Optional function to transform the parameter value
1297
+ * @returns A parameter decorator function that registers parameter metadata
1298
+ * @example
1299
+ * ```ts
1300
+ * const Body = createParamDecorator('body', async (data, ctx) => {
1301
+ * const body = await ctx.req.json();
1302
+ * return data ? body[data] : body;
1303
+ * });
1304
+ * ```
1305
+ */
1306
+ declare function createParamDecorator<T = unknown>(type: string, factory?: (data: unknown, ctx: Context$1) => T | Promise<T>): (data?: unknown) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
1307
+
1308
+ /**
1309
+ * Options for creating a lightweight test module.
1310
+ */
1311
+ interface TestModuleOptions extends ModuleOptions {
1312
+ /**
1313
+ * Optional class name to improve diagnostics in test output.
1314
+ */
1315
+ name?: string;
1316
+ }
1317
+ /**
1318
+ * Options for creating a test application instance.
1319
+ */
1320
+ interface CreateTestApplicationOptions extends TestModuleOptions {
1321
+ /**
1322
+ * Existing module class to bootstrap.
1323
+ * If omitted, a module is created from controllers/services/imports.
1324
+ */
1325
+ module?: Constructor;
1326
+ /**
1327
+ * Honest application options passed to Application.create.
1328
+ */
1329
+ appOptions?: HonestOptions;
1330
+ }
1331
+ /**
1332
+ * Options for creating a test application around a single controller.
1333
+ */
1334
+ interface CreateControllerTestApplicationOptions extends Omit<TestModuleOptions, 'controllers'> {
1335
+ /**
1336
+ * Controller class to mount in the generated test module.
1337
+ */
1338
+ controller: Constructor;
1339
+ /**
1340
+ * Honest application options passed to Application.create.
1341
+ */
1342
+ appOptions?: HonestOptions;
1343
+ }
1344
+ /**
1345
+ * Result object returned by createTestApplication.
1346
+ */
1347
+ interface TestApplication {
1348
+ /**
1349
+ * Honest application instance.
1350
+ */
1351
+ app: Application;
1352
+ /**
1353
+ * Underlying Hono app.
1354
+ */
1355
+ hono: Hono;
1356
+ /**
1357
+ * Convenience request helper for tests.
1358
+ * Relative paths are resolved against http://localhost.
1359
+ */
1360
+ request: (input: string | Request, init?: RequestInit) => Promise<Response>;
1361
+ }
1362
+ /**
1363
+ * Override a service token with a pre-built test instance.
1364
+ */
1365
+ interface ServiceTestOverride<T = unknown> {
1366
+ provide: Constructor<T>;
1367
+ useValue: T;
1368
+ }
1369
+ /**
1370
+ * Options for creating a service-only test container.
1371
+ */
1372
+ interface CreateServiceTestContainerOptions {
1373
+ /**
1374
+ * Optional service overrides registered before any resolve calls.
1375
+ */
1376
+ overrides?: ServiceTestOverride[];
1377
+ /**
1378
+ * Optional services to resolve immediately so tests can assert warm startup state.
1379
+ */
1380
+ preload?: Constructor[];
1381
+ /**
1382
+ * Optional logger used when debugDi is enabled.
1383
+ */
1384
+ logger?: ILogger;
1385
+ /**
1386
+ * Enable DI diagnostics while resolving services.
1387
+ */
1388
+ debugDi?: boolean;
1389
+ }
1390
+ /**
1391
+ * Service-only test harness around the DI container.
1392
+ */
1393
+ interface TestServiceContainer {
1394
+ container: DiContainer;
1395
+ get<T>(target: Constructor<T>): T;
1396
+ register<T>(target: Constructor<T>, instance: T): void;
1397
+ has<T>(target: Constructor<T>): boolean;
1398
+ clear(): void;
1399
+ }
1400
+
1401
+ /**
1402
+ * Create a test-friendly application instance with a convenience request helper.
1403
+ */
1404
+ declare function createTestApplication(options?: CreateTestApplicationOptions): Promise<TestApplication>;
1405
+
1406
+ /**
1407
+ * Create a test application for a single controller with optional services/imports.
1408
+ */
1409
+ declare function createControllerTestApplication(options: CreateControllerTestApplicationOptions): Promise<TestApplication>;
1410
+
1411
+ /**
1412
+ * Create a lightweight DI container for service-only tests without HTTP bootstrap.
1413
+ */
1414
+ declare function createServiceTestContainer(options?: CreateServiceTestContainerOptions): TestServiceContainer;
1415
+
1416
+ /**
1417
+ * Create a runtime module class for tests without boilerplate.
1418
+ */
1419
+ declare function createTestingModule(options?: TestModuleOptions): Constructor;
1420
+
1421
+ /**
1422
+ * Type guard that checks if a value is undefined
1423
+ * @param obj - The value to check
1424
+ * @returns True if the value is undefined, false otherwise
1425
+ */
1426
+ declare const isUndefined: (obj: unknown) => obj is undefined;
1427
+ /**
1428
+ * Type guard that checks if a value is null or undefined
1429
+ * @param val - The value to check
1430
+ * @returns True if the value is null or undefined, false otherwise
1431
+ */
1432
+ declare const isNil: (val: unknown) => val is null | undefined;
1433
+ /**
1434
+ * Type guard that checks if a value is an object (excluding null)
1435
+ * @param val - The value to check
1436
+ * @returns True if the value is a non-null object, false otherwise
1437
+ */
1438
+ declare const isObject: (val: unknown) => val is Record<PropertyKey, unknown>;
1439
+ /**
1440
+ * Type guard that checks if a value is a plain object (not a class instance or array)
1441
+ * Determines if an object is a simple key-value store created by object literals
1442
+ *
1443
+ * @param val - The value to check
1444
+ * @returns True if the value is a plain object, false otherwise
1445
+ * @example
1446
+ * ```ts
1447
+ * isPlainObject({}) // true
1448
+ * isPlainObject(new Class()) // false
1449
+ * isPlainObject([]) // false
1450
+ * ```
1451
+ */
1452
+ declare const isPlainObject: (val: unknown) => val is Record<string, unknown>;
1453
+ /**
1454
+ * Type guard that checks if a value is a function
1455
+ * @param val - The value to check
1456
+ * @returns True if the value is a function, false otherwise
1457
+ */
1458
+ declare const isFunction: (val: unknown) => val is Function;
1459
+ /**
1460
+ * Type guard that checks if a value is a string
1461
+ * @param val - The value to check
1462
+ * @returns True if the value is a string, false otherwise
1463
+ */
1464
+ declare const isString: (val: unknown) => val is string;
1465
+ /**
1466
+ * Type guard that checks if a value is a number
1467
+ * @param val - The value to check
1468
+ * @returns True if the value is a number, false otherwise
1469
+ */
1470
+ declare const isNumber: (val: unknown) => val is number;
1471
+ /**
1472
+ * Checks if an array is empty
1473
+ * @param array - The array to check
1474
+ * @returns True if the array has no elements, false otherwise
1475
+ */
1476
+ declare const isEmpty: (array: unknown[]) => boolean;
1477
+ /**
1478
+ * Type guard that checks if a value is a symbol
1479
+ * @param val - The value to check
1480
+ * @returns True if the value is a symbol, false otherwise
1481
+ */
1482
+ declare const isSymbol: (val: unknown) => val is symbol;
1483
+ /**
1484
+ * Ensures a path starts with a leading slash
1485
+ * @param path - The path to process
1486
+ * @returns The path with a leading slash, or empty string if path is undefined
1487
+ * @example
1488
+ * ```ts
1489
+ * addLeadingSlash('test') // '/test'
1490
+ * addLeadingSlash('/test') // '/test'
1491
+ * ```
1492
+ */
1493
+ declare const addLeadingSlash: (path?: string) => string;
1494
+ /**
1495
+ * Normalizes a path by ensuring:
1496
+ * - Starts with a single slash
1497
+ * - No trailing slashes
1498
+ * - No consecutive slashes
1499
+ *
1500
+ * @param path - The path to normalize
1501
+ * @returns The normalized path
1502
+ * @example
1503
+ * ```ts
1504
+ * normalizePath('//test//') // '/test'
1505
+ * normalizePath('test/path//') // '/test/path'
1506
+ * ```
1507
+ */
1508
+ declare const normalizePath: (path?: string) => string;
1509
+ /**
1510
+ * Removes the trailing slash from a path
1511
+ * @param path - The path to process
1512
+ * @returns The path without a trailing slash
1513
+ * @example
1514
+ * ```ts
1515
+ * stripEndSlash('/test/') // '/test'
1516
+ * stripEndSlash('/test') // '/test'
1517
+ * ```
1518
+ */
1519
+ declare const stripEndSlash: (path: string) => string;
1520
+ /**
1521
+ * Checks if a value is a constructor function (callable with `new`).
1522
+ * A constructor function must:
1523
+ * - Be a function
1524
+ * - Have a non-null prototype (excludes arrow functions, which have no prototype)
1525
+ * - Have a prototype that is not a function (excludes rare edge cases)
1526
+ * - Have at least the built-in 'constructor' on prototype (so empty classes are constructors)
1527
+ *
1528
+ * @param val - The value to check
1529
+ * @returns True if the value is a constructor function, false otherwise
1530
+ * @example
1531
+ * ```ts
1532
+ * class Test {}
1533
+ * isConstructor(Test) // true
1534
+ * isConstructor(() => {}) // false
1535
+ * ```
1536
+ */
1537
+ declare const isConstructor: (val: unknown) => boolean;
1538
+
1539
+ export { All, Application, ApplicationContext, type ArgumentMetadata, Body, type ComponentInstance, type ComponentType, type ComponentTypeMap, ConsoleLogger, type Constructor, Container, Context, Controller, type ControllerOptions, type CreateControllerTestApplicationOptions, type CreateServiceTestContainerOptions, type CreateTestApplicationOptions, Ctx, Delete, type DiContainer, ErrorHandler, type ErrorResponse, type FilterType, FrameworkError, type FrameworkErrorOptions, Get, type GuardType, HONEST_PIPELINE_BODY_CACHE_KEY, HONEST_PIPELINE_CONTROLLER_KEY, HONEST_PIPELINE_HANDLER_KEY, type HandlerInvocationInput, Header, type HonestOptions, type HtmlAttributes, type HttpMethodOptions, type IApplicationContext, type IFilter, type IGuard, type ILogger, type IMetadataRepository, type IMiddleware, type IPipe, type IPlugin, type IServiceRegistry, Layout, type LogCategory, type LogEvent, type LogLevel, type MetaTag, type MetadataComponentType, type MetadataComponentTypeMap, MetadataRegistry, MetadataRepository, type MiddlewareType, Module, type ModuleOptions, MvcModule, NoopLogger, NotFoundHandler, Options, Page, Param, type ParameterMetadata, type ParameterResolutionInput, Patch, type PipeType, type PipelineContextValues, type PluginEntry, type PluginEntryObject, type PluginMeta, type PluginProcessor, type PluginType, Post, Put, Query, Req, Request$1 as Request, Res, Response$1 as Response, type RouteDefinition, type RouteInfo, RouteRegistry, Service, type ServiceTestOverride, type SiteData, StaticServiceRegistry, type TestApplication, type TestModuleOptions, type TestServiceContainer, UseComponent, UseFilters, UseGuards, UseMiddleware, UsePipes, VERSION_NEUTRAL, Var, Variable, View, addLeadingSlash, createControllerTestApplication, createErrorResponse, createHttpMethodDecorator, createParamDecorator, createServiceTestContainer, createTestApplication, createTestingModule, isConstructor, isEmpty, isFunction, isNil, isNumber, isObject, isPlainObject, isString, isSymbol, isUndefined, normalizePath, stripEndSlash };