@forinda/kickjs 5.3.0 → 5.5.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 (122) hide show
  1. package/dist/{adapter-C1w_xt08.d.mts → adapter-0r2uRCD3.d.mts} +2 -2
  2. package/dist/{adapter-C1w_xt08.d.mts.map → adapter-0r2uRCD3.d.mts.map} +1 -1
  3. package/dist/app-module-CzlIIjO3.d.mts +92 -0
  4. package/dist/app-module-CzlIIjO3.d.mts.map +1 -0
  5. package/dist/{application-BTRI4aBd.d.mts → application-CaEYca9E.d.mts} +34 -7
  6. package/dist/application-CaEYca9E.d.mts.map +1 -0
  7. package/dist/application-Zt956jNS.mjs +12 -0
  8. package/dist/application-Zt956jNS.mjs.map +1 -0
  9. package/dist/bootstrap-CmFQq1ar.mjs +12 -0
  10. package/dist/{bootstrap-kPcmbbWe.mjs.map → bootstrap-CmFQq1ar.mjs.map} +1 -1
  11. package/dist/{bootstrap-B4YrBipl.d.mts → bootstrap-Db8k2-21.d.mts} +2 -2
  12. package/dist/{bootstrap-B4YrBipl.d.mts.map → bootstrap-Db8k2-21.d.mts.map} +1 -1
  13. package/dist/config/index.mjs +2 -4
  14. package/dist/config-DDz5LuWw.mjs +12 -0
  15. package/dist/{config-DxEREQmR.mjs.map → config-DDz5LuWw.mjs.map} +1 -1
  16. package/dist/container-DrioVLNv.mjs +12 -0
  17. package/dist/{container-SMnB5yeT.mjs.map → container-DrioVLNv.mjs.map} +1 -1
  18. package/dist/context-B4BeGq1B.mjs +12 -0
  19. package/dist/context-B4BeGq1B.mjs.map +1 -0
  20. package/dist/{context-Ymvv-85x.d.mts → context-BAdAV-zO.d.mts} +48 -11
  21. package/dist/context-BAdAV-zO.d.mts.map +1 -0
  22. package/dist/{context-decorator-Bca_BoRK.d.mts → context-decorator-BgdDd-6X.d.mts} +19 -4
  23. package/dist/{context-decorator-Bca_BoRK.d.mts.map → context-decorator-BgdDd-6X.d.mts.map} +1 -1
  24. package/dist/core/adapter.d.mts +1 -1
  25. package/dist/core/adapter.mjs +2 -2
  26. package/dist/core/app-module.d.mts +2 -2
  27. package/dist/core/app-module.mjs +2 -2
  28. package/dist/core/cache.mjs +2 -103
  29. package/dist/core/cache.mjs.map +1 -1
  30. package/dist/core/container.mjs +2 -3
  31. package/dist/core/cron.mjs +2 -32
  32. package/dist/core/cron.mjs.map +1 -1
  33. package/dist/core/decorators.mjs +2 -285
  34. package/dist/core/decorators.mjs.map +1 -1
  35. package/dist/core/errors.mjs +2 -110
  36. package/dist/core/errors.mjs.map +1 -1
  37. package/dist/core/interfaces.mjs +2 -53
  38. package/dist/core/interfaces.mjs.map +1 -1
  39. package/dist/core/logger.mjs +2 -207
  40. package/dist/core/logger.mjs.map +1 -1
  41. package/dist/core/path.mjs +2 -35
  42. package/dist/core/path.mjs.map +1 -1
  43. package/dist/core/plugin.d.mts +1 -1
  44. package/dist/core/plugin.mjs +2 -2
  45. package/dist/core/reactivity.mjs +2 -179
  46. package/dist/core/reactivity.mjs.map +1 -1
  47. package/dist/core-MvABl8Cl.mjs +13 -0
  48. package/dist/core-MvABl8Cl.mjs.map +1 -0
  49. package/dist/env-CObTuGZ3.mjs +12 -0
  50. package/dist/{env-C4Yr6nN8.mjs.map → env-CObTuGZ3.mjs.map} +1 -1
  51. package/dist/http/application.d.mts +1 -1
  52. package/dist/http/application.mjs +2 -3
  53. package/dist/http/bootstrap.d.mts +1 -1
  54. package/dist/http/bootstrap.mjs +2 -3
  55. package/dist/http/context.d.mts +2 -2
  56. package/dist/http/context.mjs +2 -3
  57. package/dist/http/middleware/cors.mjs +2 -73
  58. package/dist/http/middleware/cors.mjs.map +1 -1
  59. package/dist/http/middleware/csrf.mjs +2 -62
  60. package/dist/http/middleware/csrf.mjs.map +1 -1
  61. package/dist/http/middleware/error-handler.mjs +2 -54
  62. package/dist/http/middleware/error-handler.mjs.map +1 -1
  63. package/dist/http/middleware/helmet.mjs +2 -41
  64. package/dist/http/middleware/helmet.mjs.map +1 -1
  65. package/dist/http/middleware/rate-limit.mjs +2 -91
  66. package/dist/http/middleware/rate-limit.mjs.map +1 -1
  67. package/dist/http/middleware/request-id.mjs +2 -25
  68. package/dist/http/middleware/request-id.mjs.map +1 -1
  69. package/dist/http/middleware/request-logger.mjs +2 -39
  70. package/dist/http/middleware/request-logger.mjs.map +1 -1
  71. package/dist/http/middleware/session.mjs +2 -167
  72. package/dist/http/middleware/session.mjs.map +1 -1
  73. package/dist/http/middleware/spa.d.mts +1 -1
  74. package/dist/http/middleware/spa.mjs +2 -98
  75. package/dist/http/middleware/spa.mjs.map +1 -1
  76. package/dist/http/middleware/upload.mjs +2 -181
  77. package/dist/http/middleware/upload.mjs.map +1 -1
  78. package/dist/http/middleware/validate.mjs +2 -68
  79. package/dist/http/middleware/validate.mjs.map +1 -1
  80. package/dist/http/middleware/views.d.mts +1 -1
  81. package/dist/http/middleware/views.mjs +2 -56
  82. package/dist/http/middleware/views.mjs.map +1 -1
  83. package/dist/http/query/index.mjs +2 -3
  84. package/dist/http/router-builder.d.mts +1 -1
  85. package/dist/http/router-builder.mjs +2 -105
  86. package/dist/http/router-builder.mjs.map +1 -1
  87. package/dist/{index-DvZfBNIf.d.mts → index-D-Wb23e6.d.mts} +264 -86
  88. package/dist/index-D-Wb23e6.d.mts.map +1 -0
  89. package/dist/index.d.mts +12 -12
  90. package/dist/index.mjs +2 -171
  91. package/dist/index.mjs.map +1 -1
  92. package/dist/metadata-WTmSU6Sf.mjs +12 -0
  93. package/dist/{metadata-CdYaU-XM.mjs.map → metadata-WTmSU6Sf.mjs.map} +1 -1
  94. package/dist/{plugin-DF8Xfv9Z.d.mts → plugin-JMkG7soG.d.mts} +102 -8
  95. package/dist/plugin-JMkG7soG.d.mts.map +1 -0
  96. package/dist/query-BmO0aBf6.mjs +12 -0
  97. package/dist/{query-nAYUgagU.mjs.map → query-BmO0aBf6.mjs.map} +1 -1
  98. package/dist/{router-builder-C7sXk_FG.d.mts → router-builder-CaQ629tw.d.mts} +2 -2
  99. package/dist/{router-builder-C7sXk_FG.d.mts.map → router-builder-CaQ629tw.d.mts.map} +1 -1
  100. package/dist/{spa-e4FIS2RB.d.mts → spa-CreyQc4N.d.mts} +2 -2
  101. package/dist/{spa-e4FIS2RB.d.mts.map → spa-CreyQc4N.d.mts.map} +1 -1
  102. package/dist/{views-DkNp9JJs.d.mts → views-1e3jQr5C.d.mts} +4 -4
  103. package/dist/{views-DkNp9JJs.d.mts.map → views-1e3jQr5C.d.mts.map} +1 -1
  104. package/package.json +2 -2
  105. package/dist/app-module-D6zL_V5S.d.mts +0 -50
  106. package/dist/app-module-D6zL_V5S.d.mts.map +0 -1
  107. package/dist/application-BTRI4aBd.d.mts.map +0 -1
  108. package/dist/application-Cna_2gex.mjs +0 -574
  109. package/dist/application-Cna_2gex.mjs.map +0 -1
  110. package/dist/bootstrap-kPcmbbWe.mjs +0 -195
  111. package/dist/config-DxEREQmR.mjs +0 -135
  112. package/dist/container-SMnB5yeT.mjs +0 -897
  113. package/dist/context-B0B3WQft.mjs +0 -348
  114. package/dist/context-B0B3WQft.mjs.map +0 -1
  115. package/dist/context-Ymvv-85x.d.mts.map +0 -1
  116. package/dist/core--a4XflX7.mjs +0 -820
  117. package/dist/core--a4XflX7.mjs.map +0 -1
  118. package/dist/env-C4Yr6nN8.mjs +0 -137
  119. package/dist/index-DvZfBNIf.d.mts.map +0 -1
  120. package/dist/metadata-CdYaU-XM.mjs +0 -76
  121. package/dist/plugin-DF8Xfv9Z.d.mts.map +0 -1
  122. package/dist/query-nAYUgagU.mjs +0 -164
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs v5.3.0
2
+ * @forinda/kickjs v5.5.0
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -8,4 +8,4 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- export {};
11
+ export{};
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs v5.3.0
2
+ * @forinda/kickjs v5.5.0
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -8,106 +8,5 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import "reflect-metadata";
12
- //#region src/core/cache.ts
13
- const CACHEABLE_META = "kick/cacheable";
14
- /**
15
- * Default in-memory cache provider using a Map.
16
- * Suitable for development and single-instance deployments.
17
- * For multi-instance or production, use a Redis-backed provider.
18
- */
19
- var MemoryCacheProvider = class {
20
- store = /* @__PURE__ */ new Map();
21
- async get(key) {
22
- const entry = this.store.get(key);
23
- if (!entry) return null;
24
- if (entry.expiresAt <= Date.now()) {
25
- this.store.delete(key);
26
- return null;
27
- }
28
- return entry.data;
29
- }
30
- async set(key, value, ttlMs) {
31
- this.store.set(key, {
32
- data: value,
33
- expiresAt: Date.now() + ttlMs
34
- });
35
- }
36
- async del(key) {
37
- this.store.delete(key);
38
- }
39
- async delByPrefix(prefix) {
40
- for (const key of this.store.keys()) if (key.startsWith(prefix)) this.store.delete(key);
41
- }
42
- async shutdown() {
43
- this.store.clear();
44
- }
45
- };
46
- let _cacheProvider = new MemoryCacheProvider();
47
- /**
48
- * Set the global cache provider used by @Cacheable and @CacheEvict.
49
- * Call this before bootstrapping your app.
50
- *
51
- * @example
52
- * ```ts
53
- * import { setCacheProvider } from '@forinda/kickjs'
54
- * import { RedisCacheProvider } from './redis-cache'
55
- *
56
- * setCacheProvider(new RedisCacheProvider(redisClient))
57
- * ```
58
- */
59
- function setCacheProvider(provider) {
60
- _cacheProvider = provider;
61
- }
62
- /** Get the current cache provider */
63
- function getCacheProvider() {
64
- return _cacheProvider;
65
- }
66
- /**
67
- * Cache the return value of a method for the specified TTL.
68
- * Uses the globally registered CacheProvider (default: MemoryCacheProvider).
69
- *
70
- * Call `setCacheProvider()` to use Redis or any custom backend.
71
- *
72
- * @param ttl - Time-to-live in seconds (default: 60)
73
- * @param options.key - Custom cache key prefix
74
- */
75
- function Cacheable(ttl, options) {
76
- return (_target, propertyKey, descriptor) => {
77
- const original = descriptor.value;
78
- const cacheTtl = (ttl ?? 60) * 1e3;
79
- const keyPrefix = options?.key ?? String(propertyKey);
80
- descriptor.value = async function(...args) {
81
- const cacheKey = `${keyPrefix}:${JSON.stringify(args)}`;
82
- const provider = getCacheProvider();
83
- const cached = await provider.get(cacheKey);
84
- if (cached !== null) return cached;
85
- const result = await original.apply(this, args);
86
- await provider.set(cacheKey, result, cacheTtl);
87
- return result;
88
- };
89
- return descriptor;
90
- };
91
- }
92
- /**
93
- * Evict cached values matching a key prefix after the method executes.
94
- * Works with any CacheProvider that implements `delByPrefix`.
95
- *
96
- * @param key - Cache key prefix to evict (matches the @Cacheable key)
97
- */
98
- function CacheEvict(key) {
99
- return (_target, _propertyKey, descriptor) => {
100
- const original = descriptor.value;
101
- descriptor.value = async function(...args) {
102
- const result = await original.apply(this, args);
103
- const provider = getCacheProvider();
104
- if (provider.delByPrefix) await provider.delByPrefix(key);
105
- return result;
106
- };
107
- return descriptor;
108
- };
109
- }
110
- //#endregion
111
- export { CACHEABLE_META, CacheEvict, Cacheable, MemoryCacheProvider, getCacheProvider, setCacheProvider };
112
-
11
+ import"reflect-metadata";const CACHEABLE_META=`kick/cacheable`;var MemoryCacheProvider=class{store=new Map;async get(key){let entry=this.store.get(key);return entry?entry.expiresAt<=Date.now()?(this.store.delete(key),null):entry.data:null}async set(key,value,ttlMs){this.store.set(key,{data:value,expiresAt:Date.now()+ttlMs})}async del(key){this.store.delete(key)}async delByPrefix(prefix){for(let key of this.store.keys())key.startsWith(prefix)&&this.store.delete(key)}async shutdown(){this.store.clear()}};let _cacheProvider=new MemoryCacheProvider;function setCacheProvider(provider){_cacheProvider=provider}function getCacheProvider(){return _cacheProvider}function Cacheable(ttl,options){return(_target,propertyKey,descriptor)=>{let original=descriptor.value,cacheTtl=(ttl??60)*1e3,keyPrefix=options?.key??String(propertyKey);return descriptor.value=async function(...args){let cacheKey=`${keyPrefix}:${JSON.stringify(args)}`,provider=getCacheProvider(),cached=await provider.get(cacheKey);if(cached!==null)return cached;let result=await original.apply(this,args);return await provider.set(cacheKey,result,cacheTtl),result},descriptor}}function CacheEvict(key){return(_target,_propertyKey,descriptor)=>{let original=descriptor.value;return descriptor.value=async function(...args){let result=await original.apply(this,args),provider=getCacheProvider();return provider.delByPrefix&&await provider.delByPrefix(key),result},descriptor}}export{CACHEABLE_META,CacheEvict,Cacheable,MemoryCacheProvider,getCacheProvider,setCacheProvider};
113
12
  //# sourceMappingURL=cache.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"cache.mjs","names":[],"sources":["../../src/core/cache.ts"],"sourcesContent":["import 'reflect-metadata'\n\n// String metadata key (post-Symbol migration). Slash-delimited\n// `kick/cacheable` so it can't collide with adopter metadata keys.\nconst CACHEABLE_META = '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":";;;;;;;;;;;;AAIA,MAAM,iBAAiB;;;;;;AAgDvB,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
+ {"version":3,"file":"cache.mjs","names":[],"sources":["../../src/core/cache.ts"],"sourcesContent":["import 'reflect-metadata'\n\n// String metadata key (post-Symbol migration). Slash-delimited\n// `kick/cacheable` so it can't collide with adopter metadata keys.\nconst CACHEABLE_META = '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":";;;;;;;;;;yBAIA,MAAM,eAAiB,iBAgDvB,IAAa,oBAAb,KAA0D,CACxD,MAAgB,IAAI,IAEpB,MAAM,IAAI,IAAkC,CAC1C,IAAM,MAAQ,KAAK,MAAM,IAAI,IAAI,CAMjC,OALK,MACD,MAAM,WAAa,KAAK,KAAK,EAC/B,KAAK,MAAM,OAAO,IAAI,CACf,MAEF,MAAM,KALM,KAQrB,MAAM,IAAI,IAAa,MAAY,MAA8B,CAC/D,KAAK,MAAM,IAAI,IAAK,CAAE,KAAM,MAAO,UAAW,KAAK,KAAK,CAAG,MAAO,CAAC,CAGrE,MAAM,IAAI,IAA4B,CACpC,KAAK,MAAM,OAAO,IAAI,CAGxB,MAAM,YAAY,OAA+B,CAC/C,IAAK,IAAM,OAAO,KAAK,MAAM,MAAM,CAC7B,IAAI,WAAW,OAAO,EACxB,KAAK,MAAM,OAAO,IAAI,CAK5B,MAAM,UAA0B,CAC9B,KAAK,MAAM,OAAO,GAMtB,IAAI,eAAgC,IAAI,oBAcxC,SAAgB,iBAAiB,SAA+B,CAC9D,eAAiB,SAInB,SAAgB,kBAAkC,CAChD,OAAO,eAuBT,SAAgB,UAAU,IAAc,QAA6C,CACnF,OAAQ,QAAS,YAAa,aAAmC,CAC/D,IAAM,SAAW,WAAW,MACtB,UAAY,KAAO,IAAM,IACzB,UAAY,SAAS,KAAO,OAAO,YAAY,CAgBrD,MAdA,YAAW,MAAQ,eAAgB,GAAG,KAAa,CACjD,IAAM,SAAW,GAAG,UAAU,GAAG,KAAK,UAAU,KAAK,GAC/C,SAAW,kBAAkB,CAE7B,OAAS,MAAM,SAAS,IAAI,SAAS,CAC3C,GAAI,SAAW,KACb,OAAO,OAGT,IAAM,OAAS,MAAM,SAAS,MAAM,KAAM,KAAK,CAE/C,OADA,MAAM,SAAS,IAAI,SAAU,OAAQ,SAAS,CACvC,QAGF,YAYX,SAAgB,WAAW,IAA8B,CACvD,OAAQ,QAAS,aAAc,aAAmC,CAChE,IAAM,SAAW,WAAW,MAW5B,MATA,YAAW,MAAQ,eAAgB,GAAG,KAAa,CACjD,IAAM,OAAS,MAAM,SAAS,MAAM,KAAM,KAAK,CACzC,SAAW,kBAAkB,CAInC,OAHI,SAAS,aACX,MAAM,SAAS,YAAY,IAAI,CAE1B,QAGF"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs v5.3.0
2
+ * @forinda/kickjs v5.5.0
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -8,5 +8,4 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import { n as tokenName, t as Container } from "../container-SMnB5yeT.mjs";
12
- export { Container, tokenName };
11
+ import{n as tokenName,t as Container}from"../container-DrioVLNv.mjs";export{Container,tokenName};
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs v5.3.0
2
+ * @forinda/kickjs v5.5.0
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -8,35 +8,5 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import { c as pushClassMeta, t as getClassMeta } from "../metadata-CdYaU-XM.mjs";
12
- //#region src/core/cron.ts
13
- const CRON_META = "kick/cron";
14
- /**
15
- * Schedule a method to run on a cron expression.
16
- * Requires a CronAdapter to be registered in bootstrap().
17
- *
18
- * @param expression - Standard 5-part cron: minute hour day month weekday.
19
- * Use forward-slash for intervals (e.g. every 5 min, every 2 hours).
20
- * @param options.description - Human-readable label for logging
21
- * @param options.timezone - IANA timezone (e.g. 'America/New_York', 'UTC')
22
- * @param options.runOnInit - Run immediately on startup before first scheduled tick
23
- */
24
- function Cron(expression, options) {
25
- return (target, propertyKey) => {
26
- pushClassMeta(CRON_META, target.constructor, {
27
- expression,
28
- handlerName: propertyKey,
29
- description: options?.description,
30
- timezone: options?.timezone,
31
- runOnInit: options?.runOnInit
32
- });
33
- };
34
- }
35
- /** Read cron jobs registered on a class */
36
- function getCronJobs(target) {
37
- return getClassMeta(CRON_META, target, []);
38
- }
39
- //#endregion
40
- export { CRON_META, Cron, getCronJobs };
41
-
11
+ import{c as pushClassMeta,t as getClassMeta}from"../metadata-WTmSU6Sf.mjs";const CRON_META=`kick/cron`;function Cron(expression,options){return(target,propertyKey)=>{pushClassMeta(CRON_META,target.constructor,{expression,handlerName:propertyKey,description:options?.description,timezone:options?.timezone,runOnInit:options?.runOnInit})}}function getCronJobs(target){return getClassMeta(CRON_META,target,[])}export{CRON_META,Cron,getCronJobs};
42
12
  //# sourceMappingURL=cron.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"cron.mjs","names":[],"sources":["../../src/core/cron.ts"],"sourcesContent":["import { pushClassMeta, getClassMeta } from './metadata'\n\n// String metadata key (post-Symbol migration). Slash-delimited\n// `kick/cron` so it can't collide with adopter metadata keys.\nconst CRON_META = 'kick/cron'\n\nexport interface CronJobMeta {\n expression: string\n handlerName: string\n description?: string\n timezone?: string\n runOnInit?: boolean\n}\n\n// Cron format: minute hour day month weekday\n// Examples:\n// '* * * * *' - every minute\n// '0 * * * *' - every hour\n// '0 0 * * *' - daily at midnight\n// '0 9 * * MON-FRI' - weekdays at 9am\n// '0 0 1 * *' - first of each month\n\n/**\n * Schedule a method to run on a cron expression.\n * Requires a CronAdapter to be registered in bootstrap().\n *\n * @param expression - Standard 5-part cron: minute hour day month weekday.\n * Use forward-slash for intervals (e.g. every 5 min, every 2 hours).\n * @param options.description - Human-readable label for logging\n * @param options.timezone - IANA timezone (e.g. 'America/New_York', 'UTC')\n * @param options.runOnInit - Run immediately on startup before first scheduled tick\n */\nexport function Cron(\n expression: string,\n options?: { description?: string; timezone?: string; runOnInit?: boolean },\n): MethodDecorator {\n return (target, propertyKey) => {\n pushClassMeta<CronJobMeta>(CRON_META, target.constructor, {\n expression,\n handlerName: propertyKey as string,\n description: options?.description,\n timezone: options?.timezone,\n runOnInit: options?.runOnInit,\n })\n }\n}\n\n/** Read cron jobs registered on a class */\nexport function getCronJobs(target: any): CronJobMeta[] {\n return getClassMeta<CronJobMeta[]>(CRON_META, target, [])\n}\n\nexport { CRON_META }\n"],"mappings":";;;;;;;;;;;;AAIA,MAAM,YAAY;;;;;;;;;;;AA4BlB,SAAgB,KACd,YACA,SACiB;AACjB,SAAQ,QAAQ,gBAAgB;AAC9B,gBAA2B,WAAW,OAAO,aAAa;GACxD;GACA,aAAa;GACb,aAAa,SAAS;GACtB,UAAU,SAAS;GACnB,WAAW,SAAS;GACrB,CAAC;;;;AAKN,SAAgB,YAAY,QAA4B;AACtD,QAAO,aAA4B,WAAW,QAAQ,EAAE,CAAC"}
1
+ {"version":3,"file":"cron.mjs","names":[],"sources":["../../src/core/cron.ts"],"sourcesContent":["import { pushClassMeta, getClassMeta } from './metadata'\n\n// String metadata key (post-Symbol migration). Slash-delimited\n// `kick/cron` so it can't collide with adopter metadata keys.\nconst CRON_META = 'kick/cron'\n\nexport interface CronJobMeta {\n expression: string\n handlerName: string\n description?: string\n timezone?: string\n runOnInit?: boolean\n}\n\n// Cron format: minute hour day month weekday\n// Examples:\n// '* * * * *' - every minute\n// '0 * * * *' - every hour\n// '0 0 * * *' - daily at midnight\n// '0 9 * * MON-FRI' - weekdays at 9am\n// '0 0 1 * *' - first of each month\n\n/**\n * Schedule a method to run on a cron expression.\n * Requires a CronAdapter to be registered in bootstrap().\n *\n * @param expression - Standard 5-part cron: minute hour day month weekday.\n * Use forward-slash for intervals (e.g. every 5 min, every 2 hours).\n * @param options.description - Human-readable label for logging\n * @param options.timezone - IANA timezone (e.g. 'America/New_York', 'UTC')\n * @param options.runOnInit - Run immediately on startup before first scheduled tick\n */\nexport function Cron(\n expression: string,\n options?: { description?: string; timezone?: string; runOnInit?: boolean },\n): MethodDecorator {\n return (target, propertyKey) => {\n pushClassMeta<CronJobMeta>(CRON_META, target.constructor, {\n expression,\n handlerName: propertyKey as string,\n description: options?.description,\n timezone: options?.timezone,\n runOnInit: options?.runOnInit,\n })\n }\n}\n\n/** Read cron jobs registered on a class */\nexport function getCronJobs(target: any): CronJobMeta[] {\n return getClassMeta<CronJobMeta[]>(CRON_META, target, [])\n}\n\nexport { CRON_META }\n"],"mappings":";;;;;;;;;;2EAIA,MAAM,UAAY,YA4BlB,SAAgB,KACd,WACA,QACiB,CACjB,OAAQ,OAAQ,cAAgB,CAC9B,cAA2B,UAAW,OAAO,YAAa,CACxD,WACA,YAAa,YACb,YAAa,SAAS,YACtB,SAAU,SAAS,SACnB,UAAW,SAAS,UACrB,CAAC,EAKN,SAAgB,YAAY,OAA4B,CACtD,OAAO,aAA4B,UAAW,OAAQ,EAAE,CAAC"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs v5.3.0
2
+ * @forinda/kickjs v5.5.0
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -8,288 +8,5 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import { t as Container } from "../container-SMnB5yeT.mjs";
12
- import { METADATA, Scope } from "./interfaces.mjs";
13
- import { c as pushClassMeta, d as setInMetaMap, f as setInMetaRecord, l as pushMethodMeta, p as setMethodMeta, u as setClassMeta } from "../metadata-CdYaU-XM.mjs";
14
- import "reflect-metadata";
15
- //#region src/core/decorators.ts
16
- const pendingRegistrations = [];
17
- const allRegistrations = /* @__PURE__ */ new Map();
18
- let containerRef = null;
19
- function flushPending(container) {
20
- containerRef = container;
21
- for (const { target, scope } of pendingRegistrations) if (!container.has(target)) container.register(target, target, scope);
22
- pendingRegistrations.length = 0;
23
- }
24
- Container._onReady = flushPending;
25
- Container._onReset = (container) => {
26
- containerRef = container;
27
- for (const [, { target, scope }] of allRegistrations) if (!container.has(target)) container.register(target, target, scope);
28
- };
29
- function registerInContainer(target, scope) {
30
- setClassMeta(METADATA.INJECTABLE, true, target);
31
- setClassMeta(METADATA.SCOPE, scope, target);
32
- const name = target.name || String(target);
33
- allRegistrations.set(name, {
34
- target,
35
- scope
36
- });
37
- if (containerRef) {
38
- if (!containerRef.has(target)) containerRef.register(target, target, scope);
39
- } else pendingRegistrations.push({
40
- target,
41
- scope
42
- });
43
- }
44
- /** Mark a class as injectable with lifecycle scope */
45
- function Injectable(options) {
46
- return (target) => {
47
- setClassMeta(METADATA.CLASS_KIND, "injectable", target);
48
- registerInContainer(target, options?.scope ?? Scope.SINGLETON);
49
- };
50
- }
51
- /** Mark a class as a service (semantic alias for Injectable) */
52
- function Service(options) {
53
- return (target) => {
54
- setClassMeta(METADATA.CLASS_KIND, "service", target);
55
- registerInContainer(target, options?.scope ?? Scope.SINGLETON);
56
- };
57
- }
58
- /** Mark a class as a generic managed component */
59
- function Component(options) {
60
- return (target) => {
61
- setClassMeta(METADATA.CLASS_KIND, "component", target);
62
- registerInContainer(target, options?.scope ?? Scope.SINGLETON);
63
- };
64
- }
65
- /** Mark a class as a repository */
66
- function Repository(options) {
67
- return (target) => {
68
- setClassMeta(METADATA.CLASS_KIND, "repository", target);
69
- registerInContainer(target, options?.scope ?? Scope.SINGLETON);
70
- };
71
- }
72
- /**
73
- * Mark a class as an HTTP controller and register it in the DI container.
74
- *
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.
80
- */
81
- function Controller() {
82
- return (target) => {
83
- setClassMeta(METADATA.CLASS_KIND, "controller", target);
84
- registerInContainer(target, Scope.SINGLETON);
85
- };
86
- }
87
- /** Mark a method as a lifecycle hook called after instantiation */
88
- function PostConstruct() {
89
- return (target, propertyKey) => {
90
- setClassMeta(METADATA.POST_CONSTRUCT, propertyKey, target);
91
- };
92
- }
93
- /** Property injection — resolved lazily from the container */
94
- function Autowired(token) {
95
- return (target, propertyKey) => {
96
- setInMetaMap(METADATA.AUTOWIRED, target, propertyKey, token);
97
- };
98
- }
99
- function Inject(token) {
100
- return (target, _propertyKey, parameterIndex) => {
101
- setInMetaRecord(METADATA.INJECT, target, parameterIndex, token);
102
- };
103
- }
104
- /**
105
- * Inject an environment variable value. Evaluated lazily so the env
106
- * is available at access time, not at decoration time.
107
- *
108
- * If no default is provided and the env var is missing, throws at access time
109
- * to catch misconfiguration early instead of returning undefined.
110
- *
111
- * Uses metadata + instance getter to work correctly with `useDefineForClassFields`.
112
- *
113
- * Type-safety:
114
- * - Without `kick typegen` run, any string key is accepted (back-compat).
115
- * - After typegen, `KickEnv` is populated and unknown keys become a tsc
116
- * error. The optional `defaultValue` is type-checked against the
117
- * schema's inferred type for that key.
118
- */
119
- function Value(envKey, defaultValue) {
120
- return (target, propertyKey) => {
121
- setInMetaMap(METADATA.VALUE, target, propertyKey, {
122
- envKey,
123
- defaultValue
124
- });
125
- };
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
- }
165
- function createRouteDecorator(method) {
166
- return (path, validation) => {
167
- return (target, propertyKey) => {
168
- pushClassMeta(METADATA.ROUTES, target.constructor, {
169
- method,
170
- path: path || "/",
171
- handlerName: propertyKey,
172
- validation
173
- });
174
- };
175
- };
176
- }
177
- const Get = createRouteDecorator("GET");
178
- const Post = createRouteDecorator("POST");
179
- const Put = createRouteDecorator("PUT");
180
- const Delete = createRouteDecorator("DELETE");
181
- const Patch = createRouteDecorator("PATCH");
182
- /**
183
- * Normalize a query params config to the string-based ApiQueryParamsConfig.
184
- * Handles both string-based and column-object-based configs.
185
- */
186
- function normalizeApiQueryParamsConfig(config) {
187
- if ("columns" in config && config.columns && typeof config.columns === "object") return {
188
- filterable: Object.keys(config.columns),
189
- sortable: config.sortable ? Object.keys(config.sortable) : void 0,
190
- searchable: config.searchColumns ? config.searchColumns.map((col) => col?.name ?? "").filter(Boolean) : void 0
191
- };
192
- return config;
193
- }
194
- /**
195
- * Document the query parameters accepted by a GET endpoint.
196
- * Used by SwaggerAdapter to generate `filter`, `sort`, `page`, `limit`, and `q` params
197
- * in the OpenAPI spec, with descriptions listing the allowed fields.
198
- *
199
- * Accepts both string-based configs and column-object configs (e.g., DrizzleQueryParamsConfig).
200
- *
201
- * @example
202
- * ```ts
203
- * // String-based
204
- * @ApiQueryParams({
205
- * filterable: ['status', 'category', 'price'],
206
- * sortable: ['name', 'createdAt', 'price'],
207
- * searchable: ['name', 'description'],
208
- * })
209
- *
210
- * // Column-object-based (Drizzle)
211
- * @ApiQueryParams(TASK_QUERY_CONFIG)
212
- * ```
213
- */
214
- function ApiQueryParams(config) {
215
- return (target, propertyKey) => {
216
- const normalized = normalizeApiQueryParamsConfig(config);
217
- setMethodMeta(METADATA.QUERY_PARAMS, normalized, target.constructor, propertyKey);
218
- };
219
- }
220
- /** Attach middleware handlers to a class or method */
221
- function Middleware(...handlers) {
222
- return (target, propertyKey) => {
223
- if (propertyKey) pushMethodMeta(METADATA.METHOD_MIDDLEWARES, target.constructor, propertyKey, ...handlers);
224
- else pushClassMeta(METADATA.CLASS_MIDDLEWARES, target, ...handlers);
225
- };
226
- }
227
- /** Configure file upload handling for a controller method */
228
- function FileUpload(config) {
229
- return (target, propertyKey) => {
230
- setMethodMeta(METADATA.FILE_UPLOAD, config, target.constructor, propertyKey);
231
- };
232
- }
233
- function attachBuilder(target) {
234
- setClassMeta(METADATA.BUILDER, true, target);
235
- target.builder = function() {
236
- const props = {};
237
- const proxy = new Proxy({}, { get(_, key) {
238
- if (key === "build") return () => Object.assign(new target(), props);
239
- return (value) => {
240
- props[key] = value;
241
- return proxy;
242
- };
243
- } });
244
- return proxy;
245
- };
246
- }
247
- /**
248
- * Add a static `builder()` method for fluent construction.
249
- *
250
- * Legacy decorators cannot widen the class type, so by default the
251
- * caller sees the unmodified shape. Opt into typing by adding a single
252
- * `declare static` line:
253
- *
254
- * ```ts
255
- * @Builder
256
- * class UserDto {
257
- * name!: string
258
- * email!: string
259
- * declare static readonly builder: () => BuilderOf<UserDto>
260
- * }
261
- * ```
262
- *
263
- * `readonly` keeps SonarQube's `typescript:S1444` quiet — the runtime
264
- * assigns `target.builder` once at decoration time and never again.
265
- *
266
- * If you'd rather not write the `declare`, use `withBuilder()` instead —
267
- * same runtime, types inferred automatically.
268
- */
269
- function Builder(target) {
270
- attachBuilder(target);
271
- }
272
- /**
273
- * Factory variant of `@Builder`. Wraps the class with the same runtime
274
- * and returns it intersected with `{ builder(): BuilderOf<T> }` so the
275
- * static is fully typed without any `declare` boilerplate.
276
- *
277
- * ```ts
278
- * class UserDtoBase {
279
- * name!: string
280
- * email!: string
281
- * }
282
- * export const UserDto = withBuilder(UserDtoBase)
283
- * export type UserDto = InstanceType<typeof UserDto>
284
- *
285
- * UserDto.builder().name('Alice').email('a@b.com').build() // fully typed
286
- * ```
287
- */
288
- function withBuilder(ctor) {
289
- attachBuilder(ctor);
290
- return ctor;
291
- }
292
- //#endregion
293
- export { ApiQueryParams, Asset, Autowired, Builder, Component, Controller, Delete, FileUpload, Get, Inject, Injectable, Middleware, Patch, Post, PostConstruct, Put, Repository, Service, Value, normalizeApiQueryParamsConfig, withBuilder };
294
-
11
+ import{t as Container}from"../container-DrioVLNv.mjs";import{METADATA}from"./interfaces.mjs";import{c as pushClassMeta,d as setInMetaMap,f as setInMetaRecord,l as pushMethodMeta,p as setMethodMeta,u as setClassMeta}from"../metadata-WTmSU6Sf.mjs";import"reflect-metadata";const pendingRegistrations=[],allRegistrations=new Map;let containerRef=null;function flushPending(container){containerRef=container;for(let{target,scope}of pendingRegistrations)container.has(target)||container.register(target,target,scope);pendingRegistrations.length=0}Container._onReady=flushPending,Container._onReset=container=>{containerRef=container;for(let[,{target,scope}]of allRegistrations)container.has(target)||container.register(target,target,scope)};function registerInContainer(target,scope){setClassMeta(METADATA.INJECTABLE,!0,target),setClassMeta(METADATA.SCOPE,scope,target);let name=target.name||String(target);allRegistrations.set(name,{target,scope}),containerRef?containerRef.has(target)||containerRef.register(target,target,scope):pendingRegistrations.push({target,scope})}function Injectable(options){return target=>{setClassMeta(METADATA.CLASS_KIND,`injectable`,target),registerInContainer(target,options?.scope??`singleton`)}}function Service(options){return target=>{setClassMeta(METADATA.CLASS_KIND,`service`,target),registerInContainer(target,options?.scope??`singleton`)}}function Component(options){return target=>{setClassMeta(METADATA.CLASS_KIND,`component`,target),registerInContainer(target,options?.scope??`singleton`)}}function Repository(options){return target=>{setClassMeta(METADATA.CLASS_KIND,`repository`,target),registerInContainer(target,options?.scope??`singleton`)}}function Controller(){return target=>{setClassMeta(METADATA.CLASS_KIND,`controller`,target),registerInContainer(target,`singleton`)}}function PostConstruct(){return(target,propertyKey)=>{setClassMeta(METADATA.POST_CONSTRUCT,propertyKey,target)}}function Autowired(token){return(target,propertyKey)=>{setInMetaMap(METADATA.AUTOWIRED,target,propertyKey,token)}}function Inject(token){return(target,_propertyKey,parameterIndex)=>{setInMetaRecord(METADATA.INJECT,target,parameterIndex,token)}}function Value(envKey,defaultValue){return(target,propertyKey)=>{setInMetaMap(METADATA.VALUE,target,propertyKey,{envKey,defaultValue})}}function Asset(assetKey){return(target,propertyKey)=>{setInMetaMap(METADATA.ASSET,target,propertyKey,{assetKey})}}function createRouteDecorator(method){return(path,validation)=>(target,propertyKey)=>{pushClassMeta(METADATA.ROUTES,target.constructor,{method,path:path||`/`,handlerName:propertyKey,validation})}}const Get=createRouteDecorator(`GET`),Post=createRouteDecorator(`POST`),Put=createRouteDecorator(`PUT`),Delete=createRouteDecorator(`DELETE`),Patch=createRouteDecorator(`PATCH`);function normalizeApiQueryParamsConfig(config){return`columns`in config&&config.columns&&typeof config.columns==`object`?{filterable:Object.keys(config.columns),sortable:config.sortable?Object.keys(config.sortable):void 0,searchable:config.searchColumns?config.searchColumns.map(col=>col?.name??``).filter(Boolean):void 0}:config}function ApiQueryParams(config){return(target,propertyKey)=>{let normalized=normalizeApiQueryParamsConfig(config);setMethodMeta(METADATA.QUERY_PARAMS,normalized,target.constructor,propertyKey)}}function Middleware(...handlers){return(target,propertyKey)=>{propertyKey?pushMethodMeta(METADATA.METHOD_MIDDLEWARES,target.constructor,propertyKey,...handlers):pushClassMeta(METADATA.CLASS_MIDDLEWARES,target,...handlers)}}function FileUpload(config){return(target,propertyKey)=>{setMethodMeta(METADATA.FILE_UPLOAD,config,target.constructor,propertyKey)}}function attachBuilder(target){setClassMeta(METADATA.BUILDER,!0,target),target.builder=function(){let props={},proxy=new Proxy({},{get(_,key){return key===`build`?()=>Object.assign(new target,props):value=>(props[key]=value,proxy)}});return proxy}}function Builder(target){attachBuilder(target)}function withBuilder(ctor){return attachBuilder(ctor),ctor}export{ApiQueryParams,Asset,Autowired,Builder,Component,Controller,Delete,FileUpload,Get,Inject,Injectable,Middleware,Patch,Post,PostConstruct,Put,Repository,Service,Value,normalizeApiQueryParamsConfig,withBuilder};
295
12
  //# sourceMappingURL=decorators.mjs.map