@plyaz/types 1.18.4 → 1.18.6

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.
@@ -14,8 +14,7 @@
14
14
  * - Use FeatureFlagErrorResponse in hooks/consumers for typed error handling
15
15
  */
16
16
  import type { Endpoint, Req } from 'fetchff';
17
- import type { EvaluateFlagRequest, EvaluateFlagParams, EvaluateFlagResponse, IsEnabledRequest, IsEnabledParams, IsEnabledResponse, EvaluateAllFlagsRequest, EvaluateAllFlagsResponse, CreateFlagResponse, UpdateFlagParams, UpdateFlagRequest, UpdateFlagResponse, DeleteFlagParams, DeleteFlagResponse, SetOverrideParams, SetOverrideRequest, SetOverrideResponse, RemoveOverrideParams, RemoveOverrideResponse, GetFlagRulesParams, GetFlagRulesResponse, RefreshCacheResponse, FeatureFlagHealthResponse } from './types';
18
- import type { CreateFlagRequest } from '../../../features';
17
+ import type { EvaluateFlagRequest, EvaluateFlagParams, EvaluateFlagResponse, IsEnabledRequest, IsEnabledParams, IsEnabledResponse, EvaluateAllFlagsRequest, EvaluateAllFlagsResponse, CreateFlagResponse, UpdateFlagParams, UpdateFlagRequest, UpdateFlagResponse, DeleteFlagParams, DeleteFlagResponse, SetOverrideParams, SetOverrideRequest, SetOverrideResponse, RemoveOverrideParams, RemoveOverrideResponse, GetFlagRulesParams, GetFlagRulesResponse, RefreshCacheResponse, FeatureFlagHealthResponse, CreateFeatureFlagRequest } from './types';
19
18
  /**
20
19
  * Feature Flag API endpoint types
21
20
  * Complete type definitions for feature flag endpoints
@@ -40,7 +39,7 @@ export interface FeatureFlagEndpointTypes {
40
39
  * POST /feature-flags - Create flag
41
40
  * Req<Response, Body>
42
41
  */
43
- createFeatureFlag: Endpoint<Req<CreateFlagResponse, CreateFlagRequest<string>>>;
42
+ createFeatureFlag: Endpoint<Req<CreateFlagResponse, CreateFeatureFlagRequest<string>>>;
44
43
  /**
45
44
  * PUT /feature-flags/:key - Update flag
46
45
  * Req<Response, Body, Params>
@@ -151,3 +151,23 @@ export interface FeatureFlagHealthResponse {
151
151
  isInitialized: boolean;
152
152
  provider: string;
153
153
  }
154
+ /**
155
+ * Request DTO for creating a feature flag.
156
+ * Used by both the provider interface and API endpoints.
157
+ * @typeParam FeatureFlagKey - Feature flag key type (defaults to string)
158
+ */
159
+ export interface CreateFeatureFlagRequest<FeatureFlagKey extends string = string> {
160
+ /** Environment(s) this entity applies to */
161
+ /** Whether this entity is enabled */
162
+ isEnabled: boolean;
163
+ environment: 'development' | 'staging' | 'production' | 'all' | string;
164
+ rolloutPercentage?: number;
165
+ /** Name of the entity */
166
+ name: string;
167
+ /** Description of the entity */
168
+ description: string;
169
+ /** The key */
170
+ key: FeatureFlagKey;
171
+ /** The value */
172
+ value: FeatureFlagValue;
173
+ }
@@ -0,0 +1,218 @@
1
+ /**
2
+ * Core Event Enums and Constants
3
+ *
4
+ * Type-safe event definitions for the CoreEventManager.
5
+ * All event types follow the pattern: SCOPE:ACTION
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { CoreEventType, CORE_EVENTS } from '@plyaz/types/core';
10
+ *
11
+ * // Use constants for type-safe event emission
12
+ * CoreEventManager.emit(CORE_EVENTS.ENTITY.CREATED, payload);
13
+ *
14
+ * // Subscribe with typed payloads
15
+ * CoreEventManager.on<EntityCreatedPayload>(CORE_EVENTS.ENTITY.CREATED, handler);
16
+ * ```
17
+ */
18
+ /**
19
+ * Event scope categories
20
+ */
21
+ export declare const CoreEventScope: {
22
+ readonly SYSTEM: "system";
23
+ readonly ENTITY: "entity";
24
+ readonly VALIDATION: "validation";
25
+ readonly SANITIZATION: "sanitization";
26
+ readonly API: "api";
27
+ readonly CACHE: "cache";
28
+ readonly AUTH: "auth";
29
+ readonly FEATURE_FLAG: "featureFlag";
30
+ readonly STORE: "store";
31
+ };
32
+ export type CoreEventScopeType = (typeof CoreEventScope)[keyof typeof CoreEventScope];
33
+ /**
34
+ * System event actions
35
+ */
36
+ export declare const SystemEventAction: {
37
+ readonly INITIALIZED: "initialized";
38
+ readonly READY: "ready";
39
+ readonly SHUTDOWN: "shutdown";
40
+ readonly ERROR: "error";
41
+ readonly WARNING: "warning";
42
+ };
43
+ /**
44
+ * Entity CRUD event actions
45
+ */
46
+ export declare const EntityEventAction: {
47
+ readonly CREATING: "creating";
48
+ readonly UPDATING: "updating";
49
+ readonly PATCHING: "patching";
50
+ readonly DELETING: "deleting";
51
+ readonly CREATED: "created";
52
+ readonly UPDATED: "updated";
53
+ readonly PATCHED: "patched";
54
+ readonly DELETED: "deleted";
55
+ readonly ERROR: "error";
56
+ readonly COMPLETE: "complete";
57
+ readonly BULK_CREATED: "bulkCreated";
58
+ readonly BULK_DELETED: "bulkDeleted";
59
+ };
60
+ /**
61
+ * Validation event actions
62
+ */
63
+ export declare const ValidationEventAction: {
64
+ readonly STARTED: "started";
65
+ readonly SUCCESS: "success";
66
+ readonly FAILED: "failed";
67
+ };
68
+ /**
69
+ * Sanitization event actions
70
+ */
71
+ export declare const SanitizationEventAction: {
72
+ readonly STARTED: "started";
73
+ readonly SUCCESS: "success";
74
+ readonly FAILED: "failed";
75
+ };
76
+ /**
77
+ * API event actions
78
+ */
79
+ export declare const ApiEventAction: {
80
+ readonly REQUEST_START: "requestStart";
81
+ readonly REQUEST_SUCCESS: "requestSuccess";
82
+ readonly REQUEST_ERROR: "requestError";
83
+ readonly RETRY: "retry";
84
+ readonly TIMEOUT: "timeout";
85
+ };
86
+ /**
87
+ * Cache event actions
88
+ */
89
+ export declare const CacheEventAction: {
90
+ readonly HIT: "hit";
91
+ readonly MISS: "miss";
92
+ readonly SET: "set";
93
+ readonly DELETE: "delete";
94
+ readonly CLEAR: "clear";
95
+ readonly EXPIRED: "expired";
96
+ };
97
+ /**
98
+ * Auth event actions
99
+ */
100
+ export declare const AuthEventAction: {
101
+ readonly LOGIN: "login";
102
+ readonly LOGOUT: "logout";
103
+ readonly TOKEN_REFRESH: "tokenRefresh";
104
+ readonly SESSION_EXPIRED: "sessionExpired";
105
+ readonly UNAUTHORIZED: "unauthorized";
106
+ };
107
+ /**
108
+ * Feature flag event actions
109
+ */
110
+ export declare const FeatureFlagEventAction: {
111
+ readonly CHANGED: "changed";
112
+ readonly EVALUATED: "evaluated";
113
+ readonly REFRESHED: "refreshed";
114
+ };
115
+ /**
116
+ * Store event actions
117
+ */
118
+ export declare const StoreEventAction: {
119
+ readonly UPDATED: "updated";
120
+ readonly RESET: "reset";
121
+ readonly HYDRATED: "hydrated";
122
+ };
123
+ /**
124
+ * All core event type constants
125
+ *
126
+ * @example
127
+ * ```typescript
128
+ * CoreEventManager.emit(CORE_EVENTS.ENTITY.CREATED, { entity, storeState });
129
+ * CoreEventManager.on(CORE_EVENTS.API.REQUEST_ERROR, handleApiError);
130
+ * ```
131
+ */
132
+ export declare const CORE_EVENTS: {
133
+ readonly SYSTEM: {
134
+ readonly INITIALIZED: "system:initialized";
135
+ readonly READY: "system:ready";
136
+ readonly SHUTDOWN: "system:shutdown";
137
+ readonly ERROR: "system:error";
138
+ readonly WARNING: "system:warning";
139
+ };
140
+ readonly ENTITY: {
141
+ readonly CREATING: "entity:creating";
142
+ readonly UPDATING: "entity:updating";
143
+ readonly PATCHING: "entity:patching";
144
+ readonly DELETING: "entity:deleting";
145
+ readonly CREATED: "entity:created";
146
+ readonly UPDATED: "entity:updated";
147
+ readonly PATCHED: "entity:patched";
148
+ readonly DELETED: "entity:deleted";
149
+ readonly ERROR: "entity:error";
150
+ readonly COMPLETE: "entity:complete";
151
+ readonly BULK_CREATED: "entity:bulkCreated";
152
+ readonly BULK_DELETED: "entity:bulkDeleted";
153
+ };
154
+ readonly VALIDATION: {
155
+ readonly STARTED: "validation:started";
156
+ readonly SUCCESS: "validation:success";
157
+ readonly FAILED: "validation:failed";
158
+ };
159
+ readonly SANITIZATION: {
160
+ readonly STARTED: "sanitization:started";
161
+ readonly SUCCESS: "sanitization:success";
162
+ readonly FAILED: "sanitization:failed";
163
+ };
164
+ readonly API: {
165
+ readonly REQUEST_START: "api:requestStart";
166
+ readonly REQUEST_SUCCESS: "api:requestSuccess";
167
+ readonly REQUEST_ERROR: "api:requestError";
168
+ readonly RETRY: "api:retry";
169
+ readonly TIMEOUT: "api:timeout";
170
+ };
171
+ readonly CACHE: {
172
+ readonly HIT: "cache:hit";
173
+ readonly MISS: "cache:miss";
174
+ readonly SET: "cache:set";
175
+ readonly DELETE: "cache:delete";
176
+ readonly CLEAR: "cache:clear";
177
+ readonly EXPIRED: "cache:expired";
178
+ };
179
+ readonly AUTH: {
180
+ readonly LOGIN: "auth:login";
181
+ readonly LOGOUT: "auth:logout";
182
+ readonly TOKEN_REFRESH: "auth:tokenRefresh";
183
+ readonly SESSION_EXPIRED: "auth:sessionExpired";
184
+ readonly UNAUTHORIZED: "auth:unauthorized";
185
+ };
186
+ readonly FEATURE_FLAG: {
187
+ readonly CHANGED: "featureFlag:changed";
188
+ readonly EVALUATED: "featureFlag:evaluated";
189
+ readonly REFRESHED: "featureFlag:refreshed";
190
+ };
191
+ readonly STORE: {
192
+ readonly UPDATED: "store:updated";
193
+ readonly RESET: "store:reset";
194
+ readonly HYDRATED: "store:hydrated";
195
+ };
196
+ };
197
+ /** All system event types */
198
+ export type SystemEventType = (typeof CORE_EVENTS.SYSTEM)[keyof typeof CORE_EVENTS.SYSTEM];
199
+ /** All entity event types */
200
+ export type EntityEventType = (typeof CORE_EVENTS.ENTITY)[keyof typeof CORE_EVENTS.ENTITY];
201
+ /** All validation event types */
202
+ export type ValidationEventType = (typeof CORE_EVENTS.VALIDATION)[keyof typeof CORE_EVENTS.VALIDATION];
203
+ /** All sanitization event types */
204
+ export type SanitizationEventType = (typeof CORE_EVENTS.SANITIZATION)[keyof typeof CORE_EVENTS.SANITIZATION];
205
+ /** All API event types */
206
+ export type ApiEventType = (typeof CORE_EVENTS.API)[keyof typeof CORE_EVENTS.API];
207
+ /** All cache event types */
208
+ export type CacheEventType = (typeof CORE_EVENTS.CACHE)[keyof typeof CORE_EVENTS.CACHE];
209
+ /** All auth event types */
210
+ export type AuthEventType = (typeof CORE_EVENTS.AUTH)[keyof typeof CORE_EVENTS.AUTH];
211
+ /** All feature flag event types */
212
+ export type FeatureFlagEventType = (typeof CORE_EVENTS.FEATURE_FLAG)[keyof typeof CORE_EVENTS.FEATURE_FLAG];
213
+ /** All store event types */
214
+ export type StoreEventType = (typeof CORE_EVENTS.STORE)[keyof typeof CORE_EVENTS.STORE];
215
+ /**
216
+ * Union of all core event types
217
+ */
218
+ export type CoreEventType = SystemEventType | EntityEventType | ValidationEventType | SanitizationEventType | ApiEventType | CacheEventType | AuthEventType | FeatureFlagEventType | StoreEventType;
@@ -1,4 +1,22 @@
1
1
  /**
2
2
  * Core Events Types
3
+ *
4
+ * Type-safe event system with enums, constants, and typed payloads.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import { CORE_EVENTS, CoreEventPayloadMap } from '@plyaz/types/core';
9
+ *
10
+ * // Use constants for type-safe event emission
11
+ * CoreEventManager.emit(CORE_EVENTS.ENTITY.CREATED, payload);
12
+ *
13
+ * // Subscribe with typed payloads
14
+ * CoreEventManager.on<CoreEventPayloadMap[typeof CORE_EVENTS.API.REQUEST_ERROR]>(
15
+ * CORE_EVENTS.API.REQUEST_ERROR,
16
+ * handler
17
+ * );
18
+ * ```
3
19
  */
4
- export type { CoreCrudOperation, CoreValidationStartedPayload, CoreValidationSuccessPayload, CoreValidationFailedPayload, CoreSanitizationStartedPayload, CoreSanitizationSuccessPayload, CoreSanitizationFailedPayload, CoreEntityCreatedPayload, CoreEntityUpdatedPayload, CoreEntityPatchedPayload, CoreEntityDeletedPayload, CoreEntityCreatingPayload, CoreEntityUpdatingPayload, CoreEntityPatchingPayload, CoreEntityDeletingPayload, CoreEntityErrorPayload, CoreEntityCompletePayload, CoreBulkCreatedPayload, CoreBulkDeletedPayload, } from './payloads';
20
+ export { CoreEventScope, SystemEventAction, EntityEventAction, ValidationEventAction, SanitizationEventAction, ApiEventAction, CacheEventAction, AuthEventAction, FeatureFlagEventAction, StoreEventAction, CORE_EVENTS, } from './enums';
21
+ export type { CoreEventScopeType, SystemEventType, EntityEventType, ValidationEventType, SanitizationEventType, ApiEventType, CacheEventType, AuthEventType, FeatureFlagEventType, StoreEventType, CoreEventType, } from './enums';
22
+ export type { CoreCrudOperation, CoreValidationStartedPayload, CoreValidationSuccessPayload, CoreValidationFailedPayload, CoreSanitizationStartedPayload, CoreSanitizationSuccessPayload, CoreSanitizationFailedPayload, CoreEntityCreatedPayload, CoreEntityUpdatedPayload, CoreEntityPatchedPayload, CoreEntityDeletedPayload, CoreEntityCreatingPayload, CoreEntityUpdatingPayload, CoreEntityPatchingPayload, CoreEntityDeletingPayload, CoreEntityErrorPayload, CoreEntityCompletePayload, CoreBulkCreatedPayload, CoreBulkDeletedPayload, CoreSystemInitializedPayload, CoreSystemReadyPayload, CoreSystemShutdownPayload, CoreSystemErrorPayload, CoreSystemWarningPayload, CoreApiRequestStartPayload, CoreApiRequestSuccessPayload, CoreApiRequestErrorPayload, CoreApiRetryPayload, CoreApiTimeoutPayload, CoreCacheHitPayload, CoreCacheMissPayload, CoreCacheSetPayload, CoreCacheDeletePayload, CoreCacheClearPayload, CoreCacheExpiredPayload, CoreAuthLoginPayload, CoreAuthLogoutPayload, CoreAuthTokenRefreshPayload, CoreAuthSessionExpiredPayload, CoreAuthUnauthorizedPayload, CoreFeatureFlagChangedPayload, CoreFeatureFlagEvaluatedPayload, CoreFeatureFlagRefreshedPayload, CoreStoreUpdatedPayload, CoreStoreResetPayload, CoreStoreHydratedPayload, CoreEventPayloadMap, } from './payloads';
@@ -166,3 +166,271 @@ export interface CoreBulkDeletedPayload {
166
166
  soft: boolean;
167
167
  total: number;
168
168
  }
169
+ /**
170
+ * Payload for system:initialized events
171
+ */
172
+ export interface CoreSystemInitializedPayload {
173
+ services: string[];
174
+ environment: string;
175
+ }
176
+ /**
177
+ * Payload for system:ready events
178
+ */
179
+ export interface CoreSystemReadyPayload {
180
+ startupTime: number;
181
+ }
182
+ /**
183
+ * Payload for system:shutdown events
184
+ */
185
+ export interface CoreSystemShutdownPayload {
186
+ reason?: string;
187
+ graceful: boolean;
188
+ }
189
+ /**
190
+ * Payload for system:error events
191
+ */
192
+ export interface CoreSystemErrorPayload {
193
+ error: unknown;
194
+ context?: string;
195
+ recoverable: boolean;
196
+ }
197
+ /**
198
+ * Payload for system:warning events
199
+ */
200
+ export interface CoreSystemWarningPayload {
201
+ message: string;
202
+ context?: string;
203
+ }
204
+ /**
205
+ * Payload for api:requestStart events
206
+ */
207
+ export interface CoreApiRequestStartPayload {
208
+ method: string;
209
+ url: string;
210
+ requestId: string;
211
+ }
212
+ /**
213
+ * Payload for api:requestSuccess events
214
+ */
215
+ export interface CoreApiRequestSuccessPayload {
216
+ method: string;
217
+ url: string;
218
+ requestId: string;
219
+ status: number;
220
+ duration: number;
221
+ }
222
+ /**
223
+ * Payload for api:requestError events
224
+ */
225
+ export interface CoreApiRequestErrorPayload {
226
+ method: string;
227
+ url: string;
228
+ requestId: string;
229
+ status?: number;
230
+ error: unknown;
231
+ duration: number;
232
+ }
233
+ /**
234
+ * Payload for api:retry events
235
+ */
236
+ export interface CoreApiRetryPayload {
237
+ method: string;
238
+ url: string;
239
+ requestId: string;
240
+ attempt: number;
241
+ maxAttempts: number;
242
+ delay: number;
243
+ }
244
+ /**
245
+ * Payload for api:timeout events
246
+ */
247
+ export interface CoreApiTimeoutPayload {
248
+ method: string;
249
+ url: string;
250
+ requestId: string;
251
+ timeout: number;
252
+ }
253
+ /**
254
+ * Payload for cache:hit events
255
+ */
256
+ export interface CoreCacheHitPayload {
257
+ key: string;
258
+ ttl?: number;
259
+ }
260
+ /**
261
+ * Payload for cache:miss events
262
+ */
263
+ export interface CoreCacheMissPayload {
264
+ key: string;
265
+ }
266
+ /**
267
+ * Payload for cache:set events
268
+ */
269
+ export interface CoreCacheSetPayload {
270
+ key: string;
271
+ ttl?: number;
272
+ }
273
+ /**
274
+ * Payload for cache:delete events
275
+ */
276
+ export interface CoreCacheDeletePayload {
277
+ key: string;
278
+ }
279
+ /**
280
+ * Payload for cache:clear events
281
+ */
282
+ export interface CoreCacheClearPayload {
283
+ pattern?: string;
284
+ count: number;
285
+ }
286
+ /**
287
+ * Payload for cache:expired events
288
+ */
289
+ export interface CoreCacheExpiredPayload {
290
+ key: string;
291
+ }
292
+ /**
293
+ * Payload for auth:login events
294
+ */
295
+ export interface CoreAuthLoginPayload {
296
+ userId: string;
297
+ method: string;
298
+ }
299
+ /**
300
+ * Payload for auth:logout events
301
+ */
302
+ export interface CoreAuthLogoutPayload {
303
+ userId: string;
304
+ reason?: string;
305
+ }
306
+ /**
307
+ * Payload for auth:tokenRefresh events
308
+ */
309
+ export interface CoreAuthTokenRefreshPayload {
310
+ userId: string;
311
+ expiresAt: number;
312
+ }
313
+ /**
314
+ * Payload for auth:sessionExpired events
315
+ */
316
+ export interface CoreAuthSessionExpiredPayload {
317
+ userId?: string;
318
+ expiredAt: number;
319
+ }
320
+ /**
321
+ * Payload for auth:unauthorized events
322
+ */
323
+ export interface CoreAuthUnauthorizedPayload {
324
+ resource?: string;
325
+ action?: string;
326
+ }
327
+ /**
328
+ * Payload for featureFlag:changed events
329
+ */
330
+ export interface CoreFeatureFlagChangedPayload {
331
+ flag: string;
332
+ previousValue: boolean;
333
+ newValue: boolean;
334
+ }
335
+ /**
336
+ * Payload for featureFlag:evaluated events
337
+ */
338
+ export interface CoreFeatureFlagEvaluatedPayload {
339
+ flag: string;
340
+ value: boolean;
341
+ source: 'cache' | 'provider' | 'default';
342
+ }
343
+ /**
344
+ * Payload for featureFlag:refreshed events
345
+ */
346
+ export interface CoreFeatureFlagRefreshedPayload {
347
+ flagCount: number;
348
+ changedFlags: string[];
349
+ }
350
+ /**
351
+ * Payload for store:updated events
352
+ */
353
+ export interface CoreStoreUpdatedPayload<T = unknown> {
354
+ storeName: string;
355
+ previousState?: T;
356
+ newState: T;
357
+ changedKeys?: string[];
358
+ }
359
+ /**
360
+ * Payload for store:reset events
361
+ */
362
+ export interface CoreStoreResetPayload {
363
+ storeName: string;
364
+ }
365
+ /**
366
+ * Payload for store:hydrated events
367
+ */
368
+ export interface CoreStoreHydratedPayload {
369
+ storeName: string;
370
+ source: string;
371
+ }
372
+ import type { CORE_EVENTS } from './enums';
373
+ /**
374
+ * Maps event types to their payload types for type-safe event handling.
375
+ *
376
+ * Uses computed property keys from CORE_EVENTS for:
377
+ * - Single source of truth for event names
378
+ * - Automatic updates if CORE_EVENTS values change
379
+ * - Better IDE support and refactoring
380
+ *
381
+ * @example
382
+ * ```typescript
383
+ * // Type-safe event emission and subscription
384
+ * function emit<T extends keyof CoreEventPayloadMap>(
385
+ * event: T,
386
+ * payload: CoreEventPayloadMap[T]
387
+ * ): void;
388
+ * ```
389
+ */
390
+ export interface CoreEventPayloadMap {
391
+ [CORE_EVENTS.SYSTEM.INITIALIZED]: CoreSystemInitializedPayload;
392
+ [CORE_EVENTS.SYSTEM.READY]: CoreSystemReadyPayload;
393
+ [CORE_EVENTS.SYSTEM.SHUTDOWN]: CoreSystemShutdownPayload;
394
+ [CORE_EVENTS.SYSTEM.ERROR]: CoreSystemErrorPayload;
395
+ [CORE_EVENTS.SYSTEM.WARNING]: CoreSystemWarningPayload;
396
+ [CORE_EVENTS.ENTITY.CREATING]: CoreEntityCreatingPayload<unknown>;
397
+ [CORE_EVENTS.ENTITY.UPDATING]: CoreEntityUpdatingPayload<unknown>;
398
+ [CORE_EVENTS.ENTITY.PATCHING]: CoreEntityPatchingPayload<unknown>;
399
+ [CORE_EVENTS.ENTITY.DELETING]: CoreEntityDeletingPayload;
400
+ [CORE_EVENTS.ENTITY.CREATED]: CoreEntityCreatedPayload<unknown>;
401
+ [CORE_EVENTS.ENTITY.UPDATED]: CoreEntityUpdatedPayload<unknown>;
402
+ [CORE_EVENTS.ENTITY.PATCHED]: CoreEntityPatchedPayload<unknown>;
403
+ [CORE_EVENTS.ENTITY.DELETED]: CoreEntityDeletedPayload;
404
+ [CORE_EVENTS.ENTITY.ERROR]: CoreEntityErrorPayload;
405
+ [CORE_EVENTS.ENTITY.COMPLETE]: CoreEntityCompletePayload;
406
+ [CORE_EVENTS.ENTITY.BULK_CREATED]: CoreBulkCreatedPayload<unknown>;
407
+ [CORE_EVENTS.ENTITY.BULK_DELETED]: CoreBulkDeletedPayload;
408
+ [CORE_EVENTS.VALIDATION.STARTED]: CoreValidationStartedPayload;
409
+ [CORE_EVENTS.VALIDATION.SUCCESS]: CoreValidationSuccessPayload;
410
+ [CORE_EVENTS.VALIDATION.FAILED]: CoreValidationFailedPayload;
411
+ [CORE_EVENTS.SANITIZATION.STARTED]: CoreSanitizationStartedPayload;
412
+ [CORE_EVENTS.SANITIZATION.SUCCESS]: CoreSanitizationSuccessPayload;
413
+ [CORE_EVENTS.SANITIZATION.FAILED]: CoreSanitizationFailedPayload;
414
+ [CORE_EVENTS.API.REQUEST_START]: CoreApiRequestStartPayload;
415
+ [CORE_EVENTS.API.REQUEST_SUCCESS]: CoreApiRequestSuccessPayload;
416
+ [CORE_EVENTS.API.REQUEST_ERROR]: CoreApiRequestErrorPayload;
417
+ [CORE_EVENTS.API.RETRY]: CoreApiRetryPayload;
418
+ [CORE_EVENTS.API.TIMEOUT]: CoreApiTimeoutPayload;
419
+ [CORE_EVENTS.CACHE.HIT]: CoreCacheHitPayload;
420
+ [CORE_EVENTS.CACHE.MISS]: CoreCacheMissPayload;
421
+ [CORE_EVENTS.CACHE.SET]: CoreCacheSetPayload;
422
+ [CORE_EVENTS.CACHE.DELETE]: CoreCacheDeletePayload;
423
+ [CORE_EVENTS.CACHE.CLEAR]: CoreCacheClearPayload;
424
+ [CORE_EVENTS.CACHE.EXPIRED]: CoreCacheExpiredPayload;
425
+ [CORE_EVENTS.AUTH.LOGIN]: CoreAuthLoginPayload;
426
+ [CORE_EVENTS.AUTH.LOGOUT]: CoreAuthLogoutPayload;
427
+ [CORE_EVENTS.AUTH.TOKEN_REFRESH]: CoreAuthTokenRefreshPayload;
428
+ [CORE_EVENTS.AUTH.SESSION_EXPIRED]: CoreAuthSessionExpiredPayload;
429
+ [CORE_EVENTS.AUTH.UNAUTHORIZED]: CoreAuthUnauthorizedPayload;
430
+ [CORE_EVENTS.FEATURE_FLAG.CHANGED]: CoreFeatureFlagChangedPayload;
431
+ [CORE_EVENTS.FEATURE_FLAG.EVALUATED]: CoreFeatureFlagEvaluatedPayload;
432
+ [CORE_EVENTS.FEATURE_FLAG.REFRESHED]: CoreFeatureFlagRefreshedPayload;
433
+ [CORE_EVENTS.STORE.UPDATED]: CoreStoreUpdatedPayload;
434
+ [CORE_EVENTS.STORE.RESET]: CoreStoreResetPayload;
435
+ [CORE_EVENTS.STORE.HYDRATED]: CoreStoreHydratedPayload;
436
+ }
@@ -6,8 +6,8 @@
6
6
  */
7
7
  export type { ApiEnvironmentConfig, ApiProviderProps } from './services';
8
8
  export type { CoreIdempotencyStoreType, CoreInMemoryIdempotencyAdapterConfig, CoreRedisIdempotencyAdapterConfig, CoreIdempotencyStoreOptions, CoreIdempotencyStoreConfig, } from './idempotency';
9
- export type { CoreServices, CoreRouteContext, CoreRouteHandler, CoreRouteDefinition, CoreModuleConfigSchema, CoreServiceFactory, CoreModuleLifecycle, CoreModuleDefinition, CoreRegisteredModule, CoreConfiguredModule, CoreModuleFactory, CoreFrameworkType, CoreServerConfig, CoreFrameworkAdapter, CoreAdapterFactory, CoreRuntimeEnvironment, CoreRuntimeContext, CoreNextJsHandlerContext, CoreNextJsHandlerResult, CoreNextJsHandler, CoreNextJsHandlerOptions, CoreEnvVars, CoreAppEnvironment, CoreApiInitOptions, CoreInitOptions, CoreServicesResult, CoreNestJsModuleOptions, CoreNestJsModuleAsyncOptions, } from './modules';
10
- export { BACKEND_RUNTIMES, FRONTEND_RUNTIMES, UNIVERSAL_RUNTIMES } from './modules';
9
+ export type { CoreServices, CoreRouteContext, CoreRouteHandler, CoreRouteDefinition, CoreModuleConfigSchema, CoreServiceFactory, CoreModuleLifecycle, CoreModuleDefinition, CoreRegisteredModule, CoreConfiguredModule, CoreModuleFactory, CoreFrameworkType, CoreServerConfig, CoreFrameworkAdapter, CoreAdapterFactory, CoreRuntimeEnvironment, CoreRuntimeContext, CoreNextJsHandlerContext, CoreNextJsHandlerResult, CoreNextJsHandler, CoreNextJsHandlerOptions, CoreEnvVars, CoreAppEnvironment, CoreApiInitOptions, CoreInitOptions, CoreServicesResult, CoreNestJsModuleOptions, CoreNestJsModuleAsyncOptions, CoreAppContext, CoreServiceRuntime, CoreDomainServiceConfig, } from './modules';
10
+ export { BACKEND_RUNTIMES, FRONTEND_RUNTIMES, UNIVERSAL_RUNTIMES, APP_CONTEXTS, } from './modules';
11
11
  export * from './tables/enum';
12
12
  export type * from './auth/types';
13
13
  export type * from './featureFlag/types';
@@ -3,16 +3,47 @@
3
3
  * Defines the contract for database event emission
4
4
  */
5
5
  import type { DatabaseEvent, DBEventHandler, DatabaseOperationType } from './event.types';
6
- import type { ContextType } from '@nestjs/common';
6
+ /**
7
+ * Base execution context interface for database operations.
8
+ * Extend this interface to add framework-specific context.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * // NestJS context
13
+ * interface NestJsDbContext extends DatabaseExecutionContext {
14
+ * requestId: string;
15
+ * userId?: string;
16
+ * ip?: string;
17
+ * }
18
+ *
19
+ * // Express context
20
+ * interface ExpressDbContext extends DatabaseExecutionContext {
21
+ * req: Request;
22
+ * res: Response;
23
+ * }
24
+ * ```
25
+ */
26
+ export interface DatabaseExecutionContext {
27
+ /** Optional request ID for tracing */
28
+ requestId?: string;
29
+ /** Optional user ID for audit */
30
+ userId?: string;
31
+ /** Optional tenant ID for multi-tenancy */
32
+ tenantId?: string;
33
+ /** Additional context data */
34
+ [key: string]: unknown;
35
+ }
7
36
  /**
8
37
  * Emit a query error event
38
+ *
39
+ * @typeParam TContext - Custom context type extending DatabaseExecutionContext
9
40
  */
10
- export interface EmitQueryErrorOptions {
41
+ export interface EmitQueryErrorOptions<TContext extends DatabaseExecutionContext = DatabaseExecutionContext> {
11
42
  table: string;
12
43
  operation: DatabaseOperationType;
13
44
  error: Error;
14
45
  params?: Record<string, object>;
15
- context?: ContextType;
46
+ context?: TContext;
16
47
  }
17
48
  export interface DatabaseError extends Error {
18
49
  code?: string;
@@ -71,7 +102,7 @@ export interface BeforeQueryEvent extends DatabaseEvent {
71
102
  table: string;
72
103
  operation: DatabaseOperationType;
73
104
  params?: Record<string, object>;
74
- context?: ContextType;
105
+ context?: DatabaseExecutionContext;
75
106
  }
76
107
  export interface AfterQueryEvent extends DatabaseEvent {
77
108
  type: 'afterQuery';
@@ -88,13 +119,13 @@ export interface QueryErrorEvent extends DatabaseEvent {
88
119
  operation: DatabaseOperationType;
89
120
  error: Error;
90
121
  params?: Record<string, object>;
91
- context?: ContextType;
122
+ context?: DatabaseExecutionContext;
92
123
  }
93
124
  export interface BeforeTransactionEvent extends DatabaseEvent {
94
125
  type: 'beforeTransaction';
95
126
  adapter: string;
96
127
  transactionId: string;
97
- context?: ContextType;
128
+ context?: DatabaseExecutionContext;
98
129
  }
99
130
  export interface AfterTransactionEvent extends DatabaseEvent {
100
131
  type: 'afterTransaction';
@@ -18,3 +18,4 @@ export type * from './migrations.types';
18
18
  export type * from './seeds.types';
19
19
  export type * from './health.types';
20
20
  export type * from './tenant.types';
21
+ export type * from './query.types';
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Query Builder Types
3
+ *
4
+ * Types for SQL query building utilities used by database adapters.
5
+ */
6
+ /**
7
+ * Options for building SQL WHERE clause conditions
8
+ */
9
+ export interface BuildWhereClauseOptions {
10
+ /** Field name to filter on */
11
+ field: string;
12
+ /** Comparison operator (e.g., '=', '>', '<', 'LIKE', 'IN') */
13
+ operator: string;
14
+ /** Value to compare against */
15
+ value: unknown;
16
+ /** Array to collect parameterized values */
17
+ params: unknown[];
18
+ /** Starting index for parameter placeholders ($1, $2, etc.) */
19
+ startIndex: number;
20
+ }