feat(serviceworker): Add TypedRequest traffic monitoring and SW dashboard Requests panel
This commit is contained in:
@@ -509,4 +509,131 @@ export interface IMessage_Serviceworker_ResourceCached
|
||||
cached: boolean;
|
||||
};
|
||||
response: {};
|
||||
}
|
||||
}
|
||||
|
||||
// =============================
|
||||
// TypedRequest Traffic Monitoring
|
||||
// =============================
|
||||
|
||||
/**
|
||||
* Log entry for TypedRequest traffic monitoring
|
||||
*/
|
||||
export interface ITypedRequestLogEntry {
|
||||
correlationId: string;
|
||||
method: string;
|
||||
direction: 'outgoing' | 'incoming';
|
||||
phase: 'request' | 'response';
|
||||
timestamp: number;
|
||||
durationMs?: number;
|
||||
payload: any;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Statistics for TypedRequest traffic
|
||||
*/
|
||||
export interface ITypedRequestStats {
|
||||
totalRequests: number;
|
||||
totalResponses: number;
|
||||
methodCounts: Record<string, { requests: number; responses: number; errors: number; avgDurationMs: number }>;
|
||||
errorCount: number;
|
||||
avgDurationMs: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Message for logging TypedRequest traffic from client to SW
|
||||
*/
|
||||
export interface IMessage_Serviceworker_TypedRequestLog
|
||||
extends plugins.typedrequestInterfaces.implementsTR<
|
||||
plugins.typedrequestInterfaces.ITypedRequest,
|
||||
IMessage_Serviceworker_TypedRequestLog
|
||||
> {
|
||||
method: 'serviceworker_typedRequestLog';
|
||||
request: ITypedRequestLogEntry;
|
||||
response: {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Push notification when a TypedRequest is logged
|
||||
*/
|
||||
export interface IMessage_Serviceworker_TypedRequestLogged
|
||||
extends plugins.typedrequestInterfaces.implementsTR<
|
||||
plugins.typedrequestInterfaces.ITypedRequest,
|
||||
IMessage_Serviceworker_TypedRequestLogged
|
||||
> {
|
||||
method: 'serviceworker_typedRequestLogged';
|
||||
request: ITypedRequestLogEntry;
|
||||
response: {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to get TypedRequest logs
|
||||
*/
|
||||
export interface IRequest_Serviceworker_GetTypedRequestLogs
|
||||
extends plugins.typedrequestInterfaces.implementsTR<
|
||||
plugins.typedrequestInterfaces.ITypedRequest,
|
||||
IRequest_Serviceworker_GetTypedRequestLogs
|
||||
> {
|
||||
method: 'serviceworker_getTypedRequestLogs';
|
||||
request: {
|
||||
limit?: number;
|
||||
method?: string;
|
||||
since?: number;
|
||||
};
|
||||
response: {
|
||||
logs: ITypedRequestLogEntry[];
|
||||
totalCount: number;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to get TypedRequest traffic statistics
|
||||
*/
|
||||
export interface IRequest_Serviceworker_GetTypedRequestStats
|
||||
extends plugins.typedrequestInterfaces.implementsTR<
|
||||
plugins.typedrequestInterfaces.ITypedRequest,
|
||||
IRequest_Serviceworker_GetTypedRequestStats
|
||||
> {
|
||||
method: 'serviceworker_getTypedRequestStats';
|
||||
request: {};
|
||||
response: ITypedRequestStats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to clear TypedRequest logs
|
||||
*/
|
||||
export interface IRequest_Serviceworker_ClearTypedRequestLogs
|
||||
extends plugins.typedrequestInterfaces.implementsTR<
|
||||
plugins.typedrequestInterfaces.ITypedRequest,
|
||||
IRequest_Serviceworker_ClearTypedRequestLogs
|
||||
> {
|
||||
method: 'serviceworker_clearTypedRequestLogs';
|
||||
request: {};
|
||||
response: {
|
||||
success: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
// =============================
|
||||
// Shared Constants
|
||||
// =============================
|
||||
|
||||
/**
|
||||
* HTML shell for the SW Dashboard - shared between server and service worker
|
||||
*/
|
||||
export const SW_DASH_HTML = `<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>SW Dashboard</title>
|
||||
<style>
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
body { background: #0a0a0a; min-height: 100vh; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<sw-dash-app></sw-dash-app>
|
||||
<script type="module" src="/sw-dash/bundle.js"></script>
|
||||
</body>
|
||||
</html>`;
|
||||
Reference in New Issue
Block a user