@plyaz/types 1.7.18 → 1.7.19
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/client/enum.d.ts +12 -0
- package/dist/api/client/index.d.ts +1 -0
- package/dist/api/client/types.d.ts +114 -0
- package/dist/api/config/types.d.ts +58 -10
- package/dist/api/debugger/enums.d.ts +152 -0
- package/dist/api/debugger/factories/index.d.ts +1 -0
- package/dist/api/debugger/factories/types.d.ts +191 -0
- package/dist/api/debugger/index.d.ts +2 -0
- package/dist/api/debugger/types.d.ts +664 -0
- package/dist/api/endpoints/campaigns/index.d.ts +1 -0
- package/dist/api/endpoints/campaigns/types.d.ts +68 -0
- package/dist/api/endpoints/health/index.d.ts +1 -0
- package/dist/api/endpoints/health/types.d.ts +127 -0
- package/dist/api/endpoints/index.d.ts +3 -0
- package/dist/api/endpoints/types.d.ts +5 -0
- package/dist/api/errors/enum.d.ts +182 -0
- package/dist/api/errors/index.d.ts +1 -0
- package/dist/api/errors/types.d.ts +126 -27
- package/dist/api/events/enum.d.ts +261 -0
- package/dist/api/events/factories/cache/index.d.ts +1 -0
- package/dist/api/events/factories/cache/types.d.ts +60 -0
- package/dist/api/events/factories/client/index.d.ts +1 -0
- package/dist/api/events/factories/client/types.d.ts +120 -0
- package/dist/api/events/factories/config/index.d.ts +1 -0
- package/dist/api/events/factories/config/types.d.ts +79 -0
- package/dist/api/events/factories/debug/index.d.ts +1 -0
- package/dist/api/events/factories/debug/types.d.ts +130 -0
- package/dist/api/events/factories/errors/index.d.ts +1 -0
- package/dist/api/events/factories/errors/types.d.ts +293 -0
- package/dist/api/events/factories/headers/index.d.ts +1 -0
- package/dist/api/events/factories/headers/types.d.ts +256 -0
- package/dist/api/events/factories/index.d.ts +9 -0
- package/dist/api/events/factories/network/index.d.ts +1 -0
- package/dist/api/events/factories/network/types.d.ts +196 -0
- package/dist/api/events/factories/performance/index.d.ts +1 -0
- package/dist/api/events/factories/performance/types.d.ts +150 -0
- package/dist/api/events/factories/types.d.ts +84 -0
- package/dist/api/events/index.d.ts +2 -0
- package/dist/api/events/types.d.ts +1 -726
- package/dist/api/headers/enum.d.ts +34 -0
- package/dist/api/headers/index.d.ts +1 -0
- package/dist/api/headers/types.d.ts +456 -0
- package/dist/api/hooks/index.d.ts +1 -0
- package/dist/api/hooks/types.d.ts +131 -0
- package/dist/api/index.d.ts +6 -1
- package/dist/api/network/enums.d.ts +75 -5
- package/dist/api/network/frameworks/index.d.ts +2 -0
- package/dist/api/network/frameworks/nestjs/index.d.ts +1 -0
- package/dist/api/network/frameworks/nestjs/types.d.ts +47 -0
- package/dist/api/network/frameworks/types.d.ts +76 -0
- package/dist/api/network/index.d.ts +1 -0
- package/dist/api/network/types.d.ts +347 -39
- package/dist/api/performance/types.d.ts +17 -10
- package/dist/api/polling/types.d.ts +1 -1
- package/dist/api/pubsub/enum.d.ts +12 -0
- package/dist/api/pubsub/index.d.ts +2 -0
- package/dist/api/pubsub/types.d.ts +61 -0
- package/dist/api/queue/types.d.ts +69 -0
- package/dist/api/regional/enum.d.ts +75 -0
- package/dist/api/regional/index.d.ts +1 -0
- package/dist/api/regional/types.d.ts +2 -1
- package/dist/api/request/index.d.ts +1 -0
- package/dist/api/request/types.d.ts +44 -0
- package/dist/api/retry/types.d.ts +31 -0
- package/dist/api/strategies/types.d.ts +12 -8
- package/dist/errors/index.cjs +69 -0
- package/dist/errors/index.cjs.map +1 -1
- package/dist/errors/index.d.ts +1 -1
- package/dist/errors/index.js +66 -0
- package/dist/errors/index.js.map +1 -1
- package/dist/features/cache/types.d.ts +5 -0
- package/dist/testing/features/api/types.d.ts +355 -4
- package/package.json +5 -3
|
@@ -5,10 +5,80 @@
|
|
|
5
5
|
* Network quality levels enum
|
|
6
6
|
*/
|
|
7
7
|
export declare enum NETWORK_QUALITY {
|
|
8
|
-
EXCELLENT = "excellent",
|
|
9
|
-
GOOD = "good"
|
|
10
|
-
FAIR = "fair"
|
|
11
|
-
POOR = "poor"
|
|
12
|
-
OFFLINE = "offline"
|
|
8
|
+
EXCELLENT = "excellent",// 4G, low latency
|
|
9
|
+
GOOD = "good",// 3G or good 4G
|
|
10
|
+
FAIR = "fair",// 2G or poor 3G
|
|
11
|
+
POOR = "poor",// Slow 2G or worse
|
|
12
|
+
OFFLINE = "offline",// No connection
|
|
13
13
|
UNKNOWN = "unknown"
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Event priority mapping
|
|
17
|
+
*/
|
|
18
|
+
export declare const EVENT_PRIORITY_MAP: {
|
|
19
|
+
readonly error: "critical";
|
|
20
|
+
readonly onNetworkError: "critical";
|
|
21
|
+
readonly critical: "critical";
|
|
22
|
+
readonly config: "high";
|
|
23
|
+
readonly auth: "high";
|
|
24
|
+
readonly conflict: "high";
|
|
25
|
+
readonly network: "normal";
|
|
26
|
+
readonly headers: "normal";
|
|
27
|
+
readonly performance: "normal";
|
|
28
|
+
readonly debug: "low";
|
|
29
|
+
readonly metrics: "low";
|
|
30
|
+
readonly tracking: "low";
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Export preset names for easy access
|
|
34
|
+
*/
|
|
35
|
+
export declare const NetworkPresetNames: {
|
|
36
|
+
readonly OFFLINE_FIRST: "offline-first";
|
|
37
|
+
readonly DATA_SAVER: "data-saver";
|
|
38
|
+
readonly SLOW_CONNECTION: "slow-connection";
|
|
39
|
+
readonly FAIR_CONNECTION: "fair-connection";
|
|
40
|
+
readonly GOOD_CONNECTION: "good-connection";
|
|
41
|
+
readonly EXCELLENT_CONNECTION: "excellent-connection";
|
|
42
|
+
readonly AGGRESSIVE_CACHE: "aggressive-cache";
|
|
43
|
+
readonly REALTIME: "realtime";
|
|
44
|
+
readonly BACKGROUND_SYNC: "background-sync";
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Confidence levels for quality detection
|
|
48
|
+
*/
|
|
49
|
+
export declare const NETWORK_CONFIDENCE_LEVELS: {
|
|
50
|
+
/** Excellent confidence (90%) */
|
|
51
|
+
readonly EXCELLENT: 0.9;
|
|
52
|
+
/** High confidence (80%) */
|
|
53
|
+
readonly HIGH: 0.8;
|
|
54
|
+
/** Medium confidence (70%) */
|
|
55
|
+
readonly MEDIUM: 0.7;
|
|
56
|
+
/** Low confidence (50%) */
|
|
57
|
+
readonly LOW: 0.5;
|
|
58
|
+
/** Threshold for high confidence classification */
|
|
59
|
+
readonly HIGH_THRESHOLD: 0.7;
|
|
60
|
+
/** Threshold for medium confidence classification */
|
|
61
|
+
readonly MEDIUM_THRESHOLD: 0.4;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Network quality thresholds
|
|
65
|
+
*/
|
|
66
|
+
export interface QualityThresholds {
|
|
67
|
+
excellentRTT: number;
|
|
68
|
+
goodRTT: number;
|
|
69
|
+
fairRTT: number;
|
|
70
|
+
excellentSpeed: number;
|
|
71
|
+
goodSpeed: number;
|
|
72
|
+
fairSpeed: number;
|
|
73
|
+
}
|
|
74
|
+
export declare const SPEED_THRESHOLDS: {
|
|
75
|
+
readonly EXCELLENT: 10;
|
|
76
|
+
readonly GOOD: 2;
|
|
77
|
+
readonly FAIR: 0.5;
|
|
78
|
+
};
|
|
79
|
+
export declare const RTT_THRESHOLDS: {
|
|
80
|
+
readonly EXCELLENT: 50;
|
|
81
|
+
readonly GOOD: 150;
|
|
82
|
+
readonly FAIR: 400;
|
|
83
|
+
};
|
|
84
|
+
export declare const DEFAULT_THRESHOLDS: QualityThresholds;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type * from './types';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Request } from 'express';
|
|
2
|
+
import type { NetworkInfo } from '../..';
|
|
3
|
+
import type { EnrichedHeadersOptions } from '../../../headers';
|
|
4
|
+
/**
|
|
5
|
+
* Options for the enriched headers guard
|
|
6
|
+
*/
|
|
7
|
+
export interface EnrichedHeadersGuardOptions extends EnrichedHeadersOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Debug mode - log header processing
|
|
10
|
+
* @default false
|
|
11
|
+
*/
|
|
12
|
+
debug?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Store headers in request object
|
|
15
|
+
* @default true
|
|
16
|
+
*/
|
|
17
|
+
storeInRequest?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Require specific headers to be present
|
|
20
|
+
*/
|
|
21
|
+
requiredHeaders?: string[];
|
|
22
|
+
/**
|
|
23
|
+
* Require specific compliance for access
|
|
24
|
+
*/
|
|
25
|
+
requiredCompliance?: string[];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Options for the enriched headers interceptor
|
|
29
|
+
*/
|
|
30
|
+
export interface EnrichedHeadersInterceptorOptions extends EnrichedHeadersOptions {
|
|
31
|
+
/**
|
|
32
|
+
* Debug mode - log header processing
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
debug?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Store headers in request object
|
|
38
|
+
* @default true
|
|
39
|
+
*/
|
|
40
|
+
storeInRequest?: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Extended request with network info for NestJS
|
|
44
|
+
*/
|
|
45
|
+
export interface NestRequestWithNetwork extends Request {
|
|
46
|
+
networkInfo?: NetworkInfo;
|
|
47
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { NextApiRequest } from 'next';
|
|
2
|
+
import type { NetworkInfo } from '..';
|
|
3
|
+
import type { ApiHeaders, EnrichedHeadersOptions } from '../../headers';
|
|
4
|
+
/**
|
|
5
|
+
* Extended Express request with network info
|
|
6
|
+
*/
|
|
7
|
+
export interface ExpressRequestWithNetwork extends Request {
|
|
8
|
+
networkInfo?: NetworkInfo;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Express middleware factory with options
|
|
12
|
+
*
|
|
13
|
+
* @param options - Middleware options
|
|
14
|
+
* @returns Express middleware
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import express from 'express';
|
|
19
|
+
* import { createNetworkDetectionMiddleware } from '@plyaz/api/utils/network/frameworks/express';
|
|
20
|
+
*
|
|
21
|
+
* const app = express();
|
|
22
|
+
*
|
|
23
|
+
* app.use(createNetworkDetectionMiddleware({
|
|
24
|
+
* requestClientHints: true,
|
|
25
|
+
* onNetworkDetected: (networkInfo) => {
|
|
26
|
+
* console.log('Network detected:', networkInfo);
|
|
27
|
+
* }
|
|
28
|
+
* }));
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export interface NetworkDetectionOptions {
|
|
32
|
+
/**
|
|
33
|
+
* Whether to request Client Hints from browser
|
|
34
|
+
* @default true
|
|
35
|
+
*/
|
|
36
|
+
requestClientHints?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Callback when network is detected
|
|
39
|
+
*/
|
|
40
|
+
onNetworkDetected?: (networkInfo: NetworkInfo) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Custom header name to store network info (for debugging)
|
|
43
|
+
*/
|
|
44
|
+
debugHeaderName?: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Express request with enriched headers
|
|
48
|
+
*/
|
|
49
|
+
export interface ExpressRequestWithEnrichedHeaders extends Request {
|
|
50
|
+
enrichedHeaders?: ApiHeaders;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Options for enriched headers middleware
|
|
54
|
+
*/
|
|
55
|
+
export interface EnrichedHeadersMiddlewareOptions extends EnrichedHeadersOptions {
|
|
56
|
+
/**
|
|
57
|
+
* Store enriched headers in res.locals
|
|
58
|
+
* @default false
|
|
59
|
+
*/
|
|
60
|
+
storeInLocals?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Add specific headers to response
|
|
63
|
+
*/
|
|
64
|
+
addToResponse?: string[];
|
|
65
|
+
/**
|
|
66
|
+
* Debug mode - log header processing
|
|
67
|
+
* @default false
|
|
68
|
+
*/
|
|
69
|
+
debug?: boolean;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Extended Next.js request with network info
|
|
73
|
+
*/
|
|
74
|
+
export interface NextApiRequestWithNetwork extends NextApiRequest {
|
|
75
|
+
networkInfo?: NetworkInfo;
|
|
76
|
+
}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* Network Information API types
|
|
3
3
|
* Properly typed definitions for browser and Node.js navigator
|
|
4
4
|
*/
|
|
5
|
+
import type { NETWORK_QUALITY } from '.';
|
|
6
|
+
import type { ConfigSource, NetworkEvent } from '../events';
|
|
5
7
|
/**
|
|
6
8
|
* Network Information interface (partial for what we use)
|
|
7
9
|
*/
|
|
@@ -17,20 +19,43 @@ export interface NetworkInformation {
|
|
|
17
19
|
}
|
|
18
20
|
/**
|
|
19
21
|
* Navigator-like interface with necessary properties
|
|
20
|
-
* Avoids directly extending Navigator which is experimental in Node
|
|
22
|
+
* Avoids directly extending Navigator which is experimental in Node.js environments
|
|
23
|
+
* Provides cross-platform compatibility for browser and server-side code
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* const nav: NavigatorLike = {
|
|
28
|
+
* userAgent: 'Mozilla/5.0...',
|
|
29
|
+
* platform: 'MacIntel',
|
|
30
|
+
* onLine: true,
|
|
31
|
+
* language: 'en-US'
|
|
32
|
+
* };
|
|
33
|
+
* ```
|
|
21
34
|
*/
|
|
22
35
|
interface NavigatorLike {
|
|
36
|
+
/** Browser user agent string */
|
|
23
37
|
userAgent?: string;
|
|
38
|
+
/** Operating system platform identifier */
|
|
24
39
|
platform?: string;
|
|
40
|
+
/** Browser engine identifier */
|
|
25
41
|
product?: string;
|
|
42
|
+
/** Primary language code (e.g., 'en-US') */
|
|
26
43
|
language?: string;
|
|
44
|
+
/** Array of preferred language codes */
|
|
27
45
|
languages?: readonly string[];
|
|
46
|
+
/** Whether the browser is online */
|
|
28
47
|
onLine?: boolean;
|
|
48
|
+
/** Number of logical processor cores */
|
|
29
49
|
hardwareConcurrency?: number;
|
|
50
|
+
/** Device RAM in gigabytes (from Client Hints) */
|
|
30
51
|
deviceMemory?: number;
|
|
52
|
+
/** Maximum number of simultaneous touch points */
|
|
31
53
|
maxTouchPoints?: number;
|
|
54
|
+
/** Do Not Track header value */
|
|
32
55
|
doNotTrack?: string | null;
|
|
56
|
+
/** Browser vendor identifier */
|
|
33
57
|
vendor?: string;
|
|
58
|
+
/** Browser application version */
|
|
34
59
|
appVersion?: string;
|
|
35
60
|
}
|
|
36
61
|
/**
|
|
@@ -57,65 +82,348 @@ export type ConnectionType = 'slow-2g' | '2g' | '3g' | '4g' | '5g' | 'wifi' | 'e
|
|
|
57
82
|
/**
|
|
58
83
|
* Effective connection type
|
|
59
84
|
*/
|
|
60
|
-
export type EffectiveConnectionType = 'slow-2g' | '2g' | '3g' | '4g';
|
|
85
|
+
export type EffectiveConnectionType = 'slow-2g' | '2g' | '3g' | '4g' | 'unknown';
|
|
61
86
|
/**
|
|
62
|
-
* Network information
|
|
87
|
+
* Network connection information
|
|
63
88
|
*/
|
|
64
89
|
export interface NetworkInfo {
|
|
65
|
-
type
|
|
66
|
-
effectiveType
|
|
67
|
-
downlink
|
|
68
|
-
|
|
90
|
+
type: ConnectionType;
|
|
91
|
+
effectiveType: EffectiveConnectionType;
|
|
92
|
+
downlink: number | null;
|
|
93
|
+
downlinkMax: number | null;
|
|
94
|
+
rtt: number | null;
|
|
95
|
+
saveData: boolean;
|
|
96
|
+
online: boolean;
|
|
97
|
+
deviceMemory?: number | null;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Network status callback
|
|
101
|
+
*/
|
|
102
|
+
export type NetworkStatusCallback = (online: boolean) => void;
|
|
103
|
+
/**
|
|
104
|
+
* Network client hints
|
|
105
|
+
*/
|
|
106
|
+
export interface NetworkClientHints {
|
|
107
|
+
'Save-Data'?: 'on' | null;
|
|
108
|
+
ECT?: EffectiveConnectionType;
|
|
109
|
+
RTT?: string;
|
|
110
|
+
Downlink?: string;
|
|
111
|
+
'Device-Memory'?: 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<TEvent extends NetworkEvent = NetworkEvent> = (event: TEvent) => void;
|
|
121
|
+
/**
|
|
122
|
+
* Adaptive configuration based on network
|
|
123
|
+
*/
|
|
124
|
+
export interface AdaptiveConfig {
|
|
125
|
+
enableHeavyOperations: boolean;
|
|
126
|
+
enableAutoRefresh: boolean;
|
|
127
|
+
enablePreloading: boolean;
|
|
128
|
+
imageQuality: 'high' | 'medium' | 'low';
|
|
129
|
+
videoQuality: 'auto' | '1080p' | '720p' | '480p' | '360p';
|
|
130
|
+
dataFetchStrategy: 'aggressive' | 'balanced' | 'conservative';
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Monitoring configuration for network-based optimization
|
|
134
|
+
*/
|
|
135
|
+
export interface MonitoringConfig {
|
|
136
|
+
networkBasedOptimization: boolean;
|
|
137
|
+
adaptiveQuality: boolean;
|
|
138
|
+
enableMetrics: boolean;
|
|
139
|
+
deviceId: string;
|
|
140
|
+
platform: string;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Network metrics subset
|
|
144
|
+
*/
|
|
145
|
+
export interface NetworkMetrics {
|
|
146
|
+
downlink: number | null;
|
|
147
|
+
downlinkMax: number | null;
|
|
148
|
+
rtt: number | null;
|
|
149
|
+
saveData: boolean;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Network event statistics
|
|
153
|
+
*/
|
|
154
|
+
export interface NetworkEventStats {
|
|
155
|
+
totalEvents: number;
|
|
156
|
+
listenerCount: number;
|
|
157
|
+
recentEvents: NetworkEvent[];
|
|
158
|
+
overrideCount: number;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Partial network info from headers (with null for missing values)
|
|
162
|
+
*/
|
|
163
|
+
export interface PartialNetworkInfoFromHeaders {
|
|
164
|
+
effectiveType: EffectiveConnectionType | null;
|
|
165
|
+
rtt: number | null;
|
|
166
|
+
downlink: number | null;
|
|
167
|
+
saveData: boolean;
|
|
168
|
+
deviceMemory?: number | null;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* HTTP request object with network information
|
|
172
|
+
* Used for server-side network-aware request handling
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```typescript
|
|
176
|
+
* const request: NetworkRequest = {
|
|
177
|
+
* headers: new Headers({ 'User-Agent': '...' }),
|
|
178
|
+
* networkInfo: {
|
|
179
|
+
* effectiveType: '4g',
|
|
180
|
+
* rtt: 50,
|
|
181
|
+
* downlink: 10,
|
|
182
|
+
* saveData: false
|
|
183
|
+
* },
|
|
184
|
+
* networkQuality: NETWORK_QUALITY.GOOD,
|
|
185
|
+
* saveData: false
|
|
186
|
+
* };
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
export interface NetworkRequest {
|
|
190
|
+
/** Request headers (Headers object or plain object) */
|
|
191
|
+
headers?: Headers | Record<string, string | string[] | undefined>;
|
|
192
|
+
/** Network information extracted from headers */
|
|
193
|
+
networkInfo?: PartialNetworkInfoFromHeaders;
|
|
194
|
+
/** Detected network quality level */
|
|
195
|
+
networkQuality?: NETWORK_QUALITY;
|
|
196
|
+
/** Whether data saver mode is enabled */
|
|
69
197
|
saveData?: boolean;
|
|
70
|
-
onLine: boolean;
|
|
71
198
|
}
|
|
72
199
|
/**
|
|
73
|
-
*
|
|
200
|
+
* HTTP response object for setting network-related headers
|
|
201
|
+
* Provides methods to add Client Hints and network metadata to responses
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```typescript
|
|
205
|
+
* const response: NetworkResponse = {
|
|
206
|
+
* setHeader: (key, value) => console.log(`${key}: ${value}`),
|
|
207
|
+
* headers: {
|
|
208
|
+
* set: (key, value) => console.log(`Setting ${key}: ${value}`)
|
|
209
|
+
* }
|
|
210
|
+
* };
|
|
211
|
+
* ```
|
|
74
212
|
*/
|
|
75
|
-
export interface
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
213
|
+
export interface NetworkResponse {
|
|
214
|
+
/** Function to set a single response header */
|
|
215
|
+
setHeader?: (key: string, value: string) => void;
|
|
216
|
+
/** Headers object with set method */
|
|
217
|
+
headers?: {
|
|
218
|
+
set: (key: string, value: string) => void;
|
|
79
219
|
};
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Network quality preset configurations
|
|
223
|
+
* These work alongside existing network utilities without conflicts
|
|
224
|
+
*/
|
|
225
|
+
export interface NetworkQualityPreset {
|
|
226
|
+
/** Preset identifier */
|
|
227
|
+
id: string;
|
|
228
|
+
/** Human-readable name */
|
|
229
|
+
name: string;
|
|
230
|
+
/** Network quality this preset optimizes for */
|
|
231
|
+
targetQuality: NETWORK_QUALITY;
|
|
232
|
+
/** Preset configuration values */
|
|
233
|
+
config: {
|
|
234
|
+
/** Request timeout in milliseconds */
|
|
235
|
+
timeout?: number;
|
|
236
|
+
/** Cache time in seconds */
|
|
237
|
+
cacheTime?: number;
|
|
238
|
+
/** Stale time in seconds */
|
|
239
|
+
staleTime?: number;
|
|
240
|
+
/** Enable request deduplication */
|
|
241
|
+
dedupe?: boolean;
|
|
242
|
+
/** Deduplication time window in milliseconds */
|
|
243
|
+
dedupeTime?: number;
|
|
244
|
+
/** Maximum concurrent requests */
|
|
245
|
+
maxConcurrent?: number;
|
|
246
|
+
/** Request retry configuration */
|
|
247
|
+
retry?: {
|
|
248
|
+
attempts: number;
|
|
249
|
+
delay: number;
|
|
250
|
+
backoff: number;
|
|
251
|
+
maxDelay: number;
|
|
252
|
+
};
|
|
253
|
+
/** Response compression threshold */
|
|
254
|
+
compressionThreshold?: number;
|
|
255
|
+
/** Enable progressive loading */
|
|
256
|
+
progressive?: boolean;
|
|
257
|
+
/** Skip cache for new requests */
|
|
258
|
+
skipCache?: boolean;
|
|
259
|
+
/** Cache error responses */
|
|
260
|
+
cacheErrors?: boolean;
|
|
83
261
|
};
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
262
|
+
/** Conditions when this preset should be automatically applied */
|
|
263
|
+
autoApply?: {
|
|
264
|
+
/** Network qualities that trigger this preset */
|
|
265
|
+
qualities?: NETWORK_QUALITY[];
|
|
266
|
+
/** Save-data mode requirement */
|
|
267
|
+
saveData?: boolean;
|
|
268
|
+
/** Connection types that trigger this preset */
|
|
269
|
+
connectionTypes?: string[];
|
|
270
|
+
/** RTT threshold in milliseconds */
|
|
271
|
+
maxRTT?: number;
|
|
272
|
+
/** Minimum downlink speed in Mbps */
|
|
273
|
+
minDownlink?: number;
|
|
87
274
|
};
|
|
88
275
|
}
|
|
89
276
|
/**
|
|
90
|
-
*
|
|
277
|
+
* User configuration preferences that should be preserved
|
|
91
278
|
*/
|
|
92
|
-
export
|
|
279
|
+
export interface UserNetworkPreferences {
|
|
280
|
+
/** User's preferred quality level (overrides auto-detection) */
|
|
281
|
+
preferredQuality?: NETWORK_QUALITY;
|
|
282
|
+
/** User's timeout preferences */
|
|
283
|
+
timeouts?: {
|
|
284
|
+
minimum?: number;
|
|
285
|
+
maximum?: number;
|
|
286
|
+
default?: number;
|
|
287
|
+
};
|
|
288
|
+
/** User's caching preferences */
|
|
289
|
+
caching?: {
|
|
290
|
+
enabled?: boolean;
|
|
291
|
+
maxAge?: number;
|
|
292
|
+
staleWhileRevalidate?: boolean;
|
|
293
|
+
};
|
|
294
|
+
/** User's retry preferences */
|
|
295
|
+
retry?: {
|
|
296
|
+
maxAttempts?: number;
|
|
297
|
+
aggressive?: boolean;
|
|
298
|
+
};
|
|
299
|
+
/** Features the user has disabled */
|
|
300
|
+
disabledFeatures?: string[];
|
|
301
|
+
/** Custom endpoint-specific overrides */
|
|
302
|
+
endpointOverrides?: Record<string, Partial<NetworkQualityPreset['config']>>;
|
|
303
|
+
}
|
|
93
304
|
/**
|
|
94
|
-
*
|
|
305
|
+
* Temporary override information for debugging and restoration
|
|
95
306
|
*/
|
|
96
|
-
export interface
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
307
|
+
export interface TemporaryOverride {
|
|
308
|
+
/** Property that was overridden */
|
|
309
|
+
property: string;
|
|
310
|
+
/** Original value before override */
|
|
311
|
+
originalValue: unknown;
|
|
312
|
+
/** Override value */
|
|
313
|
+
overrideValue: unknown;
|
|
314
|
+
/** When the override was applied */
|
|
315
|
+
appliedAt: number;
|
|
316
|
+
/** How long the override should last (in milliseconds) */
|
|
317
|
+
duration?: number;
|
|
318
|
+
/** Source configuration that requested the override */
|
|
319
|
+
source: ConfigSource;
|
|
320
|
+
/** Reason for the override */
|
|
321
|
+
reason: string;
|
|
322
|
+
/** Function to restore original value */
|
|
323
|
+
restore: () => void;
|
|
324
|
+
/** Whether override is still active */
|
|
325
|
+
active: boolean;
|
|
326
|
+
/** Context information for debugging */
|
|
327
|
+
context: {
|
|
328
|
+
endpoint?: string;
|
|
329
|
+
clientName?: string;
|
|
330
|
+
configPath?: string;
|
|
331
|
+
};
|
|
103
332
|
}
|
|
104
333
|
/**
|
|
105
|
-
*
|
|
334
|
+
* Extended navigator interface with additional device and platform properties
|
|
335
|
+
* Combines standard navigator properties with device capabilities
|
|
336
|
+
*
|
|
337
|
+
* @example
|
|
338
|
+
* ```typescript
|
|
339
|
+
* const navigator: ExtendedNavigator = {
|
|
340
|
+
* userAgent: window.navigator.userAgent,
|
|
341
|
+
* platform: 'MacIntel',
|
|
342
|
+
* hardwareConcurrency: 8,
|
|
343
|
+
* deviceMemory: 16,
|
|
344
|
+
* onLine: true
|
|
345
|
+
* };
|
|
346
|
+
* ```
|
|
106
347
|
*/
|
|
107
|
-
export interface
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
348
|
+
export interface ExtendedNavigator {
|
|
349
|
+
/** Browser user agent string */
|
|
350
|
+
userAgent?: string;
|
|
351
|
+
/** Operating system platform identifier */
|
|
352
|
+
platform?: string;
|
|
353
|
+
/** Browser engine identifier */
|
|
354
|
+
product?: string;
|
|
355
|
+
/** Primary language code */
|
|
356
|
+
language?: string;
|
|
357
|
+
/** Array of preferred language codes */
|
|
358
|
+
languages?: readonly string[];
|
|
359
|
+
/** Whether the browser is online */
|
|
360
|
+
onLine?: boolean;
|
|
361
|
+
/** Number of logical processor cores */
|
|
362
|
+
hardwareConcurrency?: number;
|
|
363
|
+
/** Device RAM in gigabytes */
|
|
364
|
+
deviceMemory?: number;
|
|
365
|
+
/** Maximum number of simultaneous touch points */
|
|
366
|
+
maxTouchPoints?: number;
|
|
367
|
+
/** Browser vendor identifier */
|
|
368
|
+
vendor?: string;
|
|
369
|
+
/** Browser application version */
|
|
370
|
+
appVersion?: string;
|
|
371
|
+
/** Do Not Track preference */
|
|
372
|
+
doNotTrack?: string | null;
|
|
112
373
|
}
|
|
113
374
|
/**
|
|
114
|
-
*
|
|
375
|
+
* Platform detection results
|
|
115
376
|
*/
|
|
116
|
-
export
|
|
377
|
+
export interface PlatformInfo {
|
|
378
|
+
/** Operating system */
|
|
379
|
+
os: 'windows' | 'macos' | 'linux' | 'ios' | 'android' | 'unknown';
|
|
380
|
+
/** Browser/runtime */
|
|
381
|
+
runtime: 'chrome' | 'firefox' | 'safari' | 'edge' | 'node' | 'electron' | 'unknown';
|
|
382
|
+
/** Device type */
|
|
383
|
+
deviceType: 'desktop' | 'mobile' | 'tablet' | 'unknown';
|
|
384
|
+
/** Is mobile device */
|
|
385
|
+
isMobile: boolean;
|
|
386
|
+
/** Is touch device */
|
|
387
|
+
isTouch: boolean;
|
|
388
|
+
/** Screen size category */
|
|
389
|
+
screenSize: 'small' | 'medium' | 'large' | 'xlarge' | 'unknown';
|
|
390
|
+
}
|
|
117
391
|
/**
|
|
118
|
-
*
|
|
392
|
+
* Application version information
|
|
119
393
|
*/
|
|
120
|
-
export
|
|
394
|
+
export interface AppInfo {
|
|
395
|
+
/** Version number */
|
|
396
|
+
version: string;
|
|
397
|
+
/** Environment (development, production, etc.) */
|
|
398
|
+
environment: string;
|
|
399
|
+
/** Build number or commit hash */
|
|
400
|
+
build?: string;
|
|
401
|
+
/** Feature flags */
|
|
402
|
+
features: string[];
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Device information
|
|
406
|
+
*/
|
|
407
|
+
export interface DeviceInfo {
|
|
408
|
+
/** Unique device identifier */
|
|
409
|
+
id: string;
|
|
410
|
+
/** Platform information */
|
|
411
|
+
platform: PlatformInfo;
|
|
412
|
+
/** Screen information */
|
|
413
|
+
screen: {
|
|
414
|
+
width: number;
|
|
415
|
+
height: number;
|
|
416
|
+
colorDepth: number;
|
|
417
|
+
pixelRatio: number;
|
|
418
|
+
};
|
|
419
|
+
/** Memory in GB (if available) */
|
|
420
|
+
memory?: number;
|
|
421
|
+
/** CPU cores (if available) */
|
|
422
|
+
cores?: number;
|
|
423
|
+
/** Timezone information */
|
|
424
|
+
timezone: {
|
|
425
|
+
name: string;
|
|
426
|
+
offset: number;
|
|
427
|
+
};
|
|
428
|
+
}
|
|
121
429
|
export {};
|