@guren/server 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{McpServiceProvider-7BB5FPF3.js → McpServiceProvider-GRDYNEQG.js} +1 -1
- package/dist/auth/AuthManager.d.ts +30 -0
- package/dist/auth/AuthenticatableModel.d.ts +25 -0
- package/dist/auth/RequestAuthContext.d.ts +24 -0
- package/dist/auth/SessionGuard.d.ts +31 -0
- package/dist/auth/api-token.d.ts +299 -0
- package/dist/auth/email-verification.d.ts +203 -0
- package/dist/auth/index.d.ts +18 -110
- package/dist/auth/index.js +3 -1
- package/dist/auth/oauth/index.d.ts +239 -0
- package/dist/auth/password/DefaultHasher.d.ts +13 -0
- package/dist/auth/password/NodeHasher.d.ts +22 -0
- package/dist/auth/password/PasswordHasher.d.ts +5 -0
- package/dist/auth/password/ScryptHasher.d.ts +26 -0
- package/dist/auth/password-reset.d.ts +91 -0
- package/dist/auth/providers/ModelUserProvider.d.ts +36 -0
- package/dist/auth/providers/UserProvider.d.ts +9 -0
- package/dist/auth/types.d.ts +102 -0
- package/dist/auth/utils.d.ts +39 -0
- package/dist/{Gate-CynjZCtS.d.ts → authorization/Gate.d.ts} +30 -111
- package/dist/authorization/Policy.d.ts +77 -0
- package/dist/authorization/index.d.ts +5 -129
- package/dist/authorization/index.js +3 -1
- package/dist/authorization/middleware.d.ts +49 -0
- package/dist/authorization/types.d.ts +108 -0
- package/dist/broadcasting/BroadcastManager.d.ts +205 -0
- package/dist/broadcasting/channels/Channel.d.ts +28 -0
- package/dist/broadcasting/channels/PresenceChannel.d.ts +72 -0
- package/dist/broadcasting/channels/PrivateChannel.d.ts +32 -0
- package/dist/broadcasting/channels/index.d.ts +3 -0
- package/dist/broadcasting/drivers/MemoryDriver.d.ts +93 -0
- package/dist/broadcasting/drivers/RedisDriver.d.ts +112 -0
- package/dist/broadcasting/drivers/index.d.ts +2 -0
- package/dist/broadcasting/index.d.ts +6 -233
- package/dist/broadcasting/index.js +1 -1
- package/dist/broadcasting/typed.d.ts +23 -0
- package/dist/broadcasting/types.d.ts +155 -0
- package/dist/cache/CacheManager.d.ts +87 -0
- package/dist/cache/TaggedCache.d.ts +62 -0
- package/dist/cache/index.d.ts +6 -233
- package/dist/cache/index.js +1 -1
- package/dist/cache/stores/FileStore.d.ts +64 -0
- package/dist/cache/stores/MemoryStore.d.ts +52 -0
- package/dist/cache/stores/RedisStore.d.ts +53 -0
- package/dist/{CacheManager-BmDzUKrF.d.ts → cache/types.d.ts} +26 -99
- package/dist/{chunk-TVY72CLV.js → chunk-4VE3LYOM.js} +3 -2
- package/dist/{chunk-FZD2AKJI.js → chunk-7OB2YXRE.js} +56 -28
- package/dist/{chunk-HONCNQXZ.js → chunk-BUQXOZCT.js} +97 -10
- package/dist/{chunk-DSDX3ASM.js → chunk-CDZUNKI6.js} +65 -83
- package/dist/{chunk-CWI4AJ47.js → chunk-HPET6XY5.js} +13 -9
- package/dist/{chunk-A3ISJVEV.js → chunk-HR2KZ3WL.js} +23 -5
- package/dist/{chunk-EARA7JM4.js → chunk-PZKUDFMW.js} +11 -8
- package/dist/console/Command.d.ts +179 -0
- package/dist/{ConsoleKernel-CJg975mp.d.ts → console/ConsoleKernel.d.ts} +4 -6
- package/dist/console/Input.d.ts +140 -0
- package/dist/console/Output.d.ts +161 -0
- package/dist/console/index.d.ts +5 -0
- package/dist/console/types.d.ts +106 -0
- package/dist/container/Container.d.ts +148 -0
- package/dist/container/ServiceProvider.d.ts +103 -0
- package/dist/container/bindings.d.ts +55 -0
- package/dist/container/defineModule.d.ts +88 -0
- package/dist/container/definePlugin.d.ts +62 -0
- package/dist/container/index.d.ts +8 -0
- package/dist/container/types.d.ts +73 -0
- package/dist/database/Factory.d.ts +82 -0
- package/dist/database/Seeder.d.ts +35 -0
- package/dist/database/SeederRunner.d.ts +41 -0
- package/dist/database/index.d.ts +4 -0
- package/dist/database/types.d.ts +49 -0
- package/dist/discovery/AutoDiscovery.d.ts +113 -0
- package/dist/discovery/index.d.ts +2 -0
- package/dist/docs-viewer/DocsViewerServiceProvider.d.ts +12 -0
- package/dist/docs-viewer/endpoint.d.ts +19 -0
- package/dist/encryption/Encrypter.d.ts +96 -0
- package/dist/encryption/Hash.d.ts +69 -0
- package/dist/encryption/MessageSigner.d.ts +21 -0
- package/dist/encryption/Random.d.ts +119 -0
- package/dist/encryption/app-key.d.ts +12 -0
- package/dist/encryption/index.d.ts +10 -222
- package/dist/encryption/signed-url.d.ts +9 -0
- package/dist/encryption/types.d.ts +103 -0
- package/dist/errors/ExceptionHandler.d.ts +118 -0
- package/dist/errors/HttpException.d.ts +106 -0
- package/dist/errors/debug-page.d.ts +22 -0
- package/dist/errors/error-page.d.ts +1 -0
- package/dist/errors/exceptions/AuthenticationException.d.ts +32 -0
- package/dist/errors/exceptions/AuthorizationException.d.ts +32 -0
- package/dist/errors/exceptions/MethodNotAllowedException.d.ts +31 -0
- package/dist/errors/exceptions/NotFoundHttpException.d.ts +36 -0
- package/dist/errors/exceptions/ValidationException.d.ts +60 -0
- package/dist/errors/exceptions/index.d.ts +5 -0
- package/dist/errors/index.d.ts +5 -0
- package/dist/errors/types.d.ts +43 -0
- package/dist/events/Event.d.ts +33 -0
- package/dist/{EventManager-CmIoLt7r.d.ts → events/EventManager.d.ts} +4 -86
- package/dist/events/Listener.d.ts +79 -0
- package/dist/events/builtin.d.ts +73 -0
- package/dist/events/index.d.ts +6 -155
- package/dist/events/types.d.ts +48 -0
- package/dist/facades/index.d.ts +31 -0
- package/dist/health/HealthCheck.d.ts +34 -0
- package/dist/health/HealthManager.d.ts +53 -0
- package/dist/health/checks/CacheCheck.d.ts +35 -0
- package/dist/health/checks/CustomCheck.d.ts +23 -0
- package/dist/health/checks/DatabaseCheck.d.ts +33 -0
- package/dist/health/checks/MemoryCheck.d.ts +32 -0
- package/dist/health/checks/RedisCheck.d.ts +27 -0
- package/dist/health/checks/StorageCheck.d.ts +35 -0
- package/dist/health/checks/index.d.ts +12 -0
- package/dist/health/index.d.ts +5 -185
- package/dist/health/types.d.ts +52 -0
- package/dist/hot-reload/hot-disposables.d.ts +96 -0
- package/dist/hot-reload/testing.d.ts +14 -0
- package/dist/http/Application.d.ts +187 -0
- package/dist/http/FormRequest.d.ts +73 -0
- package/dist/http/dev-assets.d.ts +51 -0
- package/dist/http/dev-banner.d.ts +7 -0
- package/dist/http/inertia-assets.d.ts +22 -0
- package/dist/http/middleware/auth.d.ts +13 -0
- package/dist/http/middleware/capabilities.d.ts +22 -0
- package/dist/http/middleware/cors.d.ts +40 -0
- package/dist/http/middleware/csp.d.ts +59 -0
- package/dist/http/middleware/csrf.d.ts +121 -0
- package/dist/http/middleware/detect-locale.d.ts +65 -0
- package/dist/http/middleware/force-https.d.ts +34 -0
- package/dist/http/middleware/host-authorization.d.ts +24 -0
- package/dist/http/middleware/index.d.ts +19 -0
- package/dist/http/middleware/loopback-guard.d.ts +38 -0
- package/dist/{rate-limit-D9J2b4S1.d.ts → http/middleware/rate-limit.d.ts} +22 -50
- package/dist/http/middleware/redirect-safety.d.ts +29 -0
- package/dist/http/middleware/request-id.d.ts +19 -0
- package/dist/http/middleware/request-logging.d.ts +16 -0
- package/dist/http/middleware/security-headers.d.ts +49 -0
- package/dist/http/middleware/session.d.ts +93 -0
- package/dist/http/middleware/validation.d.ts +94 -0
- package/dist/http/public-assets.d.ts +15 -0
- package/dist/http/request.d.ts +24 -0
- package/dist/http/resources/CursorPaginator.d.ts +106 -0
- package/dist/http/resources/Paginator.d.ts +130 -0
- package/dist/http/resources/Resource.d.ts +67 -0
- package/dist/http/resources/ResourceCollection.d.ts +60 -0
- package/dist/http/resources/index.d.ts +6 -0
- package/dist/http/resources/types.d.ts +91 -0
- package/dist/http/validation/Validator.d.ts +128 -0
- package/dist/http/validation/index.d.ts +3 -0
- package/dist/http/validation/rules.d.ts +196 -0
- package/dist/http/validation/types.d.ts +96 -0
- package/dist/http/vite-dev-server.d.ts +27 -0
- package/dist/i18n/I18nManager.d.ts +114 -0
- package/dist/i18n/Translator.d.ts +80 -0
- package/dist/i18n/index.d.ts +6 -101
- package/dist/i18n/index.js +5 -3
- package/dist/i18n/loaders/JsonLoader.d.ts +47 -0
- package/dist/i18n/loaders/MemoryLoader.d.ts +37 -0
- package/dist/i18n/pluralization.d.ts +19 -0
- package/dist/i18n/types.d.ts +106 -0
- package/dist/index.d.ts +69 -2605
- package/dist/index.js +332 -152
- package/dist/lambda/index.d.ts +17 -37
- package/dist/logging/LogManager.d.ts +83 -0
- package/dist/logging/Logger.d.ts +76 -0
- package/dist/logging/channels/ConsoleChannel.d.ts +11 -0
- package/dist/logging/channels/DailyFileChannel.d.ts +20 -0
- package/dist/logging/channels/FileChannel.d.ts +15 -0
- package/dist/logging/index.d.ts +8 -50
- package/dist/logging/types.d.ts +96 -0
- package/dist/mail/Mail.d.ts +138 -0
- package/dist/mail/MailManager.d.ts +79 -0
- package/dist/mail/address.d.ts +8 -0
- package/dist/mail/index.d.ts +7 -316
- package/dist/mail/transports/LogTransport.d.ts +19 -0
- package/dist/mail/transports/MemoryTransport.d.ts +84 -0
- package/dist/mail/transports/ResendTransport.d.ts +32 -0
- package/dist/mail/transports/SmtpTransport.d.ts +40 -0
- package/dist/{MailManager-DpMvYiP9.d.ts → mail/types.d.ts} +11 -92
- package/dist/mcp/McpServiceProvider.d.ts +17 -0
- package/dist/mcp/create-mcp-server.d.ts +144 -0
- package/dist/mcp/endpoint.d.ts +29 -0
- package/dist/mcp/index.d.ts +3 -185
- package/dist/mcp/index.js +1 -1
- package/dist/mvc/Controller.d.ts +326 -0
- package/dist/mvc/Router.d.ts +239 -0
- package/dist/mvc/ViewEngine.d.ts +11 -0
- package/dist/mvc/inertia/InertiaEngine.d.ts +114 -0
- package/dist/mvc/inertia/shared.d.ts +90 -0
- package/dist/mvc/mount-route.d.ts +10 -0
- package/dist/notifications/Notification.d.ts +99 -0
- package/dist/notifications/NotificationManager.d.ts +150 -0
- package/dist/notifications/channels/DatabaseChannel.d.ts +55 -0
- package/dist/notifications/channels/MailChannel.d.ts +45 -0
- package/dist/notifications/channels/MemoryChannel.d.ts +85 -0
- package/dist/notifications/channels/SlackChannel.d.ts +73 -0
- package/dist/notifications/channels/index.d.ts +4 -0
- package/dist/notifications/index.d.ts +6 -322
- package/dist/notifications/notifiable-type.d.ts +10 -0
- package/dist/notifications/registry.d.ts +39 -0
- package/dist/notifications/types.d.ts +162 -0
- package/dist/providers/AuthServiceProvider.d.ts +7 -0
- package/dist/providers/AuthorizationServiceProvider.d.ts +9 -0
- package/dist/providers/BroadcastServiceProvider.d.ts +7 -0
- package/dist/providers/CacheServiceProvider.d.ts +7 -0
- package/dist/providers/EncryptionServiceProvider.d.ts +7 -0
- package/dist/providers/ErrorServiceProvider.d.ts +9 -0
- package/dist/providers/EventServiceProvider.d.ts +7 -0
- package/dist/providers/HealthServiceProvider.d.ts +7 -0
- package/dist/providers/I18nServiceProvider.d.ts +27 -0
- package/dist/providers/InertiaServiceProvider.d.ts +20 -0
- package/dist/providers/LogServiceProvider.d.ts +7 -0
- package/dist/providers/MailServiceProvider.d.ts +7 -0
- package/dist/providers/NotificationServiceProvider.d.ts +8 -0
- package/dist/providers/OAuthServiceProvider.d.ts +7 -0
- package/dist/providers/QueueServiceProvider.d.ts +7 -0
- package/dist/providers/SchedulingServiceProvider.d.ts +7 -0
- package/dist/providers/StorageServiceProvider.d.ts +7 -0
- package/dist/providers/index.d.ts +17 -0
- package/dist/queue/FailedJobReporter.d.ts +40 -0
- package/dist/queue/Job.d.ts +140 -0
- package/dist/queue/QueueManager.d.ts +79 -0
- package/dist/queue/Worker.d.ts +99 -0
- package/dist/queue/drivers/MemoryDriver.d.ts +60 -0
- package/dist/queue/drivers/RedisDriver.d.ts +96 -0
- package/dist/queue/drivers/SqsDriver.d.ts +108 -0
- package/dist/queue/drivers/SyncDriver.d.ts +28 -0
- package/dist/queue/index.d.ts +9 -453
- package/dist/queue/types.d.ts +171 -0
- package/dist/redis/RedisApiTokenStore.d.ts +78 -0
- package/dist/redis/RedisEmailVerificationStore.d.ts +54 -0
- package/dist/redis/RedisOAuthStateStore.d.ts +26 -0
- package/dist/redis/RedisPasswordResetStore.d.ts +57 -0
- package/dist/redis/RedisRateLimitStore.d.ts +77 -0
- package/dist/redis/RedisSessionStore.d.ts +61 -0
- package/dist/redis/client.d.ts +41 -0
- package/dist/redis/index.d.ts +14 -356
- package/dist/redis/index.js +5 -2
- package/dist/redis/scan-keys.d.ts +6 -0
- package/dist/runtime/index.d.ts +8 -95
- package/dist/runtime/index.js +1 -1
- package/dist/scheduling/CronParser.d.ts +37 -0
- package/dist/scheduling/Schedule.d.ts +229 -0
- package/dist/scheduling/ScheduledTask.d.ts +47 -0
- package/dist/scheduling/Scheduler.d.ts +99 -0
- package/dist/scheduling/index.d.ts +5 -41
- package/dist/scheduling/types.d.ts +97 -0
- package/dist/storage/StorageManager.d.ts +65 -0
- package/dist/storage/drivers/LocalDriver.d.ts +55 -0
- package/dist/storage/drivers/MemoryDriver.d.ts +66 -0
- package/dist/storage/drivers/S3Driver.d.ts +72 -0
- package/dist/storage/index.d.ts +5 -197
- package/dist/{StorageManager-oZTHqaza.d.ts → storage/types.d.ts} +10 -77
- package/dist/support/error-polyfill.d.ts +9 -0
- package/dist/support/import-map.d.ts +13 -0
- package/dist/support/redirect-target.d.ts +11 -0
- package/dist/support/stack-frames.d.ts +56 -0
- package/dist/support/trim-slashes.d.ts +11 -0
- package/dist/vite/index.d.ts +2 -35
- package/dist/vite/index.js +0 -3
- package/dist/vite/plugin.d.ts +34 -0
- package/package.json +3 -3
- package/dist/AuthManager-DBP4KYsx.d.ts +0 -79
- package/dist/BroadcastManager-D8KoJxiV.d.ts +0 -492
- package/dist/HealthManager-DUyMIzsZ.d.ts +0 -141
- package/dist/I18nManager-BiSoczfV.d.ts +0 -275
- package/dist/LogManager-7mxnkaPM.d.ts +0 -256
- package/dist/Scheduler-pZiT8i57.d.ts +0 -471
- package/dist/api-token-D24VPr_E.d.ts +0 -663
- package/dist/app-key-CsBfRC_Q.d.ts +0 -214
- package/dist/email-verification-D60YF2ZO.d.ts +0 -329
- package/dist/index-9_Jzj5jo.d.ts +0 -7
- package/dist/validation-yAL53e1S.d.ts +0 -2610
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import type { Context } from 'hono';
|
|
2
|
+
import { type InertiaOptions } from './inertia/InertiaEngine.js';
|
|
3
|
+
import { type ResolvedSharedInertiaProps } from './inertia/shared.js';
|
|
4
|
+
import { type RegisteredTranslationKey, type ReplacementValues } from '../i18n/index.js';
|
|
5
|
+
import type { AuthContext } from '../auth/types.js';
|
|
6
|
+
import type { ServiceBindings } from '../container/bindings.js';
|
|
7
|
+
import type { ContainerLike } from '../container/types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Duck-type interface for Zod-like schemas.
|
|
10
|
+
* Allows validation without a direct Zod dependency.
|
|
11
|
+
*/
|
|
12
|
+
interface ZodLikeSchema<T> {
|
|
13
|
+
safeParse(data: unknown): {
|
|
14
|
+
success: true;
|
|
15
|
+
data: T;
|
|
16
|
+
} | {
|
|
17
|
+
success: false;
|
|
18
|
+
error: {
|
|
19
|
+
issues: Array<{
|
|
20
|
+
path: PropertyKey[];
|
|
21
|
+
message: string;
|
|
22
|
+
}>;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Result type for safe validation methods (discriminated union).
|
|
28
|
+
*/
|
|
29
|
+
export type SafeValidationResult<T> = {
|
|
30
|
+
success: true;
|
|
31
|
+
data: T;
|
|
32
|
+
} | {
|
|
33
|
+
success: false;
|
|
34
|
+
errors: Record<string, string>;
|
|
35
|
+
};
|
|
36
|
+
type DefaultInertiaProps = Record<string, unknown>;
|
|
37
|
+
export type AuthPayload = Record<string, unknown> & {
|
|
38
|
+
user: unknown;
|
|
39
|
+
};
|
|
40
|
+
export type InertiaPageContractLike<Component extends string = string, Props extends DefaultInertiaProps = DefaultInertiaProps> = {
|
|
41
|
+
id: Component;
|
|
42
|
+
component?: Component;
|
|
43
|
+
__props?: Props;
|
|
44
|
+
};
|
|
45
|
+
type InertiaResponseMarker<Component extends string, Props extends DefaultInertiaProps> = {
|
|
46
|
+
__gurenInertia: {
|
|
47
|
+
component: Component;
|
|
48
|
+
props: Props;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export type InertiaResponse<Component extends string, Props extends DefaultInertiaProps> = Response & InertiaResponseMarker<Component, Props>;
|
|
52
|
+
type InertiaWithProps = {
|
|
53
|
+
__gurenInertia: {
|
|
54
|
+
props: DefaultInertiaProps;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
type ExtractInertiaProps<T> = Awaited<T> extends infer R ? R extends InertiaWithProps ? R['__gurenInertia']['props'] : never : never;
|
|
58
|
+
export type InferInertiaProps<T> = [ExtractInertiaProps<T>] extends [never] ? DefaultInertiaProps : ExtractInertiaProps<T>;
|
|
59
|
+
export type ControllerInertiaProps<TController extends Controller, TAction extends keyof TController> = TController[TAction] extends (...args: any[]) => infer TResult ? InferInertiaProps<Awaited<TResult>> : DefaultInertiaProps;
|
|
60
|
+
export interface RedirectOptions {
|
|
61
|
+
status?: number;
|
|
62
|
+
headers?: HeadersInit;
|
|
63
|
+
}
|
|
64
|
+
type InertiaResponseOptions = Omit<InertiaOptions, 'url' | 'request'> & {
|
|
65
|
+
url?: string;
|
|
66
|
+
};
|
|
67
|
+
type InertiaPageComponent<TPage extends InertiaPageContractLike> = TPage['id'];
|
|
68
|
+
type InertiaPageProps<TPage extends InertiaPageContractLike> = NonNullable<TPage['__props']>;
|
|
69
|
+
/**
|
|
70
|
+
* Constructor type for controllers with optional DI.
|
|
71
|
+
*/
|
|
72
|
+
export type ControllerConstructorWithInject = {
|
|
73
|
+
new (...args: any[]): Controller;
|
|
74
|
+
inject?: readonly string[];
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Base controller inspired by Laravel's expressive API. Subclasses can access
|
|
78
|
+
* the current Hono context through the protected `ctx` getter and rely on the
|
|
79
|
+
* helper response builders for common patterns.
|
|
80
|
+
*
|
|
81
|
+
* Supports dependency injection via the `static inject` convention:
|
|
82
|
+
* ```typescript
|
|
83
|
+
* class PostController extends Controller {
|
|
84
|
+
* static inject = ['cache', 'events'] as const
|
|
85
|
+
* constructor(private cache: CacheManager, private events: EventManager) { super() }
|
|
86
|
+
* }
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
export declare class Controller {
|
|
90
|
+
#private;
|
|
91
|
+
/**
|
|
92
|
+
* Dependencies to inject from the container.
|
|
93
|
+
* Override in subclasses to declare required services.
|
|
94
|
+
*/
|
|
95
|
+
static inject?: readonly string[];
|
|
96
|
+
private context?;
|
|
97
|
+
private parsedBody?;
|
|
98
|
+
private resolvedModels?;
|
|
99
|
+
private _container?;
|
|
100
|
+
setContext(context: Context): void;
|
|
101
|
+
/** @internal Called by the router to inject the DI container. */
|
|
102
|
+
setContainer(container: ContainerLike): void;
|
|
103
|
+
/**
|
|
104
|
+
* Store a resolved model instance from route model binding.
|
|
105
|
+
* @internal Called by the router, not intended for direct use.
|
|
106
|
+
*/
|
|
107
|
+
setResolvedModel(modelClass: unknown, instance: unknown): void;
|
|
108
|
+
/**
|
|
109
|
+
* Retrieve a model instance resolved via route model binding.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```typescript
|
|
113
|
+
* // routes/web.ts
|
|
114
|
+
* posts.get('/:id', { bind: { id: Post }, name: 'posts.show' }, [PostController, 'show'])
|
|
115
|
+
*
|
|
116
|
+
* // PostController.ts
|
|
117
|
+
* async show() {
|
|
118
|
+
* const post = this.model(Post) // typed as PostRecord
|
|
119
|
+
* return this.inertia(pages.posts.Show, { post })
|
|
120
|
+
* }
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
protected model<T extends {
|
|
124
|
+
findOrFail(...args: any[]): Promise<any>;
|
|
125
|
+
}>(modelClass: T): Awaited<ReturnType<T['findOrFail']>>;
|
|
126
|
+
protected get ctx(): Context;
|
|
127
|
+
protected get request(): import("hono").HonoRequest<any, unknown>;
|
|
128
|
+
/**
|
|
129
|
+
* Get an uploaded file from a multipart request.
|
|
130
|
+
*
|
|
131
|
+
* Returns null when the field is missing, is not a file, or the upload is
|
|
132
|
+
* empty. Hono caches the parsed body, so this composes with other body
|
|
133
|
+
* reads in the same request.
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```typescript
|
|
137
|
+
* const avatar = await this.file('avatar')
|
|
138
|
+
* if (!avatar) {
|
|
139
|
+
* throw ValidationException.withMessages({ avatar: 'Choose a file.' })
|
|
140
|
+
* }
|
|
141
|
+
* await storage.disk().put(`avatars/${avatar.name}`, Buffer.from(await avatar.arrayBuffer()))
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
protected file(name: string): Promise<File | null>;
|
|
145
|
+
/**
|
|
146
|
+
* Get all uploaded files for a multipart field (e.g. `<input multiple>`).
|
|
147
|
+
* Returns an empty array when none were uploaded.
|
|
148
|
+
*/
|
|
149
|
+
protected files(name: string): Promise<File[]>;
|
|
150
|
+
protected get auth(): AuthContext;
|
|
151
|
+
protected make<K extends keyof ServiceBindings>(key: K): ServiceBindings[K];
|
|
152
|
+
protected make<T>(key: string): T;
|
|
153
|
+
/**
|
|
154
|
+
* Get the authenticated API token or throw AuthenticationException.
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```typescript
|
|
158
|
+
* const { userId, abilities } = this.apiToken()
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
protected apiToken(): {
|
|
162
|
+
token: import("../index.js").ApiToken;
|
|
163
|
+
userId: string | number;
|
|
164
|
+
abilities: string[];
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Get the authenticated user ID from the API token.
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```typescript
|
|
171
|
+
* const userId = this.apiTokenUserId()
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
protected apiTokenUserId(): string | number;
|
|
175
|
+
/**
|
|
176
|
+
* Authorize the current user (or guest) for an ability.
|
|
177
|
+
* Throws AuthorizationException (403) when denied.
|
|
178
|
+
*
|
|
179
|
+
* ORM records are plain objects with no constructor information, so pass
|
|
180
|
+
* the model class alongside the record to resolve the policy:
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* ```typescript
|
|
184
|
+
* const post = await Post.findOrFail(id)
|
|
185
|
+
* await this.authorize('update', [Post, post])
|
|
186
|
+
* await this.authorize('create', Post)
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
protected authorize(ability: string, ...args: unknown[]): Promise<void>;
|
|
190
|
+
/**
|
|
191
|
+
* Check whether the current user (or guest) can perform an ability.
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```typescript
|
|
195
|
+
* if (await this.can('update', [Post, post])) { ... }
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
protected can(ability: string, ...args: unknown[]): Promise<boolean>;
|
|
199
|
+
private gateUser;
|
|
200
|
+
protected inertia<TPage extends InertiaPageContractLike>(page: TPage, props: InertiaPageProps<TPage>, options?: InertiaResponseOptions): Promise<InertiaResponse<InertiaPageComponent<TPage>, InertiaPageProps<TPage> & ResolvedSharedInertiaProps>>;
|
|
201
|
+
protected inertia<Component extends string, Props extends DefaultInertiaProps>(component: Component, props: Props, options?: InertiaResponseOptions): Promise<InertiaResponse<Component, Props & ResolvedSharedInertiaProps>>;
|
|
202
|
+
/**
|
|
203
|
+
* Locale resolved for the current request: the request-scoped `locale`
|
|
204
|
+
* context variable (set by locale middleware) wins over the app-wide i18n
|
|
205
|
+
* locale (the router-injected container binding, then the `setI18n()`
|
|
206
|
+
* global). Falls back to `'en'` when no i18n is configured.
|
|
207
|
+
*/
|
|
208
|
+
protected get locale(): string;
|
|
209
|
+
/**
|
|
210
|
+
* Translate a key for the current request locale.
|
|
211
|
+
*
|
|
212
|
+
* Uses the request-scoped translator bound by the locale detection
|
|
213
|
+
* middleware when present, falling back to a translator scoped to
|
|
214
|
+
* `this.locale` from the container's `i18n` binding (then the `setI18n()`
|
|
215
|
+
* global).
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```typescript
|
|
219
|
+
* this.t('posts.created')
|
|
220
|
+
* this.t('posts.greeting', { name: user.name })
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
protected t(key: RegisteredTranslationKey, replacements?: ReplacementValues): string;
|
|
224
|
+
/**
|
|
225
|
+
* Translate a key with a count for pluralization, using the same locale
|
|
226
|
+
* resolution as {@link Controller.t}.
|
|
227
|
+
*/
|
|
228
|
+
protected tc(key: RegisteredTranslationKey, count: number, replacements?: ReplacementValues): string;
|
|
229
|
+
protected json<T>(data: T, init?: ResponseInit): Response;
|
|
230
|
+
protected text(body: string, init?: ResponseInit): Response;
|
|
231
|
+
protected redirect(url: string, options?: RedirectOptions): Response;
|
|
232
|
+
/**
|
|
233
|
+
* Return a 204 No Content response.
|
|
234
|
+
*/
|
|
235
|
+
protected noContent(): Response;
|
|
236
|
+
/**
|
|
237
|
+
* Return a 201 Created response with JSON data.
|
|
238
|
+
*/
|
|
239
|
+
protected created<T>(data?: T, init?: ResponseInit): Response;
|
|
240
|
+
/**
|
|
241
|
+
* Return a 202 Accepted response with optional JSON data.
|
|
242
|
+
*/
|
|
243
|
+
protected accepted<T>(data?: T, init?: ResponseInit): Response;
|
|
244
|
+
private jsonStatus;
|
|
245
|
+
/**
|
|
246
|
+
* Get a specific input value from the request body or query parameters.
|
|
247
|
+
* Body values take precedence over query parameters.
|
|
248
|
+
*/
|
|
249
|
+
protected input<T = unknown>(key: string, defaultValue?: T): Promise<T | undefined>;
|
|
250
|
+
/**
|
|
251
|
+
* Get a query parameter value.
|
|
252
|
+
*/
|
|
253
|
+
protected query(key: string, defaultValue?: string): string | undefined;
|
|
254
|
+
/**
|
|
255
|
+
* Get only the specified keys from the request body.
|
|
256
|
+
*/
|
|
257
|
+
protected only(...keys: string[]): Promise<Record<string, unknown>>;
|
|
258
|
+
/**
|
|
259
|
+
* Get all request body values except the specified keys.
|
|
260
|
+
*/
|
|
261
|
+
protected except(...keys: string[]): Promise<Record<string, unknown>>;
|
|
262
|
+
/**
|
|
263
|
+
* Check if a key exists in the request body.
|
|
264
|
+
*/
|
|
265
|
+
protected has(key: string): Promise<boolean>;
|
|
266
|
+
/** Flatten query string arrays to scalar values for cleaner schema usage. */
|
|
267
|
+
private flattenQueries;
|
|
268
|
+
/**
|
|
269
|
+
* Validate the request body against a Zod-like schema.
|
|
270
|
+
* Throws ValidationException on failure.
|
|
271
|
+
*
|
|
272
|
+
* @example
|
|
273
|
+
* ```typescript
|
|
274
|
+
* const data = await this.validateBody(CreatePostSchema)
|
|
275
|
+
* ```
|
|
276
|
+
*/
|
|
277
|
+
protected validateBody<T>(schema: ZodLikeSchema<T>): Promise<T>;
|
|
278
|
+
/**
|
|
279
|
+
* Validate query parameters against a Zod-like schema.
|
|
280
|
+
* Throws ValidationException on failure.
|
|
281
|
+
*
|
|
282
|
+
* @example
|
|
283
|
+
* ```typescript
|
|
284
|
+
* const { page } = this.validateQuery(PageQuerySchema)
|
|
285
|
+
* ```
|
|
286
|
+
*/
|
|
287
|
+
protected validateQuery<T>(schema: ZodLikeSchema<T>): T;
|
|
288
|
+
/**
|
|
289
|
+
* Validate route parameters against a Zod-like schema.
|
|
290
|
+
* Throws ValidationException on failure.
|
|
291
|
+
*
|
|
292
|
+
* @example
|
|
293
|
+
* ```typescript
|
|
294
|
+
* const { id } = this.validateParams(PostIdParamSchema)
|
|
295
|
+
* ```
|
|
296
|
+
*/
|
|
297
|
+
protected validateParams<T>(schema: ZodLikeSchema<T>): T;
|
|
298
|
+
/**
|
|
299
|
+
* Validate the request body against a Zod-like schema without throwing.
|
|
300
|
+
* Returns a discriminated union: `{ success: true, data }` or `{ success: false, errors }`.
|
|
301
|
+
*
|
|
302
|
+
* @example
|
|
303
|
+
* ```typescript
|
|
304
|
+
* const result = await this.validateBodySafe(CreatePostSchema)
|
|
305
|
+
* if (!result.success) {
|
|
306
|
+
* return this.inertia(pages.posts.New, { errors: result.errors }, { status: 422 })
|
|
307
|
+
* }
|
|
308
|
+
* const { title, body } = result.data
|
|
309
|
+
* ```
|
|
310
|
+
*/
|
|
311
|
+
protected validateBodySafe<T>(schema: ZodLikeSchema<T>): Promise<SafeValidationResult<T>>;
|
|
312
|
+
/**
|
|
313
|
+
* Validate query parameters against a Zod-like schema without throwing.
|
|
314
|
+
* Returns a discriminated union: `{ success: true, data }` or `{ success: false, errors }`.
|
|
315
|
+
*/
|
|
316
|
+
protected validateQuerySafe<T>(schema: ZodLikeSchema<T>): SafeValidationResult<T>;
|
|
317
|
+
/**
|
|
318
|
+
* Validate route parameters against a Zod-like schema without throwing.
|
|
319
|
+
* Returns a discriminated union: `{ success: true, data }` or `{ success: false, errors }`.
|
|
320
|
+
*/
|
|
321
|
+
protected validateParamsSafe<T>(schema: ZodLikeSchema<T>): SafeValidationResult<T>;
|
|
322
|
+
private runValidation;
|
|
323
|
+
private runValidationSafe;
|
|
324
|
+
private getBody;
|
|
325
|
+
}
|
|
326
|
+
export {};
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import type { Context, MiddlewareHandler, Hono, Next } from 'hono';
|
|
2
|
+
import { Controller } from './Controller.js';
|
|
3
|
+
import type { Container } from '../container/Container.js';
|
|
4
|
+
import type { ValidationSchema } from '../http/middleware/validation.js';
|
|
5
|
+
import { type MiddlewareCapabilities } from '../http/middleware/capabilities.js';
|
|
6
|
+
/**
|
|
7
|
+
* Constructor type for Controller classes.
|
|
8
|
+
* @template T - The controller type extending Controller
|
|
9
|
+
*/
|
|
10
|
+
export type ControllerConstructor<T extends Controller = Controller> = (new (...args: any[]) => T) & {
|
|
11
|
+
inject?: readonly string[];
|
|
12
|
+
};
|
|
13
|
+
type ControllerMethod<T extends Controller> = {
|
|
14
|
+
[K in keyof T]: T[K] extends (...args: any[]) => any ? K : never;
|
|
15
|
+
}[keyof T] & string;
|
|
16
|
+
type ControllerMethodFor<C extends ControllerConstructor> = ControllerMethod<InstanceType<C>>;
|
|
17
|
+
export type ControllerAction<C extends ControllerConstructor = ControllerConstructor> = [C, ControllerMethodFor<C>];
|
|
18
|
+
export type RouteResult = Response | string | number | boolean | Record<string, unknown> | Array<unknown> | null | void;
|
|
19
|
+
/**
|
|
20
|
+
* Handler for a route - either an inline function or a controller action tuple.
|
|
21
|
+
* Inline handlers receive `next`, so any Hono middleware (e.g.
|
|
22
|
+
* `broadcast.sseMiddleware()`) can be mounted directly as a terminal handler.
|
|
23
|
+
*/
|
|
24
|
+
export type RouteHandler<C extends ControllerConstructor = ControllerConstructor> = ((c: Context, next: Next) => RouteResult | Promise<RouteResult>) | ControllerAction<C>;
|
|
25
|
+
/**
|
|
26
|
+
* Model binding resolver function.
|
|
27
|
+
*/
|
|
28
|
+
type ModelBindingResolver = (value: string) => Promise<unknown>;
|
|
29
|
+
/**
|
|
30
|
+
* Model class with findOrFail static method.
|
|
31
|
+
*/
|
|
32
|
+
interface BindableModel {
|
|
33
|
+
findOrFail(id: unknown, key?: string): Promise<unknown>;
|
|
34
|
+
/** Bound values are model classes at runtime; the constructor name is the introspection payload. */
|
|
35
|
+
readonly name?: string;
|
|
36
|
+
}
|
|
37
|
+
type SchemaLike<T = unknown> = ValidationSchema<T> | undefined;
|
|
38
|
+
type InferSchema<TSchema extends SchemaLike<unknown>> = TSchema extends ValidationSchema<infer TValue> ? TValue : never;
|
|
39
|
+
type RouteParamsFor<TSchema extends SchemaLike<unknown>> = [
|
|
40
|
+
TSchema
|
|
41
|
+
] extends [ValidationSchema<any>] ? InferSchema<TSchema> : Record<string, string>;
|
|
42
|
+
type RouteQueryFor<TSchema extends SchemaLike<unknown>> = [
|
|
43
|
+
TSchema
|
|
44
|
+
] extends [ValidationSchema<any>] ? InferSchema<TSchema> : Record<string, string | undefined>;
|
|
45
|
+
type RouteBodyFor<TSchema extends SchemaLike<unknown>> = [
|
|
46
|
+
TSchema
|
|
47
|
+
] extends [ValidationSchema<any>] ? InferSchema<TSchema> : Record<string, unknown>;
|
|
48
|
+
export interface TypedRouteContext<TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>> {
|
|
49
|
+
ctx: Context;
|
|
50
|
+
params: RouteParamsFor<TParamsSchema>;
|
|
51
|
+
query: RouteQueryFor<TQuerySchema>;
|
|
52
|
+
body: RouteBodyFor<TBodySchema>;
|
|
53
|
+
}
|
|
54
|
+
export type TypedRouteHandler<TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>> = (input: TypedRouteContext<TParamsSchema, TQuerySchema, TBodySchema>) => ([TOutputSchema] extends [ValidationSchema<any>] ? InferSchema<TOutputSchema> : RouteResult) | Promise<[TOutputSchema] extends [ValidationSchema<any>] ? InferSchema<TOutputSchema> : RouteResult>;
|
|
55
|
+
export interface RouteContractOptions<TParamsSchema extends SchemaLike<unknown> = undefined, TQuerySchema extends SchemaLike<unknown> = undefined, TBodySchema extends SchemaLike<unknown> = undefined, TOutputSchema extends SchemaLike<unknown> = undefined> extends RouteOpenApiMetadata {
|
|
56
|
+
name?: string;
|
|
57
|
+
middlewares?: MiddlewareHandler[];
|
|
58
|
+
params?: TParamsSchema;
|
|
59
|
+
query?: TQuerySchema;
|
|
60
|
+
body?: TBodySchema;
|
|
61
|
+
output?: TOutputSchema;
|
|
62
|
+
bind?: Record<string, BindableModel>;
|
|
63
|
+
}
|
|
64
|
+
export interface RouteOpenApiMetadata {
|
|
65
|
+
summary?: string;
|
|
66
|
+
description?: string;
|
|
67
|
+
tags?: string[];
|
|
68
|
+
operationId?: string;
|
|
69
|
+
deprecated?: boolean;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Represents a registered route definition for introspection.
|
|
73
|
+
*/
|
|
74
|
+
export interface RouteDefinition {
|
|
75
|
+
/** HTTP method (GET, POST, PUT, PATCH, DELETE) */
|
|
76
|
+
method: string;
|
|
77
|
+
/** URL path pattern (e.g., '/users/:id') */
|
|
78
|
+
path: string;
|
|
79
|
+
/** Optional route name for URL generation */
|
|
80
|
+
name?: string;
|
|
81
|
+
/** Schema metadata attached via RouteContractOptions */
|
|
82
|
+
schemas?: {
|
|
83
|
+
params?: SchemaLike<unknown>;
|
|
84
|
+
query?: SchemaLike<unknown>;
|
|
85
|
+
body?: SchemaLike<unknown>;
|
|
86
|
+
output?: SchemaLike<unknown>;
|
|
87
|
+
};
|
|
88
|
+
/** Named middleware (aliases or groups) applied to this route */
|
|
89
|
+
middlewareNames?: string[];
|
|
90
|
+
/** Whether inline (unnamed) middleware handlers are attached */
|
|
91
|
+
hasInlineMiddleware?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Security capabilities aggregated from the route's middleware chain
|
|
94
|
+
* (named aliases, groups, and inline handlers). Always present on routers
|
|
95
|
+
* from this release — an empty object means "no recognized capability" —
|
|
96
|
+
* so consumers can distinguish that from definitions produced by older
|
|
97
|
+
* servers, where the field is absent. The value shape is internal and may
|
|
98
|
+
* change (RFC 0007).
|
|
99
|
+
*/
|
|
100
|
+
capabilities?: MiddlewareCapabilities;
|
|
101
|
+
/** Controller binding when the handler is a [Controller, 'method'] tuple */
|
|
102
|
+
controller?: {
|
|
103
|
+
name: string;
|
|
104
|
+
action: string;
|
|
105
|
+
};
|
|
106
|
+
/** Route model bindings: param name → bound model class name (from `bind`) */
|
|
107
|
+
bindings?: Record<string, string>;
|
|
108
|
+
summary?: string;
|
|
109
|
+
description?: string;
|
|
110
|
+
tags?: string[];
|
|
111
|
+
operationId?: string;
|
|
112
|
+
deprecated?: boolean;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Chainable builder for configuring a registered route.
|
|
116
|
+
* @template M - Union of registered middleware alias names
|
|
117
|
+
*/
|
|
118
|
+
export interface RouteBuilder<M extends string = never> {
|
|
119
|
+
/** Set the route name for URL generation. */
|
|
120
|
+
name(routeName: string): RouteBuilder<M>;
|
|
121
|
+
/** Attach middleware to this specific route. See {@link RouteMiddlewareInput}. */
|
|
122
|
+
middleware(...items: RouteMiddlewareInput<M>[]): RouteBuilder<M>;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Accepted by `.middleware()`: a registered alias name or a handler function.
|
|
126
|
+
*
|
|
127
|
+
* Resolution is by kind, not by position: every name in a route's chain runs
|
|
128
|
+
* before every handler, across scopes as well as within one call. So an inline
|
|
129
|
+
* handler on an outer group runs *after* a named one on an inner group, the
|
|
130
|
+
* reverse of how they read. Use aliases throughout when relative order matters.
|
|
131
|
+
*
|
|
132
|
+
* Aliases are also the only form that lands in `RouteDefinition.middlewareNames`,
|
|
133
|
+
* which is how `guren audit` reports middleware it cannot otherwise identify.
|
|
134
|
+
* Guards the framework stamps with a capability (`requireAuthenticated`,
|
|
135
|
+
* `requireGuest`) are recognized either way.
|
|
136
|
+
*/
|
|
137
|
+
export type RouteMiddlewareInput<M extends string = never> = M | MiddlewareHandler;
|
|
138
|
+
/** Storage form of {@link RouteMiddlewareInput}, unparameterized by alias union. */
|
|
139
|
+
type MiddlewareScopeEntry = string | MiddlewareHandler;
|
|
140
|
+
export interface RouterMountOptions {
|
|
141
|
+
container?: Container;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Available actions for resource routes.
|
|
145
|
+
*/
|
|
146
|
+
export type ResourceAction = 'index' | 'create' | 'store' | 'show' | 'edit' | 'update' | 'destroy';
|
|
147
|
+
/**
|
|
148
|
+
* Options for configuring resource routes.
|
|
149
|
+
*/
|
|
150
|
+
export interface ResourceRouteOptions {
|
|
151
|
+
name?: string;
|
|
152
|
+
param?: string;
|
|
153
|
+
only?: ResourceAction[];
|
|
154
|
+
except?: ResourceAction[];
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Instance-based router for app-local route registration and mounting.
|
|
158
|
+
* @template M - Union of registered middleware alias names (e.g. `'auth' | 'guest'`)
|
|
159
|
+
*/
|
|
160
|
+
export declare class Router<M extends string = never> {
|
|
161
|
+
private readonly registry;
|
|
162
|
+
private readonly prefixStack;
|
|
163
|
+
private readonly namedRoutes;
|
|
164
|
+
private readonly middlewareStack;
|
|
165
|
+
private readonly middlewareAliases;
|
|
166
|
+
private readonly middlewareGroups;
|
|
167
|
+
private readonly modelBindings;
|
|
168
|
+
/** Model class names for router-level bind(param, Model) calls — resolver-only binds carry no name. */
|
|
169
|
+
private readonly modelBindingNames;
|
|
170
|
+
aliasMiddleware<N extends string>(name: N, handler: MiddlewareHandler): Router<M | N>;
|
|
171
|
+
groupMiddleware<N extends string>(name: N, middlewareNames: M[]): Router<M | N>;
|
|
172
|
+
/**
|
|
173
|
+
* Open a middleware scope for the routes registered through the returned
|
|
174
|
+
* builder. See {@link RouteMiddlewareInput}.
|
|
175
|
+
*/
|
|
176
|
+
middleware(...items: RouteMiddlewareInput<M>[]): RouterMiddlewareGroupBuilder<M>;
|
|
177
|
+
bind(param: string, modelOrResolver: BindableModel | ModelBindingResolver): this;
|
|
178
|
+
on<C extends ControllerConstructor>(method: string, path: string, handler: RouteHandler<C>, ...middlewares: MiddlewareHandler[]): RouteBuilder<M>;
|
|
179
|
+
on<TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(method: string, path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: TypedRouteHandler<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>): RouteBuilder<M>;
|
|
180
|
+
on<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(method: string, path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C>): RouteBuilder<M>;
|
|
181
|
+
get<C extends ControllerConstructor>(path: string, handler: RouteHandler<C>, ...middlewares: MiddlewareHandler[]): RouteBuilder<M>;
|
|
182
|
+
get<TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: TypedRouteHandler<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>): RouteBuilder<M>;
|
|
183
|
+
get<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C>): RouteBuilder<M>;
|
|
184
|
+
post<C extends ControllerConstructor>(path: string, handler: RouteHandler<C>, ...middlewares: MiddlewareHandler[]): RouteBuilder<M>;
|
|
185
|
+
post<TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: TypedRouteHandler<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>): RouteBuilder<M>;
|
|
186
|
+
post<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C>): RouteBuilder<M>;
|
|
187
|
+
put<C extends ControllerConstructor>(path: string, handler: RouteHandler<C>, ...middlewares: MiddlewareHandler[]): RouteBuilder<M>;
|
|
188
|
+
put<TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: TypedRouteHandler<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>): RouteBuilder<M>;
|
|
189
|
+
put<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C>): RouteBuilder<M>;
|
|
190
|
+
patch<C extends ControllerConstructor>(path: string, handler: RouteHandler<C>, ...middlewares: MiddlewareHandler[]): RouteBuilder<M>;
|
|
191
|
+
patch<TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: TypedRouteHandler<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>): RouteBuilder<M>;
|
|
192
|
+
patch<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C>): RouteBuilder<M>;
|
|
193
|
+
delete<C extends ControllerConstructor>(path: string, handler: RouteHandler<C>, ...middlewares: MiddlewareHandler[]): RouteBuilder<M>;
|
|
194
|
+
delete<TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: TypedRouteHandler<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>): RouteBuilder<M>;
|
|
195
|
+
delete<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C>): RouteBuilder<M>;
|
|
196
|
+
group(prefix: string, callback: (router: Router<M>) => void): this;
|
|
197
|
+
route(name: string, params?: Record<string, string | number>): string;
|
|
198
|
+
hasRoute(name: string): boolean;
|
|
199
|
+
resource<C extends ControllerConstructor>(path: string, controller: C, options?: ResourceRouteOptions): this;
|
|
200
|
+
mount(app: Hono, options?: RouterMountOptions): void;
|
|
201
|
+
clear(): void;
|
|
202
|
+
resetMiddleware(): void;
|
|
203
|
+
definitions(): RouteDefinition[];
|
|
204
|
+
applyMiddlewareScope<T>(items: readonly MiddlewareScopeEntry[], callback: () => T): T;
|
|
205
|
+
private register;
|
|
206
|
+
private add;
|
|
207
|
+
/**
|
|
208
|
+
* Security capabilities present on a route's middleware chain, aggregated
|
|
209
|
+
* across named aliases (group-expanded) and inline handlers. Unlike
|
|
210
|
+
* `resolveMiddlewareNames`, unregistered names are skipped rather than
|
|
211
|
+
* thrown: `definitions()` must stay side-effect-free for introspection of
|
|
212
|
+
* routers that never mount (audit, codegen), and an unresolvable alias
|
|
213
|
+
* simply contributes no capabilities.
|
|
214
|
+
*/
|
|
215
|
+
private aggregateCapabilities;
|
|
216
|
+
private resolveMiddlewareNames;
|
|
217
|
+
}
|
|
218
|
+
declare class RouterMiddlewareGroupBuilder<M extends string = never> {
|
|
219
|
+
private readonly router;
|
|
220
|
+
private readonly items;
|
|
221
|
+
constructor(router: Router<M>, items: readonly MiddlewareScopeEntry[]);
|
|
222
|
+
group(callback: (router: Router<M>) => void): Router<M>;
|
|
223
|
+
get<C extends ControllerConstructor>(path: string, handler: RouteHandler<C>, ...middlewares: MiddlewareHandler[]): RouteBuilder<M>;
|
|
224
|
+
get<TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: TypedRouteHandler<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>): RouteBuilder<M>;
|
|
225
|
+
get<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C>): RouteBuilder<M>;
|
|
226
|
+
post<C extends ControllerConstructor>(path: string, handler: RouteHandler<C>, ...middlewares: MiddlewareHandler[]): RouteBuilder<M>;
|
|
227
|
+
post<TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: TypedRouteHandler<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>): RouteBuilder<M>;
|
|
228
|
+
post<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C>): RouteBuilder<M>;
|
|
229
|
+
put<C extends ControllerConstructor>(path: string, handler: RouteHandler<C>, ...middlewares: MiddlewareHandler[]): RouteBuilder<M>;
|
|
230
|
+
put<TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: TypedRouteHandler<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>): RouteBuilder<M>;
|
|
231
|
+
put<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C>): RouteBuilder<M>;
|
|
232
|
+
patch<C extends ControllerConstructor>(path: string, handler: RouteHandler<C>, ...middlewares: MiddlewareHandler[]): RouteBuilder<M>;
|
|
233
|
+
patch<TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: TypedRouteHandler<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>): RouteBuilder<M>;
|
|
234
|
+
patch<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C>): RouteBuilder<M>;
|
|
235
|
+
delete<C extends ControllerConstructor>(path: string, handler: RouteHandler<C>, ...middlewares: MiddlewareHandler[]): RouteBuilder<M>;
|
|
236
|
+
delete<TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: TypedRouteHandler<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>): RouteBuilder<M>;
|
|
237
|
+
delete<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C>): RouteBuilder<M>;
|
|
238
|
+
}
|
|
239
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type ViewRenderer = (template: string, props: Record<string, unknown>) => Response | Promise<Response>;
|
|
2
|
+
/**
|
|
3
|
+
* Registry for view renderers. Engines are typically registered via service
|
|
4
|
+
* providers so applications can opt into or replace implementations.
|
|
5
|
+
*/
|
|
6
|
+
export declare class ViewEngine {
|
|
7
|
+
private static readonly engines;
|
|
8
|
+
static register(name: string, renderer: ViewRenderer): void;
|
|
9
|
+
static has(name: string): boolean;
|
|
10
|
+
static render(name: string, template: string, props: Record<string, unknown>): Response | Promise<Response>;
|
|
11
|
+
}
|