@plyaz/types 1.5.0 → 1.5.2

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.
@@ -732,3 +732,58 @@ export interface RepositoryOperationTestInput {
732
732
  /** Whether operation should throw an error */
733
733
  shouldThrow?: boolean;
734
734
  }
735
+ /**
736
+ * Default configuration for feature flags.
737
+ * Provides template values for newly created flags.
738
+ *
739
+ * @example
740
+ * ```typescript
741
+ * const defaults: FlagDefaults = {
742
+ * name: 'New Feature',
743
+ * description: 'Enables the new experimental feature',
744
+ * isEnabled: false,
745
+ * value: false,
746
+ * type: 'boolean',
747
+ * environment: 'development',
748
+ * createdAt: new Date(),
749
+ * updatedAt: new Date(),
750
+ * createdBy: 'system',
751
+ * updatedBy: 'system'
752
+ * };
753
+ * ```
754
+ */
755
+ export interface FlagDefaults {
756
+ /** Flag name */
757
+ name: string;
758
+ /** Flag description */
759
+ description: string;
760
+ /** Whether flag is enabled */
761
+ isEnabled: boolean;
762
+ /** Default value */
763
+ value: FeatureFlagValue;
764
+ /** Flag type */
765
+ type: FlagType;
766
+ /** Environment */
767
+ environment: 'development' | 'staging' | 'production' | 'all';
768
+ /** Created date */
769
+ createdAt: Date;
770
+ /** Updated date */
771
+ updatedAt: Date;
772
+ /** Created by */
773
+ createdBy: string;
774
+ /** Updated by */
775
+ updatedBy: string;
776
+ }
777
+ /**
778
+ * Supported types for feature flag values.
779
+ * Determines how flag values are stored and evaluated.
780
+ *
781
+ * @example
782
+ * ```typescript
783
+ * const booleanFlag: FlagType = 'boolean'; // true/false flags
784
+ * const stringFlag: FlagType = 'string'; // Text values like themes
785
+ * const numberFlag: FlagType = 'number'; // Numeric values like limits
786
+ * const jsonFlag: FlagType = 'json'; // Complex configurations
787
+ * ```
788
+ */
789
+ export type FlagType = 'boolean' | 'string' | 'number' | 'json';
@@ -344,49 +344,49 @@ export interface ScenarioTestSuite<TContext, TInput, TExpected> {
344
344
  */
345
345
  export interface AutoMockedRepository {
346
346
  /** Find entities matching criteria */
347
- find: Vitest.MockInstance;
347
+ find: Vitest.Mock;
348
348
  /** Find single entity */
349
- findOne: Vitest.MockInstance;
349
+ findOne: Vitest.Mock;
350
350
  /** Find single entity by criteria */
351
- findOneBy: Vitest.MockInstance;
351
+ findOneBy: Vitest.Mock;
352
352
  /** Find single entity or throw */
353
- findOneOrFail: Vitest.MockInstance;
353
+ findOneOrFail: Vitest.Mock;
354
354
  /** Find entities by criteria */
355
- findBy: Vitest.MockInstance;
355
+ findBy: Vitest.Mock;
356
356
  /** Find entities and get count */
357
- findAndCount: Vitest.MockInstance;
357
+ findAndCount: Vitest.Mock;
358
358
  /** Save entity */
359
- save: Vitest.MockInstance;
359
+ save: Vitest.Mock;
360
360
  /** Create entity instance */
361
- create: Vitest.MockInstance;
361
+ create: Vitest.Mock;
362
362
  /** Update entity */
363
- update: Vitest.MockInstance;
363
+ update: Vitest.Mock;
364
364
  /** Delete entity */
365
- delete: Vitest.MockInstance;
365
+ delete: Vitest.Mock;
366
366
  /** Remove entity */
367
- remove: Vitest.MockInstance;
367
+ remove: Vitest.Mock;
368
368
  /** Count entities */
369
- count: Vitest.MockInstance;
369
+ count: Vitest.Mock;
370
370
  /** Execute raw query */
371
- query: Vitest.MockInstance;
371
+ query: Vitest.Mock;
372
372
  /** Create query builder */
373
- createQueryBuilder: Vitest.MockInstance;
373
+ createQueryBuilder: Vitest.Mock;
374
374
  /** Preload entity with relations */
375
- preload: Vitest.MockInstance;
375
+ preload: Vitest.Mock;
376
376
  /** Merge entity changes */
377
- merge: Vitest.MockInstance;
377
+ merge: Vitest.Mock;
378
378
  /** Soft delete entity */
379
- softDelete: Vitest.MockInstance;
379
+ softDelete: Vitest.Mock;
380
380
  /** Restore soft deleted entity */
381
- restore: Vitest.MockInstance;
381
+ restore: Vitest.Mock;
382
382
  /** Check if entity exists */
383
- exist: Vitest.MockInstance;
383
+ exist: Vitest.Mock;
384
384
  /** Clear all entities */
385
- clear: Vitest.MockInstance;
385
+ clear: Vitest.Mock;
386
386
  /** Increment field value */
387
- increment: Vitest.MockInstance;
387
+ increment: Vitest.Mock;
388
388
  /** Decrement field value */
389
- decrement: Vitest.MockInstance;
389
+ decrement: Vitest.Mock;
390
390
  }
391
391
  /**
392
392
  * Auto-mocked HTTP service interface for HTTP client testing
@@ -407,21 +407,21 @@ export interface AutoMockedRepository {
407
407
  */
408
408
  export interface AutoMockedHttpService {
409
409
  /** HTTP GET request */
410
- get: Vitest.MockInstance;
410
+ get: Vitest.Mock;
411
411
  /** HTTP POST request */
412
- post: Vitest.MockInstance;
412
+ post: Vitest.Mock;
413
413
  /** HTTP PUT request */
414
- put: Vitest.MockInstance;
414
+ put: Vitest.Mock;
415
415
  /** HTTP PATCH request */
416
- patch: Vitest.MockInstance;
416
+ patch: Vitest.Mock;
417
417
  /** HTTP DELETE request */
418
- delete: Vitest.MockInstance;
418
+ delete: Vitest.Mock;
419
419
  /** HTTP HEAD request */
420
- head: Vitest.MockInstance;
420
+ head: Vitest.Mock;
421
421
  /** HTTP OPTIONS request */
422
- options: Vitest.MockInstance;
422
+ options: Vitest.Mock;
423
423
  /** Generic HTTP request */
424
- request: Vitest.MockInstance;
424
+ request: Vitest.Mock;
425
425
  }
426
426
  /**
427
427
  * Auto-mocked configuration service interface for config testing
@@ -442,13 +442,13 @@ export interface AutoMockedHttpService {
442
442
  */
443
443
  export interface AutoMockedConfigService {
444
444
  /** Get configuration value */
445
- get: Vitest.MockInstance;
445
+ get: Vitest.Mock;
446
446
  /** Get configuration value or throw */
447
- getOrThrow: Vitest.MockInstance;
447
+ getOrThrow: Vitest.Mock;
448
448
  /** Check if configuration key exists */
449
- has: Vitest.MockInstance;
449
+ has: Vitest.Mock;
450
450
  /** Set configuration value */
451
- set: Vitest.MockInstance;
451
+ set: Vitest.Mock;
452
452
  }
453
453
  /**
454
454
  * Database update operation result
@@ -700,10 +700,29 @@ export interface ScenarioResult<T> {
700
700
  duration: number;
701
701
  }
702
702
  /**
703
- * Tracked call record for mock functions
704
- * @interface TrackedCallRecord
705
- * @typeParam TArgs - Function argument types
706
- * @typeParam TReturn - Function return type
703
+ * Record of a single function call with metadata.
704
+ * Captures comprehensive information about each mock function invocation.
705
+ *
706
+ * @template TArgs - Function argument types
707
+ * @template TReturn - Function return type
708
+ *
709
+ * @example
710
+ * ```typescript
711
+ * const record: TrackedCallRecord<[string, number], string> = {
712
+ * args: ['hello', 42],
713
+ * timestamp: new Date('2024-01-01T10:00:00Z'),
714
+ * result: 'success',
715
+ * duration: 125
716
+ * };
717
+ *
718
+ * // Error case
719
+ * const errorRecord: TrackedCallRecord<[string], void> = {
720
+ * args: ['invalid'],
721
+ * timestamp: new Date(),
722
+ * error: new Error('Validation failed'),
723
+ * duration: 50
724
+ * };
725
+ * ```
707
726
  */
708
727
  export interface TrackedCallRecord<TArgs extends unknown[], TReturn> {
709
728
  /** Function arguments */
@@ -714,32 +733,49 @@ export interface TrackedCallRecord<TArgs extends unknown[], TReturn> {
714
733
  result?: TReturn;
715
734
  /** Error if thrown */
716
735
  error?: Error;
717
- /** Call duration */
736
+ /** Call duration in milliseconds */
718
737
  duration?: number;
719
738
  }
720
739
  /**
721
- * Tracked mock function with enhanced capabilities
722
- * @interface TrackedMockFunction
723
- * @typeParam TArgs - Function argument types
724
- * @typeParam TReturn - Function return type
725
- * @extends Vitest.MockInstance from vitest
740
+ * Enhanced mock function with call tracking and filtering capabilities.
741
+ * Extends Vitest's Mock to provide detailed call history and search functionality.
742
+ *
743
+ * @template TArgs - Function argument types
744
+ * @template TReturn - Function return type
745
+ *
746
+ * @extends {Vitest.Mock<(...args: TArgs) => TReturn>}
747
+ *
748
+ * @example
749
+ * ```typescript
750
+ * const trackedFn: TrackedMockFunction<[string, number], boolean> = createTrackedMock();
751
+ *
752
+ * // Use the mock
753
+ * trackedFn('test', 42);
754
+ * trackedFn('example', 100);
755
+ *
756
+ * // Access call records
757
+ * const firstCall = trackedFn.getCall(0);
758
+ * console.log(firstCall?.args); // ['test', 42]
759
+ *
760
+ * // Find specific calls
761
+ * const testCalls = trackedFn.findCalls(
762
+ * call => call.args[0] === 'test'
763
+ * );
764
+ *
765
+ * // Reset call history
766
+ * trackedFn.resetCalls();
767
+ * ```
726
768
  */
727
- export interface TrackedMockFunction<TArgs extends unknown[], TReturn> extends Vitest.MockInstance<(...args: TArgs) => TReturn> {
728
- /** All call records */
769
+ export interface TrackedMockFunction<TArgs extends unknown[], TReturn> extends Vitest.Mock<(...args: TArgs) => TReturn> {
770
+ /** Array of all call records with metadata */
729
771
  calls: Array<TrackedCallRecord<TArgs, TReturn>>;
730
- /** Get specific call */
772
+ /** Get a specific call by index */
731
773
  getCall: (index: number) => TrackedCallRecord<TArgs, TReturn> | undefined;
732
- /** Find calls matching predicate */
774
+ /** Find calls matching a predicate */
733
775
  findCalls: (predicate: (call: {
734
776
  args: TArgs;
735
777
  timestamp: Date;
736
778
  }) => boolean) => Array<TrackedCallRecord<TArgs, TReturn>>;
737
- /** Get call count */
738
- getCallCount: () => number;
739
- /** Get total execution time */
740
- getTotalExecutionTime: () => number;
741
- /** Get average execution time */
742
- getAverageExecutionTime: () => number;
743
- /** Clear tracking history */
744
- clearTracking: () => void;
779
+ /** Reset all tracked calls */
780
+ resetCalls: () => void;
745
781
  }