mcp-adr-analysis-server
Version:
MCP server for analyzing Architectural Decision Records and project architecture
105 lines • 3.04 kB
TypeScript
/**
* Conditional Request Support
*
* Implements HTTP conditional request headers (ETag, If-Modified-Since)
* for efficient resource caching and bandwidth reduction.
*
* Features:
* - ETag generation (strong and weak)
* - If-None-Match validation
* - If-Modified-Since validation
* - 304 Not Modified support
*/
/**
* Generate strong ETag from content
* Format: "hash"
*/
export declare function generateStrongETag(content: string | object): string;
/**
* Generate weak ETag from metadata
* Format: W/"timestamp-hash"
* Useful when content hasn't changed but metadata has
*/
export declare function generateWeakETag(timestamp: string, identifier: string): string;
/**
* Parse ETag from header
* Handles both strong and weak ETags
*/
export declare function parseETag(etag: string): {
value: string;
isWeak: boolean;
};
/**
* Compare two ETags for equality
* Supports both strong and weak comparison
*/
export declare function compareETags(etag1: string, etag2: string, weakComparison?: boolean): boolean;
/**
* Parse If-None-Match header
* Returns array of ETags to check
*/
export declare function parseIfNoneMatch(header: string): string[];
/**
* Check if resource matches If-None-Match condition
* Returns true if resource has NOT been modified
*/
export declare function checkIfNoneMatch(currentETag: string, ifNoneMatchHeader: string): boolean;
/**
* Parse If-Modified-Since header to Date
*/
export declare function parseIfModifiedSince(header: string): Date | null;
/**
* Check if resource has been modified since given date
* Returns true if resource has been modified
*/
export declare function checkIfModifiedSince(lastModified: string, ifModifiedSinceHeader: string): boolean;
/**
* Evaluate conditional request
* Returns { notModified: boolean, reason?: string }
*/
export interface ConditionalRequestResult {
notModified: boolean;
reason?: string;
}
export declare function evaluateConditionalRequest(params: {
currentETag: string;
lastModified: string;
ifNoneMatch?: string;
ifModifiedSince?: string;
}): ConditionalRequestResult;
/**
* Generate HTTP cache headers for response
*/
export interface CacheHeaders {
'ETag': string;
'Last-Modified': string;
'Cache-Control': string;
'Vary'?: string;
}
export declare function generateCacheHeaders(params: {
etag: string;
lastModified: string;
maxAge?: number;
mustRevalidate?: boolean;
vary?: string[];
}): CacheHeaders;
/**
* Create 304 Not Modified response metadata
*/
export interface NotModifiedResponse {
status: 304;
statusText: 'Not Modified';
headers: CacheHeaders;
body?: never;
}
export declare function createNotModifiedResponse(params: {
etag: string;
lastModified: string;
maxAge?: number;
}): NotModifiedResponse;
/**
* Calculate cache freshness
* Returns true if cache is still fresh
*/
export declare function isCacheFresh(lastModified: string, maxAge: number): boolean;
//# sourceMappingURL=conditional-request.d.ts.map