@kozojs/core 0.3.1 → 0.3.3

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/lib/index.d.ts ADDED
@@ -0,0 +1,657 @@
1
+ import * as hono from 'hono';
2
+ import { Context } from 'hono';
3
+ import { Hono } from 'hono/quick';
4
+ import { IncomingMessage, ServerResponse, Server } from 'node:http';
5
+ import { z } from 'zod';
6
+ export { z } from 'zod';
7
+ import { TSchema, Static } from '@sinclair/typebox';
8
+ export { CorsOptions, FileSystemRoutingOptions, HttpBadRequestError, HttpConflictError, HttpError, HttpForbiddenError, HttpInternalServerError, HttpNotFoundError, HttpUnauthorizedError, LoggerOptions, ManifestHttpMethod, ManifestRoute, RateLimitOptions, RoutesManifest, applyFileSystemRouting, clearRateLimitStore, cors, createFileSystemRouting, errorHandler, logger, rateLimit } from './middleware/index.js';
9
+
10
+ type SchemaType = z.ZodType<any> | TSchema;
11
+ type RouteSchema = {
12
+ body?: SchemaType;
13
+ query?: SchemaType;
14
+ params?: SchemaType;
15
+ response?: SchemaType | Record<number, SchemaType>;
16
+ };
17
+ type InferSchema<T> = T extends z.ZodType<any> ? z.infer<T> : T extends TSchema ? Static<T> : unknown;
18
+ /** Infer the response data type from a schema's response field */
19
+ type InferResponse<T> = T extends SchemaType ? InferSchema<T> : T extends Record<number, SchemaType> ? InferSchema<T[200]> : unknown;
20
+ type KozoContext<S extends RouteSchema = {}, TServices extends Services = Services> = {
21
+ services: TServices;
22
+ body: InferSchema<S['body']>;
23
+ query: InferSchema<S['query']>;
24
+ params: InferSchema<S['params']>;
25
+ req: any;
26
+ json: (data: any) => Response;
27
+ text: (data: string, status?: number, headers?: any) => Response;
28
+ };
29
+ type KozoHandler<S extends RouteSchema = {}, TServices extends Services = Services> = (ctx: KozoContext<S, TServices>) => any | Promise<any>;
30
+ interface Services {
31
+ [key: string]: unknown;
32
+ }
33
+ interface KozoEnv {
34
+ Variables: {
35
+ services: Services;
36
+ user?: unknown;
37
+ };
38
+ }
39
+ /**
40
+ * Context object passed to native route handlers (used with `nativeListen`).
41
+ *
42
+ * Offers the same type inference as `KozoContext` but operates directly on
43
+ * Node.js primitives — no Hono adapter, no Web API Request/Response.
44
+ *
45
+ * @typeParam S - Route schema (body, query, params, response)
46
+ * @typeParam TSvc - Services type (injected at constructor)
47
+ */
48
+ interface NativeKozoContext<S extends RouteSchema = {}, TSvc extends Services = Services> {
49
+ /** Raw Node.js incoming request */
50
+ readonly req: IncomingMessage;
51
+ /** Raw Node.js server response */
52
+ readonly res: ServerResponse;
53
+ /** Route parameters — typed from schema.params */
54
+ readonly params: InferSchema<S['params']>;
55
+ /** Parsed query string — typed from schema.query */
56
+ readonly query: InferSchema<S['query']>;
57
+ /** Parsed request body — typed from schema.body */
58
+ readonly body: InferSchema<S['body']>;
59
+ /** Injected services — typed from Kozo<TServices> */
60
+ readonly services: TSvc;
61
+ /** Send a JSON response (default status 200). Uses fast-json-stringify if schema.response is defined. */
62
+ json(data: InferResponse<S['response']>, status?: number): void;
63
+ /** Send a plain text response. */
64
+ text(data: string, status?: number): void;
65
+ /** Send an HTML response (SSR page rendering). */
66
+ html(data: string, status?: number): void;
67
+ /** Set a response header. Returns `this` for chaining. */
68
+ header(name: string, value: string): this;
69
+ /** Redirect to another URL (default 302). */
70
+ redirect(url: string, status?: number): void;
71
+ }
72
+ /**
73
+ * Handler function type for native routes (used with `nativeListen`).
74
+ *
75
+ * @typeParam S - Route schema
76
+ * @typeParam TSvc - Services shape
77
+ */
78
+ type NativeKozoHandler<S extends RouteSchema = {}, TSvc extends Services = Services> = (ctx: NativeKozoContext<S, TSvc>) => void | Promise<void>;
79
+ interface HandlerContext<TBody = unknown, TParams extends Record<string, string> = Record<string, string>, TQuery extends Record<string, string> = Record<string, string>> {
80
+ body: TBody;
81
+ params: TParams;
82
+ query: TQuery;
83
+ headers: Record<string, string>;
84
+ services: Services;
85
+ user?: unknown;
86
+ c: any;
87
+ }
88
+ type RouteHandler<TBody = unknown> = (ctx: HandlerContext<TBody>) => Promise<unknown> | unknown;
89
+ interface RouteMeta {
90
+ summary?: string;
91
+ description?: string;
92
+ tags?: string[];
93
+ auth?: boolean;
94
+ rateLimit?: {
95
+ max: number;
96
+ window: number;
97
+ };
98
+ }
99
+ interface RouteModule {
100
+ default: RouteHandler;
101
+ schema?: RouteSchema;
102
+ meta?: RouteMeta;
103
+ middleware?: Array<(ctx: HandlerContext) => Promise<void> | void>;
104
+ }
105
+ type HttpMethod = 'get' | 'post' | 'put' | 'patch' | 'delete';
106
+ interface RouteDefinition {
107
+ path: string;
108
+ method: HttpMethod;
109
+ filePath: string;
110
+ module: RouteModule;
111
+ }
112
+ interface OpenAPIConfigRef {
113
+ info: {
114
+ title: string;
115
+ version: string;
116
+ description?: string;
117
+ };
118
+ servers?: Array<{
119
+ url: string;
120
+ description?: string;
121
+ }>;
122
+ tags?: Array<{
123
+ name: string;
124
+ description?: string;
125
+ }>;
126
+ }
127
+ interface KozoConfig<TServices extends Services = Services> {
128
+ routesDir?: string;
129
+ services?: TServices;
130
+ port?: number;
131
+ mode?: 'safe' | 'turbo';
132
+ runtime?: 'node' | 'bun';
133
+ target?: 'node' | 'edge' | 'cloudflare' | 'vercel' | 'netlify';
134
+ monitoring?: {
135
+ enable: boolean;
136
+ metrics: ('req/sec' | 'latency' | 'errors')[];
137
+ port?: number;
138
+ };
139
+ basePath?: string;
140
+ openapi?: OpenAPIConfigRef;
141
+ onError?: (error: Error, ctx: any) => any;
142
+ onNotFound?: (ctx: any) => any;
143
+ }
144
+
145
+ /**
146
+ * Client Generator Options
147
+ */
148
+ interface ClientGeneratorOptions {
149
+ /** Include Zod schemas for client-side validation (default: true) */
150
+ includeValidation?: boolean;
151
+ /** Base URL for the API (default: '') */
152
+ baseUrl?: string;
153
+ /** Enable runtime validation by default (default: false) */
154
+ validateByDefault?: boolean;
155
+ /** Custom headers to include in all requests */
156
+ defaultHeaders?: Record<string, string>;
157
+ }
158
+ /**
159
+ * Route information for client generation
160
+ */
161
+ interface RouteInfo {
162
+ method: string;
163
+ path: string;
164
+ schema: RouteSchema;
165
+ /** Optional: store the Zod schema instance for type extraction */
166
+ zodSchemas?: {
167
+ body?: any;
168
+ query?: any;
169
+ params?: any;
170
+ response?: any;
171
+ };
172
+ }
173
+ /**
174
+ * Generate typed client code from routes
175
+ */
176
+ declare function generateTypedClient(routes: RouteInfo[], options?: ClientGeneratorOptions): string;
177
+
178
+ type DatabaseProvider = 'postgresql' | 'mysql' | 'sqlite';
179
+ type DatabaseInstance = Record<string, unknown>;
180
+ /**
181
+ * Shutdown configuration options
182
+ */
183
+ interface ShutdownOptions {
184
+ /** Maximum time to wait for in-flight requests to complete (default: 30000ms) */
185
+ timeoutMs?: number;
186
+ /** Callback fired when shutdown starts */
187
+ onShutdownStart?: (inflightCount: number) => void;
188
+ /** Callback fired when all requests complete before timeout */
189
+ onShutdownComplete?: () => void;
190
+ /** Callback fired when shutdown times out */
191
+ onShutdownTimeout?: (remainingInflight: number) => void;
192
+ /** Database instance to close (optional) */
193
+ database?: DatabaseInstance;
194
+ /** Database provider type (required if database is provided) */
195
+ databaseProvider?: DatabaseProvider;
196
+ }
197
+ /**
198
+ * Internal state for tracking in-flight requests
199
+ */
200
+ interface InflightTracker {
201
+ count: number;
202
+ requests: Set<Promise<unknown>>;
203
+ }
204
+ /**
205
+ * Create an in-flight request tracker
206
+ */
207
+ declare function createInflightTracker(): InflightTracker;
208
+ /**
209
+ * Track a request - call at the start of each request
210
+ */
211
+ declare function trackRequest(tracker: InflightTracker): () => void;
212
+ /**
213
+ * Shutdown state machine
214
+ */
215
+ type ShutdownState = 'running' | 'shutting-down' | 'shutdown';
216
+ /**
217
+ * Graceful shutdown manager
218
+ */
219
+ declare class ShutdownManager {
220
+ private state;
221
+ private abortController;
222
+ private server;
223
+ private tracker;
224
+ private database;
225
+ private databaseProvider;
226
+ constructor();
227
+ /**
228
+ * Get current shutdown state
229
+ */
230
+ getState(): ShutdownState;
231
+ /**
232
+ * Check if server is shutting down
233
+ */
234
+ isShuttingDown(): boolean;
235
+ /**
236
+ * Get current in-flight request count
237
+ */
238
+ getInflightCount(): number;
239
+ /**
240
+ * Set the server instance for shutdown
241
+ */
242
+ setServer(server: Server): void;
243
+ /**
244
+ * Set database for cleanup
245
+ */
246
+ setDatabase(db: DatabaseInstance, provider: DatabaseProvider): void;
247
+ /**
248
+ * Get the AbortController signal for request cancellation
249
+ */
250
+ getAbortSignal(): AbortSignal | undefined;
251
+ /**
252
+ * Create a request tracker middleware
253
+ * Returns an untrack function to call when request completes
254
+ */
255
+ trackRequest(): () => void;
256
+ /**
257
+ * Initiate graceful shutdown
258
+ */
259
+ shutdown(options?: ShutdownOptions): Promise<void>;
260
+ /**
261
+ * Wait for all in-flight requests to complete
262
+ */
263
+ private drainRequests;
264
+ /**
265
+ * Close database connections based on provider
266
+ */
267
+ private closeDatabase;
268
+ }
269
+ /**
270
+ * Create a shutdown manager instance
271
+ */
272
+ declare function createShutdownManager(): ShutdownManager;
273
+
274
+ interface Plugin {
275
+ name: string;
276
+ version?: string;
277
+ install: (app: Kozo) => void | Promise<void>;
278
+ }
279
+ /**
280
+ * Kozo - High-performance TypeScript framework with Zod schemas
281
+ *
282
+ * @typeParam TServices - Shape of the services object injected into every handler.
283
+ * Pass it once at construction: `createKozo<{ db: Database }>({ services: { db } })`
284
+ * and all handler contexts will have `ctx.services.db` fully typed.
285
+ */
286
+ declare class Kozo<TServices extends Services = Services> {
287
+ private app;
288
+ private services;
289
+ private routes;
290
+ /** Routes registered directly with the uWS C++ radix router. */
291
+ private uwsRoutes;
292
+ private shutdownManager;
293
+ private _routesDir?;
294
+ constructor(config?: KozoConfig<TServices>);
295
+ use(plugin: Plugin): this;
296
+ /**
297
+ * Load routes from the file system using the configured routesDir.
298
+ * Each route file is dynamically imported, its schema compiled, and handler registered.
299
+ * This is a no-op if routesDir is not configured.
300
+ */
301
+ loadRoutes(routesDir?: string): Promise<this>;
302
+ generateClient(baseUrl?: string): string;
303
+ generateClient(options?: ClientGeneratorOptions): string;
304
+ get<S extends RouteSchema>(path: string, schema: S, handler: KozoHandler<S, TServices>): this;
305
+ post<S extends RouteSchema>(path: string, schema: S, handler: KozoHandler<S, TServices>): this;
306
+ put<S extends RouteSchema>(path: string, schema: S, handler: KozoHandler<S, TServices>): this;
307
+ patch<S extends RouteSchema>(path: string, schema: S, handler: KozoHandler<S, TServices>): this;
308
+ delete<S extends RouteSchema>(path: string, schema: S, handler: KozoHandler<S, TServices>): this;
309
+ private register;
310
+ /**
311
+ * Start a uWebSockets.js HTTP server.
312
+ *
313
+ * All routes are registered directly with uWS's C++ radix trie router —
314
+ * zero JS routing overhead per request. The C++ HTTP parser (µHttpParser)
315
+ * eliminates all IncomingMessage/ServerResponse allocations.
316
+ *
317
+ * Throws if uWebSockets.js is not installed.
318
+ * Returns { port, server } so callers can close the server when done.
319
+ */
320
+ nativeListen(port?: number): Promise<{
321
+ port: number;
322
+ server: Server;
323
+ }>;
324
+ listen(port?: number): Promise<void>;
325
+ /**
326
+ * Graceful shutdown — drains in-flight requests before closing.
327
+ * Use getShutdownManager().setDatabase(db, provider) to register DB cleanup.
328
+ */
329
+ shutdown(options?: ShutdownOptions): Promise<void>;
330
+ getShutdownManager(): ShutdownManager;
331
+ getApp(): Hono;
332
+ get fetch(): (request: Request, Env?: unknown, executionCtx?: hono.ExecutionContext) => Response | Promise<Response>;
333
+ }
334
+ declare function createKozo<TServices extends Services = Services>(config?: KozoConfig<TServices>): Kozo<TServices>;
335
+
336
+ type ZValidatorErrors = {
337
+ instancePath: string;
338
+ message: string;
339
+ }[];
340
+ type ZValidator = ((data: unknown) => boolean) & {
341
+ errors: ZValidatorErrors | null;
342
+ };
343
+ type CompiledHandler = (c: Context) => Promise<Response> | Response;
344
+ type UserHandler = (c: any) => any;
345
+ type CompiledRoute = {
346
+ validateBody?: ZValidator;
347
+ validateQuery?: ZValidator;
348
+ validateParams?: ZValidator;
349
+ serialize?: (data: any) => string;
350
+ };
351
+ declare class SchemaCompiler {
352
+ static compile(schema: RouteSchema): CompiledRoute;
353
+ }
354
+ declare function compileRouteHandler(handler: UserHandler, schema: RouteSchema, services: Services, compiled: CompiledRoute): CompiledHandler;
355
+
356
+ /**
357
+ * Build a NativeKozoContext for a native route handler.
358
+ *
359
+ * Called by the native handler compiler (`compiler.ts`) when the route
360
+ * is registered via `nativeRoute()`. Not intended for direct use.
361
+ *
362
+ * @internal
363
+ */
364
+ declare function buildNativeContext<S extends RouteSchema, TSvc extends Services>(req: IncomingMessage, res: ServerResponse, params: Record<string, string>, body: any, services: TSvc, serialize?: (data: any) => string): NativeKozoContext<S, TSvc>;
365
+
366
+ /** Fast number → string for Content-Length. Cached for values < 10 000. */
367
+ declare function fastCL(n: number): string;
368
+ /**
369
+ * Write a 200 JSON response.
370
+ *
371
+ * IMPORTANT: `body` MUST be ASCII-safe (i.e. produced by JSON.stringify
372
+ * or fast-json-stringify). We use `body.length` instead of
373
+ * `Buffer.byteLength(body)` — valid because JSON serializers escape
374
+ * non-ASCII to `\uXXXX`, keeping the output 7-bit clean.
375
+ */
376
+ declare function fastWriteJson(res: ServerResponse, body: string): void;
377
+ /**
378
+ * Write a plain text response.
379
+ */
380
+ declare function fastWriteText(res: ServerResponse, body: string, status?: number): void;
381
+ /**
382
+ * Write an HTML response (SSR page rendering).
383
+ */
384
+ declare function fastWriteHtml(res: ServerResponse, body: string, status?: number): void;
385
+ /**
386
+ * Write a JSON response with a custom status code.
387
+ */
388
+ declare function fastWriteJsonStatus(res: ServerResponse, body: string, status: number): void;
389
+ /**
390
+ * Write a pre-built 404 Not Found response (zero allocation).
391
+ */
392
+ declare function fastWrite404(res: ServerResponse): void;
393
+ /**
394
+ * Write a pre-built 500 Internal Server Error response (zero allocation).
395
+ */
396
+ declare function fastWrite500(res: ServerResponse): void;
397
+ /**
398
+ * Write a 400 validation error response.
399
+ * Allocates only the error body string.
400
+ */
401
+ declare function fastWrite400(field: string, errors: any, res: ServerResponse): void;
402
+ /**
403
+ * Write a KozoError as an RFC 7807 problem+json response.
404
+ * Falls back to 500 for unknown errors.
405
+ */
406
+ declare function fastWriteError(err: unknown, res: ServerResponse): void;
407
+
408
+ /**
409
+ * Kozo Error System - RFC 7807 Problem Details
410
+ *
411
+ * Standardized error format for all validation and runtime errors.
412
+ * Pre-serialized templates + frozen ResponseInit objects eliminate
413
+ * per-request allocations on the hot path.
414
+ *
415
+ * @see https://datatracker.ietf.org/doc/html/rfc7807
416
+ */
417
+ interface ValidationError {
418
+ field: string;
419
+ message: string;
420
+ code: string;
421
+ value?: unknown;
422
+ }
423
+ interface ProblemDetails {
424
+ type: string;
425
+ title: string;
426
+ status: number;
427
+ detail?: string;
428
+ instance?: string;
429
+ errors?: ValidationError[];
430
+ }
431
+ declare const ERROR_RESPONSES: {
432
+ readonly VALIDATION_FAILED: {
433
+ readonly type: "https://kozo.dev/errors/validation-failed";
434
+ readonly title: "Validation Failed";
435
+ readonly status: 400;
436
+ };
437
+ readonly INVALID_BODY: {
438
+ readonly type: "https://kozo.dev/errors/invalid-body";
439
+ readonly title: "Invalid Request Body";
440
+ readonly status: 400;
441
+ };
442
+ readonly INVALID_QUERY: {
443
+ readonly type: "https://kozo.dev/errors/invalid-query";
444
+ readonly title: "Invalid Query Parameters";
445
+ readonly status: 400;
446
+ };
447
+ readonly INVALID_PARAMS: {
448
+ readonly type: "https://kozo.dev/errors/invalid-params";
449
+ readonly title: "Invalid Path Parameters";
450
+ readonly status: 400;
451
+ };
452
+ readonly INTERNAL_ERROR: {
453
+ readonly type: "https://kozo.dev/errors/internal-error";
454
+ readonly title: "Internal Server Error";
455
+ readonly status: 500;
456
+ };
457
+ readonly NOT_FOUND: {
458
+ readonly type: "https://kozo.dev/errors/not-found";
459
+ readonly title: "Resource Not Found";
460
+ readonly status: 404;
461
+ };
462
+ readonly UNAUTHORIZED: {
463
+ readonly type: "https://kozo.dev/errors/unauthorized";
464
+ readonly title: "Unauthorized";
465
+ readonly status: 401;
466
+ };
467
+ readonly FORBIDDEN: {
468
+ readonly type: "https://kozo.dev/errors/forbidden";
469
+ readonly title: "Forbidden";
470
+ readonly status: 403;
471
+ };
472
+ };
473
+ /**
474
+ * Convert Ajv validation errors to standardized format
475
+ */
476
+ declare function formatAjvErrors(errors: any[] | null | undefined): ValidationError[];
477
+ /**
478
+ * Convert Zod validation errors to standardized format
479
+ */
480
+ declare function formatZodErrors(errors: any): ValidationError[];
481
+ /**
482
+ * Build a 400 Validation Failed response.
483
+ * Called on every invalid request — kept as lean as possible.
484
+ */
485
+ declare function validationErrorResponse(field: string, ajvErrors: any[] | null | undefined, instance?: string): Response;
486
+ /**
487
+ * Build a 500 Internal Server Error response.
488
+ */
489
+ declare function internalErrorResponse(err: Error, instance?: string): Response;
490
+ declare function notFoundResponse(instance?: string): Response;
491
+ declare function unauthorizedResponse(instance?: string): Response;
492
+ declare function forbiddenResponse(instance?: string): Response;
493
+ declare class KozoError extends Error {
494
+ readonly statusCode: number;
495
+ readonly code: string;
496
+ constructor(message: string, statusCode: number, code: string);
497
+ toResponse(instance?: string): Response;
498
+ }
499
+ declare class ValidationFailedError extends KozoError {
500
+ readonly errors: ValidationError[];
501
+ constructor(message: string, errors?: ValidationError[]);
502
+ toResponse(instance?: string): Response;
503
+ }
504
+ declare class NotFoundError extends KozoError {
505
+ constructor(message?: string);
506
+ }
507
+ declare class UnauthorizedError extends KozoError {
508
+ constructor(message?: string);
509
+ }
510
+ declare class ForbiddenError extends KozoError {
511
+ constructor(message?: string);
512
+ }
513
+
514
+ interface OpenAPIInfo {
515
+ title: string;
516
+ version: string;
517
+ description?: string;
518
+ contact?: {
519
+ name?: string;
520
+ url?: string;
521
+ email?: string;
522
+ };
523
+ license?: {
524
+ name: string;
525
+ url?: string;
526
+ };
527
+ }
528
+ interface OpenAPIConfig {
529
+ info: OpenAPIInfo;
530
+ servers?: Array<{
531
+ url: string;
532
+ description?: string;
533
+ }>;
534
+ tags?: Array<{
535
+ name: string;
536
+ description?: string;
537
+ }>;
538
+ security?: Array<Record<string, string[]>>;
539
+ }
540
+ interface OpenAPISpec {
541
+ openapi: '3.1.0';
542
+ info: OpenAPIInfo;
543
+ servers?: Array<{
544
+ url: string;
545
+ description?: string;
546
+ }>;
547
+ tags?: Array<{
548
+ name: string;
549
+ description?: string;
550
+ }>;
551
+ paths: Record<string, PathItem>;
552
+ components: {
553
+ schemas: Record<string, SchemaObject>;
554
+ securitySchemes?: Record<string, SecurityScheme>;
555
+ };
556
+ security?: Array<Record<string, string[]>>;
557
+ }
558
+ interface PathItem {
559
+ [method: string]: OperationObject;
560
+ }
561
+ interface OperationObject {
562
+ operationId?: string;
563
+ summary?: string;
564
+ description?: string;
565
+ tags?: string[];
566
+ parameters?: ParameterObject[];
567
+ requestBody?: RequestBodyObject;
568
+ responses: Record<string, ResponseObject>;
569
+ security?: Array<Record<string, string[]>>;
570
+ }
571
+ interface ParameterObject {
572
+ name: string;
573
+ in: 'query' | 'path' | 'header' | 'cookie';
574
+ required?: boolean;
575
+ schema: SchemaObject;
576
+ description?: string;
577
+ }
578
+ interface RequestBodyObject {
579
+ required?: boolean;
580
+ content: {
581
+ 'application/json': {
582
+ schema: SchemaObject;
583
+ };
584
+ };
585
+ }
586
+ interface ResponseObject {
587
+ description: string;
588
+ content?: {
589
+ 'application/json': {
590
+ schema: SchemaObject;
591
+ };
592
+ };
593
+ }
594
+ interface SchemaObject {
595
+ type?: string;
596
+ format?: string;
597
+ properties?: Record<string, SchemaObject>;
598
+ items?: SchemaObject;
599
+ required?: string[];
600
+ enum?: unknown[];
601
+ minimum?: number;
602
+ maximum?: number;
603
+ minLength?: number;
604
+ maxLength?: number;
605
+ pattern?: string;
606
+ description?: string;
607
+ default?: unknown;
608
+ nullable?: boolean;
609
+ oneOf?: SchemaObject[];
610
+ anyOf?: SchemaObject[];
611
+ allOf?: SchemaObject[];
612
+ additionalProperties?: SchemaObject | boolean;
613
+ $ref?: string;
614
+ }
615
+ interface SecurityScheme {
616
+ type: 'apiKey' | 'http' | 'oauth2' | 'openIdConnect';
617
+ scheme?: string;
618
+ bearerFormat?: string;
619
+ name?: string;
620
+ in?: 'query' | 'header' | 'cookie';
621
+ }
622
+ declare class OpenAPIGenerator {
623
+ private config;
624
+ private schemas;
625
+ private schemaCounter;
626
+ constructor(config: OpenAPIConfig);
627
+ /**
628
+ * Generate OpenAPI spec from routes
629
+ */
630
+ generate(routes: RouteDefinition[]): OpenAPISpec;
631
+ /**
632
+ * Convert Hono path params to OpenAPI format
633
+ * :id -> {id}
634
+ */
635
+ private honoPathToOpenApi;
636
+ /**
637
+ * Convert route to OpenAPI operation
638
+ */
639
+ private routeToOperation;
640
+ /**
641
+ * Generate operation ID from path and method
642
+ */
643
+ private generateOperationId;
644
+ /**
645
+ * Extract tag from path (first segment)
646
+ */
647
+ private extractTag;
648
+ /**
649
+ * Get HTTP status description
650
+ */
651
+ private getStatusDescription;
652
+ private capitalize;
653
+ }
654
+ declare function generateSwaggerHtml(specUrl: string, title?: string): string;
655
+ declare function createOpenAPIGenerator(config: OpenAPIConfig): OpenAPIGenerator;
656
+
657
+ export { type ClientGeneratorOptions, type CompiledRoute, ERROR_RESPONSES, ForbiddenError, type InferResponse, type InferSchema, type InflightTracker, Kozo, type KozoConfig, type KozoContext, type KozoEnv, KozoError, type KozoHandler, type NativeKozoContext, type NativeKozoHandler, NotFoundError, type OpenAPIConfig, OpenAPIGenerator, type OpenAPIInfo, type OpenAPISpec, type ProblemDetails, type RouteInfo, type RouteSchema, SchemaCompiler, type Services, ShutdownManager, type ShutdownOptions, type ShutdownState, UnauthorizedError, type ValidationError, ValidationFailedError, buildNativeContext, compileRouteHandler, createInflightTracker, createKozo, createOpenAPIGenerator, createShutdownManager, fastCL, fastWrite400, fastWrite404, fastWrite500, fastWriteError, fastWriteHtml, fastWriteJson, fastWriteJsonStatus, fastWriteText, forbiddenResponse, formatAjvErrors, formatZodErrors, generateSwaggerHtml, generateTypedClient, internalErrorResponse, notFoundResponse, trackRequest, unauthorizedResponse, validationErrorResponse };