@plyaz/types 1.7.16 → 1.7.18
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/api/cache/index.d.ts +5 -0
- package/dist/api/cache/types.d.ts +22 -0
- package/dist/api/client/index.d.ts +5 -0
- package/dist/api/client/types.d.ts +31 -0
- package/dist/api/config/index.d.ts +5 -0
- package/dist/api/config/types.d.ts +634 -0
- package/dist/api/errors/index.d.ts +5 -0
- package/dist/api/errors/types.d.ts +129 -0
- package/dist/api/events/index.d.ts +5 -0
- package/dist/api/events/types.d.ts +795 -0
- package/dist/api/headers/index.d.ts +5 -0
- package/dist/api/headers/types.d.ts +59 -0
- package/dist/api/index.d.ts +19 -1
- package/dist/api/network/enums.d.ts +14 -0
- package/dist/api/network/index.d.ts +6 -0
- package/dist/api/network/types.d.ts +121 -0
- package/dist/api/performance/index.d.ts +5 -0
- package/dist/api/performance/types.d.ts +137 -0
- package/dist/api/polling/index.d.ts +5 -0
- package/dist/api/polling/types.d.ts +74 -0
- package/dist/api/queue/enums.d.ts +31 -0
- package/dist/api/queue/index.d.ts +6 -0
- package/dist/api/queue/types.d.ts +65 -0
- package/dist/api/regional/index.d.ts +5 -0
- package/dist/api/regional/types.d.ts +50 -0
- package/dist/api/retry/index.d.ts +5 -0
- package/dist/api/retry/types.d.ts +26 -0
- package/dist/api/revalidation/index.d.ts +5 -0
- package/dist/api/revalidation/types.d.ts +33 -0
- package/dist/api/strategies/index.d.ts +5 -0
- package/dist/api/strategies/types.d.ts +27 -0
- package/dist/api/utils/enums.d.ts +23 -0
- package/dist/api/utils/index.d.ts +5 -0
- package/dist/auth/index.cjs +0 -41
- package/dist/auth/index.cjs.map +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.js +0 -38
- package/dist/auth/index.js.map +1 -1
- package/dist/common/types.d.ts +1 -4
- package/dist/errors/enums.d.ts +27 -0
- package/dist/errors/index.cjs +0 -43
- package/dist/errors/index.cjs.map +1 -1
- package/dist/errors/index.d.ts +1 -1
- package/dist/errors/index.js +0 -40
- package/dist/errors/index.js.map +1 -1
- package/dist/events/index.cjs +0 -33
- package/dist/events/index.cjs.map +1 -1
- package/dist/events/index.d.ts +1 -1
- package/dist/events/index.js +0 -30
- package/dist/events/index.js.map +1 -1
- package/dist/events/types.d.ts +2 -2
- package/dist/index.cjs +0 -138
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +0 -128
- package/dist/index.js.map +1 -1
- package/dist/testing/common/utils/types.d.ts +2 -1
- package/dist/testing/features/api/types.d.ts +173 -21
- package/dist/web3/index.cjs +0 -27
- package/dist/web3/index.cjs.map +1 -1
- package/dist/web3/index.d.ts +1 -1
- package/dist/web3/index.js +0 -26
- package/dist/web3/index.js.map +1 -1
- package/package.json +3 -2
- package/dist/api/types.d.ts +0 -51
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Header Management Type Definitions
|
|
3
|
+
* Comprehensive types for HTTP headers, following TASK-016 specification
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Headers that affect cache key generation (based on fetchff behavior)
|
|
7
|
+
* These headers will be included in cache key computation
|
|
8
|
+
*/
|
|
9
|
+
export interface CacheAffectingHeaders {
|
|
10
|
+
accept?: string;
|
|
11
|
+
'accept-language'?: string;
|
|
12
|
+
'accept-encoding'?: string;
|
|
13
|
+
authorization?: string;
|
|
14
|
+
'x-api-key'?: string;
|
|
15
|
+
cookie?: string;
|
|
16
|
+
'content-type'?: string;
|
|
17
|
+
origin?: string;
|
|
18
|
+
referer?: string;
|
|
19
|
+
'user-agent'?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Common custom headers for API requests
|
|
23
|
+
*/
|
|
24
|
+
export interface CustomHeaders {
|
|
25
|
+
'x-requested-with'?: string;
|
|
26
|
+
'x-client-id'?: string;
|
|
27
|
+
'x-tenant-id'?: string;
|
|
28
|
+
'x-user-id'?: string;
|
|
29
|
+
'x-app-version'?: string;
|
|
30
|
+
'x-feature-flag'?: string;
|
|
31
|
+
'x-device-id'?: string;
|
|
32
|
+
'x-platform'?: 'ios' | 'android' | 'web' | string;
|
|
33
|
+
'x-session-id'?: string;
|
|
34
|
+
'x-locale'?: string;
|
|
35
|
+
'x-correlation-id'?: string;
|
|
36
|
+
'x-request-id'?: string;
|
|
37
|
+
'x-trace-id'?: string;
|
|
38
|
+
'x-span-id'?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* All supported headers - combines cache-affecting, custom, and allows additional headers
|
|
42
|
+
*/
|
|
43
|
+
export type ApiHeaders = CacheAffectingHeaders & CustomHeaders & Record<string, string>;
|
|
44
|
+
/**
|
|
45
|
+
* Content types for common API scenarios
|
|
46
|
+
*/
|
|
47
|
+
export type ContentType = 'json' | 'form' | 'multipart' | 'xml' | 'html' | 'text' | string;
|
|
48
|
+
/**
|
|
49
|
+
* Accept types for API responses
|
|
50
|
+
*/
|
|
51
|
+
export type AcceptType = 'json' | 'xml' | 'html' | 'text' | 'stream' | string;
|
|
52
|
+
/**
|
|
53
|
+
* Authentication schemes
|
|
54
|
+
*/
|
|
55
|
+
export type AuthType = 'Bearer' | 'Basic' | 'ApiKey' | 'Custom';
|
|
56
|
+
/**
|
|
57
|
+
* Platform types for client identification
|
|
58
|
+
*/
|
|
59
|
+
export type PlatformType = 'ios' | 'android' | 'web' | 'desktop' | 'mobile' | string;
|
package/dist/api/index.d.ts
CHANGED
|
@@ -1 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* API Package Types
|
|
3
|
+
* Re-exports all API-related types (events, errors, etc.)
|
|
4
|
+
*/
|
|
5
|
+
export type * from './events';
|
|
6
|
+
export type * from './errors';
|
|
7
|
+
export type * from './queue';
|
|
8
|
+
export type * from './headers';
|
|
9
|
+
export type * from './network';
|
|
10
|
+
export type * from './regional';
|
|
11
|
+
export type * from './cache';
|
|
12
|
+
export type * from './retry';
|
|
13
|
+
export type * from './polling';
|
|
14
|
+
export type * from './revalidation';
|
|
15
|
+
export type * from './strategies';
|
|
16
|
+
export type * from './client';
|
|
17
|
+
export type * from './performance';
|
|
18
|
+
export type * from './config';
|
|
19
|
+
export type * from './utils';
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Network Information API types
|
|
3
|
+
* Properly typed definitions for browser and Node.js navigator
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Network Information interface (partial for what we use)
|
|
7
|
+
*/
|
|
8
|
+
export interface NetworkInformation {
|
|
9
|
+
type?: string;
|
|
10
|
+
effectiveType?: string;
|
|
11
|
+
downlink?: number;
|
|
12
|
+
downlinkMax?: number;
|
|
13
|
+
rtt?: number;
|
|
14
|
+
saveData?: boolean;
|
|
15
|
+
addEventListener?: (type: string, listener: EventListener) => void;
|
|
16
|
+
removeEventListener?: (type: string, listener: EventListener) => void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Navigator-like interface with necessary properties
|
|
20
|
+
* Avoids directly extending Navigator which is experimental in Node
|
|
21
|
+
*/
|
|
22
|
+
interface NavigatorLike {
|
|
23
|
+
userAgent?: string;
|
|
24
|
+
platform?: string;
|
|
25
|
+
product?: string;
|
|
26
|
+
language?: string;
|
|
27
|
+
languages?: readonly string[];
|
|
28
|
+
onLine?: boolean;
|
|
29
|
+
hardwareConcurrency?: number;
|
|
30
|
+
deviceMemory?: number;
|
|
31
|
+
maxTouchPoints?: number;
|
|
32
|
+
doNotTrack?: string | null;
|
|
33
|
+
vendor?: string;
|
|
34
|
+
appVersion?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Extended Navigator interface with Network Information API
|
|
38
|
+
* Extends our Navigator-like interface with network connection properties
|
|
39
|
+
*/
|
|
40
|
+
export interface NavigatorWithConnection extends NavigatorLike {
|
|
41
|
+
onLine?: boolean;
|
|
42
|
+
connection?: NetworkInformation;
|
|
43
|
+
mozConnection?: NetworkInformation;
|
|
44
|
+
webkitConnection?: NetworkInformation;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Global object with navigator property
|
|
48
|
+
*/
|
|
49
|
+
export interface GlobalWithNavigator {
|
|
50
|
+
navigator: NavigatorWithConnection;
|
|
51
|
+
[key: string]: unknown;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Connection types for adaptive behavior
|
|
55
|
+
*/
|
|
56
|
+
export type ConnectionType = 'slow-2g' | '2g' | '3g' | '4g' | '5g' | 'wifi' | 'ethernet' | 'unknown';
|
|
57
|
+
/**
|
|
58
|
+
* Effective connection type
|
|
59
|
+
*/
|
|
60
|
+
export type EffectiveConnectionType = 'slow-2g' | '2g' | '3g' | '4g';
|
|
61
|
+
/**
|
|
62
|
+
* Network information details
|
|
63
|
+
*/
|
|
64
|
+
export interface NetworkInfo {
|
|
65
|
+
type?: ConnectionType;
|
|
66
|
+
effectiveType?: EffectiveConnectionType;
|
|
67
|
+
downlink?: number;
|
|
68
|
+
rtt?: number;
|
|
69
|
+
saveData?: boolean;
|
|
70
|
+
onLine: boolean;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Quality thresholds for network assessment
|
|
74
|
+
*/
|
|
75
|
+
export interface QualityThresholds {
|
|
76
|
+
good?: {
|
|
77
|
+
rtt?: number;
|
|
78
|
+
downlink?: number;
|
|
79
|
+
};
|
|
80
|
+
fair?: {
|
|
81
|
+
rtt?: number;
|
|
82
|
+
downlink?: number;
|
|
83
|
+
};
|
|
84
|
+
poor?: {
|
|
85
|
+
rtt?: number;
|
|
86
|
+
downlink?: number;
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Network status callback
|
|
91
|
+
*/
|
|
92
|
+
export type NetworkStatusCallback = (online: boolean) => void;
|
|
93
|
+
/**
|
|
94
|
+
* Adaptive configuration based on network
|
|
95
|
+
*/
|
|
96
|
+
export interface AdaptiveConfig {
|
|
97
|
+
timeout?: number;
|
|
98
|
+
retry?: number;
|
|
99
|
+
prefetch?: boolean;
|
|
100
|
+
autoRefresh?: boolean;
|
|
101
|
+
batchSize?: number;
|
|
102
|
+
pageSize?: number;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Network client hints
|
|
106
|
+
*/
|
|
107
|
+
export interface NetworkClientHints {
|
|
108
|
+
downlink?: string;
|
|
109
|
+
rtt?: string;
|
|
110
|
+
ect?: string;
|
|
111
|
+
saveData?: string;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Network preset names
|
|
115
|
+
*/
|
|
116
|
+
export type NetworkPresetName = 'fast' | 'good' | 'moderate' | 'slow' | 'offline';
|
|
117
|
+
/**
|
|
118
|
+
* Network event listener
|
|
119
|
+
*/
|
|
120
|
+
export type NetworkEventListener = (event: Event) => void;
|
|
121
|
+
export {};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Performance Optimization Types
|
|
3
|
+
* Types for performance configuration and monitoring
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Performance preset names for optimized configurations
|
|
7
|
+
*/
|
|
8
|
+
export type PerformancePresetName = 'minimal' | 'balanced' | 'aggressive' | 'realtime' | 'offline' | 'mobile' | 'desktop';
|
|
9
|
+
/**
|
|
10
|
+
* Helper type for performance configuration in API client options
|
|
11
|
+
* Allows string preset names, full config objects, or false to disable
|
|
12
|
+
*/
|
|
13
|
+
export type PerformanceOption = PerformancePresetName | PerformanceConfig | false;
|
|
14
|
+
/**
|
|
15
|
+
* Performance metrics for monitoring
|
|
16
|
+
*/
|
|
17
|
+
export interface ApiPerformanceMetrics {
|
|
18
|
+
requestCount: number;
|
|
19
|
+
cacheHits: number;
|
|
20
|
+
cacheMisses: number;
|
|
21
|
+
averageResponseTime: number;
|
|
22
|
+
errorRate: number;
|
|
23
|
+
dedupeCount: number;
|
|
24
|
+
cacheHitRate?: number;
|
|
25
|
+
networkRequests: number;
|
|
26
|
+
cancelledRequests: number;
|
|
27
|
+
retriedRequests: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Data pattern types for optimization
|
|
31
|
+
*/
|
|
32
|
+
export type DataPatternType = 'static' | 'user' | 'list' | 'realtime' | 'mutations' | 'media' | 'analytics';
|
|
33
|
+
/**
|
|
34
|
+
* Performance configuration with API config properties
|
|
35
|
+
* Represents a configuration object that can have any ApiConfig properties
|
|
36
|
+
* plus additional performance-specific options
|
|
37
|
+
*/
|
|
38
|
+
export interface PerformanceConfig {
|
|
39
|
+
enableMetrics?: boolean;
|
|
40
|
+
enableAdaptive?: boolean;
|
|
41
|
+
enableProgressive?: boolean;
|
|
42
|
+
maxCacheSize?: number;
|
|
43
|
+
compressionThreshold?: number;
|
|
44
|
+
cacheTime?: number;
|
|
45
|
+
staleTime?: number;
|
|
46
|
+
dedupeTime?: number;
|
|
47
|
+
strategy?: string;
|
|
48
|
+
retry?: unknown;
|
|
49
|
+
cancellable?: boolean;
|
|
50
|
+
skipCache?: boolean;
|
|
51
|
+
cacheErrors?: boolean;
|
|
52
|
+
refetchOnFocus?: boolean;
|
|
53
|
+
refetchOnReconnect?: boolean;
|
|
54
|
+
immediate?: boolean;
|
|
55
|
+
timeout?: number;
|
|
56
|
+
flattenResponse?: boolean;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Performance optimization options
|
|
60
|
+
*/
|
|
61
|
+
export interface PerformanceOptions {
|
|
62
|
+
preset?: PerformancePresetName;
|
|
63
|
+
dataPattern?: DataPatternType;
|
|
64
|
+
adaptive?: boolean;
|
|
65
|
+
monitoring?: boolean;
|
|
66
|
+
progressive?: boolean;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Bundle size optimization levels
|
|
70
|
+
*/
|
|
71
|
+
export type BundleSizeLevel = 'minimal' | 'standard' | 'full';
|
|
72
|
+
/**
|
|
73
|
+
* Performance timing information
|
|
74
|
+
*/
|
|
75
|
+
export interface PerformanceTiming {
|
|
76
|
+
startTime: number;
|
|
77
|
+
dnsLookup?: number;
|
|
78
|
+
tcpConnection?: number;
|
|
79
|
+
tlsHandshake?: number;
|
|
80
|
+
requestSent?: number;
|
|
81
|
+
responseReceived?: number;
|
|
82
|
+
responseProcessed?: number;
|
|
83
|
+
totalDuration: number;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Request performance data
|
|
87
|
+
*/
|
|
88
|
+
export interface RequestPerformance {
|
|
89
|
+
url: string;
|
|
90
|
+
method: string;
|
|
91
|
+
timing: PerformanceTiming;
|
|
92
|
+
fromCache: boolean;
|
|
93
|
+
wasDeduplicated: boolean;
|
|
94
|
+
wasRetried: boolean;
|
|
95
|
+
retryCount?: number;
|
|
96
|
+
error?: Error;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Extended Request Config for Performance Monitoring
|
|
100
|
+
* Adds performance tracking fields to the base RequestConfig
|
|
101
|
+
*/
|
|
102
|
+
export interface PerformanceRequestConfig {
|
|
103
|
+
__perfMonitorId?: string;
|
|
104
|
+
fromCache?: boolean;
|
|
105
|
+
[key: string]: unknown;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Extended Fetch Response for Performance Monitoring
|
|
109
|
+
* Adds performance tracking fields to the base FetchResponse
|
|
110
|
+
*/
|
|
111
|
+
export interface PerformanceFetchResponse {
|
|
112
|
+
fromCache?: boolean;
|
|
113
|
+
deduplicated?: boolean;
|
|
114
|
+
retried?: boolean;
|
|
115
|
+
retryCount?: number;
|
|
116
|
+
config: PerformanceRequestConfig;
|
|
117
|
+
[key: string]: unknown;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Extended Response Error for Performance Monitoring
|
|
121
|
+
*/
|
|
122
|
+
export interface PerformanceResponseError {
|
|
123
|
+
config: PerformanceRequestConfig;
|
|
124
|
+
code?: string;
|
|
125
|
+
status: number;
|
|
126
|
+
statusText: string;
|
|
127
|
+
isCancelled: boolean;
|
|
128
|
+
request: PerformanceRequestConfig;
|
|
129
|
+
response: PerformanceFetchResponse | null;
|
|
130
|
+
[key: string]: unknown;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Type guards for performance monitoring
|
|
134
|
+
*/
|
|
135
|
+
export declare function isPerformanceRequestConfig(config: unknown): config is PerformanceRequestConfig;
|
|
136
|
+
export declare function isPerformanceFetchResponse(response: unknown): response is PerformanceFetchResponse;
|
|
137
|
+
export declare function isPerformanceResponseError(error: unknown): error is PerformanceResponseError;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Polling Configuration Types
|
|
3
|
+
* Provides type definitions for polling functionality
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Polling configuration for repeated requests
|
|
7
|
+
* Uses generic types to work with any response data
|
|
8
|
+
*/
|
|
9
|
+
export interface PollingConfig<T = unknown> {
|
|
10
|
+
/**
|
|
11
|
+
* Interval in milliseconds between polling attempts
|
|
12
|
+
* Set to 0 to disable polling
|
|
13
|
+
* @default 0
|
|
14
|
+
*/
|
|
15
|
+
interval?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Delay in milliseconds before each polling attempt begins
|
|
18
|
+
* Useful for throttling or staggering requests
|
|
19
|
+
* @default 0
|
|
20
|
+
*/
|
|
21
|
+
delay?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Maximum number of polling attempts before stopping
|
|
24
|
+
* Set to 0 or negative for unlimited attempts
|
|
25
|
+
* @default 0 (unlimited)
|
|
26
|
+
*/
|
|
27
|
+
maxAttempts?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Function to determine if polling should stop
|
|
30
|
+
* Return true to stop, false to continue
|
|
31
|
+
*/
|
|
32
|
+
shouldStop?: (response: T) => boolean | Promise<boolean>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Result of a polling operation
|
|
36
|
+
*/
|
|
37
|
+
export interface PollingResult<T> {
|
|
38
|
+
/** The final data received */
|
|
39
|
+
data: T;
|
|
40
|
+
/** Total number of attempts made */
|
|
41
|
+
attempts: number;
|
|
42
|
+
/** Total duration in milliseconds */
|
|
43
|
+
duration: number;
|
|
44
|
+
/** Whether polling was stopped */
|
|
45
|
+
stopped: boolean;
|
|
46
|
+
/** Reason for stopping */
|
|
47
|
+
reason?: 'condition' | 'max-attempts' | 'error' | 'cancelled';
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Options for progressive polling
|
|
51
|
+
*/
|
|
52
|
+
export interface ProgressivePollingOptions {
|
|
53
|
+
/** Base interval in milliseconds */
|
|
54
|
+
baseInterval?: number;
|
|
55
|
+
/** Maximum interval in milliseconds */
|
|
56
|
+
maxInterval?: number;
|
|
57
|
+
/** Multiplier for interval increase */
|
|
58
|
+
multiplier?: number;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Options for conditional polling
|
|
62
|
+
*/
|
|
63
|
+
export interface ConditionalPollingOptions<T = unknown> {
|
|
64
|
+
/** Function to check if polling succeeded */
|
|
65
|
+
successCondition?: (response: T) => boolean;
|
|
66
|
+
/** Function to check if polling should error */
|
|
67
|
+
errorCondition?: (response: T) => boolean;
|
|
68
|
+
/** Maximum time to poll in milliseconds */
|
|
69
|
+
timeoutMs?: number;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Polling strategy names
|
|
73
|
+
*/
|
|
74
|
+
export type PollingStrategyName = 'jobStatus' | 'healthCheck' | 'liveData' | 'longProcess' | 'resourceWait';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Queue System Enums
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Priority levels for queue operations
|
|
6
|
+
* @description Defines the priority order for queued operations, from highest (CRITICAL) to lowest (IDLE)
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { PRIORITY_LEVEL } from '@plyaz/types';
|
|
11
|
+
*
|
|
12
|
+
* const priority = PRIORITY_LEVEL.HIGH; // 1
|
|
13
|
+
* if (priority <= PRIORITY_LEVEL.HIGH) {
|
|
14
|
+
* // Handle high-priority request
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare const PRIORITY_LEVEL: {
|
|
19
|
+
/** Critical priority - highest urgency (0) */
|
|
20
|
+
readonly CRITICAL: 0;
|
|
21
|
+
/** High priority (1) */
|
|
22
|
+
readonly HIGH: 1;
|
|
23
|
+
/** Medium priority (2) */
|
|
24
|
+
readonly MEDIUM: 2;
|
|
25
|
+
/** Normal priority (3) */
|
|
26
|
+
readonly NORMAL: 3;
|
|
27
|
+
/** Low priority (4) */
|
|
28
|
+
readonly LOW: 4;
|
|
29
|
+
/** Idle priority - lowest urgency (5) */
|
|
30
|
+
readonly IDLE: 5;
|
|
31
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Queue System Type Definitions
|
|
3
|
+
*/
|
|
4
|
+
import type { PRIORITY_LEVEL } from './enums';
|
|
5
|
+
/**
|
|
6
|
+
* Processing strategy for queue operations
|
|
7
|
+
*/
|
|
8
|
+
export type ProcessingStrategy = 'immediate' | 'batch' | 'throttle' | 'debounce';
|
|
9
|
+
/**
|
|
10
|
+
* Base queue operation interface
|
|
11
|
+
*/
|
|
12
|
+
export interface QueueOperation<T = unknown> {
|
|
13
|
+
id: string;
|
|
14
|
+
timestamp: number;
|
|
15
|
+
priority?: typeof PRIORITY_LEVEL;
|
|
16
|
+
data: T;
|
|
17
|
+
metadata?: Record<string, unknown>;
|
|
18
|
+
retryCount?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Queue configuration
|
|
22
|
+
*/
|
|
23
|
+
export interface QueueConfig {
|
|
24
|
+
/** Queue name for identification */
|
|
25
|
+
name: string;
|
|
26
|
+
/** Maximum queue size (prevent memory leaks) */
|
|
27
|
+
maxSize?: number;
|
|
28
|
+
/** Processing strategy */
|
|
29
|
+
strategy?: ProcessingStrategy;
|
|
30
|
+
/** Batch size for batch processing */
|
|
31
|
+
batchSize?: number;
|
|
32
|
+
/** Processing interval in ms */
|
|
33
|
+
processingInterval?: number;
|
|
34
|
+
/** Enable priority queue */
|
|
35
|
+
enablePriority?: boolean;
|
|
36
|
+
/** Enable performance tracking */
|
|
37
|
+
enableMetrics?: boolean;
|
|
38
|
+
/** Throttle rate in operations per second */
|
|
39
|
+
throttleRate?: number;
|
|
40
|
+
/** Debounce delay in ms */
|
|
41
|
+
debounceDelay?: number;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Queue statistics
|
|
45
|
+
*/
|
|
46
|
+
export interface QueueStats {
|
|
47
|
+
name: string;
|
|
48
|
+
size: number;
|
|
49
|
+
processed: number;
|
|
50
|
+
failed: number;
|
|
51
|
+
avgProcessingTime: number;
|
|
52
|
+
throughput: number;
|
|
53
|
+
isReady: boolean;
|
|
54
|
+
strategy: ProcessingStrategy;
|
|
55
|
+
totalEnqueued: number;
|
|
56
|
+
totalProcessed: number;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Queue processor function
|
|
60
|
+
*/
|
|
61
|
+
export type QueueProcessor<T> = (operation: QueueOperation<T>) => void | Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Batch processor function
|
|
64
|
+
*/
|
|
65
|
+
export type BatchQueueProcessor<T> = (operations: QueueOperation<T>[]) => void | Promise<void>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Regional detection and compliance types
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Regional information with compliance data
|
|
6
|
+
*/
|
|
7
|
+
export interface RegionInfo {
|
|
8
|
+
region: string;
|
|
9
|
+
country?: string;
|
|
10
|
+
state?: string;
|
|
11
|
+
city?: string;
|
|
12
|
+
confidence: number;
|
|
13
|
+
source?: 'timezone' | 'locale' | 'cdn-header' | 'geolocation' | 'fallback' | 'config' | 'cached';
|
|
14
|
+
restrictions?: RegionalCompliance;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Regional compliance configuration
|
|
18
|
+
*/
|
|
19
|
+
export interface RegionalCompliance {
|
|
20
|
+
code: string;
|
|
21
|
+
regulations: string[];
|
|
22
|
+
requirements: Record<string, boolean>;
|
|
23
|
+
allowedHeaders?: string[] | 'all';
|
|
24
|
+
blockedHeaders?: string[];
|
|
25
|
+
additionalHeaders?: Record<string, string>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Cache configuration for regional detection
|
|
29
|
+
*/
|
|
30
|
+
export interface RegionalCacheConfig {
|
|
31
|
+
enabled?: boolean;
|
|
32
|
+
ttl?: number;
|
|
33
|
+
storage?: 'memory' | 'session' | 'local';
|
|
34
|
+
key?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Detection options
|
|
38
|
+
*/
|
|
39
|
+
export interface RegionDetectionOptions {
|
|
40
|
+
useCachedValue?: boolean;
|
|
41
|
+
useTimezone?: boolean;
|
|
42
|
+
useLocale?: boolean;
|
|
43
|
+
useCDNHeaders?: boolean;
|
|
44
|
+
useIPDetection?: boolean;
|
|
45
|
+
useGeolocation?: boolean;
|
|
46
|
+
headers?: Record<string, unknown>;
|
|
47
|
+
cacheExpiry?: number;
|
|
48
|
+
fallbackRegion?: string;
|
|
49
|
+
cache?: RegionalCacheConfig;
|
|
50
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retry Configuration Types
|
|
3
|
+
* Defines retry mechanism configuration options
|
|
4
|
+
*
|
|
5
|
+
* @module retry/types
|
|
6
|
+
*/
|
|
7
|
+
import type { RetryConfig as FetchffRetryConfig } from 'fetchff';
|
|
8
|
+
/**
|
|
9
|
+
* Retry configuration options
|
|
10
|
+
* Maps to fetchff's retry mechanism
|
|
11
|
+
*/
|
|
12
|
+
export interface RetryConfig extends Partial<FetchffRetryConfig> {
|
|
13
|
+
/**
|
|
14
|
+
* Number of retry attempts (default: 0)
|
|
15
|
+
* Set to 0 to disable retries
|
|
16
|
+
*/
|
|
17
|
+
attempts?: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Retry strategy names for type-safe access
|
|
21
|
+
*/
|
|
22
|
+
export type RetryStrategyName = 'none' | 'conservative' | 'standard' | 'aggressive' | 'exponential' | 'linear' | 'apiRate';
|
|
23
|
+
/**
|
|
24
|
+
* Helper type for retry configuration in API client options
|
|
25
|
+
*/
|
|
26
|
+
export type RetryOption = RetryStrategyName | RetryConfig | false;
|