@guren/server 2.23.2 → 2.24.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-Cn1E6JnO.js} +3 -217
- package/dist/{Job-BVvaY-7p.js → Job-BVRCYuVY.js} +4 -10
- package/dist/McpServiceProvider-B-LioPSz.js +43 -0
- package/dist/Resource-BJhY4aF8.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-D_W1cJp3.js → auth-vFeem6uM.js} +14 -300
- package/dist/authorization/index.js +2 -1
- package/dist/authorization-BsMTG8P1.js +217 -0
- package/dist/broadcasting/index.js +1 -1
- package/dist/{broadcasting-DVfG2vgN.js → broadcasting-6o_CCfF0.js} +2 -1
- package/dist/config/define.d.ts +50 -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-CMuAAsdf.js} +20 -31
- package/dist/deprecate-rL8jNpKX.js +31 -0
- package/dist/encryption/index.js +1 -1
- package/dist/{encryption-BRjZnshr.js → encryption-_GiNb0Ol.js} +2 -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-swsyfCzt.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-0bOJqFpX.js} +5 -3
- package/dist/index.d.ts +11 -0
- package/dist/index.js +526 -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-DshkpIkj.js} +4 -113
- package/dist/loopback-guard-CG8xB4v0.js +68 -0
- package/dist/mail/index.js +1 -1
- package/dist/{mail-zMjQimaJ.js → mail-CQlxrjYp.js} +4 -2
- package/dist/mcp/McpServiceProvider.d.ts +21 -4
- package/dist/mcp/create-mcp-server.d.ts +6 -0
- package/dist/mcp/index.js +434 -1
- 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-DmyJZGM2.js} +3 -2
- package/dist/providers/ConfigServiceProvider.d.ts +19 -0
- package/dist/queue/index.js +2 -2
- package/dist/{queue-IdJjqbyJ.js → queue-CdwHlFXE.js} +1 -1
- package/dist/resolve-optional-ax6gPWTp.js +9 -0
- package/dist/runtime/index.js +2 -1
- package/dist/support/redirect-target.d.ts +5 -1
- package/dist/validated-input-D84J8wcC.js +25 -0
- package/dist/{vite-manifest-2p0IRIcy.js → vite-manifest-DAqhhZZ9.js} +7 -32
- package/package.json +6 -2
- package/dist/McpServiceProvider-BvJRcDOm.js +0 -458
package/dist/index.js
CHANGED
|
@@ -1,104 +1,56 @@
|
|
|
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-BJhY4aF8.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-BsMTG8P1.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 {
|
|
15
|
-
import { n as
|
|
15
|
+
import { n as warnDeprecatedGetter, r as warnDeprecatedSetter } from "./deprecate-rL8jNpKX.js";
|
|
16
|
+
import { a as defaultApplication, c as resolve, d as createContainer, f as getContainer, i as bindAmbient, l as useAsDefaultApplication, n as ambientBinding, o as defaultContainer, p as setContainer, r as ambientContainer, s as resetDefaultApplication, t as adoptDefaultApplication, u as Container } from "./default-application-CMuAAsdf.js";
|
|
17
|
+
import { n as ServiceProvider, t as ProviderManager } from "./ServiceProvider-DDW3MqQJ.js";
|
|
16
18
|
import { o as AuthenticationException, r as getAuthContext, t as AUTH_CONTEXT_KEY } from "./context-af2n5abO.js";
|
|
17
19
|
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";
|
|
20
|
+
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
21
|
import { a as runInRequestScope, i as keepAlive, n as filterSensitiveData, t as Logger } from "./Logger-DWXdtLSJ.js";
|
|
19
22
|
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
23
|
import { n as createRedisClient, r as RedisSessionStore } from "./client-C5Wj9P9o.js";
|
|
21
|
-
import { r as isMcpEndpointEnabled } from "./endpoint-
|
|
24
|
+
import { r as isMcpEndpointEnabled } from "./endpoint-Coq0K_6I.js";
|
|
22
25
|
import { n as isHotReloadRuntime, r as matchingOpenParen, t as claimHotDisposable } from "./hot-disposables-W2fH-GID.js";
|
|
23
|
-
import {
|
|
24
|
-
import { r as
|
|
25
|
-
import {
|
|
26
|
+
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-0bOJqFpX.js";
|
|
27
|
+
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-Cn1E6JnO.js";
|
|
28
|
+
import { r as isDocsViewerEnabled } from "./endpoint-CTIzcagh.js";
|
|
29
|
+
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-DAqhhZZ9.js";
|
|
26
30
|
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
|
|
31
|
+
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-swsyfCzt.js";
|
|
32
|
+
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-DmyJZGM2.js";
|
|
33
|
+
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-BVRCYuVY.js";
|
|
34
|
+
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-CdwHlFXE.js";
|
|
35
|
+
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-CQlxrjYp.js";
|
|
36
|
+
import { a as LOG_LEVEL_PRIORITY, i as matchDailyFileDate, n as dailyFileDateStamp, r as dailyFilePath, t as DailyFileChannel } from "./DailyFileChannel-CTTPA0EF.js";
|
|
37
|
+
import { a as FileChannel, i as setLogManager, n as createLogManager, o as ConsoleChannel, r as getLogManager, t as LogManager } from "./logging-DshkpIkj.js";
|
|
38
|
+
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-6o_CCfF0.js";
|
|
33
39
|
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-
|
|
40
|
+
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-_GiNb0Ol.js";
|
|
35
41
|
import { a as LocalDriver, i as S3Driver, n as createStorageManager, r as MemoryDriver$2, t as StorageManager } from "./storage-6HLaUf9j.js";
|
|
36
42
|
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
43
|
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
44
|
import { Hono } from "hono";
|
|
39
45
|
import { deleteCookie, getCookie } from "hono/cookie";
|
|
40
46
|
import { createCipheriv, createDecipheriv, randomBytes } from "node:crypto";
|
|
41
|
-
import {
|
|
42
|
-
import { pathToFileURL } from "node:url";
|
|
47
|
+
import { join, resolve as resolve$1 } from "node:path";
|
|
43
48
|
import { cors } from "hono/cors";
|
|
44
49
|
import { createMiddleware } from "hono/factory";
|
|
45
|
-
import { parseAccept } from "hono/utils/accept";
|
|
46
50
|
import { serialize } from "hono/utils/cookie";
|
|
47
51
|
import { existsSync } from "node:fs";
|
|
48
52
|
import * as readline from "readline";
|
|
49
53
|
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
54
|
//#region src/mvc/mount-route.ts
|
|
103
55
|
/**
|
|
104
56
|
* Mounts a route with a dynamic HTTP method string. Hono's `app.on()` overloads
|
|
@@ -108,393 +60,6 @@ function mountRoute(app, method, path, ...handlers) {
|
|
|
108
60
|
app.on(method, path, ...handlers);
|
|
109
61
|
}
|
|
110
62
|
//#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
63
|
//#region src/mvc/prototype.ts
|
|
499
64
|
const PROTOTYPE_HANDLER = Symbol.for("guren.prototype.handler");
|
|
500
65
|
const prototype = Object.freeze({ [PROTOTYPE_HANDLER]: true });
|
|
@@ -868,6 +433,7 @@ var Router = class {
|
|
|
868
433
|
action: String(handler[1])
|
|
869
434
|
} : void 0,
|
|
870
435
|
bindings: serializeBindings(path, bindings, this.modelBindings),
|
|
436
|
+
...schemas?.body ? { validatesBody: true } : {},
|
|
871
437
|
...openapi
|
|
872
438
|
}));
|
|
873
439
|
}
|
|
@@ -1122,12 +688,13 @@ function validationErrorResponse(error, status) {
|
|
|
1122
688
|
function throwOnInvalid(schema, data) {
|
|
1123
689
|
const result = schema.safeParse(data);
|
|
1124
690
|
if (!result.success) throw ValidationException.withMessages(formatValidationErrors(result.error));
|
|
691
|
+
return result.data;
|
|
1125
692
|
}
|
|
1126
693
|
/**
|
|
1127
694
|
* The preflight seam: what a request must pass before the handler, reported
|
|
1128
695
|
* 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
|
|
696
|
+
* `.agent()` routes honour the header. An inline handler's contract is checked
|
|
697
|
+
* here (safe: this branch never calls `next()`), and `unverified` names the checks only
|
|
1131
698
|
* the action itself would make, such as `await this.authorize(...)`.
|
|
1132
699
|
*/
|
|
1133
700
|
function createAgentPreflightMiddleware(route, capabilities) {
|
|
@@ -1136,19 +703,16 @@ function createAgentPreflightMiddleware(route, capabilities) {
|
|
|
1136
703
|
const unverified = capabilities().authorization === void 0 ? ["authorization"] : [];
|
|
1137
704
|
return async (c, next) => {
|
|
1138
705
|
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
|
-
}
|
|
706
|
+
if (!getValidatedInput(c)) {
|
|
707
|
+
if (schemas?.params) throwOnInvalid(schemas.params, c.req.param());
|
|
708
|
+
if (schemas?.query) throwOnInvalid(schemas.query, flattenRequestQueries(c));
|
|
709
|
+
if (schemas?.body) throwOnInvalid(schemas.body, await parseRequestBody(c));
|
|
710
|
+
}
|
|
711
|
+
const validated = [
|
|
712
|
+
"params",
|
|
713
|
+
"query",
|
|
714
|
+
"body"
|
|
715
|
+
].filter((segment) => schemas?.[segment]);
|
|
1152
716
|
c.header(AGENT_PREFLIGHT_VERDICT_HEADER, "1");
|
|
1153
717
|
return c.json({
|
|
1154
718
|
preflight: true,
|
|
@@ -1163,10 +727,22 @@ function createAgentPreflightMiddleware(route, capabilities) {
|
|
|
1163
727
|
function createContractValidationMiddleware(route) {
|
|
1164
728
|
if (!isControllerAction(route.handler)) return null;
|
|
1165
729
|
const schemas = route.schemas;
|
|
1166
|
-
if (!schemas || !schemas.params && !schemas.query && !schemas.output) return null;
|
|
730
|
+
if (!schemas || !schemas.params && !schemas.query && !schemas.body && !schemas.output) return null;
|
|
731
|
+
const validatesInput = Boolean(schemas.params || schemas.query || schemas.body);
|
|
1167
732
|
return async (c, next) => {
|
|
1168
|
-
if (
|
|
1169
|
-
|
|
733
|
+
if (validatesInput) {
|
|
734
|
+
const record = { route: route.name };
|
|
735
|
+
if (schemas.params) record.params = throwOnInvalid(schemas.params, c.req.param());
|
|
736
|
+
if (schemas.query) record.query = throwOnInvalid(schemas.query, flattenRequestQueries(c));
|
|
737
|
+
if (schemas.body) {
|
|
738
|
+
const payload = await parseRequestBody(c);
|
|
739
|
+
const result = schemas.body.safeParse(payload);
|
|
740
|
+
if (!result.success) throw ValidationException.fromZodError(result.error);
|
|
741
|
+
record.body = result.data;
|
|
742
|
+
record.rawBody = { value: payload };
|
|
743
|
+
}
|
|
744
|
+
setValidatedInput(c, record);
|
|
745
|
+
}
|
|
1170
746
|
await next();
|
|
1171
747
|
const isSuccess = c.res !== void 0 && c.res.status >= 200 && c.res.status < 300;
|
|
1172
748
|
if (schemas.output && isSuccess && c.res.headers.get("X-Guren-Agent-Preflight-Verdict") === null) {
|
|
@@ -1313,62 +889,6 @@ function joinPaths(prefixStack, path) {
|
|
|
1313
889
|
return "/" + segments.join("/").replace(/\/+/gu, "/");
|
|
1314
890
|
}
|
|
1315
891
|
//#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
892
|
//#region src/http/middleware/cookie-session-store.ts
|
|
1373
893
|
const IV_BYTES = 12;
|
|
1374
894
|
const TAG_BYTES = 16;
|
|
@@ -2344,94 +1864,6 @@ function requestLoggingMiddleware() {
|
|
|
2344
1864
|
});
|
|
2345
1865
|
}
|
|
2346
1866
|
//#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
1867
|
//#region src/http/middleware/index.ts
|
|
2436
1868
|
function defineMiddleware(handler) {
|
|
2437
1869
|
return handler;
|
|
@@ -2825,7 +2257,7 @@ var MethodNotAllowedException = class MethodNotAllowedException extends HttpExce
|
|
|
2825
2257
|
*/
|
|
2826
2258
|
var AuthorizationServiceProvider = class extends ServiceProvider {
|
|
2827
2259
|
register() {
|
|
2828
|
-
this.container.
|
|
2260
|
+
this.container.singletonIf("gate", () => createGate());
|
|
2829
2261
|
}
|
|
2830
2262
|
};
|
|
2831
2263
|
//#endregion
|
|
@@ -2833,7 +2265,7 @@ var AuthorizationServiceProvider = class extends ServiceProvider {
|
|
|
2833
2265
|
/** Binds the ExceptionHandler singleton and attaches it as global error middleware. */
|
|
2834
2266
|
var ErrorServiceProvider = class extends ServiceProvider {
|
|
2835
2267
|
register() {
|
|
2836
|
-
this.container.
|
|
2268
|
+
this.container.singletonIf("exception.handler", () => createExceptionHandler());
|
|
2837
2269
|
}
|
|
2838
2270
|
boot() {
|
|
2839
2271
|
const hono = this.container.make("hono");
|
|
@@ -2842,8 +2274,42 @@ var ErrorServiceProvider = class extends ServiceProvider {
|
|
|
2842
2274
|
}
|
|
2843
2275
|
};
|
|
2844
2276
|
//#endregion
|
|
2277
|
+
//#region src/i18n/injected-translations.ts
|
|
2278
|
+
const INJECTED_TRANSLATIONS_HINT = "It must hold the lang/ catalogs as JSON ({ locale: { namespace: messages } }); deploy plugins inject it at build time.";
|
|
2279
|
+
/**
|
|
2280
|
+
* The `lang/` catalogs a deploy build injected for runtimes that ship no `lang/`
|
|
2281
|
+
* directory (Workers, Lambda, Vercel). Fails loudly on a value that is set but
|
|
2282
|
+
* not a catalog: falling through to the filesystem would warn about a missing
|
|
2283
|
+
* `lang/` rather than about the variable that is actually broken.
|
|
2284
|
+
*/
|
|
2285
|
+
function injectedTranslations() {
|
|
2286
|
+
const raw = process.env.GUREN_TRANSLATIONS;
|
|
2287
|
+
if (typeof raw !== "string" || raw.length === 0) return;
|
|
2288
|
+
let parsed;
|
|
2289
|
+
try {
|
|
2290
|
+
parsed = JSON.parse(raw);
|
|
2291
|
+
} catch (error) {
|
|
2292
|
+
throw new Error(`GUREN_TRANSLATIONS is set but is not valid JSON. ${INJECTED_TRANSLATIONS_HINT}`, { cause: error });
|
|
2293
|
+
}
|
|
2294
|
+
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}`);
|
|
2295
|
+
return parsed;
|
|
2296
|
+
}
|
|
2297
|
+
//#endregion
|
|
2845
2298
|
//#region src/providers/I18nServiceProvider.ts
|
|
2846
2299
|
/**
|
|
2300
|
+
* The catalogs a deploy build injected, for an app reading the default `lang/`.
|
|
2301
|
+
* The build bundles only that directory, so an explicit `loader` or `path` opts out.
|
|
2302
|
+
*/
|
|
2303
|
+
function injectedCatalogFor(options) {
|
|
2304
|
+
return options.loader || options.path !== void 0 ? void 0 : injectedTranslations();
|
|
2305
|
+
}
|
|
2306
|
+
function missingCatalogHint(options, locale) {
|
|
2307
|
+
if (options.loader) return ".";
|
|
2308
|
+
if (options.path !== void 0) return ` — expected ${options.path}/${locale}/*.json.`;
|
|
2309
|
+
if (injectedTranslations()) return ` — the deploy build found no lang/${locale}/*.json to bundle.`;
|
|
2310
|
+
return ` — expected lang/${locale}/*.json. A deployed app without lang/ on disk needs a Guren deploy build or i18n.loader.`;
|
|
2311
|
+
}
|
|
2312
|
+
/**
|
|
2847
2313
|
* Binds the I18nManager as a singleton. With `createApp({ i18n })` it also
|
|
2848
2314
|
* mounts locale detection (unless `i18n.detect` is `false`), preloads every
|
|
2849
2315
|
* supported locale at boot, and shares the request locale and its messages with
|
|
@@ -2857,14 +2323,16 @@ var I18nServiceProvider = class extends ServiceProvider {
|
|
|
2857
2323
|
if (options.supported.length === 0) throw new Error("createApp({ i18n }) requires at least one supported locale.");
|
|
2858
2324
|
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
2325
|
}
|
|
2860
|
-
this.container.
|
|
2326
|
+
this.container.singletonIf("i18n", () => {
|
|
2861
2327
|
if (!options) return createI18n({ locale: "en" });
|
|
2328
|
+
const injected = injectedCatalogFor(options);
|
|
2329
|
+
const loader = options.loader ?? (injected ? new MemoryLoader(injected) : void 0);
|
|
2862
2330
|
const fallback = options.fallback ?? options.supported[0];
|
|
2863
2331
|
return createI18n({
|
|
2864
2332
|
locale: fallback,
|
|
2865
2333
|
fallbackLocale: fallback,
|
|
2866
|
-
path:
|
|
2867
|
-
loader
|
|
2334
|
+
path: loader ? void 0 : options.path ?? "lang",
|
|
2335
|
+
loader
|
|
2868
2336
|
});
|
|
2869
2337
|
});
|
|
2870
2338
|
if (app && options && options.detect !== false) {
|
|
@@ -2882,7 +2350,7 @@ var I18nServiceProvider = class extends ServiceProvider {
|
|
|
2882
2350
|
if (!options) return;
|
|
2883
2351
|
const manager = this.container.make("i18n");
|
|
2884
2352
|
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}'
|
|
2353
|
+
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
2354
|
if (options.share !== false) {
|
|
2887
2355
|
const fallback = manager.getFallbackLocale() ?? manager.getLocale();
|
|
2888
2356
|
const supported = new Set(options.supported);
|
|
@@ -3090,6 +2558,90 @@ function identifierOf(user) {
|
|
|
3090
2558
|
return typeof record?.getAuthIdentifier === "function" ? record.getAuthIdentifier() : record?.id;
|
|
3091
2559
|
}
|
|
3092
2560
|
//#endregion
|
|
2561
|
+
//#region src/config/env-reads.ts
|
|
2562
|
+
function recordEnvReads(values) {
|
|
2563
|
+
const read = /* @__PURE__ */ new Set();
|
|
2564
|
+
return {
|
|
2565
|
+
env: new Proxy(values, { get(target, property, receiver) {
|
|
2566
|
+
if (typeof property === "string") read.add(property);
|
|
2567
|
+
return Reflect.get(target, property, receiver);
|
|
2568
|
+
} }),
|
|
2569
|
+
read
|
|
2570
|
+
};
|
|
2571
|
+
}
|
|
2572
|
+
//#endregion
|
|
2573
|
+
//#region src/providers/ConfigServiceProvider.ts
|
|
2574
|
+
/**
|
|
2575
|
+
* Validates `createApp({ env })` and binds it as `env`, then resolves and binds
|
|
2576
|
+
* each `createApp({ config })` definition (RFC 0027 §1-§3). Registered before
|
|
2577
|
+
* every other provider: a bad environment fails the boot before anything
|
|
2578
|
+
* registers, every later register() sees the configured managers, and a later
|
|
2579
|
+
* provider that rebinds one fails the boot through {@link ownedBindings}.
|
|
2580
|
+
*/
|
|
2581
|
+
var ConfigServiceProvider = class extends ServiceProvider {
|
|
2582
|
+
env = {};
|
|
2583
|
+
unset = /* @__PURE__ */ new Set();
|
|
2584
|
+
resolved = [];
|
|
2585
|
+
owned = /* @__PURE__ */ new Map();
|
|
2586
|
+
register() {
|
|
2587
|
+
const app = this.container.make("app");
|
|
2588
|
+
this.env = this.parseEnv(app);
|
|
2589
|
+
this.resolved = [];
|
|
2590
|
+
this.owned = /* @__PURE__ */ new Map();
|
|
2591
|
+
const definitions = app.configDefinitions;
|
|
2592
|
+
assertDistinctKeys(definitions);
|
|
2593
|
+
for (const definition of definitions) {
|
|
2594
|
+
const { env, read } = recordEnvReads(this.env);
|
|
2595
|
+
const config = definition.resolve(env);
|
|
2596
|
+
const placeholders = [...read].filter((key) => this.unset.has(key));
|
|
2597
|
+
if (placeholders.length > 0) {
|
|
2598
|
+
warnOnce(`config-unverified:${definition.key}`, `[guren] the "${definition.key}" config reads ${placeholders.join(", ")}, which the environment does not set; it was left unbound.`);
|
|
2599
|
+
continue;
|
|
2600
|
+
}
|
|
2601
|
+
const before = new Map(this.container.getBindings().map((key) => [key, this.container.bindingOf(key)]));
|
|
2602
|
+
definition.bind(this.container, config);
|
|
2603
|
+
for (const key of this.container.getBindings()) {
|
|
2604
|
+
const binding = this.container.bindingOf(key);
|
|
2605
|
+
if (binding !== before.get(key)) this.owned.set(key, {
|
|
2606
|
+
binding,
|
|
2607
|
+
source: `config/${definition.key}.ts`
|
|
2608
|
+
});
|
|
2609
|
+
}
|
|
2610
|
+
this.resolved.push({
|
|
2611
|
+
definition,
|
|
2612
|
+
config
|
|
2613
|
+
});
|
|
2614
|
+
}
|
|
2615
|
+
}
|
|
2616
|
+
async boot() {
|
|
2617
|
+
for (const { definition, config } of this.resolved) await definition.boot?.(this.container, config, this.env);
|
|
2618
|
+
}
|
|
2619
|
+
/** @internal The bindings the definitions made, for ProviderManager's twice-configured check. */
|
|
2620
|
+
ownedBindings() {
|
|
2621
|
+
return this.owned;
|
|
2622
|
+
}
|
|
2623
|
+
parseEnv(app) {
|
|
2624
|
+
const schema = app.envSchema;
|
|
2625
|
+
this.unset = /* @__PURE__ */ new Set();
|
|
2626
|
+
if (!schema) return {};
|
|
2627
|
+
const source = this.container.makeOptional("env.source");
|
|
2628
|
+
const introspecting = typeof process !== "undefined" && process.env.GUREN_INTROSPECT === "1";
|
|
2629
|
+
const parsed = schema.parse(source, { mode: introspecting ? "report" : "throw" });
|
|
2630
|
+
for (const problem of parsed.problems) warnOnce(`env-invalid:${problem.key}`, `[guren] Invalid environment: ${problem.key} ${problem.message} (reported under GUREN_INTROSPECT=1).`);
|
|
2631
|
+
this.unset = parsed.unset;
|
|
2632
|
+
this.container.instance("env", parsed.values);
|
|
2633
|
+
return parsed.values;
|
|
2634
|
+
}
|
|
2635
|
+
};
|
|
2636
|
+
function assertDistinctKeys(definitions) {
|
|
2637
|
+
const seen = /* @__PURE__ */ new Map();
|
|
2638
|
+
definitions.forEach((definition, index) => {
|
|
2639
|
+
const first = seen.get(definition.key);
|
|
2640
|
+
if (first !== void 0) throw new Error(`[guren] createApp({ config }) has two "${definition.key}" definitions, at config[${first}] and config[${index}]. Keep one.`);
|
|
2641
|
+
seen.set(definition.key, index);
|
|
2642
|
+
});
|
|
2643
|
+
}
|
|
2644
|
+
//#endregion
|
|
3093
2645
|
//#region src/http/Application.ts
|
|
3094
2646
|
const MANAGED_VITE_ENV_FLAG = "GUREN_MANAGED_VITE_DEV_SERVER";
|
|
3095
2647
|
const DEFAULT_DEV_ENTRY_PATH = "/resources/js/dev-entry.ts";
|
|
@@ -3336,6 +2888,8 @@ var Application = class {
|
|
|
3336
2888
|
this.container.instance("router", this.router);
|
|
3337
2889
|
if (options.inertia?.document) this.container.instance("inertia.document", options.inertia.document);
|
|
3338
2890
|
if (options.inertia?.ssrRenderer) this.container.instance("inertia.ssrRenderer", options.inertia.ssrRenderer);
|
|
2891
|
+
if (options.inertia?.share) shareInertiaProps(options.inertia.share, this.container);
|
|
2892
|
+
if (options.env || options.config?.length) this.providerManager.register(ConfigServiceProvider);
|
|
3339
2893
|
this.authManager.registerGuard("web", ({ session }) => {
|
|
3340
2894
|
const provider = this.authManager.hasProvider("users") ? this.authManager.getProvider(DEFAULT_PROVIDER) : unconfiguredUserProvider;
|
|
3341
2895
|
return new SessionGuard({
|
|
@@ -3365,6 +2919,12 @@ var Application = class {
|
|
|
3365
2919
|
get i18nOptions() {
|
|
3366
2920
|
return this.options.i18n;
|
|
3367
2921
|
}
|
|
2922
|
+
get envSchema() {
|
|
2923
|
+
return this.options.env;
|
|
2924
|
+
}
|
|
2925
|
+
get configDefinitions() {
|
|
2926
|
+
return this.options.config ?? [];
|
|
2927
|
+
}
|
|
3368
2928
|
markAutoSessionAttached() {
|
|
3369
2929
|
this.autoSessionAttached = true;
|
|
3370
2930
|
}
|
|
@@ -3453,11 +3013,12 @@ var Application = class {
|
|
|
3453
3013
|
await this.bootPromise;
|
|
3454
3014
|
}
|
|
3455
3015
|
async bootOnce() {
|
|
3016
|
+
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
3017
|
await this.providerManager.registerAll();
|
|
3457
3018
|
await this.options.boot?.(this.hono);
|
|
3458
3019
|
await this.mountRoutes();
|
|
3459
|
-
await this.mountDevEndpoint(isMcpEndpointEnabled(), async () => (await import("./McpServiceProvider-
|
|
3460
|
-
await this.mountDevEndpoint(isDocsViewerEnabled(), async () => (await import("./DocsViewerServiceProvider-
|
|
3020
|
+
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?");
|
|
3021
|
+
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
3022
|
await this.providerManager.bootAll();
|
|
3462
3023
|
this.warnOnUnconfiguredAuth();
|
|
3463
3024
|
}
|
|
@@ -3487,11 +3048,36 @@ var Application = class {
|
|
|
3487
3048
|
this.mountHostAuthorization();
|
|
3488
3049
|
}
|
|
3489
3050
|
mountHostAuthorization() {
|
|
3051
|
+
if (this.hasHttpConfig()) {
|
|
3052
|
+
this.mountConfiguredHostAuthorization();
|
|
3053
|
+
return;
|
|
3054
|
+
}
|
|
3490
3055
|
const { hostAuthorization } = this.options;
|
|
3491
3056
|
if (hostAuthorization === false || !hostAuthorization) return;
|
|
3492
3057
|
this.hono.use("*", createHostAuthorizationMiddleware(hostAuthorization));
|
|
3493
3058
|
}
|
|
3494
3059
|
/**
|
|
3060
|
+
* Holds host authorization's place ahead of every app middleware while its
|
|
3061
|
+
* options wait for `defineHttpConfig()` to resolve at boot (RFC 0027 §5), the
|
|
3062
|
+
* placeholder shape AuthServiceProvider uses for sessions. Unbound means not
|
|
3063
|
+
* booted, and an unchecked request is refused rather than passed.
|
|
3064
|
+
*/
|
|
3065
|
+
mountConfiguredHostAuthorization() {
|
|
3066
|
+
const container = this.container;
|
|
3067
|
+
let middleware;
|
|
3068
|
+
this.hono.use("*", (ctx, next) => {
|
|
3069
|
+
if (middleware === void 0) {
|
|
3070
|
+
if (!container.has("http.hostAuthorization")) return Promise.resolve(ctx.text("Service Unavailable: the application has not booted", 503));
|
|
3071
|
+
const options = container.make("http.hostAuthorization");
|
|
3072
|
+
middleware = options ? createHostAuthorizationMiddleware(options) : null;
|
|
3073
|
+
}
|
|
3074
|
+
return middleware ? middleware(ctx, next) : next();
|
|
3075
|
+
});
|
|
3076
|
+
}
|
|
3077
|
+
hasHttpConfig() {
|
|
3078
|
+
return this.configDefinitions.some((definition) => definition.key === "http");
|
|
3079
|
+
}
|
|
3080
|
+
/**
|
|
3495
3081
|
* Mounts an opt-in, dev-only framework endpoint. Only the dynamic import may
|
|
3496
3082
|
* fail silently — these providers reach optional dependencies an app need not
|
|
3497
3083
|
* have installed. A failure inside the provider's own boot is rethrown.
|
|
@@ -3686,368 +3272,6 @@ function createApp(options = {}) {
|
|
|
3686
3272
|
return new Application(options);
|
|
3687
3273
|
}
|
|
3688
3274
|
//#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
3275
|
//#region src/http/vite-assets.ts
|
|
4052
3276
|
let defaultCandidates;
|
|
4053
3277
|
const manifestCache = /* @__PURE__ */ new Map();
|
|
@@ -4623,7 +3847,8 @@ const AGENT_SURFACES = {
|
|
|
4623
3847
|
"dev-mcp": true,
|
|
4624
3848
|
"cli": true,
|
|
4625
3849
|
"webmcp": true,
|
|
4626
|
-
"durable": true
|
|
3850
|
+
"durable": true,
|
|
3851
|
+
"in-process": true
|
|
4627
3852
|
};
|
|
4628
3853
|
/** Every denial reason, as a value, total over the union for the same reason. */
|
|
4629
3854
|
const DENIAL_REASONS = {
|
|
@@ -4768,6 +3993,22 @@ function warnSinkFailure(error) {
|
|
|
4768
3993
|
console.warn(`[guren] agent audit sink failed, record dropped: ${String(error)}`);
|
|
4769
3994
|
}
|
|
4770
3995
|
//#endregion
|
|
3996
|
+
//#region src/agent/audit-sink.ts
|
|
3997
|
+
/**
|
|
3998
|
+
* The `audit` option every agent surface plugin takes (`mcpPlugin`, `aiPlugin`),
|
|
3999
|
+
* and the one rule turning it into a sink. Absent from `@guren/server/agent`:
|
|
4000
|
+
* the file branch writes to disk, which a browser dispatcher has no use for.
|
|
4001
|
+
*/
|
|
4002
|
+
/**
|
|
4003
|
+
* `{ file }` is built behind a dynamic `import()` so an application that
|
|
4004
|
+
* configured its own `sink` never evaluates the filesystem module.
|
|
4005
|
+
*/
|
|
4006
|
+
async function resolveAgentAuditSink(config) {
|
|
4007
|
+
if ("sink" in config) return config.sink;
|
|
4008
|
+
const { createFileAuditSink } = await import("./audit-file-DocumbCr.js");
|
|
4009
|
+
return createFileAuditSink(config.file ?? "storage/logs/agent-audit.log", config.days);
|
|
4010
|
+
}
|
|
4011
|
+
//#endregion
|
|
4771
4012
|
//#region src/agent/approval.ts
|
|
4772
4013
|
/**
|
|
4773
4014
|
* How long a pending request stays answerable by default: one hour. An approval
|
|
@@ -5276,6 +4517,27 @@ function elapsed(startedAt) {
|
|
|
5276
4517
|
return Math.round(performance.now() - startedAt);
|
|
5277
4518
|
}
|
|
5278
4519
|
//#endregion
|
|
4520
|
+
//#region src/agent/call-budget.ts
|
|
4521
|
+
/**
|
|
4522
|
+
* One meter per returned function: share the function to share the budget.
|
|
4523
|
+
* Throws on a limit that is not a whole number of at least 1.
|
|
4524
|
+
*/
|
|
4525
|
+
function createAgentCallBudget(options) {
|
|
4526
|
+
const { callsPerMinute: limit, message } = options;
|
|
4527
|
+
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)}.`);
|
|
4528
|
+
const now = options.now ?? Date.now;
|
|
4529
|
+
const hits = [];
|
|
4530
|
+
return () => {
|
|
4531
|
+
const at = now();
|
|
4532
|
+
while (hits.length > 0 && hits[0] <= at - 6e4) hits.shift();
|
|
4533
|
+
if (hits.length >= limit) return {
|
|
4534
|
+
reason: "rate-limit",
|
|
4535
|
+
message: message(limit)
|
|
4536
|
+
};
|
|
4537
|
+
hits.push(at);
|
|
4538
|
+
};
|
|
4539
|
+
}
|
|
4540
|
+
//#endregion
|
|
5279
4541
|
//#region src/agent/approval-status.ts
|
|
5280
4542
|
/**
|
|
5281
4543
|
* Reading one approval record as an answer for the caller that asked
|
|
@@ -5324,7 +4586,7 @@ function toApprovalStatusReport(requestId, record, principal, now) {
|
|
|
5324
4586
|
/** Binds OAuthManager as a singleton in the container. */
|
|
5325
4587
|
var OAuthServiceProvider = class extends ServiceProvider {
|
|
5326
4588
|
register() {
|
|
5327
|
-
this.container.
|
|
4589
|
+
this.container.singletonIf("oauth", () => createOAuthManager());
|
|
5328
4590
|
}
|
|
5329
4591
|
};
|
|
5330
4592
|
//#endregion
|
|
@@ -5332,7 +4594,7 @@ var OAuthServiceProvider = class extends ServiceProvider {
|
|
|
5332
4594
|
/** Binds the EventManager as a singleton in the container. */
|
|
5333
4595
|
var EventServiceProvider = class extends ServiceProvider {
|
|
5334
4596
|
register() {
|
|
5335
|
-
this.container.
|
|
4597
|
+
this.container.singletonIf("events", () => createEventManager());
|
|
5336
4598
|
}
|
|
5337
4599
|
boot() {
|
|
5338
4600
|
this.container.make("events").setQueueDispatcher(createQueueEventDispatcher());
|
|
@@ -5343,7 +4605,7 @@ var EventServiceProvider = class extends ServiceProvider {
|
|
|
5343
4605
|
/** Binds the CacheManager as a singleton in the container. */
|
|
5344
4606
|
var CacheServiceProvider = class extends ServiceProvider {
|
|
5345
4607
|
register() {
|
|
5346
|
-
this.container.
|
|
4608
|
+
this.container.singletonIf("cache", () => createCacheManager());
|
|
5347
4609
|
}
|
|
5348
4610
|
};
|
|
5349
4611
|
//#endregion
|
|
@@ -5351,7 +4613,7 @@ var CacheServiceProvider = class extends ServiceProvider {
|
|
|
5351
4613
|
/** Binds the QueueManager as a singleton in the container. */
|
|
5352
4614
|
var QueueServiceProvider = class extends ServiceProvider {
|
|
5353
4615
|
register() {
|
|
5354
|
-
this.container.
|
|
4616
|
+
this.container.singletonIf("queue", () => createQueueManager());
|
|
5355
4617
|
}
|
|
5356
4618
|
};
|
|
5357
4619
|
//#endregion
|
|
@@ -5365,7 +4627,7 @@ var QueueServiceProvider = class extends ServiceProvider {
|
|
|
5365
4627
|
*/
|
|
5366
4628
|
var MailServiceProvider = class extends ServiceProvider {
|
|
5367
4629
|
register() {
|
|
5368
|
-
this.container.
|
|
4630
|
+
this.container.singletonIf("mail", (container) => createMailManager({
|
|
5369
4631
|
default: "log",
|
|
5370
4632
|
transports: { log: { driver: "log" } }
|
|
5371
4633
|
}, container));
|
|
@@ -5381,7 +4643,7 @@ var MailServiceProvider = class extends ServiceProvider {
|
|
|
5381
4643
|
*/
|
|
5382
4644
|
var LogServiceProvider = class extends ServiceProvider {
|
|
5383
4645
|
register() {
|
|
5384
|
-
this.container.
|
|
4646
|
+
this.container.singletonIf("log", () => createLogManager({
|
|
5385
4647
|
default: "console",
|
|
5386
4648
|
channels: { console: { driver: "console" } }
|
|
5387
4649
|
}));
|
|
@@ -5395,7 +4657,7 @@ var LogServiceProvider = class extends ServiceProvider {
|
|
|
5395
4657
|
*/
|
|
5396
4658
|
var NotificationServiceProvider = class extends ServiceProvider {
|
|
5397
4659
|
register() {
|
|
5398
|
-
this.container.
|
|
4660
|
+
this.container.singletonIf("notifications", () => createNotificationManager());
|
|
5399
4661
|
}
|
|
5400
4662
|
boot() {
|
|
5401
4663
|
this.container.make("notifications").registerQueueJob();
|
|
@@ -5409,7 +4671,7 @@ var NotificationServiceProvider = class extends ServiceProvider {
|
|
|
5409
4671
|
*/
|
|
5410
4672
|
var BroadcastServiceProvider = class extends ServiceProvider {
|
|
5411
4673
|
register() {
|
|
5412
|
-
this.container.
|
|
4674
|
+
this.container.singletonIf("broadcast", () => createBroadcastManager());
|
|
5413
4675
|
}
|
|
5414
4676
|
};
|
|
5415
4677
|
//#endregion
|
|
@@ -5424,7 +4686,7 @@ var BroadcastServiceProvider = class extends ServiceProvider {
|
|
|
5424
4686
|
var EncryptionServiceProvider = class extends ServiceProvider {
|
|
5425
4687
|
register() {
|
|
5426
4688
|
if (!this.container.has("app.keyring")) this.container.instance("app.keyring", getAppKeyringFromEnv());
|
|
5427
|
-
this.container.
|
|
4689
|
+
this.container.singletonIf("encrypter", () => {
|
|
5428
4690
|
const keyring = deriveAppKeyring(this.container.make("app.keyring"), "data-encryption");
|
|
5429
4691
|
return createEncrypter({
|
|
5430
4692
|
key: encodeDerivedKey(keyring.current),
|
|
@@ -5438,7 +4700,7 @@ var EncryptionServiceProvider = class extends ServiceProvider {
|
|
|
5438
4700
|
/** Binds the StorageManager as a singleton in the container. */
|
|
5439
4701
|
var StorageServiceProvider = class extends ServiceProvider {
|
|
5440
4702
|
register() {
|
|
5441
|
-
this.container.
|
|
4703
|
+
this.container.singletonIf("storage", () => createStorageManager());
|
|
5442
4704
|
}
|
|
5443
4705
|
};
|
|
5444
4706
|
//#endregion
|
|
@@ -5446,7 +4708,7 @@ var StorageServiceProvider = class extends ServiceProvider {
|
|
|
5446
4708
|
/** Binds the HealthManager as a singleton in the container. */
|
|
5447
4709
|
var HealthServiceProvider = class extends ServiceProvider {
|
|
5448
4710
|
register() {
|
|
5449
|
-
this.container.
|
|
4711
|
+
this.container.singletonIf("health", () => createHealthManager());
|
|
5450
4712
|
}
|
|
5451
4713
|
};
|
|
5452
4714
|
//#endregion
|
|
@@ -5454,7 +4716,7 @@ var HealthServiceProvider = class extends ServiceProvider {
|
|
|
5454
4716
|
/** Binds the Scheduler as a singleton in the container. */
|
|
5455
4717
|
var SchedulingServiceProvider = class extends ServiceProvider {
|
|
5456
4718
|
register() {
|
|
5457
|
-
this.container.
|
|
4719
|
+
this.container.singletonIf("scheduler", () => createScheduler());
|
|
5458
4720
|
}
|
|
5459
4721
|
};
|
|
5460
4722
|
//#endregion
|
|
@@ -6370,75 +5632,6 @@ function createSeederRunner(options) {
|
|
|
6370
5632
|
return new SeederRunner(options);
|
|
6371
5633
|
}
|
|
6372
5634
|
//#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
5635
|
//#region src/http/resources/ResourceCollection.ts
|
|
6443
5636
|
/** Collection of resources with additional metadata. */
|
|
6444
5637
|
var ResourceCollection = class ResourceCollection {
|
|
@@ -8038,7 +7231,265 @@ function renderEnvironmentSection() {
|
|
|
8038
7231
|
</section>`;
|
|
8039
7232
|
}
|
|
8040
7233
|
//#endregion
|
|
7234
|
+
//#region src/config/env.ts
|
|
7235
|
+
/**
|
|
7236
|
+
* The declared environment (RFC 0027 §1): one schema, validated at boot by
|
|
7237
|
+
* ConfigServiceProvider, by the CLI, and by a connection thunk run outside an
|
|
7238
|
+
* application, all through {@link EnvSchema.parse}. A blank value is unset for
|
|
7239
|
+
* every builder, which is what `guren/no-nullish-env-default` exists to catch
|
|
7240
|
+
* in hand-written reads.
|
|
7241
|
+
*/
|
|
7242
|
+
/** One declared variable. Immutable: every modifier returns a new instance. */
|
|
7243
|
+
var EnvVar = class EnvVar {
|
|
7244
|
+
state;
|
|
7245
|
+
constructor(state) {
|
|
7246
|
+
this.state = state;
|
|
7247
|
+
}
|
|
7248
|
+
/** Unset resolves to `undefined`. */
|
|
7249
|
+
optional() {
|
|
7250
|
+
return new EnvVar({
|
|
7251
|
+
...this.state,
|
|
7252
|
+
presence: "optional"
|
|
7253
|
+
});
|
|
7254
|
+
}
|
|
7255
|
+
/** Unset, blank included, resolves to `value`. */
|
|
7256
|
+
default(value) {
|
|
7257
|
+
return new EnvVar({
|
|
7258
|
+
...this.state,
|
|
7259
|
+
presence: "defaulted",
|
|
7260
|
+
fallback: value
|
|
7261
|
+
});
|
|
7262
|
+
}
|
|
7263
|
+
/** Required only when `NODE_ENV` is `production`; `undefined` when unset elsewhere. */
|
|
7264
|
+
requiredInProduction() {
|
|
7265
|
+
return new EnvVar({
|
|
7266
|
+
...this.state,
|
|
7267
|
+
presence: "production"
|
|
7268
|
+
});
|
|
7269
|
+
}
|
|
7270
|
+
/** Treat `FOO=` as the value `''` rather than as unset. */
|
|
7271
|
+
allowEmpty() {
|
|
7272
|
+
return new EnvVar({
|
|
7273
|
+
...this.state,
|
|
7274
|
+
emptyAllowed: true
|
|
7275
|
+
});
|
|
7276
|
+
}
|
|
7277
|
+
/** Never echo the value, in a problem message or anywhere a schema is printed. */
|
|
7278
|
+
secret() {
|
|
7279
|
+
return new EnvVar({
|
|
7280
|
+
...this.state,
|
|
7281
|
+
isSecret: true
|
|
7282
|
+
});
|
|
7283
|
+
}
|
|
7284
|
+
describe(text) {
|
|
7285
|
+
return new EnvVar({
|
|
7286
|
+
...this.state,
|
|
7287
|
+
description: text
|
|
7288
|
+
});
|
|
7289
|
+
}
|
|
7290
|
+
get isSecret() {
|
|
7291
|
+
return this.state.isSecret;
|
|
7292
|
+
}
|
|
7293
|
+
get description() {
|
|
7294
|
+
return this.state.description;
|
|
7295
|
+
}
|
|
7296
|
+
/** The `.default()` value; `undefined` unless `presence` is `defaulted`. */
|
|
7297
|
+
get defaultValue() {
|
|
7298
|
+
return this.state.fallback;
|
|
7299
|
+
}
|
|
7300
|
+
/** The values an `Env.enum()` admits; `undefined` for every other builder. */
|
|
7301
|
+
get choices() {
|
|
7302
|
+
return this.state.choices;
|
|
7303
|
+
}
|
|
7304
|
+
/** @internal */
|
|
7305
|
+
resolve(raw, production) {
|
|
7306
|
+
const { presence } = this.state;
|
|
7307
|
+
if (raw === void 0 || raw === "" && !this.state.emptyAllowed) {
|
|
7308
|
+
if (presence === "defaulted") return { value: this.state.fallback };
|
|
7309
|
+
if (presence === "optional" || presence === "production" && !production) return { value: void 0 };
|
|
7310
|
+
return { unset: true };
|
|
7311
|
+
}
|
|
7312
|
+
return this.state.coerce(raw);
|
|
7313
|
+
}
|
|
7314
|
+
};
|
|
7315
|
+
function envVar(coerce, choices) {
|
|
7316
|
+
return new EnvVar({
|
|
7317
|
+
coerce,
|
|
7318
|
+
choices,
|
|
7319
|
+
presence: "required",
|
|
7320
|
+
emptyAllowed: false,
|
|
7321
|
+
isSecret: false
|
|
7322
|
+
});
|
|
7323
|
+
}
|
|
7324
|
+
const PORT_PATTERN = /^\d+$/u;
|
|
7325
|
+
const Env = {
|
|
7326
|
+
string: () => envVar((raw) => ({ value: raw })),
|
|
7327
|
+
url: () => envVar((raw) => {
|
|
7328
|
+
try {
|
|
7329
|
+
new URL(raw);
|
|
7330
|
+
return { value: raw };
|
|
7331
|
+
} catch {
|
|
7332
|
+
return { problem: "is not a URL" };
|
|
7333
|
+
}
|
|
7334
|
+
}),
|
|
7335
|
+
number: () => envVar((raw) => {
|
|
7336
|
+
const value = Number(raw);
|
|
7337
|
+
return raw.trim() !== "" && Number.isFinite(value) ? { value } : { problem: "is not a number" };
|
|
7338
|
+
}),
|
|
7339
|
+
port: () => envVar((raw) => {
|
|
7340
|
+
const value = Number(raw);
|
|
7341
|
+
return PORT_PATTERN.test(raw) && value >= 1 && value <= 65535 ? { value } : { problem: "is not a port" };
|
|
7342
|
+
}),
|
|
7343
|
+
boolean: () => envVar((raw) => {
|
|
7344
|
+
const normalized = raw.toLowerCase();
|
|
7345
|
+
if (normalized === "true" || normalized === "1") return { value: true };
|
|
7346
|
+
if (normalized === "false" || normalized === "0") return { value: false };
|
|
7347
|
+
return { problem: "is not a boolean (true, false, 1 or 0)" };
|
|
7348
|
+
}),
|
|
7349
|
+
enum: (values) => envVar((raw) => values.includes(raw) ? { value: raw } : { problem: `is not one of: ${values.join(", ")}` }, Object.freeze([...values])),
|
|
7350
|
+
/**
|
|
7351
|
+
* Synchronous validators only: `parse()` also runs where nothing can await it
|
|
7352
|
+
* (the CLI, a connection thunk), so a Promise result is reported as a problem.
|
|
7353
|
+
*/
|
|
7354
|
+
custom: (schema) => envVar((raw) => {
|
|
7355
|
+
const result = schema["~standard"].validate(raw);
|
|
7356
|
+
if (result instanceof Promise) return { problem: "has an asynchronous validator; Env.custom() accepts synchronous validators only" };
|
|
7357
|
+
if ("value" in result && !result.issues) return { value: result.value };
|
|
7358
|
+
return { problem: `is invalid: ${(result.issues ?? []).map((issue) => issue.message).join("; ")}` };
|
|
7359
|
+
})
|
|
7360
|
+
};
|
|
7361
|
+
var EnvValidationError = class extends Error {
|
|
7362
|
+
problems;
|
|
7363
|
+
constructor(problems) {
|
|
7364
|
+
const width = Math.max(...problems.map((problem) => problem.key.length)) + 2;
|
|
7365
|
+
const lines = problems.map((problem) => ` ${problem.key.padEnd(width)}${problem.message}`);
|
|
7366
|
+
super(`[guren] Invalid environment (${problems.length} ${problems.length === 1 ? "problem" : "problems"}):\n${lines.join("\n")}`);
|
|
7367
|
+
this.problems = problems;
|
|
7368
|
+
this.name = "EnvValidationError";
|
|
7369
|
+
}
|
|
7370
|
+
};
|
|
7371
|
+
var EnvSchema = class {
|
|
7372
|
+
vars;
|
|
7373
|
+
constructor(vars) {
|
|
7374
|
+
this.vars = vars;
|
|
7375
|
+
}
|
|
7376
|
+
/**
|
|
7377
|
+
* Looks up each declared key in `source`, then `process.env`, and does not
|
|
7378
|
+
* cache: `process.env` keeps its identity while tests and platforms mutate it.
|
|
7379
|
+
*/
|
|
7380
|
+
parse(source, options = {}) {
|
|
7381
|
+
const production = typeof process !== "undefined" && process.env.NODE_ENV === "production";
|
|
7382
|
+
const values = {};
|
|
7383
|
+
const problems = [];
|
|
7384
|
+
for (const [key, spec] of Object.entries(this.vars)) {
|
|
7385
|
+
const raw = readRaw(source, key);
|
|
7386
|
+
const outcome = spec.resolve(raw, production);
|
|
7387
|
+
if ("value" in outcome) {
|
|
7388
|
+
values[key] = outcome.value;
|
|
7389
|
+
continue;
|
|
7390
|
+
}
|
|
7391
|
+
const shown = spec.isSecret || raw === void 0 ? "value" : JSON.stringify(raw);
|
|
7392
|
+
problems.push({
|
|
7393
|
+
key,
|
|
7394
|
+
message: "unset" in outcome ? "required, not set" : `${shown} ${outcome.problem}`
|
|
7395
|
+
});
|
|
7396
|
+
values[key] = AGENT_REDACTED;
|
|
7397
|
+
}
|
|
7398
|
+
if (problems.length > 0 && (options.mode ?? "throw") === "throw") throw new EnvValidationError(problems);
|
|
7399
|
+
const unset = new Set(problems.map((problem) => problem.key));
|
|
7400
|
+
return {
|
|
7401
|
+
values: Object.freeze(values),
|
|
7402
|
+
problems,
|
|
7403
|
+
unset
|
|
7404
|
+
};
|
|
7405
|
+
}
|
|
7406
|
+
};
|
|
7407
|
+
function readRaw(source, key) {
|
|
7408
|
+
const supplied = source?.[key];
|
|
7409
|
+
if (typeof supplied === "string") return supplied;
|
|
7410
|
+
return typeof process === "undefined" ? void 0 : process.env[key];
|
|
7411
|
+
}
|
|
7412
|
+
const ENV_KEY_PATTERN = /^[A-Z_][A-Z0-9_]*$/u;
|
|
7413
|
+
/**
|
|
7414
|
+
* Keys an app schema may not declare. `NODE_ENV` gates fold at bundle time only
|
|
7415
|
+
* as the exact `process.env.NODE_ENV` expression, and `GUREN_*` are framework
|
|
7416
|
+
* security gates and tooling flags (RFC 0027 §1). The oxlint rule keeps a copy.
|
|
7417
|
+
*/
|
|
7418
|
+
function isRawEnvKey(key) {
|
|
7419
|
+
return key === "NODE_ENV" || key.startsWith("GUREN_");
|
|
7420
|
+
}
|
|
7421
|
+
function defineEnv(vars) {
|
|
7422
|
+
for (const key of Object.keys(vars)) {
|
|
7423
|
+
if (!ENV_KEY_PATTERN.test(key)) throw new Error(`[guren] defineEnv(): "${key}" is not an environment variable name (A-Z, 0-9 and _).`);
|
|
7424
|
+
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.`);
|
|
7425
|
+
}
|
|
7426
|
+
return new EnvSchema(vars);
|
|
7427
|
+
}
|
|
7428
|
+
//#endregion
|
|
7429
|
+
//#region src/config/define.ts
|
|
7430
|
+
function defineConfig(definition) {
|
|
7431
|
+
return definition;
|
|
7432
|
+
}
|
|
7433
|
+
function defineCacheConfig(resolve) {
|
|
7434
|
+
return defineConfig({
|
|
7435
|
+
key: "cache",
|
|
7436
|
+
resolve,
|
|
7437
|
+
bind: (container, config) => {
|
|
7438
|
+
container.singleton("cache", () => createCacheManager(config));
|
|
7439
|
+
}
|
|
7440
|
+
});
|
|
7441
|
+
}
|
|
7442
|
+
function defineHttpConfig(resolve) {
|
|
7443
|
+
return defineConfig({
|
|
7444
|
+
key: "http",
|
|
7445
|
+
resolve,
|
|
7446
|
+
bind: (container, config) => {
|
|
7447
|
+
container.instance("http.hostAuthorization", config.hostAuthorization ?? false);
|
|
7448
|
+
}
|
|
7449
|
+
});
|
|
7450
|
+
}
|
|
7451
|
+
function defineMailConfig(resolve) {
|
|
7452
|
+
return defineConfig({
|
|
7453
|
+
key: "mail",
|
|
7454
|
+
resolve,
|
|
7455
|
+
bind: (container, config) => {
|
|
7456
|
+
container.singleton("mail", (resolving) => createMailManager(config, resolving));
|
|
7457
|
+
}
|
|
7458
|
+
});
|
|
7459
|
+
}
|
|
7460
|
+
function defineOAuthConfig(resolve) {
|
|
7461
|
+
return defineConfig({
|
|
7462
|
+
key: "oauth",
|
|
7463
|
+
resolve,
|
|
7464
|
+
bind: (container, config) => {
|
|
7465
|
+
container.singleton("oauth", () => {
|
|
7466
|
+
const manager = createOAuthManager({ stateStore: config.stateStore });
|
|
7467
|
+
for (const [name, provider] of Object.entries(config.providers ?? {})) manager.registerProvider(name, provider);
|
|
7468
|
+
return manager;
|
|
7469
|
+
});
|
|
7470
|
+
}
|
|
7471
|
+
});
|
|
7472
|
+
}
|
|
7473
|
+
function defineQueueConfig(resolve) {
|
|
7474
|
+
return defineConfig({
|
|
7475
|
+
key: "queue",
|
|
7476
|
+
resolve,
|
|
7477
|
+
bind: (container, config) => {
|
|
7478
|
+
container.singleton("queue", () => createQueueManager(config));
|
|
7479
|
+
}
|
|
7480
|
+
});
|
|
7481
|
+
}
|
|
7482
|
+
function defineStorageConfig(resolve) {
|
|
7483
|
+
return defineConfig({
|
|
7484
|
+
key: "storage",
|
|
7485
|
+
resolve,
|
|
7486
|
+
bind: (container, config) => {
|
|
7487
|
+
container.singleton("storage", () => createStorageManager(config));
|
|
7488
|
+
}
|
|
7489
|
+
});
|
|
7490
|
+
}
|
|
7491
|
+
//#endregion
|
|
8041
7492
|
//#region src/index.ts
|
|
8042
7493
|
ensureErrorStackTracePolyfill();
|
|
8043
7494
|
//#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 };
|
|
7495
|
+
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 };
|