@guren/server 2.15.0 → 2.17.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.
Files changed (302) hide show
  1. package/dist/{DocsViewerServiceProvider-qFCaeiUv.js → DocsViewerServiceProvider-D2cuVgtN.js} +7 -12
  2. package/dist/{Hash-C8aejmi8.js → Hash-D2DFd8xX.js} +7 -57
  3. package/dist/{HttpException-BkS3euNG.js → HttpException-BlQ2yEmT.js} +2 -79
  4. package/dist/{Job-BVT813DO.js → Job-DxQK8h3P.js} +24 -179
  5. package/dist/{McpServiceProvider-BawsYjgN.js → McpServiceProvider-Zihx3Bjq.js} +35 -20
  6. package/dist/{Random-DbIJ22KQ.js → Random-S0OvCuR8.js} +9 -106
  7. package/dist/agent/AgentApprovalRequested.d.ts +11 -39
  8. package/dist/agent/approval-status.d.ts +56 -0
  9. package/dist/agent/approval.d.ts +76 -187
  10. package/dist/agent/audit-emitter.d.ts +16 -44
  11. package/dist/agent/audit.d.ts +20 -56
  12. package/dist/agent/derive.d.ts +32 -66
  13. package/dist/agent/dispatch.d.ts +38 -90
  14. package/dist/agent/events.d.ts +17 -23
  15. package/dist/agent/gate.d.ts +118 -0
  16. package/dist/agent/meta-tools.d.ts +18 -46
  17. package/dist/agent/pipeline.d.ts +234 -0
  18. package/dist/agent/public.d.ts +6 -25
  19. package/dist/agent/public.js +1 -1
  20. package/dist/agent/redact.d.ts +16 -38
  21. package/dist/agent/scopes.d.ts +55 -69
  22. package/dist/auth/AgentPrincipalGuard.d.ts +49 -0
  23. package/dist/auth/AuthManager.d.ts +22 -43
  24. package/dist/auth/AuthenticatableModel.d.ts +2 -2
  25. package/dist/auth/SessionGuard.d.ts +0 -1
  26. package/dist/auth/TokenGuard.d.ts +6 -26
  27. package/dist/auth/api-token.d.ts +16 -148
  28. package/dist/auth/context.d.ts +5 -10
  29. package/dist/auth/email-verification.d.ts +29 -127
  30. package/dist/auth/index.js +1 -1
  31. package/dist/auth/oauth/index.d.ts +35 -57
  32. package/dist/auth/password/DefaultHasher.d.ts +5 -14
  33. package/dist/auth/password/PasswordHasher.d.ts +5 -13
  34. package/dist/auth/password/hash-format.d.ts +5 -13
  35. package/dist/auth/password-reset.d.ts +16 -42
  36. package/dist/auth/providers/ModelUserProvider.d.ts +3 -4
  37. package/dist/auth/providers/UserProvider.d.ts +4 -4
  38. package/dist/auth/signed-token.d.ts +18 -0
  39. package/dist/auth/types.d.ts +9 -32
  40. package/dist/auth/utils.d.ts +6 -27
  41. package/dist/{auth-DkYoAPVn.js → auth-Gg54ppQi.js} +279 -519
  42. package/dist/authorization/Gate.d.ts +9 -145
  43. package/dist/authorization/Policy.d.ts +6 -53
  44. package/dist/authorization/index.js +1 -1
  45. package/dist/authorization/middleware.d.ts +16 -62
  46. package/dist/authorization/types.d.ts +8 -64
  47. package/dist/{authorization-CdfbCj8J.js → authorization-CdEWZZw3.js} +44 -309
  48. package/dist/broadcasting/BroadcastManager.d.ts +29 -149
  49. package/dist/broadcasting/channels/Channel.d.ts +1 -19
  50. package/dist/broadcasting/channels/PresenceChannel.d.ts +1 -55
  51. package/dist/broadcasting/channels/PrivateChannel.d.ts +1 -23
  52. package/dist/broadcasting/drivers/MemoryDriver.d.ts +18 -70
  53. package/dist/broadcasting/drivers/RedisDriver.d.ts +3 -80
  54. package/dist/broadcasting/drivers/index.d.ts +1 -1
  55. package/dist/broadcasting/index.d.ts +1 -1
  56. package/dist/broadcasting/index.js +1 -1
  57. package/dist/broadcasting/types.d.ts +7 -88
  58. package/dist/{broadcasting-BwodCA4q.js → broadcasting-B5RzB0A2.js} +87 -414
  59. package/dist/cache/CacheManager.d.ts +8 -62
  60. package/dist/cache/TaggedCache.d.ts +2 -35
  61. package/dist/cache/index.js +1 -1
  62. package/dist/cache/stores/FileStore.d.ts +2 -36
  63. package/dist/cache/stores/MemoryStore.d.ts +2 -26
  64. package/dist/cache/stores/RedisStore.d.ts +1 -29
  65. package/dist/cache/types.d.ts +21 -128
  66. package/dist/{cache-BYnZf2FR.js → cache-BOOIr324.js} +19 -198
  67. package/dist/client-C4TEr_Dd.js +9 -0
  68. package/dist/console/Command.d.ts +17 -126
  69. package/dist/console/ConsoleKernel.d.ts +2 -74
  70. package/dist/console/Input.d.ts +5 -113
  71. package/dist/console/Output.d.ts +3 -99
  72. package/dist/console/types.d.ts +3 -33
  73. package/dist/container/Container.d.ts +12 -103
  74. package/dist/container/ServiceProvider.d.ts +17 -61
  75. package/dist/container/bindings.d.ts +5 -26
  76. package/dist/container/defineModule.d.ts +16 -54
  77. package/dist/container/definePlugin.d.ts +12 -45
  78. package/dist/container/types.d.ts +2 -34
  79. package/dist/context-CXk_umpT.js +21 -0
  80. package/dist/database/Factory.d.ts +4 -57
  81. package/dist/database/Seeder.d.ts +8 -46
  82. package/dist/database/SeederRunner.d.ts +3 -33
  83. package/dist/database/types.d.ts +3 -24
  84. package/dist/discovery/AutoDiscovery.d.ts +10 -82
  85. package/dist/{dispatch-erOS9epZ.js → dispatch-BAwzftws.js} +32 -79
  86. package/dist/docs-viewer/DocsViewerServiceProvider.d.ts +2 -5
  87. package/dist/docs-viewer/endpoint.d.ts +5 -11
  88. package/dist/encryption/Encrypter.d.ts +5 -71
  89. package/dist/encryption/Hash.d.ts +7 -57
  90. package/dist/encryption/Random.d.ts +6 -99
  91. package/dist/encryption/index.js +3 -3
  92. package/dist/encryption/types.d.ts +10 -72
  93. package/dist/{encryption-D99Vmls3.js → encryption-uwP3Di4D.js} +9 -78
  94. package/dist/{endpoint-D6GIqOpe.js → endpoint-BXipU2Jj.js} +6 -12
  95. package/dist/endpoint-Dsw3Acvq.js +26 -0
  96. package/dist/errors/ExceptionHandler.d.ts +3 -90
  97. package/dist/errors/HttpException.d.ts +2 -79
  98. package/dist/errors/debug-page.d.ts +3 -17
  99. package/dist/errors/error-page.d.ts +1 -0
  100. package/dist/errors/exceptions/AuthenticationException.d.ts +2 -24
  101. package/dist/errors/exceptions/AuthorizationException.d.ts +1 -24
  102. package/dist/errors/exceptions/MethodNotAllowedException.d.ts +1 -23
  103. package/dist/errors/exceptions/NotFoundHttpException.d.ts +1 -27
  104. package/dist/errors/exceptions/ValidationException.d.ts +2 -43
  105. package/dist/errors/types.d.ts +1 -25
  106. package/dist/{errors-BgeOl_DC.js → errors-JpkcCjjn.js} +3 -41
  107. package/dist/events/Event.d.ts +1 -28
  108. package/dist/events/EventManager.d.ts +5 -107
  109. package/dist/events/Listener.d.ts +7 -55
  110. package/dist/events/builtin.d.ts +0 -24
  111. package/dist/events/index.js +1 -1
  112. package/dist/events/types.d.ts +4 -22
  113. package/dist/{events-aIH_bWRx.js → events-DOmAHDeP.js} +11 -191
  114. package/dist/facades/index.d.ts +2 -14
  115. package/dist/health/HealthCheck.d.ts +0 -24
  116. package/dist/health/HealthManager.d.ts +0 -36
  117. package/dist/health/checks/CacheCheck.d.ts +2 -17
  118. package/dist/health/checks/CustomCheck.d.ts +0 -9
  119. package/dist/health/checks/DatabaseCheck.d.ts +2 -17
  120. package/dist/health/checks/MemoryCheck.d.ts +3 -12
  121. package/dist/health/checks/RedisCheck.d.ts +1 -13
  122. package/dist/health/checks/StorageCheck.d.ts +2 -17
  123. package/dist/health/index.js +1 -1
  124. package/dist/health/types.d.ts +4 -24
  125. package/dist/{health-VWdWXRwh.js → health-DQSvUplL.js} +1 -76
  126. package/dist/hot-disposables-B5BXqaIH.js +167 -0
  127. package/dist/hot-reload/hot-disposables.d.ts +22 -74
  128. package/dist/hot-reload/testing.d.ts +4 -9
  129. package/dist/http/Application.d.ts +77 -205
  130. package/dist/http/FormRequest.d.ts +4 -55
  131. package/dist/http/dev-assets.d.ts +13 -31
  132. package/dist/http/dev-banner.d.ts +2 -5
  133. package/dist/http/inertia-assets.d.ts +3 -6
  134. package/dist/http/middleware/capabilities.d.ts +27 -50
  135. package/dist/http/middleware/cors.d.ts +4 -29
  136. package/dist/http/middleware/csp.d.ts +2 -25
  137. package/dist/http/middleware/csrf.d.ts +28 -95
  138. package/dist/http/middleware/detect-locale.d.ts +7 -27
  139. package/dist/http/middleware/force-https.d.ts +6 -24
  140. package/dist/http/middleware/host-authorization.d.ts +2 -12
  141. package/dist/http/middleware/index.d.ts +1 -1
  142. package/dist/http/middleware/loopback-guard.d.ts +15 -33
  143. package/dist/http/middleware/rate-limit.d.ts +29 -126
  144. package/dist/http/middleware/redirect-safety.d.ts +2 -20
  145. package/dist/http/middleware/request-id.d.ts +1 -14
  146. package/dist/http/middleware/request-logging.d.ts +2 -13
  147. package/dist/http/middleware/response-headers.d.ts +5 -13
  148. package/dist/http/middleware/security-headers.d.ts +2 -16
  149. package/dist/http/middleware/session.d.ts +15 -34
  150. package/dist/http/middleware/validation-errors-cookie.d.ts +7 -18
  151. package/dist/http/middleware/validation.d.ts +8 -63
  152. package/dist/http/public-assets.d.ts +11 -7
  153. package/dist/http/request.d.ts +32 -118
  154. package/dist/http/resources/CursorPaginator.d.ts +5 -64
  155. package/dist/http/resources/Paginator.d.ts +7 -84
  156. package/dist/http/resources/Resource.d.ts +9 -65
  157. package/dist/http/resources/ResourceCollection.d.ts +5 -39
  158. package/dist/http/resources/types.d.ts +10 -30
  159. package/dist/http/static-documents.d.ts +10 -20
  160. package/dist/http/validation/Validator.d.ts +25 -85
  161. package/dist/http/validation/rules.d.ts +48 -147
  162. package/dist/http/validation/types.d.ts +16 -61
  163. package/dist/http/vite-assets.d.ts +5 -28
  164. package/dist/http/vite-dev-server.d.ts +6 -9
  165. package/dist/http/vite-manifest.d.ts +19 -33
  166. package/dist/i18n/I18nManager.d.ts +12 -78
  167. package/dist/i18n/Translator.d.ts +3 -54
  168. package/dist/i18n/index.js +1 -1
  169. package/dist/i18n/loaders/JsonLoader.d.ts +4 -31
  170. package/dist/i18n/loaders/MemoryLoader.d.ts +1 -21
  171. package/dist/i18n/pluralization.d.ts +4 -13
  172. package/dist/i18n/types.d.ts +17 -69
  173. package/dist/{i18n-mcWi7LCd.js → i18n-Cg1aajRP.js} +31 -225
  174. package/dist/index.d.ts +11 -4
  175. package/dist/index.js +1186 -3040
  176. package/dist/internal/agent-preflight.d.ts +9 -21
  177. package/dist/internal/agent-principal.d.ts +32 -0
  178. package/dist/internal/request.d.ts +6 -19
  179. package/dist/internal/request.js +1 -1
  180. package/dist/internal/route-path.d.ts +9 -21
  181. package/dist/internal/route-path.js +9 -21
  182. package/dist/internal/zod-compat.d.ts +55 -122
  183. package/dist/internal/zod-compat.js +39 -70
  184. package/dist/internal/zod-json-schema.d.ts +18 -54
  185. package/dist/internal/zod-json-schema.js +46 -123
  186. package/dist/jsx-runtime.d.ts +3 -8
  187. package/dist/lambda/index.d.ts +17 -79
  188. package/dist/lambda/index.js +11 -59
  189. package/dist/logging/LogManager.d.ts +1 -51
  190. package/dist/logging/Logger.d.ts +8 -47
  191. package/dist/logging/channels/ConsoleChannel.d.ts +1 -3
  192. package/dist/logging/channels/DailyFileChannel.d.ts +1 -3
  193. package/dist/logging/channels/FileChannel.d.ts +1 -3
  194. package/dist/logging/daily-file-path.d.ts +7 -16
  195. package/dist/logging/index.js +1 -1
  196. package/dist/logging/types.d.ts +13 -45
  197. package/dist/{logging-B-kngi3q.js → logging-zOY1XCtq.js} +52 -141
  198. package/dist/{loopback-guard-D0Kc7-xc.js → loopback-guard-DT9gHF0F.js} +41 -92
  199. package/dist/mail/Mail.d.ts +10 -106
  200. package/dist/mail/MailManager.d.ts +2 -60
  201. package/dist/mail/index.js +1 -1
  202. package/dist/mail/transports/LogTransport.d.ts +1 -4
  203. package/dist/mail/transports/MemoryTransport.d.ts +1 -63
  204. package/dist/mail/transports/ResendTransport.d.ts +1 -23
  205. package/dist/mail/transports/SmtpTransport.d.ts +1 -31
  206. package/dist/mail/types.d.ts +28 -150
  207. package/dist/{mail-DfEfSQEr.js → mail-76DWy9lj.js} +31 -289
  208. package/dist/mcp/McpServiceProvider.d.ts +4 -10
  209. package/dist/mcp/create-mcp-server.d.ts +42 -57
  210. package/dist/mcp/endpoint.d.ts +12 -36
  211. package/dist/mcp/index.js +1 -1
  212. package/dist/mvc/Controller.d.ts +46 -227
  213. package/dist/mvc/Router.d.ts +50 -129
  214. package/dist/mvc/inertia/InertiaEngine.d.ts +18 -48
  215. package/dist/mvc/inertia/shared.d.ts +6 -19
  216. package/dist/mvc/mount-route.d.ts +2 -6
  217. package/dist/mvc/view.d.ts +1 -2
  218. package/dist/notifications/Notification.d.ts +8 -75
  219. package/dist/notifications/NotificationManager.d.ts +15 -88
  220. package/dist/notifications/channels/DatabaseChannel.d.ts +1 -41
  221. package/dist/notifications/channels/MailChannel.d.ts +2 -31
  222. package/dist/notifications/channels/MemoryChannel.d.ts +2 -62
  223. package/dist/notifications/channels/SlackChannel.d.ts +3 -48
  224. package/dist/notifications/index.js +1 -1
  225. package/dist/notifications/notifiable-type.d.ts +3 -6
  226. package/dist/notifications/registry.d.ts +8 -27
  227. package/dist/notifications/types.d.ts +16 -53
  228. package/dist/{notifications-BGqmUNZ8.js → notifications-okWFs9ly.js} +37 -335
  229. package/dist/providers/AuthServiceProvider.d.ts +1 -3
  230. package/dist/providers/AuthorizationServiceProvider.d.ts +2 -3
  231. package/dist/providers/BroadcastServiceProvider.d.ts +1 -3
  232. package/dist/providers/CacheServiceProvider.d.ts +1 -3
  233. package/dist/providers/EncryptionServiceProvider.d.ts +1 -3
  234. package/dist/providers/ErrorServiceProvider.d.ts +1 -4
  235. package/dist/providers/EventServiceProvider.d.ts +1 -3
  236. package/dist/providers/HealthServiceProvider.d.ts +1 -3
  237. package/dist/providers/I18nServiceProvider.d.ts +6 -10
  238. package/dist/providers/InertiaServiceProvider.d.ts +1 -4
  239. package/dist/providers/LogServiceProvider.d.ts +1 -3
  240. package/dist/providers/MailServiceProvider.d.ts +1 -3
  241. package/dist/providers/NotificationServiceProvider.d.ts +1 -3
  242. package/dist/providers/OAuthServiceProvider.d.ts +1 -3
  243. package/dist/providers/QueueServiceProvider.d.ts +1 -3
  244. package/dist/providers/SchedulingServiceProvider.d.ts +1 -3
  245. package/dist/providers/StorageServiceProvider.d.ts +1 -3
  246. package/dist/queue/FailedJobReporter.d.ts +1 -24
  247. package/dist/queue/Job.d.ts +12 -99
  248. package/dist/queue/QueueManager.d.ts +6 -57
  249. package/dist/queue/Worker.d.ts +4 -65
  250. package/dist/queue/drivers/MemoryDriver.d.ts +3 -44
  251. package/dist/queue/drivers/RedisDriver.d.ts +7 -65
  252. package/dist/queue/drivers/SqsDriver.d.ts +6 -57
  253. package/dist/queue/drivers/SyncDriver.d.ts +10 -13
  254. package/dist/queue/index.js +2 -2
  255. package/dist/queue/types.d.ts +10 -92
  256. package/dist/{queue-CXrRK85G.js → queue-CcXCjuJI.js} +32 -260
  257. package/dist/redis/RedisApiTokenStore.d.ts +4 -56
  258. package/dist/redis/RedisEmailVerificationStore.d.ts +4 -37
  259. package/dist/redis/RedisOAuthStateStore.d.ts +2 -10
  260. package/dist/redis/RedisPasswordResetStore.d.ts +4 -37
  261. package/dist/redis/RedisRateLimitStore.d.ts +16 -49
  262. package/dist/redis/RedisSessionStore.d.ts +3 -44
  263. package/dist/redis/client.d.ts +2 -32
  264. package/dist/redis/index.js +47 -232
  265. package/dist/redis/redis-values.d.ts +6 -12
  266. package/dist/redis/scan-keys.d.ts +1 -4
  267. package/dist/request-CLOYytGP.js +68 -0
  268. package/dist/runtime/index.d.ts +2 -0
  269. package/dist/runtime/index.js +50 -92
  270. package/dist/scheduling/CronParser.d.ts +0 -29
  271. package/dist/scheduling/Schedule.d.ts +1 -153
  272. package/dist/scheduling/ScheduledTask.d.ts +0 -31
  273. package/dist/scheduling/Scheduler.d.ts +0 -70
  274. package/dist/scheduling/index.js +1 -1
  275. package/dist/scheduling/types.d.ts +4 -65
  276. package/dist/{scheduling-CPiEdtQd.js → scheduling-C6tcOtUl.js} +2 -287
  277. package/dist/storage/StorageManager.d.ts +0 -48
  278. package/dist/storage/drivers/LocalDriver.d.ts +1 -25
  279. package/dist/storage/drivers/MemoryDriver.d.ts +5 -35
  280. package/dist/storage/drivers/S3Driver.d.ts +6 -36
  281. package/dist/storage/drivers/s3-acl.d.ts +5 -10
  282. package/dist/storage/index.js +1 -1
  283. package/dist/storage/types.d.ts +27 -265
  284. package/dist/{storage-TLD9t0Q2.js → storage-BB59f07j.js} +17 -157
  285. package/dist/support/contained-path.d.ts +10 -20
  286. package/dist/support/error-polyfill.d.ts +4 -6
  287. package/dist/support/expiry.d.ts +17 -33
  288. package/dist/support/expiry.js +17 -33
  289. package/dist/support/import-map.d.ts +3 -7
  290. package/dist/support/inertia-defaults.d.ts +5 -10
  291. package/dist/support/redirect-target.d.ts +4 -6
  292. package/dist/support/stack-frames.d.ts +11 -50
  293. package/dist/support/trim-slashes.d.ts +4 -7
  294. package/dist/support/warn-once.d.ts +2 -6
  295. package/dist/{trim-slashes-ZJ_VsY5s.js → trim-slashes-BLY9hKAa.js} +4 -7
  296. package/dist/{vite-manifest-w_RSOvQW.js → vite-manifest-B_Iy5183.js} +34 -58
  297. package/package.json +2 -2
  298. package/dist/client-Dd7vLcqp.js +0 -27
  299. package/dist/context-DoD0c7J_.js +0 -26
  300. package/dist/endpoint-D-20PiHY.js +0 -46
  301. package/dist/hot-disposables-WsTX2ySN.js +0 -281
  302. package/dist/request-CVQwpu2J.js +0 -129
@@ -1,48 +1,12 @@
1
1
  /**
2
- * Stops the timers a previous module evaluation left running.
3
- *
4
- * `bun --hot` re-runs the module graph inside the same process. Anything the
5
- * previous evaluation built is dropped on the floor — but a `setInterval`
6
- * callback keeps its owner reachable, so a store, manager, or scheduler that
7
- * nothing references any more goes on firing forever. One extra timer per
8
- * reload, each one retaining the dead object graph behind it.
9
- *
10
- * `globalThis` survives re-evaluation, so it is where the previous owner's
11
- * teardown is parked — the same storage `Application.listen()` uses for the Bun
12
- * and Vite dev servers, and the same approach `@guren/orm` uses for database
13
- * connections. Bun does not expose `import.meta.hot` to `bun --hot` (checked on
14
- * 1.3.14), so there is no reload hook to register with instead.
15
- *
16
- * This is deliberately not the ORM's registry with the names changed. Closing a
17
- * connection is an async operation that can hang on a wedged socket, which is
18
- * what forces that module's serialized claims and teardown timeout. Every
19
- * teardown here is synchronous — `clearInterval`, and the `destroy()`/`stop()`
20
- * methods wrapping it — so a claim can simply run the previous teardown inline
21
- * and be done. Sharing the registries would buy machinery neither side needs in
22
- * the same shape.
23
- *
24
- * Its twin is `packages/orm/src/active-connections.ts`. `parseFrameLocation` and
25
- * `describeCallerFile`'s walk past a synthetic frame follow the same rule in
26
- * both — a fix to either has to be carried to the other by hand. That has
27
- * already failed once: this walk predates the ORM's, and the ORM kept keying
28
- * handles to `unknown` in the meantime. Nothing forces the duplication —
29
- * `@guren/server` already depends on `@guren/orm`, so this layer could live
30
- * there and be imported here — it is only that the shared part is small next to
31
- * the two packages' very different teardown semantics (see above). Extract the
32
- * rest if it drifts again.
33
- *
34
- * One piece already went that way, for a reason worth recording: the debug error
35
- * page turned out to read frames too, and had written its own, wrong version of
36
- * the paren rule. That scan now lives in `../support/stack-frames`, imported by
37
- * both readers in this package — the ORM's copy of it is still hand-synced like
38
- * everything else here.
39
- *
40
- * An owner is identified by the file that built it plus a discriminator, so it
41
- * is replaced only by a later evaluation of that same file. Keying on the exact
42
- * line would be more precise, but a line number changes the moment anything
43
- * above it does — adding an import would orphan the previous entry and leak the
44
- * timer it was holding, during the very workflow this exists to fix. The file is
45
- * stable across every edit that isn't a rename.
2
+ * Stops the timers a previous module evaluation left running: `bun --hot`
3
+ * re-runs the module graph in-process and a `setInterval` callback keeps its
4
+ * owner reachable, so each reload leaks a timer and the dead graph behind it.
5
+ * Teardown is parked on `globalThis`, which survives re-evaluation — Bun
6
+ * exposes no `import.meta.hot` to `bun --hot` (1.3.14). Owners are keyed on
7
+ * file + discriminator, never line: a line moves whenever anything above it
8
+ * does. Twin of `packages/orm/src/active-connections.ts` — the frame-walk rule
9
+ * is the same in both and must be carried across by hand.
46
10
  */
47
11
  type Dispose = () => void;
48
12
  /** Frees the slot an owner claimed, unless a newer owner has since taken it. */
@@ -50,47 +14,31 @@ export interface HotDisposableClaim {
50
14
  release(): void;
51
15
  }
52
16
  /**
53
- * Whether modules can be re-evaluated in this process.
54
- *
55
- * `bun --watch` restarts the process instead, which drops every timer with it,
56
- * so `--hot` is the only mode that leaks. Everywhere else — production, tests,
57
- * CLI commands, serverless — nothing is ever torn down automatically.
58
- *
59
- * Exported so callers can skip building the `Error` whose stack identifies them:
60
- * capturing one formats the whole stack into a string, and outside `--hot` it
61
- * would only be thrown away.
17
+ * Whether modules can be re-evaluated in this process. `bun --watch` restarts
18
+ * instead, dropping every timer with it, so `--hot` is the only mode that leaks.
19
+ * Exported so callers can skip building the `Error` whose stack identifies them
20
+ * — capturing one formats the whole stack into a string.
62
21
  */
63
22
  export declare function isHotReloadRuntime(): boolean;
64
23
  /**
65
- * The file that built the timer owner.
66
- *
67
- * `stack` must come from an `Error` constructed inside the constructor or
68
- * factory itself, so frame 0 is `Error`, frame 1 is that function, and frame 2
69
- * is the caller — or the first frame after it that names a real file, since the
70
- * engine may have synthesized the frames in between. Only the path is kept: a
71
- * reload re-runs the same file, but not necessarily at the same line.
24
+ * The file that built the timer owner. `stack` must come from an `Error`
25
+ * constructed inside the constructor or factory itself, so frame 2 is the
26
+ * caller — or the first frame after it naming a real file, since the engine may
27
+ * have synthesized the ones in between.
72
28
  */
73
29
  export declare function describeCallerFile(stack: string | undefined): string | undefined;
74
30
  /**
75
31
  * Identity for a timer owner across hot reloads, or `undefined` when the owner
76
- * must be left alone.
77
- *
78
- * `target` separates owners that share a call site — the name of a cache store,
79
- * say — so one module building several does not collapse them into a slot where
80
- * each new one stops the last.
32
+ * must be left alone. `target` separates owners sharing a call site, so one
33
+ * module building several does not collapse them into a single slot.
81
34
  */
82
35
  export declare function hotReloadKey(scope: string, stack: string | undefined, target: string): string | undefined;
83
36
  /**
84
37
  * Records `dispose` as the live owner for this identity, stops whichever owner
85
- * held it before, and hands back the claim so the new owner can give it up.
86
- *
87
- * Returns `undefined` outside `--hot`, or when the stack does not name a caller
88
- * — the owner is then simply left alone, which is how things behaved before this
89
- * registry existed.
90
- *
91
- * A teardown that throws is reported and swallowed: the replacement has already
92
- * been built by the time this runs, and refusing to register it would leak the
93
- * very timer this is here to stop.
38
+ * held it before, and returns the claim. `undefined` outside `--hot`, or when
39
+ * the stack names no caller — the owner is then left alone. A teardown that
40
+ * throws is reported and swallowed, since refusing to register the replacement
41
+ * would leak the very timer this exists to stop.
94
42
  */
95
43
  export declare function claimHotDisposable(scope: string, stack: string | undefined, target: string, dispose: Dispose): HotDisposableClaim | undefined;
96
44
  export {};
@@ -1,14 +1,9 @@
1
1
  /**
2
- * Test-only helpers for the hot-reload registry.
3
- *
4
- * Not reachable from any tsdown entry point, so it never ships — it lives beside
5
- * the code it exercises because both test files in this directory need it and
6
- * `@guren/server` has no shared test-support module.
2
+ * Test-only helpers for the hot-reload registry. Not reachable from any tsdown
3
+ * entry point, so it never ships.
7
4
  */
8
5
  /**
9
- * Runs `callback` with the registry's `--hot` guard satisfied.
10
- *
11
- * The guard reads `process.execArgv`, which is also how the real thing detects
12
- * `bun --hot`; there is no flag or injection seam to prefer over it.
6
+ * Runs `callback` with the registry's `--hot` guard satisfied. The guard reads
7
+ * `process.execArgv`, which is also how the real thing detects `bun --hot`.
13
8
  */
14
9
  export declare function withHotRuntime<T>(callback: () => T): T;
@@ -21,44 +21,32 @@ type BunServer = {
21
21
  };
22
22
  type ViteServer = Awaited<ReturnType<typeof startViteDevServer>>['server'];
23
23
  /**
24
- * The one managed Vite dev server this process runs, and who owns it.
25
- *
26
- * The owner matters because a dev server outlives the `listen()` that started
27
- * it: on a `bun --hot` reload the next `listen()` adopts the running server
28
- * rather than restarting it, and both applications then hold the same object.
29
- * Instance identity cannot tell those two apart — it is the same server — so
30
- * "may I close this?" is answered here instead, by the slot naming exactly one
31
- * owner at a time.
24
+ * The one managed Vite dev server this process runs, and who owns it. A server
25
+ * outlives the `listen()` that started it — a `bun --hot` reload adopts it, so
26
+ * two applications hold the same object and instance identity cannot tell them
27
+ * apart. The slot names exactly one owner at a time instead.
32
28
  */
33
29
  export interface ActiveViteDevServer {
34
30
  readonly server: ViteServer;
35
31
  readonly localUrl: string;
36
32
  readonly owner: Application;
37
33
  /**
38
- * Detaches the owner's process teardown handlers. Whoever replaces this
39
- * record calls it, because the outgoing owner is only reachable from here —
40
- * and a set of handlers left attached would still close this server, and run
41
- * its own `process.exit()`, on the next signal.
34
+ * Detaches the owner's process teardown handlers. Whoever replaces this record
35
+ * calls it: the outgoing owner is only reachable from here, and handlers left
36
+ * attached would still close this server on the next signal.
42
37
  */
43
38
  readonly disposeTeardown: () => void;
44
39
  }
45
40
  /**
46
- * The ambient slots `listen()` plants on `globalThis` so a `bun --hot` reload,
47
- * which re-runs the entrypoint but keeps `globalThis`, can find what the
48
- * previous run left running.
49
- *
50
- * Exported so the tests that plant stand-ins in these slots can name them
51
- * against this declaration instead of restating it. Not part of the public
52
- * API: `src/index.ts` re-exports by name and does not list it.
41
+ * The ambient slots `listen()` plants on `globalThis`, which a `bun --hot`
42
+ * reload keeps, so the next run can find what the previous one left running.
43
+ * Exported for the tests that plant stand-ins; not part of the public API.
53
44
  */
54
45
  export interface GurenGlobalSlots {
55
46
  __gurenActiveServer?: BunServer;
56
47
  __gurenActiveViteDevServer?: ActiveViteDevServer;
57
48
  }
58
49
  export type BootCallback = (app: Hono) => void | Promise<void>;
59
- /**
60
- * Service provider class constructor type.
61
- */
62
50
  export type { ServiceProviderConstructor } from '../container/ServiceProvider.js';
63
51
  export type RouteRegistration = (router: Router) => void | Promise<void>;
64
52
  export type ApplicationFeatures = Record<string, unknown>;
@@ -66,81 +54,43 @@ export interface ApplicationOptions {
66
54
  readonly boot?: BootCallback;
67
55
  readonly providers?: Array<ServiceProviderConstructor>;
68
56
  readonly auth?: AuthPluginOptions;
69
- /**
70
- * Configure internationalization: translation loading, locale detection,
71
- * and Inertia `_i18n` shared props. When set, {@link I18nServiceProvider}
72
- * is registered automatically.
73
- */
57
+ /** When set, {@link I18nServiceProvider} is registered automatically. */
74
58
  readonly i18n?: I18nPluginOptions;
75
59
  readonly routes?: RouteRegistration;
76
60
  /**
77
- * Application modules (RFC 0002) — each module's providers are appended
78
- * to `providers` below, and its route registrar runs after `routes`
79
- * (wrapped in `router.group(prefix, ...)` when the module declares one).
61
+ * Application modules (RFC 0002). Their providers are appended to `providers`
62
+ * and their route registrars run after `routes`, under the module's prefix.
80
63
  */
81
64
  readonly modules?: GurenModule[];
82
65
  readonly features?: ApplicationFeatures;
83
- /**
84
- * Configure or disable the default security headers middleware.
85
- * Set to `false` to disable entirely, or pass `SecurityHeadersOptions` to customize.
86
- * Enabled by default with safe Rails-matching defaults.
87
- */
66
+ /** Enabled by default with Rails-matching defaults; `false` disables it. */
88
67
  readonly securityHeaders?: SecurityHeadersOptions | false;
89
- /**
90
- * Configure host authorization middleware for DNS rebinding protection.
91
- * Pass `HostAuthorizationOptions` to enable, or `false` / omit to disable.
92
- * The `create-app` template includes a default localhost configuration.
93
- */
68
+ /** DNS rebinding protection. Off unless configured; the template configures it. */
94
69
  readonly hostAuthorization?: HostAuthorizationOptions | false;
95
70
  }
96
71
  export interface I18nPluginOptions {
97
- /**
98
- * Locales the app supports. Locale detection only ever resolves to one of
99
- * these, and all of them are preloaded during `boot()`.
100
- */
72
+ /** Detection only resolves to one of these; all are preloaded during `boot()`. */
101
73
  readonly supported: readonly string[];
102
- /**
103
- * Fallback (and default) locale. Defaults to the first supported locale.
104
- */
74
+ /** Defaults to the first supported locale. */
105
75
  readonly fallback?: string;
106
76
  /**
107
- * Directory containing `<path>/<locale>/*.json` translation files, loaded
108
- * with {@link JsonLoader}. Defaults to `'lang'`. Ignored when `loader` is
109
- * set.
110
- *
111
- * Framework tooling (typed keys from `guren codegen`, `guren check
112
- * --i18n`, the Vite watch) assumes the default `lang/` location — a
113
- * custom path or loader opts out of those.
77
+ * Directory of `<path>/<locale>/*.json` files. Defaults to `'lang'`; ignored
78
+ * when `loader` is set. Framework tooling (typed keys, `check --i18n`, the
79
+ * Vite watch) assumes `lang/`, so a custom path or loader opts out of it.
114
80
  */
115
81
  readonly path?: string;
116
- /**
117
- * Custom translation loader (e.g. `MemoryLoader` for bundled messages on
118
- * serverless targets without a filesystem). Takes precedence over `path`.
119
- */
82
+ /** Takes precedence over `path` — e.g. `MemoryLoader` on a filesystem-less target. */
120
83
  readonly loader?: TranslationLoader;
121
- /**
122
- * Locale detection middleware options. `detectLocaleMiddleware` is mounted
123
- * automatically with the `supported` locales and `fallback` above; pass
124
- * `false` to mount (or skip) it yourself.
125
- */
84
+ /** `detectLocaleMiddleware` is mounted automatically; `false` to do it yourself. */
126
85
  readonly detect?: Omit<DetectLocaleOptions, 'supported' | 'fallback' | 'i18n'> | false;
127
- /**
128
- * Share the request locale and its messages with Inertia pages as the
129
- * `_i18n` prop. Defaults to `true`.
130
- */
86
+ /** Share the locale and its messages with Inertia as `_i18n`. Defaults to `true`. */
131
87
  readonly share?: boolean;
132
88
  }
133
89
  export interface AuthPluginOptions {
134
90
  autoSession?: boolean;
135
91
  sessionOptions?: CreateSessionMiddlewareOptions;
136
- /**
137
- * Automatically register CSRF middleware when session is enabled.
138
- * Defaults to `true`. Set to `false` to disable (e.g., for pure API servers).
139
- */
92
+ /** Defaults to `true` when session is enabled. */
140
93
  autoCsrf?: boolean;
141
- /**
142
- * Options passed to the CSRF middleware when `autoCsrf` is enabled.
143
- */
144
94
  csrfOptions?: import('./middleware/csrf.js').CsrfOptions;
145
95
  }
146
96
  export interface ApplicationListenOptions {
@@ -149,50 +99,30 @@ export interface ApplicationListenOptions {
149
99
  assetsUrl?: string;
150
100
  vite?: StartViteDevServerOptions | false;
151
101
  /**
152
- * What to do when the requested port is already taken.
153
- *
154
- * `true` walks forward through the next 20 ports; `false` fails fast with
155
- * the original EADDRINUSE. Unset walks outside production, matching the loop
156
- * this option replaces.
157
- *
158
- * `GUREN_STRICT_PORT=1` forces fail-fast regardless, and `port: 0` never
159
- * walks — the OS is already picking a free port.
102
+ * `true` walks forward through the next 20 ports, `false` fails fast on
103
+ * EADDRINUSE, unset walks outside production. `GUREN_STRICT_PORT=1` forces
104
+ * fail-fast regardless, and `port: 0` never walks.
160
105
  */
161
106
  portFallback?: boolean;
162
107
  }
163
108
  /**
164
- * Where the server actually ended up listening.
165
- *
166
- * Returned by {@link Application.listen} so callers never have to infer the
167
- * port from the port they asked for — with a port walk or `PORT=0` in play,
168
- * those are different numbers, and scraping the human-readable dev banner is
169
- * the only alternative.
170
- *
171
- * Read-only because {@link Application.address} hands back the very object
172
- * `listen()` returned: a caller that adjusted its own copy would change what
173
- * every later reader sees.
109
+ * Where the server actually ended up listening — with a port walk or `PORT=0`
110
+ * in play, not the port that was asked for. Read-only because
111
+ * {@link Application.address} hands back this very object.
174
112
  */
175
113
  export interface ListenAddress {
176
- /**
177
- * The port the socket is bound to — what the runtime reports, falling back
178
- * to the port the successful `Bun.serve` call was made with.
179
- */
114
+ /** What the runtime reports, falling back to the port `Bun.serve` succeeded on. */
180
115
  readonly port: number;
181
- /** The hostname the socket is bound to. */
182
116
  readonly hostname: string;
183
117
  /** A URL that reaches the server, with a wildcard bind resolved to localhost. */
184
118
  readonly url: string;
185
119
  }
186
120
  /**
187
- * Application wires an app-local router into a running Hono instance.
188
- *
189
- * It embeds a DI Container as the backbone of the framework, binding core
190
- * services and managing providers through the container's ProviderManager.
121
+ * Wires an app-local router and a DI container into a running Hono instance.
191
122
  *
192
123
  * Lifecycle rule for `listen()`/`stop()` and their helpers: re-check ownership
193
- * after every `await`. Any server or slot they remembered can have been
194
- * superseded by a concurrent call while they waited, and only the current
195
- * owner may clear shared state.
124
+ * after every `await`. A concurrent call may have superseded any server or slot
125
+ * they remembered, and only the current owner may clear shared state.
196
126
  */
197
127
  export declare class Application {
198
128
  private readonly options;
@@ -205,17 +135,14 @@ export declare class Application {
205
135
  private boundAddress?;
206
136
  /**
207
137
  * Detaches the Bun half's process teardown handlers, and doubles as the "are
208
- * they attached?" memo. One field rather than a separate boolean: a memo and
209
- * an undo that can disagree is how handlers end up attached while a flag says
210
- * otherwise — see {@link registerProcessTeardown}.
211
- *
212
- * The Vite half's disposer lives in {@link ActiveViteDevServer} instead,
213
- * because the application that detaches those handlers is not always the one
214
- * that attached them: adoption moves the server to a new owner, and the
215
- * outgoing owner is only reachable through the slot.
138
+ * they attached?" memo — one field, because a memo and an undo that disagree
139
+ * leave handlers attached while a flag says otherwise. The Vite half's
140
+ * disposer lives in {@link ActiveViteDevServer}, since adoption moves that
141
+ * server to an owner reachable only through the slot.
216
142
  */
217
143
  private disposeBunTeardown?;
218
144
  private autoSessionAttached;
145
+ private readonly cookielessAuthPaths;
219
146
  private routesRegistered;
220
147
  private bootPromise?;
221
148
  constructor(options?: ApplicationOptions);
@@ -225,129 +152,74 @@ export declare class Application {
225
152
  markAutoSessionAttached(): void;
226
153
  hasAutoSessionAttached(): boolean;
227
154
  /**
228
- * Mounts the application router onto the Hono instance.
155
+ * Asserts that `path` resolves its principal without ever reading a session
156
+ * cookie, so it refuses on its own terms and CSRF has no ambient authority to
157
+ * defend there. Only for an endpoint whose own code establishes that; an app
158
+ * exempting a path it chose wants `csrfOptions.exclude`. Call from `boot`,
159
+ * after `mountRoutes()` — at `register` the collision check sees no routes.
229
160
  */
161
+ declareCookielessAuthPath(path: string): void;
162
+ /** Matched by exact path — see {@link declareCookielessAuthPath}. */
163
+ getCookielessAuthPaths(): ReadonlySet<string>;
230
164
  mountRoutes(): Promise<void>;
231
- /**
232
- * Allows registering global middlewares directly on the underlying Hono app.
233
- */
234
165
  use(path: string, ...middleware: MiddlewareHandler[]): void;
235
166
  /**
236
- * Executes provider registration, boot callback, mounts routes, and boots providers.
167
+ * Registers providers, runs the boot callback, mounts routes, boots providers.
237
168
  *
238
- * Booting twice is a no-op: the first call's promise is reused, so providers
239
- * and routes are never mounted a second time — including when two callers
240
- * boot concurrently, before the first has finished. A boot that throws is not
241
- * remembered, so a later call attempts boot again (it resumes on a partially
242
- * mounted app rather than starting clean). The security defaults are mounted
243
- * by the constructor and so are outside this entirely.
169
+ * Booting twice is a no-op — the first call's promise is reused, concurrent
170
+ * callers included. A boot that throws is not remembered, so a later call
171
+ * retries on the partially mounted app rather than starting clean.
244
172
  */
245
173
  boot(): Promise<void>;
246
- private bootOnce;
247
174
  /**
248
- * Registers default security middleware (headers + host authorization).
249
- *
250
- * Called once, from the constructor — see the note there for why it does
251
- * not belong in boot().
175
+ * Resolves when the boot that is running — or has already run — completes,
176
+ * and immediately when none was ever started. For a surface holding this
177
+ * application from *inside* `boot`, whose hook runs while later providers are
178
+ * unbooted. Never await it from a provider's own `boot`: it waits on itself.
252
179
  */
180
+ booted(): Promise<void>;
181
+ private bootOnce;
182
+ /** Called once, from the constructor — see the note there for why. */
253
183
  private mountSecurityDefaults;
254
184
  private mountHostAuthorization;
255
185
  /**
256
- * Mounts an opt-in, dev-only framework endpoint: the MCP endpoint
257
- * (/_guren/mcp) and the docs viewer (/_guren/docs) both work this way.
258
- *
259
- * Only the dynamic import is allowed to fail silently — these
260
- * providers reach optional dependencies (the MCP SDK, @guren/cli) that
261
- * an app need not have installed, and `missing` names that case. A
262
- * failure inside the provider's own boot is a real problem and is
263
- * rethrown, rather than leaving the developer with a silent 404.
186
+ * Mounts an opt-in, dev-only framework endpoint. Only the dynamic import may
187
+ * fail silently — these providers reach optional dependencies an app need not
188
+ * have installed. A failure inside the provider's own boot is rethrown.
264
189
  */
265
190
  private mountDevEndpoint;
266
- /**
267
- * Fetch handler to integrate with Bun.serve or any standard Fetch runtime.
268
- */
269
191
  fetch(request: Request, env?: unknown, executionCtx?: ExecutionContext): Promise<Response>;
270
- /**
271
- * Convenience helper to start a Bun server when available.
272
- */
273
192
  listen(options?: ApplicationListenOptions): Promise<ListenAddress>;
274
193
  /**
275
- * The address {@link Application.listen} bound, or `undefined` before it has
276
- * been called and once this app's server has been superseded or torn down.
277
- *
278
- * The same object `listen()` returned, so callers that need the address
279
- * later — an OpenAPI `servers` entry, an absolute URL, a health report —
280
- * read it here instead of threading it out of the entrypoint.
281
- *
282
- * The stored value is preferred over re-reading the live server, because
283
- * `listen()` resolves the port through a fallback the socket no longer
284
- * carries.
285
- *
286
- * Liveness is only as good as the signal available: a server stopped through
287
- * the framework — {@link Application.stop}, a later `listen()`, the
288
- * process-exit teardown — clears what this reads, but one stopped by reaching
289
- * past the framework to the Bun server's own `stop()` does not, and this keeps
290
- * reporting its address. Treat it as "where `listen()` put this app", not as a
291
- * health check.
194
+ * The address {@link Application.listen} bound — the same object it returned,
195
+ * preferred over re-reading the live server, whose port `listen()` may have
196
+ * resolved through a fallback the socket itself does not carry. Only stops
197
+ * that go through the framework clear it, so treat it as "where `listen()`
198
+ * put this app", not as a health check.
292
199
  */
293
200
  get address(): ListenAddress | undefined;
294
201
  /**
295
- * Stops the server {@link listen} started, undoing that call.
296
- *
297
- * Safe to call when nothing is listening, and safe to call twice — both are
298
- * no-ops. A later `listen()` starts cleanly, so an app may be stopped and
299
- * restarted in one process.
300
- *
301
- * `closeActiveConnections` forces in-flight requests closed instead of
302
- * waiting for them, matching Bun's own `stop()` parameter. It defaults to
303
- * `false` (graceful) because a caller reaching for a public stop is usually
304
- * shutting down deliberately; the hot-reload path inside `listen()` forces
305
- * the close, since a reload must not wait on the server it is replacing.
306
- *
307
- * The managed Vite dev server is taken down too. `listen()` is what started
308
- * it, and `listen()`'s own bind-failure path already closes the one it
309
- * started — leaving it running here would strand an asset server, and its
310
- * published env vars, in a process with no application server. That close is
311
- * best-effort on the same terms as every other path: it is bounded by
312
- * {@link viteCloseTimeoutMs}, and a Vite server that overruns the bound is
313
- * warned about and abandoned rather than holding this call open. A dev server
314
- * a later `listen()` has adopted is left alone — it belongs to that call now.
315
- *
316
- * The stop itself is bounded by {@link bunStopTimeoutMs}: a graceful stop
317
- * waits on in-flight requests, and one that never finishes would otherwise
318
- * hold this call open forever.
202
+ * Stops the server {@link listen} started; a no-op when nothing is listening
203
+ * or when called twice. `closeActiveConnections` forces in-flight requests
204
+ * closed, matching Bun's own `stop()`. The managed Vite dev server goes too,
205
+ * unless a later `listen()` adopted it. Both closes are bounded
206
+ * ({@link bunStopTimeoutMs}, {@link viteCloseTimeoutMs}) and then abandoned.
319
207
  */
320
208
  stop(closeActiveConnections?: boolean): Promise<void>;
321
- /**
322
- * Register a service provider.
323
- */
324
209
  register(provider: ServiceProviderConstructor): this;
325
- /**
326
- * Register multiple service providers.
327
- */
328
210
  registerMany(providers: Array<ServiceProviderConstructor>): this;
329
- /**
330
- * Logs the rich development server banner to the console.
331
- */
332
211
  logDevServerBanner(options: DevBannerOptions): void;
333
212
  /**
334
213
  * Closes the managed Vite dev server, but only while this application still
335
- * owns it.
336
- *
337
- * Ownership is the whole check. A `listen()` elsewhere in the process may
338
- * have adopted the running server — same object, new owner — and closing it
339
- * then would take the asset server, and its published env vars, out from
340
- * under an application that is actively serving from it. The record in the
341
- * slot is the one place that distinction exists, so it is read here rather
342
- * than mirrored on the instance.
214
+ * owns it: another `listen()` may have adopted the same object, and closing it
215
+ * then would take the asset server out from under an app serving from it. The
216
+ * slot's record is the one place that distinction exists.
343
217
  */
344
218
  private closeViteDevServer;
345
219
  /**
346
- * Attaches this application's Vite teardown handlers and returns the disposer
347
- * that detaches them. The disposer is stored in the active-record slot rather
348
- * than on this instance, because whoever takes ownership next is the one that
349
- * has to call it — and a disposer another app could spend would leave this
350
- * instance believing its handlers are attached when they are not.
220
+ * Attaches this application's Vite teardown handlers and returns the disposer.
221
+ * It is stored in the active-record slot, not on this instance, because
222
+ * whoever takes ownership next is the one that has to call it.
351
223
  */
352
224
  private registerViteTeardown;
353
225
  private registerBunTeardown;
@@ -1,76 +1,25 @@
1
1
  import type { Context } from 'hono';
2
2
  import type { ValidationRule } from './validation/types.js';
3
3
  /**
4
- * Base class for form request validation.
5
- *
6
- * FormRequest encapsulates both validation rules and authorization logic
7
- * for a single request type. Extend this class and define `rules()` and
8
- * optionally `authorize()` to create type-safe request validation.
9
- *
10
- * @example
11
- * ```typescript
12
- * interface StorePostData {
13
- * title: string
14
- * content: string
15
- * status: 'draft' | 'published'
16
- * }
17
- *
18
- * class StorePostRequest extends FormRequest<StorePostData> {
19
- * rules() {
20
- * return {
21
- * title: [required(), stringRule(), min(3), max(255)],
22
- * content: [required(), stringRule()],
23
- * status: [required(), inValues(['draft', 'published'])],
24
- * }
25
- * }
26
- *
27
- * async authorize() {
28
- * return (await this.user()) !== null
29
- * }
30
- * }
31
- *
32
- * // In controller:
33
- * const data = await new StorePostRequest().handle(this.ctx)
34
- * // data is typed as StorePostData
35
- * ```
4
+ * Validation rules and authorization for one request type, in one class.
36
5
  *
37
6
  * @deprecated Legacy compatibility layer — prefer schema-first validation
38
7
  * via `this.validateBody()` / `validateQuery()` / `validateParams()`.
39
8
  */
40
9
  export declare abstract class FormRequest<T = Record<string, unknown>> {
41
10
  protected ctx: Context;
42
- /**
43
- * Define validation rules for this request.
44
- * Return an object mapping field names to arrays of validation rules.
45
- */
46
11
  abstract rules(): Record<string, ValidationRule[]>;
47
- /**
48
- * Determine if the user is authorized to make this request.
49
- * Override to implement authorization logic. Defaults to true.
50
- */
51
12
  authorize(): boolean | Promise<boolean>;
52
- /**
53
- * Custom error messages for validation rules.
54
- * Override to provide custom messages.
55
- */
13
+ /** Override to customize validation messages. */
56
14
  messages(): Record<string, string>;
57
- /**
58
- * Custom attribute names for validation errors.
59
- * Override to provide human-readable field names.
60
- */
15
+ /** Override to give fields human-readable names in errors. */
61
16
  attributes(): Record<string, string>;
62
17
  /**
63
- * Get the authenticated user from the request context.
64
- *
65
18
  * Awaiting is load-bearing: `this.user() !== null` compiles and is always
66
19
  * true, because an unawaited call is a pending promise.
67
20
  */
68
21
  protected user<TUser = unknown>(): Promise<TUser | null>;
69
- /**
70
- * Handle the form request: authorize, parse body, validate, return typed data.
71
- * Call it from a controller with the request context:
72
- * `const data = await new StorePostRequest().handle(this.ctx)`.
73
- */
22
+ /** Authorize, parse the body, validate, return typed data. */
74
23
  handle(ctx: Context): Promise<T>;
75
24
  private parseBody;
76
25
  }