@plyaz/types 1.7.2 → 1.7.4

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.
@@ -253,7 +253,7 @@ export interface Describable extends Named {
253
253
  * }
254
254
  * ```
255
255
  */
256
- export interface WithMetadata<T = UnknownRecord | undefined> {
256
+ export interface WithMetadata<T = UnknownRecord> {
257
257
  /** Metadata for additional information */
258
258
  metadata: T;
259
259
  }
@@ -868,7 +868,7 @@ export interface WithLogging {
868
868
  */
869
869
  export interface Refreshable {
870
870
  /** When the entity was last updated/refreshed */
871
- lastUpdated: Date | string | null;
871
+ lastUpdated?: Date | string | null;
872
872
  /** Function to refresh the entity */
873
873
  refresh: () => void | Promise<void>;
874
874
  }
@@ -887,7 +887,7 @@ export interface Initializable {
887
887
  /** Whether the entity has been initialized */
888
888
  isInitialized: boolean;
889
889
  /** Callback when entity is ready */
890
- onReady: () => void;
890
+ onReady?: () => void;
891
891
  }
892
892
  /**
893
893
  * Base interface for entities with a single timestamp.
@@ -922,7 +922,7 @@ export interface Tracked<T = null | undefined> extends WithTimestamp {
922
922
  /** Result of the operation */
923
923
  result: T;
924
924
  /** Error if the operation failed */
925
- error: Error | null;
925
+ error: Error | null | undefined;
926
926
  }
927
927
  /**
928
928
  * Base interface for entities with duration tracking.
@@ -1119,9 +1119,9 @@ export interface WithSessionId {
1119
1119
  */
1120
1120
  export interface WithRetryTracking {
1121
1121
  /** Current retry attempt count */
1122
- retryCount: number;
1122
+ retryCount?: number;
1123
1123
  /** Maximum allowed retries */
1124
- maxRetries: number;
1124
+ maxRetries?: number;
1125
1125
  /** retry delay in milliseconds */
1126
1126
  retryDelay?: number;
1127
1127
  }
@@ -1445,7 +1445,7 @@ export interface WithBody<T = unknown> {
1445
1445
  * }
1446
1446
  * ```
1447
1447
  */
1448
- export interface WithError extends WithMessage {
1448
+ export interface WithError extends Partial<WithMessage> {
1449
1449
  /** Error code for programmatic handling */
1450
1450
  code?: string;
1451
1451
  }
@@ -20,7 +20,7 @@ export interface Event<T> extends Identifiable, WithTimestamp, Partial<WithCorre
20
20
  * Additional contextual data for an event.
21
21
  * @description This is often populated with session/user data and retry tracking.
22
22
  */
23
- export type EventMetadata = SetOptional<WithUserId & WithSessionId & WithUserAgent & WithRetryTracking & WithIpAddress, 'userId' | 'sessionId' | 'userAgent' | 'retryCount' | 'maxRetries' | 'ip'> & {
23
+ export type EventMetadata = SetOptional<WithUserId & WithSessionId & WithUserAgent & WithRetryTracking & WithIpAddress, 'userId' | 'sessionId' | 'userAgent' | 'ip'> & {
24
24
  /**
25
25
  * Additional metadata as key-value pairs.
26
26
  */
@@ -94,9 +94,9 @@ export interface CacheStrategy {
94
94
  * Retrieves a cache entry.
95
95
  *
96
96
  * @param key - Cache key
97
- * @returns Promise that resolves to cache entry or null if not found
97
+ * @returns Promise that resolves to cache entry or null/undefined if not found
98
98
  */
99
- get<T>(key: string): Promise<CacheEntry<T> | null>;
99
+ get<T>(key: string): Promise<CacheEntry<T> | null | undefined>;
100
100
  /**
101
101
  * Removes a cache entry.
102
102
  *
@@ -6,7 +6,7 @@
6
6
  * @fileoverview Feature flags domain type definitions
7
7
  * @version 1.0.0
8
8
  */
9
- import type { UnknownRecord, UnknownArray, Arrayable, Promisable, SetOptional } from 'type-fest';
9
+ import type { UnknownRecord, UnknownArray, Arrayable, SetOptional } from 'type-fest';
10
10
  import type * as React from 'react';
11
11
  import type { Describable, Timestamped, WithMetadata, Loadable, Authored, WithTags, WithEnvironment, Identifiable, Named, WithLogging, WithApiKey, Initializable, Refreshable, WithOperation, Enabled, WithError, KeyValuePair, WithUserId, WithCountry, Versioned, WithPlatform, WithPriority, ValidationResult } from '../../common/types';
12
12
  /**
@@ -172,7 +172,7 @@ export interface FeatureFlagProviderProps<FeatureFlagKey extends string, Feature
172
172
  /**
173
173
  * Backend Request DTO for flag creation.
174
174
  */
175
- export interface CreateFlagRequest<FeatureFlagKey extends string> extends WithEnvironment, SetOptional<Enabled, 'isEnabled'>, SetOptional<Describable, 'description'>, Named, KeyValuePair<FeatureFlagKey, FeatureFlagValue> {
175
+ export interface CreateFlagRequest<FeatureFlagKey extends string> extends Partial<WithEnvironment>, SetOptional<Enabled, 'isEnabled'>, SetOptional<Describable, 'description'>, Named, KeyValuePair<FeatureFlagKey, FeatureFlagValue> {
176
176
  rolloutPercentage?: number;
177
177
  }
178
178
  /**
@@ -227,6 +227,8 @@ export interface ProviderStats {
227
227
  avgEvaluationTime: number;
228
228
  /** Last refresh timestamp */
229
229
  lastRefresh?: Date;
230
+ /** Last updated timestamp */
231
+ lastUpdated?: Date;
230
232
  /** Provider uptime in ms */
231
233
  uptime: number;
232
234
  }
@@ -254,7 +256,7 @@ export interface FeatureFlagHelpers<FeatureFlagKey extends string = string> {
254
256
  getMultipleFlags: (keys: FeatureFlagKey[], context?: FeatureFlagContext) => Promise<Record<FeatureFlagKey, FeatureFlagValue>>;
255
257
  isAnyEnabled: (keys: FeatureFlagKey[], context?: FeatureFlagContext) => Promise<boolean>;
256
258
  isAllEnabled: (keys: FeatureFlagKey[], context?: FeatureFlagContext) => Promise<boolean>;
257
- whenEnabled: <T>(key: FeatureFlagKey, callback: () => Promisable<T>, fallback?: () => Promisable<T>, context?: FeatureFlagContext) => Promise<T | undefined>;
259
+ whenEnabled: <T>(key: FeatureFlagKey, callback: () => T | Promise<T>, fallback?: () => T | Promise<T>, context?: FeatureFlagContext) => Promise<T | undefined>;
258
260
  }
259
261
  /**
260
262
  * Response structure for fetching feature flag data.
@@ -303,7 +305,7 @@ export interface FlagEvaluationTestInput<FeatureFlagKey extends string> extends
303
305
  /**
304
306
  * Input for flag creation test cases
305
307
  */
306
- export interface FlagCreationTestInput<FeatureFlagKey extends string> extends WithEnvironment, Enabled, Describable, Named, KeyValuePair<FeatureFlagKey, FeatureFlagValue> {
308
+ export interface FlagCreationTestInput<FeatureFlagKey extends string> extends Partial<WithEnvironment>, Enabled, Describable, Named, KeyValuePair<FeatureFlagKey, FeatureFlagValue> {
307
309
  /** Rollout percentage (0-100) */
308
310
  rolloutPercentage?: number;
309
311
  }
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Type definitions for assertion utilities.
5
5
  */
6
- import type { UnknownRecord, UnknownArray, Promisable } from 'type-fest';
6
+ import type { UnknownRecord, UnknownArray, SetOptional } from 'type-fest';
7
7
  import type { WithStatusCode, WithMessage, WithTimestamp, WithCorrelationId, WithMetadata, Named, WithRequestId, WithStatus } from '../../../common/types';
8
8
  /**
9
9
  * Pattern for matching HTTP errors with status code and message.
@@ -17,7 +17,7 @@ import type { WithStatusCode, WithMessage, WithTimestamp, WithCorrelationId, Wit
17
17
  * };
18
18
  * ```
19
19
  */
20
- export interface ErrorPattern extends WithStatusCode, WithStatus<string | number> {
20
+ export interface ErrorPattern extends SetOptional<WithStatusCode, 'statusCode'>, WithStatus<string | number> {
21
21
  /** Regular expression to match against error message */
22
22
  message: RegExp;
23
23
  }
@@ -33,7 +33,7 @@ export interface ErrorPattern extends WithStatusCode, WithStatus<string | number
33
33
  * };
34
34
  * ```
35
35
  */
36
- export interface ValidationErrorPattern extends WithStatusCode, WithStatus<string | number> {
36
+ export interface ValidationErrorPattern extends SetOptional<WithStatusCode, 'statusCode'>, WithStatus<string | number> {
37
37
  /** Array of field names that failed validation */
38
38
  validation: string[];
39
39
  }
@@ -203,7 +203,7 @@ export interface ErrorPropagationTestResult<T> {
203
203
  */
204
204
  export interface ErrorCircuitBreaker<T> {
205
205
  /** Execute function with circuit breaker protection */
206
- execute: (fn: () => Promisable<T>) => Promisable<T>;
206
+ execute: (fn: () => T | Promise<T>) => T | Promise<T>;
207
207
  /** Get current circuit state */
208
208
  getState: () => 'closed' | 'open' | 'half-open';
209
209
  /** Get error statistics */
@@ -623,7 +623,7 @@ export interface ScenarioResult<T> {
623
623
  * };
624
624
  * ```
625
625
  */
626
- export interface TrackedCallRecord<TArgs extends unknown[], TReturn, TTimestamp = Date> extends Omit<Tracked<TReturn>, 'timestamp'>, WithDuration, WithTimestamp<TTimestamp> {
626
+ export interface TrackedCallRecord<TArgs extends unknown[], TReturn, TTimestamp = Date> extends Omit<Tracked<TReturn | undefined>, 'timestamp'>, WithDuration, WithTimestamp<TTimestamp> {
627
627
  /** Function arguments */
628
628
  args: TArgs;
629
629
  }
@@ -2061,11 +2061,11 @@ export interface ConsoleMockParams {
2061
2061
  storage: string[];
2062
2062
  all: Array<{
2063
2063
  type: string;
2064
- args: UnknownArray;
2064
+ args: unknown[];
2065
2065
  }>;
2066
2066
  originalFn: Function;
2067
2067
  suppressTypes: string[];
2068
- formatArguments: (args: readonly unknown[]) => string;
2068
+ formatArguments: (args: unknown[]) => string;
2069
2069
  captureStackTrace?: boolean;
2070
2070
  }
2071
2071
  /**
@@ -400,10 +400,10 @@ export interface CreateTableDrivenTestOptions<TInput, TExpected> extends Named {
400
400
  }>;
401
401
  test?: (testCase: TInput & {
402
402
  expected?: TExpected;
403
- }) => Promisable<void>;
403
+ }) => void | Promise<void>;
404
404
  fn?: (testCase: TInput & {
405
405
  expected?: TExpected;
406
- }) => Promisable<void>;
406
+ }) => void | Promise<void>;
407
407
  }
408
408
  /**
409
409
  * Statistics collected for operation performance tracking.
@@ -540,7 +540,7 @@ export interface MockConsole {
540
540
  * };
541
541
  * ```
542
542
  */
543
- export interface MockEnv extends KeyValueStore<string, string> {
543
+ export interface MockEnv extends Omit<KeyValueStore<string, string>, 'has'> {
544
544
  restore: () => void;
545
545
  }
546
546
  /**
@@ -2135,7 +2135,7 @@ export interface ModuleLifecycleTest extends Named {
2135
2135
  */
2136
2136
  export interface ApplicationLifecycleTest extends Named {
2137
2137
  app: UnknownRecord;
2138
- modules: UnknownArray;
2138
+ modules: unknown[];
2139
2139
  expectedStartupSequence: string[];
2140
2140
  expectedShutdownSequence: string[];
2141
2141
  }
@@ -2611,7 +2611,8 @@ export interface MockNextRouterReturn {
2611
2611
  * };
2612
2612
  * ```
2613
2613
  */
2614
- export interface MockNextRequest extends WithUrl, WithHttpMethod, WithHeaders, WithIpAddress, WithBody {
2614
+ export interface MockNextRequest extends WithUrl, WithHttpMethod, WithIpAddress, WithBody {
2615
+ headers: Headers;
2615
2616
  searchParams?: Record<string, string>;
2616
2617
  nextUrl: {
2617
2618
  pathname: string;
@@ -2855,6 +2856,8 @@ export interface ApiRouteHandlerMethods {
2855
2856
  PUT?: Function;
2856
2857
  DELETE?: Function;
2857
2858
  PATCH?: Function;
2859
+ HEAD?: Function;
2860
+ OPTIONS?: Function;
2858
2861
  }
2859
2862
  /**
2860
2863
  * Test scenario for route handlers.
@@ -3653,7 +3656,7 @@ export interface SecretsManagementTest extends Named {
3653
3656
  }
3654
3657
  export interface SecretsManager extends KeyValueStore<string, string> {
3655
3658
  }
3656
- export interface MockEnvironment extends Exclude<KeyValueStore<string, string>, 'delete' | 'has'> {
3659
+ export interface MockEnvironment extends Omit<KeyValueStore<string, string>, 'delete' | 'has'> {
3657
3660
  update: (updates: EnvironmentConfig) => void;
3658
3661
  unset: (key: string) => void;
3659
3662
  restore: () => void;
@@ -3725,7 +3728,7 @@ export interface ApiAuthScenario {
3725
3728
  export interface ApiRouteOptions extends Partial<WithUrl> {
3726
3729
  method?: HttpMethod;
3727
3730
  headers?: Record<string, Arrayable<string>>;
3728
- query?: Record<string, Arrayable<string>>;
3731
+ query?: Record<string, Arrayable<string> | undefined>;
3729
3732
  body?: unknown;
3730
3733
  cookies?: Record<string, string>;
3731
3734
  }
@@ -4418,9 +4421,9 @@ export interface DynamicModuleClass {
4418
4421
  * ```
4419
4422
  */
4420
4423
  export interface DynamicModuleExpectations {
4421
- providers?: UnknownArray;
4422
- imports?: UnknownArray;
4423
- exports?: UnknownArray;
4424
+ providers?: unknown[];
4425
+ imports?: unknown[];
4426
+ exports?: unknown[];
4424
4427
  }
4425
4428
  /**
4426
4429
  * Return value from NestJS test suite setup.
@@ -4584,7 +4587,7 @@ export interface UserFlowStep extends Named {
4584
4587
  export interface MockNextRequestCreatorParams {
4585
4588
  url: string;
4586
4589
  options?: {
4587
- method?: string;
4590
+ method?: HttpMethod;
4588
4591
  headers?: Record<string, string>;
4589
4592
  body?: unknown;
4590
4593
  searchParams?: Record<string, string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plyaz/types",
3
- "version": "1.7.2",
3
+ "version": "1.7.4",
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.",