@forinda/kickjs 10.14.2 → 10.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (270) hide show
  1. package/dist/{adapter-B64IOivZ.d.mts → adapter-D_nUmKEQ.d.mts} +172 -34
  2. package/dist/adapter-D_nUmKEQ.d.mts.map +1 -0
  3. package/dist/{allowed-hosts-U12_gESr.d.mts → allowed-hosts-BQlQFt-1.d.mts} +6 -1
  4. package/dist/allowed-hosts-BQlQFt-1.d.mts.map +1 -0
  5. package/dist/{app-module-EmIojM4d.d.mts → app-module-BmViGLgj.d.mts} +5 -5
  6. package/dist/{app-module-EmIojM4d.d.mts.map → app-module-BmViGLgj.d.mts.map} +1 -1
  7. package/dist/application-B16ltRnC.mjs +14 -0
  8. package/dist/application-B16ltRnC.mjs.map +1 -0
  9. package/dist/{application-CGcY8SZZ.d.mts → application-ClCq0AgY.d.mts} +190 -53
  10. package/dist/application-ClCq0AgY.d.mts.map +1 -0
  11. package/dist/{body-policy-Be3Y0hjq.mjs → body-policy-D8LveWmO.mjs} +2 -2
  12. package/dist/{body-policy-Be3Y0hjq.mjs.map → body-policy-D8LveWmO.mjs.map} +1 -1
  13. package/dist/{bootstrap-Bvk3BWJX.mjs → bootstrap-C5NvsxHQ.mjs} +3 -3
  14. package/dist/bootstrap-C5NvsxHQ.mjs.map +1 -0
  15. package/dist/{bounded-counters-Bh5jeT9I.mjs → bounded-counters-BtvB2daV.mjs} +2 -2
  16. package/dist/{bounded-counters-Bh5jeT9I.mjs.map → bounded-counters-BtvB2daV.mjs.map} +1 -1
  17. package/dist/{breach-padding-DfT9MXGb.d.mts → breach-padding-BUuc21Eu.d.mts} +6 -1
  18. package/dist/breach-padding-BUuc21Eu.d.mts.map +1 -0
  19. package/dist/{cache-DMIt3c6M.d.mts → cache-ByX5O2Hp.d.mts} +26 -1
  20. package/dist/{cache-DMIt3c6M.d.mts.map → cache-ByX5O2Hp.d.mts.map} +1 -1
  21. package/dist/{client-ip-CGH_IvnC.mjs → client-ip-CWvyHmqt.mjs} +2 -2
  22. package/dist/{client-ip-CGH_IvnC.mjs.map → client-ip-CWvyHmqt.mjs.map} +1 -1
  23. package/dist/config/index.d.mts +6 -1
  24. package/dist/config/index.mjs +2 -2
  25. package/dist/{config-CjFxvh0v.mjs → config-BIQoDNil.mjs} +3 -3
  26. package/dist/{config-CjFxvh0v.mjs.map → config-BIQoDNil.mjs.map} +1 -1
  27. package/dist/container-DtdUiRwr.d.mts +3 -0
  28. package/dist/{context-BvZLaTeE.mjs → context-BzFNflxV.mjs} +3 -3
  29. package/dist/context-BzFNflxV.mjs.map +1 -0
  30. package/dist/{context-errors-BZVS0B1O.mjs → context-errors-BmaG4vwd.mjs} +2 -2
  31. package/dist/context-errors-BmaG4vwd.mjs.map +1 -0
  32. package/dist/{contributor-runner-fdKy6Tme.mjs → contributor-runner-BnJzu2GI.mjs} +3 -3
  33. package/dist/contributor-runner-BnJzu2GI.mjs.map +1 -0
  34. package/dist/core/adapter.d.mts +1 -1
  35. package/dist/core/adapter.mjs +1 -1
  36. package/dist/core/app-module.d.mts +1 -1
  37. package/dist/core/app-module.mjs +1 -1
  38. package/dist/core/cache.d.mts +1 -1
  39. package/dist/core/cache.mjs +1 -1
  40. package/dist/core/cache.mjs.map +1 -1
  41. package/dist/core/container.d.mts +1 -1
  42. package/dist/core/container.mjs +2 -2
  43. package/dist/core/cron.d.mts +1 -1
  44. package/dist/core/cron.mjs +2 -2
  45. package/dist/core/cron.mjs.map +1 -1
  46. package/dist/core/decorators.d.mts +1 -1
  47. package/dist/core/decorators.mjs +2 -2
  48. package/dist/core/decorators.mjs.map +1 -1
  49. package/dist/core/errors.d.mts +1 -1
  50. package/dist/core/errors.mjs +1 -1
  51. package/dist/core/errors.mjs.map +1 -1
  52. package/dist/core/interfaces.d.mts +1 -1
  53. package/dist/core/interfaces.mjs +1 -1
  54. package/dist/core/logger.d.mts +1 -1
  55. package/dist/core/logger.mjs +1 -1
  56. package/dist/core/logger.mjs.map +1 -1
  57. package/dist/core/path.mjs +1 -1
  58. package/dist/core/plugin.d.mts +1 -1
  59. package/dist/core/plugin.mjs +1 -1
  60. package/dist/core/reactivity.d.mts +1 -1
  61. package/dist/core/reactivity.mjs +2 -2
  62. package/dist/core/reactivity.mjs.map +1 -1
  63. package/dist/core-Dqzah_BX.mjs +12 -0
  64. package/dist/core-Dqzah_BX.mjs.map +1 -0
  65. package/dist/{cors-J-q6PuSU.d.mts → cors-u1OwTxQ8.d.mts} +6 -1
  66. package/dist/cors-u1OwTxQ8.d.mts.map +1 -0
  67. package/dist/{cron-DGV1AE0R.d.mts → cron-Bxm2MY8u.d.mts} +10 -1
  68. package/dist/cron-Bxm2MY8u.d.mts.map +1 -0
  69. package/dist/{csrf-DjtJPgA3.d.mts → csrf-8-Jknvmc.d.mts} +12 -2
  70. package/dist/csrf-8-Jknvmc.d.mts.map +1 -0
  71. package/dist/{decorate-DRbXCNQz.mjs → decorate-C3to8dG-.mjs} +3 -3
  72. package/dist/{decorate-DRbXCNQz.mjs.map → decorate-C3to8dG-.mjs.map} +1 -1
  73. package/dist/{decorators-BAD8qjuq.d.mts → decorators-Bflncyz6.d.mts} +122 -6
  74. package/dist/decorators-Bflncyz6.d.mts.map +1 -0
  75. package/dist/{define-adapter-DMo6og81.mjs → define-adapter-DCjNTP6m.mjs} +2 -2
  76. package/dist/define-adapter-DCjNTP6m.mjs.map +1 -0
  77. package/dist/{di-hooks-DCqt2yJ9.mjs → di-hooks-DTDy7ABs.mjs} +2 -2
  78. package/dist/di-hooks-DTDy7ABs.mjs.map +1 -0
  79. package/dist/{disposables-BsdVu69-.mjs → disposables-BC291ukb.mjs} +1 -1
  80. package/dist/{driver-oZBQDJZz.mjs → driver-D59oWDec.mjs} +3 -3
  81. package/dist/{driver-oZBQDJZz.mjs.map → driver-D59oWDec.mjs.map} +1 -1
  82. package/dist/{error-handler-Dl_gZRNK.d.mts → error-handler-gZLQFHeE.d.mts} +2 -2
  83. package/dist/{error-handler-Dl_gZRNK.d.mts.map → error-handler-gZLQFHeE.d.mts.map} +1 -1
  84. package/dist/{errors-DZGuPLoZ.d.mts → errors-CppqPy0A.d.mts} +2 -1
  85. package/dist/errors-CppqPy0A.d.mts.map +1 -0
  86. package/dist/{express-f9CTA8qO.mjs → express-JAXx9MK0.mjs} +3 -3
  87. package/dist/{express-f9CTA8qO.mjs.map → express-JAXx9MK0.mjs.map} +1 -1
  88. package/dist/{express-lazy-DMxcLBpT.mjs → express-lazy-jIFBeDpY.mjs} +3 -3
  89. package/dist/{express-lazy-DMxcLBpT.mjs.map → express-lazy-jIFBeDpY.mjs.map} +1 -1
  90. package/dist/{handler-B66laQY0.mjs → handler-C8iAD_xz.mjs} +3 -3
  91. package/dist/{handler-B66laQY0.mjs.map → handler-C8iAD_xz.mjs.map} +1 -1
  92. package/dist/{helmet-Rwkbp9IS.d.mts → helmet-1H0LKr6y.d.mts} +6 -1
  93. package/dist/helmet-1H0LKr6y.d.mts.map +1 -0
  94. package/dist/{host-DalMsn5Z.mjs → host-Crxmi91N.mjs} +2 -2
  95. package/dist/{host-DalMsn5Z.mjs.map → host-Crxmi91N.mjs.map} +1 -1
  96. package/dist/http/application.d.mts +1 -1
  97. package/dist/http/application.mjs +2 -2
  98. package/dist/http/bootstrap.d.mts +1 -1
  99. package/dist/http/bootstrap.mjs +2 -2
  100. package/dist/http/context.d.mts +2 -2
  101. package/dist/http/context.mjs +2 -2
  102. package/dist/http/middleware/allowed-hosts.d.mts +1 -1
  103. package/dist/http/middleware/allowed-hosts.mjs +2 -2
  104. package/dist/http/middleware/allowed-hosts.mjs.map +1 -1
  105. package/dist/http/middleware/breach-padding.d.mts +1 -1
  106. package/dist/http/middleware/breach-padding.mjs +1 -1
  107. package/dist/http/middleware/breach-padding.mjs.map +1 -1
  108. package/dist/http/middleware/cors.d.mts +1 -1
  109. package/dist/http/middleware/cors.mjs +1 -1
  110. package/dist/http/middleware/cors.mjs.map +1 -1
  111. package/dist/http/middleware/csrf.d.mts +1 -1
  112. package/dist/http/middleware/csrf.mjs +2 -2
  113. package/dist/http/middleware/csrf.mjs.map +1 -1
  114. package/dist/http/middleware/error-handler.d.mts +1 -1
  115. package/dist/http/middleware/error-handler.mjs +2 -2
  116. package/dist/http/middleware/helmet.d.mts +1 -1
  117. package/dist/http/middleware/helmet.mjs +1 -1
  118. package/dist/http/middleware/helmet.mjs.map +1 -1
  119. package/dist/http/middleware/rate-limit.d.mts +1 -1
  120. package/dist/http/middleware/rate-limit.mjs +2 -2
  121. package/dist/http/middleware/rate-limit.mjs.map +1 -1
  122. package/dist/http/middleware/request-id.d.mts +1 -1
  123. package/dist/http/middleware/request-id.mjs +1 -1
  124. package/dist/http/middleware/request-id.mjs.map +1 -1
  125. package/dist/http/middleware/request-logger.d.mts +1 -1
  126. package/dist/http/middleware/request-logger.mjs +2 -2
  127. package/dist/http/middleware/request-logger.mjs.map +1 -1
  128. package/dist/http/middleware/session.d.mts +1 -1
  129. package/dist/http/middleware/session.mjs +2 -2
  130. package/dist/http/middleware/session.mjs.map +1 -1
  131. package/dist/http/middleware/spa.d.mts +1 -1
  132. package/dist/http/middleware/spa.mjs +2 -2
  133. package/dist/http/middleware/spa.mjs.map +1 -1
  134. package/dist/http/middleware/upload.d.mts +2 -2
  135. package/dist/http/middleware/upload.mjs +2 -2
  136. package/dist/http/middleware/upload.mjs.map +1 -1
  137. package/dist/http/middleware/validate.d.mts +1 -1
  138. package/dist/http/middleware/validate.mjs +1 -1
  139. package/dist/http/middleware/views.d.mts +1 -1
  140. package/dist/http/middleware/views.mjs +2 -2
  141. package/dist/http/middleware/views.mjs.map +1 -1
  142. package/dist/http/query/index.d.mts +1 -1
  143. package/dist/http/query/index.mjs +2 -2
  144. package/dist/http/router-builder.d.mts +1 -1
  145. package/dist/http/router-builder.mjs +2 -2
  146. package/dist/http/runtimes/express.d.mts +3 -2
  147. package/dist/http/runtimes/express.d.mts.map +1 -1
  148. package/dist/http/runtimes/express.mjs +2 -2
  149. package/dist/http/runtimes/fastify.d.mts +3 -3
  150. package/dist/http/runtimes/fastify.mjs +2 -2
  151. package/dist/http/runtimes/fastify.mjs.map +1 -1
  152. package/dist/http/runtimes/h3-web.mjs +1 -1
  153. package/dist/http/runtimes/h3.d.mts +1 -1
  154. package/dist/http/runtimes/h3.mjs +2 -2
  155. package/dist/http/runtimes/h3.mjs.map +1 -1
  156. package/dist/{index-ZbCnCyQx.d.mts → index-CtjmSXFy.d.mts} +11 -1
  157. package/dist/index-CtjmSXFy.d.mts.map +1 -0
  158. package/dist/{index-CFTwnev9.d.mts → index-DoukvKwh.d.mts} +2 -2
  159. package/dist/{index-CFTwnev9.d.mts.map → index-DoukvKwh.d.mts.map} +1 -1
  160. package/dist/index.d.mts +34 -28
  161. package/dist/index.mjs +2 -2
  162. package/dist/index.mjs.map +1 -1
  163. package/dist/{interfaces-BQhYh3lL.d.mts → interfaces-CvO9sAea.d.mts} +3 -3
  164. package/dist/{interfaces-BQhYh3lL.d.mts.map → interfaces-CvO9sAea.d.mts.map} +1 -1
  165. package/dist/{is-production-9QzMIRuO.mjs → is-production-LziEMGrc.mjs} +2 -2
  166. package/dist/{is-production-9QzMIRuO.mjs.map → is-production-LziEMGrc.mjs.map} +1 -1
  167. package/dist/{jobs-CuZqVDDG.mjs → jobs-D7ToA0yF.mjs} +3 -3
  168. package/dist/jobs-D7ToA0yF.mjs.map +1 -0
  169. package/dist/{kv-stores-wTD3VDPB.d.mts → kv-stores-DdGPLXQG.d.mts} +32 -7
  170. package/dist/kv-stores-DdGPLXQG.d.mts.map +1 -0
  171. package/dist/{kv-stores-C9CJ3xCB.mjs → kv-stores-DpM57Xr5.mjs} +3 -3
  172. package/dist/kv-stores-DpM57Xr5.mjs.map +1 -0
  173. package/dist/{lazy-serve-static-DVWmKM7Z.mjs → lazy-serve-static-DxI2K-zs.mjs} +3 -3
  174. package/dist/{lazy-serve-static-DVWmKM7Z.mjs.map → lazy-serve-static-DxI2K-zs.mjs.map} +1 -1
  175. package/dist/{logger-BL8MiSrm.d.mts → logger-ByJsVwqY.d.mts} +3 -3
  176. package/dist/{logger-BL8MiSrm.d.mts.map → logger-ByJsVwqY.d.mts.map} +1 -1
  177. package/dist/{metadata-BZRtQog3.mjs → metadata-nTTSnVTO.mjs} +1 -1
  178. package/dist/{observers-B4VnKAHK.mjs → observers-fQtCIKLq.mjs} +2 -2
  179. package/dist/observers-fQtCIKLq.mjs.map +1 -0
  180. package/dist/{precompressed-AxF66Ls0.mjs → precompressed-BtwmgzyS.mjs} +2 -2
  181. package/dist/{precompressed-AxF66Ls0.mjs.map → precompressed-BtwmgzyS.mjs.map} +1 -1
  182. package/dist/{query-BwUR-ssX.mjs → query-Dr28oT30.mjs} +2 -2
  183. package/dist/query-Dr28oT30.mjs.map +1 -0
  184. package/dist/{rate-limit-DMiV6bAq.d.mts → rate-limit-BQx_P6gG.d.mts} +11 -1
  185. package/dist/rate-limit-BQx_P6gG.d.mts.map +1 -0
  186. package/dist/{reactivity-Dski64km.d.mts → reactivity-KZOrwVeK.d.mts} +32 -1
  187. package/dist/reactivity-KZOrwVeK.d.mts.map +1 -0
  188. package/dist/{reply-B5kZ6VGv.mjs → reply-ChoI5SvM.mjs} +3 -3
  189. package/dist/{reply-B5kZ6VGv.mjs.map → reply-ChoI5SvM.mjs.map} +1 -1
  190. package/dist/{request-id-B_n-3A16.d.mts → request-id-B9Myiv75.d.mts} +2 -1
  191. package/dist/request-id-B9Myiv75.d.mts.map +1 -0
  192. package/dist/{request-logger-BV1C5r5q.d.mts → request-logger-CYyAuPmo.d.mts} +6 -1
  193. package/dist/request-logger-CYyAuPmo.d.mts.map +1 -0
  194. package/dist/{request-scope-D2WQwatk.mjs → request-scope-BfSNdmz9.mjs} +3 -3
  195. package/dist/{request-scope-D2WQwatk.mjs.map → request-scope-BfSNdmz9.mjs.map} +1 -1
  196. package/dist/{respond-C6ohI69y.mjs → respond-1BjaDME9.mjs} +2 -2
  197. package/dist/{respond-C6ohI69y.mjs.map → respond-1BjaDME9.mjs.map} +1 -1
  198. package/dist/rolldown-runtime-B5KeNctS.mjs +11 -0
  199. package/dist/{route-flag-CHiMvgar.mjs → route-flag-B6ZmhkfI.mjs} +3 -3
  200. package/dist/{route-flag-CHiMvgar.mjs.map → route-flag-B6ZmhkfI.mjs.map} +1 -1
  201. package/dist/{route-policy-ckK7N1eN.mjs → route-policy-BG--gAcF.mjs} +2 -2
  202. package/dist/route-policy-BG--gAcF.mjs.map +1 -0
  203. package/dist/{router-builder-Dtyya4qP.d.mts → router-builder-BkIW_qjz.d.mts} +3 -2
  204. package/dist/router-builder-BkIW_qjz.d.mts.map +1 -0
  205. package/dist/{router-builder-D2cly8Wt.mjs → router-builder-DHKtp4I8.mjs} +3 -3
  206. package/dist/router-builder-DHKtp4I8.mjs.map +1 -0
  207. package/dist/{runtime-D9TN6CpL.mjs → runtime-CUfFIHiC.mjs} +3 -3
  208. package/dist/runtime-CUfFIHiC.mjs.map +1 -0
  209. package/dist/{session-CXWu2rXW.d.mts → session-DPTbfwKO.d.mts} +40 -1
  210. package/dist/session-DPTbfwKO.d.mts.map +1 -0
  211. package/dist/{settings-v2N3V8Bl.mjs → settings-I7GUX5ps.mjs} +3 -3
  212. package/dist/{settings-v2N3V8Bl.mjs.map → settings-I7GUX5ps.mjs.map} +1 -1
  213. package/dist/{token-DtW16tw3.mjs → token-uWfhVlfe.mjs} +1 -1
  214. package/dist/{upload-eNNueUxR.d.mts → upload-O3VTcODy.d.mts} +3 -3
  215. package/dist/{upload-eNNueUxR.d.mts.map → upload-O3VTcODy.d.mts.map} +1 -1
  216. package/dist/{upload-config-BXjBiNjC.mjs → upload-config-BXqBuyza.mjs} +2 -2
  217. package/dist/{upload-config-BXjBiNjC.mjs.map → upload-config-BXqBuyza.mjs.map} +1 -1
  218. package/dist/url-for-CuMaQ2wS.mjs +12 -0
  219. package/dist/url-for-CuMaQ2wS.mjs.map +1 -0
  220. package/dist/{validate-BbthfLBb.d.mts → validate-CTgfm7oE.d.mts} +2 -2
  221. package/dist/{validate-BbthfLBb.d.mts.map → validate-CTgfm7oE.d.mts.map} +1 -1
  222. package/dist/{view-renderer-C4sMEruA.mjs → view-renderer-Bf1Wy-DQ.mjs} +3 -3
  223. package/dist/view-renderer-Bf1Wy-DQ.mjs.map +1 -0
  224. package/dist/{web-crypto-SXVOPDxW.mjs → web-crypto-JzoGmiG0.mjs} +2 -2
  225. package/dist/{web-crypto-SXVOPDxW.mjs.map → web-crypto-JzoGmiG0.mjs.map} +1 -1
  226. package/dist/web.d.mts +6 -6
  227. package/dist/web.d.mts.map +1 -1
  228. package/dist/web.mjs +2 -2
  229. package/dist/web.mjs.map +1 -1
  230. package/package.json +10 -10
  231. package/dist/adapter-B64IOivZ.d.mts.map +0 -1
  232. package/dist/allowed-hosts-U12_gESr.d.mts.map +0 -1
  233. package/dist/application-BzimU62Q.mjs +0 -14
  234. package/dist/application-BzimU62Q.mjs.map +0 -1
  235. package/dist/application-CGcY8SZZ.d.mts.map +0 -1
  236. package/dist/bootstrap-Bvk3BWJX.mjs.map +0 -1
  237. package/dist/breach-padding-DfT9MXGb.d.mts.map +0 -1
  238. package/dist/container-4iJdDkRH.d.mts +0 -3
  239. package/dist/context-BvZLaTeE.mjs.map +0 -1
  240. package/dist/context-errors-BZVS0B1O.mjs.map +0 -1
  241. package/dist/contributor-runner-fdKy6Tme.mjs.map +0 -1
  242. package/dist/core-CCIpjo6g.mjs +0 -12
  243. package/dist/core-CCIpjo6g.mjs.map +0 -1
  244. package/dist/cors-J-q6PuSU.d.mts.map +0 -1
  245. package/dist/cron-DGV1AE0R.d.mts.map +0 -1
  246. package/dist/csrf-DjtJPgA3.d.mts.map +0 -1
  247. package/dist/decorators-BAD8qjuq.d.mts.map +0 -1
  248. package/dist/define-adapter-DMo6og81.mjs.map +0 -1
  249. package/dist/di-hooks-DCqt2yJ9.mjs.map +0 -1
  250. package/dist/errors-DZGuPLoZ.d.mts.map +0 -1
  251. package/dist/helmet-Rwkbp9IS.d.mts.map +0 -1
  252. package/dist/index-ZbCnCyQx.d.mts.map +0 -1
  253. package/dist/jobs-CuZqVDDG.mjs.map +0 -1
  254. package/dist/kv-stores-C9CJ3xCB.mjs.map +0 -1
  255. package/dist/kv-stores-wTD3VDPB.d.mts.map +0 -1
  256. package/dist/observers-B4VnKAHK.mjs.map +0 -1
  257. package/dist/query-BwUR-ssX.mjs.map +0 -1
  258. package/dist/rate-limit-DMiV6bAq.d.mts.map +0 -1
  259. package/dist/reactivity-Dski64km.d.mts.map +0 -1
  260. package/dist/request-id-B_n-3A16.d.mts.map +0 -1
  261. package/dist/request-logger-BV1C5r5q.d.mts.map +0 -1
  262. package/dist/rolldown-runtime-DuhQYUab.mjs +0 -11
  263. package/dist/route-policy-ckK7N1eN.mjs.map +0 -1
  264. package/dist/router-builder-D2cly8Wt.mjs.map +0 -1
  265. package/dist/router-builder-Dtyya4qP.d.mts.map +0 -1
  266. package/dist/runtime-D9TN6CpL.mjs.map +0 -1
  267. package/dist/session-CXWu2rXW.d.mts.map +0 -1
  268. package/dist/url-for-C4Eomib7.mjs +0 -12
  269. package/dist/url-for-C4Eomib7.mjs.map +0 -1
  270. package/dist/view-renderer-C4sMEruA.mjs.map +0 -1
@@ -1,23 +1,38 @@
1
1
 
2
2
  import { a as SettingsDeclaration, c as VarOrigin, t as ConfigVar } from "./settings-CB6lh6_s.mjs";
3
- import "./index-CFTwnev9.mjs";
4
- import { Dt as ModuleFactory, E as RequestContext, Ft as ModuleRegistry, H as RouteName, Pt as KickPlugin, Q as AdapterFactory, W as UrlForArgs, Wt as ResponseInfo, Yt as ConditionOutcome, a as KickServer, b as RuntimeCapabilities, c as ActiveRuntime, d as HttpRuntime, h as RouteEntry, m as RouteContributor, r as AppAdapter, x as RuntimeResponse } from "./adapter-B64IOivZ.mjs";
3
+ import "./index-DoukvKwh.mjs";
4
+ import { Bt as ModuleRegistry, E as RequestContext, H as RouteName, Mt as ModuleFactory, W as UrlForArgs, Yt as ResponseInfo, a as KickServer, b as RuntimeCapabilities, c as ActiveRuntime, d as HttpRuntime, en as ConditionOutcome, h as RouteEntry, m as RouteContributor, r as AppAdapter, rt as AdapterFactory, x as RuntimeResponse, zt as KickPlugin } from "./adapter-D_nUmKEQ.mjs";
5
5
  import { a as ConnectRequest, i as ConnectNext, n as ConnectHandler, o as ConnectResponse } from "./connect-DamOelO8.mjs";
6
- import { t as Container } from "./container-4iJdDkRH.mjs";
6
+ import { t as Container } from "./container-DtdUiRwr.mjs";
7
7
  import { p as RouteFlags, s as RouteFlagDeclarations } from "./route-flag-CjXQl-oX.mjs";
8
- import { C as MetaValue, c as ContextDecorator, h as DepValue, m as ContributorRegistrations, r as AppModuleEntry, u as ContextDecoratorSpec, x as ContextMetaKey } from "./app-module-EmIojM4d.mjs";
9
- import { l as PlatformContext, m as Reply } from "./kv-stores-wTD3VDPB.mjs";
10
- import { t as ComputedRef } from "./reactivity-Dski64km.mjs";
11
- import { t as ValidationErrorFactory } from "./validate-BbthfLBb.mjs";
12
- import { t as AllowedHostsOptions } from "./allowed-hosts-U12_gESr.mjs";
13
- import { t as BuildRoutesOptions } from "./router-builder-Dtyya4qP.mjs";
14
- import "./error-handler-Dl_gZRNK.mjs";
15
- import "./csrf-DjtJPgA3.mjs";
16
- import "./upload-eNNueUxR.mjs";
8
+ import { C as MetaValue, c as ContextDecorator, h as DepValue, m as ContributorRegistrations, r as AppModuleEntry, u as ContextDecoratorSpec, x as ContextMetaKey } from "./app-module-BmViGLgj.mjs";
9
+ import { l as PlatformContext, m as Reply } from "./kv-stores-DdGPLXQG.mjs";
10
+ import { t as ComputedRef } from "./reactivity-KZOrwVeK.mjs";
11
+ import { t as ValidationErrorFactory } from "./validate-CTgfm7oE.mjs";
12
+ import { t as AllowedHostsOptions } from "./allowed-hosts-BQlQFt-1.mjs";
13
+ import { t as BuildRoutesOptions } from "./router-builder-BkIW_qjz.mjs";
14
+ import "./error-handler-gZLQFHeE.mjs";
15
+ import "./csrf-8-Jknvmc.mjs";
16
+ import "./upload-O3VTcODy.mjs";
17
17
  import http, { IncomingMessage, ServerResponse } from "node:http";
18
18
  import https from "node:https";
19
19
  import tls from "node:tls";
20
20
  import { AsyncLocalStorage } from "node:async_hooks";
21
+ /** The fields of a {@link KickError}. */
22
+ interface KickErrorInit {
23
+ /** Short stable identifier (e.g. `KICK001`, `NO_PROVIDER`). */
24
+ code: string;
25
+ /** One-line headline. */
26
+ summary: string;
27
+ /** Multi-line explanation of why this happened. */
28
+ cause?: string;
29
+ /** Multi-line actionable fix — show exact code if possible. */
30
+ fix?: string;
31
+ /** Absolute URL to the docs page that covers this error. */
32
+ docsUrl?: string;
33
+ /** Arbitrary structured fields for log consumers / debug tooling. */
34
+ context?: Record<string, unknown>;
35
+ }
21
36
  /**
22
37
  * Structured framework error with code, cause, and actionable fix hint.
23
38
  *
@@ -34,21 +49,9 @@ import { AsyncLocalStorage } from "node:async_hooks";
34
49
  * Per-error factories live in `kick-errors.ts` — those are the public
35
50
  * entry points framework code uses. `KickError` is exported so adopters
36
51
  * can build their own structured errors using the same shape.
52
+ *
53
+ * @see https://kickjs.app/guide/error-handling
37
54
  */
38
- interface KickErrorInit {
39
- /** Short stable identifier (e.g. `KICK001`, `NO_PROVIDER`). */
40
- code: string;
41
- /** One-line headline. */
42
- summary: string;
43
- /** Multi-line explanation of why this happened. */
44
- cause?: string;
45
- /** Multi-line actionable fix — show exact code if possible. */
46
- fix?: string;
47
- /** Absolute URL to the docs page that covers this error. */
48
- docsUrl?: string;
49
- /** Arbitrary structured fields for log consumers / debug tooling. */
50
- context?: Record<string, unknown>;
51
- }
52
55
  declare class KickError extends Error {
53
56
  readonly code: string;
54
57
  readonly summary: string;
@@ -58,6 +61,7 @@ declare class KickError extends Error {
58
61
  readonly context?: Record<string, unknown>;
59
62
  constructor(init: KickErrorInit);
60
63
  }
64
+ /** Options for {@link formatKickError}. */
61
65
  interface FormatKickErrorOptions {
62
66
  /**
63
67
  * Render ANSI colour codes. Defaults to TTY detection (`NO_COLOR` /
@@ -72,24 +76,8 @@ interface FormatKickErrorOptions {
72
76
  * colour — the colour flag only toggles ANSI codes.
73
77
  */
74
78
  declare function formatKickError(err: KickErrorInit | KickError, options?: FormatKickErrorOptions): string;
75
- /**
76
- * Circuit Breaker pattern for external service calls.
77
- *
78
- * Protects your application from cascading failures when downstream
79
- * services are unhealthy by short-circuiting requests after a
80
- * configurable failure threshold.
81
- *
82
- * @example
83
- * ```ts
84
- * const breaker = new CircuitBreaker('payment-api', {
85
- * failureThreshold: 5,
86
- * resetTimeout: 30_000,
87
- * })
88
- *
89
- * const result = await breaker.execute(() => fetch('https://payment.example.com/charge'))
90
- * ```
91
- */
92
79
  type CircuitBreakerState = 'closed' | 'open' | 'half_open';
80
+ /** Options for {@link CircuitBreaker}. */
93
81
  interface CircuitBreakerOptions {
94
82
  /** Number of consecutive failures before the circuit opens. */
95
83
  failureThreshold: number;
@@ -98,6 +86,7 @@ interface CircuitBreakerOptions {
98
86
  /** Max requests allowed in HALF_OPEN state before deciding (default 1). */
99
87
  halfOpenMax?: number;
100
88
  }
89
+ /** What {@link CircuitBreaker.getStats} returns. */
101
90
  interface CircuitBreakerStats {
102
91
  failures: number;
103
92
  successes: number;
@@ -111,6 +100,25 @@ declare class CircuitOpenError extends Error {
111
100
  readonly breakerName: string;
112
101
  constructor(breakerName: string);
113
102
  }
103
+ /**
104
+ * Circuit Breaker pattern for external service calls.
105
+ *
106
+ * Protects your application from cascading failures when downstream
107
+ * services are unhealthy by short-circuiting requests after a
108
+ * configurable failure threshold.
109
+ *
110
+ * @example
111
+ * ```ts
112
+ * const breaker = new CircuitBreaker('payment-api', {
113
+ * failureThreshold: 5,
114
+ * resetTimeout: 30_000,
115
+ * })
116
+ *
117
+ * const result = await breaker.execute(() => fetch('https://payment.example.com/charge'))
118
+ * ```
119
+ *
120
+ * @see https://kickjs.app/guide/middleware
121
+ */
114
122
  declare class CircuitBreaker {
115
123
  readonly name: string;
116
124
  private state;
@@ -145,7 +153,7 @@ declare class CircuitBreaker {
145
153
  * `DuplicateContributorError` are startup-time errors raised during
146
154
  * pipeline build (topo-sort + validation), not per-request — a
147
155
  * misconfigured app fails to boot rather than fails a request. Per the
148
- * locked design in `architecture.md` §20.4, the pipeline is validated
156
+ * locked design in https://kickjs.app/guide/context-decorators, the pipeline is validated
149
157
  * once when each route is mounted and the resolved order is cached on
150
158
  * the route.
151
159
  *
@@ -191,7 +199,7 @@ declare class MissingContributorError extends Error {
191
199
  * than reaching this error at all. This error remains the backstop for
192
200
  * routes typegen couldn't prove (module/adapter/bootstrap registrations),
193
201
  * handlers typed as plain `RequestContext`, and contributors that ran but
194
- * resolved to `undefined`. See `architecture.md` §20.14.
202
+ * resolved to `undefined`. See https://kickjs.app/guide/context-decorators
195
203
  *
196
204
  * @example
197
205
  * ```text
@@ -224,7 +232,7 @@ declare class ContributorCycleError extends Error {
224
232
  /**
225
233
  * Two contributors at the same precedence level both produce the same key
226
234
  * for the same route. Precedence resolution (method > class > module >
227
- * adapter > global, per architecture.md §20.4) silently drops
235
+ * adapter > global, per https://kickjs.app/guide/context-decorators) silently drops
228
236
  * lower-precedence duplicates; this error fires only when ties occur
229
237
  * within a single level — e.g., two method-level decorators declaring
230
238
  * `key: 'tenant'`.
@@ -266,7 +274,7 @@ interface MountSortItem {
266
274
  /**
267
275
  * Other plugin/adapter names that must mount before this one. Cycles
268
276
  * and missing names fail at boot — same fail-fast contract as the
269
- * Context Contributor pipeline (architecture.md §20.4).
277
+ * Context Contributor pipeline.
270
278
  */
271
279
  dependsOn?: readonly string[];
272
280
  }
@@ -318,13 +326,16 @@ declare class MountCycleError extends Error {
318
326
  * @throws {MountCycleError} the dep graph contains a cycle
319
327
  */
320
328
  declare function mountSort<T extends MountSortItem>(items: readonly T[], kind: MountKind): T[];
329
+ /** How asset keys are made from file paths: `'strip'` drops the extension, `'with-extension'` keeps it, `'auto'` keeps it only when two files would share a key. */
321
330
  type AssetKeyStrategy = 'auto' | 'strip' | 'with-extension';
331
+ /** One file's source-relative path and its manifest key. */
322
332
  interface AssetKeyPair {
323
333
  /** Source-relative path the file was discovered at. */
324
334
  rel: string;
325
335
  /** Final logical key for the manifest, including the namespace prefix. */
326
336
  key: string;
327
337
  }
338
+ /** Options for `groupAssetKeys()`. */
328
339
  interface GroupAssetKeysOptions {
329
340
  /**
330
341
  * Strategy applied to this namespace. Default `'auto'`.
@@ -335,6 +346,7 @@ interface GroupAssetKeysOptions {
335
346
  */
336
347
  strategy?: AssetKeyStrategy;
337
348
  }
349
+ /** What `groupAssetKeys()` returns: the path/key pairs, and how many key collisions `'auto'` resolved by keeping extensions. */
338
350
  interface GroupAssetKeysResult {
339
351
  pairs: AssetKeyPair[];
340
352
  /**
@@ -359,6 +371,9 @@ interface GroupAssetKeysResult {
359
371
  declare function groupAssetKeys(namespace: string, paths: readonly string[], opts?: GroupAssetKeysOptions): GroupAssetKeysResult;
360
372
  /** Strip the final extension from a path. `'mails/welcome.ejs'` → `'mails/welcome'`. */
361
373
  declare function stripExt(path: string): string;
374
+ /**
375
+ * Route flags by method and path, for middleware that runs before route matching. Each mounted route is added at boot; `lookup(method, pathname)` returns the flags of the first matching route, or an empty map. One table per Application; middleware gets it through {@link bindRoutePolicy}.
376
+ */
362
377
  declare class RoutePolicyTable {
363
378
  /** Bucketed by method: an incoming request only scans its own verb. */
364
379
  private readonly byMethod;
@@ -394,6 +409,7 @@ interface StartupStep {
394
409
  name: string;
395
410
  ms: number;
396
411
  }
412
+ /** What `app.getStartupTimeline()` returns: total boot time and each timed step, in milliseconds. */
397
413
  interface StartupTimelineSnapshot {
398
414
  totalMs: number;
399
415
  steps: readonly StartupStep[];
@@ -418,6 +434,7 @@ interface CheckContext {
418
434
  }>;
419
435
  production: boolean;
420
436
  }
437
+ /** A check run at boot against the app's options and mounted routes. Create one with {@link defineCheck} and pass it in `bootstrap({ checks })`. */
421
438
  interface StartupCheck {
422
439
  /** Names the check in logs; its messages carry their own IDs. */
423
440
  name: string;
@@ -432,6 +449,11 @@ declare class StartupCheckError extends Error {
432
449
  readonly messages: CheckMessage[];
433
450
  constructor(messages: CheckMessage[]);
434
451
  }
452
+ /**
453
+ * Options for {@link CacheResponse}.
454
+ *
455
+ * @see https://kickjs.app/guide/caching#caching-whole-responses
456
+ */
435
457
  interface CacheResponseOptions {
436
458
  /** Seconds a stored response is served as fresh. */
437
459
  maxAge: number;
@@ -462,7 +484,31 @@ interface CacheResponseOptions {
462
484
  */
463
485
  key?: string | ((ctx: RequestContext) => string | null);
464
486
  }
487
+ /**
488
+ * Caches a route's whole response for `maxAge` seconds, answers `304` on a
489
+ * matching ETag, and with `swr` serves a stale copy while one request
490
+ * rebuilds it. Only `200` responses are stored. With the default or a string
491
+ * key, requests that identify the caller skip the cache unless the header is
492
+ * listed in `varies`; a `key` function skips that check, so it must include
493
+ * the user or tenant when the response depends on them.
494
+ *
495
+ * @example
496
+ * ```ts
497
+ * `@CacheResponse({ maxAge: 60, swr: 300, varies: ['accept-language'] })`
498
+ * `@Get('/')`
499
+ * list(ctx: RequestContext) {
500
+ * // …
501
+ * }
502
+ * ```
503
+ *
504
+ * @see https://kickjs.app/guide/caching
505
+ */
465
506
  declare function CacheResponse(options: CacheResponseOptions): MethodDecorator;
507
+ /**
508
+ * Options for {@link metricsAdapter}.
509
+ *
510
+ * @see https://kickjs.app/guide/deployment#metrics
511
+ */
466
512
  interface MetricsOptions {
467
513
  /** Where to serve the metrics. Default `/metrics`. */
468
514
  path?: string;
@@ -537,15 +583,41 @@ interface CronSchedule {
537
583
  type CronScheduler = (expression: string, options: {
538
584
  timezone?: string;
539
585
  }, tick: () => void) => CronSchedule;
586
+ /**
587
+ * Options for {@link KickCronAdapter}.
588
+ *
589
+ * @see https://kickjs.app/guide/cron
590
+ */
540
591
  interface CronAdapterOptions {
541
592
  /** Off for processes that should run no jobs (replicas, one-off scripts). Default `true`. */
542
593
  enabled?: boolean;
543
594
  /** The scheduler that drives the jobs. Default: `croner`, which must then be installed. */
544
595
  schedule?: CronScheduler;
545
596
  }
597
+ /**
598
+ * Runs every `@Cron()` method of the app's services on its schedule, after
599
+ * the server starts. Uses `croner` unless `schedule` brings another
600
+ * scheduler; `enabled: false` turns it off for a process. Under a cluster
601
+ * only one process runs the jobs.
602
+ *
603
+ * @example
604
+ * ```ts
605
+ * // pnpm add croner — or pass `schedule`
606
+ * bootstrap({ modules, adapters: [KickCronAdapter()] })
607
+ * ```
608
+ *
609
+ * @see https://kickjs.app/guide/cron
610
+ */
546
611
  declare const KickCronAdapter: AdapterFactory<CronAdapterOptions, unknown>;
612
+ /**
613
+ * `node:diagnostics_channel` tracing channel wrapping each route handler. Subscribers receive a {@link HandlerTraceContext}.
614
+ *
615
+ * @see https://kickjs.app/guide/observability#the-channels
616
+ */
547
617
  declare const HANDLER_CHANNEL = "kickjs:handler";
618
+ /** `node:diagnostics_channel` channel that publishes each reported error with its {@link ErrorInfo} fields. */
548
619
  declare const ERROR_CHANNEL = "kickjs:error";
620
+ /** `node:diagnostics_channel` channel that publishes a {@link ResponseInfo} for each finished response. */
549
621
  declare const RESPONSE_CHANNEL = "kickjs:response";
550
622
  /** What subscribers to `kickjs:handler` receive. */
551
623
  interface HandlerTraceContext {
@@ -641,6 +713,7 @@ interface KickHandler {
641
713
  * ```
642
714
  */
643
715
  declare function createHandler(options: ApplicationOptions | (() => Promise<unknown>)): KickHandler;
716
+ /** Options for {@link setupClusterPrimary}: worker count, shutdown timeout and restart limits. */
644
717
  interface ClusterOptions {
645
718
  /** Number of worker processes (default: os.cpus().length) */
646
719
  workers?: number;
@@ -687,6 +760,19 @@ interface DefineHttpContextDecoratorFn {
687
760
  */
688
761
  withParams<P extends Record<string, unknown>>(): DefineHttpContextDecoratorWithParams<P>;
689
762
  }
763
+ /**
764
+ * `defineContextDecorator` with the resolver's context typed as `RequestContext`, so `resolve` can read `ctx.req`, `ctx.headers` and `ctx.params` without generics. Use `.withParams<P>()()` for a parameterised decorator.
765
+ *
766
+ * @example
767
+ * ```ts
768
+ * const LoadTenant = defineHttpContextDecorator({
769
+ * key: 'tenant',
770
+ * resolve: (ctx) => ({ id: ctx.req.headers['x-tenant-id'] as string }),
771
+ * })
772
+ * ```
773
+ *
774
+ * @see https://kickjs.app/guide/context-decorators
775
+ */
690
776
  declare const defineHttpContextDecorator: DefineHttpContextDecoratorFn;
691
777
  /** scrypt cost. Memory per hash is `128 * N * r` bytes. */
692
778
  interface PasswordHashOptions {
@@ -757,6 +843,11 @@ interface VerifyPasswordOptions extends PasswordHashOptions {
757
843
  * `options.legacy` reads it.
758
844
  */
759
845
  declare function verifyPassword(password: string, stored: string | null | undefined, options?: VerifyPasswordOptions): Promise<PasswordCheck>;
846
+ /**
847
+ * Options for {@link createSigner}.
848
+ *
849
+ * @see https://kickjs.app/guide/passwords-and-tokens
850
+ */
760
851
  interface SignerOptions {
761
852
  /**
762
853
  * The signing secret. Pass a list to rotate: the first signs, every one
@@ -770,6 +861,7 @@ interface SignerOptions {
770
861
  */
771
862
  salt: string;
772
863
  }
864
+ /** Options for {@link Signer.verify}. */
773
865
  interface VerifyOptions {
774
866
  /** Reject tokens older than this, in milliseconds. */
775
867
  maxAge?: number;
@@ -783,6 +875,11 @@ type SignedCheck<T> = {
783
875
  ok: false;
784
876
  reason: 'invalid' | 'expired';
785
877
  };
878
+ /**
879
+ * Signs values into tamper-proof tokens and verifies them. Create one per purpose with {@link createSigner}.
880
+ *
881
+ * @see https://kickjs.app/guide/passwords-and-tokens
882
+ */
786
883
  interface Signer {
787
884
  /** Sign a JSON-serialisable value: `payload.timestamp.signature`, URL-safe. */
788
885
  sign(value: unknown): string;
@@ -800,7 +897,9 @@ declare function createSigner(options: SignerOptions): Signer;
800
897
  * @module @forinda/kickjs/http/form
801
898
  */
802
899
  declare const FLASH_KEY = "__inertia_flash";
900
+ /** Session key holding a failed form's field errors for the next page. */
803
901
  declare const FORM_ERRORS_KEY = "__inertia_errors";
902
+ /** Session key holding the values a failed form submitted, to refill the form. */
804
903
  declare const OLD_INPUT_KEY = "__kick_old";
805
904
  /** The last full page this session rendered: where a failed form goes back to. */
806
905
  declare const PREVIOUS_URL_KEY = "__inertia_previous";
@@ -829,7 +928,13 @@ declare function oldInput(body: unknown, limits?: {
829
928
  field?: number;
830
929
  total?: number;
831
930
  }): Record<string, string | string[]> | undefined;
931
+ /** An error handler in the shape `bootstrap({ onError })` takes; what {@link formErrorHandler} returns and wraps. */
832
932
  type FormErrorHandler = (err: any, req: any, res: RuntimeResponse, next: (err?: unknown) => void) => unknown;
933
+ /**
934
+ * Options for {@link formErrorHandler}.
935
+ *
936
+ * @see https://kickjs.app/guide/views
937
+ */
833
938
  interface FormErrorHandlerOptions {
834
939
  /** Where to go back to when the `Referer` is missing or another site's. Default `'/'`. */
835
940
  fallbackUrl?: string;
@@ -870,8 +975,7 @@ interface RequestStore {
870
975
  * execution context constructed for the same request, regardless of
871
976
  * which middleware/contributor wrote it.
872
977
  *
873
- * Keys are constrained to `string` per the locked decision in
874
- * `architecture.md` §20.12 (#4); the value type is `unknown` because
978
+ * Keys are `string`; the value type is `unknown` because
875
979
  * the concrete shape at each key is determined by the consumer's
876
980
  * `ContextMeta` augmentation, not by the store itself.
877
981
  *
@@ -935,6 +1039,11 @@ declare function requestScopeMiddleware(): (req: ConnectRequest, res: ConnectRes
935
1039
  * @see https://www.w3.org/TR/trace-context/#traceparent-header
936
1040
  */
937
1041
  declare const TRACEPARENT_HEADER = "traceparent";
1042
+ /**
1043
+ * Options for {@link traceContext}.
1044
+ *
1045
+ * @see https://kickjs.app/guide/middleware
1046
+ */
938
1047
  interface TraceContextOptions {
939
1048
  /**
940
1049
  * When true, respond with a `traceresponse` header containing the trace ID.
@@ -982,6 +1091,11 @@ declare function parseTraceparent(header: string): TraceContext | null;
982
1091
  * ```
983
1092
  */
984
1093
  declare function traceContext(options?: TraceContextOptions): (req: ConnectRequest, res: ConnectResponse, next: ConnectNext) => void;
1094
+ /**
1095
+ * Options for {@link ViewAdapter}.
1096
+ *
1097
+ * @see https://kickjs.app/guide/view-engines
1098
+ */
985
1099
  interface ViewAdapterOptions {
986
1100
  /**
987
1101
  * Template engine — pass the engine module or a render function.
@@ -1018,7 +1132,7 @@ interface ViewAdapterOptions {
1018
1132
  *
1019
1133
  * Migrated to the `defineAdapter()` factory in v4 — call without `new`.
1020
1134
  * The pre-v4 `new ViewAdapter({...})` form is gone; see
1021
- * `docs/guide/migration-v3-to-v4.md` for the rename.
1135
+ * https://kickjs.app/guide/migration-v3-to-v4#viewadapter-—-drop-the-new-keyword
1022
1136
  *
1023
1137
  * @example
1024
1138
  * ```ts
@@ -1048,6 +1162,11 @@ declare const ViewAdapter: AdapterFactory<ViewAdapterOptions, unknown>;
1048
1162
  * `copyDirs` copies it). Express tries them in order.
1049
1163
  */
1050
1164
  declare function viewDirs(viewsDir: string): string[];
1165
+ /**
1166
+ * Options for {@link SpaAdapter}.
1167
+ *
1168
+ * @see https://kickjs.app/guide/spa
1169
+ */
1051
1170
  interface SpaAdapterOptions {
1052
1171
  /**
1053
1172
  * Directory containing the built SPA files (index.html, assets, etc.)
@@ -1171,6 +1290,8 @@ declare function resolveClientDir(clientDir: string, cwd?: string, entry?: strin
1171
1290
  * style.css
1172
1291
  * server/ ← KickJS server
1173
1292
  * ```
1293
+ *
1294
+ * @see https://kickjs.app/guide/spa
1174
1295
  */
1175
1296
  declare const SpaAdapter: AdapterFactory<SpaAdapterOptions, unknown>;
1176
1297
  /** One adapter's answer to `onHealthCheck()`. */
@@ -1195,6 +1316,7 @@ interface HealthProbe {
1195
1316
  /** Aggregated `onHealthCheck()` results from every adapter that has one. */
1196
1317
  checks(): Promise<HealthCheckResult[]>;
1197
1318
  }
1319
+ /** DI token for the {@link HealthProbe} that {@link HealthController} reads. */
1198
1320
  declare const HEALTH_PROBE: import("@forinda/kickjs-di").InjectionToken<HealthProbe>;
1199
1321
  /** Config for {@link healthModule}. */
1200
1322
  interface HealthModuleConfig {
@@ -1222,6 +1344,11 @@ interface HealthModuleConfig {
1222
1344
  */
1223
1345
  checkTimeout?: number;
1224
1346
  }
1347
+ /**
1348
+ * Serves `GET /health/live` and `GET /health/ready`. Liveness stays 200 while the app drains; readiness answers 503 while starting or draining, or when any adapter's `onHealthCheck()` is not `up`.
1349
+ *
1350
+ * @see https://kickjs.app/guide/deployment#behind-a-load-balancer-or-on-kubernetes
1351
+ */
1225
1352
  declare class HealthController {
1226
1353
  private readonly probe;
1227
1354
  constructor(probe: HealthProbe);
@@ -1338,6 +1465,7 @@ interface ConfigOrigins {
1338
1465
  vars: VarOrigin[];
1339
1466
  }>;
1340
1467
  }
1468
+ /** Options for `bootstrap()` and `new Application()`: modules, middleware, adapters, plugins, runtime and server settings. */
1341
1469
  interface ApplicationOptions {
1342
1470
  /**
1343
1471
  * Feature modules to load. Accepts both class form
@@ -1525,7 +1653,7 @@ interface ApplicationOptions {
1525
1653
  * `@forinda/kickjs/fastify`) or a custom engine driver. Defaults to
1526
1654
  * {@link expressRuntime}. The engine-native escape hatches
1527
1655
  * (`getRuntimeApp()`, `AdapterContext.app`) follow the active runtime via the
1528
- * registry (`ActiveRuntime`, spec §4.3b) — Express by default, or the augmented
1656
+ * registry (`ActiveRuntime`) — Express by default, or the augmented
1529
1657
  * engine once the `kick/runtime` typegen output is present.
1530
1658
  */
1531
1659
  /**
@@ -1791,6 +1919,15 @@ interface ManagementOptions {
1791
1919
  */
1792
1920
  tls?: tls.SecureContextOptions & tls.TlsOptions;
1793
1921
  }
1922
+ /**
1923
+ * A KickJS app: loads modules, adapters and plugins into the DI container,
1924
+ * mounts their routes on the HTTP runtime, and runs the lifecycle
1925
+ * (`setup`, `start`, `rebuild`, `shutdown`). `bootstrap()`,
1926
+ * `createHandler()` and `createTestApp()` create one; construct it directly
1927
+ * when you drive the lifecycle yourself.
1928
+ *
1929
+ * @see https://kickjs.app/guide/lifecycle
1930
+ */
1794
1931
  declare class Application {
1795
1932
  private readonly options;
1796
1933
  private app;
@@ -2065,7 +2202,7 @@ declare class Application {
2065
2202
  getAdapters(): AppAdapter[];
2066
2203
  /**
2067
2204
  * Get registered plugins — used by DevToolsAdapter for topology
2068
- * introspection (architecture.md §23). Read-only; returns the
2205
+ * introspection (https://kickjs.app/guide/devtools). Read-only; returns the
2069
2206
  * already-sorted plugin list (post-`dependsOn` topo-sort).
2070
2207
  */
2071
2208
  getPlugins(): readonly KickPlugin[];
@@ -2140,4 +2277,4 @@ declare class Application {
2140
2277
  */
2141
2278
  declare function describeRoutes(routes: readonly MountedRouteInfo[]): string[];
2142
2279
  export { createSigner as $, CircuitBreaker as $t, requestScopeMiddleware as A, StartupCheckError as At, formErrorHandler as B, GroupAssetKeysResult as Bt, ViewAdapterOptions as C, RequestHistogram as Ct, TraceContextOptions as D, CheckContext as Dt, TraceContext as E, CacheResponseOptions as Et, buildRoutes as F, bindRoutePolicy as Ft, SECRET_FIELD as G, MountCycleError as Gt, FORM_ERRORS_KEY as H, stripExt as Ht, expressRuntime as I, offerRoutePolicy as It, oldInput as J, mountSort as Jt, fieldErrors as K, MountKind as Kt, materializeRouter as L, AssetKeyPair as Lt, getRequestStore as M, StartupStep as Mt, getRequestValue as N, StartupTimelineSnapshot as Nt, parseTraceparent as O, CheckMessage as Ot, requestStore as P, RoutePolicyTable as Pt, VerifyOptions as Q, MissingContributorError as Qt, FormErrorHandler as R, AssetKeyStrategy as Rt, ViewAdapter as S, MetricsOptions as St, TRACEPARENT_HEADER as T, CacheResponse as Tt, OLD_INPUT_KEY as U, DuplicateMountNameError as Ut, FLASH_KEY as V, groupAssetKeys as Vt, PREVIOUS_URL_KEY as W, MissingMountDepError as Wt, Signer as X, DuplicateContributorError as Xt, SignedCheck as Y, ContributorCycleError as Yt, SignerOptions as Z, MissingContextValueError as Zt, HealthProbe as _, CronAdapterOptions as _t, ConfigDescription as a, KickError as an, verifyPassword as at, SpaAdapterOptions as b, KickCronAdapter as bt, MiddlewareEntry as c, isClusterPrimary as ct, ShutdownOptions as d, bootstrap as dt, CircuitBreakerOptions as en, LegacyHasher as et, describeRoutes as f, ERROR_CHANNEL as ft, HealthModuleConfig as g, CRON_WORKER_ENV as gt, HealthController as h, RESPONSE_CHANNEL as ht, ApplicationOptions as i, FormatKickErrorOptions as in, hashPassword as it, RequestStore as j, defineCheck as jt, traceContext as k, StartupCheck as kt, MountedRouteInfo as l, KickHandler as lt, HealthCheckResult as m, HandlerTraceContext as mt, AppStatus as n, CircuitBreakerStats as nn, PasswordHashOptions as nt, ConfigOrigins as o, KickErrorInit as on, defineHttpContextDecorator as ot, HEALTH_PROBE as p, HANDLER_CHANNEL as pt, flash as q, MountSortItem as qt, Application as r, CircuitOpenError as rn, VerifyPasswordOptions as rt, ManagementOptions as s, formatKickError as sn, ClusterOptions as st, APPLICATION as t, CircuitBreakerState as tn, PasswordCheck as tt, ServerOptions as u, createHandler as ut, healthModule as v, CronSchedule as vt, viewDirs as w, metricsAdapter as wt, resolveClientDir as x, RAW_BODY as xt, SpaAdapter as y, CronScheduler as yt, FormErrorHandlerOptions as z, GroupAssetKeysOptions as zt };
2143
- //# sourceMappingURL=application-CGcY8SZZ.d.mts.map
2280
+ //# sourceMappingURL=application-ClCq0AgY.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"application-ClCq0AgY.d.mts","names":["_$__0.AdapterFactory","Request","Response","NextFunction","Request","Response","NextFunction","_$_____0.AdapterFactory","_$_____0.AdapterFactory","_$__reply0.Reply","_$__0.ModuleFactory"],"sources":["../src/core/kick-error.ts","../src/core/circuit-breaker.ts","../src/core/context-errors.ts","../src/core/mount-sort.ts","../src/core/asset-keys.ts","../src/core/route-policy.ts","../src/http/startup-timeline.ts","../src/http/startup-checks.ts","../src/http/cache-response.ts","../src/http/metrics.ts","../src/http/body-policy.ts","../src/http/cron-adapter.ts","../src/http/tracing.ts","../src/http/bootstrap.ts","../src/http/handler.ts","../src/http/cluster.ts","../src/http/define-http-context-decorator.ts","../src/core/password.ts","../src/core/signing.ts","../src/http/form.ts","../src/http/middleware/form-errors.ts","../src/http/runtimes/express-lazy.ts","../src/http/request-store.ts","../src/http/middleware/request-scope.ts","../src/http/middleware/trace-context.ts","../src/http/middleware/views.ts","../src/http/middleware/spa.ts","../src/http/health-module.ts","../src/http/application.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;UACiB;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA,UAAU;;;;;;;;;;;;;;;;;;;;;cAsBC,kBAAkB;WACb;WACA;WACA;WACA;WACA;WACA,UAAU;EAE1B,YAAY,MAAM;;;UAkDH;;;;;;EAMf;;;;;;;iBAQc,gBACd,KAAK,gBAAgB,WACrB,UAAS;KC7GC;;UAGK;;EAEf;;EAEA;;EAEA;;;UAIe;EACf;EACA;EACA,OAAO;EACP,cAAc;;;;;cAMH,yBAAyB;WACR;EAA5B,YAA4B;;;;;;;;;;;;;;;;;;;;;cAyBjB;WAaO;UAZV;UACA;UACA;UACA;UACA;UACA;mBAES;mBACA;mBACA;EAEjB,YACkB,cAChB,SAAS;;;;;EAWL,QAAQ,GAAG,UAAU,QAAQ,KAAK,QAAQ;;EA0BhD,YAAY;;EAMZ,YAAY;;EAWZ;UASQ;UAWA;UAeA;;;;;;;;;;;;;;;;;;;;;;;;;;;;cC7HG,gCAAgC;WAClC;WACA;WACA;WACA;EAET,YAAY,aAAa,mBAAmB,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA0CjD,iCAAiC;WACnC;WACA;EAET,YAAY,aAAa;;;;;;;;;;;;cA6Cd,8BAA8B;WAChC;WACA;EAET,YAAY,0BAA0B;;;;;;;;;;;;;;;;;;;cA0B3B,kCAAkC;WACpC;WACA;EAET,YAAY,aAAa;;;;;;;;;;;;;;;;;;;UC5IV;;EAEf;;;;;;EAMA;;;KAIU;;;;;cAMC,gCAAgC;WAClC,MAAM;WACN;EAET,YAAY,MAAM,WAAW;;;;;;;;cAclB,6BAA6B;WAC/B,MAAM;WACN;WACA;EAET,YAAY,MAAM,WAAW,iBAAiB;;;;;;;cAiBnC,wBAAwB;WAC1B,MAAM;WACN;E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FA;UA6CA;;UAWA;;UAwBN;UAeA;;EAsBF,WAAW;;;;;;;;;;;EAgEjB,SAAS,UAAS,kBAAuB;UAW3B;;;;;;;EA4Ld,iBAAiB;;;;;;;;EAWjB;IAAsB;IAAc,cAAc;;;EAKlD,iBAAiB;;EAKjB,eAAe;;;;;;EASf,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;EA2BvB,sBAAsB;EAItB,mBAAmB;IACjB;IACA;IACA;IACA;;EA+DF,iBAAiB;;;;;;EASjB,uBAAuB,KAAK,SAAS,MAAM;;;;;;;;;;;;;;UAmBnC;UAWA;UAmBA;UAUA;;;;;;;;UAeA;;UAoBA;;;;;;iBAgDM,eAAe,iBAAiB"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs v10.14.2
2
+ * @forinda/kickjs v10.15.0
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -9,4 +9,4 @@
9
9
  * @license MIT
10
10
  */
11
11
  import{HttpException}from"./core/errors.mjs";function normalizeMediaType(contentType){return((Array.isArray(contentType)?contentType[0]:contentType)??``).split(`;`)[0].trim().toLowerCase()}function isJsonMediaType(mediaType){return mediaType===`application/json`||/^application\/[\w.+-]+\+json$/.test(mediaType)}function classifyMediaType(contentType){let mediaType=normalizeMediaType(contentType);return mediaType?isJsonMediaType(mediaType)?`json`:mediaType===`application/x-www-form-urlencoded`?`urlencoded`:mediaType.startsWith(`multipart/`)?`multipart`:mediaType.startsWith(`text/`)?`text`:`unsupported`:`unsupported`}const EXPRESS_JSON_TYPES=[`application/json`,`application/*+json`],SUPPORTED_BODY_TYPES=[`application/json`,`application/*+json`,`application/x-www-form-urlencoded`,`text/*`,`multipart/form-data`];function unsupportedMediaTypeError(contentType){let mediaType=normalizeMediaType(contentType);return new HttpException(415,mediaType?`Unsupported Media Type: ${mediaType}`:`Unsupported Media Type: request has a body but no Content-Type`,void 0,{Accept:SUPPORTED_BODY_TYPES.join(`, `)})}const BODY_METHODS=/* @__PURE__ */ new Set([`POST`,`PUT`,`PATCH`,`DELETE`]),RAW_BODY=Symbol.for(`kick/http/raw-body`);function rejectUnsupportedBody(){return(req,_res,next)=>{if(!BODY_METHODS.has((req.method??`GET`).toUpperCase())||req[RAW_BODY]||classifyMediaType(req.headers?.[`content-type`])!==`unsupported`)return next();let reject=()=>next(unsupportedMediaTypeError(req.headers?.[`content-type`])),length=req.headers?.[`content-length`];if(length!==void 0)return length===`0`?next():reject();if(req.headers?.[`transfer-encoding`]===void 0)return next();let decided=!1,settle=fn=>()=>{decided||(decided=!0,req.off?.(`data`,onData),req.off?.(`end`,onEnd),fn())},onData=settle(reject),onEnd=settle(()=>next());req.on?.(`data`,onData),req.on?.(`end`,onEnd)}}const BYTE_UNITS={b:1,kb:1024,mb:1024**2,gb:1024**3};function parseByteSize(value){if(typeof value==`number`)return value;let match=/^\s*(\d+(?:\.\d+)?)\s*(b|kb|mb|gb)?\s*$/i.exec(value);if(!match)throw Error(`Invalid body size limit: '${value}'`);return Math.floor(Number(match[1])*BYTE_UNITS[(match[2]??`b`).toLowerCase()])}function tooLarge(limit){return new HttpException(413,`Request body is larger than the ${limit}-byte limit`)}async function readBodyBytes(request,limit){if(Number(request.headers.get(`content-length`))>limit)throw tooLarge(limit);if(!request.body)return/* @__PURE__ */ new Uint8Array;let reader=request.body.getReader(),chunks=[],size=0;for(;;){let{done,value}=await reader.read();if(done)break;if(size+=value.byteLength,size>limit)throw await reader.cancel().catch(()=>{}),tooLarge(limit);chunks.push(value)}let bytes=new Uint8Array(size),offset=0;for(let chunk of chunks)bytes.set(chunk,offset),offset+=chunk.byteLength;return bytes}async function readBodyText(request,limit){return new TextDecoder().decode(await readBodyBytes(request,limit))}function parseForm(raw){return formFields(new URLSearchParams(raw))}function formFields(pairs){let fields=/* @__PURE__ */ new Map;for(let[key,value]of pairs){let prev=fields.get(key);prev===void 0?fields.set(key,value):Array.isArray(prev)?prev.push(value):fields.set(key,[prev,value])}return Object.fromEntries(fields)}function hasPrototypeKey(value){let pending=[value],seen=/* @__PURE__ */ new Set;for(;pending.length>0;){let current=pending.pop();if(typeof current!=`object`||!current||seen.has(current)||ArrayBuffer.isView(current))continue;if(seen.add(current),Object.hasOwn(current,`__proto__`))return!0;let ctor=Object.hasOwn(current,`constructor`)?current.constructor:void 0;if(typeof ctor==`object`&&ctor&&Object.hasOwn(ctor,`prototype`))return!0;for(let key of Object.keys(current))pending.push(current[key])}return!1}function prototypeKeyError(){return HttpException.badRequest(`A body key that sets a prototype (__proto__, constructor.prototype) is not allowed`)}export{hasPrototypeKey as a,prototypeKeyError as c,rejectUnsupportedBody as d,tooLarge as f,formFields as i,readBodyBytes as l,RAW_BODY as n,parseByteSize as o,unsupportedMediaTypeError as p,classifyMediaType as r,parseForm as s,EXPRESS_JSON_TYPES as t,readBodyText as u};
12
- //# sourceMappingURL=body-policy-Be3Y0hjq.mjs.map
12
+ //# sourceMappingURL=body-policy-D8LveWmO.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"body-policy-Be3Y0hjq.mjs","names":[],"sources":["../src/http/body-policy.ts"],"sourcesContent":["/**\n * How a request body is interpreted, decided in ONE place for every runtime.\n *\n * Before this, each engine brought its own library's opinion: Express parsed\n * only exact `application/json` and silently left everything else `undefined`,\n * Fastify answered 415 for anything it had no parser for, and h3 routed\n * unrecognised types through `destr` — so the same request produced a parsed\n * object, an empty body, or a 415 depending on which engine the app was\n * configured with. The runtime is meant to be swappable; that made it not\n * swappable for any app accepting a body outside `application/json` (#590).\n *\n * @module @forinda/kickjs/http/body-policy\n */\n\nimport { HttpException } from '../core/errors'\n\n/**\n * A header as the runtimes hand it over. Node's `IncomingHttpHeaders` and\n * Fastify's normalised map both allow `string[]`, so take the union here\n * rather than casting at every call site.\n */\nexport type HeaderValue = string | string[] | undefined\n\n/** What the framework does with a body of a given media type. */\nexport type BodyKind =\n /** Parse as JSON, strictly. */\n | 'json'\n /** Parse as `application/x-www-form-urlencoded` into an object. */\n | 'urlencoded'\n /** Hand the handler the raw string. Never JSON — see `classifyMediaType`. */\n | 'text'\n /** Left to the upload path, which consumes the stream itself. */\n | 'multipart'\n /** Not parsed. `ctx.body` stays undefined. */\n | 'unsupported'\n\n/**\n * Strip parameters and normalise: `Application/JSON; charset=utf-8` →\n * `application/json`. h3's own check is `===` against the bare type, which is\n * why `application/json; charset=utf-8` — what most clients actually send —\n * missed it and fell to a non-strict branch.\n */\nexport function normalizeMediaType(contentType: HeaderValue): string {\n const value = Array.isArray(contentType) ? contentType[0] : contentType\n return (value ?? '').split(';')[0].trim().toLowerCase()\n}\n\n/**\n * `application/*+json` is JSON, and this is not a judgement call: RFC 6838\n * §4.2.8 says a media type \"MUST NOT be given names incorporating suffixes for\n * structured syntaxes they do not actually employ\", and RFC 6839 §2 exists so\n * receivers can \"do generic processing of the underlying representation\".\n * Spring, ASP.NET Core and Hono's validator all match the suffix by default.\n *\n * So `application/merge-patch+json` (RFC 7396) and `application/problem+json`\n * (RFC 9457) parse as JSON — which the framework already emits for every\n * problem response, and previously could not read back.\n */\nfunction isJsonMediaType(mediaType: string): boolean {\n return mediaType === 'application/json' || /^application\\/[\\w.+-]+\\+json$/.test(mediaType)\n}\n\n/**\n * Decide how to treat a body, from its declared media type alone.\n *\n * `text/*` deliberately yields the raw string and is NEVER JSON-parsed.\n * `text/plain` is one of three CORS-safelisted content types, so it crosses\n * origins without a preflight; JSON-parsing it would re-open the simple-request\n * CSRF that requiring `application/json` closes. h3's own source carries this\n * warning, and h3 v2 pulled back from `destr` partly because of it.\n */\nexport function classifyMediaType(contentType: HeaderValue): BodyKind {\n const mediaType = normalizeMediaType(contentType)\n if (!mediaType) return 'unsupported'\n if (isJsonMediaType(mediaType)) return 'json'\n if (mediaType === 'application/x-www-form-urlencoded') return 'urlencoded'\n if (mediaType.startsWith('multipart/')) return 'multipart'\n if (mediaType.startsWith('text/')) return 'text'\n return 'unsupported'\n}\n\n/**\n * Media types Express should hand to its JSON body parser. `express.json()`\n * defaults to the exact string `application/json`, and `type-is` will not match\n * `application/json` against a bare wildcard-plus-json pattern (a length guard rejects\n * it), so BOTH entries are required — passing only the wildcard silently stops\n * parsing ordinary JSON.\n */\nexport const EXPRESS_JSON_TYPES = ['application/json', 'application/*+json'] as const\n\n/** Media types the framework claims to parse, for diagnostics and docs. */\nexport const SUPPORTED_BODY_TYPES = [\n 'application/json',\n 'application/*+json',\n 'application/x-www-form-urlencoded',\n 'text/*',\n 'multipart/form-data',\n] as const\n\n/**\n * The 415 for a body whose media type the framework does not parse.\n *\n * Only ever raised when a body was actually SENT. An absent or empty body is\n * treated as absent regardless of its declared type — the same call Spring's\n * `readWithMessageConverters` and ASP.NET's `BodyModelBinder` both make, and\n * the reason neither rejects a bodyless POST. A bare `POST` with no payload is\n * a legitimate request, not an unsupported one.\n *\n * Carries `Accept`, which RFC 9110 §15.5.16 says a 415 \"can\" use to indicate\n * which media types would have been accepted.\n */\nexport function unsupportedMediaTypeError(contentType: HeaderValue): HttpException {\n const mediaType = normalizeMediaType(contentType)\n return new HttpException(\n 415,\n mediaType\n ? `Unsupported Media Type: ${mediaType}`\n : 'Unsupported Media Type: request has a body but no Content-Type',\n undefined,\n { Accept: SUPPORTED_BODY_TYPES.join(', ') },\n )\n}\n\n/** Verbs whose body the framework reads. */\nconst BODY_METHODS = new Set(['POST', 'PUT', 'PATCH', 'DELETE'])\n\n/**\n * Did this request actually carry a body? Decided from the framing headers\n * rather than from whether a parser produced anything — the distinction that\n * separates \"nothing was sent\" from \"something was sent that we could not\n * read\", which is the whole basis for answering 415 on one and 200 on the other.\n */\nexport function hasRequestBody(headers: Record<string, unknown>): boolean {\n const length = headers['content-length'] as string | undefined\n const encoding = headers['transfer-encoding'] as string | undefined\n return encoding !== undefined || (length !== undefined && length !== '0')\n}\n\n/**\n * Set to `true` on a request (`req[RAW_BODY] = true`) by middleware that will\n * read the body stream itself — a tus endpoint, a proxy — so the 415 below\n * leaves it alone. Mark it in an earlier phase (an adapter's `beforeGlobal`),\n * consume it later.\n */\nexport const RAW_BODY = Symbol.for('kick/http/raw-body')\n\n/**\n * Connect middleware that answers 415 for a body Express's parsers left\n * untouched.\n *\n * Express has no concept of an unsupported type: a parser whose `type` does not\n * match simply calls `next()` and leaves `req.body` undefined, indistinguishable\n * from a request that sent nothing. Mounted after the parsers, this restores the\n * distinction so Express agrees with the other runtimes.\n */\nexport function rejectUnsupportedBody() {\n return (req: any, _res: unknown, next: (err?: unknown) => void): void => {\n if (!BODY_METHODS.has((req.method ?? 'GET').toUpperCase())) return next()\n if (req[RAW_BODY]) return next()\n if (classifyMediaType(req.headers?.['content-type']) !== 'unsupported') return next()\n\n const reject = (): void => next(unsupportedMediaTypeError(req.headers?.['content-type']))\n const length = req.headers?.['content-length'] as string | undefined\n if (length !== undefined) return length === '0' ? next() : reject()\n if (req.headers?.['transfer-encoding'] === undefined) return next()\n\n // Chunked: the framing headers say a body MAY follow, but an empty chunked\n // post sends none. Deciding on the headers alone would 415 a request that\n // sent nothing, so wait to see whether a byte actually arrives — the same\n // distinction the other runtimes make by inspecting the read body.\n let decided = false\n const settle = (fn: () => void) => (): void => {\n if (decided) return\n decided = true\n req.off?.('data', onData)\n req.off?.('end', onEnd)\n fn()\n }\n const onData = settle(reject)\n const onEnd = settle(() => next())\n req.on?.('data', onData)\n req.on?.('end', onEnd)\n }\n}\n\n/** Default body size limit — Express's `express.json()` default. */\nexport const DEFAULT_BODY_LIMIT = '1mb'\n\nconst BYTE_UNITS: Record<string, number> = { b: 1, kb: 1024, mb: 1024 ** 2, gb: 1024 ** 3 }\n\n/**\n * `'1mb'` / `'512kb'` / `1048576` → bytes, the forms `express.json({ limit })`\n * accepts (1024-based, like the `bytes` package Express uses), so one\n * `jsonLimit` means the same size on every engine.\n */\nexport function parseByteSize(value: string | number): number {\n if (typeof value === 'number') return value\n const match = /^\\s*(\\d+(?:\\.\\d+)?)\\s*(b|kb|mb|gb)?\\s*$/i.exec(value)\n if (!match) throw new Error(`Invalid body size limit: '${value}'`)\n return Math.floor(Number(match[1]) * BYTE_UNITS[(match[2] ?? 'b').toLowerCase()])\n}\n\n/** The 413 for a body past `limit` bytes. */\nexport function tooLarge(limit: number): HttpException {\n return new HttpException(413, `Request body is larger than the ${limit}-byte limit`)\n}\n\n/**\n * Read a web `Request` body, refusing more than `limit` bytes with a 413 —\n * from `Content-Length` before reading, and while streaming for a body that\n * doesn't declare one (or declares less than it sends).\n */\nexport async function readBodyBytes(request: Request, limit: number): Promise<Uint8Array> {\n const declared = Number(request.headers.get('content-length'))\n if (declared > limit) throw tooLarge(limit)\n if (!request.body) return new Uint8Array(0)\n\n const reader = request.body.getReader()\n const chunks: Uint8Array[] = []\n let size = 0\n for (;;) {\n const { done, value } = await reader.read()\n if (done) break\n size += value.byteLength\n if (size > limit) {\n await reader.cancel().catch(() => {})\n throw tooLarge(limit)\n }\n chunks.push(value)\n }\n const bytes = new Uint8Array(size)\n let offset = 0\n for (const chunk of chunks) {\n bytes.set(chunk, offset)\n offset += chunk.byteLength\n }\n return bytes\n}\n\n/** {@link readBodyBytes}, decoded as UTF-8. */\nexport async function readBodyText(request: Request, limit: number): Promise<string> {\n return new TextDecoder().decode(await readBodyBytes(request, limit))\n}\n\n/**\n * `application/x-www-form-urlencoded` → object, with a repeated key becoming\n * an array — the same rule the query string follows on every engine, and\n * what Express's form parser does.\n */\nexport function parseForm(raw: string): Record<string, string | string[]> {\n return formFields(new URLSearchParams(raw))\n}\n\n/**\n * Form fields → object, a repeated name becoming an array — urlencoded bodies\n * and multipart fields alike. A Map, then fromEntries: assigning keys onto a\n * plain object would let a `__proto__` field set the result's prototype, or\n * vanish; this way it is an own key, which {@link hasPrototypeKey} refuses.\n */\nexport function formFields(\n pairs: Iterable<readonly [string, string]>,\n): Record<string, string | string[]> {\n const fields = new Map<string, string | string[]>()\n for (const [key, value] of pairs) {\n const prev = fields.get(key)\n if (prev === undefined) fields.set(key, value)\n else if (Array.isArray(prev)) prev.push(value)\n else fields.set(key, [prev, value])\n }\n return Object.fromEntries(fields)\n}\n\n/**\n * Whether parsed input carries a key that can rewrite a prototype: `__proto__`\n * anywhere, or `constructor.prototype`. A body with one is refused on every\n * engine, as Fastify's parsers already do. Harmless while it sits in the body,\n * it turns `Object.assign(target, ctx.body)` or a naive deep merge into\n * prototype pollution.\n */\nexport function hasPrototypeKey(value: unknown): boolean {\n const pending: unknown[] = [value]\n const seen = new Set<object>()\n while (pending.length > 0) {\n const current = pending.pop()\n if (current === null || typeof current !== 'object' || seen.has(current)) continue\n // Bytes (a raw body) have no keys worth walking.\n if (ArrayBuffer.isView(current)) continue\n seen.add(current)\n if (Object.hasOwn(current, '__proto__')) return true\n const ctor: unknown = Object.hasOwn(current, 'constructor')\n ? (current as { constructor: unknown }).constructor\n : undefined\n if (ctor !== null && typeof ctor === 'object' && Object.hasOwn(ctor, 'prototype')) return true\n for (const key of Object.keys(current)) pending.push((current as Record<string, unknown>)[key])\n }\n return false\n}\n\n/** The 400 for a body {@link hasPrototypeKey} refuses. */\nexport function prototypeKeyError(): HttpException {\n return HttpException.badRequest(\n 'A body key that sets a prototype (__proto__, constructor.prototype) is not allowed',\n )\n}\n"],"mappings":";;;;;;;;;;A,6CA0CA,SAAgB,mBAAmB,YAAkC,CAEnE,QADc,MAAM,QAAQ,WAAW,EAAI,YAAY,GAAK,cAC3C,GAAA,CAAI,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,YAAY,CACxD,CAaA,SAAS,gBAAgB,UAA4B,CACnD,OAAO,YAAc,oBAAsB,gCAAgC,KAAK,SAAS,CAC3F,CAWA,SAAgB,kBAAkB,YAAoC,CACpE,IAAM,UAAY,mBAAmB,WAAW,EAMhD,OALK,UACD,gBAAgB,SAAS,EAAU,OACnC,YAAc,oCAA4C,aAC1D,UAAU,WAAW,YAAY,EAAU,YAC3C,UAAU,WAAW,OAAO,EAAU,OACnC,cALgB,aAMzB,CASA,MAAa,mBAAqB,CAAC,mBAAoB,oBAAoB,EAG9D,qBAAuB,CAClC,mBACA,qBACA,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YAAY,MAAM,CAClC,CASA,SAAgB,gBAAgB,MAAyB,CACvD,IAAM,QAAqB,CAAC,KAAK,EAC3B,qBAAO,IAAI,IACjB,KAAO,QAAQ,OAAS,GAAG,CACzB,IAAM,QAAU,QAAQ,IAAI,EAG5B,GAFwB,OAAO,SAAY,WAAvC,SAAmD,KAAK,IAAI,OAAO,GAEnE,YAAY,OAAO,OAAO,EAAG,SAEjC,GADA,KAAK,IAAI,OAAO,EACZ,OAAO,OAAO,QAAS,WAAW,EAAG,MAAO,GAChD,IAAM,KAAgB,OAAO,OAAO,QAAS,aAAa,EACrD,QAAqC,YACtC,IAAA,GACJ,GAAqB,OAAO,MAAS,UAAjC,MAA6C,OAAO,OAAO,KAAM,WAAW,EAAG,MAAO,GAC1F,IAAK,IAAM,OAAO,OAAO,KAAK,OAAO,EAAG,QAAQ,KAAM,QAAoC,IAAI,CAChG,CACA,MAAO,EACT,CAGA,SAAgB,mBAAmC,CACjD,OAAO,cAAc,WACnB,oFACF,CACF,C"}
1
+ {"version":3,"file":"body-policy-D8LveWmO.mjs","names":[],"sources":["../src/http/body-policy.ts"],"sourcesContent":["/**\n * How a request body is interpreted, decided in ONE place for every runtime.\n *\n * Before this, each engine brought its own library's opinion: Express parsed\n * only exact `application/json` and silently left everything else `undefined`,\n * Fastify answered 415 for anything it had no parser for, and h3 routed\n * unrecognised types through `destr` — so the same request produced a parsed\n * object, an empty body, or a 415 depending on which engine the app was\n * configured with. The runtime is meant to be swappable; that made it not\n * swappable for any app accepting a body outside `application/json` (#590).\n *\n * @module @forinda/kickjs/http/body-policy\n */\n\nimport { HttpException } from '../core/errors'\n\n/**\n * A header as the runtimes hand it over. Node's `IncomingHttpHeaders` and\n * Fastify's normalised map both allow `string[]`, so take the union here\n * rather than casting at every call site.\n */\nexport type HeaderValue = string | string[] | undefined\n\n/** What the framework does with a body of a given media type. */\nexport type BodyKind =\n /** Parse as JSON, strictly. */\n | 'json'\n /** Parse as `application/x-www-form-urlencoded` into an object. */\n | 'urlencoded'\n /** Hand the handler the raw string. Never JSON — see `classifyMediaType`. */\n | 'text'\n /** Left to the upload path, which consumes the stream itself. */\n | 'multipart'\n /** Not parsed. `ctx.body` stays undefined. */\n | 'unsupported'\n\n/**\n * Strip parameters and normalise: `Application/JSON; charset=utf-8` →\n * `application/json`. h3's own check is `===` against the bare type, which is\n * why `application/json; charset=utf-8` — what most clients actually send —\n * missed it and fell to a non-strict branch.\n */\nexport function normalizeMediaType(contentType: HeaderValue): string {\n const value = Array.isArray(contentType) ? contentType[0] : contentType\n return (value ?? '').split(';')[0].trim().toLowerCase()\n}\n\n/**\n * `application/*+json` is JSON, and this is not a judgement call: RFC 6838\n * §4.2.8 says a media type \"MUST NOT be given names incorporating suffixes for\n * structured syntaxes they do not actually employ\", and RFC 6839 §2 exists so\n * receivers can \"do generic processing of the underlying representation\".\n * Spring, ASP.NET Core and Hono's validator all match the suffix by default.\n *\n * So `application/merge-patch+json` (RFC 7396) and `application/problem+json`\n * (RFC 9457) parse as JSON — which the framework already emits for every\n * problem response, and previously could not read back.\n */\nfunction isJsonMediaType(mediaType: string): boolean {\n return mediaType === 'application/json' || /^application\\/[\\w.+-]+\\+json$/.test(mediaType)\n}\n\n/**\n * Decide how to treat a body, from its declared media type alone.\n *\n * `text/*` deliberately yields the raw string and is NEVER JSON-parsed.\n * `text/plain` is one of three CORS-safelisted content types, so it crosses\n * origins without a preflight; JSON-parsing it would re-open the simple-request\n * CSRF that requiring `application/json` closes. h3's own source carries this\n * warning, and h3 v2 pulled back from `destr` partly because of it.\n */\nexport function classifyMediaType(contentType: HeaderValue): BodyKind {\n const mediaType = normalizeMediaType(contentType)\n if (!mediaType) return 'unsupported'\n if (isJsonMediaType(mediaType)) return 'json'\n if (mediaType === 'application/x-www-form-urlencoded') return 'urlencoded'\n if (mediaType.startsWith('multipart/')) return 'multipart'\n if (mediaType.startsWith('text/')) return 'text'\n return 'unsupported'\n}\n\n/**\n * Media types Express should hand to its JSON body parser. `express.json()`\n * defaults to the exact string `application/json`, and `type-is` will not match\n * `application/json` against a bare wildcard-plus-json pattern (a length guard rejects\n * it), so BOTH entries are required — passing only the wildcard silently stops\n * parsing ordinary JSON.\n */\nexport const EXPRESS_JSON_TYPES = ['application/json', 'application/*+json'] as const\n\n/** Media types the framework claims to parse, for diagnostics and docs. */\nexport const SUPPORTED_BODY_TYPES = [\n 'application/json',\n 'application/*+json',\n 'application/x-www-form-urlencoded',\n 'text/*',\n 'multipart/form-data',\n] as const\n\n/**\n * The 415 for a body whose media type the framework does not parse.\n *\n * Only ever raised when a body was actually SENT. An absent or empty body is\n * treated as absent regardless of its declared type — the same call Spring's\n * `readWithMessageConverters` and ASP.NET's `BodyModelBinder` both make, and\n * the reason neither rejects a bodyless POST. A bare `POST` with no payload is\n * a legitimate request, not an unsupported one.\n *\n * Carries `Accept`, which RFC 9110 §15.5.16 says a 415 \"can\" use to indicate\n * which media types would have been accepted.\n */\nexport function unsupportedMediaTypeError(contentType: HeaderValue): HttpException {\n const mediaType = normalizeMediaType(contentType)\n return new HttpException(\n 415,\n mediaType\n ? `Unsupported Media Type: ${mediaType}`\n : 'Unsupported Media Type: request has a body but no Content-Type',\n undefined,\n { Accept: SUPPORTED_BODY_TYPES.join(', ') },\n )\n}\n\n/** Verbs whose body the framework reads. */\nconst BODY_METHODS = new Set(['POST', 'PUT', 'PATCH', 'DELETE'])\n\n/**\n * Did this request actually carry a body? Decided from the framing headers\n * rather than from whether a parser produced anything — the distinction that\n * separates \"nothing was sent\" from \"something was sent that we could not\n * read\", which is the whole basis for answering 415 on one and 200 on the other.\n */\nexport function hasRequestBody(headers: Record<string, unknown>): boolean {\n const length = headers['content-length'] as string | undefined\n const encoding = headers['transfer-encoding'] as string | undefined\n return encoding !== undefined || (length !== undefined && length !== '0')\n}\n\n/**\n * Set to `true` on a request (`req[RAW_BODY] = true`) by middleware that will\n * read the body stream itself — a tus endpoint, a proxy — so the 415 below\n * leaves it alone. Mark it in an earlier phase (an adapter's `beforeGlobal`),\n * consume it later.\n */\nexport const RAW_BODY = Symbol.for('kick/http/raw-body')\n\n/**\n * Connect middleware that answers 415 for a body Express's parsers left\n * untouched.\n *\n * Express has no concept of an unsupported type: a parser whose `type` does not\n * match simply calls `next()` and leaves `req.body` undefined, indistinguishable\n * from a request that sent nothing. Mounted after the parsers, this restores the\n * distinction so Express agrees with the other runtimes.\n */\nexport function rejectUnsupportedBody() {\n return (req: any, _res: unknown, next: (err?: unknown) => void): void => {\n if (!BODY_METHODS.has((req.method ?? 'GET').toUpperCase())) return next()\n if (req[RAW_BODY]) return next()\n if (classifyMediaType(req.headers?.['content-type']) !== 'unsupported') return next()\n\n const reject = (): void => next(unsupportedMediaTypeError(req.headers?.['content-type']))\n const length = req.headers?.['content-length'] as string | undefined\n if (length !== undefined) return length === '0' ? next() : reject()\n if (req.headers?.['transfer-encoding'] === undefined) return next()\n\n // Chunked: the framing headers say a body MAY follow, but an empty chunked\n // post sends none. Deciding on the headers alone would 415 a request that\n // sent nothing, so wait to see whether a byte actually arrives — the same\n // distinction the other runtimes make by inspecting the read body.\n let decided = false\n const settle = (fn: () => void) => (): void => {\n if (decided) return\n decided = true\n req.off?.('data', onData)\n req.off?.('end', onEnd)\n fn()\n }\n const onData = settle(reject)\n const onEnd = settle(() => next())\n req.on?.('data', onData)\n req.on?.('end', onEnd)\n }\n}\n\n/** Default body size limit — Express's `express.json()` default. */\nexport const DEFAULT_BODY_LIMIT = '1mb'\n\nconst BYTE_UNITS: Record<string, number> = { b: 1, kb: 1024, mb: 1024 ** 2, gb: 1024 ** 3 }\n\n/**\n * `'1mb'` / `'512kb'` / `1048576` → bytes, the forms `express.json({ limit })`\n * accepts (1024-based, like the `bytes` package Express uses), so one\n * `jsonLimit` means the same size on every engine.\n */\nexport function parseByteSize(value: string | number): number {\n if (typeof value === 'number') return value\n const match = /^\\s*(\\d+(?:\\.\\d+)?)\\s*(b|kb|mb|gb)?\\s*$/i.exec(value)\n if (!match) throw new Error(`Invalid body size limit: '${value}'`)\n return Math.floor(Number(match[1]) * BYTE_UNITS[(match[2] ?? 'b').toLowerCase()])\n}\n\n/** The 413 for a body past `limit` bytes. */\nexport function tooLarge(limit: number): HttpException {\n return new HttpException(413, `Request body is larger than the ${limit}-byte limit`)\n}\n\n/**\n * Read a web `Request` body, refusing more than `limit` bytes with a 413 —\n * from `Content-Length` before reading, and while streaming for a body that\n * doesn't declare one (or declares less than it sends).\n */\nexport async function readBodyBytes(request: Request, limit: number): Promise<Uint8Array> {\n const declared = Number(request.headers.get('content-length'))\n if (declared > limit) throw tooLarge(limit)\n if (!request.body) return new Uint8Array(0)\n\n const reader = request.body.getReader()\n const chunks: Uint8Array[] = []\n let size = 0\n for (;;) {\n const { done, value } = await reader.read()\n if (done) break\n size += value.byteLength\n if (size > limit) {\n await reader.cancel().catch(() => {})\n throw tooLarge(limit)\n }\n chunks.push(value)\n }\n const bytes = new Uint8Array(size)\n let offset = 0\n for (const chunk of chunks) {\n bytes.set(chunk, offset)\n offset += chunk.byteLength\n }\n return bytes\n}\n\n/** {@link readBodyBytes}, decoded as UTF-8. */\nexport async function readBodyText(request: Request, limit: number): Promise<string> {\n return new TextDecoder().decode(await readBodyBytes(request, limit))\n}\n\n/**\n * `application/x-www-form-urlencoded` → object, with a repeated key becoming\n * an array — the same rule the query string follows on every engine, and\n * what Express's form parser does.\n */\nexport function parseForm(raw: string): Record<string, string | string[]> {\n return formFields(new URLSearchParams(raw))\n}\n\n/**\n * Form fields → object, a repeated name becoming an array — urlencoded bodies\n * and multipart fields alike. A Map, then fromEntries: assigning keys onto a\n * plain object would let a `__proto__` field set the result's prototype, or\n * vanish; this way it is an own key, which {@link hasPrototypeKey} refuses.\n */\nexport function formFields(\n pairs: Iterable<readonly [string, string]>,\n): Record<string, string | string[]> {\n const fields = new Map<string, string | string[]>()\n for (const [key, value] of pairs) {\n const prev = fields.get(key)\n if (prev === undefined) fields.set(key, value)\n else if (Array.isArray(prev)) prev.push(value)\n else fields.set(key, [prev, value])\n }\n return Object.fromEntries(fields)\n}\n\n/**\n * Whether parsed input carries a key that can rewrite a prototype: `__proto__`\n * anywhere, or `constructor.prototype`. A body with one is refused on every\n * engine, as Fastify's parsers already do. Harmless while it sits in the body,\n * it turns `Object.assign(target, ctx.body)` or a naive deep merge into\n * prototype pollution.\n */\nexport function hasPrototypeKey(value: unknown): boolean {\n const pending: unknown[] = [value]\n const seen = new Set<object>()\n while (pending.length > 0) {\n const current = pending.pop()\n if (current === null || typeof current !== 'object' || seen.has(current)) continue\n // Bytes (a raw body) have no keys worth walking.\n if (ArrayBuffer.isView(current)) continue\n seen.add(current)\n if (Object.hasOwn(current, '__proto__')) return true\n const ctor: unknown = Object.hasOwn(current, 'constructor')\n ? (current as { constructor: unknown }).constructor\n : undefined\n if (ctor !== null && typeof ctor === 'object' && Object.hasOwn(ctor, 'prototype')) return true\n for (const key of Object.keys(current)) pending.push((current as Record<string, unknown>)[key])\n }\n return false\n}\n\n/** The 400 for a body {@link hasPrototypeKey} refuses. */\nexport function prototypeKeyError(): HttpException {\n return HttpException.badRequest(\n 'A body key that sets a prototype (__proto__, constructor.prototype) is not allowed',\n )\n}\n"],"mappings":";;;;;;;;;;A,6CA0CA,SAAgB,mBAAmB,YAAkC,CAEnE,QADc,MAAM,QAAQ,WAAW,EAAI,YAAY,GAAK,cAC3C,GAAA,CAAI,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,YAAY,CACxD,CAaA,SAAS,gBAAgB,UAA4B,CACnD,OAAO,YAAc,oBAAsB,gCAAgC,KAAK,SAAS,CAC3F,CAWA,SAAgB,kBAAkB,YAAoC,CACpE,IAAM,UAAY,mBAAmB,WAAW,EAMhD,OALK,UACD,gBAAgB,SAAS,EAAU,OACnC,YAAc,oCAA4C,aAC1D,UAAU,WAAW,YAAY,EAAU,YAC3C,UAAU,WAAW,OAAO,EAAU,OACnC,cALgB,aAMzB,CASA,MAAa,mBAAqB,CAAC,mBAAoB,oBAAoB,EAG9D,qBAA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