@forinda/kickjs 2.1.0 → 2.2.1

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 (104) hide show
  1. package/README.md +63 -20
  2. package/dist/{adapter-BqGjZCSm.d.mts → adapter-wuoBNkNs.d.mts} +3 -3
  3. package/dist/{adapter-BqGjZCSm.d.mts.map → adapter-wuoBNkNs.d.mts.map} +1 -1
  4. package/dist/{app-module-CcEbAVtB.d.mts → app-module-DOBmxARW.d.mts} +11 -4
  5. package/dist/app-module-DOBmxARW.d.mts.map +1 -0
  6. package/dist/{application-DNHj-_UL.mjs → application-cYhTEy84.mjs} +6 -6
  7. package/dist/application-cYhTEy84.mjs.map +1 -0
  8. package/dist/{bootstrap-DLEZaJ3b.mjs → bootstrap-8_iBHhWp.mjs} +6 -6
  9. package/dist/{bootstrap-DLEZaJ3b.mjs.map → bootstrap-8_iBHhWp.mjs.map} +1 -1
  10. package/dist/{cache-DJeMaGqb.d.mts → cache-PufEhr0n.d.mts} +1 -1
  11. package/dist/{cache-DJeMaGqb.d.mts.map → cache-PufEhr0n.d.mts.map} +1 -1
  12. package/dist/{chunk-C5Qp-JxE.mjs → chunk-Djztpsb3.mjs} +1 -1
  13. package/dist/container-BKiJzakw.mjs +496 -0
  14. package/dist/container-BKiJzakw.mjs.map +1 -0
  15. package/dist/{container-nBSIhyqV.d.mts → container-CcgV8eHL.d.mts} +116 -4
  16. package/dist/container-CcgV8eHL.d.mts.map +1 -0
  17. package/dist/core/adapter.d.mts +1 -1
  18. package/dist/core/adapter.mjs +1 -1
  19. package/dist/core/app-module.d.mts +1 -1
  20. package/dist/core/app-module.mjs +1 -1
  21. package/dist/core/cache.d.mts +1 -1
  22. package/dist/core/cache.mjs +1 -1
  23. package/dist/core/container.d.mts +2 -2
  24. package/dist/core/container.mjs +2 -416
  25. package/dist/core/cron.d.mts +1 -1
  26. package/dist/core/cron.mjs +2 -2
  27. package/dist/core/decorators.d.mts +2 -2
  28. package/dist/core/decorators.mjs +9 -3
  29. package/dist/core/decorators.mjs.map +1 -1
  30. package/dist/core/errors.d.mts +1 -1
  31. package/dist/core/errors.mjs +1 -1
  32. package/dist/core/interfaces.d.mts +1 -1
  33. package/dist/core/interfaces.mjs +1 -1
  34. package/dist/core/logger.d.mts +1 -1
  35. package/dist/core/logger.mjs +1 -1
  36. package/dist/core/path.d.mts +1 -1
  37. package/dist/core/path.mjs +1 -1
  38. package/dist/core/plugin.d.mts +1 -1
  39. package/dist/core/plugin.mjs +1 -1
  40. package/dist/core/reactivity.d.mts +1 -1
  41. package/dist/core/reactivity.mjs +1 -1
  42. package/dist/{core-BL_H8fEZ.mjs → core-CXHuViXn.mjs} +4 -4
  43. package/dist/{core-BL_H8fEZ.mjs.map → core-CXHuViXn.mjs.map} +1 -1
  44. package/dist/{cron-RKhH5TOd.d.mts → cron-C29iHvHT.d.mts} +1 -1
  45. package/dist/{cron-RKhH5TOd.d.mts.map → cron-C29iHvHT.d.mts.map} +1 -1
  46. package/dist/{decorators-CQ93ak6Z.d.mts → decorators-D3lBlmud.d.mts} +54 -4
  47. package/dist/decorators-D3lBlmud.d.mts.map +1 -0
  48. package/dist/{errors-te5Km00o.d.mts → errors-BZUdxtjC.d.mts} +1 -1
  49. package/dist/{errors-te5Km00o.d.mts.map → errors-BZUdxtjC.d.mts.map} +1 -1
  50. package/dist/http/application.d.mts +4 -4
  51. package/dist/http/application.d.mts.map +1 -1
  52. package/dist/http/application.mjs +2 -2
  53. package/dist/http/bootstrap.mjs +2 -2
  54. package/dist/http/context.d.mts +67 -8
  55. package/dist/http/context.d.mts.map +1 -1
  56. package/dist/http/context.mjs +10 -5
  57. package/dist/http/context.mjs.map +1 -1
  58. package/dist/http/middleware/cors.mjs +1 -1
  59. package/dist/http/middleware/csrf.mjs +1 -1
  60. package/dist/http/middleware/error-handler.mjs +2 -2
  61. package/dist/http/middleware/helmet.mjs +1 -1
  62. package/dist/http/middleware/rate-limit.mjs +1 -1
  63. package/dist/http/middleware/request-id.mjs +1 -1
  64. package/dist/http/middleware/request-logger.mjs +2 -2
  65. package/dist/http/middleware/session.mjs +1 -1
  66. package/dist/http/middleware/spa.d.mts +1 -1
  67. package/dist/http/middleware/spa.mjs +3 -3
  68. package/dist/http/middleware/upload.d.mts +1 -1
  69. package/dist/http/middleware/upload.mjs +1 -1
  70. package/dist/http/middleware/validate.mjs +1 -1
  71. package/dist/http/middleware/views.d.mts +1 -1
  72. package/dist/http/middleware/views.mjs +2 -2
  73. package/dist/http/query/index.d.mts +2 -2
  74. package/dist/http/query/index.mjs +2 -2
  75. package/dist/http/router-builder.mjs +4 -4
  76. package/dist/{index-C0gbnpSg.d.mts → index-4VM4dUJf.d.mts} +1 -1
  77. package/dist/{index-C0gbnpSg.d.mts.map → index-4VM4dUJf.d.mts.map} +1 -1
  78. package/dist/{index-Cls52etj.d.mts → index-rnK23QBD.d.mts} +39 -3
  79. package/dist/index-rnK23QBD.d.mts.map +1 -0
  80. package/dist/index.d.mts +16 -16
  81. package/dist/index.mjs +8 -8
  82. package/dist/{interfaces-D-48zotH.d.mts → interfaces-D5ohYl6D.d.mts} +1 -1
  83. package/dist/{interfaces-D-48zotH.d.mts.map → interfaces-D5ohYl6D.d.mts.map} +1 -1
  84. package/dist/{logger-Dzj-TF0t.d.mts → logger-BLdfUF5b.d.mts} +1 -1
  85. package/dist/{logger-Dzj-TF0t.d.mts.map → logger-BLdfUF5b.d.mts.map} +1 -1
  86. package/dist/{metadata-fmvikBA0.mjs → metadata-D5L3_cdl.mjs} +2 -2
  87. package/dist/{metadata-fmvikBA0.mjs.map → metadata-D5L3_cdl.mjs.map} +1 -1
  88. package/dist/{path-LmwfhfyH.d.mts → path-Dq5V-i-x.d.mts} +1 -1
  89. package/dist/path-Dq5V-i-x.d.mts.map +1 -0
  90. package/dist/{plugin-DIoPIpSm.d.mts → plugin-D20muJwC.d.mts} +4 -4
  91. package/dist/{plugin-DIoPIpSm.d.mts.map → plugin-D20muJwC.d.mts.map} +1 -1
  92. package/dist/{query-7cdHF6ry.mjs → query-BSIApo6Y.mjs} +6 -6
  93. package/dist/query-BSIApo6Y.mjs.map +1 -0
  94. package/dist/{reactivity-BbS-99ow.d.mts → reactivity-CMAQh0gi.d.mts} +1 -1
  95. package/dist/{reactivity-BbS-99ow.d.mts.map → reactivity-CMAQh0gi.d.mts.map} +1 -1
  96. package/package.json +16 -13
  97. package/dist/app-module-CcEbAVtB.d.mts.map +0 -1
  98. package/dist/application-DNHj-_UL.mjs.map +0 -1
  99. package/dist/container-nBSIhyqV.d.mts.map +0 -1
  100. package/dist/core/container.mjs.map +0 -1
  101. package/dist/decorators-CQ93ak6Z.d.mts.map +0 -1
  102. package/dist/index-Cls52etj.d.mts.map +0 -1
  103. package/dist/path-LmwfhfyH.d.mts.map +0 -1
  104. package/dist/query-7cdHF6ry.mjs.map +0 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs v2.1.0
2
+ * @forinda/kickjs v2.2.1
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -9,8 +9,8 @@
9
9
  * @license MIT
10
10
  */
11
11
  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-fmvikBA0.mjs";
13
- import { Container } from "./container.mjs";
12
+ import { c as pushClassMeta, d as setInMetaMap, f as setInMetaRecord, l as pushMethodMeta, p as setMethodMeta, u as setClassMeta } from "../metadata-D5L3_cdl.mjs";
13
+ import { t as Container } from "../container-BKiJzakw.mjs";
14
14
  import "reflect-metadata";
15
15
  //#region src/core/decorators.ts
16
16
  const pendingRegistrations = [];
@@ -115,6 +115,12 @@ function Inject(token) {
115
115
  * to catch misconfiguration early instead of returning undefined.
116
116
  *
117
117
  * Uses metadata + instance getter to work correctly with `useDefineForClassFields`.
118
+ *
119
+ * Type-safety:
120
+ * - Without `kick typegen` run, any string key is accepted (back-compat).
121
+ * - After typegen, `KickEnv` is populated and unknown keys become a tsc
122
+ * error. The optional `defaultValue` is type-checked against the
123
+ * schema's inferred type for that key.
118
124
  */
119
125
  function Value(envKey, defaultValue) {
120
126
  return (target, propertyKey) => {
@@ -1 +1 @@
1
- {"version":3,"file":"decorators.mjs","names":[],"sources":["../../src/core/decorators.ts"],"sourcesContent":["import 'reflect-metadata'\nimport { METADATA, Scope, type ServiceOptions } from './interfaces'\nimport { Container } from './container'\nimport {\n setClassMeta,\n setMethodMeta,\n getClassMeta,\n pushClassMeta,\n pushMethodMeta,\n setInMetaMap,\n setInMetaRecord,\n} from './metadata'\n\n// ── Decorator Registration System ───────────────────────────────────────\n// Decorators execute at class-definition time (module load). The Container\n// may not exist yet when the first decorator fires. We queue registrations\n// and flush them on first Container.getInstance() call.\n//\n// `allRegistrations` is a persistent registry that survives Container.reset().\n// On reset (HMR), all previously decorated classes are re-registered on the\n// fresh container. This ensures @Service, @Controller, @Repository, etc.\n// all survive HMR without manual re-registration.\n\ntype PendingRegistration = { target: any; scope: Scope }\nconst pendingRegistrations: PendingRegistration[] = []\n// Keyed by class name to prevent memory leaks during HMR — new class with\n// the same name replaces the old entry instead of accumulating references.\nconst allRegistrations = new Map<string, { target: any; scope: Scope }>()\nlet containerRef: any = null\n\nfunction flushPending(container: any): void {\n containerRef = container\n for (const { target, scope } of pendingRegistrations) {\n if (!container.has(target)) {\n container.register(target, target, scope)\n }\n }\n pendingRegistrations.length = 0\n}\n\n// Wire up synchronously — Container._onReady is called on first getInstance()\nContainer._onReady = flushPending\n\n// On Container.reset(), update containerRef and replay ALL decorator\n// registrations on the fresh container. This handles HMR where the container\n// is wiped but not all decorated modules are re-evaluated.\nContainer._onReset = (container: any) => {\n containerRef = container\n for (const [, { target, scope }] of allRegistrations) {\n if (!container.has(target)) {\n container.register(target, target, scope)\n }\n }\n}\n\n// ── Class Decorators ────────────────────────────────────────────────────\n\nfunction registerInContainer(target: any, scope: Scope): void {\n setClassMeta(METADATA.INJECTABLE, true, target)\n setClassMeta(METADATA.SCOPE, scope, target)\n\n // Track in persistent registry — survives Container.reset() for HMR replay.\n // Keyed by name so HMR class re-creation replaces the old entry.\n const name = target.name || String(target)\n allRegistrations.set(name, { target, scope })\n\n if (containerRef) {\n // Container already initialized — register immediately\n if (!containerRef.has(target)) {\n containerRef.register(target, target, scope)\n }\n } else {\n // Container not ready yet — queue for later\n pendingRegistrations.push({ target, scope })\n }\n}\n\n/** Mark a class as injectable with lifecycle scope */\nexport function Injectable(options?: ServiceOptions): ClassDecorator {\n return (target: any) => {\n setClassMeta(METADATA.CLASS_KIND, 'injectable', target)\n registerInContainer(target, options?.scope ?? Scope.SINGLETON)\n }\n}\n\n/** Mark a class as a service (semantic alias for Injectable) */\nexport function Service(options?: ServiceOptions): ClassDecorator {\n return (target: any) => {\n setClassMeta(METADATA.CLASS_KIND, 'service', target)\n registerInContainer(target, options?.scope ?? Scope.SINGLETON)\n }\n}\n\n/** Mark a class as a generic managed component */\nexport function Component(options?: ServiceOptions): ClassDecorator {\n return (target: any) => {\n setClassMeta(METADATA.CLASS_KIND, 'component', target)\n registerInContainer(target, options?.scope ?? Scope.SINGLETON)\n }\n}\n\n/** Mark a class as a repository */\nexport function Repository(options?: ServiceOptions): ClassDecorator {\n return (target: any) => {\n setClassMeta(METADATA.CLASS_KIND, 'repository', target)\n registerInContainer(target, options?.scope ?? Scope.SINGLETON)\n }\n}\n\n/**\n * Mark a class as an HTTP controller and register it in the DI container.\n *\n * @param path - **Deprecated.** The path parameter is no longer used for routing.\n * Route prefixes are defined by the module's `routes().path` — the single source\n * of truth for where routes are mounted. This parameter will be removed in a\n * future major version.\n */\nexport function Controller(path?: string): ClassDecorator {\n return (target: any) => {\n setClassMeta(METADATA.CLASS_KIND, 'controller', target)\n registerInContainer(target, Scope.SINGLETON)\n setClassMeta(METADATA.CONTROLLER_PATH, path || '/', target)\n }\n}\n\n// ── Method Decorators ───────────────────────────────────────────────────\n\n/** Mark a method as a lifecycle hook called after instantiation */\nexport function PostConstruct(): MethodDecorator {\n return (target, propertyKey) => {\n setClassMeta(METADATA.POST_CONSTRUCT, propertyKey, target)\n }\n}\n\n// ── Property Decorators ─────────────────────────────────────────────────\n\n/** Property injection — resolved lazily from the container */\nexport function Autowired(token?: any): PropertyDecorator {\n return (target, propertyKey) => {\n setInMetaMap(METADATA.AUTOWIRED, target, propertyKey as string, token)\n }\n}\n\n/**\n * Constructor parameter injection with an explicit token.\n *\n * **Constructor parameters only** — does not work as a property decorator.\n * For property injection with a token, use `@Autowired(token)` instead.\n */\nexport function Inject(token: any): ParameterDecorator {\n return (target, _propertyKey, parameterIndex) => {\n setInMetaRecord(METADATA.INJECT, target as object, parameterIndex, token)\n }\n}\n\n/**\n * Inject an environment variable value. Evaluated lazily so the env\n * is available at access time, not at decoration time.\n *\n * If no default is provided and the env var is missing, throws at access time\n * to catch misconfiguration early instead of returning undefined.\n *\n * Uses metadata + instance getter to work correctly with `useDefineForClassFields`.\n */\nexport function Value(envKey: string, defaultValue?: any): PropertyDecorator {\n return (target, propertyKey) => {\n setInMetaMap(METADATA.VALUE, target, propertyKey as string, { envKey, defaultValue })\n }\n}\n\n// ── HTTP Route Decorators ───────────────────────────────────────────────\n\nexport interface RouteDefinition {\n method: string\n path: string\n handlerName: string\n validation?: {\n /** JSON Schema object for validating the request body */\n body?: any\n /** JSON Schema object for validating query parameters */\n query?: any\n /** JSON Schema object for validating URL params */\n params?: any\n /** Schema name in OpenAPI components/schemas for the request body. Auto-generated from handler name if omitted. */\n name?: string\n }\n}\n\nfunction createRouteDecorator(method: string) {\n return (path?: string, validation?: RouteDefinition['validation']): MethodDecorator => {\n return (target, propertyKey) => {\n pushClassMeta<RouteDefinition>(METADATA.ROUTES, target.constructor, {\n method,\n path: path || '/',\n handlerName: propertyKey as string,\n validation,\n })\n }\n }\n}\n\nexport const Get = createRouteDecorator('GET')\nexport const Post = createRouteDecorator('POST')\nexport const Put = createRouteDecorator('PUT')\nexport const Delete = createRouteDecorator('DELETE')\nexport const Patch = createRouteDecorator('PATCH')\n\n// ── Query Params Decorator ─────────────────────────────────────────────\n\nexport interface ApiQueryParamsConfig {\n /** Fields that can be used in filter queries (e.g., `?filter=status:eq:active`) */\n filterable?: string[]\n /** Fields that can be used in sort queries (e.g., `?sort=createdAt:desc`) */\n sortable?: string[]\n /** Fields that are searched with the `?q=` parameter */\n searchable?: string[]\n}\n\n/**\n * Column-object-based query params config (e.g., from DrizzleQueryParamsConfig).\n * `Object.keys()` is used to derive field names for OpenAPI docs.\n */\nexport interface ColumnApiQueryParamsConfig {\n columns: Record<string, any>\n sortable?: Record<string, any>\n searchColumns?: any[]\n [key: string]: any\n}\n\n/**\n * Normalize a query params config to the string-based ApiQueryParamsConfig.\n * Handles both string-based and column-object-based configs.\n */\nexport function normalizeApiQueryParamsConfig(\n config: ApiQueryParamsConfig | ColumnApiQueryParamsConfig,\n): ApiQueryParamsConfig {\n if ('columns' in config && config.columns && typeof config.columns === 'object') {\n return {\n filterable: Object.keys(config.columns),\n sortable: config.sortable ? Object.keys(config.sortable) : undefined,\n searchable: config.searchColumns\n ? config.searchColumns.map((col: any) => col?.name ?? '').filter(Boolean)\n : undefined,\n }\n }\n return config as ApiQueryParamsConfig\n}\n\n/**\n * Document the query parameters accepted by a GET endpoint.\n * Used by SwaggerAdapter to generate `filter`, `sort`, `page`, `limit`, and `q` params\n * in the OpenAPI spec, with descriptions listing the allowed fields.\n *\n * Accepts both string-based configs and column-object configs (e.g., DrizzleQueryParamsConfig).\n *\n * @example\n * ```ts\n * // String-based\n * @ApiQueryParams({\n * filterable: ['status', 'category', 'price'],\n * sortable: ['name', 'createdAt', 'price'],\n * searchable: ['name', 'description'],\n * })\n *\n * // Column-object-based (Drizzle)\n * @ApiQueryParams(TASK_QUERY_CONFIG)\n * ```\n */\nexport function ApiQueryParams(\n config: ApiQueryParamsConfig | ColumnApiQueryParamsConfig,\n): MethodDecorator {\n return (target, propertyKey) => {\n const normalized = normalizeApiQueryParamsConfig(config)\n setMethodMeta(METADATA.QUERY_PARAMS, normalized, target.constructor, propertyKey as string)\n }\n}\n\n// ── Middleware Decorators ───────────────────────────────────────────────\n\n/**\n * Middleware handler function.\n * Generic `TCtx` defaults to `any` — import `RequestContext` from\n * `@forinda/kickjs-http` for full type safety:\n *\n * ```ts\n * import type { MiddlewareHandler } from '@forinda/kickjs-core'\n * import type { RequestContext } from '@forinda/kickjs-http'\n *\n * const auth: MiddlewareHandler<RequestContext> = (ctx, next) => {\n * ctx.body // fully typed\n * next()\n * }\n * ```\n */\nexport type MiddlewareHandler<TCtx = any> = (ctx: TCtx, next: () => void) => void | Promise<void>\n\n/** Attach middleware handlers to a class or method */\nexport function Middleware(...handlers: MiddlewareHandler[]): ClassDecorator & MethodDecorator {\n return (target: any, propertyKey?: string | symbol) => {\n if (propertyKey) {\n pushMethodMeta(\n METADATA.METHOD_MIDDLEWARES,\n target.constructor,\n propertyKey as string,\n ...handlers,\n )\n } else {\n pushClassMeta(METADATA.CLASS_MIDDLEWARES, target, ...handlers)\n }\n }\n}\n\n// ── File Upload Decorator ───────────────────────────────────────────────\n\n/**\n * File filter — accepts short extensions ('jpg'), full MIME types ('image/jpeg'),\n * wildcards ('image/*'), or a function `(mimetype, filename) => boolean` for full control.\n */\nexport type FileTypeFilter = string[] | ((mimetype: string, filename: string) => boolean)\n\n/**\n * Shared upload options used by both the `@FileUpload` decorator and the\n * `upload.single()` / `upload.array()` / `upload.none()` middleware.\n */\nexport interface BaseUploadOptions {\n /** Max file size in bytes (default: 5MB) */\n maxSize?: number\n /**\n * Allowed file types:\n * - **string[]** — short extensions ('jpg'), full MIME types ('image/jpeg'), or wildcards ('image/*')\n * - **function** — `(mimetype, filename) => boolean` for full control\n */\n allowedTypes?: FileTypeFilter\n /** Extend the built-in extension-to-MIME map */\n customMimeMap?: Record<string, string>\n}\n\nexport interface FileUploadConfig extends BaseUploadOptions {\n mode: 'single' | 'array' | 'none'\n /** Form field name (default: 'file') */\n fieldName?: string\n /** Max files for array mode (default: 10) */\n maxCount?: number\n}\n\n/** Configure file upload handling for a controller method */\nexport function FileUpload(config: FileUploadConfig): MethodDecorator {\n return (target, propertyKey) => {\n setMethodMeta(METADATA.FILE_UPLOAD, config, target.constructor, propertyKey as string)\n }\n}\n\n// ── Builder Decorator ───────────────────────────────────────────────────\n\n/** Add a static builder() method for fluent construction */\nexport function Builder(target: any): void {\n setClassMeta(METADATA.BUILDER, true, target)\n\n target.builder = function () {\n const props: Record<string, any> = {}\n const proxy: any = new Proxy(\n {},\n {\n get(_, key) {\n if (key === 'build') {\n return () => Object.assign(new target(), props)\n }\n return (value: any) => {\n props[key as string] = value\n return proxy\n }\n },\n },\n )\n return proxy\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAwBA,MAAM,uBAA8C,EAAE;AAGtD,MAAM,mCAAmB,IAAI,KAA4C;AACzE,IAAI,eAAoB;AAExB,SAAS,aAAa,WAAsB;AAC1C,gBAAe;AACf,MAAK,MAAM,EAAE,QAAQ,WAAW,qBAC9B,KAAI,CAAC,UAAU,IAAI,OAAO,CACxB,WAAU,SAAS,QAAQ,QAAQ,MAAM;AAG7C,sBAAqB,SAAS;;AAIhC,UAAU,WAAW;AAKrB,UAAU,YAAY,cAAmB;AACvC,gBAAe;AACf,MAAK,MAAM,GAAG,EAAE,QAAQ,YAAY,iBAClC,KAAI,CAAC,UAAU,IAAI,OAAO,CACxB,WAAU,SAAS,QAAQ,QAAQ,MAAM;;AAO/C,SAAS,oBAAoB,QAAa,OAAoB;AAC5D,cAAa,SAAS,YAAY,MAAM,OAAO;AAC/C,cAAa,SAAS,OAAO,OAAO,OAAO;CAI3C,MAAM,OAAO,OAAO,QAAQ,OAAO,OAAO;AAC1C,kBAAiB,IAAI,MAAM;EAAE;EAAQ;EAAO,CAAC;AAE7C,KAAI;MAEE,CAAC,aAAa,IAAI,OAAO,CAC3B,cAAa,SAAS,QAAQ,QAAQ,MAAM;OAI9C,sBAAqB,KAAK;EAAE;EAAQ;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ACF,EACE,IAAI,GAAG,KAAK;AACV,OAAI,QAAQ,QACV,cAAa,OAAO,OAAO,IAAI,QAAQ,EAAE,MAAM;AAEjD,WAAQ,UAAe;AACrB,UAAM,OAAiB;AACvB,WAAO;;KAGZ,CACF;AACD,SAAO"}
1
+ {"version":3,"file":"decorators.mjs","names":[],"sources":["../../src/core/decorators.ts"],"sourcesContent":["import 'reflect-metadata'\nimport { METADATA, Scope, type ServiceOptions } from './interfaces'\nimport { Container } from './container'\nimport {\n setClassMeta,\n setMethodMeta,\n getClassMeta,\n pushClassMeta,\n pushMethodMeta,\n setInMetaMap,\n setInMetaRecord,\n} from './metadata'\n\n// ── Decorator Registration System ───────────────────────────────────────\n// Decorators execute at class-definition time (module load). The Container\n// may not exist yet when the first decorator fires. We queue registrations\n// and flush them on first Container.getInstance() call.\n//\n// `allRegistrations` is a persistent registry that survives Container.reset().\n// On reset (HMR), all previously decorated classes are re-registered on the\n// fresh container. This ensures @Service, @Controller, @Repository, etc.\n// all survive HMR without manual re-registration.\n\ntype PendingRegistration = { target: any; scope: Scope }\nconst pendingRegistrations: PendingRegistration[] = []\n// Keyed by class name to prevent memory leaks during HMR — new class with\n// the same name replaces the old entry instead of accumulating references.\nconst allRegistrations = new Map<string, { target: any; scope: Scope }>()\nlet containerRef: any = null\n\nfunction flushPending(container: any): void {\n containerRef = container\n for (const { target, scope } of pendingRegistrations) {\n if (!container.has(target)) {\n container.register(target, target, scope)\n }\n }\n pendingRegistrations.length = 0\n}\n\n// Wire up synchronously — Container._onReady is called on first getInstance()\nContainer._onReady = flushPending\n\n// On Container.reset(), update containerRef and replay ALL decorator\n// registrations on the fresh container. This handles HMR where the container\n// is wiped but not all decorated modules are re-evaluated.\nContainer._onReset = (container: any) => {\n containerRef = container\n for (const [, { target, scope }] of allRegistrations) {\n if (!container.has(target)) {\n container.register(target, target, scope)\n }\n }\n}\n\n// ── Class Decorators ────────────────────────────────────────────────────\n\nfunction registerInContainer(target: any, scope: Scope): void {\n setClassMeta(METADATA.INJECTABLE, true, target)\n setClassMeta(METADATA.SCOPE, scope, target)\n\n // Track in persistent registry — survives Container.reset() for HMR replay.\n // Keyed by name so HMR class re-creation replaces the old entry.\n const name = target.name || String(target)\n allRegistrations.set(name, { target, scope })\n\n if (containerRef) {\n // Container already initialized — register immediately\n if (!containerRef.has(target)) {\n containerRef.register(target, target, scope)\n }\n } else {\n // Container not ready yet — queue for later\n pendingRegistrations.push({ target, scope })\n }\n}\n\n/** Mark a class as injectable with lifecycle scope */\nexport function Injectable(options?: ServiceOptions): ClassDecorator {\n return (target: any) => {\n setClassMeta(METADATA.CLASS_KIND, 'injectable', target)\n registerInContainer(target, options?.scope ?? Scope.SINGLETON)\n }\n}\n\n/** Mark a class as a service (semantic alias for Injectable) */\nexport function Service(options?: ServiceOptions): ClassDecorator {\n return (target: any) => {\n setClassMeta(METADATA.CLASS_KIND, 'service', target)\n registerInContainer(target, options?.scope ?? Scope.SINGLETON)\n }\n}\n\n/** Mark a class as a generic managed component */\nexport function Component(options?: ServiceOptions): ClassDecorator {\n return (target: any) => {\n setClassMeta(METADATA.CLASS_KIND, 'component', target)\n registerInContainer(target, options?.scope ?? Scope.SINGLETON)\n }\n}\n\n/** Mark a class as a repository */\nexport function Repository(options?: ServiceOptions): ClassDecorator {\n return (target: any) => {\n setClassMeta(METADATA.CLASS_KIND, 'repository', target)\n registerInContainer(target, options?.scope ?? Scope.SINGLETON)\n }\n}\n\n/**\n * Mark a class as an HTTP controller and register it in the DI container.\n *\n * @param path - **Deprecated.** The path parameter is no longer used for routing.\n * Route prefixes are defined by the module's `routes().path` — the single source\n * of truth for where routes are mounted. This parameter will be removed in a\n * future major version.\n */\nexport function Controller(path?: string): ClassDecorator {\n return (target: any) => {\n setClassMeta(METADATA.CLASS_KIND, 'controller', target)\n registerInContainer(target, Scope.SINGLETON)\n setClassMeta(METADATA.CONTROLLER_PATH, path || '/', target)\n }\n}\n\n// ── Method Decorators ───────────────────────────────────────────────────\n\n/** Mark a method as a lifecycle hook called after instantiation */\nexport function PostConstruct(): MethodDecorator {\n return (target, propertyKey) => {\n setClassMeta(METADATA.POST_CONSTRUCT, propertyKey, target)\n }\n}\n\n// ── Property Decorators ─────────────────────────────────────────────────\n\n/** Property injection — resolved lazily from the container */\nexport function Autowired(token?: any): PropertyDecorator {\n return (target, propertyKey) => {\n setInMetaMap(METADATA.AUTOWIRED, target, propertyKey as string, token)\n }\n}\n\n/**\n * Constructor parameter injection with an explicit token.\n *\n * **Constructor parameters only** — does not work as a property decorator.\n * For property injection with a token, use `@Autowired(token)` instead.\n */\nexport function Inject(token: any): ParameterDecorator {\n return (target, _propertyKey, parameterIndex) => {\n setInMetaRecord(METADATA.INJECT, target as object, parameterIndex, token)\n }\n}\n\n/**\n * Global ambient registry of typed environment variables, populated by\n * `kick typegen` from the project's env schema (typically\n * `src/env.ts`'s `export default defineEnv(...)`).\n *\n * Empty by default — declarations come from `.kickjs/types/env.ts`\n * generated alongside the rest of the typegen output. Once populated,\n * `@Value('PORT')` autocompletes the key, type-checks the default\n * value, and `process.env.PORT` is also typed via the parallel\n * `NodeJS.ProcessEnv` augmentation in the same generated file.\n */\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n interface KickEnv {}\n}\n\n/** A string key known to the typed env registry (`never` until typegen runs) */\nexport type EnvKey = keyof KickEnv & string\n\n/**\n * Look up the type of a typed env entry.\n *\n * Decorators can't propagate the property type from the key, so users\n * still need to write the property's type — but `Env<K>` lets them\n * derive it from `KickEnv` instead of duplicating the schema:\n *\n * ```ts\n * @Service()\n * class MyService {\n * @Value('PORT')\n * private port!: Env<'PORT'> // → number, narrowed from KickEnv['PORT']\n * }\n * ```\n */\nexport type Env<K extends EnvKey = EnvKey> = KickEnv[K]\n\n/**\n * Constraint that allows any string when the typed env registry is\n * empty (no `kick typegen` has run yet, so existing code with raw\n * string keys keeps working) but locks the argument down to known\n * `EnvKey` literals once the registry is populated.\n *\n * Implementation: when `EnvKey` is `never`, the conditional resolves\n * to the user's `K`, accepting anything. Once typegen has populated\n * `KickEnv`, `EnvKey` becomes a real union and the conditional forces\n * `K` to be assignable to it.\n */\ntype ValueKey<K extends string> = [EnvKey] extends [never] ? K : K & EnvKey\n\n/**\n * Inject an environment variable value. Evaluated lazily so the env\n * is available at access time, not at decoration time.\n *\n * If no default is provided and the env var is missing, throws at access time\n * to catch misconfiguration early instead of returning undefined.\n *\n * Uses metadata + instance getter to work correctly with `useDefineForClassFields`.\n *\n * Type-safety:\n * - Without `kick typegen` run, any string key is accepted (back-compat).\n * - After typegen, `KickEnv` is populated and unknown keys become a tsc\n * error. The optional `defaultValue` is type-checked against the\n * schema's inferred type for that key.\n */\nexport function Value<K extends string>(\n envKey: ValueKey<K>,\n defaultValue?: K extends EnvKey ? KickEnv[K] : unknown,\n): PropertyDecorator {\n return (target, propertyKey) => {\n setInMetaMap(METADATA.VALUE, target, propertyKey as string, { envKey, defaultValue })\n }\n}\n\n// ── HTTP Route Decorators ───────────────────────────────────────────────\n\nexport interface RouteDefinition {\n method: string\n path: string\n handlerName: string\n validation?: {\n /** JSON Schema object for validating the request body */\n body?: any\n /** JSON Schema object for validating query parameters */\n query?: any\n /** JSON Schema object for validating URL params */\n params?: any\n /** Schema name in OpenAPI components/schemas for the request body. Auto-generated from handler name if omitted. */\n name?: string\n }\n}\n\nfunction createRouteDecorator(method: string) {\n return (path?: string, validation?: RouteDefinition['validation']): MethodDecorator => {\n return (target, propertyKey) => {\n pushClassMeta<RouteDefinition>(METADATA.ROUTES, target.constructor, {\n method,\n path: path || '/',\n handlerName: propertyKey as string,\n validation,\n })\n }\n }\n}\n\nexport const Get = createRouteDecorator('GET')\nexport const Post = createRouteDecorator('POST')\nexport const Put = createRouteDecorator('PUT')\nexport const Delete = createRouteDecorator('DELETE')\nexport const Patch = createRouteDecorator('PATCH')\n\n// ── Query Params Decorator ─────────────────────────────────────────────\n\nexport interface ApiQueryParamsConfig {\n /** Fields that can be used in filter queries (e.g., `?filter=status:eq:active`) */\n filterable?: string[]\n /** Fields that can be used in sort queries (e.g., `?sort=createdAt:desc`) */\n sortable?: string[]\n /** Fields that are searched with the `?q=` parameter */\n searchable?: string[]\n}\n\n/**\n * Column-object-based query params config (e.g., from DrizzleQueryParamsConfig).\n * `Object.keys()` is used to derive field names for OpenAPI docs.\n */\nexport interface ColumnApiQueryParamsConfig {\n columns: Record<string, any>\n sortable?: Record<string, any>\n searchColumns?: any[]\n [key: string]: any\n}\n\n/**\n * Normalize a query params config to the string-based ApiQueryParamsConfig.\n * Handles both string-based and column-object-based configs.\n */\nexport function normalizeApiQueryParamsConfig(\n config: ApiQueryParamsConfig | ColumnApiQueryParamsConfig,\n): ApiQueryParamsConfig {\n if ('columns' in config && config.columns && typeof config.columns === 'object') {\n return {\n filterable: Object.keys(config.columns),\n sortable: config.sortable ? Object.keys(config.sortable) : undefined,\n searchable: config.searchColumns\n ? config.searchColumns.map((col: any) => col?.name ?? '').filter(Boolean)\n : undefined,\n }\n }\n return config as ApiQueryParamsConfig\n}\n\n/**\n * Document the query parameters accepted by a GET endpoint.\n * Used by SwaggerAdapter to generate `filter`, `sort`, `page`, `limit`, and `q` params\n * in the OpenAPI spec, with descriptions listing the allowed fields.\n *\n * Accepts both string-based configs and column-object configs (e.g., DrizzleQueryParamsConfig).\n *\n * @example\n * ```ts\n * // String-based\n * @ApiQueryParams({\n * filterable: ['status', 'category', 'price'],\n * sortable: ['name', 'createdAt', 'price'],\n * searchable: ['name', 'description'],\n * })\n *\n * // Column-object-based (Drizzle)\n * @ApiQueryParams(TASK_QUERY_CONFIG)\n * ```\n */\nexport function ApiQueryParams(\n config: ApiQueryParamsConfig | ColumnApiQueryParamsConfig,\n): MethodDecorator {\n return (target, propertyKey) => {\n const normalized = normalizeApiQueryParamsConfig(config)\n setMethodMeta(METADATA.QUERY_PARAMS, normalized, target.constructor, propertyKey as string)\n }\n}\n\n// ── Middleware Decorators ───────────────────────────────────────────────\n\n/**\n * Middleware handler function.\n * Generic `TCtx` defaults to `any` — import `RequestContext` from\n * `@forinda/kickjs-http` for full type safety:\n *\n * ```ts\n * import type { MiddlewareHandler } from '@forinda/kickjs-core'\n * import type { RequestContext } from '@forinda/kickjs-http'\n *\n * const auth: MiddlewareHandler<RequestContext> = (ctx, next) => {\n * ctx.body // fully typed\n * next()\n * }\n * ```\n */\nexport type MiddlewareHandler<TCtx = any> = (ctx: TCtx, next: () => void) => void | Promise<void>\n\n/** Attach middleware handlers to a class or method */\nexport function Middleware(...handlers: MiddlewareHandler[]): ClassDecorator & MethodDecorator {\n return (target: any, propertyKey?: string | symbol) => {\n if (propertyKey) {\n pushMethodMeta(\n METADATA.METHOD_MIDDLEWARES,\n target.constructor,\n propertyKey as string,\n ...handlers,\n )\n } else {\n pushClassMeta(METADATA.CLASS_MIDDLEWARES, target, ...handlers)\n }\n }\n}\n\n// ── File Upload Decorator ───────────────────────────────────────────────\n\n/**\n * File filter — accepts short extensions ('jpg'), full MIME types ('image/jpeg'),\n * wildcards ('image/*'), or a function `(mimetype, filename) => boolean` for full control.\n */\nexport type FileTypeFilter = string[] | ((mimetype: string, filename: string) => boolean)\n\n/**\n * Shared upload options used by both the `@FileUpload` decorator and the\n * `upload.single()` / `upload.array()` / `upload.none()` middleware.\n */\nexport interface BaseUploadOptions {\n /** Max file size in bytes (default: 5MB) */\n maxSize?: number\n /**\n * Allowed file types:\n * - **string[]** — short extensions ('jpg'), full MIME types ('image/jpeg'), or wildcards ('image/*')\n * - **function** — `(mimetype, filename) => boolean` for full control\n */\n allowedTypes?: FileTypeFilter\n /** Extend the built-in extension-to-MIME map */\n customMimeMap?: Record<string, string>\n}\n\nexport interface FileUploadConfig extends BaseUploadOptions {\n mode: 'single' | 'array' | 'none'\n /** Form field name (default: 'file') */\n fieldName?: string\n /** Max files for array mode (default: 10) */\n maxCount?: number\n}\n\n/** Configure file upload handling for a controller method */\nexport function FileUpload(config: FileUploadConfig): MethodDecorator {\n return (target, propertyKey) => {\n setMethodMeta(METADATA.FILE_UPLOAD, config, target.constructor, propertyKey as string)\n }\n}\n\n// ── Builder Decorator ───────────────────────────────────────────────────\n\n/** Add a static builder() method for fluent construction */\nexport function Builder(target: any): void {\n setClassMeta(METADATA.BUILDER, true, target)\n\n target.builder = function () {\n const props: Record<string, any> = {}\n const proxy: any = new Proxy(\n {},\n {\n get(_, key) {\n if (key === 'build') {\n return () => Object.assign(new target(), props)\n }\n return (value: any) => {\n props[key as string] = value\n return proxy\n }\n },\n },\n )\n return proxy\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAwBA,MAAM,uBAA8C,EAAE;AAGtD,MAAM,mCAAmB,IAAI,KAA4C;AACzE,IAAI,eAAoB;AAExB,SAAS,aAAa,WAAsB;AAC1C,gBAAe;AACf,MAAK,MAAM,EAAE,QAAQ,WAAW,qBAC9B,KAAI,CAAC,UAAU,IAAI,OAAO,CACxB,WAAU,SAAS,QAAQ,QAAQ,MAAM;AAG7C,sBAAqB,SAAS;;AAIhC,UAAU,WAAW;AAKrB,UAAU,YAAY,cAAmB;AACvC,gBAAe;AACf,MAAK,MAAM,GAAG,EAAE,QAAQ,YAAY,iBAClC,KAAI,CAAC,UAAU,IAAI,OAAO,CACxB,WAAU,SAAS,QAAQ,QAAQ,MAAM;;AAO/C,SAAS,oBAAoB,QAAa,OAAoB;AAC5D,cAAa,SAAS,YAAY,MAAM,OAAO;AAC/C,cAAa,SAAS,OAAO,OAAO,OAAO;CAI3C,MAAM,OAAO,OAAO,QAAQ,OAAO,OAAO;AAC1C,kBAAiB,IAAI,MAAM;EAAE;EAAQ;EAAO,CAAC;AAE7C,KAAI;MAEE,CAAC,aAAa,IAAI,OAAO,CAC3B,cAAa,SAAS,QAAQ,QAAQ,MAAM;OAI9C,sBAAqB,KAAK;EAAE;EAAQ;EAAO,CAAC;;;AAKhD,SAAgB,WAAW,SAA0C;AACnE,SAAQ,WAAgB;AACtB,eAAa,SAAS,YAAY,cAAc,OAAO;AACvD,sBAAoB,QAAQ,SAAS,SAAS,MAAM,U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,WAAO;;KAGZ,CACF;AACD,SAAO"}
@@ -1,3 +1,3 @@
1
1
 
2
- import { i as ValidationError, n as HttpStatus, r as HttpStatusCode, t as HttpException } from "../errors-te5Km00o.mjs";
2
+ import { i as ValidationError, n as HttpStatus, r as HttpStatusCode, t as HttpException } from "../errors-BZUdxtjC.mjs";
3
3
  export { HttpException, HttpStatus, HttpStatusCode, ValidationError };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs v2.1.0
2
+ * @forinda/kickjs v2.2.1
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -1,3 +1,3 @@
1
1
 
2
- import { a as METADATA, c as Scope, i as Constructor, l as ServiceOptions, n as BuilderOf, o as MaybePromise, r as ClassKind, s as PostConstructStatus, t as Buildable } from "../interfaces-D-48zotH.mjs";
2
+ import { a as METADATA, c as Scope, i as Constructor, l as ServiceOptions, n as BuilderOf, o as MaybePromise, r as ClassKind, s as PostConstructStatus, t as Buildable } from "../interfaces-D5ohYl6D.mjs";
3
3
  export { Buildable, BuilderOf, ClassKind, Constructor, METADATA, MaybePromise, PostConstructStatus, Scope, ServiceOptions };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs v2.1.0
2
+ * @forinda/kickjs v2.2.1
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -1,3 +1,3 @@
1
1
 
2
- import { a as logger, i as createLogger, n as Logger, o as rootLogger, r as LoggerProvider, t as ConsoleLoggerProvider } from "../logger-Dzj-TF0t.mjs";
2
+ import { a as logger, i as createLogger, n as Logger, o as rootLogger, r as LoggerProvider, t as ConsoleLoggerProvider } from "../logger-BLdfUF5b.mjs";
3
3
  export { ConsoleLoggerProvider, Logger, LoggerProvider, createLogger, logger, rootLogger };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs v2.1.0
2
+ * @forinda/kickjs v2.2.1
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -1,3 +1,3 @@
1
1
 
2
- import { n as normalizePath, t as joinPaths } from "../path-LmwfhfyH.mjs";
2
+ import { n as normalizePath, t as joinPaths } from "../path-Dq5V-i-x.mjs";
3
3
  export { joinPaths, normalizePath };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs v2.1.0
2
+ * @forinda/kickjs v2.2.1
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -1,3 +1,3 @@
1
1
 
2
- import { t as KickPlugin } from "../plugin-DIoPIpSm.mjs";
2
+ import { t as KickPlugin } from "../plugin-D20muJwC.mjs";
3
3
  export { KickPlugin };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs v2.1.0
2
+ * @forinda/kickjs v2.2.1
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -1,3 +1,3 @@
1
1
 
2
- import { a as isRef, c as toRefs, i as computed, l as unref, n as Ref, o as reactive, r as WatchOptions, s as ref, t as ComputedRef, u as watch } from "../reactivity-BbS-99ow.mjs";
2
+ import { a as isRef, c as toRefs, i as computed, l as unref, n as Ref, o as reactive, r as WatchOptions, s as ref, t as ComputedRef, u as watch } from "../reactivity-CMAQh0gi.mjs";
3
3
  export { ComputedRef, Ref, WatchOptions, computed, isRef, reactive, ref, toRefs, unref, watch };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs v2.1.0
2
+ * @forinda/kickjs v2.2.1
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs v2.1.0
2
+ * @forinda/kickjs v2.2.1
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -10,8 +10,8 @@
10
10
  */
11
11
  import "./core/interfaces.mjs";
12
12
  import "./core/logger.mjs";
13
- import "./metadata-fmvikBA0.mjs";
14
- import "./core/container.mjs";
13
+ import "./metadata-D5L3_cdl.mjs";
14
+ import "./container-BKiJzakw.mjs";
15
15
  import "./core/decorators.mjs";
16
16
  import "./core/cron.mjs";
17
17
  import "./core/cache.mjs";
@@ -118,4 +118,4 @@ var CircuitBreaker = class {
118
118
  //#endregion
119
119
  export { CircuitOpenError as n, CircuitBreaker as t };
120
120
 
121
- //# sourceMappingURL=core-BL_H8fEZ.mjs.map
121
+ //# sourceMappingURL=core-CXHuViXn.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"core-BL_H8fEZ.mjs","names":[],"sources":["../src/core/circuit-breaker.ts"],"sourcesContent":["/**\n * Circuit Breaker pattern for external service calls.\n *\n * Protects your application from cascading failures when downstream\n * services are unhealthy by short-circuiting requests after a\n * configurable failure threshold.\n *\n * @example\n * ```ts\n * const breaker = new CircuitBreaker('payment-api', {\n * failureThreshold: 5,\n * resetTimeout: 30_000,\n * })\n *\n * const result = await breaker.execute(() => fetch('https://payment.example.com/charge'))\n * ```\n */\n\nexport type CircuitBreakerState = 'closed' | 'open' | 'half_open'\n\nexport interface CircuitBreakerOptions {\n /** Number of consecutive failures before the circuit opens. */\n failureThreshold: number\n /** Milliseconds to wait before transitioning from OPEN to HALF_OPEN. */\n resetTimeout: number\n /** Max requests allowed in HALF_OPEN state before deciding (default 1). */\n halfOpenMax?: number\n}\n\nexport interface CircuitBreakerStats {\n failures: number\n successes: number\n state: CircuitBreakerState\n lastFailure?: Date\n}\n\n/**\n * Error thrown when the circuit is open and calls are being rejected.\n */\nexport class CircuitOpenError extends Error {\n constructor(public readonly breakerName: string) {\n super(`Circuit breaker \"${breakerName}\" is open — request rejected`)\n this.name = 'CircuitOpenError'\n }\n}\n\nexport class CircuitBreaker {\n private state: CircuitBreakerState = 'closed'\n private failures = 0\n private successes = 0\n private halfOpenAttempts = 0\n private lastFailure?: Date\n private openedAt?: number\n\n private readonly failureThreshold: number\n private readonly resetTimeout: number\n private readonly halfOpenMax: number\n\n constructor(\n public readonly name: string,\n options: CircuitBreakerOptions,\n ) {\n this.failureThreshold = options.failureThreshold\n this.resetTimeout = options.resetTimeout\n this.halfOpenMax = options.halfOpenMax ?? 1\n }\n\n /**\n * Execute an async function through the circuit breaker.\n * Throws `CircuitOpenError` if the circuit is open.\n */\n async execute<T>(fn: () => Promise<T>): Promise<T> {\n this.maybeTransitionToHalfOpen()\n\n if (this.state === 'open') {\n throw new CircuitOpenError(this.name)\n }\n\n if (this.state === 'half_open' && this.halfOpenAttempts >= this.halfOpenMax) {\n throw new CircuitOpenError(this.name)\n }\n\n if (this.state === 'half_open') {\n this.halfOpenAttempts++\n }\n\n try {\n const result = await fn()\n this.onSuccess()\n return result\n } catch (error) {\n this.onFailure()\n throw error\n }\n }\n\n /** Returns the current circuit state. */\n getState(): CircuitBreakerState {\n this.maybeTransitionToHalfOpen()\n return this.state\n }\n\n /** Returns current statistics. */\n getStats(): CircuitBreakerStats {\n this.maybeTransitionToHalfOpen()\n return {\n failures: this.failures,\n successes: this.successes,\n state: this.state,\n ...(this.lastFailure ? { lastFailure: this.lastFailure } : {}),\n }\n }\n\n /** Manually reset the circuit breaker to CLOSED state. */\n reset(): void {\n this.state = 'closed'\n this.failures = 0\n this.successes = 0\n this.halfOpenAttempts = 0\n this.lastFailure = undefined\n this.openedAt = undefined\n }\n\n private onSuccess(): void {\n if (this.state === 'half_open') {\n // Recovery confirmed — close the circuit\n this.state = 'closed'\n this.failures = 0\n this.halfOpenAttempts = 0\n this.openedAt = undefined\n }\n this.successes++\n }\n\n private onFailure(): void {\n this.failures++\n this.lastFailure = new Date()\n\n if (this.state === 'half_open') {\n // Recovery failed — re-open\n this.state = 'open'\n this.openedAt = Date.now()\n this.halfOpenAttempts = 0\n } else if (this.state === 'closed' && this.failures >= this.failureThreshold) {\n this.state = 'open'\n this.openedAt = Date.now()\n }\n }\n\n private maybeTransitionToHalfOpen(): void {\n if (this.state === 'open' && this.openedAt != null) {\n if (Date.now() - this.openedAt >= this.resetTimeout) {\n this.state = 'half_open'\n this.halfOpenAttempts = 0\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;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AGP,YAA0B;AACxB,OAAK;AACL,OAAK,8BAAc,IAAI,MAAM;AAE7B,MAAI,KAAK,UAAU,aAAa;AAE9B,QAAK,QAAQ;AACb,QAAK,WAAW,KAAK,KAAK;AAC1B,QAAK,mBAAmB;aACf,KAAK,UAAU,YAAY,KAAK,YAAY,KAAK,kBAAkB;AAC5E,QAAK,QAAQ;AACb,QAAK,WAAW,KAAK,KAAK;;;CAI9B,4BAA0C;AACxC,MAAI,KAAK,UAAU,UAAU,KAAK,YAAY;OACxC,KAAK,KAAK,GAAG,KAAK,YAAY,KAAK,cAAc;AACnD,SAAK,QAAQ;AACb,SAAK,mBAAmB"}
1
+ {"version":3,"file":"core-CXHuViXn.mjs","names":[],"sources":["../src/core/circuit-breaker.ts"],"sourcesContent":["/**\n * Circuit Breaker pattern for external service calls.\n *\n * Protects your application from cascading failures when downstream\n * services are unhealthy by short-circuiting requests after a\n * configurable failure threshold.\n *\n * @example\n * ```ts\n * const breaker = new CircuitBreaker('payment-api', {\n * failureThreshold: 5,\n * resetTimeout: 30_000,\n * })\n *\n * const result = await breaker.execute(() => fetch('https://payment.example.com/charge'))\n * ```\n */\n\nexport type CircuitBreakerState = 'closed' | 'open' | 'half_open'\n\nexport interface CircuitBreakerOptions {\n /** Number of consecutive failures before the circuit opens. */\n failureThreshold: number\n /** Milliseconds to wait before transitioning from OPEN to HALF_OPEN. */\n resetTimeout: number\n /** Max requests allowed in HALF_OPEN state before deciding (default 1). */\n halfOpenMax?: number\n}\n\nexport interface CircuitBreakerStats {\n failures: number\n successes: number\n state: CircuitBreakerState\n lastFailure?: Date\n}\n\n/**\n * Error thrown when the circuit is open and calls are being rejected.\n */\nexport class CircuitOpenError extends Error {\n constructor(public readonly breakerName: string) {\n super(`Circuit breaker \"${breakerName}\" is open — request rejected`)\n this.name = 'CircuitOpenError'\n }\n}\n\nexport class CircuitBreaker {\n private state: CircuitBreakerState = 'closed'\n private failures = 0\n private successes = 0\n private halfOpenAttempts = 0\n private lastFailure?: Date\n private openedAt?: number\n\n private readonly failureThreshold: number\n private readonly resetTimeout: number\n private readonly halfOpenMax: number\n\n constructor(\n public readonly name: string,\n options: CircuitBreakerOptions,\n ) {\n this.failureThreshold = options.failureThreshold\n this.resetTimeout = options.resetTimeout\n this.halfOpenMax = options.halfOpenMax ?? 1\n }\n\n /**\n * Execute an async function through the circuit breaker.\n * Throws `CircuitOpenError` if the circuit is open.\n */\n async execute<T>(fn: () => Promise<T>): Promise<T> {\n this.maybeTransitionToHalfOpen()\n\n if (this.state === 'open') {\n throw new CircuitOpenError(this.name)\n }\n\n if (this.state === 'half_open' && this.halfOpenAttempts >= this.halfOpenMax) {\n throw new CircuitOpenError(this.name)\n }\n\n if (this.state === 'half_open') {\n this.halfOpenAttempts++\n }\n\n try {\n const result = await fn()\n this.onSuccess()\n return result\n } catch (error) {\n this.onFailure()\n throw error\n }\n }\n\n /** Returns the current circuit state. */\n getState(): CircuitBreakerState {\n this.maybeTransitionToHalfOpen()\n return this.state\n }\n\n /** Returns current statistics. */\n getStats(): CircuitBreakerStats {\n this.maybeTransitionToHalfOpen()\n return {\n failures: this.failures,\n successes: this.successes,\n state: this.state,\n ...(this.lastFailure ? { lastFailure: this.lastFailure } : {}),\n }\n }\n\n /** Manually reset the circuit breaker to CLOSED state. */\n reset(): void {\n this.state = 'closed'\n this.failures = 0\n this.successes = 0\n this.halfOpenAttempts = 0\n this.lastFailure = undefined\n this.openedAt = undefined\n }\n\n private onSuccess(): void {\n if (this.state === 'half_open') {\n // Recovery confirmed — close the circuit\n this.state = 'closed'\n this.failures = 0\n this.halfOpenAttempts = 0\n this.openedAt = undefined\n }\n this.successes++\n }\n\n private onFailure(): void {\n this.failures++\n this.lastFailure = new Date()\n\n if (this.state === 'half_open') {\n // Recovery failed — re-open\n this.state = 'open'\n this.openedAt = Date.now()\n this.halfOpenAttempts = 0\n } else if (this.state === 'closed' && this.failures >= this.failureThreshold) {\n this.state = 'open'\n this.openedAt = Date.now()\n }\n }\n\n private maybeTransitionToHalfOpen(): void {\n if (this.state === 'open' && this.openedAt != null) {\n if (Date.now() - this.openedAt >= this.resetTimeout) {\n this.state = 'half_open'\n this.halfOpenAttempts = 0\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuCA,IAAa,mBAAb,cAAsC,MAAM;CAC1C,YAAY,aAAqC;AAC/C,QAAM,oBAAoB,YAAY,8BAA8B;AAD1C,OAAA,cAAA;AAE1B,OAAK,OAAO;;;AAIhB,IAAa,iBAAb,MAA4B;CAC1B,QAAqC;CACrC,WAAmB;CACnB,YAAoB;CACpB,mBAA2B;CAC3B;CACA;CAEA;CACA;CACA;CAEA,YACE,MACA,SACA;AAFgB,OAAA,OAAA;AAGhB,OAAK,mBAAmB,QAAQ;AAChC,OAAK,eAAe,QAAQ;AAC5B,OAAK,cAAc,QAAQ,eAAe;;;;;;CAO5C,MAAM,QAAW,IAAkC;AACjD,OAAK,2BAA2B;AAEhC,MAAI,KAAK,UAAU,OACjB,OAAM,IAAI,iBAAiB,KAAK,KAAK;AAGvC,MAAI,KAAK,UAAU,eAAe,KAAK,oBAAoB,KAAK,YAC9D,OAAM,IAAI,iBAAiB,KAAK,KAAK;AAGvC,MAAI,KAAK,UAAU,YACjB,MAAK;AAGP,MAAI;GACF,MAAM,SAAS,MAAM,IAAI;AACzB,QAAK,WAAW;AAChB,UAAO;WACA,OAAO;AACd,QAAK,WAAW;AAChB,SAAM;;;;CAKV,WAAgC;AAC9B,OAAK,2BAA2B;AAChC,SAAO,KAAK;;;CAId,WAAgC;AAC9B,OAAK,2BAA2B;AAChC,SAAO;GACL,UAAU,KAAK;GACf,WAAW,KAAK;GAChB,OAAO,KAAK;GACZ,GAAI,KAAK,cAAc,EAAE,aAAa,KAAK,aAAa,GAAG,EAAE;GAC9D;;;CAIH,QAAc;AACZ,OAAK,QAAQ;AACb,OAAK,WAAW;AAChB,OAAK,YAAY;AACjB,OAAK,mBAAmB;AACxB,OAAK,cAAc,KAAA;AACnB,OAAK,WAAW,KAAA;;CAGlB,YAA0B;AACxB,MAAI,KAAK,UAAU,aAAa;AAE9B,QAAK,QAAQ;AACb,QAAK,WAAW;AAChB,QAAK,mBAAmB;AACxB,QAAK,WAAW,KAAA;;AAElB,OAAK;;CAGP,YAA0B;AACxB,OAAK;AACL,OAAK,8BAAc,IAAI,MAAM;AAE7B,MAAI,KAAK,UAAU,aAAa;AAE9B,QAAK,QAAQ;AACb,QAAK,WAAW,KAAK,KAAK;AAC1B,QAAK,mBAAmB;aACf,KAAK,UAAU,YAAY,KAAK,YAAY,KAAK,kBAAkB;AAC5E,QAAK,QAAQ;AACb,QAAK,WAAW,KAAK,KAAK;;;CAI9B,4BAA0C;AACxC,MAAI,KAAK,UAAU,UAAU,KAAK,YAAY;OACxC,KAAK,KAAK,GAAG,KAAK,YAAY,KAAK,cAAc;AACnD,SAAK,QAAQ;AACb,SAAK,mBAAmB"}
@@ -27,4 +27,4 @@ declare function Cron(expression: string, options?: {
27
27
  declare function getCronJobs(target: any): CronJobMeta[];
28
28
  //#endregion
29
29
  export { getCronJobs as i, Cron as n, CronJobMeta as r, CRON_META as t };
30
- //# sourceMappingURL=cron-RKhH5TOd.d.mts.map
30
+ //# sourceMappingURL=cron-C29iHvHT.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cron-RKhH5TOd.d.mts","names":[],"sources":["../src/core/cron.ts"],"mappings":";;cAEM,SAAA;AAAA,UAEW,WAAA;EACf,UAAA;EACA,WAAA;EACA,WAAA;EACA,QAAA;EACA,SAAA;AAAA;;;;;;;;;;AAqBF;iBAAgB,IAAA,CACd,UAAA,UACA,OAAA;EAAY,WAAA;EAAsB,QAAA;EAAmB,SAAA;AAAA,IACpD,eAAA;;iBAaa,WAAA,CAAY,MAAA,QAAc,WAAA"}
1
+ {"version":3,"file":"cron-C29iHvHT.d.mts","names":[],"sources":["../src/core/cron.ts"],"mappings":";;cAEM,SAAA;AAAA,UAEW,WAAA;EACf,UAAA;EACA,WAAA;EACA,WAAA;EACA,QAAA;EACA,SAAA;AAAA;;;;;;;;;;AAqBF;iBAAgB,IAAA,CACd,UAAA,UACA,OAAA;EAAY,WAAA;EAAsB,QAAA;EAAmB,SAAA;AAAA,IACpD,eAAA;;iBAaa,WAAA,CAAY,MAAA,QAAc,WAAA"}
@@ -1,5 +1,5 @@
1
1
 
2
- import { l as ServiceOptions } from "./interfaces-D-48zotH.mjs";
2
+ import { l as ServiceOptions } from "./interfaces-D5ohYl6D.mjs";
3
3
  //#region src/core/decorators.d.ts
4
4
  /** Mark a class as injectable with lifecycle scope */
5
5
  declare function Injectable(options?: ServiceOptions): ClassDecorator;
@@ -29,6 +29,50 @@ declare function Autowired(token?: any): PropertyDecorator;
29
29
  * For property injection with a token, use `@Autowired(token)` instead.
30
30
  */
31
31
  declare function Inject(token: any): ParameterDecorator;
32
+ /**
33
+ * Global ambient registry of typed environment variables, populated by
34
+ * `kick typegen` from the project's env schema (typically
35
+ * `src/env.ts`'s `export default defineEnv(...)`).
36
+ *
37
+ * Empty by default — declarations come from `.kickjs/types/env.ts`
38
+ * generated alongside the rest of the typegen output. Once populated,
39
+ * `@Value('PORT')` autocompletes the key, type-checks the default
40
+ * value, and `process.env.PORT` is also typed via the parallel
41
+ * `NodeJS.ProcessEnv` augmentation in the same generated file.
42
+ */
43
+ declare global {
44
+ interface KickEnv {}
45
+ }
46
+ /** A string key known to the typed env registry (`never` until typegen runs) */
47
+ type EnvKey = keyof KickEnv & string;
48
+ /**
49
+ * Look up the type of a typed env entry.
50
+ *
51
+ * Decorators can't propagate the property type from the key, so users
52
+ * still need to write the property's type — but `Env<K>` lets them
53
+ * derive it from `KickEnv` instead of duplicating the schema:
54
+ *
55
+ * ```ts
56
+ * @Service()
57
+ * class MyService {
58
+ * @Value('PORT')
59
+ * private port!: Env<'PORT'> // → number, narrowed from KickEnv['PORT']
60
+ * }
61
+ * ```
62
+ */
63
+ type Env<K extends EnvKey = EnvKey> = KickEnv[K];
64
+ /**
65
+ * Constraint that allows any string when the typed env registry is
66
+ * empty (no `kick typegen` has run yet, so existing code with raw
67
+ * string keys keeps working) but locks the argument down to known
68
+ * `EnvKey` literals once the registry is populated.
69
+ *
70
+ * Implementation: when `EnvKey` is `never`, the conditional resolves
71
+ * to the user's `K`, accepting anything. Once typegen has populated
72
+ * `KickEnv`, `EnvKey` becomes a real union and the conditional forces
73
+ * `K` to be assignable to it.
74
+ */
75
+ type ValueKey<K extends string> = [EnvKey] extends [never] ? K : K & EnvKey;
32
76
  /**
33
77
  * Inject an environment variable value. Evaluated lazily so the env
34
78
  * is available at access time, not at decoration time.
@@ -37,8 +81,14 @@ declare function Inject(token: any): ParameterDecorator;
37
81
  * to catch misconfiguration early instead of returning undefined.
38
82
  *
39
83
  * Uses metadata + instance getter to work correctly with `useDefineForClassFields`.
84
+ *
85
+ * Type-safety:
86
+ * - Without `kick typegen` run, any string key is accepted (back-compat).
87
+ * - After typegen, `KickEnv` is populated and unknown keys become a tsc
88
+ * error. The optional `defaultValue` is type-checked against the
89
+ * schema's inferred type for that key.
40
90
  */
41
- declare function Value(envKey: string, defaultValue?: any): PropertyDecorator;
91
+ declare function Value<K extends string>(envKey: ValueKey<K>, defaultValue?: K extends EnvKey ? KickEnv[K] : unknown): PropertyDecorator;
42
92
  interface RouteDefinition {
43
93
  method: string;
44
94
  path: string;
@@ -150,5 +200,5 @@ declare function FileUpload(config: FileUploadConfig): MethodDecorator;
150
200
  /** Add a static builder() method for fluent construction */
151
201
  declare function Builder(target: any): void;
152
202
  //#endregion
153
- export { RouteDefinition as C, normalizeApiQueryParamsConfig as E, Repository as S, Value as T, MiddlewareHandler as _, Builder as a, PostConstruct as b, Controller as c, FileUpload as d, FileUploadConfig as f, Middleware as g, Injectable as h, BaseUploadOptions as i, Delete as l, Inject as m, ApiQueryParamsConfig as n, ColumnApiQueryParamsConfig as o, Get as p, Autowired as r, Component as s, ApiQueryParams as t, FileTypeFilter as u, Patch as v, Service as w, Put as x, Post as y };
154
- //# sourceMappingURL=decorators-CQ93ak6Z.d.mts.map
203
+ export { Put as C, Value as D, Service as E, normalizeApiQueryParamsConfig as O, PostConstruct as S, RouteDefinition as T, Injectable as _, Builder as a, Patch as b, Controller as c, EnvKey as d, FileTypeFilter as f, Inject as g, Get as h, BaseUploadOptions as i, Delete as l, FileUploadConfig as m, ApiQueryParamsConfig as n, ColumnApiQueryParamsConfig as o, FileUpload as p, Autowired as r, Component as s, ApiQueryParams as t, Env as u, Middleware as v, Repository as w, Post as x, MiddlewareHandler as y };
204
+ //# sourceMappingURL=decorators-D3lBlmud.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorators-D3lBlmud.d.mts","names":[],"sources":["../src/core/decorators.ts"],"mappings":";;;;iBA8EgB,UAAA,CAAW,OAAA,GAAU,cAAA,GAAiB,cAAA;AAAtD;AAAA,iBAQgB,OAAA,CAAQ,OAAA,GAAU,cAAA,GAAiB,cAAA;;iBAQnC,SAAA,CAAU,OAAA,GAAU,cAAA,GAAiB,cAAA;;iBAQrC,UAAA,CAAW,OAAA,GAAU,cAAA,GAAiB,cAAA;;;;AAhBtD;;;;;iBA+BgB,UAAA,CAAW,IAAA,YAAgB,cAAA;;iBAW3B,aAAA,CAAA,GAAiB,eAAA;;iBASjB,SAAA,CAAU,KAAA,SAAc,iBAAA;;;;;;;iBAYxB,MAAA,CAAO,KAAA,QAAa,kBAAA;;AA/CpC;;;;;;;;;AAeA;QAiDQ,MAAA;EAAA,UAEI,OAAA;AAAA;AAxCZ;AAAA,KA4CY,MAAA,SAAe,OAAA;;;;AAnC3B;;;;;AAYA;;;;;AAIC;;KAoCW,GAAA,WAAc,MAAA,GAAS,MAAA,IAAU,OAAA,CAAQ,CAAA;;;;AAjBrD;;;;;AAiBA;;;KAaK,QAAA,sBAA8B,MAAA,oBAA0B,CAAA,GAAI,CAAA,GAAI,MAAA;;;;;;;;;;;;;AAbd;;;iBA8BvC,KAAA,kBAAA,CACd,MAAA,EAAQ,QAAA,CAAS,CAAA,GACj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HhB,YAAA,GAAe,cAAA;EA3HA;EA6Hf,aAAA,GAAgB,MAAA;AAAA;AAAA,UAGD,gBAAA,SAAyB,iBAAA;EACxC,IAAA;EA7HA;EA+HA,SAAA;EA7HU;EA+HV,QAAA;AAAA;;iBAIc,UAAA,CAAW,MAAA,EAAQ,gBAAA,GAAmB,eAAA;;iBAStC,OAAA,CAAQ,MAAA"}
@@ -65,4 +65,4 @@ declare class HttpException extends Error {
65
65
  }
66
66
  //#endregion
67
67
  export { ValidationError as i, HttpStatus as n, HttpStatusCode as r, HttpException as t };
68
- //# sourceMappingURL=errors-te5Km00o.d.mts.map
68
+ //# sourceMappingURL=errors-BZUdxtjC.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors-te5Km00o.d.mts","names":[],"sources":["../src/core/errors.ts"],"mappings":";;;AAUA;;;;;;;;;cAAa,UAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;KAmCD,cAAA,WAAyB,UAAA,eAAyB,UAAA;;UAG7C,eAAA;EACf,KAAA;EACA,OAAA;EACA,IAAA;AAAA;;;AAOF;;cAAa,aAAA,SAAsB,KAAA;EAAA,SAEf,MAAA;EAAA,SAEA,OAAA,GAAU,eAAA;cAFV,MAAA,UAChB,OAAA,UACgB,OAAA,GAAU,eAAA;EAsBa;EAAA,OAflC,YAAA,CAAa,KAAA,OAAY,OAAA,YAAmB,aAAA;EAAA,OAe5C,UAAA,CAAW,OAAA,YAAuB,aAAA;EAAA,OAGlC,YAAA,CAAa,OAAA,YAAwB,aAAA;EAAA,OAGrC,SAAA,CAAU,OAAA,YAAqB,aAAA;EAAA,OAG/B,QAAA,CAAS,OAAA,YAAqB,aAAA;EAAA,OAG9B,QAAA,CAAS,OAAA,YAAoB,aAAA;EAAA,OAG7B,aAAA,CAAc,OAAA,WAAkC,OAAA,GAAU,eAAA,KAAiB,aAAA;EAAA,OAG3E,eAAA,CAAgB,OAAA,YAA6B,aAAA;EAAA,OAG7C,QAAA,CAAS,OAAA,YAAiC,aAAA;AAAA"}
1
+ {"version":3,"file":"errors-BZUdxtjC.d.mts","names":[],"sources":["../src/core/errors.ts"],"mappings":";;;AAUA;;;;;;;;;cAAa,UAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;KAmCD,cAAA,WAAyB,UAAA,eAAyB,UAAA;;UAG7C,eAAA;EACf,KAAA;EACA,OAAA;EACA,IAAA;AAAA;;;AAOF;;cAAa,aAAA,SAAsB,KAAA;EAAA,SAEf,MAAA;EAAA,SAEA,OAAA,GAAU,eAAA;cAFV,MAAA,UAChB,OAAA,UACgB,OAAA,GAAU,eAAA;EAsBa;EAAA,OAflC,YAAA,CAAa,KAAA,OAAY,OAAA,YAAmB,aAAA;EAAA,OAe5C,UAAA,CAAW,OAAA,YAAuB,aAAA;EAAA,OAGlC,YAAA,CAAa,OAAA,YAAwB,aAAA;EAAA,OAGrC,SAAA,CAAU,OAAA,YAAqB,aAAA;EAAA,OAG/B,QAAA,CAAS,OAAA,YAAqB,aAAA;EAAA,OAG9B,QAAA,CAAS,OAAA,YAAoB,aAAA;EAAA,OAG7B,aAAA,CAAc,OAAA,WAAkC,OAAA,GAAU,eAAA,KAAiB,aAAA;EAAA,OAG3E,eAAA,CAAgB,OAAA,YAA6B,aAAA;EAAA,OAG7C,QAAA,CAAS,OAAA,YAAiC,aAAA;AAAA"}
@@ -1,8 +1,8 @@
1
1
 
2
- import { t as Container } from "../container-nBSIhyqV.mjs";
3
- import { r as AppAdapter } from "../adapter-BqGjZCSm.mjs";
4
- import { n as AppModuleClass } from "../app-module-CcEbAVtB.mjs";
5
- import { t as KickPlugin } from "../plugin-DIoPIpSm.mjs";
2
+ import { t as Container } from "../container-CcgV8eHL.mjs";
3
+ import { r as AppAdapter } from "../adapter-wuoBNkNs.mjs";
4
+ import { n as AppModuleClass } from "../app-module-DOBmxARW.mjs";
5
+ import { t as KickPlugin } from "../plugin-D20muJwC.mjs";
6
6
  import http from "node:http";
7
7
  import { Express, RequestHandler } from "express";
8
8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AAA,QAphBpB,iBAAA;;UAEA,SAAA;;UAEA,kBAAA;;UAEA,eAAA;cAEqB,OAAA,EAAS,kBAAA;;MAyBlC,UAAA,CAAA;;MAKA,gBAAA,CAAA;;EAKJ,YAAA,CAAA,GAAgB,SAAA;;;;;;;;;;;;;;;EAkBhB,MAAA,CAAO,GAAA,EAAK,IAAA,CAAK,eAAA,EAAiB,GAAA,EAAK,IAAA,CAAK,cAAA,EAAgB,IAAA,IAAQ,GAAA;;;;;;;;;;;;;;;UAsB5D,UAAA;;UAYM,QAAA;EAeR,KAAA,CAAA,GAAS,OAAA;;EAwKT,YAAA,CAAA,GAAgB,OAAA;;;;;;;;;;EAahB,KAAA,CAAA,GAAS,OAAA;;EAkET,OAAA,CAAA,GAAW,OAAA;;;;;;;;;;;EAoCX,QAAA,CAAA,GAAY,OAAA;EAgElB,aAAA,CAAA,GAAiB,OAAA;;EAKjB,WAAA,CAAA,GAAe,UAAA;EAIf,aAAA,CAAA,GAAiB,IAAA,CAAK,MAAA;EAAA,QAMd,wBAAA;EAAA,QAmBA,mBAAA;EAAA,QAUA,oBAAA;;UASA,yBAAA;;UAsBA,oBAAA;AAAA"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs v2.1.0
2
+ * @forinda/kickjs v2.2.1
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -8,5 +8,5 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import { t as Application } from "../application-DNHj-_UL.mjs";
11
+ import { t as Application } from "../application-cYhTEy84.mjs";
12
12
  export { Application };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs v2.1.0
2
+ * @forinda/kickjs v2.2.1
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -8,5 +8,5 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import { t as bootstrap } from "../bootstrap-DLEZaJ3b.mjs";
11
+ import { t as bootstrap } from "../bootstrap-8_iBHhWp.mjs";
12
12
  export { bootstrap };
@@ -1,9 +1,22 @@
1
1
 
2
- import { h as QueryFieldConfig, p as ParsedQuery } from "../index-Cls52etj.mjs";
2
+ import { g as QueryFieldConfig, y as TypedParsedQuery } from "../index-rnK23QBD.mjs";
3
3
  import * as _$node_http0 from "node:http";
4
4
  import { NextFunction, Request, Response } from "express";
5
5
 
6
6
  //#region src/http/context.d.ts
7
+ /**
8
+ * The shape of a single route entry in `KickRoutes`. Generated by
9
+ * `kick typegen` and consumed via the `Ctx<T>` helper. Each field is
10
+ * `unknown` by default and is filled in as the typegen learns more
11
+ * about the route (URL params from the path, body/query from validation
12
+ * schemas, etc.).
13
+ */
14
+ interface RouteShape {
15
+ params?: unknown;
16
+ body?: unknown;
17
+ query?: unknown;
18
+ response?: unknown;
19
+ }
7
20
  /**
8
21
  * Unified request/response abstraction passed to every controller method.
9
22
  * Shields handlers from raw Express objects and provides convenience methods.
@@ -30,6 +43,11 @@ declare class RequestContext<TBody = any, TParams = any, TQuery = any> {
30
43
  * Parse the request query string into structured filters, sort, pagination, and search.
31
44
  * Pass the result to an ORM query builder adapter (Drizzle, Prisma, Sequelize, etc.).
32
45
  *
46
+ * Generic over the field config: when passed an inline literal (or
47
+ * `as const`), `filters[].field` and `sort[].field` are narrowed to
48
+ * the exact whitelisted field names. Pass nothing or a non-literal
49
+ * config and you get the loose `string` fallback.
50
+ *
33
51
  * @param fieldConfig - Optional whitelist for filterable, sortable, and searchable fields
34
52
  *
35
53
  * @example
@@ -39,13 +57,13 @@ declare class RequestContext<TBody = any, TParams = any, TQuery = any> {
39
57
  * const parsed = ctx.qs({
40
58
  * filterable: ['status', 'priority'],
41
59
  * sortable: ['createdAt', 'title'],
42
- * })
43
- * const q = drizzleAdapter.build(parsed, { columns })
44
- * // ... use q.where, q.orderBy, q.limit, q.offset
60
+ * } as const)
61
+ * parsed.filters[0].field // typed as 'status' | 'priority'
62
+ * parsed.sort[0].field // typed as 'createdAt' | 'title'
45
63
  * }
46
64
  * ```
47
65
  */
48
- qs(fieldConfig?: QueryFieldConfig): ParsedQuery;
66
+ qs<TConfig extends QueryFieldConfig | undefined = undefined>(fieldConfig?: TConfig): TypedParsedQuery<TConfig>;
49
67
  /** Single uploaded file (requires @FileUpload({ mode: 'single' })) */
50
68
  get file(): any;
51
69
  /** Array of uploaded files (requires @FileUpload({ mode: 'array' })) */
@@ -97,10 +115,10 @@ declare class RequestContext<TBody = any, TParams = any, TQuery = any> {
97
115
  * }
98
116
  * ```
99
117
  */
100
- paginate<T>(fetcher: (parsed: ParsedQuery) => Promise<{
118
+ paginate<T, TConfig extends QueryFieldConfig | undefined = undefined>(fetcher: (parsed: TypedParsedQuery<TConfig>) => Promise<{
101
119
  data: T[];
102
120
  total: number;
103
- }>, fieldConfig?: QueryFieldConfig): Promise<Response<any, Record<string, any>>>;
121
+ }>, fieldConfig?: TConfig): Promise<Response<any, Record<string, any>>>;
104
122
  /**
105
123
  * Start an SSE (Server-Sent Events) stream.
106
124
  * Sets the correct headers and returns helpers to send events.
@@ -126,6 +144,47 @@ declare class RequestContext<TBody = any, TParams = any, TQuery = any> {
126
144
  close: () => void;
127
145
  };
128
146
  }
147
+ /**
148
+ * Short alias for `RequestContext` parameterised by a route shape.
149
+ *
150
+ * Use this with `kick typegen`'s generated `KickRoutes` global namespace
151
+ * to get fully-typed `ctx.params`, `ctx.body`, and `ctx.query` from a
152
+ * single annotation:
153
+ *
154
+ * ```ts
155
+ * @Get('/:id')
156
+ * getUser(ctx: Ctx<KickRoutes.UserController['getUser']>) {
157
+ * ctx.params.id // typed
158
+ * ctx.body // typed (or never if no body schema)
159
+ * ctx.query.page // typed
160
+ * }
161
+ * ```
162
+ *
163
+ * `Ctx<>` (no arg) is equivalent to the loose `RequestContext`.
164
+ *
165
+ * Backward compat: existing handlers using `ctx: RequestContext` keep
166
+ * working untouched. `Ctx<T>` is opt-in.
167
+ */
168
+ type Ctx<TRoute extends RouteShape = RouteShape> = RequestContext<TRoute extends {
169
+ body: infer B;
170
+ } ? B : any, TRoute extends {
171
+ params: infer P;
172
+ } ? P : any, TRoute extends {
173
+ query: infer Q;
174
+ } ? Q : any>;
175
+ /**
176
+ * Global ambient registry of typed routes, populated by `kick typegen`.
177
+ *
178
+ * Each interface inside `KickRoutes` corresponds to a controller class;
179
+ * each property is one route method on that controller. The values
180
+ * conform to `RouteShape`.
181
+ *
182
+ * Empty by default — declarations come from `.kickjs/types/routes.d.ts`
183
+ * generated alongside the rest of the typegen output.
184
+ */
185
+ declare global {
186
+ namespace KickRoutes {}
187
+ } //# sourceMappingURL=context.d.ts.map
129
188
  //#endregion
130
- export { RequestContext };
189
+ export { Ctx, RequestContext, RouteShape };
131
190
  //# sourceMappingURL=context.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.mts","names":[],"sources":["../../src/http/context.ts"],"mappings":";;;;;;;;;AAYA;cAAa,cAAA;EAAA,SAEO,GAAA,EAAK,OAAA;EAAA,SACL,GAAA,EAAK,QAAA;EAAA,SACL,IAAA,EAAM,YAAA;cAFN,GAAA,EAAK,OAAA,EACL,GAAA,EAAK,QAAA,EACL,IAAA,EAAM,YAAA;EAFD;;;;;EAAA,YAUX,QAAA,CAAA;EAAA,IAQR,IAAA,CAAA,GAAQ,KAAA;EAAA,IAIR,MAAA,CAAA,GAAU,OAAA;EAAA,IAIV,KAAA,CAAA,GAAS,MAAA;EAAA,IAIT,OAAA,CAAA,GAJe,YAAA,CAIR,mBAAA;EAAA,IAIP,SAAA,CAAA;EA0DwB;EAAA,IArDxB,OAAA,CAAA;EAyDa;;;;;;;;;;;;;;;;;;;EAhCjB,EAAA,CAAG,WAAA,GAAc,gBAAA,GAAmB,WAAA;EAqGJ;EAAA,IA9F5B,IAAA,CAAA;EAzEsB;EAAA,IA8EtB,KAAA,CAAA;EAMJ,GAAA,SAAA,CAAa,GAAA,WAAc,CAAA;EAI3B,GAAA,CAAI,GAAA,UAAa,KAAA;EAMjB,IAAA,CAAK,IAAA,OAAW,MAAA,YAAY,Q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xB,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,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs v2.1.0
2
+ * @forinda/kickjs v2.2.1
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import { i as parseQuery } from "../query-7cdHF6ry.mjs";
11
+ import { i as parseQuery } from "../query-BSIApo6Y.mjs";
12
12
  //#region src/http/context.ts
13
13
  /**
14
14
  * Unified request/response abstraction passed to every controller method.
@@ -53,6 +53,11 @@ var RequestContext = class {
53
53
  * Parse the request query string into structured filters, sort, pagination, and search.
54
54
  * Pass the result to an ORM query builder adapter (Drizzle, Prisma, Sequelize, etc.).
55
55
  *
56
+ * Generic over the field config: when passed an inline literal (or
57
+ * `as const`), `filters[].field` and `sort[].field` are narrowed to
58
+ * the exact whitelisted field names. Pass nothing or a non-literal
59
+ * config and you get the loose `string` fallback.
60
+ *
56
61
  * @param fieldConfig - Optional whitelist for filterable, sortable, and searchable fields
57
62
  *
58
63
  * @example
@@ -62,9 +67,9 @@ var RequestContext = class {
62
67
  * const parsed = ctx.qs({
63
68
  * filterable: ['status', 'priority'],
64
69
  * sortable: ['createdAt', 'title'],
65
- * })
66
- * const q = drizzleAdapter.build(parsed, { columns })
67
- * // ... use q.where, q.orderBy, q.limit, q.offset
70
+ * } as const)
71
+ * parsed.filters[0].field // typed as 'status' | 'priority'
72
+ * parsed.sort[0].field // typed as 'createdAt' | 'title'
68
73
  * }
69
74
  * ```
70
75
  */