@plyaz/types 1.3.5 → 1.3.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.
@@ -1,32 +1,70 @@
1
1
  /**
2
2
  * Enum representing the different roles a user can have within the system.
3
3
  * @description Roles are used to determine access levels, permissions, and user-specific experiences.
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * import { USER_ROLE } from '@plyaz/types';
8
+ *
9
+ * const userRole = USER_ROLE.Athlete; // 'athlete'
10
+ * const isAdmin = userRole === USER_ROLE.Admin || userRole === USER_ROLE.SuperAdmin;
11
+ * ```
4
12
  */
5
13
  export declare const USER_ROLE: {
14
+ /** A user who is an athlete and participates in sports activities. */
6
15
  readonly Athlete: "athlete";
16
+ /** A user who scouts and discovers talent. */
7
17
  readonly Scout: "scout";
18
+ /** A user who acts as an agent representing athletes or clubs. */
8
19
  readonly Agent: "agent";
20
+ /** A user representing a sports club or organization. */
9
21
  readonly Club: "club";
22
+ /** A fan or supporter of athletes or clubs. */
10
23
  readonly Fan: "fan";
24
+ /** A system administrator with access to management tools. */
11
25
  readonly Admin: "admin";
26
+ /** A super admin with the highest level of access and control. */
12
27
  readonly SuperAdmin: "super.admin";
13
28
  };
14
29
  /**
15
30
  * Enum representing the current status of a user account.
16
31
  * @description Statuses are used to determine login availability, visibility, and user flow.
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * import { USER_STATUS } from '@plyaz/types';
36
+ *
37
+ * const isAccessible = status === USER_STATUS.Active;
38
+ * const needsReview = status === USER_STATUS.Pending;
39
+ * ```
17
40
  */
18
41
  export declare const USER_STATUS: {
42
+ /** Active user with full access. */
19
43
  readonly Active: "active";
44
+ /** Inactive user, typically not currently using the platform. */
20
45
  readonly Inactive: "inactive";
46
+ /** User account is awaiting approval or completion of setup. */
21
47
  readonly Pending: "pending";
48
+ /** User has been temporarily suspended due to policy violations or manual review. */
22
49
  readonly Suspended: "suspended";
50
+ /** User has been permanently banned from the platform. */
23
51
  readonly Banned: "banned";
24
52
  };
25
53
  /**
26
54
  * Enum representing the supported authentication providers for user login.
27
55
  * @description Auth Providers allowed such as Email, Wallet, etc.
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * import { AUTH_PROVIDER } from '@plyaz/types';
60
+ *
61
+ * const provider = AUTH_PROVIDER.Wallet; // 'wallet'
62
+ * const isWeb3Auth = provider === AUTH_PROVIDER.Wallet;
63
+ * ```
28
64
  */
29
65
  export declare const AUTH_PROVIDER: {
66
+ /** Authentication via email and password. */
30
67
  readonly Email: "email";
68
+ /** Authentication via connected blockchain wallet. */
31
69
  readonly Wallet: "wallet";
32
70
  };
@@ -1,33 +1,75 @@
1
1
  /**
2
2
  * Enum representing standardized error types used across the application.
3
3
  * @description These error types help classify different categories of errors such as validation issues and system-level failures.
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * import { ERROR_TYPE } from '@plyaz/types';
8
+ *
9
+ * const errorType = ERROR_TYPE.ValidationError; // 'validation.error'
10
+ *
11
+ * // Error handling example
12
+ * if (error.type === ERROR_TYPE.RateLimitExceeded) {
13
+ * // Handle rate limiting
14
+ * }
15
+ * ```
4
16
  */
5
17
  export declare const ERROR_TYPE: {
18
+ /** A general validation error (e.g., form or input errors). */
6
19
  readonly ValidationError: "validation.error";
20
+ /** Error related to schema validation, such as JSON schema or API payload checks. */
7
21
  readonly SchemaValidationError: "validation.schema.error";
22
+ /** Unhandled or unexpected system error. */
8
23
  readonly InternalError: "system.internal.error";
24
+ /** System dependency is currently unavailable (e.g., database or external API). */
9
25
  readonly ServiceUnavailable: "system.service.unavailable";
26
+ /** The request took too long and timed out. */
10
27
  readonly TimeoutError: "system.timeout";
28
+ /** Too many requests made in a short period of time. */
11
29
  readonly RateLimitExceeded: "system.rate.limit.exceeded";
12
30
  };
13
31
  /**
14
32
  * Enum representing the severity level of an error.
15
33
  * @description This allows categorization of errors by their potential impact on the system or user.
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * import { ERROR_SEVERITY } from '@plyaz/types';
38
+ *
39
+ * const severity = ERROR_SEVERITY.Critical; // 'critical'
40
+ * const shouldAlert = severity === ERROR_SEVERITY.High || severity === ERROR_SEVERITY.Critical;
41
+ * ```
16
42
  */
17
43
  export declare const ERROR_SEVERITY: {
44
+ /** Low severity - does not impact functionality significantly. */
18
45
  readonly Low: "low";
46
+ /** Medium severity - minor disruption or warning. */
19
47
  readonly Medium: "medium";
48
+ /** High severity - major issue requiring attention. */
20
49
  readonly High: "high";
50
+ /** Critical severity - blocking or crashing issue. */
21
51
  readonly Critical: "critical";
22
52
  };
23
53
  /**
24
54
  * Enum representing the category or origin of an error.
25
55
  * @description Useful for filtering or logging errors based on their source or nature.
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * import { ERROR_CATEGORY } from '@plyaz/types';
60
+ *
61
+ * const category = ERROR_CATEGORY.Blockchain; // 'blockchain'
62
+ * const isClientError = category === ERROR_CATEGORY.Client;
63
+ * ```
26
64
  */
27
65
  export declare const ERROR_CATEGORY: {
66
+ /** Client-side error (e.g., invalid request). */
28
67
  readonly Client: "client";
68
+ /** Server-side error (e.g., logic failure or exception). */
29
69
  readonly Server: "server";
70
+ /** Network-related error (e.g., unreachable endpoint). */
30
71
  readonly Network: "network";
72
+ /** Blockchain-related error (e.g., transaction failure, gas limit). */
31
73
  readonly Blockchain: "blockchain";
32
74
  readonly Validation: "validation";
33
75
  };
@@ -1,25 +1,64 @@
1
1
  /**
2
2
  * Enum representing the types of events in the application.
3
+ * Uses dot notation for event naming convention.
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * import { EVENT_TYPE } from '@plyaz/types';
8
+ *
9
+ * const eventType = EVENT_TYPE.AppInit; // 'app.init'
10
+ * ```
3
11
  */
4
12
  export declare const EVENT_TYPE: {
13
+ /** Application initialization event. */
5
14
  readonly AppInit: "app.init";
6
15
  };
7
16
  /**
8
17
  * Const representing the priority levels for events.
18
+ * Used to determine processing order and resource allocation.
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * import { EVENT_PRIORITY } from '@plyaz/types';
23
+ *
24
+ * const priority = EVENT_PRIORITY.High; // 'high'
25
+ * ```
9
26
  */
10
27
  export declare const EVENT_PRIORITY: {
28
+ /** Low priority event. */
11
29
  readonly Low: "low";
30
+ /** Normal priority event. */
12
31
  readonly Normal: "normal";
32
+ /** High priority event. */
13
33
  readonly High: "high";
34
+ /** Critical priority event. */
14
35
  readonly Critical: "critical";
15
36
  };
16
37
  /**
17
38
  * Const representing the status of an event.
39
+ * Tracks the lifecycle of event processing from creation to completion.
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * import { EVENT_STATUS } from '@plyaz/types';
44
+ *
45
+ * const status = EVENT_STATUS.Processing; // 'processing'
46
+ *
47
+ * // Typical event lifecycle:
48
+ * // Pending -> Processing -> Completed
49
+ * // or
50
+ * // Pending -> Processing -> Failed -> Retrying -> Processing -> Completed
51
+ * ```
18
52
  */
19
53
  export declare const EVENT_STATUS: {
54
+ /** Event is pending and has not started processing. */
20
55
  readonly Pending: "pending";
56
+ /** Event is currently being processed. */
21
57
  readonly Processing: "processing";
58
+ /** Event has been completed successfully. */
22
59
  readonly Completed: "completed";
60
+ /** Event processing failed. */
23
61
  readonly Failed: "failed";
62
+ /** Event is being retried after a failure. */
24
63
  readonly Retrying: "retrying";
25
64
  };
@@ -1,6 +1,18 @@
1
1
  /**
2
2
  * User Payloads.
3
3
  */
4
+ /**
5
+ * Payload for user update events.
6
+ * Contains the unique identifier of the user that was updated.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * const payload: UserUpdatePayload = {
11
+ * uuid: '123e4567-e89b-12d3-a456-426614174000'
12
+ * };
13
+ * ```
14
+ */
4
15
  export interface UserUpdatePayload {
16
+ /** The unique identifier of the updated user */
5
17
  readonly uuid: string;
6
18
  }
@@ -41,6 +41,10 @@ export interface FeatureFlag<FeatureFlagKey extends string> {
41
41
  createdBy: string;
42
42
  /** Email or ID of the user who last updated this flag */
43
43
  updatedBy: string;
44
+ /** Additional metadata */
45
+ metadata?: Record<string, unknown>;
46
+ /** Tags for categorization */
47
+ tags?: string[];
44
48
  }
45
49
  /**
46
50
  * Feature flag rule for advanced targeting and conditional logic.
@@ -62,6 +66,8 @@ export interface FeatureFlagRule<FeatureFlagKey extends string> {
62
66
  priority: number;
63
67
  /** Whether this rule is currently active */
64
68
  isEnabled: boolean;
69
+ /** Rule metadata */
70
+ metadata?: Record<string, unknown>;
65
71
  }
66
72
  /**
67
73
  * Individual condition for feature flag rule evaluation.
@@ -110,7 +116,7 @@ export interface FeatureFlagEvaluation<FeatureFlagKey extends string> {
110
116
  /** Source of the evaluation result */
111
117
  source?: 'default' | 'override' | 'rule' | 'rollout';
112
118
  /** ID of the rule that matched (if reason is 'rule_match') */
113
- ruleId?: string;
119
+ matchedRuleId?: string;
114
120
  /** Timestamp when this evaluation occurred */
115
121
  evaluatedAt: Date;
116
122
  }
@@ -138,20 +144,25 @@ export interface FeatureFlagConfig<FeatureFlagKey extends string> {
138
144
  databaseConfig?: {
139
145
  connectionString: string;
140
146
  tableName: string;
147
+ options?: Record<string, unknown>;
141
148
  };
142
149
  /** Redis configuration (required if provider is 'redis') */
143
150
  redisConfig?: {
144
151
  url: string;
145
152
  keyPrefix: string;
153
+ options?: Record<string, unknown>;
146
154
  };
147
155
  /** File configuration (required if provider is 'file') */
148
156
  fileConfig?: {
149
157
  filePath: string;
150
158
  format: 'json' | 'yaml';
151
159
  shouldWatchForChanges: boolean;
160
+ fileCheckInterval?: number;
152
161
  };
153
162
  /** Memory provider rules (optional for memory provider) */
154
163
  memoryRules?: FeatureFlagRule<FeatureFlagKey>[];
164
+ /** Optional override values for testing */
165
+ overrides?: Record<FeatureFlagKey, FeatureFlagValue>;
155
166
  }
156
167
  /**
157
168
  * React Hook Options for Feature Flags
@@ -264,6 +275,29 @@ export interface FeatureFlagProvider<FeatureFlagKey extends string> {
264
275
  clearOverrides(): void;
265
276
  /** Disposes of the provider, cleaning up resources */
266
277
  dispose(): void;
278
+ /** Optional: Update a flag (not all providers support this) */
279
+ updateFlag?(flag: FeatureFlag<FeatureFlagKey>): Promise<void>;
280
+ /** Optional: Update a rule (not all providers support this) */
281
+ updateRule?(rule: FeatureFlagRule<FeatureFlagKey>): Promise<void>;
282
+ /** Optional: Sync features at runtime (for providers that support dynamic updates) */
283
+ syncFeatures?(newFeatures: Record<FeatureFlagKey, FeatureFlagValue>): Promise<void>;
284
+ }
285
+ /**
286
+ * Provider statistics
287
+ */
288
+ export interface ProviderStats {
289
+ /** Total number of evaluations */
290
+ evaluations: number;
291
+ /** Cache hits */
292
+ cacheHits: number;
293
+ /** Cache misses */
294
+ cacheMisses: number;
295
+ /** Average evaluation time in ms */
296
+ avgEvaluationTime: number;
297
+ /** Last refresh timestamp */
298
+ lastRefresh?: Date;
299
+ /** Provider uptime in ms */
300
+ uptime: number;
267
301
  }
268
302
  /**
269
303
  * Partial mapping for flag overrides.
package/dist/index.js CHANGED
@@ -2,73 +2,73 @@
2
2
 
3
3
  // src/auth/enums.ts
4
4
  var USER_ROLE = {
5
- // A user who is an athlete and participates in sports activities.
5
+ /** A user who is an athlete and participates in sports activities. */
6
6
  Athlete: "athlete",
7
- // A user who scouts and discovers talent.
7
+ /** A user who scouts and discovers talent. */
8
8
  Scout: "scout",
9
- // A user who acts as an agent representing athletes or clubs.
9
+ /** A user who acts as an agent representing athletes or clubs. */
10
10
  Agent: "agent",
11
- // A user representing a sports club or organization.
11
+ /** A user representing a sports club or organization. */
12
12
  Club: "club",
13
- // A fan or supporter of athletes or clubs.
13
+ /** A fan or supporter of athletes or clubs. */
14
14
  Fan: "fan",
15
- // A system administrator with access to management tools.
15
+ /** A system administrator with access to management tools. */
16
16
  Admin: "admin",
17
- // A super admin with the highest level of access and control.
17
+ /** A super admin with the highest level of access and control. */
18
18
  SuperAdmin: "super.admin"
19
19
  };
20
20
  var USER_STATUS = {
21
- // Active user with full access.
21
+ /** Active user with full access. */
22
22
  Active: "active",
23
- // Inactive user, typically not currently using the platform.
23
+ /** Inactive user, typically not currently using the platform. */
24
24
  Inactive: "inactive",
25
- // User account is awaiting approval or completion of setup.
25
+ /** User account is awaiting approval or completion of setup. */
26
26
  Pending: "pending",
27
- // User has been temporarily suspended due to policy violations or manual review.
27
+ /** User has been temporarily suspended due to policy violations or manual review. */
28
28
  Suspended: "suspended",
29
- // User has been permanently banned from the platform.
29
+ /** User has been permanently banned from the platform. */
30
30
  Banned: "banned"
31
31
  };
32
32
  var AUTH_PROVIDER = {
33
- // Authentication via email and password.
33
+ /** Authentication via email and password. */
34
34
  Email: "email",
35
- // Authentication via connected blockchain wallet.
35
+ /** Authentication via connected blockchain wallet. */
36
36
  Wallet: "wallet"
37
37
  };
38
38
 
39
39
  // src/errors/enums.ts
40
40
  var ERROR_TYPE = {
41
- // A general validation error (e.g., form or input errors).
41
+ /** A general validation error (e.g., form or input errors). */
42
42
  ValidationError: "validation.error",
43
- // Error related to schema validation, such as JSON schema or API payload checks.
43
+ /** Error related to schema validation, such as JSON schema or API payload checks. */
44
44
  SchemaValidationError: "validation.schema.error",
45
- // Unhandled or unexpected system error.
45
+ /** Unhandled or unexpected system error. */
46
46
  InternalError: "system.internal.error",
47
- // System dependency is currently unavailable (e.g., database or external API).
47
+ /** System dependency is currently unavailable (e.g., database or external API). */
48
48
  ServiceUnavailable: "system.service.unavailable",
49
- // The request took too long and timed out.
49
+ /** The request took too long and timed out. */
50
50
  TimeoutError: "system.timeout",
51
- // Too many requests made in a short period of time.
51
+ /** Too many requests made in a short period of time. */
52
52
  RateLimitExceeded: "system.rate.limit.exceeded"
53
53
  };
54
54
  var ERROR_SEVERITY = {
55
- // Low severity - does not impact functionality significantly.
55
+ /** Low severity - does not impact functionality significantly. */
56
56
  Low: "low",
57
- // Medium severity - minor disruption or warning.
57
+ /** Medium severity - minor disruption or warning. */
58
58
  Medium: "medium",
59
- // High severity - major issue requiring attention.
59
+ /** High severity - major issue requiring attention. */
60
60
  High: "high",
61
- // Critical severity - blocking or crashing issue.
61
+ /** Critical severity - blocking or crashing issue. */
62
62
  Critical: "critical"
63
63
  };
64
64
  var ERROR_CATEGORY = {
65
- // Client-side error (e.g., invalid request).
65
+ /** Client-side error (e.g., invalid request). */
66
66
  Client: "client",
67
- // Server-side error (e.g., logic failure or exception).
67
+ /** Server-side error (e.g., logic failure or exception). */
68
68
  Server: "server",
69
- // Network-related error (e.g., unreachable endpoint).
69
+ /** Network-related error (e.g., unreachable endpoint). */
70
70
  Network: "network",
71
- // Blockchain-related error (e.g., transaction failure, gas limit).
71
+ /** Blockchain-related error (e.g., transaction failure, gas limit). */
72
72
  Blockchain: "blockchain",
73
73
  // Validation-specific error (e.g., failed constraints or field errors).
74
74
  Validation: "validation"
@@ -76,53 +76,53 @@ var ERROR_CATEGORY = {
76
76
 
77
77
  // src/events/enums.ts
78
78
  var EVENT_TYPE = {
79
- // Application initialization event.
79
+ /** Application initialization event. */
80
80
  AppInit: "app.init"
81
81
  };
82
82
  var EVENT_PRIORITY = {
83
- // Low priority event.
83
+ /** Low priority event. */
84
84
  Low: "low",
85
- // Normal priority event.
85
+ /** Normal priority event. */
86
86
  Normal: "normal",
87
- // High priority event.
87
+ /** High priority event. */
88
88
  High: "high",
89
- // Critical priority event.
89
+ /** Critical priority event. */
90
90
  Critical: "critical"
91
91
  };
92
92
  var EVENT_STATUS = {
93
- // Event is pending and has not started processing.
93
+ /** Event is pending and has not started processing. */
94
94
  Pending: "pending",
95
- // Event is currently being processed.
95
+ /** Event is currently being processed. */
96
96
  Processing: "processing",
97
- // Event has been completed successfully.
97
+ /** Event has been completed successfully. */
98
98
  Completed: "completed",
99
- // Event processing failed.
99
+ /** Event processing failed. */
100
100
  Failed: "failed",
101
- // Event is being retried after a failure.
101
+ /** Event is being retried after a failure. */
102
102
  Retrying: "retrying"
103
103
  };
104
104
 
105
105
  // src/web3/enums.ts
106
106
  var CHAIN_ID = {
107
- // Ethereum Mainnet (Chain ID: 1).
107
+ /** Ethereum Mainnet (Chain ID: 1). */
108
108
  EthereumMainnet: 1,
109
- // Ethereum Sepolia Testnet (Chain ID: 11155111).
109
+ /** Ethereum Sepolia Testnet (Chain ID: 11155111). */
110
110
  EthereumSepolia: 11155111,
111
- // Optimism Mainnet (Chain ID: 10).
111
+ /** Optimism Mainnet (Chain ID: 10). */
112
112
  Optimism: 10,
113
- // Optimism Sepolia Testnet (Chain ID: 11155420).
113
+ /** Optimism Sepolia Testnet (Chain ID: 11155420). */
114
114
  OptimismSepolia: 11155420,
115
- // Arbitrum One Mainnet (Chain ID: 42161).
115
+ /** Arbitrum One Mainnet (Chain ID: 42161). */
116
116
  Arbitrum: 42161,
117
- // Arbitrum Sepolia Testnet (Chain ID: 421614).
117
+ /** Arbitrum Sepolia Testnet (Chain ID: 421614). */
118
118
  ArbitrumSepolia: 421614,
119
- // Polygon Mainnet (Chain ID: 137).
119
+ /** Polygon Mainnet (Chain ID: 137). */
120
120
  Polygon: 137,
121
- // Polygon Amoy Testnet (Chain ID: 80002).
121
+ /** Polygon Amoy Testnet (Chain ID: 80002). */
122
122
  PolygonAmoy: 80002,
123
- // Base Mainnet (Chain ID: 8453).
123
+ /** Base Mainnet (Chain ID: 8453). */
124
124
  Base: 8453,
125
- // Base Sepolia Testnet (Chain ID: 84532).
125
+ /** Base Sepolia Testnet (Chain ID: 84532). */
126
126
  BaseSepolia: 84532
127
127
  };
128
128
 
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":";;;AAIO,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;AAMO,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;AAMO,IAAM,aAAA,GAAgB;AAAA;AAAA,EAE3B,KAAA,EAAO,OAAA;AAAA;AAAA,EAGP,MAAA,EAAQ;AACV;;;ACtDO,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;AAMO,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;AAMO,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;;;AC1DO,IAAM,UAAA,GAAa;AAAA;AAAA,EAExB,OAAA,EAAS;AACX;AAKO,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;AAKO,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;;;AC/BO,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 */\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 */\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 */\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 */\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 */\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 */\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 */\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 */\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 */\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 */\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,135 +3,354 @@
3
3
  *
4
4
  * Type definitions for assertion utilities.
5
5
  */
6
+ /**
7
+ * Pattern for matching HTTP errors with status code and message.
8
+ * Used in testing to assert specific error responses.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const pattern: ErrorPattern = {
13
+ * status: 404,
14
+ * message: /resource not found/i
15
+ * };
16
+ * ```
17
+ */
6
18
  export interface ErrorPattern {
19
+ /** HTTP status code to match */
7
20
  status: number;
21
+ /** Regular expression to match against error message */
8
22
  message: RegExp;
9
23
  }
24
+ /**
25
+ * Pattern for matching validation errors with status and field errors.
26
+ * Used to assert specific validation failures in API responses.
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * const pattern: ValidationErrorPattern = {
31
+ * status: 400,
32
+ * validation: ['email', 'password']
33
+ * };
34
+ * ```
35
+ */
10
36
  export interface ValidationErrorPattern {
37
+ /** HTTP status code (typically 400 for validation errors) */
11
38
  status: number;
39
+ /** Array of field names that failed validation */
12
40
  validation: string[];
13
41
  }
42
+ /**
43
+ * Simple pattern for matching error messages.
44
+ * Used when only the message content needs to be validated.
45
+ */
14
46
  export interface ErrorMessagePattern {
47
+ /** Regular expression to match against error message */
15
48
  message: RegExp;
16
49
  }
50
+ /**
51
+ * Statistics tracking error occurrences.
52
+ * Useful for monitoring error rates in tests.
53
+ */
17
54
  export interface ErrorStats {
55
+ /** Total number of failed operations */
18
56
  failures: number;
57
+ /** Total number of successful operations */
19
58
  successes: number;
59
+ /** The most recent error that occurred */
20
60
  lastFailure?: Error;
21
61
  }
62
+ /**
63
+ * Entry in an error timeline tracking when errors occurred.
64
+ * Used for debugging error patterns over time.
65
+ */
22
66
  export interface ErrorTimelineEntry {
67
+ /** Unix timestamp when the error occurred */
23
68
  timestamp: number;
69
+ /** The error that occurred */
24
70
  error: Error;
71
+ /** Additional context data at the time of error */
25
72
  context?: Record<string, unknown>;
26
73
  }
74
+ /**
75
+ * Expected error pattern for validation.
76
+ * Used to define what errors should be thrown in test scenarios.
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * const expected: ExpectedError = {
81
+ * message: /unauthorized/i,
82
+ * type: UnauthorizedError
83
+ * };
84
+ * ```
85
+ */
27
86
  export interface ExpectedError {
87
+ /** Expected error message (string or pattern) */
28
88
  message?: string | RegExp;
89
+ /** Expected error constructor/type */
29
90
  type?: new (...args: unknown[]) => unknown;
30
91
  }
92
+ /**
93
+ * Validation response containing an array of error messages.
94
+ * Common pattern for form validation results.
95
+ */
31
96
  export interface ValidationResponse {
97
+ /** Array of validation error messages */
32
98
  message?: unknown[];
33
99
  }
100
+ /**
101
+ * Result type for hooks that return a value.
102
+ * Wraps the value in a current ref pattern.
103
+ *
104
+ * @template T - The type of the value
105
+ */
34
106
  export interface HookResultValue<T> {
107
+ /** Current ref containing the value */
35
108
  current: {
36
109
  value: T;
37
110
  };
38
111
  }
112
+ /**
113
+ * Result type for hooks that track loading state.
114
+ * Used to assert loading states in async operations.
115
+ */
39
116
  export interface HookResultLoading {
117
+ /** Current ref containing loading state */
40
118
  current: {
41
119
  isLoading: boolean;
42
120
  };
43
121
  }
122
+ /**
123
+ * Result type for hooks that track error state.
124
+ * Used to assert error handling in hooks.
125
+ */
44
126
  export interface HookResultError {
127
+ /** Current ref containing error state */
45
128
  current: {
46
129
  error: Error | null;
47
130
  };
48
131
  }
132
+ /**
133
+ * Result of an error recovery operation.
134
+ * Tracks both the original error and recovery outcome.
135
+ */
49
136
  export interface ErrorRecoveryResult {
137
+ /** The original error that triggered recovery */
50
138
  error: Error;
139
+ /** Result of the recovery attempt */
51
140
  recoveryResult: unknown;
52
141
  }
142
+ /**
143
+ * Entry for correlating errors with additional context.
144
+ * Used in error tracking and debugging systems.
145
+ */
53
146
  export interface ErrorCorrelationEntry {
147
+ /** The error being tracked */
54
148
  error: Error;
149
+ /** Additional metadata for correlation */
55
150
  metadata?: Record<string, unknown>;
56
151
  }
152
+ /**
153
+ * Definition of an error test scenario.
154
+ * Used to parameterize error testing across multiple cases.
155
+ */
57
156
  export interface ErrorTestScenario {
157
+ /** Descriptive name for the test scenario */
58
158
  name: string;
159
+ /** Function that should trigger the error */
59
160
  fn: () => unknown | Promise<unknown>;
161
+ /** Expected error or error pattern */
60
162
  expectedError: unknown;
163
+ /** Whether to skip this scenario */
61
164
  skip?: boolean;
62
165
  }
166
+ /**
167
+ * Configuration options for circuit breaker pattern.
168
+ * Used to prevent cascading failures in test scenarios.
169
+ *
170
+ * @example
171
+ * ```typescript
172
+ * const options: CircuitBreakerOptions = {
173
+ * failureThreshold: 5,
174
+ * resetTimeout: 30000,
175
+ * onOpen: () => console.log('Circuit opened'),
176
+ * onClose: () => console.log('Circuit closed')
177
+ * };
178
+ * ```
179
+ */
63
180
  export interface CircuitBreakerOptions {
181
+ /** Number of failures before opening circuit */
64
182
  failureThreshold: number;
183
+ /** Time in ms before attempting to close circuit */
65
184
  resetTimeout: number;
185
+ /** Callback when circuit opens */
66
186
  onOpen?: () => void;
187
+ /** Callback when circuit closes */
67
188
  onClose?: () => void;
189
+ /** Callback when circuit enters half-open state */
68
190
  onHalfOpen?: () => void;
69
191
  }
192
+ /**
193
+ * Result of testing error propagation through system.
194
+ * Tracks how errors flow through multiple layers.
195
+ *
196
+ * @template T - Type of intermediate results
197
+ */
70
198
  export interface ErrorPropagationTestResult<T> {
199
+ /** Number of layers the error propagated through */
71
200
  propagatedTo: number;
201
+ /** The final error after all transformations */
72
202
  finalError: Error;
203
+ /** Results from each layer (success or error) */
73
204
  intermediateResults: Array<T | Error>;
74
205
  }
206
+ /**
207
+ * Circuit breaker implementation for error handling.
208
+ * Prevents repeated failures by temporarily blocking operations.
209
+ *
210
+ * @template T - Return type of protected operations
211
+ */
75
212
  export interface ErrorCircuitBreaker<T> {
213
+ /** Execute function with circuit breaker protection */
76
214
  execute: (fn: () => T | Promise<T>) => Promise<T>;
215
+ /** Get current circuit state */
77
216
  getState: () => 'closed' | 'open' | 'half-open';
217
+ /** Get error statistics */
78
218
  getStats: () => ErrorStats;
219
+ /** Reset circuit to closed state */
79
220
  reset: () => void;
80
221
  }
222
+ /**
223
+ * Interface for correlating related errors.
224
+ * Helps track error chains and related failures.
225
+ */
81
226
  export interface ErrorCorrelator {
227
+ /** Create correlation ID for an error */
82
228
  correlate: (error: Error, metadata?: Record<string, unknown>) => string;
229
+ /** Get all errors with same correlation ID */
83
230
  getRelated: (correlationId: string) => Array<ErrorCorrelationEntry>;
231
+ /** Get chain of errors leading to this one */
84
232
  getChain: (error: Error) => Array<ErrorCorrelationEntry>;
85
233
  }
234
+ /**
235
+ * Interface for collecting error metrics.
236
+ * Provides insights into error patterns and rates.
237
+ */
86
238
  export interface ErrorMetrics {
239
+ /** Record an error occurrence */
87
240
  record: (error: Error, context?: Record<string, unknown>) => void;
241
+ /** Get aggregated error metrics */
88
242
  getMetrics: () => {
243
+ /** Total error count */
89
244
  total: number;
245
+ /** Errors grouped by type/constructor */
90
246
  byType: Record<string, number>;
247
+ /** Errors grouped by message */
91
248
  byMessage: Record<string, number>;
249
+ /** Chronological error timeline */
92
250
  timeline: Array<ErrorTimelineEntry>;
251
+ /** Calculate error rate for time window */
93
252
  errorRate: (windowMs: number) => number;
94
253
  };
254
+ /** Reset all metrics */
95
255
  reset: () => void;
96
256
  }
257
+ /**
258
+ * Interface for deduplicating similar errors.
259
+ * Prevents noise from repeated identical errors.
260
+ */
97
261
  export interface ErrorDeduplicator {
262
+ /** Check if error is duplicate of previously seen */
98
263
  isDuplicate: (error: Error) => boolean;
264
+ /** Record error for deduplication tracking */
99
265
  record: (error: Error) => void;
266
+ /** Get list of unique errors seen */
100
267
  getUniqueErrors: () => Error[];
268
+ /** Reset deduplication tracking */
101
269
  reset: () => void;
102
270
  }
271
+ /**
272
+ * Simple error interface with message property.
273
+ * Used for type guards and error handling.
274
+ */
103
275
  export interface ErrorWithMessage {
276
+ /** Error message */
104
277
  message: string;
105
278
  }
279
+ /**
280
+ * Error interface that includes HTTP response data.
281
+ * Common in API error handling scenarios.
282
+ */
106
283
  export interface ErrorWithResponse {
284
+ /** Method to retrieve response data */
107
285
  getResponse?: () => unknown;
286
+ /** Direct response data property */
108
287
  response?: unknown;
109
288
  }
289
+ /**
290
+ * Validation message structure for field-level errors.
291
+ * Commonly used in form validation responses.
292
+ */
110
293
  export interface ValidationMessage {
294
+ /** Property/field that failed validation */
111
295
  property?: string;
296
+ /** Map of constraint names to error messages */
112
297
  constraints?: Record<string, string>;
113
298
  }
299
+ /**
300
+ * Expected HTTP exception pattern for testing.
301
+ * Used to assert specific HTTP error responses.
302
+ */
114
303
  export interface ExpectedHttpException {
304
+ /** Expected HTTP status code */
115
305
  status?: number;
306
+ /** Expected error message or pattern */
116
307
  message?: string | RegExp;
308
+ /** Expected response body */
117
309
  response?: unknown;
118
310
  }
311
+ /**
312
+ * Expected service-level error pattern.
313
+ * Used for testing business logic errors.
314
+ */
119
315
  export interface ExpectedServiceError {
316
+ /** Expected error message or pattern */
120
317
  message?: string | RegExp;
318
+ /** Expected error constructor/type */
121
319
  type?: new (...args: unknown[]) => unknown;
122
320
  }
321
+ /**
322
+ * Configuration for injecting errors during propagation tests.
323
+ * Allows testing error handling at specific points.
324
+ */
123
325
  export interface ErrorPropagationInjection {
326
+ /** Step number where error should be injected */
124
327
  atStep: number;
328
+ /** Error to inject at specified step */
125
329
  error: Error;
126
330
  }
331
+ /**
332
+ * Context data for enriching errors with additional information.
333
+ * Helps with debugging and error tracking.
334
+ */
127
335
  export interface ErrorEnrichmentContext {
336
+ /** Operation being performed when error occurred */
128
337
  operation?: string;
338
+ /** User identifier associated with error */
129
339
  user?: string;
340
+ /** Timestamp of error occurrence */
130
341
  timestamp?: number;
342
+ /** Request ID for tracing */
131
343
  requestId?: string;
344
+ /** Additional metadata */
132
345
  metadata?: Record<string, unknown>;
133
346
  }
347
+ /**
348
+ * Configuration options for error deduplication.
349
+ * Controls how errors are identified as duplicates.
350
+ */
134
351
  export interface ErrorDeduplicatorOptions {
352
+ /** Function to generate deduplication key from error */
135
353
  keyFn?: (error: Error) => string;
354
+ /** Time window in ms for considering errors as duplicates */
136
355
  windowMs?: number;
137
356
  }
@@ -1033,101 +1033,247 @@ export interface FeatureFlagPerformanceMetrics {
1033
1033
  /** Total operations measured */
1034
1034
  total: number;
1035
1035
  }
1036
+ /**
1037
+ * Result of feature flag load testing.
1038
+ * Contains performance metrics and any errors encountered.
1039
+ */
1036
1040
  export interface FeatureFlagLoadTestResult {
1041
+ /** Total test duration in milliseconds */
1037
1042
  duration: number;
1043
+ /** Array of errors encountered during load test */
1038
1044
  errors: Error[];
1039
1045
  }
1046
+ /**
1047
+ * Controllable feature flag provider for testing.
1048
+ * Allows manual control over provider method resolution.
1049
+ *
1050
+ * @template FeatureFlagKey - Type of feature flag keys
1051
+ */
1040
1052
  export interface ControllableProvider<FeatureFlagKey extends string> {
1053
+ /** The wrapped provider instance */
1041
1054
  provider: IFeatureFlagProvider<FeatureFlagKey>;
1055
+ /** Control methods for test manipulation */
1042
1056
  control: {
1057
+ /** Resolve a specific method call */
1043
1058
  resolveMethod: (method: string) => void;
1059
+ /** Reject a specific method call with error */
1044
1060
  rejectMethod: (method: string, error: Error) => void;
1061
+ /** Resolve all pending method calls */
1045
1062
  resolveAll: () => void;
1063
+ /** Reject all pending method calls */
1046
1064
  rejectAll: (error: Error) => void;
1065
+ /** Reset control state */
1047
1066
  reset: () => void;
1048
1067
  };
1049
1068
  }
1069
+ /**
1070
+ * Tracker for feature flag subscription testing.
1071
+ * Monitors subscription lifecycle and callback invocations.
1072
+ *
1073
+ * @template FeatureFlagKey - Type of feature flag keys
1074
+ */
1050
1075
  export interface SubscriptionFeatureFlagTracker<FeatureFlagKey extends string> {
1076
+ /** Track a new subscription */
1051
1077
  track: (provider: IFeatureFlagProvider<FeatureFlagKey>, id?: string) => {
1052
1078
  id: string;
1053
1079
  callback: Vitest.Mock;
1054
1080
  unsubscribe: () => void;
1055
1081
  };
1082
+ /** Unsubscribe by ID */
1056
1083
  unsubscribe: (id: string) => void;
1084
+ /** Unsubscribe all tracked subscriptions */
1057
1085
  unsubscribeAll: () => void;
1086
+ /** Get call count for subscription */
1058
1087
  getCallCount: (id: string) => number;
1088
+ /** Get last call arguments for subscription */
1059
1089
  getLastCall: (id: string) => unknown;
1090
+ /** Reset all tracking data */
1060
1091
  reset: () => void;
1061
1092
  }
1093
+ /**
1094
+ * Assertions for feature flag evaluation results.
1095
+ * Provides chainable assertions for testing evaluations.
1096
+ */
1062
1097
  export interface EvaluationAssertions {
1098
+ /** Assert evaluation has expected value */
1063
1099
  hasValue: (expected: unknown) => void;
1100
+ /** Assert evaluation has expected reason */
1064
1101
  hasReason: (expected: string) => void;
1102
+ /** Assert evaluation has expected source */
1065
1103
  hasSource: (expected: string) => void;
1104
+ /** Assert evaluation has expected rule ID */
1066
1105
  hasRuleId: (expected: string) => void;
1106
+ /** Assert evaluation occurred within time window */
1067
1107
  wasEvaluatedRecently: (maxAgeMs?: number) => void;
1068
1108
  }
1109
+ /**
1110
+ * Props for test feature flag provider component.
1111
+ * Configures provider behavior for testing scenarios.
1112
+ *
1113
+ * @template FeatureFlagKey - Type of feature flag keys
1114
+ */
1069
1115
  export interface TestFeatureFlagProviderProps<FeatureFlagKey extends string> {
1116
+ /** Feature flag provider instance */
1070
1117
  provider: IFeatureFlagProvider<FeatureFlagKey>;
1118
+ /** Child components to render */
1071
1119
  children: React.ReactNode;
1120
+ /** Optional custom context */
1072
1121
  context?: React.Context<FeatureFlagContextValue<FeatureFlagKey> | null>;
1073
1122
  }
1123
+ /**
1124
+ * Options for creating a test feature flag provider.
1125
+ * Allows customization of provider setup for tests.
1126
+ *
1127
+ * @template FeatureFlagKey - Type of feature flag keys
1128
+ */
1074
1129
  export interface CreateProviderForTestOptions<FeatureFlagKey extends string> {
1130
+ /** Existing provider to use */
1075
1131
  provider?: IFeatureFlagProvider<FeatureFlagKey>;
1132
+ /** Configuration overrides */
1076
1133
  config?: Partial<FeatureFlagConfig<FeatureFlagKey>>;
1134
+ /** Flag values by string key */
1077
1135
  flags?: Record<string, FeatureFlagValue>;
1136
+ /** Flag values by typed key */
1078
1137
  features?: Record<FeatureFlagKey, FeatureFlagValue>;
1138
+ /** Custom provider class constructor */
1079
1139
  ProviderClass?: new (config: FeatureFlagConfig<FeatureFlagKey>, features: Record<FeatureFlagKey, FeatureFlagValue>) => IFeatureFlagProvider<FeatureFlagKey>;
1080
1140
  }
1141
+ /**
1142
+ * Options for setting up feature flag testing environment.
1143
+ * Configures test suite with feature flag capabilities.
1144
+ *
1145
+ * @template FeatureFlagKey - Type of feature flag keys
1146
+ */
1081
1147
  export interface SetupFeatureFlagTestOptions<FeatureFlagKey extends string> {
1148
+ /** Provider instance to use */
1082
1149
  provider?: IFeatureFlagProvider<FeatureFlagKey>;
1150
+ /** Configuration overrides */
1083
1151
  config?: Partial<FeatureFlagConfig<FeatureFlagKey>>;
1152
+ /** Flag values by string key */
1084
1153
  flags?: Record<string, FeatureFlagValue>;
1154
+ /** Setup before each test */
1085
1155
  setupBeforeEach?: boolean;
1156
+ /** Auto-initialize provider */
1086
1157
  autoInit: boolean;
1158
+ /** Custom React context */
1087
1159
  context?: React.Context<FeatureFlagContextValue<FeatureFlagKey> | null>;
1160
+ /** Custom provider class */
1088
1161
  ProviderClass?: new (config: FeatureFlagConfig<FeatureFlagKey>, features: Record<FeatureFlagKey, FeatureFlagValue>) => IFeatureFlagProvider<FeatureFlagKey>;
1162
+ /** Flag values by typed key */
1089
1163
  features?: Record<FeatureFlagKey, FeatureFlagValue>;
1090
1164
  }
1165
+ /**
1166
+ * Scenario for testing percentage-based rollouts.
1167
+ * Validates rollout distribution across users.
1168
+ *
1169
+ * @template FeatureFlagKey - Type of feature flag keys
1170
+ */
1091
1171
  export interface PercentageRolloutScenario<FeatureFlagKey extends string> {
1172
+ /** Rollout rule configuration */
1092
1173
  rule: FeatureFlagRule<FeatureFlagKey>;
1174
+ /** Test user IDs */
1093
1175
  users: string[];
1176
+ /** Expected number of enabled users */
1094
1177
  expectedEnabled: number;
1178
+ /** Evaluate if user should be enabled */
1095
1179
  evaluate: (userId: string) => boolean;
1096
1180
  }
1181
+ /**
1182
+ * Scenario for testing time-based feature rollouts.
1183
+ * Validates feature activation based on time windows.
1184
+ *
1185
+ * @template FeatureFlagKey - Type of feature flag keys
1186
+ */
1097
1187
  export interface TimeBasedRolloutScenario<FeatureFlagKey extends string> {
1188
+ /** Time-based rule configuration */
1098
1189
  rule: FeatureFlagRule<FeatureFlagKey>;
1190
+ /** Check if feature is active at given time */
1099
1191
  isActive: (date?: Date) => boolean;
1100
1192
  }
1193
+ /**
1194
+ * Scenario for testing user-targeted features.
1195
+ * Validates feature targeting specific users.
1196
+ *
1197
+ * @template FeatureFlagKey - Type of feature flag keys
1198
+ */
1101
1199
  export interface TargetedUsersScenario<FeatureFlagKey extends string> {
1200
+ /** Targeting rule configuration */
1102
1201
  rule: FeatureFlagRule<FeatureFlagKey>;
1202
+ /** Check if user is targeted */
1103
1203
  isTargeted: (userId: string) => boolean;
1104
1204
  }
1205
+ /**
1206
+ * Scenario for testing A/B test configurations.
1207
+ * Validates variant distribution and assignment.
1208
+ *
1209
+ * @template FeatureFlagKey - Type of feature flag keys
1210
+ */
1105
1211
  export interface ABTestScenario<FeatureFlagKey extends string> {
1212
+ /** A/B test rules */
1106
1213
  rules: FeatureFlagRule<FeatureFlagKey>[];
1214
+ /** Available variants */
1107
1215
  variants: Record<string, FeatureFlagValue>;
1216
+ /** Expected distribution percentages */
1108
1217
  distribution: Record<string, number>;
1218
+ /** Assign variant to user */
1109
1219
  assignVariant: (userId: string) => string;
1110
1220
  }
1221
+ /**
1222
+ * Scenario for testing complex rule combinations.
1223
+ * Validates feature behavior with multiple rules.
1224
+ *
1225
+ * @template FeatureFlagKey - Type of feature flag keys
1226
+ */
1111
1227
  export interface ComplexRulesScenario<FeatureFlagKey extends string> {
1228
+ /** Complex rule set */
1112
1229
  rules: FeatureFlagRule<FeatureFlagKey>[];
1230
+ /** Evaluate rules with context */
1113
1231
  evaluate: (context: FeatureFlagContext) => FeatureFlagEvaluation<FeatureFlagKey>;
1114
1232
  }
1233
+ /**
1234
+ * Mock provider with exposed internal state.
1235
+ * Allows direct state manipulation in tests.
1236
+ *
1237
+ * @template FeatureFlagKey - Type of feature flag keys
1238
+ */
1115
1239
  export interface MockFeatureFlagProviderWithState<FeatureFlagKey extends string> extends IFeatureFlagProvider<FeatureFlagKey> {
1240
+ /** Exposed mock state for testing */
1116
1241
  _mockState: {
1242
+ /** Flag definitions */
1117
1243
  flags: Map<FeatureFlagKey, FeatureFlag<FeatureFlagKey>>;
1244
+ /** Value overrides */
1118
1245
  overrides: Map<FeatureFlagKey, FeatureFlagValue>;
1246
+ /** Active subscribers */
1119
1247
  subscribers: Set<(flags: FeatureFlag<FeatureFlagKey>[]) => void>;
1120
1248
  };
1121
1249
  }
1250
+ /**
1251
+ * Test-specific feature flag context value.
1252
+ * Enhanced context for testing scenarios.
1253
+ *
1254
+ * @template FeatureFlagKey - Type of feature flag keys
1255
+ */
1122
1256
  export interface TestFeatureFlagContextValue<FeatureFlagKey extends string> {
1257
+ /** Provider instance */
1123
1258
  provider: IFeatureFlagProvider<FeatureFlagKey>;
1259
+ /** Initialization status */
1124
1260
  isInitialized: boolean;
1261
+ /** Loading state */
1125
1262
  isLoading: boolean;
1263
+ /** Current error if any */
1126
1264
  error: Error | null;
1265
+ /** Last update timestamp */
1127
1266
  lastUpdated: Date;
1267
+ /** Force refresh flags */
1128
1268
  refresh: () => Promise<void>;
1129
1269
  }
1270
+ /**
1271
+ * Options for waiting for flag value changes.
1272
+ * Used in async flag testing scenarios.
1273
+ */
1130
1274
  export interface WaitForFlagValueOptions {
1275
+ /** Evaluation context */
1131
1276
  context?: FeatureFlagContext;
1277
+ /** Maximum wait time in ms */
1132
1278
  timeout?: number;
1133
1279
  }
@@ -2,16 +2,34 @@
2
2
  * Enum representing supported EVM-compatible blockchain networks by their numeric chain IDs.
3
3
  * @description These IDs are used to identify the specific network when interacting with wallets or smart contracts.
4
4
  * @see https://chainlist.org for reference chain IDs
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import { CHAIN_ID } from '@plyaz/types';
9
+ *
10
+ * const chainId = CHAIN_ID.EthereumMainnet; // 1
11
+ * const isTestnet = chainId === CHAIN_ID.EthereumSepolia || chainId === CHAIN_ID.PolygonAmoy;
12
+ * ```
5
13
  */
6
14
  export declare const CHAIN_ID: {
15
+ /** Ethereum Mainnet (Chain ID: 1). */
7
16
  readonly EthereumMainnet: 1;
17
+ /** Ethereum Sepolia Testnet (Chain ID: 11155111). */
8
18
  readonly EthereumSepolia: 11155111;
19
+ /** Optimism Mainnet (Chain ID: 10). */
9
20
  readonly Optimism: 10;
21
+ /** Optimism Sepolia Testnet (Chain ID: 11155420). */
10
22
  readonly OptimismSepolia: 11155420;
23
+ /** Arbitrum One Mainnet (Chain ID: 42161). */
11
24
  readonly Arbitrum: 42161;
25
+ /** Arbitrum Sepolia Testnet (Chain ID: 421614). */
12
26
  readonly ArbitrumSepolia: 421614;
27
+ /** Polygon Mainnet (Chain ID: 137). */
13
28
  readonly Polygon: 137;
29
+ /** Polygon Amoy Testnet (Chain ID: 80002). */
14
30
  readonly PolygonAmoy: 80002;
31
+ /** Base Mainnet (Chain ID: 8453). */
15
32
  readonly Base: 8453;
33
+ /** Base Sepolia Testnet (Chain ID: 84532). */
16
34
  readonly BaseSepolia: 84532;
17
35
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plyaz/types",
3
- "version": "1.3.5",
3
+ "version": "1.3.6",
4
4
  "author": "Redeemer Pace",
5
5
  "license": "ISC",
6
6
  "description": "Provides shared TypeScript types and schema utilities for validation and parsing in the @playz ecosystem.",