@catbee/utils 2.0.0-next.0 → 2.0.0-next.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 (97) hide show
  1. package/README.md +52 -16
  2. package/array/index.cjs +180 -71
  3. package/array/index.d.ts +293 -1
  4. package/array/index.mjs +171 -72
  5. package/async/index.cjs +92 -36
  6. package/async/index.d.ts +275 -1
  7. package/async/index.mjs +92 -36
  8. package/cache/index.cjs +1 -1
  9. package/cache/index.d.ts +155 -1
  10. package/cache/index.mjs +2 -2
  11. package/config/index.cjs +78 -64
  12. package/config/index.d.ts +64 -2
  13. package/config/index.mjs +76 -64
  14. package/context-store/index.d.ts +192 -1
  15. package/crypto/index.d.ts +163 -1
  16. package/date/index.cjs +46 -1
  17. package/date/index.d.ts +190 -1
  18. package/date/index.mjs +45 -2
  19. package/decorators/index.cjs +1156 -18
  20. package/decorators/index.d.ts +684 -1
  21. package/decorators/index.mjs +1156 -18
  22. package/dir/index.cjs +4 -3
  23. package/dir/index.d.ts +195 -1
  24. package/dir/index.mjs +4 -3
  25. package/env/index.cjs +10 -26
  26. package/env/index.d.ts +379 -1
  27. package/env/index.mjs +10 -26
  28. package/exception/index.d.ts +232 -1
  29. package/fs/index.cjs +70 -36
  30. package/fs/index.d.ts +205 -1
  31. package/fs/index.mjs +64 -34
  32. package/http-status-codes/index.d.ts +267 -1
  33. package/id/index.d.ts +37 -1
  34. package/index.cjs +3 -3
  35. package/index.d.ts +1 -1
  36. package/index.mjs +1 -1
  37. package/logger/index.cjs +11 -11
  38. package/logger/index.d.ts +189 -1
  39. package/logger/index.mjs +12 -12
  40. package/middleware/index.d.ts +103 -1
  41. package/obj/index.cjs +150 -162
  42. package/obj/index.d.ts +136 -1
  43. package/obj/index.mjs +150 -162
  44. package/package.json +11 -11
  45. package/performance/index.cjs +2 -2
  46. package/performance/index.d.ts +138 -1
  47. package/performance/index.mjs +2 -2
  48. package/request/index.cjs +1 -1
  49. package/request/index.d.ts +241 -2
  50. package/request/index.mjs +1 -1
  51. package/response/index.d.ts +318 -2
  52. package/server/index.cjs +27 -23
  53. package/server/index.d.ts +785 -4
  54. package/server/index.mjs +28 -23
  55. package/stream/index.d.ts +90 -1
  56. package/string/index.d.ts +102 -1
  57. package/type/index.cjs +1 -1
  58. package/type/index.d.ts +107 -1
  59. package/type/index.mjs +1 -1
  60. package/types/index.d.ts +774 -4
  61. package/url/index.cjs +2 -4
  62. package/url/index.d.ts +142 -1
  63. package/url/index.mjs +2 -4
  64. package/{validate → validation}/index.cjs +89 -42
  65. package/{validate/validate.utils.d.ts → validation/index.d.ts} +32 -23
  66. package/{validate → validation}/index.mjs +85 -42
  67. package/array/array.utils.d.ts +0 -191
  68. package/async/async.utils.d.ts +0 -296
  69. package/cache/cache.utils.d.ts +0 -176
  70. package/config/config.d.ts +0 -57
  71. package/context-store/context-store.utils.d.ts +0 -212
  72. package/crypto/crypto.utils.d.ts +0 -183
  73. package/date/date.utils.d.ts +0 -190
  74. package/decorators/decorators.utils.d.ts +0 -705
  75. package/dir/dir.utils.d.ts +0 -216
  76. package/env/env.utils.d.ts +0 -400
  77. package/exception/exception.utils.d.ts +0 -253
  78. package/fs/fs.utils.d.ts +0 -196
  79. package/http-status-codes/http-status-codes.d.ts +0 -289
  80. package/id/id.utils.d.ts +0 -59
  81. package/logger/logger.utils.d.ts +0 -210
  82. package/middleware/middleware.utils.d.ts +0 -123
  83. package/obj/obj.utils.d.ts +0 -156
  84. package/performance/performance.utils.d.ts +0 -159
  85. package/request/request.utils.d.ts +0 -109
  86. package/response/response.utils.d.ts +0 -186
  87. package/server/server.builder.d.ts +0 -531
  88. package/server/server.d.ts +0 -303
  89. package/stream/stream.utils.d.ts +0 -111
  90. package/string/string.utils.d.ts +0 -124
  91. package/type/type.utils.d.ts +0 -129
  92. package/types/api-response.d.ts +0 -175
  93. package/types/common.d.ts +0 -148
  94. package/types/config.d.ts +0 -88
  95. package/types/server.d.ts +0 -291
  96. package/url/url.utils.d.ts +0 -164
  97. package/validate/index.d.ts +0 -25
@@ -1,296 +0,0 @@
1
- /*
2
- * The MIT License
3
- *
4
- * Copyright (c) 2025 Catbee Technologies. https://catbee.in/license
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in all
14
- * copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- * SOFTWARE.
23
- */
24
-
25
- /**
26
- * Delays execution for a specified number of milliseconds.
27
- *
28
- * @param {number} ms - The number of milliseconds to sleep.
29
- * @returns {Promise<void>} A Promise that resolves after the given time.
30
- */
31
- export declare function sleep(ms: number): Promise<void>;
32
- /**
33
- * Creates a debounced version of a function that delays its execution.
34
- * Provides `.cancel()` and `.flush()` methods.
35
- *
36
- * @template T
37
- * @param {T} fn - The function to debounce.
38
- * @param {number} delay - Delay in milliseconds.
39
- * @returns {T & { cancel: () => void; flush: () => void }} A debounced function.
40
- */
41
- export declare function debounce<T extends (...args: any[]) => void>(fn: T, delay: number): {
42
- (...args: Parameters<T>): void;
43
- cancel(): void;
44
- flush(): void;
45
- } & {
46
- cancel: () => void;
47
- flush: () => void;
48
- };
49
- /**
50
- * Creates a throttled version of a function that limits its execution rate.
51
- * Allows control over leading/trailing invocation.
52
- *
53
- * @template T
54
- * @param {T} fn - The function to throttle.
55
- * @param {number} limit - Minimum time between calls in milliseconds.
56
- * @param {{ leading?: boolean, trailing?: boolean }} [opts] - Options for leading/trailing edge throttling.
57
- * @returns {(...args: Parameters<T>) => void} A throttled function.
58
- */
59
- export declare function throttle<T extends (...args: any[]) => void>(fn: T, limit: number, opts?: {
60
- leading?: boolean;
61
- trailing?: boolean;
62
- }): (...args: Parameters<T>) => void;
63
- /**
64
- * Retries an asynchronous function a given number of times with optional delay/backoff.
65
- *
66
- * @template T
67
- * @param {() => Promise<T>} fn - The async function to retry.
68
- * @param {number} [retries=3] - Number of retry attempts.
69
- * @param {number} [delay=500] - Delay in milliseconds between retries.
70
- * @param {boolean} [backoff=false] - Use exponential backoff between attempts.
71
- * @param {(error: unknown, attempt: number) => void} [onRetry] - Callback for each retry attempt.
72
- * @returns {Promise<T>} The result of the async function if successful.
73
- * @throws {*} The last encountered error if all retries fail.
74
- */
75
- export declare function retry<T>(fn: () => Promise<T>, retries?: number, delay?: number, backoff?: boolean, onRetry?: (error: unknown, attempt: number) => void): Promise<T>;
76
- /**
77
- * Wraps a promise and rejects it if it doesn't resolve within the specified timeout.
78
- *
79
- * @template T
80
- * @param {Promise<T>} promise - The original promise.
81
- * @param {number} ms - Timeout in milliseconds.
82
- * @param {string} [message="Operation timed out"] - Optional timeout message.
83
- * @returns {Promise<T>} A promise that resolves or rejects within the timeout.
84
- */
85
- export declare function withTimeout<T>(promise: Promise<T>, ms: number, message?: string): Promise<T>;
86
- /**
87
- * Executes async tasks in true batches.
88
- * Each batch runs in parallel, but batches run sequentially.
89
- * All tasks in a batch start at the same time, next batch waits for full completion.
90
- * NOTE: For more granular concurrency, use a "queue" or "pooled" approach.
91
- *
92
- * @template T
93
- * @param {Array<() => Promise<T>>} tasks - An array of functions that return Promises.
94
- * @param {number} limit - Number of tasks to run in parallel per batch.
95
- * @returns {Promise<T[]>} A promise that resolves to an array of resolved values.
96
- */
97
- export declare function runInBatches<T>(tasks: (() => Promise<T>)[], limit: number): Promise<T[]>;
98
- /**
99
- * Wraps a function and ensures it is only called once at a time.
100
- * Calls made while one is in progress will wait for the same Promise.
101
- * Optionally, new calls can be dropped while in progress (drop=true).
102
- *
103
- * @template TArgs
104
- * @template TResult
105
- * @param {(...args: TArgs) => Promise<TResult>} fn - The async function to wrap.
106
- * @param {boolean} [drop=false] - If true, new calls while one is pending are rejected.
107
- * @returns {(...args: TArgs) => Promise<TResult>} A wrapped function with singleton behavior.
108
- */
109
- export declare function singletonAsync<TArgs extends unknown[], TResult>(fn: (...args: TArgs) => Promise<TResult>, drop?: boolean): (...args: TArgs) => Promise<TResult>;
110
- /**
111
- * Resolves a list of async tasks in parallel, returning both resolved and rejected results.
112
- *
113
- * @template T
114
- * @param {Array<() => Promise<T>>} tasks - Array of promise-returning functions.
115
- * @returns {Promise<PromiseSettledResult<T>[]>} Results including status and value/reason.
116
- */
117
- export declare function settleAll<T>(tasks: (() => Promise<T>)[]): Promise<PromiseSettledResult<T>[]>;
118
- export interface TaskQueue {
119
- <T>(taskFn: () => Promise<T>): Promise<T>;
120
- pause: () => void;
121
- resume: () => void;
122
- readonly length: number;
123
- readonly isPaused: boolean;
124
- }
125
- /**
126
- * A simple task queue that executes async tasks with a concurrency limit.
127
- * Exposes pause, resume, and queue length getters.
128
- *
129
- * @param {number} limit - Maximum number of concurrent tasks.
130
- * @returns {function & { pause: () => void, resume: () => void, length: number, isPaused: boolean }}
131
- * Enqueue function plus queue controls.
132
- */
133
- export declare function createTaskQueue(limit: number): TaskQueue;
134
- /**
135
- * Executes async functions sequentially and collects results.
136
- * Useful when order matters or tasks depend on each other.
137
- *
138
- * @template T
139
- * @param {Array<() => Promise<T>>} tasks - Array of promise-returning functions.
140
- * @returns {Promise<T[]>} Array of resolved values.
141
- */
142
- export declare function runInSeries<T>(tasks: (() => Promise<T>)[]): Promise<T[]>;
143
- /**
144
- * Memoizes an async function, caching results for repeated calls with identical arguments.
145
- * Optional TTL (time-to-live) for cached entries.
146
- *
147
- * @template T Function return type
148
- * @template Args Function arguments types
149
- * @param {(...args: Args) => Promise<T>} fn - The async function to memoize
150
- * @param {object} [options] - Memoization options
151
- * @param {number} [options.ttl] - Cache TTL in milliseconds (optional)
152
- * @param {(args: Args) => string} [options.keyFn] - Custom key generator function
153
- * @returns {(...args: Args) => Promise<T>} Memoized function
154
- */
155
- export declare function memoizeAsync<T, Args extends any[]>(fn: (...args: Args) => Promise<T>, options?: {
156
- ttl?: number;
157
- keyFn?: (args: Args) => string;
158
- }): (...args: Args) => Promise<T>;
159
- /**
160
- * Creates an abortable version of a promise that can be cancelled using an AbortController.
161
- *
162
- * @template T
163
- * @param {Promise<T>} promise - The promise to make abortable
164
- * @param {AbortSignal} signal - AbortSignal from AbortController
165
- * @param {any} [abortValue] - Value to use when rejecting on abort
166
- * @returns {Promise<T>} Promise that rejects if the signal is aborted
167
- */
168
- export declare function abortable<T>(promise: Promise<T>, signal: AbortSignal, abortValue?: any): Promise<T>;
169
- /**
170
- * Creates a promise with external resolve/reject functions.
171
- * Useful for creating promises that can be resolved or rejected from outside.
172
- *
173
- * @template T
174
- * @returns {[Promise<T>, (value: T | PromiseLike<T>) => void, (reason?: any) => void]}
175
- * Tuple of [promise, resolve, reject]
176
- */
177
- export declare function createDeferred<T>(): [Promise<T>, (value: T | PromiseLike<T>) => void, (reason?: any) => void];
178
- /**
179
- * Chains a series of async functions, passing the result of each to the next.
180
- * Similar to function composition but for async functions.
181
- *
182
- * @template T
183
- * @param {Array<(input: any) => Promise<any>>} fns - Array of async functions to compose
184
- * @returns {(input: any) => Promise<T>} Composed function
185
- */
186
- export declare function waterfall<T>(fns: Array<(input: any) => Promise<any>>): (initialValue: any) => Promise<T>;
187
- /**
188
- * Creates a rate limiter that ensures functions aren't called more than
189
- * a specified number of times per interval.
190
- *
191
- * @template T
192
- * @param {(...args: any[]) => Promise<T>} fn - Function to rate limit
193
- * @param {number} maxCalls - Maximum calls allowed per interval
194
- * @param {number} interval - Time interval in milliseconds
195
- * @returns {(...args: any[]) => Promise<T>} Rate limited function
196
- */
197
- export declare function rateLimit<T>(fn: (...args: any[]) => Promise<T>, maxCalls: number, interval: number): (...args: any[]) => Promise<T>;
198
- /**
199
- * Circuit breaker pattern implementation for protecting against cascading failures.
200
- * Tracks failures and prevents calling the function when too many failures occur.
201
- *
202
- * @param fn - Function to protect with circuit breaker
203
- * @param options - Circuit breaker options
204
- * @returns Function wrapped with circuit breaker logic
205
- *
206
- * @example
207
- * ```typescript
208
- * const protectedFetch = circuitBreaker(
209
- * async (url) => {
210
- * const response = await fetch(url);
211
- * if (!response.ok) throw new Error(`HTTP error: ${response.status}`);
212
- * return response.json();
213
- * },
214
- * {
215
- * failureThreshold: 3,
216
- * resetTimeout: 30000,
217
- * onOpen: () => console.log('Circuit breaker opened'),
218
- * onClose: () => console.log('Circuit breaker closed')
219
- * }
220
- * );
221
- *
222
- * // Will throw CircuitBreakerOpenError after failureThreshold consecutive failures
223
- * try {
224
- * const data = await protectedFetch('https://api.example.com');
225
- * } catch (error) {
226
- * if (error instanceof CircuitBreakerOpenError) {
227
- * console.log('Service is currently unavailable, please try again later');
228
- * }
229
- * }
230
- * ```
231
- */
232
- export declare class CircuitBreakerOpenError extends Error {
233
- constructor(message?: string);
234
- }
235
- /**
236
- * Circuit breaker states
237
- */
238
- export declare enum CircuitBreakerState {
239
- CLOSED = "CLOSED",
240
- OPEN = "OPEN",
241
- HALF_OPEN = "HALF_OPEN"
242
- }
243
- export interface CircuitBreakerOptions {
244
- /** Number of consecutive failures before opening circuit (default: 5) */
245
- failureThreshold?: number;
246
- /** Time in milliseconds to wait before trying again (default: 10000) */
247
- resetTimeout?: number;
248
- /** Number of successful calls to close the circuit again (default: 1) */
249
- successThreshold?: number;
250
- /** Callback when circuit opens */
251
- onOpen?: () => void;
252
- /** Callback when circuit closes */
253
- onClose?: () => void;
254
- /** Callback when circuit enters half-open state */
255
- onHalfOpen?: () => void;
256
- }
257
- export declare function circuitBreaker<T, Args extends any[]>(fn: (...args: Args) => Promise<T>, options?: CircuitBreakerOptions): (...args: Args) => Promise<T>;
258
- /**
259
- * Run multiple async tasks with concurrency control.
260
- *
261
- * @param tasks - Array of async tasks to run
262
- * @param options - Concurrency options
263
- * @returns Promise that resolves when all tasks are complete
264
- *
265
- * @example
266
- * ```typescript
267
- * const urls = ['https://example.com/1', 'https://example.com/2', many more ];
268
- *
269
- * // Process up to 5 requests at a time, with progress reporting
270
- * const results = await runWithConcurrency(
271
- * urls.map(url => () => fetch(url).then(res => res.json())),
272
- * {
273
- * concurrency: 5,
274
- * onProgress: (completed, total) => {
275
- * console.log(`Progress: ${completed}/${total}`);
276
- * }
277
- * }
278
- * );
279
- * ```
280
- */
281
- export declare function runWithConcurrency<T>(tasks: Array<() => Promise<T>>, options?: {
282
- /** Maximum number of tasks to run at once (default: 3) */
283
- concurrency?: number;
284
- /** Called whenever a task completes */
285
- onProgress?: (completed: number, total: number) => void;
286
- /** Abort signal to cancel execution */
287
- signal?: AbortSignal;
288
- }): Promise<T[]>;
289
- /**
290
- * Optionally requires a module, returning null if not found.
291
- *
292
- * @template T
293
- * @param {string} name - The name of the module to require.
294
- * @returns {T | null} The required module or null if not found.
295
- */
296
- export declare function optionalRequire<T = any>(name: string): T | null;
@@ -1,176 +0,0 @@
1
- /*
2
- * The MIT License
3
- *
4
- * Copyright (c) 2025 Catbee Technologies. https://catbee.in/license
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in all
14
- * copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- * SOFTWARE.
23
- */
24
-
25
- /**
26
- * Options for configuring a TTLCache instance.
27
- */
28
- export interface TTLCacheOptions {
29
- /** Default time-to-live in milliseconds for cache entries */
30
- ttlMs?: number;
31
- /** Maximum number of entries to keep in cache (uses LRU eviction policy) */
32
- maxSize?: number;
33
- /** Auto-cleanup interval in milliseconds (disabled if 0 or negative) */
34
- autoCleanupMs?: number;
35
- }
36
- /**
37
- * An in-memory cache with time-to-live (TTL) support for each entry.
38
- *
39
- * @typeParam K - Type of the key.
40
- * @typeParam V - Type of the value.
41
- *
42
- * @example
43
- * const cache = new TTLCache<string, number>({ ttlMs: 1000 });
44
- * cache.set("x", 123);
45
- * const value = cache.get("x"); // 123
46
- */
47
- export declare class TTLCache<K, V> {
48
- private cache;
49
- private ttlMs;
50
- private maxSize?;
51
- private cleanupInterval?;
52
- /**
53
- * @param options - Configuration options for the cache
54
- */
55
- constructor(options?: TTLCacheOptions);
56
- /**
57
- * Sets a key-value pair in the cache with the default TTL.
58
- *
59
- * @param key - The key to set.
60
- * @param value - The value to associate with the key.
61
- */
62
- set(key: K, value: V): void;
63
- /**
64
- * Sets a key-value pair in the cache with a custom TTL.
65
- *
66
- * @param key - The key to set.
67
- * @param value - The value to associate with the key.
68
- * @param ttlMs - Time-to-live in milliseconds.
69
- */
70
- setWithTTL(key: K, value: V, ttlMs: number): void;
71
- /**
72
- * Retrieves the value for a given key if it hasn't expired.
73
- *
74
- * @param key - The key to retrieve.
75
- * @returns The cached value, or undefined if not found or expired.
76
- */
77
- get(key: K): V | undefined;
78
- /**
79
- * Retrieves or computes a value if it's not in the cache or has expired.
80
- *
81
- * @param key - The key to retrieve
82
- * @param producer - Function to generate the value if not cached
83
- * @param ttlMs - Optional custom TTL for the computed value
84
- * @returns The cached or computed value
85
- */
86
- getOrCompute(key: K, producer: () => Promise<V>, ttlMs?: number): Promise<V>;
87
- /**
88
- * Checks if the key exists and hasn't expired.
89
- *
90
- * @param key - The key to check.
91
- * @returns `true` if key exists and is valid, otherwise `false`.
92
- */
93
- has(key: K): boolean;
94
- /**
95
- * Deletes a key from the cache.
96
- *
97
- * @param key - The key to delete.
98
- * @returns `true` if the key existed and was removed, `false` otherwise.
99
- */
100
- delete(key: K): boolean;
101
- /**
102
- * Clears all entries from the cache.
103
- */
104
- clear(): void;
105
- /**
106
- * Returns the number of entries currently in the cache (includes expired entries until next access/cleanup).
107
- *
108
- * @returns Number of items in the cache (may include expired keys).
109
- */
110
- size(): number;
111
- /**
112
- * Set multiple key-value pairs at once with the default TTL.
113
- *
114
- * @param entries - Array of [key, value] tuples to set
115
- */
116
- setMany(entries: [K, V][]): void;
117
- /**
118
- * Get multiple values at once.
119
- *
120
- * @param keys - Array of keys to retrieve
121
- * @returns Array of values (undefined for keys that don't exist or expired)
122
- */
123
- getMany(keys: K[]): (V | undefined)[];
124
- /**
125
- * Removes all expired entries from the cache.
126
- *
127
- * @returns Number of entries removed.
128
- */
129
- cleanup(): number;
130
- /**
131
- * Returns an iterator of all current valid [key, value] pairs.
132
- *
133
- * @returns IterableIterator<[K, V]>
134
- */
135
- entries(): IterableIterator<[K, V]>;
136
- /**
137
- * Returns an iterator of all current valid keys.
138
- *
139
- * @returns IterableIterator<K>
140
- */
141
- keys(): IterableIterator<K>;
142
- /**
143
- * Returns an iterator of all current valid values.
144
- *
145
- * @returns IterableIterator<V>
146
- */
147
- values(): IterableIterator<V>;
148
- /**
149
- * Extends the expiration of a key by the specified time or default TTL.
150
- *
151
- * @param key - The key to refresh
152
- * @param ttlMs - Optional new TTL in milliseconds (uses default if not specified)
153
- * @returns true if the key was found and refreshed, false otherwise
154
- */
155
- refresh(key: K, ttlMs?: number): boolean;
156
- /**
157
- * Returns a snapshot of cache stats.
158
- *
159
- * @returns Object containing cache statistics
160
- */
161
- stats(): {
162
- size: number;
163
- validEntries: number;
164
- expiredEntries: number;
165
- maxSize: number | undefined;
166
- };
167
- /**
168
- * Stop the auto-cleanup interval if it's running.
169
- */
170
- destroy(): void;
171
- /**
172
- * Evict the least recently used entry from the cache.
173
- * @private
174
- */
175
- private evictLRU;
176
- }
@@ -1,57 +0,0 @@
1
- /*
2
- * The MIT License
3
- *
4
- * Copyright (c) 2025 Catbee Technologies. https://catbee.in/license
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in all
14
- * copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- * SOFTWARE.
23
- */
24
-
25
- import type { CatbeeConfig, ServerConfig } from '@catbee/utils/types';
26
- import type { Logger } from '@catbee/utils/logger';
27
- /**
28
- * Extends Express Request interface to add request ID tracking.
29
- * Added by requestId middleware during request processing.
30
- */
31
- declare global {
32
- namespace Express {
33
- interface Request {
34
- /** Unique request identifier (set by middleware) */
35
- id?: string;
36
- /** Logger instance for the request (set by middleware) */
37
- logger?: Logger;
38
- /** User information (set by authentication middleware) */
39
- user?: any;
40
- }
41
- }
42
- }
43
- /**
44
- * Application runtime configuration loaded from environment variables.
45
- */
46
- export declare let defaultCatbeeConfig: CatbeeConfig;
47
- export declare const defaultServerConfig: ServerConfig;
48
- /**
49
- * Update the @catbee/utils configuration.
50
- * @param value Partial configuration object.
51
- */
52
- export declare function setConfig(value: Partial<CatbeeConfig>): void;
53
- /**
54
- * Get the current @catbee/utils configuration.
55
- * @returns The current configuration object.
56
- */
57
- export declare function getConfig(): CatbeeConfig;