@plyaz/types 1.22.0 → 1.22.2

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 (38) hide show
  1. package/dist/api/index.cjs.map +1 -1
  2. package/dist/api/index.js.map +1 -1
  3. package/dist/core/domain/crud.d.ts +27 -0
  4. package/dist/core/domain/index.d.ts +2 -1
  5. package/dist/core/domain/types.d.ts +34 -0
  6. package/dist/core/events/payloads.d.ts +1 -0
  7. package/dist/core/frontend/featureFlags.d.ts +3 -3
  8. package/dist/core/frontend/index.d.ts +1 -1
  9. package/dist/core/frontend/types.d.ts +544 -8
  10. package/dist/core/index.d.ts +1 -0
  11. package/dist/core/init/index.d.ts +1 -1
  12. package/dist/core/init/types.d.ts +133 -3
  13. package/dist/core/services/index.d.ts +1 -0
  14. package/dist/core/services/keys.d.ts +40 -0
  15. package/dist/errors/codes.d.ts +11 -0
  16. package/dist/errors/index.cjs +13 -1
  17. package/dist/errors/index.cjs.map +1 -1
  18. package/dist/errors/index.js +13 -1
  19. package/dist/errors/index.js.map +1 -1
  20. package/dist/errors/middleware.d.ts +23 -4
  21. package/dist/examples/types.d.ts +9 -5
  22. package/dist/features/cache/index.cjs +6 -0
  23. package/dist/features/cache/index.cjs.map +1 -1
  24. package/dist/features/cache/index.d.ts +1 -0
  25. package/dist/features/cache/index.js +5 -0
  26. package/dist/features/cache/index.js.map +1 -1
  27. package/dist/features/cache/types.d.ts +9 -1
  28. package/dist/features/index.cjs +6 -0
  29. package/dist/features/index.cjs.map +1 -1
  30. package/dist/features/index.d.ts +1 -0
  31. package/dist/features/index.js +5 -0
  32. package/dist/features/index.js.map +1 -1
  33. package/dist/index.cjs +30 -1
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.d.ts +1 -0
  36. package/dist/index.js +28 -2
  37. package/dist/index.js.map +1 -1
  38. package/package.json +1 -1
@@ -7,12 +7,29 @@
7
7
  import type { Request, Response } from 'express';
8
8
  import type { SerializedError, ErrorStoreActions } from './store';
9
9
  import type { ErrorEventFactory, ErrorResponse } from './types';
10
+ /**
11
+ * Source identifier for error tracking.
12
+ * Used to identify where an error originated from.
13
+ */
14
+ export type ErrorSource = 'express' | 'nestjs' | 'nodejs' | 'nextjs' | 'http' | 'api' | 'global' | string;
15
+ /**
16
+ * Logger interface for error handlers.
17
+ * Compatible with @plyaz/logger PackageLogger and standard loggers.
18
+ */
19
+ export interface ErrorHandlerLogger {
20
+ error(message: string, meta?: Record<string, unknown>, ...details: unknown[]): void;
21
+ warn?(message: string, meta?: Record<string, unknown>, ...details: unknown[]): void;
22
+ info?(message: string, meta?: Record<string, unknown>, ...details: unknown[]): void;
23
+ debug?(message: string, meta?: Record<string, unknown>, ...details: unknown[]): void;
24
+ }
10
25
  /**
11
26
  * Configuration for HTTP error handler middleware.
12
- * Used by Express and NestJS error handlers.
27
+ * Used by Express, NestJS, and other Node.js backend error handlers.
13
28
  */
14
29
  export interface HttpErrorHandlerConfig {
15
- /** Global error handler instance (optional - for tracking) */
30
+ /** Source identifier for errors (e.g., 'express', 'nestjs', 'nextjs') */
31
+ source?: ErrorSource;
32
+ /** Global error handler instance (optional - for tracking). If not provided, uses global handler. */
16
33
  errorHandler?: GlobalErrorHandler;
17
34
  /** Include stack traces in response (default: false) */
18
35
  includeStack?: boolean;
@@ -20,8 +37,10 @@ export interface HttpErrorHandlerConfig {
20
37
  formatError?: (error: SerializedError, req: Request) => ErrorResponse;
21
38
  /** Callback when error is handled */
22
39
  onError?: (error: SerializedError, req: Request, res: Response) => void;
23
- /** Log errors to console (default: true) */
24
- logErrors?: boolean;
40
+ /** Log errors (default: true). Set false to disable, or provide a logger instance */
41
+ logErrors?: boolean | ErrorHandlerLogger;
42
+ /** Callback before clearing errors - use for monitoring (Grafana, Sentry, Datadog) */
43
+ beforeClear?: (errors: SerializedError[]) => void | Promise<void>;
25
44
  }
26
45
  /**
27
46
  * Configuration for the global error handler.
@@ -9,7 +9,6 @@ import type { CreateExampleSchema, UpdateExampleSchema, PatchExampleSchema, Quer
9
9
  import type { CoreEntityCreatedPayload, CoreEntityUpdatedPayload, CoreEntityDeletedPayload, CoreValidationFailedPayload } from '../core/events';
10
10
  import type { CoreBaseFrontendStore, CoreBaseFrontendServiceConfig } from '../core/frontend';
11
11
  import type { CoreServiceInitConfig } from '../core/init';
12
- import type { CoreBaseDomainServiceConfig } from '../core/domain';
13
12
  /**
14
13
  * Create request DTO (POST body)
15
14
  */
@@ -118,17 +117,14 @@ export interface ExampleFrontendStore extends CoreBaseFrontendStore<ExampleFront
118
117
  items: ExampleEntity[];
119
118
  selectedId: string | null;
120
119
  isLoading: boolean;
121
- error: Error | null;
122
120
  setData(data: ExampleFrontendStoreData): void;
123
121
  updateData?(data: Partial<ExampleFrontendStoreData>): void;
124
122
  setLoading(isLoading: boolean): void;
125
- setError(error: unknown): void;
126
123
  setItems(items: ExampleEntity[]): void;
127
124
  addItem(item: ExampleEntity): void;
128
125
  updateItem(id: string, updates: Partial<ExampleEntity>): void;
129
126
  removeItem(id: string): void;
130
127
  selectItem(id: string | null): void;
131
- clearError(): void;
132
128
  }
133
129
  /**
134
130
  * Example Frontend Service Configuration
@@ -159,9 +155,17 @@ export interface ExampleUser extends Record<string, unknown> {
159
155
  /**
160
156
  * Example Domain Service Configuration
161
157
  */
162
- export interface ExampleDomainServiceConfig extends CoreBaseDomainServiceConfig, CoreServiceInitConfig {
158
+ export interface ExampleDomainServiceConfig extends CoreServiceInitConfig {
163
159
  /** Use real API client instead of mocks */
164
160
  useRealApi?: boolean;
165
161
  /** API base path for example endpoints */
166
162
  apiBasePath?: string;
163
+ /** Throw on validation errors (default: true) */
164
+ throwOnValidationError?: boolean;
165
+ /** Throw on repository errors (default: true) */
166
+ throwOnRepositoryError?: boolean;
167
+ /** Emit lifecycle events (default: true) */
168
+ emitEvents?: boolean;
169
+ /** Service enabled */
170
+ enabled?: boolean;
167
171
  }
@@ -1,4 +1,10 @@
1
1
  'use strict';
2
2
 
3
+ // @plyaz package - Built with tsup
4
+
5
+ // src/features/cache/types.ts
6
+ var CACHE_STRATEGIES = ["memory", "redis"];
7
+
8
+ exports.CACHE_STRATEGIES = CACHE_STRATEGIES;
3
9
  //# sourceMappingURL=index.cjs.map
4
10
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
1
+ {"version":3,"sources":["../../../src/features/cache/types.ts"],"names":[],"mappings":";;;;;AAyBO,IAAM,gBAAA,GAAmB,CAAC,QAAA,EAAU,OAAO","file":"index.cjs","sourcesContent":["/**\n * Cache Types and Interfaces\n *\n * Type definitions for the caching layer.\n * This will be moved to @plyaz/core when the package structure is finalized.\n *\n * @fileoverview Cache type definitions\n * @version 1.0.0\n */\n\n/**\n * Cache entry structure that wraps cached data with metadata.\n */\nimport type {\n Configurable,\n WithExpiration,\n WithMetadata,\n Enabled,\n WithUrl,\n Timestamped,\n} from '../../common/types';\n\n/**\n * Available cache strategies\n */\nexport const CACHE_STRATEGIES = ['memory', 'redis'] as const;\n\n/**\n * Cache strategy type\n */\nexport type CacheStrategyType = (typeof CACHE_STRATEGIES)[number];\n\nexport interface CacheEntry<T = unknown>\n extends Partial<WithMetadata<Record<string, unknown>>>,\n WithExpiration<number>,\n Pick<Timestamped<number, number>, 'createdAt'> {\n /** The cached data */\n data: T;\n}\n\nexport interface GenericCacheEntry<T = unknown> {\n value: T;\n timestamp: number;\n ttl: number;\n}\n\n/**\n * Cache statistics for monitoring and debugging.\n */\nexport interface CacheStats {\n /** Total number of cache hits */\n hits: number;\n /** Total number of cache misses */\n misses: number;\n /** Total number of set operations */\n sets: number;\n /** Total number of delete operations */\n deletes: number;\n /** Number of entries currently in cache */\n size: number;\n /** Cache hit ratio (hits / (hits + misses)) */\n hitRatio?: number;\n}\n\n/**\n * Configuration for cache strategies.\n */\nexport interface CacheConfig extends Configurable, Enabled {\n /** Default TTL in seconds */\n ttl: number;\n /** Cache strategy to use */\n strategy: CacheStrategyType;\n /** Redis-specific configuration */\n redisConfig?: RedisCacheConfig;\n /** Memory cache specific configuration */\n memoryConfig?: MemoryCacheConfig;\n}\n\n/**\n * Configuration for memory cache strategy.\n */\nexport interface MemoryCacheConfig {\n /** Maximum number of entries to store (default: 1000) */\n maxSize?: number;\n /** Maximum number of entries to store (alias for maxSize) */\n maxEntries?: number;\n /** Check for expired entries every N milliseconds (default: 60000) */\n cleanupInterval?: number;\n /** Callback when entry is evicted */\n onEvict?: (key: string, entry: CacheEntry) => void;\n}\n\n/**\n * Configuration for Redis cache strategy.\n */\nexport interface RedisCacheConfig extends WithUrl {\n /** Redis password for authentication */\n password?: string;\n /** Redis database number */\n db?: number;\n /** Key prefix for Redis keys */\n keyPrefix?: string;\n /** Connection timeout in milliseconds */\n connectTimeout?: number;\n /** Command timeout in milliseconds */\n commandTimeout?: number;\n}\n\n/**\n * Cache manager statistics interface.\n */\nexport type CacheManagerStats = CacheStats;\n\n/**\n * Interface that all cache strategies must implement.\n */\nexport interface CacheStrategy {\n /**\n * Stores a cache entry.\n *\n * @param key - Cache key\n * @param entry - Cache entry to store\n * @returns Promise that resolves when entry is stored\n */\n set<T>(key: string, entry: CacheEntry<T>): Promise<void>;\n\n /**\n * Retrieves a cache entry.\n *\n * @param key - Cache key\n * @returns Promise that resolves to cache entry or null if not found\n */\n get<T>(key: string): Promise<CacheEntry<T> | null>;\n\n /**\n * Removes a cache entry.\n *\n * @param key - Cache key to remove\n * @returns Promise that resolves when entry is removed\n */\n delete(key: string): Promise<void>;\n\n /**\n * Clears all cache entries.\n *\n * @returns Promise that resolves when cache is cleared\n */\n clear(): Promise<void>;\n\n /**\n * Gets cache statistics.\n *\n * @returns Promise that resolves to cache statistics\n */\n getStats(): Promise<CacheStats>;\n\n /**\n * Disposes of the cache strategy and cleans up resources.\n * Optional method for cleanup.\n *\n * @returns Promise that resolves when cleanup is complete\n */\n dispose?(): Promise<void>;\n}\n"]}
@@ -1 +1,2 @@
1
1
  export type * from './types';
2
+ export { CACHE_STRATEGIES } from './types';
@@ -1,3 +1,8 @@
1
+ // @plyaz package - Built with tsup
1
2
 
3
+ // src/features/cache/types.ts
4
+ var CACHE_STRATEGIES = ["memory", "redis"];
5
+
6
+ export { CACHE_STRATEGIES };
2
7
  //# sourceMappingURL=index.js.map
3
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
1
+ {"version":3,"sources":["../../../src/features/cache/types.ts"],"names":[],"mappings":";;;AAyBO,IAAM,gBAAA,GAAmB,CAAC,QAAA,EAAU,OAAO","file":"index.js","sourcesContent":["/**\n * Cache Types and Interfaces\n *\n * Type definitions for the caching layer.\n * This will be moved to @plyaz/core when the package structure is finalized.\n *\n * @fileoverview Cache type definitions\n * @version 1.0.0\n */\n\n/**\n * Cache entry structure that wraps cached data with metadata.\n */\nimport type {\n Configurable,\n WithExpiration,\n WithMetadata,\n Enabled,\n WithUrl,\n Timestamped,\n} from '../../common/types';\n\n/**\n * Available cache strategies\n */\nexport const CACHE_STRATEGIES = ['memory', 'redis'] as const;\n\n/**\n * Cache strategy type\n */\nexport type CacheStrategyType = (typeof CACHE_STRATEGIES)[number];\n\nexport interface CacheEntry<T = unknown>\n extends Partial<WithMetadata<Record<string, unknown>>>,\n WithExpiration<number>,\n Pick<Timestamped<number, number>, 'createdAt'> {\n /** The cached data */\n data: T;\n}\n\nexport interface GenericCacheEntry<T = unknown> {\n value: T;\n timestamp: number;\n ttl: number;\n}\n\n/**\n * Cache statistics for monitoring and debugging.\n */\nexport interface CacheStats {\n /** Total number of cache hits */\n hits: number;\n /** Total number of cache misses */\n misses: number;\n /** Total number of set operations */\n sets: number;\n /** Total number of delete operations */\n deletes: number;\n /** Number of entries currently in cache */\n size: number;\n /** Cache hit ratio (hits / (hits + misses)) */\n hitRatio?: number;\n}\n\n/**\n * Configuration for cache strategies.\n */\nexport interface CacheConfig extends Configurable, Enabled {\n /** Default TTL in seconds */\n ttl: number;\n /** Cache strategy to use */\n strategy: CacheStrategyType;\n /** Redis-specific configuration */\n redisConfig?: RedisCacheConfig;\n /** Memory cache specific configuration */\n memoryConfig?: MemoryCacheConfig;\n}\n\n/**\n * Configuration for memory cache strategy.\n */\nexport interface MemoryCacheConfig {\n /** Maximum number of entries to store (default: 1000) */\n maxSize?: number;\n /** Maximum number of entries to store (alias for maxSize) */\n maxEntries?: number;\n /** Check for expired entries every N milliseconds (default: 60000) */\n cleanupInterval?: number;\n /** Callback when entry is evicted */\n onEvict?: (key: string, entry: CacheEntry) => void;\n}\n\n/**\n * Configuration for Redis cache strategy.\n */\nexport interface RedisCacheConfig extends WithUrl {\n /** Redis password for authentication */\n password?: string;\n /** Redis database number */\n db?: number;\n /** Key prefix for Redis keys */\n keyPrefix?: string;\n /** Connection timeout in milliseconds */\n connectTimeout?: number;\n /** Command timeout in milliseconds */\n commandTimeout?: number;\n}\n\n/**\n * Cache manager statistics interface.\n */\nexport type CacheManagerStats = CacheStats;\n\n/**\n * Interface that all cache strategies must implement.\n */\nexport interface CacheStrategy {\n /**\n * Stores a cache entry.\n *\n * @param key - Cache key\n * @param entry - Cache entry to store\n * @returns Promise that resolves when entry is stored\n */\n set<T>(key: string, entry: CacheEntry<T>): Promise<void>;\n\n /**\n * Retrieves a cache entry.\n *\n * @param key - Cache key\n * @returns Promise that resolves to cache entry or null if not found\n */\n get<T>(key: string): Promise<CacheEntry<T> | null>;\n\n /**\n * Removes a cache entry.\n *\n * @param key - Cache key to remove\n * @returns Promise that resolves when entry is removed\n */\n delete(key: string): Promise<void>;\n\n /**\n * Clears all cache entries.\n *\n * @returns Promise that resolves when cache is cleared\n */\n clear(): Promise<void>;\n\n /**\n * Gets cache statistics.\n *\n * @returns Promise that resolves to cache statistics\n */\n getStats(): Promise<CacheStats>;\n\n /**\n * Disposes of the cache strategy and cleans up resources.\n * Optional method for cleanup.\n *\n * @returns Promise that resolves when cleanup is complete\n */\n dispose?(): Promise<void>;\n}\n"]}
@@ -11,6 +11,14 @@
11
11
  * Cache entry structure that wraps cached data with metadata.
12
12
  */
13
13
  import type { Configurable, WithExpiration, WithMetadata, Enabled, WithUrl, Timestamped } from '../../common/types';
14
+ /**
15
+ * Available cache strategies
16
+ */
17
+ export declare const CACHE_STRATEGIES: readonly ["memory", "redis"];
18
+ /**
19
+ * Cache strategy type
20
+ */
21
+ export type CacheStrategyType = (typeof CACHE_STRATEGIES)[number];
14
22
  export interface CacheEntry<T = unknown> extends Partial<WithMetadata<Record<string, unknown>>>, WithExpiration<number>, Pick<Timestamped<number, number>, 'createdAt'> {
15
23
  /** The cached data */
16
24
  data: T;
@@ -44,7 +52,7 @@ export interface CacheConfig extends Configurable, Enabled {
44
52
  /** Default TTL in seconds */
45
53
  ttl: number;
46
54
  /** Cache strategy to use */
47
- strategy: 'memory' | 'redis';
55
+ strategy: CacheStrategyType;
48
56
  /** Redis-specific configuration */
49
57
  redisConfig?: RedisCacheConfig;
50
58
  /** Memory cache specific configuration */
@@ -1,4 +1,10 @@
1
1
  'use strict';
2
2
 
3
+ // @plyaz package - Built with tsup
4
+
5
+ // src/features/cache/types.ts
6
+ var CACHE_STRATEGIES = ["memory", "redis"];
7
+
8
+ exports.CACHE_STRATEGIES = CACHE_STRATEGIES;
3
9
  //# sourceMappingURL=index.cjs.map
4
10
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
1
+ {"version":3,"sources":["../../src/features/cache/types.ts"],"names":[],"mappings":";;;;;AAyBO,IAAM,gBAAA,GAAmB,CAAC,QAAA,EAAU,OAAO","file":"index.cjs","sourcesContent":["/**\n * Cache Types and Interfaces\n *\n * Type definitions for the caching layer.\n * This will be moved to @plyaz/core when the package structure is finalized.\n *\n * @fileoverview Cache type definitions\n * @version 1.0.0\n */\n\n/**\n * Cache entry structure that wraps cached data with metadata.\n */\nimport type {\n Configurable,\n WithExpiration,\n WithMetadata,\n Enabled,\n WithUrl,\n Timestamped,\n} from '../../common/types';\n\n/**\n * Available cache strategies\n */\nexport const CACHE_STRATEGIES = ['memory', 'redis'] as const;\n\n/**\n * Cache strategy type\n */\nexport type CacheStrategyType = (typeof CACHE_STRATEGIES)[number];\n\nexport interface CacheEntry<T = unknown>\n extends Partial<WithMetadata<Record<string, unknown>>>,\n WithExpiration<number>,\n Pick<Timestamped<number, number>, 'createdAt'> {\n /** The cached data */\n data: T;\n}\n\nexport interface GenericCacheEntry<T = unknown> {\n value: T;\n timestamp: number;\n ttl: number;\n}\n\n/**\n * Cache statistics for monitoring and debugging.\n */\nexport interface CacheStats {\n /** Total number of cache hits */\n hits: number;\n /** Total number of cache misses */\n misses: number;\n /** Total number of set operations */\n sets: number;\n /** Total number of delete operations */\n deletes: number;\n /** Number of entries currently in cache */\n size: number;\n /** Cache hit ratio (hits / (hits + misses)) */\n hitRatio?: number;\n}\n\n/**\n * Configuration for cache strategies.\n */\nexport interface CacheConfig extends Configurable, Enabled {\n /** Default TTL in seconds */\n ttl: number;\n /** Cache strategy to use */\n strategy: CacheStrategyType;\n /** Redis-specific configuration */\n redisConfig?: RedisCacheConfig;\n /** Memory cache specific configuration */\n memoryConfig?: MemoryCacheConfig;\n}\n\n/**\n * Configuration for memory cache strategy.\n */\nexport interface MemoryCacheConfig {\n /** Maximum number of entries to store (default: 1000) */\n maxSize?: number;\n /** Maximum number of entries to store (alias for maxSize) */\n maxEntries?: number;\n /** Check for expired entries every N milliseconds (default: 60000) */\n cleanupInterval?: number;\n /** Callback when entry is evicted */\n onEvict?: (key: string, entry: CacheEntry) => void;\n}\n\n/**\n * Configuration for Redis cache strategy.\n */\nexport interface RedisCacheConfig extends WithUrl {\n /** Redis password for authentication */\n password?: string;\n /** Redis database number */\n db?: number;\n /** Key prefix for Redis keys */\n keyPrefix?: string;\n /** Connection timeout in milliseconds */\n connectTimeout?: number;\n /** Command timeout in milliseconds */\n commandTimeout?: number;\n}\n\n/**\n * Cache manager statistics interface.\n */\nexport type CacheManagerStats = CacheStats;\n\n/**\n * Interface that all cache strategies must implement.\n */\nexport interface CacheStrategy {\n /**\n * Stores a cache entry.\n *\n * @param key - Cache key\n * @param entry - Cache entry to store\n * @returns Promise that resolves when entry is stored\n */\n set<T>(key: string, entry: CacheEntry<T>): Promise<void>;\n\n /**\n * Retrieves a cache entry.\n *\n * @param key - Cache key\n * @returns Promise that resolves to cache entry or null if not found\n */\n get<T>(key: string): Promise<CacheEntry<T> | null>;\n\n /**\n * Removes a cache entry.\n *\n * @param key - Cache key to remove\n * @returns Promise that resolves when entry is removed\n */\n delete(key: string): Promise<void>;\n\n /**\n * Clears all cache entries.\n *\n * @returns Promise that resolves when cache is cleared\n */\n clear(): Promise<void>;\n\n /**\n * Gets cache statistics.\n *\n * @returns Promise that resolves to cache statistics\n */\n getStats(): Promise<CacheStats>;\n\n /**\n * Disposes of the cache strategy and cleans up resources.\n * Optional method for cleanup.\n *\n * @returns Promise that resolves when cleanup is complete\n */\n dispose?(): Promise<void>;\n}\n"]}
@@ -1,3 +1,4 @@
1
1
  export type * from './cache';
2
+ export { CACHE_STRATEGIES } from './cache';
2
3
  export type * from './feature-flag';
3
4
  export type * from './community';
@@ -1,3 +1,8 @@
1
+ // @plyaz package - Built with tsup
1
2
 
3
+ // src/features/cache/types.ts
4
+ var CACHE_STRATEGIES = ["memory", "redis"];
5
+
6
+ export { CACHE_STRATEGIES };
2
7
  //# sourceMappingURL=index.js.map
3
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
1
+ {"version":3,"sources":["../../src/features/cache/types.ts"],"names":[],"mappings":";;;AAyBO,IAAM,gBAAA,GAAmB,CAAC,QAAA,EAAU,OAAO","file":"index.js","sourcesContent":["/**\n * Cache Types and Interfaces\n *\n * Type definitions for the caching layer.\n * This will be moved to @plyaz/core when the package structure is finalized.\n *\n * @fileoverview Cache type definitions\n * @version 1.0.0\n */\n\n/**\n * Cache entry structure that wraps cached data with metadata.\n */\nimport type {\n Configurable,\n WithExpiration,\n WithMetadata,\n Enabled,\n WithUrl,\n Timestamped,\n} from '../../common/types';\n\n/**\n * Available cache strategies\n */\nexport const CACHE_STRATEGIES = ['memory', 'redis'] as const;\n\n/**\n * Cache strategy type\n */\nexport type CacheStrategyType = (typeof CACHE_STRATEGIES)[number];\n\nexport interface CacheEntry<T = unknown>\n extends Partial<WithMetadata<Record<string, unknown>>>,\n WithExpiration<number>,\n Pick<Timestamped<number, number>, 'createdAt'> {\n /** The cached data */\n data: T;\n}\n\nexport interface GenericCacheEntry<T = unknown> {\n value: T;\n timestamp: number;\n ttl: number;\n}\n\n/**\n * Cache statistics for monitoring and debugging.\n */\nexport interface CacheStats {\n /** Total number of cache hits */\n hits: number;\n /** Total number of cache misses */\n misses: number;\n /** Total number of set operations */\n sets: number;\n /** Total number of delete operations */\n deletes: number;\n /** Number of entries currently in cache */\n size: number;\n /** Cache hit ratio (hits / (hits + misses)) */\n hitRatio?: number;\n}\n\n/**\n * Configuration for cache strategies.\n */\nexport interface CacheConfig extends Configurable, Enabled {\n /** Default TTL in seconds */\n ttl: number;\n /** Cache strategy to use */\n strategy: CacheStrategyType;\n /** Redis-specific configuration */\n redisConfig?: RedisCacheConfig;\n /** Memory cache specific configuration */\n memoryConfig?: MemoryCacheConfig;\n}\n\n/**\n * Configuration for memory cache strategy.\n */\nexport interface MemoryCacheConfig {\n /** Maximum number of entries to store (default: 1000) */\n maxSize?: number;\n /** Maximum number of entries to store (alias for maxSize) */\n maxEntries?: number;\n /** Check for expired entries every N milliseconds (default: 60000) */\n cleanupInterval?: number;\n /** Callback when entry is evicted */\n onEvict?: (key: string, entry: CacheEntry) => void;\n}\n\n/**\n * Configuration for Redis cache strategy.\n */\nexport interface RedisCacheConfig extends WithUrl {\n /** Redis password for authentication */\n password?: string;\n /** Redis database number */\n db?: number;\n /** Key prefix for Redis keys */\n keyPrefix?: string;\n /** Connection timeout in milliseconds */\n connectTimeout?: number;\n /** Command timeout in milliseconds */\n commandTimeout?: number;\n}\n\n/**\n * Cache manager statistics interface.\n */\nexport type CacheManagerStats = CacheStats;\n\n/**\n * Interface that all cache strategies must implement.\n */\nexport interface CacheStrategy {\n /**\n * Stores a cache entry.\n *\n * @param key - Cache key\n * @param entry - Cache entry to store\n * @returns Promise that resolves when entry is stored\n */\n set<T>(key: string, entry: CacheEntry<T>): Promise<void>;\n\n /**\n * Retrieves a cache entry.\n *\n * @param key - Cache key\n * @returns Promise that resolves to cache entry or null if not found\n */\n get<T>(key: string): Promise<CacheEntry<T> | null>;\n\n /**\n * Removes a cache entry.\n *\n * @param key - Cache key to remove\n * @returns Promise that resolves when entry is removed\n */\n delete(key: string): Promise<void>;\n\n /**\n * Clears all cache entries.\n *\n * @returns Promise that resolves when cache is cleared\n */\n clear(): Promise<void>;\n\n /**\n * Gets cache statistics.\n *\n * @returns Promise that resolves to cache statistics\n */\n getStats(): Promise<CacheStats>;\n\n /**\n * Disposes of the cache strategy and cleans up resources.\n * Optional method for cleanup.\n *\n * @returns Promise that resolves when cleanup is complete\n */\n dispose?(): Promise<void>;\n}\n"]}
package/dist/index.cjs CHANGED
@@ -345,6 +345,17 @@ var CORE_EVENTS = {
345
345
  }
346
346
  };
347
347
 
348
+ // src/core/services/keys.ts
349
+ var SERVICE_KEYS = {
350
+ /** Example domain service (backend) */
351
+ EXAMPLE: "example",
352
+ /** Example domain service (frontend) */
353
+ EXAMPLE_FRONTEND: "example-frontend",
354
+ /** Feature flags service */
355
+ FEATURE_FLAGS: "featureFlags"
356
+ };
357
+ var ALL_SERVICE_KEYS = Object.values(SERVICE_KEYS);
358
+
348
359
  // src/errors/enums.ts
349
360
  var ERROR_TYPE = {
350
361
  /** A general validation error (e.g., form or input errors). */
@@ -1833,7 +1844,19 @@ var CORE_ERROR_CODES = {
1833
1844
  INITIALIZATION_FAILED: ERROR_CODES.CORE_INITIALIZATION_FAILED,
1834
1845
  CONFIGURATION_INVALID: ERROR_CODES.CORE_CONFIGURATION_INVALID,
1835
1846
  OPERATION_FAILED: ERROR_CODES.CORE_OPERATION_FAILED,
1836
- UNKNOWN_ERROR: ERROR_CODES.CORE_UNKNOWN_ERROR
1847
+ UNKNOWN_ERROR: ERROR_CODES.CORE_UNKNOWN_ERROR,
1848
+ // Common/Generic Errors (used across core package)
1849
+ CLIENT_INITIALIZATION_FAILED: ERROR_CODES.CLIENT_INITIALIZATION_FAILED,
1850
+ CLIENT_INVALID_CONFIG: ERROR_CODES.CLIENT_INVALID_CONFIG,
1851
+ CONTEXT_OPERATION_FAILED: ERROR_CODES.CONTEXT_OPERATION_FAILED,
1852
+ FEATURE_NOT_SUPPORTED: ERROR_CODES.FEATURE_NOT_SUPPORTED,
1853
+ VALIDATION_ERROR: ERROR_CODES.VALIDATION_ERROR,
1854
+ NETWORK_ERROR: ERROR_CODES.NETWORK_ERROR,
1855
+ RESOURCE_NOT_FOUND: ERROR_CODES.RESOURCE_NOT_FOUND,
1856
+ DB_CONNECTION_FAILED: ERROR_CODES.DB_CONNECTION_FAILED,
1857
+ DB_DUPLICATE_ENTRY: ERROR_CODES.DB_DUPLICATE_ENTRY,
1858
+ PROVIDER_NOT_IMPLEMENTED: ERROR_CODES.PROVIDER_NOT_IMPLEMENTED,
1859
+ STORAGE_FILE_WRITE_FAILED: ERROR_CODES.STORAGE_FILE_WRITE_FAILED
1837
1860
  };
1838
1861
  var PAYMENT_ERROR_CODES = {
1839
1862
  // Timeout & Network
@@ -6289,6 +6312,9 @@ var CHAIN_ID = {
6289
6312
  BaseSepolia: 84532
6290
6313
  };
6291
6314
 
6315
+ // src/features/cache/types.ts
6316
+ var CACHE_STRATEGIES = ["memory", "redis"];
6317
+
6292
6318
  // src/user/enums.ts
6293
6319
  var COUNTRIES = {
6294
6320
  unitedKingdom: "unitedKingdom",
@@ -8504,6 +8530,7 @@ exports.ALERT_SEVERITY = ALERT_SEVERITY;
8504
8530
  exports.ALERT_SOURCE = ALERT_SOURCE;
8505
8531
  exports.ALERT_TYPES = ALERT_TYPES;
8506
8532
  exports.ALL_EVENTS = ALL_EVENTS;
8533
+ exports.ALL_SERVICE_KEYS = ALL_SERVICE_KEYS;
8507
8534
  exports.API_ERROR_CODES = API_ERROR_CODES;
8508
8535
  exports.APP_CONTEXTS = APP_CONTEXTS;
8509
8536
  exports.ATHLETE_PROFILE_ERRORS = ATHLETE_PROFILE_ERRORS;
@@ -8518,6 +8545,7 @@ exports.BUCKET_PURPOSE = BUCKET_PURPOSE;
8518
8545
  exports.BUSINESS_MODEL = BUSINESS_MODEL;
8519
8546
  exports.CACHE_DURATION_MS = CACHE_DURATION_MS;
8520
8547
  exports.CACHE_EVENTS = CACHE_EVENTS;
8548
+ exports.CACHE_STRATEGIES = CACHE_STRATEGIES;
8521
8549
  exports.CHAIN_ID = CHAIN_ID;
8522
8550
  exports.CHANGE_TYPES = CHANGE_TYPES;
8523
8551
  exports.CLIENT_EVENTS = CLIENT_EVENTS;
@@ -8668,6 +8696,7 @@ exports.ROUTER_RULE_NAME = ROUTER_RULE_NAME;
8668
8696
  exports.ROUTING_STRATEGY = ROUTING_STRATEGY;
8669
8697
  exports.RTT_THRESHOLDS = RTT_THRESHOLDS;
8670
8698
  exports.SECURITY_THREAT_TYPE = SECURITY_THREAT_TYPE;
8699
+ exports.SERVICE_KEYS = SERVICE_KEYS;
8671
8700
  exports.SIGNATURE_METHOD = SIGNATURE_METHOD;
8672
8701
  exports.SORT_DIRECTION = SORT_DIRECTION;
8673
8702
  exports.SPEED_THRESHOLDS = SPEED_THRESHOLDS;