@plyaz/types 1.1.4 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,7 +17,7 @@ export type FeatureFlagValue = boolean | string | number | Record<string, unknow
17
17
  * Core feature flag definition interface.
18
18
  * Represents a complete feature flag with all its metadata and configuration.
19
19
  */
20
- export interface FeatureFlag<FeatureFlagKey> {
20
+ export interface FeatureFlag<FeatureFlagKey extends string> {
21
21
  /** The unique identifier for this flag */
22
22
  key: FeatureFlagKey;
23
23
  /** Human-readable name for the flag */
@@ -46,7 +46,7 @@ export interface FeatureFlag<FeatureFlagKey> {
46
46
  /**
47
47
  * Feature flag rule for advanced targeting and conditional logic.
48
48
  */
49
- export interface FeatureFlagRule<FeatureFlagKey> {
49
+ export interface FeatureFlagRule<FeatureFlagKey extends string> {
50
50
  /** Unique identifier for this rule */
51
51
  id: string;
52
52
  /** The feature flag this rule applies to */
@@ -99,7 +99,7 @@ export interface FeatureFlagContext {
99
99
  /**
100
100
  * Result of a feature flag evaluation.
101
101
  */
102
- export interface FeatureFlagEvaluation<FeatureFlagKey> {
102
+ export interface FeatureFlagEvaluation<FeatureFlagKey extends string> {
103
103
  /** The feature flag key that was evaluated */
104
104
  flagKey: FeatureFlagKey;
105
105
  /** The resolved value for this flag */
@@ -118,7 +118,7 @@ export interface FeatureFlagEvaluation<FeatureFlagKey> {
118
118
  /**
119
119
  * Configuration options for the feature flag system.
120
120
  */
121
- export interface FeatureFlagConfig<FeatureFlagKey> {
121
+ export interface FeatureFlagConfig<FeatureFlagKey extends string> {
122
122
  /** The storage provider to use for flag data */
123
123
  provider: 'database' | 'redis' | 'memory' | 'api' | 'file';
124
124
  /** Whether to enable caching of flag evaluations */
@@ -170,7 +170,7 @@ export interface UseFeatureFlagOptions {
170
170
  /**
171
171
  * Internal state for feature flag evaluation in React hooks.
172
172
  */
173
- export interface FeatureFlagState<FeatureFlagKey, T extends FeatureFlagValue = FeatureFlagValue> {
173
+ export interface FeatureFlagState<FeatureFlagKey extends string, T extends FeatureFlagValue = FeatureFlagValue> {
174
174
  value: T;
175
175
  isLoading: boolean;
176
176
  error: Error | null;
@@ -179,7 +179,7 @@ export interface FeatureFlagState<FeatureFlagKey, T extends FeatureFlagValue = F
179
179
  /**
180
180
  * Context value interface for React feature flag provider.
181
181
  */
182
- export interface FeatureFlagContextValue<FeatureFlagKey> {
182
+ export interface FeatureFlagContextValue<FeatureFlagKey extends string> {
183
183
  /** The feature flag provider instance */
184
184
  provider: FeatureFlagProvider<FeatureFlagKey>;
185
185
  /** Whether the provider is initialized */
@@ -196,7 +196,7 @@ export interface FeatureFlagContextValue<FeatureFlagKey> {
196
196
  /**
197
197
  * Props for the React FeatureFlagProvider component.
198
198
  */
199
- export interface FeatureFlagProviderProps<FeatureFlagKey> {
199
+ export interface FeatureFlagProviderProps<FeatureFlagKey extends string> {
200
200
  /** Provider configuration */
201
201
  config: FeatureFlagConfig<FeatureFlagKey>;
202
202
  /** Default context for flag evaluation */
@@ -220,7 +220,7 @@ export interface FeatureFlagProviderProps<FeatureFlagKey> {
220
220
  /**
221
221
  * Backend Request DTO for flag creation.
222
222
  */
223
- export interface CreateFlagRequest<FeatureFlagKey> {
223
+ export interface CreateFlagRequest<FeatureFlagKey extends string> {
224
224
  key: FeatureFlagKey;
225
225
  name: string;
226
226
  description?: string;
@@ -240,7 +240,7 @@ export interface ProviderHealthStatus {
240
240
  /**
241
241
  * Main interface for feature flag providers.
242
242
  */
243
- export interface FeatureFlagProvider<FeatureFlagKey> {
243
+ export interface FeatureFlagProvider<FeatureFlagKey extends string> {
244
244
  /** Initializes the provider by loading initial data */
245
245
  initialize(): Promise<void>;
246
246
  /** Evaluates a feature flag and returns full evaluation details */
@@ -296,7 +296,195 @@ export interface FeatureFlagHelpers<FeatureFlagKey extends string = string> {
296
296
  isAllEnabled: (keys: FeatureFlagKey[], context?: FeatureFlagContext) => Promise<boolean>;
297
297
  whenEnabled: <T>(key: FeatureFlagKey, callback: () => T | Promise<T>, fallback?: () => T | Promise<T>, context?: FeatureFlagContext) => Promise<T | undefined>;
298
298
  }
299
- export interface FetchFeatureFlagDataResponse<FeatureFlagKey> {
299
+ export interface FetchFeatureFlagDataResponse<FeatureFlagKey extends string> {
300
300
  flags: FeatureFlag<FeatureFlagKey>[];
301
301
  rules: FeatureFlagRule<FeatureFlagKey>[];
302
302
  }
303
+ /**
304
+ * Input for error handling test cases
305
+ */
306
+ export interface ErrorHandlingTestInput {
307
+ /** The error to test */
308
+ error: unknown;
309
+ /** Expected error message */
310
+ expectedMessage: string;
311
+ /** Expected HTTP status code */
312
+ expectedStatus: number;
313
+ }
314
+ /**
315
+ * Input for flag evaluation test cases
316
+ */
317
+ export interface FlagEvaluationTestInput<FeatureFlagKey extends string> {
318
+ /** The flag key to evaluate */
319
+ flagKey: FeatureFlagKey;
320
+ /** Optional evaluation context */
321
+ context?: FeatureFlagContext;
322
+ /** Mock value to return */
323
+ mockValue: boolean;
324
+ /** Whether the flag is enabled */
325
+ isEnabled: boolean;
326
+ }
327
+ /**
328
+ * Input for flag creation test cases
329
+ */
330
+ export interface FlagCreationTestInput<FeatureFlagKey extends string> {
331
+ /** Unique key for the flag */
332
+ key: FeatureFlagKey;
333
+ /** Human-readable name */
334
+ name: string;
335
+ /** Optional description */
336
+ description?: string;
337
+ /** Flag value */
338
+ value: FeatureFlagValue;
339
+ /** Whether the flag is enabled */
340
+ isEnabled?: boolean;
341
+ /** Target environment */
342
+ environment?: 'all' | 'development' | 'production' | 'staging';
343
+ /** Rollout percentage (0-100) */
344
+ rolloutPercentage?: number;
345
+ }
346
+ /**
347
+ * Input for flag update test cases
348
+ */
349
+ export interface FlagUpdateTestInput<FeatureFlagKey extends string> {
350
+ /** Key of the flag to update */
351
+ flagKey: FeatureFlagKey;
352
+ /** Update data object */
353
+ updateData: Record<string, unknown>;
354
+ }
355
+ /**
356
+ * Input for override test cases
357
+ */
358
+ export interface OverrideTestInput<FeatureFlagKey extends string> {
359
+ /** Flag key to override */
360
+ flagKey: FeatureFlagKey;
361
+ /** Override value */
362
+ value: FeatureFlagValue;
363
+ }
364
+ /**
365
+ * Input for service initialization test cases
366
+ */
367
+ export interface ServiceInitializationTestInput {
368
+ /** Environment variables to set */
369
+ envVars: Record<string, string>;
370
+ /** Expected configuration after initialization */
371
+ expectedConfig: {
372
+ /** Provider type */
373
+ provider: string;
374
+ /** Whether caching is enabled */
375
+ isCacheEnabled: boolean;
376
+ /** Cache TTL in seconds */
377
+ cacheTtl: number;
378
+ /** Refresh interval in seconds */
379
+ refreshInterval: number;
380
+ /** Whether to fallback to defaults on error */
381
+ shouldFallbackToDefaults: boolean;
382
+ /** Whether logging is enabled */
383
+ isLoggingEnabled: boolean;
384
+ };
385
+ }
386
+ /**
387
+ * Input for flag operation error test cases
388
+ */
389
+ export interface FlagOperationErrorTestInput<FeatureFlagKey extends string> {
390
+ /** Flag key involved in the operation */
391
+ flagKey: FeatureFlagKey;
392
+ /** Error that occurred */
393
+ error: Error;
394
+ /** Expected log message */
395
+ expectedLogMessage: string;
396
+ }
397
+ /**
398
+ * Input for type inference test cases
399
+ */
400
+ export interface TypeInferenceTestInput {
401
+ /** Value to infer type from */
402
+ value: unknown;
403
+ /** Expected type string */
404
+ expectedType: string;
405
+ }
406
+ /**
407
+ * Input for environment filter test cases
408
+ */
409
+ export interface EnvironmentFilterTestInput {
410
+ /** Environment to filter by */
411
+ environment: string;
412
+ /** List of allowed environments */
413
+ allowedEnvironments: string[];
414
+ }
415
+ /**
416
+ * Input for timestamp behavior test cases
417
+ */
418
+ export interface TimestampTestInput {
419
+ /** Operation type */
420
+ operation: 'create' | 'update';
421
+ /** Description of expected timestamp behavior */
422
+ expectedTimestampBehavior: string;
423
+ }
424
+ export interface ModuleConfigurationTestInput {
425
+ config: Record<string, unknown>;
426
+ expectedConfig: Record<string, unknown>;
427
+ }
428
+ export interface ProviderTypeTestInput {
429
+ provider: string;
430
+ }
431
+ export interface FlagOperationTestInput<FeatureFlagKey extends string> {
432
+ operation: 'create' | 'update' | 'delete' | 'evaluate';
433
+ flagKey: FeatureFlagKey;
434
+ data?: unknown;
435
+ context?: FeatureFlagContext;
436
+ expectedResult?: unknown;
437
+ }
438
+ export interface PermissionTestInput {
439
+ role: string;
440
+ operation: string;
441
+ resource: string;
442
+ expected: boolean;
443
+ }
444
+ export interface CacheOperationTestInput<FeatureFlagKey extends string> {
445
+ operation: 'set' | 'get' | 'refresh' | 'clear';
446
+ flagKey?: FeatureFlagKey;
447
+ expectedBehavior: string;
448
+ }
449
+ export interface RuleEvaluationTestInput<FeatureFlagKey extends string> {
450
+ flagKey: FeatureFlagKey;
451
+ rules: Array<{
452
+ conditions: Record<string, unknown>;
453
+ value: FeatureFlagValue;
454
+ }>;
455
+ context: FeatureFlagContext;
456
+ expectedValue: FeatureFlagValue;
457
+ }
458
+ export interface BatchOperationTestInput<FeatureFlagKey extends string> {
459
+ operations: Array<{
460
+ type: 'create' | 'update' | 'delete';
461
+ flagKey: FeatureFlagKey;
462
+ data?: unknown;
463
+ }>;
464
+ expectedResults: unknown[];
465
+ }
466
+ export interface ValidationTestInput {
467
+ input: unknown;
468
+ field: string;
469
+ expectedError?: string;
470
+ isValid: boolean;
471
+ }
472
+ export interface DynamicModuleTestInput {
473
+ config: Record<string, unknown>;
474
+ expectedProviders?: string[];
475
+ expectedImports?: string[];
476
+ expectedExports?: string[];
477
+ }
478
+ export interface AsyncModuleConfigTestInput {
479
+ imports?: string[];
480
+ inject?: string[];
481
+ useFactory?: (...args: unknown[]) => Record<string, unknown>;
482
+ expectedImports?: string[];
483
+ expectedProviders?: string[];
484
+ }
485
+ export interface RepositoryOperationTestInput {
486
+ operation: 'create' | 'update' | 'delete' | 'find';
487
+ data?: unknown;
488
+ expectedResult?: unknown;
489
+ shouldThrow?: boolean;
490
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plyaz/types",
3
- "version": "1.1.4",
3
+ "version": "1.2.1",
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.",
@@ -37,9 +37,10 @@
37
37
  "@eslint/markdown": "^6.5.0",
38
38
  "@nestjs/common": "^11.1.3",
39
39
  "@next/eslint-plugin-next": "^15.0.3",
40
- "@plyaz/devtools": "^1.4.2",
41
- "@types/node": "^20.0.0",
40
+ "@plyaz/devtools": "^1.6.11",
41
+ "@types/node": "^22.14.0",
42
42
  "@types/react": "^19.1.8",
43
+ "@types/react-dom": "^19.1.6",
43
44
  "@typescript-eslint/eslint-plugin": "^8.15.0",
44
45
  "@typescript-eslint/parser": "^8.15.0",
45
46
  "@vitest/coverage-v8": "^3.1.3",