@guren/server 2.23.3 → 2.25.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/DailyFileChannel-CTTPA0EF.js +114 -0
- package/dist/{DocsViewerServiceProvider-DWnlXx_y.js → DocsViewerServiceProvider-CIRNHQ2I.js} +2 -2
- package/dist/{authorization-0mCGUFoI.js → Gate-YOt54xGF.js} +2 -217
- package/dist/{Job-BVvaY-7p.js → Job-COMzBNOL.js} +3 -10
- package/dist/McpServiceProvider-B-LioPSz.js +43 -0
- package/dist/Resource-BdYd4J9a.js +1035 -0
- package/dist/{loopback-guard-DT9gHF0F.js → ServiceProvider-DDW3MqQJ.js} +10 -68
- package/dist/agent/audit-file.d.ts +3 -0
- package/dist/agent/audit-sink.d.ts +16 -0
- package/dist/agent/call-budget.d.ts +22 -0
- package/dist/agent/events.d.ts +6 -6
- package/dist/api-token-BbgDEd6j.js +298 -0
- package/dist/audit-file-DocumbCr.js +29 -0
- package/dist/auth/index.js +2 -1
- package/dist/auth/oauth/index.d.ts +7 -0
- package/dist/{auth-Jp_MB8Il.js → auth-vFeem6uM.js} +8 -298
- package/dist/authorization/index.js +2 -1
- package/dist/authorization-BLhwA2Yh.js +217 -0
- package/dist/broadcasting/index.js +1 -1
- package/dist/{broadcasting-DVfG2vgN.js → broadcasting-BUBCPCnu.js} +1 -1
- package/dist/config/define.d.ts +49 -0
- package/dist/config/env-reads.d.ts +12 -0
- package/dist/config/env.d.ts +122 -0
- package/dist/container/Container.d.ts +13 -2
- package/dist/container/ServiceProvider.d.ts +7 -0
- package/dist/container/bindings.d.ts +8 -0
- package/dist/{default-application-Chbrul_m.js → default-application-D5ezhhiV.js} +18 -1
- package/dist/encryption/index.js +1 -1
- package/dist/{encryption-BRjZnshr.js → encryption-D1dxfMqD.js} +1 -1
- package/dist/{endpoint-BXipU2Jj.js → endpoint-CTIzcagh.js} +1 -1
- package/dist/{endpoint-Dsw3Acvq.js → endpoint-Coq0K_6I.js} +1 -1
- package/dist/events/index.js +1 -1
- package/dist/{events-CaJKZ2qk.js → events-c94CdUFc.js} +1 -1
- package/dist/http/Application.d.ts +22 -0
- package/dist/http/vite-manifest.d.ts +5 -1
- package/dist/i18n/index.js +1 -1
- package/dist/i18n/injected-translations.d.ts +8 -0
- package/dist/i18n/loaders/JsonLoader.d.ts +3 -2
- package/dist/{i18n-DRo1g0AN.js → i18n-DqcRD4qL.js} +4 -3
- package/dist/index.d.ts +11 -0
- package/dist/index.js +525 -1075
- package/dist/inertia-defaults-BjrcT7za.js +30 -0
- package/dist/internal/request.d.ts +4 -3
- package/dist/internal/request.js +2 -1
- package/dist/internal/testing.d.ts +17 -0
- package/dist/internal/testing.js +6 -0
- package/dist/lambda/index.js +1 -1
- package/dist/logging/index.js +2 -1
- package/dist/{logging-CXotojgW.js → logging-YbKmbAd7.js} +3 -113
- package/dist/loopback-guard-CG8xB4v0.js +68 -0
- package/dist/mail/index.js +1 -1
- package/dist/{mail-zMjQimaJ.js → mail-uRBrUl9q.js} +3 -2
- package/dist/mcp/McpServiceProvider.d.ts +21 -4
- package/dist/mcp/endpoint.d.ts +3 -3
- package/dist/mcp/index.d.ts +0 -2
- package/dist/mcp/index.js +2 -2
- package/dist/mvc/Controller.d.ts +11 -1
- package/dist/mvc/Router.d.ts +6 -0
- package/dist/mvc/inertia/InertiaEngine.d.ts +2 -0
- package/dist/mvc/validated-input.d.ts +55 -0
- package/dist/notifications/index.js +1 -1
- package/dist/{notifications-BLid0Y6M.js → notifications-LHuujttf.js} +2 -2
- package/dist/providers/ConfigServiceProvider.d.ts +19 -0
- package/dist/queue/index.js +2 -2
- package/dist/{queue-IdJjqbyJ.js → queue-BiBn5Sff.js} +1 -1
- package/dist/resolve-optional-ax6gPWTp.js +9 -0
- package/dist/runtime/index.js +2 -1
- package/dist/validated-input-D84J8wcC.js +25 -0
- package/dist/{vite-manifest-DeWRFXTm.js → vite-manifest-C5kqRoBV.js} +7 -32
- package/package.json +6 -3
- package/dist/McpServiceProvider-BvJRcDOm.js +0 -458
- package/dist/mcp/create-mcp-server.d.ts +0 -180
package/dist/index.js
CHANGED
|
@@ -1,104 +1,55 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { S as ensureErrorStackTracePolyfill, a as renderDocument, b as setInertiaDocument, c as getRequestLocale, d as mountModuleRoutes, f as definePlugin, g as shareInertiaProps, h as setInertiaSharedProps, i as Controller, l as getRequestTranslator, m as resolveSharedInertiaProps, n as Resource, o as LOCALE_CONTEXT_KEY, p as getInertiaSharedPropsResolver, r as collect, s as detectLocaleMiddleware, t as JsonResource, u as defineModule, v as inertia, x as setInertiaSsrRenderer } from "./Resource-BdYd4J9a.js";
|
|
2
|
+
import { a as parseRequestPayload, i as parseRequestBody, n as flattenRequestQueries, r as formatValidationErrors } from "./request-CLOYytGP.js";
|
|
3
|
+
import { i as setValidatedInput, n as getValidatedInput } from "./validated-input-D84J8wcC.js";
|
|
2
4
|
import { t as HttpException } from "./HttpException-BlQ2yEmT.js";
|
|
3
5
|
import { n as ValidationException } from "./errors-JpkcCjjn.js";
|
|
4
|
-
import {
|
|
6
|
+
import { a as withAuthorization, c as capabilitiesOf, i as resourceAbilityForMethod, l as mergeCapabilities, n as authorizeMiddleware, o as Policy, r as authorizeResourceMiddleware, s as definePolicy, t as authorizeAllMiddleware, u as stampCapabilities } from "./authorization-BLhwA2Yh.js";
|
|
5
7
|
import { a as mapToolResponse, i as describeBuildFailure, n as advertisesStructuredOutput, r as buildToolRequest, s as AGENT_PREFLIGHT_VERDICT_HEADER, t as PREFLIGHT_ARGUMENT } from "./dispatch-BAwzftws.js";
|
|
6
8
|
import { t as trimSlashes } from "./trim-slashes-BLY9hKAa.js";
|
|
7
9
|
import { PATH_PARAM_PATTERN, extractPathParamNames } from "./internal/route-path.js";
|
|
8
10
|
import { a as generateAppKey, c as parseAppKey, i as encodeDerivedKey, l as parsePreviousAppKeys, n as deriveAppKey, o as getAppKeyringFromEnv, r as deriveAppKeyring, s as normalizeAppKey, t as MessageSigner } from "./MessageSigner-Bd25ZJAV.js";
|
|
9
11
|
import { n as detectServerlessRuntime, t as SERVERLESS_RUNTIME_LABELS } from "./serverless-D96rJb6x.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { a as getJob, d as resolveQueueDriver, f as setQueueDriver, l as registerJob, n as clearJobRegistry, o as getQueueDriver, p as resolveOptional, r as clearQueueDriver, s as getRegisteredJobs, t as Job, u as resolveJobName } from "./Job-BVvaY-7p.js";
|
|
12
|
+
import { A as verifyOAuthState, B as NodeHasher, C as createGoogleOAuthProviderConfig, D as fetchOAuthUserProfile, E as exchangeOAuthCode, F as DEFAULT_PROVIDER, G as MemorySessionStore, H as BaseUserProvider, I as TokenGuard, J as getSessionFromContext, K as createSessionMiddleware, L as SessionGuard, M as isAppRelativePath, N as normalizeRedirectTarget, O as parseOAuthRedirectUrl, P as AuthManager, R as ModelUserProvider, S as createGitHubOAuthProviderConfig, T as createOAuthState, U as installAgentPrincipal, V as ScryptHasher, W as readAgentPrincipal, _ as OAUTH_SESSION_BINDING_KEY, a as isEmailVerified, b as buildOAuthRedirectUrl, c as verifyEmailToken, d as completePasswordReset, f as createPasswordResetToken, g as MemoryOAuthStateStore, h as AuthenticatableModel, i as createEmailVerificationToken, j as hostMatchesAllowlist, k as sanitizeOAuthRedirect, l as MemoryPasswordResetStore, m as verifyPasswordResetToken, n as buildVerificationUrl, o as parseVerificationUrl, p as parsePasswordResetUrl, q as defaultCookieSecure, r as completeEmailVerification, s as requireVerifiedEmail, t as MemoryEmailVerificationStore, u as buildPasswordResetUrl, v as OAuthManager, w as createOAuthManager, x as createDiscordOAuthProviderConfig, y as buildOAuthAuthorizeUrl, z as DefaultHasher } from "./auth-vFeem6uM.js";
|
|
13
|
+
import { t as resolveOptional } from "./resolve-optional-ax6gPWTp.js";
|
|
13
14
|
import { t as warnOnce } from "./warn-once-p-IlMjra.js";
|
|
14
|
-
import { a as defaultApplication, c as resolve, d as createContainer, f as getContainer, h as warnDeprecatedSetter, i as bindAmbient, l as useAsDefaultApplication, m as warnDeprecatedGetter, n as ambientBinding, o as defaultContainer, p as setContainer, r as ambientContainer, s as resetDefaultApplication, t as adoptDefaultApplication, u as Container } from "./default-application-
|
|
15
|
-
import { n as
|
|
15
|
+
import { a as defaultApplication, c as resolve, d as createContainer, f as getContainer, h as warnDeprecatedSetter, i as bindAmbient, l as useAsDefaultApplication, m as warnDeprecatedGetter, n as ambientBinding, o as defaultContainer, p as setContainer, r as ambientContainer, s as resetDefaultApplication, t as adoptDefaultApplication, u as Container } from "./default-application-D5ezhhiV.js";
|
|
16
|
+
import { n as ServiceProvider, t as ProviderManager } from "./ServiceProvider-DDW3MqQJ.js";
|
|
16
17
|
import { o as AuthenticationException, r as getAuthContext, t as AUTH_CONTEXT_KEY } from "./context-af2n5abO.js";
|
|
17
18
|
import { a as md5, c as sha256, d as verifyPassword, i as hmac, l as sha512, n as hash, o as needsRehash, r as hashPassword, s as secureCompare, t as check, u as verifyHmac } from "./Hash-D2DFd8xX.js";
|
|
19
|
+
import { _ as verifyApiToken, a as getApiToken, c as hasBearerHeader, d as revokeAllApiTokens, f as revokeApiToken, g as tokenCanAny, h as tokenCanAll, i as createBearerTokenMiddleware, l as parseApiToken, m as tokenCan, n as MemoryApiTokenStore, o as getApiTokenOrFail, r as createApiToken, s as getUserApiTokens, t as API_TOKEN_KEY, u as readBearerToken } from "./api-token-BbgDEd6j.js";
|
|
18
20
|
import { a as runInRequestScope, i as keepAlive, n as filterSensitiveData, t as Logger } from "./Logger-DWXdtLSJ.js";
|
|
19
21
|
import { a as RedisStore, i as FileStore, n as createCacheManager, o as MemoryStore, r as TaggedCache, s as resolveLazyRedisClient, t as CacheManager } from "./cache-93n2PCnB.js";
|
|
20
22
|
import { n as createRedisClient, r as RedisSessionStore } from "./client-C5Wj9P9o.js";
|
|
21
|
-
import { r as isMcpEndpointEnabled } from "./endpoint-
|
|
23
|
+
import { r as isMcpEndpointEnabled } from "./endpoint-Coq0K_6I.js";
|
|
22
24
|
import { n as isHotReloadRuntime, r as matchingOpenParen, t as claimHotDisposable } from "./hot-disposables-W2fH-GID.js";
|
|
23
|
-
import {
|
|
24
|
-
import { r as
|
|
25
|
-
import {
|
|
25
|
+
import { c as tc, d as Translator, f as getPluralizationRule, i as getI18n, l as tryGetI18n, m as selectPluralForm, n as I18nManager, o as setI18n, p as pluralizationRules, r as createI18n, s as t, t as MemoryLoader, u as JsonLoader } from "./i18n-DqcRD4qL.js";
|
|
26
|
+
import { a as cannot, f as setGate, g as tryGetRequestContainer, h as getRequestContainer, i as can, l as getGate, m as CONTAINER_CONTEXT_KEY, n as Response$1, o as createGate, p as AuthorizationException, r as authorize, s as defineGate, t as Gate } from "./Gate-YOt54xGF.js";
|
|
27
|
+
import { r as isDocsViewerEnabled } from "./endpoint-CTIzcagh.js";
|
|
28
|
+
import { c as isViteProduction, d as startViteDevServer, h as logDevServerBanner, i as clientManifestCandidates, l as loadViteManifest, m as isWildcardHost, n as INJECTED_CLIENT_MANIFEST_SOURCE, o as getManifestFile, p as formatHostPort, r as PUBLIC_ASSETS_URL_PREFIX, s as injectedClientManifest, u as normalizeDevServerUrl } from "./vite-manifest-C5kqRoBV.js";
|
|
26
29
|
import { readObjectSchema, toJsonSchema } from "./internal/zod-json-schema.js";
|
|
27
|
-
import { a as RequestFinished, c as UserLoggedOut, d as EventManager, f as createEventManager, i as JobProcessed, l as createQueueEventDispatcher, n as ApplicationStarted, o as RequestReceived, p as Event, r as JobFailed, s as UserAuthenticated, t as ApplicationShutdown, u as Listener } from "./events-
|
|
28
|
-
import { a as NotificationManager, c as setNotificationManager, d as getNotification, f as registerNotification, i as MailChannel, l as resolveNotifiableType, n as SlackChannel, o as createNotificationManager, p as Notification, r as DatabaseChannel, s as getNotificationManager, t as MemoryChannel, u as clearNotificationRegistry } from "./notifications-
|
|
29
|
-
import { a as
|
|
30
|
-
import { a as
|
|
31
|
-
import { a as
|
|
32
|
-
import { a as
|
|
30
|
+
import { a as RequestFinished, c as UserLoggedOut, d as EventManager, f as createEventManager, i as JobProcessed, l as createQueueEventDispatcher, n as ApplicationStarted, o as RequestReceived, p as Event, r as JobFailed, s as UserAuthenticated, t as ApplicationShutdown, u as Listener } from "./events-c94CdUFc.js";
|
|
31
|
+
import { a as NotificationManager, c as setNotificationManager, d as getNotification, f as registerNotification, i as MailChannel, l as resolveNotifiableType, n as SlackChannel, o as createNotificationManager, p as Notification, r as DatabaseChannel, s as getNotificationManager, t as MemoryChannel, u as clearNotificationRegistry } from "./notifications-LHuujttf.js";
|
|
32
|
+
import { a as getJob, d as resolveQueueDriver, f as setQueueDriver, l as registerJob, n as clearJobRegistry, o as getQueueDriver, r as clearQueueDriver, s as getRegisteredJobs, t as Job, u as resolveJobName } from "./Job-COMzBNOL.js";
|
|
33
|
+
import { a as processJob, c as RedisDriver$1, i as Worker, l as SyncDriver, n as createQueueManager, o as SqsDriver, r as FailedJobReporter, s as createSqsAdapter, t as QueueManager, u as MemoryDriver$1 } from "./queue-BiBn5Sff.js";
|
|
34
|
+
import { a as MailManager, c as MemoryTransport, i as setMailManager, l as ResendTransport, n as getMailManager, o as createMailManager, r as mail, s as LogTransport, t as Mail, u as SmtpTransport } from "./mail-uRBrUl9q.js";
|
|
35
|
+
import { a as LOG_LEVEL_PRIORITY, i as matchDailyFileDate, n as dailyFileDateStamp, r as dailyFilePath, t as DailyFileChannel } from "./DailyFileChannel-CTTPA0EF.js";
|
|
36
|
+
import { a as FileChannel, i as setLogManager, n as createLogManager, o as ConsoleChannel, r as getLogManager, t as LogManager } from "./logging-YbKmbAd7.js";
|
|
37
|
+
import { a as setBroadcastManager, c as PresenceChannel, i as getBroadcastManager, l as PrivateChannel, n as BroadcastManager, o as RedisDriver, r as createBroadcastManager, s as MemoryDriver, t as createTypedBroadcaster, u as Channel } from "./broadcasting-BUBCPCnu.js";
|
|
33
38
|
import { a as random, c as randomHex, d as sample, f as shuffle, i as pick, l as randomInt, m as uuid, n as generatePassword, o as randomBase64, p as urlSafeToken, r as generateSlug, s as randomBase64Url, t as generateOtp, u as randomString } from "./Random-S0OvCuR8.js";
|
|
34
|
-
import { a as decrypt, c as getEncrypter, i as createEncrypter, l as setEncrypter, n as verifySignedUrl, o as encrypt, r as Encrypter, s as generateKey, t as signUrl } from "./encryption-
|
|
39
|
+
import { a as decrypt, c as getEncrypter, i as createEncrypter, l as setEncrypter, n as verifySignedUrl, o as encrypt, r as Encrypter, s as generateKey, t as signUrl } from "./encryption-D1dxfMqD.js";
|
|
35
40
|
import { a as LocalDriver, i as S3Driver, n as createStorageManager, r as MemoryDriver$2, t as StorageManager } from "./storage-6HLaUf9j.js";
|
|
36
41
|
import { a as CacheCheck, c as HealthManager, i as StorageCheck, l as createHealthManager, n as customCheck, o as RedisCheck, r as MemoryCheck, s as DatabaseCheck, t as CustomCheck, u as HealthCheck } from "./health-CB0oS_UE.js";
|
|
37
42
|
import { a as ScheduledTask, c as isDue, d as parseCron, f as toTimezone, i as Schedule, l as isDueInTimezone, n as createScheduler, o as getNextOccurrence, p as MemorySchedulerLock, r as PendingSchedule, s as getNextOccurrences, t as Scheduler, u as matchesCron } from "./scheduling-DhYfbJFj.js";
|
|
38
43
|
import { Hono } from "hono";
|
|
39
44
|
import { deleteCookie, getCookie } from "hono/cookie";
|
|
40
45
|
import { createCipheriv, createDecipheriv, randomBytes } from "node:crypto";
|
|
41
|
-
import {
|
|
42
|
-
import { pathToFileURL } from "node:url";
|
|
46
|
+
import { join, resolve as resolve$1 } from "node:path";
|
|
43
47
|
import { cors } from "hono/cors";
|
|
44
48
|
import { createMiddleware } from "hono/factory";
|
|
45
|
-
import { parseAccept } from "hono/utils/accept";
|
|
46
49
|
import { serialize } from "hono/utils/cookie";
|
|
47
50
|
import { existsSync } from "node:fs";
|
|
48
51
|
import * as readline from "readline";
|
|
49
52
|
import { join as join$1 } from "path";
|
|
50
|
-
//#region src/support/error-polyfill.ts
|
|
51
|
-
let patched = false;
|
|
52
|
-
/**
|
|
53
|
-
* Bun 1.x throws from Error.captureStackTrace unless the first argument is a
|
|
54
|
-
* real Error. Packages that pass plain objects (notably follow-redirects, which
|
|
55
|
-
* Node tolerates) then crash SSR boot before Inertia can import the SSR entry.
|
|
56
|
-
* This mirrors Node by copying a real Error's stack onto whatever it is given.
|
|
57
|
-
*/
|
|
58
|
-
function ensureErrorStackTracePolyfill() {
|
|
59
|
-
if (patched) return;
|
|
60
|
-
const capture = Error.captureStackTrace;
|
|
61
|
-
if (typeof capture !== "function") {
|
|
62
|
-
Error.captureStackTrace = (target) => copyStackFromNewError(target);
|
|
63
|
-
patched = true;
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
Error.captureStackTrace = (target, constructorOpt) => {
|
|
67
|
-
if (target instanceof Error) try {
|
|
68
|
-
return capture(target, constructorOpt);
|
|
69
|
-
} catch {}
|
|
70
|
-
const placeholder = /* @__PURE__ */ new Error();
|
|
71
|
-
capture(placeholder, constructorOpt);
|
|
72
|
-
copyStackFromError(target, placeholder);
|
|
73
|
-
return target;
|
|
74
|
-
};
|
|
75
|
-
patched = true;
|
|
76
|
-
}
|
|
77
|
-
function copyStackFromNewError(target) {
|
|
78
|
-
copyStackFromError(target, /* @__PURE__ */ new Error());
|
|
79
|
-
}
|
|
80
|
-
function copyStackFromError(target, source) {
|
|
81
|
-
if (!target || typeof target !== "object") return;
|
|
82
|
-
if (source.stack) Object.defineProperty(target, "stack", {
|
|
83
|
-
configurable: true,
|
|
84
|
-
enumerable: false,
|
|
85
|
-
writable: true,
|
|
86
|
-
value: source.stack
|
|
87
|
-
});
|
|
88
|
-
if (source.name && !("name" in target)) Object.defineProperty(target, "name", {
|
|
89
|
-
configurable: true,
|
|
90
|
-
enumerable: false,
|
|
91
|
-
writable: true,
|
|
92
|
-
value: source.name
|
|
93
|
-
});
|
|
94
|
-
if (source.message && !("message" in target)) Object.defineProperty(target, "message", {
|
|
95
|
-
configurable: true,
|
|
96
|
-
enumerable: false,
|
|
97
|
-
writable: true,
|
|
98
|
-
value: source.message
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
//#endregion
|
|
102
53
|
//#region src/mvc/mount-route.ts
|
|
103
54
|
/**
|
|
104
55
|
* Mounts a route with a dynamic HTTP method string. Hono's `app.on()` overloads
|
|
@@ -108,393 +59,6 @@ function mountRoute(app, method, path, ...handlers) {
|
|
|
108
59
|
app.on(method, path, ...handlers);
|
|
109
60
|
}
|
|
110
61
|
//#endregion
|
|
111
|
-
//#region src/mvc/inertia/InertiaEngine.ts
|
|
112
|
-
ensureErrorStackTracePolyfill();
|
|
113
|
-
let documentOptions;
|
|
114
|
-
/**
|
|
115
|
-
* Register app-wide document defaults for server-rendered Inertia responses.
|
|
116
|
-
* Process-wide, not request-scoped: calling it mid-flight leaks the policy into
|
|
117
|
-
* in-flight requests — use the {@link InertiaOptions} fields per response.
|
|
118
|
-
* Values are emitted verbatim, so never pass user input. `undefined` clears.
|
|
119
|
-
*
|
|
120
|
-
* @deprecated since 2.23.0, removed in 3.0.0 (RFC 0023). Pass
|
|
121
|
-
* `createApp({ inertia: { document } })`, which binds it on the app rather than
|
|
122
|
-
* the process. The slot stays the engine's second read.
|
|
123
|
-
*/
|
|
124
|
-
function setInertiaDocument(options) {
|
|
125
|
-
warnDeprecatedSetter("setInertiaDocument");
|
|
126
|
-
documentOptions = options;
|
|
127
|
-
}
|
|
128
|
-
let defaultSsrRenderer;
|
|
129
|
-
/**
|
|
130
|
-
* Register a process-wide default SSR renderer, for adapters whose bundler
|
|
131
|
-
* cannot resolve a runtime path (Workers has no filesystem for
|
|
132
|
-
* `GUREN_INERTIA_SSR_ENTRY`'s dynamic import). Per-call `ssr.render` still
|
|
133
|
-
* wins; `undefined` clears (test isolation).
|
|
134
|
-
*
|
|
135
|
-
* @deprecated since 2.23.0, removed in 3.0.0 (RFC 0023). Pass
|
|
136
|
-
* `createApp({ inertia: { ssrRenderer } })`, or bind `inertia.ssrRenderer` on
|
|
137
|
-
* the app when the renderer only exists after `createApp()` has run.
|
|
138
|
-
*/
|
|
139
|
-
function setInertiaSsrRenderer(renderer) {
|
|
140
|
-
warnDeprecatedSetter("setInertiaSsrRenderer");
|
|
141
|
-
defaultSsrRenderer = renderer;
|
|
142
|
-
}
|
|
143
|
-
const DEFAULT_TITLE = "Guren";
|
|
144
|
-
const DEV_FALLBACK_IMPORT_MAP = {
|
|
145
|
-
react: "https://esm.sh/react@19.0.0?dev",
|
|
146
|
-
"react/jsx-runtime": "https://esm.sh/react@19.0.0/jsx-runtime?dev",
|
|
147
|
-
"react/jsx-dev-runtime": "https://esm.sh/react@19.0.0/jsx-dev-runtime?dev",
|
|
148
|
-
"react-dom/client": "https://esm.sh/react-dom@19.0.0/client?dev",
|
|
149
|
-
"@guren/inertia-client": "/vendor/inertia-client.tsx",
|
|
150
|
-
"@inertiajs/react": "https://esm.sh/@inertiajs/react@2.2.15?dev&external=react,react-dom/client"
|
|
151
|
-
};
|
|
152
|
-
async function inertia(component, props, options = {}) {
|
|
153
|
-
const resolvedVersion = options.version ?? process.env.GUREN_INERTIA_VERSION ?? void 0;
|
|
154
|
-
const page = {
|
|
155
|
-
component,
|
|
156
|
-
props,
|
|
157
|
-
url: options.url ?? inertiaPageUrl(options.request) ?? "",
|
|
158
|
-
version: resolvedVersion
|
|
159
|
-
};
|
|
160
|
-
const request = options.request;
|
|
161
|
-
const isInertiaVisit = Boolean(request?.headers.get("X-Inertia"));
|
|
162
|
-
const prefersJson = request ? acceptsJson(request) : false;
|
|
163
|
-
const versionHeader = resolvedVersion ? { "X-Inertia-Version": resolvedVersion } : {};
|
|
164
|
-
if (request && resolvedVersion && isInertiaVisit && request.method === "GET") {
|
|
165
|
-
if (request.headers.get("X-Inertia-Version") !== resolvedVersion) return new Response(null, {
|
|
166
|
-
status: 409,
|
|
167
|
-
headers: {
|
|
168
|
-
"X-Inertia-Location": options.url ?? request.url,
|
|
169
|
-
Vary: "Accept"
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
if (isInertiaVisit || prefersJson) return new Response(serializePage(page), {
|
|
174
|
-
status: options.status ?? 200,
|
|
175
|
-
headers: {
|
|
176
|
-
"Content-Type": "application/json; charset=utf-8",
|
|
177
|
-
"X-Inertia": "true",
|
|
178
|
-
Vary: "Accept",
|
|
179
|
-
...versionHeader,
|
|
180
|
-
...options.headers
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
const html = await renderDocument$1(page, options);
|
|
184
|
-
return new Response(html, {
|
|
185
|
-
status: options.status ?? 200,
|
|
186
|
-
headers: {
|
|
187
|
-
"Content-Type": "text/html; charset=utf-8",
|
|
188
|
-
"X-Inertia": "true",
|
|
189
|
-
Vary: "Accept",
|
|
190
|
-
...versionHeader,
|
|
191
|
-
...options.headers
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* The Inertia protocol's page `url` is the request path plus query string, kept
|
|
197
|
-
* relative. Derived from the request when the caller does not override it.
|
|
198
|
-
*/
|
|
199
|
-
function inertiaPageUrl(request) {
|
|
200
|
-
if (!request) return;
|
|
201
|
-
const { pathname, search } = new URL(request.url);
|
|
202
|
-
return `${pathname}${search}`;
|
|
203
|
-
}
|
|
204
|
-
async function renderDocument$1(page, options) {
|
|
205
|
-
const defaultEntry = process.env.GUREN_INERTIA_ENTRY || "/resources/js/app.tsx";
|
|
206
|
-
const entry = options.entry ?? defaultEntry;
|
|
207
|
-
const title = escapeHtml$2(options.title ?? DEFAULT_TITLE);
|
|
208
|
-
const isProduction = process.env.NODE_ENV === "production";
|
|
209
|
-
const configuredStyles = options.styles ?? parseStylesEnv(process.env.GUREN_INERTIA_STYLES);
|
|
210
|
-
const styles = !isProduction && options.styles === void 0 && isDevServerEntry(entry) ? configuredStyles.filter((href) => href !== DEFAULT_DEV_STYLES_ENTRY) : configuredStyles;
|
|
211
|
-
const envImportMap = parseImportMap(process.env.GUREN_INERTIA_IMPORT_MAP, { context: "GUREN_INERTIA_IMPORT_MAP" });
|
|
212
|
-
const importMapEntries = {
|
|
213
|
-
...isProduction ? {} : DEV_FALLBACK_IMPORT_MAP,
|
|
214
|
-
...envImportMap,
|
|
215
|
-
...options.importMap
|
|
216
|
-
};
|
|
217
|
-
const importMap = JSON.stringify({ imports: importMapEntries }, null, 2);
|
|
218
|
-
const stylesheetLinks = renderStyles(styles);
|
|
219
|
-
const criticalCss = resolveDocumentValue("criticalCss", options, page.component);
|
|
220
|
-
const prepaintScript = resolveDocumentValue("prepaintScript", options, page.component);
|
|
221
|
-
const headMarkup = resolveDocumentValue("head", options, page.component);
|
|
222
|
-
const ssrResult = await tryRenderSsr(page, options);
|
|
223
|
-
const headElements = (ssrResult?.head ?? []).map(normalizeHeadElement);
|
|
224
|
-
const hasCustomTitle = headElements.some((element) => /<title\b[^>]*>/iu.test(element));
|
|
225
|
-
const appMarkup = ssrResult === void 0 ? `${pagePayloadElement(page)}<div id="app"></div>` : ssrResult.pageEmbedded ? ssrResult.body : `${ssrResult.body}${pagePayloadElement(page)}`;
|
|
226
|
-
const headSegments = [
|
|
227
|
-
"<meta charset=\"utf-8\" />",
|
|
228
|
-
"<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />",
|
|
229
|
-
hasCustomTitle ? "" : `<title>${title}</title>`,
|
|
230
|
-
headMarkup ?? "",
|
|
231
|
-
criticalCss ? `<style id="guren-critical">${criticalCss}</style>` : "",
|
|
232
|
-
prepaintScript ? `<script>${prepaintScript}<\/script>` : "",
|
|
233
|
-
stylesheetLinks,
|
|
234
|
-
...headElements,
|
|
235
|
-
Object.keys(importMapEntries).length > 0 ? `<script type="importmap">${importMap}<\/script>` : ""
|
|
236
|
-
].filter((segment) => segment && segment.length > 0);
|
|
237
|
-
const bodyClass = resolveDocumentValue("bodyClass", options, page.component);
|
|
238
|
-
const bodyAttributes = bodyClass ? ` class="${escapeAttribute(bodyClass)}"` : "";
|
|
239
|
-
return `<!DOCTYPE html>
|
|
240
|
-
<html lang="${escapeAttribute(options.lang ?? "en")}">
|
|
241
|
-
<head>
|
|
242
|
-
${headSegments.join("\n ")}
|
|
243
|
-
</head>
|
|
244
|
-
<body${bodyAttributes}>
|
|
245
|
-
${appMarkup}${PAGE_GLOBAL_FROM_ELEMENT}
|
|
246
|
-
<script type="module" src="${entry}"><\/script>
|
|
247
|
-
</body>
|
|
248
|
-
</html>`;
|
|
249
|
-
}
|
|
250
|
-
function pagePayloadElement(page) {
|
|
251
|
-
return `<script data-page="app" type="application/json">${serializePage(page)}<\/script>`;
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* `window.__INERTIA_PAGE__` for readers other than the client. Same selector
|
|
255
|
-
* and guards as the client's `getInitialPage` (@guren/inertia-client), so a
|
|
256
|
-
* container carrying a non-payload `data-page` is ignored rather than mounted.
|
|
257
|
-
* A classic inline script, so it has run before the module entry does.
|
|
258
|
-
*/
|
|
259
|
-
const PAGE_GLOBAL_FROM_ELEMENT = "<script>try{var e=document.querySelector('script[data-page=\"app\"][type=\"application/json\"]')||document.getElementById(\"app\"),p=JSON.parse(e.tagName===\"SCRIPT\"?e.textContent:e.getAttribute(\"data-page\"));if(p&&p.component)window.__INERTIA_PAGE__=p}catch(_){}<\/script>";
|
|
260
|
-
async function tryRenderSsr(page, options) {
|
|
261
|
-
const ssrOptions = options.ssr;
|
|
262
|
-
if (ssrOptions?.enabled === false) return;
|
|
263
|
-
const manifest = (ssrOptions?.manifest ?? process.env.GUREN_INERTIA_SSR_MANIFEST)?.trim() || void 0;
|
|
264
|
-
const renderer = ssrOptions?.render ?? resolveOptional(options.container, "inertia.ssrRenderer") ?? defaultSsrRenderer ?? await loadSsrRenderer(ssrOptions?.entry ?? process.env.GUREN_INERTIA_SSR_ENTRY);
|
|
265
|
-
if (!renderer) return;
|
|
266
|
-
try {
|
|
267
|
-
const result = await renderer({
|
|
268
|
-
page,
|
|
269
|
-
request: options.request,
|
|
270
|
-
manifest
|
|
271
|
-
});
|
|
272
|
-
if (!result || typeof result.body !== "string") return;
|
|
273
|
-
return {
|
|
274
|
-
body: result.body,
|
|
275
|
-
head: Array.isArray(result.head) ? result.head : [],
|
|
276
|
-
pageEmbedded: result.pageEmbedded === true
|
|
277
|
-
};
|
|
278
|
-
} catch (error) {
|
|
279
|
-
console.error("Inertia SSR renderer failed; falling back to client rendering.", error);
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
async function loadSsrRenderer(entry) {
|
|
284
|
-
const specifier = entry?.trim();
|
|
285
|
-
if (!specifier) return;
|
|
286
|
-
const normalized = normalizeSsrSpecifier(specifier);
|
|
287
|
-
try {
|
|
288
|
-
const renderCandidate = extractSsrRenderer(await import(normalized));
|
|
289
|
-
if (!renderCandidate) {
|
|
290
|
-
console.warn(`Inertia SSR entry "${specifier}" does not export a renderer. Expected a default export or a named "render" function.`);
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
return renderCandidate;
|
|
294
|
-
} catch (error) {
|
|
295
|
-
console.error(`Failed to import Inertia SSR entry "${specifier}".`, error);
|
|
296
|
-
return;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
function extractSsrRenderer(module) {
|
|
300
|
-
if (!module || typeof module !== "object") return;
|
|
301
|
-
const candidate = typeof module.render === "function" ? module.render : typeof module.default === "function" ? module.default : void 0;
|
|
302
|
-
if (!candidate) return;
|
|
303
|
-
return (context) => Promise.resolve(candidate(context));
|
|
304
|
-
}
|
|
305
|
-
function normalizeSsrSpecifier(specifier) {
|
|
306
|
-
if (specifier.startsWith("file://") || isUrlLike(specifier)) return specifier;
|
|
307
|
-
if (specifier.startsWith("./") || specifier.startsWith("../")) {
|
|
308
|
-
const absolute = resolve$1(process.cwd(), specifier);
|
|
309
|
-
return pathToFileURL(absolute).href;
|
|
310
|
-
}
|
|
311
|
-
if (isAbsolute(specifier)) return pathToFileURL(specifier).href;
|
|
312
|
-
return specifier;
|
|
313
|
-
}
|
|
314
|
-
function isUrlLike(specifier) {
|
|
315
|
-
return /^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(specifier);
|
|
316
|
-
}
|
|
317
|
-
/**
|
|
318
|
-
* An absolute http(s) entry means an asset dev server (Vite) is serving the
|
|
319
|
-
* module graph; a same-origin path means source files are served directly,
|
|
320
|
-
* where the raw stylesheet link is the only styling.
|
|
321
|
-
*/
|
|
322
|
-
function isDevServerEntry(entry) {
|
|
323
|
-
return /^https?:\/\//iu.test(entry);
|
|
324
|
-
}
|
|
325
|
-
function renderStyles(styles) {
|
|
326
|
-
if (!styles.length) return "";
|
|
327
|
-
return styles.map((href) => `<link rel="stylesheet" href="${escapeAttribute(href)}" />`).join("\n ");
|
|
328
|
-
}
|
|
329
|
-
function normalizeHeadElement(element) {
|
|
330
|
-
return (typeof element === "string" ? element : String(element ?? "")).replace(/href="\/(?!public\/)([^"?]+\.(?:js|css))(\?[^"']*)?"/g, (_match, file, query = "") => `href="/public/assets/${file}${query}"`);
|
|
331
|
-
}
|
|
332
|
-
/** One document field: per-response override, then app-wide default, then "". */
|
|
333
|
-
function resolveDocumentValue(key, options, componentName) {
|
|
334
|
-
const override = options[key];
|
|
335
|
-
if (override !== void 0) return override;
|
|
336
|
-
const value = (resolveOptional(options.container, "inertia.document") ?? documentOptions)?.[key];
|
|
337
|
-
return (typeof value === "function" ? value({ component: componentName }) : value) ?? "";
|
|
338
|
-
}
|
|
339
|
-
function serializePage(page) {
|
|
340
|
-
return JSON.stringify(page).replace(/[<\u2028\u2029]/gu, (char) => {
|
|
341
|
-
switch (char) {
|
|
342
|
-
case "<": return "\\u003c";
|
|
343
|
-
case "\u2028": return "\\u2028";
|
|
344
|
-
case "\u2029": return "\\u2029";
|
|
345
|
-
default: return char;
|
|
346
|
-
}
|
|
347
|
-
});
|
|
348
|
-
}
|
|
349
|
-
function acceptsJson(request) {
|
|
350
|
-
const accept = request.headers.get("accept")?.toLowerCase() ?? "";
|
|
351
|
-
if (!accept || accept === "*/*") return false;
|
|
352
|
-
if (accept.includes("text/html")) return false;
|
|
353
|
-
return accept.includes("application/json") || accept.includes("json");
|
|
354
|
-
}
|
|
355
|
-
function escapeHtml$2(value) {
|
|
356
|
-
return value.replace(/[&<>"']/gu, (char) => {
|
|
357
|
-
switch (char) {
|
|
358
|
-
case "&": return "&";
|
|
359
|
-
case "<": return "<";
|
|
360
|
-
case ">": return ">";
|
|
361
|
-
case "\"": return """;
|
|
362
|
-
case "'": return "'";
|
|
363
|
-
default: return char;
|
|
364
|
-
}
|
|
365
|
-
});
|
|
366
|
-
}
|
|
367
|
-
function escapeAttribute(value) {
|
|
368
|
-
return value.replace(/[&"]/gu, (char) => {
|
|
369
|
-
if (char === "&") return "&";
|
|
370
|
-
return """;
|
|
371
|
-
});
|
|
372
|
-
}
|
|
373
|
-
function parseStylesEnv(value) {
|
|
374
|
-
if (!value) return [];
|
|
375
|
-
return value.split(",").map((item) => item.trim()).filter((item) => item.length > 0);
|
|
376
|
-
}
|
|
377
|
-
//#endregion
|
|
378
|
-
//#region src/mvc/inertia/shared.ts
|
|
379
|
-
/** Container binding key for the scoped {@link SharedInertiaPropsRegistry}. */
|
|
380
|
-
const INERTIA_SHARED_PROPS_BINDING = "inertia.sharedProps";
|
|
381
|
-
/**
|
|
382
|
-
* Registrations are numbered from one process-wide counter so that props keep
|
|
383
|
-
* resolving in registration order — later registrations win on conflicting
|
|
384
|
-
* keys — no matter which registry each one landed in.
|
|
385
|
-
*/
|
|
386
|
-
let registrationSequence = 0;
|
|
387
|
-
/**
|
|
388
|
-
* Holds the shared-props resolvers for one scope: either a single
|
|
389
|
-
* Application's container or the module-global fallback for bare-Hono apps.
|
|
390
|
-
*/
|
|
391
|
-
var SharedInertiaPropsRegistry = class {
|
|
392
|
-
resolvers = [];
|
|
393
|
-
/** Replace every resolver registered in this scope. */
|
|
394
|
-
set(resolverFn) {
|
|
395
|
-
this.resolvers = resolverFn ? [orderedResolver(resolverFn)] : [];
|
|
396
|
-
}
|
|
397
|
-
/**
|
|
398
|
-
* Register additional shared props without replacing resolvers registered
|
|
399
|
-
* earlier — the new resolver's props are merged over the previous ones.
|
|
400
|
-
*/
|
|
401
|
-
share(resolverFn) {
|
|
402
|
-
this.resolvers.push(orderedResolver(resolverFn));
|
|
403
|
-
}
|
|
404
|
-
/** The resolvers registered in this scope, ordered by registration. */
|
|
405
|
-
entries() {
|
|
406
|
-
return this.resolvers;
|
|
407
|
-
}
|
|
408
|
-
/**
|
|
409
|
-
* The scope's registrations composed into one resolver, or null when empty.
|
|
410
|
-
* The composition is a snapshot: resolvers registered later are not picked up.
|
|
411
|
-
*/
|
|
412
|
-
get() {
|
|
413
|
-
if (this.resolvers.length === 0) return null;
|
|
414
|
-
if (this.resolvers.length === 1) return this.resolvers[0].resolve;
|
|
415
|
-
const snapshot = [...this.resolvers];
|
|
416
|
-
return (ctx) => applyResolvers(snapshot, ctx);
|
|
417
|
-
}
|
|
418
|
-
async resolve(ctx) {
|
|
419
|
-
return applyResolvers(this.resolvers, ctx);
|
|
420
|
-
}
|
|
421
|
-
};
|
|
422
|
-
function orderedResolver(resolverFn) {
|
|
423
|
-
return {
|
|
424
|
-
seq: registrationSequence++,
|
|
425
|
-
resolve: resolverFn
|
|
426
|
-
};
|
|
427
|
-
}
|
|
428
|
-
async function applyResolvers(entries, ctx) {
|
|
429
|
-
const merged = {};
|
|
430
|
-
for (const entry of entries) {
|
|
431
|
-
const props = await entry.resolve(ctx);
|
|
432
|
-
if (props && typeof props === "object") Object.assign(merged, props);
|
|
433
|
-
}
|
|
434
|
-
return merged;
|
|
435
|
-
}
|
|
436
|
-
const globalRegistry = new SharedInertiaPropsRegistry();
|
|
437
|
-
/** The registry bound to `container`, or null when it owns none yet. */
|
|
438
|
-
function scopedRegistry(container) {
|
|
439
|
-
if (!container?.has?.("inertia.sharedProps")) return null;
|
|
440
|
-
return container.make(INERTIA_SHARED_PROPS_BINDING);
|
|
441
|
-
}
|
|
442
|
-
/**
|
|
443
|
-
* The shared-props registry scoped to `container`, binding a fresh one on
|
|
444
|
-
* first use.
|
|
445
|
-
*/
|
|
446
|
-
function ensureSharedInertiaPropsRegistry(container) {
|
|
447
|
-
const existing = scopedRegistry(container);
|
|
448
|
-
if (existing) return existing;
|
|
449
|
-
const registry = new SharedInertiaPropsRegistry();
|
|
450
|
-
container.instance(INERTIA_SHARED_PROPS_BINDING, registry);
|
|
451
|
-
return registry;
|
|
452
|
-
}
|
|
453
|
-
/**
|
|
454
|
-
* Replace the module-global shared props resolver. Props registered on an
|
|
455
|
-
* application's container (see {@link shareInertiaProps}) are unaffected.
|
|
456
|
-
* @deprecated since 2.23.0, removed in 3.0.0 (RFC 0023). Use
|
|
457
|
-
* `shareInertiaProps(fn, container)`, which scopes the registration to one app.
|
|
458
|
-
* It composes rather than replaces, so a wholesale reset becomes one
|
|
459
|
-
* registration on a fresh container.
|
|
460
|
-
*/
|
|
461
|
-
function setInertiaSharedProps(resolverFn) {
|
|
462
|
-
warnDeprecatedSetter("setInertiaSharedProps");
|
|
463
|
-
globalRegistry.set(resolverFn);
|
|
464
|
-
}
|
|
465
|
-
/**
|
|
466
|
-
* The module-global registrations composed into one resolver, for manual
|
|
467
|
-
* composition. Container-scoped props are not included — get those from
|
|
468
|
-
* `ensureSharedInertiaPropsRegistry(container).get()`.
|
|
469
|
-
* @deprecated since 2.23.0, removed in 3.0.0 (RFC 0023). Use
|
|
470
|
-
* `ensureSharedInertiaPropsRegistry(container).get()` on the container that owns
|
|
471
|
-
* the call.
|
|
472
|
-
*/
|
|
473
|
-
function getInertiaSharedPropsResolver() {
|
|
474
|
-
warnDeprecatedGetter("getInertiaSharedPropsResolver");
|
|
475
|
-
return globalRegistry.get();
|
|
476
|
-
}
|
|
477
|
-
/**
|
|
478
|
-
* Register additional shared props without replacing earlier resolvers, so
|
|
479
|
-
* several providers can each contribute (`setInertiaSharedProps` replaces
|
|
480
|
-
* wholesale). Pass the provider's `this.container` to scope them; without it
|
|
481
|
-
* they are module-global and a second Application in the process shares them.
|
|
482
|
-
*/
|
|
483
|
-
function shareInertiaProps(resolverFn, container) {
|
|
484
|
-
(container ? ensureSharedInertiaPropsRegistry(container) : globalRegistry).share(resolverFn);
|
|
485
|
-
}
|
|
486
|
-
/**
|
|
487
|
-
* Resolve shared props for a request, merging the module-global registrations
|
|
488
|
-
* with those scoped to `container` in registration order.
|
|
489
|
-
*/
|
|
490
|
-
async function resolveSharedInertiaProps(ctx, container) {
|
|
491
|
-
const scoped = scopedRegistry(container);
|
|
492
|
-
if (!scoped) return globalRegistry.resolve(ctx);
|
|
493
|
-
const globalEntries = globalRegistry.entries();
|
|
494
|
-
if (globalEntries.length === 0) return scoped.resolve(ctx);
|
|
495
|
-
return applyResolvers([...globalEntries, ...scoped.entries()].sort((a, b) => a.seq - b.seq), ctx);
|
|
496
|
-
}
|
|
497
|
-
//#endregion
|
|
498
62
|
//#region src/mvc/prototype.ts
|
|
499
63
|
const PROTOTYPE_HANDLER = Symbol.for("guren.prototype.handler");
|
|
500
64
|
const prototype = Object.freeze({ [PROTOTYPE_HANDLER]: true });
|
|
@@ -868,6 +432,7 @@ var Router = class {
|
|
|
868
432
|
action: String(handler[1])
|
|
869
433
|
} : void 0,
|
|
870
434
|
bindings: serializeBindings(path, bindings, this.modelBindings),
|
|
435
|
+
...schemas?.body ? { validatesBody: true } : {},
|
|
871
436
|
...openapi
|
|
872
437
|
}));
|
|
873
438
|
}
|
|
@@ -1122,12 +687,13 @@ function validationErrorResponse(error, status) {
|
|
|
1122
687
|
function throwOnInvalid(schema, data) {
|
|
1123
688
|
const result = schema.safeParse(data);
|
|
1124
689
|
if (!result.success) throw ValidationException.withMessages(formatValidationErrors(result.error));
|
|
690
|
+
return result.data;
|
|
1125
691
|
}
|
|
1126
692
|
/**
|
|
1127
693
|
* The preflight seam: what a request must pass before the handler, reported
|
|
1128
694
|
* instead of executed. Mounted last, so the chain in front really ran; only
|
|
1129
|
-
* `.agent()` routes honour the header.
|
|
1130
|
-
* this branch never calls `next()`), and `unverified` names the checks only
|
|
695
|
+
* `.agent()` routes honour the header. An inline handler's contract is checked
|
|
696
|
+
* here (safe: this branch never calls `next()`), and `unverified` names the checks only
|
|
1131
697
|
* the action itself would make, such as `await this.authorize(...)`.
|
|
1132
698
|
*/
|
|
1133
699
|
function createAgentPreflightMiddleware(route, capabilities) {
|
|
@@ -1136,19 +702,16 @@ function createAgentPreflightMiddleware(route, capabilities) {
|
|
|
1136
702
|
const unverified = capabilities().authorization === void 0 ? ["authorization"] : [];
|
|
1137
703
|
return async (c, next) => {
|
|
1138
704
|
if (c.req.header("X-Guren-Agent-Preflight") === void 0) return next();
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
throwOnInvalid(schemas.
|
|
1142
|
-
|
|
1143
|
-
}
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
throwOnInvalid(schemas.body, await parseRequestBody(c));
|
|
1150
|
-
validated.push("body");
|
|
1151
|
-
}
|
|
705
|
+
if (!getValidatedInput(c)) {
|
|
706
|
+
if (schemas?.params) throwOnInvalid(schemas.params, c.req.param());
|
|
707
|
+
if (schemas?.query) throwOnInvalid(schemas.query, flattenRequestQueries(c));
|
|
708
|
+
if (schemas?.body) throwOnInvalid(schemas.body, await parseRequestBody(c));
|
|
709
|
+
}
|
|
710
|
+
const validated = [
|
|
711
|
+
"params",
|
|
712
|
+
"query",
|
|
713
|
+
"body"
|
|
714
|
+
].filter((segment) => schemas?.[segment]);
|
|
1152
715
|
c.header(AGENT_PREFLIGHT_VERDICT_HEADER, "1");
|
|
1153
716
|
return c.json({
|
|
1154
717
|
preflight: true,
|
|
@@ -1163,10 +726,22 @@ function createAgentPreflightMiddleware(route, capabilities) {
|
|
|
1163
726
|
function createContractValidationMiddleware(route) {
|
|
1164
727
|
if (!isControllerAction(route.handler)) return null;
|
|
1165
728
|
const schemas = route.schemas;
|
|
1166
|
-
if (!schemas || !schemas.params && !schemas.query && !schemas.output) return null;
|
|
729
|
+
if (!schemas || !schemas.params && !schemas.query && !schemas.body && !schemas.output) return null;
|
|
730
|
+
const validatesInput = Boolean(schemas.params || schemas.query || schemas.body);
|
|
1167
731
|
return async (c, next) => {
|
|
1168
|
-
if (
|
|
1169
|
-
|
|
732
|
+
if (validatesInput) {
|
|
733
|
+
const record = { route: route.name };
|
|
734
|
+
if (schemas.params) record.params = throwOnInvalid(schemas.params, c.req.param());
|
|
735
|
+
if (schemas.query) record.query = throwOnInvalid(schemas.query, flattenRequestQueries(c));
|
|
736
|
+
if (schemas.body) {
|
|
737
|
+
const payload = await parseRequestBody(c);
|
|
738
|
+
const result = schemas.body.safeParse(payload);
|
|
739
|
+
if (!result.success) throw ValidationException.fromZodError(result.error);
|
|
740
|
+
record.body = result.data;
|
|
741
|
+
record.rawBody = { value: payload };
|
|
742
|
+
}
|
|
743
|
+
setValidatedInput(c, record);
|
|
744
|
+
}
|
|
1170
745
|
await next();
|
|
1171
746
|
const isSuccess = c.res !== void 0 && c.res.status >= 200 && c.res.status < 300;
|
|
1172
747
|
if (schemas.output && isSuccess && c.res.headers.get("X-Guren-Agent-Preflight-Verdict") === null) {
|
|
@@ -1313,62 +888,6 @@ function joinPaths(prefixStack, path) {
|
|
|
1313
888
|
return "/" + segments.join("/").replace(/\/+/gu, "/");
|
|
1314
889
|
}
|
|
1315
890
|
//#endregion
|
|
1316
|
-
//#region src/container/definePlugin.ts
|
|
1317
|
-
/**
|
|
1318
|
-
* Define a configurable Guren plugin without ServiceProvider boilerplate. Each
|
|
1319
|
-
* factory call returns a fresh provider class, so the same plugin can be
|
|
1320
|
-
* registered twice with different configurations.
|
|
1321
|
-
*/
|
|
1322
|
-
function definePlugin(definition) {
|
|
1323
|
-
const className = `${definition.name}PluginProvider`;
|
|
1324
|
-
return (config) => {
|
|
1325
|
-
class ConfiguredPluginProvider extends ServiceProvider {
|
|
1326
|
-
static deferred = definition.deferred ?? false;
|
|
1327
|
-
static provides = definition.provides ?? [];
|
|
1328
|
-
register() {
|
|
1329
|
-
return definition.register(this.container, config);
|
|
1330
|
-
}
|
|
1331
|
-
boot() {
|
|
1332
|
-
return definition.boot?.(this.container, config);
|
|
1333
|
-
}
|
|
1334
|
-
}
|
|
1335
|
-
Object.defineProperty(ConfiguredPluginProvider, "name", { value: className });
|
|
1336
|
-
return ConfiguredPluginProvider;
|
|
1337
|
-
};
|
|
1338
|
-
}
|
|
1339
|
-
//#endregion
|
|
1340
|
-
//#region src/container/defineModule.ts
|
|
1341
|
-
/** Define a Guren application module without boilerplate. */
|
|
1342
|
-
function defineModule(definition) {
|
|
1343
|
-
return {
|
|
1344
|
-
name: definition.name,
|
|
1345
|
-
prefix: definition.prefix,
|
|
1346
|
-
routes: definition.routes,
|
|
1347
|
-
providers: definition.providers ?? [],
|
|
1348
|
-
commands: definition.commands ?? []
|
|
1349
|
-
};
|
|
1350
|
-
}
|
|
1351
|
-
/**
|
|
1352
|
-
* Runs a module's route registrar, applying its `prefix` via `router.group()`.
|
|
1353
|
-
* Shared by `Application.mountRoutes()` and the CLI's route loader, so both see
|
|
1354
|
-
* the same route set. `router.group()`'s callback is synchronous (prefix
|
|
1355
|
-
* pushed, callback run, prefix popped), so route calls made after an `await`
|
|
1356
|
-
* inside an async prefixed registrar run with the prefix already popped.
|
|
1357
|
-
*/
|
|
1358
|
-
async function mountModuleRoutes(router, gurenModule) {
|
|
1359
|
-
const registrar = gurenModule.routes;
|
|
1360
|
-
if (!registrar) return;
|
|
1361
|
-
if (!gurenModule.prefix) {
|
|
1362
|
-
await registrar(router);
|
|
1363
|
-
return;
|
|
1364
|
-
}
|
|
1365
|
-
let pending = void 0;
|
|
1366
|
-
router.group(gurenModule.prefix, (grouped) => {
|
|
1367
|
-
pending = registrar(grouped);
|
|
1368
|
-
});
|
|
1369
|
-
await pending;
|
|
1370
|
-
}
|
|
1371
|
-
//#endregion
|
|
1372
891
|
//#region src/http/middleware/cookie-session-store.ts
|
|
1373
892
|
const IV_BYTES = 12;
|
|
1374
893
|
const TAG_BYTES = 16;
|
|
@@ -2344,94 +1863,6 @@ function requestLoggingMiddleware() {
|
|
|
2344
1863
|
});
|
|
2345
1864
|
}
|
|
2346
1865
|
//#endregion
|
|
2347
|
-
//#region src/http/middleware/detect-locale.ts
|
|
2348
|
-
/** Context key for the resolved request locale (read by Inertia for `<html lang>`). */
|
|
2349
|
-
const LOCALE_CONTEXT_KEY = "locale";
|
|
2350
|
-
/** Reads the `locale` context variable, whoever set it. */
|
|
2351
|
-
function getRequestLocale(c) {
|
|
2352
|
-
const locale = c.var?.[LOCALE_CONTEXT_KEY];
|
|
2353
|
-
return typeof locale === "string" && locale.length > 0 ? locale : void 0;
|
|
2354
|
-
}
|
|
2355
|
-
/** The request-scoped translator bound by {@link detectLocaleMiddleware}. */
|
|
2356
|
-
function getRequestTranslator(c) {
|
|
2357
|
-
const vars = c.var;
|
|
2358
|
-
const t = vars?.["t"];
|
|
2359
|
-
const tc = vars?.["tc"];
|
|
2360
|
-
return typeof t === "function" && typeof tc === "function" ? {
|
|
2361
|
-
t,
|
|
2362
|
-
tc
|
|
2363
|
-
} : void 0;
|
|
2364
|
-
}
|
|
2365
|
-
const DEFAULT_SOURCES = [
|
|
2366
|
-
"query",
|
|
2367
|
-
"cookie",
|
|
2368
|
-
"header"
|
|
2369
|
-
];
|
|
2370
|
-
/**
|
|
2371
|
-
* Resolves the request locale from the query string, a cookie, or
|
|
2372
|
-
* `Accept-Language`, restricted to the `supported` allowlist, and stores it as
|
|
2373
|
-
* the `locale` context variable that Inertia reads for `<html lang>`.
|
|
2374
|
-
*/
|
|
2375
|
-
function detectLocaleMiddleware(options) {
|
|
2376
|
-
const supported = options.supported.map((locale) => locale.trim()).filter(Boolean);
|
|
2377
|
-
if (supported.length === 0) throw new Error("detectLocaleMiddleware requires at least one supported locale.");
|
|
2378
|
-
const fallback = options.fallback ?? supported[0];
|
|
2379
|
-
const sources = options.sources ?? DEFAULT_SOURCES;
|
|
2380
|
-
const queryParam = options.queryParam ?? "locale";
|
|
2381
|
-
const cookieName = options.cookieName ?? "locale";
|
|
2382
|
-
const byLowerCase = new Map(supported.map((locale) => [locale.toLowerCase(), locale]));
|
|
2383
|
-
const match = (candidate) => {
|
|
2384
|
-
const value = candidate?.trim().toLowerCase();
|
|
2385
|
-
if (!value) return;
|
|
2386
|
-
return byLowerCase.get(value) ?? byLowerCase.get(value.split("-")[0]);
|
|
2387
|
-
};
|
|
2388
|
-
const matchHeader = (header) => {
|
|
2389
|
-
if (!header) return;
|
|
2390
|
-
for (const accept of parseAccept(header)) {
|
|
2391
|
-
if (accept.type === "*" || accept.q <= 0) continue;
|
|
2392
|
-
const matched = match(accept.type);
|
|
2393
|
-
if (matched) return matched;
|
|
2394
|
-
}
|
|
2395
|
-
};
|
|
2396
|
-
const translators = /* @__PURE__ */ new Map();
|
|
2397
|
-
const supportedSet = new Set(supported);
|
|
2398
|
-
const bindingFor = (locale, i18n) => {
|
|
2399
|
-
const cached = translators.get(locale);
|
|
2400
|
-
if (cached) return cached;
|
|
2401
|
-
const translator = i18n.forLocale(locale);
|
|
2402
|
-
const binding = {
|
|
2403
|
-
t: translator.t.bind(translator),
|
|
2404
|
-
tc: translator.tc.bind(translator)
|
|
2405
|
-
};
|
|
2406
|
-
if (supportedSet.has(locale) && i18n.isLocaleLoaded(locale)) translators.set(locale, binding);
|
|
2407
|
-
return binding;
|
|
2408
|
-
};
|
|
2409
|
-
return createMiddleware(async (c, next) => {
|
|
2410
|
-
const readers = {
|
|
2411
|
-
query: () => match(c.req.query(queryParam)),
|
|
2412
|
-
cookie: () => match(getCookie(c, cookieName)),
|
|
2413
|
-
header: () => matchHeader(c.req.header("Accept-Language"))
|
|
2414
|
-
};
|
|
2415
|
-
let resolved = fallback;
|
|
2416
|
-
for (const source of sources) {
|
|
2417
|
-
const matched = readers[source]();
|
|
2418
|
-
if (matched) {
|
|
2419
|
-
resolved = matched;
|
|
2420
|
-
break;
|
|
2421
|
-
}
|
|
2422
|
-
}
|
|
2423
|
-
c.set(LOCALE_CONTEXT_KEY, resolved);
|
|
2424
|
-
const i18n = options.i18n === false ? void 0 : options.i18n ?? tryGetRequestContainer(c)?.makeOptional("i18n") ?? resolveI18n();
|
|
2425
|
-
if (i18n) {
|
|
2426
|
-
await i18n.loadLocale(resolved).catch(() => {});
|
|
2427
|
-
const current = () => bindingFor(getRequestLocale(c) ?? resolved, i18n);
|
|
2428
|
-
c.set("t", (key, replacements) => current().t(key, replacements));
|
|
2429
|
-
c.set("tc", (key, count, replacements) => current().tc(key, count, replacements));
|
|
2430
|
-
}
|
|
2431
|
-
await next();
|
|
2432
|
-
});
|
|
2433
|
-
}
|
|
2434
|
-
//#endregion
|
|
2435
1866
|
//#region src/http/middleware/index.ts
|
|
2436
1867
|
function defineMiddleware(handler) {
|
|
2437
1868
|
return handler;
|
|
@@ -2825,7 +2256,7 @@ var MethodNotAllowedException = class MethodNotAllowedException extends HttpExce
|
|
|
2825
2256
|
*/
|
|
2826
2257
|
var AuthorizationServiceProvider = class extends ServiceProvider {
|
|
2827
2258
|
register() {
|
|
2828
|
-
this.container.
|
|
2259
|
+
this.container.singletonIf("gate", () => createGate());
|
|
2829
2260
|
}
|
|
2830
2261
|
};
|
|
2831
2262
|
//#endregion
|
|
@@ -2833,7 +2264,7 @@ var AuthorizationServiceProvider = class extends ServiceProvider {
|
|
|
2833
2264
|
/** Binds the ExceptionHandler singleton and attaches it as global error middleware. */
|
|
2834
2265
|
var ErrorServiceProvider = class extends ServiceProvider {
|
|
2835
2266
|
register() {
|
|
2836
|
-
this.container.
|
|
2267
|
+
this.container.singletonIf("exception.handler", () => createExceptionHandler());
|
|
2837
2268
|
}
|
|
2838
2269
|
boot() {
|
|
2839
2270
|
const hono = this.container.make("hono");
|
|
@@ -2842,8 +2273,42 @@ var ErrorServiceProvider = class extends ServiceProvider {
|
|
|
2842
2273
|
}
|
|
2843
2274
|
};
|
|
2844
2275
|
//#endregion
|
|
2276
|
+
//#region src/i18n/injected-translations.ts
|
|
2277
|
+
const INJECTED_TRANSLATIONS_HINT = "It must hold the lang/ catalogs as JSON ({ locale: { namespace: messages } }); deploy plugins inject it at build time.";
|
|
2278
|
+
/**
|
|
2279
|
+
* The `lang/` catalogs a deploy build injected for runtimes that ship no `lang/`
|
|
2280
|
+
* directory (Workers, Lambda, Vercel). Fails loudly on a value that is set but
|
|
2281
|
+
* not a catalog: falling through to the filesystem would warn about a missing
|
|
2282
|
+
* `lang/` rather than about the variable that is actually broken.
|
|
2283
|
+
*/
|
|
2284
|
+
function injectedTranslations() {
|
|
2285
|
+
const raw = process.env.GUREN_TRANSLATIONS;
|
|
2286
|
+
if (typeof raw !== "string" || raw.length === 0) return;
|
|
2287
|
+
let parsed;
|
|
2288
|
+
try {
|
|
2289
|
+
parsed = JSON.parse(raw);
|
|
2290
|
+
} catch (error) {
|
|
2291
|
+
throw new Error(`GUREN_TRANSLATIONS is set but is not valid JSON. ${INJECTED_TRANSLATIONS_HINT}`, { cause: error });
|
|
2292
|
+
}
|
|
2293
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) throw new Error(`GUREN_TRANSLATIONS is set but does not hold a catalog object. ${INJECTED_TRANSLATIONS_HINT}`);
|
|
2294
|
+
return parsed;
|
|
2295
|
+
}
|
|
2296
|
+
//#endregion
|
|
2845
2297
|
//#region src/providers/I18nServiceProvider.ts
|
|
2846
2298
|
/**
|
|
2299
|
+
* The catalogs a deploy build injected, for an app reading the default `lang/`.
|
|
2300
|
+
* The build bundles only that directory, so an explicit `loader` or `path` opts out.
|
|
2301
|
+
*/
|
|
2302
|
+
function injectedCatalogFor(options) {
|
|
2303
|
+
return options.loader || options.path !== void 0 ? void 0 : injectedTranslations();
|
|
2304
|
+
}
|
|
2305
|
+
function missingCatalogHint(options, locale) {
|
|
2306
|
+
if (options.loader) return ".";
|
|
2307
|
+
if (options.path !== void 0) return ` — expected ${options.path}/${locale}/*.json.`;
|
|
2308
|
+
if (injectedTranslations()) return ` — the deploy build found no lang/${locale}/*.json to bundle.`;
|
|
2309
|
+
return ` — expected lang/${locale}/*.json. A deployed app without lang/ on disk needs a Guren deploy build or i18n.loader.`;
|
|
2310
|
+
}
|
|
2311
|
+
/**
|
|
2847
2312
|
* Binds the I18nManager as a singleton. With `createApp({ i18n })` it also
|
|
2848
2313
|
* mounts locale detection (unless `i18n.detect` is `false`), preloads every
|
|
2849
2314
|
* supported locale at boot, and shares the request locale and its messages with
|
|
@@ -2857,14 +2322,16 @@ var I18nServiceProvider = class extends ServiceProvider {
|
|
|
2857
2322
|
if (options.supported.length === 0) throw new Error("createApp({ i18n }) requires at least one supported locale.");
|
|
2858
2323
|
if (options.fallback && !options.supported.includes(options.fallback)) throw new Error(`createApp({ i18n }): fallback locale '${options.fallback}' must be one of the supported locales (${options.supported.join(", ")}).`);
|
|
2859
2324
|
}
|
|
2860
|
-
this.container.
|
|
2325
|
+
this.container.singletonIf("i18n", () => {
|
|
2861
2326
|
if (!options) return createI18n({ locale: "en" });
|
|
2327
|
+
const injected = injectedCatalogFor(options);
|
|
2328
|
+
const loader = options.loader ?? (injected ? new MemoryLoader(injected) : void 0);
|
|
2862
2329
|
const fallback = options.fallback ?? options.supported[0];
|
|
2863
2330
|
return createI18n({
|
|
2864
2331
|
locale: fallback,
|
|
2865
2332
|
fallbackLocale: fallback,
|
|
2866
|
-
path:
|
|
2867
|
-
loader
|
|
2333
|
+
path: loader ? void 0 : options.path ?? "lang",
|
|
2334
|
+
loader
|
|
2868
2335
|
});
|
|
2869
2336
|
});
|
|
2870
2337
|
if (app && options && options.detect !== false) {
|
|
@@ -2882,7 +2349,7 @@ var I18nServiceProvider = class extends ServiceProvider {
|
|
|
2882
2349
|
if (!options) return;
|
|
2883
2350
|
const manager = this.container.make("i18n");
|
|
2884
2351
|
await manager.loadLocales([...options.supported]);
|
|
2885
|
-
for (const locale of options.supported) if (Object.keys(manager.getMessages(locale)).length === 0) console.warn(`[guren] i18n: no translations loaded for locale '${locale}'
|
|
2352
|
+
for (const locale of options.supported) if (Object.keys(manager.getMessages(locale)).length === 0) console.warn(`[guren] i18n: no translations loaded for locale '${locale}'${missingCatalogHint(options, locale)}`);
|
|
2886
2353
|
if (options.share !== false) {
|
|
2887
2354
|
const fallback = manager.getFallbackLocale() ?? manager.getLocale();
|
|
2888
2355
|
const supported = new Set(options.supported);
|
|
@@ -3090,6 +2557,90 @@ function identifierOf(user) {
|
|
|
3090
2557
|
return typeof record?.getAuthIdentifier === "function" ? record.getAuthIdentifier() : record?.id;
|
|
3091
2558
|
}
|
|
3092
2559
|
//#endregion
|
|
2560
|
+
//#region src/config/env-reads.ts
|
|
2561
|
+
function recordEnvReads(values) {
|
|
2562
|
+
const read = /* @__PURE__ */ new Set();
|
|
2563
|
+
return {
|
|
2564
|
+
env: new Proxy(values, { get(target, property, receiver) {
|
|
2565
|
+
if (typeof property === "string") read.add(property);
|
|
2566
|
+
return Reflect.get(target, property, receiver);
|
|
2567
|
+
} }),
|
|
2568
|
+
read
|
|
2569
|
+
};
|
|
2570
|
+
}
|
|
2571
|
+
//#endregion
|
|
2572
|
+
//#region src/providers/ConfigServiceProvider.ts
|
|
2573
|
+
/**
|
|
2574
|
+
* Validates `createApp({ env })` and binds it as `env`, then resolves and binds
|
|
2575
|
+
* each `createApp({ config })` definition (RFC 0027 §1-§3). Registered before
|
|
2576
|
+
* every other provider: a bad environment fails the boot before anything
|
|
2577
|
+
* registers, every later register() sees the configured managers, and a later
|
|
2578
|
+
* provider that rebinds one fails the boot through {@link ownedBindings}.
|
|
2579
|
+
*/
|
|
2580
|
+
var ConfigServiceProvider = class extends ServiceProvider {
|
|
2581
|
+
env = {};
|
|
2582
|
+
unset = /* @__PURE__ */ new Set();
|
|
2583
|
+
resolved = [];
|
|
2584
|
+
owned = /* @__PURE__ */ new Map();
|
|
2585
|
+
register() {
|
|
2586
|
+
const app = this.container.make("app");
|
|
2587
|
+
this.env = this.parseEnv(app);
|
|
2588
|
+
this.resolved = [];
|
|
2589
|
+
this.owned = /* @__PURE__ */ new Map();
|
|
2590
|
+
const definitions = app.configDefinitions;
|
|
2591
|
+
assertDistinctKeys(definitions);
|
|
2592
|
+
for (const definition of definitions) {
|
|
2593
|
+
const { env, read } = recordEnvReads(this.env);
|
|
2594
|
+
const config = definition.resolve(env);
|
|
2595
|
+
const placeholders = [...read].filter((key) => this.unset.has(key));
|
|
2596
|
+
if (placeholders.length > 0) {
|
|
2597
|
+
warnOnce(`config-unverified:${definition.key}`, `[guren] the "${definition.key}" config reads ${placeholders.join(", ")}, which the environment does not set; it was left unbound.`);
|
|
2598
|
+
continue;
|
|
2599
|
+
}
|
|
2600
|
+
const before = new Map(this.container.getBindings().map((key) => [key, this.container.bindingOf(key)]));
|
|
2601
|
+
definition.bind(this.container, config);
|
|
2602
|
+
for (const key of this.container.getBindings()) {
|
|
2603
|
+
const binding = this.container.bindingOf(key);
|
|
2604
|
+
if (binding !== before.get(key)) this.owned.set(key, {
|
|
2605
|
+
binding,
|
|
2606
|
+
source: `config/${definition.key}.ts`
|
|
2607
|
+
});
|
|
2608
|
+
}
|
|
2609
|
+
this.resolved.push({
|
|
2610
|
+
definition,
|
|
2611
|
+
config
|
|
2612
|
+
});
|
|
2613
|
+
}
|
|
2614
|
+
}
|
|
2615
|
+
async boot() {
|
|
2616
|
+
for (const { definition, config } of this.resolved) await definition.boot?.(this.container, config, this.env);
|
|
2617
|
+
}
|
|
2618
|
+
/** @internal The bindings the definitions made, for ProviderManager's twice-configured check. */
|
|
2619
|
+
ownedBindings() {
|
|
2620
|
+
return this.owned;
|
|
2621
|
+
}
|
|
2622
|
+
parseEnv(app) {
|
|
2623
|
+
const schema = app.envSchema;
|
|
2624
|
+
this.unset = /* @__PURE__ */ new Set();
|
|
2625
|
+
if (!schema) return {};
|
|
2626
|
+
const source = this.container.makeOptional("env.source");
|
|
2627
|
+
const introspecting = typeof process !== "undefined" && process.env.GUREN_INTROSPECT === "1";
|
|
2628
|
+
const parsed = schema.parse(source, { mode: introspecting ? "report" : "throw" });
|
|
2629
|
+
for (const problem of parsed.problems) warnOnce(`env-invalid:${problem.key}`, `[guren] Invalid environment: ${problem.key} ${problem.message} (reported under GUREN_INTROSPECT=1).`);
|
|
2630
|
+
this.unset = parsed.unset;
|
|
2631
|
+
this.container.instance("env", parsed.values);
|
|
2632
|
+
return parsed.values;
|
|
2633
|
+
}
|
|
2634
|
+
};
|
|
2635
|
+
function assertDistinctKeys(definitions) {
|
|
2636
|
+
const seen = /* @__PURE__ */ new Map();
|
|
2637
|
+
definitions.forEach((definition, index) => {
|
|
2638
|
+
const first = seen.get(definition.key);
|
|
2639
|
+
if (first !== void 0) throw new Error(`[guren] createApp({ config }) has two "${definition.key}" definitions, at config[${first}] and config[${index}]. Keep one.`);
|
|
2640
|
+
seen.set(definition.key, index);
|
|
2641
|
+
});
|
|
2642
|
+
}
|
|
2643
|
+
//#endregion
|
|
3093
2644
|
//#region src/http/Application.ts
|
|
3094
2645
|
const MANAGED_VITE_ENV_FLAG = "GUREN_MANAGED_VITE_DEV_SERVER";
|
|
3095
2646
|
const DEFAULT_DEV_ENTRY_PATH = "/resources/js/dev-entry.ts";
|
|
@@ -3336,6 +2887,8 @@ var Application = class {
|
|
|
3336
2887
|
this.container.instance("router", this.router);
|
|
3337
2888
|
if (options.inertia?.document) this.container.instance("inertia.document", options.inertia.document);
|
|
3338
2889
|
if (options.inertia?.ssrRenderer) this.container.instance("inertia.ssrRenderer", options.inertia.ssrRenderer);
|
|
2890
|
+
if (options.inertia?.share) shareInertiaProps(options.inertia.share, this.container);
|
|
2891
|
+
if (options.env || options.config?.length) this.providerManager.register(ConfigServiceProvider);
|
|
3339
2892
|
this.authManager.registerGuard("web", ({ session }) => {
|
|
3340
2893
|
const provider = this.authManager.hasProvider("users") ? this.authManager.getProvider(DEFAULT_PROVIDER) : unconfiguredUserProvider;
|
|
3341
2894
|
return new SessionGuard({
|
|
@@ -3365,6 +2918,12 @@ var Application = class {
|
|
|
3365
2918
|
get i18nOptions() {
|
|
3366
2919
|
return this.options.i18n;
|
|
3367
2920
|
}
|
|
2921
|
+
get envSchema() {
|
|
2922
|
+
return this.options.env;
|
|
2923
|
+
}
|
|
2924
|
+
get configDefinitions() {
|
|
2925
|
+
return this.options.config ?? [];
|
|
2926
|
+
}
|
|
3368
2927
|
markAutoSessionAttached() {
|
|
3369
2928
|
this.autoSessionAttached = true;
|
|
3370
2929
|
}
|
|
@@ -3453,11 +3012,12 @@ var Application = class {
|
|
|
3453
3012
|
await this.bootPromise;
|
|
3454
3013
|
}
|
|
3455
3014
|
async bootOnce() {
|
|
3015
|
+
if (this.options.hostAuthorization !== void 0 && this.hasHttpConfig()) throw new Error("[guren] Host authorization is configured twice: createApp({ hostAuthorization }) and config/http.ts. Keep one.");
|
|
3456
3016
|
await this.providerManager.registerAll();
|
|
3457
3017
|
await this.options.boot?.(this.hono);
|
|
3458
3018
|
await this.mountRoutes();
|
|
3459
|
-
await this.mountDevEndpoint(isMcpEndpointEnabled(), async () => (await import("./McpServiceProvider-
|
|
3460
|
-
await this.mountDevEndpoint(isDocsViewerEnabled(), async () => (await import("./DocsViewerServiceProvider-
|
|
3019
|
+
await this.mountDevEndpoint(isMcpEndpointEnabled(), async () => (await import("./McpServiceProvider-B-LioPSz.js").then((n) => n.n)).McpServiceProvider, "GUREN_MCP=1 but the MCP endpoint could not load — is @guren/cli installed?");
|
|
3020
|
+
await this.mountDevEndpoint(isDocsViewerEnabled(), async () => (await import("./DocsViewerServiceProvider-CIRNHQ2I.js")).DocsViewerServiceProvider, "GUREN_DOCS=1 but the docs viewer could not load — is @guren/cli resolvable from this app?");
|
|
3461
3021
|
await this.providerManager.bootAll();
|
|
3462
3022
|
this.warnOnUnconfiguredAuth();
|
|
3463
3023
|
}
|
|
@@ -3487,11 +3047,36 @@ var Application = class {
|
|
|
3487
3047
|
this.mountHostAuthorization();
|
|
3488
3048
|
}
|
|
3489
3049
|
mountHostAuthorization() {
|
|
3050
|
+
if (this.hasHttpConfig()) {
|
|
3051
|
+
this.mountConfiguredHostAuthorization();
|
|
3052
|
+
return;
|
|
3053
|
+
}
|
|
3490
3054
|
const { hostAuthorization } = this.options;
|
|
3491
3055
|
if (hostAuthorization === false || !hostAuthorization) return;
|
|
3492
3056
|
this.hono.use("*", createHostAuthorizationMiddleware(hostAuthorization));
|
|
3493
3057
|
}
|
|
3494
3058
|
/**
|
|
3059
|
+
* Holds host authorization's place ahead of every app middleware while its
|
|
3060
|
+
* options wait for `defineHttpConfig()` to resolve at boot (RFC 0027 §5), the
|
|
3061
|
+
* placeholder shape AuthServiceProvider uses for sessions. Unbound means not
|
|
3062
|
+
* booted, and an unchecked request is refused rather than passed.
|
|
3063
|
+
*/
|
|
3064
|
+
mountConfiguredHostAuthorization() {
|
|
3065
|
+
const container = this.container;
|
|
3066
|
+
let middleware;
|
|
3067
|
+
this.hono.use("*", (ctx, next) => {
|
|
3068
|
+
if (middleware === void 0) {
|
|
3069
|
+
if (!container.has("http.hostAuthorization")) return Promise.resolve(ctx.text("Service Unavailable: the application has not booted", 503));
|
|
3070
|
+
const options = container.make("http.hostAuthorization");
|
|
3071
|
+
middleware = options ? createHostAuthorizationMiddleware(options) : null;
|
|
3072
|
+
}
|
|
3073
|
+
return middleware ? middleware(ctx, next) : next();
|
|
3074
|
+
});
|
|
3075
|
+
}
|
|
3076
|
+
hasHttpConfig() {
|
|
3077
|
+
return this.configDefinitions.some((definition) => definition.key === "http");
|
|
3078
|
+
}
|
|
3079
|
+
/**
|
|
3495
3080
|
* Mounts an opt-in, dev-only framework endpoint. Only the dynamic import may
|
|
3496
3081
|
* fail silently — these providers reach optional dependencies an app need not
|
|
3497
3082
|
* have installed. A failure inside the provider's own boot is rethrown.
|
|
@@ -3686,368 +3271,6 @@ function createApp(options = {}) {
|
|
|
3686
3271
|
return new Application(options);
|
|
3687
3272
|
}
|
|
3688
3273
|
//#endregion
|
|
3689
|
-
//#region src/mvc/view.ts
|
|
3690
|
-
/**
|
|
3691
|
-
* Does the output begin with an `<html>` root, allowing leading whitespace and
|
|
3692
|
-
* complete comments? A linear scan rather than a regex: the equivalent pattern
|
|
3693
|
-
* backtracks exponentially on adversarial comment runs (CodeQL js/redos), and
|
|
3694
|
-
* the scanned body can embed user-influenced raw markup.
|
|
3695
|
-
*/
|
|
3696
|
-
function startsWithHtmlRoot(body) {
|
|
3697
|
-
let i = 0;
|
|
3698
|
-
while (i < body.length) {
|
|
3699
|
-
const ch = body.charCodeAt(i);
|
|
3700
|
-
if (ch === 32 || ch >= 9 && ch <= 13) {
|
|
3701
|
-
i++;
|
|
3702
|
-
continue;
|
|
3703
|
-
}
|
|
3704
|
-
if (body.startsWith("<!--", i)) {
|
|
3705
|
-
const end = body.indexOf("-->", i + 4);
|
|
3706
|
-
if (end === -1) return false;
|
|
3707
|
-
i = end + 3;
|
|
3708
|
-
continue;
|
|
3709
|
-
}
|
|
3710
|
-
break;
|
|
3711
|
-
}
|
|
3712
|
-
if (body.slice(i, i + 5).toLowerCase() !== "<html") return false;
|
|
3713
|
-
const next = body.charCodeAt(i + 5);
|
|
3714
|
-
return next === 62 || next === 32 || next >= 9 && next <= 13;
|
|
3715
|
-
}
|
|
3716
|
-
/**
|
|
3717
|
-
* Render a `hono/jsx` component to a plain server-rendered HTML `Response` —
|
|
3718
|
-
* the engine behind `Controller.view()` (RFC 0014).
|
|
3719
|
-
*/
|
|
3720
|
-
async function renderDocument(component, props, options = {}) {
|
|
3721
|
-
const body = String(await (0, jsx_runtime_exports.jsx)(component, props, void 0).toString());
|
|
3722
|
-
if (options.doctype !== false && !startsWithHtmlRoot(body)) {
|
|
3723
|
-
const name = component.displayName ?? component.name ?? "component";
|
|
3724
|
-
throw new Error(`view(): ${name} rendered a fragment, not a document. Wrap the page in your Layout (an <html> root), or pass { doctype: false } for an intentional fragment response. Without <html>/<head>, <title> and <meta> tags are not hoisted and the page ships unstyled.`);
|
|
3725
|
-
}
|
|
3726
|
-
const { doctype, headers: headersInit, ...init } = options;
|
|
3727
|
-
const headers = new Headers(headersInit);
|
|
3728
|
-
if (!headers.has("content-type")) headers.set("content-type", "text/html; charset=utf-8");
|
|
3729
|
-
return new Response((doctype === false ? "" : "<!doctype html>") + body, {
|
|
3730
|
-
...init,
|
|
3731
|
-
headers
|
|
3732
|
-
});
|
|
3733
|
-
}
|
|
3734
|
-
//#endregion
|
|
3735
|
-
//#region src/mvc/Controller.ts
|
|
3736
|
-
/**
|
|
3737
|
-
* Base controller inspired by Laravel's expressive API. Subclasses reach the
|
|
3738
|
-
* Hono context through the protected `ctx` getter. Dependencies are declared
|
|
3739
|
-
* with `static inject = ['cache'] as const` and passed to the constructor.
|
|
3740
|
-
*/
|
|
3741
|
-
var Controller = class {
|
|
3742
|
-
/** Services to resolve from the container and pass to the constructor. */
|
|
3743
|
-
static inject;
|
|
3744
|
-
context;
|
|
3745
|
-
parsedBody;
|
|
3746
|
-
resolvedModels;
|
|
3747
|
-
_container;
|
|
3748
|
-
setContext(context) {
|
|
3749
|
-
this.context = context;
|
|
3750
|
-
}
|
|
3751
|
-
/** @internal Called by the router to inject the DI container. */
|
|
3752
|
-
setContainer(container) {
|
|
3753
|
-
this._container = container;
|
|
3754
|
-
}
|
|
3755
|
-
/** @internal Called by the router to store a route-bound model instance. */
|
|
3756
|
-
setResolvedModel(modelClass, instance) {
|
|
3757
|
-
if (!this.resolvedModels) this.resolvedModels = /* @__PURE__ */ new Map();
|
|
3758
|
-
this.resolvedModels.set(modelClass, instance);
|
|
3759
|
-
}
|
|
3760
|
-
/**
|
|
3761
|
-
* Retrieve a model instance resolved via route model binding — a per-route
|
|
3762
|
-
* `bind` option or a router-level `router.bind(param, Model)`. The class
|
|
3763
|
-
* alone looks up by primary key, a `[Model, column]` tuple by that column.
|
|
3764
|
-
*/
|
|
3765
|
-
model(modelClass) {
|
|
3766
|
-
const instance = this.resolvedModels?.get(modelClass);
|
|
3767
|
-
if (instance === void 0) throw new Error(`No model binding found for ${modelClass.name ?? "unknown"}. Ensure the route has a matching bind option in RouteContractOptions, or the router a bind(param, Model) call.`);
|
|
3768
|
-
return instance;
|
|
3769
|
-
}
|
|
3770
|
-
get ctx() {
|
|
3771
|
-
if (!this.context) throw new Error("Controller context has not been set.");
|
|
3772
|
-
return this.context;
|
|
3773
|
-
}
|
|
3774
|
-
get request() {
|
|
3775
|
-
return this.ctx.req;
|
|
3776
|
-
}
|
|
3777
|
-
/**
|
|
3778
|
-
* Get an uploaded file from a multipart request. Returns null when the field
|
|
3779
|
-
* is missing, is not a file, or the upload is empty. Hono caches the parsed
|
|
3780
|
-
* body, so this composes with other body reads in the same request.
|
|
3781
|
-
*/
|
|
3782
|
-
async file(name) {
|
|
3783
|
-
const value = (await parseRequestUploads(this.ctx))[name];
|
|
3784
|
-
const candidate = Array.isArray(value) ? value[0] : value;
|
|
3785
|
-
return candidate instanceof File && candidate.size > 0 ? candidate : null;
|
|
3786
|
-
}
|
|
3787
|
-
/**
|
|
3788
|
-
* Get all uploaded files for a multipart field (e.g. `<input multiple>`).
|
|
3789
|
-
* Returns an empty array when none were uploaded.
|
|
3790
|
-
*/
|
|
3791
|
-
async files(name) {
|
|
3792
|
-
const value = (await parseRequestUploads(this.ctx))[name];
|
|
3793
|
-
return (Array.isArray(value) ? value : value !== void 0 ? [value] : []).filter((item) => item instanceof File && item.size > 0);
|
|
3794
|
-
}
|
|
3795
|
-
get auth() {
|
|
3796
|
-
const auth = getAuthContext(this.ctx);
|
|
3797
|
-
if (!auth) throw new Error("Controller auth helper requires the auth middleware. Make sure AuthServiceProvider is registered.");
|
|
3798
|
-
return auth;
|
|
3799
|
-
}
|
|
3800
|
-
make(key) {
|
|
3801
|
-
if (!this._container) throw new Error("Controller.make() requires a DI container. Ensure the app is booted with a Container.");
|
|
3802
|
-
return this._container.make(key);
|
|
3803
|
-
}
|
|
3804
|
-
/** Get the authenticated API token, or throw AuthenticationException. */
|
|
3805
|
-
apiToken() {
|
|
3806
|
-
return getApiTokenOrFail(this.ctx);
|
|
3807
|
-
}
|
|
3808
|
-
/** Get the authenticated user ID from the API token. */
|
|
3809
|
-
apiTokenUserId() {
|
|
3810
|
-
return this.apiToken().userId;
|
|
3811
|
-
}
|
|
3812
|
-
/**
|
|
3813
|
-
* Authorize the current user (or guest) for an ability; throws
|
|
3814
|
-
* AuthorizationException (403) when denied. ORM records are plain objects
|
|
3815
|
-
* with no constructor information, so pass the model class alongside the
|
|
3816
|
-
* record: `await this.authorize('update', [Post, post])`.
|
|
3817
|
-
*/
|
|
3818
|
-
async authorize(ability, ...args) {
|
|
3819
|
-
await this.#resolveGate().forUser(await this.gateUser()).authorize(ability, ...args);
|
|
3820
|
-
}
|
|
3821
|
-
/** Check an ability without throwing: `await this.can('update', [Post, post])`. */
|
|
3822
|
-
async can(ability, ...args) {
|
|
3823
|
-
return this.#resolveGate().forUser(await this.gateUser()).allows(ability, ...args);
|
|
3824
|
-
}
|
|
3825
|
-
/** This app's `gate` (RFC 0023 §2); the ambient one only off a container, as on a bare Hono app. */
|
|
3826
|
-
#resolveGate() {
|
|
3827
|
-
return resolveOptional(this._container, "gate") ?? resolveGate();
|
|
3828
|
-
}
|
|
3829
|
-
async gateUser() {
|
|
3830
|
-
const auth = getAuthContext(this.ctx);
|
|
3831
|
-
if (!auth) return null;
|
|
3832
|
-
return await auth.user();
|
|
3833
|
-
}
|
|
3834
|
-
/**
|
|
3835
|
-
* Render a `hono/jsx` component to a plain server-rendered HTML response —
|
|
3836
|
-
* the non-hydrating counterpart to {@link inertia} (RFC 0014). Escaping
|
|
3837
|
-
* covers markup only, not URL schemes: a `javascript:` href built from user
|
|
3838
|
-
* data is emitted verbatim, so sanitize user-supplied URLs upstream.
|
|
3839
|
-
*/
|
|
3840
|
-
view(component, props, options) {
|
|
3841
|
-
return renderDocument(component, props, options);
|
|
3842
|
-
}
|
|
3843
|
-
async inertia(componentOrPage, props, options = {}) {
|
|
3844
|
-
const ctx = this.ctx;
|
|
3845
|
-
const component = typeof componentOrPage === "string" ? componentOrPage : componentOrPage.component ?? componentOrPage.id;
|
|
3846
|
-
const propsWithShared = {
|
|
3847
|
-
...await resolveSharedInertiaProps(ctx, this._container),
|
|
3848
|
-
...props
|
|
3849
|
-
};
|
|
3850
|
-
const response = await inertia(component, propsWithShared, {
|
|
3851
|
-
...options,
|
|
3852
|
-
lang: options.lang ?? this.#resolveLocale(),
|
|
3853
|
-
request: ctx.req.raw,
|
|
3854
|
-
container: this._container
|
|
3855
|
-
});
|
|
3856
|
-
response.__gurenInertia = {
|
|
3857
|
-
component,
|
|
3858
|
-
props: propsWithShared
|
|
3859
|
-
};
|
|
3860
|
-
return response;
|
|
3861
|
-
}
|
|
3862
|
-
/**
|
|
3863
|
-
* Locale for the current request: the request-scoped `locale` context
|
|
3864
|
-
* variable wins over the app-wide i18n locale. Falls back to `'en'`.
|
|
3865
|
-
*/
|
|
3866
|
-
get locale() {
|
|
3867
|
-
return this.#resolveLocale() ?? "en";
|
|
3868
|
-
}
|
|
3869
|
-
/**
|
|
3870
|
-
* Translate a key for the current request locale, using the request-scoped
|
|
3871
|
-
* translator the locale middleware bound, else one scoped to `this.locale`.
|
|
3872
|
-
*/
|
|
3873
|
-
t(key, replacements) {
|
|
3874
|
-
return this.#requestTranslator().t(key, replacements);
|
|
3875
|
-
}
|
|
3876
|
-
/**
|
|
3877
|
-
* Translate a key with a count for pluralization, using the same locale
|
|
3878
|
-
* resolution as {@link Controller.t}.
|
|
3879
|
-
*/
|
|
3880
|
-
tc(key, count, replacements) {
|
|
3881
|
-
return this.#requestTranslator().tc(key, count, replacements);
|
|
3882
|
-
}
|
|
3883
|
-
#requestTranslator() {
|
|
3884
|
-
const bound = getRequestTranslator(this.ctx);
|
|
3885
|
-
if (bound) return bound;
|
|
3886
|
-
const i18n = this.#resolveI18n();
|
|
3887
|
-
if (!i18n) throw new Error("Controller i18n helpers require i18n to be configured. Pass createApp({ i18n }) or register an I18nManager.");
|
|
3888
|
-
const locale = getRequestLocale(this.ctx);
|
|
3889
|
-
return locale && locale !== i18n.getLocale() ? i18n.forLocale(locale) : i18n;
|
|
3890
|
-
}
|
|
3891
|
-
#resolveLocale() {
|
|
3892
|
-
const requestLocale = getRequestLocale(this.ctx);
|
|
3893
|
-
if (requestLocale) return requestLocale;
|
|
3894
|
-
const locale = this.#resolveI18n()?.getLocale();
|
|
3895
|
-
return typeof locale === "string" && locale.length > 0 ? locale : void 0;
|
|
3896
|
-
}
|
|
3897
|
-
#resolveI18n() {
|
|
3898
|
-
return resolveOptional(this._container, "i18n") ?? resolveI18n();
|
|
3899
|
-
}
|
|
3900
|
-
json(data, init = {}) {
|
|
3901
|
-
return new Response(JSON.stringify(data), {
|
|
3902
|
-
...init,
|
|
3903
|
-
headers: {
|
|
3904
|
-
"Content-Type": "application/json; charset=utf-8",
|
|
3905
|
-
...init.headers
|
|
3906
|
-
}
|
|
3907
|
-
});
|
|
3908
|
-
}
|
|
3909
|
-
text(body, init = {}) {
|
|
3910
|
-
return new Response(body, {
|
|
3911
|
-
...init,
|
|
3912
|
-
headers: {
|
|
3913
|
-
"Content-Type": "text/plain; charset=utf-8",
|
|
3914
|
-
...init.headers
|
|
3915
|
-
}
|
|
3916
|
-
});
|
|
3917
|
-
}
|
|
3918
|
-
redirect(url, options = {}) {
|
|
3919
|
-
const requestMethod = this.request.method?.toUpperCase?.();
|
|
3920
|
-
const defaultStatus = requestMethod && requestMethod !== "GET" ? 303 : 302;
|
|
3921
|
-
const { status = defaultStatus, headers } = options;
|
|
3922
|
-
return new Response(null, {
|
|
3923
|
-
status,
|
|
3924
|
-
headers: {
|
|
3925
|
-
Location: url,
|
|
3926
|
-
...headers
|
|
3927
|
-
}
|
|
3928
|
-
});
|
|
3929
|
-
}
|
|
3930
|
-
noContent() {
|
|
3931
|
-
return new Response(null, { status: 204 });
|
|
3932
|
-
}
|
|
3933
|
-
created(data, init = {}) {
|
|
3934
|
-
return this.jsonStatus(201, data, init);
|
|
3935
|
-
}
|
|
3936
|
-
accepted(data, init = {}) {
|
|
3937
|
-
return this.jsonStatus(202, data, init);
|
|
3938
|
-
}
|
|
3939
|
-
jsonStatus(status, data, init = {}) {
|
|
3940
|
-
if (data === void 0) return new Response(null, {
|
|
3941
|
-
status,
|
|
3942
|
-
...init
|
|
3943
|
-
});
|
|
3944
|
-
return new Response(JSON.stringify(data), {
|
|
3945
|
-
status,
|
|
3946
|
-
...init,
|
|
3947
|
-
headers: {
|
|
3948
|
-
"Content-Type": "application/json; charset=utf-8",
|
|
3949
|
-
...init.headers
|
|
3950
|
-
}
|
|
3951
|
-
});
|
|
3952
|
-
}
|
|
3953
|
-
/** Get an input value; body values take precedence over query parameters. */
|
|
3954
|
-
async input(key, defaultValue) {
|
|
3955
|
-
const body = await this.getBody();
|
|
3956
|
-
if (key in body) return body[key];
|
|
3957
|
-
const queryValue = this.ctx.req.query(key);
|
|
3958
|
-
if (queryValue !== void 0) return queryValue;
|
|
3959
|
-
return defaultValue;
|
|
3960
|
-
}
|
|
3961
|
-
query(key, defaultValue) {
|
|
3962
|
-
return this.ctx.req.query(key) ?? defaultValue;
|
|
3963
|
-
}
|
|
3964
|
-
/** Get only the specified keys from the request body. */
|
|
3965
|
-
async only(...keys) {
|
|
3966
|
-
const body = await this.getBody();
|
|
3967
|
-
const result = {};
|
|
3968
|
-
for (const key of keys) if (key in body) result[key] = body[key];
|
|
3969
|
-
return result;
|
|
3970
|
-
}
|
|
3971
|
-
/** Get all request body values except the specified keys. */
|
|
3972
|
-
async except(...keys) {
|
|
3973
|
-
const body = await this.getBody();
|
|
3974
|
-
const excluded = new Set(keys);
|
|
3975
|
-
const result = {};
|
|
3976
|
-
for (const [key, value] of Object.entries(body)) if (!excluded.has(key)) result[key] = value;
|
|
3977
|
-
return result;
|
|
3978
|
-
}
|
|
3979
|
-
/** Check if a key exists in the request body. */
|
|
3980
|
-
async has(key) {
|
|
3981
|
-
return key in await this.getBody();
|
|
3982
|
-
}
|
|
3983
|
-
/** Flatten query string arrays to scalar values for cleaner schema usage. */
|
|
3984
|
-
flattenQueries() {
|
|
3985
|
-
return flattenRequestQueries(this.ctx);
|
|
3986
|
-
}
|
|
3987
|
-
/** Validate the request body; throws ValidationException on failure. */
|
|
3988
|
-
async validateBody(schema) {
|
|
3989
|
-
return this.runValidation(schema, await this.getRawBody());
|
|
3990
|
-
}
|
|
3991
|
-
/** Validate query parameters; throws ValidationException on failure. */
|
|
3992
|
-
validateQuery(schema) {
|
|
3993
|
-
return this.runValidation(schema, this.flattenQueries());
|
|
3994
|
-
}
|
|
3995
|
-
/** Validate route parameters; throws ValidationException on failure. */
|
|
3996
|
-
validateParams(schema) {
|
|
3997
|
-
const params = this.ctx.req.param();
|
|
3998
|
-
return this.runValidation(schema, params);
|
|
3999
|
-
}
|
|
4000
|
-
/** Validate the request body without throwing; returns data or field errors. */
|
|
4001
|
-
async validateBodySafe(schema) {
|
|
4002
|
-
return this.runValidationSafe(schema, await this.getRawBody());
|
|
4003
|
-
}
|
|
4004
|
-
/** Validate query parameters without throwing; returns data or field errors. */
|
|
4005
|
-
validateQuerySafe(schema) {
|
|
4006
|
-
return this.runValidationSafe(schema, this.flattenQueries());
|
|
4007
|
-
}
|
|
4008
|
-
/** Validate route parameters without throwing; returns data or field errors. */
|
|
4009
|
-
validateParamsSafe(schema) {
|
|
4010
|
-
const params = this.ctx.req.param();
|
|
4011
|
-
return this.runValidationSafe(schema, params);
|
|
4012
|
-
}
|
|
4013
|
-
runValidation(schema, data) {
|
|
4014
|
-
const result = schema.safeParse(data);
|
|
4015
|
-
if (result.success) return result.data;
|
|
4016
|
-
throw ValidationException.fromZodError(result.error);
|
|
4017
|
-
}
|
|
4018
|
-
runValidationSafe(schema, data) {
|
|
4019
|
-
const result = schema.safeParse(data);
|
|
4020
|
-
if (result.success) return {
|
|
4021
|
-
success: true,
|
|
4022
|
-
data: result.data
|
|
4023
|
-
};
|
|
4024
|
-
const errors = {};
|
|
4025
|
-
for (const issue of result.error.issues) {
|
|
4026
|
-
const field = issue.path.join(".") || issue.message;
|
|
4027
|
-
if (!errors[field]) errors[field] = issue.message;
|
|
4028
|
-
}
|
|
4029
|
-
return {
|
|
4030
|
-
success: false,
|
|
4031
|
-
errors
|
|
4032
|
-
};
|
|
4033
|
-
}
|
|
4034
|
-
/**
|
|
4035
|
-
* The parsed body as sent: an array stays an array, so a non-object contract
|
|
4036
|
-
* stays reachable. Boxed rather than memoized by truthiness — `null`, `''`,
|
|
4037
|
-
* `0` and `false` are parsed bodies, and re-reading would find the stream
|
|
4038
|
-
* consumed. No fallback here: {@link parseRequestBody} already yields `{}`.
|
|
4039
|
-
*/
|
|
4040
|
-
async getRawBody() {
|
|
4041
|
-
if (this.parsedBody) return this.parsedBody.value;
|
|
4042
|
-
this.parsedBody = { value: await parseRequestBody(this.ctx) };
|
|
4043
|
-
return this.parsedBody.value;
|
|
4044
|
-
}
|
|
4045
|
-
/** The record view of {@link getRawBody}; a non-object body reads as `{}`. */
|
|
4046
|
-
async getBody() {
|
|
4047
|
-
return asRecord(await this.getRawBody());
|
|
4048
|
-
}
|
|
4049
|
-
};
|
|
4050
|
-
//#endregion
|
|
4051
3274
|
//#region src/http/vite-assets.ts
|
|
4052
3275
|
let defaultCandidates;
|
|
4053
3276
|
const manifestCache = /* @__PURE__ */ new Map();
|
|
@@ -4623,7 +3846,8 @@ const AGENT_SURFACES = {
|
|
|
4623
3846
|
"dev-mcp": true,
|
|
4624
3847
|
"cli": true,
|
|
4625
3848
|
"webmcp": true,
|
|
4626
|
-
"durable": true
|
|
3849
|
+
"durable": true,
|
|
3850
|
+
"in-process": true
|
|
4627
3851
|
};
|
|
4628
3852
|
/** Every denial reason, as a value, total over the union for the same reason. */
|
|
4629
3853
|
const DENIAL_REASONS = {
|
|
@@ -4768,6 +3992,22 @@ function warnSinkFailure(error) {
|
|
|
4768
3992
|
console.warn(`[guren] agent audit sink failed, record dropped: ${String(error)}`);
|
|
4769
3993
|
}
|
|
4770
3994
|
//#endregion
|
|
3995
|
+
//#region src/agent/audit-sink.ts
|
|
3996
|
+
/**
|
|
3997
|
+
* The `audit` option every agent surface plugin takes (`mcpPlugin`, `aiPlugin`),
|
|
3998
|
+
* and the one rule turning it into a sink. Absent from `@guren/server/agent`:
|
|
3999
|
+
* the file branch writes to disk, which a browser dispatcher has no use for.
|
|
4000
|
+
*/
|
|
4001
|
+
/**
|
|
4002
|
+
* `{ file }` is built behind a dynamic `import()` so an application that
|
|
4003
|
+
* configured its own `sink` never evaluates the filesystem module.
|
|
4004
|
+
*/
|
|
4005
|
+
async function resolveAgentAuditSink(config) {
|
|
4006
|
+
if ("sink" in config) return config.sink;
|
|
4007
|
+
const { createFileAuditSink } = await import("./audit-file-DocumbCr.js");
|
|
4008
|
+
return createFileAuditSink(config.file ?? "storage/logs/agent-audit.log", config.days);
|
|
4009
|
+
}
|
|
4010
|
+
//#endregion
|
|
4771
4011
|
//#region src/agent/approval.ts
|
|
4772
4012
|
/**
|
|
4773
4013
|
* How long a pending request stays answerable by default: one hour. An approval
|
|
@@ -5276,6 +4516,27 @@ function elapsed(startedAt) {
|
|
|
5276
4516
|
return Math.round(performance.now() - startedAt);
|
|
5277
4517
|
}
|
|
5278
4518
|
//#endregion
|
|
4519
|
+
//#region src/agent/call-budget.ts
|
|
4520
|
+
/**
|
|
4521
|
+
* One meter per returned function: share the function to share the budget.
|
|
4522
|
+
* Throws on a limit that is not a whole number of at least 1.
|
|
4523
|
+
*/
|
|
4524
|
+
function createAgentCallBudget(options) {
|
|
4525
|
+
const { callsPerMinute: limit, message } = options;
|
|
4526
|
+
if (!Number.isInteger(limit) || limit < 1) throw new RangeError(`An agent call budget must be a whole number of calls of at least 1, not ${String(limit)}.`);
|
|
4527
|
+
const now = options.now ?? Date.now;
|
|
4528
|
+
const hits = [];
|
|
4529
|
+
return () => {
|
|
4530
|
+
const at = now();
|
|
4531
|
+
while (hits.length > 0 && hits[0] <= at - 6e4) hits.shift();
|
|
4532
|
+
if (hits.length >= limit) return {
|
|
4533
|
+
reason: "rate-limit",
|
|
4534
|
+
message: message(limit)
|
|
4535
|
+
};
|
|
4536
|
+
hits.push(at);
|
|
4537
|
+
};
|
|
4538
|
+
}
|
|
4539
|
+
//#endregion
|
|
5279
4540
|
//#region src/agent/approval-status.ts
|
|
5280
4541
|
/**
|
|
5281
4542
|
* Reading one approval record as an answer for the caller that asked
|
|
@@ -5324,7 +4585,7 @@ function toApprovalStatusReport(requestId, record, principal, now) {
|
|
|
5324
4585
|
/** Binds OAuthManager as a singleton in the container. */
|
|
5325
4586
|
var OAuthServiceProvider = class extends ServiceProvider {
|
|
5326
4587
|
register() {
|
|
5327
|
-
this.container.
|
|
4588
|
+
this.container.singletonIf("oauth", () => createOAuthManager());
|
|
5328
4589
|
}
|
|
5329
4590
|
};
|
|
5330
4591
|
//#endregion
|
|
@@ -5332,7 +4593,7 @@ var OAuthServiceProvider = class extends ServiceProvider {
|
|
|
5332
4593
|
/** Binds the EventManager as a singleton in the container. */
|
|
5333
4594
|
var EventServiceProvider = class extends ServiceProvider {
|
|
5334
4595
|
register() {
|
|
5335
|
-
this.container.
|
|
4596
|
+
this.container.singletonIf("events", () => createEventManager());
|
|
5336
4597
|
}
|
|
5337
4598
|
boot() {
|
|
5338
4599
|
this.container.make("events").setQueueDispatcher(createQueueEventDispatcher());
|
|
@@ -5343,7 +4604,7 @@ var EventServiceProvider = class extends ServiceProvider {
|
|
|
5343
4604
|
/** Binds the CacheManager as a singleton in the container. */
|
|
5344
4605
|
var CacheServiceProvider = class extends ServiceProvider {
|
|
5345
4606
|
register() {
|
|
5346
|
-
this.container.
|
|
4607
|
+
this.container.singletonIf("cache", () => createCacheManager());
|
|
5347
4608
|
}
|
|
5348
4609
|
};
|
|
5349
4610
|
//#endregion
|
|
@@ -5351,7 +4612,7 @@ var CacheServiceProvider = class extends ServiceProvider {
|
|
|
5351
4612
|
/** Binds the QueueManager as a singleton in the container. */
|
|
5352
4613
|
var QueueServiceProvider = class extends ServiceProvider {
|
|
5353
4614
|
register() {
|
|
5354
|
-
this.container.
|
|
4615
|
+
this.container.singletonIf("queue", () => createQueueManager());
|
|
5355
4616
|
}
|
|
5356
4617
|
};
|
|
5357
4618
|
//#endregion
|
|
@@ -5365,7 +4626,7 @@ var QueueServiceProvider = class extends ServiceProvider {
|
|
|
5365
4626
|
*/
|
|
5366
4627
|
var MailServiceProvider = class extends ServiceProvider {
|
|
5367
4628
|
register() {
|
|
5368
|
-
this.container.
|
|
4629
|
+
this.container.singletonIf("mail", (container) => createMailManager({
|
|
5369
4630
|
default: "log",
|
|
5370
4631
|
transports: { log: { driver: "log" } }
|
|
5371
4632
|
}, container));
|
|
@@ -5381,7 +4642,7 @@ var MailServiceProvider = class extends ServiceProvider {
|
|
|
5381
4642
|
*/
|
|
5382
4643
|
var LogServiceProvider = class extends ServiceProvider {
|
|
5383
4644
|
register() {
|
|
5384
|
-
this.container.
|
|
4645
|
+
this.container.singletonIf("log", () => createLogManager({
|
|
5385
4646
|
default: "console",
|
|
5386
4647
|
channels: { console: { driver: "console" } }
|
|
5387
4648
|
}));
|
|
@@ -5395,7 +4656,7 @@ var LogServiceProvider = class extends ServiceProvider {
|
|
|
5395
4656
|
*/
|
|
5396
4657
|
var NotificationServiceProvider = class extends ServiceProvider {
|
|
5397
4658
|
register() {
|
|
5398
|
-
this.container.
|
|
4659
|
+
this.container.singletonIf("notifications", () => createNotificationManager());
|
|
5399
4660
|
}
|
|
5400
4661
|
boot() {
|
|
5401
4662
|
this.container.make("notifications").registerQueueJob();
|
|
@@ -5409,7 +4670,7 @@ var NotificationServiceProvider = class extends ServiceProvider {
|
|
|
5409
4670
|
*/
|
|
5410
4671
|
var BroadcastServiceProvider = class extends ServiceProvider {
|
|
5411
4672
|
register() {
|
|
5412
|
-
this.container.
|
|
4673
|
+
this.container.singletonIf("broadcast", () => createBroadcastManager());
|
|
5413
4674
|
}
|
|
5414
4675
|
};
|
|
5415
4676
|
//#endregion
|
|
@@ -5424,7 +4685,7 @@ var BroadcastServiceProvider = class extends ServiceProvider {
|
|
|
5424
4685
|
var EncryptionServiceProvider = class extends ServiceProvider {
|
|
5425
4686
|
register() {
|
|
5426
4687
|
if (!this.container.has("app.keyring")) this.container.instance("app.keyring", getAppKeyringFromEnv());
|
|
5427
|
-
this.container.
|
|
4688
|
+
this.container.singletonIf("encrypter", () => {
|
|
5428
4689
|
const keyring = deriveAppKeyring(this.container.make("app.keyring"), "data-encryption");
|
|
5429
4690
|
return createEncrypter({
|
|
5430
4691
|
key: encodeDerivedKey(keyring.current),
|
|
@@ -5438,7 +4699,7 @@ var EncryptionServiceProvider = class extends ServiceProvider {
|
|
|
5438
4699
|
/** Binds the StorageManager as a singleton in the container. */
|
|
5439
4700
|
var StorageServiceProvider = class extends ServiceProvider {
|
|
5440
4701
|
register() {
|
|
5441
|
-
this.container.
|
|
4702
|
+
this.container.singletonIf("storage", () => createStorageManager());
|
|
5442
4703
|
}
|
|
5443
4704
|
};
|
|
5444
4705
|
//#endregion
|
|
@@ -5446,7 +4707,7 @@ var StorageServiceProvider = class extends ServiceProvider {
|
|
|
5446
4707
|
/** Binds the HealthManager as a singleton in the container. */
|
|
5447
4708
|
var HealthServiceProvider = class extends ServiceProvider {
|
|
5448
4709
|
register() {
|
|
5449
|
-
this.container.
|
|
4710
|
+
this.container.singletonIf("health", () => createHealthManager());
|
|
5450
4711
|
}
|
|
5451
4712
|
};
|
|
5452
4713
|
//#endregion
|
|
@@ -5454,7 +4715,7 @@ var HealthServiceProvider = class extends ServiceProvider {
|
|
|
5454
4715
|
/** Binds the Scheduler as a singleton in the container. */
|
|
5455
4716
|
var SchedulingServiceProvider = class extends ServiceProvider {
|
|
5456
4717
|
register() {
|
|
5457
|
-
this.container.
|
|
4718
|
+
this.container.singletonIf("scheduler", () => createScheduler());
|
|
5458
4719
|
}
|
|
5459
4720
|
};
|
|
5460
4721
|
//#endregion
|
|
@@ -6370,75 +5631,6 @@ function createSeederRunner(options) {
|
|
|
6370
5631
|
return new SeederRunner(options);
|
|
6371
5632
|
}
|
|
6372
5633
|
//#endregion
|
|
6373
|
-
//#region src/http/resources/Resource.ts
|
|
6374
|
-
/**
|
|
6375
|
-
* Abstract base class for API resources: transforms model data into an API
|
|
6376
|
-
* response payload. `TData` names what `toArray()` builds, so `toJSON()` reports
|
|
6377
|
-
* it too; it defaults to `ResourceData` so `Resource<T>` and narrowing overrides
|
|
6378
|
-
* keep compiling. `TData` is a claim about `toArray()` only — `additional()` is
|
|
6379
|
-
* spread *after* the payload, so a colliding key overwrites a typed field.
|
|
6380
|
-
*/
|
|
6381
|
-
var Resource = class {
|
|
6382
|
-
resource;
|
|
6383
|
-
additionalData = {};
|
|
6384
|
-
constructor(resource) {
|
|
6385
|
-
this.resource = resource;
|
|
6386
|
-
}
|
|
6387
|
-
toJSON() {
|
|
6388
|
-
return {
|
|
6389
|
-
...this.toArray(),
|
|
6390
|
-
...this.additionalData
|
|
6391
|
-
};
|
|
6392
|
-
}
|
|
6393
|
-
/** Keys merged beside the payload, overriding colliding `toArray()` keys. */
|
|
6394
|
-
additional(data) {
|
|
6395
|
-
this.additionalData = {
|
|
6396
|
-
...this.additionalData,
|
|
6397
|
-
...data
|
|
6398
|
-
};
|
|
6399
|
-
return this;
|
|
6400
|
-
}
|
|
6401
|
-
when(condition, value) {
|
|
6402
|
-
if (!condition) return;
|
|
6403
|
-
return typeof value === "function" ? value() : value;
|
|
6404
|
-
}
|
|
6405
|
-
whenOr(condition, value, defaultValue) {
|
|
6406
|
-
if (!condition) return defaultValue;
|
|
6407
|
-
return typeof value === "function" ? value() : value;
|
|
6408
|
-
}
|
|
6409
|
-
/** Loaded means the relation key is present and not `undefined`. */
|
|
6410
|
-
whenLoaded(relation, value, defaultValue) {
|
|
6411
|
-
const resource = this.resource;
|
|
6412
|
-
if (!(relation in resource && resource[relation] !== void 0)) return defaultValue;
|
|
6413
|
-
return typeof value === "function" ? value() : value;
|
|
6414
|
-
}
|
|
6415
|
-
whenNotNull(value) {
|
|
6416
|
-
return value ?? void 0;
|
|
6417
|
-
}
|
|
6418
|
-
merge(data) {
|
|
6419
|
-
return {
|
|
6420
|
-
...this.toArray(),
|
|
6421
|
-
...data
|
|
6422
|
-
};
|
|
6423
|
-
}
|
|
6424
|
-
static make(resource) {
|
|
6425
|
-
return new this(resource);
|
|
6426
|
-
}
|
|
6427
|
-
static collection(resources) {
|
|
6428
|
-
return resources.map((resource) => new this(resource).toJSON());
|
|
6429
|
-
}
|
|
6430
|
-
};
|
|
6431
|
-
/** Create a resource collection from a resource class. */
|
|
6432
|
-
function collect(resources, resourceClass) {
|
|
6433
|
-
return resources.map((resource) => new resourceClass(resource).toJSON());
|
|
6434
|
-
}
|
|
6435
|
-
/** Simple resource wrapper for objects that need no transformation. */
|
|
6436
|
-
var JsonResource = class extends Resource {
|
|
6437
|
-
toArray() {
|
|
6438
|
-
return { ...this.resource };
|
|
6439
|
-
}
|
|
6440
|
-
};
|
|
6441
|
-
//#endregion
|
|
6442
5634
|
//#region src/http/resources/ResourceCollection.ts
|
|
6443
5635
|
/** Collection of resources with additional metadata. */
|
|
6444
5636
|
var ResourceCollection = class ResourceCollection {
|
|
@@ -8038,7 +7230,265 @@ function renderEnvironmentSection() {
|
|
|
8038
7230
|
</section>`;
|
|
8039
7231
|
}
|
|
8040
7232
|
//#endregion
|
|
7233
|
+
//#region src/config/env.ts
|
|
7234
|
+
/**
|
|
7235
|
+
* The declared environment (RFC 0027 §1): one schema, validated at boot by
|
|
7236
|
+
* ConfigServiceProvider, by the CLI, and by a connection thunk run outside an
|
|
7237
|
+
* application, all through {@link EnvSchema.parse}. A blank value is unset for
|
|
7238
|
+
* every builder, which is what `guren/no-nullish-env-default` exists to catch
|
|
7239
|
+
* in hand-written reads.
|
|
7240
|
+
*/
|
|
7241
|
+
/** One declared variable. Immutable: every modifier returns a new instance. */
|
|
7242
|
+
var EnvVar = class EnvVar {
|
|
7243
|
+
state;
|
|
7244
|
+
constructor(state) {
|
|
7245
|
+
this.state = state;
|
|
7246
|
+
}
|
|
7247
|
+
/** Unset resolves to `undefined`. */
|
|
7248
|
+
optional() {
|
|
7249
|
+
return new EnvVar({
|
|
7250
|
+
...this.state,
|
|
7251
|
+
presence: "optional"
|
|
7252
|
+
});
|
|
7253
|
+
}
|
|
7254
|
+
/** Unset, blank included, resolves to `value`. */
|
|
7255
|
+
default(value) {
|
|
7256
|
+
return new EnvVar({
|
|
7257
|
+
...this.state,
|
|
7258
|
+
presence: "defaulted",
|
|
7259
|
+
fallback: value
|
|
7260
|
+
});
|
|
7261
|
+
}
|
|
7262
|
+
/** Required only when `NODE_ENV` is `production`; `undefined` when unset elsewhere. */
|
|
7263
|
+
requiredInProduction() {
|
|
7264
|
+
return new EnvVar({
|
|
7265
|
+
...this.state,
|
|
7266
|
+
presence: "production"
|
|
7267
|
+
});
|
|
7268
|
+
}
|
|
7269
|
+
/** Treat `FOO=` as the value `''` rather than as unset. */
|
|
7270
|
+
allowEmpty() {
|
|
7271
|
+
return new EnvVar({
|
|
7272
|
+
...this.state,
|
|
7273
|
+
emptyAllowed: true
|
|
7274
|
+
});
|
|
7275
|
+
}
|
|
7276
|
+
/** Never echo the value, in a problem message or anywhere a schema is printed. */
|
|
7277
|
+
secret() {
|
|
7278
|
+
return new EnvVar({
|
|
7279
|
+
...this.state,
|
|
7280
|
+
isSecret: true
|
|
7281
|
+
});
|
|
7282
|
+
}
|
|
7283
|
+
describe(text) {
|
|
7284
|
+
return new EnvVar({
|
|
7285
|
+
...this.state,
|
|
7286
|
+
description: text
|
|
7287
|
+
});
|
|
7288
|
+
}
|
|
7289
|
+
get isSecret() {
|
|
7290
|
+
return this.state.isSecret;
|
|
7291
|
+
}
|
|
7292
|
+
get description() {
|
|
7293
|
+
return this.state.description;
|
|
7294
|
+
}
|
|
7295
|
+
/** The `.default()` value; `undefined` unless `presence` is `defaulted`. */
|
|
7296
|
+
get defaultValue() {
|
|
7297
|
+
return this.state.fallback;
|
|
7298
|
+
}
|
|
7299
|
+
/** The values an `Env.enum()` admits; `undefined` for every other builder. */
|
|
7300
|
+
get choices() {
|
|
7301
|
+
return this.state.choices;
|
|
7302
|
+
}
|
|
7303
|
+
/** @internal */
|
|
7304
|
+
resolve(raw, production) {
|
|
7305
|
+
const { presence } = this.state;
|
|
7306
|
+
if (raw === void 0 || raw === "" && !this.state.emptyAllowed) {
|
|
7307
|
+
if (presence === "defaulted") return { value: this.state.fallback };
|
|
7308
|
+
if (presence === "optional" || presence === "production" && !production) return { value: void 0 };
|
|
7309
|
+
return { unset: true };
|
|
7310
|
+
}
|
|
7311
|
+
return this.state.coerce(raw);
|
|
7312
|
+
}
|
|
7313
|
+
};
|
|
7314
|
+
function envVar(coerce, choices) {
|
|
7315
|
+
return new EnvVar({
|
|
7316
|
+
coerce,
|
|
7317
|
+
choices,
|
|
7318
|
+
presence: "required",
|
|
7319
|
+
emptyAllowed: false,
|
|
7320
|
+
isSecret: false
|
|
7321
|
+
});
|
|
7322
|
+
}
|
|
7323
|
+
const PORT_PATTERN = /^\d+$/u;
|
|
7324
|
+
const Env = {
|
|
7325
|
+
string: () => envVar((raw) => ({ value: raw })),
|
|
7326
|
+
url: () => envVar((raw) => {
|
|
7327
|
+
try {
|
|
7328
|
+
new URL(raw);
|
|
7329
|
+
return { value: raw };
|
|
7330
|
+
} catch {
|
|
7331
|
+
return { problem: "is not a URL" };
|
|
7332
|
+
}
|
|
7333
|
+
}),
|
|
7334
|
+
number: () => envVar((raw) => {
|
|
7335
|
+
const value = Number(raw);
|
|
7336
|
+
return raw.trim() !== "" && Number.isFinite(value) ? { value } : { problem: "is not a number" };
|
|
7337
|
+
}),
|
|
7338
|
+
port: () => envVar((raw) => {
|
|
7339
|
+
const value = Number(raw);
|
|
7340
|
+
return PORT_PATTERN.test(raw) && value >= 1 && value <= 65535 ? { value } : { problem: "is not a port" };
|
|
7341
|
+
}),
|
|
7342
|
+
boolean: () => envVar((raw) => {
|
|
7343
|
+
const normalized = raw.toLowerCase();
|
|
7344
|
+
if (normalized === "true" || normalized === "1") return { value: true };
|
|
7345
|
+
if (normalized === "false" || normalized === "0") return { value: false };
|
|
7346
|
+
return { problem: "is not a boolean (true, false, 1 or 0)" };
|
|
7347
|
+
}),
|
|
7348
|
+
enum: (values) => envVar((raw) => values.includes(raw) ? { value: raw } : { problem: `is not one of: ${values.join(", ")}` }, Object.freeze([...values])),
|
|
7349
|
+
/**
|
|
7350
|
+
* Synchronous validators only: `parse()` also runs where nothing can await it
|
|
7351
|
+
* (the CLI, a connection thunk), so a Promise result is reported as a problem.
|
|
7352
|
+
*/
|
|
7353
|
+
custom: (schema) => envVar((raw) => {
|
|
7354
|
+
const result = schema["~standard"].validate(raw);
|
|
7355
|
+
if (result instanceof Promise) return { problem: "has an asynchronous validator; Env.custom() accepts synchronous validators only" };
|
|
7356
|
+
if ("value" in result && !result.issues) return { value: result.value };
|
|
7357
|
+
return { problem: `is invalid: ${(result.issues ?? []).map((issue) => issue.message).join("; ")}` };
|
|
7358
|
+
})
|
|
7359
|
+
};
|
|
7360
|
+
var EnvValidationError = class extends Error {
|
|
7361
|
+
problems;
|
|
7362
|
+
constructor(problems) {
|
|
7363
|
+
const width = Math.max(...problems.map((problem) => problem.key.length)) + 2;
|
|
7364
|
+
const lines = problems.map((problem) => ` ${problem.key.padEnd(width)}${problem.message}`);
|
|
7365
|
+
super(`[guren] Invalid environment (${problems.length} ${problems.length === 1 ? "problem" : "problems"}):\n${lines.join("\n")}`);
|
|
7366
|
+
this.problems = problems;
|
|
7367
|
+
this.name = "EnvValidationError";
|
|
7368
|
+
}
|
|
7369
|
+
};
|
|
7370
|
+
var EnvSchema = class {
|
|
7371
|
+
vars;
|
|
7372
|
+
constructor(vars) {
|
|
7373
|
+
this.vars = vars;
|
|
7374
|
+
}
|
|
7375
|
+
/**
|
|
7376
|
+
* Looks up each declared key in `source`, then `process.env`, and does not
|
|
7377
|
+
* cache: `process.env` keeps its identity while tests and platforms mutate it.
|
|
7378
|
+
*/
|
|
7379
|
+
parse(source, options = {}) {
|
|
7380
|
+
const production = typeof process !== "undefined" && process.env.NODE_ENV === "production";
|
|
7381
|
+
const values = {};
|
|
7382
|
+
const problems = [];
|
|
7383
|
+
for (const [key, spec] of Object.entries(this.vars)) {
|
|
7384
|
+
const raw = readRaw(source, key);
|
|
7385
|
+
const outcome = spec.resolve(raw, production);
|
|
7386
|
+
if ("value" in outcome) {
|
|
7387
|
+
values[key] = outcome.value;
|
|
7388
|
+
continue;
|
|
7389
|
+
}
|
|
7390
|
+
const shown = spec.isSecret || raw === void 0 ? "value" : JSON.stringify(raw);
|
|
7391
|
+
problems.push({
|
|
7392
|
+
key,
|
|
7393
|
+
message: "unset" in outcome ? "required, not set" : `${shown} ${outcome.problem}`
|
|
7394
|
+
});
|
|
7395
|
+
values[key] = AGENT_REDACTED;
|
|
7396
|
+
}
|
|
7397
|
+
if (problems.length > 0 && (options.mode ?? "throw") === "throw") throw new EnvValidationError(problems);
|
|
7398
|
+
const unset = new Set(problems.map((problem) => problem.key));
|
|
7399
|
+
return {
|
|
7400
|
+
values: Object.freeze(values),
|
|
7401
|
+
problems,
|
|
7402
|
+
unset
|
|
7403
|
+
};
|
|
7404
|
+
}
|
|
7405
|
+
};
|
|
7406
|
+
function readRaw(source, key) {
|
|
7407
|
+
const supplied = source?.[key];
|
|
7408
|
+
if (typeof supplied === "string") return supplied;
|
|
7409
|
+
return typeof process === "undefined" ? void 0 : process.env[key];
|
|
7410
|
+
}
|
|
7411
|
+
const ENV_KEY_PATTERN = /^[A-Z_][A-Z0-9_]*$/u;
|
|
7412
|
+
/**
|
|
7413
|
+
* Keys an app schema may not declare. `NODE_ENV` gates fold at bundle time only
|
|
7414
|
+
* as the exact `process.env.NODE_ENV` expression, and `GUREN_*` are framework
|
|
7415
|
+
* security gates and tooling flags (RFC 0027 §1). The oxlint rule keeps a copy.
|
|
7416
|
+
*/
|
|
7417
|
+
function isRawEnvKey(key) {
|
|
7418
|
+
return key === "NODE_ENV" || key.startsWith("GUREN_");
|
|
7419
|
+
}
|
|
7420
|
+
function defineEnv(vars) {
|
|
7421
|
+
for (const key of Object.keys(vars)) {
|
|
7422
|
+
if (!ENV_KEY_PATTERN.test(key)) throw new Error(`[guren] defineEnv(): "${key}" is not an environment variable name (A-Z, 0-9 and _).`);
|
|
7423
|
+
if (isRawEnvKey(key)) throw new Error(`[guren] defineEnv(): ${key} cannot be declared. NODE_ENV stays a raw \`process.env.NODE_ENV\` read so bundlers can fold production gates, and GUREN_* are framework security gates, not app settings.`);
|
|
7424
|
+
}
|
|
7425
|
+
return new EnvSchema(vars);
|
|
7426
|
+
}
|
|
7427
|
+
//#endregion
|
|
7428
|
+
//#region src/config/define.ts
|
|
7429
|
+
function defineConfig(definition) {
|
|
7430
|
+
return definition;
|
|
7431
|
+
}
|
|
7432
|
+
function defineCacheConfig(resolve) {
|
|
7433
|
+
return defineConfig({
|
|
7434
|
+
key: "cache",
|
|
7435
|
+
resolve,
|
|
7436
|
+
bind: (container, config) => {
|
|
7437
|
+
container.singleton("cache", () => createCacheManager(config));
|
|
7438
|
+
}
|
|
7439
|
+
});
|
|
7440
|
+
}
|
|
7441
|
+
function defineHttpConfig(resolve) {
|
|
7442
|
+
return defineConfig({
|
|
7443
|
+
key: "http",
|
|
7444
|
+
resolve,
|
|
7445
|
+
bind: (container, config) => {
|
|
7446
|
+
container.instance("http.hostAuthorization", config.hostAuthorization ?? false);
|
|
7447
|
+
}
|
|
7448
|
+
});
|
|
7449
|
+
}
|
|
7450
|
+
function defineMailConfig(resolve) {
|
|
7451
|
+
return defineConfig({
|
|
7452
|
+
key: "mail",
|
|
7453
|
+
resolve,
|
|
7454
|
+
bind: (container, config) => {
|
|
7455
|
+
container.singleton("mail", (resolving) => createMailManager(config, resolving));
|
|
7456
|
+
}
|
|
7457
|
+
});
|
|
7458
|
+
}
|
|
7459
|
+
function defineOAuthConfig(resolve) {
|
|
7460
|
+
return defineConfig({
|
|
7461
|
+
key: "oauth",
|
|
7462
|
+
resolve,
|
|
7463
|
+
bind: (container, config) => {
|
|
7464
|
+
container.singleton("oauth", () => {
|
|
7465
|
+
const manager = createOAuthManager(config);
|
|
7466
|
+
for (const [name, provider] of Object.entries(config.providers ?? {})) manager.registerProvider(name, provider);
|
|
7467
|
+
return manager;
|
|
7468
|
+
});
|
|
7469
|
+
}
|
|
7470
|
+
});
|
|
7471
|
+
}
|
|
7472
|
+
function defineQueueConfig(resolve) {
|
|
7473
|
+
return defineConfig({
|
|
7474
|
+
key: "queue",
|
|
7475
|
+
resolve,
|
|
7476
|
+
bind: (container, config) => {
|
|
7477
|
+
container.singleton("queue", () => createQueueManager(config));
|
|
7478
|
+
}
|
|
7479
|
+
});
|
|
7480
|
+
}
|
|
7481
|
+
function defineStorageConfig(resolve) {
|
|
7482
|
+
return defineConfig({
|
|
7483
|
+
key: "storage",
|
|
7484
|
+
resolve,
|
|
7485
|
+
bind: (container, config) => {
|
|
7486
|
+
container.singleton("storage", () => createStorageManager(config));
|
|
7487
|
+
}
|
|
7488
|
+
});
|
|
7489
|
+
}
|
|
7490
|
+
//#endregion
|
|
8041
7491
|
//#region src/index.ts
|
|
8042
7492
|
ensureErrorStackTracePolyfill();
|
|
8043
7493
|
//#endregion
|
|
8044
|
-
export { AGENT_APPROVAL_CONFIG_KEY, AGENT_AUDIT_BINDING, AGENT_REDACTED, AGENT_TOOL_NAME_PATTERN, API_TOKEN_KEY, APPROVAL_STATUS_TOOL_NAME, AUTH_CONTEXT_KEY, AgentApprovalRequested, AgentToolDenied, AgentToolInvoked, Application, ApplicationShutdown, ApplicationStarted, ScryptHasher as Argon2Hasher, ScryptHasher, AuthManager, Response$1 as AuthResponse, AuthServiceProvider, AuthenticatableModel, AuthenticationException, AuthorizationException, AuthorizationServiceProvider, AutoDiscovery, BUILT_IN_SESSION_DRIVERS, BaseFactory, BaseFactory as Factory, BaseSeeder, BaseSeeder as Seeder, BaseUserProvider, BroadcastManager, BroadcastServiceProvider, BufferedOutput, CONTAINER_CONTEXT_KEY, CSP_NONCE_KEY, CSRF_FORM_FIELD, CSRF_HEADER_NAME, CSRF_TOKEN_KEY, CacheCheck, CacheManager, CacheServiceProvider, Channel, Command, ConsoleChannel, ConsoleKernel, Container, Controller, CookieSessionStore, CursorPaginator, CustomCheck, DEFAULT_AGENT_APPROVAL_TTL_MS, DEFAULT_AGENT_AUDIT_PATH, DEFAULT_APPROVAL_CONFIGURE_HINT, DEFAULT_SCOPE_SUBJECT, DEFAULT_SESSION_STORE_NAME, DailyFileChannel, DatabaseChannel, DatabaseCheck, DefaultHasher, DefaultHasher as Hash, Encrypter, EncryptionServiceProvider, ErrorServiceProvider, Event, EventManager, EventServiceProvider, ExceptionHandler, FailedJobReporter, FieldValidator, FileStore as FileCacheStore, FileChannel, FormRequest, Gate, HealthCheck, HealthManager, HealthServiceProvider, HttpException, I18nManager, I18nServiceProvider, InertiaServiceProvider, Input, Job, JobFailed, JobProcessed, JsonLoader, JsonResource, LOCALE_CONTEXT_KEY, LOG_LEVEL_PRIORITY, Listener, LocalDriver as LocalStorageDriver, LogManager, LogServiceProvider, LogTransport, Logger, Mail, MailChannel, MailManager, MailServiceProvider, MemoryApiTokenStore, MemoryDriver as MemoryBroadcastDriver, MemoryStore as MemoryCacheStore, MemoryChannel, MemoryCheck, MemoryDriver$1 as MemoryDriver, MemoryDriver$1 as MemoryQueueDriver, MemoryEmailVerificationStore, MemoryLoader, MemoryOAuthStateStore, MemoryPasswordResetStore, MemoryRateLimitStore, MemorySchedulerLock, MemorySessionStore, MemoryDriver$2 as MemoryStorageDriver, MemoryTransport, MessageSigner, MethodNotAllowedException, ModelUserProvider, NodeHasher, NotFoundHttpException, Notification, NotificationManager, NotificationServiceProvider, OAUTH_SESSION_BINDING_KEY, OAuthManager, OAuthServiceProvider, Output, PER_PROCESS_SESSION_DRIVERS, PORTABLE_AGENT_TOOL_NAME_PATTERN, PREFLIGHT_ARGUMENT, PREFLIGHT_TOOL_NAME, Paginator, PendingSchedule, Policy, PresenceChannel, PrivateChannel, ProviderManager, QueueManager, QueueServiceProvider, RESERVED_AGENT_TOOL_NAMES, RedisDriver as RedisBroadcastDriver, RedisStore as RedisCacheStore, RedisCheck, RedisDriver$1 as RedisDriver, RedisDriver$1 as RedisQueueDriver, RequestFinished, RequestReceived, ResendTransport, Resource, ResourceCollection, Router, S3Driver, SERVERLESS_RUNTIME_LABELS, Schedule, ScheduledTask, Scheduler, SchedulingServiceProvider, SeederRunner, ServiceProvider, SessionGuard, SessionManager, SlackChannel, SlidingWindowRateLimitStore, SmtpTransport, SqsDriver, StorageCheck, StorageManager, StorageServiceProvider, SyncDriver, SyncDriver as SyncQueueDriver, TaggedCache, TokenGuard, Translator, UserAuthenticated, UserLoggedOut, VALIDATED_DATA_KEY, ValidationException, Validator, ViewEngine, Worker, abort, abortIf, abortUnless, advertisesStructuredOutput, after, afterOrEqual, agentApprovalExpiredAt, agentApprovalFingerprint, agentApprovalPrincipalKey, agentApprovalStatusAt, agentApprovalUsableAt, agentApprovalVisibleTo, alpha, alphaDash, alphaNum, ambientBinding, ambientContainer, approvalStatusNotFoundMessage, array as arrayRule, attachAuthContext, authorize as authorizeAbility, authorizeAllMiddleware, authorizeMiddleware, authorizeResourceMiddleware, before, beforeOrEqual, between, boolean as booleanRule, buildAgentApprovalRequest, buildOAuthAuthorizeUrl, buildOAuthRedirectUrl, buildPasswordResetUrl, buildToolRequest, buildVerificationUrl, can, cannot, canonicalizeAgentApprovalInput, check as checkHash, classifyRegistrationScope, clearJobRegistry, clearNotificationRegistry, clearQueueDriver, collect, completeEmailVerification, completePasswordReset, confirmed, createAgentApprovalContext, createAgentAuditRecorder, createAgentInvocationPipeline, createApiToken, createApp, createAuditEmitter, createBearerTokenMiddleware, createBroadcastManager, createCacheManager, createConsoleKernel, createContainer, createCorsMiddleware, createCspMiddleware, createCsrfMiddleware, createDiscordOAuthProviderConfig, createEmailVerificationToken, createEncrypter, createEventManager, createExceptionHandler, createFacade, createFacades, createForceHttpsMiddleware, createGate, createGitHubOAuthProviderConfig, createGoogleOAuthProviderConfig, createHealthManager, createHostAuthorizationMiddleware, createI18n, createLogManager, createMailManager, createNotificationManager, createOAuthManager, createOAuthState, createPasswordResetToken, createQueueEventDispatcher, createQueueManager, createRateLimitMiddleware, createRedirectSafetyMiddleware, createRedisClient, createScheduler, createSecurityHeaders, createSeederRunner, createSessionMiddleware, createSqsAdapter, createStorageManager, createTypedBroadcaster, createValidator, csrfField, cursorPaginate, custom, customCheck, dailyFileDateStamp, dailyFilePath, dateFormat, date as dateRule, debugErrorMiddleware, decodeCursor, decrypt, defaultApplication, defaultContainer, defineFactory, defineGate, defineMiddleware, defineModule, definePlugin, definePolicy, deriveAgentTools, deriveAppKey, deriveAppKeyring, describeBuildFailure, detectLocaleMiddleware, detectServerlessRuntime, different, email as emailRule, encodeCursor, encrypt, endsWith, exchangeOAuthCode, exists, expandToolScopes, fetchOAuthUserProfile, file as fileRule, filterSensitiveData, formatValidationErrors, gateApproval, gatePreflight, gateToolCall, generateAppKey, generateKey, generateOtp, generatePassword, generateSlug, getApiToken, getApiTokenOrFail, getAppKeyringFromEnv, getBroadcastManager, getContainer, getCspNonce, getCsrfToken, getEncrypter, getExceptionHandler, getGate, getI18n, getInertiaSharedPropsResolver, getJob, getLogManager, getMailManager, getNextOccurrence, getNextOccurrences, getNotification, getNotificationManager, getPluralizationRule, getQueueDriver, getRateLimitInfo, getRegisteredJobs, getRequestContainer, getRequestLocale, getRequestTranslator, getSessionFromContext, getUserApiTokens, getValidatedData, hash, hashPassword, hmac, image as imageRule, inValues, inertia, integer, ip, ipv4, ipv6, isDue, isDueInTimezone, isEmailVerified, isReservedAgentToolName, isSafeRedirectUrl, jsonResponse, json as jsonRule, mail, mapToolResponse, matchDailyFileDate, matchesCron, max, maxFileSize, md5, mimes, min, minFileSize, mountModuleRoutes, needsRehash, normalizeAppKey, notIn, notifyApprovers, nullable, numeric, object as objectRule, paginate, parseApiToken, parseAppKey, parseAuditRecord, parseCron, parseOAuthRedirectUrl, parsePasswordResetUrl, parsePreviousAppKeys, parseRequestPayload, parseSignature, parseToolScope, parseVerificationUrl, pick, pluralizationRules, processJob, prototype, quickValidate, quickValidateOrThrow, random, randomBase64, randomBase64Url, randomHex, randomInt, randomString, readBearerToken, redactAgentArguments, regex, registerJob, registerNotification, renderDebugPage, renderDocument, renderErrorPage, requestIdMiddleware, requestLoggingMiddleware, requireAuthenticated, requireGuest, requireVerifiedEmail, required, requiredIf, requiredUnless, requiredWith, requiredWithout, resetCalledSeeders, resetDefaultApplication, resetRateLimit, resolve, resolveJobName, resolveNotifiableType, resolveOptional, resolveQueueDriver, revokeAllApiTokens, revokeApiToken, same, sample, sanitizeOAuthRedirect, scopedShape, scopesAllowTool, secureCompare, selectPluralForm, setBroadcastManager, setContainer, setEncrypter, setExceptionHandler, setGate, setI18n, setInertiaDocument, setInertiaSharedProps, setInertiaSsrRenderer, setLogManager, setMailManager, setNotificationManager, setQueueDriver, sha256, sha512, shareInertiaProps, shuffle, signUrl, size, startsWith, string as stringRule, t, tc, toApprovalStatusReport, toAuditRecord, toTimezone, tokenCan, tokenCanAll, tokenCanAny, tryGetI18n, tryGetRequestContainer, unique, url as urlRule, urlSafeToken, useAsDefaultApplication, uuid, uuid$1 as uuidRule, validate, validateRequest, validateRequestWith, validateSafe, verifyApiToken, verifyCsrfToken, verifyEmailToken, verifyHmac, verifyOAuthState, verifyPassword, verifyPasswordResetToken, verifySignedUrl, viteAsset, withAuthorization };
|
|
7494
|
+
export { AGENT_APPROVAL_CONFIG_KEY, AGENT_AUDIT_BINDING, AGENT_REDACTED, AGENT_TOOL_NAME_PATTERN, API_TOKEN_KEY, APPROVAL_STATUS_TOOL_NAME, AUTH_CONTEXT_KEY, AgentApprovalRequested, AgentToolDenied, AgentToolInvoked, Application, ApplicationShutdown, ApplicationStarted, ScryptHasher as Argon2Hasher, ScryptHasher, AuthManager, Response$1 as AuthResponse, AuthServiceProvider, AuthenticatableModel, AuthenticationException, AuthorizationException, AuthorizationServiceProvider, AutoDiscovery, BUILT_IN_SESSION_DRIVERS, BaseFactory, BaseFactory as Factory, BaseSeeder, BaseSeeder as Seeder, BaseUserProvider, BroadcastManager, BroadcastServiceProvider, BufferedOutput, CONTAINER_CONTEXT_KEY, CSP_NONCE_KEY, CSRF_FORM_FIELD, CSRF_HEADER_NAME, CSRF_TOKEN_KEY, CacheCheck, CacheManager, CacheServiceProvider, Channel, Command, ConsoleChannel, ConsoleKernel, Container, Controller, CookieSessionStore, CursorPaginator, CustomCheck, DEFAULT_AGENT_APPROVAL_TTL_MS, DEFAULT_AGENT_AUDIT_PATH, DEFAULT_APPROVAL_CONFIGURE_HINT, DEFAULT_SCOPE_SUBJECT, DEFAULT_SESSION_STORE_NAME, DailyFileChannel, DatabaseChannel, DatabaseCheck, DefaultHasher, DefaultHasher as Hash, Encrypter, EncryptionServiceProvider, Env, EnvSchema, EnvValidationError, EnvVar, ErrorServiceProvider, Event, EventManager, EventServiceProvider, ExceptionHandler, FailedJobReporter, FieldValidator, FileStore as FileCacheStore, FileChannel, FormRequest, Gate, HealthCheck, HealthManager, HealthServiceProvider, HttpException, I18nManager, I18nServiceProvider, InertiaServiceProvider, Input, Job, JobFailed, JobProcessed, JsonLoader, JsonResource, LOCALE_CONTEXT_KEY, LOG_LEVEL_PRIORITY, Listener, LocalDriver as LocalStorageDriver, LogManager, LogServiceProvider, LogTransport, Logger, Mail, MailChannel, MailManager, MailServiceProvider, MemoryApiTokenStore, MemoryDriver as MemoryBroadcastDriver, MemoryStore as MemoryCacheStore, MemoryChannel, MemoryCheck, MemoryDriver$1 as MemoryDriver, MemoryDriver$1 as MemoryQueueDriver, MemoryEmailVerificationStore, MemoryLoader, MemoryOAuthStateStore, MemoryPasswordResetStore, MemoryRateLimitStore, MemorySchedulerLock, MemorySessionStore, MemoryDriver$2 as MemoryStorageDriver, MemoryTransport, MessageSigner, MethodNotAllowedException, ModelUserProvider, NodeHasher, NotFoundHttpException, Notification, NotificationManager, NotificationServiceProvider, OAUTH_SESSION_BINDING_KEY, OAuthManager, OAuthServiceProvider, Output, PER_PROCESS_SESSION_DRIVERS, PORTABLE_AGENT_TOOL_NAME_PATTERN, PREFLIGHT_ARGUMENT, PREFLIGHT_TOOL_NAME, Paginator, PendingSchedule, Policy, PresenceChannel, PrivateChannel, ProviderManager, QueueManager, QueueServiceProvider, RESERVED_AGENT_TOOL_NAMES, RedisDriver as RedisBroadcastDriver, RedisStore as RedisCacheStore, RedisCheck, RedisDriver$1 as RedisDriver, RedisDriver$1 as RedisQueueDriver, RequestFinished, RequestReceived, ResendTransport, Resource, ResourceCollection, Router, S3Driver, SERVERLESS_RUNTIME_LABELS, Schedule, ScheduledTask, Scheduler, SchedulingServiceProvider, SeederRunner, ServiceProvider, SessionGuard, SessionManager, SlackChannel, SlidingWindowRateLimitStore, SmtpTransport, SqsDriver, StorageCheck, StorageManager, StorageServiceProvider, SyncDriver, SyncDriver as SyncQueueDriver, TaggedCache, TokenGuard, Translator, UserAuthenticated, UserLoggedOut, VALIDATED_DATA_KEY, ValidationException, Validator, ViewEngine, Worker, abort, abortIf, abortUnless, advertisesStructuredOutput, after, afterOrEqual, agentApprovalExpiredAt, agentApprovalFingerprint, agentApprovalPrincipalKey, agentApprovalStatusAt, agentApprovalUsableAt, agentApprovalVisibleTo, alpha, alphaDash, alphaNum, ambientBinding, ambientContainer, approvalStatusNotFoundMessage, array as arrayRule, attachAuthContext, authorize as authorizeAbility, authorizeAllMiddleware, authorizeMiddleware, authorizeResourceMiddleware, before, beforeOrEqual, between, boolean as booleanRule, buildAgentApprovalRequest, buildOAuthAuthorizeUrl, buildOAuthRedirectUrl, buildPasswordResetUrl, buildToolRequest, buildVerificationUrl, can, cannot, canonicalizeAgentApprovalInput, check as checkHash, classifyRegistrationScope, clearJobRegistry, clearNotificationRegistry, clearQueueDriver, collect, completeEmailVerification, completePasswordReset, confirmed, createAgentApprovalContext, createAgentAuditRecorder, createAgentCallBudget, createAgentInvocationPipeline, createApiToken, createApp, createAuditEmitter, createBearerTokenMiddleware, createBroadcastManager, createCacheManager, createConsoleKernel, createContainer, createCorsMiddleware, createCspMiddleware, createCsrfMiddleware, createDiscordOAuthProviderConfig, createEmailVerificationToken, createEncrypter, createEventManager, createExceptionHandler, createFacade, createFacades, createForceHttpsMiddleware, createGate, createGitHubOAuthProviderConfig, createGoogleOAuthProviderConfig, createHealthManager, createHostAuthorizationMiddleware, createI18n, createLogManager, createMailManager, createNotificationManager, createOAuthManager, createOAuthState, createPasswordResetToken, createQueueEventDispatcher, createQueueManager, createRateLimitMiddleware, createRedirectSafetyMiddleware, createRedisClient, createScheduler, createSecurityHeaders, createSeederRunner, createSessionMiddleware, createSqsAdapter, createStorageManager, createTypedBroadcaster, createValidator, csrfField, cursorPaginate, custom, customCheck, dailyFileDateStamp, dailyFilePath, dateFormat, date as dateRule, debugErrorMiddleware, decodeCursor, decrypt, defaultApplication, defaultContainer, defineCacheConfig, defineConfig, defineEnv, defineFactory, defineGate, defineHttpConfig, defineMailConfig, defineMiddleware, defineModule, defineOAuthConfig, definePlugin, definePolicy, defineQueueConfig, defineStorageConfig, deriveAgentTools, deriveAppKey, deriveAppKeyring, describeBuildFailure, detectLocaleMiddleware, detectServerlessRuntime, different, email as emailRule, encodeCursor, encrypt, endsWith, exchangeOAuthCode, exists, expandToolScopes, fetchOAuthUserProfile, file as fileRule, filterSensitiveData, formatValidationErrors, gateApproval, gatePreflight, gateToolCall, generateAppKey, generateKey, generateOtp, generatePassword, generateSlug, getApiToken, getApiTokenOrFail, getAppKeyringFromEnv, getBroadcastManager, getContainer, getCspNonce, getCsrfToken, getEncrypter, getExceptionHandler, getGate, getI18n, getInertiaSharedPropsResolver, getJob, getLogManager, getMailManager, getNextOccurrence, getNextOccurrences, getNotification, getNotificationManager, getPluralizationRule, getQueueDriver, getRateLimitInfo, getRegisteredJobs, getRequestContainer, getRequestLocale, getRequestTranslator, getSessionFromContext, getUserApiTokens, getValidatedData, hash, hashPassword, hmac, image as imageRule, inValues, inertia, integer, ip, ipv4, ipv6, isDue, isDueInTimezone, isEmailVerified, isRawEnvKey, isReservedAgentToolName, isSafeRedirectUrl, jsonResponse, json as jsonRule, mail, mapToolResponse, matchDailyFileDate, matchesCron, max, maxFileSize, md5, mimes, min, minFileSize, mountModuleRoutes, needsRehash, normalizeAppKey, notIn, notifyApprovers, nullable, numeric, object as objectRule, paginate, parseApiToken, parseAppKey, parseAuditRecord, parseCron, parseOAuthRedirectUrl, parsePasswordResetUrl, parsePreviousAppKeys, parseRequestPayload, parseSignature, parseToolScope, parseVerificationUrl, pick, pluralizationRules, processJob, prototype, quickValidate, quickValidateOrThrow, random, randomBase64, randomBase64Url, randomHex, randomInt, randomString, readBearerToken, recordEnvReads, redactAgentArguments, regex, registerJob, registerNotification, renderDebugPage, renderDocument, renderErrorPage, requestIdMiddleware, requestLoggingMiddleware, requireAuthenticated, requireGuest, requireVerifiedEmail, required, requiredIf, requiredUnless, requiredWith, requiredWithout, resetCalledSeeders, resetDefaultApplication, resetRateLimit, resolve, resolveAgentAuditSink, resolveJobName, resolveNotifiableType, resolveOptional, resolveQueueDriver, revokeAllApiTokens, revokeApiToken, same, sample, sanitizeOAuthRedirect, scopedShape, scopesAllowTool, secureCompare, selectPluralForm, setBroadcastManager, setContainer, setEncrypter, setExceptionHandler, setGate, setI18n, setInertiaDocument, setInertiaSharedProps, setInertiaSsrRenderer, setLogManager, setMailManager, setNotificationManager, setQueueDriver, sha256, sha512, shareInertiaProps, shuffle, signUrl, size, startsWith, string as stringRule, t, tc, toApprovalStatusReport, toAuditRecord, toTimezone, tokenCan, tokenCanAll, tokenCanAny, tryGetI18n, tryGetRequestContainer, unique, url as urlRule, urlSafeToken, useAsDefaultApplication, uuid, uuid$1 as uuidRule, validate, validateRequest, validateRequestWith, validateSafe, verifyApiToken, verifyCsrfToken, verifyEmailToken, verifyHmac, verifyOAuthState, verifyPassword, verifyPasswordResetToken, verifySignedUrl, viteAsset, withAuthorization };
|