@plyaz/types 1.7.0 → 1.7.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.
- package/dist/common/types.d.ts +8 -6
- package/dist/testing/common/assertions/types.d.ts +10 -6
- package/dist/testing/common/factories/types.d.ts +7 -8
- package/dist/testing/common/mocks/types.d.ts +2 -2
- package/dist/testing/common/patterns/types.d.ts +1 -1
- package/dist/testing/common/utils/types.d.ts +13 -13
- package/dist/testing/features/cache/types.d.ts +5 -1
- package/package.json +1 -1
package/dist/common/types.d.ts
CHANGED
|
@@ -201,9 +201,9 @@ export interface NavigablePaginatedCollection<T> extends PaginatedCollection<T>,
|
|
|
201
201
|
* }
|
|
202
202
|
* ```
|
|
203
203
|
*/
|
|
204
|
-
export interface SoftDeletable {
|
|
204
|
+
export interface SoftDeletable<T = Date | null> {
|
|
205
205
|
/** When the entity was soft deleted */
|
|
206
|
-
deletedAt:
|
|
206
|
+
deletedAt: T;
|
|
207
207
|
}
|
|
208
208
|
/**
|
|
209
209
|
* Base interface for named entities.
|
|
@@ -918,9 +918,9 @@ export interface WithTimestamp<T = Date | string> {
|
|
|
918
918
|
* }
|
|
919
919
|
* ```
|
|
920
920
|
*/
|
|
921
|
-
export interface Tracked<T =
|
|
921
|
+
export interface Tracked<T = null | undefined> extends WithTimestamp {
|
|
922
922
|
/** Result of the operation */
|
|
923
|
-
result: T
|
|
923
|
+
result: T;
|
|
924
924
|
/** Error if the operation failed */
|
|
925
925
|
error: Error | null;
|
|
926
926
|
}
|
|
@@ -950,9 +950,9 @@ export interface WithDuration {
|
|
|
950
950
|
* }
|
|
951
951
|
* ```
|
|
952
952
|
*/
|
|
953
|
-
export interface WithLastAccessed {
|
|
953
|
+
export interface WithLastAccessed<T = Date | string | null> {
|
|
954
954
|
/** When the entity was last accessed */
|
|
955
|
-
lastAccessedAt:
|
|
955
|
+
lastAccessedAt: T;
|
|
956
956
|
}
|
|
957
957
|
/**
|
|
958
958
|
* Base interface for versioned entities.
|
|
@@ -1122,6 +1122,8 @@ export interface WithRetryTracking {
|
|
|
1122
1122
|
retryCount: number;
|
|
1123
1123
|
/** Maximum allowed retries */
|
|
1124
1124
|
maxRetries: number;
|
|
1125
|
+
/** retry delay in milliseconds */
|
|
1126
|
+
retryDelay?: number;
|
|
1125
1127
|
}
|
|
1126
1128
|
/**
|
|
1127
1129
|
* Base interface for entities with roles.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Type definitions for assertion utilities.
|
|
5
5
|
*/
|
|
6
6
|
import type { UnknownRecord, UnknownArray, Promisable } from 'type-fest';
|
|
7
|
-
import type { WithStatusCode, WithMessage, WithTimestamp,
|
|
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.
|
|
10
10
|
* Used in testing to assert specific error responses.
|
|
@@ -17,7 +17,7 @@ import type { WithStatusCode, WithMessage, WithTimestamp, WithError, WithCorrela
|
|
|
17
17
|
* };
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
|
-
export interface ErrorPattern extends WithStatusCode {
|
|
20
|
+
export interface ErrorPattern extends WithStatusCode, WithStatus {
|
|
21
21
|
/** Regular expression to match against error message */
|
|
22
22
|
message: RegExp;
|
|
23
23
|
}
|
|
@@ -61,7 +61,9 @@ export interface ErrorStats {
|
|
|
61
61
|
* Entry in an error timeline tracking when errors occurred.
|
|
62
62
|
* Used for debugging error patterns over time.
|
|
63
63
|
*/
|
|
64
|
-
export interface ErrorTimelineEntry extends WithTimestamp<number
|
|
64
|
+
export interface ErrorTimelineEntry extends WithTimestamp<number> {
|
|
65
|
+
/** The error that occurred */
|
|
66
|
+
error: Error;
|
|
65
67
|
/** Additional context data at the time of error */
|
|
66
68
|
context?: UnknownRecord;
|
|
67
69
|
}
|
|
@@ -137,7 +139,9 @@ export interface ErrorRecoveryResult {
|
|
|
137
139
|
* Entry for correlating errors with additional context.
|
|
138
140
|
* Used in error tracking and debugging systems.
|
|
139
141
|
*/
|
|
140
|
-
export interface ErrorCorrelationEntry extends
|
|
142
|
+
export interface ErrorCorrelationEntry extends Partial<WithMetadata<UnknownRecord>> {
|
|
143
|
+
/** The original error that triggered recovery */
|
|
144
|
+
error: Error;
|
|
141
145
|
}
|
|
142
146
|
/**
|
|
143
147
|
* Definition of an error test scenario.
|
|
@@ -199,7 +203,7 @@ export interface ErrorPropagationTestResult<T> {
|
|
|
199
203
|
*/
|
|
200
204
|
export interface ErrorCircuitBreaker<T> {
|
|
201
205
|
/** Execute function with circuit breaker protection */
|
|
202
|
-
execute: (fn: () => Promisable<T>) =>
|
|
206
|
+
execute: (fn: () => Promisable<T>) => Promisable<T>;
|
|
203
207
|
/** Get current circuit state */
|
|
204
208
|
getState: () => 'closed' | 'open' | 'half-open';
|
|
205
209
|
/** Get error statistics */
|
|
@@ -285,7 +289,7 @@ export interface ValidationMessage {
|
|
|
285
289
|
* Expected HTTP exception pattern for testing.
|
|
286
290
|
* Used to assert specific HTTP error responses.
|
|
287
291
|
*/
|
|
288
|
-
export interface ExpectedHttpException extends Partial<WithStatusCode
|
|
292
|
+
export interface ExpectedHttpException extends Partial<WithStatusCode>, WithStatus {
|
|
289
293
|
/** Expected error message or pattern */
|
|
290
294
|
message?: string | RegExp;
|
|
291
295
|
/** Expected response body */
|
|
@@ -137,8 +137,7 @@ export type TestMetadata = Versioned & WithSource & Authored & WithTags & WithLa
|
|
|
137
137
|
* };
|
|
138
138
|
* ```
|
|
139
139
|
*/
|
|
140
|
-
export
|
|
141
|
-
}
|
|
140
|
+
export type TestTimestamps = Timestamped<Date, Date> & SoftDeletable & WithExpiration<Date | null> & WithLastAccessed<Date | null>;
|
|
142
141
|
/**
|
|
143
142
|
* Test scenario interface for scenario-driven testing
|
|
144
143
|
*
|
|
@@ -624,7 +623,7 @@ export interface ScenarioResult<T> {
|
|
|
624
623
|
* };
|
|
625
624
|
* ```
|
|
626
625
|
*/
|
|
627
|
-
export interface TrackedCallRecord<TArgs extends unknown[], TReturn> extends Tracked<TReturn>, WithDuration {
|
|
626
|
+
export interface TrackedCallRecord<TArgs extends unknown[], TReturn, TTimestamp = Date> extends Omit<Tracked<TReturn>, 'timestamp'>, WithDuration, WithTimestamp<TTimestamp> {
|
|
628
627
|
/** Function arguments */
|
|
629
628
|
args: TArgs;
|
|
630
629
|
}
|
|
@@ -658,16 +657,16 @@ export interface TrackedCallRecord<TArgs extends unknown[], TReturn> extends Tra
|
|
|
658
657
|
* trackedFn.resetCalls();
|
|
659
658
|
* ```
|
|
660
659
|
*/
|
|
661
|
-
export interface TrackedMockFunction<TArgs extends unknown[], TReturn> extends Vitest.Mock<(...args: TArgs) => TReturn> {
|
|
660
|
+
export interface TrackedMockFunction<TArgs extends unknown[], TReturn, TTimestamp = Date> extends Vitest.Mock<(...args: TArgs) => TReturn> {
|
|
662
661
|
/** Array of all call records with metadata */
|
|
663
|
-
calls: Array<TrackedCallRecord<TArgs, TReturn>>;
|
|
662
|
+
calls: Array<TrackedCallRecord<TArgs, TReturn, TTimestamp>>;
|
|
664
663
|
/** Get a specific call by index */
|
|
665
|
-
getCall: (index: number) => TrackedCallRecord<TArgs, TReturn> | undefined;
|
|
664
|
+
getCall: (index: number) => TrackedCallRecord<TArgs, TReturn, TTimestamp> | undefined;
|
|
666
665
|
/** Find calls matching a predicate */
|
|
667
666
|
findCalls: (predicate: (call: {
|
|
668
667
|
args: TArgs;
|
|
669
|
-
timestamp:
|
|
670
|
-
}) => boolean) => Array<TrackedCallRecord<TArgs, TReturn>>;
|
|
668
|
+
timestamp: TTimestamp;
|
|
669
|
+
}) => boolean) => Array<TrackedCallRecord<TArgs, TReturn, TTimestamp>>;
|
|
671
670
|
/** Reset all tracked calls */
|
|
672
671
|
resetCalls: () => void;
|
|
673
672
|
}
|
|
@@ -444,7 +444,7 @@ export interface MockTestingModule {
|
|
|
444
444
|
* };
|
|
445
445
|
* ```
|
|
446
446
|
*/
|
|
447
|
-
export type HttpExceptionError = Error & WithStatus & {
|
|
447
|
+
export type HttpExceptionError = Error & WithStatus<number> & {
|
|
448
448
|
/** Error response data */
|
|
449
449
|
response: string | object;
|
|
450
450
|
/** Get HTTP status code */
|
|
@@ -2065,7 +2065,7 @@ export interface ConsoleMockParams {
|
|
|
2065
2065
|
}>;
|
|
2066
2066
|
originalFn: Function;
|
|
2067
2067
|
suppressTypes: string[];
|
|
2068
|
-
formatArguments: (args:
|
|
2068
|
+
formatArguments: (args: readonly unknown[]) => string;
|
|
2069
2069
|
captureStackTrace?: boolean;
|
|
2070
2070
|
}
|
|
2071
2071
|
/**
|
|
@@ -586,7 +586,7 @@ export interface StressTestConfig {
|
|
|
586
586
|
* };
|
|
587
587
|
* ```
|
|
588
588
|
*/
|
|
589
|
-
export interface ProcessWithRetryParams<T> extends WithRetryTracking {
|
|
589
|
+
export interface ProcessWithRetryParams<T = unknown> extends WithRetryTracking {
|
|
590
590
|
/** Operation to process */
|
|
591
591
|
operation: Operation<T>;
|
|
592
592
|
/** Function to process the operation */
|
|
@@ -52,8 +52,8 @@ import type { Provider, Type } from '@nestjs/common';
|
|
|
52
52
|
import type { RenderOptions as RTLRenderOptions, RenderHookOptions as RTLRenderHookOptions } from '@testing-library/react';
|
|
53
53
|
import type { UserEvent as UserEventLib } from '@testing-library/user-event';
|
|
54
54
|
import type { MockEventEmitter, MockNextRouter, MockGetServerSidePropsContext, MockGetStaticPropsContext, MockNextApiResponse, MockNextApiRequest, TestScenario, CreateMockUseRouterReturn, CreateMockWebSocketReturn, CreateMockNextRequestFunction } from '..';
|
|
55
|
-
import type { UnknownRecord, UnknownArray, Promisable, Arrayable } from 'type-fest';
|
|
56
|
-
import type { KeyValueStore, Identifiable, WithUrl, WithHttpMethod, WithHeaders, WithIpAddress, WithQueryParams, WithBody, Named, Clearable, Resettable, Describable, WithImpact, WithElement, WithDuration, IntervalControl, WithTimestamp, WithParams,
|
|
55
|
+
import type { UnknownRecord, UnknownArray, Promisable, Arrayable, SetOptional } from 'type-fest';
|
|
56
|
+
import type { KeyValueStore, Identifiable, WithUrl, WithHttpMethod, HttpMethod, WithHeaders, WithIpAddress, WithQueryParams, WithBody, Named, Clearable, Resettable, Describable, WithImpact, WithElement, WithDuration, IntervalControl, WithTimestamp, WithParams, WithTimeout, WithStatus, WithLocale, WithUserId, WithMessage } from '../../../common';
|
|
57
57
|
/**
|
|
58
58
|
* Subscription information for tracking subscriptions in tests
|
|
59
59
|
*
|
|
@@ -494,7 +494,7 @@ export interface PollingTestOptions {
|
|
|
494
494
|
* ```
|
|
495
495
|
*/
|
|
496
496
|
export interface TestCleanup {
|
|
497
|
-
add: (cleanup: () =>
|
|
497
|
+
add: (cleanup: () => void | Promise<void>) => void;
|
|
498
498
|
runAll: () => Promise<void>;
|
|
499
499
|
clear: () => void;
|
|
500
500
|
}
|
|
@@ -2907,7 +2907,7 @@ export interface ImageLoaderTestScenario {
|
|
|
2907
2907
|
* ```
|
|
2908
2908
|
*/
|
|
2909
2909
|
export interface ParameterizedTest<T> {
|
|
2910
|
-
test: (name: string, fn: (input: T, expected: unknown) =>
|
|
2910
|
+
test: (name: string, fn: (input: T, expected: unknown) => void | Promise<void>) => void;
|
|
2911
2911
|
}
|
|
2912
2912
|
/**
|
|
2913
2913
|
* Test suite for service testing.
|
|
@@ -2940,7 +2940,7 @@ export interface ServiceTestSuite<T> {
|
|
|
2940
2940
|
* ```
|
|
2941
2941
|
*/
|
|
2942
2942
|
export interface NestJSTestSuiteReturn {
|
|
2943
|
-
testProviderRegistration: (providerTokens:
|
|
2943
|
+
testProviderRegistration: (providerTokens: unknown[]) => void;
|
|
2944
2944
|
testProviderInjection: (injectionTests: Array<ProviderInjectionTest>) => void;
|
|
2945
2945
|
}
|
|
2946
2946
|
/**
|
|
@@ -3653,7 +3653,7 @@ export interface SecretsManagementTest extends Named {
|
|
|
3653
3653
|
}
|
|
3654
3654
|
export interface SecretsManager extends KeyValueStore<string, string> {
|
|
3655
3655
|
}
|
|
3656
|
-
export interface MockEnvironment extends KeyValueStore<string, string> {
|
|
3656
|
+
export interface MockEnvironment extends Exclude<KeyValueStore<string, string>, 'delete' | 'has'> {
|
|
3657
3657
|
update: (updates: EnvironmentConfig) => void;
|
|
3658
3658
|
unset: (key: string) => void;
|
|
3659
3659
|
restore: () => void;
|
|
@@ -3723,7 +3723,7 @@ export interface ApiAuthScenario {
|
|
|
3723
3723
|
expectedMessage?: string;
|
|
3724
3724
|
}
|
|
3725
3725
|
export interface ApiRouteOptions extends Partial<WithUrl> {
|
|
3726
|
-
method?:
|
|
3726
|
+
method?: HttpMethod;
|
|
3727
3727
|
headers?: Record<string, Arrayable<string>>;
|
|
3728
3728
|
query?: Record<string, Arrayable<string>>;
|
|
3729
3729
|
body?: unknown;
|
|
@@ -4176,7 +4176,7 @@ export type ModuleMockFactories = Record<string, () => UnknownRecord>;
|
|
|
4176
4176
|
* ```
|
|
4177
4177
|
*/
|
|
4178
4178
|
export interface TestCaseWithSetup<T> extends Named {
|
|
4179
|
-
args:
|
|
4179
|
+
args: unknown[];
|
|
4180
4180
|
expected: unknown;
|
|
4181
4181
|
setup?: (instance: T) => void;
|
|
4182
4182
|
}
|
|
@@ -4219,7 +4219,7 @@ export interface LifecycleHookTestConfig<T> extends Named {
|
|
|
4219
4219
|
*/
|
|
4220
4220
|
export interface ErrorHandlingScenario<T> {
|
|
4221
4221
|
method: keyof T;
|
|
4222
|
-
args:
|
|
4222
|
+
args: unknown[];
|
|
4223
4223
|
expectedError: string | RegExp | typeof Error;
|
|
4224
4224
|
setup?: (instance: T) => void;
|
|
4225
4225
|
}
|
|
@@ -4652,10 +4652,10 @@ export interface CreateMockRedisClientMock {
|
|
|
4652
4652
|
* ```
|
|
4653
4653
|
*/
|
|
4654
4654
|
export interface CallTracker {
|
|
4655
|
-
trackCall: (name: string, args:
|
|
4655
|
+
trackCall: (name: string, args: unknown[]) => void;
|
|
4656
4656
|
getCalls: (name?: string) => Array<{
|
|
4657
4657
|
name: string;
|
|
4658
|
-
args:
|
|
4658
|
+
args: unknown[];
|
|
4659
4659
|
timestamp: number;
|
|
4660
4660
|
}>;
|
|
4661
4661
|
reset: () => void;
|
|
@@ -5179,7 +5179,7 @@ export interface A11yOptions {
|
|
|
5179
5179
|
* Accessibility violation
|
|
5180
5180
|
* @interface A11yViolation
|
|
5181
5181
|
*/
|
|
5182
|
-
export interface A11yViolation extends Identifiable, Describable, Partial<WithImpact> {
|
|
5182
|
+
export interface A11yViolation extends Identifiable, SetOptional<Describable, 'name'>, Partial<WithImpact> {
|
|
5183
5183
|
help: string;
|
|
5184
5184
|
helpUrl: string;
|
|
5185
5185
|
nodes: Array<{
|
|
@@ -5684,7 +5684,7 @@ export interface EnvMock {
|
|
|
5684
5684
|
* Environment snapshot
|
|
5685
5685
|
* @interface EnvSnapshot
|
|
5686
5686
|
*/
|
|
5687
|
-
export interface EnvSnapshot extends
|
|
5687
|
+
export interface EnvSnapshot extends WithTimestamp<number> {
|
|
5688
5688
|
variables: Record<string, string | undefined>;
|
|
5689
5689
|
}
|
|
5690
5690
|
/**
|
|
@@ -62,8 +62,12 @@ export interface CacheStrategyTestConfig extends Named {
|
|
|
62
62
|
* };
|
|
63
63
|
* ```
|
|
64
64
|
*/
|
|
65
|
-
export interface Cache<T = unknown> extends Omit<KeyValueStore<T>, 'set'> {
|
|
65
|
+
export interface Cache<T = unknown> extends Omit<KeyValueStore<string, T>, 'set'> {
|
|
66
66
|
set(key: string, value: T, ttl?: number): Promise<void>;
|
|
67
|
+
size(): Promise<number>;
|
|
68
|
+
keys(): Promise<string[]>;
|
|
69
|
+
values(): Promise<T[]>;
|
|
70
|
+
entries(): Promise<Array<[string, T]>>;
|
|
67
71
|
getStats?(): CacheStats;
|
|
68
72
|
getRaw?(key: string): Promise<CacheEntry<T> | null>;
|
|
69
73
|
onEviction?(callback: (key: string, value: T) => void): void;
|
package/package.json
CHANGED