@plyaz/types 1.6.0 → 1.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,68 +6,36 @@
6
6
  * @fileoverview Feature flags domain type definitions
7
7
  * @version 1.0.0
8
8
  */
9
+ import type { UnknownRecord, UnknownArray, Arrayable, Promisable, SetOptional } from 'type-fest';
9
10
  import type * as React from 'react';
11
+ import type { Describable, Timestamped, WithMetadata, Loadable, Authored, WithTags, WithEnvironment, Identifiable, Named, WithLogging, WithApiKey, Initializable, Refreshable, WithOperation, Enabled, WithError, KeyValuePair, WithUserId, WithCountry, Versioned, WithPlatform, WithPriority, ValidationResult } from '../../common/types';
10
12
  /**
11
13
  * Possible values that a feature flag can hold.
12
14
  * Supports primitive types and JSON objects for complex configurations.
13
15
  */
14
- export type FeatureFlagValue = boolean | string | number | Record<string, unknown>;
16
+ export type FeatureFlagValue = boolean | string | number | UnknownRecord;
15
17
  /**
16
18
  * Core feature flag definition interface.
17
19
  * Represents a complete feature flag with all its metadata and configuration.
18
20
  */
19
- export interface FeatureFlag<FeatureFlagKey extends string> {
20
- /** The unique identifier for this flag */
21
- key: FeatureFlagKey;
22
- /** Human-readable name for the flag */
23
- name: string;
24
- /** Detailed description of what this flag controls */
25
- description: string;
26
- /** Whether this flag is currently active */
27
- isEnabled: boolean;
28
- /** The value returned when this flag is evaluated */
29
- value: FeatureFlagValue;
21
+ export interface FeatureFlag<FeatureFlagKey extends string> extends Describable, Timestamped, WithMetadata, Authored, Named, WithTags, WithEnvironment, Enabled, KeyValuePair<FeatureFlagKey, FeatureFlagValue> {
30
22
  /** The data type of the flag value */
31
- type: 'boolean' | 'string' | 'number' | 'json';
32
- /** Which environment(s) this flag applies to */
33
- environment: 'development' | 'staging' | 'production' | 'all';
23
+ type: FlagType;
34
24
  /** Percentage of users who should receive this flag (0-100) */
35
25
  rolloutPercentage?: number;
36
- /** Timestamp when this flag was created */
37
- createdAt: Date;
38
- /** Timestamp when this flag was last updated */
39
- updatedAt: Date;
40
- /** Email or ID of the user who created this flag */
41
- createdBy: string;
42
- /** Email or ID of the user who last updated this flag */
43
- updatedBy: string;
44
- /** Additional metadata */
45
- metadata?: Record<string, unknown>;
46
- /** Tags for categorization */
47
- tags?: string[];
48
26
  }
49
27
  /**
50
28
  * Feature flag rule for advanced targeting and conditional logic.
51
29
  */
52
- export interface FeatureFlagRule<FeatureFlagKey extends string> {
53
- /** Unique identifier for this rule */
54
- id: string;
30
+ export interface FeatureFlagRule<FeatureFlagKey extends string> extends Identifiable, Named, WithPriority<number>, WithMetadata, Enabled {
55
31
  /** The feature flag this rule applies to */
56
32
  flagKey: FeatureFlagKey;
57
- /** Human-readable name for this rule */
58
- name: string;
59
33
  /** Array of conditions that must all be met for this rule to apply */
60
34
  conditions: FeatureFlagCondition[];
61
35
  /** The value to return if this rule matches */
62
36
  value: FeatureFlagValue;
63
37
  /** Percentage of matching users who should receive this value (0-100) */
64
38
  rolloutPercentage?: number;
65
- /** Priority for rule evaluation (higher numbers = higher priority) */
66
- priority: number;
67
- /** Whether this rule is currently active */
68
- isEnabled: boolean;
69
- /** Rule metadata */
70
- metadata?: Record<string, unknown>;
71
39
  }
72
40
  /**
73
41
  * Individual condition for feature flag rule evaluation.
@@ -78,39 +46,27 @@ export interface FeatureFlagCondition {
78
46
  /** The comparison operator to use */
79
47
  operator: 'equals' | 'not_equals' | 'contains' | 'not_contains' | 'in' | 'not_in' | 'greater_than' | 'less_than';
80
48
  /** The value(s) to compare against */
81
- value: string | number | string[] | number[];
49
+ value: Arrayable<string | number>;
82
50
  }
83
51
  /**
84
52
  * Context information used for feature flag evaluation.
85
53
  */
86
- export interface FeatureFlagContext {
87
- /** Unique identifier for the user */
88
- userId?: string;
54
+ export interface FeatureFlagContext extends SetOptional<WithUserId, 'userId'>, WithCountry, Versioned, WithEnvironment, WithPlatform {
89
55
  /** User's email address */
90
56
  userEmail?: string;
91
57
  /** User's role or permission level */
92
58
  userRole?: string;
93
- /** User's country code (ISO 3166-1 alpha-2) */
94
- country?: string;
95
- /** Platform the user is accessing from */
96
- platform?: 'web' | 'mobile' | 'desktop';
97
- /** Application version */
98
- version?: string;
99
59
  /** Custom context data for advanced targeting */
100
- custom?: Record<string, unknown>;
101
- /** Current environment */
102
- environment: 'development' | 'staging' | 'production';
60
+ custom?: UnknownRecord;
103
61
  }
104
62
  /**
105
63
  * Result of a feature flag evaluation.
106
64
  */
107
- export interface FeatureFlagEvaluation<FeatureFlagKey extends string> {
65
+ export interface FeatureFlagEvaluation<FeatureFlagKey extends string> extends Enabled {
108
66
  /** The feature flag key that was evaluated */
109
67
  flagKey: FeatureFlagKey;
110
68
  /** The resolved value for this flag */
111
69
  value: FeatureFlagValue;
112
- /** Whether the flag is considered enabled (truthy value) */
113
- isEnabled: boolean;
114
70
  /** Explanation of how this value was determined */
115
71
  reason: 'default' | 'rule_match' | 'rollout' | 'override' | 'disabled';
116
72
  /** Source of the evaluation result */
@@ -123,7 +79,7 @@ export interface FeatureFlagEvaluation<FeatureFlagKey extends string> {
123
79
  /**
124
80
  * Configuration options for the feature flag system.
125
81
  */
126
- export interface FeatureFlagConfig<FeatureFlagKey extends string> {
82
+ export interface FeatureFlagConfig<FeatureFlagKey extends string> extends SetOptional<WithLogging, 'isLoggingEnabled'>, WithApiKey {
127
83
  /** The storage provider to use for flag data */
128
84
  provider: 'database' | 'redis' | 'memory' | 'api' | 'file';
129
85
  /** Whether to enable caching of flag evaluations */
@@ -134,23 +90,19 @@ export interface FeatureFlagConfig<FeatureFlagKey extends string> {
134
90
  refreshInterval: number;
135
91
  /** Whether to fall back to default values on errors */
136
92
  shouldFallbackToDefaults: boolean;
137
- /** Whether to enable debug logging */
138
- isLoggingEnabled: boolean;
139
93
  /** API endpoint URL (required if provider is 'api') */
140
94
  apiEndpoint?: string;
141
- /** API authentication key (required if provider is 'api') */
142
- apiKey?: string;
143
95
  /** Database configuration (required if provider is 'database') */
144
96
  databaseConfig?: {
145
97
  connectionString: string;
146
98
  tableName: string;
147
- options?: Record<string, unknown>;
99
+ options?: UnknownRecord;
148
100
  };
149
101
  /** Redis configuration (required if provider is 'redis') */
150
102
  redisConfig?: {
151
103
  url: string;
152
104
  keyPrefix: string;
153
- options?: Record<string, unknown>;
105
+ options?: UnknownRecord;
154
106
  };
155
107
  /** File configuration (required if provider is 'file') */
156
108
  fileConfig?: {
@@ -180,28 +132,16 @@ export interface UseFeatureFlagOptions {
180
132
  /**
181
133
  * Internal state for feature flag evaluation in React hooks.
182
134
  */
183
- export interface FeatureFlagState<FeatureFlagKey extends string, T extends FeatureFlagValue = FeatureFlagValue> {
135
+ export interface FeatureFlagState<FeatureFlagKey extends string, T extends FeatureFlagValue = FeatureFlagValue> extends Loadable {
184
136
  value: T;
185
- isLoading: boolean;
186
- error: Error | null;
187
137
  evaluation: FeatureFlagEvaluation<FeatureFlagKey> | null;
188
138
  }
189
139
  /**
190
140
  * Context value interface for React feature flag provider.
191
141
  */
192
- export interface FeatureFlagContextValue<FeatureFlagKey extends string> {
142
+ export interface FeatureFlagContextValue<FeatureFlagKey extends string> extends Loadable, Initializable, Refreshable {
193
143
  /** The feature flag provider instance */
194
144
  provider: FeatureFlagProvider<FeatureFlagKey>;
195
- /** Whether the provider is initialized */
196
- isInitialized: boolean;
197
- /** Whether the provider is currently loading */
198
- isLoading: boolean;
199
- /** Any error that occurred during initialization */
200
- error: Error | null;
201
- /** When the provider was last updated */
202
- lastUpdated: Date | null;
203
- /** Manual refresh function */
204
- refresh: () => Promise<void>;
205
145
  }
206
146
  /**
207
147
  * Props for the React FeatureFlagProvider component.
@@ -232,27 +172,20 @@ export interface FeatureFlagProviderProps<FeatureFlagKey extends string, Feature
232
172
  /**
233
173
  * Backend Request DTO for flag creation.
234
174
  */
235
- export interface CreateFlagRequest<FeatureFlagKey extends string> {
236
- key: FeatureFlagKey;
237
- name: string;
238
- description?: string;
239
- value: FeatureFlagValue;
240
- isEnabled?: boolean;
241
- environment?: 'all' | 'development' | 'staging' | 'production';
175
+ export interface CreateFlagRequest<FeatureFlagKey extends string> extends WithEnvironment, SetOptional<Enabled, 'isEnabled'>, SetOptional<Describable, 'description'>, Named, KeyValuePair<FeatureFlagKey, FeatureFlagValue> {
242
176
  rolloutPercentage?: number;
243
177
  }
244
178
  /**
245
179
  * Backend Provider health status information.
246
180
  */
247
- export interface ProviderHealthStatus {
248
- isInitialized: boolean;
181
+ export interface ProviderHealthStatus extends Initializable {
249
182
  provider: string;
250
183
  isCacheEnabled: boolean;
251
184
  }
252
185
  /**
253
186
  * Main interface for feature flag providers.
254
187
  */
255
- export interface FeatureFlagProvider<FeatureFlagKey extends string> {
188
+ export interface FeatureFlagProvider<FeatureFlagKey extends string> extends Refreshable {
256
189
  /** Initializes the provider by loading initial data */
257
190
  initialize(): Promise<void>;
258
191
  /** Evaluates a feature flag and returns full evaluation details */
@@ -263,8 +196,6 @@ export interface FeatureFlagProvider<FeatureFlagKey extends string> {
263
196
  isEnabled(key: FeatureFlagKey, context?: FeatureFlagContext): Promise<boolean>;
264
197
  /** Gets the value of a feature flag with optional type casting */
265
198
  getValue<T = FeatureFlagValue>(key: FeatureFlagKey, context?: FeatureFlagContext): Promise<T>;
266
- /** Refreshes the flag data from the underlying storage */
267
- refresh(): Promise<void>;
268
199
  /** Subscribes to flag changes and updates */
269
200
  subscribe(callback: () => void): () => void;
270
201
  /** Sets an override for a specific flag key */
@@ -308,15 +239,9 @@ export type FeatureFlagOverrides<FeatureFlagKey extends string = string> = Parti
308
239
  /**
309
240
  * Hook-like interface for reactive feature flag usage.
310
241
  */
311
- export type FeatureFlagHook<T = boolean> = {
242
+ export type FeatureFlagHook<T = boolean> = Loadable & WithError & Refreshable & {
312
243
  /** The current value of the flag */
313
244
  value: T;
314
- /** Whether the flag is currently being loaded */
315
- isLoading: boolean;
316
- /** Any error that occurred during flag evaluation */
317
- error: Error | null;
318
- /** Function to manually refresh the flag value */
319
- refresh: () => Promise<void>;
320
245
  };
321
246
  /**
322
247
  * Helper functions for managing feature flags.
@@ -329,7 +254,7 @@ export interface FeatureFlagHelpers<FeatureFlagKey extends string = string> {
329
254
  getMultipleFlags: (keys: FeatureFlagKey[], context?: FeatureFlagContext) => Promise<Record<FeatureFlagKey, FeatureFlagValue>>;
330
255
  isAnyEnabled: (keys: FeatureFlagKey[], context?: FeatureFlagContext) => Promise<boolean>;
331
256
  isAllEnabled: (keys: FeatureFlagKey[], context?: FeatureFlagContext) => Promise<boolean>;
332
- whenEnabled: <T>(key: FeatureFlagKey, callback: () => T | Promise<T>, fallback?: () => T | Promise<T>, context?: FeatureFlagContext) => Promise<T | undefined>;
257
+ whenEnabled: <T>(key: FeatureFlagKey, callback: () => Promisable<T>, fallback?: () => Promisable<T>, context?: FeatureFlagContext) => Promise<T | undefined>;
333
258
  }
334
259
  /**
335
260
  * Response structure for fetching feature flag data.
@@ -367,32 +292,18 @@ export interface ErrorHandlingTestInput {
367
292
  /**
368
293
  * Input for flag evaluation test cases
369
294
  */
370
- export interface FlagEvaluationTestInput<FeatureFlagKey extends string> {
295
+ export interface FlagEvaluationTestInput<FeatureFlagKey extends string> extends Enabled {
371
296
  /** The flag key to evaluate */
372
297
  flagKey: FeatureFlagKey;
373
298
  /** Optional evaluation context */
374
299
  context?: FeatureFlagContext;
375
300
  /** Mock value to return */
376
301
  mockValue: boolean;
377
- /** Whether the flag is enabled */
378
- isEnabled: boolean;
379
302
  }
380
303
  /**
381
304
  * Input for flag creation test cases
382
305
  */
383
- export interface FlagCreationTestInput<FeatureFlagKey extends string> {
384
- /** Unique key for the flag */
385
- key: FeatureFlagKey;
386
- /** Human-readable name */
387
- name: string;
388
- /** Optional description */
389
- description?: string;
390
- /** Flag value */
391
- value: FeatureFlagValue;
392
- /** Whether the flag is enabled */
393
- isEnabled?: boolean;
394
- /** Target environment */
395
- environment?: 'all' | 'development' | 'production' | 'staging';
306
+ export interface FlagCreationTestInput<FeatureFlagKey extends string> extends WithEnvironment, Enabled, Describable, Named, KeyValuePair<FeatureFlagKey, FeatureFlagValue> {
396
307
  /** Rollout percentage (0-100) */
397
308
  rolloutPercentage?: number;
398
309
  }
@@ -403,7 +314,7 @@ export interface FlagUpdateTestInput<FeatureFlagKey extends string> {
403
314
  /** Key of the flag to update */
404
315
  flagKey: FeatureFlagKey;
405
316
  /** Update data object */
406
- updateData: Record<string, unknown>;
317
+ updateData: UnknownRecord;
407
318
  }
408
319
  /**
409
320
  * Input for override test cases
@@ -468,15 +379,13 @@ export interface EnvironmentFilterTestInput {
468
379
  /**
469
380
  * Input for timestamp behavior test cases
470
381
  */
471
- export interface TimestampTestInput {
472
- /** Operation type */
473
- operation: 'create' | 'update';
382
+ export interface TimestampTestInput extends WithOperation<'create' | 'update'> {
474
383
  /** Description of expected timestamp behavior */
475
384
  expectedTimestampBehavior: string;
476
385
  }
477
386
  export interface ModuleConfigurationTestInput {
478
- config: Record<string, unknown>;
479
- expectedConfig: Record<string, unknown>;
387
+ config: UnknownRecord;
388
+ expectedConfig: UnknownRecord;
480
389
  }
481
390
  /**
482
391
  * Input for provider type test cases.
@@ -509,9 +418,7 @@ export interface ProviderTypeTestInput {
509
418
  * };
510
419
  * ```
511
420
  */
512
- export interface FlagOperationTestInput<FeatureFlagKey extends string> {
513
- /** Type of operation to perform */
514
- operation: 'create' | 'update' | 'delete' | 'evaluate';
421
+ export interface FlagOperationTestInput<FeatureFlagKey extends string> extends WithOperation<'create' | 'update' | 'delete' | 'evaluate'>, Partial<Identifiable>, Partial<WithMetadata> {
515
422
  /** Key of the flag to operate on */
516
423
  flagKey: FeatureFlagKey;
517
424
  /** Data for create/update operations */
@@ -535,11 +442,9 @@ export interface FlagOperationTestInput<FeatureFlagKey extends string> {
535
442
  * };
536
443
  * ```
537
444
  */
538
- export interface PermissionTestInput {
445
+ export interface PermissionTestInput extends WithOperation {
539
446
  /** User role to test */
540
447
  role: string;
541
- /** Operation being performed */
542
- operation: string;
543
448
  /** Resource being accessed */
544
449
  resource: string;
545
450
  /** Expected permission result */
@@ -560,9 +465,7 @@ export interface PermissionTestInput {
560
465
  * };
561
466
  * ```
562
467
  */
563
- export interface CacheOperationTestInput<FeatureFlagKey extends string> {
564
- /** Cache operation to perform */
565
- operation: 'set' | 'get' | 'refresh' | 'clear';
468
+ export interface CacheOperationTestInput<FeatureFlagKey extends string> extends WithOperation<'set' | 'get' | 'refresh' | 'clear'> {
566
469
  /** Flag key for operations (optional for 'clear') */
567
470
  flagKey?: FeatureFlagKey;
568
471
  /** Description of expected cache behavior */
@@ -593,7 +496,7 @@ export interface RuleEvaluationTestInput<FeatureFlagKey extends string> {
593
496
  /** Array of rules with conditions and values */
594
497
  rules: Array<{
595
498
  /** Conditions that must be met */
596
- conditions: Record<string, unknown>;
499
+ conditions: UnknownRecord;
597
500
  /** Value to return if conditions match */
598
501
  value: FeatureFlagValue;
599
502
  }>;
@@ -622,16 +525,14 @@ export interface RuleEvaluationTestInput<FeatureFlagKey extends string> {
622
525
  */
623
526
  export interface BatchOperationTestInput<FeatureFlagKey extends string> {
624
527
  /** Array of operations to execute in batch */
625
- operations: Array<{
626
- /** Type of operation */
627
- type: 'create' | 'update' | 'delete';
528
+ operations: Array<WithOperation<'create' | 'update' | 'delete'> & {
628
529
  /** Flag key to operate on */
629
530
  flagKey: FeatureFlagKey;
630
531
  /** Operation data (for create/update) */
631
532
  data?: unknown;
632
533
  }>;
633
534
  /** Expected results for each operation */
634
- expectedResults: unknown[];
535
+ expectedResults: UnknownArray;
635
536
  }
636
537
  /**
637
538
  * Input for validation test cases.
@@ -647,15 +548,13 @@ export interface BatchOperationTestInput<FeatureFlagKey extends string> {
647
548
  * };
648
549
  * ```
649
550
  */
650
- export interface ValidationTestInput {
551
+ export interface ValidationTestInput extends Pick<ValidationResult, 'isValid'> {
651
552
  /** Input value to validate */
652
553
  input: unknown;
653
554
  /** Field name being validated */
654
555
  field: string;
655
556
  /** Expected error message if validation fails */
656
557
  expectedError?: string;
657
- /** Whether the input should be valid */
658
- isValid: boolean;
659
558
  }
660
559
  /**
661
560
  * Input for dynamic module configuration test cases.
@@ -673,7 +572,7 @@ export interface ValidationTestInput {
673
572
  */
674
573
  export interface DynamicModuleTestInput {
675
574
  /** Module configuration object */
676
- config: Record<string, unknown>;
575
+ config: UnknownRecord;
677
576
  /** Expected providers to be registered */
678
577
  expectedProviders?: string[];
679
578
  /** Expected modules to be imported */
@@ -702,7 +601,7 @@ export interface AsyncModuleConfigTestInput {
702
601
  /** Services to inject into factory */
703
602
  inject?: string[];
704
603
  /** Factory function for configuration */
705
- useFactory?: (...args: unknown[]) => Record<string, unknown>;
604
+ useFactory?: (...args: unknown[]) => UnknownRecord;
706
605
  /** Expected modules in result */
707
606
  expectedImports?: string[];
708
607
  /** Expected providers in result */
@@ -722,9 +621,7 @@ export interface AsyncModuleConfigTestInput {
722
621
  * };
723
622
  * ```
724
623
  */
725
- export interface RepositoryOperationTestInput {
726
- /** Repository operation to test */
727
- operation: 'create' | 'update' | 'delete' | 'find';
624
+ export interface RepositoryOperationTestInput extends WithOperation<'create' | 'update' | 'delete' | 'find'> {
728
625
  /** Data for the operation */
729
626
  data?: unknown;
730
627
  /** Expected operation result */
@@ -752,27 +649,11 @@ export interface RepositoryOperationTestInput {
752
649
  * };
753
650
  * ```
754
651
  */
755
- export interface FlagDefaults {
756
- /** Flag name */
757
- name: string;
758
- /** Flag description */
759
- description: string;
760
- /** Whether flag is enabled */
761
- isEnabled: boolean;
652
+ export interface FlagDefaults extends Named, Describable, Enabled, WithEnvironment, Timestamped<Date, Date>, Authored {
762
653
  /** Default value */
763
654
  value: FeatureFlagValue;
764
655
  /** Flag type */
765
656
  type: FlagType;
766
- /** Environment */
767
- environment: 'development' | 'staging' | 'production' | 'all';
768
- /** Created date */
769
- createdAt: Date;
770
- /** Updated date */
771
- updatedAt: Date;
772
- /** Created by */
773
- createdBy: string;
774
- /** Updated by */
775
- updatedBy: string;
776
657
  }
777
658
  /**
778
659
  * Supported types for feature flag values.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/auth/enums.ts","../src/errors/enums.ts","../src/events/enums.ts","../src/web3/enums.ts"],"names":[],"mappings":";;;AAYO,IAAM,SAAY,GAAA;AAAA;AAAA,EAEvB,OAAS,EAAA,SAAA;AAAA;AAAA,EAGT,KAAO,EAAA,OAAA;AAAA;AAAA,EAGP,KAAO,EAAA,OAAA;AAAA;AAAA,EAGP,IAAM,EAAA,MAAA;AAAA;AAAA,EAGN,GAAK,EAAA,KAAA;AAAA;AAAA,EAGL,KAAO,EAAA,OAAA;AAAA;AAAA,EAGP,UAAY,EAAA;AACd;AAcO,IAAM,WAAc,GAAA;AAAA;AAAA,EAEzB,MAAQ,EAAA,QAAA;AAAA;AAAA,EAGR,QAAU,EAAA,UAAA;AAAA;AAAA,EAGV,OAAS,EAAA,SAAA;AAAA;AAAA,EAGT,SAAW,EAAA,WAAA;AAAA;AAAA,EAGX,MAAQ,EAAA;AACV;AAcO,IAAM,aAAgB,GAAA;AAAA;AAAA,EAE3B,KAAO,EAAA,OAAA;AAAA;AAAA,EAGP,MAAQ,EAAA;AACV;;;AClEO,IAAM,UAAa,GAAA;AAAA;AAAA,EAExB,eAAiB,EAAA,kBAAA;AAAA;AAAA,EAGjB,qBAAuB,EAAA,yBAAA;AAAA;AAAA,EAGvB,aAAe,EAAA,uBAAA;AAAA;AAAA,EAGf,kBAAoB,EAAA,4BAAA;AAAA;AAAA,EAGpB,YAAc,EAAA,gBAAA;AAAA;AAAA,EAGd,iBAAmB,EAAA;AACrB;AAcO,IAAM,cAAiB,GAAA;AAAA;AAAA,EAE5B,GAAK,EAAA,KAAA;AAAA;AAAA,EAGL,MAAQ,EAAA,QAAA;AAAA;AAAA,EAGR,IAAM,EAAA,MAAA;AAAA;AAAA,EAGN,QAAU,EAAA;AACZ;AAcO,IAAM,cAAiB,GAAA;AAAA;AAAA,EAE5B,MAAQ,EAAA,QAAA;AAAA;AAAA,EAGR,MAAQ,EAAA,QAAA;AAAA;AAAA,EAGR,OAAS,EAAA,SAAA;AAAA;AAAA,EAGT,UAAY,EAAA,YAAA;AAAA;AAAA,EAGZ,UAAY,EAAA;AACd;;;AC9EO,IAAM,UAAa,GAAA;AAAA;AAAA,EAExB,OAAS,EAAA;AACX;AAaO,IAAM,cAAiB,GAAA;AAAA;AAAA,EAE5B,GAAK,EAAA,KAAA;AAAA;AAAA,EAEL,MAAQ,EAAA,QAAA;AAAA;AAAA,EAER,IAAM,EAAA,MAAA;AAAA;AAAA,EAEN,QAAU,EAAA;AACZ;AAkBO,IAAM,YAAe,GAAA;AAAA;AAAA,EAE1B,OAAS,EAAA,SAAA;AAAA;AAAA,EAET,UAAY,EAAA,YAAA;AAAA;AAAA,EAEZ,SAAW,EAAA,WAAA;AAAA;AAAA,EAEX,MAAQ,EAAA,QAAA;AAAA;AAAA,EAER,QAAU,EAAA;AACZ;;;ACpDO,IAAM,QAAW,GAAA;AAAA;AAAA,EAEtB,eAAiB,EAAA,CAAA;AAAA;AAAA,EAGjB,eAAiB,EAAA,QAAA;AAAA;AAAA,EAGjB,QAAU,EAAA,EAAA;AAAA;AAAA,EAGV,eAAiB,EAAA,QAAA;AAAA;AAAA,EAGjB,QAAU,EAAA,KAAA;AAAA;AAAA,EAGV,eAAiB,EAAA,MAAA;AAAA;AAAA,EAGjB,OAAS,EAAA,GAAA;AAAA;AAAA,EAGT,WAAa,EAAA,KAAA;AAAA;AAAA,EAGb,IAAM,EAAA,IAAA;AAAA;AAAA,EAGN,WAAa,EAAA;AACf","file":"index.js","sourcesContent":["/**\n * Enum representing the different roles a user can have within the system.\n * @description Roles are used to determine access levels, permissions, and user-specific experiences.\n *\n * @example\n * ```typescript\n * import { USER_ROLE } from '@plyaz/types';\n *\n * const userRole = USER_ROLE.Athlete; // 'athlete'\n * const isAdmin = userRole === USER_ROLE.Admin || userRole === USER_ROLE.SuperAdmin;\n * ```\n */\nexport const USER_ROLE = {\n /** A user who is an athlete and participates in sports activities. */\n Athlete: 'athlete',\n\n /** A user who scouts and discovers talent. */\n Scout: 'scout',\n\n /** A user who acts as an agent representing athletes or clubs. */\n Agent: 'agent',\n\n /** A user representing a sports club or organization. */\n Club: 'club',\n\n /** A fan or supporter of athletes or clubs. */\n Fan: 'fan',\n\n /** A system administrator with access to management tools. */\n Admin: 'admin',\n\n /** A super admin with the highest level of access and control. */\n SuperAdmin: 'super.admin',\n} as const;\n\n/**\n * Enum representing the current status of a user account.\n * @description Statuses are used to determine login availability, visibility, and user flow.\n *\n * @example\n * ```typescript\n * import { USER_STATUS } from '@plyaz/types';\n *\n * const isAccessible = status === USER_STATUS.Active;\n * const needsReview = status === USER_STATUS.Pending;\n * ```\n */\nexport const USER_STATUS = {\n /** Active user with full access. */\n Active: 'active',\n\n /** Inactive user, typically not currently using the platform. */\n Inactive: 'inactive',\n\n /** User account is awaiting approval or completion of setup. */\n Pending: 'pending',\n\n /** User has been temporarily suspended due to policy violations or manual review. */\n Suspended: 'suspended',\n\n /** User has been permanently banned from the platform. */\n Banned: 'banned',\n} as const;\n\n/**\n * Enum representing the supported authentication providers for user login.\n * @description Auth Providers allowed such as Email, Wallet, etc.\n *\n * @example\n * ```typescript\n * import { AUTH_PROVIDER } from '@plyaz/types';\n *\n * const provider = AUTH_PROVIDER.Wallet; // 'wallet'\n * const isWeb3Auth = provider === AUTH_PROVIDER.Wallet;\n * ```\n */\nexport const AUTH_PROVIDER = {\n /** Authentication via email and password. */\n Email: 'email',\n\n /** Authentication via connected blockchain wallet. */\n Wallet: 'wallet',\n} as const;\n","/**\n * Enum representing standardized error types used across the application.\n * @description These error types help classify different categories of errors such as validation issues and system-level failures.\n *\n * @example\n * ```typescript\n * import { ERROR_TYPE } from '@plyaz/types';\n *\n * const errorType = ERROR_TYPE.ValidationError; // 'validation.error'\n *\n * // Error handling example\n * if (error.type === ERROR_TYPE.RateLimitExceeded) {\n * // Handle rate limiting\n * }\n * ```\n */\nexport const ERROR_TYPE = {\n /** A general validation error (e.g., form or input errors). */\n ValidationError: 'validation.error',\n\n /** Error related to schema validation, such as JSON schema or API payload checks. */\n SchemaValidationError: 'validation.schema.error',\n\n /** Unhandled or unexpected system error. */\n InternalError: 'system.internal.error',\n\n /** System dependency is currently unavailable (e.g., database or external API). */\n ServiceUnavailable: 'system.service.unavailable',\n\n /** The request took too long and timed out. */\n TimeoutError: 'system.timeout',\n\n /** Too many requests made in a short period of time. */\n RateLimitExceeded: 'system.rate.limit.exceeded',\n} as const;\n\n/**\n * Enum representing the severity level of an error.\n * @description This allows categorization of errors by their potential impact on the system or user.\n *\n * @example\n * ```typescript\n * import { ERROR_SEVERITY } from '@plyaz/types';\n *\n * const severity = ERROR_SEVERITY.Critical; // 'critical'\n * const shouldAlert = severity === ERROR_SEVERITY.High || severity === ERROR_SEVERITY.Critical;\n * ```\n */\nexport const ERROR_SEVERITY = {\n /** Low severity - does not impact functionality significantly. */\n Low: 'low',\n\n /** Medium severity - minor disruption or warning. */\n Medium: 'medium',\n\n /** High severity - major issue requiring attention. */\n High: 'high',\n\n /** Critical severity - blocking or crashing issue. */\n Critical: 'critical',\n} as const;\n\n/**\n * Enum representing the category or origin of an error.\n * @description Useful for filtering or logging errors based on their source or nature.\n *\n * @example\n * ```typescript\n * import { ERROR_CATEGORY } from '@plyaz/types';\n *\n * const category = ERROR_CATEGORY.Blockchain; // 'blockchain'\n * const isClientError = category === ERROR_CATEGORY.Client;\n * ```\n */\nexport const ERROR_CATEGORY = {\n /** Client-side error (e.g., invalid request). */\n Client: 'client',\n\n /** Server-side error (e.g., logic failure or exception). */\n Server: 'server',\n\n /** Network-related error (e.g., unreachable endpoint). */\n Network: 'network',\n\n /** Blockchain-related error (e.g., transaction failure, gas limit). */\n Blockchain: 'blockchain',\n\n // Validation-specific error (e.g., failed constraints or field errors).\n Validation: 'validation',\n} as const;\n","/**\n * Enum representing the types of events in the application.\n * Uses dot notation for event naming convention.\n *\n * @example\n * ```typescript\n * import { EVENT_TYPE } from '@plyaz/types';\n *\n * const eventType = EVENT_TYPE.AppInit; // 'app.init'\n * ```\n */\nexport const EVENT_TYPE = {\n /** Application initialization event. */\n AppInit: 'app.init',\n} as const;\n\n/**\n * Const representing the priority levels for events.\n * Used to determine processing order and resource allocation.\n *\n * @example\n * ```typescript\n * import { EVENT_PRIORITY } from '@plyaz/types';\n *\n * const priority = EVENT_PRIORITY.High; // 'high'\n * ```\n */\nexport const EVENT_PRIORITY = {\n /** Low priority event. */\n Low: 'low',\n /** Normal priority event. */\n Normal: 'normal',\n /** High priority event. */\n High: 'high',\n /** Critical priority event. */\n Critical: 'critical',\n} as const;\n\n/**\n * Const representing the status of an event.\n * Tracks the lifecycle of event processing from creation to completion.\n *\n * @example\n * ```typescript\n * import { EVENT_STATUS } from '@plyaz/types';\n *\n * const status = EVENT_STATUS.Processing; // 'processing'\n *\n * // Typical event lifecycle:\n * // Pending -> Processing -> Completed\n * // or\n * // Pending -> Processing -> Failed -> Retrying -> Processing -> Completed\n * ```\n */\nexport const EVENT_STATUS = {\n /** Event is pending and has not started processing. */\n Pending: 'pending',\n /** Event is currently being processed. */\n Processing: 'processing',\n /** Event has been completed successfully. */\n Completed: 'completed',\n /** Event processing failed. */\n Failed: 'failed',\n /** Event is being retried after a failure. */\n Retrying: 'retrying',\n} as const;\n","/**\n * Enum representing supported EVM-compatible blockchain networks by their numeric chain IDs.\n * @description These IDs are used to identify the specific network when interacting with wallets or smart contracts.\n * @see https://chainlist.org for reference chain IDs\n *\n * @example\n * ```typescript\n * import { CHAIN_ID } from '@plyaz/types';\n *\n * const chainId = CHAIN_ID.EthereumMainnet; // 1\n * const isTestnet = chainId === CHAIN_ID.EthereumSepolia || chainId === CHAIN_ID.PolygonAmoy;\n * ```\n */\nexport const CHAIN_ID = {\n /** Ethereum Mainnet (Chain ID: 1). */\n EthereumMainnet: 1,\n\n /** Ethereum Sepolia Testnet (Chain ID: 11155111). */\n EthereumSepolia: 11_155_111,\n\n /** Optimism Mainnet (Chain ID: 10). */\n Optimism: 10,\n\n /** Optimism Sepolia Testnet (Chain ID: 11155420). */\n OptimismSepolia: 11_155_420,\n\n /** Arbitrum One Mainnet (Chain ID: 42161). */\n Arbitrum: 42_161,\n\n /** Arbitrum Sepolia Testnet (Chain ID: 421614). */\n ArbitrumSepolia: 421_614,\n\n /** Polygon Mainnet (Chain ID: 137). */\n Polygon: 137,\n\n /** Polygon Amoy Testnet (Chain ID: 80002). */\n PolygonAmoy: 80_002,\n\n /** Base Mainnet (Chain ID: 8453). */\n Base: 8_453,\n\n /** Base Sepolia Testnet (Chain ID: 84532). */\n BaseSepolia: 84_532,\n} as const;\n"]}
1
+ {"version":3,"sources":["../src/auth/enums.ts","../src/errors/enums.ts","../src/events/enums.ts","../src/web3/enums.ts"],"names":[],"mappings":";;;AAYO,IAAM,SAAA,GAAY;AAAA;AAAA,EAEvB,OAAA,EAAS,SAAA;AAAA;AAAA,EAGT,KAAA,EAAO,OAAA;AAAA;AAAA,EAGP,KAAA,EAAO,OAAA;AAAA;AAAA,EAGP,IAAA,EAAM,MAAA;AAAA;AAAA,EAGN,GAAA,EAAK,KAAA;AAAA;AAAA,EAGL,KAAA,EAAO,OAAA;AAAA;AAAA,EAGP,UAAA,EAAY;AACd;AAcO,IAAM,WAAA,GAAc;AAAA;AAAA,EAEzB,MAAA,EAAQ,QAAA;AAAA;AAAA,EAGR,QAAA,EAAU,UAAA;AAAA;AAAA,EAGV,OAAA,EAAS,SAAA;AAAA;AAAA,EAGT,SAAA,EAAW,WAAA;AAAA;AAAA,EAGX,MAAA,EAAQ;AACV;AAcO,IAAM,aAAA,GAAgB;AAAA;AAAA,EAE3B,KAAA,EAAO,OAAA;AAAA;AAAA,EAGP,MAAA,EAAQ;AACV;;;AClEO,IAAM,UAAA,GAAa;AAAA;AAAA,EAExB,eAAA,EAAiB,kBAAA;AAAA;AAAA,EAGjB,qBAAA,EAAuB,yBAAA;AAAA;AAAA,EAGvB,aAAA,EAAe,uBAAA;AAAA;AAAA,EAGf,kBAAA,EAAoB,4BAAA;AAAA;AAAA,EAGpB,YAAA,EAAc,gBAAA;AAAA;AAAA,EAGd,iBAAA,EAAmB;AACrB;AAcO,IAAM,cAAA,GAAiB;AAAA;AAAA,EAE5B,GAAA,EAAK,KAAA;AAAA;AAAA,EAGL,MAAA,EAAQ,QAAA;AAAA;AAAA,EAGR,IAAA,EAAM,MAAA;AAAA;AAAA,EAGN,QAAA,EAAU;AACZ;AAcO,IAAM,cAAA,GAAiB;AAAA;AAAA,EAE5B,MAAA,EAAQ,QAAA;AAAA;AAAA,EAGR,MAAA,EAAQ,QAAA;AAAA;AAAA,EAGR,OAAA,EAAS,SAAA;AAAA;AAAA,EAGT,UAAA,EAAY,YAAA;AAAA;AAAA,EAGZ,UAAA,EAAY;AACd;;;AC9EO,IAAM,UAAA,GAAa;AAAA;AAAA,EAExB,OAAA,EAAS;AACX;AAaO,IAAM,cAAA,GAAiB;AAAA;AAAA,EAE5B,GAAA,EAAK,KAAA;AAAA;AAAA,EAEL,MAAA,EAAQ,QAAA;AAAA;AAAA,EAER,IAAA,EAAM,MAAA;AAAA;AAAA,EAEN,QAAA,EAAU;AACZ;AAkBO,IAAM,YAAA,GAAe;AAAA;AAAA,EAE1B,OAAA,EAAS,SAAA;AAAA;AAAA,EAET,UAAA,EAAY,YAAA;AAAA;AAAA,EAEZ,SAAA,EAAW,WAAA;AAAA;AAAA,EAEX,MAAA,EAAQ,QAAA;AAAA;AAAA,EAER,QAAA,EAAU;AACZ;;;ACpDO,IAAM,QAAA,GAAW;AAAA;AAAA,EAEtB,eAAA,EAAiB,CAAA;AAAA;AAAA,EAGjB,eAAA,EAAiB,QAAA;AAAA;AAAA,EAGjB,QAAA,EAAU,EAAA;AAAA;AAAA,EAGV,eAAA,EAAiB,QAAA;AAAA;AAAA,EAGjB,QAAA,EAAU,KAAA;AAAA;AAAA,EAGV,eAAA,EAAiB,MAAA;AAAA;AAAA,EAGjB,OAAA,EAAS,GAAA;AAAA;AAAA,EAGT,WAAA,EAAa,KAAA;AAAA;AAAA,EAGb,IAAA,EAAM,IAAA;AAAA;AAAA,EAGN,WAAA,EAAa;AACf","file":"index.js","sourcesContent":["/**\n * Enum representing the different roles a user can have within the system.\n * @description Roles are used to determine access levels, permissions, and user-specific experiences.\n *\n * @example\n * ```typescript\n * import { USER_ROLE } from '@plyaz/types';\n *\n * const userRole = USER_ROLE.Athlete; // 'athlete'\n * const isAdmin = userRole === USER_ROLE.Admin || userRole === USER_ROLE.SuperAdmin;\n * ```\n */\nexport const USER_ROLE = {\n /** A user who is an athlete and participates in sports activities. */\n Athlete: 'athlete',\n\n /** A user who scouts and discovers talent. */\n Scout: 'scout',\n\n /** A user who acts as an agent representing athletes or clubs. */\n Agent: 'agent',\n\n /** A user representing a sports club or organization. */\n Club: 'club',\n\n /** A fan or supporter of athletes or clubs. */\n Fan: 'fan',\n\n /** A system administrator with access to management tools. */\n Admin: 'admin',\n\n /** A super admin with the highest level of access and control. */\n SuperAdmin: 'super.admin',\n} as const;\n\n/**\n * Enum representing the current status of a user account.\n * @description Statuses are used to determine login availability, visibility, and user flow.\n *\n * @example\n * ```typescript\n * import { USER_STATUS } from '@plyaz/types';\n *\n * const isAccessible = status === USER_STATUS.Active;\n * const needsReview = status === USER_STATUS.Pending;\n * ```\n */\nexport const USER_STATUS = {\n /** Active user with full access. */\n Active: 'active',\n\n /** Inactive user, typically not currently using the platform. */\n Inactive: 'inactive',\n\n /** User account is awaiting approval or completion of setup. */\n Pending: 'pending',\n\n /** User has been temporarily suspended due to policy violations or manual review. */\n Suspended: 'suspended',\n\n /** User has been permanently banned from the platform. */\n Banned: 'banned',\n} as const;\n\n/**\n * Enum representing the supported authentication providers for user login.\n * @description Auth Providers allowed such as Email, Wallet, etc.\n *\n * @example\n * ```typescript\n * import { AUTH_PROVIDER } from '@plyaz/types';\n *\n * const provider = AUTH_PROVIDER.Wallet; // 'wallet'\n * const isWeb3Auth = provider === AUTH_PROVIDER.Wallet;\n * ```\n */\nexport const AUTH_PROVIDER = {\n /** Authentication via email and password. */\n Email: 'email',\n\n /** Authentication via connected blockchain wallet. */\n Wallet: 'wallet',\n} as const;\n","/**\n * Enum representing standardized error types used across the application.\n * @description These error types help classify different categories of errors such as validation issues and system-level failures.\n *\n * @example\n * ```typescript\n * import { ERROR_TYPE } from '@plyaz/types';\n *\n * const errorType = ERROR_TYPE.ValidationError; // 'validation.error'\n *\n * // Error handling example\n * if (error.type === ERROR_TYPE.RateLimitExceeded) {\n * // Handle rate limiting\n * }\n * ```\n */\nexport const ERROR_TYPE = {\n /** A general validation error (e.g., form or input errors). */\n ValidationError: 'validation.error',\n\n /** Error related to schema validation, such as JSON schema or API payload checks. */\n SchemaValidationError: 'validation.schema.error',\n\n /** Unhandled or unexpected system error. */\n InternalError: 'system.internal.error',\n\n /** System dependency is currently unavailable (e.g., database or external API). */\n ServiceUnavailable: 'system.service.unavailable',\n\n /** The request took too long and timed out. */\n TimeoutError: 'system.timeout',\n\n /** Too many requests made in a short period of time. */\n RateLimitExceeded: 'system.rate.limit.exceeded',\n} as const;\n\n/**\n * Enum representing the severity level of an error.\n * @description This allows categorization of errors by their potential impact on the system or user.\n *\n * @example\n * ```typescript\n * import { ERROR_SEVERITY } from '@plyaz/types';\n *\n * const severity = ERROR_SEVERITY.Critical; // 'critical'\n * const shouldAlert = severity === ERROR_SEVERITY.High || severity === ERROR_SEVERITY.Critical;\n * ```\n */\nexport const ERROR_SEVERITY = {\n /** Low severity - does not impact functionality significantly. */\n Low: 'low',\n\n /** Medium severity - minor disruption or warning. */\n Medium: 'medium',\n\n /** High severity - major issue requiring attention. */\n High: 'high',\n\n /** Critical severity - blocking or crashing issue. */\n Critical: 'critical',\n} as const;\n\n/**\n * Enum representing the category or origin of an error.\n * @description Useful for filtering or logging errors based on their source or nature.\n *\n * @example\n * ```typescript\n * import { ERROR_CATEGORY } from '@plyaz/types';\n *\n * const category = ERROR_CATEGORY.Blockchain; // 'blockchain'\n * const isClientError = category === ERROR_CATEGORY.Client;\n * ```\n */\nexport const ERROR_CATEGORY = {\n /** Client-side error (e.g., invalid request). */\n Client: 'client',\n\n /** Server-side error (e.g., logic failure or exception). */\n Server: 'server',\n\n /** Network-related error (e.g., unreachable endpoint). */\n Network: 'network',\n\n /** Blockchain-related error (e.g., transaction failure, gas limit). */\n Blockchain: 'blockchain',\n\n // Validation-specific error (e.g., failed constraints or field errors).\n Validation: 'validation',\n} as const;\n","/**\n * Enum representing the types of events in the application.\n * Uses dot notation for event naming convention.\n *\n * @example\n * ```typescript\n * import { EVENT_TYPE } from '@plyaz/types';\n *\n * const eventType = EVENT_TYPE.AppInit; // 'app.init'\n * ```\n */\nexport const EVENT_TYPE = {\n /** Application initialization event. */\n AppInit: 'app.init',\n} as const;\n\n/**\n * Const representing the priority levels for events.\n * Used to determine processing order and resource allocation.\n *\n * @example\n * ```typescript\n * import { EVENT_PRIORITY } from '@plyaz/types';\n *\n * const priority = EVENT_PRIORITY.High; // 'high'\n * ```\n */\nexport const EVENT_PRIORITY = {\n /** Low priority event. */\n Low: 'low',\n /** Normal priority event. */\n Normal: 'normal',\n /** High priority event. */\n High: 'high',\n /** Critical priority event. */\n Critical: 'critical',\n} as const;\n\n/**\n * Const representing the status of an event.\n * Tracks the lifecycle of event processing from creation to completion.\n *\n * @example\n * ```typescript\n * import { EVENT_STATUS } from '@plyaz/types';\n *\n * const status = EVENT_STATUS.Processing; // 'processing'\n *\n * // Typical event lifecycle:\n * // Pending -> Processing -> Completed\n * // or\n * // Pending -> Processing -> Failed -> Retrying -> Processing -> Completed\n * ```\n */\nexport const EVENT_STATUS = {\n /** Event is pending and has not started processing. */\n Pending: 'pending',\n /** Event is currently being processed. */\n Processing: 'processing',\n /** Event has been completed successfully. */\n Completed: 'completed',\n /** Event processing failed. */\n Failed: 'failed',\n /** Event is being retried after a failure. */\n Retrying: 'retrying',\n} as const;\n","/**\n * Enum representing supported EVM-compatible blockchain networks by their numeric chain IDs.\n * @description These IDs are used to identify the specific network when interacting with wallets or smart contracts.\n * @see https://chainlist.org for reference chain IDs\n *\n * @example\n * ```typescript\n * import { CHAIN_ID } from '@plyaz/types';\n *\n * const chainId = CHAIN_ID.EthereumMainnet; // 1\n * const isTestnet = chainId === CHAIN_ID.EthereumSepolia || chainId === CHAIN_ID.PolygonAmoy;\n * ```\n */\nexport const CHAIN_ID = {\n /** Ethereum Mainnet (Chain ID: 1). */\n EthereumMainnet: 1,\n\n /** Ethereum Sepolia Testnet (Chain ID: 11155111). */\n EthereumSepolia: 11_155_111,\n\n /** Optimism Mainnet (Chain ID: 10). */\n Optimism: 10,\n\n /** Optimism Sepolia Testnet (Chain ID: 11155420). */\n OptimismSepolia: 11_155_420,\n\n /** Arbitrum One Mainnet (Chain ID: 42161). */\n Arbitrum: 42_161,\n\n /** Arbitrum Sepolia Testnet (Chain ID: 421614). */\n ArbitrumSepolia: 421_614,\n\n /** Polygon Mainnet (Chain ID: 137). */\n Polygon: 137,\n\n /** Polygon Amoy Testnet (Chain ID: 80002). */\n PolygonAmoy: 80_002,\n\n /** Base Mainnet (Chain ID: 8453). */\n Base: 8_453,\n\n /** Base Sepolia Testnet (Chain ID: 84532). */\n BaseSepolia: 84_532,\n} as const;\n"]}
@@ -3,6 +3,8 @@
3
3
  *
4
4
  * Type definitions for assertion utilities.
5
5
  */
6
+ import type { UnknownRecord, UnknownArray, Promisable } from 'type-fest';
7
+ import type { WithStatusCode, WithMessage, WithTimestamp, WithCorrelationId, WithMetadata, Named, WithRequestId, WithStatus } from '../../../common/types';
6
8
  /**
7
9
  * Pattern for matching HTTP errors with status code and message.
8
10
  * Used in testing to assert specific error responses.
@@ -15,9 +17,7 @@
15
17
  * };
16
18
  * ```
17
19
  */
18
- export interface ErrorPattern {
19
- /** HTTP status code to match */
20
- status: number;
20
+ export interface ErrorPattern extends WithStatusCode, WithStatus {
21
21
  /** Regular expression to match against error message */
22
22
  message: RegExp;
23
23
  }
@@ -33,9 +33,7 @@ export interface ErrorPattern {
33
33
  * };
34
34
  * ```
35
35
  */
36
- export interface ValidationErrorPattern {
37
- /** HTTP status code (typically 400 for validation errors) */
38
- status: number;
36
+ export interface ValidationErrorPattern extends WithStatusCode {
39
37
  /** Array of field names that failed validation */
40
38
  validation: string[];
41
39
  }
@@ -63,13 +61,11 @@ export interface ErrorStats {
63
61
  * Entry in an error timeline tracking when errors occurred.
64
62
  * Used for debugging error patterns over time.
65
63
  */
66
- export interface ErrorTimelineEntry {
67
- /** Unix timestamp when the error occurred */
68
- timestamp: number;
64
+ export interface ErrorTimelineEntry extends WithTimestamp<number> {
69
65
  /** The error that occurred */
70
66
  error: Error;
71
67
  /** Additional context data at the time of error */
72
- context?: Record<string, unknown>;
68
+ context?: UnknownRecord;
73
69
  }
74
70
  /**
75
71
  * Expected error pattern for validation.
@@ -95,7 +91,7 @@ export interface ExpectedError {
95
91
  */
96
92
  export interface ValidationResponse {
97
93
  /** Array of validation error messages */
98
- message?: unknown[];
94
+ message?: UnknownArray;
99
95
  }
100
96
  /**
101
97
  * Result type for hooks that return a value.
@@ -143,19 +139,15 @@ export interface ErrorRecoveryResult {
143
139
  * Entry for correlating errors with additional context.
144
140
  * Used in error tracking and debugging systems.
145
141
  */
146
- export interface ErrorCorrelationEntry {
147
- /** The error being tracked */
142
+ export interface ErrorCorrelationEntry extends Partial<WithMetadata<UnknownRecord>> {
143
+ /** The original error that triggered recovery */
148
144
  error: Error;
149
- /** Additional metadata for correlation */
150
- metadata?: Record<string, unknown>;
151
145
  }
152
146
  /**
153
147
  * Definition of an error test scenario.
154
148
  * Used to parameterize error testing across multiple cases.
155
149
  */
156
- export interface ErrorTestScenario {
157
- /** Descriptive name for the test scenario */
158
- name: string;
150
+ export interface ErrorTestScenario extends Named {
159
151
  /** Function that should trigger the error */
160
152
  fn: () => unknown | Promise<unknown>;
161
153
  /** Expected error or error pattern */
@@ -211,7 +203,7 @@ export interface ErrorPropagationTestResult<T> {
211
203
  */
212
204
  export interface ErrorCircuitBreaker<T> {
213
205
  /** Execute function with circuit breaker protection */
214
- execute: (fn: () => T | Promise<T>) => Promise<T>;
206
+ execute: (fn: () => Promisable<T>) => Promisable<T>;
215
207
  /** Get current circuit state */
216
208
  getState: () => 'closed' | 'open' | 'half-open';
217
209
  /** Get error statistics */
@@ -225,7 +217,7 @@ export interface ErrorCircuitBreaker<T> {
225
217
  */
226
218
  export interface ErrorCorrelator {
227
219
  /** Create correlation ID for an error */
228
- correlate: (error: Error, metadata?: Record<string, unknown>) => string;
220
+ correlate: (error: Error, metadata?: UnknownRecord) => string;
229
221
  /** Get all errors with same correlation ID */
230
222
  getRelated: (correlationId: string) => Array<ErrorCorrelationEntry>;
231
223
  /** Get chain of errors leading to this one */
@@ -237,7 +229,7 @@ export interface ErrorCorrelator {
237
229
  */
238
230
  export interface ErrorMetrics {
239
231
  /** Record an error occurrence */
240
- record: (error: Error, context?: Record<string, unknown>) => void;
232
+ record: (error: Error, context?: UnknownRecord) => void;
241
233
  /** Get aggregated error metrics */
242
234
  getMetrics: () => {
243
235
  /** Total error count */
@@ -272,10 +264,7 @@ export interface ErrorDeduplicator {
272
264
  * Simple error interface with message property.
273
265
  * Used for type guards and error handling.
274
266
  */
275
- export interface ErrorWithMessage {
276
- /** Error message */
277
- message: string;
278
- }
267
+ export type ErrorWithMessage = WithMessage;
279
268
  /**
280
269
  * Error interface that includes HTTP response data.
281
270
  * Common in API error handling scenarios.
@@ -300,9 +289,7 @@ export interface ValidationMessage {
300
289
  * Expected HTTP exception pattern for testing.
301
290
  * Used to assert specific HTTP error responses.
302
291
  */
303
- export interface ExpectedHttpException {
304
- /** Expected HTTP status code */
305
- status?: number;
292
+ export interface ExpectedHttpException extends Partial<WithStatusCode>, WithStatus {
306
293
  /** Expected error message or pattern */
307
294
  message?: string | RegExp;
308
295
  /** Expected response body */
@@ -332,17 +319,11 @@ export interface ErrorPropagationInjection {
332
319
  * Context data for enriching errors with additional information.
333
320
  * Helps with debugging and error tracking.
334
321
  */
335
- export interface ErrorEnrichmentContext {
322
+ export interface ErrorEnrichmentContext extends Partial<WithTimestamp<number>>, Partial<WithCorrelationId>, Partial<WithMetadata<UnknownRecord>>, Partial<WithRequestId> {
336
323
  /** Operation being performed when error occurred */
337
324
  operation?: string;
338
325
  /** User identifier associated with error */
339
326
  user?: string;
340
- /** Timestamp of error occurrence */
341
- timestamp?: number;
342
- /** Request ID for tracing */
343
- requestId?: string;
344
- /** Additional metadata */
345
- metadata?: Record<string, unknown>;
346
327
  }
347
328
  /**
348
329
  * Configuration options for error deduplication.