@forinda/kickjs 3.2.0 → 4.0.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 (187) hide show
  1. package/README.md +13 -212
  2. package/dist/{adapter-DLEHb0K6.d.mts → adapter-BNw2pGbg.d.mts} +117 -7
  3. package/dist/adapter-BNw2pGbg.d.mts.map +1 -0
  4. package/dist/{app-module-ERR9jhow.d.mts → app-module-CO0ksPCm.d.mts} +3 -3
  5. package/dist/{app-module-ERR9jhow.d.mts.map → app-module-CO0ksPCm.d.mts.map} +1 -1
  6. package/dist/{application-x8CXLOlv.mjs → application-Ce4DQN6m.mjs} +28 -9
  7. package/dist/application-Ce4DQN6m.mjs.map +1 -0
  8. package/dist/application-Czwm7Gty.d.mts +302 -0
  9. package/dist/application-Czwm7Gty.d.mts.map +1 -0
  10. package/dist/{bootstrap-CYnxozL_.mjs → bootstrap-CB7bJeJG.mjs} +6 -6
  11. package/dist/{bootstrap-CYnxozL_.mjs.map → bootstrap-CB7bJeJG.mjs.map} +1 -1
  12. package/dist/bootstrap-NxFRaNTh.d.mts +28 -0
  13. package/dist/bootstrap-NxFRaNTh.d.mts.map +1 -0
  14. package/dist/{cache-V91BNTIM.d.mts → cache-BStrqXSZ.d.mts} +2 -2
  15. package/dist/{cache-V91BNTIM.d.mts.map → cache-BStrqXSZ.d.mts.map} +1 -1
  16. package/dist/config/index.d.mts +1 -1
  17. package/dist/config/index.mjs +3 -3
  18. package/dist/{config-aWxKLk4A.mjs → config-wZ_TgBfs.mjs} +4 -4
  19. package/dist/{config-aWxKLk4A.mjs.map → config-wZ_TgBfs.mjs.map} +1 -1
  20. package/dist/{container-fIS1uLx-.d.mts → container-CnWDsxi-.d.mts} +9 -7
  21. package/dist/container-CnWDsxi-.d.mts.map +1 -0
  22. package/dist/{container-Dnk43k54.mjs → container-DYYSu58w.mjs} +313 -9
  23. package/dist/container-DYYSu58w.mjs.map +1 -0
  24. package/dist/{context-OktlOQBQ.mjs → context-BAGzqT7-.mjs} +33 -41
  25. package/dist/context-BAGzqT7-.mjs.map +1 -0
  26. package/dist/context-Ymvv-85x.d.mts +260 -0
  27. package/dist/context-Ymvv-85x.d.mts.map +1 -0
  28. package/dist/{context-decorator-GA8-hDLe.d.mts → context-decorator-B5v3VQCN.d.mts} +4 -4
  29. package/dist/{context-decorator-GA8-hDLe.d.mts.map → context-decorator-B5v3VQCN.d.mts.map} +1 -1
  30. package/dist/core/adapter.d.mts +1 -1
  31. package/dist/core/adapter.mjs +1 -1
  32. package/dist/core/app-module.d.mts +1 -1
  33. package/dist/core/app-module.mjs +1 -1
  34. package/dist/core/cache.d.mts +1 -1
  35. package/dist/core/cache.mjs +2 -2
  36. package/dist/core/cache.mjs.map +1 -1
  37. package/dist/core/container.d.mts +1 -1
  38. package/dist/core/container.mjs +2 -2
  39. package/dist/core/cron.d.mts +1 -1
  40. package/dist/core/cron.mjs +2 -2
  41. package/dist/core/decorators.d.mts +2 -2
  42. package/dist/core/decorators.mjs +48 -16
  43. package/dist/core/decorators.mjs.map +1 -1
  44. package/dist/core/errors.d.mts +1 -1
  45. package/dist/core/errors.mjs +1 -1
  46. package/dist/core/interfaces.d.mts +1 -1
  47. package/dist/core/interfaces.mjs +35 -18
  48. package/dist/core/interfaces.mjs.map +1 -1
  49. package/dist/core/logger.d.mts +2 -2
  50. package/dist/core/logger.mjs +2 -4
  51. package/dist/core/logger.mjs.map +1 -1
  52. package/dist/core/path.d.mts +1 -1
  53. package/dist/core/path.mjs +1 -1
  54. package/dist/core/plugin.d.mts +1 -1
  55. package/dist/core/plugin.mjs +1 -1
  56. package/dist/core/reactivity.d.mts +1 -1
  57. package/dist/core/reactivity.mjs +1 -1
  58. package/dist/{core-DANnH5-e.mjs → core-DBcoqPHM.mjs} +282 -8
  59. package/dist/core-DBcoqPHM.mjs.map +1 -0
  60. package/dist/cors-BfgqfLPd.d.mts +48 -0
  61. package/dist/cors-BfgqfLPd.d.mts.map +1 -0
  62. package/dist/{cron-CfsPdi7R.d.mts → cron-7zqvsmMI.d.mts} +1 -1
  63. package/dist/{cron-CfsPdi7R.d.mts.map → cron-7zqvsmMI.d.mts.map} +1 -1
  64. package/dist/csrf-DiK9zept.d.mts +52 -0
  65. package/dist/csrf-DiK9zept.d.mts.map +1 -0
  66. package/dist/{decorators-H42oPg0m.d.mts → decorators-BMvaLliz.d.mts} +147 -12
  67. package/dist/decorators-BMvaLliz.d.mts.map +1 -0
  68. package/dist/{env-Cs8Wt8A_.mjs → env-CdH5-dM_.mjs} +3 -4
  69. package/dist/{env-Cs8Wt8A_.mjs.map → env-CdH5-dM_.mjs.map} +1 -1
  70. package/dist/error-handler-Xud_3Lah.d.mts +20 -0
  71. package/dist/error-handler-Xud_3Lah.d.mts.map +1 -0
  72. package/dist/{errors-D_CWI7Bl.d.mts → errors-uaHCeXRz.d.mts} +1 -1
  73. package/dist/{errors-D_CWI7Bl.d.mts.map → errors-uaHCeXRz.d.mts.map} +1 -1
  74. package/dist/{execution-context-Dl2CKqSo.d.mts → execution-context-DKnt61pY.d.mts} +1 -1
  75. package/dist/{execution-context-Dl2CKqSo.d.mts.map → execution-context-DKnt61pY.d.mts.map} +1 -1
  76. package/dist/helmet-CaMbjzBG.d.mts +41 -0
  77. package/dist/helmet-CaMbjzBG.d.mts.map +1 -0
  78. package/dist/http/application.d.mts +2 -293
  79. package/dist/http/application.mjs +2 -2
  80. package/dist/http/bootstrap.d.mts +2 -27
  81. package/dist/http/bootstrap.mjs +2 -2
  82. package/dist/http/context.d.mts +3 -251
  83. package/dist/http/context.mjs +2 -2
  84. package/dist/http/middleware/cors.d.mts +2 -47
  85. package/dist/http/middleware/cors.mjs +1 -1
  86. package/dist/http/middleware/csrf.d.mts +2 -51
  87. package/dist/http/middleware/csrf.mjs +2 -2
  88. package/dist/http/middleware/csrf.mjs.map +1 -1
  89. package/dist/http/middleware/error-handler.d.mts +2 -19
  90. package/dist/http/middleware/error-handler.mjs +2 -2
  91. package/dist/http/middleware/helmet.d.mts +2 -40
  92. package/dist/http/middleware/helmet.mjs +1 -1
  93. package/dist/http/middleware/rate-limit.d.mts +2 -55
  94. package/dist/http/middleware/rate-limit.mjs +2 -2
  95. package/dist/http/middleware/rate-limit.mjs.map +1 -1
  96. package/dist/http/middleware/request-id.d.mts +2 -9
  97. package/dist/http/middleware/request-id.mjs +12 -3
  98. package/dist/http/middleware/request-id.mjs.map +1 -1
  99. package/dist/http/middleware/request-logger.d.mts +2 -31
  100. package/dist/http/middleware/request-logger.mjs +2 -2
  101. package/dist/http/middleware/session.d.mts +2 -69
  102. package/dist/http/middleware/session.mjs +1 -1
  103. package/dist/http/middleware/spa.d.mts +2 -100
  104. package/dist/http/middleware/spa.mjs +5 -5
  105. package/dist/http/middleware/spa.mjs.map +1 -1
  106. package/dist/http/middleware/upload.d.mts +2 -78
  107. package/dist/http/middleware/upload.mjs +1 -1
  108. package/dist/http/middleware/validate.d.mts +2 -22
  109. package/dist/http/middleware/validate.mjs +2 -2
  110. package/dist/http/middleware/views.d.mts +2 -61
  111. package/dist/http/middleware/views.mjs +16 -15
  112. package/dist/http/middleware/views.mjs.map +1 -1
  113. package/dist/http/query/index.d.mts +1 -1
  114. package/dist/http/query/index.mjs +2 -2
  115. package/dist/http/router-builder.d.mts +2 -32
  116. package/dist/http/router-builder.mjs +10 -14
  117. package/dist/http/router-builder.mjs.map +1 -1
  118. package/dist/{index-RNK41JPE.d.mts → index-B9cyOQAe.d.mts} +1 -1
  119. package/dist/{index-RNK41JPE.d.mts.map → index-B9cyOQAe.d.mts.map} +1 -1
  120. package/dist/{index-Cf-MGrqT.d.mts → index-D-qhXg9M.d.mts} +3 -3
  121. package/dist/{index-Cf-MGrqT.d.mts.map → index-D-qhXg9M.d.mts.map} +1 -1
  122. package/dist/{index-BQM9pJrV.d.mts → index-DQyWtyp0.d.mts} +241 -5
  123. package/dist/index-DQyWtyp0.d.mts.map +1 -0
  124. package/dist/index.d.mts +34 -152
  125. package/dist/index.mjs +14 -14
  126. package/dist/interfaces-B50n7dwl.d.mts +71 -0
  127. package/dist/{interfaces-CwcdqfNq.d.mts.map → interfaces-B50n7dwl.d.mts.map} +1 -1
  128. package/dist/{logger-GK8yT0BD.d.mts → logger-CLVRZf2N.d.mts} +2 -4
  129. package/dist/{logger-GK8yT0BD.d.mts.map → logger-CLVRZf2N.d.mts.map} +1 -1
  130. package/dist/{metadata-BFuoSEX6.mjs → metadata-VQM9wChy.mjs} +2 -2
  131. package/dist/{metadata-BFuoSEX6.mjs.map → metadata-VQM9wChy.mjs.map} +1 -1
  132. package/dist/{path-Bj3vZMUY.d.mts → path-Diviu6hv.d.mts} +1 -1
  133. package/dist/path-Diviu6hv.d.mts.map +1 -0
  134. package/dist/{plugin-3rKA0Loy.d.mts → plugin-WdrDgNzk.d.mts} +45 -7
  135. package/dist/plugin-WdrDgNzk.d.mts.map +1 -0
  136. package/dist/{query-BcYEjYyX.mjs → query-DJMxdx5r.mjs} +2 -2
  137. package/dist/{query-BcYEjYyX.mjs.map → query-DJMxdx5r.mjs.map} +1 -1
  138. package/dist/rate-limit-DUwoICtI.d.mts +56 -0
  139. package/dist/rate-limit-DUwoICtI.d.mts.map +1 -0
  140. package/dist/{reactivity-CczHu3R-.d.mts → reactivity-CfJceo4H.d.mts} +1 -1
  141. package/dist/{reactivity-CczHu3R-.d.mts.map → reactivity-CfJceo4H.d.mts.map} +1 -1
  142. package/dist/request-id-BgglvZHN.d.mts +19 -0
  143. package/dist/request-id-BgglvZHN.d.mts.map +1 -0
  144. package/dist/request-logger-CWHbAzTE.d.mts +32 -0
  145. package/dist/request-logger-CWHbAzTE.d.mts.map +1 -0
  146. package/dist/router-builder-C799BAf0.d.mts +31 -0
  147. package/dist/router-builder-C799BAf0.d.mts.map +1 -0
  148. package/dist/session-N0hActOO.d.mts +70 -0
  149. package/dist/session-N0hActOO.d.mts.map +1 -0
  150. package/dist/spa-CrFR2_cz.d.mts +101 -0
  151. package/dist/spa-CrFR2_cz.d.mts.map +1 -0
  152. package/dist/upload-BueOnnLw.d.mts +79 -0
  153. package/dist/upload-BueOnnLw.d.mts.map +1 -0
  154. package/dist/validate-HwAyWTwH.d.mts +23 -0
  155. package/dist/validate-HwAyWTwH.d.mts.map +1 -0
  156. package/dist/views-DhQSXV2P.d.mts +176 -0
  157. package/dist/views-DhQSXV2P.d.mts.map +1 -0
  158. package/package.json +6 -9
  159. package/dist/adapter-DLEHb0K6.d.mts.map +0 -1
  160. package/dist/application-x8CXLOlv.mjs.map +0 -1
  161. package/dist/chunk-Bt-rz0Tp.mjs +0 -15
  162. package/dist/container-Dnk43k54.mjs.map +0 -1
  163. package/dist/container-fIS1uLx-.d.mts.map +0 -1
  164. package/dist/context-OktlOQBQ.mjs.map +0 -1
  165. package/dist/core-DANnH5-e.mjs.map +0 -1
  166. package/dist/decorators-H42oPg0m.d.mts.map +0 -1
  167. package/dist/http/application.d.mts.map +0 -1
  168. package/dist/http/bootstrap.d.mts.map +0 -1
  169. package/dist/http/context.d.mts.map +0 -1
  170. package/dist/http/middleware/cors.d.mts.map +0 -1
  171. package/dist/http/middleware/csrf.d.mts.map +0 -1
  172. package/dist/http/middleware/error-handler.d.mts.map +0 -1
  173. package/dist/http/middleware/helmet.d.mts.map +0 -1
  174. package/dist/http/middleware/rate-limit.d.mts.map +0 -1
  175. package/dist/http/middleware/request-id.d.mts.map +0 -1
  176. package/dist/http/middleware/request-logger.d.mts.map +0 -1
  177. package/dist/http/middleware/session.d.mts.map +0 -1
  178. package/dist/http/middleware/spa.d.mts.map +0 -1
  179. package/dist/http/middleware/upload.d.mts.map +0 -1
  180. package/dist/http/middleware/validate.d.mts.map +0 -1
  181. package/dist/http/middleware/views.d.mts.map +0 -1
  182. package/dist/http/router-builder.d.mts.map +0 -1
  183. package/dist/index-BQM9pJrV.d.mts.map +0 -1
  184. package/dist/index.d.mts.map +0 -1
  185. package/dist/interfaces-CwcdqfNq.d.mts +0 -54
  186. package/dist/path-Bj3vZMUY.d.mts.map +0 -1
  187. package/dist/plugin-3rKA0Loy.d.mts.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-BAGzqT7-.mjs","names":[],"sources":["../src/http/request-store.ts","../src/http/context.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks'\n\n/** Per-request storage for REQUEST-scoped DI and request context propagation */\nexport interface RequestStore {\n /** Unique request identifier */\n requestId: string\n /**\n * Per-request singleton cache for REQUEST-scoped services. Keys are\n * heterogeneous (class constructors, `InjectionToken` objects, raw\n * strings), so the map type stays `Map<any, any>`.\n */\n instances: Map<any, any>\n /**\n * Per-request key/value bag. Canonical backing store for\n * `RequestContext.set/get` and the Context Contributor pipeline (#107)\n * since Phase 3. Anything written here is visible to every concrete\n * execution context constructed for the same request, regardless of\n * which middleware/contributor wrote it.\n *\n * Keys are constrained to `string` per the locked decision in\n * `architecture.md` §20.12 (#4); the value type is `unknown` because\n * the concrete shape at each key is determined by the consumer's\n * `ContextMeta` augmentation, not by the store itself.\n */\n values: Map<string, unknown>\n}\n\n/** AsyncLocalStorage instance shared across the framework */\nexport const requestStore = new AsyncLocalStorage<RequestStore>()\n\n/**\n * Get the current request store. Throws if called outside a request context.\n * Used by the Container to resolve REQUEST-scoped dependencies.\n */\nexport function getRequestStore(): RequestStore {\n const store = requestStore.getStore()\n if (!store) {\n throw new Error(\n 'No active request context. REQUEST-scoped services can only be resolved during an HTTP request.',\n )\n }\n return store\n}\n","import type { Request, Response, NextFunction } from 'express'\nimport { type ContextMeta, type ExecutionContext, type MetaValue } from '../core/execution-context'\nimport { requestStore } from './request-store'\nimport {\n parseQuery,\n type QueryFieldConfig,\n type PaginatedResponse,\n type TypedParsedQuery,\n} from './query'\n\n/**\n * Re-export the augmentable {@link ContextMeta} registry from core/.\n * Declared in `core/execution-context.ts` so non-HTTP transports\n * (WS/queue/cron, V2) share one declaration site. Apps still augment\n * via the canonical `declare module '@forinda/kickjs'` form.\n */\nexport type { ContextMeta } from '../core/execution-context'\n\n/**\n * The shape of a single route entry in `KickRoutes`. Generated by\n * `kick typegen` and consumed via the `Ctx<T>` helper. Each field is\n * `unknown` by default and is filled in as the typegen learns more\n * about the route (URL params from the path, body/query from validation\n * schemas, etc.).\n */\nexport interface RouteShape {\n params?: unknown\n body?: unknown\n query?: unknown\n response?: unknown\n}\n\n/**\n * Unified request/response abstraction passed to every controller method.\n * Shields handlers from raw Express objects and provides convenience methods.\n *\n * Implements {@link ExecutionContext} so the transport-agnostic Context\n * Contributor pipeline (#107) can run against this concrete HTTP context\n * the same way it will run against future WS / queue / cron contexts.\n */\nexport class RequestContext<TBody = any, TParams = any, TQuery = any> implements ExecutionContext {\n constructor(\n public readonly req: Request,\n public readonly res: Response,\n public readonly next: NextFunction,\n ) {}\n\n /**\n * Read-side accessor for the per-request metadata map.\n *\n * Returns the AsyncLocalStorage map (`requestStore.getStore().values`)\n * shared with the Context Contributor pipeline when an ALS frame is\n * active. Returns `null` outside any frame — read-side callers\n * (`ctx.get`, `ctx.user`, `ctx.tenantId`, `ctx.roles`) treat that as\n * \"no metadata\" and fall through to their `req.*` defaults. Reads\n * never throw because outside an ALS frame nobody could have written\n * via `ctx.set` anyway, so an empty answer is the truthful one.\n */\n private metadataReadOnly(): Map<string, any> | null {\n return (requestStore.getStore()?.values as Map<string, any> | undefined) ?? null\n }\n\n /**\n * Write-side accessor for the per-request metadata map.\n *\n * Returns the same map as {@link metadataReadOnly} when an ALS frame\n * is active. Throws otherwise — writing to a fallback map outside\n * the ALS frame would silently lose data because other call sites\n * (downstream contributors, request-logger, etc.) read from the\n * canonical store and would never see it. Mount\n * `requestScopeMiddleware()` (Application does this for you in\n * `'auto'` mode) or wrap your test setup in\n * `requestStore.run({...}, () => …)` to fix.\n */\n private metadataForWrite(): Map<string, any> {\n const store = requestStore.getStore()\n if (store) return store.values as Map<string, any>\n throw new Error(\n 'RequestContext.set called outside an AsyncLocalStorage frame. ' +\n 'Mount requestScopeMiddleware() before constructing RequestContext, ' +\n 'or wrap test setup in requestStore.run({ requestId, instances: new Map(), values: new Map() }, () => ...).',\n )\n }\n\n // ── Request Data ────────────────────────────────────────────────────\n\n get body(): TBody {\n return this.req.body as TBody\n }\n\n get params(): TParams {\n return this.req.params as TParams\n }\n\n get query(): TQuery {\n return this.req.query as TQuery\n }\n\n get headers() {\n return this.req.headers\n }\n\n get requestId(): string | undefined {\n return (this.req as any).requestId ?? (this.req.headers['x-request-id'] as string | undefined)\n }\n\n /** Session data (requires session middleware) */\n get session(): any {\n return (this.req as any).session\n }\n\n /**\n * The authenticated user set by AuthAdapter.\n * Reads from the per-request metadata store first (`ctx.set('user', ...)`),\n * then falls back to `req.user` (set directly by AuthAdapter middleware).\n *\n * Extend the `AuthUser` interface via module augmentation in `@forinda/kickjs-auth`\n * to get full typing.\n *\n * @example\n * ```ts\n * @Get('/me')\n * @Authenticated()\n * getProfile(ctx: RequestContext) {\n * const user = ctx.user\n * if (!user) return ctx.notFound()\n * return ctx.json({ user })\n * }\n * ```\n */\n get user(): MetaValue<'user', Record<string, any>> | undefined {\n return this.metadataReadOnly()?.get('user') ?? (this.req as any).user\n }\n\n /**\n * Tenant identifier for multi-tenant apps. Reads `user.tenantId` —\n * populated either by `AuthAdapter.testMode({ tenantId })`, a tenant\n * resolver middleware, or manually on the strategy's `mapPayload`.\n *\n * Augment `AuthUser` (or `ContextMeta['user']`) to widen the return\n * type if your user shape guarantees a non-`string | undefined` id.\n */\n get tenantId(): string | undefined {\n const u = this.user as Record<string, any> | undefined\n return u?.tenantId\n }\n\n /**\n * Effective role list for the current user. Prefers `user.tenantRoles`\n * (populated by `AuthAdapterOptions.roleResolver` under a tenant) and\n * falls back to `user.roles`. Returns an empty array when the user is\n * absent or the shape has neither field.\n */\n get roles(): string[] {\n const u = this.user as Record<string, any> | undefined\n return u?.tenantRoles ?? u?.roles ?? []\n }\n\n // ── Query String Parsing ───────────────────────────────────────────\n\n /**\n * Parse the request query string into structured filters, sort, pagination, and search.\n * Pass the result to an ORM query builder adapter (Drizzle, Prisma, Sequelize, etc.).\n *\n * Generic over the field config: when passed an inline literal (or\n * `as const`), `filters[].field` and `sort[].field` are narrowed to\n * the exact whitelisted field names. Pass nothing or a non-literal\n * config and you get the loose `string` fallback.\n *\n * @param fieldConfig - Optional whitelist for filterable, sortable, and searchable fields\n *\n * @example\n * ```ts\n * @Get('/')\n * async list(ctx: RequestContext) {\n * const parsed = ctx.qs({\n * filterable: ['status', 'priority'],\n * sortable: ['createdAt', 'title'],\n * } as const)\n * parsed.filters[0].field // typed as 'status' | 'priority'\n * parsed.sort[0].field // typed as 'createdAt' | 'title'\n * }\n * ```\n */\n qs<TConfig extends QueryFieldConfig | undefined = undefined>(\n fieldConfig?: TConfig,\n ): TypedParsedQuery<TConfig> {\n return parseQuery<TConfig>(this.req.query as Record<string, any>, fieldConfig)\n }\n\n // ── File Uploads ────────────────────────────────────────────────────\n\n /** Single uploaded file (requires @FileUpload({ mode: 'single' })) */\n get file(): any {\n return (this.req as any).file\n }\n\n /** Array of uploaded files (requires @FileUpload({ mode: 'array' })) */\n get files(): any[] | undefined {\n return (this.req as any).files\n }\n\n // ── Metadata Store ──────────────────────────────────────────────────\n\n /**\n * Read a value from the per-request metadata store.\n *\n * When `ContextMeta` has been augmented with a matching key, the return\n * type is inferred automatically. For ad-hoc keys, pass a generic:\n * `ctx.get<MyType>('custom')`.\n */\n get<K extends string>(key: K): MetaValue<K> | undefined {\n return this.metadataReadOnly()?.get(key) as MetaValue<K> | undefined\n }\n\n /**\n * Write a value to the per-request metadata store. Throws when no\n * AsyncLocalStorage frame is active — see {@link metadataForWrite}\n * for why a silent fallback is the wrong default.\n */\n set<K extends string>(key: K, value: MetaValue<K>): void {\n this.metadataForWrite().set(key, value)\n }\n\n // ── Response Helpers ────────────────────────────────────────────────\n\n json(data: any, status = 200) {\n return this.res.status(status).json(data)\n }\n\n created(data: any) {\n return this.res.status(201).json(data)\n }\n\n noContent() {\n return this.res.status(204).end()\n }\n\n notFound(message = 'Not Found') {\n return this.res.status(404).json({ message })\n }\n\n badRequest(message: string) {\n return this.res.status(400).json({ message })\n }\n\n html(content: string, status = 200) {\n return this.res.status(status).type('html').send(content)\n }\n\n download(buffer: Buffer, filename: string, contentType = 'application/octet-stream') {\n this.res.setHeader('Content-Disposition', `attachment; filename=\"${filename}\"`)\n this.res.setHeader('Content-Type', contentType)\n return this.res.send(buffer)\n }\n\n /**\n * Render a template using the registered view engine (EJS, Pug, Handlebars, etc.).\n * Requires a ViewAdapter to be configured in bootstrap().\n *\n * @param template - Template name (without extension, relative to viewsDir)\n * @param data - Data to pass to the template\n *\n * @example\n * ```ts\n * ctx.render('dashboard', { user, title: 'Dashboard' })\n * ctx.render('emails/welcome', { name: 'Alice' })\n * ```\n */\n render(template: string, data: Record<string, any> = {}) {\n return this.res.render(template, data)\n }\n\n /**\n * Parse query params and return a standardized paginated response.\n * Calls `ctx.qs()` internally, then wraps your data with pagination meta.\n *\n * @param fetcher - Async function that receives ParsedQuery and returns `{ data, total }`\n * @param fieldConfig - Optional whitelist for filterable, sortable, searchable fields\n *\n * @example\n * ```ts\n * @Get('/')\n * async list(ctx: RequestContext) {\n * return ctx.paginate(\n * async (parsed) => {\n * const data = await db.select().from(users)\n * .where(query.where).limit(parsed.pagination.limit)\n * .offset(parsed.pagination.offset).all()\n * const total = await db.select({ count: count() }).from(users).get()\n * return { data, total: total?.count ?? 0 }\n * },\n * { filterable: ['name', 'role'], sortable: ['createdAt'] },\n * )\n * }\n * ```\n */\n async paginate<T, TConfig extends QueryFieldConfig | undefined = undefined>(\n fetcher: (parsed: TypedParsedQuery<TConfig>) => Promise<{ data: T[]; total: number }>,\n fieldConfig?: TConfig,\n ) {\n const parsed = this.qs<TConfig>(fieldConfig)\n const { data, total } = await fetcher(parsed)\n const { page, limit } = parsed.pagination\n const totalPages = Math.ceil(total / limit) || 1\n\n const response: PaginatedResponse<T> = {\n data,\n meta: {\n page,\n limit,\n total,\n totalPages,\n hasNext: page < totalPages,\n hasPrev: page > 1,\n },\n }\n\n return this.json(response)\n }\n\n // ── Server-Sent Events ──────────────────────────────────────────────\n\n /**\n * Start an SSE (Server-Sent Events) stream.\n * Sets the correct headers and returns helpers to send events.\n *\n * @example\n * ```ts\n * @Get('/events')\n * async stream(ctx: RequestContext) {\n * const sse = ctx.sse()\n *\n * const interval = setInterval(() => {\n * sse.send({ time: new Date().toISOString() }, 'tick')\n * }, 1000)\n *\n * sse.onClose(() => clearInterval(interval))\n * }\n * ```\n */\n sse() {\n this.res.writeHead(200, {\n 'Content-Type': 'text/event-stream',\n 'Cache-Control': 'no-cache',\n Connection: 'keep-alive',\n 'X-Accel-Buffering': 'no',\n })\n this.res.flushHeaders()\n\n const closeCallbacks: Array<() => void> = []\n\n this.req.on('close', () => {\n for (const cb of closeCallbacks) cb()\n })\n\n return {\n /** Send an SSE event with optional event name and id */\n send: (data: any, event?: string, id?: string) => {\n if (id) this.res.write(`id: ${id}\\n`)\n if (event) this.res.write(`event: ${event}\\n`)\n this.res.write(`data: ${JSON.stringify(data)}\\n\\n`)\n },\n /** Send a comment (keeps connection alive) */\n comment: (text: string) => {\n this.res.write(`: ${text}\\n\\n`)\n },\n /** Register a callback when the client disconnects */\n onClose: (fn: () => void) => {\n closeCallbacks.push(fn)\n },\n /** End the SSE stream */\n close: () => {\n this.res.end()\n },\n }\n }\n}\n\n/**\n * Short alias for `RequestContext` parameterised by a route shape.\n *\n * Use with `kick typegen`'s generated `KickRoutes` namespace for\n * fully-typed `ctx.params`, `ctx.body`, and `ctx.query`. Metadata\n * typing (`ctx.get()`, `ctx.set()`, `ctx.user`) comes from\n * `ContextMeta` augmentation and works on all `RequestContext` instances.\n *\n * @example\n * ```ts\n * @Get('/:id')\n * getUser(ctx: Ctx<KickRoutes.UserController['getUser']>) {\n * ctx.params.id // typed from RouteShape\n * ctx.body // typed from RouteShape\n * ctx.user // typed from ContextMeta\n * ctx.get('tenant') // typed from ContextMeta\n * }\n * ```\n */\nexport type Ctx<TRoute extends RouteShape = RouteShape> = RequestContext<\n TRoute extends { body: infer B } ? B : any,\n TRoute extends { params: infer P } ? P : any,\n TRoute extends { query: infer Q } ? Q : any\n>\n\n/**\n * Global ambient registry of typed routes, populated by `kick typegen`.\n *\n * Each interface inside `KickRoutes` corresponds to a controller class;\n * each property is one route method on that controller. The values\n * conform to `RouteShape`.\n *\n * Empty by default — declarations come from `.kickjs/types/routes.d.ts`\n * generated alongside the rest of the typegen output.\n */\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace KickRoutes {}\n}\n"],"mappings":";;;;;;;;;;;;;;AA4BA,MAAa,eAAe,IAAI,mBAAiC;;;;;AAMjE,SAAgB,kBAAgC;CAC9C,MAAM,QAAQ,aAAa,UAAU;AACrC,KAAI,CAAC,MACH,OAAM,IAAI,MACR,kGACD;AAEH,QAAO;;;;;;;;;;;;ACDT,IAAa,iBAAb,MAAkG;CAChG,YACE,KACA,KACA,MACA;AAHgB,OAAA,MAAA;AACA,OAAA,MAAA;AACA,OAAA,OAAA;;;;;;;;;;;;;CAclB,mBAAoD;AAClD,SAAQ,aAAa,UAAU,EAAE,UAA2C;;;;;;;;;;;;;;CAe9E,mBAA6C;EAC3C,MAAM,QAAQ,aAAa,UAAU;AACrC,MAAI,MAAO,QAAO,MAAM;AACxB,QAAM,IAAI,MACR,8OAGD;;CAKH,IAAI,OAAc;AAChB,SAAO,KAAK,IAAI;;CAGlB,IAAI,SAAkB;AACpB,SAAO,KAAK,IAAI;;CAGlB,IAAI,QAAgB;AAClB,SAAO,KAAK,IAAI;;CAGlB,IAAI,UAAU;AACZ,SAAO,KAAK,IAAI;;CAGlB,IAAI,YAAgC;AAClC,SAAQ,KAAK,IAAY,aAAc,KAAK,IAAI,QAAQ;;;CAI1D,IAAI,UAAe;AACjB,SAAQ,KAAK,IAAY;;;;;;;;;;;;;;;;;;;;;CAsB3B,IAAI,OAA2D;AAC7D,SAAO,KAAK,kBAAkB,EAAE,IAAI,OAAO,IAAK,KAAK,IAAY;;;;;;;;;;CAWnE,IAAI,W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K,IAAI,OAAO,UAAU,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BxC,MAAM,SACJ,SACA,aACA;EACA,MAAM,SAAS,KAAK,GAAY,YAAY;EAC5C,MAAM,EAAE,MAAM,UAAU,MAAM,QAAQ,OAAO;EAC7C,MAAM,EAAE,MAAM,UAAU,OAAO;EAC/B,MAAM,aAAa,KAAK,KAAK,QAAQ,MAAM,IAAI;EAE/C,MAAM,WAAiC;GACrC;GACA,MAAM;IACJ;IACA;IACA;IACA;IACA,SAAS,OAAO;IAChB,SAAS,OAAO;IACjB;GACF;AAED,SAAO,KAAK,KAAK,SAAS;;;;;;;;;;;;;;;;;;;;CAuB5B,MAAM;AACJ,OAAK,IAAI,UAAU,KAAK;GACtB,gBAAgB;GAChB,iBAAiB;GACjB,YAAY;GACZ,qBAAqB;GACtB,CAAC;AACF,OAAK,IAAI,cAAc;EAEvB,MAAM,iBAAoC,EAAE;AAE5C,OAAK,IAAI,GAAG,eAAe;AACzB,QAAK,MAAM,MAAM,eAAgB,KAAI;IACrC;AAEF,SAAO;GAEL,OAAO,MAAW,OAAgB,OAAgB;AAChD,QAAI,GAAI,MAAK,IAAI,MAAM,OAAO,GAAG,IAAI;AACrC,QAAI,MAAO,MAAK,IAAI,MAAM,UAAU,MAAM,IAAI;AAC9C,SAAK,IAAI,MAAM,SAAS,KAAK,UAAU,KAAK,CAAC,MAAM;;GAGrD,UAAU,SAAiB;AACzB,SAAK,IAAI,MAAM,KAAK,KAAK,MAAM;;GAGjC,UAAU,OAAmB;AAC3B,mBAAe,KAAK,GAAG;;GAGzB,aAAa;AACX,SAAK,IAAI,KAAK;;GAEjB"}
@@ -0,0 +1,260 @@
1
+
2
+ import { n as ExecutionContext, r as MetaValue } from "./execution-context-DKnt61pY.mjs";
3
+ import { g as QueryFieldConfig, y as TypedParsedQuery } from "./index-B9cyOQAe.mjs";
4
+ import * as _$node_http0 from "node:http";
5
+ import { NextFunction, Request, Response } from "express";
6
+
7
+ //#region src/http/context.d.ts
8
+ /**
9
+ * The shape of a single route entry in `KickRoutes`. Generated by
10
+ * `kick typegen` and consumed via the `Ctx<T>` helper. Each field is
11
+ * `unknown` by default and is filled in as the typegen learns more
12
+ * about the route (URL params from the path, body/query from validation
13
+ * schemas, etc.).
14
+ */
15
+ interface RouteShape {
16
+ params?: unknown;
17
+ body?: unknown;
18
+ query?: unknown;
19
+ response?: unknown;
20
+ }
21
+ /**
22
+ * Unified request/response abstraction passed to every controller method.
23
+ * Shields handlers from raw Express objects and provides convenience methods.
24
+ *
25
+ * Implements {@link ExecutionContext} so the transport-agnostic Context
26
+ * Contributor pipeline (#107) can run against this concrete HTTP context
27
+ * the same way it will run against future WS / queue / cron contexts.
28
+ */
29
+ declare class RequestContext<TBody = any, TParams = any, TQuery = any> implements ExecutionContext {
30
+ readonly req: Request;
31
+ readonly res: Response;
32
+ readonly next: NextFunction;
33
+ constructor(req: Request, res: Response, next: NextFunction);
34
+ /**
35
+ * Read-side accessor for the per-request metadata map.
36
+ *
37
+ * Returns the AsyncLocalStorage map (`requestStore.getStore().values`)
38
+ * shared with the Context Contributor pipeline when an ALS frame is
39
+ * active. Returns `null` outside any frame — read-side callers
40
+ * (`ctx.get`, `ctx.user`, `ctx.tenantId`, `ctx.roles`) treat that as
41
+ * "no metadata" and fall through to their `req.*` defaults. Reads
42
+ * never throw because outside an ALS frame nobody could have written
43
+ * via `ctx.set` anyway, so an empty answer is the truthful one.
44
+ */
45
+ private metadataReadOnly;
46
+ /**
47
+ * Write-side accessor for the per-request metadata map.
48
+ *
49
+ * Returns the same map as {@link metadataReadOnly} when an ALS frame
50
+ * is active. Throws otherwise — writing to a fallback map outside
51
+ * the ALS frame would silently lose data because other call sites
52
+ * (downstream contributors, request-logger, etc.) read from the
53
+ * canonical store and would never see it. Mount
54
+ * `requestScopeMiddleware()` (Application does this for you in
55
+ * `'auto'` mode) or wrap your test setup in
56
+ * `requestStore.run({...}, () => …)` to fix.
57
+ */
58
+ private metadataForWrite;
59
+ get body(): TBody;
60
+ get params(): TParams;
61
+ get query(): TQuery;
62
+ get headers(): _$node_http0.IncomingHttpHeaders;
63
+ get requestId(): string | undefined;
64
+ /** Session data (requires session middleware) */
65
+ get session(): any;
66
+ /**
67
+ * The authenticated user set by AuthAdapter.
68
+ * Reads from the per-request metadata store first (`ctx.set('user', ...)`),
69
+ * then falls back to `req.user` (set directly by AuthAdapter middleware).
70
+ *
71
+ * Extend the `AuthUser` interface via module augmentation in `@forinda/kickjs-auth`
72
+ * to get full typing.
73
+ *
74
+ * @example
75
+ * ```ts
76
+ * @Get('/me')
77
+ * @Authenticated()
78
+ * getProfile(ctx: RequestContext) {
79
+ * const user = ctx.user
80
+ * if (!user) return ctx.notFound()
81
+ * return ctx.json({ user })
82
+ * }
83
+ * ```
84
+ */
85
+ get user(): MetaValue<'user', Record<string, any>> | undefined;
86
+ /**
87
+ * Tenant identifier for multi-tenant apps. Reads `user.tenantId` —
88
+ * populated either by `AuthAdapter.testMode({ tenantId })`, a tenant
89
+ * resolver middleware, or manually on the strategy's `mapPayload`.
90
+ *
91
+ * Augment `AuthUser` (or `ContextMeta['user']`) to widen the return
92
+ * type if your user shape guarantees a non-`string | undefined` id.
93
+ */
94
+ get tenantId(): string | undefined;
95
+ /**
96
+ * Effective role list for the current user. Prefers `user.tenantRoles`
97
+ * (populated by `AuthAdapterOptions.roleResolver` under a tenant) and
98
+ * falls back to `user.roles`. Returns an empty array when the user is
99
+ * absent or the shape has neither field.
100
+ */
101
+ get roles(): string[];
102
+ /**
103
+ * Parse the request query string into structured filters, sort, pagination, and search.
104
+ * Pass the result to an ORM query builder adapter (Drizzle, Prisma, Sequelize, etc.).
105
+ *
106
+ * Generic over the field config: when passed an inline literal (or
107
+ * `as const`), `filters[].field` and `sort[].field` are narrowed to
108
+ * the exact whitelisted field names. Pass nothing or a non-literal
109
+ * config and you get the loose `string` fallback.
110
+ *
111
+ * @param fieldConfig - Optional whitelist for filterable, sortable, and searchable fields
112
+ *
113
+ * @example
114
+ * ```ts
115
+ * @Get('/')
116
+ * async list(ctx: RequestContext) {
117
+ * const parsed = ctx.qs({
118
+ * filterable: ['status', 'priority'],
119
+ * sortable: ['createdAt', 'title'],
120
+ * } as const)
121
+ * parsed.filters[0].field // typed as 'status' | 'priority'
122
+ * parsed.sort[0].field // typed as 'createdAt' | 'title'
123
+ * }
124
+ * ```
125
+ */
126
+ qs<TConfig extends QueryFieldConfig | undefined = undefined>(fieldConfig?: TConfig): TypedParsedQuery<TConfig>;
127
+ /** Single uploaded file (requires @FileUpload({ mode: 'single' })) */
128
+ get file(): any;
129
+ /** Array of uploaded files (requires @FileUpload({ mode: 'array' })) */
130
+ get files(): any[] | undefined;
131
+ /**
132
+ * Read a value from the per-request metadata store.
133
+ *
134
+ * When `ContextMeta` has been augmented with a matching key, the return
135
+ * type is inferred automatically. For ad-hoc keys, pass a generic:
136
+ * `ctx.get<MyType>('custom')`.
137
+ */
138
+ get<K extends string>(key: K): MetaValue<K> | undefined;
139
+ /**
140
+ * Write a value to the per-request metadata store. Throws when no
141
+ * AsyncLocalStorage frame is active — see {@link metadataForWrite}
142
+ * for why a silent fallback is the wrong default.
143
+ */
144
+ set<K extends string>(key: K, value: MetaValue<K>): void;
145
+ json(data: any, status?: number): Response<any, Record<string, any>>;
146
+ created(data: any): Response<any, Record<string, any>>;
147
+ noContent(): Response<any, Record<string, any>>;
148
+ notFound(message?: string): Response<any, Record<string, any>>;
149
+ badRequest(message: string): Response<any, Record<string, any>>;
150
+ html(content: string, status?: number): Response<any, Record<string, any>>;
151
+ download(buffer: Buffer, filename: string, contentType?: string): Response<any, Record<string, any>>;
152
+ /**
153
+ * Render a template using the registered view engine (EJS, Pug, Handlebars, etc.).
154
+ * Requires a ViewAdapter to be configured in bootstrap().
155
+ *
156
+ * @param template - Template name (without extension, relative to viewsDir)
157
+ * @param data - Data to pass to the template
158
+ *
159
+ * @example
160
+ * ```ts
161
+ * ctx.render('dashboard', { user, title: 'Dashboard' })
162
+ * ctx.render('emails/welcome', { name: 'Alice' })
163
+ * ```
164
+ */
165
+ render(template: string, data?: Record<string, any>): void;
166
+ /**
167
+ * Parse query params and return a standardized paginated response.
168
+ * Calls `ctx.qs()` internally, then wraps your data with pagination meta.
169
+ *
170
+ * @param fetcher - Async function that receives ParsedQuery and returns `{ data, total }`
171
+ * @param fieldConfig - Optional whitelist for filterable, sortable, searchable fields
172
+ *
173
+ * @example
174
+ * ```ts
175
+ * @Get('/')
176
+ * async list(ctx: RequestContext) {
177
+ * return ctx.paginate(
178
+ * async (parsed) => {
179
+ * const data = await db.select().from(users)
180
+ * .where(query.where).limit(parsed.pagination.limit)
181
+ * .offset(parsed.pagination.offset).all()
182
+ * const total = await db.select({ count: count() }).from(users).get()
183
+ * return { data, total: total?.count ?? 0 }
184
+ * },
185
+ * { filterable: ['name', 'role'], sortable: ['createdAt'] },
186
+ * )
187
+ * }
188
+ * ```
189
+ */
190
+ paginate<T, TConfig extends QueryFieldConfig | undefined = undefined>(fetcher: (parsed: TypedParsedQuery<TConfig>) => Promise<{
191
+ data: T[];
192
+ total: number;
193
+ }>, fieldConfig?: TConfig): Promise<Response<any, Record<string, any>>>;
194
+ /**
195
+ * Start an SSE (Server-Sent Events) stream.
196
+ * Sets the correct headers and returns helpers to send events.
197
+ *
198
+ * @example
199
+ * ```ts
200
+ * @Get('/events')
201
+ * async stream(ctx: RequestContext) {
202
+ * const sse = ctx.sse()
203
+ *
204
+ * const interval = setInterval(() => {
205
+ * sse.send({ time: new Date().toISOString() }, 'tick')
206
+ * }, 1000)
207
+ *
208
+ * sse.onClose(() => clearInterval(interval))
209
+ * }
210
+ * ```
211
+ */
212
+ sse(): {
213
+ /** Send an SSE event with optional event name and id */send: (data: any, event?: string, id?: string) => void; /** Send a comment (keeps connection alive) */
214
+ comment: (text: string) => void; /** Register a callback when the client disconnects */
215
+ onClose: (fn: () => void) => void; /** End the SSE stream */
216
+ close: () => void;
217
+ };
218
+ }
219
+ /**
220
+ * Short alias for `RequestContext` parameterised by a route shape.
221
+ *
222
+ * Use with `kick typegen`'s generated `KickRoutes` namespace for
223
+ * fully-typed `ctx.params`, `ctx.body`, and `ctx.query`. Metadata
224
+ * typing (`ctx.get()`, `ctx.set()`, `ctx.user`) comes from
225
+ * `ContextMeta` augmentation and works on all `RequestContext` instances.
226
+ *
227
+ * @example
228
+ * ```ts
229
+ * @Get('/:id')
230
+ * getUser(ctx: Ctx<KickRoutes.UserController['getUser']>) {
231
+ * ctx.params.id // typed from RouteShape
232
+ * ctx.body // typed from RouteShape
233
+ * ctx.user // typed from ContextMeta
234
+ * ctx.get('tenant') // typed from ContextMeta
235
+ * }
236
+ * ```
237
+ */
238
+ type Ctx<TRoute extends RouteShape = RouteShape> = RequestContext<TRoute extends {
239
+ body: infer B;
240
+ } ? B : any, TRoute extends {
241
+ params: infer P;
242
+ } ? P : any, TRoute extends {
243
+ query: infer Q;
244
+ } ? Q : any>;
245
+ /**
246
+ * Global ambient registry of typed routes, populated by `kick typegen`.
247
+ *
248
+ * Each interface inside `KickRoutes` corresponds to a controller class;
249
+ * each property is one route method on that controller. The values
250
+ * conform to `RouteShape`.
251
+ *
252
+ * Empty by default — declarations come from `.kickjs/types/routes.d.ts`
253
+ * generated alongside the rest of the typegen output.
254
+ */
255
+ declare global {
256
+ namespace KickRoutes {}
257
+ } //# sourceMappingURL=context.d.ts.map
258
+ //#endregion
259
+ export { RequestContext as n, RouteShape as r, Ctx as t };
260
+ //# sourceMappingURL=context-Ymvv-85x.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-Ymvv-85x.d.mts","names":[],"sources":["../src/http/context.ts"],"mappings":";;;;;;;;;;;;;AAwCA;UAfiB,UAAA;EACf,MAAA;EACA,IAAA;EACA,KAAA;EACA,QAAA;AAAA;;;;;;;;;cAWW,cAAA,sDAAoE,gBAAA;EAAA,SAE7D,GAAA,EAAK,OAAA;EAAA,SACL,GAAA,EAAK,QAAA;EAAA,SACL,IAAA,EAAM,YAAA;cAFN,GAA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AAA,EAAQ,MAAA,EAAQ,QAAA,UAAkB,WAAA,YAAwC,QAAA,MAAA,MAAA;EAAxC;;;;;;;;;;;;;EAmB3C,MAAA,CAAO,QAAA,UAAkB,IAAA,GAAM,MAAA;EA6BmB;;;;;;;;;;;;;;;;;;;;;;AAoGpD;;EArGQ,QAAA,oBAA4B,gBAAA,yBAAA,CAChC,OAAA,GAAU,MAAA,EAAQ,gBAAA,CAAiB,OAAA,MAAa,OAAA;IAAU,IAAA,EAAM,CAAA;IAAK,KAAA;EAAA,IACrE,WAAA,GAAc,OAAA,GAAO,OAAA,CAAA,QAAA,MAAA,MAAA;EAqGvB;;;;;;;;;;;;;;;;;;EA3DA,GAAA,CAAA;IA4D8B,0EA3CV,KAAA,WAAgB,EAAA,oBA2CC;qCACtC;uCAAA;;;;;;;;;;;;;;;;;;;;;;;KAJW,GAAA,gBAAmB,UAAA,GAAa,UAAA,IAAc,cAAA,CACxD,MAAA;EAAiB,IAAA;AAAA,IAAkB,CAAA,QACnC,MAAA;EAAiB,MAAA;AAAA,IAAoB,CAAA,QACrC,MAAA;EAAiB,KAAA;AAAA,IAAmB,CAAA;;;;;;;;;;;QAa9B,MAAA;EAAA,UAEI,UAAA;AAAA"}
@@ -1,7 +1,7 @@
1
1
 
2
- import { i as Constructor, o as MaybePromise } from "./interfaces-CwcdqfNq.mjs";
3
- import { s as InjectionToken } from "./container-fIS1uLx-.mjs";
4
- import { n as ExecutionContext, r as MetaValue } from "./execution-context-Dl2CKqSo.mjs";
2
+ import { i as Constructor, o as MaybePromise } from "./interfaces-B50n7dwl.mjs";
3
+ import { s as InjectionToken } from "./container-CnWDsxi-.mjs";
4
+ import { n as ExecutionContext, r as MetaValue } from "./execution-context-DKnt61pY.mjs";
5
5
  //#region src/core/context-decorator.d.ts
6
6
  /**
7
7
  * Maps a `deps` declaration object to its resolved-instance shape.
@@ -108,4 +108,4 @@ interface ContextDecorator<K extends string = string, D extends Record<string, u
108
108
  declare function defineContextDecorator<K extends string, D extends Record<string, unknown> = Record<string, never>, Ctx extends ExecutionContext = ExecutionContext>(spec: ContextDecoratorSpec<K, D, Ctx>): ContextDecorator<K, D, Ctx>;
109
109
  //#endregion
110
110
  export { defineContextDecorator as a, ResolvedDeps as i, ContextDecoratorSpec as n, ContributorRegistration as r, ContextDecorator as t };
111
- //# sourceMappingURL=context-decorator-GA8-hDLe.d.mts.map
111
+ //# sourceMappingURL=context-decorator-B5v3VQCN.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context-decorator-GA8-hDLe.d.mts","names":[],"sources":["../src/core/context-decorator.ts"],"mappings":";;;;;;;AAaA;;;;;KAAY,YAAA,WAAuB,MAAA,mCACrB,CAAA,GAAI,CAAA,CAAE,CAAA,UAAW,cAAA,YACzB,CAAA,GACA,CAAA,CAAE,CAAA,UAAW,WAAA,YACX,CAAA;;;;;;;;;;;UAcS,oBAAA,sCAEL,MAAA,oBAA0B,MAAA,6BACxB,gBAAA,GAAmB,gBAAA;EApBF;EAuB7B,GAAA,EAAK,CAAA;EAtBD;;;;;EA4BJ,IAAA,GAAO,CAAA;EA1BA;;AAcT;;EAiBE,SAAA;EAfU;;;;;EAqBV,QAAA;EAU8B;;;;;;;;;EAA9B,OAAA,IAAW,GAAA,WAAc,GAAA,EAAK,GAAA,KAAQ,YAAA,CAAa,SAAA,CAAU,CAAA;EAEH;EAA1D,OAAA,GAAU,GAAA,EAAK,GAAA,EAAK,IAAA,EAAM,YAAA,CAAa,CAAA,MAAO,YAAA,CAAa,SAAA,CAAU,CAAA;AAAA;;;;;;;;UAUtD,uBAAA,sCAEL,MAAA,oBAA0B,MAAA,6BACxB,gBAAA,GAAmB,gBAAA;EAAA,SAEtB,GAAA,EAAK,CAAA;EAAA,SACL,IAAA,EAAM,CAAA;EAAA,SACN,SAAA;EAAA,SACA,QAAA;EAAA,SACA,OAAA,GAAU,oBAAA,CAAqB,CAAA,EAAG,CAAA,EAAG,GAAA;EAAA,SACrC,OAAA,EAAS,oBAAA,CAAqB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EtB,GAAA,EAAK,CAAA;EAAA,SACL,IAAA,EAAM,CAAA;EAAA,SACN,SAAA;EAAA,SACA,QAAA;EAAA,SACA,OAAA,GAAU,oBAAA,CAAqB,CAAA,EAAG,CAAA,EAAG,GAAA;EAAA,SACrC,OAAA,EAAS,oBAAA,CAAqB,CAAA,EAAG,CAAA,EAAG,GAAA;AAAA;;;;;;;UAS9B,gBAAA,sCAEL,MAAA,oBAA0B,MAAA,6BACxB,gBAAA,GAAmB,gBAAA;EAAA,CAE9B,MAAA,UAAgB,WAAA,oBAA+B,UAAA,GAAa,kBAAA;EAAA,SACpD,YAAA,EAAc,uBAAA,CAAwB,CAAA,EAAG,CAAA,EAAG,GAAA;AAAA;;;;;;AAzBvD;;;;;;;;;;;;;;;;;;;;;iBAsDgB,sBAAA,6BAEJ,MAAA,oBAA0B,MAAA,6BACxB,gBAAA,GAAmB,gBAAA,CAAA,CAC/B,IAAA,EAAM,oBAAA,CAAqB,CAAA,EAAG,CAAA,EAAG,GAAA,IAAO,gBAAA,CAAiB,CAAA,EAAG,CAAA,EAAG,GAAA"}
@@ -1,3 +1,3 @@
1
1
 
2
- import { a as MiddlewarePhase, i as AppAdapterClass, n as AdapterMiddleware, r as AppAdapter, t as AdapterContext } from "../adapter-DLEHb0K6.mjs";
2
+ import { a as MiddlewarePhase, i as AppAdapterClass, n as AdapterMiddleware, r as AppAdapter, t as AdapterContext } from "../adapter-BNw2pGbg.mjs";
3
3
  export { AdapterContext, AdapterMiddleware, AppAdapter, AppAdapterClass, MiddlewarePhase };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs v3.2.0
2
+ * @forinda/kickjs v4.0.0
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -1,3 +1,3 @@
1
1
 
2
- import { n as AppModuleClass, r as ModuleRoutes, t as AppModule } from "../app-module-ERR9jhow.mjs";
2
+ import { n as AppModuleClass, r as ModuleRoutes, t as AppModule } from "../app-module-CO0ksPCm.mjs";
3
3
  export { AppModule, AppModuleClass, ModuleRoutes };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs v3.2.0
2
+ * @forinda/kickjs v4.0.0
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -1,3 +1,3 @@
1
1
 
2
- import { a as Cacheable, c as setCacheProvider, i as CacheProvider, n as CacheEvict, o as MemoryCacheProvider, r as CacheOptions, s as getCacheProvider, t as CACHEABLE_META } from "../cache-V91BNTIM.mjs";
2
+ import { a as Cacheable, c as setCacheProvider, i as CacheProvider, n as CacheEvict, o as MemoryCacheProvider, r as CacheOptions, s as getCacheProvider, t as CACHEABLE_META } from "../cache-BStrqXSZ.mjs";
3
3
  export { CACHEABLE_META, CacheEvict, CacheOptions, CacheProvider, Cacheable, MemoryCacheProvider, getCacheProvider, setCacheProvider };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs v3.2.0
2
+ * @forinda/kickjs v4.0.0
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -50,7 +50,7 @@ let _cacheProvider = new MemoryCacheProvider();
50
50
  *
51
51
  * @example
52
52
  * ```ts
53
- * import { setCacheProvider } from '@forinda/kickjs-core'
53
+ * import { setCacheProvider } from '@forinda/kickjs'
54
54
  * import { RedisCacheProvider } from './redis-cache'
55
55
  *
56
56
  * setCacheProvider(new RedisCacheProvider(redisClient))
@@ -1 +1 @@
1
- {"version":3,"file":"cache.mjs","names":[],"sources":["../../src/core/cache.ts"],"sourcesContent":["import 'reflect-metadata'\n\nconst CACHEABLE_META = Symbol('kick:cacheable')\n\n// ── CacheProvider Interface ─────────────────────────────────────────────\n\n/**\n * Abstract cache backend. Implement this interface to use Redis, Memcached,\n * or any other cache store with @Cacheable and @CacheEvict.\n *\n * @example\n * ```ts\n * class RedisCacheProvider implements CacheProvider {\n * private client: RedisClient\n * constructor(client: RedisClient) { this.client = client }\n * async get(key: string) {\n * const val = await this.client.get(key)\n * return val ? JSON.parse(val) : null\n * }\n * async set(key: string, value: any, ttlMs: number) {\n * await this.client.set(key, JSON.stringify(value), 'PX', ttlMs)\n * }\n * async del(key: string) { await this.client.del(key) }\n * async delByPrefix(prefix: string) {\n * const keys = await this.client.keys(prefix + '*')\n * if (keys.length) await this.client.del(...keys)\n * }\n * }\n * ```\n */\nexport interface CacheProvider {\n /** Retrieve a cached value. Return null if not found or expired. */\n get(key: string): Promise<any | null>\n /** Store a value with a TTL in milliseconds. */\n set(key: string, value: any, ttlMs: number): Promise<void>\n /** Delete a specific cache key. */\n del(key: string): Promise<void>\n /** Delete all keys matching a prefix. Used by @CacheEvict. */\n delByPrefix?(prefix: string): Promise<void>\n /** Optional cleanup on shutdown. */\n shutdown?(): Promise<void>\n}\n\n// ── Built-in Memory Provider ────────────────────────────────────────────\n\n/**\n * Default in-memory cache provider using a Map.\n * Suitable for development and single-instance deployments.\n * For multi-instance or production, use a Redis-backed provider.\n */\nexport class MemoryCacheProvider implements CacheProvider {\n private store = new Map<string, { data: any; expiresAt: number }>()\n\n async get(key: string): Promise<any | null> {\n const entry = this.store.get(key)\n if (!entry) return null\n if (entry.expiresAt <= Date.now()) {\n this.store.delete(key)\n return null\n }\n return entry.data\n }\n\n async set(key: string, value: any, ttlMs: number): Promise<void> {\n this.store.set(key, { data: value, expiresAt: Date.now() + ttlMs })\n }\n\n async del(key: string): Promise<void> {\n this.store.delete(key)\n }\n\n async delByPrefix(prefix: string): Promise<void> {\n for (const key of this.store.keys()) {\n if (key.startsWith(prefix)) {\n this.store.delete(key)\n }\n }\n }\n\n async shutdown(): Promise<void> {\n this.store.clear()\n }\n}\n\n// ── Global Cache Registry ───────────────────────────────────────────────\n\nlet _cacheProvider: CacheProvider = new MemoryCacheProvider()\n\n/**\n * Set the global cache provider used by @Cacheable and @CacheEvict.\n * Call this before bootstrapping your app.\n *\n * @example\n * ```ts\n * import { setCacheProvider } from '@forinda/kickjs-core'\n * import { RedisCacheProvider } from './redis-cache'\n *\n * setCacheProvider(new RedisCacheProvider(redisClient))\n * ```\n */\nexport function setCacheProvider(provider: CacheProvider): void {\n _cacheProvider = provider\n}\n\n/** Get the current cache provider */\nexport function getCacheProvider(): CacheProvider {\n return _cacheProvider\n}\n\n// ── Cache Options ───────────────────────────────────────────────────────\n\nexport interface CacheOptions {\n /** Time-to-live in seconds (default: 60) */\n ttl?: number\n /** Cache key prefix (default: ClassName.methodName) */\n key?: string\n}\n\n// ── @Cacheable Decorator ────────────────────────────────────────────────\n\n/**\n * Cache the return value of a method for the specified TTL.\n * Uses the globally registered CacheProvider (default: MemoryCacheProvider).\n *\n * Call `setCacheProvider()` to use Redis or any custom backend.\n *\n * @param ttl - Time-to-live in seconds (default: 60)\n * @param options.key - Custom cache key prefix\n */\nexport function Cacheable(ttl?: number, options?: { key?: string }): MethodDecorator {\n return (_target, propertyKey, descriptor: PropertyDescriptor) => {\n const original = descriptor.value\n const cacheTtl = (ttl ?? 60) * 1000\n const keyPrefix = options?.key ?? String(propertyKey)\n\n descriptor.value = async function (...args: any[]) {\n const cacheKey = `${keyPrefix}:${JSON.stringify(args)}`\n const provider = getCacheProvider()\n\n const cached = await provider.get(cacheKey)\n if (cached !== null) {\n return cached\n }\n\n const result = await original.apply(this, args)\n await provider.set(cacheKey, result, cacheTtl)\n return result\n }\n\n return descriptor\n }\n}\n\n// ── @CacheEvict Decorator ───────────────────────────────────────────────\n\n/**\n * Evict cached values matching a key prefix after the method executes.\n * Works with any CacheProvider that implements `delByPrefix`.\n *\n * @param key - Cache key prefix to evict (matches the @Cacheable key)\n */\nexport function CacheEvict(key: string): MethodDecorator {\n return (_target, _propertyKey, descriptor: PropertyDescriptor) => {\n const original = descriptor.value\n\n descriptor.value = async function (...args: any[]) {\n const result = await original.apply(this, args)\n const provider = getCacheProvider()\n if (provider.delByPrefix) {\n await provider.delByPrefix(key)\n }\n return result\n }\n\n return descriptor\n }\n}\n\nexport { CACHEABLE_META }\n"],"mappings":";;;;;;;;;;;;AAEA,MAAM,iBAAiB,OAA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S;AAC9C,UAAO;;AAGT,SAAO;;;;;;;;;AAYX,SAAgB,WAAW,KAA8B;AACvD,SAAQ,SAAS,cAAc,eAAmC;EAChE,MAAM,WAAW,WAAW;AAE5B,aAAW,QAAQ,eAAgB,GAAG,MAAa;GACjD,MAAM,SAAS,MAAM,SAAS,MAAM,MAAM,KAAK;GAC/C,MAAM,WAAW,kBAAkB;AACnC,OAAI,SAAS,YACX,OAAM,SAAS,YAAY,IAAI;AAEjC,UAAO;;AAGT,SAAO"}
1
+ {"version":3,"file":"cache.mjs","names":[],"sources":["../../src/core/cache.ts"],"sourcesContent":["import 'reflect-metadata'\n\nconst CACHEABLE_META = Symbol('kick:cacheable')\n\n// ── CacheProvider Interface ─────────────────────────────────────────────\n\n/**\n * Abstract cache backend. Implement this interface to use Redis, Memcached,\n * or any other cache store with @Cacheable and @CacheEvict.\n *\n * @example\n * ```ts\n * class RedisCacheProvider implements CacheProvider {\n * private client: RedisClient\n * constructor(client: RedisClient) { this.client = client }\n * async get(key: string) {\n * const val = await this.client.get(key)\n * return val ? JSON.parse(val) : null\n * }\n * async set(key: string, value: any, ttlMs: number) {\n * await this.client.set(key, JSON.stringify(value), 'PX', ttlMs)\n * }\n * async del(key: string) { await this.client.del(key) }\n * async delByPrefix(prefix: string) {\n * const keys = await this.client.keys(prefix + '*')\n * if (keys.length) await this.client.del(...keys)\n * }\n * }\n * ```\n */\nexport interface CacheProvider {\n /** Retrieve a cached value. Return null if not found or expired. */\n get(key: string): Promise<any | null>\n /** Store a value with a TTL in milliseconds. */\n set(key: string, value: any, ttlMs: number): Promise<void>\n /** Delete a specific cache key. */\n del(key: string): Promise<void>\n /** Delete all keys matching a prefix. Used by @CacheEvict. */\n delByPrefix?(prefix: string): Promise<void>\n /** Optional cleanup on shutdown. */\n shutdown?(): Promise<void>\n}\n\n// ── Built-in Memory Provider ────────────────────────────────────────────\n\n/**\n * Default in-memory cache provider using a Map.\n * Suitable for development and single-instance deployments.\n * For multi-instance or production, use a Redis-backed provider.\n */\nexport class MemoryCacheProvider implements CacheProvider {\n private store = new Map<string, { data: any; expiresAt: number }>()\n\n async get(key: string): Promise<any | null> {\n const entry = this.store.get(key)\n if (!entry) return null\n if (entry.expiresAt <= Date.now()) {\n this.store.delete(key)\n return null\n }\n return entry.data\n }\n\n async set(key: string, value: any, ttlMs: number): Promise<void> {\n this.store.set(key, { data: value, expiresAt: Date.now() + ttlMs })\n }\n\n async del(key: string): Promise<void> {\n this.store.delete(key)\n }\n\n async delByPrefix(prefix: string): Promise<void> {\n for (const key of this.store.keys()) {\n if (key.startsWith(prefix)) {\n this.store.delete(key)\n }\n }\n }\n\n async shutdown(): Promise<void> {\n this.store.clear()\n }\n}\n\n// ── Global Cache Registry ───────────────────────────────────────────────\n\nlet _cacheProvider: CacheProvider = new MemoryCacheProvider()\n\n/**\n * Set the global cache provider used by @Cacheable and @CacheEvict.\n * Call this before bootstrapping your app.\n *\n * @example\n * ```ts\n * import { setCacheProvider } from '@forinda/kickjs'\n * import { RedisCacheProvider } from './redis-cache'\n *\n * setCacheProvider(new RedisCacheProvider(redisClient))\n * ```\n */\nexport function setCacheProvider(provider: CacheProvider): void {\n _cacheProvider = provider\n}\n\n/** Get the current cache provider */\nexport function getCacheProvider(): CacheProvider {\n return _cacheProvider\n}\n\n// ── Cache Options ───────────────────────────────────────────────────────\n\nexport interface CacheOptions {\n /** Time-to-live in seconds (default: 60) */\n ttl?: number\n /** Cache key prefix (default: ClassName.methodName) */\n key?: string\n}\n\n// ── @Cacheable Decorator ────────────────────────────────────────────────\n\n/**\n * Cache the return value of a method for the specified TTL.\n * Uses the globally registered CacheProvider (default: MemoryCacheProvider).\n *\n * Call `setCacheProvider()` to use Redis or any custom backend.\n *\n * @param ttl - Time-to-live in seconds (default: 60)\n * @param options.key - Custom cache key prefix\n */\nexport function Cacheable(ttl?: number, options?: { key?: string }): MethodDecorator {\n return (_target, propertyKey, descriptor: PropertyDescriptor) => {\n const original = descriptor.value\n const cacheTtl = (ttl ?? 60) * 1000\n const keyPrefix = options?.key ?? String(propertyKey)\n\n descriptor.value = async function (...args: any[]) {\n const cacheKey = `${keyPrefix}:${JSON.stringify(args)}`\n const provider = getCacheProvider()\n\n const cached = await provider.get(cacheKey)\n if (cached !== null) {\n return cached\n }\n\n const result = await original.apply(this, args)\n await provider.set(cacheKey, result, cacheTtl)\n return result\n }\n\n return descriptor\n }\n}\n\n// ── @CacheEvict Decorator ───────────────────────────────────────────────\n\n/**\n * Evict cached values matching a key prefix after the method executes.\n * Works with any CacheProvider that implements `delByPrefix`.\n *\n * @param key - Cache key prefix to evict (matches the @Cacheable key)\n */\nexport function CacheEvict(key: string): MethodDecorator {\n return (_target, _propertyKey, descriptor: PropertyDescriptor) => {\n const original = descriptor.value\n\n descriptor.value = async function (...args: any[]) {\n const result = await original.apply(this, args)\n const provider = getCacheProvider()\n if (provider.delByPrefix) {\n await provider.delByPrefix(key)\n }\n return result\n }\n\n return descriptor\n }\n}\n\nexport { CACHEABLE_META }\n"],"mappings":";;;;;;;;;;;;AAEA,MAAM,iBAAiB,OAAO,iBAAiB;;;;;;AAgD/C,IAAa,sBAAb,MAA0D;CACxD,wBAAgB,IAAI,KAA+C;CAEnE,MAAM,IAAI,KAAkC;EAC1C,MAAM,QAAQ,KAAK,MAAM,IAAI,IAAI;AACjC,MAAI,CAAC,MAAO,QAAO;AACnB,MAAI,MAAM,aAAa,KAAK,KAAK,EAAE;AACjC,QAAK,MAAM,OAAO,IAAI;AACtB,UAAO;;AAET,SAAO,MAAM;;CAGf,MAAM,IAAI,KAAa,OAAY,OAA8B;AAC/D,OAAK,MAAM,IAAI,KAAK;GAAE,MAAM;GAAO,WAAW,KAAK,KAAK,GAAG;GAAO,CAAC;;CAGrE,MAAM,IAAI,KAA4B;AACpC,OAAK,MAAM,OAAO,IAAI;;CAGxB,MAAM,YAAY,QAA+B;AAC/C,OAAK,MAAM,OAAO,KAAK,MAAM,MAAM,CACjC,KAAI,IAAI,WAAW,OAAO,CACxB,MAAK,MAAM,OAAO,IAAI;;CAK5B,MAAM,WAA0B;AAC9B,OAAK,MAAM,OAAO;;;AAMtB,IAAI,iBAAgC,IAAI,qBAAqB;;;;;;;;;;;;;AAc7D,SAAgB,iBAAiB,UAA+B;AAC9D,kBAAiB;;;AAInB,SAAgB,mBAAkC;AAChD,QAAO;;;;;;;;;;;AAuBT,SAAgB,UAAU,KAAc,SAA6C;AACnF,SAAQ,SAAS,aAAa,eAAmC;EAC/D,MAAM,WAAW,WAAW;EAC5B,MAAM,YAAY,OAAO,MAAM;EAC/B,MAAM,YAAY,SAAS,OAAO,OAAO,YAAY;AAErD,aAAW,QAAQ,eAAgB,GAAG,MAAa;GACjD,MAAM,WAAW,GAAG,UAAU,GAAG,KAAK,UAAU,KAAK;GACrD,MAAM,WAAW,kBAAkB;GAEnC,MAAM,SAAS,MAAM,SAAS,IAAI,SAAS;AAC3C,OAAI,WAAW,KACb,QAAO;GAGT,MAAM,SAAS,MAAM,SAAS,MAAM,MAAM,KAAK;AAC/C,SAAM,SAAS,IAAI,UAAU,QAAQ,SAAS;AAC9C,UAAO;;AAGT,SAAO;;;;;;;;;AAYX,SAAgB,WAAW,KAA8B;AACvD,SAAQ,SAAS,cAAc,eAAmC;EAChE,MAAM,WAAW,WAAW;AAE5B,aAAW,QAAQ,eAAgB,GAAG,MAAa;GACjD,MAAM,SAAS,MAAM,SAAS,MAAM,MAAM,KAAK;GAC/C,MAAM,WAAW,kBAAkB;AACnC,OAAI,SAAS,YACX,OAAM,SAAS,YAAY,IAAI;AAEjC,UAAO;;AAGT,SAAO"}
@@ -1,3 +1,3 @@
1
1
 
2
- import { a as tokenName, i as KickJsRegistry, n as ContainerChangeEvent, r as ContainerChangeListener, t as Container } from "../container-fIS1uLx-.mjs";
2
+ import { a as tokenName, i as KickJsRegistry, n as ContainerChangeEvent, r as ContainerChangeListener, t as Container } from "../container-CnWDsxi-.mjs";
3
3
  export { Container, ContainerChangeEvent, ContainerChangeListener, KickJsRegistry, tokenName };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs v3.2.0
2
+ * @forinda/kickjs v4.0.0
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -8,5 +8,5 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import { n as tokenName, t as Container } from "../container-Dnk43k54.mjs";
11
+ import { n as tokenName, t as Container } from "../container-DYYSu58w.mjs";
12
12
  export { Container, tokenName };
@@ -1,3 +1,3 @@
1
1
 
2
- import { i as getCronJobs, n as Cron, r as CronJobMeta, t as CRON_META } from "../cron-CfsPdi7R.mjs";
2
+ import { i as getCronJobs, n as Cron, r as CronJobMeta, t as CRON_META } from "../cron-7zqvsmMI.mjs";
3
3
  export { CRON_META, Cron, CronJobMeta, getCronJobs };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs v3.2.0
2
+ * @forinda/kickjs v4.0.0
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import { c as pushClassMeta, t as getClassMeta } from "../metadata-BFuoSEX6.mjs";
11
+ import { c as pushClassMeta, t as getClassMeta } from "../metadata-VQM9wChy.mjs";
12
12
  //#region src/core/cron.ts
13
13
  const CRON_META = Symbol("kick:cron");
14
14
  /**
@@ -1,3 +1,3 @@
1
1
 
2
- import { C as Put, D as Value, E as Service, O as normalizeApiQueryParamsConfig, S as PostConstruct, T as RouteDefinition, _ as Injectable, a as Builder, b as Patch, c as Controller, d as EnvKey, f as FileTypeFilter, g as Inject, h as Get, i as BaseUploadOptions, l as Delete, m as FileUploadConfig, n as ApiQueryParamsConfig, o as ColumnApiQueryParamsConfig, p as FileUpload, r as Autowired, s as Component, t as ApiQueryParams, u as Env, v as Middleware, w as Repository, x as Post, y as MiddlewareHandler } from "../decorators-H42oPg0m.mjs";
3
- export { ApiQueryParams, ApiQueryParamsConfig, Autowired, BaseUploadOptions, Builder, ColumnApiQueryParamsConfig, Component, Controller, Delete, Env, EnvKey, FileTypeFilter, FileUpload, FileUploadConfig, Get, Inject, Injectable, Middleware, MiddlewareHandler, Patch, Post, PostConstruct, Put, Repository, RouteDefinition, Service, Value, normalizeApiQueryParamsConfig };
2
+ import { A as normalizeApiQueryParamsConfig, C as Post, D as RouteDefinition, E as Repository, O as Service, S as Patch, T as Put, _ as Get, a as Autowired, b as Middleware, c as ColumnApiQueryParamsConfig, d as Delete, f as Env, g as FileUploadConfig, h as FileUpload, i as AssetKey, k as Value, l as Component, m as FileTypeFilter, n as ApiQueryParamsConfig, o as BaseUploadOptions, p as EnvKey, r as Asset, s as Builder, t as ApiQueryParams, u as Controller, v as Inject, w as PostConstruct, x as MiddlewareHandler, y as Injectable } from "../decorators-BMvaLliz.mjs";
3
+ export { ApiQueryParams, ApiQueryParamsConfig, Asset, AssetKey, Autowired, BaseUploadOptions, Builder, ColumnApiQueryParamsConfig, Component, Controller, Delete, Env, EnvKey, FileTypeFilter, FileUpload, FileUploadConfig, Get, Inject, Injectable, Middleware, MiddlewareHandler, Patch, Post, PostConstruct, Put, Repository, RouteDefinition, Service, Value, normalizeApiQueryParamsConfig };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs v3.2.0
2
+ * @forinda/kickjs v4.0.0
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -8,9 +8,9 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
+ import { t as Container } from "../container-DYYSu58w.mjs";
11
12
  import { METADATA, Scope } from "./interfaces.mjs";
12
- import { c as pushClassMeta, d as setInMetaMap, f as setInMetaRecord, l as pushMethodMeta, p as setMethodMeta, u as setClassMeta } from "../metadata-BFuoSEX6.mjs";
13
- import { t as Container } from "../container-Dnk43k54.mjs";
13
+ import { c as pushClassMeta, d as setInMetaMap, f as setInMetaRecord, l as pushMethodMeta, p as setMethodMeta, u as setClassMeta } from "../metadata-VQM9wChy.mjs";
14
14
  import "reflect-metadata";
15
15
  //#region src/core/decorators.ts
16
16
  const pendingRegistrations = [];
@@ -72,16 +72,16 @@ function Repository(options) {
72
72
  /**
73
73
  * Mark a class as an HTTP controller and register it in the DI container.
74
74
  *
75
- * @param path - **Deprecated.** The path parameter is no longer used for routing.
76
- * Route prefixes are defined by the module's `routes().path` — the single source
77
- * of truth for where routes are mounted. This parameter will be removed in a
78
- * future major version.
75
+ * Route prefixes are defined by the module's `routes().path` — the single
76
+ * source of truth for where routes mount. The legacy
77
+ * `@Controller('/path')` parameter was removed in v4; if your code
78
+ * still passes a string, see `docs/guide/migration-v3-to-v4.md` for
79
+ * the rename map.
79
80
  */
80
- function Controller(path) {
81
+ function Controller() {
81
82
  return (target) => {
82
83
  setClassMeta(METADATA.CLASS_KIND, "controller", target);
83
84
  registerInContainer(target, Scope.SINGLETON);
84
- setClassMeta(METADATA.CONTROLLER_PATH, path || "/", target);
85
85
  };
86
86
  }
87
87
  /** Mark a method as a lifecycle hook called after instantiation */
@@ -96,12 +96,6 @@ function Autowired(token) {
96
96
  setInMetaMap(METADATA.AUTOWIRED, target, propertyKey, token);
97
97
  };
98
98
  }
99
- /**
100
- * Constructor parameter injection with an explicit token.
101
- *
102
- * **Constructor parameters only** — does not work as a property decorator.
103
- * For property injection with a token, use `@Autowired(token)` instead.
104
- */
105
99
  function Inject(token) {
106
100
  return (target, _propertyKey, parameterIndex) => {
107
101
  setInMetaRecord(METADATA.INJECT, target, parameterIndex, token);
@@ -130,6 +124,44 @@ function Value(envKey, defaultValue) {
130
124
  });
131
125
  };
132
126
  }
127
+ /**
128
+ * Inject the resolved file-system path for a typed asset. Mirrors
129
+ * `@Value`'s lazy-getter pattern — the asset is resolved on every
130
+ * property access, NOT at class instantiation, so:
131
+ *
132
+ * - Tests can swap fixtures + clear the cache without re-instantiating
133
+ * the consuming class.
134
+ * - The first access cost is paid once per process (the manifest cache
135
+ * in `core/assets.ts` makes subsequent calls cheap).
136
+ *
137
+ * Type-safety:
138
+ *
139
+ * - Without typegen, any string key is accepted (back-compat — same
140
+ * trick as `@Value`).
141
+ * - After typegen, `KickAssets` is populated and `AssetKey` is a
142
+ * union of every flattened `<namespace>/<key>` path. Unknown keys
143
+ * become a TS error.
144
+ *
145
+ * @example
146
+ * ```ts
147
+ * import { Service, Asset } from '@forinda/kickjs'
148
+ *
149
+ * `@Service()`
150
+ * class MailService {
151
+ * `@Asset('mails/welcome')`
152
+ * private welcomeTemplate!: string
153
+ *
154
+ * send(user: User) {
155
+ * return ejs.renderFile(this.welcomeTemplate, { user })
156
+ * }
157
+ * }
158
+ * ```
159
+ */
160
+ function Asset(assetKey) {
161
+ return (target, propertyKey) => {
162
+ setInMetaMap(METADATA.ASSET, target, propertyKey, { assetKey });
163
+ };
164
+ }
133
165
  function createRouteDecorator(method) {
134
166
  return (path, validation) => {
135
167
  return (target, propertyKey) => {
@@ -214,6 +246,6 @@ function Builder(target) {
214
246
  };
215
247
  }
216
248
  //#endregion
217
- export { ApiQueryParams, Autowired, Builder, Component, Controller, Delete, FileUpload, Get, Inject, Injectable, Middleware, Patch, Post, PostConstruct, Put, Repository, Service, Value, normalizeApiQueryParamsConfig };
249
+ export { ApiQueryParams, Asset, Autowired, Builder, Component, Controller, Delete, FileUpload, Get, Inject, Injectable, Middleware, Patch, Post, PostConstruct, Put, Repository, Service, Value, normalizeApiQueryParamsConfig };
218
250
 
219
251
  //# sourceMappingURL=decorators.mjs.map