@naman_deep_singh/utils 2.3.0 → 2.6.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 (58) hide show
  1. package/README.md +228 -129
  2. package/dist/cjs/array/arrayExtensions.js +23 -23
  3. package/dist/cjs/core/index.js +14 -16
  4. package/dist/cjs/errors/CompressionError.js +19 -0
  5. package/dist/cjs/errors/ConnectionError.js +21 -0
  6. package/dist/cjs/errors/PoolError.js +20 -0
  7. package/dist/cjs/errors/TimeoutError.js +24 -0
  8. package/dist/cjs/errors/ValidationError.js +22 -0
  9. package/dist/cjs/errors/index.js +13 -0
  10. package/dist/cjs/extensions/index.js +9 -18
  11. package/dist/cjs/init/index.js +7 -16
  12. package/dist/cjs/init/initializer.js +10 -10
  13. package/dist/cjs/number/numberExtensions.js +23 -23
  14. package/dist/cjs/object/objectExtensions.js +14 -14
  15. package/dist/cjs/string/stringExtensions.js +22 -22
  16. package/dist/cjs/types/index.js +0 -17
  17. package/dist/cjs/utils/compression.js +455 -0
  18. package/dist/cjs/utils/index.js +35 -18
  19. package/dist/cjs/utils/pool.js +375 -0
  20. package/dist/cjs/utils/timeout.js +133 -0
  21. package/dist/esm/array/arrayExtensions.js +1 -1
  22. package/dist/esm/core/index.js +3 -2
  23. package/dist/esm/errors/CompressionError.js +15 -0
  24. package/dist/esm/errors/ConnectionError.js +17 -0
  25. package/dist/esm/errors/PoolError.js +16 -0
  26. package/dist/esm/errors/TimeoutError.js +20 -0
  27. package/dist/esm/errors/ValidationError.js +18 -0
  28. package/dist/esm/errors/index.js +5 -0
  29. package/dist/esm/extensions/index.js +4 -4
  30. package/dist/esm/init/index.js +2 -2
  31. package/dist/esm/init/initializer.js +5 -5
  32. package/dist/esm/number/numberExtensions.js +2 -2
  33. package/dist/esm/object/objectExtensions.js +1 -1
  34. package/dist/esm/string/stringExtensions.js +1 -1
  35. package/dist/esm/types/index.js +1 -3
  36. package/dist/esm/utils/compression.js +415 -0
  37. package/dist/esm/utils/index.js +16 -4
  38. package/dist/esm/utils/pool.js +370 -0
  39. package/dist/esm/utils/timeout.js +128 -0
  40. package/dist/types/core/index.d.ts +3 -2
  41. package/dist/types/errors/CompressionError.d.ts +8 -0
  42. package/dist/types/errors/ConnectionError.d.ts +9 -0
  43. package/dist/types/errors/PoolError.d.ts +8 -0
  44. package/dist/types/errors/TimeoutError.d.ts +12 -0
  45. package/dist/types/errors/ValidationError.d.ts +9 -0
  46. package/dist/types/errors/index.d.ts +5 -0
  47. package/dist/types/extensions/index.d.ts +4 -4
  48. package/dist/types/init/index.d.ts +2 -2
  49. package/dist/types/init/initializer.d.ts +1 -1
  50. package/dist/types/init/options.d.ts +1 -1
  51. package/dist/types/types/extensionTypes.d.ts +1 -1
  52. package/dist/types/types/index.d.ts +1 -2
  53. package/dist/types/utils/compression.d.ts +164 -0
  54. package/dist/types/utils/config.d.ts +1 -1
  55. package/dist/types/utils/index.d.ts +11 -3
  56. package/dist/types/utils/pool.d.ts +157 -0
  57. package/dist/types/utils/timeout.d.ts +64 -0
  58. package/package.json +2 -1
@@ -0,0 +1,370 @@
1
+ /**
2
+ * Generic connection pooling utilities
3
+ * @packageDocumentation
4
+ */
5
+ import { ConnectionError } from '../errors/ConnectionError.js';
6
+ import { PoolError } from '../errors/PoolError.js';
7
+ /**
8
+ * Pool connection wrapper with metadata
9
+ */
10
+ class PooledConnection {
11
+ constructor(connection, poolName) {
12
+ this.connection = connection;
13
+ this.poolName = poolName;
14
+ this.id = `${poolName}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
15
+ this.createdAt = new Date();
16
+ this.lastUsedAt = new Date();
17
+ this.isAcquired = false;
18
+ this.useCount = 0;
19
+ this.isMarkedForDestruction = false;
20
+ }
21
+ /** Mark connection as used */
22
+ markUsed() {
23
+ this.lastUsedAt = new Date();
24
+ this.useCount++;
25
+ }
26
+ /** Check if connection is idle beyond timeout */
27
+ isIdle(idleTimeoutMs) {
28
+ const idleTime = Date.now() - this.lastUsedAt.getTime();
29
+ return idleTime > idleTimeoutMs;
30
+ }
31
+ /** Check if connection has exceeded max lifetime */
32
+ hasExceededLifetime(maxLifetimeMs) {
33
+ const lifetime = Date.now() - this.createdAt.getTime();
34
+ return lifetime > maxLifetimeMs;
35
+ }
36
+ }
37
+ /**
38
+ * Generic connection pool manager
39
+ */
40
+ export class GenericPool {
41
+ constructor(config) {
42
+ this.connections = new Map();
43
+ this.pendingAcquires = [];
44
+ this.isShuttingDown = false;
45
+ this.stats = {
46
+ totalConnectionsCreated: 0,
47
+ totalConnectionsDestroyed: 0,
48
+ totalAcquireRequests: 0,
49
+ totalAcquireTimeouts: 0,
50
+ totalAcquireErrors: 0,
51
+ totalReleaseRequests: 0,
52
+ };
53
+ this.config = {
54
+ name: config.name || 'default',
55
+ minConnections: config.minConnections ?? 1,
56
+ maxConnections: config.maxConnections ?? 10,
57
+ acquireTimeoutMs: config.acquireTimeoutMs ?? 30000,
58
+ releaseTimeoutMs: config.releaseTimeoutMs ?? 5000,
59
+ idleTimeoutMs: config.idleTimeoutMs ?? 60000,
60
+ maxLifetimeMs: config.maxLifetimeMs ?? 3600000,
61
+ healthCheckIntervalMs: config.healthCheckIntervalMs ?? 30000,
62
+ createConnection: config.createConnection,
63
+ validateConnection: config.validateConnection ?? ((conn) => conn.isHealthy()),
64
+ destroyConnection: config.destroyConnection ?? ((conn) => conn.close()),
65
+ };
66
+ this.validateConfig();
67
+ this.startHealthChecks();
68
+ }
69
+ /**
70
+ * Validate pool configuration
71
+ */
72
+ validateConfig() {
73
+ if (this.config.minConnections < 0) {
74
+ throw new RangeError('minConnections must be non-negative');
75
+ }
76
+ if (this.config.maxConnections <= 0) {
77
+ throw new RangeError('maxConnections must be positive');
78
+ }
79
+ if (this.config.minConnections > this.config.maxConnections) {
80
+ throw new RangeError('minConnections cannot exceed maxConnections');
81
+ }
82
+ if (this.config.acquireTimeoutMs <= 0) {
83
+ throw new RangeError('acquireTimeoutMs must be positive');
84
+ }
85
+ if (this.config.idleTimeoutMs < 0) {
86
+ throw new RangeError('idleTimeoutMs must be non-negative');
87
+ }
88
+ if (this.config.maxLifetimeMs < 0) {
89
+ throw new RangeError('maxLifetimeMs must be non-negative');
90
+ }
91
+ }
92
+ /**
93
+ * Start periodic health checks
94
+ */
95
+ startHealthChecks() {
96
+ if (this.config.healthCheckIntervalMs > 0) {
97
+ this.healthCheckInterval = setInterval(() => {
98
+ this.cleanupIdleConnections();
99
+ this.cleanupExpiredConnections();
100
+ this.maintainMinConnections();
101
+ }, this.config.healthCheckIntervalMs);
102
+ }
103
+ }
104
+ /**
105
+ * Stop health checks
106
+ */
107
+ stopHealthChecks() {
108
+ if (this.healthCheckInterval) {
109
+ clearInterval(this.healthCheckInterval);
110
+ }
111
+ }
112
+ /**
113
+ * Acquire a connection from the pool
114
+ * @returns Promise resolving to connection
115
+ */
116
+ async acquire() {
117
+ if (this.isShuttingDown) {
118
+ throw new PoolError('Cannot acquire connection: pool is shutting down', this.config.name);
119
+ }
120
+ this.stats.totalAcquireRequests++;
121
+ // Try to get available connection
122
+ for (const pooledConn of this.connections.values()) {
123
+ if (!pooledConn.isAcquired &&
124
+ this.config.validateConnection(pooledConn.connection)) {
125
+ pooledConn.isAcquired = true;
126
+ pooledConn.markUsed();
127
+ return pooledConn.connection;
128
+ }
129
+ }
130
+ // Create new connection if under max
131
+ if (this.connections.size < this.config.maxConnections) {
132
+ try {
133
+ const connection = await this.createAndRegisterConnection();
134
+ connection.isAcquired = true;
135
+ connection.markUsed();
136
+ return connection.connection;
137
+ }
138
+ catch (error) {
139
+ this.stats.totalAcquireErrors++;
140
+ throw new ConnectionError('Failed to create connection', undefined, { poolName: this.config.name }, error instanceof Error ? error : undefined);
141
+ }
142
+ }
143
+ // Wait for connection to be released
144
+ return new Promise((resolve, reject) => {
145
+ const request = {
146
+ resolve,
147
+ reject,
148
+ timestamp: Date.now(),
149
+ };
150
+ this.pendingAcquires.push(request);
151
+ // Set timeout for acquire request
152
+ setTimeout(() => {
153
+ const index = this.pendingAcquires.indexOf(request);
154
+ if (index !== -1) {
155
+ this.pendingAcquires.splice(index, 1);
156
+ this.stats.totalAcquireTimeouts++;
157
+ reject(new PoolError(`Acquire timeout after ${this.config.acquireTimeoutMs}ms`, this.config.name, { pendingRequests: this.pendingAcquires.length }));
158
+ }
159
+ }, this.config.acquireTimeoutMs);
160
+ });
161
+ }
162
+ /**
163
+ * Release a connection back to the pool
164
+ * @param connection Connection to release
165
+ */
166
+ async release(connection) {
167
+ this.stats.totalReleaseRequests++;
168
+ const pooledConn = Array.from(this.connections.values()).find((pc) => pc.connection === connection);
169
+ if (!pooledConn) {
170
+ throw new PoolError('Connection not found in pool', this.config.name, {
171
+ connectionId: connection.id,
172
+ });
173
+ }
174
+ if (!pooledConn.isAcquired) {
175
+ throw new PoolError('Connection is not acquired', this.config.name, {
176
+ connectionId: connection.id,
177
+ });
178
+ }
179
+ // Validate connection before returning to pool
180
+ if (!this.config.validateConnection(connection)) {
181
+ await this.destroyConnection(pooledConn);
182
+ this.tryFulfillPendingAcquires();
183
+ return;
184
+ }
185
+ pooledConn.isAcquired = false;
186
+ pooledConn.markUsed();
187
+ // Fulfill pending acquire requests
188
+ this.tryFulfillPendingAcquires();
189
+ }
190
+ /**
191
+ * Try to fulfill pending acquire requests
192
+ */
193
+ tryFulfillPendingAcquires() {
194
+ while (this.pendingAcquires.length > 0) {
195
+ const availableConn = Array.from(this.connections.values()).find((pc) => !pc.isAcquired && this.config.validateConnection(pc.connection));
196
+ if (!availableConn) {
197
+ break;
198
+ }
199
+ const request = this.pendingAcquires.shift();
200
+ if (request) {
201
+ availableConn.isAcquired = true;
202
+ availableConn.markUsed();
203
+ request.resolve(availableConn.connection);
204
+ }
205
+ }
206
+ }
207
+ /**
208
+ * Create and register a new connection
209
+ */
210
+ async createAndRegisterConnection() {
211
+ const connection = await this.config.createConnection();
212
+ const pooledConn = new PooledConnection(connection, this.config.name);
213
+ this.connections.set(pooledConn.id, pooledConn);
214
+ this.stats.totalConnectionsCreated++;
215
+ return pooledConn;
216
+ }
217
+ /**
218
+ * Destroy a connection
219
+ */
220
+ async destroyConnection(pooledConn) {
221
+ try {
222
+ await this.config.destroyConnection(pooledConn.connection);
223
+ this.connections.delete(pooledConn.id);
224
+ this.stats.totalConnectionsDestroyed++;
225
+ }
226
+ catch (error) {
227
+ console.error(`Failed to destroy connection ${pooledConn.id}:`, error);
228
+ }
229
+ }
230
+ /**
231
+ * Clean up idle connections
232
+ */
233
+ cleanupIdleConnections() {
234
+ if (this.config.idleTimeoutMs <= 0)
235
+ return;
236
+ for (const pooledConn of this.connections.values()) {
237
+ if (!pooledConn.isAcquired &&
238
+ !pooledConn.isMarkedForDestruction &&
239
+ pooledConn.isIdle(this.config.idleTimeoutMs) &&
240
+ this.connections.size > this.config.minConnections) {
241
+ pooledConn.isMarkedForDestruction = true;
242
+ this.destroyConnection(pooledConn);
243
+ }
244
+ }
245
+ }
246
+ /**
247
+ * Clean up expired connections
248
+ */
249
+ cleanupExpiredConnections() {
250
+ if (this.config.maxLifetimeMs <= 0)
251
+ return;
252
+ for (const pooledConn of this.connections.values()) {
253
+ if (!pooledConn.isMarkedForDestruction &&
254
+ pooledConn.hasExceededLifetime(this.config.maxLifetimeMs)) {
255
+ pooledConn.isMarkedForDestruction = true;
256
+ this.destroyConnection(pooledConn);
257
+ }
258
+ }
259
+ }
260
+ /**
261
+ * Maintain minimum connections
262
+ */
263
+ async maintainMinConnections() {
264
+ const needed = this.config.minConnections - this.getAvailableCount();
265
+ for (let i = 0; i < needed && this.connections.size < this.config.maxConnections; i++) {
266
+ try {
267
+ await this.createAndRegisterConnection();
268
+ }
269
+ catch (error) {
270
+ console.error('Failed to maintain min connections:', error);
271
+ break;
272
+ }
273
+ }
274
+ }
275
+ /**
276
+ * Get pool statistics
277
+ */
278
+ getStats() {
279
+ return {
280
+ ...this.stats,
281
+ totalConnections: this.connections.size,
282
+ acquiredConnections: Array.from(this.connections.values()).filter((c) => c.isAcquired).length,
283
+ availableConnections: this.getAvailableCount(),
284
+ pendingAcquires: this.pendingAcquires.length,
285
+ isShuttingDown: this.isShuttingDown,
286
+ config: {
287
+ name: this.config.name,
288
+ minConnections: this.config.minConnections,
289
+ maxConnections: this.config.maxConnections,
290
+ },
291
+ };
292
+ }
293
+ /**
294
+ * Get number of available connections
295
+ */
296
+ getAvailableCount() {
297
+ return Array.from(this.connections.values()).filter((pc) => !pc.isAcquired && this.config.validateConnection(pc.connection)).length;
298
+ }
299
+ /**
300
+ * Drain the pool (graceful shutdown)
301
+ */
302
+ async drain() {
303
+ this.isShuttingDown = true;
304
+ this.stopHealthChecks();
305
+ // Reject all pending acquire requests
306
+ for (const request of this.pendingAcquires) {
307
+ request.reject(new PoolError('Pool is draining', this.config.name));
308
+ }
309
+ this.pendingAcquires.length = 0;
310
+ // Close all connections
311
+ const destroyPromises = Array.from(this.connections.values()).map((pooledConn) => this.destroyConnection(pooledConn));
312
+ await Promise.allSettled(destroyPromises);
313
+ }
314
+ /**
315
+ * Execute a function with a connection from the pool
316
+ */
317
+ async withConnection(fn) {
318
+ const connection = await this.acquire();
319
+ try {
320
+ return await fn(connection);
321
+ }
322
+ finally {
323
+ await this.release(connection);
324
+ }
325
+ }
326
+ }
327
+ /**
328
+ * Pool manager for multiple pools
329
+ */
330
+ export class PoolManager {
331
+ constructor() {
332
+ this.pools = new Map();
333
+ }
334
+ /**
335
+ * Create or get a pool
336
+ */
337
+ createPool(config) {
338
+ const name = config.name || 'default';
339
+ if (this.pools.has(name)) {
340
+ throw new PoolError(`Pool with name '${name}' already exists`, name);
341
+ }
342
+ const pool = new GenericPool(config);
343
+ this.pools.set(name, pool);
344
+ return pool;
345
+ }
346
+ /**
347
+ * Get a pool by name
348
+ */
349
+ getPool(name) {
350
+ return this.pools.get(name);
351
+ }
352
+ /**
353
+ * Drain all pools
354
+ */
355
+ async drainAll() {
356
+ const drainPromises = Array.from(this.pools.values()).map((pool) => pool.drain());
357
+ await Promise.all(drainPromises);
358
+ this.pools.clear();
359
+ }
360
+ /**
361
+ * Get statistics for all pools
362
+ */
363
+ getAllStats() {
364
+ const stats = {};
365
+ for (const [name, pool] of this.pools.entries()) {
366
+ stats[name] = pool.getStats();
367
+ }
368
+ return stats;
369
+ }
370
+ }
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Timeout utilities for async operations
3
+ * @packageDocumentation
4
+ */
5
+ import { TimeoutError } from '../errors/TimeoutError.js';
6
+ /**
7
+ * Timeout manager for async operations
8
+ */
9
+ export class TimeoutManager {
10
+ /**
11
+ * Execute a promise with a timeout
12
+ * @param promise Promise to execute
13
+ * @param timeoutMs Timeout duration in milliseconds
14
+ * @param errorMessage Optional custom error message
15
+ * @returns Promise result or throws TimeoutError
16
+ * @throws {TimeoutError} If operation times out
17
+ * @throws Any error thrown by the original promise
18
+ */
19
+ static async withTimeout(promise, timeoutMs, errorMessage) {
20
+ if (timeoutMs <= 0) {
21
+ throw new RangeError(`Timeout must be positive, got ${timeoutMs}`);
22
+ }
23
+ return new Promise((resolve, reject) => {
24
+ const timeoutId = setTimeout(() => {
25
+ reject(new TimeoutError(errorMessage || 'Operation timed out', timeoutMs));
26
+ }, timeoutMs);
27
+ promise
28
+ .then((result) => {
29
+ clearTimeout(timeoutId);
30
+ resolve(result);
31
+ })
32
+ .catch((error) => {
33
+ clearTimeout(timeoutId);
34
+ reject(error);
35
+ });
36
+ });
37
+ }
38
+ /**
39
+ * Create an AbortSignal that aborts after specified timeout
40
+ * @param timeoutMs Timeout duration in milliseconds
41
+ * @returns AbortSignal that aborts after timeout
42
+ */
43
+ static createTimeoutSignal(timeoutMs) {
44
+ if (timeoutMs <= 0) {
45
+ throw new RangeError(`Timeout must be positive, got ${timeoutMs}`);
46
+ }
47
+ const controller = new AbortController();
48
+ setTimeout(() => controller.abort(), timeoutMs);
49
+ return controller.signal;
50
+ }
51
+ /**
52
+ * Create a promise that resolves after specified delay
53
+ * @param delayMs Delay in milliseconds
54
+ * @returns Promise that resolves after delay
55
+ */
56
+ static delay(delayMs) {
57
+ if (delayMs < 0) {
58
+ throw new RangeError(`Delay must be non-negative, got ${delayMs}`);
59
+ }
60
+ return new Promise((resolve) => {
61
+ setTimeout(resolve, delayMs);
62
+ });
63
+ }
64
+ /**
65
+ * Create a promise that rejects after specified timeout
66
+ * @param timeoutMs Timeout in milliseconds
67
+ * @param errorMessage Optional error message
68
+ * @returns Promise that rejects with TimeoutError after timeout
69
+ */
70
+ static timeoutPromise(timeoutMs, errorMessage) {
71
+ return new Promise((_, reject) => {
72
+ setTimeout(() => {
73
+ reject(new TimeoutError(errorMessage || 'Timeout reached', timeoutMs));
74
+ }, timeoutMs);
75
+ });
76
+ }
77
+ /**
78
+ * Race multiple promises with individual timeouts
79
+ * @param promises Array of promises to race
80
+ * @param timeoutMs Timeout for each promise
81
+ * @returns First promise to resolve, or rejects if all timeout
82
+ */
83
+ static async raceWithTimeout(promises, timeoutMs) {
84
+ const timeoutPromises = promises.map((promise) => this.withTimeout(promise, timeoutMs, 'Race participant timed out'));
85
+ return Promise.race(timeoutPromises);
86
+ }
87
+ /**
88
+ * Execute function with retry and timeout for each attempt
89
+ * @param fn Function to execute
90
+ * @param options Retry and timeout options
91
+ * @returns Function result
92
+ */
93
+ static async retryWithTimeout(fn, options = {}) {
94
+ const { maxAttempts = 3, timeoutPerAttempt = 5000, delayBetweenAttempts = 1000, backoffMultiplier = 2, } = options;
95
+ if (maxAttempts < 1) {
96
+ throw new RangeError(`maxAttempts must be at least 1, got ${maxAttempts}`);
97
+ }
98
+ let lastError;
99
+ let currentDelay = delayBetweenAttempts;
100
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
101
+ try {
102
+ return await this.withTimeout(fn(), timeoutPerAttempt, `Attempt ${attempt} timed out`);
103
+ }
104
+ catch (error) {
105
+ lastError = error;
106
+ // Don't delay after last attempt
107
+ if (attempt < maxAttempts) {
108
+ await this.delay(currentDelay);
109
+ currentDelay *= backoffMultiplier;
110
+ }
111
+ }
112
+ }
113
+ throw lastError || new Error('All retry attempts failed');
114
+ }
115
+ }
116
+ /**
117
+ * Create a timeout wrapper for async functions
118
+ * @param timeoutMs Timeout in milliseconds
119
+ * @param errorMessage Optional error message
120
+ * @returns Function wrapper that adds timeout
121
+ */
122
+ export function withTimeout(timeoutMs, errorMessage) {
123
+ return (target, _context) => {
124
+ return function (...args) {
125
+ return TimeoutManager.withTimeout(target.apply(this, args), timeoutMs, errorMessage);
126
+ };
127
+ };
128
+ }
@@ -1,2 +1,3 @@
1
- export * from './validation.js';
2
- export * from './performance.js';
1
+ export { validateExtensionInput, validateArrayInput, validateNumberRange, validatePositiveInteger, } from './validation.js';
2
+ export { type PerformanceConfig, setPerformanceConfig, getPerformanceConfig, LRUCache, makeInternalCacheKey, withCache, } from './performance.js';
3
+ export { getPackageVersion } from './version.js';
@@ -0,0 +1,8 @@
1
+ import { AppError } from '@naman_deep_singh/errors';
2
+ /**
3
+ * Compression error - when compression/decompression fails
4
+ */
5
+ export declare class CompressionError extends AppError {
6
+ readonly algorithm?: string | undefined;
7
+ constructor(message: string, algorithm?: string | undefined, details?: unknown, cause?: Error);
8
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Connection error - when connection fails
3
+ * @packageDocumentation
4
+ */
5
+ import { AppError } from '@naman_deep_singh/errors';
6
+ export declare class ConnectionError extends AppError {
7
+ readonly endpoint?: string | undefined;
8
+ constructor(message: string, endpoint?: string | undefined, details?: unknown, cause?: Error);
9
+ }
@@ -0,0 +1,8 @@
1
+ import { AppError } from '@naman_deep_singh/errors';
2
+ /**
3
+ * Pool error - when pool operations fail
4
+ */
5
+ export declare class PoolError extends AppError {
6
+ readonly poolName?: string | undefined;
7
+ constructor(message: string, poolName?: string | undefined, details?: unknown, cause?: Error);
8
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Utility-specific error classes
3
+ * @packageDocumentation
4
+ */
5
+ import { AppError } from '@naman_deep_singh/errors';
6
+ /**
7
+ * Timeout error - when operation times out
8
+ */
9
+ export declare class TimeoutError extends AppError {
10
+ readonly timeoutMs: number;
11
+ constructor(message: string | undefined, timeoutMs: number, details?: unknown, cause?: Error);
12
+ }
@@ -0,0 +1,9 @@
1
+ import { AppError } from '@naman_deep_singh/errors';
2
+ /**
3
+ * Validation error - when utility input validation fails
4
+ */
5
+ export declare class ValidationError extends AppError {
6
+ readonly field?: string | undefined;
7
+ readonly value?: unknown | undefined;
8
+ constructor(message: string, field?: string | undefined, value?: unknown | undefined, details?: unknown, cause?: Error);
9
+ }
@@ -0,0 +1,5 @@
1
+ export { CompressionError } from './CompressionError.js';
2
+ export { ConnectionError } from './ConnectionError.js';
3
+ export { PoolError } from './PoolError.js';
4
+ export { TimeoutError } from './TimeoutError.js';
5
+ export { ValidationError } from './ValidationError.js';
@@ -1,4 +1,4 @@
1
- export * from '../string/index.js';
2
- export * from '../array/index.js';
3
- export * from '../object/index.js';
4
- export * from '../number/index.js';
1
+ export { extendString } from '../string/index.js';
2
+ export { extendArray } from '../array/index.js';
3
+ export { extendObject } from '../object/index.js';
4
+ export { extendNumber } from '../number/index.js';
@@ -1,2 +1,2 @@
1
- export * from './initializer.js';
2
- export * from './options.js';
1
+ export { initExtensions, extendAll } from './initializer.js';
2
+ export { validateExtensionOptions, createExtensionOptions } from './options.js';
@@ -1,3 +1,3 @@
1
- import type { ExtensionOptions } from '../types/index.js';
1
+ import type { ExtensionOptions } from '../types/extensionTypes.js';
2
2
  export declare function initExtensions(options?: ExtensionOptions): void;
3
3
  export declare function extendAll(): void;
@@ -1,3 +1,3 @@
1
- import type { ExtensionOptions } from '../types/index.js';
1
+ import type { ExtensionOptions } from '../types/extensionTypes.js';
2
2
  export declare function validateExtensionOptions(options: Partial<ExtensionOptions>): ExtensionOptions;
3
3
  export declare function createExtensionOptions(enableString?: boolean, enableArray?: boolean, enableObject?: boolean, enableNumber?: boolean, performanceConfig?: any): ExtensionOptions;
@@ -1,4 +1,4 @@
1
- import { type PerformanceConfig } from '../core/index.js';
1
+ import type { PerformanceConfig } from '../core/performance.js';
2
2
  export interface ExtensionOptions {
3
3
  string?: boolean;
4
4
  array?: boolean;
@@ -1,2 +1 @@
1
- export * from './extensionTypes.js';
2
- export * from './globalAugmentations.js';
1
+ export { type ExtensionOptions, type PerformanceConfig, } from './extensionTypes.js';