import { type PageCacheService } from './page-cache-service.js'; import type { CacheStrategy, RenderResult } from './cache.types.js'; /** * Coordinates request-time page caching concerns around one render invocation. * * This service keeps `FileSystemResponseMatcher` from owning low-level cache * policy mechanics such as cache key construction, `dynamic` bypass behavior, * body normalization for cache storage, and final cache header generation. */ export declare class PageRequestCacheCoordinator { private cacheService; private defaultCacheStrategy; private readonly getRuntimeAssetGeneration?; constructor(cacheService: PageCacheService | null, defaultCacheStrategy: CacheStrategy, getRuntimeAssetGeneration?: () => number); /** * Builds the cache key used for page lookups. * * Query parameters are part of the key so two requests that hit the same * pathname but differ by search params do not share the same rendered entry. * * @param input Pathname plus optional query record. * @returns Stable cache key for the request. */ buildCacheKey(input: { pathname: string; query?: Record; }): string; /** * Resolves a render request through the configured cache policy. * * Pages using `dynamic` rendering, or applications without a cache service, * bypass cache lookup entirely and still receive the same response header * contract as cached pages. * * @param options Cache coordination inputs for one page request. * @returns HTTP response with cache headers applied. */ render(options: { cacheKey: string; pageCacheStrategy: CacheStrategy; renderFn: () => Promise; }): Promise; /** * Exposes the underlying cache service for invalidation and adapter plumbing. * * @returns Configured cache service or `null` when caching is disabled. */ getCacheService(): PageCacheService | null; /** * Returns the default render strategy used when a page does not declare one. * * @returns Application-level fallback cache strategy. */ getDefaultCacheStrategy(): CacheStrategy; /** * Normalizes various route render body shapes into a cacheable string. * * Page rendering may produce strings, buffers, byte arrays, or streams. The * matcher needs a single representation before passing HTML through the cache * layer, so this method centralizes the conversion rules. * * @param body Render output body in any supported form. * @returns HTML string representation. */ bodyToString(body: unknown): Promise; /** * Creates the final HTML response with the current cache semantics encoded in * response headers. * * @param html Rendered page HTML. * @param strategy Effective cache strategy for the response. * @param cacheStatus Status used for `X-Cache` and `Cache-Control` generation. * @returns HTTP response ready to send to the client. */ private createCachedResponse; }