@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,303 @@
1
+ /**
2
+ * Response — accumulates HTTP response state with a fluent API.
3
+ *
4
+ * Wraps the same { status, headers, body } wire format expected by the NAPI layer.
5
+ * Provides AdonisJS-compatible methods: json(), send(), status(), header(), etc.
6
+ *
7
+ * @implements FR21
8
+ */
9
+ import { openSseStream, } from './SseStream.js';
10
+ /**
11
+ * Reject CR / LF / NUL bytes in header names or values. Without this guard
12
+ * an attacker controlling part of a header (e.g. a redirect URL parameter
13
+ * echoed into `Location`) could splice extra response headers — the classic
14
+ * CRLF injection / response-splitting attack (CWE-113).
15
+ */
16
+ function assertNoCRLF(name, value) {
17
+ if (/[\r\n\0]/.test(name) || /[\r\n\0]/.test(value)) {
18
+ throw new Error(`CRLF / NUL byte in header '${name}' is not allowed (response-splitting protection).`);
19
+ }
20
+ }
21
+ export class Response {
22
+ #status = 200;
23
+ #headers = {};
24
+ #cookies = [];
25
+ #body = '';
26
+ #finished = false;
27
+ #redirectBuilderFactory;
28
+ #streamBackend;
29
+ #streamId;
30
+ /**
31
+ * CSP nonce for this request (AdonisJS idiom: `response.nonce`). Seeded by
32
+ * the `@c9up/blackhole` middleware when the CSP uses `@nonce`; `undefined`
33
+ * otherwise. Also published to `ctx.store` as `cspNonce` for templating.
34
+ */
35
+ nonce;
36
+ // ─── Status ───────────────────────────────────────────────
37
+ /** Set the HTTP status code. Chainable. */
38
+ status(code) {
39
+ this.#status = code;
40
+ return this;
41
+ }
42
+ /** Set status only if not already set (still 200). */
43
+ safeStatus(code) {
44
+ if (this.#status === 200) {
45
+ this.#status = code;
46
+ }
47
+ return this;
48
+ }
49
+ // ─── Headers ──────────────────────────────────────────────
50
+ /** Set a response header. Chainable. */
51
+ header(key, value) {
52
+ assertNoCRLF(key, value);
53
+ this.#headers[key.toLowerCase()] = value;
54
+ return this;
55
+ }
56
+ /** Append to a response header (for multi-value like Set-Cookie). */
57
+ append(key, value) {
58
+ assertNoCRLF(key, value);
59
+ const k = key.toLowerCase();
60
+ if (k === 'set-cookie') {
61
+ // Set-Cookie must NOT be comma-joined — each cookie is its own
62
+ // header line, or browsers/proxies mis-parse the lot. Route into
63
+ // the same `#cookies` channel `cookie()` uses; `getHeaders()`
64
+ // emits them newline-separated for the serializer.
65
+ this.#cookies.push(value);
66
+ return this;
67
+ }
68
+ const existing = this.#headers[k];
69
+ this.#headers[k] = existing ? `${existing}, ${value}` : value;
70
+ return this;
71
+ }
72
+ /** Remove a response header. */
73
+ removeHeader(key) {
74
+ delete this.#headers[key.toLowerCase()];
75
+ return this;
76
+ }
77
+ /** Set the Content-Type header. Chainable. */
78
+ type(contentType) {
79
+ // Same CRLF/NUL guard as header() — `type(userValue)` must not be a
80
+ // response-splitting hole just because it writes a fixed header key.
81
+ assertNoCRLF('content-type', contentType);
82
+ this.#headers['content-type'] = contentType;
83
+ return this;
84
+ }
85
+ // ─── Body ─────────────────────────────────────────────────
86
+ /** Send a JSON response. Sets content-type and stringifies. */
87
+ json(data) {
88
+ this.#headers['content-type'] = 'application/json';
89
+ this.#body = JSON.stringify(data);
90
+ this.#finished = true;
91
+ }
92
+ /** Send a response body. Auto-detects content type if not set. */
93
+ send(data) {
94
+ if (typeof data === 'string') {
95
+ if (!this.#headers['content-type']) {
96
+ this.#headers['content-type'] = 'text/html; charset=utf-8';
97
+ }
98
+ this.#body = data;
99
+ }
100
+ else if (Buffer.isBuffer(data)) {
101
+ // Without this branch a Buffer would hit the `typeof === 'object'`
102
+ // path and be JSON-stringified into `{"type":"Buffer","data":[...]}`
103
+ // — every binary asset (PNG, PDF, ...) would arrive corrupted.
104
+ this.sendBuffer(data);
105
+ return;
106
+ }
107
+ else if (typeof data === 'object' && data !== null) {
108
+ this.#headers['content-type'] = 'application/json';
109
+ this.#body = JSON.stringify(data);
110
+ }
111
+ else if (data !== undefined && data !== null) {
112
+ if (!this.#headers['content-type']) {
113
+ this.#headers['content-type'] = 'text/plain';
114
+ }
115
+ this.#body = String(data);
116
+ }
117
+ this.#finished = true;
118
+ }
119
+ /**
120
+ * Send a binary body as-is. Encodes to base64 across the NAPI bridge
121
+ * with the `x-ream-body-encoding: base64` marker so the Rust HTTP
122
+ * layer decodes it before writing to the socket. The marker header is
123
+ * stripped server-side and never leaks to the client.
124
+ *
125
+ * Use this for any non-UTF-8 payload (images, PDFs, archives, etc.) —
126
+ * `send()` auto-routes Buffers here, but call directly when intent is
127
+ * unambiguous.
128
+ */
129
+ sendBuffer(buffer) {
130
+ if (!this.#headers['content-type']) {
131
+ this.#headers['content-type'] = 'application/octet-stream';
132
+ }
133
+ this.#headers['x-ream-body-encoding'] = 'base64';
134
+ this.#body = buffer.toString('base64');
135
+ this.#finished = true;
136
+ }
137
+ /** Send 204 No Content. */
138
+ noContent() {
139
+ this.#status = 204;
140
+ this.#body = '';
141
+ this.#finished = true;
142
+ }
143
+ // ─── Redirect ─────────────────────────────────────────────
144
+ /** Get a redirect builder. */
145
+ redirect() {
146
+ if (this.#redirectBuilderFactory) {
147
+ return this.#redirectBuilderFactory();
148
+ }
149
+ throw new Error('redirect() requires an HttpContext. Response was created outside a request handler.');
150
+ }
151
+ /** @internal Set the redirect builder factory (injected by HttpContext). */
152
+ setRedirectFactory(factory) {
153
+ this.#redirectBuilderFactory = factory;
154
+ }
155
+ /** @internal Wire the SSE backend (HyperServer NAPI). Injected by HttpKernel. */
156
+ setStreamBackend(backend) {
157
+ this.#streamBackend = backend;
158
+ }
159
+ // ─── Streaming (SSE) ──────────────────────────────────────
160
+ /**
161
+ * Open a Server-Sent Events stream. The returned `SseStream` lets the
162
+ * handler push named events for as long as the client stays
163
+ * connected. Headers are pre-set to the SSE wire format; the host
164
+ * router serializes the response with the reserved stream id so the
165
+ * Rust HyperServer keeps the connection open.
166
+ *
167
+ * const sse = await ctx.response.sse()
168
+ * sse.send('connected', { uid: caller.id })
169
+ * onTaskAssigned((evt) => sse.send('task.assigned', evt))
170
+ *
171
+ * Throws `STREAMING_UNSUPPORTED` if the underlying HyperServer host
172
+ * does not implement the streaming NAPI (e.g. a mock server in unit
173
+ * tests). The host capability is opt-in: implement
174
+ * `registerStream`/`writeStream`/`closeStream`/`onStreamDisconnect`
175
+ * to participate.
176
+ */
177
+ async sse(options) {
178
+ if (!this.#streamBackend) {
179
+ throw new Error('[ream] response.sse() requires a streaming-capable HyperServer host. ' +
180
+ 'The current server has no stream backend wired.');
181
+ }
182
+ // SSE wire format + safety defaults. The buffered body string stays
183
+ // empty — every chunk goes through the registry instead.
184
+ this.#headers['content-type'] = 'text/event-stream';
185
+ if (!this.#headers['cache-control']) {
186
+ this.#headers['cache-control'] = 'no-cache, no-transform';
187
+ }
188
+ if (!this.#headers['x-accel-buffering']) {
189
+ this.#headers['x-accel-buffering'] = 'no';
190
+ }
191
+ const stream = await openSseStream(this.#streamBackend, options);
192
+ this.#streamId = stream.id;
193
+ // Mark the response as "finished" so middleware that bails when
194
+ // `isFinished()` is true (the standard short-circuit) doesn't
195
+ // re-touch the body or headers after the SSE pipe has been set up.
196
+ this.#finished = true;
197
+ return stream;
198
+ }
199
+ // ─── Cookies ──────────────────────────────────────────────
200
+ /** Set a response cookie. */
201
+ cookie(name, value, options) {
202
+ // SameSite=None cookies REQUIRE the Secure attribute — modern browsers
203
+ // (Chrome 80+, Firefox, Safari) silently reject the cookie otherwise, so
204
+ // a missing Secure here turns OAuth callbacks / iframe sessions into a
205
+ // "works in dev (localhost relaxes Secure), breaks in prod" foot-gun.
206
+ if (options?.sameSite === 'none' && !options.secure) {
207
+ throw new Error(`Cookie '${name}': SameSite=None requires Secure: true (browsers reject SameSite=None cookies without Secure).`);
208
+ }
209
+ const parts = [`${encodeURIComponent(name)}=${encodeURIComponent(value)}`];
210
+ // `maxAge: 0` is the RFC 6265 "delete-now" signal used by logout
211
+ // flows. A truthiness check would skip it and leave the cookie
212
+ // alive for the session — explicit `!== undefined` covers both
213
+ // 0 and negative values that browsers also treat as immediate
214
+ // expiry.
215
+ if (options?.maxAge !== undefined)
216
+ parts.push(`Max-Age=${options.maxAge}`);
217
+ if (options?.path) {
218
+ // `Path` is concatenated raw (encodeURIComponent would mangle the `/`
219
+ // separators a path legitimately contains), so it needs the same
220
+ // CRLF/NUL guard as header()/append() — otherwise a controlled path
221
+ // injects into the `\n`-joined Set-Cookie header (response-splitting).
222
+ assertNoCRLF(`Set-Cookie path for '${name}'`, options.path);
223
+ parts.push(`Path=${options.path}`);
224
+ }
225
+ if (options?.httpOnly !== false)
226
+ parts.push('HttpOnly');
227
+ if (options?.secure)
228
+ parts.push('Secure');
229
+ if (options?.sameSite)
230
+ parts.push(`SameSite=${options.sameSite}`);
231
+ this.#cookies.push(parts.join('; '));
232
+ return this;
233
+ }
234
+ // ─── Internals (used by HttpKernel for NAPI serialization) ─
235
+ /** @internal Get the accumulated status code. */
236
+ getStatus() {
237
+ return this.#status;
238
+ }
239
+ /** @internal Get all accumulated headers (Set-Cookie as separate entries joined by newline). */
240
+ getHeaders() {
241
+ const headers = { ...this.#headers };
242
+ if (this.#cookies.length > 0) {
243
+ // Multiple Set-Cookie headers must be separate — we join with \n for the serializer
244
+ headers['set-cookie'] = this.#cookies.join('\n');
245
+ }
246
+ return headers;
247
+ }
248
+ /**
249
+ * Read a single accumulated response header by name (case-insensitive).
250
+ * Returns `undefined` when not set — used by middleware that conditionally
251
+ * inspects the outgoing content-type before sanitisation.
252
+ */
253
+ getHeader(name) {
254
+ return this.#headers[name.toLowerCase()];
255
+ }
256
+ /** @internal Get the accumulated body string. */
257
+ getBody() {
258
+ return this.#body;
259
+ }
260
+ /** @internal Check if response has been finalized. */
261
+ isFinished() {
262
+ return this.#finished;
263
+ }
264
+ /** @internal Set body directly (used by redirect, exception handler). */
265
+ setBody(body) {
266
+ this.#body = body;
267
+ this.#finished = true;
268
+ }
269
+ /**
270
+ * @internal Streaming-response handle, set by `sse()`. The host
271
+ * router forwards this id to the Rust HyperServer so the connection
272
+ * stays open and chunks flow from the JS-side writer.
273
+ */
274
+ getStreamId() {
275
+ return this.#streamId;
276
+ }
277
+ /**
278
+ * @internal Tear down a stream the handler opened via `sse()` but
279
+ * then abandoned by throwing. Closes the backend registry slot and
280
+ * clears the stream id + finished flag so the kernel's error path
281
+ * serializes a normal buffered error response instead of emitting
282
+ * `streamId` alongside an error body (which would leave the
283
+ * HyperServer feeding a dead/empty stream forever). Best-effort: a
284
+ * closeStream failure is swallowed — the slot's TTL/disconnect will
285
+ * reclaim it.
286
+ */
287
+ async abortStream() {
288
+ const id = this.#streamId;
289
+ if (id === undefined)
290
+ return;
291
+ this.#streamId = undefined;
292
+ this.#finished = false;
293
+ if (this.#streamBackend) {
294
+ try {
295
+ await this.#streamBackend.closeStream(id);
296
+ }
297
+ catch {
298
+ // benign — registry TTL / client disconnect reclaims the slot.
299
+ }
300
+ }
301
+ }
302
+ }
303
+ //# sourceMappingURL=Response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Response.js","sourceRoot":"","sources":["../../src/http/Response.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EACL,aAAa,GAId,MAAM,gBAAgB,CAAA;AAEvB;;;;;GAKG;AACH,SAAS,YAAY,CAAC,IAAY,EAAE,KAAa;IAC/C,IAAI,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C;gBACH,MAAM,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,CAAC,CAAA;YAC3C,CAAC;YAAC,MAAM,CAAC;gBACP,+DAA+D;YACjE,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Server-Sent Events writer — owns one logical SSE stream and pushes
3
+ * encoded events through the underlying `StreamBackend` (a thin
4
+ * abstraction over the HyperServer NAPI `registerStream` / `writeStream`
5
+ * / `closeStream` trio).
6
+ *
7
+ * Lifecycle:
8
+ *
9
+ * 1. `ctx.response.sse()` returns a ready-to-use writer. Internally it
10
+ * asks the backend to reserve a stream id and stamps the response
11
+ * with the right `Content-Type` + caching headers so the host
12
+ * router knows to switch into streaming mode.
13
+ * 2. The handler calls `writer.send(event, data)` / `writer.comment(...)`
14
+ * to push frames. Each call returns a boolean — `false` once the
15
+ * client has disconnected, so callers can bail out of long loops
16
+ * without polling.
17
+ * 3. The handler RETURNS the Response from the route — buffered body is
18
+ * empty, but `response.getStreamId()` is set, so Ream tells the
19
+ * Rust HyperServer to keep the connection open and feed the body
20
+ * from the stream registry.
21
+ * 4. Background tasks keep pushing through `writer.send(...)` until
22
+ * either the client leaves (`onClose` callback fires) or the
23
+ * server calls `writer.end()`.
24
+ *
25
+ * The encoding follows the SSE wire format (RFC chez WHATWG):
26
+ *
27
+ * event: <name>\n
28
+ * data: <stringified payload>\n
29
+ * id: <optional event id>\n
30
+ * \n
31
+ *
32
+ * Multi-line payloads are split on `\n` and each line is prefixed with
33
+ * `data: ` so the consumer browser reassembles them with newlines.
34
+ */
35
+ /** Minimal backend the writer needs — the HyperServer NAPI fits exactly. */
36
+ export interface StreamBackend {
37
+ registerStream(streamId: string): Promise<boolean>;
38
+ writeStream(streamId: string, chunk: string): Promise<boolean>;
39
+ closeStream(streamId: string): Promise<boolean>;
40
+ onStreamDisconnect(streamId: string, callback: () => void): void;
41
+ }
42
+ export interface SseStreamOptions {
43
+ /** Keep-alive ping interval (ms). Defaults to 30s. Set to 0 to disable. */
44
+ pingInterval?: number;
45
+ /** Initial `retry: <ms>` directive sent before any event. Defaults to 5_000. */
46
+ retry?: number;
47
+ }
48
+ /** Active SSE writer returned by `response.sse()`. */
49
+ export declare class SseStream {
50
+ #private;
51
+ readonly id: string;
52
+ constructor(id: string, backend: StreamBackend, options?: SseStreamOptions);
53
+ /** True until the client disconnects or the server calls `end()`. */
54
+ isOpen(): boolean;
55
+ /**
56
+ * Send a named SSE event. `data` is JSON-stringified unless it is
57
+ * already a string. Returns `false` if the stream is closed.
58
+ *
59
+ * `eventId` is optional — set it when you want browsers to send
60
+ * `Last-Event-ID` on reconnection. Useful for resumable streams.
61
+ */
62
+ send(event: string, data: unknown, eventId?: string): Promise<boolean>;
63
+ /**
64
+ * Send a comment frame (`:text\n\n`) — useful for keep-alives and
65
+ * for human-readable inline debug. Comments are NOT delivered to
66
+ * `EventSource.onmessage`; the browser silently consumes them.
67
+ */
68
+ comment(text: string): Promise<boolean>;
69
+ /** Register a callback fired once the underlying connection drops. */
70
+ onClose(callback: () => void): void;
71
+ /**
72
+ * End the stream from the server side. Idempotent. The matching
73
+ * NAPI receiver finishes its work and hyper closes the body.
74
+ */
75
+ end(): Promise<void>;
76
+ }
77
+ /**
78
+ * Open a new SSE stream against the given backend. Returns once the
79
+ * registry slot is reserved — safe to call `send()` immediately, even
80
+ * before the handler has returned (frames buffer in the bounded mpsc
81
+ * inside Rust).
82
+ *
83
+ * The `retry: <ms>` directive is sent as the first thing on the wire
84
+ * (a comment frame would be invisible to the client; the retry hint
85
+ * needs to land before any real event so browsers know how long to
86
+ * wait before reconnecting if the connection drops).
87
+ */
88
+ export declare function openSseStream(backend: StreamBackend, options?: SseStreamOptions): Promise<SseStream>;
89
+ //# sourceMappingURL=SseStream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SseStream.d.ts","sourceRoot":"","sources":["../../src/http/SseStream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;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AapB"}
@@ -0,0 +1,228 @@
1
+ /**
2
+ * Server-Sent Events writer — owns one logical SSE stream and pushes
3
+ * encoded events through the underlying `StreamBackend` (a thin
4
+ * abstraction over the HyperServer NAPI `registerStream` / `writeStream`
5
+ * / `closeStream` trio).
6
+ *
7
+ * Lifecycle:
8
+ *
9
+ * 1. `ctx.response.sse()` returns a ready-to-use writer. Internally it
10
+ * asks the backend to reserve a stream id and stamps the response
11
+ * with the right `Content-Type` + caching headers so the host
12
+ * router knows to switch into streaming mode.
13
+ * 2. The handler calls `writer.send(event, data)` / `writer.comment(...)`
14
+ * to push frames. Each call returns a boolean — `false` once the
15
+ * client has disconnected, so callers can bail out of long loops
16
+ * without polling.
17
+ * 3. The handler RETURNS the Response from the route — buffered body is
18
+ * empty, but `response.getStreamId()` is set, so Ream tells the
19
+ * Rust HyperServer to keep the connection open and feed the body
20
+ * from the stream registry.
21
+ * 4. Background tasks keep pushing through `writer.send(...)` until
22
+ * either the client leaves (`onClose` callback fires) or the
23
+ * server calls `writer.end()`.
24
+ *
25
+ * The encoding follows the SSE wire format (RFC chez WHATWG):
26
+ *
27
+ * event: <name>\n
28
+ * data: <stringified payload>\n
29
+ * id: <optional event id>\n
30
+ * \n
31
+ *
32
+ * Multi-line payloads are split on `\n` and each line is prefixed with
33
+ * `data: ` so the consumer browser reassembles them with newlines.
34
+ */
35
+ const DEFAULT_PING_INTERVAL = 30_000;
36
+ const DEFAULT_RETRY = 5_000;
37
+ /** Cryptographic-quality stream id — 16 random bytes, hex-encoded. */
38
+ function generateStreamId() {
39
+ const bytes = new Uint8Array(16);
40
+ // `crypto.getRandomValues` is the WHATWG primitive available on every
41
+ // supported Node version (>=22). Avoids pulling in `node:crypto` for
42
+ // a 32-char hex string.
43
+ globalThis.crypto.getRandomValues(bytes);
44
+ return Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
45
+ }
46
+ /** Active SSE writer returned by `response.sse()`. */
47
+ export class SseStream {
48
+ id;
49
+ #backend;
50
+ #open = true;
51
+ #closeFired = false;
52
+ #pingTimer = null;
53
+ #closeListeners = [];
54
+ constructor(id, backend, options) {
55
+ this.id = id;
56
+ this.#backend = backend;
57
+ // The backend disconnect signal and a server-side end() can BOTH
58
+ // fire (e.g. server end() followed by the client-drop signal). The
59
+ // shared #fireClose() guards idempotency so user cleanups run once.
60
+ backend.onStreamDisconnect(id, () => {
61
+ this.#open = false;
62
+ this.#stopPing();
63
+ this.#fireClose();
64
+ });
65
+ const ping = options?.pingInterval ?? DEFAULT_PING_INTERVAL;
66
+ if (ping > 0) {
67
+ this.#pingTimer = setInterval(() => {
68
+ if (!this.#open)
69
+ return;
70
+ // Comment frames keep the connection alive without firing a
71
+ // JS event on the client. `writeStream` returns false once the
72
+ // client has disconnected (per the NAPI contract); if we see
73
+ // that while still "open" the disconnect signal was missed —
74
+ // e.g. the client dropped in the window between registerStream
75
+ // and the constructor wiring onStreamDisconnect. Self-heal:
76
+ // stop the timer and run close listeners once, so a dropped-
77
+ // at-open stream can't leave an orphaned keepalive ticking
78
+ // against a dead registry slot.
79
+ void this.#backend.writeStream(this.id, ':keepalive\n\n').then((ok) => {
80
+ if (!ok && this.#open) {
81
+ this.#open = false;
82
+ this.#stopPing();
83
+ this.#fireClose();
84
+ }
85
+ });
86
+ }, ping);
87
+ // The keepalive must not pin the Node event loop — letting the
88
+ // process exit on its own when nothing else is keeping it busy
89
+ // matches Adonis Transmit's behavior.
90
+ if (typeof this.#pingTimer === 'object' && 'unref' in this.#pingTimer) {
91
+ ;
92
+ this.#pingTimer.unref();
93
+ }
94
+ }
95
+ }
96
+ /** True until the client disconnects or the server calls `end()`. */
97
+ isOpen() {
98
+ return this.#open;
99
+ }
100
+ /**
101
+ * Send a named SSE event. `data` is JSON-stringified unless it is
102
+ * already a string. Returns `false` if the stream is closed.
103
+ *
104
+ * `eventId` is optional — set it when you want browsers to send
105
+ * `Last-Event-ID` on reconnection. Useful for resumable streams.
106
+ */
107
+ async send(event, data, eventId) {
108
+ if (!this.#open)
109
+ return false;
110
+ const payload = typeof data === 'string' ? data : JSON.stringify(data);
111
+ return this.#backend.writeStream(this.id, encodeFrame(event, payload, eventId));
112
+ }
113
+ /**
114
+ * Send a comment frame (`:text\n\n`) — useful for keep-alives and
115
+ * for human-readable inline debug. Comments are NOT delivered to
116
+ * `EventSource.onmessage`; the browser silently consumes them.
117
+ */
118
+ async comment(text) {
119
+ if (!this.#open)
120
+ return false;
121
+ // Strip newlines so a malicious comment cannot inject `\n\n` and
122
+ // close a frame early.
123
+ const sanitized = text.replace(/[\r\n]+/g, ' ');
124
+ return this.#backend.writeStream(this.id, `:${sanitized}\n\n`);
125
+ }
126
+ /** Register a callback fired once the underlying connection drops. */
127
+ onClose(callback) {
128
+ if (!this.#open) {
129
+ // Already closed — run the callback synchronously so behavior
130
+ // matches the standard observer pattern.
131
+ try {
132
+ callback();
133
+ }
134
+ catch {
135
+ // Swallow — same isolation as the normal listener loop.
136
+ }
137
+ return;
138
+ }
139
+ this.#closeListeners.push(callback);
140
+ }
141
+ /**
142
+ * End the stream from the server side. Idempotent. The matching
143
+ * NAPI receiver finishes its work and hyper closes the body.
144
+ */
145
+ async end() {
146
+ if (!this.#open)
147
+ return;
148
+ this.#open = false;
149
+ this.#stopPing();
150
+ await this.#backend.closeStream(this.id);
151
+ this.#fireClose();
152
+ }
153
+ #stopPing() {
154
+ if (this.#pingTimer !== null) {
155
+ clearInterval(this.#pingTimer);
156
+ this.#pingTimer = null;
157
+ }
158
+ }
159
+ /**
160
+ * Run every close listener exactly once. Both end() (server-side) and
161
+ * the backend disconnect signal funnel through here; the #closeFired
162
+ * latch stops user cleanups from being replayed when both fire.
163
+ */
164
+ #fireClose() {
165
+ if (this.#closeFired)
166
+ return;
167
+ this.#closeFired = true;
168
+ for (const cb of this.#closeListeners) {
169
+ try {
170
+ cb();
171
+ }
172
+ catch {
173
+ // Listener errors are isolated — one bad cleanup callback
174
+ // mustn't take down the rest.
175
+ }
176
+ }
177
+ }
178
+ }
179
+ /**
180
+ * Open a new SSE stream against the given backend. Returns once the
181
+ * registry slot is reserved — safe to call `send()` immediately, even
182
+ * before the handler has returned (frames buffer in the bounded mpsc
183
+ * inside Rust).
184
+ *
185
+ * The `retry: <ms>` directive is sent as the first thing on the wire
186
+ * (a comment frame would be invisible to the client; the retry hint
187
+ * needs to land before any real event so browsers know how long to
188
+ * wait before reconnecting if the connection drops).
189
+ */
190
+ export async function openSseStream(backend, options) {
191
+ const id = generateStreamId();
192
+ const registered = await backend.registerStream(id);
193
+ if (!registered) {
194
+ // Hex collision is astronomically improbable, but surfacing it
195
+ // cleanly beats a silent stream-id mismatch (the response builder
196
+ // would then 500 with E_STREAM_UNKNOWN, which is far less helpful).
197
+ throw new Error(`[ream] failed to reserve SSE stream id ${id} — collision in the registry`);
198
+ }
199
+ // First frame: the recommended retry hint. Conforms to the EventSource
200
+ // reconnection backoff spec; falling through with the default 5s.
201
+ await backend.writeStream(id, `retry: ${options?.retry ?? DEFAULT_RETRY}\n\n`);
202
+ return new SseStream(id, backend, options);
203
+ }
204
+ /** Encode a single SSE event in the wire format. */
205
+ function encodeFrame(event, data, eventId) {
206
+ // `event:` line first if we have a name (a frame without `event:` is
207
+ // delivered as a generic `message` event by the browser — both forms
208
+ // are valid).
209
+ const lines = [];
210
+ // `event:` and `id:` are single-line tokens — strip CR/LF so a
211
+ // caller-supplied event name or id can't splice extra SSE frames
212
+ // (the same injection `comment()` guards against). `data` is safe:
213
+ // it's split on `\n` and each line re-prefixed, so newlines there
214
+ // stay inside one logical event.
215
+ if (event)
216
+ lines.push(`event: ${event.replace(/[\r\n]+/g, ' ')}`);
217
+ // Multi-line data is allowed by SSE but each line must repeat the
218
+ // `data: ` prefix. Splitting on `\n` keeps the browser's
219
+ // reassembly intact (it joins back with `\n`).
220
+ for (const line of data.split('\n')) {
221
+ lines.push(`data: ${line}`);
222
+ }
223
+ if (eventId)
224
+ lines.push(`id: ${eventId.replace(/[\r\n]+/g, ' ')}`);
225
+ // Trailing blank line terminates the event.
226
+ return `${lines.join('\n')}\n\n`;
227
+ }
228
+ //# sourceMappingURL=SseStream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SseStream.js","sourceRoot":"","sources":["../../src/http/SseStream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAiBH,MAAM,qBAAqB,GAAG,MAAM,CAAA;AACpC,MAAM,aAAa,GAAG,KAAK,CAAA;AAE3B,sEAAsE;AACtE,SAAS,gBAAgB;IACvB,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAA;IAChC,sEAAsE;IACtE,qEAAqE;IACrE,wBAAwB;IACxB,UAAU,CAAC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAA;IACxC,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AAC3E,CAAC;AAED,sDAAsD;AACtD,MAAM,OAAO,SAAS;IACX,EAAE,CAAQ;IACnB,QAAQ,CAAe;IACvB,KAAK,GAAG,IAAI,CAAA;IACZ,WAAW,GAAG,KAAK,CAAA;IACnB,UAAU,GAA0C,IAAI,CAAA;IACxD,eAAe,GAAsB,EAAE,CAAA;IAEvC,YAAY,EAAU,EAAE,OAAsB,EAAE,OAA0B;QACxE,IAAI,CAAC,EAAE,GAAG,EAAE,CAAA;QACZ,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;QAEvB,iEAAiE;QACjE,mEAAmE;QACnE,oEAAoE;QACpE,OAAO,CAAC,kBAAkB,CAAC,EAAE,EAAE,GAAG,EAAE;YAClC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;YAClB,IAAI,CAAC,SAAS,EAAE,CAAA;YAChB,IAAI,CAAC,UA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E,mEAAmE;IACnE,kEAAkE;IAClE,iCAAiC;IACjC,IAAI,KAAK;QAAE,KAAK,CAAC,IAAI,CAAC,UAAU,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC,EAAE,CAAC,CAAA;IACjE,kEAAkE;IAClE,yDAAyD;IACzD,+CAA+C;IAC/C,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACpC,KAAK,CAAC,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC,CAAA;IAC7B,CAAC;IACD,IAAI,OAAO;QAAE,KAAK,CAAC,IAAI,CAAC,OAAO,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC,EAAE,CAAC,CAAA;IAClE,4CAA4C;IAC5C,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAA;AAClC,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Safe URL decoding helpers for untrusted request inputs.
3
+ */
4
+ /** Decode URI component and keep raw value on malformed escapes. */
5
+ export declare function safeDecodeURIComponent(value: string): string;
6
+ /** Decode x-www-form-urlencoded component (`+` => space) safely. */
7
+ export declare function safeDecodeFormComponent(value: string): string;
8
+ //# sourceMappingURL=urlDecode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"urlDecode.d.ts","sourceRoot":"","sources":["../../src/http/urlDecode.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,oEAAoE;AACpE,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAM5D;AAED,oEAAoE;AACpE,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAG7D"}