@plyaz/types 1.5.5 → 1.7.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.
@@ -48,8 +48,10 @@
48
48
  * @since 1.0.0
49
49
  */
50
50
  import type * as React from 'react';
51
+ import type { UnknownRecord } from 'type-fest';
51
52
  import type { RenderOptions, RenderHookOptions, MockNextRouter } from '..';
52
53
  import type * as TestingLibraryReact from '@testing-library/react';
54
+ import type { Named, Resettable, WithTimestamp } from '../../../common/types';
53
55
  /**
54
56
  * React wrapper component interface for test utilities
55
57
  *
@@ -122,7 +124,7 @@ export interface WrapperOptions {
122
124
  children: React.ReactNode;
123
125
  }>>;
124
126
  /** Props to pass to the providers */
125
- providerProps?: Record<string, unknown>;
127
+ providerProps?: UnknownRecord;
126
128
  }
127
129
  /**
128
130
  * Extended render options combining RTL options with wrapper configuration.
@@ -233,10 +235,9 @@ export interface ErrorBoundaryProps {
233
235
  * };
234
236
  * ```
235
237
  */
236
- export interface MockProviderContextValue<T> {
238
+ export interface MockProviderContextValue<T> extends Resettable {
237
239
  value: T;
238
240
  setValue: (value: T) => void;
239
- reset: () => void;
240
241
  }
241
242
  /**
242
243
  * Props for mock provider components.
@@ -328,15 +329,13 @@ export interface TrackedProviderProps<T> {
328
329
  * expect(history[0].value).toEqual(initialState);
329
330
  * ```
330
331
  */
331
- export interface TrackedProviderReturn<T> {
332
+ export interface TrackedProviderReturn<T> extends Resettable {
332
333
  /** Tracked provider component */
333
334
  Provider: React.FC<TrackedProviderProps<T>>;
334
335
  /** Get total render count */
335
336
  getRenderCount: () => number;
336
337
  /** Get history of value updates */
337
338
  getUpdateHistory: () => Array<UpdateHistoryEntry<T>>;
338
- /** Reset tracking data */
339
- reset: () => void;
340
339
  }
341
340
  /**
342
341
  * Context value for async data providers.
@@ -508,13 +507,11 @@ export interface ContextProvider<T = unknown> {
508
507
  * };
509
508
  * ```
510
509
  */
511
- export interface ProviderConfigOptions<T = unknown> {
510
+ export interface ProviderConfigOptions<T = unknown> extends Partial<Named> {
512
511
  /** The context provider to configure */
513
512
  provider: ContextProvider<T>;
514
513
  /** Value to provide through the context */
515
514
  value: T;
516
- /** Optional name for identification */
517
- name?: string;
518
515
  /** Names of providers this depends on */
519
516
  dependencies?: string[];
520
517
  }
@@ -607,9 +604,7 @@ export interface MockProviderOptions<T> {
607
604
  * };
608
605
  * ```
609
606
  */
610
- export interface TrackedProviderOptions {
611
- /** Name for identification in logs */
612
- name: string;
607
+ export interface TrackedProviderOptions extends Named {
613
608
  /** Whether to log renders to console */
614
609
  logRenders?: boolean;
615
610
  }
@@ -650,11 +645,9 @@ export interface AsyncProviderOptions<T> {
650
645
  * };
651
646
  * ```
652
647
  */
653
- export interface SubscribableProviderOptions<T> {
648
+ export interface SubscribableProviderOptions<T> extends Named {
654
649
  /** Initial value for subscribers */
655
650
  initialValue: T;
656
- /** Provider name for debugging */
657
- name: string;
658
651
  }
659
652
  /**
660
653
  * Options for time-travel providers.
@@ -671,13 +664,11 @@ export interface SubscribableProviderOptions<T> {
671
664
  * };
672
665
  * ```
673
666
  */
674
- export interface TimeTravelProviderOptions<T> {
667
+ export interface TimeTravelProviderOptions<T> extends Named {
675
668
  /** Initial state value */
676
669
  initialState: T;
677
670
  /** Maximum history entries to keep */
678
671
  maxHistory?: number;
679
- /** Provider name for debugging */
680
- name: string;
681
672
  }
682
673
  /**
683
674
  * Options for mock API providers.
@@ -697,13 +688,11 @@ export interface TimeTravelProviderOptions<T> {
697
688
  * };
698
689
  * ```
699
690
  */
700
- export interface MockApiProviderOptions {
691
+ export interface MockApiProviderOptions extends Named {
701
692
  /** Mock endpoint implementations */
702
693
  endpoints: Record<string, () => Promise<unknown> | unknown>;
703
694
  /** Artificial delay in ms */
704
695
  delay?: number;
705
- /** Provider name for debugging */
706
- name: string;
707
696
  }
708
697
  /**
709
698
  * Entry in the update history for tracked providers.
@@ -719,9 +708,7 @@ export interface MockApiProviderOptions {
719
708
  * };
720
709
  * ```
721
710
  */
722
- export interface UpdateHistoryEntry<T> {
723
- /** When the update occurred */
724
- timestamp: number;
711
+ export interface UpdateHistoryEntry<T> extends WithTimestamp<number> {
725
712
  /** Partial state updates applied */
726
713
  updates: Partial<T>;
727
714
  }
@@ -743,7 +730,7 @@ export interface ProviderChainItem {
743
730
  children: React.ReactNode;
744
731
  }>;
745
732
  /** Props to pass to provider */
746
- props?: Record<string, unknown>;
733
+ props?: UnknownRecord;
747
734
  }
748
735
  /**
749
736
  * Context value for subscribable providers.
@@ -857,7 +844,7 @@ export type Subscriber<T> = (value: T) => void;
857
844
  * };
858
845
  * ```
859
846
  */
860
- export interface TimeTravelContextValue<T> {
847
+ export interface TimeTravelContextValue<T> extends Resettable {
861
848
  /** Current state value */
862
849
  state: T;
863
850
  /** Whether undo operation is available */
@@ -870,8 +857,6 @@ export interface TimeTravelContextValue<T> {
870
857
  redo: () => void;
871
858
  /** Update state and add to history */
872
859
  update: (newState: T) => void;
873
- /** Clear all history and reset to initial state */
874
- reset: () => void;
875
860
  /** Get the complete state history */
876
861
  getHistory: () => T[];
877
862
  }
@@ -952,7 +937,7 @@ export interface TimeTravelProviderReturn<T> {
952
937
  * });
953
938
  * ```
954
939
  */
955
- export interface MockApiProviderReturn<T extends Record<string, unknown>> {
940
+ export interface MockApiProviderReturn<T extends UnknownRecord> {
956
941
  /** Mock API provider component */
957
942
  Provider: React.FC<{
958
943
  children: React.ReactNode;
@@ -1,4 +1,5 @@
1
1
  import type { CacheEntry, CacheStats, CacheStrategy } from '../../../features';
2
+ import type { KeyValueStore, Named } from '../../../common';
2
3
  /**
3
4
  * Configuration for cache strategy test suite
4
5
  *
@@ -34,8 +35,7 @@ import type { CacheEntry, CacheStats, CacheStrategy } from '../../../features';
34
35
  *
35
36
  * @public
36
37
  */
37
- export interface CacheStrategyTestConfig {
38
- name: string;
38
+ export interface CacheStrategyTestConfig extends Named {
39
39
  createStrategy: () => CacheStrategy | Promise<CacheStrategy>;
40
40
  supportsExpiration?: boolean;
41
41
  supportsStats?: boolean;
@@ -62,12 +62,8 @@ export interface CacheStrategyTestConfig {
62
62
  * };
63
63
  * ```
64
64
  */
65
- export interface Cache<T = unknown> {
66
- get(key: string): Promise<T | null>;
65
+ export interface Cache<T = unknown> extends Omit<KeyValueStore<T>, 'set'> {
67
66
  set(key: string, value: T, ttl?: number): Promise<void>;
68
- delete(key: string): Promise<boolean>;
69
- clear(): Promise<void>;
70
- size(): Promise<number>;
71
67
  getStats?(): CacheStats;
72
68
  getRaw?(key: string): Promise<CacheEntry<T> | null>;
73
69
  onEviction?(callback: (key: string, value: T) => void): void;
@@ -45,8 +45,11 @@
45
45
  */
46
46
  import type * as Vitest from 'vitest';
47
47
  import type * as React from 'react';
48
+ import type { UnknownRecord, UnknownArray, Arrayable, SetOptional } from 'type-fest';
48
49
  import type { FeatureFlag, FeatureFlagCondition, FeatureFlagConfig, FeatureFlagContext, FeatureFlagEvaluation, FeatureFlagRule, FeatureFlagValue, FeatureFlagProvider as IFeatureFlagProvider, FeatureFlagContextValue } from '../../../features';
49
50
  import type { MockLogger, RenderFunction, RenderHookFunction } from '../../common';
51
+ import type { Promisable } from 'type-fest';
52
+ import type { Describable, KeyValuePair, Resettable, WithMetadata, WithTimestamp } from '../../../common';
50
53
  /**
51
54
  * Builder interface for creating feature flag test objects with fluent API
52
55
  *
@@ -132,7 +135,7 @@ export interface FeatureFlagContextBuilder {
132
135
  /** Set the application version */
133
136
  withVersion: (version: string) => FeatureFlagContextBuilder;
134
137
  /** Set custom context properties */
135
- withCustom: (custom: Record<string, unknown>) => FeatureFlagContextBuilder;
138
+ withCustom: (custom: UnknownRecord) => FeatureFlagContextBuilder;
136
139
  /** Build the final context object */
137
140
  build: () => FeatureFlagContext;
138
141
  }
@@ -154,7 +157,7 @@ export interface FeatureFlagConditionBuilder {
154
157
  /** Set the comparison operator */
155
158
  withOperator: (operator: FeatureFlagCondition['operator']) => FeatureFlagConditionBuilder;
156
159
  /** Set the comparison value(s) */
157
- withValue: (value: string | number | string[] | number[]) => FeatureFlagConditionBuilder;
160
+ withValue: (value: Arrayable<string | number>) => FeatureFlagConditionBuilder;
158
161
  /** Build the final condition object */
159
162
  build: () => FeatureFlagCondition;
160
163
  }
@@ -196,7 +199,7 @@ export interface FeatureFlagFactory<FeatureFlagKey extends string> {
196
199
  /** Create a number feature flag */
197
200
  createNumber: (key: string, value: number, overrides?: Partial<FeatureFlag<FeatureFlagKey>>) => FeatureFlag<FeatureFlagKey>;
198
201
  /** Create an object feature flag */
199
- createObject: (key: string, value: Record<string, unknown>, overrides?: Partial<FeatureFlag<FeatureFlagKey>>) => FeatureFlag<FeatureFlagKey>;
202
+ createObject: (key: string, value: UnknownRecord, overrides?: Partial<FeatureFlag<FeatureFlagKey>>) => FeatureFlag<FeatureFlagKey>;
200
203
  }
201
204
  /**
202
205
  * Pre-defined feature flag scenario generators for common testing patterns
@@ -489,11 +492,7 @@ export interface FeatureFlagTestOptions<FeatureFlagKey extends string> {
489
492
  * };
490
493
  * ```
491
494
  */
492
- export interface FeatureFlagScenario<FeatureFlagKey extends string> {
493
- /** Scenario name */
494
- name: string;
495
- /** Optional scenario description */
496
- description?: string;
495
+ export interface FeatureFlagScenario<FeatureFlagKey extends string> extends SetOptional<Describable, 'description'> {
497
496
  /** Feature flags for this scenario */
498
497
  flags: FeatureFlag<FeatureFlagKey>[];
499
498
  /** Evaluation context */
@@ -501,9 +500,9 @@ export interface FeatureFlagScenario<FeatureFlagKey extends string> {
501
500
  /** Expected flag evaluation results */
502
501
  expectedResults: Record<string, FeatureFlagValue>;
503
502
  /** Setup function run before scenario */
504
- setup?: () => void | Promise<void>;
503
+ setup?: () => Promisable<void>;
505
504
  /** Teardown function run after scenario */
506
- teardown?: () => void | Promise<void>;
505
+ teardown?: () => Promisable<void>;
507
506
  }
508
507
  /**
509
508
  * Test suite for managing and running multiple feature flag scenarios
@@ -685,7 +684,7 @@ export interface FeatureFlagTestConfig {
685
684
  * eventEmitter.emit(event);
686
685
  * ```
687
686
  */
688
- export interface FeatureFlagEvent {
687
+ export interface FeatureFlagEvent extends WithTimestamp<Date>, SetOptional<WithMetadata, 'metadata'> {
689
688
  /** Type of flag operation */
690
689
  type: 'evaluation' | 'update' | 'create' | 'delete' | 'refresh';
691
690
  /** Flag identifier */
@@ -694,10 +693,6 @@ export interface FeatureFlagEvent {
694
693
  context?: FeatureFlagContext;
695
694
  /** Flag value (for evaluations/updates) */
696
695
  value?: FeatureFlagValue;
697
- /** Event timestamp */
698
- timestamp: Date;
699
- /** Additional event metadata */
700
- metadata?: Record<string, unknown>;
701
696
  }
702
697
  /**
703
698
  * Handler function for feature flag events
@@ -716,7 +711,7 @@ export interface FeatureFlagEvent {
716
711
  * ```
717
712
  */
718
713
  export interface FeatureFlagEventHandler {
719
- (event: FeatureFlagEvent): void | Promise<void>;
714
+ (event: FeatureFlagEvent): Promisable<void>;
720
715
  }
721
716
  /**
722
717
  * Event emitter for feature flag events with subscription management
@@ -918,11 +913,7 @@ export interface FeatureFlagStubManager {
918
913
  * await scheduleFeatureFlagUpdate(update);
919
914
  * ```
920
915
  */
921
- export interface FeatureFlagUpdate<FeatureFlagKey extends string> {
922
- /** Flag key to update */
923
- key: FeatureFlagKey;
924
- /** New flag value */
925
- value: FeatureFlagValue;
916
+ export interface FeatureFlagUpdate<FeatureFlagKey extends string> extends KeyValuePair<FeatureFlagKey, FeatureFlagValue> {
926
917
  /** Delay before applying update (ms) */
927
918
  delay: number;
928
919
  }
@@ -1072,7 +1063,7 @@ export interface ControllableProvider<FeatureFlagKey extends string> {
1072
1063
  *
1073
1064
  * @template FeatureFlagKey - Type of feature flag keys
1074
1065
  */
1075
- export interface SubscriptionFeatureFlagTracker<FeatureFlagKey extends string> {
1066
+ export interface SubscriptionFeatureFlagTracker<FeatureFlagKey extends string> extends Resettable {
1076
1067
  /** Track a new subscription */
1077
1068
  track: (provider: IFeatureFlagProvider<FeatureFlagKey>, id?: string) => {
1078
1069
  id: string;
@@ -1087,8 +1078,6 @@ export interface SubscriptionFeatureFlagTracker<FeatureFlagKey extends string> {
1087
1078
  getCallCount: (id: string) => number;
1088
1079
  /** Get last call arguments for subscription */
1089
1080
  getLastCall: (id: string) => unknown;
1090
- /** Reset all tracking data */
1091
- reset: () => void;
1092
1081
  }
1093
1082
  /**
1094
1083
  * Assertions for feature flag evaluation results.
@@ -1415,8 +1404,8 @@ export interface FeatureFlagService {
1415
1404
  deleteFlag(key: string): Promise<void>;
1416
1405
  setOverride(key: string, value: unknown): Promise<void>;
1417
1406
  removeOverride(key: string): Promise<void>;
1418
- getAllFeatureFlags(environment?: string): Promise<unknown[]>;
1419
- getFlagRules(key: string): Promise<unknown[]>;
1407
+ getAllFeatureFlags(environment?: string): Promise<UnknownArray>;
1408
+ getFlagRules(key: string): Promise<UnknownArray>;
1420
1409
  refreshCache(): Promise<void>;
1421
1410
  getHealthStatus(): Promise<unknown>;
1422
1411
  initializeProvider(): Promise<void>;
@@ -1458,16 +1447,16 @@ export interface FeatureFlagRepository<FeatureFlagKey extends string> {
1458
1447
  createFlag(createData: unknown): Promise<unknown>;
1459
1448
  updateFlag(key: FeatureFlagKey, updateData: unknown): Promise<unknown>;
1460
1449
  deleteFlag(key: FeatureFlagKey): Promise<void>;
1461
- getAllFlags(environment?: string): Promise<unknown[]>;
1462
- getFlagRules(key: FeatureFlagKey): Promise<unknown[]>;
1450
+ getAllFlags(environment?: string): Promise<UnknownArray>;
1451
+ getFlagRules(key: FeatureFlagKey): Promise<UnknownArray>;
1463
1452
  getFlag(key: FeatureFlagKey): Promise<unknown>;
1464
1453
  createRule(rule: unknown): Promise<unknown>;
1465
1454
  updateRule(ruleId: string, updateData: unknown): Promise<unknown>;
1466
1455
  deleteRule(ruleId: string): Promise<void>;
1467
1456
  getFlagByKey(key: FeatureFlagKey): Promise<unknown>;
1468
- getAllRules(): Promise<unknown[]>;
1457
+ getAllRules(): Promise<UnknownArray>;
1469
1458
  createSampleFlags(): Promise<void>;
1470
- filterFlagsByEnvironment(flags: unknown[], environment: string): unknown[];
1459
+ filterFlagsByEnvironment(flags: UnknownArray, environment: string): UnknownArray;
1471
1460
  inferFlagType(value: unknown): string;
1472
1461
  }
1473
1462
  /**
@@ -1613,7 +1602,7 @@ export interface CreateABTestScenario<T extends string> {
1613
1602
  /** A/B test configuration */
1614
1603
  config: ABTestConfig<T>;
1615
1604
  /** Get variant for user */
1616
- getVariantForUser: (userId: string, attributes?: Record<string, unknown>) => FeatureFlagValue;
1605
+ getVariantForUser: (userId: string, attributes?: UnknownRecord) => FeatureFlagValue;
1617
1606
  getTrafficDistribution: () => {
1618
1607
  control: number;
1619
1608
  treatment: number;
@@ -1,20 +1,16 @@
1
1
  import type { CHAIN_ID } from './enums';
2
+ import type { Named } from '../common/types';
2
3
  /**
3
4
  * Defines the configuration structure for an EVM-compatible blockchain network.
4
5
  * @description This is commonly used for wallet integration, chain switching, and displaying metadata such as currency and explorer links.
5
6
  */
6
- export interface NetworkConfig {
7
+ export interface NetworkConfig extends Named {
7
8
  /**
8
9
  * Numeric chain ID of the blockchain network.
9
10
  * @description Should match the value from {@link typeof CHAIN_ID}.
10
11
  * @example 137 // Polygon Mainnet
11
12
  */
12
13
  readonly chainId: typeof CHAIN_ID;
13
- /**
14
- * @description Full name of the network.
15
- * @example "Polygon"
16
- */
17
- readonly name: string;
18
14
  /**
19
15
  * @description Short, user-friendly name for display purposes.
20
16
  * @example "MATIC"
@@ -24,11 +20,6 @@ export interface NetworkConfig {
24
20
  * Native currency used on the network for fees and balances.
25
21
  */
26
22
  readonly nativeCurrency: {
27
- /**
28
- * @description Full name of the native currency.
29
- * @example "Matic"
30
- */
31
- readonly name: string;
32
23
  /**
33
24
  * @description Symbol of the currency used in wallet UIs.
34
25
  * @example "MATIC"
@@ -39,7 +30,7 @@ export interface NetworkConfig {
39
30
  * @example 18
40
31
  */
41
32
  readonly decimals: number;
42
- };
33
+ } & Named;
43
34
  /**
44
35
  * @description List of public RPC endpoints used to communicate with the blockchain.
45
36
  * @example ["https://polygon-rpc.com"]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plyaz/types",
3
- "version": "1.5.5",
3
+ "version": "1.7.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.",
@@ -31,6 +31,7 @@
31
31
  "pnpm": ">=8.0.0"
32
32
  },
33
33
  "keywords": [],
34
+ "packageManager": "pnpm@10.11.0",
34
35
  "dependencies": {
35
36
  "type-fest": "^4.41.0"
36
37
  },