@plyaz/types 1.3.2 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/index.d.ts +1 -0
- package/dist/api/types.d.ts +84 -0
- package/dist/auth/enums.d.ts +32 -0
- package/dist/auth/index.d.ts +3 -0
- package/dist/auth/schemas.d.ts +27 -0
- package/dist/auth/types.d.ts +34 -0
- package/dist/common/index.d.ts +2 -0
- package/dist/common/types.d.ts +22 -0
- package/dist/entities/index.d.ts +1 -0
- package/dist/errors/enums.d.ts +33 -0
- package/dist/errors/index.d.ts +2 -0
- package/dist/errors/types.d.ts +79 -0
- package/dist/events/enums.d.ts +25 -0
- package/dist/events/index.d.ts +3 -0
- package/dist/events/payload.d.ts +6 -0
- package/dist/events/types.d.ts +136 -0
- package/dist/features/cache/index.d.ts +1 -0
- package/dist/features/cache/types.d.ts +142 -0
- package/dist/features/feature-flag/index.d.ts +1 -0
- package/dist/features/feature-flag/types.d.ts +491 -0
- package/dist/features/index.d.ts +2 -0
- package/dist/index.d.ts +12 -0
- package/dist/store/index.d.ts +1 -0
- package/dist/testing/common/assertions/index.d.ts +1 -0
- package/dist/testing/common/assertions/types.d.ts +137 -0
- package/dist/testing/common/factories/index.d.ts +1 -0
- package/dist/testing/common/factories/types.d.ts +701 -0
- package/dist/testing/common/index.d.ts +6 -0
- package/dist/testing/common/mocks/index.d.ts +1 -0
- package/dist/testing/common/mocks/types.d.ts +1662 -0
- package/dist/testing/common/patterns/index.d.ts +1 -0
- package/dist/testing/common/patterns/types.d.ts +397 -0
- package/dist/testing/common/utils/index.d.ts +1 -0
- package/dist/testing/common/utils/types.d.ts +1970 -0
- package/dist/testing/common/wrappers/index.d.ts +1 -0
- package/dist/testing/common/wrappers/types.d.ts +373 -0
- package/dist/testing/features/cache/index.d.ts +1 -0
- package/dist/testing/features/cache/types.d.ts +43 -0
- package/dist/testing/features/feature-flags/index.d.ts +1 -0
- package/dist/testing/features/feature-flags/types.d.ts +1133 -0
- package/dist/testing/features/index.d.ts +2 -0
- package/dist/testing/index.d.ts +2 -0
- package/dist/translations/index.d.ts +1 -0
- package/dist/translations/types.d.ts +390 -0
- package/dist/ui/index.d.ts +1 -0
- package/dist/web3/enums.d.ts +17 -0
- package/dist/web3/index.d.ts +2 -0
- package/dist/web3/types.d.ts +63 -0
- package/package.json +2 -2
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Feature Flags Domain Types
|
|
3
|
+
*
|
|
4
|
+
* Core type definitions for the feature flags domain.
|
|
5
|
+
*
|
|
6
|
+
* @fileoverview Feature flags domain type definitions
|
|
7
|
+
* @version 1.0.0
|
|
8
|
+
*/
|
|
9
|
+
import type * as React from 'react';
|
|
10
|
+
/**
|
|
11
|
+
* Possible values that a feature flag can hold.
|
|
12
|
+
* Supports primitive types and JSON objects for complex configurations.
|
|
13
|
+
*/
|
|
14
|
+
export type FeatureFlagValue = boolean | string | number | Record<string, unknown>;
|
|
15
|
+
/**
|
|
16
|
+
* Core feature flag definition interface.
|
|
17
|
+
* Represents a complete feature flag with all its metadata and configuration.
|
|
18
|
+
*/
|
|
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;
|
|
30
|
+
/** 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';
|
|
34
|
+
/** Percentage of users who should receive this flag (0-100) */
|
|
35
|
+
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
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Feature flag rule for advanced targeting and conditional logic.
|
|
47
|
+
*/
|
|
48
|
+
export interface FeatureFlagRule<FeatureFlagKey extends string> {
|
|
49
|
+
/** Unique identifier for this rule */
|
|
50
|
+
id: string;
|
|
51
|
+
/** The feature flag this rule applies to */
|
|
52
|
+
flagKey: FeatureFlagKey;
|
|
53
|
+
/** Human-readable name for this rule */
|
|
54
|
+
name: string;
|
|
55
|
+
/** Array of conditions that must all be met for this rule to apply */
|
|
56
|
+
conditions: FeatureFlagCondition[];
|
|
57
|
+
/** The value to return if this rule matches */
|
|
58
|
+
value: FeatureFlagValue;
|
|
59
|
+
/** Percentage of matching users who should receive this value (0-100) */
|
|
60
|
+
rolloutPercentage?: number;
|
|
61
|
+
/** Priority for rule evaluation (higher numbers = higher priority) */
|
|
62
|
+
priority: number;
|
|
63
|
+
/** Whether this rule is currently active */
|
|
64
|
+
isEnabled: boolean;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Individual condition for feature flag rule evaluation.
|
|
68
|
+
*/
|
|
69
|
+
export interface FeatureFlagCondition {
|
|
70
|
+
/** The context field to evaluate */
|
|
71
|
+
field: 'userId' | 'userEmail' | 'userRole' | 'country' | 'platform' | 'version' | 'environment' | 'custom';
|
|
72
|
+
/** The comparison operator to use */
|
|
73
|
+
operator: 'equals' | 'not_equals' | 'contains' | 'not_contains' | 'in' | 'not_in' | 'greater_than' | 'less_than';
|
|
74
|
+
/** The value(s) to compare against */
|
|
75
|
+
value: string | number | string[] | number[];
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Context information used for feature flag evaluation.
|
|
79
|
+
*/
|
|
80
|
+
export interface FeatureFlagContext {
|
|
81
|
+
/** Unique identifier for the user */
|
|
82
|
+
userId?: string;
|
|
83
|
+
/** User's email address */
|
|
84
|
+
userEmail?: string;
|
|
85
|
+
/** User's role or permission level */
|
|
86
|
+
userRole?: string;
|
|
87
|
+
/** User's country code (ISO 3166-1 alpha-2) */
|
|
88
|
+
country?: string;
|
|
89
|
+
/** Platform the user is accessing from */
|
|
90
|
+
platform?: 'web' | 'mobile' | 'desktop';
|
|
91
|
+
/** Application version */
|
|
92
|
+
version?: string;
|
|
93
|
+
/** Custom context data for advanced targeting */
|
|
94
|
+
custom?: Record<string, unknown>;
|
|
95
|
+
/** Current environment */
|
|
96
|
+
environment: 'development' | 'staging' | 'production';
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Result of a feature flag evaluation.
|
|
100
|
+
*/
|
|
101
|
+
export interface FeatureFlagEvaluation<FeatureFlagKey extends string> {
|
|
102
|
+
/** The feature flag key that was evaluated */
|
|
103
|
+
flagKey: FeatureFlagKey;
|
|
104
|
+
/** The resolved value for this flag */
|
|
105
|
+
value: FeatureFlagValue;
|
|
106
|
+
/** Whether the flag is considered enabled (truthy value) */
|
|
107
|
+
isEnabled: boolean;
|
|
108
|
+
/** Explanation of how this value was determined */
|
|
109
|
+
reason: 'default' | 'rule_match' | 'rollout' | 'override' | 'disabled';
|
|
110
|
+
/** Source of the evaluation result */
|
|
111
|
+
source?: 'default' | 'override' | 'rule' | 'rollout';
|
|
112
|
+
/** ID of the rule that matched (if reason is 'rule_match') */
|
|
113
|
+
ruleId?: string;
|
|
114
|
+
/** Timestamp when this evaluation occurred */
|
|
115
|
+
evaluatedAt: Date;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Configuration options for the feature flag system.
|
|
119
|
+
*/
|
|
120
|
+
export interface FeatureFlagConfig<FeatureFlagKey extends string> {
|
|
121
|
+
/** The storage provider to use for flag data */
|
|
122
|
+
provider: 'database' | 'redis' | 'memory' | 'api' | 'file';
|
|
123
|
+
/** Whether to enable caching of flag evaluations */
|
|
124
|
+
isCacheEnabled: boolean;
|
|
125
|
+
/** Cache time-to-live in seconds */
|
|
126
|
+
cacheTtl: number;
|
|
127
|
+
/** How often to refresh flag data in seconds (0 = no auto-refresh) */
|
|
128
|
+
refreshInterval: number;
|
|
129
|
+
/** Whether to fall back to default values on errors */
|
|
130
|
+
shouldFallbackToDefaults: boolean;
|
|
131
|
+
/** Whether to enable debug logging */
|
|
132
|
+
isLoggingEnabled: boolean;
|
|
133
|
+
/** API endpoint URL (required if provider is 'api') */
|
|
134
|
+
apiEndpoint?: string;
|
|
135
|
+
/** API authentication key (required if provider is 'api') */
|
|
136
|
+
apiKey?: string;
|
|
137
|
+
/** Database configuration (required if provider is 'database') */
|
|
138
|
+
databaseConfig?: {
|
|
139
|
+
connectionString: string;
|
|
140
|
+
tableName: string;
|
|
141
|
+
};
|
|
142
|
+
/** Redis configuration (required if provider is 'redis') */
|
|
143
|
+
redisConfig?: {
|
|
144
|
+
url: string;
|
|
145
|
+
keyPrefix: string;
|
|
146
|
+
};
|
|
147
|
+
/** File configuration (required if provider is 'file') */
|
|
148
|
+
fileConfig?: {
|
|
149
|
+
filePath: string;
|
|
150
|
+
format: 'json' | 'yaml';
|
|
151
|
+
shouldWatchForChanges: boolean;
|
|
152
|
+
};
|
|
153
|
+
/** Memory provider rules (optional for memory provider) */
|
|
154
|
+
memoryRules?: FeatureFlagRule<FeatureFlagKey>[];
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* React Hook Options for Feature Flags
|
|
158
|
+
*/
|
|
159
|
+
export interface UseFeatureFlagOptions {
|
|
160
|
+
/** Evaluation context for targeting */
|
|
161
|
+
context?: FeatureFlagContext;
|
|
162
|
+
/** Whether to automatically refresh on provider updates */
|
|
163
|
+
isAutoRefresh?: boolean;
|
|
164
|
+
/** Default value to use while loading or on error */
|
|
165
|
+
defaultValue?: FeatureFlagValue;
|
|
166
|
+
/** Whether to suspend on initial load (for Suspense) */
|
|
167
|
+
isSuspense?: boolean;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Internal state for feature flag evaluation in React hooks.
|
|
171
|
+
*/
|
|
172
|
+
export interface FeatureFlagState<FeatureFlagKey extends string, T extends FeatureFlagValue = FeatureFlagValue> {
|
|
173
|
+
value: T;
|
|
174
|
+
isLoading: boolean;
|
|
175
|
+
error: Error | null;
|
|
176
|
+
evaluation: FeatureFlagEvaluation<FeatureFlagKey> | null;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Context value interface for React feature flag provider.
|
|
180
|
+
*/
|
|
181
|
+
export interface FeatureFlagContextValue<FeatureFlagKey extends string> {
|
|
182
|
+
/** The feature flag provider instance */
|
|
183
|
+
provider: FeatureFlagProvider<FeatureFlagKey>;
|
|
184
|
+
/** Whether the provider is initialized */
|
|
185
|
+
isInitialized: boolean;
|
|
186
|
+
/** Whether the provider is currently loading */
|
|
187
|
+
isLoading: boolean;
|
|
188
|
+
/** Any error that occurred during initialization */
|
|
189
|
+
error: Error | null;
|
|
190
|
+
/** When the provider was last updated */
|
|
191
|
+
lastUpdated: Date | null;
|
|
192
|
+
/** Manual refresh function */
|
|
193
|
+
refresh: () => Promise<void>;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Props for the React FeatureFlagProvider component.
|
|
197
|
+
*/
|
|
198
|
+
export interface FeatureFlagProviderProps<FeatureFlagKey extends string, FeatureFlags extends Record<FeatureFlagKey, FeatureFlagValue>> {
|
|
199
|
+
/** Provider configuration */
|
|
200
|
+
config: FeatureFlagConfig<FeatureFlagKey>;
|
|
201
|
+
/** Default context for flag evaluation */
|
|
202
|
+
defaultContext?: FeatureFlagContext;
|
|
203
|
+
/** Children components */
|
|
204
|
+
children: React.ReactNode;
|
|
205
|
+
/** Predefined feature flags and their values */
|
|
206
|
+
features: FeatureFlags;
|
|
207
|
+
/** Callback when provider is ready */
|
|
208
|
+
onReady?: (provider: FeatureFlagProvider<FeatureFlagKey>) => void;
|
|
209
|
+
/** Callback when an error occurs */
|
|
210
|
+
onError?: (error: Error) => void;
|
|
211
|
+
/** Whether to show loading state while initializing */
|
|
212
|
+
isShowLoading?: boolean;
|
|
213
|
+
/** Custom loading component */
|
|
214
|
+
loadingComponent?: React.ComponentType;
|
|
215
|
+
/** Custom error component */
|
|
216
|
+
errorComponent?: React.ComponentType<{
|
|
217
|
+
error: Error;
|
|
218
|
+
retry: () => void;
|
|
219
|
+
}>;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Backend Request DTO for flag creation.
|
|
223
|
+
*/
|
|
224
|
+
export interface CreateFlagRequest<FeatureFlagKey extends string> {
|
|
225
|
+
key: FeatureFlagKey;
|
|
226
|
+
name: string;
|
|
227
|
+
description?: string;
|
|
228
|
+
value: FeatureFlagValue;
|
|
229
|
+
isEnabled?: boolean;
|
|
230
|
+
environment?: 'all' | 'development' | 'staging' | 'production';
|
|
231
|
+
rolloutPercentage?: number;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Backend Provider health status information.
|
|
235
|
+
*/
|
|
236
|
+
export interface ProviderHealthStatus {
|
|
237
|
+
isInitialized: boolean;
|
|
238
|
+
provider: string;
|
|
239
|
+
isCacheEnabled: boolean;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Main interface for feature flag providers.
|
|
243
|
+
*/
|
|
244
|
+
export interface FeatureFlagProvider<FeatureFlagKey extends string> {
|
|
245
|
+
/** Initializes the provider by loading initial data */
|
|
246
|
+
initialize(): Promise<void>;
|
|
247
|
+
/** Evaluates a feature flag and returns full evaluation details */
|
|
248
|
+
getFlag(key: FeatureFlagKey, context?: FeatureFlagContext): Promise<FeatureFlagEvaluation<FeatureFlagKey>>;
|
|
249
|
+
/** Evaluates all feature flags for the given context */
|
|
250
|
+
getAllFlags(context?: FeatureFlagContext): Promise<Record<string, FeatureFlagEvaluation<FeatureFlagKey>>>;
|
|
251
|
+
/** Checks if a feature flag is enabled */
|
|
252
|
+
isEnabled(key: FeatureFlagKey, context?: FeatureFlagContext): Promise<boolean>;
|
|
253
|
+
/** Gets the value of a feature flag with optional type casting */
|
|
254
|
+
getValue<T = FeatureFlagValue>(key: FeatureFlagKey, context?: FeatureFlagContext): Promise<T>;
|
|
255
|
+
/** Refreshes the flag data from the underlying storage */
|
|
256
|
+
refresh(): Promise<void>;
|
|
257
|
+
/** Subscribes to flag changes and updates */
|
|
258
|
+
subscribe(callback: () => void): () => void;
|
|
259
|
+
/** Sets an override for a specific flag key */
|
|
260
|
+
setOverride(key: FeatureFlagKey, value: FeatureFlagValue): void;
|
|
261
|
+
/** Removes an override for a specific flag key */
|
|
262
|
+
removeOverride(key: FeatureFlagKey): void;
|
|
263
|
+
/** Clears all overrides */
|
|
264
|
+
clearOverrides(): void;
|
|
265
|
+
/** Disposes of the provider, cleaning up resources */
|
|
266
|
+
dispose(): void;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Partial mapping for flag overrides.
|
|
270
|
+
*/
|
|
271
|
+
export type FeatureFlagOverrides<FeatureFlagKey extends string = string> = Partial<{
|
|
272
|
+
[K in FeatureFlagKey]: FeatureFlagValue;
|
|
273
|
+
}>;
|
|
274
|
+
/**
|
|
275
|
+
* Hook-like interface for reactive feature flag usage.
|
|
276
|
+
*/
|
|
277
|
+
export type FeatureFlagHook<T = boolean> = {
|
|
278
|
+
/** The current value of the flag */
|
|
279
|
+
value: T;
|
|
280
|
+
/** Whether the flag is currently being loaded */
|
|
281
|
+
isLoading: boolean;
|
|
282
|
+
/** Any error that occurred during flag evaluation */
|
|
283
|
+
error: Error | null;
|
|
284
|
+
/** Function to manually refresh the flag value */
|
|
285
|
+
refresh: () => Promise<void>;
|
|
286
|
+
};
|
|
287
|
+
/**
|
|
288
|
+
* Helper functions for managing feature flags.
|
|
289
|
+
*/
|
|
290
|
+
export interface FeatureFlagHelpers<FeatureFlagKey extends string = string> {
|
|
291
|
+
setOverride: (key: FeatureFlagKey, value: FeatureFlagValue) => void;
|
|
292
|
+
removeOverride: (key: FeatureFlagKey) => void;
|
|
293
|
+
clearOverrides: () => void;
|
|
294
|
+
refresh: () => Promise<void>;
|
|
295
|
+
getMultipleFlags: (keys: FeatureFlagKey[], context?: FeatureFlagContext) => Promise<Record<FeatureFlagKey, FeatureFlagValue>>;
|
|
296
|
+
isAnyEnabled: (keys: FeatureFlagKey[], context?: FeatureFlagContext) => Promise<boolean>;
|
|
297
|
+
isAllEnabled: (keys: FeatureFlagKey[], context?: FeatureFlagContext) => Promise<boolean>;
|
|
298
|
+
whenEnabled: <T>(key: FeatureFlagKey, callback: () => T | Promise<T>, fallback?: () => T | Promise<T>, context?: FeatureFlagContext) => Promise<T | undefined>;
|
|
299
|
+
}
|
|
300
|
+
export interface FetchFeatureFlagDataResponse<FeatureFlagKey extends string> {
|
|
301
|
+
flags: FeatureFlag<FeatureFlagKey>[];
|
|
302
|
+
rules: FeatureFlagRule<FeatureFlagKey>[];
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Input for error handling test cases
|
|
306
|
+
*/
|
|
307
|
+
export interface ErrorHandlingTestInput {
|
|
308
|
+
/** The error to test */
|
|
309
|
+
error: unknown;
|
|
310
|
+
/** Expected error message */
|
|
311
|
+
expectedMessage: string;
|
|
312
|
+
/** Expected HTTP status code */
|
|
313
|
+
expectedStatus: number;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Input for flag evaluation test cases
|
|
317
|
+
*/
|
|
318
|
+
export interface FlagEvaluationTestInput<FeatureFlagKey extends string> {
|
|
319
|
+
/** The flag key to evaluate */
|
|
320
|
+
flagKey: FeatureFlagKey;
|
|
321
|
+
/** Optional evaluation context */
|
|
322
|
+
context?: FeatureFlagContext;
|
|
323
|
+
/** Mock value to return */
|
|
324
|
+
mockValue: boolean;
|
|
325
|
+
/** Whether the flag is enabled */
|
|
326
|
+
isEnabled: boolean;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Input for flag creation test cases
|
|
330
|
+
*/
|
|
331
|
+
export interface FlagCreationTestInput<FeatureFlagKey extends string> {
|
|
332
|
+
/** Unique key for the flag */
|
|
333
|
+
key: FeatureFlagKey;
|
|
334
|
+
/** Human-readable name */
|
|
335
|
+
name: string;
|
|
336
|
+
/** Optional description */
|
|
337
|
+
description?: string;
|
|
338
|
+
/** Flag value */
|
|
339
|
+
value: FeatureFlagValue;
|
|
340
|
+
/** Whether the flag is enabled */
|
|
341
|
+
isEnabled?: boolean;
|
|
342
|
+
/** Target environment */
|
|
343
|
+
environment?: 'all' | 'development' | 'production' | 'staging';
|
|
344
|
+
/** Rollout percentage (0-100) */
|
|
345
|
+
rolloutPercentage?: number;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Input for flag update test cases
|
|
349
|
+
*/
|
|
350
|
+
export interface FlagUpdateTestInput<FeatureFlagKey extends string> {
|
|
351
|
+
/** Key of the flag to update */
|
|
352
|
+
flagKey: FeatureFlagKey;
|
|
353
|
+
/** Update data object */
|
|
354
|
+
updateData: Record<string, unknown>;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Input for override test cases
|
|
358
|
+
*/
|
|
359
|
+
export interface OverrideTestInput<FeatureFlagKey extends string> {
|
|
360
|
+
/** Flag key to override */
|
|
361
|
+
flagKey: FeatureFlagKey;
|
|
362
|
+
/** Override value */
|
|
363
|
+
value: FeatureFlagValue;
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Input for service initialization test cases
|
|
367
|
+
*/
|
|
368
|
+
export interface ServiceInitializationTestInput {
|
|
369
|
+
/** Environment variables to set */
|
|
370
|
+
envVars: Record<string, string>;
|
|
371
|
+
/** Expected configuration after initialization */
|
|
372
|
+
expectedConfig: {
|
|
373
|
+
/** Provider type */
|
|
374
|
+
provider: string;
|
|
375
|
+
/** Whether caching is enabled */
|
|
376
|
+
isCacheEnabled: boolean;
|
|
377
|
+
/** Cache TTL in seconds */
|
|
378
|
+
cacheTtl: number;
|
|
379
|
+
/** Refresh interval in seconds */
|
|
380
|
+
refreshInterval: number;
|
|
381
|
+
/** Whether to fallback to defaults on error */
|
|
382
|
+
shouldFallbackToDefaults: boolean;
|
|
383
|
+
/** Whether logging is enabled */
|
|
384
|
+
isLoggingEnabled: boolean;
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Input for flag operation error test cases
|
|
389
|
+
*/
|
|
390
|
+
export interface FlagOperationErrorTestInput<FeatureFlagKey extends string> {
|
|
391
|
+
/** Flag key involved in the operation */
|
|
392
|
+
flagKey: FeatureFlagKey;
|
|
393
|
+
/** Error that occurred */
|
|
394
|
+
error: Error;
|
|
395
|
+
/** Expected log message */
|
|
396
|
+
expectedLogMessage: string;
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Input for type inference test cases
|
|
400
|
+
*/
|
|
401
|
+
export interface TypeInferenceTestInput {
|
|
402
|
+
/** Value to infer type from */
|
|
403
|
+
value: unknown;
|
|
404
|
+
/** Expected type string */
|
|
405
|
+
expectedType: string;
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Input for environment filter test cases
|
|
409
|
+
*/
|
|
410
|
+
export interface EnvironmentFilterTestInput {
|
|
411
|
+
/** Environment to filter by */
|
|
412
|
+
environment: string;
|
|
413
|
+
/** List of allowed environments */
|
|
414
|
+
allowedEnvironments: string[];
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Input for timestamp behavior test cases
|
|
418
|
+
*/
|
|
419
|
+
export interface TimestampTestInput {
|
|
420
|
+
/** Operation type */
|
|
421
|
+
operation: 'create' | 'update';
|
|
422
|
+
/** Description of expected timestamp behavior */
|
|
423
|
+
expectedTimestampBehavior: string;
|
|
424
|
+
}
|
|
425
|
+
export interface ModuleConfigurationTestInput {
|
|
426
|
+
config: Record<string, unknown>;
|
|
427
|
+
expectedConfig: Record<string, unknown>;
|
|
428
|
+
}
|
|
429
|
+
export interface ProviderTypeTestInput {
|
|
430
|
+
provider: string;
|
|
431
|
+
}
|
|
432
|
+
export interface FlagOperationTestInput<FeatureFlagKey extends string> {
|
|
433
|
+
operation: 'create' | 'update' | 'delete' | 'evaluate';
|
|
434
|
+
flagKey: FeatureFlagKey;
|
|
435
|
+
data?: unknown;
|
|
436
|
+
context?: FeatureFlagContext;
|
|
437
|
+
expectedResult?: unknown;
|
|
438
|
+
}
|
|
439
|
+
export interface PermissionTestInput {
|
|
440
|
+
role: string;
|
|
441
|
+
operation: string;
|
|
442
|
+
resource: string;
|
|
443
|
+
expected: boolean;
|
|
444
|
+
}
|
|
445
|
+
export interface CacheOperationTestInput<FeatureFlagKey extends string> {
|
|
446
|
+
operation: 'set' | 'get' | 'refresh' | 'clear';
|
|
447
|
+
flagKey?: FeatureFlagKey;
|
|
448
|
+
expectedBehavior: string;
|
|
449
|
+
}
|
|
450
|
+
export interface RuleEvaluationTestInput<FeatureFlagKey extends string> {
|
|
451
|
+
flagKey: FeatureFlagKey;
|
|
452
|
+
rules: Array<{
|
|
453
|
+
conditions: Record<string, unknown>;
|
|
454
|
+
value: FeatureFlagValue;
|
|
455
|
+
}>;
|
|
456
|
+
context: FeatureFlagContext;
|
|
457
|
+
expectedValue: FeatureFlagValue;
|
|
458
|
+
}
|
|
459
|
+
export interface BatchOperationTestInput<FeatureFlagKey extends string> {
|
|
460
|
+
operations: Array<{
|
|
461
|
+
type: 'create' | 'update' | 'delete';
|
|
462
|
+
flagKey: FeatureFlagKey;
|
|
463
|
+
data?: unknown;
|
|
464
|
+
}>;
|
|
465
|
+
expectedResults: unknown[];
|
|
466
|
+
}
|
|
467
|
+
export interface ValidationTestInput {
|
|
468
|
+
input: unknown;
|
|
469
|
+
field: string;
|
|
470
|
+
expectedError?: string;
|
|
471
|
+
isValid: boolean;
|
|
472
|
+
}
|
|
473
|
+
export interface DynamicModuleTestInput {
|
|
474
|
+
config: Record<string, unknown>;
|
|
475
|
+
expectedProviders?: string[];
|
|
476
|
+
expectedImports?: string[];
|
|
477
|
+
expectedExports?: string[];
|
|
478
|
+
}
|
|
479
|
+
export interface AsyncModuleConfigTestInput {
|
|
480
|
+
imports?: string[];
|
|
481
|
+
inject?: string[];
|
|
482
|
+
useFactory?: (...args: unknown[]) => Record<string, unknown>;
|
|
483
|
+
expectedImports?: string[];
|
|
484
|
+
expectedProviders?: string[];
|
|
485
|
+
}
|
|
486
|
+
export interface RepositoryOperationTestInput {
|
|
487
|
+
operation: 'create' | 'update' | 'delete' | 'find';
|
|
488
|
+
data?: unknown;
|
|
489
|
+
expectedResult?: unknown;
|
|
490
|
+
shouldThrow?: boolean;
|
|
491
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type * from './api';
|
|
2
|
+
export * from './auth';
|
|
3
|
+
export type * from './common';
|
|
4
|
+
export type * from './entities';
|
|
5
|
+
export * from './errors';
|
|
6
|
+
export * from './events';
|
|
7
|
+
export type * from './store';
|
|
8
|
+
export type * from './ui';
|
|
9
|
+
export * from './web3';
|
|
10
|
+
export type * from './translations';
|
|
11
|
+
export type * from './features';
|
|
12
|
+
export type * from './testing';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type * from './types';
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Assertion Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for assertion utilities.
|
|
5
|
+
*/
|
|
6
|
+
export interface ErrorPattern {
|
|
7
|
+
status: number;
|
|
8
|
+
message: RegExp;
|
|
9
|
+
}
|
|
10
|
+
export interface ValidationErrorPattern {
|
|
11
|
+
status: number;
|
|
12
|
+
validation: string[];
|
|
13
|
+
}
|
|
14
|
+
export interface ErrorMessagePattern {
|
|
15
|
+
message: RegExp;
|
|
16
|
+
}
|
|
17
|
+
export interface ErrorStats {
|
|
18
|
+
failures: number;
|
|
19
|
+
successes: number;
|
|
20
|
+
lastFailure?: Error;
|
|
21
|
+
}
|
|
22
|
+
export interface ErrorTimelineEntry {
|
|
23
|
+
timestamp: number;
|
|
24
|
+
error: Error;
|
|
25
|
+
context?: Record<string, unknown>;
|
|
26
|
+
}
|
|
27
|
+
export interface ExpectedError {
|
|
28
|
+
message?: string | RegExp;
|
|
29
|
+
type?: new (...args: unknown[]) => unknown;
|
|
30
|
+
}
|
|
31
|
+
export interface ValidationResponse {
|
|
32
|
+
message?: unknown[];
|
|
33
|
+
}
|
|
34
|
+
export interface HookResultValue<T> {
|
|
35
|
+
current: {
|
|
36
|
+
value: T;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export interface HookResultLoading {
|
|
40
|
+
current: {
|
|
41
|
+
isLoading: boolean;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export interface HookResultError {
|
|
45
|
+
current: {
|
|
46
|
+
error: Error | null;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export interface ErrorRecoveryResult {
|
|
50
|
+
error: Error;
|
|
51
|
+
recoveryResult: unknown;
|
|
52
|
+
}
|
|
53
|
+
export interface ErrorCorrelationEntry {
|
|
54
|
+
error: Error;
|
|
55
|
+
metadata?: Record<string, unknown>;
|
|
56
|
+
}
|
|
57
|
+
export interface ErrorTestScenario {
|
|
58
|
+
name: string;
|
|
59
|
+
fn: () => unknown | Promise<unknown>;
|
|
60
|
+
expectedError: unknown;
|
|
61
|
+
skip?: boolean;
|
|
62
|
+
}
|
|
63
|
+
export interface CircuitBreakerOptions {
|
|
64
|
+
failureThreshold: number;
|
|
65
|
+
resetTimeout: number;
|
|
66
|
+
onOpen?: () => void;
|
|
67
|
+
onClose?: () => void;
|
|
68
|
+
onHalfOpen?: () => void;
|
|
69
|
+
}
|
|
70
|
+
export interface ErrorPropagationTestResult<T> {
|
|
71
|
+
propagatedTo: number;
|
|
72
|
+
finalError: Error;
|
|
73
|
+
intermediateResults: Array<T | Error>;
|
|
74
|
+
}
|
|
75
|
+
export interface ErrorCircuitBreaker<T> {
|
|
76
|
+
execute: (fn: () => T | Promise<T>) => Promise<T>;
|
|
77
|
+
getState: () => 'closed' | 'open' | 'half-open';
|
|
78
|
+
getStats: () => ErrorStats;
|
|
79
|
+
reset: () => void;
|
|
80
|
+
}
|
|
81
|
+
export interface ErrorCorrelator {
|
|
82
|
+
correlate: (error: Error, metadata?: Record<string, unknown>) => string;
|
|
83
|
+
getRelated: (correlationId: string) => Array<ErrorCorrelationEntry>;
|
|
84
|
+
getChain: (error: Error) => Array<ErrorCorrelationEntry>;
|
|
85
|
+
}
|
|
86
|
+
export interface ErrorMetrics {
|
|
87
|
+
record: (error: Error, context?: Record<string, unknown>) => void;
|
|
88
|
+
getMetrics: () => {
|
|
89
|
+
total: number;
|
|
90
|
+
byType: Record<string, number>;
|
|
91
|
+
byMessage: Record<string, number>;
|
|
92
|
+
timeline: Array<ErrorTimelineEntry>;
|
|
93
|
+
errorRate: (windowMs: number) => number;
|
|
94
|
+
};
|
|
95
|
+
reset: () => void;
|
|
96
|
+
}
|
|
97
|
+
export interface ErrorDeduplicator {
|
|
98
|
+
isDuplicate: (error: Error) => boolean;
|
|
99
|
+
record: (error: Error) => void;
|
|
100
|
+
getUniqueErrors: () => Error[];
|
|
101
|
+
reset: () => void;
|
|
102
|
+
}
|
|
103
|
+
export interface ErrorWithMessage {
|
|
104
|
+
message: string;
|
|
105
|
+
}
|
|
106
|
+
export interface ErrorWithResponse {
|
|
107
|
+
getResponse?: () => unknown;
|
|
108
|
+
response?: unknown;
|
|
109
|
+
}
|
|
110
|
+
export interface ValidationMessage {
|
|
111
|
+
property?: string;
|
|
112
|
+
constraints?: Record<string, string>;
|
|
113
|
+
}
|
|
114
|
+
export interface ExpectedHttpException {
|
|
115
|
+
status?: number;
|
|
116
|
+
message?: string | RegExp;
|
|
117
|
+
response?: unknown;
|
|
118
|
+
}
|
|
119
|
+
export interface ExpectedServiceError {
|
|
120
|
+
message?: string | RegExp;
|
|
121
|
+
type?: new (...args: unknown[]) => unknown;
|
|
122
|
+
}
|
|
123
|
+
export interface ErrorPropagationInjection {
|
|
124
|
+
atStep: number;
|
|
125
|
+
error: Error;
|
|
126
|
+
}
|
|
127
|
+
export interface ErrorEnrichmentContext {
|
|
128
|
+
operation?: string;
|
|
129
|
+
user?: string;
|
|
130
|
+
timestamp?: number;
|
|
131
|
+
requestId?: string;
|
|
132
|
+
metadata?: Record<string, unknown>;
|
|
133
|
+
}
|
|
134
|
+
export interface ErrorDeduplicatorOptions {
|
|
135
|
+
keyFn?: (error: Error) => string;
|
|
136
|
+
windowMs?: number;
|
|
137
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type * from './types';
|