@forinda/kickjs 10.0.0 → 10.2.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 (211) hide show
  1. package/dist/adapter-C5I5e_-i.d.mts +4866 -0
  2. package/dist/adapter-C5I5e_-i.d.mts.map +1 -0
  3. package/dist/allowed-hosts-D6qcuK5I.d.mts +46 -0
  4. package/dist/allowed-hosts-D6qcuK5I.d.mts.map +1 -0
  5. package/dist/{app-module-DCA65GZZ.d.mts → app-module-Ftz6m7SO.d.mts} +8 -2
  6. package/dist/app-module-Ftz6m7SO.d.mts.map +1 -0
  7. package/dist/application-Ch5jT4fj.mjs +14 -0
  8. package/dist/application-Ch5jT4fj.mjs.map +1 -0
  9. package/dist/bootstrap-D56HIq1N.mjs +12 -0
  10. package/dist/bootstrap-D56HIq1N.mjs.map +1 -0
  11. package/dist/bounded-counters-B9dzk5o_.mjs +12 -0
  12. package/dist/bounded-counters-B9dzk5o_.mjs.map +1 -0
  13. package/dist/breach-padding-C-Dnq8CS.d.mts +39 -0
  14. package/dist/breach-padding-C-Dnq8CS.d.mts.map +1 -0
  15. package/dist/{client-ip-BkLX8wXf.mjs → client-ip-lYnBU2PR.mjs} +2 -2
  16. package/dist/{client-ip-BkLX8wXf.mjs.map → client-ip-lYnBU2PR.mjs.map} +1 -1
  17. package/dist/config/index.d.mts +1 -1
  18. package/dist/config/index.mjs +2 -2
  19. package/dist/config-BfImCyaG.mjs +12 -0
  20. package/dist/{config-rXsEm1rn.mjs.map → config-BfImCyaG.mjs.map} +1 -1
  21. package/dist/{container-CsCdem73.mjs → container-C2aTj8Cb.mjs} +3 -3
  22. package/dist/{container-CsCdem73.mjs.map → container-C2aTj8Cb.mjs.map} +1 -1
  23. package/dist/context-C6iKf9hN.mjs +12 -0
  24. package/dist/context-C6iKf9hN.mjs.map +1 -0
  25. package/dist/{context-errors-BUdMBVWO.mjs → context-errors-6psUheqc.mjs} +2 -2
  26. package/dist/{context-errors-BUdMBVWO.mjs.map → context-errors-6psUheqc.mjs.map} +1 -1
  27. package/dist/{contributor-runner-CZTAFvla.mjs → contributor-runner-Bn-ipSS5.mjs} +3 -3
  28. package/dist/{contributor-runner-CZTAFvla.mjs.map → contributor-runner-Bn-ipSS5.mjs.map} +1 -1
  29. package/dist/core/adapter.d.mts +1 -1
  30. package/dist/core/adapter.mjs +1 -1
  31. package/dist/core/app-module.d.mts +1 -1
  32. package/dist/core/app-module.mjs +1 -1
  33. package/dist/core/cache.mjs +1 -1
  34. package/dist/core/container.mjs +2 -2
  35. package/dist/core/cron.mjs +2 -2
  36. package/dist/core/decorators.d.mts +1 -1
  37. package/dist/core/decorators.mjs +2 -2
  38. package/dist/core/errors.mjs +2 -2
  39. package/dist/core/errors.mjs.map +1 -1
  40. package/dist/core/interfaces.mjs +1 -1
  41. package/dist/core/logger.mjs +1 -1
  42. package/dist/core/path.mjs +1 -1
  43. package/dist/core/plugin.d.mts +1 -1
  44. package/dist/core/plugin.mjs +1 -1
  45. package/dist/core/reactivity.mjs +1 -1
  46. package/dist/core-CFXpwc7m.mjs +12 -0
  47. package/dist/{core-B0mErNE1.mjs.map → core-CFXpwc7m.mjs.map} +1 -1
  48. package/dist/{cors-CsibNTQ6.d.mts → cors-2Bwhyhpt.d.mts} +4 -1
  49. package/dist/{cors-CsibNTQ6.d.mts.map → cors-2Bwhyhpt.d.mts.map} +1 -1
  50. package/dist/csrf-C3RRSCMs.mjs +12 -0
  51. package/dist/csrf-C3RRSCMs.mjs.map +1 -0
  52. package/dist/{csrf-C73UkRgc.d.mts → csrf-Cy1meSpf.d.mts} +27 -3
  53. package/dist/csrf-Cy1meSpf.d.mts.map +1 -0
  54. package/dist/decorate-DkxaoRo5.mjs +13 -0
  55. package/dist/decorate-DkxaoRo5.mjs.map +1 -0
  56. package/dist/{decorators-BxNSz9Qt.d.mts → decorators-DaQUNXOn.d.mts} +2 -2
  57. package/dist/{decorators-BxNSz9Qt.d.mts.map → decorators-DaQUNXOn.d.mts.map} +1 -1
  58. package/dist/{define-adapter-B4D_Rci1.mjs → define-adapter-BRJ6lXkV.mjs} +2 -2
  59. package/dist/{define-adapter-B4D_Rci1.mjs.map → define-adapter-BRJ6lXkV.mjs.map} +1 -1
  60. package/dist/{disposables-CgQqGmPL.mjs → disposables-5nFqc1aC.mjs} +2 -2
  61. package/dist/{disposables-CgQqGmPL.mjs.map → disposables-5nFqc1aC.mjs.map} +1 -1
  62. package/dist/errors-By6UueCm.d.mts.map +1 -1
  63. package/dist/handler-Dl_1fGxE.mjs +12 -0
  64. package/dist/handler-Dl_1fGxE.mjs.map +1 -0
  65. package/dist/{helmet-C2QEU6S-.d.mts → helmet-CEOmo516.d.mts} +4 -1
  66. package/dist/helmet-CEOmo516.d.mts.map +1 -0
  67. package/dist/host-DTQ5pZgg.mjs +12 -0
  68. package/dist/host-DTQ5pZgg.mjs.map +1 -0
  69. package/dist/http/application.d.mts +2 -2
  70. package/dist/http/application.mjs +2 -2
  71. package/dist/http/bootstrap.d.mts +1 -1
  72. package/dist/http/bootstrap.mjs +2 -2
  73. package/dist/http/context.d.mts +2 -2
  74. package/dist/http/context.mjs +2 -2
  75. package/dist/http/middleware/allowed-hosts.d.mts +3 -0
  76. package/dist/http/middleware/allowed-hosts.mjs +12 -0
  77. package/dist/http/middleware/allowed-hosts.mjs.map +1 -0
  78. package/dist/http/middleware/breach-padding.d.mts +3 -0
  79. package/dist/http/middleware/breach-padding.mjs +12 -0
  80. package/dist/http/middleware/breach-padding.mjs.map +1 -0
  81. package/dist/http/middleware/cors.d.mts +1 -1
  82. package/dist/http/middleware/cors.mjs +2 -2
  83. package/dist/http/middleware/cors.mjs.map +1 -1
  84. package/dist/http/middleware/csrf.d.mts +2 -2
  85. package/dist/http/middleware/csrf.mjs +2 -2
  86. package/dist/http/middleware/error-handler.d.mts +1 -1
  87. package/dist/http/middleware/error-handler.mjs +2 -2
  88. package/dist/http/middleware/error-handler.mjs.map +1 -1
  89. package/dist/http/middleware/helmet.d.mts +1 -1
  90. package/dist/http/middleware/helmet.mjs +2 -2
  91. package/dist/http/middleware/helmet.mjs.map +1 -1
  92. package/dist/http/middleware/rate-limit.d.mts +2 -2
  93. package/dist/http/middleware/rate-limit.mjs +2 -2
  94. package/dist/http/middleware/rate-limit.mjs.map +1 -1
  95. package/dist/http/middleware/request-id.mjs +2 -2
  96. package/dist/http/middleware/request-id.mjs.map +1 -1
  97. package/dist/http/middleware/request-logger.mjs +2 -2
  98. package/dist/http/middleware/session.d.mts +2 -2
  99. package/dist/http/middleware/session.mjs +2 -2
  100. package/dist/http/middleware/session.mjs.map +1 -1
  101. package/dist/http/middleware/spa.d.mts +1 -1
  102. package/dist/http/middleware/spa.mjs +2 -2
  103. package/dist/http/middleware/upload.d.mts +1 -1
  104. package/dist/http/middleware/upload.mjs +2 -2
  105. package/dist/http/middleware/validate.d.mts +2 -2
  106. package/dist/http/middleware/validate.mjs +2 -2
  107. package/dist/http/middleware/validate.mjs.map +1 -1
  108. package/dist/http/middleware/views.d.mts +1 -1
  109. package/dist/http/middleware/views.mjs +2 -2
  110. package/dist/http/query/index.mjs +2 -2
  111. package/dist/http/router-builder.d.mts +1 -1
  112. package/dist/http/router-builder.mjs +2 -2
  113. package/dist/http/runtimes/fastify.d.mts +5 -1
  114. package/dist/http/runtimes/fastify.d.mts.map +1 -1
  115. package/dist/http/runtimes/fastify.mjs +3 -3
  116. package/dist/http/runtimes/fastify.mjs.map +1 -1
  117. package/dist/http/runtimes/h3-web.mjs +1 -1
  118. package/dist/http/runtimes/h3.d.mts +1 -1
  119. package/dist/http/runtimes/h3.d.mts.map +1 -1
  120. package/dist/http/runtimes/h3.mjs +2 -2
  121. package/dist/http/runtimes/h3.mjs.map +1 -1
  122. package/dist/{index-CNHSbZTE.d.mts → index-CuiWSnZL.d.mts} +3 -2
  123. package/dist/index-CuiWSnZL.d.mts.map +1 -0
  124. package/dist/index.d.mts +16 -18
  125. package/dist/index.mjs +6 -2
  126. package/dist/index.mjs.map +1 -1
  127. package/dist/is-production-tnFh6NCj.mjs +12 -0
  128. package/dist/is-production-tnFh6NCj.mjs.map +1 -0
  129. package/dist/{jobs-Ccs6PkmC.mjs → jobs-lLcPhIqq.mjs} +3 -3
  130. package/dist/{jobs-Ccs6PkmC.mjs.map → jobs-lLcPhIqq.mjs.map} +1 -1
  131. package/dist/kv-stores-_wz4DEiw.mjs +12 -0
  132. package/dist/kv-stores-_wz4DEiw.mjs.map +1 -0
  133. package/dist/{metadata-DCWKG472.mjs → metadata-Tc6jhIBi.mjs} +2 -2
  134. package/dist/{metadata-DCWKG472.mjs.map → metadata-Tc6jhIBi.mjs.map} +1 -1
  135. package/dist/{observers-9FRE8VCB.mjs → observers-IGga6yut.mjs} +2 -2
  136. package/dist/{observers-9FRE8VCB.mjs.map → observers-IGga6yut.mjs.map} +1 -1
  137. package/dist/{query-DUkboS0j.mjs → query-AnbWMCd6.mjs} +2 -2
  138. package/dist/{query-DUkboS0j.mjs.map → query-AnbWMCd6.mjs.map} +1 -1
  139. package/dist/{rate-limit-Bwed3jOV.d.mts → rate-limit-BgoeahE5.d.mts} +17 -2
  140. package/dist/rate-limit-BgoeahE5.d.mts.map +1 -0
  141. package/dist/reply-DjysdCPI.mjs +12 -0
  142. package/dist/reply-DjysdCPI.mjs.map +1 -0
  143. package/dist/respond-vPZlRnZR.mjs +12 -0
  144. package/dist/respond-vPZlRnZR.mjs.map +1 -0
  145. package/dist/{route-flag-jd8PDm20.mjs → route-flag-BjRpxryx.mjs} +3 -3
  146. package/dist/{route-flag-jd8PDm20.mjs.map → route-flag-BjRpxryx.mjs.map} +1 -1
  147. package/dist/{route-policy-DlunIjGc.mjs → route-policy-Pffte5M1.mjs} +2 -2
  148. package/dist/{route-policy-DlunIjGc.mjs.map → route-policy-Pffte5M1.mjs.map} +1 -1
  149. package/dist/{router-builder-DZsCjpeV.mjs → router-builder-CrWKq6O2.mjs} +3 -3
  150. package/dist/router-builder-CrWKq6O2.mjs.map +1 -0
  151. package/dist/{session-4Tb6q0Ny.d.mts → session-ChXx7jG5.d.mts} +43 -7
  152. package/dist/session-ChXx7jG5.d.mts.map +1 -0
  153. package/dist/settings-C8VKewNS.d.mts +119 -0
  154. package/dist/settings-C8VKewNS.d.mts.map +1 -0
  155. package/dist/settings-CFtEAQUs.mjs +14 -0
  156. package/dist/settings-CFtEAQUs.mjs.map +1 -0
  157. package/dist/{upload-config-BiL1QXkT.mjs → upload-config-DLgt4l7F.mjs} +2 -2
  158. package/dist/{upload-config-BiL1QXkT.mjs.map → upload-config-DLgt4l7F.mjs.map} +1 -1
  159. package/dist/url-for-Cyh7pJCb.mjs +12 -0
  160. package/dist/url-for-Cyh7pJCb.mjs.map +1 -0
  161. package/dist/validate-CzjCbRUn.d.mts +53 -0
  162. package/dist/validate-CzjCbRUn.d.mts.map +1 -0
  163. package/dist/web.d.mts +19 -19
  164. package/dist/web.d.mts.map +1 -1
  165. package/dist/web.mjs +2 -2
  166. package/dist/web.mjs.map +1 -1
  167. package/package.json +14 -1
  168. package/dist/adapter-CvEm8Gpp.d.mts +0 -2134
  169. package/dist/adapter-CvEm8Gpp.d.mts.map +0 -1
  170. package/dist/app-module-DCA65GZZ.d.mts.map +0 -1
  171. package/dist/application-1Hln746x.d.mts +0 -1578
  172. package/dist/application-1Hln746x.d.mts.map +0 -1
  173. package/dist/application-D21ZVAWG.mjs +0 -12
  174. package/dist/application-D21ZVAWG.mjs.map +0 -1
  175. package/dist/bootstrap-2hi7Zhs8.mjs +0 -12
  176. package/dist/bootstrap-2hi7Zhs8.mjs.map +0 -1
  177. package/dist/config-rXsEm1rn.mjs +0 -12
  178. package/dist/context-Bd02q5Sm.mjs +0 -12
  179. package/dist/context-Bd02q5Sm.mjs.map +0 -1
  180. package/dist/core-B0mErNE1.mjs +0 -12
  181. package/dist/csrf-BnetlmWY.mjs +0 -12
  182. package/dist/csrf-BnetlmWY.mjs.map +0 -1
  183. package/dist/csrf-C73UkRgc.d.mts.map +0 -1
  184. package/dist/decorate-B7-z930n.mjs +0 -11
  185. package/dist/env-ngWmBB9d.mjs +0 -13
  186. package/dist/env-ngWmBB9d.mjs.map +0 -1
  187. package/dist/error-handler-Chw07m-M.d.mts +0 -63
  188. package/dist/error-handler-Chw07m-M.d.mts.map +0 -1
  189. package/dist/handler-CyRoAqNt.mjs +0 -13
  190. package/dist/handler-CyRoAqNt.mjs.map +0 -1
  191. package/dist/helmet-C2QEU6S-.d.mts.map +0 -1
  192. package/dist/index-CNHSbZTE.d.mts.map +0 -1
  193. package/dist/kv-stores-9IkW7Rjj.mjs +0 -12
  194. package/dist/kv-stores-9IkW7Rjj.mjs.map +0 -1
  195. package/dist/kv-stores-BYeO77zK.d.mts +0 -367
  196. package/dist/kv-stores-BYeO77zK.d.mts.map +0 -1
  197. package/dist/module-registry-Cl12vSJd.mjs +0 -12
  198. package/dist/module-registry-Cl12vSJd.mjs.map +0 -1
  199. package/dist/rate-limit-Bwed3jOV.d.mts.map +0 -1
  200. package/dist/reply-DElkObMy.mjs +0 -12
  201. package/dist/reply-DElkObMy.mjs.map +0 -1
  202. package/dist/respond-Dcj1NF_X.mjs +0 -12
  203. package/dist/respond-Dcj1NF_X.mjs.map +0 -1
  204. package/dist/router-builder-DZsCjpeV.mjs.map +0 -1
  205. package/dist/router-builder-D_SkWTfE.d.mts +0 -56
  206. package/dist/router-builder-D_SkWTfE.d.mts.map +0 -1
  207. package/dist/session-4Tb6q0Ny.d.mts.map +0 -1
  208. package/dist/upload-DL_jrBGk.d.mts +0 -104
  209. package/dist/upload-DL_jrBGk.d.mts.map +0 -1
  210. package/dist/validate-DMYpUnrf.d.mts +0 -25
  211. package/dist/validate-DMYpUnrf.d.mts.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"respond-Dcj1NF_X.mjs","names":[],"sources":["../src/http/middleware/respond.ts"],"sourcesContent":["/**\n * Response helpers that work on every runtime.\n *\n * Connect middleware receives an Express response under Express and a raw\n * `ServerResponse` under Fastify and h3. `res.cookie()` and `res.status().json()`\n * are Express conveniences that do not exist on the raw object, so a shipped\n * middleware reaching for them works on one engine and throws on the other two:\n *\n * csrf → `res.cookie()` threw before any check ran, so EVERY request\n * became a 500 — including safe methods the middleware is\n * supposed to wave through\n * rateLimit → `res.status()` threw only once the limit was hit, and the\n * throw left the request hanging rather than answering 429\n * session → `res.cookie()` threw on every response that issued a session\n *\n * These take the Express path when it is there — so behaviour under Express is\n * byte-identical to before — and fall back to the Node primitives otherwise.\n *\n * @module @forinda/kickjs/http/middleware/respond\n */\n\n/**\n * Cookies on the request, whoever parsed them.\n *\n * `req.cookies` exists only when an upstream cookie parser populated it —\n * `cookie-parser` under Express, nothing at all under Fastify and h3, which\n * pass a raw node request. A middleware that reads only `req.cookies` therefore\n * sees no cookies on those runtimes, and none under Express either unless the\n * app happens to mount a parser.\n *\n * For `csrf` that broke the double-submit flow outright: with no cookie visible\n * it minted a fresh token on every request and compared the submitted header\n * against that new value, so a client could never complete a protected request.\n */\nexport function readCookies(req: unknown): Record<string, string> {\n const source = req as { cookies?: Record<string, string>; headers?: Record<string, unknown> }\n if (source.cookies) return source.cookies\n const header = source.headers?.cookie\n return typeof header === 'string' ? parseCookieHeader(header) : {}\n}\n\n/** `a=1; b=2` → `{ a: '1', b: '2' }`. */\nexport function parseCookieHeader(header: string): Record<string, string> {\n const out: Record<string, string> = {}\n for (const pair of header.split(';')) {\n const eq = pair.indexOf('=')\n if (eq === -1) continue\n const key = pair.slice(0, eq).trim()\n if (!key) continue\n let value = pair.slice(eq + 1).trim()\n if (value.startsWith('\"') && value.endsWith('\"')) {\n value = value.slice(1, -1)\n }\n try {\n out[key] = decodeURIComponent(value)\n } catch {\n // A malformed escape is not a reason to lose the whole cookie jar.\n out[key] = value\n }\n }\n return out\n}\n\n/** Cookie attributes, matching the subset of Express's `res.cookie` we use. */\nexport interface CookieOptions {\n maxAge?: number\n expires?: Date\n domain?: string\n path?: string\n httpOnly?: boolean\n secure?: boolean\n sameSite?: boolean | 'lax' | 'strict' | 'none'\n}\n\ninterface AnyResponse {\n cookie?: (name: string, value: string, options?: CookieOptions) => unknown\n status?: (code: number) => { json?: (body: unknown) => unknown }\n statusCode?: number\n getHeader?: (name: string) => unknown\n setHeader?: (name: string, value: unknown) => unknown\n end?: (chunk?: unknown) => unknown\n}\n\n/** `Set-Cookie` value for one cookie, per RFC 6265 §4.1. */\nfunction serializeCookie(name: string, value: string, options: CookieOptions): string {\n const parts = [`${name}=${encodeURIComponent(value)}`]\n // Express takes `maxAge` in milliseconds; `Max-Age` is seconds.\n if (options.maxAge !== undefined) parts.push(`Max-Age=${Math.floor(options.maxAge / 1000)}`)\n if (options.expires) parts.push(`Expires=${options.expires.toUTCString()}`)\n if (options.domain) parts.push(`Domain=${options.domain}`)\n parts.push(`Path=${options.path ?? '/'}`)\n if (options.httpOnly) parts.push('HttpOnly')\n if (options.secure) parts.push('Secure')\n if (options.sameSite) {\n // `true` means Strict, matching Express.\n const value = options.sameSite === true ? 'Strict' : options.sameSite\n parts.push(`SameSite=${value.charAt(0).toUpperCase()}${value.slice(1)}`)\n }\n return parts.join('; ')\n}\n\n/** Set a cookie without assuming Express. Appends, never replaces. */\nexport function setCookie(\n res: unknown,\n name: string,\n value: string,\n options: CookieOptions = {},\n): void {\n const target = res as AnyResponse\n if (typeof target.cookie === 'function') {\n target.cookie(name, value, options)\n return\n }\n const cookie = serializeCookie(name, value, options)\n const prior = target.getHeader?.('Set-Cookie')\n const all = prior === undefined ? [cookie] : [...(Array.isArray(prior) ? prior : [prior]), cookie]\n target.setHeader?.('Set-Cookie', all)\n}\n\n/** Send a JSON body with a status, without assuming Express. */\nexport function sendJson(res: unknown, status: number, body: unknown): void {\n const target = res as AnyResponse\n if (typeof target.status === 'function') {\n const chained = target.status(status)\n if (typeof chained?.json === 'function') {\n chained.json(body)\n return\n }\n }\n target.statusCode = status\n if (!target.getHeader?.('content-type')) {\n target.setHeader?.('content-type', 'application/json; charset=utf-8')\n }\n target.end?.(JSON.stringify(body))\n}\n"],"mappings":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AC,CAAC,CAAC,YAAY,IAAI,MAAM,MAAM,CAAC,GAAG,CACzE,CACA,OAAO,MAAM,KAAK,IAAI,CACxB,CAGA,SAAgB,UACd,IACA,KACA,MACA,QAAyB,CAAC,EACpB,CACN,IAAM,OAAS,IACf,GAAI,OAAO,OAAO,QAAW,WAAY,CACvC,OAAO,OAAO,KAAM,MAAO,OAAO,EAClC,MACF,CACA,IAAM,OAAS,gBAAgB,KAAM,MAAO,OAAO,EAC7C,MAAQ,OAAO,YAAY,YAAY,EACvC,IAAM,QAAU,IAAA,GAAY,CAAC,MAAM,EAAI,CAAC,GAAI,MAAM,QAAQ,KAAK,EAAI,MAAQ,CAAC,KAAK,EAAI,MAAM,EACjG,OAAO,YAAY,aAAc,GAAG,CACtC,CAGA,SAAgB,SAAS,IAAc,OAAgB,KAAqB,CAC1E,IAAM,OAAS,IACf,GAAI,OAAO,OAAO,QAAW,WAAY,CACvC,IAAM,QAAU,OAAO,OAAO,MAAM,EACpC,GAAI,OAAO,SAAS,MAAS,WAAY,CACvC,QAAQ,KAAK,IAAI,EACjB,MACF,CACF,CACA,OAAO,WAAa,OACf,OAAO,YAAY,cAAc,GACpC,OAAO,YAAY,eAAgB,iCAAiC,EAEtE,OAAO,MAAM,KAAK,UAAU,IAAI,CAAC,CACnC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"router-builder-DZsCjpeV.mjs","names":[],"sources":["../src/core/contributor-pipeline.ts","../src/http/router-builder.ts"],"sourcesContent":["import type { AnyContributorRegistration } from './context-decorator'\nimport {\n ContributorCycleError,\n DuplicateContributorError,\n MissingContributorError,\n} from './context-errors'\n\n/**\n * Where a contributor was registered, ordered by precedence\n * (lower index wins). Mirrors `architecture.md` §20.4.\n *\n * Levels (highest → lowest precedence):\n * - `'method'` — `@LoadX` on a controller method.\n * - `'class'` — `@LoadX` on a controller class.\n * - `'module'` — returned by `AppModule.contributors?()`. Per-module scope.\n * - `'adapter'` — returned by `AppAdapter.contributors?()`. Cross-cutting, applies\n * to every module's routes.\n * - `'global'` — `ApplicationOptions.contributors`. App-wide default.\n */\nexport type ContributorSource = 'method' | 'class' | 'module' | 'adapter' | 'global'\n\n/** Precedence-ranked source list. Index = precedence; method (0) wins ties. */\nconst PRECEDENCE_ORDER: readonly ContributorSource[] = [\n 'method',\n 'class',\n 'module',\n 'adapter',\n 'global',\n]\n\n/**\n * Input row to {@link buildPipeline}. Pairs a registration with its origin\n * so dedup can apply the precedence rule and diagnostic errors can name\n * the offending site.\n *\n * `registration` is the type-erased {@link AnyContributorRegistration}\n * — the runner doesn't care about each registration's narrow `D` /\n * `Ctx` shape, and adopters frequently mix HTTP / transport-agnostic\n * contributors in the same `externalSources` / `contributors()`\n * array. The narrow generics from `defineContextDecorator` survive\n * at the *definition* site (where `resolve` is typed); they're erased\n * here so collections compose without `as any` casts.\n */\nexport interface SourcedRegistration {\n registration: AnyContributorRegistration\n source: ContributorSource\n /** Human label surfaced in DuplicateContributorError messages. */\n label?: string\n}\n\n/**\n * Resolved, validated, topo-sorted pipeline ready for execution.\n *\n * `contributors` is in execution order — every entry's `dependsOn`\n * keys appear earlier. `keys` is the set of all keys this pipeline\n * produces; the runner uses it for fast existence checks and the\n * builder uses it for missing-dep validation.\n */\nexport interface ContributorPipeline {\n readonly contributors: readonly AnyContributorRegistration[]\n readonly keys: ReadonlySet<string>\n}\n\nexport interface BuildPipelineOptions {\n /** Optional route identifier surfaced in diagnostic errors (e.g., 'GET /projects/:id'). */\n route?: string\n}\n\n/**\n * Build, validate, and topo-sort a contributor pipeline.\n *\n * Pipeline:\n *\n * 1. Group sources by precedence (method > class > module > adapter > global).\n * 2. Within each precedence level, two contributors with the same `key`\n * raise {@link DuplicateContributorError}.\n * 3. Across levels, the highest-precedence contributor wins each key\n * (lower-precedence duplicates are silently dropped — that is the\n * documented override mechanism, not an error).\n * 4. Every key referenced by `dependsOn` must be produced by the\n * surviving set, otherwise {@link MissingContributorError}.\n * 5. Kahn's algorithm topo-sorts the survivors. Any nodes left after\n * the queue drains form a cycle → {@link ContributorCycleError}\n * with a reconstructed path.\n *\n * Pure function — no DI, no I/O. Safe to call once at startup per\n * route and cache the result.\n */\nexport function buildPipeline(\n sources: readonly SourcedRegistration[],\n options: BuildPipelineOptions = {},\n): ContributorPipeline {\n const route = options.route\n\n // Step 1: group by source.\n const bySource = new Map<ContributorSource, SourcedRegistration[]>()\n for (const src of PRECEDENCE_ORDER) bySource.set(src, [])\n for (const entry of sources) bySource.get(entry.source)!.push(entry)\n\n // Step 2 + 3: dedup with precedence. We walk highest precedence first,\n // claim its keys, and drop lower-precedence rows that conflict.\n const winners = new Map<string, SourcedRegistration>()\n for (const src of PRECEDENCE_ORDER) {\n const rows = bySource.get(src)!\n const keysAtThisLevel = new Map<string, SourcedRegistration[]>()\n for (const row of rows) {\n const key = row.registration.key\n const existing = keysAtThisLevel.get(key) ?? []\n existing.push(row)\n keysAtThisLevel.set(key, existing)\n }\n for (const [key, rowsForKey] of keysAtThisLevel) {\n if (rowsForKey.length > 1) {\n const labels = rowsForKey.map((r, i) => r.label ?? `${src}#${i}`)\n throw new DuplicateContributorError(key, labels)\n }\n if (!winners.has(key)) winners.set(key, rowsForKey[0])\n }\n }\n\n const survivors = [...winners.values()].map((r) => r.registration)\n const allKeys = new Set(survivors.map((r) => r.key))\n\n // Step 4: dependsOn validation.\n for (const reg of survivors) {\n for (const dep of reg.dependsOn) {\n if (!allKeys.has(dep)) {\n throw new MissingContributorError(dep, reg.key, route, reg.definedAt)\n }\n }\n }\n\n // Step 5: Kahn topo-sort.\n const sorted = topoSort(survivors, route)\n\n return Object.freeze({\n contributors: Object.freeze(sorted),\n keys: allKeys,\n })\n}\n\n/**\n * Split a built pipeline into the contributors that run before request\n * validation (`beforeValidation: true`) and the rest, which keep their place\n * after `@Middleware()`. Both halves stay in topo order.\n *\n * An early contributor can only depend on other early ones — its dependency\n * would not have run yet otherwise — so that fails here, at boot.\n */\nexport function splitBeforeValidation(\n pipeline: ContributorPipeline,\n route?: string,\n): { early: ContributorPipeline | null; late: ContributorPipeline | null } {\n const early = pipeline.contributors.filter((reg) => reg.beforeValidation)\n if (early.length === 0) return { early: null, late: pipeline }\n\n const earlyKeys = new Set(early.map((reg) => reg.key))\n for (const reg of early) {\n const lateDep = reg.dependsOn.find((dep) => !earlyKeys.has(dep))\n if (lateDep !== undefined) {\n throw new Error(\n `Contributor '${reg.key}'${route ? ` on ${route}` : ''} sets beforeValidation but ` +\n `depends on '${lateDep}', which runs after validation. Set beforeValidation on ` +\n `'${lateDep}' too, or remove it from '${reg.key}'.`,\n )\n }\n }\n\n const late = pipeline.contributors.filter((reg) => !reg.beforeValidation)\n return {\n early: Object.freeze({ contributors: Object.freeze(early), keys: earlyKeys }),\n late:\n late.length === 0\n ? null\n : Object.freeze({\n contributors: Object.freeze(late),\n keys: new Set(late.map((reg) => reg.key)),\n }),\n }\n}\n\n/**\n * Kahn's algorithm with deterministic ordering on ties.\n *\n * Nodes with no remaining incoming edges enter the queue in input\n * order. Cycles surface as nodes still present after the queue\n * drains; we reconstruct one cycle path for diagnostics.\n */\nfunction topoSort(\n registrations: readonly AnyContributorRegistration[],\n route: string | undefined,\n): AnyContributorRegistration[] {\n // indegree[key] = number of unresolved dependsOn entries for key\n const indegree = new Map<string, number>()\n // dependents[depKey] = list of registrations that depend on depKey\n const dependents = new Map<string, AnyContributorRegistration[]>()\n const byKey = new Map<string, AnyContributorRegistration>()\n\n for (const reg of registrations) {\n indegree.set(reg.key, reg.dependsOn.length)\n byKey.set(reg.key, reg)\n }\n for (const reg of registrations) {\n for (const dep of reg.dependsOn) {\n const list = dependents.get(dep) ?? []\n list.push(reg)\n dependents.set(dep, list)\n }\n }\n\n // Initial queue: registrations with zero indegree, preserving input order.\n const queue: AnyContributorRegistration[] = []\n for (const reg of registrations) {\n if (indegree.get(reg.key) === 0) queue.push(reg)\n }\n\n const sorted: AnyContributorRegistration[] = []\n while (queue.length > 0) {\n const node = queue.shift()!\n sorted.push(node)\n for (const dependent of dependents.get(node.key) ?? []) {\n const next = (indegree.get(dependent.key) ?? 0) - 1\n indegree.set(dependent.key, next)\n if (next === 0) queue.push(dependent)\n }\n }\n\n if (sorted.length !== registrations.length) {\n const remaining = registrations.filter((r) => (indegree.get(r.key) ?? 0) > 0)\n throw new ContributorCycleError(reconstructCycle(remaining, byKey), route)\n }\n\n return sorted\n}\n\n/**\n * Reconstruct one cycle path from the residual graph.\n *\n * Walks from any remaining node, following its first dependency that's\n * still in the residual set, until we revisit a node. The path returned\n * starts and ends with the same key so the message reads naturally:\n * `tenant → project → tenant`.\n */\nfunction reconstructCycle(\n residual: readonly AnyContributorRegistration[],\n byKey: ReadonlyMap<string, AnyContributorRegistration>,\n): string[] {\n const residualKeys = new Set(residual.map((r) => r.key))\n const start = residual[0].key\n const path: string[] = [start]\n const seen = new Set<string>([start])\n let cursor: string = start\n\n while (true) {\n const reg = byKey.get(cursor)!\n const nextDep = reg.dependsOn.find((d) => residualKeys.has(d))\n if (nextDep === undefined) break\n if (seen.has(nextDep)) {\n // Trim the prefix that isn't part of the cycle.\n const cycleStart = path.indexOf(nextDep)\n return [...path.slice(cycleStart), nextDep]\n }\n path.push(nextDep)\n seen.add(nextDep)\n cursor = nextDep\n }\n\n // Fallback — couldn't reconstruct a strict cycle, return what we walked.\n return path\n}\n","// Concrete-module imports (NOT the `../core` barrel): the barrel re-exports\n// the asset manager, whose eager `node:fs` import would poison the edge-safe\n// `@forinda/kickjs/web` entry graph that flows through this file.\nimport {\n buildPipeline,\n splitBeforeValidation,\n type SourcedRegistration,\n} from '../core/contributor-pipeline'\nimport { runContributors } from '../core/contributor-runner'\nimport { Container } from '../core/container'\nimport { METADATA } from '../core/interfaces'\nimport type { ContributorRegistration } from '../core/context-decorator'\nimport type { FileUploadConfig, MiddlewareHandler, RouteDefinition } from '../core/decorators'\nimport { getClassMeta, getMethodMeta, getMethodMetaOrUndefined } from '../core/metadata'\nimport {\n getClassFlagDeclarations,\n getMethodFlagDeclarations,\n registerMountFlags,\n resolveRouteFlags,\n toFlagDeclarations,\n type RouteFlagDeclarations,\n} from '../core/route-flag'\nimport { duplicateRouteError } from '../core/kick-errors'\nimport type { CtxHandler, RouteEntry, RouteMethod } from './runtime'\n\n/**\n * Per-module SourcedRegistration[] threaded through the route-mount loop by\n * Application.setup(). Carries module + adapter + global contributors so\n * buildRouteTable() can merge them with class + method ones into a single pipeline.\n *\n * Module setup is sequential, so this slot is race-free. Cleared in a finally\n * block after each module mounts. Outside of Application setup the slot is\n * empty — direct buildRouteTable()/buildRoutes() callers (mostly tests) see only\n * class + method contributors unless they pass `externalSources` explicitly.\n *\n * Same idiom as `Container._requestStoreProvider`: an internal escape hatch for\n * cross-module wiring without inversion-of-control gymnastics.\n *\n * @internal\n */\nlet _externalContributorSources: readonly SourcedRegistration[] = []\n\n/** @internal — set by Application.setup() before each `mod.routes()` call. */\nexport function _setExternalContributorSources(sources: readonly SourcedRegistration[]): void {\n _externalContributorSources = sources\n}\n\n/**\n * Boot-time duplicate-route guard shared by the node and web mount loops.\n *\n * Registers `METHOD /mounted/path` into `registry` and throws\n * {@link duplicateRouteError} (KICK006) if another handler already claimed\n * it. Param *names* are ignored — `/tasks/:id` and `/tasks/:taskId` are the\n * same route at dispatch time, so they collide here too.\n *\n * @internal\n */\nexport function assertRouteUnique(\n registry: Map<string, string>,\n method: string,\n fullPath: string,\n owner: string,\n): void {\n const key = `${method.toUpperCase()} ${fullPath.replace(/:[^/]+/g, ':*')}`\n const prior = registry.get(key)\n if (prior !== undefined) {\n throw duplicateRouteError(method.toUpperCase(), fullPath, owner, prior)\n }\n registry.set(key, owner)\n}\n\nexport interface BuildRoutesOptions {\n /**\n * Extra contributors to merge into the per-route pipeline at their declared\n * precedence levels. Pass explicitly when calling buildRouteTable/buildRoutes\n * outside the Application route-mount loop (typically in tests). When omitted,\n * falls back to the slot set by Application.setup().\n */\n externalSources?: readonly SourcedRegistration[]\n /**\n * Flags the mounting module declares for every route on this controller\n * (`ModuleRoutes.flags`). Lowest precedence — a class or method declaration\n * of the same name wins, and `@Flag.off` on a method removes it.\n */\n mountFlags?: RouteFlagDeclarations\n}\n\n/**\n * Turn a controller class decorated with @Get, @Post, etc. into a plain-data\n * {@link RouteEntry}[] — the engine-neutral route table an {@link HttpRuntime}\n * materializes.\n *\n * What used to be per-handler Express `(req, res, next)` closures is now\n * captured as data: `middlewares` keep their `(ctx, next)` shape, the contributor\n * pipeline is pre-built into a `contributorRunner` closure, validation / upload\n * stay as metadata, and the terminal `handler` resolves the controller per-request\n * (to respect DI scoping) and invokes it. The runtime owns how these get wrapped\n * onto its engine.\n *\n * Routes use only the method-level decorator paths (e.g. @Get('/me') → '/me').\n * The @Controller path is NOT baked in — it is metadata for Swagger/introspection.\n * The module's routes().path is the single source of truth for the mount prefix,\n * which avoids path doubling when both the module and controller specify the path.\n *\n * The contributor pipeline is built here, so a cycle or missing `dependsOn`\n * throws at table-build time (boot) rather than on first request.\n */\nexport function buildRouteTable(\n controllerClass: any,\n options: BuildRoutesOptions = {},\n): RouteEntry[] {\n const container = Container.getInstance()\n const externalSources = options.externalSources ?? _externalContributorSources\n const routes: RouteDefinition[] = getClassMeta<RouteDefinition[]>(\n METADATA.ROUTES,\n controllerClass,\n [],\n )\n\n // Class-level middleware\n const classMiddlewares: MiddlewareHandler[] = getClassMeta<MiddlewareHandler[]>(\n METADATA.CLASS_MIDDLEWARES,\n controllerClass,\n [],\n )\n\n // Class-level Context Contributors (#107) — applied to every method on the\n // controller. Method-level contributors are added per-route below.\n const classContributors: ContributorRegistration[] = getClassMeta<ContributorRegistration[]>(\n METADATA.CLASS_CONTRIBUTORS,\n controllerClass,\n [],\n )\n\n // Route flags declared on the controller — inherited by every method below\n // unless a method declares the same flag `false` (see core/route-flag.ts).\n const classFlagDeclarations = getClassFlagDeclarations(controllerClass)\n\n // Flags the module declared for this whole mount. Recorded against the class\n // so `getRouteFlags()` — the resolver Swagger and DevTools use, which sees no\n // mount — reports what the runtime actually resolved.\n const mountFlagDeclarations = toFlagDeclarations(\n options.mountFlags,\n `${controllerClass?.name ?? 'controller'} mount flags`,\n )\n registerMountFlags(controllerClass, mountFlagDeclarations)\n\n const entries: RouteEntry[] = []\n\n for (const route of routes) {\n const method = route.method.toUpperCase() as RouteMethod\n const fullPath = route.path || '/'\n\n // Method-level middleware\n const methodMiddlewares: MiddlewareHandler[] = getMethodMeta<MiddlewareHandler[]>(\n METADATA.METHOD_MIDDLEWARES,\n controllerClass,\n route.handlerName,\n [],\n )\n\n // @FileUpload decorator — runtime supplies the upload backend.\n const fileUploadConfig = getMethodMetaOrUndefined<FileUploadConfig>(\n METADATA.FILE_UPLOAD,\n controllerClass,\n route.handlerName,\n )\n\n // Context Contributor pipeline (#107) — class + method contributors,\n // built once at mount time so cycle/missing-dep failures abort boot.\n const methodContributors: ContributorRegistration[] = getMethodMeta<ContributorRegistration[]>(\n METADATA.METHOD_CONTRIBUTORS,\n controllerClass,\n route.handlerName,\n [],\n )\n\n // Flags in force for THIS route: class declarations overridden by method\n // ones. Resolved at build time so the per-request cost is a map lookup.\n const flags = resolveRouteFlags(\n classFlagDeclarations,\n getMethodFlagDeclarations(controllerClass, route.handlerName),\n mountFlagDeclarations,\n )\n\n let contributorRunner: CtxHandler | null = null\n let earlyContributorRunner: CtxHandler | null = null\n if (\n classContributors.length > 0 ||\n methodContributors.length > 0 ||\n externalSources.length > 0\n ) {\n // Labels are surfaced in DuplicateContributorError messages — include\n // the registration's key + the original index so a same-key collision\n // at one precedence level points at the conflicting decorator slot,\n // not just the host method/class.\n const sources: SourcedRegistration[] = [\n ...methodContributors.map((registration, i): SourcedRegistration => ({\n source: 'method',\n registration,\n label: `${controllerClass.name}.${String(route.handlerName)}#${i}(${registration.key})`,\n })),\n ...classContributors.map((registration, i): SourcedRegistration => ({\n source: 'class',\n registration,\n label: `${controllerClass.name}.@class#${i}(${registration.key})`,\n })),\n ...externalSources,\n ]\n const routeLabel = `${method} ${fullPath}`\n const { early, late } = splitBeforeValidation(\n buildPipeline(sources, { route: routeLabel }),\n routeLabel,\n )\n if (early) {\n earlyContributorRunner = (ctx) =>\n runContributors({ pipeline: early, ctx, container, flags })\n }\n if (late) {\n contributorRunner = (ctx) => runContributors({ pipeline: late, ctx, container, flags })\n }\n }\n\n // Terminal handler — resolve controller per-request to respect DI scoping.\n const handler: CtxHandler = (ctx) => container.resolve(controllerClass)[route.handlerName](ctx)\n\n entries.push({\n method,\n path: fullPath,\n middlewares: [...classMiddlewares, ...methodMiddlewares],\n contributorRunner,\n earlyContributorRunner,\n handler,\n meta: {\n controller: controllerClass,\n handlerName: route.handlerName,\n validation: route.validation,\n upload: fileUploadConfig,\n flags,\n },\n })\n }\n\n return entries\n}\n"],"mappings":";;;;;;;;;;mlBAsBA,MAAM,iBAAiD,CACrD,SACA,QACA,SACA,UACA,QACF,EA4DA,SAAgB,cACd,QACA,QAAgC,CAAC,EACZ,CACrB,IAAM,MAAQ,QAAQ,MAGhB,yBAAW,IAAI,IACrB,IAAK,IAAM,OAAO,iBAAkB,SAAS,IAAI,IAAK,CAAC,CAAC,EACxD,IAAK,IAAM,SAAS,QAAS,SAAS,IAAI,MAAM,MAAM,CAAC,CAAE,KAAK,KAAK,EAInE,IAAM,wBAAU,IAAI,IACpB,IAAK,IAAM,OAAO,iBAAkB,CAClC,IAAM,KAAO,SAAS,IAAI,GAAG,EACvB,gCAAkB,IAAI,IAC5B,IAAK,IAAM,OAAO,KAAM,CACtB,IAAM,IAAM,IAAI,aAAa,IACvB,SAAW,gBAAgB,IAAI,GAAG,GAAK,CAAC,EAC9C,SAAS,KAAK,GAAG,EACjB,gBAAgB,IAAI,IAAK,QAAQ,CACnC,CACA,IAAK,GAAM,CAAC,IAAK,cAAe,gBAAiB,CAC/C,GAAI,WAAW,OAAS,EAAG,CACzB,IAAM,OAAS,WAAW,KAAK,EAAG,IAAM,EAAE,OAAS,GAAG,IAAI,GAAG,GAAG,EAChE,MAAM,IAAI,0BAA0B,IAAK,MAAM,CACjD,CACK,QAAQ,IAAI,GAAG,GA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1
-
2
- import { B as SourcedRegistration, g as RouteEntry } from "./adapter-CvEm8Gpp.mjs";
3
- import { s as RouteFlagDeclarations } from "./route-flag-B1lQht6v.mjs";
4
- //#region src/http/router-builder.d.ts
5
- /** @internal — set by Application.setup() before each `mod.routes()` call. */
6
- declare function _setExternalContributorSources(sources: readonly SourcedRegistration[]): void;
7
- /**
8
- * Boot-time duplicate-route guard shared by the node and web mount loops.
9
- *
10
- * Registers `METHOD /mounted/path` into `registry` and throws
11
- * {@link duplicateRouteError} (KICK006) if another handler already claimed
12
- * it. Param *names* are ignored — `/tasks/:id` and `/tasks/:taskId` are the
13
- * same route at dispatch time, so they collide here too.
14
- *
15
- * @internal
16
- */
17
- declare function assertRouteUnique(registry: Map<string, string>, method: string, fullPath: string, owner: string): void;
18
- interface BuildRoutesOptions {
19
- /**
20
- * Extra contributors to merge into the per-route pipeline at their declared
21
- * precedence levels. Pass explicitly when calling buildRouteTable/buildRoutes
22
- * outside the Application route-mount loop (typically in tests). When omitted,
23
- * falls back to the slot set by Application.setup().
24
- */
25
- externalSources?: readonly SourcedRegistration[];
26
- /**
27
- * Flags the mounting module declares for every route on this controller
28
- * (`ModuleRoutes.flags`). Lowest precedence — a class or method declaration
29
- * of the same name wins, and `@Flag.off` on a method removes it.
30
- */
31
- mountFlags?: RouteFlagDeclarations;
32
- }
33
- /**
34
- * Turn a controller class decorated with @Get, @Post, etc. into a plain-data
35
- * {@link RouteEntry}[] — the engine-neutral route table an {@link HttpRuntime}
36
- * materializes.
37
- *
38
- * What used to be per-handler Express `(req, res, next)` closures is now
39
- * captured as data: `middlewares` keep their `(ctx, next)` shape, the contributor
40
- * pipeline is pre-built into a `contributorRunner` closure, validation / upload
41
- * stay as metadata, and the terminal `handler` resolves the controller per-request
42
- * (to respect DI scoping) and invokes it. The runtime owns how these get wrapped
43
- * onto its engine.
44
- *
45
- * Routes use only the method-level decorator paths (e.g. @Get('/me') → '/me').
46
- * The @Controller path is NOT baked in — it is metadata for Swagger/introspection.
47
- * The module's routes().path is the single source of truth for the mount prefix,
48
- * which avoids path doubling when both the module and controller specify the path.
49
- *
50
- * The contributor pipeline is built here, so a cycle or missing `dependsOn`
51
- * throws at table-build time (boot) rather than on first request.
52
- */
53
- declare function buildRouteTable(controllerClass: any, options?: BuildRoutesOptions): RouteEntry[];
54
- //#endregion
55
- export { buildRouteTable as i, _setExternalContributorSources as n, assertRouteUnique as r, BuildRoutesOptions as t };
56
- //# sourceMappingURL=router-builder-D_SkWTfE.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"router-builder-D_SkWTfE.d.mts","names":[],"sources":["../src/http/router-builder.ts"],"mappings":";;;;;iBA2CgB,+BAA+B,kBAAkB;;;;;;;;;;;iBAcjD,kBACd,UAAU,qBACV,gBACA,kBACA;UAUe;;;;;;;EAOf,2BAA2B;;;;;;EAM3B,aAAa;;;;;;;;;;;;;;;;;;;;;;iBAuBC,gBACd,sBACA,UAAS,qBACR"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"session-4Tb6q0Ny.d.mts","names":[],"sources":["../src/http/middleware/session.ts"],"mappings":";;;;;;;;;;;;;UAgBiB;GACd;;UAGc;EACf,IAAI,cAAc,QAAQ;EAC1B,IAAI,aAAa,MAAM,aAAa,iBAAiB;EACrD,QAAQ,cAAc;EACtB,OAAO,aAAa,iBAAiB;;UAGtB;EACf;EACA,MAAM;EACN,cAAc;EACd,WAAW;EACX,QAAQ;;UAGO;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;IACE;IACA;IACA;IACA;IACA;;;EAGF,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiHM,QAAQ,SAAS,kBAAc,KAoB1B,SAAO,KAAO,UAAQ,MAAQ,iBAAY"}
@@ -1,104 +0,0 @@
1
-
2
- import { g as FileUploadConfig, o as BaseUploadOptions } from "./decorators-BxNSz9Qt.mjs";
3
- import "./adapter-CvEm8Gpp.mjs";
4
- import { NextFunction, Request, RequestHandler, Response } from "express";
5
- import { Options } from "multer";
6
- //#region src/http/middleware/upload-config.d.ts
7
- /**
8
- * Resolves a list of file type identifiers to MIME type strings.
9
- * Accepts short extensions (`'jpg'`, `'pdf'`) or full MIME types (`'image/jpeg'`).
10
- *
11
- * @example
12
- * ```ts
13
- * resolveMimeTypes(['jpg', 'png', 'application/pdf'])
14
- * // → ['image/jpeg', 'image/png', 'application/pdf']
15
- * ```
16
- */
17
- declare function resolveMimeTypes(types: string[]): string[];
18
- /**
19
- * Build a runtime-agnostic `(mimetype, filename) => boolean` file-type filter
20
- * from `allowedTypes` (a predicate, or a list of extensions / MIME types /
21
- * wildcards). Returned by both the multer middleware (Express) and the
22
- * Fastify / h3 / web multipart paths so the accept/reject rule stays
23
- * identical across engines. No `allowedTypes` → accept everything.
24
- */
25
- declare function buildFileTypeFilter(allowedTypes: BaseUploadOptions['allowedTypes'], customMimeMap?: Record<string, string>): (mimetype: string, filename: string) => boolean;
26
- /** A multer-shaped uploaded file — what `ctx.file` / `ctx.files` expose. */
27
- interface UploadedFileLike {
28
- fieldname: string;
29
- originalname: string;
30
- encoding: string;
31
- mimetype: string;
32
- size: number;
33
- buffer: Buffer;
34
- }
35
- /** A buffered multipart file part, as the runtime hands it to {@link applyUploadConfig}. */
36
- interface RawUploadPart {
37
- fieldname: string;
38
- filename: string;
39
- mimetype: string;
40
- buffer: Buffer;
41
- }
42
- /**
43
- * Apply a `@FileUpload` config to already-buffered multipart parts and return
44
- * the multer-shaped `file` / `files` for `ctx`. Enforces the field name, type
45
- * filter, per-file size limit, and (array mode) max count — throwing
46
- * `HttpException` on a violation, mirroring the Express/multer error path.
47
- * Used by the Fastify, h3 and web runtimes; Express keeps using multer directly.
48
- */
49
- declare function applyUploadConfig(parts: RawUploadPart[], config: FileUploadConfig): {
50
- file?: UploadedFileLike;
51
- files?: UploadedFileLike[];
52
- };
53
- //#endregion
54
- //#region src/http/middleware/upload.d.ts
55
- /**
56
- * Upload options for the middleware.
57
- * Extends BaseUploadOptions from core (shared with @FileUpload decorator)
58
- * and adds Multer-specific storage options.
59
- */
60
- interface UploadOptions extends BaseUploadOptions {
61
- /** Multer storage config (default: memory storage) */
62
- storage?: Options['storage'];
63
- /** Multer dest for disk storage shorthand */
64
- dest?: string;
65
- }
66
- declare function single(fieldName: string, options?: UploadOptions): RequestHandler;
67
- /**
68
- * Multiple file upload middleware. Attaches files to `req.files`.
69
- */
70
- declare function array(fieldName: string, maxCount?: number, options?: UploadOptions): RequestHandler;
71
- /**
72
- * No file upload — just parse multipart form data without file fields.
73
- */
74
- declare function none(options?: UploadOptions): RequestHandler;
75
- /**
76
- * Removes temporary files from disk after the response is sent.
77
- * Attach this as Express middleware after the upload middleware.
78
- * Works with both `req.file` (single) and `req.files` (array).
79
- *
80
- * @example
81
- * ```ts
82
- * @Post('/process')
83
- * @Middleware(upload.single('document', { dest: '/tmp/uploads' }), cleanupFiles())
84
- * async processDocument(ctx: RequestContext) {
85
- * ctx.json({ ok: true })
86
- * }
87
- * ```
88
- */
89
- declare function cleanupFiles(): (req: Request, res: Response, next: NextFunction) => void;
90
- /**
91
- * Build upload middleware from a @FileUpload decorator config.
92
- * Used internally by the router builder when it detects FILE_UPLOAD metadata.
93
- * Accepts the same FileUploadConfig interface used by the @FileUpload decorator.
94
- */
95
- declare function buildUploadMiddleware(config: FileUploadConfig): RequestHandler;
96
- /** Upload middleware factory with `.single()`, `.array()`, `.none()` methods */
97
- declare const upload: {
98
- single: typeof single;
99
- array: typeof array;
100
- none: typeof none;
101
- };
102
- //#endregion
103
- export { RawUploadPart as a, buildFileTypeFilter as c, upload as i, resolveMimeTypes as l, buildUploadMiddleware as n, UploadedFileLike as o, cleanupFiles as r, applyUploadConfig as s, UploadOptions as t };
104
- //# sourceMappingURL=upload-DL_jrBGk.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"upload-DL_jrBGk.d.mts","names":["MulterOptions"],"sources":["../src/http/middleware/upload-config.ts","../src/http/middleware/upload.ts"],"mappings":";;;;;;;;;;;;;;;;iBAuEgB,iBAAiB;;;;;;;;iBAcjB,oBACd,cAAc,mCACd,gBAAgB,0BACd,kBAAkB;;UAYL;EACf;EACA;EACA;EACA;EACA;EACA,QAAQ;;;UAIO;EACf;EACA;EACA;EACA,QAAQ;;;;;;;;;iBAYM,kBACd,OAAO,iBACP,QAAQ;EACL,OAAO;EAAkB,QAAQ;;;;;;;;;UC/ErB,sBAAsB;;EAErC,UAAUA;;EAEV;;iBAwGO,OAAO,mBAAmB,UAAS,gBAAqB;;;;iBAQxD,MAAM,mBAAmB,mBAAe,UAAS,gBAAqB;;;;iBAUtE,KAAK,UAAS,gBAAqB;;;;;;;;;;;;;;;iBAmB5B,iBAAY,KACb,SAAO,KAAO,UAAQ,MAAQ;;;;;;iBA+B7B,sBAAsB,QAAQ,mBAAmB;;cAmBpD"}
@@ -1,25 +0,0 @@
1
-
2
- import { NextFunction, Request, Response } from "express";
3
- //#region src/http/middleware/validate.d.ts
4
- interface ValidationSchema {
5
- body?: any;
6
- query?: any;
7
- params?: any;
8
- }
9
- /**
10
- * Express middleware that validates request body/query/params against schemas.
11
- *
12
- * Accepts any schema supported by `@forinda/kickjs-schema`:
13
- * - Zod schemas (auto-detected)
14
- * - Standard Schema v1 objects
15
- * - KickSchema instances (from adapters like fromZod, fromValibot, etc.)
16
- * - Plain validator functions
17
- *
18
- * Validation failures are forwarded via `next(err)` as an `HttpException`, so
19
- * they flow through the application's global error handler (`onError`) and
20
- * produce a uniform response envelope.
21
- */
22
- declare function validate(schema: ValidationSchema): (req: Request, _res: Response, next: NextFunction) => void;
23
- //#endregion
24
- export { validate as n, ValidationSchema as t };
25
- //# sourceMappingURL=validate-DMYpUnrf.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validate-DMYpUnrf.d.mts","names":[],"sources":["../src/http/middleware/validate.ts"],"mappings":";;;UAMiB;EACf;EACA;EACA;;;;;;;;;;;;;;;iBAgDc,SAAS,QAAQ,oBAAgB,KAClC,SAAO,MAAQ,UAAQ,MAAQ"}