@c9up/ream 0.1.3

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 (451) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +70 -0
  3. package/dist/Application.d.ts +71 -0
  4. package/dist/Application.d.ts.map +1 -0
  5. package/dist/Application.js +151 -0
  6. package/dist/Application.js.map +1 -0
  7. package/dist/Codemods.d.ts +16 -0
  8. package/dist/Codemods.d.ts.map +1 -0
  9. package/dist/Codemods.js +277 -0
  10. package/dist/Codemods.js.map +1 -0
  11. package/dist/ConfigLoader.d.ts +29 -0
  12. package/dist/ConfigLoader.d.ts.map +1 -0
  13. package/dist/ConfigLoader.js +43 -0
  14. package/dist/ConfigLoader.js.map +1 -0
  15. package/dist/ErrorBoundary.d.ts +51 -0
  16. package/dist/ErrorBoundary.d.ts.map +1 -0
  17. package/dist/ErrorBoundary.js +122 -0
  18. package/dist/ErrorBoundary.js.map +1 -0
  19. package/dist/GracefulShutdown.d.ts +28 -0
  20. package/dist/GracefulShutdown.d.ts.map +1 -0
  21. package/dist/GracefulShutdown.js +55 -0
  22. package/dist/GracefulShutdown.js.map +1 -0
  23. package/dist/HealthCheck.d.ts +42 -0
  24. package/dist/HealthCheck.d.ts.map +1 -0
  25. package/dist/HealthCheck.js +65 -0
  26. package/dist/HealthCheck.js.map +1 -0
  27. package/dist/HotReload.d.ts +28 -0
  28. package/dist/HotReload.d.ts.map +1 -0
  29. package/dist/HotReload.js +60 -0
  30. package/dist/HotReload.js.map +1 -0
  31. package/dist/HttpKernel.d.ts +62 -0
  32. package/dist/HttpKernel.d.ts.map +1 -0
  33. package/dist/HttpKernel.js +210 -0
  34. package/dist/HttpKernel.js.map +1 -0
  35. package/dist/Ignitor.d.ts +195 -0
  36. package/dist/Ignitor.d.ts.map +1 -0
  37. package/dist/Ignitor.js +505 -0
  38. package/dist/Ignitor.js.map +1 -0
  39. package/dist/Provider.d.ts +54 -0
  40. package/dist/Provider.d.ts.map +1 -0
  41. package/dist/Provider.js +37 -0
  42. package/dist/Provider.js.map +1 -0
  43. package/dist/bodyparser/BodyParserMiddleware.d.ts +38 -0
  44. package/dist/bodyparser/BodyParserMiddleware.d.ts.map +1 -0
  45. package/dist/bodyparser/BodyParserMiddleware.js +143 -0
  46. package/dist/bodyparser/BodyParserMiddleware.js.map +1 -0
  47. package/dist/bodyparser/MultipartFile.d.ts +77 -0
  48. package/dist/bodyparser/MultipartFile.d.ts.map +1 -0
  49. package/dist/bodyparser/MultipartFile.js +138 -0
  50. package/dist/bodyparser/MultipartFile.js.map +1 -0
  51. package/dist/bodyparser/parseSize.d.ts +6 -0
  52. package/dist/bodyparser/parseSize.d.ts.map +1 -0
  53. package/dist/bodyparser/parseSize.js +21 -0
  54. package/dist/bodyparser/parseSize.js.map +1 -0
  55. package/dist/bootstrap/hyper-server.d.ts +27 -0
  56. package/dist/bootstrap/hyper-server.d.ts.map +1 -0
  57. package/dist/bootstrap/hyper-server.js +63 -0
  58. package/dist/bootstrap/hyper-server.js.map +1 -0
  59. package/dist/console/CommandRunner.d.ts +18 -0
  60. package/dist/console/CommandRunner.d.ts.map +1 -0
  61. package/dist/console/CommandRunner.js +65 -0
  62. package/dist/console/CommandRunner.js.map +1 -0
  63. package/dist/container/Container.d.ts +60 -0
  64. package/dist/container/Container.d.ts.map +1 -0
  65. package/dist/container/Container.js +329 -0
  66. package/dist/container/Container.js.map +1 -0
  67. package/dist/container/types.d.ts +25 -0
  68. package/dist/container/types.d.ts.map +1 -0
  69. package/dist/container/types.js +6 -0
  70. package/dist/container/types.js.map +1 -0
  71. package/dist/decorators/Lazy.d.ts +19 -0
  72. package/dist/decorators/Lazy.d.ts.map +1 -0
  73. package/dist/decorators/Lazy.js +53 -0
  74. package/dist/decorators/Lazy.js.map +1 -0
  75. package/dist/decorators/Service.d.ts +48 -0
  76. package/dist/decorators/Service.d.ts.map +1 -0
  77. package/dist/decorators/Service.js +70 -0
  78. package/dist/decorators/Service.js.map +1 -0
  79. package/dist/errors/FuzzyMatcher.d.ts +41 -0
  80. package/dist/errors/FuzzyMatcher.d.ts.map +1 -0
  81. package/dist/errors/FuzzyMatcher.js +81 -0
  82. package/dist/errors/FuzzyMatcher.js.map +1 -0
  83. package/dist/errors/ModuleErrors.d.ts +41 -0
  84. package/dist/errors/ModuleErrors.d.ts.map +1 -0
  85. package/dist/errors/ModuleErrors.js +65 -0
  86. package/dist/errors/ModuleErrors.js.map +1 -0
  87. package/dist/errors/PipelineStageError.d.ts +31 -0
  88. package/dist/errors/PipelineStageError.d.ts.map +1 -0
  89. package/dist/errors/PipelineStageError.js +77 -0
  90. package/dist/errors/PipelineStageError.js.map +1 -0
  91. package/dist/errors/ReamError.d.ts +50 -0
  92. package/dist/errors/ReamError.d.ts.map +1 -0
  93. package/dist/errors/ReamError.js +108 -0
  94. package/dist/errors/ReamError.js.map +1 -0
  95. package/dist/events/Emitter.d.ts +124 -0
  96. package/dist/events/Emitter.d.ts.map +1 -0
  97. package/dist/events/Emitter.js +271 -0
  98. package/dist/events/Emitter.js.map +1 -0
  99. package/dist/events/EventsProvider.d.ts +28 -0
  100. package/dist/events/EventsProvider.d.ts.map +1 -0
  101. package/dist/events/EventsProvider.js +36 -0
  102. package/dist/events/EventsProvider.js.map +1 -0
  103. package/dist/events/config.d.ts +8 -0
  104. package/dist/events/config.d.ts.map +1 -0
  105. package/dist/events/config.js +4 -0
  106. package/dist/events/config.js.map +1 -0
  107. package/dist/events/configure.d.ts +10 -0
  108. package/dist/events/configure.d.ts.map +1 -0
  109. package/dist/events/configure.js +11 -0
  110. package/dist/events/configure.js.map +1 -0
  111. package/dist/events/helix/helpers.d.ts +62 -0
  112. package/dist/events/helix/helpers.d.ts.map +1 -0
  113. package/dist/events/helix/helpers.js +187 -0
  114. package/dist/events/helix/helpers.js.map +1 -0
  115. package/dist/events/index.d.ts +17 -0
  116. package/dist/events/index.d.ts.map +1 -0
  117. package/dist/events/index.js +15 -0
  118. package/dist/events/index.js.map +1 -0
  119. package/dist/events/native.d.ts +21 -0
  120. package/dist/events/native.d.ts.map +1 -0
  121. package/dist/events/native.js +17 -0
  122. package/dist/events/native.js.map +1 -0
  123. package/dist/events/services/main.d.ts +18 -0
  124. package/dist/events/services/main.d.ts.map +1 -0
  125. package/dist/events/services/main.js +31 -0
  126. package/dist/events/services/main.js.map +1 -0
  127. package/dist/events/testing/FakeBus.d.ts +66 -0
  128. package/dist/events/testing/FakeBus.d.ts.map +1 -0
  129. package/dist/events/testing/FakeBus.js +356 -0
  130. package/dist/events/testing/FakeBus.js.map +1 -0
  131. package/dist/graphql/GraphQLEngine.d.ts +69 -0
  132. package/dist/graphql/GraphQLEngine.d.ts.map +1 -0
  133. package/dist/graphql/GraphQLEngine.js +309 -0
  134. package/dist/graphql/GraphQLEngine.js.map +1 -0
  135. package/dist/graphql/GraphQLProvider.d.ts +32 -0
  136. package/dist/graphql/GraphQLProvider.d.ts.map +1 -0
  137. package/dist/graphql/GraphQLProvider.js +49 -0
  138. package/dist/graphql/GraphQLProvider.js.map +1 -0
  139. package/dist/helpers/base64.d.ts +40 -0
  140. package/dist/helpers/base64.d.ts.map +1 -0
  141. package/dist/helpers/base64.js +70 -0
  142. package/dist/helpers/base64.js.map +1 -0
  143. package/dist/helpers/index.d.ts +7 -0
  144. package/dist/helpers/index.d.ts.map +1 -0
  145. package/dist/helpers/index.js +5 -0
  146. package/dist/helpers/index.js.map +1 -0
  147. package/dist/helpers/is.d.ts +101 -0
  148. package/dist/helpers/is.d.ts.map +1 -0
  149. package/dist/helpers/is.js +151 -0
  150. package/dist/helpers/is.js.map +1 -0
  151. package/dist/helpers/napi-loader.d.ts +46 -0
  152. package/dist/helpers/napi-loader.d.ts.map +1 -0
  153. package/dist/helpers/napi-loader.js +69 -0
  154. package/dist/helpers/napi-loader.js.map +1 -0
  155. package/dist/helpers/safeEqual.d.ts +9 -0
  156. package/dist/helpers/safeEqual.d.ts.map +1 -0
  157. package/dist/helpers/safeEqual.js +16 -0
  158. package/dist/helpers/safeEqual.js.map +1 -0
  159. package/dist/helpers/string.d.ts +161 -0
  160. package/dist/helpers/string.d.ts.map +1 -0
  161. package/dist/helpers/string.js +429 -0
  162. package/dist/helpers/string.js.map +1 -0
  163. package/dist/helpers/types.d.ts +83 -0
  164. package/dist/helpers/types.d.ts.map +1 -0
  165. package/dist/helpers/types.js +6 -0
  166. package/dist/helpers/types.js.map +1 -0
  167. package/dist/http/Exception.d.ts +103 -0
  168. package/dist/http/Exception.d.ts.map +1 -0
  169. package/dist/http/Exception.js +228 -0
  170. package/dist/http/Exception.js.map +1 -0
  171. package/dist/http/HttpContext.d.ts +69 -0
  172. package/dist/http/HttpContext.d.ts.map +1 -0
  173. package/dist/http/HttpContext.js +55 -0
  174. package/dist/http/HttpContext.js.map +1 -0
  175. package/dist/http/RedirectBuilder.d.ts +31 -0
  176. package/dist/http/RedirectBuilder.d.ts.map +1 -0
  177. package/dist/http/RedirectBuilder.js +75 -0
  178. package/dist/http/RedirectBuilder.js.map +1 -0
  179. package/dist/http/Request.d.ts +160 -0
  180. package/dist/http/Request.d.ts.map +1 -0
  181. package/dist/http/Request.js +484 -0
  182. package/dist/http/Request.js.map +1 -0
  183. package/dist/http/Response.d.ts +114 -0
  184. package/dist/http/Response.d.ts.map +1 -0
  185. package/dist/http/Response.js +303 -0
  186. package/dist/http/Response.js.map +1 -0
  187. package/dist/http/SseStream.d.ts +89 -0
  188. package/dist/http/SseStream.d.ts.map +1 -0
  189. package/dist/http/SseStream.js +228 -0
  190. package/dist/http/SseStream.js.map +1 -0
  191. package/dist/http/urlDecode.d.ts +8 -0
  192. package/dist/http/urlDecode.d.ts.map +1 -0
  193. package/dist/http/urlDecode.js +18 -0
  194. package/dist/http/urlDecode.js.map +1 -0
  195. package/dist/index.d.ts +92 -0
  196. package/dist/index.d.ts.map +1 -0
  197. package/dist/index.js +67 -0
  198. package/dist/index.js.map +1 -0
  199. package/dist/middleware/Pipeline.d.ts +36 -0
  200. package/dist/middleware/Pipeline.d.ts.map +1 -0
  201. package/dist/middleware/Pipeline.js +104 -0
  202. package/dist/middleware/Pipeline.js.map +1 -0
  203. package/dist/openapi/OpenApiGenerator.d.ts +58 -0
  204. package/dist/openapi/OpenApiGenerator.d.ts.map +1 -0
  205. package/dist/openapi/OpenApiGenerator.js +192 -0
  206. package/dist/openapi/OpenApiGenerator.js.map +1 -0
  207. package/dist/openapi/OpenApiMiddleware.d.ts +24 -0
  208. package/dist/openapi/OpenApiMiddleware.d.ts.map +1 -0
  209. package/dist/openapi/OpenApiMiddleware.js +78 -0
  210. package/dist/openapi/OpenApiMiddleware.js.map +1 -0
  211. package/dist/openapi/OpenApiProvider.d.ts +36 -0
  212. package/dist/openapi/OpenApiProvider.d.ts.map +1 -0
  213. package/dist/openapi/OpenApiProvider.js +42 -0
  214. package/dist/openapi/OpenApiProvider.js.map +1 -0
  215. package/dist/resources/ApiResource.d.ts +45 -0
  216. package/dist/resources/ApiResource.d.ts.map +1 -0
  217. package/dist/resources/ApiResource.js +58 -0
  218. package/dist/resources/ApiResource.js.map +1 -0
  219. package/dist/router/Router.d.ts +205 -0
  220. package/dist/router/Router.d.ts.map +1 -0
  221. package/dist/router/Router.js +552 -0
  222. package/dist/router/Router.js.map +1 -0
  223. package/dist/rpc/RpcProvider.d.ts +34 -0
  224. package/dist/rpc/RpcProvider.d.ts.map +1 -0
  225. package/dist/rpc/RpcProvider.js +37 -0
  226. package/dist/rpc/RpcProvider.js.map +1 -0
  227. package/dist/rpc/RpcRouter.d.ts +61 -0
  228. package/dist/rpc/RpcRouter.d.ts.map +1 -0
  229. package/dist/rpc/RpcRouter.js +187 -0
  230. package/dist/rpc/RpcRouter.js.map +1 -0
  231. package/dist/scheduler/Schedule.d.ts +53 -0
  232. package/dist/scheduler/Schedule.d.ts.map +1 -0
  233. package/dist/scheduler/Schedule.js +76 -0
  234. package/dist/scheduler/Schedule.js.map +1 -0
  235. package/dist/scheduler/ScheduleProvider.d.ts +56 -0
  236. package/dist/scheduler/ScheduleProvider.d.ts.map +1 -0
  237. package/dist/scheduler/ScheduleProvider.js +145 -0
  238. package/dist/scheduler/ScheduleProvider.js.map +1 -0
  239. package/dist/scheduler/Scheduler.d.ts +209 -0
  240. package/dist/scheduler/Scheduler.d.ts.map +1 -0
  241. package/dist/scheduler/Scheduler.js +432 -0
  242. package/dist/scheduler/Scheduler.js.map +1 -0
  243. package/dist/scheduler/index.d.ts +14 -0
  244. package/dist/scheduler/index.d.ts.map +1 -0
  245. package/dist/scheduler/index.js +6 -0
  246. package/dist/scheduler/index.js.map +1 -0
  247. package/dist/scheduler/locks/LockBackend.d.ts +37 -0
  248. package/dist/scheduler/locks/LockBackend.d.ts.map +1 -0
  249. package/dist/scheduler/locks/LockBackend.js +13 -0
  250. package/dist/scheduler/locks/LockBackend.js.map +1 -0
  251. package/dist/scheduler/locks/MemoryLockBackend.d.ts +39 -0
  252. package/dist/scheduler/locks/MemoryLockBackend.d.ts.map +1 -0
  253. package/dist/scheduler/locks/MemoryLockBackend.js +71 -0
  254. package/dist/scheduler/locks/MemoryLockBackend.js.map +1 -0
  255. package/dist/scheduler/observability/ErrorReporter.d.ts +15 -0
  256. package/dist/scheduler/observability/ErrorReporter.d.ts.map +1 -0
  257. package/dist/scheduler/observability/ErrorReporter.js +13 -0
  258. package/dist/scheduler/observability/ErrorReporter.js.map +1 -0
  259. package/dist/scheduler/observability/ScheduleEvent.d.ts +57 -0
  260. package/dist/scheduler/observability/ScheduleEvent.d.ts.map +1 -0
  261. package/dist/scheduler/observability/ScheduleEvent.js +12 -0
  262. package/dist/scheduler/observability/ScheduleEvent.js.map +1 -0
  263. package/dist/scheduler/observability/ScheduleEventSink.d.ts +20 -0
  264. package/dist/scheduler/observability/ScheduleEventSink.d.ts.map +1 -0
  265. package/dist/scheduler/observability/ScheduleEventSink.js +17 -0
  266. package/dist/scheduler/observability/ScheduleEventSink.js.map +1 -0
  267. package/dist/scheduler/observability/StatsTracker.d.ts +50 -0
  268. package/dist/scheduler/observability/StatsTracker.d.ts.map +1 -0
  269. package/dist/scheduler/observability/StatsTracker.js +96 -0
  270. package/dist/scheduler/observability/StatsTracker.js.map +1 -0
  271. package/dist/security/CookieSigner.d.ts +13 -0
  272. package/dist/security/CookieSigner.d.ts.map +1 -0
  273. package/dist/security/CookieSigner.js +51 -0
  274. package/dist/security/CookieSigner.js.map +1 -0
  275. package/dist/security/SignedUrl.d.ts +17 -0
  276. package/dist/security/SignedUrl.d.ts.map +1 -0
  277. package/dist/security/SignedUrl.js +63 -0
  278. package/dist/security/SignedUrl.js.map +1 -0
  279. package/dist/security/crypto.d.ts +25 -0
  280. package/dist/security/crypto.d.ts.map +1 -0
  281. package/dist/security/crypto.js +82 -0
  282. package/dist/security/crypto.js.map +1 -0
  283. package/dist/server/HyperServer.d.ts +64 -0
  284. package/dist/server/HyperServer.d.ts.map +1 -0
  285. package/dist/server/HyperServer.js +54 -0
  286. package/dist/server/HyperServer.js.map +1 -0
  287. package/dist/server/Server.d.ts +68 -0
  288. package/dist/server/Server.d.ts.map +1 -0
  289. package/dist/server/Server.js +113 -0
  290. package/dist/server/Server.js.map +1 -0
  291. package/dist/services/app.d.ts +14 -0
  292. package/dist/services/app.d.ts.map +1 -0
  293. package/dist/services/app.js +27 -0
  294. package/dist/services/app.js.map +1 -0
  295. package/dist/services/router.d.ts +21 -0
  296. package/dist/services/router.d.ts.map +1 -0
  297. package/dist/services/router.js +36 -0
  298. package/dist/services/router.js.map +1 -0
  299. package/dist/services/server.d.ts +16 -0
  300. package/dist/services/server.d.ts.map +1 -0
  301. package/dist/services/server.js +32 -0
  302. package/dist/services/server.js.map +1 -0
  303. package/dist/session/Session.d.ts +88 -0
  304. package/dist/session/Session.d.ts.map +1 -0
  305. package/dist/session/Session.js +186 -0
  306. package/dist/session/Session.js.map +1 -0
  307. package/dist/session/SessionMiddleware.d.ts +16 -0
  308. package/dist/session/SessionMiddleware.d.ts.map +1 -0
  309. package/dist/session/SessionMiddleware.js +132 -0
  310. package/dist/session/SessionMiddleware.js.map +1 -0
  311. package/dist/session/drivers/CookieDriver.d.ts +17 -0
  312. package/dist/session/drivers/CookieDriver.d.ts.map +1 -0
  313. package/dist/session/drivers/CookieDriver.js +42 -0
  314. package/dist/session/drivers/CookieDriver.js.map +1 -0
  315. package/dist/session/drivers/MemoryDriver.d.ts +9 -0
  316. package/dist/session/drivers/MemoryDriver.d.ts.map +1 -0
  317. package/dist/session/drivers/MemoryDriver.js +24 -0
  318. package/dist/session/drivers/MemoryDriver.js.map +1 -0
  319. package/dist/storage/S3Driver.d.ts +27 -0
  320. package/dist/storage/S3Driver.d.ts.map +1 -0
  321. package/dist/storage/S3Driver.js +135 -0
  322. package/dist/storage/S3Driver.js.map +1 -0
  323. package/dist/storage/StaticMiddleware.d.ts +27 -0
  324. package/dist/storage/StaticMiddleware.d.ts.map +1 -0
  325. package/dist/storage/StaticMiddleware.js +153 -0
  326. package/dist/storage/StaticMiddleware.js.map +1 -0
  327. package/dist/storage/StaticProvider.d.ts +26 -0
  328. package/dist/storage/StaticProvider.d.ts.map +1 -0
  329. package/dist/storage/StaticProvider.js +31 -0
  330. package/dist/storage/StaticProvider.js.map +1 -0
  331. package/dist/storage/StorageManager.d.ts +31 -0
  332. package/dist/storage/StorageManager.d.ts.map +1 -0
  333. package/dist/storage/StorageManager.js +120 -0
  334. package/dist/storage/StorageManager.js.map +1 -0
  335. package/dist/testing/RequestBuilder.d.ts +67 -0
  336. package/dist/testing/RequestBuilder.d.ts.map +1 -0
  337. package/dist/testing/RequestBuilder.js +202 -0
  338. package/dist/testing/RequestBuilder.js.map +1 -0
  339. package/dist/testing/TestClient.d.ts +96 -0
  340. package/dist/testing/TestClient.d.ts.map +1 -0
  341. package/dist/testing/TestClient.js +263 -0
  342. package/dist/testing/TestClient.js.map +1 -0
  343. package/dist/types/helpers.d.ts +47 -0
  344. package/dist/types/helpers.d.ts.map +1 -0
  345. package/dist/types/helpers.js +5 -0
  346. package/dist/types/helpers.js.map +1 -0
  347. package/events.darwin-arm64.node +0 -0
  348. package/events.darwin-x64.node +0 -0
  349. package/events.linux-arm64-gnu.node +0 -0
  350. package/events.linux-x64-gnu.node +0 -0
  351. package/events.win32-x64-msvc.node +0 -0
  352. package/index.darwin-arm64.node +0 -0
  353. package/index.darwin-x64.node +0 -0
  354. package/index.linux-arm64-gnu.node +0 -0
  355. package/index.linux-x64-gnu.node +0 -0
  356. package/index.win32-x64-msvc.node +0 -0
  357. package/package.json +106 -0
  358. package/scheduler.darwin-arm64.node +0 -0
  359. package/scheduler.darwin-x64.node +0 -0
  360. package/scheduler.linux-arm64-gnu.node +0 -0
  361. package/scheduler.linux-x64-gnu.node +0 -0
  362. package/scheduler.win32-x64-msvc.node +0 -0
  363. package/scripts/copy-napi.mjs +113 -0
  364. package/src/Application.ts +177 -0
  365. package/src/Codemods.ts +343 -0
  366. package/src/ConfigLoader.ts +49 -0
  367. package/src/ErrorBoundary.ts +157 -0
  368. package/src/GracefulShutdown.ts +80 -0
  369. package/src/HealthCheck.ts +96 -0
  370. package/src/HotReload.ts +78 -0
  371. package/src/HttpKernel.ts +305 -0
  372. package/src/Ignitor.ts +656 -0
  373. package/src/Provider.ts +74 -0
  374. package/src/bodyparser/BodyParserMiddleware.ts +183 -0
  375. package/src/bodyparser/MultipartFile.ts +181 -0
  376. package/src/bodyparser/parseSize.ts +19 -0
  377. package/src/bootstrap/hyper-server.ts +78 -0
  378. package/src/console/CommandRunner.ts +82 -0
  379. package/src/container/Container.ts +383 -0
  380. package/src/container/types.ts +30 -0
  381. package/src/decorators/Lazy.ts +57 -0
  382. package/src/decorators/Service.ts +85 -0
  383. package/src/errors/FuzzyMatcher.ts +93 -0
  384. package/src/errors/ModuleErrors.ts +73 -0
  385. package/src/errors/PipelineStageError.ts +97 -0
  386. package/src/errors/ReamError.ts +138 -0
  387. package/src/events/Emitter.ts +333 -0
  388. package/src/events/EventsProvider.ts +58 -0
  389. package/src/events/config.ts +10 -0
  390. package/src/events/configure.ts +19 -0
  391. package/src/events/helix/helpers.ts +260 -0
  392. package/src/events/index.ts +22 -0
  393. package/src/events/native.ts +37 -0
  394. package/src/events/services/main.ts +39 -0
  395. package/src/events/testing/FakeBus.ts +420 -0
  396. package/src/graphql/GraphQLEngine.ts +421 -0
  397. package/src/graphql/GraphQLProvider.ts +59 -0
  398. package/src/helpers/base64.ts +72 -0
  399. package/src/helpers/index.ts +6 -0
  400. package/src/helpers/is.ts +162 -0
  401. package/src/helpers/napi-loader.ts +106 -0
  402. package/src/helpers/safeEqual.ts +15 -0
  403. package/src/helpers/string.ts +469 -0
  404. package/src/helpers/types.ts +100 -0
  405. package/src/http/Exception.ts +272 -0
  406. package/src/http/HttpContext.ts +108 -0
  407. package/src/http/RedirectBuilder.ts +89 -0
  408. package/src/http/Request.ts +540 -0
  409. package/src/http/Response.ts +351 -0
  410. package/src/http/SseStream.ts +250 -0
  411. package/src/http/urlDecode.ts +18 -0
  412. package/src/index.ts +263 -0
  413. package/src/middleware/Pipeline.ts +136 -0
  414. package/src/openapi/OpenApiGenerator.ts +254 -0
  415. package/src/openapi/OpenApiMiddleware.ts +101 -0
  416. package/src/openapi/OpenApiProvider.ts +67 -0
  417. package/src/resources/ApiResource.ts +79 -0
  418. package/src/router/Router.ts +733 -0
  419. package/src/rpc/RpcProvider.ts +54 -0
  420. package/src/rpc/RpcRouter.ts +243 -0
  421. package/src/scheduler/Schedule.ts +96 -0
  422. package/src/scheduler/ScheduleProvider.ts +177 -0
  423. package/src/scheduler/Scheduler.ts +601 -0
  424. package/src/scheduler/index.ts +24 -0
  425. package/src/scheduler/locks/LockBackend.ts +38 -0
  426. package/src/scheduler/locks/MemoryLockBackend.ts +85 -0
  427. package/src/scheduler/observability/ErrorReporter.ts +13 -0
  428. package/src/scheduler/observability/ScheduleEvent.ts +61 -0
  429. package/src/scheduler/observability/ScheduleEventSink.ts +21 -0
  430. package/src/scheduler/observability/StatsTracker.ts +134 -0
  431. package/src/security/CookieSigner.ts +54 -0
  432. package/src/security/SignedUrl.ts +71 -0
  433. package/src/security/crypto.ts +98 -0
  434. package/src/server/HyperServer.ts +121 -0
  435. package/src/server/Server.ts +147 -0
  436. package/src/services/app.ts +34 -0
  437. package/src/services/router.ts +44 -0
  438. package/src/services/server.ts +40 -0
  439. package/src/session/Session.ts +231 -0
  440. package/src/session/SessionMiddleware.ts +153 -0
  441. package/src/session/drivers/CookieDriver.ts +48 -0
  442. package/src/session/drivers/MemoryDriver.ts +29 -0
  443. package/src/storage/S3Driver.ts +171 -0
  444. package/src/storage/StaticMiddleware.ts +182 -0
  445. package/src/storage/StaticProvider.ts +40 -0
  446. package/src/storage/StorageManager.ts +142 -0
  447. package/src/testing/RequestBuilder.ts +275 -0
  448. package/src/testing/TestClient.ts +344 -0
  449. package/src/types/helpers.ts +52 -0
  450. package/swcrc.app.json +17 -0
  451. package/tsconfig.app.json +21 -0
@@ -0,0 +1,228 @@
1
+ /**
2
+ * Exception system — AdonisJS-compatible exception handling.
3
+ *
4
+ * - Exception: base class with self-handling support
5
+ * - ExceptionHandler: global exception handler with content negotiation
6
+ * - Built-in E_* exceptions
7
+ */
8
+ /**
9
+ * Base exception class. Extend this to create self-handling exceptions.
10
+ *
11
+ * Usage:
12
+ * throw new Exception('Something went wrong', { status: 400, code: 'E_BAD_REQUEST' })
13
+ *
14
+ * Self-handled exception:
15
+ * class PaymentFailed extends Exception {
16
+ * static status = 402
17
+ * static code = 'E_PAYMENT_FAILED'
18
+ * async handle(error: this, ctx: HttpContext) {
19
+ * ctx.response.status(402).json({ error: 'Payment failed' })
20
+ * }
21
+ * async report(error: this, ctx: HttpContext) {
22
+ * logger.error('Payment failed', { userId: ctx.auth.user?.id })
23
+ * }
24
+ * }
25
+ */
26
+ export class Exception extends Error {
27
+ static status = 500;
28
+ static code = 'E_UNKNOWN';
29
+ status;
30
+ code;
31
+ constructor(message, options) {
32
+ super(message);
33
+ this.name = this.constructor.name;
34
+ // biome-ignore lint/suspicious/noExplicitAny: this.constructor is typed as Function; subclass pattern requires the cast
35
+ const ctor = this.constructor;
36
+ this.status = options?.status ?? ctor.status;
37
+ this.code = options?.code ?? ctor.code;
38
+ }
39
+ }
40
+ // ─── Built-in exceptions ──────────────────────────────────
41
+ export class E_ROUTE_NOT_FOUND extends Exception {
42
+ static status = 404;
43
+ static code = 'E_ROUTE_NOT_FOUND';
44
+ constructor(method, path) {
45
+ super(`Route not found: ${method} ${path}`, { status: 404, code: 'E_ROUTE_NOT_FOUND' });
46
+ }
47
+ }
48
+ export class E_UNAUTHORIZED extends Exception {
49
+ static status = 401;
50
+ static code = 'E_UNAUTHORIZED';
51
+ constructor(message = 'Authentication required') {
52
+ super(message, { status: 401, code: 'E_UNAUTHORIZED' });
53
+ }
54
+ handle(_error, ctx) {
55
+ ctx.response.status(401).json({ error: { code: 'E_UNAUTHORIZED', message: this.message } });
56
+ }
57
+ }
58
+ export class E_FORBIDDEN extends Exception {
59
+ static status = 403;
60
+ static code = 'E_FORBIDDEN';
61
+ required;
62
+ constructor(message = 'Insufficient permissions', required) {
63
+ super(message, { status: 403, code: 'E_FORBIDDEN' });
64
+ this.required = required;
65
+ }
66
+ handle(_error, ctx) {
67
+ ctx.response.status(403).json({
68
+ error: {
69
+ code: 'E_FORBIDDEN',
70
+ message: this.message,
71
+ ...(this.required ? { required: this.required } : {}),
72
+ },
73
+ });
74
+ }
75
+ }
76
+ export class E_VALIDATION_ERROR extends Exception {
77
+ static status = 422;
78
+ static code = 'E_VALIDATION_ERROR';
79
+ errors;
80
+ constructor(errors) {
81
+ super('Validation failed', { status: 422, code: 'E_VALIDATION_ERROR' });
82
+ this.errors = errors;
83
+ }
84
+ handle(_error, ctx) {
85
+ ctx.response.status(422).json({ errors: this.errors });
86
+ }
87
+ }
88
+ export class E_ROW_NOT_FOUND extends Exception {
89
+ static status = 404;
90
+ static code = 'E_ROW_NOT_FOUND';
91
+ constructor(model) {
92
+ super(model ? `${model} not found` : 'Resource not found', {
93
+ status: 404,
94
+ code: 'E_ROW_NOT_FOUND',
95
+ });
96
+ }
97
+ handle(_error, ctx) {
98
+ ctx.response.status(404).json({ error: { code: 'E_ROW_NOT_FOUND', message: this.message } });
99
+ }
100
+ }
101
+ export class E_HTTP_EXCEPTION extends Exception {
102
+ constructor(message, status) {
103
+ super(message, { status, code: 'E_HTTP_EXCEPTION' });
104
+ }
105
+ }
106
+ // ─── ExceptionHandler ─────────────────────────────────────
107
+ /**
108
+ * Global exception handler — catches all unhandled exceptions and converts
109
+ * them to HTTP responses.
110
+ *
111
+ * Extend this in your app:
112
+ * export default class Handler extends ExceptionHandler {
113
+ * protected debug = app.inDev
114
+ * protected ignoreStatuses = [400, 401, 404, 422]
115
+ * }
116
+ *
117
+ * Flow:
118
+ * 1. If exception has handle() → self-handled (bypass global)
119
+ * 2. Else → this.handle() → content negotiation (JSON or HTML)
120
+ * 3. Then → this.report() → logging/monitoring
121
+ */
122
+ export class ExceptionHandler {
123
+ debug;
124
+ ignoreStatuses = [400, 401, 404, 422];
125
+ ignoreCodes = [];
126
+ constructor(debug = false) {
127
+ this.debug = debug;
128
+ }
129
+ /** Convert an exception to an HTTP response. */
130
+ async handle(error, ctx) {
131
+ // Self-handled exceptions take over entirely.
132
+ if (error instanceof Exception && typeof error.handle === 'function') {
133
+ await error.handle(error, ctx);
134
+ return;
135
+ }
136
+ const { status, code } = extractErrorMeta(error);
137
+ const message = this.#errorMessage(error);
138
+ if (wantsJson(ctx)) {
139
+ this.#sendJsonError(ctx, status, code, message, error);
140
+ }
141
+ else {
142
+ this.#sendHtmlError(ctx, status, message);
143
+ }
144
+ }
145
+ /** Pick the user-facing message — full detail only in debug mode. */
146
+ #errorMessage(error) {
147
+ if (this.debug && error instanceof Error)
148
+ return error.message;
149
+ if (error instanceof Exception)
150
+ return error.message;
151
+ return 'An internal error occurred';
152
+ }
153
+ #sendJsonError(ctx, status, code, message, error) {
154
+ const errorPayload = { code, message };
155
+ if (this.debug && error instanceof Error && error.stack) {
156
+ errorPayload.stack = error.stack;
157
+ }
158
+ ctx.response.status(status).json({ error: errorPayload });
159
+ }
160
+ #sendHtmlError(ctx, status, message) {
161
+ ctx.response
162
+ .status(status)
163
+ .type('text/html; charset=utf-8')
164
+ .send(`<!DOCTYPE html><html><head><title>Error ${status}</title></head>` +
165
+ `<body><h1>${status}</h1><p>${escapeHtml(message)}</p></body></html>`);
166
+ }
167
+ /** Log/report an exception. Override for custom monitoring. */
168
+ async report(error, ctx) {
169
+ if (error instanceof Exception) {
170
+ if (this.ignoreStatuses.includes(error.status))
171
+ return;
172
+ if (this.ignoreCodes.includes(error.code))
173
+ return;
174
+ }
175
+ // Self-reported exceptions
176
+ if (error instanceof Exception && typeof error.report === 'function') {
177
+ await error.report(error, ctx);
178
+ return;
179
+ }
180
+ // Default: log to stderr
181
+ const context = this.context(ctx);
182
+ if (error instanceof Error) {
183
+ console.error(`[${new Date().toISOString()}] ${error.message}`, context, error.stack);
184
+ }
185
+ else {
186
+ console.error(`[${new Date().toISOString()}] Unknown error:`, error, context);
187
+ }
188
+ }
189
+ /** Provide additional context for error reports. Override for custom data. */
190
+ context(ctx) {
191
+ return {
192
+ requestId: ctx.id,
193
+ method: ctx.request.method(),
194
+ url: ctx.request.url(),
195
+ userId: ctx.auth.user?.id,
196
+ };
197
+ }
198
+ }
199
+ /** Extract status + code from an Exception, ReamError, or duck-typed error. */
200
+ function extractErrorMeta(error) {
201
+ let status = 500;
202
+ let code = 'E_UNKNOWN';
203
+ if (error instanceof Exception) {
204
+ status = error.status;
205
+ code = error.code;
206
+ }
207
+ else if (error !== null && typeof error === 'object') {
208
+ if ('status' in error && typeof error.status === 'number')
209
+ status = error.status;
210
+ if ('code' in error && typeof error.code === 'string')
211
+ code = error.code;
212
+ }
213
+ return { status, code };
214
+ }
215
+ /** Content negotiation: JSON unless the client explicitly prefers HTML. */
216
+ function wantsJson(ctx) {
217
+ return (ctx.request.accepts(['json', 'html']) === 'json' ||
218
+ (ctx.request.header('accept')?.includes('application/json') ?? false) ||
219
+ !ctx.request.header('accept')?.includes('text/html'));
220
+ }
221
+ function escapeHtml(str) {
222
+ return str
223
+ .replace(/&/g, '&amp;')
224
+ .replace(/</g, '&lt;')
225
+ .replace(/>/g, '&gt;')
226
+ .replace(/"/g, '&quot;');
227
+ }
228
+ //# sourceMappingURL=Exception.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Exception.js","sourceRoot":"","sources":["../../src/http/Exception.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,SAAU,SAAQ,KAAK;IAClC,MAAM,CAAC,MAAM,GAAG,GAAG,CAAA;IACnB,MAAM,CAAC,IAAI,GAAG,WAAW,CAAA;IAEzB,MAAM,CAAQ;IACd,IAAI,CAAQ;IAEZ,YAAY,OAAe,EAAE,OAA4C;QACvE,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAA;QACjC,wHAAwH;QACxH,MAAM,IAAI,GAAG,IAAI,CAAC,WAAsC,CAAA;QACxD,IAAI,CAAC,MAAM,GAAG,OAAO,EAAE,MAAM,IAAI,IAAI,CAAC,MAAM,CAAA;QAC5C,IAAI,CAAC,IAAI,GAAG,OAAO,EAAE,IAAI,IAAI,IAAI,CAAC,IAAI,CAAA;IACxC,CAAC;;AASH,6DAA6D;AAE7D,MAAM,OAAO,iBAAkB,SAAQ,SAAS;IAC9C,MAAM,CAAU,MAAM,GAAG,GAAG,CAAA;IAC5B,MAAM,CAAU,IAAI,GAAG,mBAAmB,CAAA;IAE1C,YAAY,MAAc,EAAE,IAAY;QACtC,KAAK,CAAC,oBAAoB,MAAM,IAAI,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,mBAAmB,EAAE,CAAC,CAAA;IACzF,CAAC;;AAGH,MAAM,OAAO,cAAe,SAAQ,SAAS;IAC3C,MAAM,CAAU,MAAM,GAAG,GAAG,CAAA;IAC5B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,CAAC,CAAC,KAAK,MAAM;QAChD,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,kBAAkB,CAAC,IAAI,KAAK,CAAC;QACrE,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,CACrD,CAAA;AACH,CAAC;AAED,SAAS,UAAU,CAAC,GAAW;IAC7B,OAAO,GAAG;SACP,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;AAC5B,CAAC"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * HttpContext — fully typed HTTP context for handlers, middleware, and controllers.
3
+ *
4
+ * Replaces Context.http() for HTTP transport. Always has request + response (no ! assertions).
5
+ * Compatible with AdonisJS destructuring: { request, response, auth, params }
6
+ *
7
+ * @implements FR21
8
+ */
9
+ import type { Emitter } from '../events/Emitter.js';
10
+ import type { RouteUrlResolver } from './RedirectBuilder.js';
11
+ import type { RawRequest } from './Request.js';
12
+ import { Request } from './Request.js';
13
+ import { Response } from './Response.js';
14
+ export interface AuthState {
15
+ authenticated: boolean;
16
+ user?: {
17
+ id: string;
18
+ email?: string;
19
+ roles?: string[];
20
+ permissions?: string[];
21
+ [key: string]: unknown;
22
+ };
23
+ roles?: string[];
24
+ permissions?: string[];
25
+ }
26
+ export interface RouteInfo {
27
+ pattern: string;
28
+ name?: string;
29
+ middleware: string[];
30
+ /**
31
+ * Controller class + method that owns this route, when the route was
32
+ * registered as `router.get('/x', SomeController, 'method')` (vs an
33
+ * inline arrow handler). Middleware that reads decorator metadata —
34
+ * `@Guard`, `@Permission`, `@Role` (Warden), `@Meta` (Photon) —
35
+ * needs both fields. Absent when the route handler is an inline
36
+ * function. Populated by `HttpKernel` from `match.route.controller`.
37
+ */
38
+ controller?: object;
39
+ action?: string;
40
+ }
41
+ export declare class HttpContext {
42
+ #private;
43
+ /** Unique request/correlation ID. */
44
+ readonly id: string;
45
+ /** Typed HTTP request. */
46
+ readonly request: Request;
47
+ /** Typed HTTP response builder. */
48
+ readonly response: Response;
49
+ /** Route parameters extracted from the URL pattern. */
50
+ readonly params: Record<string, string>;
51
+ /** Information about the matched route. */
52
+ readonly route: RouteInfo;
53
+ /** Authentication state — populated by auth middleware. */
54
+ auth: AuthState;
55
+ /** Detected locale. */
56
+ locale: string;
57
+ /** Per-request key-value store (for middleware to pass data downstream). */
58
+ readonly store: Map<string, unknown>;
59
+ /**
60
+ * The event bus emitter, when the app registered `EventsProvider`. Lets a
61
+ * handler emit/subscribe without resolving from the container:
62
+ * `ctx.events?.emit('user:updated', user)`. Undefined when events aren't wired.
63
+ */
64
+ events?: Emitter;
65
+ constructor(id: string, rawRequest: RawRequest, params: Record<string, string>, route: RouteInfo);
66
+ /** @internal Set the route URL resolver (injected by HttpKernel from Router). */
67
+ setRouteUrlResolver(resolver: RouteUrlResolver): void;
68
+ }
69
+ //# sourceMappingURL=HttpContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HttpContext.d.ts","sourceRoot":"","sources":["../../src/http/HttpContext.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAE5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,MAAM,WAAW,SAAS;IACxB,aAAa,EAAE,OAAO,CAAA;IACtB,IAAI,CAAC,EAAE;QACL,EAAE,EAAE,MAAM,CAAA;QACV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BAAgB,GAAG,IAAI;CAGtD"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * HttpContext — fully typed HTTP context for handlers, middleware, and controllers.
3
+ *
4
+ * Replaces Context.http() for HTTP transport. Always has request + response (no ! assertions).
5
+ * Compatible with AdonisJS destructuring: { request, response, auth, params }
6
+ *
7
+ * @implements FR21
8
+ */
9
+ import { RedirectBuilder } from './RedirectBuilder.js';
10
+ import { Request } from './Request.js';
11
+ import { Response } from './Response.js';
12
+ export class HttpContext {
13
+ /** Unique request/correlation ID. */
14
+ id;
15
+ /** Typed HTTP request. */
16
+ request;
17
+ /** Typed HTTP response builder. */
18
+ response;
19
+ /** Route parameters extracted from the URL pattern. */
20
+ params;
21
+ /** Information about the matched route. */
22
+ route;
23
+ /** Authentication state — populated by auth middleware. */
24
+ auth = { authenticated: false };
25
+ /** Detected locale. */
26
+ locale = 'en';
27
+ /** Per-request key-value store (for middleware to pass data downstream). */
28
+ store = new Map();
29
+ /**
30
+ * The event bus emitter, when the app registered `EventsProvider`. Lets a
31
+ * handler emit/subscribe without resolving from the container:
32
+ * `ctx.events?.emit('user:updated', user)`. Undefined when events aren't wired.
33
+ */
34
+ events;
35
+ /** Route URL resolver for redirect().toRoute(). */
36
+ #routeUrlResolver;
37
+ constructor(id, rawRequest, params, route) {
38
+ this.id = id;
39
+ this.params = params;
40
+ this.route = route;
41
+ this.request = new Request(rawRequest, params);
42
+ this.response = new Response();
43
+ // Wire redirect builder with request context
44
+ this.response.setRedirectFactory(() => new RedirectBuilder(this.response, {
45
+ requestUrl: this.request.url(),
46
+ requestReferer: this.request.header('referer'),
47
+ routeUrlResolver: this.#routeUrlResolver,
48
+ }));
49
+ }
50
+ /** @internal Set the route URL resolver (injected by HttpKernel from Router). */
51
+ setRouteUrlResolver(resolver) {
52
+ this.#routeUrlResolver = resolver;
53
+ }
54
+ }
55
+ //# sourceMappingURL=HttpContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HttpContext.js","sourceRoot":"","s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,EAAE,IAAI,CAAC,iBAAiB;SACzC,CAAC,CACL,CAAA;IACH,CAAC;IAED,iFAAiF;IACjF,mBAAmB,CAAC,QAA0B;QAC5C,IAAI,CAAC,iBAAiB,GAAG,QAAQ,CAAA;IACnC,CAAC;CACF"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * RedirectBuilder — fluent API for building redirect responses.
3
+ *
4
+ * Usage:
5
+ * response.redirect().toPath('/login')
6
+ * response.redirect().status(301).toPath('/new-url')
7
+ * response.redirect().back()
8
+ * response.redirect().withQs({ page: '2' }).toPath('/results')
9
+ * response.redirect().toRoute('posts.show', { id: '42' })
10
+ */
11
+ import type { Response } from './Response.js';
12
+ export type RouteUrlResolver = (name: string, params?: Record<string, string>) => string;
13
+ export declare class RedirectBuilder {
14
+ #private;
15
+ constructor(response: Response, options?: {
16
+ requestUrl?: string;
17
+ requestReferer?: string;
18
+ routeUrlResolver?: RouteUrlResolver;
19
+ });
20
+ /** Set redirect status code. */
21
+ status(code: number): this;
22
+ /** Forward current query string to the redirect target. */
23
+ withQs(qs?: Record<string, string>): this;
24
+ /** Redirect to an absolute or relative path. */
25
+ toPath(path: string): void;
26
+ /** Redirect to a named route. */
27
+ toRoute(name: string, params?: Record<string, string>): void;
28
+ /** Redirect back to the previous page (Referer header). */
29
+ back(fallback?: string): void;
30
+ }
31
+ //# sourceMappingURL=RedirectBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RedirectBuilder.d.ts","sourceRoot":"","sources":["../../src/http/RedirectBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAE7C,MAAM,MAAM,gBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,MAAM,CAAA;AAExF,qBAAa,eAAe;;gBAUxB,QAAQ,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE;QACR,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,cAAc,CAAC,EAAE,MAAM,CAAA;QACvB,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;KACpC;IAQH,gCAAgC;IAChC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAK1B,2DAA2D;IAC3D,MAAM,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IASzC,gDAAgD;IAChD,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAO1B,iCAAiC;IACjC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAQ5D,2DAA2D;IAC3D,IAAI,CAAC,QAAQ,SAAM,GAAG,IAAI;CAgB3B"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * RedirectBuilder — fluent API for building redirect responses.
3
+ *
4
+ * Usage:
5
+ * response.redirect().toPath('/login')
6
+ * response.redirect().status(301).toPath('/new-url')
7
+ * response.redirect().back()
8
+ * response.redirect().withQs({ page: '2' }).toPath('/results')
9
+ * response.redirect().toRoute('posts.show', { id: '42' })
10
+ */
11
+ export class RedirectBuilder {
12
+ #response;
13
+ #status = 302;
14
+ #qs = null;
15
+ #forwardQs = false;
16
+ #requestUrl;
17
+ #requestReferer;
18
+ #routeUrlResolver;
19
+ constructor(response, options) {
20
+ this.#response = response;
21
+ this.#requestUrl = options?.requestUrl;
22
+ this.#requestReferer = options?.requestReferer;
23
+ this.#routeUrlResolver = options?.routeUrlResolver;
24
+ }
25
+ /** Set redirect status code. */
26
+ status(code) {
27
+ this.#status = code;
28
+ return this;
29
+ }
30
+ /** Forward current query string to the redirect target. */
31
+ withQs(qs) {
32
+ if (qs) {
33
+ this.#qs = qs;
34
+ }
35
+ else {
36
+ this.#forwardQs = true;
37
+ }
38
+ return this;
39
+ }
40
+ /** Redirect to an absolute or relative path. */
41
+ toPath(path) {
42
+ const url = this.#appendQs(path);
43
+ this.#response.status(this.#status);
44
+ this.#response.header('location', url);
45
+ this.#response.setBody('');
46
+ }
47
+ /** Redirect to a named route. */
48
+ toRoute(name, params) {
49
+ if (!this.#routeUrlResolver) {
50
+ throw new Error('Route URL resolver not configured. Cannot redirect to named route.');
51
+ }
52
+ const path = this.#routeUrlResolver(name, params);
53
+ this.toPath(path);
54
+ }
55
+ /** Redirect back to the previous page (Referer header). */
56
+ back(fallback = '/') {
57
+ const referer = this.#requestReferer ?? fallback;
58
+ this.toPath(referer);
59
+ }
60
+ #appendQs(path) {
61
+ let qs = '';
62
+ if (this.#qs) {
63
+ qs = new URLSearchParams(this.#qs).toString();
64
+ }
65
+ else if (this.#forwardQs && this.#requestUrl) {
66
+ const qsIdx = this.#requestUrl.indexOf('?');
67
+ if (qsIdx !== -1)
68
+ qs = this.#requestUrl.slice(qsIdx + 1);
69
+ }
70
+ if (!qs)
71
+ return path;
72
+ return path.includes('?') ? `${path}&${qs}` : `${path}?${qs}`;
73
+ }
74
+ }
75
+ //# sourceMappingURL=RedirectBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RedirectBuilder.js","sourceRoot":"","sources":["../../src/http/RedirectBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,MAAM,OAAO,eAAe;IAC1B,SAAS,CAAU;IACnB,OAAO,GAAG,GAAG,CAAA;IACb,GAAG,GAAkC,IAAI,CAAA;IACzC,UAAU,GAAG,KAAK,CAAA;IAClB,WAAW,CAAS;IACpB,eAAe,CAAS;IACxB,iBAAiB,CAAmB;IAEpC,YACE,QAAkB,EAClB,OAIC;QAED,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAA;QACzB,IAAI,CAAC,WAAW,GAAG,OAAO,EAAE,UAAU,CAAA;QACtC,IAAI,CAAC,eAAe,GAAG,OAAO,EAAE,cAAc,CAAA;QAC9C,IAAI,CAAC,iBA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AE,CAAA;QACX,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;YACb,EAAE,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAA;QAC/C,CAAC;aAAM,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YAC/C,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;YAC3C,IAAI,KAAK,KAAK,CAAC,CAAC;gBAAE,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAA;QAC1D,CAAC;QACD,IAAI,CAAC,EAAE;YAAE,OAAO,IAAI,CAAA;QACpB,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,EAAE,EAAE,CAAA;IAC/D,CAAC;CACF"}
@@ -0,0 +1,160 @@
1
+ /**
2
+ * Request — wraps raw HTTP request data from the NAPI layer.
3
+ *
4
+ * Provides a fluent, AdonisJS-compatible API for reading request data.
5
+ * JSON body parsing is lazy — deferred until first access via input()/all()/body().
6
+ *
7
+ * @implements FR21
8
+ */
9
+ import type { Dict } from '../types/helpers.js';
10
+ export interface RawRequest {
11
+ method: string;
12
+ path: string;
13
+ query: string;
14
+ headers: Dict;
15
+ body: string;
16
+ bodyEncoding?: 'utf8' | 'base64';
17
+ /** Socket-level peer address (filled by the HTTP server). */
18
+ remoteAddr?: string;
19
+ /**
20
+ * Resolved client IP — pre-computed by the Rust-side HyperServer using the
21
+ * configured trusted-proxy CIDR list. JS reads this field directly; CIDR
22
+ * matching no longer happens in TS. When absent (mock/test fixtures) the
23
+ * `ip()` accessor falls back to legacy header parsing.
24
+ */
25
+ ip?: string;
26
+ /**
27
+ * Pre-parsed `multipart/form-data` payload — the HyperServer parses bodies
28
+ * server-side via `multer` and ships fields/files in this typed shape.
29
+ * Files are base64-encoded so the payload stays JSON-safe.
30
+ */
31
+ multipart?: {
32
+ fields: Array<{
33
+ name: string;
34
+ value: string;
35
+ }>;
36
+ files: Array<{
37
+ fieldName: string;
38
+ clientName: string;
39
+ contentType: string;
40
+ size: number;
41
+ contentB64: string;
42
+ }>;
43
+ };
44
+ /**
45
+ * Pre-parsed `Cookie:` header — name → value map computed by the Rust
46
+ * cookie crate. JS reads via `request.cookie(name)`. When absent (test
47
+ * fixtures), the accessor falls back to inline header parsing.
48
+ */
49
+ cookies?: Dict;
50
+ }
51
+ export declare class Request {
52
+ #private;
53
+ /**
54
+ * CSRF token for this request (AdonisJS idiom: `request.csrfToken`). Seeded
55
+ * by the `@c9up/blackhole` middleware when CSRF is enabled; `undefined`
56
+ * otherwise. Also published to `ctx.store` for templating helpers.
57
+ */
58
+ csrfToken?: string;
59
+ constructor(raw: RawRequest, params?: Dict);
60
+ /** HTTP method (GET, POST, etc.). */
61
+ method(): string;
62
+ /** Request URL (path + query string). */
63
+ url(includeQs?: boolean): string;
64
+ /** Request path (without query string). */
65
+ path(): string;
66
+ /**
67
+ * Resolved client IP. The HyperServer computes this once per request from
68
+ * the socket peer + `X-Forwarded-For` / `X-Real-IP` headers, gated by the
69
+ * configured trusted-proxy CIDR list, and ships the resolved value on
70
+ * `request.ip`. JS reads that field as-is.
71
+ *
72
+ * When `#raw.ip` is missing — only happens in test fixtures that
73
+ * hand-build `RawRequest` without going through the Rust pipeline — fall
74
+ * back to the socket peer (`remoteAddr`). Do NOT consult `X-Forwarded-For`
75
+ * or `X-Real-IP` here: those headers are attacker-controlled on direct
76
+ * requests and the trusted-proxy gate lives in Rust. Honouring them in
77
+ * the TS fallback would let test fixtures masking real spoofing
78
+ * regressions (two semantics for the same API). Fixtures that need to
79
+ * simulate a proxy-resolved IP must set `#raw.ip` directly to the
80
+ * desired resolved value.
81
+ */
82
+ ip(): string;
83
+ /**
84
+ * Return all cookies sent on this request as a name → value map. The
85
+ * HyperServer parses the `Cookie:` header once via the `cookie` crate
86
+ * (RFC 6265) and ships the result on `RawRequest.cookies`. Test fixtures
87
+ * that don't pre-fill the field fall back to inline parsing of the raw
88
+ * header — same tolerant `;`-split with quoted-value passthrough.
89
+ */
90
+ cookies(): Dict;
91
+ /** Pre-parsed cookie value by name, or `null` when absent. */
92
+ cookie(name: string): string | null;
93
+ /** Get the raw body as a string (decoded from base64 if binary). */
94
+ raw(): string;
95
+ /** Get the raw body as a Buffer (preserves binary integrity for file uploads). */
96
+ rawBuffer(): Buffer;
97
+ /** Get a single request header (case-insensitive). */
98
+ header(key: string): string | undefined;
99
+ /** Get all request headers. */
100
+ headers(): Readonly<Dict>;
101
+ /** Get a single route parameter. */
102
+ param(key: string, defaultValue?: string): string | undefined;
103
+ /** Get all route parameters. */
104
+ params(): Readonly<Dict>;
105
+ /** Get parsed query string as an object. */
106
+ qs(): Dict<unknown>;
107
+ /** Get the parsed request body. */
108
+ body(): unknown;
109
+ /** Get a single input value from body or query string. */
110
+ input<T = unknown>(key: string, defaultValue?: T): T;
111
+ /** Get all input (query string merged with body). */
112
+ all(): Dict<unknown>;
113
+ /** Cherry-pick specific keys from input. */
114
+ only<K extends string>(keys: K[]): Partial<Record<K, unknown>>;
115
+ /** Get all input except specific keys. */
116
+ except(keys: string[]): Dict<unknown>;
117
+ /** Check if the request content-type matches any of the given types. */
118
+ is(types: string[]): string | null;
119
+ /**
120
+ * Content negotiation — which of the offered types does the client accept,
121
+ * honouring RFC 7231 §5.3.2 quality values?
122
+ *
123
+ * Walks the parsed Accept header in descending q-order and returns the
124
+ * first server-offered type that matches. The server's preference order
125
+ * (`types` argument) is the tiebreaker only when multiple client entries
126
+ * share the same q. A bare `accepts(types)` therefore respects the
127
+ * client's stated priorities (`application/json;q=0.9, text/html;q=0.1`
128
+ * beats a server passing `['html', 'json']`).
129
+ *
130
+ * Aliases (`'json'` ↔ `application/json`, `'html'` ↔ `text/html`,
131
+ * `'xml'` ↔ any subtype containing `xml`) are honoured.
132
+ */
133
+ accepts(types: string[]): string | null;
134
+ /**
135
+ * Language negotiation from Accept-Language honouring RFC 4647 / 7231
136
+ * quality values. Returns the first offered language whose tag (or its
137
+ * primary subtag) matches the highest-q client entry, falling back to
138
+ * `langs[0]` when nothing matches and the client header is empty/absent.
139
+ */
140
+ language(langs: string[]): string | null;
141
+ /** Get an uploaded file by field name. */
142
+ file(fieldName: string, options?: import('../bodyparser/MultipartFile.js').FileValidationOptions): import('../bodyparser/MultipartFile.js').MultipartFile | null;
143
+ /** Get all uploaded files for a field name. */
144
+ files(fieldName: string, options?: import('../bodyparser/MultipartFile.js').FileValidationOptions): import('../bodyparser/MultipartFile.js').MultipartFile[];
145
+ /** Get all uploaded files. */
146
+ allFiles(): Map<string, import('../bodyparser/MultipartFile.js').MultipartFile[]>;
147
+ /**
148
+ * Pre-parsed `multipart/form-data` payload as the HyperServer wrote it.
149
+ * Returns `undefined` when the request wasn't multipart (or the test
150
+ * fixture didn't fill the field). BodyParser hydrates `MultipartFile`
151
+ * instances from this — application code should keep using
152
+ * `request.file()` / `request.files()`.
153
+ */
154
+ multipart(): NonNullable<RawRequest['multipart']> | undefined;
155
+ /** @internal Set files (called by BodyParser middleware). */
156
+ setFiles(files: import('../bodyparser/MultipartFile.js').MultipartFile[]): void;
157
+ /** @internal Set the parsed body (called by BodyParser middleware). */
158
+ setParsedBody(body: Dict<unknown>): void;
159
+ }
160
+ //# sourceMappingURL=Request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Request.d.ts","sourceRoot":"","sources":["../../src/http/Request.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAE/C,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,IAA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