@xbg.solutions/backend-core 1.0.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.
- package/lib/core/src/app.d.ts +28 -0
- package/lib/core/src/app.d.ts.map +1 -0
- package/lib/core/src/app.js +188 -0
- package/lib/core/src/app.js.map +1 -0
- package/lib/core/src/base/BaseController.d.ts +108 -0
- package/lib/core/src/base/BaseController.d.ts.map +1 -0
- package/lib/core/src/base/BaseController.js +307 -0
- package/lib/core/src/base/BaseController.js.map +1 -0
- package/lib/core/src/base/BaseEntity.d.ts +92 -0
- package/lib/core/src/base/BaseEntity.d.ts.map +1 -0
- package/lib/core/src/base/BaseEntity.js +143 -0
- package/lib/core/src/base/BaseEntity.js.map +1 -0
- package/lib/core/src/base/BaseRepository.d.ts +124 -0
- package/lib/core/src/base/BaseRepository.d.ts.map +1 -0
- package/lib/core/src/base/BaseRepository.js +414 -0
- package/lib/core/src/base/BaseRepository.js.map +1 -0
- package/lib/core/src/base/BaseService.d.ts +89 -0
- package/lib/core/src/base/BaseService.d.ts.map +1 -0
- package/lib/core/src/base/BaseService.js +342 -0
- package/lib/core/src/base/BaseService.js.map +1 -0
- package/lib/core/src/base/index.d.ts +8 -0
- package/lib/core/src/base/index.d.ts.map +1 -0
- package/lib/core/src/base/index.js +24 -0
- package/lib/core/src/base/index.js.map +1 -0
- package/lib/core/src/config/app.config.d.ts +70 -0
- package/lib/core/src/config/app.config.d.ts.map +1 -0
- package/lib/core/src/config/app.config.js +106 -0
- package/lib/core/src/config/app.config.js.map +1 -0
- package/lib/core/src/config/auth.config.d.ts +54 -0
- package/lib/core/src/config/auth.config.d.ts.map +1 -0
- package/lib/core/src/config/auth.config.js +88 -0
- package/lib/core/src/config/auth.config.js.map +1 -0
- package/lib/core/src/config/cache.config.d.ts +47 -0
- package/lib/core/src/config/cache.config.d.ts.map +1 -0
- package/lib/core/src/config/cache.config.js +225 -0
- package/lib/core/src/config/cache.config.js.map +1 -0
- package/lib/core/src/config/communications.config.d.ts +175 -0
- package/lib/core/src/config/communications.config.d.ts.map +1 -0
- package/lib/core/src/config/communications.config.js +219 -0
- package/lib/core/src/config/communications.config.js.map +1 -0
- package/lib/core/src/config/database.config.d.ts +68 -0
- package/lib/core/src/config/database.config.d.ts.map +1 -0
- package/lib/core/src/config/database.config.js +95 -0
- package/lib/core/src/config/database.config.js.map +1 -0
- package/lib/core/src/config/firebase-event-mapping.config.d.ts +41 -0
- package/lib/core/src/config/firebase-event-mapping.config.d.ts.map +1 -0
- package/lib/core/src/config/firebase-event-mapping.config.js +180 -0
- package/lib/core/src/config/firebase-event-mapping.config.js.map +1 -0
- package/lib/core/src/config/firestore.config.d.ts +61 -0
- package/lib/core/src/config/firestore.config.d.ts.map +1 -0
- package/lib/core/src/config/firestore.config.js +74 -0
- package/lib/core/src/config/firestore.config.js.map +1 -0
- package/lib/core/src/config/index.d.ts +15 -0
- package/lib/core/src/config/index.d.ts.map +1 -0
- package/lib/core/src/config/index.js +41 -0
- package/lib/core/src/config/index.js.map +1 -0
- package/lib/core/src/config/maps.config.d.ts +31 -0
- package/lib/core/src/config/maps.config.d.ts.map +1 -0
- package/lib/core/src/config/maps.config.js +50 -0
- package/lib/core/src/config/maps.config.js.map +1 -0
- package/lib/core/src/config/middleware.config.d.ts +57 -0
- package/lib/core/src/config/middleware.config.d.ts.map +1 -0
- package/lib/core/src/config/middleware.config.js +68 -0
- package/lib/core/src/config/middleware.config.js.map +1 -0
- package/lib/core/src/config/tokens.config.d.ts +53 -0
- package/lib/core/src/config/tokens.config.d.ts.map +1 -0
- package/lib/core/src/config/tokens.config.js +129 -0
- package/lib/core/src/config/tokens.config.js.map +1 -0
- package/lib/core/src/generator/generator.d.ts +38 -0
- package/lib/core/src/generator/generator.d.ts.map +1 -0
- package/lib/core/src/generator/generator.js +159 -0
- package/lib/core/src/generator/generator.js.map +1 -0
- package/lib/core/src/generator/index.d.ts +7 -0
- package/lib/core/src/generator/index.d.ts.map +1 -0
- package/lib/core/src/generator/index.js +23 -0
- package/lib/core/src/generator/index.js.map +1 -0
- package/lib/core/src/generator/parser.d.ts +10 -0
- package/lib/core/src/generator/parser.d.ts.map +1 -0
- package/lib/core/src/generator/parser.js +197 -0
- package/lib/core/src/generator/parser.js.map +1 -0
- package/lib/core/src/generator/types.d.ts +112 -0
- package/lib/core/src/generator/types.d.ts.map +1 -0
- package/lib/core/src/generator/types.js +7 -0
- package/lib/core/src/generator/types.js.map +1 -0
- package/lib/core/src/index.d.ts +19 -0
- package/lib/core/src/index.d.ts.map +1 -0
- package/lib/core/src/index.js +46 -0
- package/lib/core/src/index.js.map +1 -0
- package/lib/core/src/middleware/auth.middleware.d.ts +57 -0
- package/lib/core/src/middleware/auth.middleware.d.ts.map +1 -0
- package/lib/core/src/middleware/auth.middleware.js +256 -0
- package/lib/core/src/middleware/auth.middleware.js.map +1 -0
- package/lib/core/src/middleware/cors.middleware.d.ts +13 -0
- package/lib/core/src/middleware/cors.middleware.d.ts.map +1 -0
- package/lib/core/src/middleware/cors.middleware.js +50 -0
- package/lib/core/src/middleware/cors.middleware.js.map +1 -0
- package/lib/core/src/middleware/error.middleware.d.ts +46 -0
- package/lib/core/src/middleware/error.middleware.d.ts.map +1 -0
- package/lib/core/src/middleware/error.middleware.js +174 -0
- package/lib/core/src/middleware/error.middleware.js.map +1 -0
- package/lib/core/src/middleware/index.d.ts +11 -0
- package/lib/core/src/middleware/index.d.ts.map +1 -0
- package/lib/core/src/middleware/index.js +27 -0
- package/lib/core/src/middleware/index.js.map +1 -0
- package/lib/core/src/middleware/logging.middleware.d.ts +10 -0
- package/lib/core/src/middleware/logging.middleware.d.ts.map +1 -0
- package/lib/core/src/middleware/logging.middleware.js +87 -0
- package/lib/core/src/middleware/logging.middleware.js.map +1 -0
- package/lib/core/src/middleware/rateLimit.middleware.d.ts +26 -0
- package/lib/core/src/middleware/rateLimit.middleware.d.ts.map +1 -0
- package/lib/core/src/middleware/rateLimit.middleware.js +105 -0
- package/lib/core/src/middleware/rateLimit.middleware.js.map +1 -0
- package/lib/core/src/middleware/requestId.middleware.d.ts +11 -0
- package/lib/core/src/middleware/requestId.middleware.d.ts.map +1 -0
- package/lib/core/src/middleware/requestId.middleware.js +26 -0
- package/lib/core/src/middleware/requestId.middleware.js.map +1 -0
- package/lib/core/src/middleware/validation.middleware.d.ts +25 -0
- package/lib/core/src/middleware/validation.middleware.d.ts.map +1 -0
- package/lib/core/src/middleware/validation.middleware.js +133 -0
- package/lib/core/src/middleware/validation.middleware.js.map +1 -0
- package/lib/core/src/types/errors.d.ts +119 -0
- package/lib/core/src/types/errors.d.ts.map +1 -0
- package/lib/core/src/types/errors.js +210 -0
- package/lib/core/src/types/errors.js.map +1 -0
- package/lib/utils-cache-connector/src/cache-connector.d.ts +139 -0
- package/lib/utils-cache-connector/src/cache-connector.d.ts.map +1 -0
- package/lib/utils-cache-connector/src/cache-connector.js +277 -0
- package/lib/utils-cache-connector/src/cache-connector.js.map +1 -0
- package/lib/utils-cache-connector/src/index.d.ts +52 -0
- package/lib/utils-cache-connector/src/index.d.ts.map +1 -0
- package/lib/utils-cache-connector/src/index.js +103 -0
- package/lib/utils-cache-connector/src/index.js.map +1 -0
- package/lib/utils-cache-connector/src/providers/base-cache-provider.d.ts +95 -0
- package/lib/utils-cache-connector/src/providers/base-cache-provider.d.ts.map +1 -0
- package/lib/utils-cache-connector/src/providers/base-cache-provider.js +120 -0
- package/lib/utils-cache-connector/src/providers/base-cache-provider.js.map +1 -0
- package/lib/utils-cache-connector/src/providers/firestore-cache-provider.d.ts +58 -0
- package/lib/utils-cache-connector/src/providers/firestore-cache-provider.d.ts.map +1 -0
- package/lib/utils-cache-connector/src/providers/firestore-cache-provider.js +418 -0
- package/lib/utils-cache-connector/src/providers/firestore-cache-provider.js.map +1 -0
- package/lib/utils-cache-connector/src/providers/memory-cache-provider.d.ts +57 -0
- package/lib/utils-cache-connector/src/providers/memory-cache-provider.d.ts.map +1 -0
- package/lib/utils-cache-connector/src/providers/memory-cache-provider.js +217 -0
- package/lib/utils-cache-connector/src/providers/memory-cache-provider.js.map +1 -0
- package/lib/utils-cache-connector/src/providers/noop-cache-provider.d.ts +21 -0
- package/lib/utils-cache-connector/src/providers/noop-cache-provider.d.ts.map +1 -0
- package/lib/utils-cache-connector/src/providers/noop-cache-provider.js +42 -0
- package/lib/utils-cache-connector/src/providers/noop-cache-provider.js.map +1 -0
- package/lib/utils-cache-connector/src/providers/redis-cache-provider.d.ts +64 -0
- package/lib/utils-cache-connector/src/providers/redis-cache-provider.d.ts.map +1 -0
- package/lib/utils-cache-connector/src/providers/redis-cache-provider.js +414 -0
- package/lib/utils-cache-connector/src/providers/redis-cache-provider.js.map +1 -0
- package/lib/utils-cache-connector/src/types.d.ts +342 -0
- package/lib/utils-cache-connector/src/types.d.ts.map +1 -0
- package/lib/utils-cache-connector/src/types.js +8 -0
- package/lib/utils-cache-connector/src/types.js.map +1 -0
- package/lib/utils-events/src/event-bus.d.ts +42 -0
- package/lib/utils-events/src/event-bus.d.ts.map +1 -0
- package/lib/utils-events/src/event-bus.js +93 -0
- package/lib/utils-events/src/event-bus.js.map +1 -0
- package/lib/utils-events/src/event-types.d.ts +146 -0
- package/lib/utils-events/src/event-types.d.ts.map +1 -0
- package/lib/utils-events/src/event-types.js +49 -0
- package/lib/utils-events/src/event-types.js.map +1 -0
- package/lib/utils-events/src/index.d.ts +7 -0
- package/lib/utils-events/src/index.d.ts.map +1 -0
- package/lib/utils-events/src/index.js +11 -0
- package/lib/utils-events/src/index.js.map +1 -0
- package/lib/utils-logger/src/index.d.ts +12 -0
- package/lib/utils-logger/src/index.d.ts.map +1 -0
- package/lib/utils-logger/src/index.js +29 -0
- package/lib/utils-logger/src/index.js.map +1 -0
- package/lib/utils-logger/src/logger-types.d.ts +32 -0
- package/lib/utils-logger/src/logger-types.d.ts.map +1 -0
- package/lib/utils-logger/src/logger-types.js +17 -0
- package/lib/utils-logger/src/logger-types.js.map +1 -0
- package/lib/utils-logger/src/logger.d.ts +42 -0
- package/lib/utils-logger/src/logger.d.ts.map +1 -0
- package/lib/utils-logger/src/logger.js +123 -0
- package/lib/utils-logger/src/logger.js.map +1 -0
- package/package.json +49 -0
- package/src/templates/controller.hbs +48 -0
- package/src/templates/entity.hbs +80 -0
- package/src/templates/repository.hbs +56 -0
- package/src/templates/service.hbs +108 -0
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cache Connector Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Defines the types and interfaces for the multi-level caching system.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Supported cache provider types
|
|
8
|
+
*/
|
|
9
|
+
export type CacheProviderType = 'memory' | 'firestore' | 'redis' | 'noop';
|
|
10
|
+
/**
|
|
11
|
+
* Cache strategies for advanced behavior
|
|
12
|
+
*/
|
|
13
|
+
export type CacheStrategy = 'write-through' | 'write-behind' | 'cache-aside' | 'refresh-ahead';
|
|
14
|
+
/**
|
|
15
|
+
* Global cache configuration (project-level)
|
|
16
|
+
*/
|
|
17
|
+
export interface CacheConfig {
|
|
18
|
+
/**
|
|
19
|
+
* Master switch - if false, all caching is disabled
|
|
20
|
+
*/
|
|
21
|
+
enabled: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Default provider for repositories that don't specify
|
|
24
|
+
*/
|
|
25
|
+
defaultProvider: CacheProviderType;
|
|
26
|
+
/**
|
|
27
|
+
* Default TTL in seconds
|
|
28
|
+
*/
|
|
29
|
+
defaultTTL: number;
|
|
30
|
+
/**
|
|
31
|
+
* Global cache namespace (for versioning)
|
|
32
|
+
* Change this to invalidate all cached data
|
|
33
|
+
*/
|
|
34
|
+
namespace: string;
|
|
35
|
+
/**
|
|
36
|
+
* Provider-specific configurations
|
|
37
|
+
*/
|
|
38
|
+
providers: {
|
|
39
|
+
memory: MemoryCacheProviderConfig;
|
|
40
|
+
firestore: FirestoreCacheProviderConfig;
|
|
41
|
+
redis?: RedisCacheProviderConfig;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Memory cache provider configuration
|
|
46
|
+
*/
|
|
47
|
+
export interface MemoryCacheProviderConfig {
|
|
48
|
+
/**
|
|
49
|
+
* Maximum cache size in bytes
|
|
50
|
+
*/
|
|
51
|
+
maxSize: number;
|
|
52
|
+
/**
|
|
53
|
+
* Interval to check for expired entries (seconds)
|
|
54
|
+
*/
|
|
55
|
+
checkPeriod: number;
|
|
56
|
+
/**
|
|
57
|
+
* Whether to use LRU eviction when max size is reached
|
|
58
|
+
*/
|
|
59
|
+
useClones?: boolean;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Firestore cache provider configuration
|
|
63
|
+
*/
|
|
64
|
+
export interface FirestoreCacheProviderConfig {
|
|
65
|
+
/**
|
|
66
|
+
* Which database to use for cache storage
|
|
67
|
+
*/
|
|
68
|
+
database: string;
|
|
69
|
+
/**
|
|
70
|
+
* Collection name for cache entries
|
|
71
|
+
*/
|
|
72
|
+
collection: string;
|
|
73
|
+
/**
|
|
74
|
+
* Enable automatic cleanup of expired entries
|
|
75
|
+
*/
|
|
76
|
+
enableCleanup: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Cleanup interval in seconds
|
|
79
|
+
*/
|
|
80
|
+
cleanupInterval: number;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Redis cache provider configuration
|
|
84
|
+
*/
|
|
85
|
+
export interface RedisCacheProviderConfig {
|
|
86
|
+
/**
|
|
87
|
+
* Redis server host
|
|
88
|
+
*/
|
|
89
|
+
host: string;
|
|
90
|
+
/**
|
|
91
|
+
* Redis server port
|
|
92
|
+
*/
|
|
93
|
+
port: number;
|
|
94
|
+
/**
|
|
95
|
+
* Redis password (optional)
|
|
96
|
+
*/
|
|
97
|
+
password?: string;
|
|
98
|
+
/**
|
|
99
|
+
* Redis database number
|
|
100
|
+
*/
|
|
101
|
+
db: number;
|
|
102
|
+
/**
|
|
103
|
+
* Connection timeout in milliseconds
|
|
104
|
+
*/
|
|
105
|
+
connectTimeout?: number;
|
|
106
|
+
/**
|
|
107
|
+
* Enable TLS
|
|
108
|
+
*/
|
|
109
|
+
tls?: boolean;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Repository-level cache configuration
|
|
113
|
+
*/
|
|
114
|
+
export interface RepositoryCacheConfig {
|
|
115
|
+
/**
|
|
116
|
+
* Enable caching for this repository (only if global is enabled)
|
|
117
|
+
*/
|
|
118
|
+
enabled: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Which provider to use (overrides global default)
|
|
121
|
+
*/
|
|
122
|
+
provider?: CacheProviderType;
|
|
123
|
+
/**
|
|
124
|
+
* Default TTL for this repository (overrides global default)
|
|
125
|
+
*/
|
|
126
|
+
ttl?: number;
|
|
127
|
+
/**
|
|
128
|
+
* Cache key prefix for this repository
|
|
129
|
+
*/
|
|
130
|
+
keyPrefix?: string;
|
|
131
|
+
/**
|
|
132
|
+
* Invalidation tags (auto-applied to all cache entries)
|
|
133
|
+
*/
|
|
134
|
+
tags?: string[];
|
|
135
|
+
/**
|
|
136
|
+
* Advanced: cache strategies
|
|
137
|
+
*/
|
|
138
|
+
strategies?: CacheStrategy[];
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Method-level cache options (runtime)
|
|
142
|
+
*/
|
|
143
|
+
export interface CacheOptions {
|
|
144
|
+
/**
|
|
145
|
+
* Time-to-live override in seconds
|
|
146
|
+
*/
|
|
147
|
+
ttl?: number;
|
|
148
|
+
/**
|
|
149
|
+
* Tags for cache invalidation
|
|
150
|
+
*/
|
|
151
|
+
tags?: string[];
|
|
152
|
+
/**
|
|
153
|
+
* Force refresh, skip cache lookup
|
|
154
|
+
*/
|
|
155
|
+
forceRefresh?: boolean;
|
|
156
|
+
/**
|
|
157
|
+
* Additional metadata for debugging
|
|
158
|
+
*/
|
|
159
|
+
metadata?: Record<string, any>;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Options for setting cache entries
|
|
163
|
+
*/
|
|
164
|
+
export interface CacheSetOptions extends CacheOptions {
|
|
165
|
+
/**
|
|
166
|
+
* Provider to use for this operation
|
|
167
|
+
*/
|
|
168
|
+
provider?: CacheProviderType;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Options for getting cache entries
|
|
172
|
+
*/
|
|
173
|
+
export interface CacheGetOptions {
|
|
174
|
+
/**
|
|
175
|
+
* Provider to use for this operation
|
|
176
|
+
*/
|
|
177
|
+
provider?: CacheProviderType;
|
|
178
|
+
/**
|
|
179
|
+
* Return metadata along with value
|
|
180
|
+
*/
|
|
181
|
+
includeMetadata?: boolean;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Options for invalidation operations
|
|
185
|
+
*/
|
|
186
|
+
export interface CacheInvalidateOptions {
|
|
187
|
+
/**
|
|
188
|
+
* Provider to use for this operation
|
|
189
|
+
*/
|
|
190
|
+
provider?: CacheProviderType;
|
|
191
|
+
/**
|
|
192
|
+
* Pattern matching mode
|
|
193
|
+
*/
|
|
194
|
+
pattern?: 'exact' | 'prefix' | 'suffix' | 'contains';
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Cache entry metadata
|
|
198
|
+
*/
|
|
199
|
+
export interface CacheEntryMetadata {
|
|
200
|
+
/**
|
|
201
|
+
* When the entry was created
|
|
202
|
+
*/
|
|
203
|
+
createdAt: Date;
|
|
204
|
+
/**
|
|
205
|
+
* When the entry expires
|
|
206
|
+
*/
|
|
207
|
+
expiresAt: Date;
|
|
208
|
+
/**
|
|
209
|
+
* Number of times this entry has been accessed
|
|
210
|
+
*/
|
|
211
|
+
hitCount: number;
|
|
212
|
+
/**
|
|
213
|
+
* Last access timestamp
|
|
214
|
+
*/
|
|
215
|
+
lastAccessedAt: Date;
|
|
216
|
+
/**
|
|
217
|
+
* Tags associated with this entry
|
|
218
|
+
*/
|
|
219
|
+
tags: string[];
|
|
220
|
+
/**
|
|
221
|
+
* Size in bytes (approximate)
|
|
222
|
+
*/
|
|
223
|
+
size?: number;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Cache entry with metadata
|
|
227
|
+
*/
|
|
228
|
+
export interface CacheEntry<T = any> {
|
|
229
|
+
/**
|
|
230
|
+
* Cache key
|
|
231
|
+
*/
|
|
232
|
+
key: string;
|
|
233
|
+
/**
|
|
234
|
+
* Cached value
|
|
235
|
+
*/
|
|
236
|
+
value: T;
|
|
237
|
+
/**
|
|
238
|
+
* Entry metadata
|
|
239
|
+
*/
|
|
240
|
+
metadata: CacheEntryMetadata;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Cache statistics
|
|
244
|
+
*/
|
|
245
|
+
export interface CacheStats {
|
|
246
|
+
/**
|
|
247
|
+
* Total number of cache hits
|
|
248
|
+
*/
|
|
249
|
+
hits: number;
|
|
250
|
+
/**
|
|
251
|
+
* Total number of cache misses
|
|
252
|
+
*/
|
|
253
|
+
misses: number;
|
|
254
|
+
/**
|
|
255
|
+
* Hit ratio (hits / (hits + misses))
|
|
256
|
+
*/
|
|
257
|
+
hitRatio: number;
|
|
258
|
+
/**
|
|
259
|
+
* Total number of entries in cache
|
|
260
|
+
*/
|
|
261
|
+
entryCount: number;
|
|
262
|
+
/**
|
|
263
|
+
* Total size of cache in bytes
|
|
264
|
+
*/
|
|
265
|
+
size: number;
|
|
266
|
+
/**
|
|
267
|
+
* Number of evictions (LRU or size-based)
|
|
268
|
+
*/
|
|
269
|
+
evictions: number;
|
|
270
|
+
/**
|
|
271
|
+
* Number of expirations
|
|
272
|
+
*/
|
|
273
|
+
expirations: number;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Cache operation result
|
|
277
|
+
*/
|
|
278
|
+
export interface CacheOperationResult {
|
|
279
|
+
/**
|
|
280
|
+
* Whether the operation succeeded
|
|
281
|
+
*/
|
|
282
|
+
success: boolean;
|
|
283
|
+
/**
|
|
284
|
+
* Error message if operation failed
|
|
285
|
+
*/
|
|
286
|
+
error?: string;
|
|
287
|
+
/**
|
|
288
|
+
* Operation duration in milliseconds
|
|
289
|
+
*/
|
|
290
|
+
duration?: number;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Base cache provider interface
|
|
294
|
+
* All cache providers must implement this interface
|
|
295
|
+
*/
|
|
296
|
+
export interface ICacheProvider {
|
|
297
|
+
/**
|
|
298
|
+
* Get a value from cache
|
|
299
|
+
*/
|
|
300
|
+
get<T>(key: string): Promise<T | null>;
|
|
301
|
+
/**
|
|
302
|
+
* Get a value with metadata
|
|
303
|
+
*/
|
|
304
|
+
getWithMetadata<T>(key: string): Promise<CacheEntry<T> | null>;
|
|
305
|
+
/**
|
|
306
|
+
* Set a value in cache
|
|
307
|
+
*/
|
|
308
|
+
set<T>(key: string, value: T, options?: CacheSetOptions): Promise<void>;
|
|
309
|
+
/**
|
|
310
|
+
* Delete a specific key
|
|
311
|
+
*/
|
|
312
|
+
delete(key: string): Promise<boolean>;
|
|
313
|
+
/**
|
|
314
|
+
* Check if a key exists
|
|
315
|
+
*/
|
|
316
|
+
has(key: string): Promise<boolean>;
|
|
317
|
+
/**
|
|
318
|
+
* Invalidate cache entries by tags
|
|
319
|
+
*/
|
|
320
|
+
invalidateByTags(tags: string[]): Promise<number>;
|
|
321
|
+
/**
|
|
322
|
+
* Invalidate cache entries by pattern
|
|
323
|
+
*/
|
|
324
|
+
invalidateByPattern(pattern: string, mode?: 'prefix' | 'suffix' | 'contains'): Promise<number>;
|
|
325
|
+
/**
|
|
326
|
+
* Clear all cache entries
|
|
327
|
+
*/
|
|
328
|
+
clear(): Promise<void>;
|
|
329
|
+
/**
|
|
330
|
+
* Get cache statistics
|
|
331
|
+
*/
|
|
332
|
+
getStats(): Promise<CacheStats>;
|
|
333
|
+
/**
|
|
334
|
+
* Get the provider type
|
|
335
|
+
*/
|
|
336
|
+
getType(): CacheProviderType;
|
|
337
|
+
/**
|
|
338
|
+
* Cleanup expired entries (if supported)
|
|
339
|
+
*/
|
|
340
|
+
cleanup?(): Promise<number>;
|
|
341
|
+
}
|
|
342
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../utils-cache-connector/src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,WAAW,GAAG,OAAO,GAAG,MAAM,CAAC;AAE1E;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,eAAe,GACf,cAAc,GACd,aAAa,GACb,eAAe,CAAC;AAEpB;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;OAEG;IACH,eAAe,EAAE,iBAAiB,CAAC;IAEnC;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,SAAS,EAAE;QACT,MAAM,EAAE,yBAAyB,CAAC;QAClC,SAAS,EAAE,4BAA4B,CAAC;QACxC,KAAK,CAAC,EAAE,wBAAwB,CAAC;KAClC,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,aAAa,EAAE,OAAO,CAAC;IAEvB;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,IAAI,EAA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,IAAI,CAAC,CAAC;IAEvC;;OAEG;IACH,eAAe,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAE/D;;OAEG;IACH,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAExE;;OAEG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEtC;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEnC;;OAEG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAElD;;OAEG;IACH,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE/F;;OAEG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvB;;OAEG;IACH,QAAQ,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC;IAEhC;;OAEG;IACH,OAAO,IAAI,iBAAiB,CAAC;IAE7B;;OAEG;IACH,OAAO,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CAC7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../utils-cache-connector/src/types.ts"],"names":[],"mappings":";AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal Event Bus
|
|
3
|
+
*
|
|
4
|
+
* Decouples components via publish/subscribe pattern.
|
|
5
|
+
* Uses Node.js EventEmitter for reliability.
|
|
6
|
+
*/
|
|
7
|
+
import { EventEmitter } from 'events';
|
|
8
|
+
import { EventType, BaseEventPayload } from './event-types';
|
|
9
|
+
declare class EventBus extends EventEmitter {
|
|
10
|
+
constructor();
|
|
11
|
+
/**
|
|
12
|
+
* Emit an event with type-safe payload
|
|
13
|
+
*/
|
|
14
|
+
publish<T extends BaseEventPayload>(eventType: EventType, payload: T): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Subscribe to an event
|
|
17
|
+
*/
|
|
18
|
+
subscribe<T extends BaseEventPayload>(eventType: EventType, handler: (payload: T) => void | Promise<void>): void;
|
|
19
|
+
/**
|
|
20
|
+
* Subscribe to an event (one-time only)
|
|
21
|
+
*/
|
|
22
|
+
subscribeOnce<T extends BaseEventPayload>(eventType: EventType, handler: (payload: T) => void | Promise<void>): void;
|
|
23
|
+
/**
|
|
24
|
+
* Unsubscribe from an event
|
|
25
|
+
*/
|
|
26
|
+
unsubscribe<T extends BaseEventPayload>(eventType: EventType, handler: (payload: T) => void | Promise<void>): void;
|
|
27
|
+
/**
|
|
28
|
+
* Unsubscribe all handlers for an event type
|
|
29
|
+
*/
|
|
30
|
+
unsubscribeAll(eventType: EventType): void;
|
|
31
|
+
/**
|
|
32
|
+
* Get count of listeners for an event type
|
|
33
|
+
*/
|
|
34
|
+
listenerCount(eventType: EventType): number;
|
|
35
|
+
/**
|
|
36
|
+
* Clear all event listeners (useful for testing)
|
|
37
|
+
*/
|
|
38
|
+
clear(): void;
|
|
39
|
+
}
|
|
40
|
+
export declare const eventBus: EventBus;
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=event-bus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-bus.d.ts","sourceRoot":"","sources":["../../../../utils-events/src/event-bus.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAE5D,cAAM,QAAS,SAAQ,YAAY;;IAQjC;;OAEG;IACH,OAAO,CAAC,CAAC,SAAS,gBAAgB,EAChC,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,CAAC,GACT,OAAO;IAqCV;;OAEG;IACH,SAAS,CAAC,CAAC,SAAS,gBAAgB,EAClC,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAC5C,IAAI;IAIP;;OAEG;IACH,aAAa,CAAC,CAAC,SAAS,gBAAgB,EACtC,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAC5C,IAAI;IAIP;;OAEG;IACH,WAAW,CAAC,CAAC,SAAS,gBAAgB,EACpC,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAC5C,IAAI;IAIP;;OAEG;IACH,cAAc,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;IAI1C;;OAEG;IACH,aAAa,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM;IAI3C;;OAEG;IACH,KAAK,IAAI,IAAI;CAGd;AAGD,eAAO,MAAM,QAAQ,UAAiB,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Internal Event Bus
|
|
4
|
+
*
|
|
5
|
+
* Decouples components via publish/subscribe pattern.
|
|
6
|
+
* Uses Node.js EventEmitter for reliability.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.eventBus = void 0;
|
|
10
|
+
const events_1 = require("events");
|
|
11
|
+
class EventBus extends events_1.EventEmitter {
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
// Increase max listeners to avoid warnings in complex workflows
|
|
15
|
+
this.setMaxListeners(100);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Emit an event with type-safe payload
|
|
19
|
+
*/
|
|
20
|
+
publish(eventType, payload) {
|
|
21
|
+
// Add timestamp if not provided
|
|
22
|
+
if (!payload.timestamp) {
|
|
23
|
+
payload.timestamp = new Date();
|
|
24
|
+
}
|
|
25
|
+
// Check if there are any listeners
|
|
26
|
+
const listenerCount = this.listenerCount(eventType);
|
|
27
|
+
if (listenerCount === 0) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
// Call each listener and catch any errors to prevent one failing listener
|
|
31
|
+
// from stopping others from being called
|
|
32
|
+
const rawListeners = this.rawListeners(eventType);
|
|
33
|
+
for (const rawListener of rawListeners) {
|
|
34
|
+
try {
|
|
35
|
+
// Check if this is a once listener (has a 'listener' property)
|
|
36
|
+
if (typeof rawListener === 'function' && rawListener.listener) {
|
|
37
|
+
// For once listeners, remove them first, then call
|
|
38
|
+
this.off(eventType, rawListener);
|
|
39
|
+
rawListener.listener(payload);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
// Regular listener
|
|
43
|
+
rawListener(payload);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
// Silently catch errors from listeners
|
|
48
|
+
// This matches the behavior expected by the tests
|
|
49
|
+
// where one failing listener doesn't stop others
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Subscribe to an event
|
|
56
|
+
*/
|
|
57
|
+
subscribe(eventType, handler) {
|
|
58
|
+
this.on(eventType, handler);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Subscribe to an event (one-time only)
|
|
62
|
+
*/
|
|
63
|
+
subscribeOnce(eventType, handler) {
|
|
64
|
+
this.once(eventType, handler);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Unsubscribe from an event
|
|
68
|
+
*/
|
|
69
|
+
unsubscribe(eventType, handler) {
|
|
70
|
+
this.off(eventType, handler);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Unsubscribe all handlers for an event type
|
|
74
|
+
*/
|
|
75
|
+
unsubscribeAll(eventType) {
|
|
76
|
+
this.removeAllListeners(eventType);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get count of listeners for an event type
|
|
80
|
+
*/
|
|
81
|
+
listenerCount(eventType) {
|
|
82
|
+
return super.listenerCount(eventType);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Clear all event listeners (useful for testing)
|
|
86
|
+
*/
|
|
87
|
+
clear() {
|
|
88
|
+
this.removeAllListeners();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// Singleton instance
|
|
92
|
+
exports.eventBus = new EventBus();
|
|
93
|
+
//# sourceMappingURL=event-bus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-bus.js","sourceRoot":"","sources":["../../../../utils-events/src/event-bus.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,mCAAsC;AAGtC,MAAM,QAAS,SAAQ,qBAAY;IACjC;QACE,KAAK,EAAE,CAAC;QAER,gEAAgE;QAChE,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,OAAO,CACL,SAAoB,EACpB,OAAU;QAEV,gCAAgC;QAChC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;YACvB,OAAO,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;QACjC,CAAC;QAED,mCAAmC;QACnC,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;QAEpD,IAAI,aAAa,KAAK,CAAC,EAAE,CAAC;YACxB,OAAO,KAAK,CAAC;QACf,CA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BAAkB,EAAE,CAAC;IAC5B,CAAC;CACF;AAED,qBAAqB;AACR,QAAA,QAAQ,GAAG,IAAI,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Base event types for the internal event bus. These cover the standard
|
|
5
|
+
* lifecycle events that most applications need out of the box.
|
|
6
|
+
*
|
|
7
|
+
* ─── Extending with project-specific events ───────────────────────────
|
|
8
|
+
*
|
|
9
|
+
* The code generator adds entity-specific CRUD events automatically
|
|
10
|
+
* (e.g. ORDER_CREATED, PRODUCT_UPDATED) via BaseService.publishEvent().
|
|
11
|
+
* Those events are cast to EventType at runtime, so they work with the
|
|
12
|
+
* event bus without being listed here.
|
|
13
|
+
*
|
|
14
|
+
* To add custom domain events (e.g. ORDER_SHIPPED, PAYMENT_FAILED):
|
|
15
|
+
*
|
|
16
|
+
* 1. Add the new member to this enum.
|
|
17
|
+
* 2. Optionally define a typed payload interface below.
|
|
18
|
+
* 3. Add the mapping to EventPayloadMap for full type safety.
|
|
19
|
+
* 4. Subscribe in your service or in subscribers/.
|
|
20
|
+
*
|
|
21
|
+
* The enum is deliberately kept small so that new projects start clean
|
|
22
|
+
* and only grow the event catalogue as needed.
|
|
23
|
+
*/
|
|
24
|
+
export declare enum EventType {
|
|
25
|
+
USER_CREATED = "user.created",
|
|
26
|
+
USER_UPDATED = "user.updated",
|
|
27
|
+
USER_DELETED = "user.deleted",
|
|
28
|
+
AUTH_LOGIN = "auth.login",
|
|
29
|
+
AUTH_LOGOUT = "auth.logout",
|
|
30
|
+
AUTH_TOKEN_REFRESHED = "auth.token_refreshed",
|
|
31
|
+
AUTH_TOKEN_BLACKLISTED = "auth.token_blacklisted",
|
|
32
|
+
AUTH_PASSWORD_CHANGED = "auth.password_changed",
|
|
33
|
+
FILE_UPLOADED = "file.uploaded",
|
|
34
|
+
FILE_DELETED = "file.deleted",
|
|
35
|
+
NOTIFICATION_SENT = "notification.sent",
|
|
36
|
+
NOTIFICATION_FAILED = "notification.failed",
|
|
37
|
+
/** Catch-all for external data changes (Firebase triggers, webhooks, etc.) */
|
|
38
|
+
EXTERNAL_DATA_CHANGE = "external.data.change"
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Every event payload extends this interface.
|
|
42
|
+
* The event bus adds a `timestamp` automatically if one is not provided.
|
|
43
|
+
*/
|
|
44
|
+
export interface BaseEventPayload {
|
|
45
|
+
timestamp?: Date;
|
|
46
|
+
[key: string]: unknown;
|
|
47
|
+
}
|
|
48
|
+
/** Payload published by BaseService on entity creation */
|
|
49
|
+
export interface EntityCreatedPayload extends BaseEventPayload {
|
|
50
|
+
entityId: string;
|
|
51
|
+
entityType: string;
|
|
52
|
+
action: 'CREATED';
|
|
53
|
+
userId?: string;
|
|
54
|
+
requestId?: string;
|
|
55
|
+
data?: Record<string, unknown>;
|
|
56
|
+
}
|
|
57
|
+
/** Payload published by BaseService on entity update */
|
|
58
|
+
export interface EntityUpdatedPayload extends BaseEventPayload {
|
|
59
|
+
entityId: string;
|
|
60
|
+
entityType: string;
|
|
61
|
+
action: 'UPDATED';
|
|
62
|
+
userId?: string;
|
|
63
|
+
requestId?: string;
|
|
64
|
+
data?: Record<string, unknown>;
|
|
65
|
+
}
|
|
66
|
+
/** Payload published by BaseService on entity deletion */
|
|
67
|
+
export interface EntityDeletedPayload extends BaseEventPayload {
|
|
68
|
+
entityId: string;
|
|
69
|
+
entityType: string;
|
|
70
|
+
action: 'DELETED';
|
|
71
|
+
userId?: string;
|
|
72
|
+
requestId?: string;
|
|
73
|
+
data?: Record<string, unknown>;
|
|
74
|
+
}
|
|
75
|
+
/** User lifecycle events */
|
|
76
|
+
export interface UserCreatedPayload extends BaseEventPayload {
|
|
77
|
+
userUID: string;
|
|
78
|
+
email?: string;
|
|
79
|
+
}
|
|
80
|
+
export interface UserUpdatedPayload extends BaseEventPayload {
|
|
81
|
+
userUID: string;
|
|
82
|
+
}
|
|
83
|
+
export interface UserDeletedPayload extends BaseEventPayload {
|
|
84
|
+
userUID: string;
|
|
85
|
+
}
|
|
86
|
+
/** Authentication events */
|
|
87
|
+
export interface AuthLoginPayload extends BaseEventPayload {
|
|
88
|
+
userUID: string;
|
|
89
|
+
method?: string;
|
|
90
|
+
}
|
|
91
|
+
export interface AuthLogoutPayload extends BaseEventPayload {
|
|
92
|
+
userUID: string;
|
|
93
|
+
}
|
|
94
|
+
export interface AuthTokenBlacklistedPayload extends BaseEventPayload {
|
|
95
|
+
userUID: string;
|
|
96
|
+
reason?: string;
|
|
97
|
+
}
|
|
98
|
+
/** File events */
|
|
99
|
+
export interface FileUploadedPayload extends BaseEventPayload {
|
|
100
|
+
filePath: string;
|
|
101
|
+
contentType?: string;
|
|
102
|
+
size?: number;
|
|
103
|
+
bucket?: string;
|
|
104
|
+
}
|
|
105
|
+
export interface FileDeletedPayload extends BaseEventPayload {
|
|
106
|
+
filePath: string;
|
|
107
|
+
}
|
|
108
|
+
/** Notification events */
|
|
109
|
+
export interface NotificationSentPayload extends BaseEventPayload {
|
|
110
|
+
channel: 'email' | 'sms' | 'push' | string;
|
|
111
|
+
recipientId?: string;
|
|
112
|
+
}
|
|
113
|
+
export interface NotificationFailedPayload extends BaseEventPayload {
|
|
114
|
+
channel: 'email' | 'sms' | 'push' | string;
|
|
115
|
+
recipientId?: string;
|
|
116
|
+
error?: string;
|
|
117
|
+
}
|
|
118
|
+
/** External data change (Firebase triggers, webhooks, etc.) */
|
|
119
|
+
export interface ExternalDataChangePayload extends BaseEventPayload {
|
|
120
|
+
source: 'firestore' | 'auth' | 'storage' | string;
|
|
121
|
+
collection?: string;
|
|
122
|
+
documentId?: string;
|
|
123
|
+
operation?: string;
|
|
124
|
+
userId?: string;
|
|
125
|
+
filePath?: string;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Maps each EventType to its strongly-typed payload.
|
|
129
|
+
* Extend this map when adding new event types.
|
|
130
|
+
*/
|
|
131
|
+
export interface EventPayloadMap {
|
|
132
|
+
[EventType.USER_CREATED]: UserCreatedPayload;
|
|
133
|
+
[EventType.USER_UPDATED]: UserUpdatedPayload;
|
|
134
|
+
[EventType.USER_DELETED]: UserDeletedPayload;
|
|
135
|
+
[EventType.AUTH_LOGIN]: AuthLoginPayload;
|
|
136
|
+
[EventType.AUTH_LOGOUT]: AuthLogoutPayload;
|
|
137
|
+
[EventType.AUTH_TOKEN_REFRESHED]: BaseEventPayload;
|
|
138
|
+
[EventType.AUTH_TOKEN_BLACKLISTED]: AuthTokenBlacklistedPayload;
|
|
139
|
+
[EventType.AUTH_PASSWORD_CHANGED]: BaseEventPayload;
|
|
140
|
+
[EventType.FILE_UPLOADED]: FileUploadedPayload;
|
|
141
|
+
[EventType.FILE_DELETED]: FileDeletedPayload;
|
|
142
|
+
[EventType.NOTIFICATION_SENT]: NotificationSentPayload;
|
|
143
|
+
[EventType.NOTIFICATION_FAILED]: NotificationFailedPayload;
|
|
144
|
+
[EventType.EXTERNAL_DATA_CHANGE]: ExternalDataChangePayload;
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=event-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-types.d.ts","sourceRoot":"","sources":["../../../../utils-events/src/event-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,oBAAY,SAAS;IAEnB,YAAY,iBAAiB;IAC7B,YAAY,iBAAiB;IAC7B,YAAY,iBAAiB;IAG7B,UAAU,eAAe;IACzB,WAAW,gBAAgB;IAC3B,oBAAoB,yBAAyB;IAC7C,sBAAsB,2BAA2B;IACjD,qBAAqB,0BAA0B;IAG/C,aAAa,kBAAkB;IAC/B,YAAY,iBAAiB;IAG7B,iBAAiB,sBAAsB;IACvC,mBAAmB,wBAAwB;IAG3C,8EAA8E;IAC9E,oBAAoB,yBAAyB;CAC9C;AAMD;;;GAGG;AACH,MAAM,WAAW,gBAA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