@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
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event Namespace Constants
|
|
3
|
+
* Centralized constants for all event namespaces in the API package
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Main event namespaces for the API package
|
|
7
|
+
*/
|
|
8
|
+
export declare const EVENT_NAMESPACES: {
|
|
9
|
+
readonly HEADERS: "headers";
|
|
10
|
+
readonly NETWORK: "network";
|
|
11
|
+
readonly ERRORS: "errors";
|
|
12
|
+
readonly DEBUG: "debug";
|
|
13
|
+
readonly CONFIG: "config";
|
|
14
|
+
readonly PERFORMANCE: "performance";
|
|
15
|
+
readonly CLIENT: "client";
|
|
16
|
+
readonly CACHE: "cache";
|
|
17
|
+
readonly POLLING: "polling";
|
|
18
|
+
readonly REQUEST: "request";
|
|
19
|
+
readonly REVALIDATION: "revalidation";
|
|
20
|
+
readonly EVENT_MANAGER: "eventManager";
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Header-specific event keys
|
|
24
|
+
*/
|
|
25
|
+
export declare const HEADER_EVENTS: {
|
|
26
|
+
readonly CHANGED: "headers:changed";
|
|
27
|
+
readonly ENRICHED: "headers:enriched";
|
|
28
|
+
readonly CONFLICT: "headers:conflict";
|
|
29
|
+
readonly OVERRIDE: "headers:override";
|
|
30
|
+
readonly TRACKED: "headers:tracked";
|
|
31
|
+
readonly MERGED: "headers:merged";
|
|
32
|
+
readonly FILTERED: "headers:filtered";
|
|
33
|
+
readonly VALIDATED: "headers:validated";
|
|
34
|
+
readonly CACHED: "headers:cached";
|
|
35
|
+
readonly CACHE_HIT: "headers:cache:hit";
|
|
36
|
+
readonly CACHE_MISS: "headers:cache:miss";
|
|
37
|
+
readonly ANY: "headers:*";
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Network-specific event keys
|
|
41
|
+
*/
|
|
42
|
+
export declare const NETWORK_EVENTS: {
|
|
43
|
+
readonly QUALITY_CHANGE: "network:quality:changed";
|
|
44
|
+
readonly INFO_UPDATE: "network:info-update";
|
|
45
|
+
readonly CONFIG_OVERRIDE: "network:config:override";
|
|
46
|
+
readonly CONFIG_RESTORED: "network:config:restored";
|
|
47
|
+
readonly OVERRIDE_CHANGE: "network:override-change";
|
|
48
|
+
readonly PRESET_APPLIED: "network:preset-applied";
|
|
49
|
+
readonly PRESET_CHANGED: "network:preset:changed";
|
|
50
|
+
readonly HINTS_UPDATED: "network:hints:updated";
|
|
51
|
+
readonly AUTO_DETECTION: "network:auto:detection";
|
|
52
|
+
readonly MANUAL_UPDATE: "network:manual:update";
|
|
53
|
+
readonly ANY: "network:*";
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Error-specific event keys
|
|
57
|
+
*/
|
|
58
|
+
export declare const ERROR_EVENTS: {
|
|
59
|
+
readonly NETWORK_ERROR: "errors:network";
|
|
60
|
+
readonly VALIDATION_ERROR: "errors:validation";
|
|
61
|
+
readonly AUTHENTICATION_ERROR: "errors:authentication";
|
|
62
|
+
readonly AUTHORIZATION_ERROR: "errors:authorization";
|
|
63
|
+
readonly RATE_LIMIT_ERROR: "errors:rate-limit";
|
|
64
|
+
readonly SERVER_ERROR: "errors:server";
|
|
65
|
+
readonly CLIENT_ERROR: "errors:client";
|
|
66
|
+
readonly TIMEOUT_ERROR: "errors:timeout";
|
|
67
|
+
readonly CONFLICT_ERROR: "errors:conflict";
|
|
68
|
+
readonly CACHE_ERROR: "errors:cache";
|
|
69
|
+
readonly HEADERS_ERROR: "errors:headers";
|
|
70
|
+
readonly RETRY_ERROR: "errors:retry";
|
|
71
|
+
readonly STRATEGY_ERROR: "errors:strategy";
|
|
72
|
+
readonly REGIONAL_ERROR: "errors:regional";
|
|
73
|
+
readonly NOT_FOUND_ERROR: "errors:not-found";
|
|
74
|
+
readonly EXTERNAL_SERVICE_ERROR: "errors:external-service";
|
|
75
|
+
readonly UNKNOWN_ERROR: "errors:unknown";
|
|
76
|
+
readonly GENERIC_ERROR: "errors:generic";
|
|
77
|
+
readonly ANY: "errors:*";
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Handler scopes for different levels of event handlers
|
|
81
|
+
* These prefixes are used for registering handlers at different priority levels
|
|
82
|
+
* Can be used for any type of handler (error, request, response, debug, etc.)
|
|
83
|
+
*
|
|
84
|
+
* Priority order (lowest to highest):
|
|
85
|
+
* 1. GLOBAL - Set via setGlobalErrorHandlers(), persists across all instances
|
|
86
|
+
* 2. CONFIG - Set via setGlobalConfig({ errorHandlers }), global configuration
|
|
87
|
+
* 3. CLIENT - Set via createApiClient({ errorHandlers }), instance-specific
|
|
88
|
+
* 4. REQUEST/TEMPORARY - Set per-request or via updateConfig(), highest priority
|
|
89
|
+
*
|
|
90
|
+
* Usage:
|
|
91
|
+
* - GLOBAL: For app-wide handlers that should always run (e.g., logging)
|
|
92
|
+
* - CONFIG: For environment-specific handlers (e.g., dev vs prod)
|
|
93
|
+
* - CLIENT: For instance-specific handlers (e.g., per-service client)
|
|
94
|
+
* - REQUEST/TEMPORARY: For request-specific or runtime updates
|
|
95
|
+
*
|
|
96
|
+
* Note: REQUEST and TEMPORARY are aliases - both use 'request' scope
|
|
97
|
+
*
|
|
98
|
+
* Examples of namespaced handlers:
|
|
99
|
+
* - Error handlers: 'global:error', 'config:error', 'client:error'
|
|
100
|
+
* - Debug handlers: 'global:debug', 'config:debug', 'client:debug'
|
|
101
|
+
* - Request handlers: 'global:request', 'config:request', 'client:request'
|
|
102
|
+
*/
|
|
103
|
+
export declare const HANDLER_SCOPES: {
|
|
104
|
+
readonly GLOBAL: "global";
|
|
105
|
+
readonly CONFIG: "config";
|
|
106
|
+
readonly CLIENT: "client";
|
|
107
|
+
readonly TEMPORARY: "request";
|
|
108
|
+
readonly REQUEST: "request";
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Core event scopes (excluding aliases)
|
|
112
|
+
* These are the actual scope values used by the event system
|
|
113
|
+
*/
|
|
114
|
+
export declare const EVENT_SCOPES: readonly ["global", "config", "client", "request"];
|
|
115
|
+
/**
|
|
116
|
+
* All event scopes including 'temporary' alias
|
|
117
|
+
* Used in APIs where 'temporary' provides semantic clarity
|
|
118
|
+
*/
|
|
119
|
+
export declare const EVENT_SCOPES_WITH_TEMPORARY: readonly ["global", "config", "client", "request", "temporary"];
|
|
120
|
+
/**
|
|
121
|
+
* Debug-specific event keys
|
|
122
|
+
*/
|
|
123
|
+
export declare const DEBUG_EVENTS: {
|
|
124
|
+
readonly CONFIG_CONFLICT: "debug:config-conflict";
|
|
125
|
+
readonly CONFIG_CHANGE: "debug:config-change";
|
|
126
|
+
readonly HEADERS_TRACKED: "debug:headers-tracked";
|
|
127
|
+
readonly NETWORK_OVERRIDE: "debug:network-override";
|
|
128
|
+
readonly NETWORK_STATE_CHANGED: "debug:network-state-changed";
|
|
129
|
+
readonly NETWORK_DATA_CLEARED: "debug:network-data-cleared";
|
|
130
|
+
readonly DEBUG_INFO: "debug:info";
|
|
131
|
+
readonly PERFORMANCE_IMPACT: "debug:performance-impact";
|
|
132
|
+
readonly MONITORING_ALERT: "debug:monitoring-alert";
|
|
133
|
+
readonly CONFIG_TRACKED: "debug:config-tracked";
|
|
134
|
+
readonly CONFLICTS_BATCH: "debug:conflicts-batch";
|
|
135
|
+
readonly EVENT_OPERATION: "debug:event-operation";
|
|
136
|
+
readonly ANY: "debug:*";
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Configuration sources - where config updates originate from
|
|
140
|
+
*/
|
|
141
|
+
export declare const CONFIG_SOURCES: {
|
|
142
|
+
readonly GLOBAL: "global";
|
|
143
|
+
readonly CREATE_API_CLIENT: "createApiClient";
|
|
144
|
+
readonly UPDATE_CONFIG: "updateConfig";
|
|
145
|
+
readonly MANUAL: "manual";
|
|
146
|
+
readonly ENVIRONMENT: "environment";
|
|
147
|
+
readonly PRESET: "preset";
|
|
148
|
+
readonly NETWORK_AWARE: "networkAware";
|
|
149
|
+
readonly ADAPTIVE: "adaptive";
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* Configuration-specific event keys
|
|
153
|
+
*/
|
|
154
|
+
export declare const CONFIG_EVENTS: {
|
|
155
|
+
readonly GLOBAL_UPDATED: "config:global-updated";
|
|
156
|
+
readonly GLOBAL_RESET: "config:global-reset";
|
|
157
|
+
readonly ENVIRONMENT_CONFIGURED: "config:environment-configured";
|
|
158
|
+
readonly PRESET_APPLIED: "config:preset-applied";
|
|
159
|
+
readonly ANY: "config:*";
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Performance-specific event keys
|
|
163
|
+
*/
|
|
164
|
+
export declare const PERFORMANCE_EVENTS: {
|
|
165
|
+
readonly REQUEST_START: "performance:request-start";
|
|
166
|
+
readonly REQUEST_COMPLETE: "performance:request-complete";
|
|
167
|
+
readonly RETRY: "performance:retry";
|
|
168
|
+
readonly THRESHOLD_EXCEEDED: "performance:threshold-exceeded";
|
|
169
|
+
readonly OPTIMIZATION_APPLIED: "performance:optimization-applied";
|
|
170
|
+
readonly METRIC_RECORDED: "performance:metric-recorded";
|
|
171
|
+
readonly ANY: "performance:*";
|
|
172
|
+
};
|
|
173
|
+
/**
|
|
174
|
+
* Client-specific event keys
|
|
175
|
+
*/
|
|
176
|
+
export declare const CLIENT_EVENTS: {
|
|
177
|
+
readonly CONFLICT: "client:conflict";
|
|
178
|
+
readonly DEBUG: "client:debug";
|
|
179
|
+
readonly CREATED: "client:created";
|
|
180
|
+
readonly ANY: "client:*";
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* Cache-specific event keys
|
|
184
|
+
*/
|
|
185
|
+
export declare const CACHE_EVENTS: {
|
|
186
|
+
readonly HIT: "cache:hit";
|
|
187
|
+
readonly MISS: "cache:miss";
|
|
188
|
+
readonly INVALIDATE: "cache:invalidate";
|
|
189
|
+
readonly ANY: "cache:*";
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* All event keys combined for easy access
|
|
193
|
+
*/
|
|
194
|
+
export declare const ALL_EVENTS: {
|
|
195
|
+
readonly HIT: "cache:hit";
|
|
196
|
+
readonly MISS: "cache:miss";
|
|
197
|
+
readonly INVALIDATE: "cache:invalidate";
|
|
198
|
+
readonly ANY: "cache:*";
|
|
199
|
+
readonly CONFLICT: "client:conflict";
|
|
200
|
+
readonly DEBUG: "client:debug";
|
|
201
|
+
readonly CREATED: "client:created";
|
|
202
|
+
readonly REQUEST_START: "performance:request-start";
|
|
203
|
+
readonly REQUEST_COMPLETE: "performance:request-complete";
|
|
204
|
+
readonly RETRY: "performance:retry";
|
|
205
|
+
readonly THRESHOLD_EXCEEDED: "performance:threshold-exceeded";
|
|
206
|
+
readonly OPTIMIZATION_APPLIED: "performance:optimization-applied";
|
|
207
|
+
readonly METRIC_RECORDED: "performance:metric-recorded";
|
|
208
|
+
readonly GLOBAL_UPDATED: "config:global-updated";
|
|
209
|
+
readonly GLOBAL_RESET: "config:global-reset";
|
|
210
|
+
readonly ENVIRONMENT_CONFIGURED: "config:environment-configured";
|
|
211
|
+
readonly PRESET_APPLIED: "config:preset-applied";
|
|
212
|
+
readonly CONFIG_CONFLICT: "debug:config-conflict";
|
|
213
|
+
readonly CONFIG_CHANGE: "debug:config-change";
|
|
214
|
+
readonly HEADERS_TRACKED: "debug:headers-tracked";
|
|
215
|
+
readonly NETWORK_OVERRIDE: "debug:network-override";
|
|
216
|
+
readonly NETWORK_STATE_CHANGED: "debug:network-state-changed";
|
|
217
|
+
readonly NETWORK_DATA_CLEARED: "debug:network-data-cleared";
|
|
218
|
+
readonly DEBUG_INFO: "debug:info";
|
|
219
|
+
readonly PERFORMANCE_IMPACT: "debug:performance-impact";
|
|
220
|
+
readonly MONITORING_ALERT: "debug:monitoring-alert";
|
|
221
|
+
readonly CONFIG_TRACKED: "debug:config-tracked";
|
|
222
|
+
readonly CONFLICTS_BATCH: "debug:conflicts-batch";
|
|
223
|
+
readonly EVENT_OPERATION: "debug:event-operation";
|
|
224
|
+
readonly NETWORK_ERROR: "errors:network";
|
|
225
|
+
readonly VALIDATION_ERROR: "errors:validation";
|
|
226
|
+
readonly AUTHENTICATION_ERROR: "errors:authentication";
|
|
227
|
+
readonly AUTHORIZATION_ERROR: "errors:authorization";
|
|
228
|
+
readonly RATE_LIMIT_ERROR: "errors:rate-limit";
|
|
229
|
+
readonly SERVER_ERROR: "errors:server";
|
|
230
|
+
readonly CLIENT_ERROR: "errors:client";
|
|
231
|
+
readonly TIMEOUT_ERROR: "errors:timeout";
|
|
232
|
+
readonly CONFLICT_ERROR: "errors:conflict";
|
|
233
|
+
readonly CACHE_ERROR: "errors:cache";
|
|
234
|
+
readonly HEADERS_ERROR: "errors:headers";
|
|
235
|
+
readonly RETRY_ERROR: "errors:retry";
|
|
236
|
+
readonly STRATEGY_ERROR: "errors:strategy";
|
|
237
|
+
readonly REGIONAL_ERROR: "errors:regional";
|
|
238
|
+
readonly NOT_FOUND_ERROR: "errors:not-found";
|
|
239
|
+
readonly EXTERNAL_SERVICE_ERROR: "errors:external-service";
|
|
240
|
+
readonly UNKNOWN_ERROR: "errors:unknown";
|
|
241
|
+
readonly GENERIC_ERROR: "errors:generic";
|
|
242
|
+
readonly QUALITY_CHANGE: "network:quality:changed";
|
|
243
|
+
readonly INFO_UPDATE: "network:info-update";
|
|
244
|
+
readonly CONFIG_OVERRIDE: "network:config:override";
|
|
245
|
+
readonly CONFIG_RESTORED: "network:config:restored";
|
|
246
|
+
readonly OVERRIDE_CHANGE: "network:override-change";
|
|
247
|
+
readonly PRESET_CHANGED: "network:preset:changed";
|
|
248
|
+
readonly HINTS_UPDATED: "network:hints:updated";
|
|
249
|
+
readonly AUTO_DETECTION: "network:auto:detection";
|
|
250
|
+
readonly MANUAL_UPDATE: "network:manual:update";
|
|
251
|
+
readonly CHANGED: "headers:changed";
|
|
252
|
+
readonly ENRICHED: "headers:enriched";
|
|
253
|
+
readonly OVERRIDE: "headers:override";
|
|
254
|
+
readonly TRACKED: "headers:tracked";
|
|
255
|
+
readonly MERGED: "headers:merged";
|
|
256
|
+
readonly FILTERED: "headers:filtered";
|
|
257
|
+
readonly VALIDATED: "headers:validated";
|
|
258
|
+
readonly CACHED: "headers:cached";
|
|
259
|
+
readonly CACHE_HIT: "headers:cache:hit";
|
|
260
|
+
readonly CACHE_MISS: "headers:cache:miss";
|
|
261
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type * from './types';
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { EventOptions } from '..';
|
|
2
|
+
import type { CACHE_EVENTS } from '../..';
|
|
3
|
+
/**
|
|
4
|
+
* Cache hit event
|
|
5
|
+
*/
|
|
6
|
+
export interface CacheHitEvent {
|
|
7
|
+
type: typeof CACHE_EVENTS.HIT;
|
|
8
|
+
timestamp: number;
|
|
9
|
+
data: {
|
|
10
|
+
key: string;
|
|
11
|
+
value?: unknown;
|
|
12
|
+
age?: number;
|
|
13
|
+
ttl?: number;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Cache miss event
|
|
18
|
+
*/
|
|
19
|
+
export interface CacheMissEvent {
|
|
20
|
+
type: typeof CACHE_EVENTS.MISS;
|
|
21
|
+
timestamp: number;
|
|
22
|
+
data: {
|
|
23
|
+
key: string;
|
|
24
|
+
reason?: 'not_found' | 'expired' | 'disabled';
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Cache invalidate event
|
|
29
|
+
*/
|
|
30
|
+
export interface CacheInvalidateEvent {
|
|
31
|
+
type: typeof CACHE_EVENTS.INVALIDATE;
|
|
32
|
+
timestamp: number;
|
|
33
|
+
data: {
|
|
34
|
+
key?: string;
|
|
35
|
+
pattern?: string;
|
|
36
|
+
reason?: string;
|
|
37
|
+
count?: number;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* All cache event types
|
|
42
|
+
*/
|
|
43
|
+
export type CacheEventData = CacheHitEvent | CacheMissEvent | CacheInvalidateEvent;
|
|
44
|
+
/**
|
|
45
|
+
* Options for emitHit method
|
|
46
|
+
*/
|
|
47
|
+
export interface EmitHitOptions extends EventOptions {
|
|
48
|
+
value?: unknown;
|
|
49
|
+
age?: number;
|
|
50
|
+
ttl?: number;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Options for emitInvalidate method
|
|
54
|
+
*/
|
|
55
|
+
export interface EmitInvalidateOptions extends EventOptions {
|
|
56
|
+
key?: string;
|
|
57
|
+
pattern?: string;
|
|
58
|
+
reason?: string;
|
|
59
|
+
count?: number;
|
|
60
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type * from './types';
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client Event Factory
|
|
3
|
+
* Creates and emits client-related events with type safety
|
|
4
|
+
*/
|
|
5
|
+
import { type BaseEvent, type EventOptions } from '..';
|
|
6
|
+
import type { CLIENT_EVENTS } from '../..';
|
|
7
|
+
import type { ConfigConflict, DebugInfo } from '../../../debugger';
|
|
8
|
+
/**
|
|
9
|
+
* Base structure for client events
|
|
10
|
+
*/
|
|
11
|
+
export interface ClientEvent extends BaseEvent {
|
|
12
|
+
type: string;
|
|
13
|
+
data: unknown;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Client conflict event
|
|
17
|
+
*/
|
|
18
|
+
export interface ClientConflictEvent extends BaseEvent {
|
|
19
|
+
type: typeof CLIENT_EVENTS.CONFLICT;
|
|
20
|
+
data: ConfigConflict;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Client debug event
|
|
24
|
+
*/
|
|
25
|
+
export interface ClientDebugEvent extends BaseEvent {
|
|
26
|
+
type: typeof CLIENT_EVENTS.DEBUG;
|
|
27
|
+
data: DebugInfo;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Client created event
|
|
31
|
+
*/
|
|
32
|
+
export interface ClientCreatedEvent extends BaseEvent {
|
|
33
|
+
type: typeof CLIENT_EVENTS.CREATED;
|
|
34
|
+
data: {
|
|
35
|
+
clientId: string;
|
|
36
|
+
config: Record<string, unknown>;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Request start event (client-level)
|
|
41
|
+
*/
|
|
42
|
+
export interface RequestStartEvent extends BaseEvent {
|
|
43
|
+
type: 'request:start';
|
|
44
|
+
data: {
|
|
45
|
+
url?: string;
|
|
46
|
+
method?: string;
|
|
47
|
+
timestamp: number;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Response received event
|
|
52
|
+
*/
|
|
53
|
+
export interface ResponseReceivedEvent extends BaseEvent {
|
|
54
|
+
type: 'response:received';
|
|
55
|
+
data: {
|
|
56
|
+
url?: string;
|
|
57
|
+
status?: number;
|
|
58
|
+
statusText?: string;
|
|
59
|
+
headers?: Record<string, string>;
|
|
60
|
+
timestamp: number;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Retry attempt event
|
|
65
|
+
*/
|
|
66
|
+
export interface RetryAttemptEvent extends BaseEvent {
|
|
67
|
+
type: 'retry:attempt';
|
|
68
|
+
data: {
|
|
69
|
+
error: {
|
|
70
|
+
message: string;
|
|
71
|
+
code?: string;
|
|
72
|
+
status?: number;
|
|
73
|
+
};
|
|
74
|
+
attempt: number;
|
|
75
|
+
maxAttempts: number;
|
|
76
|
+
delay: number;
|
|
77
|
+
url?: string;
|
|
78
|
+
method?: string;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Options for emitResponseReceived method
|
|
83
|
+
*/
|
|
84
|
+
export interface EmitResponseReceivedOptions extends EventOptions {
|
|
85
|
+
url?: string;
|
|
86
|
+
status?: number;
|
|
87
|
+
statusText?: string;
|
|
88
|
+
headers?: Record<string, string>;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Options for emitRetryAttempt method
|
|
92
|
+
*/
|
|
93
|
+
export interface EmitRetryAttemptOptions extends EventOptions {
|
|
94
|
+
error: {
|
|
95
|
+
message: string;
|
|
96
|
+
code?: string;
|
|
97
|
+
status?: number;
|
|
98
|
+
};
|
|
99
|
+
attempt: number;
|
|
100
|
+
maxAttempts: number;
|
|
101
|
+
delay: number;
|
|
102
|
+
url?: string;
|
|
103
|
+
method?: string;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* All client event types union
|
|
107
|
+
*/
|
|
108
|
+
export type ClientEventType = ClientConflictEvent | ClientDebugEvent | ClientCreatedEvent | RequestStartEvent | ResponseReceivedEvent | RetryAttemptEvent;
|
|
109
|
+
/**
|
|
110
|
+
* Client event handlers interface
|
|
111
|
+
*/
|
|
112
|
+
export interface ClientEventHandlers {
|
|
113
|
+
onClientConflict?: (event: ClientConflictEvent) => void;
|
|
114
|
+
onClientDebug?: (event: ClientDebugEvent) => void;
|
|
115
|
+
onClientCreated?: (event: ClientCreatedEvent) => void;
|
|
116
|
+
onRequestStart?: (event: RequestStartEvent) => void;
|
|
117
|
+
onResponseReceived?: (event: ResponseReceivedEvent) => void;
|
|
118
|
+
onRetryAttempt?: (event: RetryAttemptEvent) => void;
|
|
119
|
+
onAnyClientEvent?: (event: ClientEventType) => void;
|
|
120
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type * from './types';
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config Event Factory
|
|
3
|
+
* Factory for creating and emitting configuration-related events
|
|
4
|
+
*/
|
|
5
|
+
import type { EventOptions } from '../types';
|
|
6
|
+
import type { CONFIG_EVENTS, ConfigSource } from '../../../events';
|
|
7
|
+
import type { ApiConfig } from '../../../config';
|
|
8
|
+
/**
|
|
9
|
+
* Configuration updated event
|
|
10
|
+
*/
|
|
11
|
+
export interface ConfigGlobalUpdatedEvent {
|
|
12
|
+
type: typeof CONFIG_EVENTS.GLOBAL_UPDATED;
|
|
13
|
+
timestamp: number;
|
|
14
|
+
data: {
|
|
15
|
+
previous: ApiConfig;
|
|
16
|
+
current: ApiConfig;
|
|
17
|
+
source: ConfigSource;
|
|
18
|
+
changes: string[];
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Configuration reset event
|
|
23
|
+
*/
|
|
24
|
+
export interface ConfigGlobalResetEvent {
|
|
25
|
+
type: typeof CONFIG_EVENTS.GLOBAL_RESET;
|
|
26
|
+
timestamp: number;
|
|
27
|
+
data: {
|
|
28
|
+
previous: ApiConfig;
|
|
29
|
+
defaults: ApiConfig;
|
|
30
|
+
source: ConfigSource;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Environment configured event
|
|
35
|
+
*/
|
|
36
|
+
export interface ConfigEnvironmentEvent {
|
|
37
|
+
type: typeof CONFIG_EVENTS.ENVIRONMENT_CONFIGURED;
|
|
38
|
+
timestamp: number;
|
|
39
|
+
data: {
|
|
40
|
+
environment: string;
|
|
41
|
+
config: ApiConfig;
|
|
42
|
+
source: ConfigSource;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Preset applied event
|
|
47
|
+
*/
|
|
48
|
+
export interface ConfigPresetAppliedEvent {
|
|
49
|
+
type: typeof CONFIG_EVENTS.PRESET_APPLIED;
|
|
50
|
+
timestamp: number;
|
|
51
|
+
data: {
|
|
52
|
+
presetName: string;
|
|
53
|
+
config: ApiConfig;
|
|
54
|
+
source: ConfigSource;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* All config event types
|
|
59
|
+
*/
|
|
60
|
+
export type ConfigEventData = ConfigGlobalUpdatedEvent | ConfigGlobalResetEvent | ConfigEnvironmentEvent | ConfigPresetAppliedEvent;
|
|
61
|
+
/**
|
|
62
|
+
* Options for emitGlobalUpdated method
|
|
63
|
+
*/
|
|
64
|
+
export interface EmitGlobalUpdatedOptions extends EventOptions {
|
|
65
|
+
previous: ApiConfig;
|
|
66
|
+
current: ApiConfig;
|
|
67
|
+
source: ConfigSource;
|
|
68
|
+
changes: string[];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Configuration event handlers interface
|
|
72
|
+
*/
|
|
73
|
+
export interface ConfigEventHandlers {
|
|
74
|
+
onGlobalUpdated?: (event: ConfigGlobalUpdatedEvent) => void;
|
|
75
|
+
onGlobalReset?: (event: ConfigGlobalResetEvent) => void;
|
|
76
|
+
onEnvironmentConfigured?: (event: ConfigEnvironmentEvent) => void;
|
|
77
|
+
onPresetApplied?: (event: ConfigPresetAppliedEvent) => void;
|
|
78
|
+
onAnyConfigEvent?: (event: ConfigEventData) => void;
|
|
79
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type * from './types';
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Debug Event Factory
|
|
3
|
+
* Creates and emits debug-related events with type safety
|
|
4
|
+
*/
|
|
5
|
+
import { type BaseEvent, type EventOptions } from '..';
|
|
6
|
+
import type { DEBUG_EVENTS } from '../..';
|
|
7
|
+
import type { ConfigConflict, DebugInfo, ActiveOverride, PerformanceImpact, MonitoringAlert } from '../../../debugger';
|
|
8
|
+
import type { ConfigSource } from '../../types';
|
|
9
|
+
/**
|
|
10
|
+
* Base structure for debug events
|
|
11
|
+
*/
|
|
12
|
+
export interface DebugEvent extends BaseEvent {
|
|
13
|
+
type: string;
|
|
14
|
+
data: Record<string, unknown>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Config conflict event
|
|
18
|
+
*/
|
|
19
|
+
export interface ConfigConflictEvent extends BaseEvent {
|
|
20
|
+
type: typeof DEBUG_EVENTS.CONFIG_CONFLICT;
|
|
21
|
+
data: ConfigConflict;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Config change event
|
|
25
|
+
*/
|
|
26
|
+
export interface ConfigChangeEvent extends BaseEvent {
|
|
27
|
+
type: typeof DEBUG_EVENTS.CONFIG_CHANGE;
|
|
28
|
+
data: {
|
|
29
|
+
property: string;
|
|
30
|
+
oldValue: unknown;
|
|
31
|
+
newValue: unknown;
|
|
32
|
+
source: ConfigSource;
|
|
33
|
+
reason?: string;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Headers tracked event
|
|
38
|
+
*/
|
|
39
|
+
export interface HeadersTrackedEvent extends BaseEvent {
|
|
40
|
+
type: typeof DEBUG_EVENTS.HEADERS_TRACKED;
|
|
41
|
+
data: {
|
|
42
|
+
headers: Record<string, string>;
|
|
43
|
+
source: ConfigSource;
|
|
44
|
+
metadata?: {
|
|
45
|
+
phase: 'config' | 'request' | 'response';
|
|
46
|
+
reason?: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Network override event
|
|
52
|
+
*/
|
|
53
|
+
export interface NetworkOverrideEvent extends BaseEvent {
|
|
54
|
+
type: typeof DEBUG_EVENTS.NETWORK_OVERRIDE;
|
|
55
|
+
data: {
|
|
56
|
+
overrides: ActiveOverride[];
|
|
57
|
+
reason: string;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Debug info update event
|
|
62
|
+
*/
|
|
63
|
+
export interface DebugInfoUpdateEvent extends BaseEvent {
|
|
64
|
+
type: typeof DEBUG_EVENTS.DEBUG_INFO;
|
|
65
|
+
data: DebugInfo;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Performance impact event
|
|
69
|
+
*/
|
|
70
|
+
export interface PerformanceImpactEvent extends BaseEvent {
|
|
71
|
+
type: typeof DEBUG_EVENTS.PERFORMANCE_IMPACT;
|
|
72
|
+
data: PerformanceImpact & {
|
|
73
|
+
source: 'network' | 'config' | 'strategy' | 'adaptive';
|
|
74
|
+
recommendation?: string;
|
|
75
|
+
operation?: string;
|
|
76
|
+
duration?: number;
|
|
77
|
+
impact?: 'low' | 'medium' | 'high';
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Monitoring alert event
|
|
82
|
+
*/
|
|
83
|
+
export interface MonitoringAlertEvent extends BaseEvent {
|
|
84
|
+
type: typeof DEBUG_EVENTS.MONITORING_ALERT;
|
|
85
|
+
data: MonitoringAlert;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Config tracking event
|
|
89
|
+
*/
|
|
90
|
+
export interface ConfigTrackingEvent extends BaseEvent {
|
|
91
|
+
type: typeof DEBUG_EVENTS.CONFIG_TRACKED;
|
|
92
|
+
data: {
|
|
93
|
+
config: Record<string, unknown>;
|
|
94
|
+
source: ConfigSource;
|
|
95
|
+
phase: 'initialization' | 'runtime' | 'update';
|
|
96
|
+
metadata?: Record<string, unknown>;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Options for emitConfigChange method
|
|
101
|
+
*/
|
|
102
|
+
export interface EmitConfigChangeOptions extends EventOptions {
|
|
103
|
+
property: string;
|
|
104
|
+
oldValue: unknown;
|
|
105
|
+
newValue: unknown;
|
|
106
|
+
source: ConfigSource;
|
|
107
|
+
reason?: string;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Options for emitHeadersTracked method
|
|
111
|
+
*/
|
|
112
|
+
export interface EmitHeadersTrackedOptions extends EventOptions {
|
|
113
|
+
headers: Record<string, string>;
|
|
114
|
+
source: ConfigSource;
|
|
115
|
+
phase?: 'config' | 'request' | 'response';
|
|
116
|
+
reason?: string;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Options for emitConfigTracked method
|
|
120
|
+
*/
|
|
121
|
+
export interface EmitConfigTrackedOptions extends EventOptions {
|
|
122
|
+
config: Record<string, unknown>;
|
|
123
|
+
source: ConfigSource;
|
|
124
|
+
phase?: 'initialization' | 'runtime' | 'update';
|
|
125
|
+
metadata?: Record<string, unknown>;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Union type for all debug event types
|
|
129
|
+
*/
|
|
130
|
+
export type DebugEventData = ConfigConflictEvent | ConfigChangeEvent | HeadersTrackedEvent | NetworkOverrideEvent | DebugInfoUpdateEvent | PerformanceImpactEvent | MonitoringAlertEvent | ConfigTrackingEvent;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type * from './types';
|