@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 @@
1
+ {"version":3,"file":"BodyParserMiddleware.d.ts","sourceRoot":"","sources":["../../src/bodyparser/BodyParserMiddleware.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAGzD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE;QACL,OAAO,CAAC,EAAE,OAAO,CAAA;QACjB,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;KACjB,CAAA;IACD,IAAI,CAAC,EAAE;QACL,OAAO,CAAC,EAAE,OAAO,CAAA;QACjB,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;KACjB,CAAA;IACD,GAAG,CAAC,EAAE;QACJ,OAAO,CAAC,EAAE,OAAO,CAAA;QACjB,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;KACjB,CAAA;IACD,SAAS,CAAC,EAAE;QACV,OAAO,CAAC,EAAE,OAAO,CAAA;QACjB,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;KACjB,CAAA;CACF;AAkCD,MAAM,CAAC,OAAO,OAAO,oBAAoB;;gBAG3B,MAAM,CAAC,EAAE,gBAAgB;IAS/B,MAAM,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC;CAkDzD"}
@@ -0,0 +1,143 @@
1
+ /**
2
+ * BodyParser middleware — parses request bodies by content-type.
3
+ *
4
+ * Supports JSON, form-urlencoded, and raw text.
5
+ * Multipart (file uploads) handled separately.
6
+ * Configured via config/bodyparser.ts.
7
+ */
8
+ import { hydrateMultipartPayload } from './MultipartFile.js';
9
+ const DEFAULT_CONFIG = {
10
+ json: {
11
+ enabled: true,
12
+ limit: '1mb',
13
+ types: ['application/json', 'application/vnd.api+json'],
14
+ },
15
+ form: {
16
+ enabled: true,
17
+ limit: '1mb',
18
+ types: ['application/x-www-form-urlencoded'],
19
+ },
20
+ raw: {
21
+ enabled: false,
22
+ limit: '1mb',
23
+ types: ['text/plain'],
24
+ },
25
+ multipart: {
26
+ enabled: true,
27
+ limit: '20mb',
28
+ maxFields: 500,
29
+ tmpDir: '/tmp',
30
+ types: ['multipart/form-data'],
31
+ },
32
+ };
33
+ export default class BodyParserMiddleware {
34
+ #config;
35
+ constructor(config) {
36
+ this.#config = {
37
+ json: { ...DEFAULT_CONFIG.json, ...config?.json },
38
+ form: { ...DEFAULT_CONFIG.form, ...config?.form },
39
+ raw: { ...DEFAULT_CONFIG.raw, ...config?.raw },
40
+ multipart: { ...DEFAULT_CONFIG.multipart, ...config?.multipart },
41
+ };
42
+ }
43
+ async handle(ctx, next) {
44
+ const contentType = ctx.request.header('content-type') ?? '';
45
+ const rawBody = ctx.request.raw();
46
+ // Size check
47
+ if (Buffer.byteLength(rawBody, 'utf8') > parseSize(this.#getLimit(contentType))) {
48
+ ctx.response.status(413).json({
49
+ error: { code: 'E_REQUEST_ENTITY_TOO_LARGE', message: 'Request body exceeds size limit' },
50
+ });
51
+ return;
52
+ }
53
+ // JSON
54
+ if (this.#config.json.enabled && matchesType(contentType, this.#config.json.types)) {
55
+ // Request already lazy-parses JSON — nothing to do
56
+ }
57
+ // Form URL-encoded
58
+ if (this.#config.form.enabled && matchesType(contentType, this.#config.form.types)) {
59
+ ctx.request.setParsedBody(parseFormUrlEncoded(rawBody));
60
+ }
61
+ // Raw text — wrap the string under `_body` so consumers can still
62
+ // reach it through `request.input('_body')`. This matches the fallback
63
+ // shape used by `Request.#ensureParsedBody` when JSON yields a non-object.
64
+ if (this.#config.raw.enabled && matchesType(contentType, this.#config.raw.types)) {
65
+ ctx.request.setParsedBody({ _body: rawBody });
66
+ }
67
+ // Multipart — the Rust-side HyperServer parses the body server-side
68
+ // (multer crate) and ships the structured payload on `request.multipart`.
69
+ // JS just hydrates `MultipartFile` instances from the typed envelope.
70
+ if (this.#config.multipart.enabled && matchesType(contentType, this.#config.multipart.types)) {
71
+ const payload = ctx.request.multipart();
72
+ if (payload) {
73
+ const { fields, files } = hydrateMultipartPayload(payload);
74
+ ctx.request.setParsedBody(fields);
75
+ ctx.request.setFiles(files);
76
+ }
77
+ }
78
+ await next();
79
+ }
80
+ #getLimit(contentType) {
81
+ if (matchesType(contentType, this.#config.json.types))
82
+ return this.#config.json.limit;
83
+ if (matchesType(contentType, this.#config.form.types))
84
+ return this.#config.form.limit;
85
+ if (matchesType(contentType, this.#config.multipart.types))
86
+ return this.#config.multipart.limit;
87
+ return this.#config.raw.limit;
88
+ }
89
+ }
90
+ function matchesType(contentType, types) {
91
+ return types.some((t) => contentType.includes(t));
92
+ }
93
+ function parseSize(size) {
94
+ const match = size.match(/^(\d+)(kb|mb|gb)?$/i);
95
+ if (!match)
96
+ return 1024 * 1024; // default 1mb
97
+ const num = parseInt(match[1], 10);
98
+ switch (match[2]?.toLowerCase()) {
99
+ case 'kb':
100
+ return num * 1024;
101
+ case 'mb':
102
+ return num * 1024 * 1024;
103
+ case 'gb':
104
+ return num * 1024 * 1024 * 1024;
105
+ default:
106
+ return num;
107
+ }
108
+ }
109
+ function parseFormUrlEncoded(body) {
110
+ const result = {};
111
+ if (!body)
112
+ return result;
113
+ for (const pair of body.split('&')) {
114
+ if (!pair)
115
+ continue;
116
+ const eqIdx = pair.indexOf('=');
117
+ if (eqIdx === -1) {
118
+ result[decodeFormComponent(pair)] = '';
119
+ }
120
+ else {
121
+ result[decodeFormComponent(pair.slice(0, eqIdx))] = decodeFormComponent(pair.slice(eqIdx + 1));
122
+ }
123
+ }
124
+ return result;
125
+ }
126
+ // `application/x-www-form-urlencoded` reserves `+` for space (RFC 1866 / WHATWG
127
+ // URL form spec), so the substitution must happen before percent-decoding —
128
+ // otherwise a literal `+` (encoded as `%2B`) would be turned into a space too.
129
+ //
130
+ // Malformed percent-encoding (e.g. a truncated `a=%E0%A4%A`) makes
131
+ // decodeURIComponent throw URIError; mirror Request.ts#safeDecode and fall back
132
+ // to the substituted-but-undecoded value so an invalid body is a parse miss,
133
+ // not a 500.
134
+ function decodeFormComponent(value) {
135
+ const spaced = value.replace(/\+/g, ' ');
136
+ try {
137
+ return decodeURIComponent(spaced);
138
+ }
139
+ catch {
140
+ return spaced;
141
+ }
142
+ }
143
+ //# sourceMappingURL=BodyParserMiddleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BodyParserMiddleware.js","sourceRoot":"","sources":["../../src/bodyparser/BodyParserMiddleware.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAA;AAkC5D,MAAM,cAAc,GAA6B;IAC/C,IAAI,EAAE;QACJ,OAAO,EAAE,IAAI;QACb,KAAK,EAAE,KAAK;QACZ,KAAK,EAAE,CAAC,kBAAkB,EAAE,0BAA0B,CAAC;K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;QACP,OAAO,MAAM,CAAA;IACf,CAAC;AACH,CAAC"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * MultipartFile — represents an uploaded file.
3
+ *
4
+ * Like AdonisJS MultipartFile:
5
+ * const avatar = request.file('avatar', { size: '2mb', extnames: ['jpg', 'png'] })
6
+ * await avatar.moveToDisk('uploads')
7
+ */
8
+ import { Readable } from 'node:stream';
9
+ export interface FileValidationOptions {
10
+ size?: string;
11
+ extnames?: string[];
12
+ }
13
+ export declare class MultipartFile {
14
+ #private;
15
+ /** Original filename from the client. */
16
+ readonly clientName: string;
17
+ /** File extension (without dot). */
18
+ readonly extname: string;
19
+ /** MIME type from the Content-Type header. */
20
+ readonly type: string;
21
+ /** File size in bytes. */
22
+ readonly size: number;
23
+ /** Raw file content as Buffer. */
24
+ readonly content: Buffer;
25
+ /** Field name in the form. */
26
+ readonly fieldName: string;
27
+ /** Validation errors. */
28
+ readonly errors: string[];
29
+ constructor(options: {
30
+ fieldName: string;
31
+ clientName: string;
32
+ type: string;
33
+ content: Buffer;
34
+ });
35
+ /** Validate file against size and extension rules. */
36
+ validate(options: FileValidationOptions): boolean;
37
+ get isValid(): boolean;
38
+ /**
39
+ * Move file to a directory on disk. When `name` is supplied it must be
40
+ * a plain filename — no path separators, no `.`/`..` segments. The
41
+ * common footgun is passing the client-supplied `clientName` directly
42
+ * (`await file.moveToDisk('uploads', file.clientName)`); a malicious
43
+ * upload could otherwise traverse out of `directory` via `../../etc/...`.
44
+ */
45
+ moveToDisk(directory: string, name?: string): Promise<string>;
46
+ get isMoved(): boolean;
47
+ /**
48
+ * Return a fresh `Readable` over the file's bytes. The underlying buffer is
49
+ * not consumed — repeated calls always start at byte 0, so callers can pipe
50
+ * the same file into multiple sinks (e.g. validation hash + disk write)
51
+ * without `Buffer.from(this.content)` boilerplate.
52
+ */
53
+ stream(): Readable;
54
+ }
55
+ /**
56
+ * Hydrate `MultipartFile` instances from the typed payload the Rust
57
+ * HyperServer attaches to the request. The wire-level parser (multer crate,
58
+ * see `crates/ream-http/src/multipart.rs`) handles the actual RFC 7578
59
+ * parsing — JS just decodes the base64 envelope and wraps the result.
60
+ */
61
+ export declare function hydrateMultipartPayload(payload: {
62
+ fields: Array<{
63
+ name: string;
64
+ value: string;
65
+ }>;
66
+ files: Array<{
67
+ fieldName: string;
68
+ clientName: string;
69
+ contentType: string;
70
+ size: number;
71
+ contentB64: string;
72
+ }>;
73
+ }): {
74
+ fields: Record<string, string>;
75
+ files: MultipartFile[];
76
+ };
77
+ //# sourceMappingURL=MultipartFile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MultipartFile.d.ts","sourceRoot":"","sources":["../../src/bodyparser/MultipartFile.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC,MAAM,WAAW,qBAAqB;IACpC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;CACpB;AAED,qBAAa,aAAa;;IACxB,yCAAyC;IACzC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAE3B,oCAAoC;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IAExB,8CAA8C;IAC9C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IAErB,0BAA0B;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IAErB,kCAAkC;IAClC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IAExB,8BAA8B;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAE1B,yBAAyB;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,CAAK;gBAKlB,OAAO,EAAE;QACnB,SAAS,EAAE,MAAM,CAAA;QACjB,UAAU,EAAE,MAAM,CAAA;QAClB,IAAI,EAAE,MAAM,CAAA;QACZ,OAAO,EAAE,MAAM,CAAA;KAChB;IAUD,sDAAsD;IACtD,QAAQ,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO;IAiBjD,IAAI,OAAO,IAAI,OAAO,CAErB;IAED;;;;;;OAMG;IACG,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA2BnE,IAAI,OAAO,IAAI,OAAO,CAErB;IAED;;;;;OAKG;IACH,MAAM,IAAI,QAAQ;CAGnB;AAyBD;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE;IAC/C,MAAM,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IAC9C,KAAK,EAAE,KAAK,CAAC;QACX,SAAS,EAAE,MAAM,CAAA;QACjB,UAAU,EAAE,MAAM,CAAA;QAClB,WAAW,EAAE,MAAM,CAAA;QACnB,IAAI,EAAE,MAAM,CAAA;QACZ,UAAU,EAAE,MAAM,CAAA;KACnB,CAAC,CAAA;CACH,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,KAAK,EAAE,aAAa,EAAE,CAAA;CAAE,CAe7D"}
@@ -0,0 +1,138 @@
1
+ /**
2
+ * MultipartFile — represents an uploaded file.
3
+ *
4
+ * Like AdonisJS MultipartFile:
5
+ * const avatar = request.file('avatar', { size: '2mb', extnames: ['jpg', 'png'] })
6
+ * await avatar.moveToDisk('uploads')
7
+ */
8
+ import { randomBytes } from 'node:crypto';
9
+ import { Readable } from 'node:stream';
10
+ export class MultipartFile {
11
+ /** Original filename from the client. */
12
+ clientName;
13
+ /** File extension (without dot). */
14
+ extname;
15
+ /** MIME type from the Content-Type header. */
16
+ type;
17
+ /** File size in bytes. */
18
+ size;
19
+ /** Raw file content as Buffer. */
20
+ content;
21
+ /** Field name in the form. */
22
+ fieldName;
23
+ /** Validation errors. */
24
+ errors = [];
25
+ /** Whether the file has been moved. */
26
+ #moved = false;
27
+ constructor(options) {
28
+ this.fieldName = options.fieldName;
29
+ this.clientName = options.clientName;
30
+ this.type = options.type;
31
+ this.content = options.content;
32
+ this.size = options.content.length;
33
+ const segments = options.clientName.split('.');
34
+ this.extname = segments.length > 1 ? (segments.at(-1) ?? '').toLowerCase() : '';
35
+ }
36
+ /** Validate file against size and extension rules. */
37
+ validate(options) {
38
+ if (options.size) {
39
+ const maxBytes = parseFileSize(options.size);
40
+ if (this.size > maxBytes) {
41
+ this.errors.push(`File size ${this.size} exceeds limit ${options.size}`);
42
+ }
43
+ }
44
+ if (options.extnames && options.extnames.length > 0) {
45
+ if (!options.extnames.includes(this.extname)) {
46
+ this.errors.push(`Extension '${this.extname}' not allowed. Allowed: ${options.extnames.join(', ')}`);
47
+ }
48
+ }
49
+ return this.errors.length === 0;
50
+ }
51
+ get isValid() {
52
+ return this.errors.length === 0;
53
+ }
54
+ /**
55
+ * Move file to a directory on disk. When `name` is supplied it must be
56
+ * a plain filename — no path separators, no `.`/`..` segments. The
57
+ * common footgun is passing the client-supplied `clientName` directly
58
+ * (`await file.moveToDisk('uploads', file.clientName)`); a malicious
59
+ * upload could otherwise traverse out of `directory` via `../../etc/...`.
60
+ */
61
+ async moveToDisk(directory, name) {
62
+ const { mkdirSync, writeFileSync } = await import('node:fs');
63
+ const { join } = await import('node:path');
64
+ if (name !== undefined && !isSafeFilename(name)) {
65
+ throw new Error(`MultipartFile.moveToDisk: 'name' must be a plain filename (no path separators, '.', or '..'). Got: ${JSON.stringify(name)}`);
66
+ }
67
+ mkdirSync(directory, { recursive: true });
68
+ const fileName = name ?? `${randomBytes(16).toString('hex')}.${this.extname}`;
69
+ // Defense-in-depth: the default branch interpolates `extname` (derived
70
+ // from attacker-controlled `clientName`) into the filename, bypassing
71
+ // the `name` guard above. Re-validate the synthesized fileName before
72
+ // join to reject a hostile extname (separators, NUL).
73
+ if (!isSafeFilename(fileName)) {
74
+ throw new Error(`MultipartFile.moveToDisk: derived filename '${fileName}' is unsafe (separator or invalid char in clientName-derived extname).`);
75
+ }
76
+ const filePath = join(directory, fileName);
77
+ writeFileSync(filePath, this.content);
78
+ this.#moved = true;
79
+ return filePath;
80
+ }
81
+ get isMoved() {
82
+ return this.#moved;
83
+ }
84
+ /**
85
+ * Return a fresh `Readable` over the file's bytes. The underlying buffer is
86
+ * not consumed — repeated calls always start at byte 0, so callers can pipe
87
+ * the same file into multiple sinks (e.g. validation hash + disk write)
88
+ * without `Buffer.from(this.content)` boilerplate.
89
+ */
90
+ stream() {
91
+ return Readable.from(this.content, { objectMode: false });
92
+ }
93
+ }
94
+ function isSafeFilename(name) {
95
+ if (name.length === 0)
96
+ return false;
97
+ if (name === '.' || name === '..')
98
+ return false;
99
+ if (/[\\/\0]/.test(name))
100
+ return false;
101
+ return true;
102
+ }
103
+ function parseFileSize(size) {
104
+ const match = size.match(/^(\d+)(kb|mb|gb)?$/i);
105
+ if (!match)
106
+ return 1024 * 1024;
107
+ const num = parseInt(match[1], 10);
108
+ switch (match[2]?.toLowerCase()) {
109
+ case 'kb':
110
+ return num * 1024;
111
+ case 'mb':
112
+ return num * 1024 * 1024;
113
+ case 'gb':
114
+ return num * 1024 * 1024 * 1024;
115
+ default:
116
+ return num;
117
+ }
118
+ }
119
+ /**
120
+ * Hydrate `MultipartFile` instances from the typed payload the Rust
121
+ * HyperServer attaches to the request. The wire-level parser (multer crate,
122
+ * see `crates/ream-http/src/multipart.rs`) handles the actual RFC 7578
123
+ * parsing — JS just decodes the base64 envelope and wraps the result.
124
+ */
125
+ export function hydrateMultipartPayload(payload) {
126
+ const fields = {};
127
+ for (const field of payload.fields) {
128
+ fields[field.name] = field.value;
129
+ }
130
+ const files = payload.files.map((f) => new MultipartFile({
131
+ fieldName: f.fieldName,
132
+ clientName: f.clientName,
133
+ type: f.contentType,
134
+ content: Buffer.from(f.contentB64, 'base64'),
135
+ }));
136
+ return { fields, files };
137
+ }
138
+ //# sourceMappingURL=MultipartFile.js.map
@@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,EAAE,EAAE,CAAC,CAAA;IAClC,QAAQ,KAAK,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,EAAE,CAAC;QAChC,KAAK,IAAI;YACP,OAAO,GAAG,GAAG,IAAI,CAAA;QACnB,KAAK,IAAI;YACP,OAAO,GAAG,GAAG,IAAI,GAAG,IAAI,CAAA;QAC1B,KAAK,IAAI;YACP,OAAO,GAAG,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;QACjC;YACE,OAAO,GAAG,CAAA;IACd,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,OASvC;IACC,MAAM,MAAM,GAA2B,EAAE,CAAA;IACzC,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACnC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,KAAK,CAAA;IAClC,CAAC;IACD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAC7B,CAAC,CAAC,EAAE,EAAE,CACJ,IAAI,aAAa,CAAC;QAChB,SAAS,EAAE,CAAC,CAAC,SAAS;QACtB,UAAU,EAAE,CAAC,CAAC,UAAU;QACxB,IAAI,EAAE,CAAC,CAAC,WAAW;QACnB,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,EAAE,QAAQ,CAAC;KAC7C,CAAC,CACL,CAAA;IACD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAA;AAC1B,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Parse a human-readable size string (e.g. '1mb', '512kb', '2gb') to bytes.
3
+ * Single source of truth — used by both BodyParserMiddleware and MultipartFile.
4
+ */
5
+ export declare function parseSize(size: string): number;
6
+ //# sourceMappingURL=parseSize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseSize.d.ts","sourceRoot":"","sources":["../../src/bodyparser/parseSize.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAc9C"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Parse a human-readable size string (e.g. '1mb', '512kb', '2gb') to bytes.
3
+ * Single source of truth — used by both BodyParserMiddleware and MultipartFile.
4
+ */
5
+ export function parseSize(size) {
6
+ const match = size.match(/^(\d+)(kb|mb|gb)?$/i);
7
+ if (!match)
8
+ return 1024 * 1024; // default 1mb
9
+ const num = parseInt(match[1], 10);
10
+ switch (match[2]?.toLowerCase()) {
11
+ case 'kb':
12
+ return num * 1024;
13
+ case 'mb':
14
+ return num * 1024 * 1024;
15
+ case 'gb':
16
+ return num * 1024 * 1024 * 1024;
17
+ default:
18
+ return num;
19
+ }
20
+ }
21
+ //# sourceMappingURL=parseSize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseSize.js","sourceRoot":"","sources":["../../src/bodyparser/parseSize.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAA;IAC/C,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,GAAG,IAAI,CAAA,CAAC,cAAc;IAC7C,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IAClC,QAAQ,KAAK,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,EAAE,CAAC;QAChC,KAAK,IAAI;YACP,OAAO,GAAG,GAAG,IAAI,CAAA;QACnB,KAAK,IAAI;YACP,OAAO,GAAG,GAAG,IAAI,GAAG,IAAI,CAAA;QAC1B,KAAK,IAAI;YACP,OAAO,GAAG,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;QACjC;YACE,OAAO,GAAG,CAAA;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Default HyperServer factory — encapsulates the platform-suffix mapping
3
+ * and the require() lookup so consumer apps stop hand-rolling the same
4
+ * ~25 lines in every `bin/server.ts`.
5
+ *
6
+ * Usage in an app:
7
+ *
8
+ * import { createHyperServerFactory } from '@c9up/ream/bootstrap'
9
+ * new Ignitor(APP_ROOT, {
10
+ * port: 3000,
11
+ * serverFactory: await createHyperServerFactory(),
12
+ * })
13
+ *
14
+ * Returns `undefined` when no prebuilt binary matches the host platform —
15
+ * callers can branch on that to fall back to a JS-only server in tests.
16
+ *
17
+ * Binary lives at the package root (`./index.<platform>.node`),
18
+ * matching the @c9up/chronos / @c9up/sigil convention.
19
+ */
20
+ import type { HyperServerLike } from '../Ignitor.js';
21
+ /**
22
+ * Resolve the prebuilt HyperServer NAPI binary for the current platform.
23
+ * Returns a `serverFactory` compatible with `IgnitorConfig`, or `undefined`
24
+ * when no binary is available (unsupported platform / missing build).
25
+ */
26
+ export declare function createHyperServerFactory(): ((port: number) => HyperServerLike) | undefined;
27
+ //# sourceMappingURL=hyper-server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hyper-server.d.ts","sourceRoot":"","sources":["../../src/bootstrap/hyper-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAMH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AA2BpD;;;;GAIG;AACH,wBAAgB,wBAAwB,IAAI,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,eAAe,CAAC,GAAG,SAAS,CAqB1F"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Default HyperServer factory — encapsulates the platform-suffix mapping
3
+ * and the require() lookup so consumer apps stop hand-rolling the same
4
+ * ~25 lines in every `bin/server.ts`.
5
+ *
6
+ * Usage in an app:
7
+ *
8
+ * import { createHyperServerFactory } from '@c9up/ream/bootstrap'
9
+ * new Ignitor(APP_ROOT, {
10
+ * port: 3000,
11
+ * serverFactory: await createHyperServerFactory(),
12
+ * })
13
+ *
14
+ * Returns `undefined` when no prebuilt binary matches the host platform —
15
+ * callers can branch on that to fall back to a JS-only server in tests.
16
+ *
17
+ * Binary lives at the package root (`./index.<platform>.node`),
18
+ * matching the @c9up/chronos / @c9up/sigil convention.
19
+ */
20
+ import { createRequire } from 'node:module';
21
+ import { dirname, join } from 'node:path';
22
+ import { arch, platform } from 'node:process';
23
+ import { fileURLToPath } from 'node:url';
24
+ const PLATFORM_SUFFIX = {
25
+ 'linux-x64': 'linux-x64-gnu',
26
+ 'linux-arm64': 'linux-arm64-gnu',
27
+ 'darwin-x64': 'darwin-x64',
28
+ 'darwin-arm64': 'darwin-arm64',
29
+ 'win32-x64': 'win32-x64-msvc',
30
+ };
31
+ function isHyperServerNapi(value) {
32
+ return (typeof value === 'object' &&
33
+ value !== null &&
34
+ 'HyperServer' in value &&
35
+ typeof value.HyperServer === 'function');
36
+ }
37
+ /**
38
+ * Resolve the prebuilt HyperServer NAPI binary for the current platform.
39
+ * Returns a `serverFactory` compatible with `IgnitorConfig`, or `undefined`
40
+ * when no binary is available (unsupported platform / missing build).
41
+ */
42
+ export function createHyperServerFactory() {
43
+ const suffix = PLATFORM_SUFFIX[`${platform}-${arch}`];
44
+ if (!suffix)
45
+ return undefined;
46
+ const require2 = createRequire(import.meta.url);
47
+ const here = dirname(fileURLToPath(import.meta.url));
48
+ // bootstrap/hyper-server.ts lives at src/bootstrap/, so the package root
49
+ // is two directories up.
50
+ const binaryPath = join(here, '..', '..', `index.${suffix}.node`);
51
+ let mod;
52
+ try {
53
+ mod = require2(binaryPath);
54
+ }
55
+ catch {
56
+ return undefined;
57
+ }
58
+ if (!isHyperServerNapi(mod))
59
+ return undefined;
60
+ const Ctor = mod.HyperServer;
61
+ return (port) => new Ctor(port);
62
+ }
63
+ //# sourceMappingURL=hyper-server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hyper-server.js","sourceRoot":"","sources":["../../src/bootstrap/hyper-server.ts"],"names":[],"mappings":"AAAA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ClB,CAAC;IAED,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC;QAAE,OAAO,SAAS,CAAA;IAE7C,MAAM,IAAI,GAAG,GAAG,CAAC,WAAW,CAAA;IAC5B,OAAO,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAA;AACzC,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * CommandRunner — minimal CLI command framework.
3
+ *
4
+ * Registers commands and dispatches based on argv.
5
+ * Like AdonisJS Ace but lightweight.
6
+ */
7
+ export interface Command {
8
+ name: string;
9
+ description: string;
10
+ run(args: string[], flags: Record<string, string | boolean>): Promise<void>;
11
+ }
12
+ export declare class CommandRunner {
13
+ #private;
14
+ register(command: Command): this;
15
+ handle(argv: string[]): Promise<void>;
16
+ getCommands(): Map<string, Command>;
17
+ }
18
+ //# sourceMappingURL=CommandRunner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandRunner.d.ts","sourceRoot":"","sources":["../../src/console/CommandRunner.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAC5E;AAED,qBAAa,aAAa;;IAGxB,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAK1B,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IA2B3C,WAAW,IAAI,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;CAGpC"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * CommandRunner — minimal CLI command framework.
3
+ *
4
+ * Registers commands and dispatches based on argv.
5
+ * Like AdonisJS Ace but lightweight.
6
+ */
7
+ export class CommandRunner {
8
+ #commands = new Map();
9
+ register(command) {
10
+ this.#commands.set(command.name, command);
11
+ return this;
12
+ }
13
+ async handle(argv) {
14
+ const { commandName, args, flags } = parseArgv(argv);
15
+ if (!commandName || commandName === 'help') {
16
+ this.#printHelp();
17
+ return;
18
+ }
19
+ const command = this.#commands.get(commandName);
20
+ if (!command) {
21
+ console.error(`Unknown command: ${commandName}`);
22
+ console.error(`Run without arguments to see available commands.`);
23
+ process.exitCode = 1;
24
+ return;
25
+ }
26
+ await command.run(args, flags);
27
+ }
28
+ #printHelp() {
29
+ console.log('\nAvailable commands:\n');
30
+ for (const [name, cmd] of this.#commands) {
31
+ console.log(` ${name.padEnd(25)} ${cmd.description}`);
32
+ }
33
+ console.log('');
34
+ }
35
+ getCommands() {
36
+ return new Map(this.#commands);
37
+ }
38
+ }
39
+ function parseArgv(argv) {
40
+ const flags = {};
41
+ const positional = [];
42
+ for (const arg of argv) {
43
+ if (arg.startsWith('--')) {
44
+ const eqIdx = arg.indexOf('=');
45
+ if (eqIdx !== -1) {
46
+ flags[arg.slice(2, eqIdx)] = arg.slice(eqIdx + 1);
47
+ }
48
+ else {
49
+ flags[arg.slice(2)] = true;
50
+ }
51
+ }
52
+ else if (arg.startsWith('-') && arg.length === 2) {
53
+ flags[arg.slice(1)] = true;
54
+ }
55
+ else {
56
+ positional.push(arg);
57
+ }
58
+ }
59
+ return {
60
+ commandName: positional[0],
61
+ args: positional.slice(1),
62
+ flags,
63
+ };
64
+ }
65
+ //# sourceMappingURL=CommandRunner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandRunner.js","sourceRoot":"","sources":["../../src/console/CommandRunner.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,MAAM,OAAO,aAAa;IACxB,SAAS,GAAyB,IAAI,GAAG,EAAE,CAAA;IAE3C,QAAQ,CAAC,OAAgB;QACvB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC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