@guren/server 2.14.0 → 2.16.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/{DocsViewerServiceProvider-qFCaeiUv.js → DocsViewerServiceProvider-D2cuVgtN.js} +7 -12
- package/dist/{Hash-CzrwKeDp.js → Hash-D2DFd8xX.js} +12 -57
- package/dist/{HttpException-BkS3euNG.js → HttpException-BlQ2yEmT.js} +2 -79
- package/dist/{Job-BVT813DO.js → Job-DxQK8h3P.js} +24 -179
- package/dist/{McpServiceProvider-BawsYjgN.js → McpServiceProvider-nNcbCIQX.js} +11 -20
- package/dist/{Random-DbIJ22KQ.js → Random-S0OvCuR8.js} +9 -106
- package/dist/agent/AgentApprovalRequested.d.ts +31 -0
- package/dist/agent/approval.d.ts +184 -0
- package/dist/agent/audit-emitter.d.ts +36 -0
- package/dist/agent/audit.d.ts +67 -0
- package/dist/agent/derive.d.ts +32 -66
- package/dist/agent/dispatch.d.ts +53 -63
- package/dist/agent/events.d.ts +11 -19
- package/dist/agent/meta-tools.d.ts +34 -0
- package/dist/agent/public.d.ts +14 -0
- package/dist/agent/public.js +2 -0
- package/dist/agent/redact.d.ts +16 -38
- package/dist/agent/scopes.d.ts +23 -69
- package/dist/auth/AuthManager.d.ts +19 -40
- package/dist/auth/AuthenticatableModel.d.ts +2 -2
- package/dist/auth/SessionGuard.d.ts +0 -1
- package/dist/auth/TokenGuard.d.ts +6 -26
- package/dist/auth/api-token.d.ts +16 -148
- package/dist/auth/context.d.ts +5 -10
- package/dist/auth/email-verification.d.ts +29 -127
- package/dist/auth/index.js +1 -1
- package/dist/auth/oauth/index.d.ts +35 -57
- package/dist/auth/password/DefaultHasher.d.ts +9 -5
- package/dist/auth/password/PasswordHasher.d.ts +7 -0
- package/dist/auth/password/hash-format.d.ts +11 -0
- package/dist/auth/password-reset.d.ts +16 -42
- package/dist/auth/providers/ModelUserProvider.d.ts +3 -4
- package/dist/auth/providers/UserProvider.d.ts +4 -4
- package/dist/auth/signed-token.d.ts +18 -0
- package/dist/auth/types.d.ts +9 -32
- package/dist/auth/utils.d.ts +6 -27
- package/dist/{auth-BSUc14CD.js → auth-CbdPH4Cd.js} +252 -496
- package/dist/authorization/Gate.d.ts +9 -145
- package/dist/authorization/Policy.d.ts +6 -53
- package/dist/authorization/index.js +1 -1
- package/dist/authorization/middleware.d.ts +16 -62
- package/dist/authorization/types.d.ts +8 -64
- package/dist/{authorization-CdfbCj8J.js → authorization-CdEWZZw3.js} +44 -309
- package/dist/broadcasting/BroadcastManager.d.ts +29 -149
- package/dist/broadcasting/channels/Channel.d.ts +1 -19
- package/dist/broadcasting/channels/PresenceChannel.d.ts +1 -55
- package/dist/broadcasting/channels/PrivateChannel.d.ts +1 -23
- package/dist/broadcasting/drivers/MemoryDriver.d.ts +18 -70
- package/dist/broadcasting/drivers/RedisDriver.d.ts +3 -80
- package/dist/broadcasting/drivers/index.d.ts +1 -1
- package/dist/broadcasting/index.d.ts +1 -1
- package/dist/broadcasting/index.js +1 -1
- package/dist/broadcasting/types.d.ts +7 -88
- package/dist/{broadcasting-BxU-LIfF.js → broadcasting-B5RzB0A2.js} +87 -414
- package/dist/cache/CacheManager.d.ts +8 -62
- package/dist/cache/TaggedCache.d.ts +2 -35
- package/dist/cache/index.js +1 -1
- package/dist/cache/stores/FileStore.d.ts +2 -36
- package/dist/cache/stores/MemoryStore.d.ts +2 -26
- package/dist/cache/stores/RedisStore.d.ts +1 -29
- package/dist/cache/types.d.ts +21 -128
- package/dist/{cache-BYnZf2FR.js → cache-BOOIr324.js} +19 -198
- package/dist/client-C4TEr_Dd.js +9 -0
- package/dist/console/Command.d.ts +17 -126
- package/dist/console/ConsoleKernel.d.ts +2 -74
- package/dist/console/Input.d.ts +5 -113
- package/dist/console/Output.d.ts +3 -99
- package/dist/console/types.d.ts +3 -33
- package/dist/container/Container.d.ts +12 -103
- package/dist/container/ServiceProvider.d.ts +17 -61
- package/dist/container/bindings.d.ts +10 -12
- package/dist/container/defineModule.d.ts +16 -54
- package/dist/container/definePlugin.d.ts +12 -45
- package/dist/container/types.d.ts +2 -34
- package/dist/context-CXk_umpT.js +21 -0
- package/dist/database/Factory.d.ts +4 -57
- package/dist/database/Seeder.d.ts +8 -46
- package/dist/database/SeederRunner.d.ts +3 -33
- package/dist/database/types.d.ts +3 -24
- package/dist/discovery/AutoDiscovery.d.ts +10 -82
- package/dist/dispatch-BAwzftws.js +238 -0
- package/dist/docs-viewer/DocsViewerServiceProvider.d.ts +2 -5
- package/dist/docs-viewer/endpoint.d.ts +5 -11
- package/dist/encryption/Encrypter.d.ts +5 -71
- package/dist/encryption/Hash.d.ts +7 -57
- package/dist/encryption/Random.d.ts +6 -99
- package/dist/encryption/index.js +3 -3
- package/dist/encryption/types.d.ts +10 -72
- package/dist/{encryption-DJtkkhiw.js → encryption-uwP3Di4D.js} +13 -79
- package/dist/{endpoint-D6GIqOpe.js → endpoint-BXipU2Jj.js} +6 -12
- package/dist/endpoint-Dsw3Acvq.js +26 -0
- package/dist/errors/ExceptionHandler.d.ts +3 -90
- package/dist/errors/HttpException.d.ts +2 -79
- package/dist/errors/debug-page.d.ts +3 -17
- package/dist/errors/error-page.d.ts +1 -0
- package/dist/errors/exceptions/AuthenticationException.d.ts +2 -24
- package/dist/errors/exceptions/AuthorizationException.d.ts +1 -24
- package/dist/errors/exceptions/MethodNotAllowedException.d.ts +1 -23
- package/dist/errors/exceptions/NotFoundHttpException.d.ts +1 -27
- package/dist/errors/exceptions/ValidationException.d.ts +2 -43
- package/dist/errors/types.d.ts +1 -25
- package/dist/{errors-BgeOl_DC.js → errors-JpkcCjjn.js} +3 -41
- package/dist/events/Event.d.ts +1 -28
- package/dist/events/EventManager.d.ts +5 -107
- package/dist/events/Listener.d.ts +7 -55
- package/dist/events/builtin.d.ts +0 -24
- package/dist/events/index.js +1 -1
- package/dist/events/types.d.ts +4 -22
- package/dist/{events-aIH_bWRx.js → events-DOmAHDeP.js} +11 -191
- package/dist/facades/index.d.ts +2 -14
- package/dist/health/HealthCheck.d.ts +0 -24
- package/dist/health/HealthManager.d.ts +0 -36
- package/dist/health/checks/CacheCheck.d.ts +2 -17
- package/dist/health/checks/CustomCheck.d.ts +0 -9
- package/dist/health/checks/DatabaseCheck.d.ts +2 -17
- package/dist/health/checks/MemoryCheck.d.ts +3 -12
- package/dist/health/checks/RedisCheck.d.ts +1 -13
- package/dist/health/checks/StorageCheck.d.ts +2 -17
- package/dist/health/index.js +1 -1
- package/dist/health/types.d.ts +4 -24
- package/dist/{health-VWdWXRwh.js → health-DQSvUplL.js} +1 -76
- package/dist/hot-disposables-B5BXqaIH.js +167 -0
- package/dist/hot-reload/hot-disposables.d.ts +22 -74
- package/dist/hot-reload/testing.d.ts +4 -9
- package/dist/http/Application.d.ts +62 -208
- package/dist/http/FormRequest.d.ts +4 -55
- package/dist/http/dev-assets.d.ts +16 -18
- package/dist/http/dev-banner.d.ts +2 -5
- package/dist/http/inertia-assets.d.ts +3 -6
- package/dist/http/middleware/capabilities.d.ts +27 -50
- package/dist/http/middleware/cors.d.ts +4 -29
- package/dist/http/middleware/csp.d.ts +2 -25
- package/dist/http/middleware/csrf.d.ts +20 -95
- package/dist/http/middleware/detect-locale.d.ts +7 -27
- package/dist/http/middleware/force-https.d.ts +6 -24
- package/dist/http/middleware/host-authorization.d.ts +2 -12
- package/dist/http/middleware/loopback-guard.d.ts +15 -33
- package/dist/http/middleware/rate-limit.d.ts +29 -126
- package/dist/http/middleware/redirect-safety.d.ts +2 -20
- package/dist/http/middleware/request-id.d.ts +1 -14
- package/dist/http/middleware/request-logging.d.ts +2 -13
- package/dist/http/middleware/response-headers.d.ts +5 -13
- package/dist/http/middleware/security-headers.d.ts +2 -16
- package/dist/http/middleware/session.d.ts +15 -34
- package/dist/http/middleware/validation-errors-cookie.d.ts +7 -18
- package/dist/http/middleware/validation.d.ts +8 -63
- package/dist/http/public-assets.d.ts +14 -0
- package/dist/http/request.d.ts +49 -48
- package/dist/http/resources/CursorPaginator.d.ts +5 -64
- package/dist/http/resources/Paginator.d.ts +7 -84
- package/dist/http/resources/Resource.d.ts +9 -65
- package/dist/http/resources/ResourceCollection.d.ts +5 -39
- package/dist/http/resources/types.d.ts +10 -30
- package/dist/http/static-documents.d.ts +21 -0
- package/dist/http/validation/Validator.d.ts +25 -85
- package/dist/http/validation/rules.d.ts +48 -147
- package/dist/http/validation/types.d.ts +16 -61
- package/dist/http/vite-assets.d.ts +5 -28
- package/dist/http/vite-dev-server.d.ts +6 -9
- package/dist/http/vite-manifest.d.ts +19 -33
- package/dist/i18n/I18nManager.d.ts +12 -78
- package/dist/i18n/Translator.d.ts +3 -54
- package/dist/i18n/index.js +1 -1
- package/dist/i18n/loaders/JsonLoader.d.ts +4 -31
- package/dist/i18n/loaders/MemoryLoader.d.ts +1 -21
- package/dist/i18n/pluralization.d.ts +4 -13
- package/dist/i18n/types.d.ts +17 -69
- package/dist/{i18n-mcWi7LCd.js → i18n-Cg1aajRP.js} +31 -225
- package/dist/index.d.ts +13 -4
- package/dist/index.js +1036 -3080
- package/dist/internal/agent-preflight.d.ts +9 -21
- package/dist/internal/request.d.ts +10 -17
- package/dist/internal/request.js +2 -2
- package/dist/internal/route-path.d.ts +9 -21
- package/dist/internal/route-path.js +9 -21
- package/dist/internal/zod-compat.d.ts +55 -122
- package/dist/internal/zod-compat.js +39 -70
- package/dist/internal/zod-json-schema.d.ts +18 -54
- package/dist/internal/zod-json-schema.js +46 -123
- package/dist/jsx-runtime.d.ts +3 -8
- package/dist/lambda/index.d.ts +17 -79
- package/dist/lambda/index.js +11 -59
- package/dist/logging/LogManager.d.ts +1 -51
- package/dist/logging/Logger.d.ts +8 -47
- package/dist/logging/channels/ConsoleChannel.d.ts +1 -3
- package/dist/logging/channels/DailyFileChannel.d.ts +1 -5
- package/dist/logging/channels/FileChannel.d.ts +1 -3
- package/dist/logging/daily-file-path.d.ts +15 -0
- package/dist/logging/index.d.ts +1 -0
- package/dist/logging/index.js +2 -2
- package/dist/logging/types.d.ts +13 -45
- package/dist/{logging-CPaRMuPP.js → logging-zOY1XCtq.js} +83 -129
- package/dist/{loopback-guard-D0Kc7-xc.js → loopback-guard-DT9gHF0F.js} +41 -92
- package/dist/mail/Mail.d.ts +10 -106
- package/dist/mail/MailManager.d.ts +2 -60
- package/dist/mail/index.js +1 -1
- package/dist/mail/transports/LogTransport.d.ts +1 -4
- package/dist/mail/transports/MemoryTransport.d.ts +1 -63
- package/dist/mail/transports/ResendTransport.d.ts +1 -23
- package/dist/mail/transports/SmtpTransport.d.ts +1 -31
- package/dist/mail/types.d.ts +28 -150
- package/dist/{mail-DfEfSQEr.js → mail-76DWy9lj.js} +31 -289
- package/dist/mcp/McpServiceProvider.d.ts +4 -10
- package/dist/mcp/create-mcp-server.d.ts +25 -57
- package/dist/mcp/endpoint.d.ts +12 -36
- package/dist/mcp/index.js +1 -1
- package/dist/mvc/Controller.d.ts +46 -253
- package/dist/mvc/Router.d.ts +50 -129
- package/dist/mvc/inertia/InertiaEngine.d.ts +18 -48
- package/dist/mvc/inertia/shared.d.ts +6 -19
- package/dist/mvc/mount-route.d.ts +2 -6
- package/dist/mvc/view.d.ts +1 -2
- package/dist/notifications/Notification.d.ts +8 -75
- package/dist/notifications/NotificationManager.d.ts +15 -88
- package/dist/notifications/channels/DatabaseChannel.d.ts +1 -41
- package/dist/notifications/channels/MailChannel.d.ts +2 -31
- package/dist/notifications/channels/MemoryChannel.d.ts +2 -62
- package/dist/notifications/channels/SlackChannel.d.ts +3 -48
- package/dist/notifications/index.js +1 -1
- package/dist/notifications/notifiable-type.d.ts +3 -6
- package/dist/notifications/registry.d.ts +8 -27
- package/dist/notifications/types.d.ts +16 -53
- package/dist/{notifications-BGqmUNZ8.js → notifications-okWFs9ly.js} +37 -335
- package/dist/providers/AuthServiceProvider.d.ts +1 -3
- package/dist/providers/AuthorizationServiceProvider.d.ts +2 -3
- package/dist/providers/BroadcastServiceProvider.d.ts +1 -3
- package/dist/providers/CacheServiceProvider.d.ts +1 -3
- package/dist/providers/EncryptionServiceProvider.d.ts +1 -3
- package/dist/providers/ErrorServiceProvider.d.ts +1 -4
- package/dist/providers/EventServiceProvider.d.ts +1 -3
- package/dist/providers/HealthServiceProvider.d.ts +1 -3
- package/dist/providers/I18nServiceProvider.d.ts +6 -10
- package/dist/providers/InertiaServiceProvider.d.ts +1 -4
- package/dist/providers/LogServiceProvider.d.ts +1 -3
- package/dist/providers/MailServiceProvider.d.ts +1 -3
- package/dist/providers/NotificationServiceProvider.d.ts +1 -3
- package/dist/providers/OAuthServiceProvider.d.ts +1 -3
- package/dist/providers/QueueServiceProvider.d.ts +1 -3
- package/dist/providers/SchedulingServiceProvider.d.ts +1 -3
- package/dist/providers/StorageServiceProvider.d.ts +1 -3
- package/dist/queue/FailedJobReporter.d.ts +1 -24
- package/dist/queue/Job.d.ts +12 -99
- package/dist/queue/QueueManager.d.ts +6 -57
- package/dist/queue/Worker.d.ts +4 -65
- package/dist/queue/drivers/MemoryDriver.d.ts +3 -44
- package/dist/queue/drivers/RedisDriver.d.ts +7 -65
- package/dist/queue/drivers/SqsDriver.d.ts +6 -57
- package/dist/queue/drivers/SyncDriver.d.ts +10 -13
- package/dist/queue/index.js +2 -2
- package/dist/queue/types.d.ts +10 -92
- package/dist/{queue-CXrRK85G.js → queue-CcXCjuJI.js} +32 -260
- package/dist/redis/RedisApiTokenStore.d.ts +4 -56
- package/dist/redis/RedisEmailVerificationStore.d.ts +4 -37
- package/dist/redis/RedisOAuthStateStore.d.ts +2 -10
- package/dist/redis/RedisPasswordResetStore.d.ts +4 -37
- package/dist/redis/RedisRateLimitStore.d.ts +16 -49
- package/dist/redis/RedisSessionStore.d.ts +3 -44
- package/dist/redis/client.d.ts +2 -32
- package/dist/redis/index.js +47 -232
- package/dist/redis/redis-values.d.ts +6 -12
- package/dist/redis/scan-keys.d.ts +1 -4
- package/dist/request-CLOYytGP.js +68 -0
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.js +108 -74
- package/dist/scheduling/CronParser.d.ts +0 -29
- package/dist/scheduling/Schedule.d.ts +1 -153
- package/dist/scheduling/ScheduledTask.d.ts +0 -31
- package/dist/scheduling/Scheduler.d.ts +0 -70
- package/dist/scheduling/index.js +1 -1
- package/dist/scheduling/types.d.ts +4 -65
- package/dist/{scheduling-CPiEdtQd.js → scheduling-C6tcOtUl.js} +2 -287
- package/dist/storage/StorageManager.d.ts +0 -48
- package/dist/storage/drivers/LocalDriver.d.ts +1 -25
- package/dist/storage/drivers/MemoryDriver.d.ts +5 -35
- package/dist/storage/drivers/S3Driver.d.ts +6 -36
- package/dist/storage/drivers/s3-acl.d.ts +5 -10
- package/dist/storage/index.js +1 -1
- package/dist/storage/types.d.ts +27 -265
- package/dist/{storage-TLD9t0Q2.js → storage-BB59f07j.js} +17 -157
- package/dist/support/contained-path.d.ts +10 -20
- package/dist/support/error-polyfill.d.ts +4 -6
- package/dist/support/expiry.d.ts +17 -33
- package/dist/support/expiry.js +17 -33
- package/dist/support/import-map.d.ts +3 -7
- package/dist/support/inertia-defaults.d.ts +5 -10
- package/dist/support/redirect-target.d.ts +4 -6
- package/dist/support/stack-frames.d.ts +11 -50
- package/dist/support/trim-slashes.d.ts +4 -7
- package/dist/support/warn-once.d.ts +2 -6
- package/dist/{trim-slashes-ZJ_VsY5s.js → trim-slashes-BLY9hKAa.js} +4 -7
- package/dist/{vite-manifest-BGfWbPYp.js → vite-manifest-CTQp-SOo.js} +34 -58
- package/package.json +6 -2
- package/dist/client-Dd7vLcqp.js +0 -27
- package/dist/context-DoD0c7J_.js +0 -26
- package/dist/endpoint-D-20PiHY.js +0 -46
- package/dist/hot-disposables-WsTX2ySN.js +0 -281
- package/dist/request-CRVuIiQr.js +0 -78
|
@@ -1,38 +1,23 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
/**
|
|
3
|
-
* Options the `.guren/*.gen.ts` generators are called with. `cwd` is the
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* Options the `.guren/*.gen.ts` generators are called with. `cwd` is the project
|
|
4
|
+
* they resolve output paths against; nothing changes `process.cwd()`, which is
|
|
5
|
+
* process-wide and shared by concurrent requests.
|
|
6
6
|
*/
|
|
7
7
|
export interface CodegenOptions {
|
|
8
8
|
cwd: string;
|
|
9
9
|
force?: boolean;
|
|
10
10
|
}
|
|
11
|
-
/**
|
|
12
|
-
* What every scaffolder takes. `cwd` names the project the scaffold belongs
|
|
13
|
-
* to, for the same reason: this server handles requests for a workspace
|
|
14
|
-
* without a per-request `process.cwd()` to fall back on.
|
|
15
|
-
*/
|
|
11
|
+
/** What every scaffolder takes; `cwd` names the project, for the same reason. */
|
|
16
12
|
export interface ScaffoldOptions {
|
|
17
13
|
force?: boolean;
|
|
18
14
|
cwd?: string;
|
|
19
15
|
}
|
|
20
16
|
/**
|
|
21
|
-
* What a generator reports back. An empty `outputPath` means
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* `skipped` is an optional sentence explaining that empty `outputPath` when
|
|
26
|
-
* "nothing to describe" would be wrong — the pages generator declines to write
|
|
27
|
-
* a manifest into an app that cannot compile one, and an agent reading this
|
|
28
|
-
* result is exactly who needs to hear that a page it just wrote was ignored.
|
|
29
|
-
*
|
|
30
|
-
* `definitions` is what a generator extracted: the route manifest from
|
|
31
|
-
* `generateRouteTypes`, the Resource definitions from `generateDataTypes`.
|
|
32
|
-
* It stays opaque here — this package only carries it from one CLI call to
|
|
33
|
-
* the next (`generateApiClientTypes` consumes both) and never reads inside
|
|
34
|
-
* it, so mirroring the CLI's shapes would only create something to keep in
|
|
35
|
-
* sync.
|
|
17
|
+
* What a generator reports back. An empty `outputPath` means it found nothing to
|
|
18
|
+
* describe and wrote no file; `skipped` explains that when "nothing to describe"
|
|
19
|
+
* would be wrong. `definitions` stays opaque — this package only carries it from
|
|
20
|
+
* one CLI call to the next, so mirroring the CLI's shapes would need syncing.
|
|
36
21
|
*/
|
|
37
22
|
export interface CodegenResult {
|
|
38
23
|
outputPath?: string;
|
|
@@ -40,17 +25,12 @@ export interface CodegenResult {
|
|
|
40
25
|
skipped?: {
|
|
41
26
|
message: string;
|
|
42
27
|
} | null;
|
|
43
|
-
/**
|
|
44
|
-
* Diagnostics the generator wants surfaced to whoever asked for the run —
|
|
45
|
-
* a `resource` response hint naming an unknown Resource class, for
|
|
46
|
-
* instance. Non-fatal: the artifact was still written.
|
|
47
|
-
*/
|
|
28
|
+
/** Non-fatal diagnostics for whoever asked for the run; the artifact was still written. */
|
|
48
29
|
warnings?: string[];
|
|
49
30
|
}
|
|
50
31
|
/**
|
|
51
|
-
* CLI functions
|
|
52
|
-
*
|
|
53
|
-
* (@guren/server cannot depend on @guren/cli directly).
|
|
32
|
+
* CLI functions the MCP server wraps, injected at runtime because
|
|
33
|
+
* `@guren/server` cannot depend on `@guren/cli`.
|
|
54
34
|
*/
|
|
55
35
|
export interface GurenCliApi {
|
|
56
36
|
generateContext(opts: {
|
|
@@ -133,51 +113,39 @@ export interface GurenCliApi {
|
|
|
133
113
|
generateDataTypes(opts: CodegenOptions): Promise<CodegenResult | void>;
|
|
134
114
|
generateChannelTypes(opts: CodegenOptions): Promise<CodegenResult | void>;
|
|
135
115
|
/**
|
|
136
|
-
* Takes the route manifest `generateRouteTypes` returns
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
* Resource" and the client's `json()` stays untyped.
|
|
116
|
+
* Takes the route manifest `generateRouteTypes` returns. `resources` is what
|
|
117
|
+
* `generateDataTypes` extracted — without it every `resource` response hint
|
|
118
|
+
* is "unknown Resource" and the client's `json()` stays untyped.
|
|
140
119
|
*/
|
|
141
120
|
generateApiClientTypes(definitions: unknown[], opts: CodegenOptions & {
|
|
142
121
|
resources?: unknown[];
|
|
143
122
|
}): Promise<CodegenResult | void>;
|
|
144
123
|
/**
|
|
145
124
|
* Agent tools derived from the route manifest (RFC 0016), so it runs after
|
|
146
|
-
* `generateRouteTypes` and
|
|
147
|
-
*
|
|
148
|
-
* because `@guren/cli` is resolved from the app at runtime and may predate
|
|
149
|
-
* it; an older CLI simply generates no agent manifest.
|
|
125
|
+
* `generateRouteTypes` and `generateDataTypes`. Optional: `@guren/cli` is
|
|
126
|
+
* resolved from the app and an older one simply generates no agent manifest.
|
|
150
127
|
*/
|
|
151
128
|
generateAgentTypes?(definitions: unknown[], opts: CodegenOptions & {
|
|
152
129
|
resources?: unknown[];
|
|
153
130
|
}): Promise<CodegenResult | void>;
|
|
154
131
|
/**
|
|
155
|
-
* Route-dependent context generation
|
|
156
|
-
*
|
|
157
|
-
* runtime and may predate it — see `McpServiceProvider`.
|
|
132
|
+
* Route-dependent context generation in a fresh process. Optional because
|
|
133
|
+
* `@guren/cli` is resolved from the app at runtime and may predate it.
|
|
158
134
|
*/
|
|
159
135
|
createFreshContextApi?: () => Pick<GurenCliApi, 'generateContext' | 'generateEntityContext'>;
|
|
160
136
|
/**
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
* CLI
|
|
165
|
-
*
|
|
166
|
-
* Optional for the same runtime-resolution reason as the members above, and
|
|
167
|
-
* read for exactly that reason: an older CLI emits routes with no `agent`
|
|
168
|
-
* field at all, which reads identically to an app exposing no agent tools.
|
|
137
|
+
* Spelled exactly as `@guren/cli` exports it — this interface describes that
|
|
138
|
+
* module namespace, so a camelCase name here would read `undefined` off every
|
|
139
|
+
* real CLI. Optional for the runtime-resolution reason above, and read for it:
|
|
140
|
+
* an older CLI emits routes with no `agent` field, which looks like no tools.
|
|
169
141
|
*/
|
|
170
142
|
CONTEXT_ROUTE_FEATURES?: readonly string[];
|
|
171
143
|
/**
|
|
172
|
-
* Every route as a context route, without
|
|
173
|
-
*
|
|
174
|
-
* `generateContext` when an older CLI does not provide it.
|
|
144
|
+
* Every route as a context route, without the rest of the project context.
|
|
145
|
+
* Optional; `guren_agent_surface` falls back to `generateContext`.
|
|
175
146
|
*/
|
|
176
147
|
loadContextRoutes?(cwd: string, routesFile?: string, loadErrors?: string[]): Promise<unknown[]>;
|
|
177
|
-
/**
|
|
178
|
-
* The OKF docs relation graph (RFC 0005). Optional for the same
|
|
179
|
-
* runtime-resolution reason as above.
|
|
180
|
-
*/
|
|
148
|
+
/** The OKF docs relation graph (RFC 0005). Optional, like the above. */
|
|
181
149
|
buildDocsGraphReport?(options: {
|
|
182
150
|
cwd?: string;
|
|
183
151
|
entity?: string;
|
package/dist/mcp/endpoint.d.ts
CHANGED
|
@@ -1,47 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Identity and activation rules for the dev-only MCP endpoint.
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* application bootstrap can reason about the endpoint without pulling in
|
|
6
|
-
* `@modelcontextprotocol/sdk`, which apps are not required to install.
|
|
7
|
-
* The loopback access guard itself is shared with the docs viewer — see
|
|
8
|
-
* `http/middleware/loopback-guard.ts`.
|
|
2
|
+
* Identity and activation rules for the dev-only MCP endpoint. Free of MCP SDK
|
|
3
|
+
* imports so middleware (CSRF) and the app bootstrap can reason about the
|
|
4
|
+
* endpoint without `@modelcontextprotocol/sdk`, which apps need not install.
|
|
9
5
|
*/
|
|
10
6
|
import type { MiddlewareHandler } from 'hono';
|
|
11
7
|
export { isLoopbackAddress, isLoopbackOrigin } from '../http/middleware/loopback-guard.js';
|
|
12
8
|
export declare const MCP_ENDPOINT_PATH = "/_guren/mcp";
|
|
13
9
|
/**
|
|
14
|
-
* Whether the MCP endpoint is mounted
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* The environment reads below are deliberately written as plain member
|
|
21
|
-
* access. Do not "harden" them with optional chaining: the deploy plugins
|
|
22
|
-
* bundle server code with `--define 'process.env.NODE_ENV="production"'`,
|
|
23
|
-
* and a define matches one exact expression. Inserting `?.` produces a
|
|
24
|
-
* different expression that no define touches, leaving this gate a runtime
|
|
25
|
-
* read — and on hosts where the platform's environment is not in
|
|
26
|
-
* `process.env` by the time the module graph evaluates (workerd is the
|
|
27
|
-
* documented case; see the comment on the Cloudflare plugin's `define`),
|
|
28
|
-
* that runtime read answers "not production" and the gate silently reopens.
|
|
29
|
-
* A test in `tests/mcp/endpoint.test.ts` reads this file and fails on any
|
|
30
|
-
* optional chain after `process.env`, because nothing observable at runtime
|
|
31
|
-
* distinguishes the two forms.
|
|
32
|
-
*
|
|
33
|
-
* The `typeof process` check covers the only runtimes without `process`;
|
|
34
|
-
* every runtime the framework supports that has `process` has `process.env`.
|
|
10
|
+
* Whether the MCP endpoint is mounted: opt-in via `GUREN_MCP=1`, never in
|
|
11
|
+
* production (it exposes project introspection and code generation). The env
|
|
12
|
+
* reads are plain member access on purpose: the deploy plugins settle NODE_ENV
|
|
13
|
+
* with `--define`, which matches one exact expression, so an optional chain
|
|
14
|
+
* leaves a runtime read that reopens the gate on workerd; `tests/mcp/endpoint.test.ts` pins the form.
|
|
35
15
|
*/
|
|
36
16
|
export declare function isMcpEndpointEnabled(): boolean;
|
|
37
17
|
/**
|
|
38
|
-
* Restricts the MCP endpoint to the developer's own machine.
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* their `Origin` is loopback (the check the MCP specification asks local
|
|
43
|
-
* servers for), and every caller is rejected unless its socket peer is
|
|
44
|
-
* loopback. The guard fails closed when the runtime reports no peer at
|
|
45
|
-
* all; see `http/middleware/loopback-guard.ts` for the opt-out.
|
|
18
|
+
* Restricts the MCP endpoint to the developer's own machine. The endpoint is
|
|
19
|
+
* CSRF-exempt (agent clients carry no token), so this guard takes over: a web
|
|
20
|
+
* page is rejected unless its `Origin` is loopback, and every caller unless its
|
|
21
|
+
* socket peer is. It fails closed when the runtime reports no peer at all.
|
|
46
22
|
*/
|
|
47
23
|
export declare function createMcpAccessGuard(): MiddlewareHandler;
|
package/dist/mcp/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { r as createMcpServer, t as McpServiceProvider } from "../McpServiceProvider-
|
|
1
|
+
import { r as createMcpServer, t as McpServiceProvider } from "../McpServiceProvider-nNcbCIQX.js";
|
|
2
2
|
export { McpServiceProvider, createMcpServer };
|
package/dist/mvc/Controller.d.ts
CHANGED
|
@@ -7,10 +7,7 @@ import { type RegisteredTranslationKey, type ReplacementValues } from '../i18n/i
|
|
|
7
7
|
import type { AuthContext } from '../auth/types.js';
|
|
8
8
|
import type { ServiceBindings } from '../container/bindings.js';
|
|
9
9
|
import type { ContainerLike } from '../container/types.js';
|
|
10
|
-
/**
|
|
11
|
-
* Duck-type interface for Zod-like schemas.
|
|
12
|
-
* Allows validation without a direct Zod dependency.
|
|
13
|
-
*/
|
|
10
|
+
/** Duck-typed Zod-like schema, so validation needs no direct Zod dependency. */
|
|
14
11
|
interface ZodLikeSchema<T> {
|
|
15
12
|
safeParse(data: unknown): {
|
|
16
13
|
success: true;
|
|
@@ -25,9 +22,7 @@ interface ZodLikeSchema<T> {
|
|
|
25
22
|
};
|
|
26
23
|
};
|
|
27
24
|
}
|
|
28
|
-
/**
|
|
29
|
-
* Result type for safe validation methods (discriminated union).
|
|
30
|
-
*/
|
|
25
|
+
/** Result type for safe validation methods (discriminated union). */
|
|
31
26
|
export type SafeValidationResult<T> = {
|
|
32
27
|
success: true;
|
|
33
28
|
data: T;
|
|
@@ -36,15 +31,10 @@ export type SafeValidationResult<T> = {
|
|
|
36
31
|
errors: Record<string, string>;
|
|
37
32
|
};
|
|
38
33
|
/**
|
|
39
|
-
* The record `Controller.model()` returns
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* Anything without a usable marker — a class extending `Model` directly
|
|
44
|
-
* without redeclaring it, or a plain `{ findOrFail }` adapter — falls back to
|
|
45
|
-
* whatever its `findOrFail` resolves to. The marker is only trusted when it
|
|
46
|
-
* names an object type: `Model`'s own is `unknown`, and an unrelated
|
|
47
|
-
* `recordType` on some adapter (a string tag, say) describes no record.
|
|
34
|
+
* The record `Controller.model()` returns. ORM models carry their row type as a
|
|
35
|
+
* `recordType` marker (set by `defineModel()`); `findOrFail`'s return type cannot
|
|
36
|
+
* stand in because it is generic in `this` and `ReturnType` widens it to the base
|
|
37
|
+
* row. The marker is trusted only when it names an object type.
|
|
48
38
|
*/
|
|
49
39
|
export type BoundModelRecord<T extends {
|
|
50
40
|
findOrFail(...args: any[]): Promise<any>;
|
|
@@ -84,32 +74,19 @@ type InertiaResponseOptions = Omit<InertiaOptions, 'url' | 'request'> & {
|
|
|
84
74
|
};
|
|
85
75
|
type InertiaPageComponent<TPage extends InertiaPageContractLike> = TPage['id'];
|
|
86
76
|
type InertiaPageProps<TPage extends InertiaPageContractLike> = NonNullable<TPage['__props']>;
|
|
87
|
-
/**
|
|
88
|
-
* Constructor type for controllers with optional DI.
|
|
89
|
-
*/
|
|
77
|
+
/** Constructor type for controllers with optional DI. */
|
|
90
78
|
export type ControllerConstructorWithInject = {
|
|
91
79
|
new (...args: any[]): Controller;
|
|
92
80
|
inject?: readonly string[];
|
|
93
81
|
};
|
|
94
82
|
/**
|
|
95
|
-
* Base controller inspired by Laravel's expressive API. Subclasses
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* Supports dependency injection via the `static inject` convention:
|
|
100
|
-
* ```typescript
|
|
101
|
-
* class PostController extends Controller {
|
|
102
|
-
* static inject = ['cache', 'events'] as const
|
|
103
|
-
* constructor(private cache: CacheManager, private events: EventManager) { super() }
|
|
104
|
-
* }
|
|
105
|
-
* ```
|
|
83
|
+
* Base controller inspired by Laravel's expressive API. Subclasses reach the
|
|
84
|
+
* Hono context through the protected `ctx` getter. Dependencies are declared
|
|
85
|
+
* with `static inject = ['cache'] as const` and passed to the constructor.
|
|
106
86
|
*/
|
|
107
87
|
export declare class Controller {
|
|
108
88
|
#private;
|
|
109
|
-
/**
|
|
110
|
-
* Dependencies to inject from the container.
|
|
111
|
-
* Override in subclasses to declare required services.
|
|
112
|
-
*/
|
|
89
|
+
/** Services to resolve from the container and pass to the constructor. */
|
|
113
90
|
static inject?: readonly string[];
|
|
114
91
|
private context?;
|
|
115
92
|
private parsedBody?;
|
|
@@ -118,29 +95,12 @@ export declare class Controller {
|
|
|
118
95
|
setContext(context: Context): void;
|
|
119
96
|
/** @internal Called by the router to inject the DI container. */
|
|
120
97
|
setContainer(container: ContainerLike): void;
|
|
121
|
-
/**
|
|
122
|
-
* Store a resolved model instance from route model binding.
|
|
123
|
-
* @internal Called by the router, not intended for direct use.
|
|
124
|
-
*/
|
|
98
|
+
/** @internal Called by the router to store a route-bound model instance. */
|
|
125
99
|
setResolvedModel(modelClass: unknown, instance: unknown): void;
|
|
126
100
|
/**
|
|
127
101
|
* Retrieve a model instance resolved via route model binding — a per-route
|
|
128
|
-
* `bind` option or a router-level `router.bind(param, Model)`.
|
|
129
|
-
* primary key
|
|
130
|
-
* `[Model, column]` tuple.
|
|
131
|
-
*
|
|
132
|
-
* @example
|
|
133
|
-
* ```typescript
|
|
134
|
-
* // routes/web.ts
|
|
135
|
-
* posts.get('/:id', { bind: { id: Post }, name: 'posts.show' }, [PostController, 'show'])
|
|
136
|
-
* posts.get('/by-slug/:slug', { bind: { slug: [Post, 'slug'] } }, [PostController, 'show'])
|
|
137
|
-
*
|
|
138
|
-
* // PostController.ts
|
|
139
|
-
* async show() {
|
|
140
|
-
* const post = this.model(Post) // typed as PostRecord
|
|
141
|
-
* return this.inertia(pages.posts.Show, { post })
|
|
142
|
-
* }
|
|
143
|
-
* ```
|
|
102
|
+
* `bind` option or a router-level `router.bind(param, Model)`. The class
|
|
103
|
+
* alone looks up by primary key, a `[Model, column]` tuple by that column.
|
|
144
104
|
*/
|
|
145
105
|
protected model<T extends {
|
|
146
106
|
findOrFail(...args: any[]): Promise<any>;
|
|
@@ -148,20 +108,9 @@ export declare class Controller {
|
|
|
148
108
|
protected get ctx(): Context;
|
|
149
109
|
protected get request(): import("hono").HonoRequest<any, unknown>;
|
|
150
110
|
/**
|
|
151
|
-
* Get an uploaded file from a multipart request.
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
* empty. Hono caches the parsed body, so this composes with other body
|
|
155
|
-
* reads in the same request.
|
|
156
|
-
*
|
|
157
|
-
* @example
|
|
158
|
-
* ```typescript
|
|
159
|
-
* const avatar = await this.file('avatar')
|
|
160
|
-
* if (!avatar) {
|
|
161
|
-
* throw ValidationException.withMessages({ avatar: 'Choose a file.' })
|
|
162
|
-
* }
|
|
163
|
-
* await storage.disk().put(`avatars/${avatar.name}`, Buffer.from(await avatar.arrayBuffer()))
|
|
164
|
-
* ```
|
|
111
|
+
* Get an uploaded file from a multipart request. Returns null when the field
|
|
112
|
+
* is missing, is not a file, or the upload is empty. Hono caches the parsed
|
|
113
|
+
* body, so this composes with other body reads in the same request.
|
|
165
114
|
*/
|
|
166
115
|
protected file(name: string): Promise<File | null>;
|
|
167
116
|
/**
|
|
@@ -169,125 +118,44 @@ export declare class Controller {
|
|
|
169
118
|
* Returns an empty array when none were uploaded.
|
|
170
119
|
*/
|
|
171
120
|
protected files(name: string): Promise<File[]>;
|
|
172
|
-
/**
|
|
173
|
-
* The one multipart read behind {@link file} and {@link files}, guarded so a
|
|
174
|
-
* body the parser cannot decode carries no files rather than crashing the
|
|
175
|
-
* request: it reads as `{}`, which is the same answer both helpers already
|
|
176
|
-
* give for a field that is simply absent — `null` and `[]`. Left to throw,
|
|
177
|
-
* the parser's `TypeError` escaped as a 500 reporting the exception and a
|
|
178
|
-
* stack, the defect {@link parseRequestBody} fixes for the validation paths.
|
|
179
|
-
*
|
|
180
|
-
* Deliberately *not* routed through `parseRequestBody()`, which looks like
|
|
181
|
-
* the same rule and is not: it parses without `{ all: true }` and flattens a
|
|
182
|
-
* repeated field to its first value, so sharing it would silently reduce
|
|
183
|
-
* `files()` to one file per field. `{ all: true }` is the contract here, and
|
|
184
|
-
* a malformed-body test cannot see its loss — hence the separate helper.
|
|
185
|
-
*
|
|
186
|
-
* try/catch rather than `.catch()`, for the reason given on the shared
|
|
187
|
-
* fallback: `parseBody` may throw synchronously as well as reject, and only
|
|
188
|
-
* one of those two shapes reaches a `.catch()`.
|
|
189
|
-
*
|
|
190
|
-
* It fails open in one direction, deliberately and for the same reason
|
|
191
|
-
* {@link parseRequestBody} does: a body already consumed upstream reads as
|
|
192
|
-
* "no upload" rather than throwing, so a middleware-ordering bug loses the
|
|
193
|
-
* 500 that used to announce it. Telling that apart from a client's malformed
|
|
194
|
-
* body means matching runtime-specific error codes, which answer differently
|
|
195
|
-
* on Bun, Node and Workers.
|
|
196
|
-
*/
|
|
197
|
-
private parseUploads;
|
|
198
121
|
protected get auth(): AuthContext;
|
|
199
122
|
protected make<K extends keyof ServiceBindings>(key: K): ServiceBindings[K];
|
|
200
123
|
protected make<T>(key: string): T;
|
|
201
|
-
/**
|
|
202
|
-
* Get the authenticated API token or throw AuthenticationException.
|
|
203
|
-
*
|
|
204
|
-
* @example
|
|
205
|
-
* ```typescript
|
|
206
|
-
* const { userId, abilities } = this.apiToken()
|
|
207
|
-
* ```
|
|
208
|
-
*/
|
|
124
|
+
/** Get the authenticated API token, or throw AuthenticationException. */
|
|
209
125
|
protected apiToken(): {
|
|
210
126
|
token: import("../index.js").ApiToken;
|
|
211
127
|
userId: string | number;
|
|
212
128
|
abilities: string[];
|
|
213
129
|
};
|
|
214
|
-
/**
|
|
215
|
-
* Get the authenticated user ID from the API token.
|
|
216
|
-
*
|
|
217
|
-
* @example
|
|
218
|
-
* ```typescript
|
|
219
|
-
* const userId = this.apiTokenUserId()
|
|
220
|
-
* ```
|
|
221
|
-
*/
|
|
130
|
+
/** Get the authenticated user ID from the API token. */
|
|
222
131
|
protected apiTokenUserId(): string | number;
|
|
223
132
|
/**
|
|
224
|
-
* Authorize the current user (or guest) for an ability
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
* the model class alongside the record to resolve the policy:
|
|
229
|
-
*
|
|
230
|
-
* @example
|
|
231
|
-
* ```typescript
|
|
232
|
-
* const post = await Post.findOrFail(id)
|
|
233
|
-
* await this.authorize('update', [Post, post])
|
|
234
|
-
* await this.authorize('create', Post)
|
|
235
|
-
* ```
|
|
133
|
+
* Authorize the current user (or guest) for an ability; throws
|
|
134
|
+
* AuthorizationException (403) when denied. ORM records are plain objects
|
|
135
|
+
* with no constructor information, so pass the model class alongside the
|
|
136
|
+
* record: `await this.authorize('update', [Post, post])`.
|
|
236
137
|
*/
|
|
237
138
|
protected authorize(ability: string, ...args: unknown[]): Promise<void>;
|
|
238
|
-
/**
|
|
239
|
-
* Check whether the current user (or guest) can perform an ability.
|
|
240
|
-
*
|
|
241
|
-
* @example
|
|
242
|
-
* ```typescript
|
|
243
|
-
* if (await this.can('update', [Post, post])) { ... }
|
|
244
|
-
* ```
|
|
245
|
-
*/
|
|
139
|
+
/** Check an ability without throwing: `await this.can('update', [Post, post])`. */
|
|
246
140
|
protected can(ability: string, ...args: unknown[]): Promise<boolean>;
|
|
247
141
|
private gateUser;
|
|
248
142
|
/**
|
|
249
143
|
* Render a `hono/jsx` component to a plain server-rendered HTML response —
|
|
250
|
-
* the non-hydrating counterpart to {@link inertia}
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
* Escaping covers markup: text children and attribute values are escaped,
|
|
255
|
-
* so tag and attribute breakout cannot occur. It does **not** validate URL
|
|
256
|
-
* schemes — a `javascript:` href built from user data is emitted verbatim.
|
|
257
|
-
* Sanitize user-supplied URLs upstream (e.g. `@guren/plugin-markdown`'s
|
|
258
|
-
* allowlist) before they reach a View.
|
|
259
|
-
*
|
|
260
|
-
* @example
|
|
261
|
-
* ```typescript
|
|
262
|
-
* async show() {
|
|
263
|
-
* const post = await Post.findOrFail(id)
|
|
264
|
-
* return this.view(PostPage, { post })
|
|
265
|
-
* }
|
|
266
|
-
* ```
|
|
144
|
+
* the non-hydrating counterpart to {@link inertia} (RFC 0014). Escaping
|
|
145
|
+
* covers markup only, not URL schemes: a `javascript:` href built from user
|
|
146
|
+
* data is emitted verbatim, so sanitize user-supplied URLs upstream.
|
|
267
147
|
*/
|
|
268
148
|
protected view<P>(component: FC<P>, props: P, options?: ViewOptions): Promise<Response>;
|
|
269
149
|
protected inertia<TPage extends InertiaPageContractLike>(page: TPage, props: InertiaPageProps<TPage>, options?: InertiaResponseOptions): Promise<InertiaResponse<InertiaPageComponent<TPage>, InertiaPageProps<TPage> & ResolvedSharedInertiaProps>>;
|
|
270
150
|
protected inertia<Component extends string, Props extends DefaultInertiaProps>(component: Component, props: Props, options?: InertiaResponseOptions): Promise<InertiaResponse<Component, Props & ResolvedSharedInertiaProps>>;
|
|
271
151
|
/**
|
|
272
|
-
* Locale
|
|
273
|
-
*
|
|
274
|
-
* locale (the router-injected container binding, then the `setI18n()`
|
|
275
|
-
* global). Falls back to `'en'` when no i18n is configured.
|
|
152
|
+
* Locale for the current request: the request-scoped `locale` context
|
|
153
|
+
* variable wins over the app-wide i18n locale. Falls back to `'en'`.
|
|
276
154
|
*/
|
|
277
155
|
protected get locale(): string;
|
|
278
156
|
/**
|
|
279
|
-
* Translate a key for the current request locale
|
|
280
|
-
*
|
|
281
|
-
* Uses the request-scoped translator bound by the locale detection
|
|
282
|
-
* middleware when present, falling back to a translator scoped to
|
|
283
|
-
* `this.locale` from the container's `i18n` binding (then the `setI18n()`
|
|
284
|
-
* global).
|
|
285
|
-
*
|
|
286
|
-
* @example
|
|
287
|
-
* ```typescript
|
|
288
|
-
* this.t('posts.created')
|
|
289
|
-
* this.t('posts.greeting', { name: user.name })
|
|
290
|
-
* ```
|
|
157
|
+
* Translate a key for the current request locale, using the request-scoped
|
|
158
|
+
* translator the locale middleware bound, else one scoped to `this.locale`.
|
|
291
159
|
*/
|
|
292
160
|
protected t(key: RegisteredTranslationKey, replacements?: ReplacementValues): string;
|
|
293
161
|
/**
|
|
@@ -298,118 +166,43 @@ export declare class Controller {
|
|
|
298
166
|
protected json<T>(data: T, init?: ResponseInit): Response;
|
|
299
167
|
protected text(body: string, init?: ResponseInit): Response;
|
|
300
168
|
protected redirect(url: string, options?: RedirectOptions): Response;
|
|
301
|
-
/**
|
|
302
|
-
* Return a 204 No Content response.
|
|
303
|
-
*/
|
|
304
169
|
protected noContent(): Response;
|
|
305
|
-
/**
|
|
306
|
-
* Return a 201 Created response with JSON data.
|
|
307
|
-
*/
|
|
308
170
|
protected created<T>(data?: T, init?: ResponseInit): Response;
|
|
309
|
-
/**
|
|
310
|
-
* Return a 202 Accepted response with optional JSON data.
|
|
311
|
-
*/
|
|
312
171
|
protected accepted<T>(data?: T, init?: ResponseInit): Response;
|
|
313
172
|
private jsonStatus;
|
|
314
|
-
/**
|
|
315
|
-
* Get a specific input value from the request body or query parameters.
|
|
316
|
-
* Body values take precedence over query parameters.
|
|
317
|
-
*/
|
|
173
|
+
/** Get an input value; body values take precedence over query parameters. */
|
|
318
174
|
protected input<T = unknown>(key: string, defaultValue?: T): Promise<T | undefined>;
|
|
319
|
-
/**
|
|
320
|
-
* Get a query parameter value.
|
|
321
|
-
*/
|
|
322
175
|
protected query(key: string, defaultValue?: string): string | undefined;
|
|
323
|
-
/**
|
|
324
|
-
* Get only the specified keys from the request body.
|
|
325
|
-
*/
|
|
176
|
+
/** Get only the specified keys from the request body. */
|
|
326
177
|
protected only(...keys: string[]): Promise<Record<string, unknown>>;
|
|
327
|
-
/**
|
|
328
|
-
* Get all request body values except the specified keys.
|
|
329
|
-
*/
|
|
178
|
+
/** Get all request body values except the specified keys. */
|
|
330
179
|
protected except(...keys: string[]): Promise<Record<string, unknown>>;
|
|
331
|
-
/**
|
|
332
|
-
* Check if a key exists in the request body.
|
|
333
|
-
*/
|
|
180
|
+
/** Check if a key exists in the request body. */
|
|
334
181
|
protected has(key: string): Promise<boolean>;
|
|
335
182
|
/** Flatten query string arrays to scalar values for cleaner schema usage. */
|
|
336
183
|
private flattenQueries;
|
|
337
|
-
/**
|
|
338
|
-
* Validate the request body against a Zod-like schema.
|
|
339
|
-
* Throws ValidationException on failure.
|
|
340
|
-
*
|
|
341
|
-
* @example
|
|
342
|
-
* ```typescript
|
|
343
|
-
* const data = await this.validateBody(CreatePostSchema)
|
|
344
|
-
* ```
|
|
345
|
-
*/
|
|
184
|
+
/** Validate the request body; throws ValidationException on failure. */
|
|
346
185
|
protected validateBody<T>(schema: ZodLikeSchema<T>): Promise<T>;
|
|
347
|
-
/**
|
|
348
|
-
* Validate query parameters against a Zod-like schema.
|
|
349
|
-
* Throws ValidationException on failure.
|
|
350
|
-
*
|
|
351
|
-
* @example
|
|
352
|
-
* ```typescript
|
|
353
|
-
* const { page } = this.validateQuery(PageQuerySchema)
|
|
354
|
-
* ```
|
|
355
|
-
*/
|
|
186
|
+
/** Validate query parameters; throws ValidationException on failure. */
|
|
356
187
|
protected validateQuery<T>(schema: ZodLikeSchema<T>): T;
|
|
357
|
-
/**
|
|
358
|
-
* Validate route parameters against a Zod-like schema.
|
|
359
|
-
* Throws ValidationException on failure.
|
|
360
|
-
*
|
|
361
|
-
* @example
|
|
362
|
-
* ```typescript
|
|
363
|
-
* const { id } = this.validateParams(PostIdParamSchema)
|
|
364
|
-
* ```
|
|
365
|
-
*/
|
|
188
|
+
/** Validate route parameters; throws ValidationException on failure. */
|
|
366
189
|
protected validateParams<T>(schema: ZodLikeSchema<T>): T;
|
|
367
|
-
/**
|
|
368
|
-
* Validate the request body against a Zod-like schema without throwing.
|
|
369
|
-
* Returns a discriminated union: `{ success: true, data }` or `{ success: false, errors }`.
|
|
370
|
-
*
|
|
371
|
-
* @example
|
|
372
|
-
* ```typescript
|
|
373
|
-
* const result = await this.validateBodySafe(CreatePostSchema)
|
|
374
|
-
* if (!result.success) {
|
|
375
|
-
* return this.inertia(pages.posts.New, { errors: result.errors }, { status: 422 })
|
|
376
|
-
* }
|
|
377
|
-
* const { title, body } = result.data
|
|
378
|
-
* ```
|
|
379
|
-
*/
|
|
190
|
+
/** Validate the request body without throwing; returns data or field errors. */
|
|
380
191
|
protected validateBodySafe<T>(schema: ZodLikeSchema<T>): Promise<SafeValidationResult<T>>;
|
|
381
|
-
/**
|
|
382
|
-
* Validate query parameters against a Zod-like schema without throwing.
|
|
383
|
-
* Returns a discriminated union: `{ success: true, data }` or `{ success: false, errors }`.
|
|
384
|
-
*/
|
|
192
|
+
/** Validate query parameters without throwing; returns data or field errors. */
|
|
385
193
|
protected validateQuerySafe<T>(schema: ZodLikeSchema<T>): SafeValidationResult<T>;
|
|
386
|
-
/**
|
|
387
|
-
* Validate route parameters against a Zod-like schema without throwing.
|
|
388
|
-
* Returns a discriminated union: `{ success: true, data }` or `{ success: false, errors }`.
|
|
389
|
-
*/
|
|
194
|
+
/** Validate route parameters without throwing; returns data or field errors. */
|
|
390
195
|
protected validateParamsSafe<T>(schema: ZodLikeSchema<T>): SafeValidationResult<T>;
|
|
391
196
|
private runValidation;
|
|
392
197
|
private runValidationSafe;
|
|
393
198
|
/**
|
|
394
|
-
* The parsed body as sent: an array stays an array, a
|
|
395
|
-
*
|
|
396
|
-
*
|
|
397
|
-
*
|
|
398
|
-
*
|
|
399
|
-
* Memoized in a box rather than by truthiness: a body of `null`, `''`, `0`
|
|
400
|
-
* or `false` is a parsed body, and re-reading the request would find the
|
|
401
|
-
* stream consumed.
|
|
402
|
-
*
|
|
403
|
-
* No fallback of its own: an unparseable body already arrives here as `{}`
|
|
404
|
-
* from {@link parseRequestBody}, which is what gives every dispatch path the
|
|
405
|
-
* same answer. A second fallback here could only diverge from that one.
|
|
199
|
+
* The parsed body as sent: an array stays an array, so a non-object contract
|
|
200
|
+
* stays reachable. Boxed rather than memoized by truthiness — `null`, `''`,
|
|
201
|
+
* `0` and `false` are parsed bodies, and re-reading would find the stream
|
|
202
|
+
* consumed. No fallback here: {@link parseRequestBody} already yields `{}`.
|
|
406
203
|
*/
|
|
407
204
|
private getRawBody;
|
|
408
|
-
/**
|
|
409
|
-
* The record view of {@link getRawBody}, for the field-by-field helpers
|
|
410
|
-
* (`input`, `only`, `except`, `has`). A non-object body has no field to
|
|
411
|
-
* read, so it reads as `{}`.
|
|
412
|
-
*/
|
|
205
|
+
/** The record view of {@link getRawBody}; a non-object body reads as `{}`. */
|
|
413
206
|
private getBody;
|
|
414
207
|
}
|
|
415
208
|
export {};
|