@plyaz/types 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Feature Flags Domain Types
|
|
3
3
|
*
|
|
4
4
|
* Core type definitions for the feature flags domain.
|
|
5
|
-
* These types will be moved to @plyaz/types when the package structure is finalized.
|
|
6
5
|
*
|
|
7
6
|
* @fileoverview Feature flags domain type definitions
|
|
8
7
|
* @version 1.0.0
|
|
@@ -17,7 +16,7 @@ export type FeatureFlagValue = boolean | string | number | Record<string, unknow
|
|
|
17
16
|
* Core feature flag definition interface.
|
|
18
17
|
* Represents a complete feature flag with all its metadata and configuration.
|
|
19
18
|
*/
|
|
20
|
-
export interface FeatureFlag<FeatureFlagKey> {
|
|
19
|
+
export interface FeatureFlag<FeatureFlagKey extends string> {
|
|
21
20
|
/** The unique identifier for this flag */
|
|
22
21
|
key: FeatureFlagKey;
|
|
23
22
|
/** Human-readable name for the flag */
|
|
@@ -46,7 +45,7 @@ export interface FeatureFlag<FeatureFlagKey> {
|
|
|
46
45
|
/**
|
|
47
46
|
* Feature flag rule for advanced targeting and conditional logic.
|
|
48
47
|
*/
|
|
49
|
-
export interface FeatureFlagRule<FeatureFlagKey> {
|
|
48
|
+
export interface FeatureFlagRule<FeatureFlagKey extends string> {
|
|
50
49
|
/** Unique identifier for this rule */
|
|
51
50
|
id: string;
|
|
52
51
|
/** The feature flag this rule applies to */
|
|
@@ -99,7 +98,7 @@ export interface FeatureFlagContext {
|
|
|
99
98
|
/**
|
|
100
99
|
* Result of a feature flag evaluation.
|
|
101
100
|
*/
|
|
102
|
-
export interface FeatureFlagEvaluation<FeatureFlagKey> {
|
|
101
|
+
export interface FeatureFlagEvaluation<FeatureFlagKey extends string> {
|
|
103
102
|
/** The feature flag key that was evaluated */
|
|
104
103
|
flagKey: FeatureFlagKey;
|
|
105
104
|
/** The resolved value for this flag */
|
|
@@ -118,7 +117,7 @@ export interface FeatureFlagEvaluation<FeatureFlagKey> {
|
|
|
118
117
|
/**
|
|
119
118
|
* Configuration options for the feature flag system.
|
|
120
119
|
*/
|
|
121
|
-
export interface FeatureFlagConfig<FeatureFlagKey> {
|
|
120
|
+
export interface FeatureFlagConfig<FeatureFlagKey extends string> {
|
|
122
121
|
/** The storage provider to use for flag data */
|
|
123
122
|
provider: 'database' | 'redis' | 'memory' | 'api' | 'file';
|
|
124
123
|
/** Whether to enable caching of flag evaluations */
|
|
@@ -170,7 +169,7 @@ export interface UseFeatureFlagOptions {
|
|
|
170
169
|
/**
|
|
171
170
|
* Internal state for feature flag evaluation in React hooks.
|
|
172
171
|
*/
|
|
173
|
-
export interface FeatureFlagState<FeatureFlagKey, T extends FeatureFlagValue = FeatureFlagValue> {
|
|
172
|
+
export interface FeatureFlagState<FeatureFlagKey extends string, T extends FeatureFlagValue = FeatureFlagValue> {
|
|
174
173
|
value: T;
|
|
175
174
|
isLoading: boolean;
|
|
176
175
|
error: Error | null;
|
|
@@ -179,7 +178,7 @@ export interface FeatureFlagState<FeatureFlagKey, T extends FeatureFlagValue = F
|
|
|
179
178
|
/**
|
|
180
179
|
* Context value interface for React feature flag provider.
|
|
181
180
|
*/
|
|
182
|
-
export interface FeatureFlagContextValue<FeatureFlagKey> {
|
|
181
|
+
export interface FeatureFlagContextValue<FeatureFlagKey extends string> {
|
|
183
182
|
/** The feature flag provider instance */
|
|
184
183
|
provider: FeatureFlagProvider<FeatureFlagKey>;
|
|
185
184
|
/** Whether the provider is initialized */
|
|
@@ -196,13 +195,15 @@ export interface FeatureFlagContextValue<FeatureFlagKey> {
|
|
|
196
195
|
/**
|
|
197
196
|
* Props for the React FeatureFlagProvider component.
|
|
198
197
|
*/
|
|
199
|
-
export interface FeatureFlagProviderProps<FeatureFlagKey
|
|
198
|
+
export interface FeatureFlagProviderProps<FeatureFlagKey extends string, FeatureFlags extends Record<FeatureFlagKey, FeatureFlagValue>> {
|
|
200
199
|
/** Provider configuration */
|
|
201
200
|
config: FeatureFlagConfig<FeatureFlagKey>;
|
|
202
201
|
/** Default context for flag evaluation */
|
|
203
202
|
defaultContext?: FeatureFlagContext;
|
|
204
203
|
/** Children components */
|
|
205
204
|
children: React.ReactNode;
|
|
205
|
+
/** Predefined feature flags and their values */
|
|
206
|
+
features: FeatureFlags;
|
|
206
207
|
/** Callback when provider is ready */
|
|
207
208
|
onReady?: (provider: FeatureFlagProvider<FeatureFlagKey>) => void;
|
|
208
209
|
/** Callback when an error occurs */
|
|
@@ -220,7 +221,7 @@ export interface FeatureFlagProviderProps<FeatureFlagKey> {
|
|
|
220
221
|
/**
|
|
221
222
|
* Backend Request DTO for flag creation.
|
|
222
223
|
*/
|
|
223
|
-
export interface CreateFlagRequest<FeatureFlagKey> {
|
|
224
|
+
export interface CreateFlagRequest<FeatureFlagKey extends string> {
|
|
224
225
|
key: FeatureFlagKey;
|
|
225
226
|
name: string;
|
|
226
227
|
description?: string;
|
|
@@ -240,7 +241,7 @@ export interface ProviderHealthStatus {
|
|
|
240
241
|
/**
|
|
241
242
|
* Main interface for feature flag providers.
|
|
242
243
|
*/
|
|
243
|
-
export interface FeatureFlagProvider<FeatureFlagKey> {
|
|
244
|
+
export interface FeatureFlagProvider<FeatureFlagKey extends string> {
|
|
244
245
|
/** Initializes the provider by loading initial data */
|
|
245
246
|
initialize(): Promise<void>;
|
|
246
247
|
/** Evaluates a feature flag and returns full evaluation details */
|
|
@@ -296,7 +297,7 @@ export interface FeatureFlagHelpers<FeatureFlagKey extends string = string> {
|
|
|
296
297
|
isAllEnabled: (keys: FeatureFlagKey[], context?: FeatureFlagContext) => Promise<boolean>;
|
|
297
298
|
whenEnabled: <T>(key: FeatureFlagKey, callback: () => T | Promise<T>, fallback?: () => T | Promise<T>, context?: FeatureFlagContext) => Promise<T | undefined>;
|
|
298
299
|
}
|
|
299
|
-
export interface FetchFeatureFlagDataResponse<FeatureFlagKey> {
|
|
300
|
+
export interface FetchFeatureFlagDataResponse<FeatureFlagKey extends string> {
|
|
300
301
|
flags: FeatureFlag<FeatureFlagKey>[];
|
|
301
302
|
rules: FeatureFlagRule<FeatureFlagKey>[];
|
|
302
303
|
}
|
|
@@ -314,7 +315,7 @@ export interface ErrorHandlingTestInput {
|
|
|
314
315
|
/**
|
|
315
316
|
* Input for flag evaluation test cases
|
|
316
317
|
*/
|
|
317
|
-
export interface FlagEvaluationTestInput<FeatureFlagKey> {
|
|
318
|
+
export interface FlagEvaluationTestInput<FeatureFlagKey extends string> {
|
|
318
319
|
/** The flag key to evaluate */
|
|
319
320
|
flagKey: FeatureFlagKey;
|
|
320
321
|
/** Optional evaluation context */
|
|
@@ -327,7 +328,7 @@ export interface FlagEvaluationTestInput<FeatureFlagKey> {
|
|
|
327
328
|
/**
|
|
328
329
|
* Input for flag creation test cases
|
|
329
330
|
*/
|
|
330
|
-
export interface FlagCreationTestInput<FeatureFlagKey> {
|
|
331
|
+
export interface FlagCreationTestInput<FeatureFlagKey extends string> {
|
|
331
332
|
/** Unique key for the flag */
|
|
332
333
|
key: FeatureFlagKey;
|
|
333
334
|
/** Human-readable name */
|
|
@@ -346,7 +347,7 @@ export interface FlagCreationTestInput<FeatureFlagKey> {
|
|
|
346
347
|
/**
|
|
347
348
|
* Input for flag update test cases
|
|
348
349
|
*/
|
|
349
|
-
export interface FlagUpdateTestInput<FeatureFlagKey> {
|
|
350
|
+
export interface FlagUpdateTestInput<FeatureFlagKey extends string> {
|
|
350
351
|
/** Key of the flag to update */
|
|
351
352
|
flagKey: FeatureFlagKey;
|
|
352
353
|
/** Update data object */
|
|
@@ -355,7 +356,7 @@ export interface FlagUpdateTestInput<FeatureFlagKey> {
|
|
|
355
356
|
/**
|
|
356
357
|
* Input for override test cases
|
|
357
358
|
*/
|
|
358
|
-
export interface OverrideTestInput<FeatureFlagKey> {
|
|
359
|
+
export interface OverrideTestInput<FeatureFlagKey extends string> {
|
|
359
360
|
/** Flag key to override */
|
|
360
361
|
flagKey: FeatureFlagKey;
|
|
361
362
|
/** Override value */
|
|
@@ -386,7 +387,7 @@ export interface ServiceInitializationTestInput {
|
|
|
386
387
|
/**
|
|
387
388
|
* Input for flag operation error test cases
|
|
388
389
|
*/
|
|
389
|
-
export interface FlagOperationErrorTestInput<FeatureFlagKey> {
|
|
390
|
+
export interface FlagOperationErrorTestInput<FeatureFlagKey extends string> {
|
|
390
391
|
/** Flag key involved in the operation */
|
|
391
392
|
flagKey: FeatureFlagKey;
|
|
392
393
|
/** Error that occurred */
|
|
@@ -428,7 +429,7 @@ export interface ModuleConfigurationTestInput {
|
|
|
428
429
|
export interface ProviderTypeTestInput {
|
|
429
430
|
provider: string;
|
|
430
431
|
}
|
|
431
|
-
export interface FlagOperationTestInput<FeatureFlagKey> {
|
|
432
|
+
export interface FlagOperationTestInput<FeatureFlagKey extends string> {
|
|
432
433
|
operation: 'create' | 'update' | 'delete' | 'evaluate';
|
|
433
434
|
flagKey: FeatureFlagKey;
|
|
434
435
|
data?: unknown;
|
|
@@ -441,12 +442,12 @@ export interface PermissionTestInput {
|
|
|
441
442
|
resource: string;
|
|
442
443
|
expected: boolean;
|
|
443
444
|
}
|
|
444
|
-
export interface CacheOperationTestInput<FeatureFlagKey> {
|
|
445
|
+
export interface CacheOperationTestInput<FeatureFlagKey extends string> {
|
|
445
446
|
operation: 'set' | 'get' | 'refresh' | 'clear';
|
|
446
447
|
flagKey?: FeatureFlagKey;
|
|
447
448
|
expectedBehavior: string;
|
|
448
449
|
}
|
|
449
|
-
export interface RuleEvaluationTestInput<FeatureFlagKey> {
|
|
450
|
+
export interface RuleEvaluationTestInput<FeatureFlagKey extends string> {
|
|
450
451
|
flagKey: FeatureFlagKey;
|
|
451
452
|
rules: Array<{
|
|
452
453
|
conditions: Record<string, unknown>;
|
|
@@ -455,7 +456,7 @@ export interface RuleEvaluationTestInput<FeatureFlagKey> {
|
|
|
455
456
|
context: FeatureFlagContext;
|
|
456
457
|
expectedValue: FeatureFlagValue;
|
|
457
458
|
}
|
|
458
|
-
export interface BatchOperationTestInput<FeatureFlagKey> {
|
|
459
|
+
export interface BatchOperationTestInput<FeatureFlagKey extends string> {
|
|
459
460
|
operations: Array<{
|
|
460
461
|
type: 'create' | 'update' | 'delete';
|
|
461
462
|
flagKey: FeatureFlagKey;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plyaz/types",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
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.",
|
|
@@ -43,6 +43,8 @@
|
|
|
43
43
|
"@types/react-dom": "^19.1.6",
|
|
44
44
|
"@typescript-eslint/eslint-plugin": "^8.15.0",
|
|
45
45
|
"@typescript-eslint/parser": "^8.15.0",
|
|
46
|
+
"@testing-library/react": "^16.3.0",
|
|
47
|
+
"@testing-library/user-event": "^14.6.1",
|
|
46
48
|
"@vitest/coverage-v8": "^3.1.3",
|
|
47
49
|
"eslint": "^9.29.0",
|
|
48
50
|
"eslint-config-next": "^15.3.3",
|